@xenon-device-management/xenon 2.11.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/package.json +2 -2
- package/lib/public/assets/{AnnotationOverlay-Dt5AmXCR.js → AnnotationOverlay-CzbFYtPI.js} +1 -1
- package/lib/public/assets/{ApiKeyGate-CS05jXd7.js → ApiKeyGate-CA5KFHHJ.js} +1 -1
- package/lib/public/assets/{BugReportButton-ejWk5lof.js → BugReportButton-D-DSGg8C.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-paDEFU4B.js +2 -0
- package/lib/public/assets/{EmptyState-DyojFa86.js → EmptyState-BE_5f8Vw.js} +1 -1
- package/lib/public/assets/{FieldGroup-Dm-U3Ucr.js → FieldGroup-DqMf7Rf3.js} +1 -1
- package/lib/public/assets/{FilterMenu-B3hgDfy_.js → FilterMenu-BQY75Su3.js} +1 -1
- package/lib/public/assets/{Menu-DFNsTx2i.js → Menu-BiW3os9u.js} +1 -1
- package/lib/public/assets/{Modal-BdWYrwfK.js → Modal-DfawTxih.js} +1 -1
- package/lib/public/assets/RecordingPage-BvemyRiy.js +1 -0
- package/lib/public/assets/{RecordingsPage-FAUS-RwG.js → RecordingsPage-CXfw7wpd.js} +2 -2
- package/lib/public/assets/{SegmentedControl-EBzIUjnM.js → SegmentedControl-B7m9kpom.js} +1 -1
- package/lib/public/assets/{SettingCard-BQ8wMHrz.js → SettingCard-Cw6lDD0l.js} +1 -1
- package/lib/public/assets/{Table-DDahAwGb.js → Table-DlEuFgv-.js} +1 -1
- package/lib/public/assets/{activity-CFEfukVD.js → activity-CnLvNwae.js} +1 -1
- package/lib/public/assets/{ai-settings-iPPNZMnS.js → ai-settings-D7Te8o-a.js} +2 -2
- package/lib/public/assets/{api-keys-DS979X_e.js → api-keys-DphSVzBr.js} +1 -1
- package/lib/public/assets/{apps-DQnxhScG.js → apps-vUfu15lX.js} +3 -3
- package/lib/public/assets/{arrow-left-CIqcStpJ.js → arrow-left-CLQWAiCY.js} +1 -1
- package/lib/public/assets/{arrow-right-Pw0XgjBJ.js → arrow-right-K6A5e_Ee.js} +1 -1
- package/lib/public/assets/{arrow-up-right-DWaEiSQf.js → arrow-up-right-DUA_lq6f.js} +1 -1
- package/lib/public/assets/{auth-shell-DvJ8qKdR.js → auth-shell-BYRHcZd6.js} +2 -2
- package/lib/public/assets/{builds-page-BIWuhGph.js → builds-page-C0fTvIG8.js} +1 -1
- package/lib/public/assets/{button-B1XDl_TT.js → button-BxnHCCsX.js} +1 -1
- package/lib/public/assets/{calendar-BPrY2NZL.js → calendar-CqVsn28A.js} +1 -1
- package/lib/public/assets/{check-DjbzNVbd.js → check-R6V3bot0.js} +1 -1
- package/lib/public/assets/{chevron-right-J_WfelGu.js → chevron-right-BA2Fntu-.js} +1 -1
- package/lib/public/assets/{circle-check-CGwn46BE.js → circle-check-D4EzyGzs.js} +1 -1
- package/lib/public/assets/{circle-x-Rfn2Zmq3.js → circle-x-Cf6AF2B2.js} +1 -1
- package/lib/public/assets/{clock-BAD4KA9j.js → clock-EZfet0sS.js} +1 -1
- package/lib/public/assets/{copy-CcNlsrXH.js → copy-Bc6P8v9V.js} +1 -1
- package/lib/public/assets/device-explorer-BFXpRq6d.js +279 -0
- package/lib/public/assets/device-explorer-CHv1miyr.css +1 -0
- package/lib/public/assets/{download-CoBA2mT_.js → download-Bd8OGLzi.js} +1 -1
- package/lib/public/assets/{forgot-password-BrV3pKRK.js → forgot-password-CoE7Ugtx.js} +1 -1
- package/lib/public/assets/{index-DQa193-A.css → index-BTYMAqNW.css} +1 -1
- package/lib/public/assets/{index-BHI_dBXi.js → index-BiL0Enl_.js} +1 -1
- package/lib/public/assets/index-CHOr4JCs.js +219 -0
- package/lib/public/assets/{input-Bo2b9153.js → input-CJ8z3IO5.js} +1 -1
- package/lib/public/assets/{line-chart-X7ZCpjWB.js → line-chart-CPK0ObjV.js} +1 -1
- package/lib/public/assets/{list-checks-Cqso6ROH.js → list-checks-mXGHUVbB.js} +1 -1
- package/lib/public/assets/{lock-D9WyaPyU.js → lock-BSXM1xvq.js} +1 -1
- package/lib/public/assets/{login-DqIYeZ2q.js → login-Ct2iW066.js} +1 -1
- package/lib/public/assets/{maintenance-settings-C7pWE0--.js → maintenance-settings-DaOs00P6.js} +1 -1
- package/lib/public/assets/{monitor-ZC2MoScA.js → monitor-D8WQK8md.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-DXh-LIn9.js → mouse-pointer-2-Cw2tWzDX.js} +1 -1
- package/lib/public/assets/{network-CivILLOW.js → network-Ba_uFxWo.js} +1 -1
- package/lib/public/assets/{overview-ClDfJNL5.js → overview-CxrZ7_6k.js} +1 -1
- package/lib/public/assets/{page-header-CV-WOQ7B.js → page-header-Cm1XL49f.js} +1 -1
- package/lib/public/assets/play-C0CuKLXj.js +11 -0
- package/lib/public/assets/{plus-DOp8RUCs.js → plus-CIIvR_6Z.js} +1 -1
- package/lib/public/assets/{profile-page-Ckx1bcSx.js → profile-page-BZ_e-Bgw.js} +2 -2
- package/lib/public/assets/recording-group-store-BWeeNs2_.js +26 -0
- package/lib/public/assets/{reset-password-CZDSfFZ6.js → reset-password-lfNz8Rm1.js} +1 -1
- package/lib/public/assets/{runbook-page-BXe7SL5K.js → runbook-page-Cnec3VSx.js} +1 -1
- package/lib/public/assets/{select-Bo_2fqDM.js → select-CZuCnold.js} +1 -1
- package/lib/public/assets/{selector-detail-redirect-D_aNBNim.js → selector-detail-redirect-BG3pxFLw.js} +1 -1
- package/lib/public/assets/{selector-health-page-BP4XhSI4.js → selector-health-page-DsyL58tb.js} +2 -2
- package/lib/public/assets/{session-detail-page-DN8MPDsL.js → session-detail-page-ZZyGM413.js} +1 -1
- package/lib/public/assets/{settings-rFQ6qW9Q.js → settings-DGZ7B_AR.js} +1 -1
- package/lib/public/assets/{stat-tile-D8taj4dL.js → stat-tile-DFhv8JoI.js} +1 -1
- package/lib/public/assets/{tablet-Cz9pTLGh.js → tablet-68J5f6zh.js} +1 -1
- package/lib/public/assets/{teams-DkFhPU6N.js → teams-eHSyEpbD.js} +1 -1
- package/lib/public/assets/{trash-2-DMkIlO0b.js → trash-2-CcSsv4fS.js} +1 -1
- package/lib/public/assets/{upload-Dg76vQUo.js → upload-BYf26K71.js} +1 -1
- package/lib/public/assets/{use-builds-data-iSxxYh9G.js → use-builds-data-CHW-MhaP.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-DsNcDXiv.js → use-password-reset-mode-DozShXkk.js} +1 -1
- package/lib/public/assets/{users-BShiNYd9.js → users-BpYnpOl2.js} +1 -1
- package/lib/public/assets/{users-Bu1HulwN.js → users-CcSQRoK9.js} +1 -1
- package/lib/public/assets/{video-off-BJ_s_mLK.js → video-off-dFKgps73.js} +1 -1
- package/lib/public/assets/webhook-settings-DD1XjiOD.js +1 -0
- package/lib/public/assets/{zap-BXZlQKN8.js → zap-COC2tZaH.js} +1 -1
- package/lib/public/index.html +2 -2
- package/lib/src/app/apiErrors.js +118 -0
- package/lib/src/app/index.js +6 -1
- package/lib/src/app/openapi/control.yaml +3129 -0
- package/lib/src/app/openapi/grid.yaml +2295 -0
- package/lib/src/app/openapi/identity.yaml +2168 -0
- package/lib/src/app/openapi/platform.yaml +2885 -0
- package/lib/src/app/openapi/sessions.yaml +3784 -0
- package/lib/src/app/routers/bug-report.js +4 -1
- package/lib/src/app/routers/config.js +6 -107
- package/lib/src/app/routers/control.js +117 -59
- package/lib/src/app/routers/dashboard.js +13 -7
- package/lib/src/app/routers/grid.js +54 -14
- package/lib/src/app/routers/profile.js +27 -13
- package/lib/src/app/routers/recordings.js +11 -5
- package/lib/src/app/routers/reservation.js +63 -15
- package/lib/src/app/routers/users.js +4 -0
- package/lib/src/app/routers/webhook.js +17 -8
- package/lib/src/app/swagger.js +259 -177
- package/lib/src/data-service/device-service.js +4 -1
- package/lib/src/data-service/deviceFieldOwners.js +1 -0
- package/lib/src/device-managers/AndroidDeviceManager.js +5 -2
- package/lib/src/device-managers/iOSTracker.js +14 -1
- package/lib/src/device-managers/ios/IOSDiscoveryService.js +9 -5
- package/lib/src/device-managers/ios/WDAClient.js +32 -32
- package/lib/src/device-managers/ios/usbmuxd.js +46 -0
- package/lib/src/generated/client/edge.js +4 -3
- package/lib/src/generated/client/index-browser.js +1 -0
- package/lib/src/generated/client/index.d.ts +38 -0
- package/lib/src/generated/client/index.js +4 -3
- package/lib/src/generated/client/package.json +1 -1
- package/lib/src/generated/client/schema.prisma +2 -0
- package/lib/src/generated/client/wasm.js +1 -0
- package/lib/src/middleware/csrfMiddleware.js +13 -5
- package/lib/src/middleware/rateLimitMiddleware.js +19 -5
- package/lib/src/middleware/roleGuard.js +20 -0
- package/lib/src/services/AIService.js +13 -3
- package/lib/src/services/NotificationService.js +28 -28
- package/lib/src/services/bug-report/BugReportService.js +8 -2
- package/lib/src/services/lease/LeaseService.js +71 -20
- package/lib/src/services/omni-vision/OmniVisionService.js +14 -5
- package/lib/src/services/recording/RecordingOrchestrator.js +16 -2
- package/lib/test/helpers/expressRoutes.js +41 -0
- package/lib/test/integration/team-visibility-control.spec.js +2 -2
- package/lib/test/unit/access-scopes.spec.js +227 -0
- package/lib/test/unit/api-error-handling.spec.js +179 -0
- package/lib/test/unit/bug-report/route.spec.js +29 -0
- package/lib/test/unit/bug-report/service.spec.js +30 -0
- package/lib/test/unit/control-honest-answers.spec.js +134 -0
- package/lib/test/unit/device-allocation-routes.spec.js +232 -0
- package/lib/test/unit/healing-state-endpoints.spec.js +8 -5
- package/lib/test/unit/install-repository-app-team.spec.js +4 -1
- package/lib/test/unit/ios-usbmuxd-missing.spec.js +111 -0
- package/lib/test/unit/lease/LeaseService.spec.js +5 -4
- package/lib/test/unit/lease/lease-device-match.spec.js +161 -0
- package/lib/test/unit/lease/lease-session-ownership.spec.js +10 -9
- package/lib/test/unit/omni-vision-failures.spec.js +81 -0
- package/lib/test/unit/openapi-coverage.spec.js +114 -0
- package/lib/test/unit/profile-router.test.js +42 -0
- package/lib/test/unit/rateLimitMiddleware.test.js +49 -0
- package/lib/test/unit/recording-orchestrator.spec.js +80 -0
- package/lib/test/unit/recordings-library-routes.spec.js +37 -0
- package/lib/test/unit/reservation-team-visibility.spec.js +4 -3
- package/lib/test/unit/reset-link.test.js +2 -1
- package/lib/test/unit/stream-ticket-identity.spec.js +1 -1
- package/lib/test/unit/users-router.test.js +14 -1
- package/lib/test/unit/wda-client-failures.spec.js +90 -0
- package/lib/test/unit/webhook-delivery.spec.js +142 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/prisma/migrations/20261004120000_reservation_holder/migration.sql +2 -0
- package/prisma/schema.prisma +2 -0
- package/lib/public/assets/DeviceMosaicView-C9AypMcW.js +0 -2
- package/lib/public/assets/RecordingPage-FIRd8b5d.js +0 -11
- package/lib/public/assets/device-explorer-D2AqrrLN.css +0 -1
- package/lib/public/assets/device-explorer-Dl1QGKQN.js +0 -268
- package/lib/public/assets/index-DklX18ye.js +0 -219
- package/lib/public/assets/keycodes-B5mWBGMd.js +0 -26
- package/lib/public/assets/webhook-settings-CJxMc7-Q.js +0 -1
- package/lib/src/app/swagger-docs.js +0 -1701
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import{c as U,j as e,r as c,C as Ms,U as Wn,X as M,t as Ve,v as sn,b as qn,u as mt,a as Mt,T as Kn,q as ns,R as Fe,w as Xn,x as _s,y as $e,z as hs,I as nn,S as Nt,f as ct,A as St,i as an,B as Gn,D as Yn,E as Zn,p as Jn}from"./index-DklX18ye.js";import{P as Qn}from"./page-header-CV-WOQ7B.js";import{P as Ct,S as ea,B as ta}from"./BugReportButton-ejWk5lof.js";import{A as sa}from"./activity-CFEfukVD.js";import{h as na,M as rn,S as on,C as aa,a as zs,H as ia,b as Gt,A as ot,I as Yt}from"./keycodes-B5mWBGMd.js";import{p as _t}from"./labels-C21SA4JG.js";import{B as Y}from"./button-B1XDl_TT.js";import{S as ms}from"./select-Bo_2fqDM.js";import{P as cn,M as ln,a as pe,b as ra}from"./Menu-DFNsTx2i.js";import{M as ps}from"./Modal-BdWYrwfK.js";import{F as $t}from"./FieldGroup-Dm-U3Ucr.js";import{C as oa}from"./clock-BAD4KA9j.js";import{P as ca}from"./plus-DOp8RUCs.js";import{C as Te}from"./copy-CcNlsrXH.js";import{T as la}from"./tablet-Cz9pTLGh.js";import{S as da,a as Ls}from"./SegmentedControl-EBzIUjnM.js";import{T as ua,a as ha,b as dn,c as At,d as ma,e as Oe}from"./Table-DDahAwGb.js";import{f as pa}from"./time-D-gjmE1o.js";import{L as un,a as fa}from"./list-checks-Cqso6ROH.js";import{C as ya}from"./chevron-right-J_WfelGu.js";import{M as Os}from"./mouse-pointer-2-DXh-LIn9.js";import{Z as hn}from"./zap-BXZlQKN8.js";import{C as dt}from"./check-DjbzNVbd.js";import{C as mn}from"./circle-check-CGwn46BE.js";import{C as pn}from"./circle-x-Rfn2Zmq3.js";import{D as xa}from"./download-CoBA2mT_.js";import{T as as}from"./trash-2-DMkIlO0b.js";import{U as va,T as ga}from"./upload-Dg76vQUo.js";import{A as ba}from"./arrow-left-CIqcStpJ.js";import{A as ja}from"./arrow-right-Pw0XgjBJ.js";import{L as Na}from"./lock-D9WyaPyU.js";import{F as Ps}from"./FilterMenu-B3hgDfy_.js";import"./utils-CDN07tui.js";import"./index-BHI_dBXi.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 ka=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],fs=U("arrow-down",ka);/**
|
|
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 wa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ys=U("arrow-up",wa);/**
|
|
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 Sa=[["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"}]],Ca=U("battery-low",Sa);/**
|
|
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 $a=[["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"}]],Ta=U("battery-warning",$a);/**
|
|
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 Ra=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],Aa=U("battery",Ra);/**
|
|
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 Ea=[["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"}]],Da=U("box",Ea);/**
|
|
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 Ia=[["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"}]],Ma=U("calendar-plus",Ia);/**
|
|
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 _a=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],za=U("case-sensitive",_a);/**
|
|
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 La=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Oa=U("chevrons-down-up",La);/**
|
|
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 Pa=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Fa=U("chevrons-up-down",Pa);/**
|
|
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 Ua=[["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"}]],Ba=U("circle-question-mark",Ua);/**
|
|
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 Va=[["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"}]],Fs=U("code-xml",Va);/**
|
|
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 Ha=[["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"}]],Wa=U("crosshair",Ha);/**
|
|
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 qa=[["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"}]],Ka=U("ellipsis",qa);/**
|
|
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 Xa=[["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"}]],Ga=U("hand",Xa);/**
|
|
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 Ya=[["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"}]],Za=U("image",Ya);/**
|
|
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 Ja=[["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"}]],Qa=U("keyboard",Ja);/**
|
|
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 ei=[["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"}]],ti=U("library",ei);/**
|
|
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 si=[["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"}]],ni=U("lock-open",si);/**
|
|
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 ai=[["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"}]],ii=U("map-pin",ai);/**
|
|
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 ri=[["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"}]],oi=U("message-square",ri);/**
|
|
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 ci=[["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"}]],li=U("moon-star",ci);/**
|
|
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 di=[["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"}]],ui=U("mouse-pointer-click",di);/**
|
|
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 hi=[["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"}]],mi=U("package",hi);/**
|
|
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 pi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],fi=U("panel-top",pi);/**
|
|
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 yi=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],xi=U("rectangle-horizontal",yi);/**
|
|
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 vi=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],gi=U("rectangle-vertical",vi);/**
|
|
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 bi=[["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"}]],lt=U("rotate-cw",bi);/**
|
|
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 ji=[["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"}]],fn=U("scroll-text",ji);/**
|
|
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 Ni=[["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"}]],Ze=U("shield-alert",Ni);/**
|
|
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 ki=[["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"}]],wi=U("tag",ki);/**
|
|
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 Si=[["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"}]],Zt=U("target",Si);/**
|
|
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 Ci=[["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"}]],$i=U("text-cursor-input",Ci);/**
|
|
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 Ti=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Ri=U("text-wrap",Ti);/**
|
|
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 Ai=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ei=U("thermometer",Ai);/**
|
|
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 Di=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Ii=U("toggle-left",Di);/**
|
|
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 Mi=[["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"}]],Us=U("touchpad",Mi);/**
|
|
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 _i=[["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"}]],zi=U("type",_i);/**
|
|
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 Li=[["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"}]],Oi=U("volume-1",Li);/**
|
|
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 Pi=[["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"}]],Fi=U("volume-2",Pi);/**
|
|
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 Ui=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Bi=U("wifi",Ui);function Vi(t){return t>=50?"ready":t>=20?"warning":"error"}function Hi(t){return t>=50?e.jsx(Aa,{size:10}):t>=20?e.jsx(Ca,{size:10}):e.jsx(Ta,{size:10})}function Wi(t){return t==="Normal"?"ready":t==="Critical"?"error":"warning"}const qi=({device:t})=>{if(t.deviceType==="emulator"||t.deviceType==="simulator"||t.offline)return null;const n=typeof t.batteryLevel=="number",a=typeof t.thermalStatus=="string"&&t.thermalStatus.length>0&&t.thermalStatus!=="Unknown";return!n&&!a?e.jsx("div",{className:"dc2-health",children:e.jsxs(Ct,{tone:"neutral",title:"Device does not report battery or thermal data",children:[e.jsx(sa,{size:10}),"No telemetry"]})}):e.jsxs("div",{className:"dc2-health",children:[n&&e.jsxs(Ct,{tone:Vi(t.batteryLevel),title:`Battery ${t.batteryLevel}%`,children:[Hi(t.batteryLevel),t.batteryLevel,"%"]}),a&&e.jsxs(Ct,{tone:Wi(t.thermalStatus),title:`Thermal: ${t.thermalStatus}`,children:[e.jsx(Ei,{size:10}),t.thermalStatus]})]})};function Ki(t){if(typeof t!="number")throw new TypeError("Expected a number");const s=t>0?Math.floor:Math.ceil;return{days:s(t/864e5),hours:s(t/36e5)%24,minutes:s(t/6e4)%60,seconds:s(t/1e3)%60,milliseconds:s(t)%1e3,microseconds:s(t*1e3)%1e3,nanoseconds:s(t*1e6)%1e3}}const Xi=(t,s)=>s===1?t:`${t}s`,Gi=1e-7;function yn(t,s={}){if(!Number.isFinite(t))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],a=(l,u)=>{const d=Math.floor(l*10**u+Gi);return(Math.round(d)/10**u).toFixed(u)},o=(l,u,d,i)=>{if((n.length===0||!s.colonNotation)&&l===0&&!(s.colonNotation&&d==="m"))return;i=(i||l||"0").toString();let m,x;if(s.colonNotation){m=n.length>0?":":"",x="";const k=i.includes(".")?i.split(".")[0].length:i.length,f=n.length>0?2:1;i="0".repeat(Math.max(0,f-k))+i}else m="",x=s.verbose?" "+Xi(u,l):d;n.push(m+i+x)},r=Ki(t);if(o(Math.trunc(r.days/365),"year","y"),o(r.days%365,"day","d"),o(r.hours,"hour","h"),o(r.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&t<1e3)if(o(r.seconds,"second","s"),s.formatSubMilliseconds)o(r.milliseconds,"millisecond","ms"),o(r.microseconds,"microsecond","µs"),o(r.nanoseconds,"nanosecond","ns");else{const l=r.milliseconds+r.microseconds/1e3+r.nanoseconds/1e6,u=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=l>=1?Math.round(l):Math.ceil(l),i=u?l.toFixed(u):d;o(Number.parseFloat(i),"millisecond","ms",i)}else{const l=t/1e3%60,u=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=a(l,u),i=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");o(Number.parseFloat(i),"second","s",i)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const l=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(l)}return s.colonNotation?n.join(""):n.join(" ")}const Jt=6e4;function Yi(t){return!Number.isFinite(t)||t<=0?"expiring":t<Jt?"under 1m":yn(Math.floor(t/Jt)*Jt,{unitCount:2})}const is=["ready","busy","reserved","maintenance","offline"],xn={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function ut(t,s){return t.offline?"offline":t.userBlocked?"maintenance":t.busy?"busy":t.reservedUntil&&s<t.reservedUntil?"reserved":"ready"}function vn(t,s){const n=na(t);if(!t.busy||!n)return null;const a=String(n);return a.startsWith("manual_")?s!=null&&s.userId&&a===`manual_${s.userId}_${t.udid}`?"self":"other":"session"}const Bs=t=>(t==null?void 0:t.role)==="ADMIN"||(t==null?void 0:t.role)==="SUPER_ADMIN";function Zi(t,s,n){switch(vn(t,s)){case"session":return t.sessionStartTime&&t.sessionStartTime>0&&n>t.sessionStartTime?`Test session · ${yn(n-t.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(t.reservedUntil&&n<t.reservedUntil){const o=!!t.reservedBy&&(t.reservedBy===(s==null?void 0:s.email)||t.reservedBy===(s==null?void 0:s.name))?"you":t.reservedBy||"another user";return`${Yi(t.reservedUntil-n)} left · by ${o}`}return null}function Ji(t,s){if(t.offline)return{enabled:!1,reason:"Device is offline"};if(t.userBlocked&&!Bs(s))return{enabled:!1,reason:"In maintenance"};const n=vn(t,s);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!Bs(s)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function Me(t){var s;return((s=t.marketingName)==null?void 0:s.trim())||t.name}function gn(t){const s=[_t(t.platform),t.sdk].filter(Boolean).join(" ");if(t.deviceType==="emulator")return`Emulator · ${s}`;if(t.deviceType==="simulator")return`Simulator · ${s}`;const a=[t.manufacturer?t.manufacturer.charAt(0).toUpperCase()+t.manufacturer.slice(1):"",t.model].filter(Boolean).join(" ");return a?`${a} · ${s}`:s}function Qi(t){return t.formFactor==="tablet"||t.formFactor==="tv"?t.formFactor:"phone"}function Qe(t,s){return t.teamId?(s==null?void 0:s.get(t.teamId))??t.teamName??`Team ${t.teamId.slice(0,6)}`:null}const er=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],tr=({device:t,onClose:s,onReserved:n})=>{const[a,o]=c.useState(""),[r,l]=c.useState("1h"),[u,d]=c.useState(""),[i,m]=c.useState(!1),[x,k]=c.useState(null),[f,y]=c.useState(null),S=async()=>{if(!a.trim()){k("Please enter your name/ID");return}m(!0),k(null),y(null);try{const C=await M.reserveDevice(t.udid,t.host,a,r,u);C.success?(n(),s()):y(C.error||"Failed to reserve device")}catch(C){y(C.message||"An unexpected error occurred")}finally{m(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(Ma,{size:16,className:"title-icon"}),"Reserve device"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,disabled:i,children:"Cancel"}),e.jsx("button",{className:"btn-reserve",onClick:S,disabled:i||!a.trim(),children:i?"Reserving...":"Confirm Reservation"})]}),children:e.jsxs("div",{className:"reservation-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsxs("p",{children:["Reserve ",e.jsx("strong",{children:t.name||t.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(Wn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:x?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),x]}):void 0,children:e.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:a,onChange:C=>{o(C.target.value),x&&k(null)},disabled:i})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(oa,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:e.jsx("div",{className:"duration-selector",children:er.map(C=>e.jsx("div",{className:`duration-option ${r===C.value?"active":""}`,onClick:()=>l(C.value),children:C.label},C.value))})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(oi,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:e.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:u,onChange:C=>d(C.target.value),disabled:i})})]})})},sr=({device:t,onClose:s,onUpdated:n})=>{const{toast:a}=Ve(),[o,r]=c.useState(t.tags||[]),[l,u]=c.useState(""),[d,i]=c.useState(!1),m=c.useRef(null);c.useEffect(()=>{m.current&&m.current.focus()},[]);const x=()=>{const S=l.trim();S&&!o.includes(S)&&(r([...o,S]),u(""))},k=S=>{r(o.filter(C=>C!==S))},f=S=>{S.key==="Enter"&&x()},y=async()=>{i(!0);try{await M.updateDeviceTags(t.udid,t.host,o),n(),s()}catch(S){console.error("Failed to update tags",S),a("Error saving tags. Please try again.","error")}finally{i(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(wi,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),e.jsx("button",{className:"btn-save",onClick:y,disabled:d,children:d?"Saving...":"Apply Changes"})]}),children:e.jsxs("div",{className:"tag-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsx($t,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:e.jsxs("div",{className:"input-with-button",children:[e.jsx("input",{ref:m,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:l,onChange:S=>u(S.target.value),onKeyDown:f}),e.jsx("button",{className:"add-inline-btn",onClick:x,disabled:!l.trim(),children:e.jsx(ca,{size:16})})]})}),e.jsxs("div",{className:"tags-display-section",children:[e.jsx("label",{children:"Current Tags"}),e.jsx("div",{className:"tags-list",children:o.length>0?o.map(S=>e.jsxs("div",{className:"tag-pill-editable",children:[S,e.jsx("button",{className:"remove-tag",onClick:()=>k(S),children:e.jsx(sn,{size:12})})]},S)):e.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},nr="/wd/hub";function ar(t){return t==="android"?"UiAutomator2":"XCUITest"}function ir(t){return t==="android"?"Android":t==="tvos"?"tvOS":"iOS"}function rr(t,s=nr){if(!t)return"—";try{const n=new URL(t.includes("://")?t:`http://${t}`),a=s.startsWith("/")?s:`/${s}`,o=n.pathname.replace(/\/$/,"");return o===a||o.endsWith(a)?`${n.protocol}//${n.host}${o}`:`${n.protocol}//${n.host}${a}`}catch{return t}}function or(t){const s={platformName:ir(t.platform),"appium:automationName":ar(t.platform),"appium:udid":t.udid};return t.sdk&&t.sdk!=="Unknown"&&t.sdk!=="unknown"&&(s["appium:platformVersion"]=t.sdk),t.name&&(s["appium:deviceName"]=t.name),s}function cr(t){return JSON.stringify(or(t),null,2)}const lr=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,dr=/^(?:\d{1,3}\.){3}\d{1,3}$/;function ur(t){const s=t.trim();return!s||lr.test(s)||!dr.test(s)?!1:s.split(".").every(n=>{const a=Number(n);return Number.isInteger(a)&&a>=0&&a<=255})}function hr(t){return t.ip&&ur(t.ip)?t.ip.trim():null}const bn=({udid:t,currentTeamId:s,teams:n,onDone:a,className:o})=>{const{toast:r}=Ve(),[l,u]=c.useState(!1);async function d(i){u(!0);try{await M.setDeviceTeam(t,i),r(i?"Device assigned":"Device returned to shared pool","success"),a(!0)}catch(m){r((m==null?void 0:m.message)||"Failed to update team","error")}finally{u(!1)}}return e.jsxs(ms,{selectSize:"sm",className:o,autoFocus:!0,"aria-label":"Team",disabled:l,defaultValue:s??"",onBlur:()=>a(!1),onChange:i=>d(i.target.value||null),children:[e.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([i,m])=>e.jsx("option",{value:i,children:m},i))]})};function jn(t,s){const[n,a]=c.useState(!1),[o,r]=c.useState(!1),[l,u]=c.useState(!1),{me:d}=qn(),{toast:i}=Ve(),m=(d==null?void 0:d.role)==="ADMIN"||(d==null?void 0:d.role)==="SUPER_ADMIN",x=Date.now(),k=ut(t,x),f=k==="reserved",y=Zi(t,d,x),S=Ji(t,d),C=rr(t.host),L=hr(t),w=async(O,W)=>{var V;try{await((V=navigator.clipboard)==null?void 0:V.writeText(O)),i(W,"success")}catch{i("Failed to copy","error")}},j=async()=>{await M.releaseReservation(t.udid,t.host),s()},$=async()=>{await M.blockDevice(t.udid,t.host),s()},p=async()=>{await M.unblockDevice(t.udid,t.host),s()},D=async()=>{t.userBlocked?await p():await $()},A=e.jsxs(e.Fragment,{children:[n&&e.jsx(tr,{device:t,onClose:()=>a(!1),onReserved:()=>s()}),o&&e.jsx(sr,{device:t,onClose:()=>r(!1),onUpdated:()=>s()})]});return{kind:k,reserved:f,activity:y,control:S,isAdmin:m,editingTeam:l,setEditingTeam:u,openReservation:()=>a(!0),openTagManager:()=>r(!0),release:j,toggleMaintenance:D,copy:w,serverUrl:C,ip:L,dialogs:A}}const Nn=({device:t,actions:s,navigate:n,reasonId:a})=>{const{kind:o,reserved:r,control:l}=s;return e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"tonal",size:"sm",disabled:!l.enabled,"aria-describedby":l.enabled?void 0:a,onClick:()=>{l.enabled&&n(`/devices/${t.udid}/control`)},children:"Control"}),r?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.release,children:"Release"}):o==="ready"?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.openReservation,children:"Reserve"}):null]})},kn=({device:t,actions:s})=>{const[n,a]=c.useState(!1),o=c.useRef(null),{isAdmin:r,serverUrl:l,ip:u,copy:d}=s;return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:o,type:"button",className:"dc2-more",onClick:()=>a(i=>!i),"aria-label":"More actions",children:e.jsx(Ka,{size:14})}),e.jsx(cn,{open:n,onClose:()=>a(!1),anchorRef:o,children:e.jsxs(ln,{children:[e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(t.udid,"UDID copied")},children:"Copy UDID"}),l!=="—"&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(l,"Server URL copied")},children:"Copy server URL"}),u&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(u,"IP address copied")},children:"Copy IP address"}),e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(cr(t),"Session capabilities copied")},children:"Copy capabilities"}),r&&e.jsxs(e.Fragment,{children:[e.jsx(ra,{}),e.jsx(pe,{onClick:()=>{a(!1),s.openTagManager()},children:"Manage tags…"}),e.jsx(pe,{onClick:()=>{a(!1),s.setEditingTeam(!0)},children:"Assign team…"}),e.jsx(pe,{onClick:()=>{a(!1),s.toggleMaintenance()},children:t.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},mr=({device:t})=>{const s={phone:ns,tablet:la,tv:Kn}[Qi(t)],n=t.deviceType==="emulator"||t.deviceType==="simulator";return e.jsx(s,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},pr=({device:t,reloadDevices:s,navigate:n,teams:a})=>{var x,k,f;const o=jn(t,s),{kind:r,activity:l,control:u}=o,d=`dc2-reason-${t.udid}`,i=Me(t),m=Qe(t,a);return e.jsxs("div",{className:`dc2 dc2-${r}`,children:[e.jsxs("div",{className:`dc2-band dc2-band-${r}`,children:[e.jsxs("span",{className:"dc2-band-label",children:[e.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),xn[r]]}),l&&e.jsx("span",{className:"dc2-band-activity",title:l,children:l})]}),e.jsxs("div",{className:`dc2-body${r==="offline"?" dc2-dim":""}`,children:[e.jsxs("div",{className:"dc2-head",children:[e.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:e.jsx(mr,{device:t})}),e.jsxs("div",{className:"dc2-id",children:[e.jsx("div",{className:"dc2-title",title:`${i}
|
|
207
|
-
${t.udid}`,children:i}),e.jsx("div",{className:"dc2-subtitle",children:gn(t)})]})]}),e.jsxs("div",{className:"dc2-meta",children:[e.jsx(qi,{device:t}),o.editingTeam?e.jsx(bn,{className:"dc2-team-picker",udid:t.udid,currentTeamId:t.teamId??null,teams:a??new Map,onDone:y=>{o.setEditingTeam(!1),y&&s()}}):m&&e.jsx(Ct,{tone:"accent",className:"dc2-team",title:`Team: ${m}`,children:m}),(x=t.tags)==null?void 0:x.slice(0,2).map(y=>e.jsxs("span",{className:"dc2-tag",title:y,children:["#",y]},y)),(((k=t.tags)==null?void 0:k.length)||0)>2&&e.jsxs("span",{className:"dc2-tag",children:["+",(((f=t.tags)==null?void 0:f.length)||0)-2]})]})]}),e.jsxs("div",{className:"dc2-foot",children:[e.jsx(Nn,{device:t,actions:o,navigate:n,reasonId:d}),!u.enabled&&e.jsx("span",{id:d,className:"dc2-unavailable",title:u.reason,children:u.reason}),e.jsx("span",{className:"dc2-spacer"}),e.jsx(kn,{device:t,actions:o})]}),o.dialogs]})};function fr(t){const s=mt(),{search:n}=Mt();return e.jsx(pr,{device:t.device,reloadDevices:t.reloadDevices,navigate:a=>s(`${a}${n}`),teams:t.teams})}class yr extends Fe.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){M.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return e.jsx("div",{className:"device-explorer-card-container",children:Fe.Children.toArray(this.props.devices.map(s=>e.jsx(fr,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const xr={status:"all",platform:"all",type:"all",q:""},wn=["all",...is],Sn=["all","android","ios","tvos"],Cn=["all","real","virtual"];function Qt(t,s){return s.includes(t)?t:s[0]}function vr(t){const s=t.get("q")??"";return{status:Qt(t.get("status"),wn),platform:Qt(t.get("platform"),Sn),type:Qt(t.get("type"),Cn),q:s.trim()?s:""}}function gr(t){const s=new URLSearchParams;return t.status!=="all"&&s.set("status",t.status),t.platform!=="all"&&s.set("platform",t.platform),t.type!=="all"&&s.set("type",t.type),t.q.trim()&&s.set("q",t.q),s}function ht(t){return t.deviceType==="simulator"||t.deviceType==="emulator"?!0:!t.deviceType&&t.realDevice===!1}function xs(t){const s=(t.platform||"").toLowerCase();return s==="android"||s==="ios"||s==="tvos"?s:null}function br(t){const s=t.deviceType==="emulator"?"Emulator":t.deviceType==="simulator"?"Simulator":"";return[Me(t),t.name,t.manufacturer,t.model,_t(t.platform),t.sdk,s,t.teamName,t.udid].filter(Boolean).join(" ").toLowerCase()}function Tt(t,s,n,a){if(a!=="status"&&s.status!=="all"&&ut(t,n)!==s.status||a!=="platform"&&s.platform!=="all"&&xs(t)!==s.platform||a!=="type"&&s.type!=="all"&&s.type==="virtual"!==ht(t))return!1;const o=s.q.toLowerCase().split(/\s+/).filter(Boolean);if(o.length===0)return!0;const r=br(t);return o.every(l=>r.includes(l))}const es=t=>Object.fromEntries(t.map(s=>[s,0]));function jr(t,s,n){const a=es(wn),o=es(Sn),r=es(Cn);for(const l of t){if(Tt(l,s,n,"status")&&(a.all+=1,a[ut(l,n)]+=1),Tt(l,s,n,"platform")){o.all+=1;const u=xs(l);u&&(o[u]+=1)}Tt(l,s,n,"type")&&(r.all+=1,r[ht(l)?"virtual":"real"]+=1)}return{status:a,platform:o,type:r}}function Nr(t){return t.some(s=>xs(s)==="tvos")}function kr(t){return t.status!=="all"||t.platform!=="all"||t.type!=="all"||t.q.trim()!==""}function wr(t,s){const n=a=>a===1?"device":"devices";return t===s?`${s} ${n(s)}`:`${t} of ${s} ${n(s)}`}const rs={key:"status",dir:"asc"},Sr=["status","device","platform","type","team","host"],Cr=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),Pe=(t,s)=>Cr.compare(t,s);function $r(t,s,n,a){switch(n){case"status":return is.indexOf(ut(t,a.now))-is.indexOf(ut(s,a.now));case"device":return Pe(Me(t),Me(s));case"platform":return Pe(t.platform||"",s.platform||"")||Pe(t.sdk||"",s.sdk||"");case"type":return Number(ht(t))-Number(ht(s));case"team":return Pe(Qe(t,a.teams)??"",Qe(s,a.teams)??"");case"host":return Pe(t.host||"",s.host||"")}}function Tr(t,s,n){const a=s.dir==="desc"?-1:1;return t.slice().sort((o,r)=>{if(s.key==="team"){const l=Qe(o,n.teams)===null,u=Qe(r,n.teams)===null;if(l!==u)return l?1:-1}return a*$r(o,r,s.key,n)||Pe(Me(o),Me(r))||Pe(o.udid,r.udid)})}function Rr(t){const s=t.get("sort");return!s||!Sr.includes(s)?rs:{key:s,dir:t.get("dir")==="desc"?"desc":"asc"}}function Ar(t,s){t.delete("sort"),t.delete("dir"),!(s.key===rs.key&&s.dir===rs.dir)&&(t.set("sort",s.key),s.dir==="desc"&&t.set("dir","desc"))}const Je=({sortKey:t,label:s,sort:n,onSortChange:a})=>{const o=n.key===t,r=o?n.dir:"asc";return e.jsx(At,{scope:"col","aria-sort":o?r==="asc"?"ascending":"descending":"none",children:e.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>a(o?{key:t,dir:r==="asc"?"desc":"asc"}:{key:t,dir:"asc"}),children:[s,o&&(r==="asc"?e.jsx(ys,{size:12,"aria-hidden":"true"}):e.jsx(fs,{size:12,"aria-hidden":"true"}))]})})},Er=({device:t,reloadDevices:s,navigate:n,teams:a,showHost:o})=>{const r=jn(t,s),{kind:l,activity:u,control:d}=r,i=Me(t),m=gn(t),x=Qe(t,a),k=`${_t(t.platform)} ${t.sdk??""}`,f=t.tags??[],y=`devtable-reason-${t.udid}`;return e.jsxs(dn,{className:`devtable-row${l==="offline"?" is-offline":""}`,children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"devtable-line",children:[e.jsx(da,{kind:l,className:"devtable-status-dot"})," ",xn[l]]}),u&&e.jsx("div",{className:"devtable-muted devtable-line",title:u,children:u})]}),e.jsxs(At,{scope:"row",className:"devtable-rowheader",title:`${i}
|
|
208
|
-
${t.udid}`,children:[e.jsx("div",{className:"devtable-title devtable-line",children:i}),e.jsx("div",{className:"devtable-muted devtable-line",title:m,children:m})]}),e.jsx(Oe,{title:k,children:k}),e.jsx(Oe,{children:ht(t)?"Virtual":"Real"}),e.jsx(Oe,{title:r.editingTeam?void 0:x??"Shared",children:r.editingTeam?e.jsx(bn,{udid:t.udid,currentTeamId:t.teamId??null,teams:a,onDone:S=>{r.setEditingTeam(!1),S&&s()}}):x??"Shared"}),e.jsxs(Oe,{title:f.join(", "),children:[f.slice(0,2).map(S=>e.jsxs("span",{className:"devtable-tag",children:["#",S]},S)),f.length>2&&e.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),o&&e.jsx(Oe,{title:t.host,children:t.host}),e.jsx(Oe,{className:"devtable-actions",title:d.enabled?void 0:d.reason,children:e.jsxs("div",{className:"devtable-actions-inner",children:[e.jsx(Nn,{device:t,actions:r,navigate:n,reasonId:y}),!d.enabled&&e.jsx("span",{id:y,className:"sr-only",children:d.reason}),e.jsx(kn,{device:t,actions:r})]})}),r.dialogs]})};function Dr({devices:t,reloadDevices:s,sort:n,onSortChange:a,navigate:o,teams:r}){const l=new Set(t.map(d=>d.host)).size>1||n.key==="host",u=Tr(t,n,{now:Date.now(),teams:r});return e.jsxs(ua,{className:"devtable",children:[e.jsxs("caption",{className:"sr-only",children:["Devices, ",t.length," shown"]}),e.jsxs("colgroup",{children:[e.jsx("col",{className:"devtable-col-status"}),e.jsx("col",{}),e.jsx("col",{className:"devtable-col-platform"}),e.jsx("col",{className:"devtable-col-type"}),e.jsx("col",{className:"devtable-col-team"}),e.jsx("col",{className:"devtable-col-tags"}),l&&e.jsx("col",{className:"devtable-col-host"}),e.jsx("col",{className:"devtable-col-actions"})]}),e.jsx(ha,{children:e.jsxs(dn,{children:[e.jsx(Je,{sortKey:"status",label:"Status",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"device",label:"Device",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"platform",label:"Platform",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"type",label:"Type",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"team",label:"Team",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Tags"}),l&&e.jsx(Je,{sortKey:"host",label:"Host",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Actions"})]})}),e.jsx(ma,{children:u.map(d=>e.jsx(Er,{device:d,reloadDevices:s,navigate:o,teams:r,showHost:l},d.udid))})]})}function Ir(t){const s=mt(),{search:n}=Mt(),[a,o]=c.useState(new Map);return c.useEffect(()=>{M.listTeams().then(r=>o(new Map(r.map(l=>[l.id,l.name])))).catch(()=>{})},[]),e.jsx(Dr,{devices:t.devices,reloadDevices:t.reloadDevices,sort:t.sort,onSortChange:t.onSortChange,navigate:r=>s(`${r}${n}`),teams:a})}var kt,Mr=new Uint8Array(16);function _r(){if(!kt&&(kt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!kt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kt(Mr)}const zr=/^(?:[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 Lr(t){return typeof t=="string"&&zr.test(t)}var re=[];for(var ts=0;ts<256;++ts)re.push((ts+256).toString(16).substr(1));function Or(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(re[t[s+0]]+re[t[s+1]]+re[t[s+2]]+re[t[s+3]]+"-"+re[t[s+4]]+re[t[s+5]]+"-"+re[t[s+6]]+re[t[s+7]]+"-"+re[t[s+8]]+re[t[s+9]]+"-"+re[t[s+10]]+re[t[s+11]]+re[t[s+12]]+re[t[s+13]]+re[t[s+14]]+re[t[s+15]]).toLowerCase();if(!Lr(n))throw TypeError("Stringified UUID is invalid");return n}function Pr(t,s,n){t=t||{};var a=t.random||(t.rng||_r)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Or(a)}const Fr=({onCommand:t,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:a})=>{const[o,r]=c.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[l,u]=c.useState(""),[d,i]=c.useState([]),[m,x]=c.useState(-1),[k,f]=c.useState(!1),y=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[o]);const C=w=>{const j=w.trim();if((j.startsWith("{")||j.startsWith("["))&&(j.endsWith("}")||j.endsWith("]")))try{const $=JSON.parse(j);return JSON.stringify($,null,2)}catch{}return w},L=async w=>{if(w.key==="Enter"&&!k){const j=l.trim();if(!j)return;if(u(""),r($=>[...$,{type:"command",content:`${s} ${j}`,timestamp:Date.now()}]),i($=>[...$,j]),x(-1),f(!0),j==="clear"){r([]),f(!1);return}if(j==="help"){let $="";a==="android"?$=`
|
|
209
|
-
Android Allowed Commands:
|
|
210
|
-
• System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
|
|
211
|
-
• Process Mgmt: ps, top
|
|
212
|
-
• File System: ls
|
|
213
|
-
• Diagnostics: dumpsys [battery|wifi|power]
|
|
214
|
-
• Packages: pm list packages
|
|
215
|
-
`:(a==="ios"||a==="tvos")&&($=`
|
|
216
|
-
iOS Allowed Commands:
|
|
217
|
-
• Real Device (go-ios):
|
|
218
|
-
apps, info, list, syslog, deviceinfo, diagnostics
|
|
219
|
-
• Simulator (xcrun simctl):
|
|
220
|
-
listapps, get_app_container, list, getenv
|
|
221
|
-
• Simulator System:
|
|
222
|
-
ls, ps, top, date, uptime, whoami
|
|
223
|
-
`),r(p=>[...p,{type:"output",content:$.trim(),timestamp:Date.now()}]),f(!1);return}try{const $=await t(j),p=C($||"(No output)");r(D=>[...D,{type:"output",content:p,timestamp:Date.now()}])}catch($){r(p=>[...p,{type:"error",content:$.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var $;return($=S.current)==null?void 0:$.focus()},10)}}else if(w.key==="ArrowUp"){if(w.preventDefault(),d.length>0){const j=m===-1?d.length-1:Math.max(0,m-1);x(j),u(d[j])}}else if(w.key==="ArrowDown"&&(w.preventDefault(),m!==-1)){const j=m+1;j>=d.length?(x(-1),u("")):(x(j),u(d[j]))}};return e.jsxs("div",{className:"terminal-container theme-dark",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"terminal-header",children:[e.jsxs("div",{className:"terminal-controls",children:[e.jsx("div",{className:"dot red"}),e.jsx("div",{className:"dot yellow"}),e.jsx("div",{className:"dot green"})]}),e.jsxs("div",{className:"terminal-title",children:[_t(a)," shell"]}),e.jsx("div",{className:"terminal-actions",children:e.jsx("button",{className:"terminal-action-btn",onClick:()=>r([]),title:"Clear terminal",children:"CLEAR"})})]}),e.jsxs("div",{className:"terminal-history",ref:y,onClick:()=>{var w;return(w=S.current)==null?void 0:w.focus()},children:[o.map((w,j)=>e.jsx("div",{className:`terminal-line ${w.type}`,children:w.content},j)),k&&e.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),e.jsxs("div",{className:"terminal-input-area",children:[e.jsx("span",{className:"terminal-prompt",children:s}),e.jsx("input",{ref:S,className:"terminal-input",value:l,onChange:w=>u(w.target.value),onKeyDown:L,disabled:k,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ae(t,s){var n;s(t),(n=t.children)==null||n.forEach(a=>Ae(a,s))}function Re(t,...s){var n;for(const a of s){const o=(n=t.attributes)==null?void 0:n[a];if(o!=null&&o!=="")return String(o)}}function et(t){var s;return((s=t.type)==null?void 0:s.split(".").pop())||t.type||""}function Ur(t,s){const n=[];return Ae(t,a=>{Re(a,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(a)}),n}function Br(t,s){const n=[];return Ae(t,a=>{Re(a,"resource-id","resourceId","identifier")===s&&n.push(a)}),n}function os(t,s){const n=[];return Ae(t,a=>{(a.type===s||et(a)===s)&&n.push(a)}),n}function Vr(t,s){const n=[];return Ae(t,a=>{Re(a,"name")===s&&n.push(a)}),n}function Hr(t){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(t.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function Wr(t,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const a=[];for(const r of n){const l=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(r);if(!l)return null;a.push({type:l[1],index:parseInt(l[2],10)})}if(a[0].type!==t.type&&a[0].type!==et(t)||a[0].index!==1)return null;let o=t;for(let r=1;r<a.length&&o;r++){const{type:l,index:u}=a[r];let d=0,i;for(const m of o.children||[])if((m.type===l||et(m)===l)&&(d+=1,d===u)){i=m;break}o=i}return o?[o]:[]}function qr(t,s){const n=Wr(t,s);if(n!==null)return{kind:"matched",nodes:n};const a=Hr(s);if(a){const o=[];return Ae(t,r=>{if(a.tag&&r.type!==a.tag&&et(r)!==a.tag)return;Re(r,a.attrKey)===a.attrValue&&o.push(r)}),{kind:"matched",nodes:o}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Kr(t,s){const n=s.trim(),a=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(a){const[,l,u,d]=a,i=[];return Ae(t,m=>{if(m.type!==l&&et(m)!==l)return;Re(m,u)===d&&i.push(m)}),{kind:"matched",nodes:i}}const o=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(o){const[,l,u]=o,d=parseInt(u,10),i=[];return Ae(t,m=>{(m.type===l||et(m)===l)&&i.push(m)}),{kind:"matched",nodes:i[d-1]?[i[d-1]]:[]}}const r=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return r?os(t,r[1]).length>0?{kind:"matched",nodes:os(t,r[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Xr(t,s){const a=s.trim().split(/\s+AND\s+/i).map(l=>l.trim()),o=[];for(const l of a){const u=/^(\w+)\s*==\s*"([^"]*)"$/.exec(l);if(!u)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};o.push({key:u[1],value:u[2]})}const r=[];return Ae(t,l=>{for(const u of o){let d;if(u.key==="type"?d=l.type:u.key==="label"?d=Re(l,"label")??l.label:u.key==="name"?d=Re(l,"name")??l.name:u.key==="value"?d=Re(l,"value")??l.value:d=Re(l,u.key),d!==u.value)return}r.push(l)}),{kind:"matched",nodes:r}}function cs(t,s,n){const a=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(a){case"accessibility id":return{kind:"matched",nodes:Ur(t,n)};case"id":return{kind:"matched",nodes:Br(t,n)};case"class name":return{kind:"matched",nodes:os(t,n)};case"name":return{kind:"matched",nodes:Vr(t,n)};case"xpath":return qr(t,n);case"-ios class chain":return Kr(t,n);case"-ios predicate string":return Xr(t,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Vs(t){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}[t.toLowerCase()]??7}function ls(t,s){const n=t.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{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(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{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(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const a=(s.match(/\//g)||[]).length;return a>7?{level:"fragile",reason:`${a}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.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"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.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 $n(t){return[...t].sort((s,n)=>Vs(s.strategy)-Vs(n.strategy))}const wt=t=>t===!0||t==="true",Gr=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Yr=/(EditText|AutoCompleteTextView)$/;function Tn(t){const s=t.attributes||{};return wt(s.clickable)||wt(s["long-clickable"])||wt(s.checkable)||wt(s.scrollable)||Yr.test(t.type||"")||Gr.test(t.type||"")}function Zr(t){const s=t.attributes||{};return String(t.text||s["content-desc"]||t.label||s.label||s.name||"").trim()}function Jr(t,s){const n="Unique locator",a=$n(t.suggestedLocators||[]),o=a[0];if(!o)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const r=cs(s.hierarchy,o.strategy,o.value),l=`${o.strategy} ${o.value}`;if(r.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${o.strategy} locators here`};const u=k=>k.length===1&&k[0].xpath===t.xpath;if(u(r.nodes))return{id:"unique",label:n,status:"pass",detail:`${l} matches only this element`};const d=a.slice(1).find(k=>{const f=cs(s.hierarchy,k.strategy,k.value);return f.kind==="matched"&&u(f.nodes)}),i=d?`; use ${d.strategy} ${d.value} instead`:"",m=r.nodes.length,x=m===0?"matches nothing in this capture":`matches ${m} elements`;return{id:"unique",label:n,status:"fail",detail:`${l} ${x}${i}`}}function Qr(t){const s=$n(t.suggestedLocators||[])[0];if(!s)return null;const{level:n,reason:a}=ls(s.strategy,s.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:a}}function eo(t,s){const{screenWidth:n,screenHeight:a}=s.metadata||{screenWidth:0,screenHeight:0};if(!n||!a)return null;const{x:o,y:r,width:l,height:u}=t.rect,d="On screen";return o+l<=0||r+u<=0||o>=n||r>=a?{id:"onscreen",label:d,status:"warn",detail:"Off screen — scroll it into view first"}:o<0||r<0||o+l>n||r+u>a?{id:"onscreen",label:d,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:d,status:"pass",detail:"Fully inside the screen"}}function to(t,s){var u,d;const n=Tn(t),a=!(((u=t.attributes)==null?void 0:u.enabled)===!1||((d=t.attributes)==null?void 0:d.enabled)==="false"),o=t.rect.width>0&&t.rect.height>0,r=Zr(t);return[Jr(t,s),Qr(t),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"},a?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},o?{id:"size",label:"Has size",status:"pass",detail:`${t.rect.width} × ${t.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},eo(t,s),n?r?{id:"name",label:"Accessible name",status:"pass",detail:`“${r.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(i=>i!==null)}function so(t){return{pass:t.filter(s=>s.status==="pass").length,warn:t.filter(s=>s.status==="warn").length,fail:t.filter(s=>s.status==="fail").length}}function no(t,s){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const a=Math.floor(n/60);return a<60?`Captured ${a} min ago`:`Captured ${Math.floor(a/60)} h ago`}function ao(t,s){return t>0&&s>t}function Rn(t){var r,l,u,d,i;const s=(t.type||"").toLowerCase(),n=((r=t.attributes)==null?void 0:r.clickable)==="true"||((l=t.attributes)==null?void 0:l.clickable)===!0,a=((u=t.attributes)==null?void 0:u.scrollable)==="true"||((d=t.attributes)==null?void 0:d.scrollable)===!0,o=((i=t.children)==null?void 0:i.length)||0;return s.includes("button")||s.includes("btn")||n&&o===0?{role:"Button",key:"button"}:s.includes("edit")||s.includes("input")||s.includes("field")?{role:"Text input",key:"input"}:s.includes("image")||s.includes("img")||s.includes("imageview")?{role:"Image",key:"image"}:s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?{role:"Scrollable list",key:"list"}:s.includes("text")||s.includes("label")?{role:"Text label",key:"text"}:s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?{role:"Navigation bar",key:"nav"}:o>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const An={button:e.jsx(ui,{size:13}),input:e.jsx($i,{size:13}),image:e.jsx(Za,{size:13}),list:e.jsx(fn,{size:13}),text:e.jsx(zi,{size:13}),toggle:e.jsx(Ii,{size:13}),nav:e.jsx(fi,{size:13}),container:e.jsx(un,{size:13}),element:e.jsx(Da,{size:13})};function En(t,s){if(!s)return!0;const n=s.toLowerCase().trim(),a={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"]},o=(t.type||"").toLowerCase(),r=(t.text||t.label||t.value||"").toLowerCase(),l=(t.name||"").toLowerCase(),u=Object.values(t.attributes||{}).join(" ").toLowerCase();for(const[d,i]of Object.entries(a))if(n.includes(d)&&i.some(m=>o.includes(m)))return!0;return o.includes(n)||r.includes(n)||l.includes(n)||u.includes(n)}const je=t=>typeof t=="string"?t.trim():typeof t=="number"?String(t):"";function io(t){const s=je(t),n=s.indexOf(":id/");return n>=0?s.slice(n+4):s}function Dn(t){return(t.type||"").split(".").pop()||""}function Et(t){var s;return[t.type,(s=t.attributes)==null?void 0:s["resource-id"],t.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
|
|
224
|
-
`)}function Ue(t){const s=t.attributes||{};return je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label)||io(s["resource-id"])||je(s.name)||Dn(t)||"Element"}const ro=t=>{const s=t.attributes||{};return!!(je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label))};function oo(t){var s;return(((s=t.children)==null?void 0:s.length)??0)===1&&!Tn(t)&&!ro(t)}function In(t){const s=[t];let n=t;for(;oo(n);)n=n.children[0],s.push(n);return s}function Mn(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{var r;En(o,s)&&n.add(o.xpath),(r=o.children)==null||r.forEach(a)};return a(t),n}function co(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{let r=!1;for(const l of o.children||[])a(l)&&(r=!0);return r&&n.add(o.xpath),r||En(o,s)};return a(t),n}function lo(t,s,n=""){if(!t)return[];const a=!!n.trim(),o=a?Mn(t,n):null,r=a?co(t,n):null,l=i=>!a||i.some(m=>o.has(m.xpath)||r.has(m.xpath)),u=[],d=(i,m,x)=>{const k=i.map(In).filter(l);k.forEach((f,y)=>{var j;const S=f[f.length-1],C=(((j=S.children)==null?void 0:j.length)??0)>0,L=a&&r.has(S.xpath),w=C&&(s.has(S.xpath)||L);u.push({key:S.xpath,nodes:f,level:m,setSize:k.length,posInSet:y+1,hasChildren:C,expanded:w,collapsible:w&&!L,parentKey:x}),w&&d(S.children,m+1,S.xpath)})};return d([t],1,null),u}function uo(t,s=3){const n=new Set,a=(o,r)=>{var d;const l=In(o),u=l[l.length-1];r>s||!((d=u.children)!=null&&d.length)||(n.add(u.xpath),u.children.forEach(i=>a(i,r+1)))};return t&&a(t,1),n}function Rt(t,s){if(!t)return null;if(t.xpath===s)return[t];for(const n of t.children||[]){const a=Rt(n,s);if(a)return[t,...a]}return null}function Hs(t,s){return t.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function ho(t,s,n){var o;const a=t[s];if(!a)return null;switch(n){case"ArrowDown":return s<t.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((o=t[s+1])==null?void 0:o.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const r=t.findIndex(l=>l.key===a.parentKey);return r>=0?{focus:r}:null}case"Home":return{focus:0};case"End":return{focus:t.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const mo=10;function po({rows:t,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:o,onSelect:r,onHover:l,revealSeq:u=0}){const d=c.useRef(null),[i,m]=c.useState(null),x=c.useRef(0),k=c.useRef(null),f=s?Hs(t,s):-1,y=i?t.findIndex(p=>p.key===i):-1,S=y>=0?y:Math.max(f,0),C=p=>{var D;return((D=d.current)==null?void 0:D.querySelector(`[data-row="${p}"]`))??null},L=p=>p.nodes[p.nodes.length-1],w=p=>{var O;const D=t[p];if(!D)return;m(D.key),x.current=p;const A=C(p);A==null||A.focus({preventScroll:!0}),(O=A==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"})};c.useEffect(()=>{k.current=s},[s,u]),c.useEffect(()=>{var A,O;const p=k.current;if(!p)return;const D=Hs(t,p);D<0||((O=(A=C(D))==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"}),k.current=null)}),c.useEffect(()=>{var A,O;if(!i||t.some(W=>W.key===i))return;const p=Math.min(x.current,t.length-1),D=!document.activeElement||document.activeElement===document.body;m(((A=t[p])==null?void 0:A.key)??null),D&&p>=0&&((O=C(p))==null||O.focus({preventScroll:!0}))});const j=p=>{const D=p.target;if(D.getAttribute("role")!=="treeitem")return;const A=ho(t,Number(D.dataset.row),p.key);A&&(p.preventDefault(),"focus"in A?w(A.focus):"toggle"in A?o(A.toggle):r(A.select))},$=p=>{var D;(D=d.current)!=null&&D.contains(p.relatedTarget)||(l(null),m(null))};return e.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:j,onBlur:$,children:t.map((p,D)=>{const A=L(p),O=E=>!!E&&p.nodes.some(J=>J.xpath===E),W=O(s),V=!W&&O(n),q=Ue(A),Q=Dn(A),b=!!Q&&Q!==q,oe=p.nodes.map(E=>Ue(E)).join(", "),te=b?`${oe}, ${Q}`:oe,ce=p.expanded&&!p.collapsible,B=(E,J)=>`omni-tree-row__part${J?" is-target":""}${a.has(E.xpath)?" is-match":""}${E.xpath===s?" is-current":""}`;return e.jsxs("div",{"data-row":D,role:"treeitem","aria-level":p.level,"aria-setsize":p.setSize,"aria-posinset":p.posInSet,"aria-selected":W,"aria-expanded":p.hasChildren?p.expanded:void 0,"aria-label":te,tabIndex:D===S?0:-1,className:`omni-tree-row${W?" is-selected":""}${V?" is-hovered":""}`,onClick:()=>r(A),onFocus:E=>{E.target===E.currentTarget&&(m(p.key),x.current=D,l(A))},onMouseEnter:()=>l(A),onMouseLeave:()=>l(null),children:[e.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[e.jsx("span",{className:"omni-tree-row__indent",style:{width:(p.level-1)*mo}}),e.jsx("span",{className:`omni-tree-row__caret${ce?" is-locked":""}`,onClick:p.hasChildren?E=>{E.stopPropagation(),ce||o(p.key)}:void 0,children:p.hasChildren&&(p.expanded?e.jsx(Xn,{size:12}):e.jsx(ya,{size:12}))}),e.jsx("span",{className:"omni-tree-row__icon",children:An[Rn(A).key]})]}),e.jsxs("span",{className:"omni-tree-row__label",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__head",children:p.nodes.slice(0,-1).map((E,J)=>e.jsxs(Fe.Fragment,{children:[J>0&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsx("span",{className:B(E,!1),title:Et(E),onClick:le=>{le.stopPropagation(),r(E)},onMouseEnter:()=>l(E),onMouseLeave:()=>l(A),children:Ue(E)})]},E.xpath))}),e.jsxs("span",{className:"omni-tree-row__tail",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsxs("span",{className:"omni-tree-row__name",children:[e.jsx("span",{className:B(A,!0),title:Et(A),children:Ue(A)}),b&&e.jsx("span",{className:"omni-tree-row__type",children:Q})]})]})]}),p.hasChildren&&!p.expanded&&e.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:A.children.length})]},p.key)})})}const Ws=4;function fo({path:t,onSelect:s,focusCurrent:n=!1}){const[a,o]=c.useState(!1),r=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{var m;n&&((m=l.current)==null||m.focus())},[]),c.useEffect(()=>{var m;a&&((m=r.current)==null||m.focus())},[a]),!t.length)return null;const u=t[t.length-1],d=t.slice(0,-1),i=!a&&d.length>Ws?d.length-Ws:0;return e.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:e.jsxs("ol",{children:[i>0&&e.jsx("li",{children:e.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>o(!0),children:"…"})}),d.slice(i).map((m,x)=>e.jsx("li",{children:e.jsx("button",{ref:x===0?r:void 0,type:"button",className:"omni-crumb",title:Et(m),"aria-label":Ue(m),onClick:()=>s(m),children:Ue(m)})},m.xpath)),e.jsx("li",{children:e.jsx("span",{ref:l,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Et(u),children:Ue(u)})})]})})}const Dt=.4,yo=240,xo=340,qs=.02,It=12,_n="xenon.omni.split";function zn(t){if(!(t>0))return{min:0,max:1};const s=Math.min(1,yo/t);return{min:s,max:Math.max(s,(t-xo)/t)}}function vo(t,s){const{min:n,max:a}=zn(s),o=Number.isFinite(t)?t:Dt;return Math.min(a,Math.max(n,o))}function go(t){try{const s=Number.parseFloat((t==null?void 0:t.getItem(_n))??"");return s>0&&s<1?s:Dt}catch{return Dt}}function bo(t,s){try{t==null||t.setItem(_n,String(Math.round(s*1e3)/1e3))}catch{}}function Ks(){try{return window.localStorage}catch{return null}}const jo=3;function No({share:t,limits:s,containerRef:n,onChange:a,onCommit:o,onReset:r}){const[l,u]=c.useState(!1),d=c.useRef(t);d.current=t;const i=c.useRef(!0),m=c.useRef(!1),x=c.useRef(0),k=c.useRef(t),f=w=>Math.min(s.max,Math.max(s.min,w)),y=w=>Math.round(w*100),S=()=>{i.current||(i.current=!0,u(!1),m.current&&o(d.current))},C=w=>{var $;const j=($=n.current)==null?void 0:$.getBoundingClientRect();return!j||j.width<=It?d.current:f(k.current+(w-x.current)/(j.width-It))},L=w=>{const j=w.key==="ArrowLeft"?t-qs:w.key==="ArrowRight"?t+qs:w.key==="Home"?s.min:w.key==="End"?s.max:null;j!==null&&(w.preventDefault(),o(f(Math.round(j*1e3)/1e3)))};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":y(t),"aria-valuemin":y(s.min),"aria-valuemax":y(s.max),tabIndex:0,className:`omni-split-divider${l?" is-dragging":""}`,onKeyDown:L,onDoubleClick:r,onPointerDown:w=>{var j,$;($=(j=w.currentTarget).setPointerCapture)==null||$.call(j,w.pointerId),i.current=!1,m.current=!1,x.current=w.clientX,k.current=d.current,u(!0)},onPointerMove:w=>{if(!l||!m.current&&Math.abs(w.clientX-x.current)<jo)return;const j=C(w.clientX);j!==d.current&&(m.current=!0,a(j))},onPointerUp:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onPointerCancel:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onLostPointerCapture:S,children:e.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Xs(t,s,n,a){var w,j,$,p,D,A,O;const{strategy:o,value:r}=a,l=(t.text||t.name||((w=t.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",u=l.charAt(0).toLowerCase()+l.slice(1),d=((j=t.type)==null?void 0:j.toLowerCase().includes("edit"))||(($=t.type)==null?void 0:$.toLowerCase().includes("input"))||((p=t.type)==null?void 0:p.toLowerCase().includes("field"))||((D=t.type)==null?void 0:D.toLowerCase().includes("textfield")),i=((A=t.attributes)==null?void 0:A.scrollable)==="true"||((O=t.attributes)==null?void 0:O.scrollable)===!0,m=o.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
|
|
225
|
-
`:o.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
|
|
226
|
-
`:"",x={"accessibility id":`~${r}`,id:s==="ios"?`-ios predicate string:label == "${r}"`:`android=new UiSelector().resourceId("${r}")`,xpath:`${r}`,"-ios predicate string":`-ios predicate string:${r}`,"-ios class chain":`-ios class chain:${r}`,"-android uiautomator":`android=${r}`},k={"accessibility id":`AppiumBy.accessibilityId("${r}")`,id:`AppiumBy.id("${r}")`,xpath:`AppiumBy.xpath("${r}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${r}")`,"-ios class chain":`AppiumBy.iOSClassChain("${r}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${r}")`,"class name":`AppiumBy.className("${r}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${r}"`,id:`AppiumBy.ID, "${r}"`,xpath:`AppiumBy.XPATH, "${r}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${r}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${r}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${r}'`,"class name":`AppiumBy.CLASS_NAME, "${r}"`},y=k[o.toLowerCase()],S=f[o.toLowerCase()],C=x[o.toLowerCase()];return n==="java"?y?`${m}// Appium Java Client 9.x + Selenium 4 + TestNG
|
|
227
|
-
import io.appium.java_client.AppiumBy;
|
|
228
|
-
import io.appium.java_client.${s==="android"?"AndroidDriver":s==="ios"?"IOSDriver":"AppiumDriver"};
|
|
229
|
-
import org.openqa.selenium.WebElement;
|
|
230
|
-
import org.testng.annotations.Test;
|
|
231
|
-
|
|
232
|
-
@Test
|
|
233
|
-
public void test_${u}() {
|
|
234
|
-
WebElement element = driver.findElement(${y});
|
|
235
|
-
${i?'((Scrollable) element).scrollTo("target text");':d?`element.clear();
|
|
236
|
-
element.sendKeys("your text here");`:"element.click();"}
|
|
237
|
-
// Add assertions here via TestNG Assert or Hamcrest
|
|
238
|
-
}`:`// Strategy "${o}" not supported in Appium Java Client`:n==="python"?S?`${m}# Appium Python Client 4.x + pytest
|
|
239
|
-
from appium.webdriver.common.appiumby import AppiumBy
|
|
240
|
-
import pytest
|
|
241
|
-
|
|
242
|
-
def test_${u}(self):
|
|
243
|
-
element = self.driver.find_element(${S})
|
|
244
|
-
${d?`element.clear()
|
|
245
|
-
element.send_keys("your text here")`:"element.click()"}
|
|
246
|
-
# Add assertions here via assert or pytest.assert`:`# Strategy "${o}" not supported in Appium Python Client`:n==="javascript"?C?`${m}// WebdriverIO 9.x + @wdio/appium-service
|
|
247
|
-
describe('${u} test', () => {
|
|
248
|
-
it('should interact with ${u}', async () => {
|
|
249
|
-
const element = await $('${C}');
|
|
250
|
-
await element.waitForDisplayed({ timeout: 5000 });
|
|
251
|
-
${d?`await element.clearValue();
|
|
252
|
-
await element.addValue("your text here");`:"await element.click();"}
|
|
253
|
-
// Add assertions here via expect(element)
|
|
254
|
-
});
|
|
255
|
-
});`:`// Strategy "${o}" not supported in WebdriverIO mobile`:C?`${m}// WebdriverIO 9.x standalone
|
|
256
|
-
const element = await driver.$('${C}');
|
|
257
|
-
await element.waitForExist({ timeout: 5000 });
|
|
258
|
-
${d?`await driver.$('target').clearValue();
|
|
259
|
-
await element.addValue("your text here");`:"await element.click();"}
|
|
260
|
-
// Assert with expect(element).toBeDisplayed()`:`// Strategy "${o}" not supported in WebdriverIO mobile`}const ko={pass:e.jsx(mn,{size:13}),warn:e.jsx($e,{size:13}),fail:e.jsx(pn,{size:13}),info:e.jsx(nn,{size:13})},wo={pass:"passed",warn:"warning",fail:"failed",info:"note"},So={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},Co=({sessionId:t,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:o=null,onModeChange:r,deviceActionAt:l=0})=>{var ks,ws,Ss,Cs,$s,Ts;const[u,d]=c.useState(!0),[i,m]=c.useState(null),[x,k]=c.useState(null),[f,y]=c.useState(null),[S,C]=c.useState(0),L=c.useRef(!1),[w,j]=c.useState(null),[$,p]=c.useState(()=>new Set),[D,A]=c.useState(""),[O,W]=c.useState(null),[V,q]=c.useState("info"),[Q,b]=c.useState(0),[oe,te]=c.useState(0),[ce,B]=c.useState(()=>Date.now()),E=c.useRef(0),J=c.useRef(null),[le,ue]=c.useState("java"),[de,fe]=c.useState(null),[ee,ge]=c.useState({width:0,height:0}),[be,_]=c.useState({width:0,height:0}),[v,H]=c.useState(!1),[P,K]=c.useState("inspect");c.useEffect(()=>{r==null||r(P)},[P,r]);const[Ne,tt]=c.useState({}),[zt,st]=c.useState({}),[He,nt]=c.useState(null),[Z,ke]=c.useState(null),[Ee,_e]=c.useState(null),We=c.useRef(null),Lt=c.useRef(null),pt=c.useRef(null),we=c.useRef(null),qe=c.useRef(null),[Ot,ft]=c.useState(()=>go(Ks())),[yt,Pt]=c.useState(0);c.useEffect(()=>{const h=qe.current;if(!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(([N])=>Pt(Math.max(0,N.contentRect.width-It)));return g.observe(h),()=>g.disconnect()},[]);const at=vo(Ot,yt),xt=h=>{ft(h),bo(Ks(),h)},Ke=c.useCallback(()=>{var Se,Ce,Ie;if(!We.current)return;const h=We.current.getBoundingClientRect(),g=h.width,N=h.height,T=(Se=i==null?void 0:i.hierarchy)==null?void 0:Se.rect;let z=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.screenWidth)||ee.width||1,R=((Ie=i==null?void 0:i.metadata)==null?void 0:Ie.screenHeight)||ee.height||1;T&&T.width>0&&T.height>0&&(z=T.width,R=T.height);const X=z/R;let ve,me;g/N>X?(me=N,ve=me*X):(ve=g,me=ve/X),_({width:ve,height:me})},[i,ee]);c.useEffect(()=>(Ke(),window.addEventListener("resize",Ke),()=>window.removeEventListener("resize",Ke)),[Ke]),c.useEffect(()=>{s&&De()},[s]);const vt=c.useCallback(async(h,g,N)=>{if(Z!=null&&Z.sessionId){nt(h);try{const T=await M.verifyLocator(Z.basePath,Z.sessionId,{strategy:h,selector:g,action:N});st(z=>({...z,[h]:T})),N==="tap"&&te(Date.now())}catch(T){st(z=>({...z,[h]:{found:!1,count:0,error:(T==null?void 0:T.message)||String(T)}}))}finally{nt(null)}}},[Z]),it=c.useRef(null);c.useEffect(()=>{const h=!!f&&f.xpath===it.current;it.current=(f==null?void 0:f.xpath)??null;const g=(f==null?void 0:f.suggestedLocators)??[];fe(N=>{const T=h&&N?g.find(R=>R.strategy===N.strategy):null,z=g.find(R=>R.strategy==="accessibility id"||R.strategy==="id");return T||z||g[0]||null}),tt({}),st({}),_e(null)},[f]);const Ft=c.useCallback((h,g)=>{if(!(i!=null&&i.hierarchy))return;const N=cs(i.hierarchy,h,g);tt(T=>({...T,[h]:N})),_e(h)},[i]),De=async()=>{if(!s)return;const h=++E.current,g=()=>h===E.current;d(!0),k(null),M.getAppiumSession(s).then(N=>{g()&&ke({sessionId:(N==null?void 0:N.sessionId)??null,basePath:(N==null?void 0:N.basePath)??""})}).catch(()=>{g()&&ke({sessionId:null,basePath:""})});try{const N=await M.getInspectorSnapshot(s);if(!g())return;if(!(N!=null&&N.hierarchy)){m(null),k((N==null?void 0:N.error)||"Failed to capture snapshot");return}const T=N.udid||s,z=T===J.current;J.current=T,_s.unstable_batchedUpdates(()=>{m(N),b(Date.now()),p(uo(N.hierarchy)),y(R=>{var X;return R&&z?((X=Rt(N.hierarchy,R.xpath))==null?void 0:X.pop())??null:null}),C(R=>R+1)})}catch(N){if(!g())return;m(null),k(N.message||"Failed to capture snapshot")}finally{g()&&d(!1)}};c.useEffect(()=>{const h=setInterval(()=>B(Date.now()),1e4);return()=>clearInterval(h)},[]);const Ut=h=>{const{naturalWidth:g,naturalHeight:N}=h.currentTarget;ge({width:g,height:N})},Bt=()=>H(!0),I=h=>{H(!1);const{naturalWidth:g,naturalHeight:N}=h.currentTarget;g>0&&N>0&&ge({width:g,height:N})},F=n&&!v,G=h=>{if(P!=="interact"||!s)return;const g=h.currentTarget.getBoundingClientRect();we.current={x:h.clientX-g.left,y:h.clientY-g.top,time:Date.now()}},se=async h=>{var As,Es,Ds;if(P!=="interact"||!s||!we.current)return;const g=we.current,N=h.currentTarget.getBoundingClientRect(),T=h.clientX-N.left,z=h.clientY-N.top,R=Date.now()-g.time,X=be.width,ve=be.height,me=(As=i==null?void 0:i.hierarchy)==null?void 0:As.rect;let Se=((Es=i==null?void 0:i.metadata)==null?void 0:Es.screenWidth)||ee.width,Ce=((Ds=i==null?void 0:i.metadata)==null?void 0:Ds.screenHeight)||ee.height;if(me&&me.width>0&&me.height>0&&(Se=me.width,Ce=me.height),!Se||!Ce||X===0||ve===0)return;const Ie=(jt,Is)=>({x:Math.round(jt/X*Se),y:Math.round(Is/ve*Ce),px:jt/X,py:Is/ve}),he=Ie(g.x,g.y),Rs=Ie(T,z),Xt=Math.sqrt(Math.pow(T-g.x,2)+Math.pow(z-g.y,2));if(!(he.px<0||he.px>1||he.py<0||he.py>1)){try{R<500&&Xt<10?await M.tap(s,he.x,he.y):R>=500&&Xt<10?await M.touchAndHold(s,he.x,he.y,R):Xt>=10&&await M.swipe(s,he.x,he.y,Rs.x,Rs.y),te(Date.now())}catch(jt){console.error("Interaction failed:",jt)}we.current=null}},ye=h=>{p(g=>{const N=new Set(g);return N.has(h)?N.delete(h):N.add(h),N})},ie=()=>{const h=new Set,g=N=>{var T;h.add(N.xpath),(T=N.children)==null||T.forEach(g)};i!=null&&i.hierarchy&&g(i.hierarchy),p(h)},xe=()=>p(new Set),ne=(h,g)=>{navigator.clipboard.writeText(h),W(g),setTimeout(()=>W(null),2e3)},ae=h=>{var N;let g=1;return(N=h.children)==null||N.forEach(T=>g+=ae(T)),g},Xe=h=>{if(!h)return[];const g={},N=T=>{var R;const z=Rn(T);g[z.role]||(g[z.role]={key:z.key,count:0}),g[z.role].count+=1,(R=T.children)==null||R.forEach(N)};return N(h),Object.entries(g).map(([T,z])=>({role:T,key:z.key,count:z.count})).sort((T,z)=>z.count-T.count)},Ge=c.useMemo(()=>lo(i==null?void 0:i.hierarchy,$,D),[i,$,D]),ze=c.useMemo(()=>Mn(i==null?void 0:i.hierarchy,D),[i,D]),rt=ze.size===0?"No matches":ze.size===1?"1 match":`${ze.size} matches`;c.useEffect(()=>{if(!f||!(i!=null&&i.hierarchy))return;const h=Rt(i.hierarchy,f.xpath);!h||h.length<2||p(g=>{const N=h.slice(0,-1).filter(z=>!g.has(z.xpath));if(!N.length)return g;const T=new Set(g);return N.forEach(z=>T.add(z.xpath)),T})},[S]),c.useEffect(()=>{L.current=!1});const Ye=h=>{y(h),C(g=>g+1),q("info")},Vt=h=>{L.current=!0,Ye(h)},gs=h=>{D.trim()&&!h.trim()&&C(g=>g+1),A(h)},Ht=()=>{var T,z,R;const h=(T=i==null?void 0:i.hierarchy)==null?void 0:T.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const g=((z=i==null?void 0:i.metadata)==null?void 0:z.screenWidth)||ee.width,N=((R=i==null?void 0:i.metadata)==null?void 0:R.screenHeight)||ee.height;return g>0&&N>0?{w:g,h:N}:null},bs=h=>{const g=Ht();if(!g)return[];const N=[],{w:T,h:z}=g,R=(X,ve)=>{var Se,Ce,Ie;const me=!X.children||X.children.length===0;((Se=X.rect)==null?void 0:Se.width)>0&&((Ce=X.rect)==null?void 0:Ce.height)>0&&me&&N.push(e.jsx("div",{className:"omni-hit-area",style:{left:`${X.rect.x/T*100}%`,top:`${X.rect.y/z*100}%`,width:`${X.rect.width/T*100}%`,height:`${X.rect.height/z*100}%`,zIndex:ve},onClick:he=>{he.stopPropagation(),Ye(X)},onMouseEnter:()=>j(X),onMouseLeave:()=>j(null)},X.xpath)),(Ie=X.children)==null||Ie.forEach(he=>R(he,ve+1))};return i!=null&&i.hierarchy&&R(i.hierarchy,1),N},js=()=>{const h=Ht();if(!Ee||!h)return[];const g=Ne[Ee];if(!g||g.kind!=="matched"||g.nodes.length===0)return[];const{w:N,h:T}=h,z=g.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return g.nodes.filter(R=>R.rect&&R.rect.width>0&&R.rect.height>0).map((R,X)=>e.jsx("div",{className:z,style:{left:`${R.rect.x/N*100}%`,top:`${R.rect.y/T*100}%`,width:`${R.rect.width/N*100}%`,height:`${R.rect.height/T*100}%`}},`match-${Ee}-${X}`))},gt=(h,g)=>{const N=Ht();if(!(h!=null&&h.rect)||!N)return null;const{w:T,h:z}=N;return e.jsx("div",{className:`omni-frame-${g}`,style:{left:`${h.rect.x/T*100}%`,top:`${h.rect.y/z*100}%`,width:`${h.rect.width/T*100}%`,height:`${h.rect.height/z*100}%`}})},Wt=i!=null&&i.hierarchy?ae(i.hierarchy):0,bt=f&&(i!=null&&i.hierarchy)?to(f,i):null,Le=bt?so(bt):null,qt=ao(Q,Math.max(l,oe)),Kt=i!=null&&i.hierarchy&&P==="inspect"?e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]}):null,Hn={stable:{icon:e.jsx(Nt,{size:10}),cls:"stable"},moderate:{icon:e.jsx($e,{size:10}),cls:"moderate"},fragile:{icon:e.jsx(Ze,{size:10}),cls:"fragile"},"very-fragile":{icon:e.jsx(Ze,{size:10}),cls:"very-fragile"}},Ns=a&&(i!=null&&i.hierarchy)?Xe(i.hierarchy):[];return e.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&o&&Kt?_s.createPortal(Kt,o):null,e.jsxs("div",{className:"omni-main-content",children:[!a&&e.jsxs("div",{className:"omni-screenshot-panel",children:[e.jsxs("div",{className:"omni-screenshot-header",children:[e.jsxs("div",{className:"omni-header-left",children:[e.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),e.jsxs("div",{className:"omni-mode-toggle",children:[e.jsxs("button",{className:`omni-mode-btn ${P==="inspect"?"active":""}`,onClick:()=>K("inspect"),title:"Inspection mode (highlight elements)",children:[e.jsx(Os,{size:12}),e.jsx("span",{children:"Inspect"})]}),e.jsxs("button",{className:`omni-mode-btn ${P==="interact"?"active":""}`,onClick:()=>K("interact"),title:"Interaction mode (direct control)",children:[e.jsx(Us,{size:12}),e.jsx("span",{children:"Interact"})]})]})]}),e.jsxs("button",{className:"omni-refresh-btn",onClick:De,disabled:u,children:[e.jsx(lt,{size:12,className:u?"animate-spin":""}),u?"Capturing...":"Refresh"]})]}),e.jsxs("div",{className:"omni-screenshot-container",ref:We,children:[u&&!F&&e.jsxs("div",{className:"omni-loading-overlay",children:[e.jsx("div",{className:"omni-spinner"}),e.jsx("span",{children:"Capturing screen..."})]}),!i&&!u&&!F&&e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:40}),e.jsx("span",{children:"Click Refresh to capture"})]}),F&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx(rn,{ref:pt,src:n,onLoad:I,onError:Bt,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),Kt]}),!F&&(i==null?void 0:i.screenshot)&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:Lt,src:`data:image/png;base64,${i.screenshot}`,onLoad:Ut,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1}),P==="inspect"&&e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]})]})]})]}),e.jsxs("div",{className:"omni-split",ref:qe,children:[e.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${at*100}% - ${at*It}px)`},children:[e.jsxs("div",{className:"omni-tree-header",children:[e.jsxs("div",{className:"omni-tree-title",children:[e.jsx(un,{size:14}),e.jsx("span",{children:"Source"})]}),e.jsxs("div",{className:"omni-tree-actions",children:[e.jsx("button",{onClick:ie,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:e.jsx(Fa,{size:12})}),e.jsx("button",{onClick:xe,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:e.jsx(Oa,{size:12})}),a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(P==="inspect"?"interact":"inspect"),className:`omni-action-btn ${P==="inspect"?"active":""}`,title:P==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":P==="inspect"?"Inspect mode":"Interact mode","aria-pressed":P==="inspect",children:P==="inspect"?e.jsx(Os,{size:12}):e.jsx(Us,{size:12})}),e.jsx("button",{onClick:De,className:"omni-action-btn",title:u?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:u,children:e.jsx(lt,{size:12,className:u?"animate-spin":""})})]})]})]}),x&&!u&&e.jsxs("div",{className:"omni-tree-error",role:"alert",children:[e.jsx(Ze,{size:12}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",onClick:De,className:"omni-tree-error-retry",children:"Retry"})]}),i&&!u&&!x&&(qt?e.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[e.jsx($e,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"The screen may have changed since this capture."}),e.jsx("button",{type:"button",onClick:De,className:"omni-capture-refresh",children:"Refresh"})]}):e.jsxs("div",{className:"omni-capture-meta",children:[e.jsxs("span",{children:[Wt," ",Wt===1?"element":"elements"]}),i.hierarchySource&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"omni-capture-source",title:i.hierarchySource==="appium-session"?`From Appium session ${i.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:i.hierarchySource==="appium-session"?"Session":"Device"})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:no(Q,ce)})]})),e.jsxs("div",{className:"omni-tree-search",children:[e.jsx(hs,{size:14}),e.jsx("input",{type:"text",placeholder:"Search elements",value:D,onChange:h=>gs(h.target.value),"aria-label":"Search elements"}),D&&e.jsx("button",{onClick:()=>gs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),e.jsx("div",{role:"status",className:"sr-only",children:D.trim()?rt:""}),D.trim()&&e.jsxs("div",{className:"omni-search-hint",children:[rt," · try a role: button, input, image"]}),e.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?e.jsx(po,{rows:Ge,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:ze,onToggle:ye,onSelect:Ye,onHover:j,revealSeq:S}):e.jsx("div",{className:"omni-empty-state small",children:e.jsx("span",{children:"No hierarchy loaded"})})})]}),e.jsx(No,{share:at,limits:zn(yt),containerRef:qe,onChange:ft,onCommit:xt,onReset:()=>xt(Dt)}),e.jsxs("div",{className:"omni-details-panel",children:[e.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[e.jsxs("button",{className:`omni-details-tab ${V==="info"?"active":""}`,onClick:()=>q("info"),role:"tab","aria-selected":V==="info",children:[e.jsx(ii,{size:12})," ",e.jsx("span",{children:"Info"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="checks"?"active":""}`,onClick:()=>q("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":V==="checks",children:[e.jsx(fa,{size:12})," ",e.jsx("span",{children:"Checks"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="code"?"active":""}`,onClick:()=>q("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":V==="code",children:[e.jsx(Fs,{size:12})," ",e.jsx("span",{children:"Code gen"})]})]}),e.jsx("div",{className:"omni-details-content",children:f?e.jsxs(e.Fragment,{children:[V==="info"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Element info"}),e.jsxs("div",{className:"omni-info-table",children:[e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Type"}),e.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Text"}),e.jsx("span",{className:"omni-info-value",children:f.text})]}),e.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[e.jsx("span",{className:"omni-info-key",children:"Path"}),e.jsx(fo,{path:(i==null?void 0:i.hierarchy)&&Rt(i.hierarchy,f.xpath)||[f],onSelect:Vt,focusCurrent:L.current},f.xpath)]})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Layout"}),e.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>e.jsxs("div",{className:"omni-layout-item",children:[e.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),e.jsx("span",{className:"omni-layout-value",children:f.rect[h]})]},h))})]}),e.jsxs("div",{className:"omni-section",children:[e.jsxs("div",{className:"omni-section-header",children:["Locators",e.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(Z!=null&&Z.sessionId)&&((Ss=f.suggestedLocators)==null?void 0:Ss.length)>0&&e.jsxs("p",{className:"omni-locators-note",children:[e.jsx(nn,{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."]}),e.jsxs("div",{className:"omni-locators-list",children:[!((Cs=f.suggestedLocators)!=null&&Cs.length)&&e.jsx("div",{className:"omni-locators-empty",children:f===(i==null?void 0:i.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."}),($s=f.suggestedLocators)==null?void 0:$s.map(h=>{const g=ls(h.strategy,h.value),N=Hn[g.level],T=Ne[h.strategy];let z=null;return T&&(T.kind==="unsupported"?z=e.jsxs("span",{className:"omni-match-badge unsupported",title:T.reason||"Cannot evaluate without a real driver",children:[e.jsx(Ba,{size:10})," preview unavailable"]}):T.nodes.length===0?z=e.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[e.jsx(Ze,{size:10})," 0 matches"]}):T.nodes.length===1?z=e.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[e.jsx(Nt,{size:10})," unique"]}):z=e.jsxs("span",{className:"omni-match-badge multi",title:`${T.nodes.length} elements match — selector is not unique`,children:[e.jsx($e,{size:10})," ",T.nodes.length," matches"]})),e.jsx("div",{className:`omni-locator-row ${(de==null?void 0:de.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>fe(h),title:"Click to use in Code gen",children:e.jsxs("div",{className:"omni-locator-left",children:[e.jsxs("div",{className:"omni-locator-top",children:[e.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),e.jsxs("span",{className:`omni-stability-badge ${N.cls}`,title:g.reason,children:[N.icon,g.level]}),z]}),e.jsx("code",{className:"omni-locator-value",children:h.value}),e.jsx("span",{className:"omni-stability-reason",children:g.reason}),(()=>{const R=zt[h.strategy];return R?R.error?e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium error: ",R.error]}):R.found?R.count>1?e.jsxs("span",{className:"omni-verify-line is-warn",children:[e.jsx($e,{size:10})," Ambiguous — Appium found"," ",R.count," elements",R.actionError?` · ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-ok",children:[e.jsx(Nt,{size:10})," Appium found 1 element",R.elapsedMs!=null?` in ${R.elapsedMs}ms`:"",R.actionPerformed&&R.actionPerformed!=="none"?` · ${R.actionPerformed} ok`:"",R.actionError?` · action failed: ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium found 0 elements"]}):null})(),e.jsxs("div",{className:"omni-locator-actions",children:[e.jsxs(Y,{type:"button",variant:Ee===h.strategy?"tonal":"secondary",size:"sm",onClick:R=>{R.stopPropagation(),Ft(h.strategy,h.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[e.jsx(Wa,{size:12,"aria-hidden":"true"}),"Test"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[He===h.strategy?e.jsx(lt,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(Nt,{size:12,"aria-hidden":"true"}),"Verify"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[e.jsx(hn,{size:12,"aria-hidden":"true"}),"Tap"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",onClick:R=>{R.stopPropagation(),ne(h.value,h.strategy)},title:"Copy the locator's value","aria-label":O===h.strategy?"Copied":"Copy locator",children:[O===h.strategy?e.jsx(dt,{size:12,"aria-hidden":"true"}):e.jsx(Te,{size:12,"aria-hidden":"true"}),O===h.strategy?"Copied":"Copy"]})]})]})},h.strategy)})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Attributes"}),e.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([h,g])=>g!=null&&g!=="").map(([h,g])=>e.jsxs("div",{className:"omni-attr-row",children:[e.jsx("span",{className:"omni-attr-key",children:h}),e.jsx("span",{className:"omni-attr-value",children:String(g)})]},h))})]})]}),V==="checks"&&bt&&Le&&e.jsxs("div",{className:"omni-checks-panel",children:[e.jsxs("p",{className:"omni-checks-summary",children:[e.jsxs("span",{className:"is-pass",children:[e.jsx(mn,{size:12,"aria-hidden":"true"})," ",Le.pass," passed"]}),Le.warn>0&&e.jsxs("span",{className:"is-warn",children:[e.jsx($e,{size:12,"aria-hidden":"true"})," ",Le.warn," ",Le.warn===1?"warning":"warnings"]}),Le.fail>0&&e.jsxs("span",{className:"is-fail",children:[e.jsx(pn,{size:12,"aria-hidden":"true"})," ",Le.fail," failed"]})]}),e.jsx("ul",{className:"omni-checks-list",children:bt.map(h=>e.jsxs("li",{className:`omni-check is-${h.status}`,children:[e.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:ko[h.status]}),e.jsxs("div",{className:"omni-check-body",children:[e.jsxs("div",{className:"omni-check-label",children:[h.label,e.jsxs("span",{className:"sr-only",children:[": ",wo[h.status]]})]}),e.jsx("div",{className:"omni-check-detail",children:h.detail})]})]},h.id))})]}),V==="code"&&e.jsxs("div",{className:"omni-codegen-panel",children:[e.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>e.jsx("button",{className:`omni-fw-btn ${le===h?"active":""}`,onClick:()=>ue(h),children:So[h]},h))}),de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-codegen-locator-selector",children:[e.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),e.jsx(ms,{selectSize:"sm",value:de.strategy,onChange:h=>{var N;const g=(N=f.suggestedLocators)==null?void 0:N.find(T=>T.strategy===h.target.value);g&&fe(g)},className:"flex-1",children:(Ts=f.suggestedLocators)==null?void 0:Ts.map(h=>e.jsxs("option",{value:h.strategy,children:[h.strategy," — ",ls(h.strategy,h.value).level]},h.strategy))})]}),e.jsxs("div",{className:"omni-codegen-output",children:[e.jsxs("div",{className:"omni-codegen-header",children:[e.jsx("span",{className:"omni-codegen-lang",children:le==="java"?"Java / TestNG":le==="python"?"Python / unittest":le==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),e.jsx("button",{className:"omni-copy-btn",onClick:()=>ne(Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de),"code"),children:O==="code"?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]}),e.jsx("pre",{className:"omni-codegen-pre theme-dark",children:e.jsx("code",{children:Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de)})})]})]}):e.jsxs("div",{className:"omni-empty-state small",children:[e.jsx(Fs,{size:24}),e.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?e.jsxs("div",{className:"omni-summary-panel",children:[e.jsxs("div",{className:"omni-summary-hero",children:[e.jsx(Zt,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"omni-summary-title",children:"No element selected"}),e.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),e.jsxs("div",{className:"omni-summary-stats",children:[e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),e.jsx("span",{className:"omni-summary-stat__value",children:Wt})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ks=i.metadata)==null?void 0:ks.screenWidth)??ee.width??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ws=i.metadata)==null?void 0:ws.screenHeight)??ee.height??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),e.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),Ns.length>0&&e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"By role"}),e.jsx("div",{className:"omni-summary-roles",children:Ns.slice(0,8).map(h=>e.jsxs("div",{className:"omni-summary-role",children:[e.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:An[h.key]}),e.jsx("span",{className:"omni-summary-role__name",children:h.role}),e.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:32}),e.jsx("span",{children:u?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Gs=5e3;function $o(t,s=!0){const[n,a]=c.useState("unknown"),o=c.useRef("unknown");return c.useEffect(()=>{if(!t||!s){a("unknown"),o.current="unknown";return}let r=!1,l;const u=m=>{r||m===o.current||(o.current=m,a(m))},d=async()=>{if(!r){if(l&&(clearTimeout(l),l=void 0),typeof document<"u"&&document.visibilityState==="hidden"){l=setTimeout(d,Gs);return}try{const m=await M.getDisplayState(t);u((m==null?void 0:m.state)??"unknown")}catch{}r||(l=setTimeout(d,Gs))}};d();const i=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",i),()=>{r=!0,l&&clearTimeout(l),document.removeEventListener("visibilitychange",i)}},[t,s]),n}function To(t,s){const n=c.useRef(t),a=c.useRef(s);n.current=t,a.current=s,c.useEffect(()=>{const o=()=>n.current(),r=l=>{var u;l.persisted&&((u=a.current)==null||u.call(a))};return window.addEventListener("pagehide",o),window.addEventListener("pageshow",r),()=>{window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",r)}},[])}const Ys=5e3,Ro=500,Ao=1e4,Eo=10,Do=50;function Io(t,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[o,r]=c.useState([]),[l,u]=c.useState(!1),[d,i]=c.useState(null),[m,x]=c.useState(!1),k=c.useRef(null),f=c.useRef(0),y=c.useRef(void 0),S=c.useRef(()=>{}),C=c.useRef([]),L=c.useRef(void 0),w=c.useRef(0),j=c.useRef(void 0),$=c.useCallback(()=>{if(C.current.length===0)return;const O=C.current;C.current=[],r(W=>{const V=W.concat(O);return V.length>Ys?V.slice(-Ys):V})},[]),p=c.useCallback(()=>{L.current===void 0&&(L.current=window.setTimeout(()=>{L.current=void 0,$()},Do))},[$]),D=c.useCallback(()=>{C.current=[],r([])},[]);c.useEffect(()=>{if(!s){u(!1),i(null),x(!1);return}i(null),x(!1),f.current=0;const O={cancelled:!1},W=()=>{if(O.cancelled)return;if(f.current>=Eo){x(!0);return}const q=Math.min(Ro*2**f.current,Ao);f.current+=1,y.current=window.setTimeout(V,q)},V=async()=>{if(!O.cancelled)try{const q=await fetch(`/xenon/api/control/${encodeURIComponent(t)}/stream/ticket`,{method:"POST",credentials:"include"});if(O.cancelled)return;if(!q.ok){W();return}const{ticket:Q}=await q.json();if(O.cancelled)return;if(!Q){W();return}const b=window.location.protocol==="https:"?"wss":"ws",[oe,te]=a.split("|"),ce=(oe?`&levels=${encodeURIComponent(oe)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),B=new WebSocket(`${b}://${window.location.host}/xenon/api/control/${encodeURIComponent(t)}/logcat?ticket=${encodeURIComponent(Q)}${ce}`);k.current=B,B.onopen=()=>{f.current=0,j.current!==1012&&(C.current=[],r([])),j.current=void 0,u(!0)},B.onmessage=E=>{try{const J=JSON.parse(E.data);C.current.push({...J,seq:w.current++}),p()}catch{}},B.onclose=E=>{if(u(!1),j.current=E.code,$(),E.code===1008){O.cancelled=!0,i(E.reason||"access denied");return}if(E.code===1012){W();return}console.warn(`[logcat] WS closed unexpectedly (code ${E.code}) — retrying`),W()},B.onerror=()=>B.close()}catch{W()}};return S.current=()=>{O.cancelled=!1,f.current=0,i(null),x(!1),V()},V(),()=>{var q;O.cancelled=!0,y.current!==void 0&&window.clearTimeout(y.current),L.current!==void 0&&(window.clearTimeout(L.current),L.current=void 0),$(),(q=k.current)==null||q.close(),k.current=null}},[t,s,a,$,p]);const A=c.useCallback(()=>{S.current()},[]);return{records:o,connected:l,clear:D,deniedReason:d,exhausted:m,retry:A}}const ds=["V","D","I","W","E","F"];function Mo(t){const s=[];let n="",a=!1,o=!1;for(const r of t){if(r==='"'){a=!a,o=!0;continue}if(!a&&/\s/.test(r)){(o||n)&&s.push(n),n="",o=!1;continue}n+=r,o=!0}return(o||n)&&s.push(n),s.filter(r=>r.length>0)}function Ln(t,s={}){const n=s.caseSensitive===!0,a=l=>n?l:l.toLowerCase(),o=n?{caseSensitive:!0}:{},r=[];for(const l of Mo(t)){const[u,...d]=l.split(":"),i=d.join(":");i&&u.toLowerCase()==="level"?o.minLevel=i.toUpperCase():i&&u.toLowerCase()==="tag"?o.tag=a(i):i&&u.toLowerCase()==="package"?o.pkg=a(i):r.push(l)}return r.length&&(o.text=a(r.join(" "))),o}function _o(t,s){if(t.synthetic)return!0;if(s.minLevel){const a=ds.indexOf(s.minLevel),o=ds.indexOf(t.level);if(a>=0&&o>=0&&o<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();return!(s.tag&&!n(t.tag).includes(s.tag)||s.pkg&&!n(t.pkg??"").includes(s.pkg)||s.text&&!n(t.message).includes(s.text))}function zo(t,s){const n=t.trim().split(/\s+/).filter(Boolean).filter(a=>{const[o,...r]=a.split(":");return!(r.join(":")&&o.toLowerCase()==="level")});return s?["level:"+s.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"}],Zs=["V","D","I","W","E","F"];function Lo(t){if(!t)return ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=Zs.indexOf(t.toUpperCase());return s<0?ss.map(n=>n.ios):ss.filter(n=>Zs.indexOf(n.android)>=s).map(n=>n.ios)}function Oo(t){const s=Ln(t,{caseSensitive:!0});return{levels:Lo(s.minLevel),process:s.pkg||void 0}}const Js=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Po(t){let s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Fo(t){return t?Js[Po(t)%Js.length]:"var(--text-muted)"}const us=5e5;function On(t){return`${new Date(t.ts).toISOString()} ${t.pid} ${t.level}/${t.tag}: ${t.message}`}function Uo(t){return{lines:[],startedAt:t,dropped:0}}function Bo(t,s){for(const n of s){if(t.lines.length>=us){t.dropped+=1;continue}t.lines.push(On(n))}return t}function Vo(t,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(t.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-t.startedAt)/1e3).toFixed(1)}s`,`# lines: ${t.lines.length}`];t.dropped>0&&a.push(`# TRUNCATED: ${t.dropped} further line(s) were dropped after the ${us}-line cap. This capture is INCOMPLETE.`);const o=t.lines.join(`
|
|
261
|
-
`),r=t.dropped>0?`
|
|
262
|
-
# --- TRUNCATED: ${t.dropped} line(s) not captured (cap ${us}) ---`:"";return`${a.join(`
|
|
263
|
-
`)}
|
|
264
|
-
|
|
265
|
-
${o}${r}
|
|
266
|
-
`}function Ho(t,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${t}-${n}.txt`}const Qs=ds.filter(t=>t!=="V").map(t=>({value:t,label:t==="F"?"F only":`${t} and above`})),Wo=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function en(t,s){const n=URL.createObjectURL(new Blob([t],{type:"text/plain"})),a=document.createElement("a");a.href=n,a.download=s,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(n),0)}const qo=c.memo(function({record:s,index:n,isHit:a,isActiveHit:o}){return e.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${a?"is-hit":""} ${o?"is-active-hit":""}`,children:[e.jsx("span",{className:"logcat-time",children:Wo.format(s.ts)}),e.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),e.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:Fo(s.tag)},children:s.tag}),e.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),e.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),e.jsx("span",{className:"logcat-msg",children:s.message})]})});function Ko({udid:t,platform:s}){const n=(s||"").toLowerCase(),a=n==="ios",o=n==="android"||a,[r,l]=c.useState(""),u=c.useMemo(()=>a?Oo(r):void 0,[a,r]),{records:d,connected:i,clear:m,deniedReason:x,exhausted:k,retry:f}=Io(t,o,u),[y,S]=c.useState(!0),[C,L]=c.useState(!1),[w,j]=c.useState(!0),[$,p]=c.useState(""),[D,A]=c.useState(0),O=c.useRef(null),W=c.useRef(null),V=c.useRef(null),[q,Q]=c.useState(!1),[b,oe]=c.useState(0),te=c.useRef(-1),ce=c.useMemo(()=>Ln(r,{caseSensitive:C}),[r,C]),B=c.useMemo(()=>d.filter(_=>_o(_,ce)),[d,ce]),E=c.useMemo(()=>{if(!$)return[];const _=C?$:$.toLowerCase(),v=[];return B.forEach((H,P)=>{(C?`${H.tag} ${H.message}`:`${H.tag} ${H.message}`.toLowerCase()).includes(_)&&v.push(P)}),v},[B,$,C]),J=E.length?Math.min(D,E.length-1):0,le=c.useMemo(()=>new Set(E),[E]),ue=c.useCallback(_=>{var H,P;if(!E.length)return;const v=(J+_+E.length)%E.length;A(v),S(!1),(P=(H=W.current)==null?void 0:H.querySelector(`[data-row-index="${E[v]}"]`))==null||P.scrollIntoView({block:"center"})},[E,J]),de=Qs.some(_=>_.value===ce.minLevel)?ce.minLevel:"",fe=c.useCallback(()=>{en(B.map(On).join(`
|
|
267
|
-
`),`logcat-${t}-${Date.now()}.txt`)},[B,t]);c.useEffect(()=>{const _=V.current;if(!_||!d.length)return;const v=d.filter(P=>P.seq>te.current);if(!v.length)return;const H=te.current+1;te.current>=0&&v[0].seq>H&&(_.dropped+=v[0].seq-H),Bo(_,v),te.current=v[v.length-1].seq,oe(_.lines.length)},[d]);const ee=c.useCallback(()=>{const _=V.current;if(!_){te.current=d.length?d[d.length-1].seq:-1,V.current=Uo(Date.now()),oe(0),Q(!0);return}const v=Vo(_,Date.now(),t);V.current=null,Q(!1),oe(0),en(v,Ho(t,_.startedAt))},[d,t]);if(c.useEffect(()=>{var _;y&&((_=O.current)==null||_.scrollIntoView({block:"end"}))},[B.length,y]),!o)return e.jsxs("div",{className:"log-empty-state",children:[e.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),e.jsx("p",{className:"log-empty-subtitle",children:"Streaming is wired up for Android (logcat) and iOS (os_trace), not for this device's platform."})]});const ge=x?"Denied":k?"Offline":i?"Live":"Connecting",be=!i&&(!!x||k);return e.jsxs("div",{className:"logcat-root",children:[e.jsxs("div",{className:"log-toolbar",children:[e.jsxs("div",{className:"log-filter-group",children:[e.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[e.jsx("span",{className:`log-live-dot ${i?"active":""} ${be?"is-error":""}`}),ge]}),e.jsxs("div",{className:"log-stat-pill logcat-count",children:[B.length," / ",d.length]}),e.jsxs(ms,{selectSize:"sm",value:de,onChange:_=>l(zo(r,_.target.value)),"aria-label":"Minimum log level",children:[e.jsx("option",{value:"",children:"All levels"}),Qs.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:r,onChange:_=>l(_.target.value),"aria-label":"Filter logs"}),r&&e.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>l(""),"aria-label":"Clear filter",title:"Clear filter",children:e.jsx(sn,{size:12})})]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:$,onChange:_=>{p(_.target.value),A(0)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),ue(_.shiftKey?-1:1))},"aria-label":"Find in logs"}),$&&e.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:E.length?`${J+1}/${E.length}`:"0/0"})]}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(-1),disabled:!E.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:e.jsx(ys,{size:14})}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(1),disabled:!E.length,"aria-label":"Next match",title:"Next match (Enter)",children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>L(!C),"aria-pressed":C,"aria-label":"Match case",title:"Match case",children:e.jsx(za,{size:15})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${w?"active":""}`,onClick:()=>j(!w),"aria-pressed":w,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:e.jsx(Ri,{size:14})})]}),e.jsxs("div",{className:"log-actions-group",children:[(x||k)&&e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:f,children:[e.jsx(lt,{size:14})," RECONNECT"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${y?"active":""}`,onClick:()=>S(!y),children:[e.jsx(Bi,{size:14})," ",y?"FREEZE":"FOLLOW"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${q?"is-recording":""}`,onClick:ee,"aria-pressed":q,title:q?"Stop recording and download the capture":"Record the raw log stream to a file",children:[q?e.jsx(on,{size:12}):e.jsx(aa,{size:12})," ",q?`STOP · ${b.toLocaleString()}`:"RECORD"]}),e.jsxs("button",{className:"btn-premium btn-sm",disabled:B.length===0,onClick:fe,children:[e.jsx(xa,{size:14})," EXPORT"]}),e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:m,children:[e.jsx(as,{size:14})," CLEAR"]})]})]}),e.jsxs("div",{className:`logcat-rows theme-dark ${w?"":"no-wrap"}`,ref:W,children:[x&&e.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[e.jsx($e,{size:14}),e.jsxs("span",{children:["Access denied — ",x]})]}),!x&&k&&e.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[e.jsx($e,{size:14}),e.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),B.map((_,v)=>e.jsx(qo,{record:_,index:v,isHit:le.has(v),isActiveHit:E.length>0&&E[J]===v},_.seq)),e.jsx("div",{ref:O})]})]})}function Pn(t){const s=t==null?void 0:t.message;return typeof s=="string"?s.trim():""}function Be(t,s){const n=Pn(s);return n?`Couldn’t ${t}: ${n}`:`Couldn’t ${t}.`}function Xo(t,s){return t==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Be("read the clipboard",s)}function Go(t,s){const n=s.trim().toLowerCase();return[...t].sort((a,o)=>a.localeCompare(o)).filter(a=>!n||a.toLowerCase().includes(n))}const Yo=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Zo(t){return Yo.test(t.trim())}function vs(t){const s=(t||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Jo(t,s){const n=vs(s);return n?t.filter(a=>(a.platform||"").toLowerCase()===n):[]}function Qo(t){return[t.version,t.packageName].filter(Boolean).join(" · ")}function ec(t){return vs(t)==="android"?"Android":"iOS"}function tc(t){return vs(t)==="android"?".apk":".ipa,.app"}const Fn="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Un(t){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(t),!0):!1}catch{return!1}}function sc({udid:t,platform:s,deviceName:n}){const{toast:a,removeToast:o}=Ve(),r=mt(),[l,u]=c.useState([]),[d,i]=c.useState("loading"),[m,x]=c.useState(""),[k,f]=c.useState(""),[y,S]=c.useState(!1),[C,L]=c.useState(!1),[w,j]=c.useState([]),[$,p]=c.useState("loading"),[D,A]=c.useState(null),[O,W]=c.useState(null),V=c.useRef(null),q=c.useRef(null),Q=c.useRef(null),b=c.useCallback(async()=>{i("loading");try{const v=await M.listApps(t);u(Array.isArray(v)?v:[]),i("ready")}catch(v){x(Pn(v)),i("error")}},[t]);c.useEffect(()=>{b()},[b]);const oe=v=>setTimeout(b,v);c.useEffect(()=>{if(!O)return;const v=setTimeout(()=>W(null),1500);return()=>clearTimeout(v)},[O]);const te=async()=>{p("loading");try{const v=await M.getApps();j(Array.isArray(v)?v:[]),p("ready")}catch{p("error")}},ce=()=>{y||(L(!0),te())},B=()=>{var v;L(!1),(v=V.current)==null||v.focus()};c.useEffect(()=>{var H;if(!C||$==="loading")return;const v=(H=q.current)==null?void 0:H.querySelector('[role="menuitem"]:not(:disabled)');v==null||v.focus()},[C,$]);const E=async(v,H)=>{S(!0);const P=a(`Installing ${v} on ${n}…`,"loading",0);try{const K=await H();K!=null&&K.success?(a(`Installed ${v} on ${n}`,"success"),oe(5e3)):a(Be(`install ${v}`,{message:K==null?void 0:K.error}),"error")}catch(K){a(Be(`install ${v}`,K),"error")}finally{o(P),S(!1)}},J=v=>{B(),E(v.name,()=>M.installRepositoryApp(t,v.id))},le=v=>{var P;const H=(P=v.target.files)==null?void 0:P[0];v.target.value="",H&&E(H.name,()=>M.uploadAndInstallApp(t,H))},ue=async()=>{const v=D;if(A(null),!v)return;const H=a(`Uninstalling ${v} from ${n}…`,"loading",0);try{await M.uninstallApp(t,v),a(`Uninstalled ${v} from ${n}`,"success"),oe(3e3)}catch(P){a(Be(`uninstall ${v}`,P),"error")}finally{o(H)}},de=async(v,H)=>{var K,Ne;if(await Un(v)){W(v);return}const P=(K=H.closest("li"))==null?void 0:K.querySelector(".actions-app-id");P&&((Ne=window.getSelection())==null||Ne.selectAllChildren(P)),a(Fn,"info")},fe=Go(l,k),ee=k.trim(),ge=d==="ready"&&fe.length===0&&Zo(ee)&&!l.includes(ee),be=Jo(w,s),_=(v,H)=>e.jsxs("li",{className:"actions-app-row",children:[e.jsx("span",{className:"actions-app-id",children:v}),H&&e.jsx("span",{className:"actions-app-note",children:H}),e.jsxs("span",{className:"actions-app-tools",children:[e.jsx(Y,{variant:"ghost",size:"icon","aria-label":O===v?"Copied":`Copy ${v}`,title:O===v?"Copied":"Copy package ID",onClick:P=>de(v,P.currentTarget),children:O===v?e.jsx(dt,{size:13,"aria-hidden":"true"}):e.jsx(Te,{size:13,"aria-hidden":"true"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${v}`,onClick:()=>A(v),children:"Uninstall"})]})]},v);return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[e.jsxs("div",{className:"actions-section-head",children:[e.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[e.jsx(mi,{size:15,"aria-hidden":"true"})," Apps"]}),e.jsxs("div",{className:"actions-section-tools",children:[e.jsxs(Y,{ref:V,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":y||void 0,onClick:ce,children:[y?e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):e.jsx(ti,{size:13,"aria-hidden":"true"}),"Install from library"]}),e.jsxs(Y,{variant:"secondary",size:"sm","aria-disabled":y||void 0,onClick:()=>{var v;return!y&&((v=Q.current)==null?void 0:v.click())},children:[e.jsx(va,{size:13,"aria-hidden":"true"})," Upload file"]}),e.jsx("input",{ref:Q,type:"file",hidden:!0,"aria-label":"App file to upload",accept:tc(s),onChange:le})]})]}),e.jsx(cn,{open:C,onClose:B,anchorRef:V,placement:"bottom-end",children:e.jsx("div",{ref:q,className:"actions-library-menu",children:e.jsxs(ln,{children:[$==="loading"&&e.jsx(pe,{disabled:!0,onClick:()=>{},children:"Loading…"}),$==="error"&&e.jsx(pe,{onClick:te,children:"Couldn’t load the library. Retry"}),$==="ready"&&be.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs(pe,{disabled:!0,onClick:()=>{},children:["No ",ec(s)," apps in the library yet"]}),e.jsx(pe,{onClick:()=>r("/apps"),children:"Open the Apps library"})]}),$==="ready"&&be.map(v=>e.jsx(pe,{note:Qo(v)||void 0,onClick:()=>J(v),children:v.name},v.id))]})})}),e.jsxs("div",{className:"actions-apps-tools",children:[e.jsxs("div",{className:"actions-search",children:[e.jsx(hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${l.length} installed apps`,value:k,onChange:v=>f(v.target.value)})]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:b,children:e.jsx(St,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&e.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",m?`: ${m}`:".",e.jsx(Y,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),d==="ready"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&l.length>0&&fe.length===0&&!ge&&e.jsxs("p",{className:"actions-list-note",children:["No apps match “",ee,"”"]}),e.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[fe.map(v=>_(v)),ge&&_(ee,"Not in the list")]}),e.jsx(ps,{open:D!==null,title:"Uninstall app?",onClose:()=>A(null),footer:e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",onClick:()=>A(null),children:"Cancel"}),e.jsx(Y,{variant:"danger",onClick:ue,children:"Uninstall"})]}),children:e.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",e.jsx("code",{children:D})," from"," ",e.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const nc=[{direction:"up",Icon:ys},{direction:"down",Icon:fs},{direction:"left",Icon:ba},{direction:"right",Icon:ja}];function ac({onSwipe:t}){return e.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[e.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[e.jsx(Ga,{size:15,"aria-hidden":"true"})," Swipe"]}),e.jsx("div",{className:"actions-swipe-buttons",children:nc.map(({direction:s,Icon:n})=>e.jsx(Y,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>t(s),children:e.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function ic(t,s,n){const a=s/2,o=n/2,r=s*.4,l=n*.4,[u,d,i,m]={up:[a,o+l,a,o-l],down:[a,o-l,a,o+l],left:[a+r,o,a-r,o],right:[a-r,o,a+r,o]}[t].map(Math.round);return{startX:u,startY:d,endX:i,endY:m}}function rc({udid:t,platform:s}){const n=s!=="android",{toast:a}=Ve(),[o,r]=c.useState(""),[l,u]=c.useState(!1),[d,i]=c.useState(""),[m,x]=c.useState(null),[k,f]=c.useState(""),[y,S]=c.useState(!1),C=c.useRef(null);c.useEffect(()=>{if(!k)return;const p=setTimeout(()=>f(""),2e3);return()=>clearTimeout(p)},[k]),c.useEffect(()=>{if(!y)return;const p=setTimeout(()=>S(!1),1500);return()=>clearTimeout(p)},[y]);const L=async()=>{if(!(!o.trim()||l)){u(!0);try{await M.typeText(t,o),r(""),f("Sent")}catch(p){a(Be("send the text",p),"error")}finally{u(!1)}}},w=async()=>{x("read");try{const p=await M.getClipboard(t),D=typeof(p==null?void 0:p.content)=="string"?p.content:"";i(D),D||f("The device clipboard is empty")}catch(p){a(Xo(s,p),"error")}finally{x(null)}},j=async()=>{if(d){x("write");try{await M.setClipboard(t,d),f("Written to the device")}catch(p){a(Be("write the clipboard",p),"error")}finally{x(null)}}},$=async()=>{var p;if(await Un(d)){S(!0);return}(p=C.current)==null||p.select(),a(Fn,"info")};return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[e.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[e.jsx(Qa,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),e.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:o,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&L()}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:L,disabled:!o.trim()||l,children:[l&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),e.jsx("input",{id:"actions-clipboard",ref:C,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:d,onChange:p=>i(p.target.value)}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:w,disabled:m!==null,children:[m==="read"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&e.jsxs(Y,{variant:"secondary",size:"md",onClick:j,disabled:!d||m!==null,children:[m==="write"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":y?"Copied":"Copy clipboard text",title:y?"Copied":"Copy to your clipboard",onClick:$,disabled:!d,children:y?e.jsx(dt,{size:14,"aria-hidden":"true"}):e.jsx(Te,{size:14,"aria-hidden":"true"})})]}),!n&&e.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),e.jsx("p",{className:"actions-status",role:"status",children:k})]})}function oc({udid:t,platform:s,deviceName:n,screenWidth:a,screenHeight:o}){const{toast:r}=Ve(),l=async u=>{const d=ic(u,a,o);try{await M.swipe(t,d.startX,d.startY,d.endX,d.endY)}catch(i){r(Be(`swipe ${u}`,i),"error")}};return e.jsxs("div",{className:"actions-panel",children:[e.jsx(sc,{udid:t,platform:s,deviceName:n}),e.jsx(rc,{udid:t,platform:s}),e.jsx(ac,{onSwipe:l})]})}function cc({device:t,onClose:s,titleId:n}){const{toast:a}=Ve(),o=mt(),{tab:r}=an(),l=Mt(),u=c.useRef(null),[d,i]=c.useState({width:0,height:0}),[m,x]=c.useState("inspect"),[k,f]=c.useState(null),[y,S]=c.useState(r||"actions"),C=y==="omni"&&m==="inspect",[L,w]=c.useState(!0),[j,$]=c.useState([]),[p,D]=c.useState(null),[A,O]=c.useState(!1),[W,V]=c.useState(!1),[q,Q]=c.useState(0),[b,oe]=c.useState(t),[te,ce]=c.useState(0),B=c.useCallback(()=>ce(Date.now()),[]),E=Me(b);c.useEffect(()=>{Gn(b.udid,E),document.title=Yn(l.pathname)},[b.udid,E,l.pathname]);const[J,le]=c.useState(!1),[ue,de]=c.useState(!1),fe=10,[ee,ge]=c.useState(!1),[be,_]=c.useState(!1),v=$o(b==null?void 0:b.udid,!ue),H=()=>{navigator.clipboard.writeText(b.udid).catch(()=>{}),ge(!0),setTimeout(()=>ge(!1),1500)},P=c.useRef(""),K=c.useRef(null),[Ne,tt]=c.useState(!1);c.useEffect(()=>{y&&(!r||r!==y)&&o(`/devices/${t.udid}/control/${y}${l.search}`,{replace:!0})},[y,r,t.udid,o,l.search]);const[zt,st]=c.useState(0);To(()=>{M.leaveStream(b.udid).catch(()=>{})},()=>st(I=>I+1)),c.useEffect(()=>((async()=>{try{V(!0),await M.startStream(b.udid);const G=(await M.getDevices()).find(se=>se.udid===b.udid);G&&oe(G)}catch(F){console.error("Auto-start stream failed:",F)}finally{V(!1)}})(),()=>{M.leaveStream(b.udid).catch(()=>{})}),[t.udid,zt]);const He=parseInt(b.screenWidth||"1080",10),nt=parseInt(b.screenHeight||"1920",10),Z=Math.min(He,nt),ke=Math.max(He,nt),Ee=Z/ke,_e=c.useCallback(()=>{const I=!L,F=I?window.innerHeight*.55:window.innerHeight*.7,G=620,ye=window.innerWidth>900;let ie;I?ie=ye?Math.min(window.innerWidth*.8,window.innerWidth-G):window.innerWidth*.8:ie=window.innerWidth*.45;const xe=L?Ee:1/Ee;let ne,ae;L?(ne=F,ae=ne*xe,ae>ie&&(ae=ie,ne=ae/xe)):(ae=ie,ne=ae/xe,ne>F&&(ne=F,ae=ne*xe)),i({width:ae,height:ne})},[Ee,L]);c.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),c.useEffect(()=>{const I=async()=>{if(P.current.length>0){const G=P.current;P.current="";try{await M.typeText(b.udid,G)}catch(se){console.error("Keyboard buffering flush failed:",se)}finally{B()}}},F=G=>{const se=document.activeElement;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||!Ne&&y!=="terminal")return;const ie=G.key;ie==="Enter"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?66:"enter").finally(B)):ie==="Backspace"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?67:"backspace").finally(B)):ie.length===1&&(P.current+=ie,K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{I()},50))};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),K.current&&clearTimeout(K.current)}},[b.udid,b.platform,Ne,y,B]);const[We,Lt]=c.useState(Date.now()),pt=()=>{const I=q>0?`r=${q}&`:"";return b.session_id&&!String(b.session_id).startsWith("manual_")?`/xenon/api/session/${b.session_id}/live_video?${I}t=${We}`:`/xenon/api/control/${b.udid}/stream?${I}t=${We}`};c.useEffect(()=>{q>0&&Lt(Date.now())},[q]),c.useEffect(()=>{if(J||ue)return;const I=setTimeout(()=>de(!0),3e4);return()=>clearTimeout(I)},[J,ue,q]);const we=c.useRef(null),qe=I=>{const F=I.currentTarget.getBoundingClientRect();return{x:I.clientX-F.left,y:I.clientY-F.top}},Ot=I=>{const F=qe(I);we.current={x:F.x,y:F.y,time:Date.now()}},ft=async I=>{var Ye;if(!we.current)return;const F=we.current,G=qe(I),se=Date.now()-F.time,ye=(Ye=u.current)==null?void 0:Ye.getBoundingClientRect(),ie=(ye==null?void 0:ye.width)||d.width,xe=(ye==null?void 0:ye.height)||d.height;let ne,ae,Xe,Ge;L?(ne=F.x/ie*Z,ae=F.y/xe*ke,Xe=G.x/ie*Z,Ge=G.y/xe*ke):(ne=F.x/ie*ke,ae=F.y/xe*Z,Xe=G.x/ie*ke,Ge=G.y/xe*Z);const ze=Math.abs(Xe-ne),rt=Math.abs(Ge-ae);try{se<500&&ze<10&&rt<10?await M.tap(b.udid,Math.round(ne),Math.round(ae)):se>=500&&ze<10&&rt<10?await M.touchAndHold(b.udid,Math.round(ne),Math.round(ae),se):await M.swipe(b.udid,Math.round(ne),Math.round(ae),Math.round(Xe),Math.round(Ge))}catch(Vt){console.error("Action failed:",Vt)}finally{B()}we.current=null},yt=()=>M.pressKey(b.udid,b.platform==="android"?ot.HOME:Yt.HOME).finally(B),Pt=()=>M.pressKey(b.udid,ot.BACK).finally(B),at=()=>M.pressKey(b.udid,ot.APP_SWITCH).finally(B),xt=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_UP:Yt.VOLUME_UP).finally(B),Ke=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_DOWN:Yt.VOLUME_DOWN).finally(B),vt=()=>M.lock(b.udid).finally(B),it=async()=>{_(!0);try{await M.unlock(b.udid)}finally{B(),setTimeout(()=>_(!1),2500)}},Ft=async()=>{O(!0);try{const I=await M.getScreenshot(b.udid);if(I!=null&&I.screenshot){const F={id:Pr(),base64:I.screenshot,timestamp:Date.now()};$(G=>[F,...G]),D(0)}}catch(I){console.error("Failed to take screenshot:",I)}finally{O(!1)}},De=I=>{$(F=>{const G=F.filter(se=>se.id!==I);return G.length===0?D(null):p!==null&&p>=G.length&&D(0),G})},Ut=()=>{$([]),D(null),a("Cleared all captured evidence.","success")},Bt=I=>{const F=document.createElement("a");F.href=`data:image/png;base64,${I}`,F.download=`screenshot-${b.udid}-${Date.now()}.png`,F.click()};return e.jsxs("div",{className:"device-control-view",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"control-view-top-bar",children:[e.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[e.jsx(zs,{size:18})," DEVICES"]}),e.jsxs("div",{className:"device-info-mini",children:[e.jsx("span",{className:`device-pill platform-pill ${b.platform}`,children:b.platform==="ios"?"Apple":"Android"}),e.jsxs("span",{className:"device-pill version-pill",children:["v",b.sdk]}),b.reservedUntil&&Date.now()<b.reservedUntil&&e.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${b.reservedBy}${b.reservationReason?`: ${b.reservationReason}`:""}`,children:["Reserved by ",b.reservedBy||"someone"]}),e.jsx("h2",{id:n,className:"device-name-text",children:E}),e.jsxs("span",{className:"udid-chip",title:b.udid,children:[e.jsx("span",{className:"udid-chip__value",children:b.udid}),e.jsx("button",{type:"button",className:"udid-chip__copy",onClick:H,"aria-label":"Copy UDID",title:ee?"Copied!":"Copy UDID",children:ee?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]})]})]}),e.jsxs("div",{className:`control-view-main ${L?"":"is-landscape"} ${y==="omni"?"omni-mode":""}`,children:[e.jsxs("div",{className:"device-preview-column",children:[e.jsx("div",{className:"device-screen-wrapper",children:e.jsxs("div",{ref:I=>{u.current=I,f(I)},className:`device-stream-canvas ${L?"":"landscape"} ${Ne?"focused":""} ${C?"is-inspecting":""}`,style:{width:d.width,height:d.height,background:"var(--black)"},tabIndex:0,onFocus:()=>tt(!0),onBlur:()=>tt(!1),onMouseDown:C?void 0:Ot,onMouseUp:C?void 0:ft,children:[ue?e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx($e,{size:40,color:"var(--red, #f87171)"}),e.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),e.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{de(!1),Q(0)},children:"Retry"})]}):(W||!J)&&e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx(lt,{size:40,className:"animate-spin",color:"var(--color-accent)"}),e.jsx("p",{style:{marginTop:16},children:W?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!ue&&e.jsx(rn,{src:pt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>le(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),le(!1),q>=fe){de(!0);return}setTimeout(()=>Q(I=>I+1),2e3)}}),v==="off"&&!ue&&e.jsxs("div",{className:"device-screen-off",role:"status",children:[e.jsx(li,{size:32}),e.jsx("p",{children:"Display is off"}),e.jsx("span",{children:"The stream is fine — the device is asleep."}),e.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:it,disabled:be,children:be?"Waking…":"Wake device"})]})]})}),e.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":L?"vertical":"horizontal",children:[e.jsx("button",{className:`footer-action-btn ${L?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":L,children:e.jsx(gi,{size:18})}),e.jsx("button",{className:`footer-action-btn ${L?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!L,children:e.jsx(xi,{size:18})}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:e.jsx(ia,{size:18})}),b.platform==="android"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"footer-action-btn",onClick:Pt,title:"Back","aria-label":"Back",children:e.jsx(zs,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:at,title:"App switcher","aria-label":"App switcher",children:e.jsx(on,{size:18})})]}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume up","aria-label":"Volume up",children:e.jsx(Fi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume down","aria-label":"Volume down",children:e.jsx(Oi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:vt,title:"Lock device","aria-label":"Lock device",children:e.jsx(Na,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:it,title:"Unlock device","aria-label":"Unlock device",children:e.jsx(ni,{size:18})})]})]}),e.jsxs("div",{className:"device-interactions-column",children:[e.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[e.jsxs("button",{className:`tab-btn ${y==="actions"?"active":""}`,onClick:()=>S("actions"),role:"tab","aria-selected":y==="actions",children:[e.jsx(hn,{size:13}),e.jsx("span",{children:"Actions"})]}),e.jsxs("button",{className:`tab-btn ${y==="screenshot"?"active":""}`,onClick:()=>S("screenshot"),role:"tab","aria-selected":y==="screenshot",children:[e.jsx(Gt,{size:13}),e.jsx("span",{children:"Screenshot"})]}),e.jsxs("button",{className:`tab-btn ${y==="logs"?"active":""}`,onClick:()=>S("logs"),role:"tab","aria-selected":y==="logs",children:[e.jsx(fn,{size:13}),e.jsx("span",{children:"Logs"})]}),e.jsxs("button",{className:`tab-btn ${y==="terminal"?"active":""}`,onClick:()=>S("terminal"),role:"tab","aria-selected":y==="terminal",children:[e.jsx(ga,{size:13}),e.jsx("span",{children:"Shell"})]}),e.jsxs("button",{className:`tab-btn ${y==="omni"?"active":""}`,onClick:()=>S("omni"),role:"tab","aria-selected":y==="omni",children:[e.jsx(ea,{size:13}),e.jsx("span",{children:"Omni-Vision"})]})]}),e.jsx("div",{className:`interactions-scroll-area ${y==="terminal"?"terminal-mode":""} ${y==="screenshot"||y==="logs"?"screenshot-mode":""}`,children:e.jsxs("div",{className:"tab-content",children:[y==="omni"&&e.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:e.jsx(Co,{sessionId:b.session_id?String(b.session_id):null,udid:b.udid,streamUrl:pt(),embedded:!0,overlayTarget:k,onModeChange:x,deviceActionAt:te})}),y==="actions"&&e.jsx(oc,{udid:b.udid,platform:b.platform,deviceName:E,screenWidth:Z,screenHeight:ke}),y==="screenshot"&&e.jsxs("div",{className:"action-card screenshot-card",children:[j.length>0&&e.jsx("header",{className:"action-card-header",children:e.jsx("button",{className:"btn-text-only",onClick:Ut,children:"CLEAR ALL"})}),e.jsxs("div",{className:`screenshot-workspace ${j.length===0?"is-empty":""}`,children:[e.jsxs("div",{className:"screenshot-gallery-sidebar",children:[e.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Ft,disabled:A,children:[A?e.jsx(ct,{className:"animate-spin",size:16}):e.jsx(Gt,{size:16}),e.jsx("span",{children:A?"CAPTURING...":"NEW CAPTURE"})]}),e.jsxs("div",{className:"screenshot-thumbnails-list",children:[j.length===0&&!A&&e.jsxs("div",{className:"empty-gallery-state",children:[e.jsx(Gt,{size:20,className:"empty-gallery-icon"}),e.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),e.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),j.map((I,F)=>e.jsxs("div",{className:`screenshot-thumb-item ${p===F?"active":""}`,onClick:()=>D(F),children:[e.jsx("img",{src:`data:image/png;base64,${I.base64}`,alt:"Thumb"}),e.jsx("span",{className:"thumb-time",children:new Date(I.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("button",{className:"thumb-delete-btn",onClick:G=>{G.stopPropagation(),De(I.id)},children:e.jsx(as,{size:12})})]},I.id))]})]}),e.jsx("div",{className:"screenshot-main-preview",children:p!==null&&j[p]?e.jsxs("div",{className:"preview-container",children:[e.jsx("div",{className:"preview-image-wrapper",children:e.jsx("img",{src:`data:image/png;base64,${j[p].base64}`,alt:"Selected Evidence"})}),e.jsxs("footer",{className:"preview-footer",children:[e.jsxs("div",{className:"preview-meta",children:[e.jsx("span",{className:"meta-label",children:"ID:"}),e.jsx("span",{className:"meta-value",children:j[p].id.substring(0,8)}),e.jsx("span",{className:"meta-divider",children:"|"}),e.jsx("span",{className:"meta-value",children:pa(j[p].timestamp)})]}),e.jsxs("div",{className:"preview-actions",children:[e.jsx("button",{className:"btn-premium btn-sm",onClick:()=>Bt(j[p].base64),children:"DOWNLOAD PNG"}),e.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>De(j[p].id),children:[e.jsx(as,{size:14})," DELETE"]})]})]})]}):null})]})]}),y==="logs"&&e.jsx("div",{className:"action-card screenshot-card",children:e.jsx(Ko,{udid:b.udid,platform:b.platform})}),y==="terminal"&&e.jsx("div",{className:"action-card full-height",children:e.jsx(Fr,{platform:(b.platform||"").toLowerCase(),prompt:`${(b.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${E} (${b.udid}).
|
|
268
|
-
Internal Shell Environment.`,onCommand:async I=>{const F=await M.executeShell(b.udid,I);if(F.error)throw new Error(F.error);return F.output}})})]})})]})]}),b.session_id&&!String(b.session_id).startsWith("manual_")&&e.jsx(ta,{sessionId:String(b.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const lc=/^(INPUT|TEXTAREA|SELECT)$/;function dc({labelledBy:t,onClose:s,children:n,style:a,...o}){const r=c.useRef(null),l=c.useRef(s);return l.current=s,c.useEffect(()=>{const u=r.current;if(!u)return;const d=document.activeElement,i=[];for(let x=u;x.parentElement&&x!==document.body;x=x.parentElement)for(const k of Array.from(x.parentElement.children))k===x||k.hasAttribute("inert")||k.matches("[aria-live], script, style, link, template")||(k.setAttribute("inert",""),i.push(k));u.contains(document.activeElement)||u.focus();const m=x=>{if(x.key!=="Escape"||x.defaultPrevented)return;const k=x.target;lc.test(k.tagName)||k.isContentEditable||(x.preventDefault(),l.current())};return u.addEventListener("keydown",m),()=>{u.removeEventListener("keydown",m),i.forEach(x=>x.removeAttribute("inert")),d&&d.isConnected&&d!==document.body&&d.focus()}},[]),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,style:{outline:"none",...a},...o,children:n})}const Bn="xenon.devices.view";function Vn(){try{return window.localStorage}catch{return null}}function uc(t,s){const n=t.get("view");return n==="table"||n==="cards"?n:s}function hc(t,s,n){s==="table"||s!==n?t.set("view",s):t.delete("view")}function tn(t=Vn()){try{return(t==null?void 0:t.getItem(Bn))==="table"?"table":"cards"}catch{return"cards"}}function mc(t,s=Vn()){try{s==null||s.setItem(Bn,t)}catch{}}class pc extends Fe.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=Fe.createRef(),this.containerRef=Fe.createRef(),this.stickyGroupRef=Fe.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var r,l;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(r=a==null?void 0:a.closest)!=null&&r.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(l=this.searchRef.current)==null||l.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(xr),(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 s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;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),(s=this.stickyObserver)==null||s.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await M.getDevices(),n=this.getBusyDevicesCount(s),a=await M.getPendingSessionsCount(),o=await M.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:o,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>Tt(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(i=>i.udid===n):null,{filters:o}=this.props,r=jr(this.state.devices,o,Date.now()),l=[{value:"all",label:"Any platform",count:r.platform.all},{value:"android",label:"Android",count:r.platform.android},{value:"ios",label:"iOS",count:r.platform.ios}];(Nr(this.state.devices)||o.platform==="tvos")&&l.push({value:"tvos",label:"tvOS",count:r.platform.tvos});const u=[{value:"all",label:"Any type",count:r.type.all},{value:"real",label:"Real devices",count:r.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:r.type.virtual}],d=`/devices${this.props.locationSearch}`;return e.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[e.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[e.jsx(Qn,{icon:ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),e.jsxs("div",{className:"de2-toolbar",children:[e.jsx(Ls,{size:"sm",label:"Status",value:o.status,onChange:i=>this.setFilters({status:i}),segments:[{value:"all",label:"All",count:r.status.all},{value:"ready",label:"Ready",tone:"ready",count:r.status.ready},{value:"busy",label:"Busy",tone:"busy",count:r.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:r.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:r.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:r.status.offline}]}),e.jsxs("div",{className:"de2-toolbar-row",children:[e.jsxs("div",{className:"de2-search-wrap",children:[e.jsx(hs,{size:13,className:"de2-search-icon","aria-hidden":"true"}),e.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:o.q,onChange:i=>this.setFilters({q:i.target.value})}),e.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),e.jsx(Ps,{name:"Platform",value:o.platform,anyValue:"all",options:l,onChange:i=>this.setFilters({platform:i})}),e.jsx(Ps,{name:"Type",value:o.type,anyValue:"all",options:u,onChange:i=>this.setFilters({type:i})}),kr(o)&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),e.jsxs("div",{className:"de2-result",children:[e.jsx(Ls,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&e.jsx("span",{"aria-live":"polite",children:wr(s.length,this.state.devices.length)}),e.jsx(Y,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:e.jsx(St,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?e.jsx(Ir,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):e.jsx(yr,{devices:s,reloadDevices:()=>this.fetchDevices()}):e.jsxs("div",{className:"device-explorer-empty stagger-1",children:[e.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?e.jsx(ns,{size:32}):e.jsx(St,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Global Device Registry Empty"}),e.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."}),e.jsxs(Y,{variant:"primary",onClick:()=>this.fetchDevices(),children:[e.jsx(St,{size:14}),"Manual sync"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"No devices match these filters"}),e.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),e.jsx(Y,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Loading devices…"}),e.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&e.jsx(dc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:e.jsx("div",{className:"device-control-modal",children:e.jsx(cc,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Gc(){const t=an(),s=mt(),n=Mt(),[a,o]=Zn(),{on:r}=Jn(),l=vr(a),u=uc(a,tn()),d=Rr(a),i=(m,x,k)=>{const f=gr(m);hc(f,x,tn()),Ar(f,k),o(f,{replace:!0})};return e.jsx(pc,{params:t,navigate:s,onSocketEvent:r,filters:l,onFiltersChange:m=>i(m,u,d),view:u,onViewChange:m=>{mc(m),i(l,m,d)},sort:d,onSortChange:m=>i(l,u,m),locationSearch:n.search})}export{pc as DeviceExplorer,Gc as default};
|