@xenon-device-management/xenon 2.14.0 → 2.15.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 (259) hide show
  1. package/README.md +7 -4
  2. package/lib/package.json +5 -5
  3. package/lib/public/assets/{AnnotationOverlay-B_VNtKBH.js → AnnotationOverlay-Btq3dZRI.js} +1 -1
  4. package/lib/public/assets/{ApiKeyGate-BwuaMjkX.js → ApiKeyGate-C9OoAgg_.js} +1 -1
  5. package/lib/public/assets/DeviceMosaicView-DBC_xczB.js +2 -0
  6. package/lib/public/assets/{EmptyState-BSjhk_IV.js → EmptyState-DqWU2-vM.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-Cb5QZsE1.js → FieldGroup-CveQ3xrA.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-BAaSlWbW.js → FilterMenu-BfKDSfHz.js} +1 -1
  9. package/lib/public/assets/{Menu-JGGYrSQQ.js → Menu-CtdCybzA.js} +1 -1
  10. package/lib/public/assets/{Modal-CFCp3n9d.js → Modal-Bsvj1tm2.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-CbJj_EBT.js → RecordingPage-CRofOiyx.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-BJeYnygR.js → RecordingsPage-jNQHb2IR.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-Bg42Atjy.js → SegmentedControl-C8HtTha-.js} +1 -1
  14. package/lib/public/assets/{SettingCard-Njz1pUIJ.js → SettingCard-D8K1LZNo.js} +1 -1
  15. package/lib/public/assets/{Table-BcTm5xV2.js → Table-zNTX92Pn.js} +1 -1
  16. package/lib/public/assets/{activity-DOVdsfMQ.js → activity-CJ8LwZq9.js} +1 -1
  17. package/lib/public/assets/ai-settings-CgxQZqrc.js +16 -0
  18. package/lib/public/assets/{api-keys-BKnNSTw9.js → api-keys-ECpo-zTo.js} +1 -1
  19. package/lib/public/assets/{apps-D0SC6uw6.js → apps-BjGymyf3.js} +1 -1
  20. package/lib/public/assets/{arrow-left-MMbTmgoE.js → arrow-left-BWfCbeHP.js} +1 -1
  21. package/lib/public/assets/{arrow-right-BMfnGmxW.js → arrow-right-DC7UGf_n.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-DuAftMWB.js → arrow-up-right-BOjwybDk.js} +1 -1
  23. package/lib/public/assets/{auth-shell-nZC2JNDO.js → auth-shell-CxMTo9aH.js} +2 -2
  24. package/lib/public/assets/{builds-page-hDCgTwkS.js → builds-page-DOCm4HkA.js} +1 -1
  25. package/lib/public/assets/{button-Dda4irn_.js → button-Cg08-EMT.js} +1 -1
  26. package/lib/public/assets/{calendar-BMr0Q62v.js → calendar-CA1ikLJs.js} +1 -1
  27. package/lib/public/assets/{check-CZ9iw9-e.js → check-BMTaH72W.js} +1 -1
  28. package/lib/public/assets/{chevron-right-BRYJJVC9.js → chevron-right-B2QOv9Nx.js} +1 -1
  29. package/lib/public/assets/{circle-check-CqAJjQ5O.js → circle-check-CYXBoUqT.js} +1 -1
  30. package/lib/public/assets/{circle-x-DlDJtnVz.js → circle-x-DTwnSAnl.js} +1 -1
  31. package/lib/public/assets/{clock-CpuDKysU.js → clock-C8_HViQP.js} +1 -1
  32. package/lib/public/assets/{copy-CAQydNFe.js → copy-Be7LNMXV.js} +1 -1
  33. package/lib/public/assets/derive-UnLRp4r3.js +1 -0
  34. package/lib/public/assets/device-explorer-BOqtfGXz.js +282 -0
  35. package/lib/public/assets/{download-C9XG6lLv.js → download-B56lwxWP.js} +1 -1
  36. package/lib/public/assets/forgot-password-CCU6bzLn.js +1 -0
  37. package/lib/public/assets/{h264Stream-VQBphYhg.js → h264Stream-C-OtmIuk.js} +6 -6
  38. package/lib/public/assets/index-B9KQ6LsY.js +15 -0
  39. package/lib/public/assets/{index-BbKEXUFH.js → index-BOxe43p1.js} +2 -2
  40. package/lib/public/assets/{index-DJGc1M2f.js → index-CfxsUslp.js} +1 -1
  41. package/lib/public/assets/{input-Cm0tmSoc.js → input-CZHFjbSg.js} +1 -1
  42. package/lib/public/assets/{line-chart-D2DyJCml.js → line-chart-Gl_Dz3X_.js} +1 -1
  43. package/lib/public/assets/{list-checks-UWf1GY99.js → list-checks-CCgjeyGY.js} +1 -1
  44. package/lib/public/assets/{lock-CCJv9m_I.js → lock-CkOwgDcx.js} +1 -1
  45. package/lib/public/assets/{login-f8vOVW-U.js → login-D5cc4w7M.js} +1 -1
  46. package/lib/public/assets/{maintenance-settings-C1PrkuAH.js → maintenance-settings-t7qr3fvX.js} +1 -1
  47. package/lib/public/assets/{monitor-B2jDgwm7.js → monitor-DEJixKQO.js} +1 -1
  48. package/lib/public/assets/{mouse-pointer-2-DLI1RtzU.js → mouse-pointer-2-CtOrk4M8.js} +1 -1
  49. package/lib/public/assets/{network-ebT86qoi.js → network-Dii9qdvk.js} +1 -1
  50. package/lib/public/assets/{overview-C0aykVrd.js → overview-rolAACrO.js} +1 -1
  51. package/lib/public/assets/{page-header-BjzgWz-T.js → page-header-COQZxJfR.js} +1 -1
  52. package/lib/public/assets/{play-DLG9t8FU.js → play-DrN1Se_R.js} +1 -1
  53. package/lib/public/assets/{plus-nBFSMu_X.js → plus-5aq-9uRx.js} +1 -1
  54. package/lib/public/assets/{profile-page-CSl0UYlv.js → profile-page-6i5kY6kF.js} +1 -1
  55. package/lib/public/assets/{reset-password-LeOuHqmB.js → reset-password-sp2IBrc7.js} +1 -1
  56. package/lib/public/assets/runbook-page-DJDjeopU.js +253 -0
  57. package/lib/public/assets/{select-88jHcl-Z.js → select-Bpyn7rWO.js} +1 -1
  58. package/lib/public/assets/{selector-detail-redirect-BbXKJjZM.js → selector-detail-redirect-BH74vmKv.js} +1 -1
  59. package/lib/public/assets/{selector-health-page-B4rA1Xkv.js → selector-health-page-Cw_g218H.js} +1 -1
  60. package/lib/public/assets/session-detail-page-AZJE6XXE.js +4 -0
  61. package/lib/public/assets/{settings-GF6ZMSQ6.js → settings-C3uyGhyc.js} +1 -1
  62. package/lib/public/assets/{settings-Dep_3kbA.css → settings-K8UHWMdI.css} +1 -1
  63. package/lib/public/assets/{stat-tile-BV98e_Sv.js → stat-tile-xVqAKIlI.js} +1 -1
  64. package/lib/public/assets/{tablet-BiAsnFDj.js → tablet-BxUScAeO.js} +1 -1
  65. package/lib/public/assets/{teams-B4-jrr-1.js → teams-B5ljGkY2.js} +1 -1
  66. package/lib/public/assets/{trash-2-C5RSuX0e.js → trash-2-B701i8sy.js} +1 -1
  67. package/lib/public/assets/{upload-BG7_rMXK.js → upload-C2gr44RS.js} +1 -1
  68. package/lib/public/assets/{use-builds-data-J-riQYyC.js → use-builds-data-NeQOFEoy.js} +1 -1
  69. package/lib/public/assets/{use-password-reset-mode-C8-eH-UG.js → use-password-reset-mode-DEzJq5ef.js} +1 -1
  70. package/lib/public/assets/{users-CFba5TSy.js → users-D_vv_yz4.js} +1 -1
  71. package/lib/public/assets/{users-Cp0beJm3.js → users-MY6eNe6s.js} +1 -1
  72. package/lib/public/assets/{video-off-DDsEISjV.js → video-off-OK1lNZQn.js} +1 -1
  73. package/lib/public/assets/{webhook-settings-BGu32vSB.js → webhook-settings-BU-C9lBf.js} +1 -1
  74. package/lib/public/assets/{zap-l4VaXzq8.js → zap-DO9ry1iz.js} +1 -1
  75. package/lib/public/index.html +1 -1
  76. package/lib/schema.json +5 -5
  77. package/lib/src/app/dashboardPluginLink.js +117 -0
  78. package/lib/src/app/index.js +13 -34
  79. package/lib/src/app/openapi/control.yaml +6 -4
  80. package/lib/src/app/openapi/grid.yaml +8 -2
  81. package/lib/src/app/openapi/identity.yaml +103 -31
  82. package/lib/src/app/openapi/platform.yaml +33 -15
  83. package/lib/src/app/openapi/sessions.yaml +10 -3
  84. package/lib/src/app/routers/apikeys.js +14 -2
  85. package/lib/src/app/routers/auth.js +29 -5
  86. package/lib/src/app/routers/control.js +13 -5
  87. package/lib/src/app/routers/dashboard.js +42 -27
  88. package/lib/src/app/routers/grid.js +5 -3
  89. package/lib/src/app/routers/profile.js +21 -0
  90. package/lib/src/app/routers/users.js +10 -5
  91. package/lib/src/app/swagger.js +2 -0
  92. package/lib/src/app/ws/h264StreamWs.js +10 -1
  93. package/lib/src/config.js +1 -0
  94. package/lib/src/dashboard/commands.js +5 -5
  95. package/lib/src/dashboard/event-manager.js +49 -61
  96. package/lib/src/dashboard/services/failure-analysis-service.js +136 -45
  97. package/lib/src/dashboard/sessionCommandSummary.js +39 -0
  98. package/lib/src/data-service/device-store.js +14 -1
  99. package/lib/src/data-service/prisma-store.js +19 -7
  100. package/lib/src/data-service/web-config-service.js +7 -0
  101. package/lib/src/device-managers/android/AndroidH264StreamService.js +69 -20
  102. package/lib/src/device-managers/android/H264Multiplexer.js +38 -4
  103. package/lib/src/device-utils.js +20 -2
  104. package/lib/src/gateway/defaultGateway.js +1 -1
  105. package/lib/src/gateway/forwardToNode.js +2 -0
  106. package/lib/src/gateway/healReport.js +87 -0
  107. package/lib/src/gateway/sessionGateway.js +12 -2
  108. package/lib/src/generated/client/edge.js +4 -3
  109. package/lib/src/generated/client/index-browser.js +1 -0
  110. package/lib/src/generated/client/index.d.ts +32 -0
  111. package/lib/src/generated/client/index.js +4 -3
  112. package/lib/src/generated/client/package.json +1 -1
  113. package/lib/src/generated/client/schema.prisma +3 -0
  114. package/lib/src/generated/client/wasm.js +1 -0
  115. package/lib/src/interceptors/CommandInterceptor.js +243 -181
  116. package/lib/src/middleware/authMiddleware.js +15 -3
  117. package/lib/src/middleware/commandCaller.js +3 -3
  118. package/lib/src/middleware/verifyCredential.js +58 -1
  119. package/lib/src/plugin.js +8 -3
  120. package/lib/src/services/AICommandService.js +9 -2
  121. package/lib/src/services/AIService.js +192 -42
  122. package/lib/src/services/EmailService.js +29 -0
  123. package/lib/src/services/OrphanSweeper.js +2 -0
  124. package/lib/src/services/SelectorVerificationJob.js +15 -4
  125. package/lib/src/services/ServerManager.js +11 -1
  126. package/lib/src/services/SessionLifecycleService.js +86 -26
  127. package/lib/src/services/SocketServer.js +19 -3
  128. package/lib/src/services/bug-report/video-slice.js +4 -1
  129. package/lib/src/services/device-access/leaseOverride.js +7 -5
  130. package/lib/src/services/healing/FuzzyXmlHealingProvider.js +51 -0
  131. package/lib/src/services/healing/HealEtalonService.js +3 -2
  132. package/lib/src/services/healing/HealingOrchestrator.js +55 -72
  133. package/lib/src/services/healing/OcrHealingProvider.js +41 -64
  134. package/lib/src/services/healing/ResilioTreeHealingProvider.js +41 -50
  135. package/lib/src/services/healing/VisualAiHealingProvider.js +1 -1
  136. package/lib/src/services/healing/fingerprintIdentity.js +126 -0
  137. package/lib/src/services/healing/resilioPath.js +274 -0
  138. package/lib/src/services/logcat/SessionDeviceLogs.js +271 -0
  139. package/lib/src/services/logcat/deviceLogBook.js +163 -0
  140. package/lib/src/services/ocr/ocrData.js +118 -0
  141. package/lib/src/services/ocr/vendor/LICENSE-tessdata.txt +202 -0
  142. package/lib/src/services/ocr/vendor/eng.traineddata.gz +0 -0
  143. package/lib/src/services/omni-vision/OmniVisionService.js +83 -56
  144. package/lib/src/services/passwordResetLink.js +50 -9
  145. package/lib/src/services/passwordResetMode.js +3 -1
  146. package/lib/src/services/publicUrl.js +45 -0
  147. package/lib/src/services/session/sessionIdentity.js +5 -3
  148. package/lib/src/services/session/shutdownReason.js +26 -0
  149. package/lib/src/services/settings/aiEngineSettings.js +219 -0
  150. package/lib/src/services/token/mintedLifetime.js +51 -0
  151. package/lib/src/sessions/SessionManager.js +8 -2
  152. package/lib/src/sessions/sessionMemory.js +25 -0
  153. package/lib/test/helpers/fake-ai-provider.js +188 -0
  154. package/lib/test/helpers/loki-stores.js +33 -0
  155. package/lib/test/helpers/page-sources.js +164 -0
  156. package/lib/test/helpers/scratch-database.js +57 -13
  157. package/lib/test/integration/audit-ingest.spec.js +10 -10
  158. package/lib/test/integration/auth-flow.spec.js +9 -14
  159. package/lib/test/integration/auth-rate-limit.spec.js +6 -3
  160. package/lib/test/integration/bug-report-route.spec.js +22 -2
  161. package/lib/test/integration/forgot-password-rate-limit.spec.js +6 -3
  162. package/lib/test/integration/forgot-password.spec.js +17 -18
  163. package/lib/test/integration/legacy-deprecation-headers.spec.js +5 -2
  164. package/lib/test/integration/migration.spec.js +6 -1
  165. package/lib/test/integration/node-pair-auth-rest.spec.js +5 -9
  166. package/lib/test/integration/ports-router.spec.js +4 -4
  167. package/lib/test/integration/prisma-device-store-add-devices.spec.js +2 -3
  168. package/lib/test/integration/prisma-device-store-team-filter.spec.js +2 -5
  169. package/lib/test/integration/profile-tokens.spec.js +10 -16
  170. package/lib/test/integration/recordings-router.spec.js +16 -16
  171. package/lib/test/integration/reset-revokes-sessions.spec.js +4 -9
  172. package/lib/test/integration/role-matrix.spec.js +4 -9
  173. package/lib/test/integration/sdk-leases-router.spec.js +9 -9
  174. package/lib/test/integration/sdk-version.spec.js +2 -2
  175. package/lib/test/integration/selector-health-endpoint.spec.js +5 -5
  176. package/lib/test/integration/team-membership-migration.spec.js +73 -12
  177. package/lib/test/integration/team-visibility-apps.spec.js +15 -22
  178. package/lib/test/integration/team-visibility-control.spec.js +96 -69
  179. package/lib/test/integration/team-visibility-dashboard.spec.js +7 -23
  180. package/lib/test/integration/team-visibility-grid.spec.js +16 -15
  181. package/lib/test/integration/team-visibility-leases.spec.js +8 -11
  182. package/lib/test/integration/team-visibility-recordings.spec.js +6 -19
  183. package/lib/test/integration/team-visibility-sessions.spec.js +6 -19
  184. package/lib/test/integration/users-flow.spec.js +7 -12
  185. package/lib/test/integration/users-lockout.spec.js +5 -3
  186. package/lib/test/unit/EmailService.test.js +66 -0
  187. package/lib/test/unit/ResilioTreeHealingProvider.test.js +46 -19
  188. package/lib/test/unit/ai-call-time-limit.spec.js +130 -0
  189. package/lib/test/unit/ai-engine-settings.spec.js +338 -0
  190. package/lib/test/unit/ai-provider-switch.spec.js +130 -0
  191. package/lib/test/unit/ai-rate-limit.spec.js +126 -0
  192. package/lib/test/unit/android-h264-viewers.spec.js +272 -0
  193. package/lib/test/unit/android-preview-hold.spec.js +3 -2
  194. package/lib/test/unit/apikeys-router.spec.js +84 -0
  195. package/lib/test/unit/authMiddleware.bearer.spec.js +9 -0
  196. package/lib/test/unit/authMiddleware.credentialLifetime.spec.js +149 -0
  197. package/lib/test/unit/bug-report/video-slice.spec.js +19 -0
  198. package/lib/test/unit/dashboard-events-device-logs.spec.js +207 -0
  199. package/lib/test/unit/dashboard-plugin-link.spec.js +213 -0
  200. package/lib/test/unit/device-log-book.spec.js +180 -0
  201. package/lib/test/unit/enable-dashboard-option.spec.js +57 -0
  202. package/lib/test/unit/event-log-session-data.spec.js +244 -0
  203. package/lib/test/unit/failure-analysis.spec.js +182 -0
  204. package/lib/test/unit/failure-categories.spec.js +128 -0
  205. package/lib/test/unit/fingerprint-identity.spec.js +433 -0
  206. package/lib/test/unit/h264-multiplexer.spec.js +46 -0
  207. package/lib/test/unit/heal-report.spec.js +71 -0
  208. package/lib/test/unit/healing-instrumentation.spec.js +6 -1
  209. package/lib/test/unit/healing-tier-gate.spec.js +73 -29
  210. package/lib/test/unit/healing-tiers-every-session.spec.js +219 -0
  211. package/lib/test/unit/hub-node-gateway-appium-server.spec.js +171 -0
  212. package/lib/test/unit/interceptor-visual-elements.spec.js +192 -0
  213. package/lib/test/unit/lease/lease-override.spec.js +23 -6
  214. package/lib/test/unit/lease/session-lease-proof.spec.js +16 -4
  215. package/lib/test/unit/ocr-healing-tier-real-ocr.spec.js +113 -0
  216. package/lib/test/unit/ocr-healing-tier.spec.js +122 -0
  217. package/lib/test/unit/ocr-offline.spec.js +213 -0
  218. package/lib/test/unit/omni-virtual-element-store.spec.js +301 -0
  219. package/lib/test/unit/omni-vision-ios-points.spec.js +0 -2
  220. package/lib/test/unit/omni-vision.spec.js +5 -7
  221. package/lib/test/unit/package-engines.spec.js +27 -0
  222. package/lib/test/unit/passwordResetMode.test.js +10 -2
  223. package/lib/test/unit/profile-router.test.js +122 -1
  224. package/lib/test/unit/queue-requester.spec.js +1 -1
  225. package/lib/test/unit/reset-link-address.spec.js +266 -0
  226. package/lib/test/unit/reset-link.test.js +10 -4
  227. package/lib/test/unit/resilio-path-healing.spec.js +270 -0
  228. package/lib/test/unit/selector-learning-every-session.spec.js +179 -0
  229. package/lib/test/unit/selector-verification-clean-build.spec.js +130 -0
  230. package/lib/test/unit/selector-verification-job.spec.js +13 -13
  231. package/lib/test/unit/self-healing-boot.spec.js +10 -5
  232. package/lib/test/unit/self-healing-setting.spec.js +7 -6
  233. package/lib/test/unit/session-app-resolution.spec.js +5 -1
  234. package/lib/test/unit/session-attribution-wiring.spec.js +41 -13
  235. package/lib/test/unit/session-create-credential-owner.spec.js +242 -0
  236. package/lib/test/unit/session-credential-strip.spec.js +1 -1
  237. package/lib/test/unit/session-device-logs.spec.js +347 -0
  238. package/lib/test/unit/session-end-failure-analysis.spec.js +133 -0
  239. package/lib/test/unit/session-log-indexes.spec.js +64 -3
  240. package/lib/test/unit/socketServer.sessionCookie.spec.js +2 -1
  241. package/lib/test/unit/stream-start-pipelines.spec.js +72 -18
  242. package/lib/test/unit/token-mint-limits.spec.js +165 -0
  243. package/lib/test/unit/unexpected-shutdown-reason.spec.js +163 -0
  244. package/lib/test/unit/verify-credential.spec.js +33 -0
  245. package/lib/test/unit/vision-assertion.spec.js +3 -2
  246. package/lib/test/unit/web-config-service.spec.js +19 -0
  247. package/lib/tsconfig.tsbuildinfo +1 -1
  248. package/package.json +5 -5
  249. package/prisma/migrations/20261004174413_locator_etalon_path/migration.sql +2 -0
  250. package/prisma/schema.prisma +3 -0
  251. package/schema.json +5 -5
  252. package/lib/public/assets/BugReportButton-BAt0_pzq.js +0 -15
  253. package/lib/public/assets/DeviceMosaicView-BYaQHhTf.js +0 -2
  254. package/lib/public/assets/ai-settings-CsuJroRf.js +0 -21
  255. package/lib/public/assets/device-explorer-CdO6_nrn.js +0 -282
  256. package/lib/public/assets/forgot-password-CGnkRgE9.js +0 -1
  257. package/lib/public/assets/runbook-page-CMMeQml9.js +0 -124
  258. package/lib/public/assets/session-detail-page-COL_RZxw.js +0 -4
  259. /package/lib/public/assets/{BugReportButton-CPBjfiv4.css → index-CPBjfiv4.css} +0 -0
@@ -1,282 +0,0 @@
1
- import{c as J,j as s,r as u,C as xn,U as wr,X as q,t as Fe,v as Vs,b as kr,u as Bt,a as ds,T as Sr,q as Ms,R as ft,w as Cr,x as $s,y as qe,z as Hs,I as ai,S as qt,f as vt,A as Jt,B as Nr,i as oi,D as Er,E as Tr,F as Ar,G as Rr,H as Mr,p as $r}from"./index-BbKEXUFH.js";import{P as zr}from"./page-header-BjzgWz-T.js";import{P as Zt,S as Ir,B as _r}from"./BugReportButton-BAt0_pzq.js";import{A as Dr}from"./activity-DOVdsfMQ.js";import{h as Lr,M as li,S as ci,C as Or,a as _t,i as Fr,b as bn,W as Pr,H as Ur,p as Br,c as Wr,A as Mt,I as xs}from"./h264Stream-VQBphYhg.js";import{p as us}from"./labels-C21SA4JG.js";import{B as U}from"./button-Dda4irn_.js";import{S as di}from"./select-88jHcl-Z.js";import{P as ss,M as Ks,a as ke,b as ui}from"./Menu-JGGYrSQQ.js";import{M as hs}from"./Modal-CFCp3n9d.js";import{F as Qt}from"./FieldGroup-Cb5QZsE1.js";import{C as Vr}from"./clock-CpuDKysU.js";import{P as Hr}from"./plus-nBFSMu_X.js";import{C as Oe}from"./copy-CAQydNFe.js";import{T as Kr}from"./tablet-BiAsnFDj.js";import{S as qr,a as jn}from"./SegmentedControl-Bg42Atjy.js";import{T as Xr,a as Yr,b as hi,c as ns,d as Gr,e as ht}from"./Table-BcTm5xV2.js";import{L as mi,a as Jr}from"./list-checks-UWf1GY99.js";import{C as Zr}from"./chevron-right-BRYJJVC9.js";import{M as wn}from"./mouse-pointer-2-DLI1RtzU.js";import{Z as fi}from"./zap-l4VaXzq8.js";import{C as Ot}from"./check-CZ9iw9-e.js";import{C as pi}from"./circle-check-CqAJjQ5O.js";import{C as gi}from"./circle-x-DlDJtnVz.js";import{E as Qr}from"./EmptyState-BSjhk_IV.js";import{I as kn}from"./input-Cm0tmSoc.js";import{P as ea,a as ta}from"./play-DLG9t8FU.js";import{D as vi}from"./download-C9XG6lLv.js";import{U as sa,T as na}from"./upload-BG7_rMXK.js";import{A as ia}from"./arrow-left-MMbTmgoE.js";import{A as ra}from"./arrow-right-BMfnGmxW.js";import{p as aa,A as oa}from"./AnnotationOverlay-B_VNtKBH.js";import{T as la}from"./trash-2-C5RSuX0e.js";import{L as ca}from"./lock-CCJv9m_I.js";import{F as Sn}from"./FilterMenu-BAaSlWbW.js";import"./utils-CDN07tui.js";import"./index-DJGc1M2f.js";/**
2
- * @license lucide-react v0.555.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const da=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],qs=J("arrow-down",da);/**
7
- * @license lucide-react v0.555.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const ua=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Xs=J("arrow-up",ua);/**
12
- * @license lucide-react v0.555.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ha=[["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 14v-4",key:"14a6bd"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ma=J("battery-low",ha);/**
17
- * @license lucide-react v0.555.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const fa=[["path",{d:"M10 17h.01",key:"nbq80n"}],["path",{d:"M10 7v6",key:"nne03l"}],["path",{d:"M14 6h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2",key:"1m83kb"}],["path",{d:"M22 14v-4",key:"14q9d5"}],["path",{d:"M6 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h2",key:"h8lgfh"}]],pa=J("battery-warning",fa);/**
22
- * @license lucide-react v0.555.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const ga=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],va=J("battery",ga);/**
27
- * @license lucide-react v0.555.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const ya=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],xa=J("box",ya);/**
32
- * @license lucide-react v0.555.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const ba=[["path",{d:"M16 19h6",key:"xwg31i"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M21 12.598V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8.5",key:"1glfrc"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}]],ja=J("calendar-plus",ba);/**
37
- * @license lucide-react v0.555.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const wa=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],ka=J("chevrons-down-up",wa);/**
42
- * @license lucide-react v0.555.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Sa=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ca=J("chevrons-up-down",Sa);/**
47
- * @license lucide-react v0.555.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Na=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],yi=J("circle-question-mark",Na);/**
52
- * @license lucide-react v0.555.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Ea=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Cn=J("code-xml",Ea);/**
57
- * @license lucide-react v0.555.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const Ta=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Aa=J("columns-2",Ta);/**
62
- * @license lucide-react v0.555.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Ra=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Ma=J("crosshair",Ra);/**
67
- * @license lucide-react v0.555.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const $a=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],xi=J("ellipsis",$a);/**
72
- * @license lucide-react v0.555.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */const za=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],Ia=J("folder-down",za);/**
77
- * @license lucide-react v0.555.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */const _a=[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]],Da=J("hand",_a);/**
82
- * @license lucide-react v0.555.0 - ISC
83
- *
84
- * This source code is licensed under the ISC license.
85
- * See the LICENSE file in the root directory of this source tree.
86
- */const La=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Oa=J("image",La);/**
87
- * @license lucide-react v0.555.0 - ISC
88
- *
89
- * This source code is licensed under the ISC license.
90
- * See the LICENSE file in the root directory of this source tree.
91
- */const Fa=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Pa=J("keyboard",Fa);/**
92
- * @license lucide-react v0.555.0 - ISC
93
- *
94
- * This source code is licensed under the ISC license.
95
- * See the LICENSE file in the root directory of this source tree.
96
- */const Ua=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ba=J("library",Ua);/**
97
- * @license lucide-react v0.555.0 - ISC
98
- *
99
- * This source code is licensed under the ISC license.
100
- * See the LICENSE file in the root directory of this source tree.
101
- */const Wa=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Va=J("lock-open",Wa);/**
102
- * @license lucide-react v0.555.0 - ISC
103
- *
104
- * This source code is licensed under the ISC license.
105
- * See the LICENSE file in the root directory of this source tree.
106
- */const Ha=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Ka=J("map-pin",Ha);/**
107
- * @license lucide-react v0.555.0 - ISC
108
- *
109
- * This source code is licensed under the ISC license.
110
- * See the LICENSE file in the root directory of this source tree.
111
- */const qa=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Xa=J("maximize-2",qa);/**
112
- * @license lucide-react v0.555.0 - ISC
113
- *
114
- * This source code is licensed under the ISC license.
115
- * See the LICENSE file in the root directory of this source tree.
116
- */const Ya=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Ga=J("message-square",Ya);/**
117
- * @license lucide-react v0.555.0 - ISC
118
- *
119
- * This source code is licensed under the ISC license.
120
- * See the LICENSE file in the root directory of this source tree.
121
- */const Ja=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Za=J("minimize-2",Ja);/**
122
- * @license lucide-react v0.555.0 - ISC
123
- *
124
- * This source code is licensed under the ISC license.
125
- * See the LICENSE file in the root directory of this source tree.
126
- */const Qa=[["path",{d:"M18 5h4",key:"1lhgn2"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],eo=J("moon-star",Qa);/**
127
- * @license lucide-react v0.555.0 - ISC
128
- *
129
- * This source code is licensed under the ISC license.
130
- * See the LICENSE file in the root directory of this source tree.
131
- */const to=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],so=J("mouse-pointer-click",to);/**
132
- * @license lucide-react v0.555.0 - ISC
133
- *
134
- * This source code is licensed under the ISC license.
135
- * See the LICENSE file in the root directory of this source tree.
136
- */const no=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],io=J("package",no);/**
137
- * @license lucide-react v0.555.0 - ISC
138
- *
139
- * This source code is licensed under the ISC license.
140
- * See the LICENSE file in the root directory of this source tree.
141
- */const ro=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],ao=J("panel-top",ro);/**
142
- * @license lucide-react v0.555.0 - ISC
143
- *
144
- * This source code is licensed under the ISC license.
145
- * See the LICENSE file in the root directory of this source tree.
146
- */const oo=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],bi=J("pen-line",oo);/**
147
- * @license lucide-react v0.555.0 - ISC
148
- *
149
- * This source code is licensed under the ISC license.
150
- * See the LICENSE file in the root directory of this source tree.
151
- */const lo=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],co=J("rectangle-horizontal",lo);/**
152
- * @license lucide-react v0.555.0 - ISC
153
- *
154
- * This source code is licensed under the ISC license.
155
- * See the LICENSE file in the root directory of this source tree.
156
- */const uo=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],ho=J("rectangle-vertical",uo);/**
157
- * @license lucide-react v0.555.0 - ISC
158
- *
159
- * This source code is licensed under the ISC license.
160
- * See the LICENSE file in the root directory of this source tree.
161
- */const mo=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Dt=J("rotate-cw",mo);/**
162
- * @license lucide-react v0.555.0 - ISC
163
- *
164
- * This source code is licensed under the ISC license.
165
- * See the LICENSE file in the root directory of this source tree.
166
- */const fo=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],ji=J("scroll-text",fo);/**
167
- * @license lucide-react v0.555.0 - ISC
168
- *
169
- * This source code is licensed under the ISC license.
170
- * See the LICENSE file in the root directory of this source tree.
171
- */const po=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],St=J("shield-alert",po);/**
172
- * @license lucide-react v0.555.0 - ISC
173
- *
174
- * This source code is licensed under the ISC license.
175
- * See the LICENSE file in the root directory of this source tree.
176
- */const go=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],vo=J("tag",go);/**
177
- * @license lucide-react v0.555.0 - ISC
178
- *
179
- * This source code is licensed under the ISC license.
180
- * See the LICENSE file in the root directory of this source tree.
181
- */const yo=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],bs=J("target",yo);/**
182
- * @license lucide-react v0.555.0 - ISC
183
- *
184
- * This source code is licensed under the ISC license.
185
- * See the LICENSE file in the root directory of this source tree.
186
- */const xo=[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]],bo=J("text-cursor-input",xo);/**
187
- * @license lucide-react v0.555.0 - ISC
188
- *
189
- * This source code is licensed under the ISC license.
190
- * See the LICENSE file in the root directory of this source tree.
191
- */const jo=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],wo=J("thermometer",jo);/**
192
- * @license lucide-react v0.555.0 - ISC
193
- *
194
- * This source code is licensed under the ISC license.
195
- * See the LICENSE file in the root directory of this source tree.
196
- */const ko=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],So=J("toggle-left",ko);/**
197
- * @license lucide-react v0.555.0 - ISC
198
- *
199
- * This source code is licensed under the ISC license.
200
- * See the LICENSE file in the root directory of this source tree.
201
- */const Co=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]],Nn=J("touchpad",Co);/**
202
- * @license lucide-react v0.555.0 - ISC
203
- *
204
- * This source code is licensed under the ISC license.
205
- * See the LICENSE file in the root directory of this source tree.
206
- */const No=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Eo=J("type",No);/**
207
- * @license lucide-react v0.555.0 - ISC
208
- *
209
- * This source code is licensed under the ISC license.
210
- * See the LICENSE file in the root directory of this source tree.
211
- */const To=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],Ao=J("volume-1",To);/**
212
- * @license lucide-react v0.555.0 - ISC
213
- *
214
- * This source code is licensed under the ISC license.
215
- * See the LICENSE file in the root directory of this source tree.
216
- */const Ro=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Mo=J("volume-2",Ro);function $o(e){return e>=50?"ready":e>=20?"warning":"error"}function zo(e){return e>=50?s.jsx(va,{size:10}):e>=20?s.jsx(ma,{size:10}):s.jsx(pa,{size:10})}function Io(e){return e==="Normal"?"ready":e==="Critical"?"error":"warning"}const _o=({device:e})=>{if(e.deviceType==="emulator"||e.deviceType==="simulator"||e.offline)return null;const n=typeof e.batteryLevel=="number",i=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!n&&!i?s.jsx("div",{className:"dc2-health",children:s.jsxs(Zt,{tone:"neutral",title:"Device does not report battery or thermal data",children:[s.jsx(Dr,{size:10}),"No telemetry"]})}):s.jsxs("div",{className:"dc2-health",children:[n&&s.jsxs(Zt,{tone:$o(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[zo(e.batteryLevel),e.batteryLevel,"%"]}),i&&s.jsxs(Zt,{tone:Io(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[s.jsx(wo,{size:10}),e.thermalStatus]})]})};function Do(e){if(typeof e!="number")throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(e*1e3)%1e3,nanoseconds:t(e*1e6)%1e3}}const Lo=(e,t)=>t===1?e:`${e}s`,Oo=1e-7;function wi(e,t={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);const n=[],i=(o,d)=>{const c=Math.floor(o*10**d+Oo);return(Math.round(c)/10**d).toFixed(d)},r=(o,d,c,l)=>{if((n.length===0||!t.colonNotation)&&o===0&&!(t.colonNotation&&c==="m"))return;l=(l||o||"0").toString();let h,m;if(t.colonNotation){h=n.length>0?":":"",m="";const g=l.includes(".")?l.split(".")[0].length:l.length,f=n.length>0?2:1;l="0".repeat(Math.max(0,f-g))+l}else h="",m=t.verbose?" "+Lo(d,o):c;n.push(h+l+m)},a=Do(e);if(r(Math.trunc(a.days/365),"year","y"),r(a.days%365,"day","d"),r(a.hours,"hour","h"),r(a.minutes,"minute","m"),t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3)if(r(a.seconds,"second","s"),t.formatSubMilliseconds)r(a.milliseconds,"millisecond","ms"),r(a.microseconds,"microsecond","µs"),r(a.nanoseconds,"nanosecond","ns");else{const o=a.milliseconds+a.microseconds/1e3+a.nanoseconds/1e6,d=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,c=o>=1?Math.round(o):Math.ceil(o),l=d?o.toFixed(d):c;r(Number.parseFloat(l),"millisecond","ms",l)}else{const o=e/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,c=i(o,d),l=t.keepDecimalsOnWholeSeconds?c:c.replace(/\.0+$/,"");r(Number.parseFloat(l),"second","s",l)}if(n.length===0)return"0"+(t.verbose?" milliseconds":"ms");if(t.compact)return n[0];if(typeof t.unitCount=="number"){const o=t.colonNotation?"":" ";return n.slice(0,Math.max(t.unitCount,1)).join(o)}return t.colonNotation?n.join(""):n.join(" ")}const js=6e4;function Fo(e){return!Number.isFinite(e)||e<=0?"expiring":e<js?"under 1m":wi(Math.floor(e/js)*js,{unitCount:2})}const zs=["ready","busy","reserved","maintenance","offline"],ki={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function Ft(e,t){return e.offline?"offline":e.userBlocked?"maintenance":e.busy?"busy":e.reservedUntil&&t<e.reservedUntil?"reserved":"ready"}function Si(e,t){const n=Lr(e);if(!e.busy||!n)return null;const i=String(n);return i.startsWith("manual_")?t!=null&&t.userId&&i===`manual_${t.userId}_${e.udid}`?"self":"other":"session"}const En=e=>(e==null?void 0:e.role)==="ADMIN"||(e==null?void 0:e.role)==="SUPER_ADMIN";function Po(e,t,n){switch(Si(e,t)){case"session":return e.sessionStartTime&&e.sessionStartTime>0&&n>e.sessionStartTime?`Test session · ${wi(n-e.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(e.reservedUntil&&n<e.reservedUntil){const r=!!e.reservedBy&&(e.reservedBy===(t==null?void 0:t.email)||e.reservedBy===(t==null?void 0:t.name))?"you":e.reservedBy||"another user";return`${Fo(e.reservedUntil-n)} left · by ${r}`}return null}function Uo(e,t){if(e.offline)return{enabled:!1,reason:"Device is offline"};if(e.userBlocked&&!En(t))return{enabled:!1,reason:"In maintenance"};const n=Si(e,t);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!En(t)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function it(e){var t;return((t=e.marketingName)==null?void 0:t.trim())||e.name}function Ci(e){const t=[us(e.platform),e.sdk].filter(Boolean).join(" ");if(e.deviceType==="emulator")return`Emulator · ${t}`;if(e.deviceType==="simulator")return`Simulator · ${t}`;const i=[e.manufacturer?e.manufacturer.charAt(0).toUpperCase()+e.manufacturer.slice(1):"",e.model].filter(Boolean).join(" ");return i?`${i} · ${t}`:t}function Bo(e){return e.formFactor==="tablet"||e.formFactor==="tv"?e.formFactor:"phone"}function Et(e,t){return e.teamId?(t==null?void 0:t.get(e.teamId))??e.teamName??`Team ${e.teamId.slice(0,6)}`:null}const Wo=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],Vo=({device:e,onClose:t,onReserved:n})=>{const[i,r]=u.useState(""),[a,o]=u.useState("1h"),[d,c]=u.useState(""),[l,h]=u.useState(!1),[m,g]=u.useState(null),[f,v]=u.useState(null),S=async()=>{if(!i.trim()){g("Please enter your name/ID");return}h(!0),g(null),v(null);try{const b=await q.reserveDevice(e.udid,e.host,i,a,d);b.success?(n(),t()):v(b.error||"Failed to reserve device")}catch(b){v(b.message||"An unexpected error occurred")}finally{h(!1)}};return s.jsx(hs,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(ja,{size:16,className:"title-icon"}),"Reserve device"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,disabled:l,children:"Cancel"}),s.jsx("button",{className:"btn-reserve",onClick:S,disabled:l||!i.trim(),children:l?"Reserving...":"Confirm Reservation"})]}),children:s.jsxs("div",{className:"reservation-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsxs("p",{children:["Reserve ",s.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),s.jsx(Qt,{label:s.jsxs(s.Fragment,{children:[s.jsx(wr,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:m?s.jsxs(s.Fragment,{children:[s.jsx(xn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),m]}):void 0,children:s.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:i,onChange:b=>{r(b.target.value),m&&g(null)},disabled:l})}),s.jsx(Qt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Vr,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:s.jsx("div",{className:"duration-selector",children:Wo.map(b=>s.jsx("div",{className:`duration-option ${a===b.value?"active":""}`,onClick:()=>o(b.value),children:b.label},b.value))})}),s.jsx(Qt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Ga,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?s.jsxs(s.Fragment,{children:[s.jsx(xn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:s.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:d,onChange:b=>c(b.target.value),disabled:l})})]})})},Ho=({device:e,onClose:t,onUpdated:n})=>{const{toast:i}=Fe(),[r,a]=u.useState(e.tags||[]),[o,d]=u.useState(""),[c,l]=u.useState(!1),h=u.useRef(null);u.useEffect(()=>{h.current&&h.current.focus()},[]);const m=()=>{const S=o.trim();S&&!r.includes(S)&&(a([...r,S]),d(""))},g=S=>{a(r.filter(b=>b!==S))},f=S=>{S.key==="Enter"&&m()},v=async()=>{l(!0);try{await q.updateDeviceTags(e.udid,e.host,r),n(),t()}catch(S){console.error("Failed to update tags",S),i("Error saving tags. Please try again.","error")}finally{l(!1)}};return s.jsx(hs,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(vo,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn-save",onClick:v,disabled:c,children:c?"Saving...":"Apply Changes"})]}),children:s.jsxs("div",{className:"tag-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsx(Qt,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:s.jsxs("div",{className:"input-with-button",children:[s.jsx("input",{ref:h,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:o,onChange:S=>d(S.target.value),onKeyDown:f}),s.jsx("button",{className:"add-inline-btn",onClick:m,disabled:!o.trim(),children:s.jsx(Hr,{size:16})})]})}),s.jsxs("div",{className:"tags-display-section",children:[s.jsx("label",{children:"Current Tags"}),s.jsx("div",{className:"tags-list",children:r.length>0?r.map(S=>s.jsxs("div",{className:"tag-pill-editable",children:[S,s.jsx("button",{className:"remove-tag",onClick:()=>g(S),children:s.jsx(Vs,{size:12})})]},S)):s.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},Ko="/wd/hub";function qo(e){return e==="android"?"UiAutomator2":"XCUITest"}function Xo(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Yo(e,t=Ko){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),i=t.startsWith("/")?t:`/${t}`,r=n.pathname.replace(/\/$/,"");return r===i||r.endsWith(i)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${i}`}catch{return e}}function Go(e){const t={platformName:Xo(e.platform),"appium:automationName":qo(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(t["appium:platformVersion"]=e.sdk),e.name&&(t["appium:deviceName"]=e.name),t}function Jo(e){return JSON.stringify(Go(e),null,2)}const Zo=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,Qo=/^(?:\d{1,3}\.){3}\d{1,3}$/;function el(e){const t=e.trim();return!t||Zo.test(t)||!Qo.test(t)?!1:t.split(".").every(n=>{const i=Number(n);return Number.isInteger(i)&&i>=0&&i<=255})}function tl(e){return e.ip&&el(e.ip)?e.ip.trim():null}const Ni=({udid:e,currentTeamId:t,teams:n,onDone:i,className:r})=>{const{toast:a}=Fe(),[o,d]=u.useState(!1);async function c(l){d(!0);try{await q.setDeviceTeam(e,l)}catch(h){d(!1),a((h==null?void 0:h.message)||"Failed to update team","error");return}d(!1),a(l?"Device assigned":"Device returned to shared pool","success"),i(!0)}return s.jsxs(di,{selectSize:"sm",className:r,autoFocus:!0,"aria-label":"Team",disabled:o,defaultValue:t??"",onBlur:()=>i(!1),onChange:l=>c(l.target.value||null),children:[s.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([l,h])=>s.jsx("option",{value:l,children:h},l))]})};function Ei(e,t){const[n,i]=u.useState(!1),[r,a]=u.useState(!1),[o,d]=u.useState(!1),{me:c}=kr(),{toast:l}=Fe(),h=(c==null?void 0:c.role)==="ADMIN"||(c==null?void 0:c.role)==="SUPER_ADMIN",m=Date.now(),g=Ft(e,m),f=g==="reserved",v=Po(e,c,m),S=Uo(e,c),b=Yo(e.host),M=tl(e),k=async(T,p)=>{var E;try{await((E=navigator.clipboard)==null?void 0:E.writeText(T)),l(p,"success")}catch{l("Failed to copy","error")}},y=async()=>{await q.releaseReservation(e.udid,e.host),t()},C=async()=>{await q.blockDevice(e.udid,e.host),t()},x=async()=>{await q.unblockDevice(e.udid,e.host),t()},A=async()=>{e.userBlocked?await x():await C()},N=s.jsxs(s.Fragment,{children:[n&&s.jsx(Vo,{device:e,onClose:()=>i(!1),onReserved:()=>t()}),r&&s.jsx(Ho,{device:e,onClose:()=>a(!1),onUpdated:()=>t()})]});return{kind:g,reserved:f,activity:v,control:S,isAdmin:h,editingTeam:o,setEditingTeam:d,openReservation:()=>i(!0),openTagManager:()=>a(!0),release:y,toggleMaintenance:A,copy:k,serverUrl:b,ip:M,dialogs:N}}const Ti=({device:e,actions:t,navigate:n,reasonId:i})=>{const{kind:r,reserved:a,control:o}=t;return s.jsxs(s.Fragment,{children:[s.jsx(U,{variant:"tonal",size:"sm",disabled:!o.enabled,"aria-describedby":o.enabled?void 0:i,onClick:()=>{o.enabled&&n(`/devices/${e.udid}/control`)},children:"Control"}),a?s.jsx(U,{variant:"secondary",size:"sm",onClick:t.release,children:"Release"}):r==="ready"?s.jsx(U,{variant:"secondary",size:"sm",onClick:t.openReservation,children:"Reserve"}):null]})},Ai=({device:e,actions:t})=>{const[n,i]=u.useState(!1),r=u.useRef(null),{isAdmin:a,serverUrl:o,ip:d,copy:c}=t;return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:r,type:"button",className:"dc2-more",onClick:()=>i(l=>!l),"aria-label":"More actions",children:s.jsx(xi,{size:14})}),s.jsx(ss,{open:n,onClose:()=>i(!1),anchorRef:r,children:s.jsxs(Ks,{children:[s.jsx(ke,{icon:s.jsx(Oe,{size:12}),onClick:()=>{i(!1),c(e.udid,"UDID copied")},children:"Copy UDID"}),o!=="—"&&s.jsx(ke,{icon:s.jsx(Oe,{size:12}),onClick:()=>{i(!1),c(o,"Server URL copied")},children:"Copy server URL"}),d&&s.jsx(ke,{icon:s.jsx(Oe,{size:12}),onClick:()=>{i(!1),c(d,"IP address copied")},children:"Copy IP address"}),s.jsx(ke,{icon:s.jsx(Oe,{size:12}),onClick:()=>{i(!1),c(Jo(e),"Session capabilities copied")},children:"Copy capabilities"}),a&&s.jsxs(s.Fragment,{children:[s.jsx(ui,{}),s.jsx(ke,{onClick:()=>{i(!1),t.openTagManager()},children:"Manage tags…"}),s.jsx(ke,{onClick:()=>{i(!1),t.setEditingTeam(!0)},children:"Assign team…"}),s.jsx(ke,{onClick:()=>{i(!1),t.toggleMaintenance()},children:e.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},sl=({device:e})=>{const t={phone:Ms,tablet:Kr,tv:Sr}[Bo(e)],n=e.deviceType==="emulator"||e.deviceType==="simulator";return s.jsx(t,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},nl=({device:e,reloadDevices:t,navigate:n,teams:i})=>{var m,g,f;const r=Ei(e,t),{kind:a,activity:o,control:d}=r,c=`dc2-reason-${e.udid}`,l=it(e),h=Et(e,i);return s.jsxs("div",{className:`dc2 dc2-${a}`,children:[s.jsxs("div",{className:`dc2-band dc2-band-${a}`,children:[s.jsxs("span",{className:"dc2-band-label",children:[s.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),ki[a]]}),o&&s.jsx("span",{className:"dc2-band-activity",title:o,children:o})]}),s.jsxs("div",{className:`dc2-body${a==="offline"?" dc2-dim":""}`,children:[s.jsxs("div",{className:"dc2-head",children:[s.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:s.jsx(sl,{device:e})}),s.jsxs("div",{className:"dc2-id",children:[s.jsx("div",{className:"dc2-title",title:`${l}
217
- ${e.udid}`,children:l}),s.jsx("div",{className:"dc2-subtitle",children:Ci(e)})]})]}),s.jsxs("div",{className:"dc2-meta",children:[s.jsx(_o,{device:e}),r.editingTeam?s.jsx(Ni,{className:"dc2-team-picker",udid:e.udid,currentTeamId:e.teamId??null,teams:i??new Map,onDone:v=>{r.setEditingTeam(!1),v&&t()}}):h&&s.jsx(Zt,{tone:"accent",className:"dc2-team",title:`Team: ${h}`,children:h}),(m=e.tags)==null?void 0:m.slice(0,2).map(v=>s.jsxs("span",{className:"dc2-tag",title:v,children:["#",v]},v)),(((g=e.tags)==null?void 0:g.length)||0)>2&&s.jsxs("span",{className:"dc2-tag",children:["+",(((f=e.tags)==null?void 0:f.length)||0)-2]})]})]}),s.jsxs("div",{className:"dc2-foot",children:[s.jsx(Ti,{device:e,actions:r,navigate:n,reasonId:c}),!d.enabled&&s.jsx("span",{id:c,className:"dc2-unavailable",title:d.reason,children:d.reason}),s.jsx("span",{className:"dc2-spacer"}),s.jsx(Ai,{device:e,actions:r})]}),r.dialogs]})};function il(e){const t=Bt(),{search:n}=ds();return s.jsx(nl,{device:e.device,reloadDevices:e.reloadDevices,navigate:i=>t(`${i}${n}`),teams:e.teams})}class rl extends ft.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){q.listTeams().then(t=>{this.setState({teamsMap:new Map(t.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return s.jsx("div",{className:"device-explorer-card-container",children:ft.Children.toArray(this.props.devices.map(t=>s.jsx(il,{device:t,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const al={status:"all",platform:"all",type:"all",q:""},Ri=["all",...zs],Mi=["all","android","ios","tvos"],$i=["all","real","virtual"];function ws(e,t){return t.includes(e)?e:t[0]}function ol(e){const t=e.get("q")??"";return{status:ws(e.get("status"),Ri),platform:ws(e.get("platform"),Mi),type:ws(e.get("type"),$i),q:t.trim()?t:""}}function ll(e){const t=new URLSearchParams;return e.status!=="all"&&t.set("status",e.status),e.platform!=="all"&&t.set("platform",e.platform),e.type!=="all"&&t.set("type",e.type),e.q.trim()&&t.set("q",e.q),t}function Pt(e){return e.deviceType==="simulator"||e.deviceType==="emulator"?!0:!e.deviceType&&e.realDevice===!1}function Ys(e){const t=(e.platform||"").toLowerCase();return t==="android"||t==="ios"||t==="tvos"?t:null}function cl(e){const t=e.deviceType==="emulator"?"Emulator":e.deviceType==="simulator"?"Simulator":"";return[it(e),e.name,e.manufacturer,e.model,us(e.platform),e.sdk,t,e.teamName,e.udid].filter(Boolean).join(" ").toLowerCase()}function es(e,t,n,i){if(i!=="status"&&t.status!=="all"&&Ft(e,n)!==t.status||i!=="platform"&&t.platform!=="all"&&Ys(e)!==t.platform||i!=="type"&&t.type!=="all"&&t.type==="virtual"!==Pt(e))return!1;const r=t.q.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return!0;const a=cl(e);return r.every(o=>a.includes(o))}const ks=e=>Object.fromEntries(e.map(t=>[t,0]));function dl(e,t,n){const i=ks(Ri),r=ks(Mi),a=ks($i);for(const o of e){if(es(o,t,n,"status")&&(i.all+=1,i[Ft(o,n)]+=1),es(o,t,n,"platform")){r.all+=1;const d=Ys(o);d&&(r[d]+=1)}es(o,t,n,"type")&&(a.all+=1,a[Pt(o)?"virtual":"real"]+=1)}return{status:i,platform:r,type:a}}function ul(e){return e.some(t=>Ys(t)==="tvos")}function hl(e){return e.status!=="all"||e.platform!=="all"||e.type!=="all"||e.q.trim()!==""}function ml(e,t){const n=i=>i===1?"device":"devices";return e===t?`${t} ${n(t)}`:`${e} of ${t} ${n(t)}`}const Is={key:"status",dir:"asc"},fl=["status","device","platform","type","team","host"],pl=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),mt=(e,t)=>pl.compare(e,t);function gl(e,t,n,i){switch(n){case"status":return zs.indexOf(Ft(e,i.now))-zs.indexOf(Ft(t,i.now));case"device":return mt(it(e),it(t));case"platform":return mt(e.platform||"",t.platform||"")||mt(e.sdk||"",t.sdk||"");case"type":return Number(Pt(e))-Number(Pt(t));case"team":return mt(Et(e,i.teams)??"",Et(t,i.teams)??"");case"host":return mt(e.host||"",t.host||"")}}function vl(e,t,n){const i=t.dir==="desc"?-1:1;return e.slice().sort((r,a)=>{if(t.key==="team"){const o=Et(r,n.teams)===null,d=Et(a,n.teams)===null;if(o!==d)return o?1:-1}return i*gl(r,a,t.key,n)||mt(it(r),it(a))||mt(r.udid,a.udid)})}function yl(e){const t=e.get("sort");return!t||!fl.includes(t)?Is:{key:t,dir:e.get("dir")==="desc"?"desc":"asc"}}function xl(e,t){e.delete("sort"),e.delete("dir"),!(t.key===Is.key&&t.dir===Is.dir)&&(e.set("sort",t.key),t.dir==="desc"&&e.set("dir","desc"))}const Ct=({sortKey:e,label:t,sort:n,onSortChange:i})=>{const r=n.key===e,a=r?n.dir:"asc";return s.jsx(ns,{scope:"col","aria-sort":r?a==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>i(r?{key:e,dir:a==="asc"?"desc":"asc"}:{key:e,dir:"asc"}),children:[t,r&&(a==="asc"?s.jsx(Xs,{size:12,"aria-hidden":"true"}):s.jsx(qs,{size:12,"aria-hidden":"true"}))]})})},bl=({device:e,reloadDevices:t,navigate:n,teams:i,showHost:r})=>{const a=Ei(e,t),{kind:o,activity:d,control:c}=a,l=it(e),h=Ci(e),m=Et(e,i),g=`${us(e.platform)} ${e.sdk??""}`,f=e.tags??[],v=`devtable-reason-${e.udid}`;return s.jsxs(hi,{className:`devtable-row${o==="offline"?" is-offline":""}`,children:[s.jsxs(ht,{children:[s.jsxs("div",{className:"devtable-line",children:[s.jsx(qr,{kind:o,className:"devtable-status-dot"})," ",ki[o]]}),d&&s.jsx("div",{className:"devtable-muted devtable-line",title:d,children:d})]}),s.jsxs(ns,{scope:"row",className:"devtable-rowheader",title:`${l}
218
- ${e.udid}`,children:[s.jsx("div",{className:"devtable-title devtable-line",children:l}),s.jsx("div",{className:"devtable-muted devtable-line",title:h,children:h})]}),s.jsx(ht,{title:g,children:g}),s.jsx(ht,{children:Pt(e)?"Virtual":"Real"}),s.jsx(ht,{title:a.editingTeam?void 0:m??"Shared",children:a.editingTeam?s.jsx(Ni,{udid:e.udid,currentTeamId:e.teamId??null,teams:i,onDone:S=>{a.setEditingTeam(!1),S&&t()}}):m??"Shared"}),s.jsxs(ht,{title:f.join(", "),children:[f.slice(0,2).map(S=>s.jsxs("span",{className:"devtable-tag",children:["#",S]},S)),f.length>2&&s.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),r&&s.jsx(ht,{title:e.host,children:e.host}),s.jsx(ht,{className:"devtable-actions",title:c.enabled?void 0:c.reason,children:s.jsxs("div",{className:"devtable-actions-inner",children:[s.jsx(Ti,{device:e,actions:a,navigate:n,reasonId:v}),!c.enabled&&s.jsx("span",{id:v,className:"sr-only",children:c.reason}),s.jsx(Ai,{device:e,actions:a})]})}),a.dialogs]})};function jl({devices:e,reloadDevices:t,sort:n,onSortChange:i,navigate:r,teams:a}){const o=new Set(e.map(c=>c.host)).size>1||n.key==="host",d=vl(e,n,{now:Date.now(),teams:a});return s.jsxs(Xr,{className:"devtable",children:[s.jsxs("caption",{className:"sr-only",children:["Devices, ",e.length," shown"]}),s.jsxs("colgroup",{children:[s.jsx("col",{className:"devtable-col-status"}),s.jsx("col",{}),s.jsx("col",{className:"devtable-col-platform"}),s.jsx("col",{className:"devtable-col-type"}),s.jsx("col",{className:"devtable-col-team"}),s.jsx("col",{className:"devtable-col-tags"}),o&&s.jsx("col",{className:"devtable-col-host"}),s.jsx("col",{className:"devtable-col-actions"})]}),s.jsx(Yr,{children:s.jsxs(hi,{children:[s.jsx(Ct,{sortKey:"status",label:"Status",sort:n,onSortChange:i}),s.jsx(Ct,{sortKey:"device",label:"Device",sort:n,onSortChange:i}),s.jsx(Ct,{sortKey:"platform",label:"Platform",sort:n,onSortChange:i}),s.jsx(Ct,{sortKey:"type",label:"Type",sort:n,onSortChange:i}),s.jsx(Ct,{sortKey:"team",label:"Team",sort:n,onSortChange:i}),s.jsx(ns,{scope:"col",children:"Tags"}),o&&s.jsx(Ct,{sortKey:"host",label:"Host",sort:n,onSortChange:i}),s.jsx(ns,{scope:"col",children:"Actions"})]})}),s.jsx(Gr,{children:d.map(c=>s.jsx(bl,{device:c,reloadDevices:t,navigate:r,teams:a,showHost:o},c.udid))})]})}function wl(e){const t=Bt(),{search:n}=ds(),[i,r]=u.useState(new Map);return u.useEffect(()=>{q.listTeams().then(a=>r(new Map(a.map(o=>[o.id,o.name])))).catch(()=>{})},[]),s.jsx(jl,{devices:e.devices,reloadDevices:e.reloadDevices,sort:e.sort,onSortChange:e.onSortChange,navigate:a=>t(`${a}${n}`),teams:i})}const kl=({onCommand:e,prompt:t="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:i})=>{const[r,a]=u.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[o,d]=u.useState(""),[c,l]=u.useState([]),[h,m]=u.useState(-1),[g,f]=u.useState(!1),v=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[r]);const b=k=>{const y=k.trim();if((y.startsWith("{")||y.startsWith("["))&&(y.endsWith("}")||y.endsWith("]")))try{const C=JSON.parse(y);return JSON.stringify(C,null,2)}catch{}return k},M=async k=>{if(k.key==="Enter"&&!g){const y=o.trim();if(!y)return;if(d(""),a(C=>[...C,{type:"command",content:`${t} ${y}`,timestamp:Date.now()}]),l(C=>[...C,y]),m(-1),f(!0),y==="clear"){a([]),f(!1);return}if(y==="help"){let C="";i==="android"?C=`
219
- Android Allowed Commands:
220
- • System Info: getprop, ip addr, date, uptime, whoami, cat /proc/meminfo, cat /proc/cpuinfo
221
- • Process Mgmt: ps, top
222
- • File System: ls
223
- • Network: netstat
224
- • Diagnostics: dumpsys [battery|wifi|power]
225
- • Packages: pm list packages
226
- One command per line, in plain words: no ; | & $ quotes or redirection.
227
- `:(i==="ios"||i==="tvos")&&(C=`
228
- iOS Allowed Commands:
229
- • Real Device (go-ios):
230
- apps, info
231
- • Simulator (xcrun simctl):
232
- listapps, get_app_container, getenv
233
- • Simulator System (no arguments):
234
- ls, ps, date, uptime, whoami, id
235
- One command per line, in plain words: no ; | & $ quotes or redirection.
236
- `),a(x=>[...x,{type:"output",content:C.trim(),timestamp:Date.now()}]),f(!1);return}try{const C=await e(y),x=b(C||"(No output)");a(A=>[...A,{type:"output",content:x,timestamp:Date.now()}])}catch(C){a(x=>[...x,{type:"error",content:C.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var C;return(C=S.current)==null?void 0:C.focus()},10)}}else if(k.key==="ArrowUp"){if(k.preventDefault(),c.length>0){const y=h===-1?c.length-1:Math.max(0,h-1);m(y),d(c[y])}}else if(k.key==="ArrowDown"&&(k.preventDefault(),h!==-1)){const y=h+1;y>=c.length?(m(-1),d("")):(m(y),d(c[y]))}};return s.jsxs("div",{className:"terminal-container theme-dark",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"terminal-header",children:[s.jsxs("div",{className:"terminal-controls",children:[s.jsx("div",{className:"dot red"}),s.jsx("div",{className:"dot yellow"}),s.jsx("div",{className:"dot green"})]}),s.jsxs("div",{className:"terminal-title",children:[us(i)," shell"]}),s.jsx("div",{className:"terminal-actions",children:s.jsx("button",{className:"terminal-action-btn",onClick:()=>a([]),title:"Clear terminal",children:"CLEAR"})})]}),s.jsxs("div",{className:"terminal-history",ref:v,onClick:()=>{var k;return(k=S.current)==null?void 0:k.focus()},children:[r.map((k,y)=>s.jsx("div",{className:`terminal-line ${k.type}`,children:k.content},y)),g&&s.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),s.jsxs("div",{className:"terminal-input-area",children:[s.jsx("span",{className:"terminal-prompt",children:t}),s.jsx("input",{ref:S,className:"terminal-input",value:o,onChange:k=>d(k.target.value),onKeyDown:M,disabled:g,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ye(e,t){var n;t(e),(n=e.children)==null||n.forEach(i=>Ye(i,t))}function Xe(e,...t){var n;for(const i of t){const r=(n=e.attributes)==null?void 0:n[i];if(r!=null&&r!=="")return String(r)}}function Tt(e){var t;return((t=e.type)==null?void 0:t.split(".").pop())||e.type||""}function Sl(e,t){const n=[];return Ye(e,i=>{Xe(i,"content-desc","contentDescription","accessibilityId","name","label")===t&&n.push(i)}),n}function Cl(e,t){const n=[];return Ye(e,i=>{Xe(i,"resource-id","resourceId","identifier")===t&&n.push(i)}),n}function _s(e,t){const n=[];return Ye(e,i=>{(i.type===t||Tt(i)===t)&&n.push(i)}),n}function Nl(e,t){const n=[];return Ye(e,i=>{Xe(i,"name")===t&&n.push(i)}),n}function El(e){const t=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return t?{tag:t[1]==="*"?null:t[1],attrKey:t[2],attrValue:t[4]}:null}function Tl(e,t){const n=t.split("/").filter(Boolean);if(n.length===0)return null;const i=[];for(const a of n){const o=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(a);if(!o)return null;i.push({type:o[1],index:parseInt(o[2],10)})}if(i[0].type!==e.type&&i[0].type!==Tt(e)||i[0].index!==1)return null;let r=e;for(let a=1;a<i.length&&r;a++){const{type:o,index:d}=i[a];let c=0,l;for(const h of r.children||[])if((h.type===o||Tt(h)===o)&&(c+=1,c===d)){l=h;break}r=l}return r?[r]:[]}function Al(e,t){const n=Tl(e,t);if(n!==null)return{kind:"matched",nodes:n};const i=El(t);if(i){const r=[];return Ye(e,a=>{if(i.tag&&a.type!==i.tag&&Tt(a)!==i.tag)return;Xe(a,i.attrKey)===i.attrValue&&r.push(a)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Rl(e,t){const n=t.trim(),i=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(i){const[,o,d,c]=i,l=[];return Ye(e,h=>{if(h.type!==o&&Tt(h)!==o)return;Xe(h,d)===c&&l.push(h)}),{kind:"matched",nodes:l}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,o,d]=r,c=parseInt(d,10),l=[];return Ye(e,h=>{(h.type===o||Tt(h)===o)&&l.push(h)}),{kind:"matched",nodes:l[c-1]?[l[c-1]]:[]}}const a=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return a?_s(e,a[1]).length>0?{kind:"matched",nodes:_s(e,a[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Ml(e,t){const i=t.trim().split(/\s+AND\s+/i).map(o=>o.trim()),r=[];for(const o of i){const d=/^(\w+)\s*==\s*"([^"]*)"$/.exec(o);if(!d)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:d[1],value:d[2]})}const a=[];return Ye(e,o=>{for(const d of r){let c;if(d.key==="type"?c=o.type:d.key==="label"?c=Xe(o,"label")??o.label:d.key==="name"?c=Xe(o,"name")??o.name:d.key==="value"?c=Xe(o,"value")??o.value:c=Xe(o,d.key),c!==d.value)return}a.push(o)}),{kind:"matched",nodes:a}}function Ds(e,t,n){const i=t.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(i){case"accessibility id":return{kind:"matched",nodes:Sl(e,n)};case"id":return{kind:"matched",nodes:Cl(e,n)};case"class name":return{kind:"matched",nodes:_s(e,n)};case"name":return{kind:"matched",nodes:Nl(e,n)};case"xpath":return Al(e,n);case"-ios class chain":return Rl(e,n);case"-ios predicate string":return Ml(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${t}" not yet supported by snapshot matcher`}}}function Tn(e){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[e.toLowerCase()]??7}function Ls(e,t){const n=e.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(t)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(t)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(t)&&!t.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(t)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(t.startsWith("/hierarchy")||t.startsWith("/")&&!t.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(t))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const i=(t.match(/\//g)||[]).length;return i>7?{level:"fragile",reason:`${i}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:t.includes("@content-desc")||t.includes("@resource-id")||t.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?t.includes("resourceId")||t.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:t.includes("textContains")||t.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function zi(e){return[...e].sort((t,n)=>Tn(t.strategy)-Tn(n.strategy))}const Xt=e=>e===!0||e==="true",$l=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,zl=/(EditText|AutoCompleteTextView)$/;function Ii(e){const t=e.attributes||{};return Xt(t.clickable)||Xt(t["long-clickable"])||Xt(t.checkable)||Xt(t.scrollable)||zl.test(e.type||"")||$l.test(e.type||"")}function Il(e){const t=e.attributes||{};return String(e.text||t["content-desc"]||e.label||t.label||t.name||"").trim()}function _l(e,t){const n="Unique locator",i=zi(e.suggestedLocators||[]),r=i[0];if(!r)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const a=Ds(t.hierarchy,r.strategy,r.value),o=`${r.strategy} ${r.value}`;if(a.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${r.strategy} locators here`};const d=g=>g.length===1&&g[0].xpath===e.xpath;if(d(a.nodes))return{id:"unique",label:n,status:"pass",detail:`${o} matches only this element`};const c=i.slice(1).find(g=>{const f=Ds(t.hierarchy,g.strategy,g.value);return f.kind==="matched"&&d(f.nodes)}),l=c?`; use ${c.strategy} ${c.value} instead`:"",h=a.nodes.length,m=h===0?"matches nothing in this capture":`matches ${h} elements`;return{id:"unique",label:n,status:"fail",detail:`${o} ${m}${l}`}}function Dl(e){const t=zi(e.suggestedLocators||[])[0];if(!t)return null;const{level:n,reason:i}=Ls(t.strategy,t.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:i}}function Ll(e,t){const{screenWidth:n,screenHeight:i}=t.metadata||{screenWidth:0,screenHeight:0};if(!n||!i)return null;const{x:r,y:a,width:o,height:d}=e.rect,c="On screen";return r+o<=0||a+d<=0||r>=n||a>=i?{id:"onscreen",label:c,status:"warn",detail:"Off screen — scroll it into view first"}:r<0||a<0||r+o>n||a+d>i?{id:"onscreen",label:c,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:c,status:"pass",detail:"Fully inside the screen"}}function Ol(e,t){var d,c;const n=Ii(e),i=!(((d=e.attributes)==null?void 0:d.enabled)===!1||((c=e.attributes)==null?void 0:c.enabled)==="false"),r=e.rect.width>0&&e.rect.height>0,a=Il(e);return[_l(e,t),Dl(e),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},i?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},r?{id:"size",label:"Has size",status:"pass",detail:`${e.rect.width} × ${e.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},Ll(e,t),n?a?{id:"name",label:"Accessible name",status:"pass",detail:`“${a.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(l=>l!==null)}function Fl(e){return{pass:e.filter(t=>t.status==="pass").length,warn:e.filter(t=>t.status==="warn").length,fail:e.filter(t=>t.status==="fail").length}}function Pl(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const i=Math.floor(n/60);return i<60?`Captured ${i} min ago`:`Captured ${Math.floor(i/60)} h ago`}function Ul(e,t){return e>0&&t>e}function _i(e){var a,o,d,c,l;const t=(e.type||"").toLowerCase(),n=((a=e.attributes)==null?void 0:a.clickable)==="true"||((o=e.attributes)==null?void 0:o.clickable)===!0,i=((d=e.attributes)==null?void 0:d.scrollable)==="true"||((c=e.attributes)==null?void 0:c.scrollable)===!0,r=((l=e.children)==null?void 0:l.length)||0;return t.includes("button")||t.includes("btn")||n&&r===0?{role:"Button",key:"button"}:t.includes("edit")||t.includes("input")||t.includes("field")?{role:"Text input",key:"input"}:t.includes("image")||t.includes("img")||t.includes("imageview")?{role:"Image",key:"image"}:t.includes("scroll")||t.includes("recyclerview")||t.includes("listview")||i?{role:"Scrollable list",key:"list"}:t.includes("text")||t.includes("label")?{role:"Text label",key:"text"}:t.includes("switch")||t.includes("toggle")||t.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:t.includes("nav")||t.includes("toolbar")||t.includes("tabbar")?{role:"Navigation bar",key:"nav"}:r>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const Di={button:s.jsx(so,{size:13}),input:s.jsx(bo,{size:13}),image:s.jsx(Oa,{size:13}),list:s.jsx(ji,{size:13}),text:s.jsx(Eo,{size:13}),toggle:s.jsx(So,{size:13}),nav:s.jsx(ao,{size:13}),container:s.jsx(mi,{size:13}),element:s.jsx(xa,{size:13})};function Li(e,t){if(!t)return!0;const n=t.toLowerCase().trim(),i={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},r=(e.type||"").toLowerCase(),a=(e.text||e.label||e.value||"").toLowerCase(),o=(e.name||"").toLowerCase(),d=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[c,l]of Object.entries(i))if(n.includes(c)&&l.some(h=>r.includes(h)))return!0;return r.includes(n)||a.includes(n)||o.includes(n)||d.includes(n)}const Le=e=>typeof e=="string"?e.trim():typeof e=="number"?String(e):"";function Bl(e){const t=Le(e),n=t.indexOf(":id/");return n>=0?t.slice(n+4):t}function Oi(e){return(e.type||"").split(".").pop()||""}function is(e){var t;return[e.type,(t=e.attributes)==null?void 0:t["resource-id"],e.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
237
- `)}function pt(e){const t=e.attributes||{};return Le(e.text)||Le(t["content-desc"])||Le(e.label)||Le(t.label)||Bl(t["resource-id"])||Le(t.name)||Oi(e)||"Element"}const Wl=e=>{const t=e.attributes||{};return!!(Le(e.text)||Le(t["content-desc"])||Le(e.label)||Le(t.label))};function Vl(e){var t;return(((t=e.children)==null?void 0:t.length)??0)===1&&!Ii(e)&&!Wl(e)}function Fi(e){const t=[e];let n=e;for(;Vl(n);)n=n.children[0],t.push(n);return t}function Pi(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{var a;Li(r,t)&&n.add(r.xpath),(a=r.children)==null||a.forEach(i)};return i(e),n}function Hl(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{let a=!1;for(const o of r.children||[])i(o)&&(a=!0);return a&&n.add(r.xpath),a||Li(r,t)};return i(e),n}function Kl(e,t,n=""){if(!e)return[];const i=!!n.trim(),r=i?Pi(e,n):null,a=i?Hl(e,n):null,o=l=>!i||l.some(h=>r.has(h.xpath)||a.has(h.xpath)),d=[],c=(l,h,m)=>{const g=l.map(Fi).filter(o);g.forEach((f,v)=>{var y;const S=f[f.length-1],b=(((y=S.children)==null?void 0:y.length)??0)>0,M=i&&a.has(S.xpath),k=b&&(t.has(S.xpath)||M);d.push({key:S.xpath,nodes:f,level:h,setSize:g.length,posInSet:v+1,hasChildren:b,expanded:k,collapsible:k&&!M,parentKey:m}),k&&c(S.children,h+1,S.xpath)})};return c([e],1,null),d}function ql(e,t=3){const n=new Set,i=(r,a)=>{var c;const o=Fi(r),d=o[o.length-1];a>t||!((c=d.children)!=null&&c.length)||(n.add(d.xpath),d.children.forEach(l=>i(l,a+1)))};return e&&i(e,1),n}function ts(e,t){if(!e)return null;if(e.xpath===t)return[e];for(const n of e.children||[]){const i=ts(n,t);if(i)return[e,...i]}return null}function An(e,t){return e.findIndex(n=>n.nodes.some(i=>i.xpath===t))}function Xl(e,t,n){var r;const i=e[t];if(!i)return null;switch(n){case"ArrowDown":return t<e.length-1?{focus:t+1}:null;case"ArrowUp":return t>0?{focus:t-1}:null;case"ArrowRight":return i.hasChildren?i.expanded?((r=e[t+1])==null?void 0:r.parentKey)===i.key?{focus:t+1}:null:{toggle:i.key}:null;case"ArrowLeft":{if(i.collapsible)return{toggle:i.key};const a=e.findIndex(o=>o.key===i.parentKey);return a>=0?{focus:a}:null}case"Home":return{focus:0};case"End":return{focus:e.length-1};case"Enter":case" ":return{select:i.nodes[i.nodes.length-1]};default:return null}}const Yl=10;function Gl({rows:e,selectedXpath:t,hoveredXpath:n,matches:i,onToggle:r,onSelect:a,onHover:o,revealSeq:d=0}){const c=u.useRef(null),[l,h]=u.useState(null),m=u.useRef(0),g=u.useRef(null),f=t?An(e,t):-1,v=l?e.findIndex(x=>x.key===l):-1,S=v>=0?v:Math.max(f,0),b=x=>{var A;return((A=c.current)==null?void 0:A.querySelector(`[data-row="${x}"]`))??null},M=x=>x.nodes[x.nodes.length-1],k=x=>{var T;const A=e[x];if(!A)return;h(A.key),m.current=x;const N=b(x);N==null||N.focus({preventScroll:!0}),(T=N==null?void 0:N.scrollIntoView)==null||T.call(N,{block:"nearest"})};u.useEffect(()=>{g.current=t},[t,d]),u.useEffect(()=>{var N,T;const x=g.current;if(!x)return;const A=An(e,x);A<0||((T=(N=b(A))==null?void 0:N.scrollIntoView)==null||T.call(N,{block:"nearest"}),g.current=null)}),u.useEffect(()=>{var N,T;if(!l||e.some(p=>p.key===l))return;const x=Math.min(m.current,e.length-1),A=!document.activeElement||document.activeElement===document.body;h(((N=e[x])==null?void 0:N.key)??null),A&&x>=0&&((T=b(x))==null||T.focus({preventScroll:!0}))});const y=x=>{const A=x.target;if(A.getAttribute("role")!=="treeitem")return;const N=Xl(e,Number(A.dataset.row),x.key);N&&(x.preventDefault(),"focus"in N?k(N.focus):"toggle"in N?r(N.toggle):a(N.select))},C=x=>{var A;(A=c.current)!=null&&A.contains(x.relatedTarget)||(o(null),h(null))};return s.jsx("div",{ref:c,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:y,onBlur:C,children:e.map((x,A)=>{const N=M(x),T=w=>!!w&&x.nodes.some(L=>L.xpath===w),p=T(t),E=!p&&T(n),_=pt(N),O=Oi(N),D=!!O&&O!==_,V=x.nodes.map(w=>pt(w)).join(", "),Y=D?`${V}, ${O}`:V,Z=x.expanded&&!x.collapsible,W=(w,L)=>`omni-tree-row__part${L?" is-target":""}${i.has(w.xpath)?" is-match":""}${w.xpath===t?" is-current":""}`;return s.jsxs("div",{"data-row":A,role:"treeitem","aria-level":x.level,"aria-setsize":x.setSize,"aria-posinset":x.posInSet,"aria-selected":p,"aria-expanded":x.hasChildren?x.expanded:void 0,"aria-label":Y,tabIndex:A===S?0:-1,className:`omni-tree-row${p?" is-selected":""}${E?" is-hovered":""}`,onClick:()=>a(N),onFocus:w=>{w.target===w.currentTarget&&(h(x.key),m.current=A,o(N))},onMouseEnter:()=>o(N),onMouseLeave:()=>o(null),children:[s.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[s.jsx("span",{className:"omni-tree-row__indent",style:{width:(x.level-1)*Yl}}),s.jsx("span",{className:`omni-tree-row__caret${Z?" is-locked":""}`,onClick:x.hasChildren?w=>{w.stopPropagation(),Z||r(x.key)}:void 0,children:x.hasChildren&&(x.expanded?s.jsx(Cr,{size:12}):s.jsx(Zr,{size:12}))}),s.jsx("span",{className:"omni-tree-row__icon",children:Di[_i(N).key]})]}),s.jsxs("span",{className:"omni-tree-row__label",children:[x.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__head",children:x.nodes.slice(0,-1).map((w,L)=>s.jsxs(ft.Fragment,{children:[L>0&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsx("span",{className:W(w,!1),title:is(w),onClick:H=>{H.stopPropagation(),a(w)},onMouseEnter:()=>o(w),onMouseLeave:()=>o(N),children:pt(w)})]},w.xpath))}),s.jsxs("span",{className:"omni-tree-row__tail",children:[x.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsxs("span",{className:"omni-tree-row__name",children:[s.jsx("span",{className:W(N,!0),title:is(N),children:pt(N)}),D&&s.jsx("span",{className:"omni-tree-row__type",children:O})]})]})]}),x.hasChildren&&!x.expanded&&s.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:N.children.length})]},x.key)})})}const Rn=4;function Jl({path:e,onSelect:t,focusCurrent:n=!1}){const[i,r]=u.useState(!1),a=u.useRef(null),o=u.useRef(null);if(u.useEffect(()=>{var h;n&&((h=o.current)==null||h.focus())},[]),u.useEffect(()=>{var h;i&&((h=a.current)==null||h.focus())},[i]),!e.length)return null;const d=e[e.length-1],c=e.slice(0,-1),l=!i&&c.length>Rn?c.length-Rn:0;return s.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:s.jsxs("ol",{children:[l>0&&s.jsx("li",{children:s.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${c.length} ancestors`,onClick:()=>r(!0),children:"…"})}),c.slice(l).map((h,m)=>s.jsx("li",{children:s.jsx("button",{ref:m===0?a:void 0,type:"button",className:"omni-crumb",title:is(h),"aria-label":pt(h),onClick:()=>t(h),children:pt(h)})},h.xpath)),s.jsx("li",{children:s.jsx("span",{ref:o,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:is(d),children:pt(d)})})]})})}const rs=.4,Zl=240,Ql=340,Mn=.02,as=12,Ui="xenon.omni.split";function Bi(e){if(!(e>0))return{min:0,max:1};const t=Math.min(1,Zl/e);return{min:t,max:Math.max(t,(e-Ql)/e)}}function ec(e,t){const{min:n,max:i}=Bi(t),r=Number.isFinite(e)?e:rs;return Math.min(i,Math.max(n,r))}function tc(e){try{const t=Number.parseFloat((e==null?void 0:e.getItem(Ui))??"");return t>0&&t<1?t:rs}catch{return rs}}function sc(e,t){try{e==null||e.setItem(Ui,String(Math.round(t*1e3)/1e3))}catch{}}function $n(){try{return window.localStorage}catch{return null}}const nc=3;function ic({share:e,limits:t,containerRef:n,onChange:i,onCommit:r,onReset:a}){const[o,d]=u.useState(!1),c=u.useRef(e);c.current=e;const l=u.useRef(!0),h=u.useRef(!1),m=u.useRef(0),g=u.useRef(e),f=k=>Math.min(t.max,Math.max(t.min,k)),v=k=>Math.round(k*100),S=()=>{l.current||(l.current=!0,d(!1),h.current&&r(c.current))},b=k=>{var C;const y=(C=n.current)==null?void 0:C.getBoundingClientRect();return!y||y.width<=as?c.current:f(g.current+(k-m.current)/(y.width-as))},M=k=>{const y=k.key==="ArrowLeft"?e-Mn:k.key==="ArrowRight"?e+Mn:k.key==="Home"?t.min:k.key==="End"?t.max:null;y!==null&&(k.preventDefault(),r(f(Math.round(y*1e3)/1e3)))};return s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":v(e),"aria-valuemin":v(t.min),"aria-valuemax":v(t.max),tabIndex:0,className:`omni-split-divider${o?" is-dragging":""}`,onKeyDown:M,onDoubleClick:a,onPointerDown:k=>{var y,C;(C=(y=k.currentTarget).setPointerCapture)==null||C.call(y,k.pointerId),l.current=!1,h.current=!1,m.current=k.clientX,g.current=c.current,d(!0)},onPointerMove:k=>{if(!o||!h.current&&Math.abs(k.clientX-m.current)<nc)return;const y=b(k.clientX);y!==c.current&&(h.current=!0,i(y))},onPointerUp:k=>{var y,C;(C=(y=k.currentTarget).releasePointerCapture)==null||C.call(y,k.pointerId),S()},onPointerCancel:k=>{var y,C;(C=(y=k.currentTarget).releasePointerCapture)==null||C.call(y,k.pointerId),S()},onLostPointerCapture:S,children:s.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function zn(e,t,n,i){var k,y,C,x,A,N,T;const{strategy:r,value:a}=i,o=(e.text||e.name||((k=e.type)==null?void 0:k.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",d=o.charAt(0).toLowerCase()+o.slice(1),c=((y=e.type)==null?void 0:y.toLowerCase().includes("edit"))||((C=e.type)==null?void 0:C.toLowerCase().includes("input"))||((x=e.type)==null?void 0:x.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),l=((N=e.attributes)==null?void 0:N.scrollable)==="true"||((T=e.attributes)==null?void 0:T.scrollable)===!0,h=r.toLowerCase().startsWith("-ios")&&t!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
238
- `:r.toLowerCase().startsWith("-android")&&t!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
239
- `:"",m={"accessibility id":`~${a}`,id:t==="ios"?`-ios predicate string:label == "${a}"`:`android=new UiSelector().resourceId("${a}")`,xpath:`${a}`,"-ios predicate string":`-ios predicate string:${a}`,"-ios class chain":`-ios class chain:${a}`,"-android uiautomator":`android=${a}`},g={"accessibility id":`AppiumBy.accessibilityId("${a}")`,id:`AppiumBy.id("${a}")`,xpath:`AppiumBy.xpath("${a}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${a}")`,"-ios class chain":`AppiumBy.iOSClassChain("${a}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${a}")`,"class name":`AppiumBy.className("${a}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${a}"`,id:`AppiumBy.ID, "${a}"`,xpath:`AppiumBy.XPATH, "${a}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${a}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${a}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${a}'`,"class name":`AppiumBy.CLASS_NAME, "${a}"`},v=g[r.toLowerCase()],S=f[r.toLowerCase()],b=m[r.toLowerCase()];return n==="java"?v?`${h}// Appium Java Client 9.x + Selenium 4 + TestNG
240
- import io.appium.java_client.AppiumBy;
241
- import io.appium.java_client.${t==="android"?"AndroidDriver":t==="ios"?"IOSDriver":"AppiumDriver"};
242
- import org.openqa.selenium.WebElement;
243
- import org.testng.annotations.Test;
244
-
245
- @Test
246
- public void test_${d}() {
247
- WebElement element = driver.findElement(${v});
248
- ${l?'((Scrollable) element).scrollTo("target text");':c?`element.clear();
249
- element.sendKeys("your text here");`:"element.click();"}
250
- // Add assertions here via TestNG Assert or Hamcrest
251
- }`:`// Strategy "${r}" not supported in Appium Java Client`:n==="python"?S?`${h}# Appium Python Client 4.x + pytest
252
- from appium.webdriver.common.appiumby import AppiumBy
253
- import pytest
254
-
255
- def test_${d}(self):
256
- element = self.driver.find_element(${S})
257
- ${c?`element.clear()
258
- element.send_keys("your text here")`:"element.click()"}
259
- # Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?b?`${h}// WebdriverIO 9.x + @wdio/appium-service
260
- describe('${d} test', () => {
261
- it('should interact with ${d}', async () => {
262
- const element = await $('${b}');
263
- await element.waitForDisplayed({ timeout: 5000 });
264
- ${c?`await element.clearValue();
265
- await element.addValue("your text here");`:"await element.click();"}
266
- // Add assertions here via expect(element)
267
- });
268
- });`:`// Strategy "${r}" not supported in WebdriverIO mobile`:b?`${h}// WebdriverIO 9.x standalone
269
- const element = await driver.$('${b}');
270
- await element.waitForExist({ timeout: 5000 });
271
- ${c?`await driver.$('target').clearValue();
272
- await element.addValue("your text here");`:"await element.click();"}
273
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}const rc={pass:s.jsx(pi,{size:13}),warn:s.jsx(qe,{size:13}),fail:s.jsx(gi,{size:13}),info:s.jsx(ai,{size:13})},ac={pass:"passed",warn:"warning",fail:"failed",info:"note"},oc={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},lc=({sessionId:e,udid:t,streamUrl:n,embedded:i=!1,overlayTarget:r=null,onModeChange:a,deviceActionAt:o=0})=>{var ln,cn,dn,un,hn,mn;const[d,c]=u.useState(!0),[l,h]=u.useState(null),[m,g]=u.useState(null),[f,v]=u.useState(null),[S,b]=u.useState(0),M=u.useRef(!1),[k,y]=u.useState(null),[C,x]=u.useState(()=>new Set),[A,N]=u.useState(""),[T,p]=u.useState(null),[E,_]=u.useState("info"),[O,D]=u.useState(0),[V,Y]=u.useState(0),[Z,W]=u.useState(()=>Date.now()),w=u.useRef(0),L=u.useRef(null),[H,I]=u.useState("java"),[K,ie]=u.useState(null),[X,ne]=u.useState({width:0,height:0}),[re,je]=u.useState({width:0,height:0}),[$,ae]=u.useState(!1),[te,se]=u.useState("inspect");u.useEffect(()=>{a==null||a(te)},[te,a]);const[me,ue]=u.useState({}),[Te,rt]=u.useState({}),[at,Ge]=u.useState(null),[he,Je]=u.useState(null),[Pe,Ce]=u.useState(null),Me=u.useRef(null),ot=u.useRef(null),Ie=u.useRef(null),Ue=u.useRef(null),Ze=u.useRef(null),[bt,Be]=u.useState(()=>tc($n())),[Qe,jt]=u.useState(0);u.useEffect(()=>{const j=Ze.current;if(!j||typeof ResizeObserver>"u")return;const R=new ResizeObserver(([z])=>jt(Math.max(0,z.contentRect.width-as)));return R.observe(j),()=>R.disconnect()},[]);const We=ec(bt,Qe),wt=j=>{Be(j),sc($n(),j)},_e=u.useCallback(()=>{var Ve,He,et;if(!Me.current)return;const j=Me.current.getBoundingClientRect(),R=j.width,z=j.height,P=(Ve=l==null?void 0:l.hierarchy)==null?void 0:Ve.rect;let G=((He=l==null?void 0:l.metadata)==null?void 0:He.screenWidth)||X.width||1,B=((et=l==null?void 0:l.metadata)==null?void 0:et.screenHeight)||X.height||1;P&&P.width>0&&P.height>0&&(G=P.width,B=P.height);const ce=G/B;let De,$e;R/z>ce?($e=z,De=$e*ce):(De=R,$e=De/ce),je({width:De,height:$e})},[l,X]);u.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),u.useEffect(()=>{t&&le()},[t]);const lt=u.useCallback(async(j,R,z)=>{if(he!=null&&he.sessionId){Ge(j);try{const P=await q.verifyLocator(he.basePath,he.sessionId,{strategy:j,selector:R,action:z});rt(G=>({...G,[j]:P})),z==="tap"&&Y(Date.now())}catch(P){rt(G=>({...G,[j]:{found:!1,count:0,error:(P==null?void 0:P.message)||String(P)}}))}finally{Ge(null)}}},[he]),F=u.useRef(null);u.useEffect(()=>{const j=!!f&&f.xpath===F.current;F.current=(f==null?void 0:f.xpath)??null;const R=(f==null?void 0:f.suggestedLocators)??[];ie(z=>{const P=j&&z?R.find(B=>B.strategy===z.strategy):null,G=R.find(B=>B.strategy==="accessibility id"||B.strategy==="id");return P||G||R[0]||null}),ue({}),rt({}),Ce(null)},[f]);const Q=u.useCallback((j,R)=>{if(!(l!=null&&l.hierarchy))return;const z=Ds(l.hierarchy,j,R);ue(P=>({...P,[j]:z})),Ce(j)},[l]),le=async()=>{if(!t)return;const j=++w.current,R=()=>j===w.current;c(!0),g(null),q.getAppiumSession(t).then(z=>{R()&&Je({sessionId:(z==null?void 0:z.sessionId)??null,basePath:(z==null?void 0:z.basePath)??""})}).catch(()=>{R()&&Je({sessionId:null,basePath:""})});try{const z=await q.getInspectorSnapshot(t);if(!R())return;if(!(z!=null&&z.hierarchy)){h(null),g((z==null?void 0:z.error)||"Failed to capture snapshot");return}const P=z.udid||t,G=P===L.current;L.current=P,$s.unstable_batchedUpdates(()=>{h(z),D(Date.now()),x(ql(z.hierarchy)),v(B=>{var ce;return B&&G?((ce=ts(z.hierarchy,B.xpath))==null?void 0:ce.pop())??null:null}),b(B=>B+1)})}catch(z){if(!R())return;h(null),g(z.message||"Failed to capture snapshot")}finally{R()&&c(!1)}};u.useEffect(()=>{const j=setInterval(()=>W(Date.now()),1e4);return()=>clearInterval(j)},[]);const Ne=j=>{const{naturalWidth:R,naturalHeight:z}=j.currentTarget;ne({width:R,height:z})},ee=()=>ae(!0),oe=j=>{ae(!1);const{naturalWidth:R,naturalHeight:z}=j.currentTarget;R>0&&z>0&&ne({width:R,height:z})},fe=n&&!$,pe=j=>{if(te!=="interact"||!t)return;const R=j.currentTarget.getBoundingClientRect();Ue.current={x:j.clientX-R.left,y:j.clientY-R.top,time:Date.now()}},Ae=async j=>{var pn,gn,vn;if(te!=="interact"||!t||!Ue.current)return;const R=Ue.current,z=j.currentTarget.getBoundingClientRect(),P=j.clientX-z.left,G=j.clientY-z.top,B=Date.now()-R.time,ce=re.width,De=re.height,$e=(pn=l==null?void 0:l.hierarchy)==null?void 0:pn.rect;let Ve=((gn=l==null?void 0:l.metadata)==null?void 0:gn.screenWidth)||X.width,He=((vn=l==null?void 0:l.metadata)==null?void 0:vn.screenHeight)||X.height;if($e&&$e.width>0&&$e.height>0&&(Ve=$e.width,He=$e.height),!Ve||!He||ce===0||De===0)return;const et=(Kt,yn)=>({x:Math.round(Kt/ce*Ve),y:Math.round(yn/De*He),px:Kt/ce,py:yn/De}),Ee=et(R.x,R.y),fn=et(P,G),ys=Math.sqrt(Math.pow(P-R.x,2)+Math.pow(G-R.y,2));if(!(Ee.px<0||Ee.px>1||Ee.py<0||Ee.py>1)){try{B<500&&ys<10?await q.tap(t,Ee.x,Ee.y):B>=500&&ys<10?await q.touchAndHold(t,Ee.x,Ee.y,B):ys>=10&&await q.swipe(t,Ee.x,Ee.y,fn.x,fn.y),Y(Date.now())}catch(Kt){console.error("Interaction failed:",Kt)}Ue.current=null}},ge=j=>{x(R=>{const z=new Set(R);return z.has(j)?z.delete(j):z.add(j),z})},we=()=>{const j=new Set,R=z=>{var P;j.add(z.xpath),(P=z.children)==null||P.forEach(R)};l!=null&&l.hierarchy&&R(l.hierarchy),x(j)},ye=()=>x(new Set),ve=(j,R)=>{navigator.clipboard.writeText(j),p(R),setTimeout(()=>p(null),2e3)},ct=j=>{var z;let R=1;return(z=j.children)==null||z.forEach(P=>R+=ct(P)),R},kt=j=>{if(!j)return[];const R={},z=P=>{var B;const G=_i(P);R[G.role]||(R[G.role]={key:G.key,count:0}),R[G.role].count+=1,(B=P.children)==null||B.forEach(z)};return z(j),Object.entries(R).map(([P,G])=>({role:P,key:G.key,count:G.count})).sort((P,G)=>G.count-P.count)},Wt=u.useMemo(()=>Kl(l==null?void 0:l.hierarchy,C,A),[l,C,A]),dt=u.useMemo(()=>Pi(l==null?void 0:l.hierarchy,A),[l,A]),At=dt.size===0?"No matches":dt.size===1?"1 match":`${dt.size} matches`;u.useEffect(()=>{if(!f||!(l!=null&&l.hierarchy))return;const j=ts(l.hierarchy,f.xpath);!j||j.length<2||x(R=>{const z=j.slice(0,-1).filter(G=>!R.has(G.xpath));if(!z.length)return R;const P=new Set(R);return z.forEach(G=>P.add(G.xpath)),P})},[S]),u.useEffect(()=>{M.current=!1});const Rt=j=>{v(j),b(R=>R+1),_("info")},br=j=>{M.current=!0,Rt(j)},nn=j=>{A.trim()&&!j.trim()&&b(R=>R+1),N(j)},fs=()=>{var P,G,B;const j=(P=l==null?void 0:l.hierarchy)==null?void 0:P.rect;if(j&&j.width>0&&j.height>0)return{w:j.width,h:j.height};const R=((G=l==null?void 0:l.metadata)==null?void 0:G.screenWidth)||X.width,z=((B=l==null?void 0:l.metadata)==null?void 0:B.screenHeight)||X.height;return R>0&&z>0?{w:R,h:z}:null},rn=j=>{const R=fs();if(!R)return[];const z=[],{w:P,h:G}=R,B=(ce,De)=>{var Ve,He,et;const $e=!ce.children||ce.children.length===0;((Ve=ce.rect)==null?void 0:Ve.width)>0&&((He=ce.rect)==null?void 0:He.height)>0&&$e&&z.push(s.jsx("div",{className:"omni-hit-area",style:{left:`${ce.rect.x/P*100}%`,top:`${ce.rect.y/G*100}%`,width:`${ce.rect.width/P*100}%`,height:`${ce.rect.height/G*100}%`,zIndex:De},onClick:Ee=>{Ee.stopPropagation(),Rt(ce)},onMouseEnter:()=>y(ce),onMouseLeave:()=>y(null)},ce.xpath)),(et=ce.children)==null||et.forEach(Ee=>B(Ee,De+1))};return l!=null&&l.hierarchy&&B(l.hierarchy,1),z},an=()=>{const j=fs();if(!Pe||!j)return[];const R=me[Pe];if(!R||R.kind!=="matched"||R.nodes.length===0)return[];const{w:z,h:P}=j,G=R.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return R.nodes.filter(B=>B.rect&&B.rect.width>0&&B.rect.height>0).map((B,ce)=>s.jsx("div",{className:G,style:{left:`${B.rect.x/z*100}%`,top:`${B.rect.y/P*100}%`,width:`${B.rect.width/z*100}%`,height:`${B.rect.height/P*100}%`}},`match-${Pe}-${ce}`))},Vt=(j,R)=>{const z=fs();if(!(j!=null&&j.rect)||!z)return null;const{w:P,h:G}=z;return s.jsx("div",{className:`omni-frame-${R}`,style:{left:`${j.rect.x/P*100}%`,top:`${j.rect.y/G*100}%`,width:`${j.rect.width/P*100}%`,height:`${j.rect.height/G*100}%`}})},ps=l!=null&&l.hierarchy?ct(l.hierarchy):0,Ht=f&&(l!=null&&l.hierarchy)?Ol(f,l):null,ut=Ht?Fl(Ht):null,gs=Ul(O,Math.max(o,V)),vs=l!=null&&l.hierarchy&&te==="inspect"?s.jsxs("div",{className:`omni-overlay${gs?" is-stale":""}`,children:[rn(l.hierarchy),an(),Vt(k,"hover"),Vt(f,"select")]}):null,jr={stable:{icon:s.jsx(qt,{size:10}),cls:"stable"},moderate:{icon:s.jsx(qe,{size:10}),cls:"moderate"},fragile:{icon:s.jsx(St,{size:10}),cls:"fragile"},"very-fragile":{icon:s.jsx(St,{size:10}),cls:"very-fragile"}},on=i&&(l!=null&&l.hierarchy)?kt(l.hierarchy):[];return s.jsxs("div",{className:`omni-inspector-container ${i?"omni-embedded":""}`,children:[i&&r&&vs?$s.createPortal(vs,r):null,s.jsxs("div",{className:"omni-main-content",children:[!i&&s.jsxs("div",{className:"omni-screenshot-panel",children:[s.jsxs("div",{className:"omni-screenshot-header",children:[s.jsxs("div",{className:"omni-header-left",children:[s.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),s.jsxs("div",{className:"omni-mode-toggle",children:[s.jsxs("button",{className:`omni-mode-btn ${te==="inspect"?"active":""}`,onClick:()=>se("inspect"),title:"Inspection mode (highlight elements)",children:[s.jsx(wn,{size:12}),s.jsx("span",{children:"Inspect"})]}),s.jsxs("button",{className:`omni-mode-btn ${te==="interact"?"active":""}`,onClick:()=>se("interact"),title:"Interaction mode (direct control)",children:[s.jsx(Nn,{size:12}),s.jsx("span",{children:"Interact"})]})]})]}),s.jsxs("button",{className:"omni-refresh-btn",onClick:le,disabled:d,children:[s.jsx(Dt,{size:12,className:d?"animate-spin":""}),d?"Capturing...":"Refresh"]})]}),s.jsxs("div",{className:"omni-screenshot-container",ref:Me,children:[d&&!fe&&s.jsxs("div",{className:"omni-loading-overlay",children:[s.jsx("div",{className:"omni-spinner"}),s.jsx("span",{children:"Capturing screen..."})]}),!l&&!d&&!fe&&s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(bs,{size:40}),s.jsx("span",{children:"Click Refresh to capture"})]}),fe&&s.jsxs("div",{className:`omni-screenshot-wrapper ${te==="interact"?"interactable":""}`,onMouseDown:pe,onMouseUp:Ae,children:[s.jsx(li,{ref:Ie,src:n,onLoad:oe,onError:ee,className:"omni-screenshot-img",style:te==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),vs]}),!fe&&(l==null?void 0:l.screenshot)&&s.jsxs("div",{className:`omni-screenshot-wrapper ${te==="interact"?"interactable":""}`,onMouseDown:pe,onMouseUp:Ae,children:[s.jsx("img",{ref:ot,src:`data:image/png;base64,${l.screenshot}`,onLoad:Ne,className:"omni-screenshot-img",style:te==="interact"?{pointerEvents:"none"}:{},draggable:!1}),te==="inspect"&&s.jsxs("div",{className:`omni-overlay${gs?" is-stale":""}`,children:[rn(l.hierarchy),an(),Vt(k,"hover"),Vt(f,"select")]})]})]})]}),s.jsxs("div",{className:"omni-split",ref:Ze,children:[s.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${We*100}% - ${We*as}px)`},children:[s.jsxs("div",{className:"omni-tree-header",children:[s.jsxs("div",{className:"omni-tree-title",children:[s.jsx(mi,{size:14}),s.jsx("span",{children:"Source"})]}),s.jsxs("div",{className:"omni-tree-actions",children:[s.jsx("button",{onClick:we,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:s.jsx(Ca,{size:12})}),s.jsx("button",{onClick:ye,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:s.jsx(ka,{size:12})}),i&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>se(te==="inspect"?"interact":"inspect"),className:`omni-action-btn ${te==="inspect"?"active":""}`,title:te==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":te==="inspect"?"Inspect mode":"Interact mode","aria-pressed":te==="inspect",children:te==="inspect"?s.jsx(wn,{size:12}):s.jsx(Nn,{size:12})}),s.jsx("button",{onClick:le,className:"omni-action-btn",title:d?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:d,children:s.jsx(Dt,{size:12,className:d?"animate-spin":""})})]})]})]}),m&&!d&&s.jsxs("div",{className:"omni-tree-error",role:"alert",children:[s.jsx(St,{size:12}),s.jsx("span",{children:m}),s.jsx("button",{type:"button",onClick:le,className:"omni-tree-error-retry",children:"Retry"})]}),l&&!d&&!m&&(gs?s.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[s.jsx(qe,{size:12,"aria-hidden":"true"}),s.jsx("span",{children:"The screen may have changed since this capture."}),s.jsx("button",{type:"button",onClick:le,className:"omni-capture-refresh",children:"Refresh"})]}):s.jsxs("div",{className:"omni-capture-meta",children:[s.jsxs("span",{children:[ps," ",ps===1?"element":"elements"]}),l.hierarchySource&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"omni-capture-source",title:l.hierarchySource==="appium-session"?`From Appium session ${l.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:l.hierarchySource==="appium-session"?"Session":"Device"})]}),s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{children:Pl(O,Z)})]})),s.jsxs("div",{className:"omni-tree-search",children:[s.jsx(Hs,{size:14}),s.jsx("input",{type:"text",placeholder:"Search elements",value:A,onChange:j=>nn(j.target.value),"aria-label":"Search elements"}),A&&s.jsx("button",{onClick:()=>nn(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),s.jsx("div",{role:"status",className:"sr-only",children:A.trim()?At:""}),A.trim()&&s.jsxs("div",{className:"omni-search-hint",children:[At," · try a role: button, input, image"]}),s.jsx("div",{className:"omni-tree-content",children:l!=null&&l.hierarchy?s.jsx(Gl,{rows:Wt,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(k==null?void 0:k.xpath)??null,matches:dt,onToggle:ge,onSelect:Rt,onHover:y,revealSeq:S}):s.jsx("div",{className:"omni-empty-state small",children:s.jsx("span",{children:"No hierarchy loaded"})})})]}),s.jsx(ic,{share:We,limits:Bi(Qe),containerRef:Ze,onChange:Be,onCommit:wt,onReset:()=>wt(rs)}),s.jsxs("div",{className:"omni-details-panel",children:[s.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[s.jsxs("button",{className:`omni-details-tab ${E==="info"?"active":""}`,onClick:()=>_("info"),role:"tab","aria-selected":E==="info",children:[s.jsx(Ka,{size:12})," ",s.jsx("span",{children:"Info"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="checks"?"active":""}`,onClick:()=>_("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":E==="checks",children:[s.jsx(Jr,{size:12})," ",s.jsx("span",{children:"Checks"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="code"?"active":""}`,onClick:()=>_("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":E==="code",children:[s.jsx(Cn,{size:12})," ",s.jsx("span",{children:"Code gen"})]})]}),s.jsx("div",{className:"omni-details-content",children:f?s.jsxs(s.Fragment,{children:[E==="info"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Element info"}),s.jsxs("div",{className:"omni-info-table",children:[s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Type"}),s.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Text"}),s.jsx("span",{className:"omni-info-value",children:f.text})]}),s.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[s.jsx("span",{className:"omni-info-key",children:"Path"}),s.jsx(Jl,{path:(l==null?void 0:l.hierarchy)&&ts(l.hierarchy,f.xpath)||[f],onSelect:br,focusCurrent:M.current},f.xpath)]})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Layout"}),s.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(j=>s.jsxs("div",{className:"omni-layout-item",children:[s.jsx("span",{className:"omni-layout-label",children:j.toUpperCase()}),s.jsx("span",{className:"omni-layout-value",children:f.rect[j]})]},j))})]}),s.jsxs("div",{className:"omni-section",children:[s.jsxs("div",{className:"omni-section-header",children:["Locators",s.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(he!=null&&he.sessionId)&&((dn=f.suggestedLocators)==null?void 0:dn.length)>0&&s.jsxs("p",{className:"omni-locators-note",children:[s.jsx(ai,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),s.jsxs("div",{className:"omni-locators-list",children:[!((un=f.suggestedLocators)!=null&&un.length)&&s.jsx("div",{className:"omni-locators-empty",children:f===(l==null?void 0:l.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),(hn=f.suggestedLocators)==null?void 0:hn.map(j=>{const R=Ls(j.strategy,j.value),z=jr[R.level],P=me[j.strategy];let G=null;return P&&(P.kind==="unsupported"?G=s.jsxs("span",{className:"omni-match-badge unsupported",title:P.reason||"Cannot evaluate without a real driver",children:[s.jsx(yi,{size:10})," preview unavailable"]}):P.nodes.length===0?G=s.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[s.jsx(St,{size:10})," 0 matches"]}):P.nodes.length===1?G=s.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[s.jsx(qt,{size:10})," unique"]}):G=s.jsxs("span",{className:"omni-match-badge multi",title:`${P.nodes.length} elements match — selector is not unique`,children:[s.jsx(qe,{size:10})," ",P.nodes.length," matches"]})),s.jsx("div",{className:`omni-locator-row ${(K==null?void 0:K.strategy)===j.strategy?"selected-for-code":""}`,onClick:()=>ie(j),title:"Click to use in Code gen",children:s.jsxs("div",{className:"omni-locator-left",children:[s.jsxs("div",{className:"omni-locator-top",children:[s.jsx("span",{className:"omni-locator-strategy",children:j.strategy}),s.jsxs("span",{className:`omni-stability-badge ${z.cls}`,title:R.reason,children:[z.icon,R.level]}),G]}),s.jsx("code",{className:"omni-locator-value",children:j.value}),s.jsx("span",{className:"omni-stability-reason",children:R.reason}),(()=>{const B=Te[j.strategy];return B?B.error?s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(St,{size:10})," Appium error: ",B.error]}):B.found?B.count>1?s.jsxs("span",{className:"omni-verify-line is-warn",children:[s.jsx(qe,{size:10})," Ambiguous — Appium found"," ",B.count," elements",B.actionError?` · ${B.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-ok",children:[s.jsx(qt,{size:10})," Appium found 1 element",B.elapsedMs!=null?` in ${B.elapsedMs}ms`:"",B.actionPerformed&&B.actionPerformed!=="none"?` · ${B.actionPerformed} ok`:"",B.actionError?` · action failed: ${B.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(St,{size:10})," Appium found 0 elements"]}):null})(),s.jsxs("div",{className:"omni-locator-actions",children:[s.jsxs(U,{type:"button",variant:Pe===j.strategy?"tonal":"secondary",size:"sm",onClick:B=>{B.stopPropagation(),Q(j.strategy,j.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[s.jsx(Ma,{size:12,"aria-hidden":"true"}),"Test"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",disabled:!(he!=null&&he.sessionId)||at===j.strategy,onClick:B=>{B.stopPropagation(),lt(j.strategy,j.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[at===j.strategy?s.jsx(Dt,{size:12,className:"animate-spin","aria-hidden":"true"}):s.jsx(qt,{size:12,"aria-hidden":"true"}),"Verify"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",disabled:!(he!=null&&he.sessionId)||at===j.strategy,onClick:B=>{B.stopPropagation(),lt(j.strategy,j.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[s.jsx(fi,{size:12,"aria-hidden":"true"}),"Tap"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:B=>{B.stopPropagation(),ve(j.value,j.strategy)},title:"Copy the locator's value","aria-label":T===j.strategy?"Copied":"Copy locator",children:[T===j.strategy?s.jsx(Ot,{size:12,"aria-hidden":"true"}):s.jsx(Oe,{size:12,"aria-hidden":"true"}),T===j.strategy?"Copied":"Copy"]})]})]})},j.strategy)})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Attributes"}),s.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([j,R])=>R!=null&&R!=="").map(([j,R])=>s.jsxs("div",{className:"omni-attr-row",children:[s.jsx("span",{className:"omni-attr-key",children:j}),s.jsx("span",{className:"omni-attr-value",children:String(R)})]},j))})]})]}),E==="checks"&&Ht&&ut&&s.jsxs("div",{className:"omni-checks-panel",children:[s.jsxs("p",{className:"omni-checks-summary",children:[s.jsxs("span",{className:"is-pass",children:[s.jsx(pi,{size:12,"aria-hidden":"true"})," ",ut.pass," passed"]}),ut.warn>0&&s.jsxs("span",{className:"is-warn",children:[s.jsx(qe,{size:12,"aria-hidden":"true"})," ",ut.warn," ",ut.warn===1?"warning":"warnings"]}),ut.fail>0&&s.jsxs("span",{className:"is-fail",children:[s.jsx(gi,{size:12,"aria-hidden":"true"})," ",ut.fail," failed"]})]}),s.jsx("ul",{className:"omni-checks-list",children:Ht.map(j=>s.jsxs("li",{className:`omni-check is-${j.status}`,children:[s.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:rc[j.status]}),s.jsxs("div",{className:"omni-check-body",children:[s.jsxs("div",{className:"omni-check-label",children:[j.label,s.jsxs("span",{className:"sr-only",children:[": ",ac[j.status]]})]}),s.jsx("div",{className:"omni-check-detail",children:j.detail})]})]},j.id))})]}),E==="code"&&s.jsxs("div",{className:"omni-codegen-panel",children:[s.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(j=>s.jsx("button",{className:`omni-fw-btn ${H===j?"active":""}`,onClick:()=>I(j),children:oc[j]},j))}),K?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-codegen-locator-selector",children:[s.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),s.jsx(di,{selectSize:"sm",value:K.strategy,onChange:j=>{var z;const R=(z=f.suggestedLocators)==null?void 0:z.find(P=>P.strategy===j.target.value);R&&ie(R)},className:"flex-1",children:(mn=f.suggestedLocators)==null?void 0:mn.map(j=>s.jsxs("option",{value:j.strategy,children:[j.strategy," — ",Ls(j.strategy,j.value).level]},j.strategy))})]}),s.jsxs("div",{className:"omni-codegen-output",children:[s.jsxs("div",{className:"omni-codegen-header",children:[s.jsx("span",{className:"omni-codegen-lang",children:H==="java"?"Java / TestNG":H==="python"?"Python / unittest":H==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),s.jsx("button",{className:"omni-copy-btn",onClick:()=>ve(zn(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",H,K),"code"),children:T==="code"?s.jsx(Ot,{size:12}):s.jsx(Oe,{size:12})})]}),s.jsx("pre",{className:"omni-codegen-pre theme-dark",children:s.jsx("code",{children:zn(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",H,K)})})]})]}):s.jsxs("div",{className:"omni-empty-state small",children:[s.jsx(Cn,{size:24}),s.jsx("span",{children:"No locators available for this element"})]})]})]}):l!=null&&l.hierarchy?s.jsxs("div",{className:"omni-summary-panel",children:[s.jsxs("div",{className:"omni-summary-hero",children:[s.jsx(bs,{size:28}),s.jsxs("div",{children:[s.jsx("div",{className:"omni-summary-title",children:"No element selected"}),s.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),s.jsxs("div",{className:"omni-summary-stats",children:[s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),s.jsx("span",{className:"omni-summary-stat__value",children:ps})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),s.jsx("span",{className:"omni-summary-stat__value",children:((ln=l.metadata)==null?void 0:ln.screenWidth)??X.width??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),s.jsx("span",{className:"omni-summary-stat__value",children:((cn=l.metadata)==null?void 0:cn.screenHeight)??X.height??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),s.jsx("span",{className:"omni-summary-stat__value",children:l.platform||"—"})]})]})]}),on.length>0&&s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"By role"}),s.jsx("div",{className:"omni-summary-roles",children:on.slice(0,8).map(j=>s.jsxs("div",{className:"omni-summary-role",children:[s.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:Di[j.key]}),s.jsx("span",{className:"omni-summary-role__name",children:j.role}),s.jsx("span",{className:"omni-summary-role__count",children:j.count})]},j.role))})]})]}):s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(bs,{size:32}),s.jsx("span",{children:d?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},In=5e3;function cc(e,t=!0){const[n,i]=u.useState("unknown"),r=u.useRef("unknown");return u.useEffect(()=>{if(!e||!t){i("unknown"),r.current="unknown";return}let a=!1,o;const d=h=>{a||h===r.current||(r.current=h,i(h))},c=async()=>{if(!a){if(o&&(clearTimeout(o),o=void 0),typeof document<"u"&&document.visibilityState==="hidden"){o=setTimeout(c,In);return}try{const h=await q.getDisplayState(e);d((h==null?void 0:h.state)??"unknown")}catch{}a||(o=setTimeout(c,In))}};c();const l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{a=!0,o&&clearTimeout(o),document.removeEventListener("visibilitychange",l)}},[e,t]),n}function dc(e,t){const n=u.useRef(e),i=u.useRef(t);n.current=e,i.current=t,u.useEffect(()=>{const r=()=>n.current(),a=o=>{var d;o.persisted&&((d=i.current)==null||d.call(i))};return window.addEventListener("pagehide",r),window.addEventListener("pageshow",a),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",a)}},[])}const uc=/^(INPUT|TEXTAREA|SELECT)$/,Gs=u.createContext(null);function hc(e){const t=u.useContext(Gs),n=u.useRef(e);n.current=e;const i=e!==null;u.useEffect(()=>{if(!(!t||!i))return t.register(()=>{var r;return((r=n.current)==null?void 0:r.call(n))??!1})},[t,i])}function Wi(e){const t=u.useContext(Gs),n=u.useRef(e);return n.current=e,u.useCallback(()=>t?t.close():n.current(),[t])}function mc({labelledBy:e,onClose:t,children:n,style:i,...r}){const a=u.useRef(null),o=u.useRef(t);o.current=t;const d=u.useMemo(()=>{const l=new Set;return{register(h){return l.add(h),()=>{l.delete(h)}},close(){for(const h of Array.from(l))if(h())return;o.current()}}},[]),c=u.useRef(d);return u.useEffect(()=>{const l=a.current;if(!l)return;const h=document.activeElement,m=[];for(let f=l;f.parentElement&&f!==document.body;f=f.parentElement)for(const v of Array.from(f.parentElement.children))v===f||v.hasAttribute("inert")||v.matches("[aria-live], script, style, link, template")||(v.setAttribute("inert",""),m.push(v));l.contains(document.activeElement)||l.focus();const g=f=>{if(f.key!=="Escape"||f.defaultPrevented)return;const v=f.target;uc.test(v.tagName)||v.isContentEditable||(f.preventDefault(),c.current.close())};return l.addEventListener("keydown",g),()=>{l.removeEventListener("keydown",g),m.forEach(f=>f.removeAttribute("inert")),h&&h.isConnected&&h!==document.body&&h.focus()}},[]),s.jsx("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,style:{outline:"none",...i},...r,children:s.jsx(Gs.Provider,{value:d,children:n})})}const Vi="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Js(e){var t;try{return(t=navigator.clipboard)!=null&&t.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}const _n=5e3,fc=500,pc=1e4,gc=10,vc=50;function yc(e,t,n){const i=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,a]=u.useState([]),[o,d]=u.useState(!1),[c,l]=u.useState(null),[h,m]=u.useState(!1),g=u.useRef(null),f=u.useRef(0),v=u.useRef(void 0),S=u.useRef(()=>{}),b=u.useRef([]),M=u.useRef(void 0),k=u.useRef(0),y=u.useRef(void 0),C=u.useCallback(()=>{if(b.current.length===0)return;const T=b.current;b.current=[],a(p=>{const E=p.concat(T);return E.length>_n?E.slice(-_n):E})},[]),x=u.useCallback(()=>{M.current===void 0&&(M.current=window.setTimeout(()=>{M.current=void 0,C()},vc))},[C]),A=u.useCallback(()=>{b.current=[],a([])},[]);u.useEffect(()=>{if(!t){d(!1),l(null),m(!1);return}l(null),m(!1),f.current=0;const T={cancelled:!1},p=()=>{if(T.cancelled)return;if(f.current>=gc){m(!0);return}const _=Math.min(fc*2**f.current,pc);f.current+=1,v.current=window.setTimeout(E,_)},E=async()=>{if(!T.cancelled)try{const _=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if(T.cancelled)return;if(!_.ok){p();return}const{ticket:O}=await _.json();if(T.cancelled)return;if(!O){p();return}const D=window.location.protocol==="https:"?"wss":"ws",[V,Y]=i.split("|"),Z=(V?`&levels=${encodeURIComponent(V)}`:"")+(Y?`&process=${encodeURIComponent(Y)}`:""),W=new WebSocket(`${D}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(O)}${Z}`);g.current=W,W.onopen=()=>{f.current=0,y.current!==1012&&(b.current=[],a([])),y.current=void 0,d(!0)},W.onmessage=w=>{try{const L=JSON.parse(w.data);b.current.push({...L,seq:k.current++}),x()}catch{}},W.onclose=w=>{if(d(!1),y.current=w.code,C(),w.code===1008){T.cancelled=!0,l(w.reason||"access denied");return}if(w.code===1012){p();return}console.warn(`[logcat] WS closed unexpectedly (code ${w.code}) — retrying`),p()},W.onerror=()=>W.close()}catch{p()}};return S.current=()=>{T.cancelled=!1,f.current=0,l(null),m(!1),E()},E(),()=>{var _;T.cancelled=!0,v.current!==void 0&&window.clearTimeout(v.current),M.current!==void 0&&(window.clearTimeout(M.current),M.current=void 0),C(),(_=g.current)==null||_.close(),g.current=null}},[e,t,i,C,x]);const N=u.useCallback(()=>{S.current()},[]);return{records:r,connected:o,clear:A,deniedReason:c,exhausted:h,retry:N}}const Ut=["V","D","I","W","E","F"];function xc(e){const t=[];let n="",i=!1,r=!1;for(const a of e){if(a==='"'){i=!i,r=!0;continue}if(!i&&/\s/.test(a)){(r||n)&&t.push(n),n="",r=!1;continue}n+=a,r=!0}return(r||n)&&t.push(n),t.filter(a=>a.length>0)}function Hi(e,t={}){const n=t.caseSensitive===!0,i=o=>n?o:o.toLowerCase(),r=n?{caseSensitive:!0}:{},a=[];for(const o of xc(e)){const[d,...c]=o.split(":"),l=c.join(":"),h=d.toLowerCase();l&&h==="level"?r.minLevel=l.toUpperCase():l&&h==="tag"?r.tag=i(l):l&&h==="package"?r.pkg=i(l):l&&h==="-tag"?(r.excludeTags=r.excludeTags||[]).push(i(l)):l&&h==="-package"?(r.excludePkgs=r.excludePkgs||[]).push(i(l)):a.push(o)}return a.length&&(r.text=i(a.join(" "))),r}function Ki(e,t){if(e.synthetic)return!0;if(t.minLevel){const i=Ut.indexOf(t.minLevel),r=Ut.indexOf(e.level);if(i>=0&&r>=0&&r<i)return!1}const n=i=>t.caseSensitive?i:i.toLowerCase();if(t.tag&&!n(e.tag).includes(t.tag)||t.pkg&&!n(e.pkg??"").includes(t.pkg)||t.text&&!n(e.message).includes(t.text))return!1;if(t.excludeTags){const i=n(e.tag);if(t.excludeTags.some(r=>i.includes(r)))return!1}if(t.excludePkgs){const i=n(e.pkg??"");if(i&&t.excludePkgs.some(r=>i.includes(r)))return!1}return!0}function qi(e){const t=[];let n="",i=!1;for(const r of e){if(r==='"'&&(i=!i),!i&&/\s/.test(r)){n&&t.push(n),n="";continue}n+=r}return n&&t.push(n),t}function Xi(e){const[t,...n]=e.replace(/"/g,"").split(":");return{key:t.toLowerCase(),value:n.join(":")}}function Yi(e){const t=e.split('"').map(n=>n.trim()).reduce((n,i)=>i.length>n.length?i:n,"");return/\s/.test(t)?`"${t}"`:t}function Dn(e,t,n){const i=Yi(n);if(!i)return e;const r=`${t}:${i}`,a=[];let o=!1;for(const d of qi(e)){const c=Xi(d);if(c.key===t&&c.value){o||a.push(r),o=!0;continue}a.push(d)}return o||a.push(r),a.join(" ")}function bc(e,t,n){const i=Yi(n);if(!i)return e;const r=i.replace(/"/g,""),a=qi(e);return a.some(d=>{const c=Xi(d);return c.key===`-${t}`&&c.value===r})?e:[...a,`-${t}:${i}`].join(" ")}function jc(e,t){const n=e.trim().split(/\s+/).filter(Boolean).filter(i=>{const[r,...a]=i.split(":");return!(a.join(":")&&r.toLowerCase()==="level")});return t?["level:"+t.toUpperCase(),...n].join(" "):n.join(" ")}const Ss=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],Ln=["V","D","I","W","E","F"];function wc(e){if(!e)return Ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const t=Ln.indexOf(e.toUpperCase());return t<0?Ss.map(n=>n.ios):Ss.filter(n=>Ln.indexOf(n.android)>=t).map(n=>n.ios)}function kc(e){const t=Hi(e,{caseSensitive:!0});return{levels:wc(t.minLevel),process:t.pkg||void 0}}const On=Ut,Sc={V:"Verbose",D:"Debug",I:"Info",W:"Warning",E:"Error",F:"Fatal"};function Cc(e,t){const n={V:0,D:0,I:0,W:0,E:0,F:0},i={...t,minLevel:void 0};for(let r=0;r<e.length;r++){const a=e[r];a.synthetic||Object.prototype.hasOwnProperty.call(n,a.level)&&Ki(a,i)&&(n[a.level]+=1)}return n}function Nc(e,t,n){return(e==="ios"?["D","I","E","F"]:t.F>0||(n||"").toUpperCase()==="F"?["V","D","I","W","E","F"]:["V","D","I","W","E"]).map(r=>({level:r,name:Gi(r,e)}))}function Ec(e,t){if(!t)return null;const n=On.indexOf(t.toUpperCase());if(n<0)return null;const i=e.find(r=>On.indexOf(r.level)>=n);return i?i.level:null}function Gi(e,t){return e==="F"?t==="ios"?"Fault":"Fatal":Sc[e]??e}const Os=5e5;function os(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function Tc(e){return{lines:[],startedAt:e,dropped:0}}function Ac(e,t){for(const n of t){if(e.lines.length>=Os){e.dropped+=1;continue}e.lines.push(os(n))}return e}function Rc(e,t,n){const i=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(t).toISOString()}`,`# duration: ${((t-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&i.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${Os}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
274
- `),a=e.dropped>0?`
275
- # --- TRUNCATED: ${e.dropped} line(s) not captured (cap ${Os}) ---`:"";return`${i.join(`
276
- `)}
277
-
278
- ${r}${a}
279
- `}function Mc(e,t){const n=new Date(t).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const Cs={selected:new Set,anchor:null,active:null};function Ji(e,t,n){const i=e.indexOf(t),r=e.indexOf(n);return i<0||r<0?null:e.slice(Math.min(i,r),Math.max(i,r)+1)}function Zi(e){return{selected:new Set([e]),anchor:e,active:e}}function $c(e,t,n,i){if(i.range&&e.anchor!==null){const r=Ji(n,e.anchor,t);if(r)return{selected:new Set(r),anchor:e.anchor,active:t}}if(i.toggle){const r=new Set(Array.from(e.selected));return r.has(t)?r.delete(t):r.add(t),{selected:r,anchor:t,active:t}}return Zi(t)}function zc(e,t,n,i){if(!t.length)return e;const r=e.active===null?-1:t.indexOf(e.active),a=r<0?n===1?0:t.length-1:Math.max(0,Math.min(t.length-1,r+n)),o=t[a];if(!i)return Zi(o);const d=e.anchor!==null&&t.indexOf(e.anchor)>=0?e.anchor:e.active??o,c=Ji(t,d,o)??[o];return{selected:new Set(c),anchor:d,active:o}}function Ic(e,t){const n=[];if(t.size)for(let i=0;i<e.length;i++)t.has(e[i].seq)&&n.push(os(e[i]));return{text:n.join(`
280
- `),count:n.length}}const Qi=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"});function st(e){return e.toLocaleString("en-US")}function _c(e){return Qi.format(e)}function Dc(e){const t=(Math.floor(e)%1e3+1e3)%1e3;return`${Qi.format(e)}.${String(t).padStart(3,"0")}`}const Lc=[["tag:Wifi","lines whose tag contains Wifi"],["package:com.example","lines from that app"],["level:W","warnings and above"],["-tag:chatty","hide a tag"]];function Oc(e){const t=u.useRef(null),n=u.useRef(null),i=u.useRef(null),[r,a]=u.useState(!1),[o,d]=u.useState(!1);u.useEffect(()=>{var m,g;o&&((g=(m=i.current)==null?void 0:m.querySelector('[role^="menuitem"]:not(:disabled)'))==null||g.focus())},[o]);const c=()=>{var m;d(!1),(m=n.current)==null||m.focus()},l=m=>()=>{c(),m()},h=e.status==="Offline"||e.status==="Denied";return s.jsxs("div",{className:"log-toolbar",children:[s.jsxs("div",{className:"log-status",role:"status",title:e.statusDetail??void 0,children:[s.jsx("span",{className:`log-live-dot${e.status==="Live"?" active":""}${h?" is-error":""}`,"aria-hidden":"true"}),e.status]}),s.jsxs("div",{className:"log-filter",children:[s.jsx(kn,{ref:e.filterRef,type:"text",className:"log-field log-filter-input",placeholder:"tag:Wifi package:com.example text",value:e.query,onChange:m=>e.onQueryChange(m.target.value),"aria-label":"Filter logs",spellCheck:!1,autoComplete:"off"}),s.jsxs("span",{className:"log-field-buttons",children:[e.query&&s.jsx("button",{type:"button",className:"log-field-btn",onClick:()=>e.onQueryChange(""),"aria-label":"Clear filter",title:"Clear filter",children:s.jsx(Vs,{size:12,"aria-hidden":"true"})}),s.jsx("button",{ref:t,type:"button",className:"log-field-btn",onClick:()=>a(m=>!m),"aria-label":"Filter syntax","aria-haspopup":"dialog","aria-expanded":r,title:"Filter syntax",children:s.jsx(yi,{size:13,"aria-hidden":"true"})})]}),s.jsx(ss,{open:r,onClose:()=>a(!1),anchorRef:t,placement:"bottom-start",children:s.jsxs("div",{className:"log-syntax",children:[s.jsxs("p",{children:["Terms are combined. Quote a value with spaces: ",s.jsx("code",{children:'package:"Food Truck"'}),"."]}),s.jsx("dl",{children:Lc.map(([m,g])=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:m})}),s.jsx("dd",{children:g})]},m))}),s.jsx("p",{children:"Other words search the message."})]})})]}),s.jsxs("div",{className:"log-find",children:[s.jsx(kn,{ref:e.findRef,type:"text",className:"log-field log-find-input",placeholder:"Find",value:e.find,onChange:m=>e.onFindChange(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),e.onStep(m.shiftKey?-1:1))},"aria-label":"Find in logs",spellCheck:!1,autoComplete:"off"}),e.find&&s.jsx("span",{className:"log-find-count","aria-live":"polite",children:e.hitCount?`${e.activeHit+1}/${e.hitCount}`:"0/0"})]}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(-1),disabled:!e.hitCount,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:s.jsx(Xs,{size:14,"aria-hidden":"true"})}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(1),disabled:!e.hitCount,"aria-label":"Next match",title:"Next match (Enter)",children:s.jsx(qs,{size:14,"aria-hidden":"true"})}),s.jsx("span",{className:"log-toolbar-divider","aria-hidden":"true"}),s.jsxs("div",{className:"log-actions",children:[s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:e.onTogglePause,children:[e.following?s.jsx(ea,{size:13,"aria-hidden":"true"}):s.jsx(ta,{size:13,"aria-hidden":"true"}),e.following?"Pause":"Resume"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",className:`log-record${e.recording?" is-recording":""}`,onClick:e.onToggleRecording,"aria-pressed":e.recording,children:[e.recording?s.jsx(ci,{size:12,"aria-hidden":"true"}):s.jsx(Or,{size:12,"aria-hidden":"true"}),e.recording?`Stop · ${st(e.recordedLines)} lines`:"Record"]}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:e.onExport,"aria-label":"Export shown lines",title:"Export shown lines",children:s.jsx(vi,{size:14,"aria-hidden":"true"})}),s.jsx(U,{ref:n,type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>d(m=>!m),"aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,title:"More options",children:s.jsx(xi,{size:14,"aria-hidden":"true"})}),s.jsx(ss,{open:o,onClose:c,anchorRef:n,placement:"bottom-end",children:s.jsx("div",{ref:i,children:s.jsxs(Ks,{children:[s.jsx(ke,{checkbox:!0,checked:e.caseSensitive,onClick:l(e.onToggleCase),children:"Match case"}),s.jsx(ke,{checkbox:!0,checked:e.wrap,onClick:l(e.onToggleWrap),children:"Wrap long lines"}),s.jsx(ui,{}),e.canCopySelected&&s.jsx(ke,{onClick:l(e.onCopySelected),children:"Copy selected lines"}),s.jsx(ke,{onClick:l(e.onClearLines),children:"Clear lines"})]})})})]})]})}function Fc({platform:e,counts:t,minLevel:n,shown:i,total:r,onChoose:a}){const o=Nc(e,t,n),d=Ec(o,n),c=d===null?-1:Ut.indexOf(d);return s.jsxs("div",{className:"log-levels",children:[s.jsxs("div",{className:"log-level-buttons",role:"group","aria-label":"Log levels",children:[s.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"log-level-btn","aria-label":"All levels","aria-pressed":d===null,onClick:()=>a(""),children:"All"}),o.map(({level:l,name:h})=>{const m=t[l],f=`${h} ${l==="F"?"only":"and above"}, ${st(m)} ${h.toLowerCase()} line${m===1?"":"s"}`,v=c>=0&&Ut.indexOf(l)>=c;return s.jsxs(U,{type:"button",variant:"ghost",size:"sm",className:`log-level-btn lvl-${l}${v?" is-included":""}${m?" has-lines":""}`,"aria-label":f,"aria-pressed":d===l,onClick:()=>a(d===l?"":l),children:[h,s.jsx("span",{className:"log-level-count",children:st(m)})]},l)})]}),s.jsxs("span",{className:"log-shown",children:[st(i)," of ",st(r)," shown"]})]})}function Pc(e){return typeof e=="object"?e.key:e}function Uc(e,t){const n=e.length;return new Proxy(e,{get(i,r,a){if(typeof r=="string"){const o=r.charCodeAt(0);if(o>=48&&o<=57){const d=+r;if(Number.isInteger(d)&&d>=0&&d<n){let c=i[d];if(typeof c!="object"){const l=t[d*2];c=i[d]={index:d,key:c,start:l,size:t[d*2+1],end:l+t[d*2+1],lane:0}}return c}}if(r==="length")return n}return Reflect.get(i,r,a)}})}function Nt(e,t,n){let i=n.initialDeps??[],r,a=!0;function o(){const d=e();return(d.length!==i.length||d.some((l,h)=>i[h]!==l))&&(i=d,r=t(...d),n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(r),a=!1),r}return o.updateDeps=d=>{i=d},o}function Fn(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Pn=(e,t)=>Math.abs(e-t)<1.01,Bc=(e,t,n)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(i)}})};let $t;const Ns=()=>{if($t!==void 0)return $t;if(typeof navigator>"u")return $t=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return $t=!0;const e=navigator.maxTouchPoints;return $t=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Un=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Wc=e=>e,er=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(i);for(let a=0;a<i;a++)r[a]=t+a;return r},Vc=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=o=>{const{width:d,height:c}=o;t({width:Math.round(d),height:Math.round(c)})};if(r(Un(n)),!i.ResizeObserver)return()=>{};const a=new i.ResizeObserver(o=>{const d=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const l=c.borderBoxSize[0];if(l){r({width:l.inlineSize,height:l.blockSize});return}}r(Un(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(d):d()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},ls={passive:!0},Hc=typeof window>"u"?!0:"onscrollend"in window,Kc=(e,t,n)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&Hc;let o=0;const d=a?null:Bc(r,()=>t(n(i),!1),e.options.isScrollingResetDelay),c=m=>()=>{o=n(i),d==null||d(),t(o,m)},l=c(!0),h=c(!1);return i.addEventListener("scroll",l,ls),a&&i.addEventListener("scrollend",h,ls),()=>{i.removeEventListener("scroll",l),a&&i.removeEventListener("scrollend",h),d==null||d.cancel()}},qc=(e,t)=>Kc(e,t,n=>{const{horizontal:i,isRtl:r}=e.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),Xc=(e,t,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(e),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=n.indexFromElement(e),r=n.options.getItemKey(i),a=n.itemSizeCache.get(r);if(a!==void 0)return a}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Yc=(e,{adjustments:t=0,behavior:n},i)=>{var r,a;(a=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[i.options.horizontal?"left":"top"]:e+t,behavior:n})},tr=Yc;function Gc(e,t,n,i){if(t===0)return!1;const r=i(0),a=new Set;let o=0;for(;o<e;){const c=n(o);if(c===r)break;a.add(c),o++}const d=e-o;if(d===0||d>=t)return!1;for(let c=0;c<d;c++)if(i(c)!==n(o+c))return!1;for(let c=d;c<t;c++)if(a.has(i(c)))return!1;return!0}class Jc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const o=()=>{const d=a.target,c=this.indexFromElement(d);if(!d.isConnected){this.observer.unobserve(d);for(const[l,h]of this.elementsCache)if(h===d){this.elementsCache.delete(l);break}return}this.isIndexInRange(c)&&this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(d,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var a;return(a=i())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=i())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Wc,rangeExtractor:er,onChange:()=>{},measureElement:Xc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const g=n[m];g!==void 0&&(r[m]=g)}const a=this.options;let o=null,d=null,c=!1;if(a!==void 0&&a.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,g=r.count,f=this.getMeasurements(),v=((i=this._singleLaneMeasurements)==null?void 0:i.items)??f,S=C=>Pc(v[C]),b=m>0?S(0):null,M=m>0?S(m-1):null;if(g!==m||m>0&&g>0&&(r.getItemKey(0)!==b||r.getItemKey(g-1)!==M)){c=!0;const C=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;C&&(o=[C.key,this.getScrollOffset()-C.start]);const x=r.followOnAppend===!0?"auto":r.followOnAppend||null;x&&g>0&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||r.getItemKey(g-1)!==M)&&(g>m||Gc(m,g,S,r.getItemKey))&&(d=x)}}this.options=r,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,h=0;if(o&&this.scrollOffset!==null){const[m,g]=o,f=this.getMeasurements(),{count:v,getItemKey:S}=this.options;let b=0;for(;b<v&&S(b)!==m;)b++;if(b<v){const M=f[b];if(M){const k=Math.max(0,M.start+g);!d&&k!==this.scrollOffset&&(h=k-this.scrollOffset,this.scrollOffset=k,l=!0)}}}(l||d)&&(this.pendingScrollAnchor=[l?o[0]:null,l?o[1]:0,d,h])},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=Nt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n,i;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,d)=>{if(d&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(o-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=d?c===o?this.scrollDirection:c<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=d,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,d=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!Ns()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",d,ls),o.addEventListener("touchend",c,ls),this.unsubs.push(()=>{o.removeEventListener("touchstart",d),o.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[o,d,c,l]=a;o!==null&&!c&&(Ns()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((i=this.scrollState)==null?void 0:i.behavior)==="smooth"&&!Pn(this.getScrollOffset()-l,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:n,maxAtWrite:i}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>i+.5&&(this._clampedAdjustment=n>r+.5?{target:n,maxAtWrite:r}:null,this._scrollToOffset(n,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;if(this._iosDeferredAdjustment<0&&n>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Nt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,a,o,d,c,l)=>(this.prevLanes!==void 0&&this.prevLanes!==d&&(this.lanesChangedFlag=!0),this.prevLanes=d,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=Nt(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l},h)=>{var m;const g=this.itemSizeCache;if(!o)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const k of this.laneAssignments.keys())k>=n&&this.laneAssignments.delete(k);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(k=>{this.itemSizeCache.set(k.key,k.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),d===1){const k=n*2;let y=(m=this._singleLaneMeasurements)==null?void 0:m.flat;if(!y||y.length<k){const N=new Float64Array(k);y&&f>0&&N.set(y.subarray(0,f*2)),y=N}const C=f===0?new Array(n):this._singleLaneMeasurements.items.slice();let x;if(f===0)x=i+r;else{const N=f-1;x=y[N*2]+y[N*2+1]+l}for(let N=f;N<n;N++){const T=a(N);C[N]=T;const p=g.get(T),E=typeof p=="number"?p:this.options.estimateSize(N);y[N*2]=x,y[N*2+1]=E,x+=E+l}this._singleLaneMeasurements={flat:y,items:C};const A=Uc(C,y);return this.measurementsCache=A,A}const v=this.measurementsCache.slice(0,f),S=new Array(d).fill(void 0),b=new Float64Array(d);let M=0;for(let k=0;k<f;k++){const y=v[k];y&&(S[y.lane]===void 0&&M++,S[y.lane]=k,b[y.lane]=y.end)}for(let k=f;k<n;k++){const y=a(k),C=this.laneAssignments.get(k);let x,A;const N=c==="estimate"||g.has(y);if(C!==void 0&&this.options.lanes>1){x=C;const _=S[x],O=_!==void 0?v[_]:void 0;A=O?O.end+l:i+r}else if(M===d){let _=0,O=b[0],D=S[0];for(let V=1;V<d;V++){const Y=b[V];(Y<O||Y===O&&S[V]<D)&&(_=V,O=Y,D=S[V])}x=_,A=O+l,N&&this.laneAssignments.set(k,x)}else x=k%this.options.lanes,A=i+r,N&&this.laneAssignments.set(k,x);const T=g.get(y),p=typeof T=="number"?T:this.options.estimateSize(k),E=A+p;v[k]={index:k,start:A,size:p,end:E,key:y,lane:x},S[x]===void 0&&M++,S[x]=k,b[x]=E}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Nt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,a)=>n.length===0||i===0?(this.range=null,null):(this.range=Qc(n,i,r,a,a===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Nt(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,a,o)=>a===null||o===null?[]:n({startIndex:a,endIndex:o,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-a),d=Math.min(this.options.count-1,r+a);return n>=o&&n<=d}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,d)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(d))});return}const i=this.indexFromElement(n);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),a=this.elementsCache.get(r);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,a,o;if(!this.isIndexInRange(n))return;let d,c,l;const h=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&h!=null)l=this.options.getItemKey(n),c=h[n*2],d=h[n*2+1];else{const f=this.measurementsCache[n];if(!f)return;l=f.key,c=f.start,d=f.size}const m=this.itemSizeCache.get(l)??d,g=i-m;if(g!==0){const f=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=f?this.getTotalSize():0,S=this.getScrollOffset()+this.scrollAdjustments,M=!this.itemSizeCache.has(l)?c<S:c+m<=S&&this.scrollDirection!=="backward",k=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:l,start:c,size:d,end:c+d,lane:0},g,this):M);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(l,i),this.itemSizeCacheVersion++;let y=!1;f?y=this.applyScrollAdjustment(this.getTotalSize()-v):k&&(y=this.applyScrollAdjustment(g)),this.notify(y),this._retryClampedAdjustment()}},this.getVirtualItems=Nt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let a=0,o=n.length;a<o;a++){const d=n[a],c=i[d];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{var i;const r=this.getMeasurements();if(r.length===0)return;const a=(i=this._singleLaneMeasurements)==null?void 0:i.flat,o=this.options.lanes===1&&a!=null,d=sr(0,r.length-1,o?c=>a[c*2]:c=>Fn(r[c]).start,n);return Fn(r[d])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=n>=o+a?"end":"start"),i==="center"?n+=(r-a)/2:i==="end"&&(n-=a);const d=this.getMaxScrollOffset();return Math.max(Math.min(d,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(i==="auto")if(o.end>=a+r-this.options.scrollPaddingEnd)i="end";else if(o.start<=a+this.options.scrollPaddingStart)i="start";else return[a,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const d=i==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(d,i,o.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const a=this.getOffsetForAlignment(n,i),o=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getOffsetForIndex(n,i);if(!a)return;const[o,d]=a,c=this.now();this.scrollState={index:n,align:d,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,a=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n,i;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,d=(n=this._singleLaneMeasurements)==null?void 0:n.flat;d!=null?a=d[o*2]+d[o*2+1]:a=((i=r[o])==null?void 0:i.end)??0}else{const o=Array(this.options.lanes).fill(null);let d=r.length-1;for(;d>=0&&o.some(c=>c===null);){const c=r[d];o[c.lane]===null&&(o[c.lane]=c.end),d--}a=Math.max(...o.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){if(t===0)return!1;if(Ns()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=t,!1;{const i=this.getScrollOffset()+this.scrollAdjustments+t,r=this.scrollElement,a=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=a!==null&&i>a+.5?{target:i,maxAtWrite:a}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,a=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&Pn(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const d=this.getSize()||600,c=Math.abs(r-this.getScrollOffset()),l=this.scrollState.behavior==="smooth"&&c>d;this.scrollState.lastTargetOffset=r,l||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:l?"smooth":"auto"})}this.scheduleScrollReconcile()}}const sr=(e,t,n,i)=>{for(;e<=t;){const r=(e+t)/2|0,a=n(r);if(a<i)e=r+1;else if(a>i)t=r-1;else return r}return e>0?e-1:0};function Zc(e,t,n){let i=0;for(;i<=t;){const r=(i+t)/2|0,a=e[r*2];if(a<n)i=r+1;else if(a>n)t=r-1;else return r}return i>0?i-1:0}function Qc(e,t,n,i,r){const a=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:a};if(i===1&&r!==null){const l=Zc(r,a,n);let h=l;const m=n+t;for(;h<a&&r[h*2]+r[h*2+1]<m;)h++;return{startIndex:l,endIndex:h}}let d=sr(0,a,l=>e[l].start,n),c=d;if(i===1)for(;c<a&&e[c].end<n+t;)c++;else if(i>1){const l=Array(i).fill(0);for(;c<a&&l.some(m=>m<n+t);){const m=e[c];l[m.lane]=m.end,c++}const h=Array(i).fill(n+t);for(;d>=0&&h.some(m=>m>=n);){const m=e[d];h[m.lane]=m.start,d--}d=Math.max(0,d-d%i),c=Math.min(a,c+(i-1-c%i))}return{startIndex:d,endIndex:c}}const Es=typeof document<"u"?u.useLayoutEffect:u.useEffect;function ed({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...i}){const r=u.useReducer(m=>m+1,0)[1],a=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;const o=u.useRef(!1),d=m=>{const g=a.current;if(!g.enabled||!g.container)return;const f=m.getTotalSize();if(f!==g.lastSize){g.lastSize=f;const v=m.options.horizontal?"width":"height";g.container.style[v]=`${f}px`}},c=m=>{const g=a.current;if(!g.enabled||!g.container)return;d(m);const f=!!m.options.horizontal,v=g.mode==="transform",S=f?"left":"top",b=m.options.scrollMargin,M=m.getVirtualItems();for(const k of M){const y=k.start-b,C=m.elementsCache.get(k.key);C&&g.lastPositions.get(C)!==y&&(g.lastPositions.set(C,y),v?C.style.transform=f?`translate3d(${y}px, 0, 0)`:`translate3d(0, ${y}px, 0)`:C.style[S]=`${y}px`)}},l={...i,onChange:(m,g)=>{var f;const v=a.current;let S=!0;if(v.enabled){c(m);const b=m.range,M=v.prevRange;S=!M||M.isScrolling!==m.isScrolling||M.startIndex!==(b==null?void 0:b.startIndex)||M.endIndex!==(b==null?void 0:b.endIndex),S&&(v.prevRange=b?{startIndex:b.startIndex,endIndex:b.endIndex,isScrolling:m.isScrolling}:null)}S&&(e&&g&&!o.current?$s.flushSync(r):r()),(f=i.onChange)==null||f.call(i,m,g)}},[h]=u.useState(()=>{const m=new Jc(l),g=m.measureElement;return m.measureElement=f=>{o.current=!0;try{g(f)}finally{o.current=!1}},Object.assign(m,{containerRef:f=>{const v=a.current;if(v.container=f,v.lastSize=null,f&&v.enabled){const S=m.getTotalSize();v.lastSize=S;const b=m.options.horizontal?"width":"height";f.style[b]=`${S}px`}}})});return h.setOptions(l),Es(()=>h._didMount(),[]),Es(()=>(d(h),h._willUpdate())),Es(()=>{c(h)}),h}function td(e){return ed({observeElementRect:Vc,observeElementOffset:qc,scrollToFn:tr,...e})}const sd=/[.*+?^${}()|[\]\\]/g;function nd(e,t,n){if(!t||!e)return[{text:e,hit:!1}];const i=new RegExp(t.replace(sd,"\\$&"),n?"g":"gi"),r=[];let a=0,o;for(;(o=i.exec(e))!==null;)o.index>a&&r.push({text:e.slice(a,o.index),hit:!1}),r.push({text:o[0],hit:!0}),a=o.index+o[0].length;return r.length?(a<e.length&&r.push({text:e.slice(a),hit:!1}),r):[{text:e,hit:!1}]}const Bn=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function id(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t>>>0}function rd(e){return e?Bn[id(e)%Bn.length]:"var(--text-muted)"}function Wn({text:e,find:t,caseSensitive:n}){if(!t)return s.jsx(s.Fragment,{children:e});const i=nd(e,t,n);return i.length===1&&!i[0].hit?s.jsx(s.Fragment,{children:e}):s.jsx(s.Fragment,{children:i.map((r,a)=>r.hit?s.jsx("mark",{className:"log-mark",children:r.text},a):s.jsx(u.Fragment,{children:r.text},a))})}const ad=u.memo(function({record:t,index:n,setSize:i,start:r,id:a,selected:o,active:d,hit:c,activeHit:l,find:h,caseSensitive:m,measureRef:g}){const f=["log-row",`lvl-${t.level}`,t.synthetic?"is-synthetic":"",c?"is-hit":"",l?"is-active-hit":"",d?"is-active":""].filter(Boolean).join(" ");return s.jsxs("div",{ref:g,role:"option",id:a,"aria-selected":o,"aria-setsize":i,"aria-posinset":n+1,"data-index":n,"data-seq":t.seq,className:f,style:{transform:`translateY(${r}px)`},children:[s.jsx("span",{className:"log-time",children:_c(t.ts)}),s.jsx("span",{className:"log-badge",children:t.level}),!t.synthetic&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"log-tag",title:t.tag,style:{color:rd(t.tag)},children:s.jsx(Wn,{text:t.tag,find:h,caseSensitive:m})}),s.jsx("span",{className:"log-pkg",title:t.pkg,children:t.pkg??""})]}),s.jsx("span",{className:"log-msg",children:s.jsx(Wn,{text:t.message,find:h,caseSensitive:m})})]})}),Vn=24,od=1e3,ld=250,cd=20,dd=38,Hn=720,ud=["PageUp","PageDown","Home"," "];let hd=0;function md(e){const[t,n]=u.useState(!0);return u.useLayoutEffect(()=>{const i=e.current;if(!i)return;n(i.offsetWidth>=Hn);const r=window.ResizeObserver;if(!r)return;const a=new r(o=>n(o[0].contentRect.width>=Hn));return a.observe(i),()=>a.disconnect()},[e]),t}const fd=u.forwardRef(function(t,n){const{records:i,wrap:r,find:a,caseSensitive:o,hits:d,activeHit:c,following:l,newLines:h}=t,m=u.useRef(null),[g]=u.useState(()=>`log-lines-${++hd}`),f=u.useRef(null),v=u.useRef(l);v.current=l;const S=u.useRef(t);S.current=t;const b=md(m),M=t.selection.active,k=u.useMemo(()=>M===null?-1:i.findIndex(w=>w.seq===M),[i,M]),y=td({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>b?cd:dd,getItemKey:w=>i[w].seq,overscan:10,rangeExtractor:w=>{const L=er(w);return k>=0&&L.indexOf(k)<0&&(L.push(k),L.sort((H,I)=>H-I)),L},anchorTo:l?"start":"end",scrollToFn:(w,L,H)=>{const I=H.scrollElement,K=w+(L.adjustments??0);f.current=I?Math.max(0,Math.min(K,I.scrollHeight-I.clientHeight)):K,tr(w,L,H)}}),C=u.useRef(`${r}|${b}`);u.useLayoutEffect(()=>{var L;const w=`${r}|${b}`;C.current!==w&&(C.current=w,y.measure(),(L=m.current)==null||L.querySelectorAll("[data-index]").forEach(H=>y.measureElement(H)))},[r,b,y]);const x=y.getTotalSize(),A=i.length?i[i.length-1].seq:-1,N=u.useRef(i);N.current=i;const T=u.useRef(null),[p,E]=u.useState(!1),_=u.useRef(()=>{});_.current=()=>{const w=m.current,L=N.current,H=w&&L.length?y.getVirtualItemForOffset(w.scrollTop):void 0;T.current=H&&L[H.index]?L[H.index].seq:null},u.useLayoutEffect(()=>{const w=T.current,L=t.oldestSeq;!v.current&&w!==null&&L!==null&&w<L&&(E(!0),y.scrollToOffset(0)),_.current()},[i,t.oldestSeq,y]),u.useEffect(()=>{l&&E(!1)},[l]);const O=u.useRef(0),D=u.useRef(!1);u.useLayoutEffect(()=>{!l||!i.length||D.current||Date.now()-O.current<ld||y.scrollToOffset(x)},[l,A,i.length,x,y]),u.useEffect(()=>{const w=m.current;if(!w)return;let L=w.scrollTop;const H=()=>{O.current=Date.now()},I=re=>{re.target===w&&(D.current=!0,H())},K=()=>{D.current&&H(),D.current=!1},ie=re=>{ud.indexOf(re.key)>=0&&H()},X=()=>{_.current();const re=w.scrollTop,je=re>L;if(L=re,f.current!==null&&Math.abs(re-f.current)<2||(f.current=null,!D.current&&Date.now()-O.current>od))return;const $=w.scrollHeight-w.clientHeight-re;v.current&&$>Vn?S.current.onPause():!v.current&&je&&$<=Vn&&S.current.onFollow()},ne={passive:!0};return w.addEventListener("wheel",H,ne),w.addEventListener("touchstart",H,ne),w.addEventListener("touchmove",H,ne),w.addEventListener("pointerdown",I),window.addEventListener("pointerup",K),w.addEventListener("keydown",ie),w.addEventListener("scroll",X,ne),()=>{w.removeEventListener("wheel",H),w.removeEventListener("touchstart",H),w.removeEventListener("touchmove",H),w.removeEventListener("pointerdown",I),window.removeEventListener("pointerup",K),w.removeEventListener("keydown",ie),w.removeEventListener("scroll",X)}},[]),u.useImperativeHandle(n,()=>({reveal:w=>y.scrollToIndex(w,{align:"center"}),focus:()=>{var w;return(w=m.current)==null?void 0:w.focus({preventScroll:!0})}}),[y]);const V=w=>`${g}-${w}`,Y=w=>{var K,ie,X,ne;const L=w.target.closest("[data-seq]");if(!L||!((K=m.current)!=null&&K.contains(L))||(((X=(ie=window.getSelection)==null?void 0:ie.call(window))==null?void 0:X.toString())??"")!=="")return;const H=Number(L.getAttribute("data-seq")),I=$c(t.selection,H,i.map(re=>re.seq),{range:w.shiftKey,toggle:w.metaKey||w.ctrlKey});t.onSelect(I,i.find(re=>re.seq===H)??null,"click"),I.selected.size&&v.current&&t.onPause(),w.shiftKey&&((ne=m.current)==null||ne.focus({preventScroll:!0}))},Z=w=>{w.shiftKey&&w.preventDefault()},W=w=>{var H,I;const L=w.metaKey||w.ctrlKey;if((w.key==="ArrowDown"||w.key==="ArrowUp")&&!L&&!w.altKey){w.preventDefault();const K=i.map(ne=>ne.seq);if(!K.length)return;const ie=zc(t.selection,K,w.key==="ArrowDown"?1:-1,w.shiftKey),X=ie.active===null?-1:K.indexOf(ie.active);if(t.onSelect(ie,X>=0?i[X]:null,"key"),X<0)return;X!==K.length-1&&v.current&&t.onPause(),y.scrollToIndex(X,{align:"auto"})}else if(w.key==="Enter"&&!L){const K=k>=0?i[k]:void 0;if(!K)return;w.preventDefault(),t.onOpenDetails(K)}else if(w.key==="End"&&!L)w.preventDefault(),t.onFollow(),y.scrollToOffset(x);else if(L&&!w.altKey&&(w.key==="c"||w.key==="C")){if(!t.selection.selected.size||(((I=(H=window.getSelection)==null?void 0:H.call(window))==null?void 0:I.toString())??"")!=="")return;w.preventDefault(),t.onCopy()}};return s.jsxs("div",{className:"log-list-wrap",children:[p&&!l&&s.jsx("div",{className:"log-dropped-note",children:"Older lines were dropped while paused"}),s.jsx("div",{ref:m,role:"listbox","aria-label":"Log lines","aria-multiselectable":"true",tabIndex:0,"aria-activedescendant":k>=0?V(i[k].seq):void 0,className:`log-list${r?"":" is-nowrap"}`,onClick:Y,onMouseDown:Z,onKeyDown:W,children:s.jsx("div",{className:"log-list-sizer",style:{height:x},children:y.getVirtualItems().map(w=>{const L=i[w.index];return s.jsx(ad,{record:L,index:w.index,setSize:i.length,start:w.start,id:V(L.seq),selected:t.selection.selected.has(L.seq),active:t.selection.active===L.seq,hit:d.has(w.index),activeHit:c===w.index,find:a,caseSensitive:o,measureRef:y.measureElement},L.seq)})})}),!l&&s.jsx(U,{type:"button",variant:"secondary",size:"sm",className:"log-new-pill",onClick:()=>S.current.onFollow(),children:h>0?`${st(h)} new line${h===1?"":"s"} · Jump to latest`:"Jump to latest"})]})});function pd({record:e,platform:t,inBuffer:n,onCopyLine:i,onCopyMessage:r,onShowOnlyTag:a,onHideTag:o,onShowOnlyApp:d,onClose:c}){const l=!!e.synthetic;return s.jsxs("section",{className:"log-details","aria-label":"Line details",children:[s.jsxs("header",{className:"log-details-head",children:[s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-details-close","aria-label":"Close details",title:"Close details (Esc)",onClick:c,children:s.jsx(Vs,{size:14,"aria-hidden":"true"})}),s.jsx("h3",{className:"log-details-title",children:l?"Added by Xenon":`${Gi(e.level,t)} · ${e.tag}`})]}),l&&s.jsx("p",{className:"log-details-note",children:"Xenon added this line. It didn’t come from the phone."}),s.jsxs("dl",{className:"log-details-fields",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Time"}),s.jsx("dd",{children:Dc(e.ts)})]}),!l&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"App"}),s.jsx("dd",{children:e.pkg??"Unknown"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Process ID"}),s.jsx("dd",{children:e.pid})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Thread ID"}),s.jsx("dd",{children:e.tid})]})]})]}),!n&&s.jsx("p",{className:"log-details-left",children:"This line has left the buffer"}),s.jsx("pre",{className:"log-details-msg",children:e.message}),s.jsxs("div",{className:"log-details-actions",children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Copy line"}),!l&&s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:r,children:"Copy message"}),e.tag&&s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:a,children:"Show only this tag"}),s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:o,children:"Hide this tag"})]}),e.pkg&&s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:d,children:"Show only this app"})]})]})]})}function Kn(e,t){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),i=document.createElement("a");i.href=n,i.download=t,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),0)}async function gd(e){var i;if(await Js(e))return!0;if(typeof document.execCommand!="function")return!1;const t=document.activeElement,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n),(i=t==null?void 0:t.focus)==null||i.call(t,{preventScroll:!0})}}const vd=e=>e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable;function yd({udid:e,platform:t}){const n=(t||"").toLowerCase(),i=n==="ios",r=n==="android"||i,a=i?"ios":"android",{toast:o}=Fe(),[d,c]=u.useState(""),l=u.useMemo(()=>i?kc(d):void 0,[i,d]),{records:h,connected:m,clear:g,deniedReason:f,exhausted:v,retry:S}=yc(e,r,l),[b,M]=u.useState(!1),[k,y]=u.useState(!0),[C,x]=u.useState(""),[A,N]=u.useState(0),[T,p]=u.useState(Cs),[E,_]=u.useState(null),O=u.useRef(null),D=u.useRef(null),V=u.useRef(null),Y=u.useRef(null),Z=u.useRef(h);Z.current=h;const[W,w]=u.useState(!0),[L,H]=u.useState(null),I=u.useRef(W);I.current=W;const K=u.useCallback(()=>{if(!I.current)return;I.current=!1;const F=Z.current;H(F.length?F[F.length-1].seq:-1),w(!1)},[]),ie=u.useCallback(()=>{I.current=!0,H(null),w(!0)},[]),X=u.useRef(null),[ne,re]=u.useState(!1),[je,$]=u.useState(0),ae=u.useRef(-1),te=u.useMemo(()=>Hi(d,{caseSensitive:b}),[d,b]),se=u.useMemo(()=>h.filter(F=>Ki(F,te)),[h,te]),me=u.useMemo(()=>Cc(h,te),[h,te]),ue=u.useMemo(()=>{if(!C)return[];const F=b?C:C.toLowerCase(),Q=[];return se.forEach((le,Ne)=>{(b?`${le.tag} ${le.message}`:`${le.tag} ${le.message}`.toLowerCase()).includes(F)&&Q.push(Ne)}),Q},[se,C,b]),Te=ue.length?Math.min(A,ue.length-1):0,rt=u.useMemo(()=>new Set(ue),[ue]),at=u.useCallback(F=>{var le;if(!ue.length)return;const Q=(Te+F+ue.length)%ue.length;N(Q),K(),(le=Y.current)==null||le.reveal(ue[Q])},[ue,Te,K]),Ge=u.useMemo(()=>{if(L===null)return 0;let F=0;for(let Q=se.length-1;Q>=0&&se[Q].seq>L;Q--)F++;return F},[se,L]),he=u.useCallback(()=>{if(!se.length){o("No lines to export","info");return}Kn(se.map(os).join(`
281
- `),`logcat-${e}-${Date.now()}.txt`)},[se,e,o]);u.useEffect(()=>{const F=X.current;if(!F||!h.length)return;const Q=h.filter(Ne=>Ne.seq>ae.current);if(!Q.length)return;const le=ae.current+1;ae.current>=0&&Q[0].seq>le&&(F.dropped+=Q[0].seq-le),Ac(F,Q),ae.current=Q[Q.length-1].seq,$(F.lines.length)},[h]);const Je=u.useCallback(()=>{const F=X.current;if(!F){ae.current=h.length?h[h.length-1].seq:-1,X.current=Tc(Date.now()),$(0),re(!0);return}const Q=Rc(F,Date.now(),e);X.current=null,re(!1),$(0),Kn(Q,Mc(e,F.startedAt))},[h,e]),[Pe,Ce]=u.useState(!1),Me=Wi(()=>{});hc(ne?()=>X.current?(Ce(!0),!0):!1:null);const ot=()=>{Ce(!1),X.current&&Je(),Me()},Ie=u.useCallback(async(F,Q)=>{await gd(F)?o(Q,"success"):o("Your browser blocked copying here.","error")},[o]),Ue=u.useMemo(()=>{if(!T.selected.size)return 0;let F=0;for(let Q=0;Q<se.length;Q++)T.selected.has(se[Q].seq)&&F++;return F},[se,T.selected]),Ze=u.useCallback(()=>{const{text:F,count:Q}=Ic(se,T.selected);Q&&Ie(F,`Copied ${st(Q)} line${Q===1?"":"s"}`)},[se,T.selected,Ie]),bt=u.useCallback((F,Q,le)=>{p(F),_(le==="click"?Q:Ne=>Ne&&Q?Q:Ne)},[]),Be=u.useCallback(()=>{g(),p(Cs)},[g]),Qe=F=>{var le,Ne,ee;const Q=F.metaKey||F.ctrlKey;F.key==="/"&&!Q&&!vd(F.target)?(F.preventDefault(),(le=D.current)==null||le.focus()):Q&&!F.altKey&&(F.key==="f"||F.key==="F")?(F.preventDefault(),(Ne=V.current)==null||Ne.focus(),(ee=V.current)==null||ee.select()):F.key==="Escape"&&(E?(F.preventDefault(),_(null)):T.selected.size&&(F.preventDefault(),p(Cs)))},jt=u.useRef(Qe);if(jt.current=Qe,u.useEffect(()=>{const F=O.current;if(!F)return;const Q=le=>jt.current(le);return F.addEventListener("keydown",Q),()=>F.removeEventListener("keydown",Q)},[r]),!r)return s.jsx("div",{className:"logcat-root",children:s.jsx(Qr,{title:"Live logs are not available here",description:"Live logs work on Android and iOS phones."})});const We=f?"Denied":v?"Offline":m?"Live":"Connecting",wt=!!E&&h.length>0&&E.seq>=h[0].seq&&E.seq<=h[h.length-1].seq;let _e=null;se.length||(h.length?_e=s.jsxs("div",{className:"log-state",children:[s.jsxs("p",{children:["No lines match ",s.jsx("code",{children:d})]}),s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>c(""),children:"Clear filter"})]}):We==="Connecting"?_e=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Waiting for the phone’s first log line…"})}):We==="Live"&&(_e=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Connected. Lines appear here as the phone logs them."})})));const lt=s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:S,children:[s.jsx(Dt,{size:13,"aria-hidden":"true"})," Reconnect"]});return s.jsxs("div",{className:"logcat-root",ref:O,children:[s.jsx(Oc,{status:We,statusDetail:f,query:d,onQueryChange:c,filterRef:D,find:C,onFindChange:F=>{x(F),N(0)},findRef:V,hitCount:ue.length,activeHit:Te,onStep:at,following:W,onTogglePause:W?K:ie,recording:ne,recordedLines:je,onToggleRecording:Je,onExport:he,caseSensitive:b,onToggleCase:()=>M(F=>!F),wrap:k,onToggleWrap:()=>y(F=>!F),canCopySelected:Ue>0,onCopySelected:Ze,onClearLines:Be}),s.jsx(Fc,{platform:a,counts:me,minLevel:te.minLevel,shown:se.length,total:h.length,onChoose:F=>c(jc(d,F))}),s.jsxs("div",{className:"log-body theme-dark",children:[f&&s.jsxs("div",{className:"log-banner is-denied",role:"alert",children:[s.jsx(qe,{size:14,"aria-hidden":"true"}),s.jsxs("span",{children:["Access denied — ",f]}),lt]}),!f&&v&&s.jsxs("div",{className:"log-banner is-exhausted",role:"alert",children:[s.jsx(qe,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect to try again."}),lt]}),s.jsxs("div",{className:"log-main",children:[s.jsx(fd,{ref:Y,records:se,oldestSeq:h.length?h[0].seq:null,wrap:k,find:C,caseSensitive:b,hits:rt,activeHit:ue.length?ue[Te]:null,following:W,newLines:Ge,onPause:K,onFollow:ie,selection:T,onSelect:bt,onOpenDetails:_,onCopy:Ze}),_e]}),E&&s.jsx(pd,{record:E,platform:a,inBuffer:wt,onCopyLine:()=>Ie(os(E),"Copied the line"),onCopyMessage:()=>Ie(E.message,"Copied the message"),onShowOnlyTag:()=>c(Dn(d,"tag",E.tag)),onHideTag:()=>c(bc(d,"tag",E.tag)),onShowOnlyApp:()=>c(Dn(d,"package",E.pkg??"")),onClose:()=>_(null)})]}),s.jsx(hs,{open:Pe,title:"Stop recording?",onClose:()=>Ce(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",onClick:()=>Ce(!1),autoFocus:!0,children:"Keep recording"}),s.jsx(U,{type:"button",onClick:ot,children:"Save and close"})]}),children:s.jsxs("p",{children:[st(je)," line",je===1?"":"s"," recorded so far. Closing device control ends the recording. Save and close downloads it first."]})})]})}function nr(e){const t=e==null?void 0:e.message;return typeof t=="string"?t.trim():""}function ze(e,t){const n=nr(t);return n?`Couldn’t ${e}: ${n}`:`Couldn’t ${e}.`}function xd(e,t){return e==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":ze("read the clipboard",t)}function bd(e,t){const n=t.trim().toLowerCase();return[...e].sort((i,r)=>i.localeCompare(r)).filter(i=>!n||i.toLowerCase().includes(n))}const jd=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function wd(e){return jd.test(e.trim())}function Zs(e){const t=(e||"").toLowerCase();return t==="android"?"android":t==="ios"||t==="tvos"?"ios":null}function kd(e,t){const n=Zs(t);return n?e.filter(i=>(i.platform||"").toLowerCase()===n):[]}function Sd(e){return[e.version,e.packageName].filter(Boolean).join(" · ")}function Cd(e){return Zs(e)==="android"?"Android":"iOS"}function Nd(e){return Zs(e)==="android"?".apk":".ipa,.app"}function Ed({udid:e,platform:t,deviceName:n}){const{toast:i,removeToast:r}=Fe(),a=Bt(),[o,d]=u.useState([]),[c,l]=u.useState("loading"),[h,m]=u.useState(""),[g,f]=u.useState(""),[v,S]=u.useState(!1),[b,M]=u.useState(!1),[k,y]=u.useState([]),[C,x]=u.useState("loading"),[A,N]=u.useState(null),[T,p]=u.useState(null),E=u.useRef(null),_=u.useRef(null),O=u.useRef(null),D=u.useCallback(async()=>{l("loading");try{const $=await q.listApps(e);d(Array.isArray($)?$:[]),l("ready")}catch($){m(nr($)),l("error")}},[e]);u.useEffect(()=>{D()},[D]);const V=$=>setTimeout(D,$);u.useEffect(()=>{if(!T)return;const $=setTimeout(()=>p(null),1500);return()=>clearTimeout($)},[T]);const Y=async()=>{x("loading");try{const $=await q.getApps();y(Array.isArray($)?$:[]),x("ready")}catch{x("error")}},Z=()=>{v||(M(!0),Y())},W=()=>{var $;M(!1),($=E.current)==null||$.focus()};u.useEffect(()=>{var ae;if(!b||C==="loading")return;const $=(ae=_.current)==null?void 0:ae.querySelector('[role="menuitem"]:not(:disabled)');$==null||$.focus()},[b,C]);const w=async($,ae)=>{S(!0);const te=i(`Installing ${$} on ${n}…`,"loading",0);try{const se=await ae();se!=null&&se.success?(i(`Installed ${$} on ${n}`,"success"),V(5e3)):i(ze(`install ${$}`,{message:se==null?void 0:se.error}),"error")}catch(se){i(ze(`install ${$}`,se),"error")}finally{r(te),S(!1)}},L=$=>{W(),w($.name,()=>q.installRepositoryApp(e,$.id))},H=$=>{var te;const ae=(te=$.target.files)==null?void 0:te[0];$.target.value="",ae&&w(ae.name,()=>q.uploadAndInstallApp(e,ae))},I=async()=>{const $=A;if(N(null),!$)return;const ae=i(`Uninstalling ${$} from ${n}…`,"loading",0);try{await q.uninstallApp(e,$),i(`Uninstalled ${$} from ${n}`,"success"),V(3e3)}catch(te){i(ze(`uninstall ${$}`,te),"error")}finally{r(ae)}},K=async($,ae)=>{var se,me;if(await Js($)){p($);return}const te=(se=ae.closest("li"))==null?void 0:se.querySelector(".actions-app-id");te&&((me=window.getSelection())==null||me.selectAllChildren(te)),i(Vi,"info")},ie=bd(o,g),X=g.trim(),ne=c==="ready"&&ie.length===0&&wd(X)&&!o.includes(X),re=kd(k,t),je=($,ae)=>s.jsxs("li",{className:"actions-app-row",children:[s.jsx("span",{className:"actions-app-id",children:$}),ae&&s.jsx("span",{className:"actions-app-note",children:ae}),s.jsxs("span",{className:"actions-app-tools",children:[s.jsx(U,{variant:"ghost",size:"icon","aria-label":T===$?"Copied":`Copy ${$}`,title:T===$?"Copied":"Copy package ID",onClick:te=>K($,te.currentTarget),children:T===$?s.jsx(Ot,{size:13,"aria-hidden":"true"}):s.jsx(Oe,{size:13,"aria-hidden":"true"})}),s.jsx(U,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${$}`,onClick:()=>N($),children:"Uninstall"})]})]},$);return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[s.jsxs("div",{className:"actions-section-head",children:[s.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[s.jsx(io,{size:15,"aria-hidden":"true"})," Apps"]}),s.jsxs("div",{className:"actions-section-tools",children:[s.jsxs(U,{ref:E,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":b,"aria-disabled":v||void 0,onClick:Z,children:[v?s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(Ba,{size:13,"aria-hidden":"true"}),"Install from library"]}),s.jsxs(U,{variant:"secondary",size:"sm","aria-disabled":v||void 0,onClick:()=>{var $;return!v&&(($=O.current)==null?void 0:$.click())},children:[s.jsx(sa,{size:13,"aria-hidden":"true"})," Upload file"]}),s.jsx("input",{ref:O,type:"file",hidden:!0,"aria-label":"App file to upload",accept:Nd(t),onChange:H})]})]}),s.jsx(ss,{open:b,onClose:W,anchorRef:E,placement:"bottom-end",children:s.jsx("div",{ref:_,className:"actions-library-menu",children:s.jsxs(Ks,{children:[C==="loading"&&s.jsx(ke,{disabled:!0,onClick:()=>{},children:"Loading…"}),C==="error"&&s.jsx(ke,{onClick:Y,children:"Couldn’t load the library. Retry"}),C==="ready"&&re.length===0&&s.jsxs(s.Fragment,{children:[s.jsxs(ke,{disabled:!0,onClick:()=>{},children:["No ",Cd(t)," apps in the library yet"]}),s.jsx(ke,{onClick:()=>a("/apps"),children:"Open the Apps library"})]}),C==="ready"&&re.map($=>s.jsx(ke,{note:Sd($)||void 0,onClick:()=>L($),children:$.name},$.id))]})})}),s.jsxs("div",{className:"actions-apps-tools",children:[s.jsxs("div",{className:"actions-search",children:[s.jsx(Hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),s.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${o.length} installed apps`,value:g,onChange:$=>f($.target.value)})]}),s.jsx(U,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:D,children:s.jsx(Jt,{size:13,"aria-hidden":"true"})})]}),c==="loading"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),c==="error"&&s.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",h?`: ${h}`:".",s.jsx(U,{variant:"secondary",size:"sm",onClick:D,children:"Retry"})]}),c==="ready"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"No apps installed"}),c==="ready"&&o.length>0&&ie.length===0&&!ne&&s.jsxs("p",{className:"actions-list-note",children:["No apps match “",X,"”"]}),s.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[ie.map($=>je($)),ne&&je(X,"Not in the list")]}),s.jsx(hs,{open:A!==null,title:"Uninstall app?",onClose:()=>N(null),footer:s.jsxs(s.Fragment,{children:[s.jsx(U,{variant:"secondary",onClick:()=>N(null),children:"Cancel"}),s.jsx(U,{variant:"danger",onClick:I,children:"Uninstall"})]}),children:s.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",s.jsx("code",{children:A})," from"," ",s.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const Td=[{direction:"up",Icon:Xs},{direction:"down",Icon:qs},{direction:"left",Icon:ia},{direction:"right",Icon:ra}];function Ad({onSwipe:e}){return s.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[s.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[s.jsx(Da,{size:15,"aria-hidden":"true"})," Swipe"]}),s.jsx("div",{className:"actions-swipe-buttons",children:Td.map(({direction:t,Icon:n})=>s.jsx(U,{variant:"secondary",size:"icon","aria-label":`Swipe ${t}`,title:`Swipe ${t}`,onClick:()=>e(t),children:s.jsx(n,{size:14,"aria-hidden":"true"})},t))})]})}function Rd(e,t,n){const i=t/2,r=n/2,a=t*.4,o=n*.4,[d,c,l,h]={up:[i,r+o,i,r-o],down:[i,r-o,i,r+o],left:[i+a,r,i-a,r],right:[i-a,r,i+a,r]}[e].map(Math.round);return{startX:d,startY:c,endX:l,endY:h}}function Md({udid:e,platform:t}){const n=t!=="android",{toast:i}=Fe(),[r,a]=u.useState(""),[o,d]=u.useState(!1),[c,l]=u.useState(""),[h,m]=u.useState(null),[g,f]=u.useState(""),[v,S]=u.useState(!1),b=u.useRef(null);u.useEffect(()=>{if(!g)return;const x=setTimeout(()=>f(""),2e3);return()=>clearTimeout(x)},[g]),u.useEffect(()=>{if(!v)return;const x=setTimeout(()=>S(!1),1500);return()=>clearTimeout(x)},[v]);const M=async()=>{if(!(!r.trim()||o)){d(!0);try{await q.typeText(e,r),a(""),f("Sent")}catch(x){i(ze("send the text",x),"error")}finally{d(!1)}}},k=async()=>{m("read");try{const x=await q.getClipboard(e),A=typeof(x==null?void 0:x.content)=="string"?x.content:"";l(A),A||f("The device clipboard is empty")}catch(x){i(xd(t,x),"error")}finally{m(null)}},y=async()=>{if(c){m("write");try{await q.setClipboard(e,c),f("Written to the device")}catch(x){i(ze("write the clipboard",x),"error")}finally{m(null)}}},C=async()=>{var x;if(await Js(c)){S(!0);return}(x=b.current)==null||x.select(),i(Vi,"info")};return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[s.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[s.jsx(Pa,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),s.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:r,onChange:x=>a(x.target.value),onKeyDown:x=>x.key==="Enter"&&M()}),s.jsxs(U,{variant:"secondary",size:"md",onClick:M,disabled:!r.trim()||o,children:[o&&s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),s.jsx("input",{id:"actions-clipboard",ref:b,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:c,onChange:x=>l(x.target.value)}),s.jsxs(U,{variant:"secondary",size:"md",onClick:k,disabled:h!==null,children:[h==="read"&&s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&s.jsxs(U,{variant:"secondary",size:"md",onClick:y,disabled:!c||h!==null,children:[h==="write"&&s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),s.jsx(U,{variant:"ghost",size:"icon","aria-label":v?"Copied":"Copy clipboard text",title:v?"Copied":"Copy to your clipboard",onClick:C,disabled:!c,children:v?s.jsx(Ot,{size:14,"aria-hidden":"true"}):s.jsx(Oe,{size:14,"aria-hidden":"true"})})]}),!n&&s.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),s.jsx("p",{className:"actions-status",role:"status",children:g})]})}function $d({udid:e,platform:t,deviceName:n,screenWidth:i,screenHeight:r}){const{toast:a}=Fe(),o=async d=>{const c=Rd(d,i,r);try{await q.swipe(e,c.startX,c.startY,c.endX,c.endY)}catch(l){a(ze(`swipe ${d}`,l),"error")}};return s.jsxs("div",{className:"actions-panel",children:[s.jsx(Ed,{udid:e,platform:t,deviceName:n}),s.jsx(Md,{udid:e,platform:t}),s.jsx(Ad,{onSwipe:o})]})}const zd=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];function Id({shape:e,color:t,marks:n,saving:i,onShape:r,onColor:a,onUndo:o,onClear:d,onCancel:c,onSave:l}){return s.jsxs("div",{className:"shots-actions",role:"toolbar","aria-label":"Annotate",children:[s.jsxs("div",{className:"shots-shapes",children:[zd.map(h=>s.jsx(U,{variant:"secondary",size:"sm","aria-pressed":e===h.id,className:e===h.id?"is-pressed":void 0,onClick:()=>r(h.id),children:h.label},h.id)),s.jsx("input",{type:"color",className:"shots-color",value:t,onChange:h=>a(h.target.value),"aria-label":"Mark colour",title:"Mark colour"})]}),s.jsx(U,{variant:"ghost",size:"sm",onClick:o,disabled:!n||i,children:"Undo mark"}),s.jsx(U,{variant:"ghost",size:"sm",onClick:d,disabled:!n||i,children:"Clear marks"}),s.jsx("span",{className:"shots-actions-gap"}),s.jsx(U,{variant:"secondary",size:"sm",onClick:c,disabled:i,children:"Cancel"}),s.jsxs(U,{size:"sm",onClick:l,disabled:!n||i,children:[i&&s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Save copy"]})]})}function yt(e){return`Screenshot ${e.n}`}const nt=e=>String(e).padStart(2,"0");function qn(e){return`${nt(e.getHours())}:${nt(e.getMinutes())}:${nt(e.getSeconds())}`}function _d(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Fs(e,t=Date.now()){const n=new Date(e);return _d(n,new Date(t))?`Today ${qn(n)}`:`${n.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} ${qn(n)}`}function Dd(e,t){return!e||!t?"":e>t?"Landscape":"Portrait"}function Ld(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ir(e,t=Date.now()){const n=[yt(e)];e.markedFrom!==void 0&&n.push(`marked copy of ${e.markedFrom}`),n.push(Fs(e.takenAt,t));const i=Dd(e.width,e.height);return i&&n.push(i,`${e.width} × ${e.height}`),n.push(Ld(e.bytes)),n.join(" · ")}function rr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"device"}function ar(e){const t=new Date(e);return`${t.getFullYear()}-${nt(t.getMonth()+1)}-${nt(t.getDate())}`}function or(e,t){const n=new Date(t.takenAt),i=`${nt(n.getHours())}-${nt(n.getMinutes())}-${nt(n.getSeconds())}`,r=t.markedFrom!==void 0?"-marked":"";return`${rr(e)}-screenshot-${t.n}${r}-${ar(t.takenAt)}-${i}.png`}function Od(e,t=Date.now()){return`${rr(e)}-screenshots-${ar(t)}.zip`}async function Fd(e){const t=globalThis.ClipboardItem,n=navigator.clipboard;if(!t||typeof(n==null?void 0:n.write)!="function")return!1;try{const i=e.type==="image/png"?e:new Blob([e],{type:"image/png"});return await n.write([new t({"image/png":i})]),!0}catch{return!1}}var Se=Uint8Array,Re=Uint16Array,Qs=Int32Array,en=new Se([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),tn=new Se([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Xn=new Se([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lr=function(e,t){for(var n=new Re(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];for(var r=new Qs(n[30]),i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return{b:n,r}},cr=lr(en,2),Pd=cr.b,Ps=cr.r;Pd[28]=258,Ps[258]=28;var Ud=lr(tn,0),Yn=Ud.r,Us=new Re(32768);for(var de=0;de<32768;++de){var tt=(de&43690)>>1|(de&21845)<<1;tt=(tt&52428)>>2|(tt&13107)<<2,tt=(tt&61680)>>4|(tt&3855)<<4,Us[de]=((tt&65280)>>8|(tt&255)<<8)>>1}var Lt=function(e,t,n){for(var i=e.length,r=0,a=new Re(t);r<i;++r)e[r]&&++a[e[r]-1];var o=new Re(t);for(r=1;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;var d;if(n){d=new Re(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],m=o[e[r]-1]++<<h,g=m|(1<<h)-1;m<=g;++m)d[Us[m]>>c]=l}else for(d=new Re(i),r=0;r<i;++r)e[r]&&(d[r]=Us[o[e[r]-1]++]>>15-e[r]);return d},xt=new Se(288);for(var de=0;de<144;++de)xt[de]=8;for(var de=144;de<256;++de)xt[de]=9;for(var de=256;de<280;++de)xt[de]=7;for(var de=280;de<288;++de)xt[de]=8;var cs=new Se(32);for(var de=0;de<32;++de)cs[de]=5;var Bd=Lt(xt,9,0),Wd=Lt(cs,5,0),dr=function(e){return(e+7)/8|0},ur=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new Se(e.subarray(t,n))},Vd=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ms=function(e,t,n){var i=new Error(t||Vd[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,ms),!n)throw i;return i},Ke=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},zt=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},Ts=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var r=n.length,a=n.slice();if(!r)return{t:mr,l:0};if(r==1){var o=new Se(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(x,A){return x.f-A.f}),n.push({s:-1,f:25001});var d=n[0],c=n[1],l=0,h=1,m=2;for(n[0]={s:-1,f:d.f+c.f,l:d,r:c};h!=r-1;)d=n[n[l].f<n[m].f?l++:m++],c=n[l!=h&&n[l].f<n[m].f?l++:m++],n[h++]={s:-1,f:d.f+c.f,l:d,r:c};for(var g=a[0].s,i=1;i<r;++i)a[i].s>g&&(g=a[i].s);var f=new Re(g+1),v=Bs(n[h-1],f,0);if(v>t){var i=0,S=0,b=v-t,M=1<<b;for(a.sort(function(A,N){return f[N.s]-f[A.s]||A.f-N.f});i<r;++i){var k=a[i].s;if(f[k]>t)S+=M-(1<<v-f[k]),f[k]=t;else break}for(S>>=b;S>0;){var y=a[i].s;f[y]<t?S-=1<<t-f[y]++-1:++i}for(;i>=0&&S;--i){var C=a[i].s;f[C]==t&&(--f[C],++S)}v=t}return{t:new Se(f),l:v}},Bs=function(e,t,n){return e.s==-1?Math.max(Bs(e.l,t,n+1),Bs(e.r,t,n+1)):t[e.s]=n},Gn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Re(++t),i=0,r=e[0],a=1,o=function(c){n[i++]=c},d=1;d<=t;++d)if(e[d]==r&&d!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(r),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(r);a=1,r=e[d]}return{c:n.subarray(0,i),n:t}},It=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},hr=function(e,t,n){var i=n.length,r=dr(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<i;++a)e[r+a+4]=n[a];return(r+4+i)*8},Jn=function(e,t,n,i,r,a,o,d,c,l,h){Ke(t,h++,n),++r[256];for(var m=Ts(r,15),g=m.t,f=m.l,v=Ts(a,15),S=v.t,b=v.l,M=Gn(g),k=M.c,y=M.n,C=Gn(S),x=C.c,A=C.n,N=new Re(19),T=0;T<k.length;++T)++N[k[T]&31];for(var T=0;T<x.length;++T)++N[x[T]&31];for(var p=Ts(N,7),E=p.t,_=p.l,O=19;O>4&&!E[Xn[O-1]];--O);var D=l+5<<3,V=It(r,xt)+It(a,cs)+o,Y=It(r,g)+It(a,S)+o+14+3*O+It(N,E)+2*N[16]+3*N[17]+7*N[18];if(c>=0&&D<=V&&D<=Y)return hr(t,h,e.subarray(c,c+l));var Z,W,w,L;if(Ke(t,h,1+(Y<V)),h+=2,Y<V){Z=Lt(g,f,0),W=g,w=Lt(S,b,0),L=S;var H=Lt(E,_,0);Ke(t,h,y-257),Ke(t,h+5,A-1),Ke(t,h+10,O-4),h+=14;for(var T=0;T<O;++T)Ke(t,h+3*T,E[Xn[T]]);h+=3*O;for(var I=[k,x],K=0;K<2;++K)for(var ie=I[K],T=0;T<ie.length;++T){var X=ie[T]&31;Ke(t,h,H[X]),h+=E[X],X>15&&(Ke(t,h,ie[T]>>5&127),h+=ie[T]>>12)}}else Z=Bd,W=xt,w=Wd,L=cs;for(var T=0;T<d;++T){var ne=i[T];if(ne>255){var X=ne>>18&31;zt(t,h,Z[X+257]),h+=W[X+257],X>7&&(Ke(t,h,ne>>23&31),h+=en[X]);var re=ne&31;zt(t,h,w[re]),h+=L[re],re>3&&(zt(t,h,ne>>5&8191),h+=tn[re])}else zt(t,h,Z[ne]),h+=W[ne]}return zt(t,h,Z[256]),h+W[256]},Hd=new Qs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mr=new Se(0),Kd=function(e,t,n,i,r,a){var o=a.z||e.length,d=new Se(i+o+5*(1+Math.ceil(o/7e3))+r),c=d.subarray(i,d.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var m=Hd[t-1],g=m>>13,f=m&8191,v=(1<<n)-1,S=a.p||new Re(32768),b=a.h||new Re(v+1),M=Math.ceil(n/3),k=2*M,y=function(Te){return(e[Te]^e[Te+1]<<M^e[Te+2]<<k)&v},C=new Qs(25e3),x=new Re(288),A=new Re(32),N=0,T=0,p=a.i||0,E=0,_=a.w||0,O=0;p+2<o;++p){var D=y(p),V=p&32767,Y=b[D];if(S[V]=Y,b[D]=V,_<=p){var Z=o-p;if((N>7e3||E>24576)&&(Z>423||!l)){h=Jn(e,c,0,C,x,A,T,E,O,p-O,h),E=N=T=0,O=p;for(var W=0;W<286;++W)x[W]=0;for(var W=0;W<30;++W)A[W]=0}var w=2,L=0,H=f,I=V-Y&32767;if(Z>2&&D==y(p-I))for(var K=Math.min(g,Z)-1,ie=Math.min(32767,p),X=Math.min(258,Z);I<=ie&&--H&&V!=Y;){if(e[p+w]==e[p+w-I]){for(var ne=0;ne<X&&e[p+ne]==e[p+ne-I];++ne);if(ne>w){if(w=ne,L=I,ne>K)break;for(var re=Math.min(I,ne-2),je=0,W=0;W<re;++W){var $=p-I+W&32767,ae=S[$],te=$-ae&32767;te>je&&(je=te,Y=$)}}}V=Y,Y=S[V],I+=V-Y&32767}if(L){C[E++]=268435456|Ps[w]<<18|Yn[L];var se=Ps[w]&31,me=Yn[L]&31;T+=en[se]+tn[me],++x[257+se],++A[me],_=p+w,++N}else C[E++]=e[p],++x[e[p]]}}for(p=Math.max(p,_);p<o;++p)C[E++]=e[p],++x[e[p]];h=Jn(e,c,l,C,x,A,T,E,O,p-O,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=b,a.p=S,a.i=p,a.w=_)}else{for(var p=a.w||0;p<o+l;p+=65535){var ue=p+65535;ue>=o&&(c[h/8|0]=l,ue=o),h=hr(c,h+1,e.subarray(p,ue))}a.i=o}return ur(d,0,i+dr(h)+r)},qd=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Xd=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=qd[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}},Yd=function(e,t,n,i,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new Se(a.length+e.length);o.set(a),o.set(e,a.length),e=o,r.w=a.length}return Kd(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},fr=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},be=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Gd(e,t){return Yd(e,t||{},0,0)}var pr=function(e,t,n,i){for(var r in e){var a=e[r],o=t+r,d=i;Array.isArray(a)&&(d=fr(i,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,d]:(n[o+="/"]=[new Se(0),d],pr(a,o,n,i))}},Zn=typeof TextEncoder<"u"&&new TextEncoder,Jd=typeof TextDecoder<"u"&&new TextDecoder,Zd=0;try{Jd.decode(mr,{stream:!0}),Zd=1}catch{}function Qn(e,t){var n;if(Zn)return Zn.encode(e);for(var i=e.length,r=new Se(e.length+(e.length>>1)),a=0,o=function(l){r[a++]=l},n=0;n<i;++n){if(a+5>r.length){var d=new Se(a+8+(i-n<<1));d.set(r),r=d}var c=e.charCodeAt(n);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return ur(r,0,a)}var Ws=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;i>65535&&ms(9),t+=i+4}return t},ei=function(e,t,n,i,r,a,o,d){var c=i.length,l=n.extra,h=d&&d.length,m=Ws(l);be(e,t,o!=null?33639248:67324752),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var g=new Date(n.mtime==null?Date.now():n.mtime),f=g.getFullYear()-1980;if((f<0||f>119)&&ms(10),be(e,t,f<<25|g.getMonth()+1<<21|g.getDate()<<16|g.getHours()<<11|g.getMinutes()<<5|g.getSeconds()>>1),t+=4,a!=-1&&(be(e,t,n.crc),be(e,t+4,a<0?-a-2:a),be(e,t+8,n.size)),be(e,t+12,c),be(e,t+14,m),t+=16,o!=null&&(be(e,t,h),be(e,t+6,n.attrs),be(e,t+10,o),t+=14),e.set(i,t),t+=c,m)for(var v in l){var S=l[v],b=S.length;be(e,t,+v),be(e,t+2,b),e.set(S,t+4),t+=4+b}return h&&(e.set(d,t),t+=h),t},Qd=function(e,t,n,i,r){be(e,t,101010256),be(e,t+8,n),be(e,t+10,n),be(e,t+12,i),be(e,t+16,r)};function eu(e,t){t||(t={});var n={},i=[];pr(e,"",n,t);var r=0,a=0;for(var o in n){var d=n[o],c=d[0],l=d[1],h=l.level==0?0:8,m=Qn(o),g=m.length,f=l.comment,v=f&&Qn(f),S=v&&v.length,b=Ws(l.extra);g>65535&&ms(11);var M=h?Gd(c,l):c,k=M.length,y=Xd();y.p(c),i.push(fr(l,{size:c.length,crc:y.d(),c:M,f:m,m:v,u:g!=o.length||v&&f.length!=S,o:r,compression:h})),r+=30+g+b+k,a+=76+2*(g+b)+(S||0)+k}for(var C=new Se(a+22),x=r,A=a-r,N=0;N<i.length;++N){var m=i[N];ei(C,m.o,m,m.f,m.u,m.c.length);var T=30+m.f.length+Ws(m.extra);C.set(m.c,m.o+T),ei(C,r,m,m.f,m.u,m.c.length,m.o,m.m),r+=16+T+(m.m?m.m.length:0)}return Qd(C,r,i.length,A,x),C}function tu(e,t="image/png"){const n=atob(e),i=new Uint8Array(n.length);for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return new Blob([i],{type:t})}async function su(e){return typeof e.arrayBuffer=="function"?new Uint8Array(await e.arrayBuffer()):new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(new Uint8Array(i.result)),i.onerror=()=>n(i.error),i.readAsArrayBuffer(e)})}function nu(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(i),t(r)},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("the picture could not be read"))},r.src=i})}function iu(e,t){return Promise.race([e,new Promise((n,i)=>setTimeout(()=>i(new Error("timed out")),t))])}async function sn(e){if(typeof createImageBitmap=="function"){const n=await createImageBitmap(e);return{source:n,width:n.width,height:n.height}}const t=await iu(nu(e),3e3);return{source:t,width:t.naturalWidth,height:t.naturalHeight}}async function ru(e){try{const{width:t,height:n}=await sn(e);return{width:t,height:n}}catch{return{width:0,height:0}}}function gr(e,t,n){return new Promise((i,r)=>{e.toBlob(a=>a?i(a):r(new Error("the picture could not be made")),t,n)})}const au=320;async function ou(e,t=au){try{const{source:n,width:i,height:r}=await sn(e);if(!i||!r)return e;const a=Math.min(1,t/Math.max(i,r)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(i*a)),o.height=Math.max(1,Math.round(r*a));const d=o.getContext("2d");return d?(d.drawImage(n,0,0,o.width,o.height),await gr(o,"image/jpeg",.8)):e}catch{return e}}async function lu(e,t){const{source:n,width:i,height:r}=await sn(e);if(!i||!r)throw new Error("the picture could not be read");const a=document.createElement("canvas");a.width=i,a.height=r;const o=a.getContext("2d");if(!o)throw new Error("this browser cannot draw here");return o.drawImage(n,0,0,i,r),t.forEach(d=>aa(o,i,r,d)),gr(a,"image/png")}function cu(e){const t=new Map;return e.map(n=>{const i=(t.get(n)??0)+1;if(t.set(n,i),i===1)return n;const r=n.lastIndexOf(".");return r>0?`${n.slice(0,r)}-${i}${n.slice(r)}`:`${n}-${i}`})}async function du(e,t){const n=cu(t.map(o=>or(e,o))),i={},r=await Promise.all(t.map(o=>su(o.png)));n.forEach((o,d)=>{i[o]=r[d]});const a=eu(i,{level:0});return new Blob([a],{type:"application/zip"})}function ti(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function vr({capture:e,actualSize:t,onToggleSize:n,annotate:i}){const r=e.width&&e.height?e.width/e.height:void 0;return s.jsx("div",{className:`shots-picture${t&&!i?" is-actual":""}`,children:s.jsxs("div",{className:"shots-picture-frame",children:[s.jsx("img",{src:e.url,alt:yt(e),draggable:!1,onClick:i?void 0:n,className:n&&!i?"is-zoomable":void 0}),i&&s.jsx(oa,{enabled:!0,shape:i.shape,color:i.color,committed:i.marks,onCommittedChange:i.onMarksChange,onCommit:()=>{},mediaAspect:r})]})})}function uu({a:e,b:t}){return s.jsx("div",{className:"shots-compare",children:[e,t].map((n,i)=>s.jsxs("figure",{className:"shots-compare-side",children:[s.jsx("span",{className:"shots-compare-tag","aria-hidden":"true",children:i===0?"A":"B"}),n?s.jsxs(s.Fragment,{children:[s.jsx(vr,{capture:n}),s.jsx("figcaption",{className:"shots-details",children:ir(n)})]}):s.jsx("p",{className:"shots-compare-empty",children:"Pick a screenshot in the list to compare with."})]},i))})}function hu({captures:e,activeId:t,compare:n,taking:i,onTake:r,onPick:a,onDelete:o}){const d=u.useRef(null),c=Date.now(),l=g=>{var v,S;const f=(v=d.current)==null?void 0:v.querySelector(`[data-capture="${g}"]`);f==null||f.focus(),(S=f==null?void 0:f.scrollIntoView)==null||S.call(f,{block:"nearest"})},h=g=>{if(!e.length)return;const f=Math.max(0,e.findIndex(S=>S.id===t));let v=null;if(g.key==="ArrowDown"||g.key==="ArrowRight")v=Math.min(e.length-1,f+1);else if(g.key==="ArrowUp"||g.key==="ArrowLeft")v=Math.max(0,f-1);else if(g.key==="Home")v=0;else if(g.key==="End")v=e.length-1;else if((g.key==="Delete"||g.key==="Backspace")&&t&&!n){g.preventDefault(),o(t);return}v!==null&&(g.preventDefault(),a(e[v].id),l(e[v].id))},m=g=>n?n.a===g?"A":n.b===g?"B":null:null;return s.jsxs("div",{className:"shots-rail",children:[s.jsxs(U,{className:"shots-take",size:"md",onClick:r,disabled:i,children:[i?s.jsx(vt,{className:"animate-spin",size:14,"aria-hidden":"true"}):s.jsx(_t,{size:14,"aria-hidden":"true"}),i?"Taking screenshot…":"Take screenshot"]}),s.jsxs("div",{ref:d,className:"shots-list",role:"listbox","aria-label":n?"Screenshots, pick the right side":"Screenshots",onKeyDown:h,children:[i&&s.jsx("div",{className:"shots-thumb is-pending","aria-hidden":"true"}),e.map(g=>{const f=g.id===t,v=m(g.id);return s.jsxs("div",{"data-capture":g.id,role:"option","aria-selected":f,tabIndex:f||!t&&g===e[0]?0:-1,className:`shots-thumb${f?" is-active":""}${v?" is-compared":""}`,"aria-label":`${yt(g)}${g.markedFrom!==void 0?`, marked copy of ${g.markedFrom}`:""}, ${Fs(g.takenAt,c)}${v?`, side ${v}`:""}`,onClick:()=>a(g.id),children:[s.jsx("img",{src:g.thumbUrl,alt:"",draggable:!1}),v&&s.jsx("span",{className:"shots-thumb-side",children:v}),s.jsxs("span",{className:"shots-thumb-label",children:[s.jsxs("span",{className:"shots-thumb-n",children:[g.markedFrom!==void 0&&s.jsx(bi,{size:10,"aria-hidden":"true"}),g.n]}),s.jsx("span",{className:"shots-thumb-time",children:Fs(g.takenAt,c).replace("Today ","")})]})]},g.id)})]})]})}var Yt,mu=new Uint8Array(16);function fu(){if(!Yt&&(Yt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Yt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Yt(mu)}const pu=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function gu(e){return typeof e=="string"&&pu.test(e)}var xe=[];for(var As=0;As<256;++As)xe.push((As+256).toString(16).substr(1));function vu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]).toLowerCase();if(!gu(n))throw TypeError("Stringified UUID is invalid");return n}function yu(e,t,n){e=e||{};var i=e.random||(e.rng||fu)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,vu(i)}const gt=50,si=6e3;function Rs(e){const t=URL.createObjectURL(e.png),n=e.thumb===e.png?t:URL.createObjectURL(e.thumb);return{...e,url:t,thumbUrl:n}}function Gt(e){URL.revokeObjectURL(e.url),e.thumbUrl!==e.url&&URL.revokeObjectURL(e.thumbUrl)}function ni({url:e,thumbUrl:t,...n}){return n}function xu(e,t){return t.takenAt-e.takenAt||t.n-e.n}function bu(e,t=Nr){const{toast:n}=Fe(),[i,r]=u.useState([]),[a,o]=u.useState(null),[d,c]=u.useState(!1),[l,h]=u.useState(!0),[m,g]=u.useState(!1),f=u.useRef(null),v=u.useRef([]);v.current=i;const S=u.useRef(0),b=u.useRef(!0);u.useEffect(()=>{b.current=!0;let p=!1;return c(!1),r([]),o(null),S.current=0,(async()=>{var D;const E=await t();let _=[];try{_=await E.list(e)}catch{_=[]}if(p)return;f.current=E;const O=_.slice(0,gt).map(Rs);S.current=O.reduce((V,Y)=>Math.max(V,Y.n),0),h(E.persistent),r(O),o(((D=O[0])==null?void 0:D.id)??null),c(!0)})(),()=>{p=!0}},[e]),u.useEffect(()=>()=>{b.current=!1,v.current.forEach(Gt)},[]);const M=u.useCallback(async p=>{const E=f.current;if(E)try{await E.put(p)}catch{n(`Couldn’t keep ${yt(p)} in this browser. It’s here until you leave the page.`,"error")}},[n]),k=u.useCallback((p,E)=>{var V,Y;const _=[...p,...v.current].sort(xu),O=_.slice(gt),D=_.slice(0,gt);O.forEach(Gt),O.length&&((V=f.current)==null||V.delete(O.map(Z=>Z.id)).catch(()=>{})),v.current=D,r(D),o(D.some(Z=>Z.id===E)?E:((Y=D[0])==null?void 0:Y.id)??null)},[]),y=u.useCallback(async(p,E={})=>{const[_,O]=await Promise.all([ru(p),ou(p)]);if(!b.current)return;S.current+=1;const D={id:yu(),udid:e,n:S.current,takenAt:Date.now(),width:_.width,height:_.height,bytes:p.size,png:p,thumb:O,...E};k([Rs(D)],D.id),await M(D)},[e,k,M]),C=u.useCallback(async()=>{g(!0);try{let p;try{p=await q.getScreenshot(e)}catch(E){n(ze("take a screenshot",E),"error");return}if(!(p!=null&&p.screenshot)){const E=(p==null?void 0:p.error)||(p==null?void 0:p.message);n(E?ze("take a screenshot",{message:E}):"Couldn’t take a screenshot. The phone sent no picture.","error");return}await y(tu(p.screenshot))}finally{b.current&&g(!1)}},[e,n,y]),x=u.useCallback((p,E)=>y(E,{markedFrom:p.n}),[y]),A=u.useCallback(async p=>{if(!b.current||!p.length)return;const E=p.filter(O=>!v.current.some(D=>D.id===O.id));k(E.map(Rs),p[0].id);const _=f.current;await Promise.all(E.map(O=>_==null?void 0:_.put(O).catch(()=>{})))},[k]),N=u.useCallback(async p=>{var Y;const E=v.current,_=E.findIndex(Z=>Z.id===p);if(_<0)return;const O=E[_],D=E.filter(Z=>Z.id!==p);v.current=D,r(D),o(Z=>{var W;return Z===p?((W=D[_]??D[_-1])==null?void 0:W.id)??null:Z}),Gt(O);const V=ni(O);n(`Deleted ${yt(O)}`,"info",si,{label:"Undo",onClick:()=>void A([V])}),await((Y=f.current)==null?void 0:Y.delete([p]).catch(()=>{}))},[n,A]),T=u.useCallback(async()=>{var _;const p=v.current;if(!p.length)return;v.current=[],r([]),o(null),p.forEach(Gt);const E=p.map(ni);n(`Cleared ${p.length} screenshot${p.length===1?"":"s"}`,"info",si,{label:"Undo",onClick:()=>void A(E)}),await((_=f.current)==null?void 0:_.clear(e).catch(()=>{}))},[e,n,A]);return{captures:i,selectedId:a,select:o,ready:d,persistent:l,taking:m,take:C,addMarkedCopy:x,remove:N,clearAll:T}}function ju({udid:e,deviceName:t,openStore:n}){const{toast:i}=Fe(),r=bu(e,n),{captures:a,selectedId:o,select:d}=r,c=a.find(I=>I.id===o)??null,[l,h]=u.useState("view"),[m,g]=u.useState(null),[f,v]=u.useState(!1),[S,b]=u.useState("RECT"),[M,k]=u.useState(Fr.color),[y,C]=u.useState([]),[x,A]=u.useState(!1),[N,T]=u.useState(!1),p=u.useCallback(()=>{h("view"),C([]),g(null)},[]);u.useEffect(()=>{l!=="view"&&(c?l==="compare"&&m&&!a.some(I=>I.id===m)&&g(null):p())},[l,c,m,a,p]);const E=u.useRef(null),_=u.useRef(l);_.current=l,u.useEffect(()=>{const I=E.current;if(!I)return;const K=ie=>{ie.key!=="Escape"||ie.defaultPrevented||_.current==="view"||(ie.preventDefault(),p())};return I.addEventListener("keydown",K),()=>I.removeEventListener("keydown",K)},[p]);const O=I=>{if(l==="compare"){I!==o&&g(I);return}l==="annotate"&&I!==o&&p(),d(I)},D=()=>{if(!c)return;const I=a.indexOf(c),K=a[I+1]??a[I-1]??null;C([]),g((K==null?void 0:K.id)??null),h("compare")},V=async()=>{c&&(await Fd(c.png)?i(`Copied ${yt(c)}`,"success"):i("Your browser can’t copy pictures on this address. Use Download instead.","error"))},Y=()=>{c&&ti(c.png,or(t,c))},Z=async()=>{T(!0);try{ti(await du(t,a),Od(t))}catch(I){i(ze("make the zip",I),"error")}finally{T(!1)}},W=async()=>{if(!(!c||!y.length)){A(!0);try{const I=await lu(c.png,y);await r.addMarkedCopy(c,I),i(`Saved a marked copy of ${yt(c)}`,"success"),p()}catch(I){i(ze("save the marked copy",I),"error")}finally{A(!1)}}},w=a.length,L=r.persistent?w>=gt?`${w} of ${gt} kept · the oldest goes when you take another`:`${w} of ${gt} kept`:"Kept until you leave this page",H=a.find(I=>I.id===m)??null;return s.jsxs("div",{ref:E,className:"shots-root",children:[s.jsxs("header",{className:"shots-head",children:[s.jsxs("h4",{className:"shots-title",children:[s.jsx(_t,{size:14,"aria-hidden":"true"}),"Screenshots"]}),r.ready&&s.jsx("span",{className:"shots-kept",title:r.persistent?"This browser keeps the newest 50 screenshots of each phone.":"This browser isn’t saving screenshots here, for example in a private window.",children:L}),s.jsx("span",{className:"shots-actions-gap"}),l==="compare"?s.jsx(U,{variant:"secondary",size:"sm",onClick:p,children:"Done"}):s.jsxs(U,{variant:"secondary",size:"sm",onClick:D,disabled:w<2||l==="annotate",children:[s.jsx(Aa,{size:13,"aria-hidden":"true"}),"Compare"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:Z,disabled:!w||N,children:[N?s.jsx(vt,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(Ia,{size:13,"aria-hidden":"true"}),"Download all"]}),s.jsx(U,{variant:"secondary",size:"sm",onClick:()=>{p(),r.clearAll()},disabled:!w,children:"Clear all"})]}),r.ready&&!w&&!r.taking?s.jsxs("div",{className:"shots-empty",children:[s.jsx(_t,{size:22,"aria-hidden":"true"}),s.jsx("p",{className:"shots-empty-title",children:"No screenshots yet"}),s.jsxs("p",{className:"shots-empty-hint",children:["Take one to keep it here. This browser keeps the newest ",gt," for this phone."]}),s.jsxs(U,{size:"md",onClick:()=>void r.take(),children:[s.jsx(_t,{size:14,"aria-hidden":"true"}),"Take screenshot"]})]}):r.ready?s.jsxs("div",{className:"shots-body",children:[s.jsx(hu,{captures:a,activeId:l==="compare"?m??o:o,compare:l==="compare"&&o?{a:o,b:m}:void 0,taking:r.taking,onTake:()=>void r.take(),onPick:O,onDelete:I=>void r.remove(I)}),s.jsx("section",{className:"shots-preview","aria-label":"Preview",children:c&&l==="compare"?s.jsx(uu,{a:c,b:H}):c?s.jsxs(s.Fragment,{children:[s.jsx(vr,{capture:c,actualSize:f,onToggleSize:()=>v(I=>!I),annotate:l==="annotate"?{shape:S,color:M,marks:y,onMarksChange:C}:void 0}),s.jsxs("footer",{className:"shots-footer",children:[s.jsx("p",{className:"shots-details",children:ir(c)}),l==="annotate"?s.jsx(Id,{shape:S,color:M,marks:y.length,saving:x,onShape:b,onColor:k,onUndo:()=>C(I=>I.slice(0,-1)),onClear:()=>C([]),onCancel:p,onSave:()=>void W()}):s.jsxs("div",{className:"shots-actions",children:[s.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>void V(),children:[s.jsx(Oe,{size:13,"aria-hidden":"true"}),"Copy"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>{v(!1),h("annotate")},children:[s.jsx(bi,{size:13,"aria-hidden":"true"}),"Annotate"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:Y,children:[s.jsx(vi,{size:13,"aria-hidden":"true"}),"Download"]}),s.jsxs(U,{variant:"ghost",size:"sm","aria-pressed":f,onClick:()=>v(I=>!I),children:[f?s.jsx(Za,{size:13,"aria-hidden":"true"}):s.jsx(Xa,{size:13,"aria-hidden":"true"}),"Actual size"]}),s.jsx("span",{className:"shots-actions-gap"}),s.jsxs(U,{variant:"ghost",size:"sm",className:"shots-delete",onClick:()=>void r.remove(c.id),children:[s.jsx(la,{size:13,"aria-hidden":"true"}),"Delete"]})]})]})]}):null})]}):null]})}const ii=e=>!!e.session_id&&!String(e.session_id).startsWith("manual_");function wu({device:e,onClose:t,titleId:n}){const i=Wi(t),{toast:r}=Fe(),a=ee=>oe=>{Rr(oe)||r(ze(ee,oe),"error")},o=Bt(),{tab:d}=oi(),c=ds(),l=u.useRef(null),[h,m]=u.useState({width:0,height:0}),[g,f]=u.useState("inspect"),[v,S]=u.useState(null),[b,M]=u.useState(d||"actions"),k=b==="omni"&&g==="inspect",[y,C]=u.useState(!0),[x,A]=u.useState(!1),[N,T]=u.useState(0),[p,E]=u.useState(e),[_,O]=u.useState(0),D=u.useCallback(()=>O(Date.now()),[]),V=it(p);u.useEffect(()=>{Er(p.udid,V),document.title=Tr(c.pathname)},[p.udid,V,c.pathname]);const[Y,Z]=u.useState(!1),[W,w]=u.useState(!1),[L,H]=u.useState(!1),[I,K]=u.useState(null),ie=u.useRef(!1),X=10,[ne,re]=u.useState(!1),[je,$]=u.useState(!1),ae=cc(p==null?void 0:p.udid,!W),te=()=>{navigator.clipboard.writeText(p.udid).catch(()=>{}),re(!0),setTimeout(()=>re(!1),1500)},se=u.useRef(""),me=u.useRef(null),[ue,Te]=u.useState(!1);u.useEffect(()=>{b&&(!d||d!==b)&&o(`/devices/${e.udid}/control/${b}${c.search}`,{replace:!0})},[b,d,e.udid,o,c.search]);const[rt,at]=u.useState(0);dc(()=>{q.leaveStream(p.udid).catch(()=>{})},()=>at(ee=>ee+1));const Ge=u.useCallback(async()=>{try{await q.startStream(e.udid,{player:"mjpeg"})}catch(ee){console.error("Switching the stream to MJPEG failed:",ee)}},[e.udid]),he=u.useCallback(async()=>{ie.current||(ie.current=!0,console.warn("H.264 stream failed; falling back to MJPEG"),H(!1),K(null),Z(!1),await Ge(),H(!0))},[Ge]);u.useEffect(()=>{let ee=!1;return ie.current=!1,(async()=>{try{A(!0),H(!1),K(null);const fe=ii(p),pe=await q.startStream(p.udid,fe?{player:"mjpeg"}:void 0);if(!fe&&(pe!=null&&pe.h264Path)&&Br(p.platform,pe.type,Ar())==="h264"){const we=await Wr(p.udid,pe.h264Path).catch(()=>null);ee||(we?K(we):await Ge())}const ge=(await q.getDevices()).find(we=>we.udid===p.udid);ge&&E(ge)}catch(fe){console.error("Auto-start stream failed:",fe)}finally{ee||(A(!1),H(!0))}})(),()=>{ee=!0,q.leaveStream(p.udid).catch(()=>{})}},[e.udid,rt]);const Je=parseInt(p.screenWidth||"1080",10),Pe=parseInt(p.screenHeight||"1920",10),Ce=Math.min(Je,Pe),Me=Math.max(Je,Pe),ot=Ce/Me,Ie=u.useCallback(()=>{const ee=!y,oe=ee?window.innerHeight*.55:window.innerHeight*.7,fe=620,Ae=window.innerWidth>900;let ge;ee?ge=Ae?Math.min(window.innerWidth*.8,window.innerWidth-fe):window.innerWidth*.8:ge=window.innerWidth*.45;const we=y?ot:1/ot;let ye,ve;y?(ye=oe,ve=ye*we,ve>ge&&(ve=ge,ye=ve/we)):(ve=ge,ye=ve/we,ye>oe&&(ye=oe,ve=ye*we)),m({width:ve,height:ye})},[ot,y]);u.useEffect(()=>(Ie(),window.addEventListener("resize",Ie),()=>window.removeEventListener("resize",Ie)),[Ie]),u.useEffect(()=>{const ee=async()=>{if(se.current.length>0){const fe=se.current;se.current="";try{await q.typeText(p.udid,fe)}catch(pe){console.error("Keyboard buffering flush failed:",pe)}finally{D()}}},oe=fe=>{const pe=document.activeElement;if(pe&&(pe.tagName==="INPUT"||pe.tagName==="TEXTAREA"||pe.isContentEditable)||!ue&&b!=="terminal")return;const ge=fe.key;ge==="Enter"?(me.current&&clearTimeout(me.current),ee(),q.pressKey(p.udid,p.platform==="android"?66:"enter").finally(D)):ge==="Backspace"?(me.current&&clearTimeout(me.current),ee(),q.pressKey(p.udid,p.platform==="android"?67:"backspace").finally(D)):ge.length===1&&(se.current+=ge,me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{ee()},50))};return window.addEventListener("keydown",oe),()=>{window.removeEventListener("keydown",oe),me.current&&clearTimeout(me.current)}},[p.udid,p.platform,ue,b,D]);const[Ue,Ze]=u.useState(Date.now()),bt=()=>{const ee=N>0?`r=${N}&`:"";return ii(p)?`/xenon/api/session/${p.session_id}/live_video?${ee}t=${Ue}`:`/xenon/api/control/${p.udid}/stream?${ee}t=${Ue}`};u.useEffect(()=>{N>0&&Ze(Date.now())},[N]),u.useEffect(()=>{if(Y||W)return;const ee=setTimeout(()=>{I?he():w(!0)},3e4);return()=>clearTimeout(ee)},[Y,W,N,I,he]);const Be=u.useRef(null),Qe=ee=>{const oe=ee.currentTarget.getBoundingClientRect();return{x:ee.clientX-oe.left,y:ee.clientY-oe.top}},jt=ee=>{const oe=Qe(ee);Be.current={x:oe.x,y:oe.y,time:Date.now()}},We=async ee=>{var At;if(!Be.current)return;const oe=Be.current,fe=Qe(ee),pe=Date.now()-oe.time,Ae=(At=l.current)==null?void 0:At.getBoundingClientRect(),ge=(Ae==null?void 0:Ae.width)||h.width,we=(Ae==null?void 0:Ae.height)||h.height;let ye,ve,ct,kt;y?(ye=oe.x/ge*Ce,ve=oe.y/we*Me,ct=fe.x/ge*Ce,kt=fe.y/we*Me):(ye=oe.x/ge*Me,ve=oe.y/we*Ce,ct=fe.x/ge*Me,kt=fe.y/we*Ce);const Wt=Math.abs(ct-ye),dt=Math.abs(kt-ve);try{pe<500&&Wt<10&&dt<10?await q.tap(p.udid,Math.round(ye),Math.round(ve)):pe>=500&&Wt<10&&dt<10?await q.touchAndHold(p.udid,Math.round(ye),Math.round(ve),pe):await q.swipe(p.udid,Math.round(ye),Math.round(ve),Math.round(ct),Math.round(kt))}catch(Rt){console.error("Action failed:",Rt)}finally{D()}Be.current=null},wt=()=>q.pressKey(p.udid,p.platform==="android"?Mt.HOME:xs.HOME).catch(a("press Home")).finally(D),_e=()=>q.pressKey(p.udid,Mt.BACK).catch(a("press Back")).finally(D),lt=()=>q.pressKey(p.udid,Mt.APP_SWITCH).catch(a("open the app switcher")).finally(D),F=()=>q.pressKey(p.udid,p.platform==="android"?Mt.VOLUME_UP:xs.VOLUME_UP).catch(a("press Volume up")).finally(D),Q=()=>q.pressKey(p.udid,p.platform==="android"?Mt.VOLUME_DOWN:xs.VOLUME_DOWN).catch(a("press Volume down")).finally(D),le=()=>q.lock(p.udid).catch(a("lock the device")).finally(D),Ne=async()=>{$(!0);try{await q.unlock(p.udid).catch(a("unlock the device"))}finally{D(),setTimeout(()=>$(!1),2500)}};return s.jsxs("div",{className:"device-control-view",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"control-view-top-bar",children:[s.jsxs("button",{className:"back-to-devices-btn",onClick:i,children:[s.jsx(bn,{size:18})," DEVICES"]}),s.jsxs("div",{className:"device-info-mini",children:[s.jsx("span",{className:`device-pill platform-pill ${p.platform}`,children:p.platform==="ios"?"Apple":"Android"}),s.jsxs("span",{className:"device-pill version-pill",children:["v",p.sdk]}),p.reservedUntil&&Date.now()<p.reservedUntil&&s.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${p.reservedBy}${p.reservationReason?`: ${p.reservationReason}`:""}`,children:["Reserved by ",p.reservedBy||"someone"]}),s.jsx("h2",{id:n,className:"device-name-text",children:V}),s.jsxs("span",{className:"udid-chip",title:p.udid,children:[s.jsx("span",{className:"udid-chip__value",children:p.udid}),s.jsx("button",{type:"button",className:"udid-chip__copy",onClick:te,"aria-label":"Copy UDID",title:ne?"Copied!":"Copy UDID",children:ne?s.jsx(Ot,{size:12}):s.jsx(Oe,{size:12})})]})]})]}),s.jsxs("div",{className:`control-view-main ${y?"":"is-landscape"} ${b==="omni"?"omni-mode":""}`,children:[s.jsxs("div",{className:"device-preview-column",children:[s.jsx("div",{className:"device-screen-wrapper",children:s.jsxs("div",{ref:ee=>{l.current=ee,S(ee)},className:`device-stream-canvas ${y?"":"landscape"} ${ue?"focused":""} ${k?"is-inspecting":""}`,style:{width:h.width,height:h.height,background:"var(--black)"},tabIndex:0,onFocus:()=>Te(!0),onBlur:()=>Te(!1),onMouseDown:k?void 0:jt,onMouseUp:k?void 0:We,children:[W?s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(qe,{size:40,color:"var(--red, #f87171)"}),s.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),s.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{w(!1),T(0)},children:"Retry"})]}):(x||!Y)&&s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(Dt,{size:40,className:"animate-spin",color:"var(--color-accent)"}),s.jsx("p",{style:{marginTop:16},children:x?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!W&&I&&s.jsx(Pr,{wsUrl:I,className:"device-stream-image",onReady:()=>Z(!0),onFatal:he}),!W&&!I&&L&&s.jsx(li,{src:bt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>Z(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),Z(!1),N>=X){w(!0);return}setTimeout(()=>T(ee=>ee+1),2e3)}}),ae==="off"&&!W&&s.jsxs("div",{className:"device-screen-off",role:"status",children:[s.jsx(eo,{size:32}),s.jsx("p",{children:"Display is off"}),s.jsx("span",{children:"The stream is fine — the device is asleep."}),s.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:Ne,disabled:je,children:je?"Waking…":"Wake device"})]})]})}),s.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":y?"vertical":"horizontal",children:[s.jsx("button",{className:`footer-action-btn ${y?"active":""}`,onClick:()=>C(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":y,children:s.jsx(ho,{size:18})}),s.jsx("button",{className:`footer-action-btn ${y?"":"active"}`,onClick:()=>C(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!y,children:s.jsx(co,{size:18})}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:wt,title:"Home","aria-label":"Home",children:s.jsx(Ur,{size:18})}),p.platform==="android"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"footer-action-btn",onClick:_e,title:"Back","aria-label":"Back",children:s.jsx(bn,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:lt,title:"App switcher","aria-label":"App switcher",children:s.jsx(ci,{size:18})})]}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:F,title:"Volume up","aria-label":"Volume up",children:s.jsx(Mo,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:Q,title:"Volume down","aria-label":"Volume down",children:s.jsx(Ao,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:le,title:"Lock device","aria-label":"Lock device",children:s.jsx(ca,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:Ne,title:"Unlock device","aria-label":"Unlock device",children:s.jsx(Va,{size:18})})]})]}),s.jsxs("div",{className:"device-interactions-column",children:[s.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[s.jsxs("button",{className:`tab-btn ${b==="actions"?"active":""}`,onClick:()=>M("actions"),role:"tab","aria-selected":b==="actions",children:[s.jsx(fi,{size:13}),s.jsx("span",{children:"Actions"})]}),s.jsxs("button",{className:`tab-btn ${b==="screenshot"?"active":""}`,onClick:()=>M("screenshot"),role:"tab","aria-selected":b==="screenshot",children:[s.jsx(_t,{size:13}),s.jsx("span",{children:"Screenshot"})]}),s.jsxs("button",{className:`tab-btn ${b==="logs"?"active":""}`,onClick:()=>M("logs"),role:"tab","aria-selected":b==="logs",children:[s.jsx(ji,{size:13}),s.jsx("span",{children:"Logs"})]}),s.jsxs("button",{className:`tab-btn ${b==="terminal"?"active":""}`,onClick:()=>M("terminal"),role:"tab","aria-selected":b==="terminal",children:[s.jsx(na,{size:13}),s.jsx("span",{children:"Shell"})]}),s.jsxs("button",{className:`tab-btn ${b==="omni"?"active":""}`,onClick:()=>M("omni"),role:"tab","aria-selected":b==="omni",children:[s.jsx(Ir,{size:13}),s.jsx("span",{children:"Omni-Vision"})]})]}),s.jsx("div",{className:`interactions-scroll-area ${b==="terminal"?"terminal-mode":""} ${b==="screenshot"||b==="logs"?"screenshot-mode":""}`,children:s.jsxs("div",{className:"tab-content",children:[b==="omni"&&s.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:s.jsx(lc,{sessionId:p.session_id?String(p.session_id):null,udid:p.udid,streamUrl:bt(),embedded:!0,overlayTarget:v,onModeChange:f,deviceActionAt:_})}),b==="actions"&&s.jsx($d,{udid:p.udid,platform:p.platform,deviceName:V,screenWidth:Ce,screenHeight:Me}),b==="screenshot"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(ju,{udid:p.udid,deviceName:V})}),b==="logs"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(yd,{udid:p.udid,platform:p.platform})}),b==="terminal"&&s.jsx("div",{className:"action-card full-height",children:s.jsx(kl,{platform:(p.platform||"").toLowerCase(),prompt:`${(p.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${V} (${p.udid}).
282
- Internal Shell Environment.`,onCommand:async ee=>{const oe=await q.executeShell(p.udid,ee);if(oe.error)throw new Error(oe.error);return oe.output}})})]})})]})]}),p.session_id&&!String(p.session_id).startsWith("manual_")&&s.jsx(_r,{sessionId:String(p.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const yr="xenon.devices.view";function xr(){try{return window.localStorage}catch{return null}}function ku(e,t){const n=e.get("view");return n==="table"||n==="cards"?n:t}function Su(e,t,n){t==="table"||t!==n?e.set("view",t):e.delete("view")}function ri(e=xr()){try{return(e==null?void 0:e.getItem(yr))==="table"?"table":"cards"}catch{return"cards"}}function Cu(e,t=xr()){try{t==null||t.setItem(yr,e)}catch{}}class Nu extends ft.Component{constructor(t){super(t),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=ft.createRef(),this.containerRef=ft.createRef(),this.stickyGroupRef=ft.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,i=this.containerRef.current;!n||!i||(this.stickyObserver=new ResizeObserver(()=>{i.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var a,o;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const i=n.target;(a=i==null?void 0:i.closest)!=null&&a.call(i,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(o=this.searchRef.current)==null||o.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(al),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const t=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(t,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var t;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(t=this.stickyObserver)==null||t.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(t){return t.filter(n=>n.busy).length}async fetchDevices(){try{const t=await q.getDevices(),n=this.getBusyDevicesCount(t),i=await q.getPendingSessionsCount(),r=await q.getQueueSummary();this.setState({devices:t,activeSessionsCount:n,pendingSessionsCount:i,queueSummary:r,loaded:!0})}catch(t){console.log(t),this.setState({loaded:!0})}}setFilters(t){this.props.onFiltersChange({...this.props.filters,...t})}getFiltered(){const t=Date.now();return this.state.devices.filter(n=>es(n,this.props.filters,t))}render(){const t=this.getFiltered(),{udid:n}=this.props.params,i=n?this.state.devices.find(l=>l.udid===n):null,{filters:r}=this.props,a=dl(this.state.devices,r,Date.now()),o=[{value:"all",label:"Any platform",count:a.platform.all},{value:"android",label:"Android",count:a.platform.android},{value:"ios",label:"iOS",count:a.platform.ios}];(ul(this.state.devices)||r.platform==="tvos")&&o.push({value:"tvos",label:"tvOS",count:a.platform.tvos});const d=[{value:"all",label:"Any type",count:a.type.all},{value:"real",label:"Real devices",count:a.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:a.type.virtual}],c=`/devices${this.props.locationSearch}`;return s.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[s.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[s.jsx(zr,{icon:Ms,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),s.jsxs("div",{className:"de2-toolbar",children:[s.jsx(jn,{size:"sm",label:"Status",value:r.status,onChange:l=>this.setFilters({status:l}),segments:[{value:"all",label:"All",count:a.status.all},{value:"ready",label:"Ready",tone:"ready",count:a.status.ready},{value:"busy",label:"Busy",tone:"busy",count:a.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:a.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:a.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:a.status.offline}]}),s.jsxs("div",{className:"de2-toolbar-row",children:[s.jsxs("div",{className:"de2-search-wrap",children:[s.jsx(Hs,{size:13,className:"de2-search-icon","aria-hidden":"true"}),s.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:r.q,onChange:l=>this.setFilters({q:l.target.value})}),s.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),s.jsx(Sn,{name:"Platform",value:r.platform,anyValue:"all",options:o,onChange:l=>this.setFilters({platform:l})}),s.jsx(Sn,{name:"Type",value:r.type,anyValue:"all",options:d,onChange:l=>this.setFilters({type:l})}),hl(r)&&s.jsx(U,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),s.jsxs("div",{className:"de2-result",children:[s.jsx(jn,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&s.jsx("span",{"aria-live":"polite",children:ml(t.length,this.state.devices.length)}),s.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:s.jsx(Jt,{size:13,"aria-hidden":"true"})})]})]})]})]}),t.length>0?this.props.view==="table"?s.jsx(wl,{devices:t,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):s.jsx(rl,{devices:t,reloadDevices:()=>this.fetchDevices()}):s.jsxs("div",{className:"device-explorer-empty stagger-1",children:[s.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?s.jsx(Ms,{size:32}):s.jsx(Jt,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Global Device Registry Empty"}),s.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),s.jsxs(U,{variant:"primary",onClick:()=>this.fetchDevices(),children:[s.jsx(Jt,{size:14}),"Manual sync"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"No devices match these filters"}),s.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),s.jsx(U,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Loading devices…"}),s.jsx("p",{children:"Syncing the global device registry."})]})]}),i&&s.jsx(mc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(c),children:s.jsx("div",{className:"device-control-modal",children:s.jsx(wu,{device:i,titleId:"device-control-title",onClose:()=>this.props.navigate(c)})})})]})}}function dh(){const e=oi(),t=Bt(),n=ds(),[i,r]=Mr(),{on:a}=$r(),o=ol(i),d=ku(i,ri()),c=yl(i),l=(h,m,g)=>{const f=ll(h);Su(f,m,ri()),xl(f,g),r(f,{replace:!0})};return s.jsx(Nu,{params:e,navigate:t,onSocketEvent:a,filters:o,onFiltersChange:h=>l(h,d,c),view:d,onViewChange:h=>{Cu(h),l(o,h,c)},sort:c,onSortChange:h=>l(o,d,h),locationSearch:n.search})}export{Nu as DeviceExplorer,dh as default};