@xenon-device-management/xenon 2.13.0 → 2.13.2
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/LICENSE +15 -0
- package/README.md +223 -488
- package/lib/package.json +1 -1
- package/lib/public/assets/{AnnotationOverlay-CzbFYtPI.js → AnnotationOverlay-BXruClDk.js} +1 -1
- package/lib/public/assets/{ApiKeyGate-CA5KFHHJ.js → ApiKeyGate-qTS4LPLC.js} +1 -1
- package/lib/public/assets/{BugReportButton-D-DSGg8C.js → BugReportButton-BoGhlI7F.js} +1 -1
- package/lib/public/assets/{DeviceMosaicView-paDEFU4B.js → DeviceMosaicView-8J0oYqMM.js} +1 -1
- package/lib/public/assets/{EmptyState-BE_5f8Vw.js → EmptyState-Cr17PdDv.js} +1 -1
- package/lib/public/assets/{FieldGroup-DqMf7Rf3.js → FieldGroup-Bvn08svv.js} +1 -1
- package/lib/public/assets/{FilterMenu-BQY75Su3.js → FilterMenu-DDSO8aDf.js} +1 -1
- package/lib/public/assets/{Menu-BiW3os9u.js → Menu-B-Qn2X3T.js} +1 -1
- package/lib/public/assets/{Modal-DfawTxih.js → Modal-Cg9V5JYU.js} +1 -1
- package/lib/public/assets/{RecordingPage-BvemyRiy.js → RecordingPage-BTUs9VTW.js} +1 -1
- package/lib/public/assets/{RecordingsPage-CXfw7wpd.js → RecordingsPage-DYcfxITK.js} +2 -2
- package/lib/public/assets/{SegmentedControl-B7m9kpom.js → SegmentedControl-Zy7suhT5.js} +1 -1
- package/lib/public/assets/{SettingCard-Cw6lDD0l.js → SettingCard-CWYmycoe.js} +1 -1
- package/lib/public/assets/{Table-DlEuFgv-.js → Table-io9fwa98.js} +1 -1
- package/lib/public/assets/{activity-CnLvNwae.js → activity-Bdf_uIWl.js} +1 -1
- package/lib/public/assets/ai-settings-Bce5SJob.js +21 -0
- package/lib/public/assets/{api-keys-DphSVzBr.js → api-keys-CPqtVpm3.js} +1 -1
- package/lib/public/assets/{apps-vUfu15lX.js → apps-BgZan0H9.js} +2 -2
- package/lib/public/assets/{arrow-left-CLQWAiCY.js → arrow-left-B27ckB31.js} +1 -1
- package/lib/public/assets/{arrow-right-K6A5e_Ee.js → arrow-right-DOF8ITCz.js} +1 -1
- package/lib/public/assets/{arrow-up-right-DUA_lq6f.js → arrow-up-right-eFG5KTFS.js} +1 -1
- package/lib/public/assets/{auth-shell-BYRHcZd6.js → auth-shell-DlC3_27j.js} +2 -2
- package/lib/public/assets/{builds-page-C0fTvIG8.js → builds-page-BuXpPfKo.js} +1 -1
- package/lib/public/assets/{button-BxnHCCsX.js → button-fIW8owMI.js} +1 -1
- package/lib/public/assets/{calendar-CqVsn28A.js → calendar-WNjmrF-a.js} +1 -1
- package/lib/public/assets/{check-R6V3bot0.js → check-BdTh1Sq7.js} +1 -1
- package/lib/public/assets/{chevron-right-BA2Fntu-.js → chevron-right-B4BKlsqk.js} +1 -1
- package/lib/public/assets/{circle-check-D4EzyGzs.js → circle-check-zJU80_EF.js} +1 -1
- package/lib/public/assets/{circle-x-Cf6AF2B2.js → circle-x-5Uwquo0h.js} +1 -1
- package/lib/public/assets/{clock-EZfet0sS.js → clock-BtUprDsZ.js} +1 -1
- package/lib/public/assets/{copy-Bc6P8v9V.js → copy-DGSbZI3u.js} +1 -1
- package/lib/public/assets/device-explorer-C-KnhMHI.js +279 -0
- package/lib/public/assets/{download-Bd8OGLzi.js → download-WG6l7BgD.js} +1 -1
- package/lib/public/assets/{forgot-password-CoE7Ugtx.js → forgot-password-DnudqFFo.js} +1 -1
- package/lib/public/assets/{index-BTYMAqNW.css → index-Bxoxt9sV.css} +1 -1
- package/lib/public/assets/{index-CHOr4JCs.js → index-DI1fGIyj.js} +43 -43
- package/lib/public/assets/{index-BiL0Enl_.js → index-HDQVe1gi.js} +1 -1
- package/lib/public/assets/{input-CJ8z3IO5.js → input-BjDRKCea.js} +1 -1
- package/lib/public/assets/{line-chart-CPK0ObjV.js → line-chart-C0zdgd0v.js} +1 -1
- package/lib/public/assets/{list-checks-mXGHUVbB.js → list-checks-BdW5CjM8.js} +1 -1
- package/lib/public/assets/{lock-BSXM1xvq.js → lock-Dy3L4I8E.js} +1 -1
- package/lib/public/assets/{login-Ct2iW066.js → login-BHbY9CLG.js} +1 -1
- package/lib/public/assets/maintenance-settings-zDVlOMVK.js +6 -0
- package/lib/public/assets/{monitor-D8WQK8md.js → monitor-8xjkeHHi.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-Cw2tWzDX.js → mouse-pointer-2-CXdKMXQ8.js} +1 -1
- package/lib/public/assets/{network-Ba_uFxWo.js → network-Cj8JOKON.js} +1 -1
- package/lib/public/assets/{overview-CxrZ7_6k.js → overview-CTg7F0im.js} +1 -1
- package/lib/public/assets/{page-header-Cm1XL49f.js → page-header--aTyJXq6.js} +1 -1
- package/lib/public/assets/{play-C0CuKLXj.js → play-B-FodgHV.js} +1 -1
- package/lib/public/assets/{plus-CIIvR_6Z.js → plus-CsIk10Cq.js} +1 -1
- package/lib/public/assets/{profile-page-BZ_e-Bgw.js → profile-page-DkFKkMfl.js} +1 -1
- package/lib/public/assets/{recording-group-store-BWeeNs2_.js → recording-group-store-WVM3hoXn.js} +1 -1
- package/lib/public/assets/{reset-password-lfNz8Rm1.js → reset-password-I2-zqLlI.js} +1 -1
- package/lib/public/assets/{runbook-page-Cnec3VSx.js → runbook-page-DJTVCJX7.js} +1 -1
- package/lib/public/assets/{select-CZuCnold.js → select-DvCSv25z.js} +1 -1
- package/lib/public/assets/{selector-detail-redirect-BG3pxFLw.js → selector-detail-redirect-BLVfMJs_.js} +1 -1
- package/lib/public/assets/{selector-health-page-DsyL58tb.js → selector-health-page-oqadRokn.js} +2 -2
- package/lib/public/assets/session-detail-page-CGn55Pvl.js +4 -0
- package/lib/public/assets/settings-MsVU2ukE.js +6 -0
- package/lib/public/assets/{stat-tile-DFhv8JoI.js → stat-tile-DV9Ix-4O.js} +1 -1
- package/lib/public/assets/{tablet-68J5f6zh.js → tablet-6b_SEN2X.js} +1 -1
- package/lib/public/assets/{teams-eHSyEpbD.js → teams-BjZyfuHh.js} +1 -1
- package/lib/public/assets/{trash-2-CcSsv4fS.js → trash-2-CTZpPSdd.js} +1 -1
- package/lib/public/assets/{upload-BYf26K71.js → upload-P3XzwQUb.js} +1 -1
- package/lib/public/assets/{use-builds-data-CHW-MhaP.js → use-builds-data-1cOCMf-z.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-DozShXkk.js → use-password-reset-mode-DgF9w088.js} +1 -1
- package/lib/public/assets/{users-CcSQRoK9.js → users-CiNTKUiz.js} +1 -1
- package/lib/public/assets/{users-BpYnpOl2.js → users-DMF9Mk5H.js} +1 -1
- package/lib/public/assets/{video-off-dFKgps73.js → video-off-CHp1KU_T.js} +1 -1
- package/lib/public/assets/webhook-settings-DiS8geIm.js +1 -0
- package/lib/public/assets/{zap-COC2tZaH.js → zap-DRz0tDq5.js} +1 -1
- package/lib/public/index.html +2 -2
- package/lib/schema.json +0 -25
- package/lib/src/app/routers/control.js +19 -4
- package/lib/src/app/routers/streamStartConflict.js +3 -0
- package/lib/src/data-service/device-service.js +40 -0
- package/lib/src/data-service/device-store.js +4 -1
- package/lib/src/data-service/prisma-store.js +2 -1
- package/lib/src/device-managers/ios/WDAClient.js +128 -16
- package/lib/src/device-utils.js +63 -13
- package/lib/src/middleware/deviceAccessGuard.js +63 -9
- package/lib/src/services/ServerManager.js +3 -0
- package/lib/src/services/SessionLifecycleService.js +16 -4
- package/lib/src/services/device-access/SessionOwnerResolver.js +26 -0
- package/lib/src/services/device-access/deviceAccessPolicy.js +38 -6
- package/lib/src/services/device-access/leaseHold.js +26 -0
- package/lib/src/services/device-access/ticketActorAccess.js +6 -0
- package/lib/src/services/lease/activeLeases.js +37 -0
- package/lib/src/services/recording/busy-precheck.js +24 -3
- package/lib/test/unit/device-access-lease.spec.js +270 -0
- package/lib/test/unit/lease/allocate-lease-branch.spec.js +22 -0
- package/lib/test/unit/lease/session-lease-proof.spec.js +59 -0
- package/lib/test/unit/lease-held-phone.spec.js +196 -0
- package/lib/test/unit/partial-config-file.spec.js +100 -0
- package/lib/test/unit/schema-required-args.spec.js +21 -16
- package/lib/test/unit/wda-client-session.spec.js +128 -0
- package/lib/test/unit/wda-clipboard-write.spec.js +135 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema.json +0 -25
- package/scripts/dev/readme-screenshots.js +231 -0
- package/scripts/generate-types-from-schema.js +6 -0
- package/scripts/lib/always-present-plugin-args.js +39 -0
- package/lib/public/assets/ai-settings-D7Te8o-a.js +0 -21
- package/lib/public/assets/device-explorer-BFXpRq6d.js +0 -279
- package/lib/public/assets/maintenance-settings-DaOs00P6.js +0 -6
- package/lib/public/assets/session-detail-page-ZZyGM413.js +0 -4
- package/lib/public/assets/settings-DGZ7B_AR.js +0 -6
- package/lib/public/assets/webhook-settings-DD1XjiOD.js +0 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import{c as Z,j as s,r as u,C as vn,U as jr,X as Y,t as Ie,v as Fs,b as wr,u as $t,a as ns,T as kr,q as Ns,R as at,w as Sr,x as Es,y as Be,z as Ps,I as ni,S as Pt,f as ct,A as Vt,B as Cr,i as ii,D as Nr,E as Er,F as Tr,G as Ar,p as Rr}from"./index-DI1fGIyj.js";import{P as Mr}from"./page-header--aTyJXq6.js";import{P as Ht,S as zr,B as $r}from"./BugReportButton-BoGhlI7F.js";import{A as Ir}from"./activity-Bdf_uIWl.js";import{h as _r,M as ri,S as ai,C as Dr,a as Nt,i as Lr,b as yn,H as Or,A as wt,I as fs}from"./recording-group-store-WVM3hoXn.js";import{p as is}from"./labels-C21SA4JG.js";import{B as U}from"./button-fIW8owMI.js";import{S as oi}from"./select-DvCSv25z.js";import{P as Yt,M as Us,a as je,b as li}from"./Menu-B-Qn2X3T.js";import{M as rs}from"./Modal-Cg9V5JYU.js";import{F as Kt}from"./FieldGroup-Bvn08svv.js";import{C as Fr}from"./clock-BtUprDsZ.js";import{P as Pr}from"./plus-CsIk10Cq.js";import{C as $e}from"./copy-DGSbZI3u.js";import{T as Ur}from"./tablet-6b_SEN2X.js";import{S as Br,a as xn}from"./SegmentedControl-Zy7suhT5.js";import{T as Wr,a as Vr,b as ci,c as Gt,d as Hr,e as it}from"./Table-io9fwa98.js";import{L as di,a as Kr}from"./list-checks-BdW5CjM8.js";import{C as qr}from"./chevron-right-B4BKlsqk.js";import{M as bn}from"./mouse-pointer-2-CXdKMXQ8.js";import{Z as ui}from"./zap-DRz0tDq5.js";import{C as At}from"./check-BdTh1Sq7.js";import{C as hi}from"./circle-check-zJU80_EF.js";import{C as mi}from"./circle-x-5Uwquo0h.js";import{E as Xr}from"./EmptyState-Cr17PdDv.js";import{I as jn}from"./input-BjDRKCea.js";import{P as Yr,a as Gr}from"./play-B-FodgHV.js";import{D as fi}from"./download-WG6l7BgD.js";import{U as Jr,T as Zr}from"./upload-P3XzwQUb.js";import{A as Qr}from"./arrow-left-B27ckB31.js";import{A as ea}from"./arrow-right-DOF8ITCz.js";import{p as ta,A as sa}from"./AnnotationOverlay-BXruClDk.js";import{T as na}from"./trash-2-CTZpPSdd.js";import{L as ia}from"./lock-Dy3L4I8E.js";import{F as wn}from"./FilterMenu-DDSO8aDf.js";import"./utils-CDN07tui.js";import"./index-HDQVe1gi.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 ra=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Bs=Z("arrow-down",ra);/**
|
|
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 aa=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ws=Z("arrow-up",aa);/**
|
|
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 oa=[["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"}]],la=Z("battery-low",oa);/**
|
|
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 ca=[["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"}]],da=Z("battery-warning",ca);/**
|
|
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 ua=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],ha=Z("battery",ua);/**
|
|
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 ma=[["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"}]],fa=Z("box",ma);/**
|
|
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 pa=[["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"}]],ga=Z("calendar-plus",pa);/**
|
|
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 va=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],ya=Z("chevrons-down-up",va);/**
|
|
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 xa=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],ba=Z("chevrons-up-down",xa);/**
|
|
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 ja=[["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"}]],pi=Z("circle-question-mark",ja);/**
|
|
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 wa=[["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"}]],kn=Z("code-xml",wa);/**
|
|
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 ka=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Sa=Z("columns-2",ka);/**
|
|
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 Ca=[["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"}]],Na=Z("crosshair",Ca);/**
|
|
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 Ea=[["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"}]],gi=Z("ellipsis",Ea);/**
|
|
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 Ta=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],Aa=Z("folder-down",Ta);/**
|
|
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 Ra=[["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"}]],Ma=Z("hand",Ra);/**
|
|
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 za=[["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"}]],$a=Z("image",za);/**
|
|
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 Ia=[["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"}]],_a=Z("keyboard",Ia);/**
|
|
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 Da=[["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"}]],La=Z("library",Da);/**
|
|
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 Oa=[["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"}]],Fa=Z("lock-open",Oa);/**
|
|
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 Pa=[["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"}]],Ua=Z("map-pin",Pa);/**
|
|
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 Ba=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Wa=Z("maximize-2",Ba);/**
|
|
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 Va=[["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"}]],Ha=Z("message-square",Va);/**
|
|
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 Ka=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],qa=Z("minimize-2",Ka);/**
|
|
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 Xa=[["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"}]],Ya=Z("moon-star",Xa);/**
|
|
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 Ga=[["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"}]],Ja=Z("mouse-pointer-click",Ga);/**
|
|
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 Za=[["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"}]],Qa=Z("package",Za);/**
|
|
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 eo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],to=Z("panel-top",eo);/**
|
|
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 so=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],vi=Z("pen-line",so);/**
|
|
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 no=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],io=Z("rectangle-horizontal",no);/**
|
|
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 ro=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],ao=Z("rectangle-vertical",ro);/**
|
|
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 oo=[["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"}]],Et=Z("rotate-cw",oo);/**
|
|
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 lo=[["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"}]],yi=Z("scroll-text",lo);/**
|
|
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 co=[["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"}]],ft=Z("shield-alert",co);/**
|
|
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 uo=[["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"}]],ho=Z("tag",uo);/**
|
|
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 mo=[["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"}]],ps=Z("target",mo);/**
|
|
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 fo=[["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"}]],po=Z("text-cursor-input",fo);/**
|
|
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 go=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],vo=Z("thermometer",go);/**
|
|
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 yo=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],xo=Z("toggle-left",yo);/**
|
|
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 bo=[["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"}]],Sn=Z("touchpad",bo);/**
|
|
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 jo=[["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"}]],wo=Z("type",jo);/**
|
|
207
|
+
* @license lucide-react v0.555.0 - ISC
|
|
208
|
+
*
|
|
209
|
+
* This source code is licensed under the ISC license.
|
|
210
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
+
*/const ko=[["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"}]],So=Z("volume-1",ko);/**
|
|
212
|
+
* @license lucide-react v0.555.0 - ISC
|
|
213
|
+
*
|
|
214
|
+
* This source code is licensed under the ISC license.
|
|
215
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
+
*/const Co=[["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"}]],No=Z("volume-2",Co);function Eo(e){return e>=50?"ready":e>=20?"warning":"error"}function To(e){return e>=50?s.jsx(ha,{size:10}):e>=20?s.jsx(la,{size:10}):s.jsx(da,{size:10})}function Ao(e){return e==="Normal"?"ready":e==="Critical"?"error":"warning"}const Ro=({device:e})=>{if(e.deviceType==="emulator"||e.deviceType==="simulator"||e.offline)return null;const n=typeof e.batteryLevel=="number",i=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!n&&!i?s.jsx("div",{className:"dc2-health",children:s.jsxs(Ht,{tone:"neutral",title:"Device does not report battery or thermal data",children:[s.jsx(Ir,{size:10}),"No telemetry"]})}):s.jsxs("div",{className:"dc2-health",children:[n&&s.jsxs(Ht,{tone:Eo(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[To(e.batteryLevel),e.batteryLevel,"%"]}),i&&s.jsxs(Ht,{tone:Ao(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[s.jsx(vo,{size:10}),e.thermalStatus]})]})};function Mo(e){if(typeof e!="number")throw new TypeError("Expected a number");const t=e>0?Math.floor:Math.ceil;return{days:t(e/864e5),hours:t(e/36e5)%24,minutes:t(e/6e4)%60,seconds:t(e/1e3)%60,milliseconds:t(e)%1e3,microseconds:t(e*1e3)%1e3,nanoseconds:t(e*1e6)%1e3}}const zo=(e,t)=>t===1?e:`${e}s`,$o=1e-7;function xi(e,t={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);const n=[],i=(o,d)=>{const c=Math.floor(o*10**d+$o);return(Math.round(c)/10**d).toFixed(d)},r=(o,d,c,l)=>{if((n.length===0||!t.colonNotation)&&o===0&&!(t.colonNotation&&c==="m"))return;l=(l||o||"0").toString();let h,m;if(t.colonNotation){h=n.length>0?":":"",m="";const g=l.includes(".")?l.split(".")[0].length:l.length,f=n.length>0?2:1;l="0".repeat(Math.max(0,f-g))+l}else h="",m=t.verbose?" "+zo(d,o):c;n.push(h+l+m)},a=Mo(e);if(r(Math.trunc(a.days/365),"year","y"),r(a.days%365,"day","d"),r(a.hours,"hour","h"),r(a.minutes,"minute","m"),t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3)if(r(a.seconds,"second","s"),t.formatSubMilliseconds)r(a.milliseconds,"millisecond","ms"),r(a.microseconds,"microsecond","µs"),r(a.nanoseconds,"nanosecond","ns");else{const o=a.milliseconds+a.microseconds/1e3+a.nanoseconds/1e6,d=typeof t.millisecondsDecimalDigits=="number"?t.millisecondsDecimalDigits:0,c=o>=1?Math.round(o):Math.ceil(o),l=d?o.toFixed(d):c;r(Number.parseFloat(l),"millisecond","ms",l)}else{const o=e/1e3%60,d=typeof t.secondsDecimalDigits=="number"?t.secondsDecimalDigits:1,c=i(o,d),l=t.keepDecimalsOnWholeSeconds?c:c.replace(/\.0+$/,"");r(Number.parseFloat(l),"second","s",l)}if(n.length===0)return"0"+(t.verbose?" milliseconds":"ms");if(t.compact)return n[0];if(typeof t.unitCount=="number"){const o=t.colonNotation?"":" ";return n.slice(0,Math.max(t.unitCount,1)).join(o)}return t.colonNotation?n.join(""):n.join(" ")}const gs=6e4;function Io(e){return!Number.isFinite(e)||e<=0?"expiring":e<gs?"under 1m":xi(Math.floor(e/gs)*gs,{unitCount:2})}const Ts=["ready","busy","reserved","maintenance","offline"],bi={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function Rt(e,t){return e.offline?"offline":e.userBlocked?"maintenance":e.busy?"busy":e.reservedUntil&&t<e.reservedUntil?"reserved":"ready"}function ji(e,t){const n=_r(e);if(!e.busy||!n)return null;const i=String(n);return i.startsWith("manual_")?t!=null&&t.userId&&i===`manual_${t.userId}_${e.udid}`?"self":"other":"session"}const Cn=e=>(e==null?void 0:e.role)==="ADMIN"||(e==null?void 0:e.role)==="SUPER_ADMIN";function _o(e,t,n){switch(ji(e,t)){case"session":return e.sessionStartTime&&e.sessionStartTime>0&&n>e.sessionStartTime?`Test session · ${xi(n-e.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(e.reservedUntil&&n<e.reservedUntil){const r=!!e.reservedBy&&(e.reservedBy===(t==null?void 0:t.email)||e.reservedBy===(t==null?void 0:t.name))?"you":e.reservedBy||"another user";return`${Io(e.reservedUntil-n)} left · by ${r}`}return null}function Do(e,t){if(e.offline)return{enabled:!1,reason:"Device is offline"};if(e.userBlocked&&!Cn(t))return{enabled:!1,reason:"In maintenance"};const n=ji(e,t);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!Cn(t)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function Qe(e){var t;return((t=e.marketingName)==null?void 0:t.trim())||e.name}function wi(e){const t=[is(e.platform),e.sdk].filter(Boolean).join(" ");if(e.deviceType==="emulator")return`Emulator · ${t}`;if(e.deviceType==="simulator")return`Simulator · ${t}`;const i=[e.manufacturer?e.manufacturer.charAt(0).toUpperCase()+e.manufacturer.slice(1):"",e.model].filter(Boolean).join(" ");return i?`${i} · ${t}`:t}function Lo(e){return e.formFactor==="tablet"||e.formFactor==="tv"?e.formFactor:"phone"}function vt(e,t){return e.teamId?(t==null?void 0:t.get(e.teamId))??e.teamName??`Team ${e.teamId.slice(0,6)}`:null}const Oo=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],Fo=({device:e,onClose:t,onReserved:n})=>{const[i,r]=u.useState(""),[a,o]=u.useState("1h"),[d,c]=u.useState(""),[l,h]=u.useState(!1),[m,g]=u.useState(null),[f,v]=u.useState(null),S=async()=>{if(!i.trim()){g("Please enter your name/ID");return}h(!0),g(null),v(null);try{const b=await Y.reserveDevice(e.udid,e.host,i,a,d);b.success?(n(),t()):v(b.error||"Failed to reserve device")}catch(b){v(b.message||"An unexpected error occurred")}finally{h(!1)}};return s.jsx(rs,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(ga,{size:16,className:"title-icon"}),"Reserve device"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,disabled:l,children:"Cancel"}),s.jsx("button",{className:"btn-reserve",onClick:S,disabled:l||!i.trim(),children:l?"Reserving...":"Confirm Reservation"})]}),children:s.jsxs("div",{className:"reservation-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsxs("p",{children:["Reserve ",s.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),s.jsx(Kt,{label:s.jsxs(s.Fragment,{children:[s.jsx(jr,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:m?s.jsxs(s.Fragment,{children:[s.jsx(vn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),m]}):void 0,children:s.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:i,onChange:b=>{r(b.target.value),m&&g(null)},disabled:l})}),s.jsx(Kt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Fr,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:s.jsx("div",{className:"duration-selector",children:Oo.map(b=>s.jsx("div",{className:`duration-option ${a===b.value?"active":""}`,onClick:()=>o(b.value),children:b.label},b.value))})}),s.jsx(Kt,{label:s.jsxs(s.Fragment,{children:[s.jsx(Ha,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?s.jsxs(s.Fragment,{children:[s.jsx(vn,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:s.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:d,onChange:b=>c(b.target.value),disabled:l})})]})})},Po=({device:e,onClose:t,onUpdated:n})=>{const{toast:i}=Ie(),[r,a]=u.useState(e.tags||[]),[o,d]=u.useState(""),[c,l]=u.useState(!1),h=u.useRef(null);u.useEffect(()=>{h.current&&h.current.focus()},[]);const m=()=>{const S=o.trim();S&&!r.includes(S)&&(a([...r,S]),d(""))},g=S=>{a(r.filter(b=>b!==S))},f=S=>{S.key==="Enter"&&m()},v=async()=>{l(!0);try{await Y.updateDeviceTags(e.udid,e.host,r),n(),t()}catch(S){console.error("Failed to update tags",S),i("Error saving tags. Please try again.","error")}finally{l(!1)}};return s.jsx(rs,{open:!0,onClose:t,width:520,title:s.jsxs(s.Fragment,{children:[s.jsx(ho,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"btn-cancel",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn-save",onClick:v,disabled:c,children:c?"Saving...":"Apply Changes"})]}),children:s.jsxs("div",{className:"tag-modal-body",children:[s.jsxs("div",{className:"device-id-badge",children:[s.jsx("span",{className:"label",children:"Device:"}),s.jsx("span",{className:"value",children:e.udid})]}),s.jsx(Kt,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:s.jsxs("div",{className:"input-with-button",children:[s.jsx("input",{ref:h,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:o,onChange:S=>d(S.target.value),onKeyDown:f}),s.jsx("button",{className:"add-inline-btn",onClick:m,disabled:!o.trim(),children:s.jsx(Pr,{size:16})})]})}),s.jsxs("div",{className:"tags-display-section",children:[s.jsx("label",{children:"Current Tags"}),s.jsx("div",{className:"tags-list",children:r.length>0?r.map(S=>s.jsxs("div",{className:"tag-pill-editable",children:[S,s.jsx("button",{className:"remove-tag",onClick:()=>g(S),children:s.jsx(Fs,{size:12})})]},S)):s.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},Uo="/wd/hub";function Bo(e){return e==="android"?"UiAutomator2":"XCUITest"}function Wo(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Vo(e,t=Uo){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),i=t.startsWith("/")?t:`/${t}`,r=n.pathname.replace(/\/$/,"");return r===i||r.endsWith(i)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${i}`}catch{return e}}function Ho(e){const t={platformName:Wo(e.platform),"appium:automationName":Bo(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(t["appium:platformVersion"]=e.sdk),e.name&&(t["appium:deviceName"]=e.name),t}function Ko(e){return JSON.stringify(Ho(e),null,2)}const qo=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,Xo=/^(?:\d{1,3}\.){3}\d{1,3}$/;function Yo(e){const t=e.trim();return!t||qo.test(t)||!Xo.test(t)?!1:t.split(".").every(n=>{const i=Number(n);return Number.isInteger(i)&&i>=0&&i<=255})}function Go(e){return e.ip&&Yo(e.ip)?e.ip.trim():null}const ki=({udid:e,currentTeamId:t,teams:n,onDone:i,className:r})=>{const{toast:a}=Ie(),[o,d]=u.useState(!1);async function c(l){d(!0);try{await Y.setDeviceTeam(e,l),a(l?"Device assigned":"Device returned to shared pool","success"),i(!0)}catch(h){a((h==null?void 0:h.message)||"Failed to update team","error")}finally{d(!1)}}return s.jsxs(oi,{selectSize:"sm",className:r,autoFocus:!0,"aria-label":"Team",disabled:o,defaultValue:t??"",onBlur:()=>i(!1),onChange:l=>c(l.target.value||null),children:[s.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([l,h])=>s.jsx("option",{value:l,children:h},l))]})};function Si(e,t){const[n,i]=u.useState(!1),[r,a]=u.useState(!1),[o,d]=u.useState(!1),{me:c}=wr(),{toast:l}=Ie(),h=(c==null?void 0:c.role)==="ADMIN"||(c==null?void 0:c.role)==="SUPER_ADMIN",m=Date.now(),g=Rt(e,m),f=g==="reserved",v=_o(e,c,m),S=Do(e,c),b=Vo(e.host),z=Go(e),k=async(T,p)=>{var E;try{await((E=navigator.clipboard)==null?void 0:E.writeText(T)),l(p,"success")}catch{l("Failed to copy","error")}},y=async()=>{await Y.releaseReservation(e.udid,e.host),t()},C=async()=>{await Y.blockDevice(e.udid,e.host),t()},x=async()=>{await Y.unblockDevice(e.udid,e.host),t()},A=async()=>{e.userBlocked?await x():await C()},N=s.jsxs(s.Fragment,{children:[n&&s.jsx(Fo,{device:e,onClose:()=>i(!1),onReserved:()=>t()}),r&&s.jsx(Po,{device:e,onClose:()=>a(!1),onUpdated:()=>t()})]});return{kind:g,reserved:f,activity:v,control:S,isAdmin:h,editingTeam:o,setEditingTeam:d,openReservation:()=>i(!0),openTagManager:()=>a(!0),release:y,toggleMaintenance:A,copy:k,serverUrl:b,ip:z,dialogs:N}}const Ci=({device:e,actions:t,navigate:n,reasonId:i})=>{const{kind:r,reserved:a,control:o}=t;return s.jsxs(s.Fragment,{children:[s.jsx(U,{variant:"tonal",size:"sm",disabled:!o.enabled,"aria-describedby":o.enabled?void 0:i,onClick:()=>{o.enabled&&n(`/devices/${e.udid}/control`)},children:"Control"}),a?s.jsx(U,{variant:"secondary",size:"sm",onClick:t.release,children:"Release"}):r==="ready"?s.jsx(U,{variant:"secondary",size:"sm",onClick:t.openReservation,children:"Reserve"}):null]})},Ni=({device:e,actions:t})=>{const[n,i]=u.useState(!1),r=u.useRef(null),{isAdmin:a,serverUrl:o,ip:d,copy:c}=t;return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:r,type:"button",className:"dc2-more",onClick:()=>i(l=>!l),"aria-label":"More actions",children:s.jsx(gi,{size:14})}),s.jsx(Yt,{open:n,onClose:()=>i(!1),anchorRef:r,children:s.jsxs(Us,{children:[s.jsx(je,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(e.udid,"UDID copied")},children:"Copy UDID"}),o!=="—"&&s.jsx(je,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(o,"Server URL copied")},children:"Copy server URL"}),d&&s.jsx(je,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(d,"IP address copied")},children:"Copy IP address"}),s.jsx(je,{icon:s.jsx($e,{size:12}),onClick:()=>{i(!1),c(Ko(e),"Session capabilities copied")},children:"Copy capabilities"}),a&&s.jsxs(s.Fragment,{children:[s.jsx(li,{}),s.jsx(je,{onClick:()=>{i(!1),t.openTagManager()},children:"Manage tags…"}),s.jsx(je,{onClick:()=>{i(!1),t.setEditingTeam(!0)},children:"Assign team…"}),s.jsx(je,{onClick:()=>{i(!1),t.toggleMaintenance()},children:e.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},Jo=({device:e})=>{const t={phone:Ns,tablet:Ur,tv:kr}[Lo(e)],n=e.deviceType==="emulator"||e.deviceType==="simulator";return s.jsx(t,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},Zo=({device:e,reloadDevices:t,navigate:n,teams:i})=>{var m,g,f;const r=Si(e,t),{kind:a,activity:o,control:d}=r,c=`dc2-reason-${e.udid}`,l=Qe(e),h=vt(e,i);return s.jsxs("div",{className:`dc2 dc2-${a}`,children:[s.jsxs("div",{className:`dc2-band dc2-band-${a}`,children:[s.jsxs("span",{className:"dc2-band-label",children:[s.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),bi[a]]}),o&&s.jsx("span",{className:"dc2-band-activity",title:o,children:o})]}),s.jsxs("div",{className:`dc2-body${a==="offline"?" dc2-dim":""}`,children:[s.jsxs("div",{className:"dc2-head",children:[s.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:s.jsx(Jo,{device:e})}),s.jsxs("div",{className:"dc2-id",children:[s.jsx("div",{className:"dc2-title",title:`${l}
|
|
217
|
+
${e.udid}`,children:l}),s.jsx("div",{className:"dc2-subtitle",children:wi(e)})]})]}),s.jsxs("div",{className:"dc2-meta",children:[s.jsx(Ro,{device:e}),r.editingTeam?s.jsx(ki,{className:"dc2-team-picker",udid:e.udid,currentTeamId:e.teamId??null,teams:i??new Map,onDone:v=>{r.setEditingTeam(!1),v&&t()}}):h&&s.jsx(Ht,{tone:"accent",className:"dc2-team",title:`Team: ${h}`,children:h}),(m=e.tags)==null?void 0:m.slice(0,2).map(v=>s.jsxs("span",{className:"dc2-tag",title:v,children:["#",v]},v)),(((g=e.tags)==null?void 0:g.length)||0)>2&&s.jsxs("span",{className:"dc2-tag",children:["+",(((f=e.tags)==null?void 0:f.length)||0)-2]})]})]}),s.jsxs("div",{className:"dc2-foot",children:[s.jsx(Ci,{device:e,actions:r,navigate:n,reasonId:c}),!d.enabled&&s.jsx("span",{id:c,className:"dc2-unavailable",title:d.reason,children:d.reason}),s.jsx("span",{className:"dc2-spacer"}),s.jsx(Ni,{device:e,actions:r})]}),r.dialogs]})};function Qo(e){const t=$t(),{search:n}=ns();return s.jsx(Zo,{device:e.device,reloadDevices:e.reloadDevices,navigate:i=>t(`${i}${n}`),teams:e.teams})}class el extends at.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){Y.listTeams().then(t=>{this.setState({teamsMap:new Map(t.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return s.jsx("div",{className:"device-explorer-card-container",children:at.Children.toArray(this.props.devices.map(t=>s.jsx(Qo,{device:t,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const tl={status:"all",platform:"all",type:"all",q:""},Ei=["all",...Ts],Ti=["all","android","ios","tvos"],Ai=["all","real","virtual"];function vs(e,t){return t.includes(e)?e:t[0]}function sl(e){const t=e.get("q")??"";return{status:vs(e.get("status"),Ei),platform:vs(e.get("platform"),Ti),type:vs(e.get("type"),Ai),q:t.trim()?t:""}}function nl(e){const t=new URLSearchParams;return e.status!=="all"&&t.set("status",e.status),e.platform!=="all"&&t.set("platform",e.platform),e.type!=="all"&&t.set("type",e.type),e.q.trim()&&t.set("q",e.q),t}function Mt(e){return e.deviceType==="simulator"||e.deviceType==="emulator"?!0:!e.deviceType&&e.realDevice===!1}function Vs(e){const t=(e.platform||"").toLowerCase();return t==="android"||t==="ios"||t==="tvos"?t:null}function il(e){const t=e.deviceType==="emulator"?"Emulator":e.deviceType==="simulator"?"Simulator":"";return[Qe(e),e.name,e.manufacturer,e.model,is(e.platform),e.sdk,t,e.teamName,e.udid].filter(Boolean).join(" ").toLowerCase()}function qt(e,t,n,i){if(i!=="status"&&t.status!=="all"&&Rt(e,n)!==t.status||i!=="platform"&&t.platform!=="all"&&Vs(e)!==t.platform||i!=="type"&&t.type!=="all"&&t.type==="virtual"!==Mt(e))return!1;const r=t.q.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return!0;const a=il(e);return r.every(o=>a.includes(o))}const ys=e=>Object.fromEntries(e.map(t=>[t,0]));function rl(e,t,n){const i=ys(Ei),r=ys(Ti),a=ys(Ai);for(const o of e){if(qt(o,t,n,"status")&&(i.all+=1,i[Rt(o,n)]+=1),qt(o,t,n,"platform")){r.all+=1;const d=Vs(o);d&&(r[d]+=1)}qt(o,t,n,"type")&&(a.all+=1,a[Mt(o)?"virtual":"real"]+=1)}return{status:i,platform:r,type:a}}function al(e){return e.some(t=>Vs(t)==="tvos")}function ol(e){return e.status!=="all"||e.platform!=="all"||e.type!=="all"||e.q.trim()!==""}function ll(e,t){const n=i=>i===1?"device":"devices";return e===t?`${t} ${n(t)}`:`${e} of ${t} ${n(t)}`}const As={key:"status",dir:"asc"},cl=["status","device","platform","type","team","host"],dl=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),rt=(e,t)=>dl.compare(e,t);function ul(e,t,n,i){switch(n){case"status":return Ts.indexOf(Rt(e,i.now))-Ts.indexOf(Rt(t,i.now));case"device":return rt(Qe(e),Qe(t));case"platform":return rt(e.platform||"",t.platform||"")||rt(e.sdk||"",t.sdk||"");case"type":return Number(Mt(e))-Number(Mt(t));case"team":return rt(vt(e,i.teams)??"",vt(t,i.teams)??"");case"host":return rt(e.host||"",t.host||"")}}function hl(e,t,n){const i=t.dir==="desc"?-1:1;return e.slice().sort((r,a)=>{if(t.key==="team"){const o=vt(r,n.teams)===null,d=vt(a,n.teams)===null;if(o!==d)return o?1:-1}return i*ul(r,a,t.key,n)||rt(Qe(r),Qe(a))||rt(r.udid,a.udid)})}function ml(e){const t=e.get("sort");return!t||!cl.includes(t)?As:{key:t,dir:e.get("dir")==="desc"?"desc":"asc"}}function fl(e,t){e.delete("sort"),e.delete("dir"),!(t.key===As.key&&t.dir===As.dir)&&(e.set("sort",t.key),t.dir==="desc"&&e.set("dir","desc"))}const pt=({sortKey:e,label:t,sort:n,onSortChange:i})=>{const r=n.key===e,a=r?n.dir:"asc";return s.jsx(Gt,{scope:"col","aria-sort":r?a==="asc"?"ascending":"descending":"none",children:s.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>i(r?{key:e,dir:a==="asc"?"desc":"asc"}:{key:e,dir:"asc"}),children:[t,r&&(a==="asc"?s.jsx(Ws,{size:12,"aria-hidden":"true"}):s.jsx(Bs,{size:12,"aria-hidden":"true"}))]})})},pl=({device:e,reloadDevices:t,navigate:n,teams:i,showHost:r})=>{const a=Si(e,t),{kind:o,activity:d,control:c}=a,l=Qe(e),h=wi(e),m=vt(e,i),g=`${is(e.platform)} ${e.sdk??""}`,f=e.tags??[],v=`devtable-reason-${e.udid}`;return s.jsxs(ci,{className:`devtable-row${o==="offline"?" is-offline":""}`,children:[s.jsxs(it,{children:[s.jsxs("div",{className:"devtable-line",children:[s.jsx(Br,{kind:o,className:"devtable-status-dot"})," ",bi[o]]}),d&&s.jsx("div",{className:"devtable-muted devtable-line",title:d,children:d})]}),s.jsxs(Gt,{scope:"row",className:"devtable-rowheader",title:`${l}
|
|
218
|
+
${e.udid}`,children:[s.jsx("div",{className:"devtable-title devtable-line",children:l}),s.jsx("div",{className:"devtable-muted devtable-line",title:h,children:h})]}),s.jsx(it,{title:g,children:g}),s.jsx(it,{children:Mt(e)?"Virtual":"Real"}),s.jsx(it,{title:a.editingTeam?void 0:m??"Shared",children:a.editingTeam?s.jsx(ki,{udid:e.udid,currentTeamId:e.teamId??null,teams:i,onDone:S=>{a.setEditingTeam(!1),S&&t()}}):m??"Shared"}),s.jsxs(it,{title:f.join(", "),children:[f.slice(0,2).map(S=>s.jsxs("span",{className:"devtable-tag",children:["#",S]},S)),f.length>2&&s.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),r&&s.jsx(it,{title:e.host,children:e.host}),s.jsx(it,{className:"devtable-actions",title:c.enabled?void 0:c.reason,children:s.jsxs("div",{className:"devtable-actions-inner",children:[s.jsx(Ci,{device:e,actions:a,navigate:n,reasonId:v}),!c.enabled&&s.jsx("span",{id:v,className:"sr-only",children:c.reason}),s.jsx(Ni,{device:e,actions:a})]})}),a.dialogs]})};function gl({devices:e,reloadDevices:t,sort:n,onSortChange:i,navigate:r,teams:a}){const o=new Set(e.map(c=>c.host)).size>1||n.key==="host",d=hl(e,n,{now:Date.now(),teams:a});return s.jsxs(Wr,{className:"devtable",children:[s.jsxs("caption",{className:"sr-only",children:["Devices, ",e.length," shown"]}),s.jsxs("colgroup",{children:[s.jsx("col",{className:"devtable-col-status"}),s.jsx("col",{}),s.jsx("col",{className:"devtable-col-platform"}),s.jsx("col",{className:"devtable-col-type"}),s.jsx("col",{className:"devtable-col-team"}),s.jsx("col",{className:"devtable-col-tags"}),o&&s.jsx("col",{className:"devtable-col-host"}),s.jsx("col",{className:"devtable-col-actions"})]}),s.jsx(Vr,{children:s.jsxs(ci,{children:[s.jsx(pt,{sortKey:"status",label:"Status",sort:n,onSortChange:i}),s.jsx(pt,{sortKey:"device",label:"Device",sort:n,onSortChange:i}),s.jsx(pt,{sortKey:"platform",label:"Platform",sort:n,onSortChange:i}),s.jsx(pt,{sortKey:"type",label:"Type",sort:n,onSortChange:i}),s.jsx(pt,{sortKey:"team",label:"Team",sort:n,onSortChange:i}),s.jsx(Gt,{scope:"col",children:"Tags"}),o&&s.jsx(pt,{sortKey:"host",label:"Host",sort:n,onSortChange:i}),s.jsx(Gt,{scope:"col",children:"Actions"})]})}),s.jsx(Hr,{children:d.map(c=>s.jsx(pl,{device:c,reloadDevices:t,navigate:r,teams:a,showHost:o},c.udid))})]})}function vl(e){const t=$t(),{search:n}=ns(),[i,r]=u.useState(new Map);return u.useEffect(()=>{Y.listTeams().then(a=>r(new Map(a.map(o=>[o.id,o.name])))).catch(()=>{})},[]),s.jsx(gl,{devices:e.devices,reloadDevices:e.reloadDevices,sort:e.sort,onSortChange:e.onSortChange,navigate:a=>t(`${a}${n}`),teams:i})}const yl=({onCommand:e,prompt:t="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:i})=>{const[r,a]=u.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[o,d]=u.useState(""),[c,l]=u.useState([]),[h,m]=u.useState(-1),[g,f]=u.useState(!1),v=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[r]);const b=k=>{const y=k.trim();if((y.startsWith("{")||y.startsWith("["))&&(y.endsWith("}")||y.endsWith("]")))try{const C=JSON.parse(y);return JSON.stringify(C,null,2)}catch{}return k},z=async k=>{if(k.key==="Enter"&&!g){const y=o.trim();if(!y)return;if(d(""),a(C=>[...C,{type:"command",content:`${t} ${y}`,timestamp:Date.now()}]),l(C=>[...C,y]),m(-1),f(!0),y==="clear"){a([]),f(!1);return}if(y==="help"){let C="";i==="android"?C=`
|
|
219
|
+
Android Allowed Commands:
|
|
220
|
+
• System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
|
|
221
|
+
• Process Mgmt: ps, top
|
|
222
|
+
• File System: ls
|
|
223
|
+
• Diagnostics: dumpsys [battery|wifi|power]
|
|
224
|
+
• Packages: pm list packages
|
|
225
|
+
`:(i==="ios"||i==="tvos")&&(C=`
|
|
226
|
+
iOS Allowed Commands:
|
|
227
|
+
• Real Device (go-ios):
|
|
228
|
+
apps, info, list, syslog, deviceinfo, diagnostics
|
|
229
|
+
• Simulator (xcrun simctl):
|
|
230
|
+
listapps, get_app_container, list, getenv
|
|
231
|
+
• Simulator System:
|
|
232
|
+
ls, ps, top, date, uptime, whoami
|
|
233
|
+
`),a(x=>[...x,{type:"output",content:C.trim(),timestamp:Date.now()}]),f(!1);return}try{const C=await e(y),x=b(C||"(No output)");a(A=>[...A,{type:"output",content:x,timestamp:Date.now()}])}catch(C){a(x=>[...x,{type:"error",content:C.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var C;return(C=S.current)==null?void 0:C.focus()},10)}}else if(k.key==="ArrowUp"){if(k.preventDefault(),c.length>0){const y=h===-1?c.length-1:Math.max(0,h-1);m(y),d(c[y])}}else if(k.key==="ArrowDown"&&(k.preventDefault(),h!==-1)){const y=h+1;y>=c.length?(m(-1),d("")):(m(y),d(c[y]))}};return s.jsxs("div",{className:"terminal-container theme-dark",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"terminal-header",children:[s.jsxs("div",{className:"terminal-controls",children:[s.jsx("div",{className:"dot red"}),s.jsx("div",{className:"dot yellow"}),s.jsx("div",{className:"dot green"})]}),s.jsxs("div",{className:"terminal-title",children:[is(i)," shell"]}),s.jsx("div",{className:"terminal-actions",children:s.jsx("button",{className:"terminal-action-btn",onClick:()=>a([]),title:"Clear terminal",children:"CLEAR"})})]}),s.jsxs("div",{className:"terminal-history",ref:v,onClick:()=>{var k;return(k=S.current)==null?void 0:k.focus()},children:[r.map((k,y)=>s.jsx("div",{className:`terminal-line ${k.type}`,children:k.content},y)),g&&s.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),s.jsxs("div",{className:"terminal-input-area",children:[s.jsx("span",{className:"terminal-prompt",children:t}),s.jsx("input",{ref:S,className:"terminal-input",value:o,onChange:k=>d(k.target.value),onKeyDown:z,disabled:g,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ve(e,t){var n;t(e),(n=e.children)==null||n.forEach(i=>Ve(i,t))}function We(e,...t){var n;for(const i of t){const r=(n=e.attributes)==null?void 0:n[i];if(r!=null&&r!=="")return String(r)}}function yt(e){var t;return((t=e.type)==null?void 0:t.split(".").pop())||e.type||""}function xl(e,t){const n=[];return Ve(e,i=>{We(i,"content-desc","contentDescription","accessibilityId","name","label")===t&&n.push(i)}),n}function bl(e,t){const n=[];return Ve(e,i=>{We(i,"resource-id","resourceId","identifier")===t&&n.push(i)}),n}function Rs(e,t){const n=[];return Ve(e,i=>{(i.type===t||yt(i)===t)&&n.push(i)}),n}function jl(e,t){const n=[];return Ve(e,i=>{We(i,"name")===t&&n.push(i)}),n}function wl(e){const t=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return t?{tag:t[1]==="*"?null:t[1],attrKey:t[2],attrValue:t[4]}:null}function kl(e,t){const n=t.split("/").filter(Boolean);if(n.length===0)return null;const i=[];for(const a of n){const o=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(a);if(!o)return null;i.push({type:o[1],index:parseInt(o[2],10)})}if(i[0].type!==e.type&&i[0].type!==yt(e)||i[0].index!==1)return null;let r=e;for(let a=1;a<i.length&&r;a++){const{type:o,index:d}=i[a];let c=0,l;for(const h of r.children||[])if((h.type===o||yt(h)===o)&&(c+=1,c===d)){l=h;break}r=l}return r?[r]:[]}function Sl(e,t){const n=kl(e,t);if(n!==null)return{kind:"matched",nodes:n};const i=wl(t);if(i){const r=[];return Ve(e,a=>{if(i.tag&&a.type!==i.tag&&yt(a)!==i.tag)return;We(a,i.attrKey)===i.attrValue&&r.push(a)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Cl(e,t){const n=t.trim(),i=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(i){const[,o,d,c]=i,l=[];return Ve(e,h=>{if(h.type!==o&&yt(h)!==o)return;We(h,d)===c&&l.push(h)}),{kind:"matched",nodes:l}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,o,d]=r,c=parseInt(d,10),l=[];return Ve(e,h=>{(h.type===o||yt(h)===o)&&l.push(h)}),{kind:"matched",nodes:l[c-1]?[l[c-1]]:[]}}const a=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return a?Rs(e,a[1]).length>0?{kind:"matched",nodes:Rs(e,a[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Nl(e,t){const i=t.trim().split(/\s+AND\s+/i).map(o=>o.trim()),r=[];for(const o of i){const d=/^(\w+)\s*==\s*"([^"]*)"$/.exec(o);if(!d)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:d[1],value:d[2]})}const a=[];return Ve(e,o=>{for(const d of r){let c;if(d.key==="type"?c=o.type:d.key==="label"?c=We(o,"label")??o.label:d.key==="name"?c=We(o,"name")??o.name:d.key==="value"?c=We(o,"value")??o.value:c=We(o,d.key),c!==d.value)return}a.push(o)}),{kind:"matched",nodes:a}}function Ms(e,t,n){const i=t.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(i){case"accessibility id":return{kind:"matched",nodes:xl(e,n)};case"id":return{kind:"matched",nodes:bl(e,n)};case"class name":return{kind:"matched",nodes:Rs(e,n)};case"name":return{kind:"matched",nodes:jl(e,n)};case"xpath":return Sl(e,n);case"-ios class chain":return Cl(e,n);case"-ios predicate string":return Nl(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${t}" not yet supported by snapshot matcher`}}}function Nn(e){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[e.toLowerCase()]??7}function zs(e,t){const n=e.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(t)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(t)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(t)&&!t.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(t)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(t.startsWith("/hierarchy")||t.startsWith("/")&&!t.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(t))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const i=(t.match(/\//g)||[]).length;return i>7?{level:"fragile",reason:`${i}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:t.includes("@content-desc")||t.includes("@resource-id")||t.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?t.includes("resourceId")||t.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:t.includes("textContains")||t.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function Ri(e){return[...e].sort((t,n)=>Nn(t.strategy)-Nn(n.strategy))}const Ut=e=>e===!0||e==="true",El=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Tl=/(EditText|AutoCompleteTextView)$/;function Mi(e){const t=e.attributes||{};return Ut(t.clickable)||Ut(t["long-clickable"])||Ut(t.checkable)||Ut(t.scrollable)||Tl.test(e.type||"")||El.test(e.type||"")}function Al(e){const t=e.attributes||{};return String(e.text||t["content-desc"]||e.label||t.label||t.name||"").trim()}function Rl(e,t){const n="Unique locator",i=Ri(e.suggestedLocators||[]),r=i[0];if(!r)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const a=Ms(t.hierarchy,r.strategy,r.value),o=`${r.strategy} ${r.value}`;if(a.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${r.strategy} locators here`};const d=g=>g.length===1&&g[0].xpath===e.xpath;if(d(a.nodes))return{id:"unique",label:n,status:"pass",detail:`${o} matches only this element`};const c=i.slice(1).find(g=>{const f=Ms(t.hierarchy,g.strategy,g.value);return f.kind==="matched"&&d(f.nodes)}),l=c?`; use ${c.strategy} ${c.value} instead`:"",h=a.nodes.length,m=h===0?"matches nothing in this capture":`matches ${h} elements`;return{id:"unique",label:n,status:"fail",detail:`${o} ${m}${l}`}}function Ml(e){const t=Ri(e.suggestedLocators||[])[0];if(!t)return null;const{level:n,reason:i}=zs(t.strategy,t.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:i}}function zl(e,t){const{screenWidth:n,screenHeight:i}=t.metadata||{screenWidth:0,screenHeight:0};if(!n||!i)return null;const{x:r,y:a,width:o,height:d}=e.rect,c="On screen";return r+o<=0||a+d<=0||r>=n||a>=i?{id:"onscreen",label:c,status:"warn",detail:"Off screen — scroll it into view first"}:r<0||a<0||r+o>n||a+d>i?{id:"onscreen",label:c,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:c,status:"pass",detail:"Fully inside the screen"}}function $l(e,t){var d,c;const n=Mi(e),i=!(((d=e.attributes)==null?void 0:d.enabled)===!1||((c=e.attributes)==null?void 0:c.enabled)==="false"),r=e.rect.width>0&&e.rect.height>0,a=Al(e);return[Rl(e,t),Ml(e),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},i?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},r?{id:"size",label:"Has size",status:"pass",detail:`${e.rect.width} × ${e.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},zl(e,t),n?a?{id:"name",label:"Accessible name",status:"pass",detail:`“${a.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(l=>l!==null)}function Il(e){return{pass:e.filter(t=>t.status==="pass").length,warn:e.filter(t=>t.status==="warn").length,fail:e.filter(t=>t.status==="fail").length}}function _l(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const i=Math.floor(n/60);return i<60?`Captured ${i} min ago`:`Captured ${Math.floor(i/60)} h ago`}function Dl(e,t){return e>0&&t>e}function zi(e){var a,o,d,c,l;const t=(e.type||"").toLowerCase(),n=((a=e.attributes)==null?void 0:a.clickable)==="true"||((o=e.attributes)==null?void 0:o.clickable)===!0,i=((d=e.attributes)==null?void 0:d.scrollable)==="true"||((c=e.attributes)==null?void 0:c.scrollable)===!0,r=((l=e.children)==null?void 0:l.length)||0;return t.includes("button")||t.includes("btn")||n&&r===0?{role:"Button",key:"button"}:t.includes("edit")||t.includes("input")||t.includes("field")?{role:"Text input",key:"input"}:t.includes("image")||t.includes("img")||t.includes("imageview")?{role:"Image",key:"image"}:t.includes("scroll")||t.includes("recyclerview")||t.includes("listview")||i?{role:"Scrollable list",key:"list"}:t.includes("text")||t.includes("label")?{role:"Text label",key:"text"}:t.includes("switch")||t.includes("toggle")||t.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:t.includes("nav")||t.includes("toolbar")||t.includes("tabbar")?{role:"Navigation bar",key:"nav"}:r>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const $i={button:s.jsx(Ja,{size:13}),input:s.jsx(po,{size:13}),image:s.jsx($a,{size:13}),list:s.jsx(yi,{size:13}),text:s.jsx(wo,{size:13}),toggle:s.jsx(xo,{size:13}),nav:s.jsx(to,{size:13}),container:s.jsx(di,{size:13}),element:s.jsx(fa,{size:13})};function Ii(e,t){if(!t)return!0;const n=t.toLowerCase().trim(),i={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},r=(e.type||"").toLowerCase(),a=(e.text||e.label||e.value||"").toLowerCase(),o=(e.name||"").toLowerCase(),d=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[c,l]of Object.entries(i))if(n.includes(c)&&l.some(h=>r.includes(h)))return!0;return r.includes(n)||a.includes(n)||o.includes(n)||d.includes(n)}const ze=e=>typeof e=="string"?e.trim():typeof e=="number"?String(e):"";function Ll(e){const t=ze(e),n=t.indexOf(":id/");return n>=0?t.slice(n+4):t}function _i(e){return(e.type||"").split(".").pop()||""}function Jt(e){var t;return[e.type,(t=e.attributes)==null?void 0:t["resource-id"],e.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
|
|
234
|
+
`)}function ot(e){const t=e.attributes||{};return ze(e.text)||ze(t["content-desc"])||ze(e.label)||ze(t.label)||Ll(t["resource-id"])||ze(t.name)||_i(e)||"Element"}const Ol=e=>{const t=e.attributes||{};return!!(ze(e.text)||ze(t["content-desc"])||ze(e.label)||ze(t.label))};function Fl(e){var t;return(((t=e.children)==null?void 0:t.length)??0)===1&&!Mi(e)&&!Ol(e)}function Di(e){const t=[e];let n=e;for(;Fl(n);)n=n.children[0],t.push(n);return t}function Li(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{var a;Ii(r,t)&&n.add(r.xpath),(a=r.children)==null||a.forEach(i)};return i(e),n}function Pl(e,t){const n=new Set;if(!e||!t.trim())return n;const i=r=>{let a=!1;for(const o of r.children||[])i(o)&&(a=!0);return a&&n.add(r.xpath),a||Ii(r,t)};return i(e),n}function Ul(e,t,n=""){if(!e)return[];const i=!!n.trim(),r=i?Li(e,n):null,a=i?Pl(e,n):null,o=l=>!i||l.some(h=>r.has(h.xpath)||a.has(h.xpath)),d=[],c=(l,h,m)=>{const g=l.map(Di).filter(o);g.forEach((f,v)=>{var y;const S=f[f.length-1],b=(((y=S.children)==null?void 0:y.length)??0)>0,z=i&&a.has(S.xpath),k=b&&(t.has(S.xpath)||z);d.push({key:S.xpath,nodes:f,level:h,setSize:g.length,posInSet:v+1,hasChildren:b,expanded:k,collapsible:k&&!z,parentKey:m}),k&&c(S.children,h+1,S.xpath)})};return c([e],1,null),d}function Bl(e,t=3){const n=new Set,i=(r,a)=>{var c;const o=Di(r),d=o[o.length-1];a>t||!((c=d.children)!=null&&c.length)||(n.add(d.xpath),d.children.forEach(l=>i(l,a+1)))};return e&&i(e,1),n}function Xt(e,t){if(!e)return null;if(e.xpath===t)return[e];for(const n of e.children||[]){const i=Xt(n,t);if(i)return[e,...i]}return null}function En(e,t){return e.findIndex(n=>n.nodes.some(i=>i.xpath===t))}function Wl(e,t,n){var r;const i=e[t];if(!i)return null;switch(n){case"ArrowDown":return t<e.length-1?{focus:t+1}:null;case"ArrowUp":return t>0?{focus:t-1}:null;case"ArrowRight":return i.hasChildren?i.expanded?((r=e[t+1])==null?void 0:r.parentKey)===i.key?{focus:t+1}:null:{toggle:i.key}:null;case"ArrowLeft":{if(i.collapsible)return{toggle:i.key};const a=e.findIndex(o=>o.key===i.parentKey);return a>=0?{focus:a}:null}case"Home":return{focus:0};case"End":return{focus:e.length-1};case"Enter":case" ":return{select:i.nodes[i.nodes.length-1]};default:return null}}const Vl=10;function Hl({rows:e,selectedXpath:t,hoveredXpath:n,matches:i,onToggle:r,onSelect:a,onHover:o,revealSeq:d=0}){const c=u.useRef(null),[l,h]=u.useState(null),m=u.useRef(0),g=u.useRef(null),f=t?En(e,t):-1,v=l?e.findIndex(x=>x.key===l):-1,S=v>=0?v:Math.max(f,0),b=x=>{var A;return((A=c.current)==null?void 0:A.querySelector(`[data-row="${x}"]`))??null},z=x=>x.nodes[x.nodes.length-1],k=x=>{var T;const A=e[x];if(!A)return;h(A.key),m.current=x;const N=b(x);N==null||N.focus({preventScroll:!0}),(T=N==null?void 0:N.scrollIntoView)==null||T.call(N,{block:"nearest"})};u.useEffect(()=>{g.current=t},[t,d]),u.useEffect(()=>{var N,T;const x=g.current;if(!x)return;const A=En(e,x);A<0||((T=(N=b(A))==null?void 0:N.scrollIntoView)==null||T.call(N,{block:"nearest"}),g.current=null)}),u.useEffect(()=>{var N,T;if(!l||e.some(p=>p.key===l))return;const x=Math.min(m.current,e.length-1),A=!document.activeElement||document.activeElement===document.body;h(((N=e[x])==null?void 0:N.key)??null),A&&x>=0&&((T=b(x))==null||T.focus({preventScroll:!0}))});const y=x=>{const A=x.target;if(A.getAttribute("role")!=="treeitem")return;const N=Wl(e,Number(A.dataset.row),x.key);N&&(x.preventDefault(),"focus"in N?k(N.focus):"toggle"in N?r(N.toggle):a(N.select))},C=x=>{var A;(A=c.current)!=null&&A.contains(x.relatedTarget)||(o(null),h(null))};return s.jsx("div",{ref:c,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:y,onBlur:C,children:e.map((x,A)=>{const N=z(x),T=w=>!!w&&x.nodes.some(O=>O.xpath===w),p=T(t),E=!p&&T(n),D=ot(N),F=_i(N),L=!!F&&F!==D,W=x.nodes.map(w=>ot(w)).join(", "),G=L?`${W}, ${F}`:W,ee=x.expanded&&!x.collapsible,V=(w,O)=>`omni-tree-row__part${O?" is-target":""}${i.has(w.xpath)?" is-match":""}${w.xpath===t?" is-current":""}`;return s.jsxs("div",{"data-row":A,role:"treeitem","aria-level":x.level,"aria-setsize":x.setSize,"aria-posinset":x.posInSet,"aria-selected":p,"aria-expanded":x.hasChildren?x.expanded:void 0,"aria-label":G,tabIndex:A===S?0:-1,className:`omni-tree-row${p?" is-selected":""}${E?" is-hovered":""}`,onClick:()=>a(N),onFocus:w=>{w.target===w.currentTarget&&(h(x.key),m.current=A,o(N))},onMouseEnter:()=>o(N),onMouseLeave:()=>o(null),children:[s.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[s.jsx("span",{className:"omni-tree-row__indent",style:{width:(x.level-1)*Vl}}),s.jsx("span",{className:`omni-tree-row__caret${ee?" is-locked":""}`,onClick:x.hasChildren?w=>{w.stopPropagation(),ee||r(x.key)}:void 0,children:x.hasChildren&&(x.expanded?s.jsx(Sr,{size:12}):s.jsx(qr,{size:12}))}),s.jsx("span",{className:"omni-tree-row__icon",children:$i[zi(N).key]})]}),s.jsxs("span",{className:"omni-tree-row__label",children:[x.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__head",children:x.nodes.slice(0,-1).map((w,O)=>s.jsxs(at.Fragment,{children:[O>0&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsx("span",{className:V(w,!1),title:Jt(w),onClick:K=>{K.stopPropagation(),a(w)},onMouseEnter:()=>o(w),onMouseLeave:()=>o(N),children:ot(w)})]},w.xpath))}),s.jsxs("span",{className:"omni-tree-row__tail",children:[x.nodes.length>1&&s.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),s.jsxs("span",{className:"omni-tree-row__name",children:[s.jsx("span",{className:V(N,!0),title:Jt(N),children:ot(N)}),L&&s.jsx("span",{className:"omni-tree-row__type",children:F})]})]})]}),x.hasChildren&&!x.expanded&&s.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:N.children.length})]},x.key)})})}const Tn=4;function Kl({path:e,onSelect:t,focusCurrent:n=!1}){const[i,r]=u.useState(!1),a=u.useRef(null),o=u.useRef(null);if(u.useEffect(()=>{var h;n&&((h=o.current)==null||h.focus())},[]),u.useEffect(()=>{var h;i&&((h=a.current)==null||h.focus())},[i]),!e.length)return null;const d=e[e.length-1],c=e.slice(0,-1),l=!i&&c.length>Tn?c.length-Tn:0;return s.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:s.jsxs("ol",{children:[l>0&&s.jsx("li",{children:s.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${c.length} ancestors`,onClick:()=>r(!0),children:"…"})}),c.slice(l).map((h,m)=>s.jsx("li",{children:s.jsx("button",{ref:m===0?a:void 0,type:"button",className:"omni-crumb",title:Jt(h),"aria-label":ot(h),onClick:()=>t(h),children:ot(h)})},h.xpath)),s.jsx("li",{children:s.jsx("span",{ref:o,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Jt(d),children:ot(d)})})]})})}const Zt=.4,ql=240,Xl=340,An=.02,Qt=12,Oi="xenon.omni.split";function Fi(e){if(!(e>0))return{min:0,max:1};const t=Math.min(1,ql/e);return{min:t,max:Math.max(t,(e-Xl)/e)}}function Yl(e,t){const{min:n,max:i}=Fi(t),r=Number.isFinite(e)?e:Zt;return Math.min(i,Math.max(n,r))}function Gl(e){try{const t=Number.parseFloat((e==null?void 0:e.getItem(Oi))??"");return t>0&&t<1?t:Zt}catch{return Zt}}function Jl(e,t){try{e==null||e.setItem(Oi,String(Math.round(t*1e3)/1e3))}catch{}}function Rn(){try{return window.localStorage}catch{return null}}const Zl=3;function Ql({share:e,limits:t,containerRef:n,onChange:i,onCommit:r,onReset:a}){const[o,d]=u.useState(!1),c=u.useRef(e);c.current=e;const l=u.useRef(!0),h=u.useRef(!1),m=u.useRef(0),g=u.useRef(e),f=k=>Math.min(t.max,Math.max(t.min,k)),v=k=>Math.round(k*100),S=()=>{l.current||(l.current=!0,d(!1),h.current&&r(c.current))},b=k=>{var C;const y=(C=n.current)==null?void 0:C.getBoundingClientRect();return!y||y.width<=Qt?c.current:f(g.current+(k-m.current)/(y.width-Qt))},z=k=>{const y=k.key==="ArrowLeft"?e-An:k.key==="ArrowRight"?e+An:k.key==="Home"?t.min:k.key==="End"?t.max:null;y!==null&&(k.preventDefault(),r(f(Math.round(y*1e3)/1e3)))};return s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":v(e),"aria-valuemin":v(t.min),"aria-valuemax":v(t.max),tabIndex:0,className:`omni-split-divider${o?" is-dragging":""}`,onKeyDown:z,onDoubleClick:a,onPointerDown:k=>{var y,C;(C=(y=k.currentTarget).setPointerCapture)==null||C.call(y,k.pointerId),l.current=!1,h.current=!1,m.current=k.clientX,g.current=c.current,d(!0)},onPointerMove:k=>{if(!o||!h.current&&Math.abs(k.clientX-m.current)<Zl)return;const y=b(k.clientX);y!==c.current&&(h.current=!0,i(y))},onPointerUp:k=>{var y,C;(C=(y=k.currentTarget).releasePointerCapture)==null||C.call(y,k.pointerId),S()},onPointerCancel:k=>{var y,C;(C=(y=k.currentTarget).releasePointerCapture)==null||C.call(y,k.pointerId),S()},onLostPointerCapture:S,children:s.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Mn(e,t,n,i){var k,y,C,x,A,N,T;const{strategy:r,value:a}=i,o=(e.text||e.name||((k=e.type)==null?void 0:k.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",d=o.charAt(0).toLowerCase()+o.slice(1),c=((y=e.type)==null?void 0:y.toLowerCase().includes("edit"))||((C=e.type)==null?void 0:C.toLowerCase().includes("input"))||((x=e.type)==null?void 0:x.toLowerCase().includes("field"))||((A=e.type)==null?void 0:A.toLowerCase().includes("textfield")),l=((N=e.attributes)==null?void 0:N.scrollable)==="true"||((T=e.attributes)==null?void 0:T.scrollable)===!0,h=r.toLowerCase().startsWith("-ios")&&t!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
|
|
235
|
+
`:r.toLowerCase().startsWith("-android")&&t!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
|
|
236
|
+
`:"",m={"accessibility id":`~${a}`,id:t==="ios"?`-ios predicate string:label == "${a}"`:`android=new UiSelector().resourceId("${a}")`,xpath:`${a}`,"-ios predicate string":`-ios predicate string:${a}`,"-ios class chain":`-ios class chain:${a}`,"-android uiautomator":`android=${a}`},g={"accessibility id":`AppiumBy.accessibilityId("${a}")`,id:`AppiumBy.id("${a}")`,xpath:`AppiumBy.xpath("${a}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${a}")`,"-ios class chain":`AppiumBy.iOSClassChain("${a}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${a}")`,"class name":`AppiumBy.className("${a}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${a}"`,id:`AppiumBy.ID, "${a}"`,xpath:`AppiumBy.XPATH, "${a}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${a}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${a}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${a}'`,"class name":`AppiumBy.CLASS_NAME, "${a}"`},v=g[r.toLowerCase()],S=f[r.toLowerCase()],b=m[r.toLowerCase()];return n==="java"?v?`${h}// Appium Java Client 9.x + Selenium 4 + TestNG
|
|
237
|
+
import io.appium.java_client.AppiumBy;
|
|
238
|
+
import io.appium.java_client.${t==="android"?"AndroidDriver":t==="ios"?"IOSDriver":"AppiumDriver"};
|
|
239
|
+
import org.openqa.selenium.WebElement;
|
|
240
|
+
import org.testng.annotations.Test;
|
|
241
|
+
|
|
242
|
+
@Test
|
|
243
|
+
public void test_${d}() {
|
|
244
|
+
WebElement element = driver.findElement(${v});
|
|
245
|
+
${l?'((Scrollable) element).scrollTo("target text");':c?`element.clear();
|
|
246
|
+
element.sendKeys("your text here");`:"element.click();"}
|
|
247
|
+
// Add assertions here via TestNG Assert or Hamcrest
|
|
248
|
+
}`:`// Strategy "${r}" not supported in Appium Java Client`:n==="python"?S?`${h}# Appium Python Client 4.x + pytest
|
|
249
|
+
from appium.webdriver.common.appiumby import AppiumBy
|
|
250
|
+
import pytest
|
|
251
|
+
|
|
252
|
+
def test_${d}(self):
|
|
253
|
+
element = self.driver.find_element(${S})
|
|
254
|
+
${c?`element.clear()
|
|
255
|
+
element.send_keys("your text here")`:"element.click()"}
|
|
256
|
+
# Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?b?`${h}// WebdriverIO 9.x + @wdio/appium-service
|
|
257
|
+
describe('${d} test', () => {
|
|
258
|
+
it('should interact with ${d}', async () => {
|
|
259
|
+
const element = await $('${b}');
|
|
260
|
+
await element.waitForDisplayed({ timeout: 5000 });
|
|
261
|
+
${c?`await element.clearValue();
|
|
262
|
+
await element.addValue("your text here");`:"await element.click();"}
|
|
263
|
+
// Add assertions here via expect(element)
|
|
264
|
+
});
|
|
265
|
+
});`:`// Strategy "${r}" not supported in WebdriverIO mobile`:b?`${h}// WebdriverIO 9.x standalone
|
|
266
|
+
const element = await driver.$('${b}');
|
|
267
|
+
await element.waitForExist({ timeout: 5000 });
|
|
268
|
+
${c?`await driver.$('target').clearValue();
|
|
269
|
+
await element.addValue("your text here");`:"await element.click();"}
|
|
270
|
+
// Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}const ec={pass:s.jsx(hi,{size:13}),warn:s.jsx(Be,{size:13}),fail:s.jsx(mi,{size:13}),info:s.jsx(ni,{size:13})},tc={pass:"passed",warn:"warning",fail:"failed",info:"note"},sc={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},nc=({sessionId:e,udid:t,streamUrl:n,embedded:i=!1,overlayTarget:r=null,onModeChange:a,deviceActionAt:o=0})=>{var an,on,ln,cn,dn,un;const[d,c]=u.useState(!0),[l,h]=u.useState(null),[m,g]=u.useState(null),[f,v]=u.useState(null),[S,b]=u.useState(0),z=u.useRef(!1),[k,y]=u.useState(null),[C,x]=u.useState(()=>new Set),[A,N]=u.useState(""),[T,p]=u.useState(null),[E,D]=u.useState("info"),[F,L]=u.useState(0),[W,G]=u.useState(0),[ee,V]=u.useState(()=>Date.now()),w=u.useRef(0),O=u.useRef(null),[K,_]=u.useState("java"),[q,ae]=u.useState(null),[X,ne]=u.useState({width:0,height:0}),[oe,ue]=u.useState({width:0,height:0}),[M,le]=u.useState(!1),[Q,ie]=u.useState("inspect");u.useEffect(()=>{a==null||a(Q)},[Q,a]);const[Se,he]=u.useState({}),[ve,Ne]=u.useState({}),[_e,De]=u.useState(null),[pe,et]=u.useState(null),[Le,Ee]=u.useState(null),He=u.useRef(null),xt=u.useRef(null),Ke=u.useRef(null),qe=u.useRef(null),Xe=u.useRef(null),[bt,ht]=u.useState(()=>Gl(Rn())),[tt,mt]=u.useState(0);u.useEffect(()=>{const j=Xe.current;if(!j||typeof ResizeObserver>"u")return;const R=new ResizeObserver(([$])=>mt(Math.max(0,$.contentRect.width-Qt)));return R.observe(j),()=>R.disconnect()},[]);const Me=Yl(bt,tt),re=j=>{ht(j),Jl(Rn(),j)},se=u.useCallback(()=>{var Fe,Pe,Ye;if(!He.current)return;const j=He.current.getBoundingClientRect(),R=j.width,$=j.height,P=(Fe=l==null?void 0:l.hierarchy)==null?void 0:Fe.rect;let J=((Pe=l==null?void 0:l.metadata)==null?void 0:Pe.screenWidth)||X.width||1,B=((Ye=l==null?void 0:l.metadata)==null?void 0:Ye.screenHeight)||X.height||1;P&&P.width>0&&P.height>0&&(J=P.width,B=P.height);const ce=J/B;let Re,Te;R/$>ce?(Te=$,Re=Te*ce):(Re=R,Te=Re/ce),ue({width:Re,height:Te})},[l,X]);u.useEffect(()=>(se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)),[se]),u.useEffect(()=>{t&&te()},[t]);const ge=u.useCallback(async(j,R,$)=>{if(pe!=null&&pe.sessionId){De(j);try{const P=await Y.verifyLocator(pe.basePath,pe.sessionId,{strategy:j,selector:R,action:$});Ne(J=>({...J,[j]:P})),$==="tap"&&G(Date.now())}catch(P){Ne(J=>({...J,[j]:{found:!1,count:0,error:(P==null?void 0:P.message)||String(P)}}))}finally{De(null)}}},[pe]),I=u.useRef(null);u.useEffect(()=>{const j=!!f&&f.xpath===I.current;I.current=(f==null?void 0:f.xpath)??null;const R=(f==null?void 0:f.suggestedLocators)??[];ae($=>{const P=j&&$?R.find(B=>B.strategy===$.strategy):null,J=R.find(B=>B.strategy==="accessibility id"||B.strategy==="id");return P||J||R[0]||null}),he({}),Ne({}),Ee(null)},[f]);const H=u.useCallback((j,R)=>{if(!(l!=null&&l.hierarchy))return;const $=Ms(l.hierarchy,j,R);he(P=>({...P,[j]:$})),Ee(j)},[l]),te=async()=>{if(!t)return;const j=++w.current,R=()=>j===w.current;c(!0),g(null),Y.getAppiumSession(t).then($=>{R()&&et({sessionId:($==null?void 0:$.sessionId)??null,basePath:($==null?void 0:$.basePath)??""})}).catch(()=>{R()&&et({sessionId:null,basePath:""})});try{const $=await Y.getInspectorSnapshot(t);if(!R())return;if(!($!=null&&$.hierarchy)){h(null),g(($==null?void 0:$.error)||"Failed to capture snapshot");return}const P=$.udid||t,J=P===O.current;O.current=P,Es.unstable_batchedUpdates(()=>{h($),L(Date.now()),x(Bl($.hierarchy)),v(B=>{var ce;return B&&J?((ce=Xt($.hierarchy,B.xpath))==null?void 0:ce.pop())??null:null}),b(B=>B+1)})}catch($){if(!R())return;h(null),g($.message||"Failed to capture snapshot")}finally{R()&&c(!1)}};u.useEffect(()=>{const j=setInterval(()=>V(Date.now()),1e4);return()=>clearInterval(j)},[]);const me=j=>{const{naturalWidth:R,naturalHeight:$}=j.currentTarget;ne({width:R,height:$})},fe=()=>le(!0),ye=j=>{le(!1);const{naturalWidth:R,naturalHeight:$}=j.currentTarget;R>0&&$>0&&ne({width:R,height:$})},Oe=n&&!M,st=j=>{if(Q!=="interact"||!t)return;const R=j.currentTarget.getBoundingClientRect();qe.current={x:j.clientX-R.left,y:j.clientY-R.top,time:Date.now()}},jt=async j=>{var mn,fn,pn;if(Q!=="interact"||!t||!qe.current)return;const R=qe.current,$=j.currentTarget.getBoundingClientRect(),P=j.clientX-$.left,J=j.clientY-$.top,B=Date.now()-R.time,ce=oe.width,Re=oe.height,Te=(mn=l==null?void 0:l.hierarchy)==null?void 0:mn.rect;let Fe=((fn=l==null?void 0:l.metadata)==null?void 0:fn.screenWidth)||X.width,Pe=((pn=l==null?void 0:l.metadata)==null?void 0:pn.screenHeight)||X.height;if(Te&&Te.width>0&&Te.height>0&&(Fe=Te.width,Pe=Te.height),!Fe||!Pe||ce===0||Re===0)return;const Ye=(Ft,gn)=>({x:Math.round(Ft/ce*Fe),y:Math.round(gn/Re*Pe),px:Ft/ce,py:gn/Re}),ke=Ye(R.x,R.y),hn=Ye(P,J),ms=Math.sqrt(Math.pow(P-R.x,2)+Math.pow(J-R.y,2));if(!(ke.px<0||ke.px>1||ke.py<0||ke.py>1)){try{B<500&&ms<10?await Y.tap(t,ke.x,ke.y):B>=500&&ms<10?await Y.touchAndHold(t,ke.x,ke.y,B):ms>=10&&await Y.swipe(t,ke.x,ke.y,hn.x,hn.y),G(Date.now())}catch(Ft){console.error("Interaction failed:",Ft)}qe.current=null}},It=j=>{x(R=>{const $=new Set(R);return $.has(j)?$.delete(j):$.add(j),$})},_t=()=>{const j=new Set,R=$=>{var P;j.add($.xpath),(P=$.children)==null||P.forEach(R)};l!=null&&l.hierarchy&&R(l.hierarchy),x(j)},os=()=>x(new Set),Zs=(j,R)=>{navigator.clipboard.writeText(j),p(R),setTimeout(()=>p(null),2e3)},Qs=j=>{var $;let R=1;return($=j.children)==null||$.forEach(P=>R+=Qs(P)),R},vr=j=>{if(!j)return[];const R={},$=P=>{var B;const J=zi(P);R[J.role]||(R[J.role]={key:J.key,count:0}),R[J.role].count+=1,(B=P.children)==null||B.forEach($)};return $(j),Object.entries(R).map(([P,J])=>({role:P,key:J.key,count:J.count})).sort((P,J)=>J.count-P.count)},yr=u.useMemo(()=>Ul(l==null?void 0:l.hierarchy,C,A),[l,C,A]),Dt=u.useMemo(()=>Li(l==null?void 0:l.hierarchy,A),[l,A]),en=Dt.size===0?"No matches":Dt.size===1?"1 match":`${Dt.size} matches`;u.useEffect(()=>{if(!f||!(l!=null&&l.hierarchy))return;const j=Xt(l.hierarchy,f.xpath);!j||j.length<2||x(R=>{const $=j.slice(0,-1).filter(J=>!R.has(J.xpath));if(!$.length)return R;const P=new Set(R);return $.forEach(J=>P.add(J.xpath)),P})},[S]),u.useEffect(()=>{z.current=!1});const ls=j=>{v(j),b(R=>R+1),D("info")},xr=j=>{z.current=!0,ls(j)},tn=j=>{A.trim()&&!j.trim()&&b(R=>R+1),N(j)},cs=()=>{var P,J,B;const j=(P=l==null?void 0:l.hierarchy)==null?void 0:P.rect;if(j&&j.width>0&&j.height>0)return{w:j.width,h:j.height};const R=((J=l==null?void 0:l.metadata)==null?void 0:J.screenWidth)||X.width,$=((B=l==null?void 0:l.metadata)==null?void 0:B.screenHeight)||X.height;return R>0&&$>0?{w:R,h:$}:null},sn=j=>{const R=cs();if(!R)return[];const $=[],{w:P,h:J}=R,B=(ce,Re)=>{var Fe,Pe,Ye;const Te=!ce.children||ce.children.length===0;((Fe=ce.rect)==null?void 0:Fe.width)>0&&((Pe=ce.rect)==null?void 0:Pe.height)>0&&Te&&$.push(s.jsx("div",{className:"omni-hit-area",style:{left:`${ce.rect.x/P*100}%`,top:`${ce.rect.y/J*100}%`,width:`${ce.rect.width/P*100}%`,height:`${ce.rect.height/J*100}%`,zIndex:Re},onClick:ke=>{ke.stopPropagation(),ls(ce)},onMouseEnter:()=>y(ce),onMouseLeave:()=>y(null)},ce.xpath)),(Ye=ce.children)==null||Ye.forEach(ke=>B(ke,Re+1))};return l!=null&&l.hierarchy&&B(l.hierarchy,1),$},nn=()=>{const j=cs();if(!Le||!j)return[];const R=Se[Le];if(!R||R.kind!=="matched"||R.nodes.length===0)return[];const{w:$,h:P}=j,J=R.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return R.nodes.filter(B=>B.rect&&B.rect.width>0&&B.rect.height>0).map((B,ce)=>s.jsx("div",{className:J,style:{left:`${B.rect.x/$*100}%`,top:`${B.rect.y/P*100}%`,width:`${B.rect.width/$*100}%`,height:`${B.rect.height/P*100}%`}},`match-${Le}-${ce}`))},Lt=(j,R)=>{const $=cs();if(!(j!=null&&j.rect)||!$)return null;const{w:P,h:J}=$;return s.jsx("div",{className:`omni-frame-${R}`,style:{left:`${j.rect.x/P*100}%`,top:`${j.rect.y/J*100}%`,width:`${j.rect.width/P*100}%`,height:`${j.rect.height/J*100}%`}})},ds=l!=null&&l.hierarchy?Qs(l.hierarchy):0,Ot=f&&(l!=null&&l.hierarchy)?$l(f,l):null,nt=Ot?Il(Ot):null,us=Dl(F,Math.max(o,W)),hs=l!=null&&l.hierarchy&&Q==="inspect"?s.jsxs("div",{className:`omni-overlay${us?" is-stale":""}`,children:[sn(l.hierarchy),nn(),Lt(k,"hover"),Lt(f,"select")]}):null,br={stable:{icon:s.jsx(Pt,{size:10}),cls:"stable"},moderate:{icon:s.jsx(Be,{size:10}),cls:"moderate"},fragile:{icon:s.jsx(ft,{size:10}),cls:"fragile"},"very-fragile":{icon:s.jsx(ft,{size:10}),cls:"very-fragile"}},rn=i&&(l!=null&&l.hierarchy)?vr(l.hierarchy):[];return s.jsxs("div",{className:`omni-inspector-container ${i?"omni-embedded":""}`,children:[i&&r&&hs?Es.createPortal(hs,r):null,s.jsxs("div",{className:"omni-main-content",children:[!i&&s.jsxs("div",{className:"omni-screenshot-panel",children:[s.jsxs("div",{className:"omni-screenshot-header",children:[s.jsxs("div",{className:"omni-header-left",children:[s.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),s.jsxs("div",{className:"omni-mode-toggle",children:[s.jsxs("button",{className:`omni-mode-btn ${Q==="inspect"?"active":""}`,onClick:()=>ie("inspect"),title:"Inspection mode (highlight elements)",children:[s.jsx(bn,{size:12}),s.jsx("span",{children:"Inspect"})]}),s.jsxs("button",{className:`omni-mode-btn ${Q==="interact"?"active":""}`,onClick:()=>ie("interact"),title:"Interaction mode (direct control)",children:[s.jsx(Sn,{size:12}),s.jsx("span",{children:"Interact"})]})]})]}),s.jsxs("button",{className:"omni-refresh-btn",onClick:te,disabled:d,children:[s.jsx(Et,{size:12,className:d?"animate-spin":""}),d?"Capturing...":"Refresh"]})]}),s.jsxs("div",{className:"omni-screenshot-container",ref:He,children:[d&&!Oe&&s.jsxs("div",{className:"omni-loading-overlay",children:[s.jsx("div",{className:"omni-spinner"}),s.jsx("span",{children:"Capturing screen..."})]}),!l&&!d&&!Oe&&s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(ps,{size:40}),s.jsx("span",{children:"Click Refresh to capture"})]}),Oe&&s.jsxs("div",{className:`omni-screenshot-wrapper ${Q==="interact"?"interactable":""}`,onMouseDown:st,onMouseUp:jt,children:[s.jsx(ri,{ref:Ke,src:n,onLoad:ye,onError:fe,className:"omni-screenshot-img",style:Q==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),hs]}),!Oe&&(l==null?void 0:l.screenshot)&&s.jsxs("div",{className:`omni-screenshot-wrapper ${Q==="interact"?"interactable":""}`,onMouseDown:st,onMouseUp:jt,children:[s.jsx("img",{ref:xt,src:`data:image/png;base64,${l.screenshot}`,onLoad:me,className:"omni-screenshot-img",style:Q==="interact"?{pointerEvents:"none"}:{},draggable:!1}),Q==="inspect"&&s.jsxs("div",{className:`omni-overlay${us?" is-stale":""}`,children:[sn(l.hierarchy),nn(),Lt(k,"hover"),Lt(f,"select")]})]})]})]}),s.jsxs("div",{className:"omni-split",ref:Xe,children:[s.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${Me*100}% - ${Me*Qt}px)`},children:[s.jsxs("div",{className:"omni-tree-header",children:[s.jsxs("div",{className:"omni-tree-title",children:[s.jsx(di,{size:14}),s.jsx("span",{children:"Source"})]}),s.jsxs("div",{className:"omni-tree-actions",children:[s.jsx("button",{onClick:_t,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:s.jsx(ba,{size:12})}),s.jsx("button",{onClick:os,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:s.jsx(ya,{size:12})}),i&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>ie(Q==="inspect"?"interact":"inspect"),className:`omni-action-btn ${Q==="inspect"?"active":""}`,title:Q==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":Q==="inspect"?"Inspect mode":"Interact mode","aria-pressed":Q==="inspect",children:Q==="inspect"?s.jsx(bn,{size:12}):s.jsx(Sn,{size:12})}),s.jsx("button",{onClick:te,className:"omni-action-btn",title:d?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:d,children:s.jsx(Et,{size:12,className:d?"animate-spin":""})})]})]})]}),m&&!d&&s.jsxs("div",{className:"omni-tree-error",role:"alert",children:[s.jsx(ft,{size:12}),s.jsx("span",{children:m}),s.jsx("button",{type:"button",onClick:te,className:"omni-tree-error-retry",children:"Retry"})]}),l&&!d&&!m&&(us?s.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[s.jsx(Be,{size:12,"aria-hidden":"true"}),s.jsx("span",{children:"The screen may have changed since this capture."}),s.jsx("button",{type:"button",onClick:te,className:"omni-capture-refresh",children:"Refresh"})]}):s.jsxs("div",{className:"omni-capture-meta",children:[s.jsxs("span",{children:[ds," ",ds===1?"element":"elements"]}),l.hierarchySource&&s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{className:"omni-capture-source",title:l.hierarchySource==="appium-session"?`From Appium session ${l.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:l.hierarchySource==="appium-session"?"Session":"Device"})]}),s.jsx("span",{"aria-hidden":"true",children:"·"}),s.jsx("span",{children:_l(F,ee)})]})),s.jsxs("div",{className:"omni-tree-search",children:[s.jsx(Ps,{size:14}),s.jsx("input",{type:"text",placeholder:"Search elements",value:A,onChange:j=>tn(j.target.value),"aria-label":"Search elements"}),A&&s.jsx("button",{onClick:()=>tn(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),s.jsx("div",{role:"status",className:"sr-only",children:A.trim()?en:""}),A.trim()&&s.jsxs("div",{className:"omni-search-hint",children:[en," · try a role: button, input, image"]}),s.jsx("div",{className:"omni-tree-content",children:l!=null&&l.hierarchy?s.jsx(Hl,{rows:yr,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(k==null?void 0:k.xpath)??null,matches:Dt,onToggle:It,onSelect:ls,onHover:y,revealSeq:S}):s.jsx("div",{className:"omni-empty-state small",children:s.jsx("span",{children:"No hierarchy loaded"})})})]}),s.jsx(Ql,{share:Me,limits:Fi(tt),containerRef:Xe,onChange:ht,onCommit:re,onReset:()=>re(Zt)}),s.jsxs("div",{className:"omni-details-panel",children:[s.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[s.jsxs("button",{className:`omni-details-tab ${E==="info"?"active":""}`,onClick:()=>D("info"),role:"tab","aria-selected":E==="info",children:[s.jsx(Ua,{size:12})," ",s.jsx("span",{children:"Info"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="checks"?"active":""}`,onClick:()=>D("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":E==="checks",children:[s.jsx(Kr,{size:12})," ",s.jsx("span",{children:"Checks"})]}),s.jsxs("button",{className:`omni-details-tab ${E==="code"?"active":""}`,onClick:()=>D("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":E==="code",children:[s.jsx(kn,{size:12})," ",s.jsx("span",{children:"Code gen"})]})]}),s.jsx("div",{className:"omni-details-content",children:f?s.jsxs(s.Fragment,{children:[E==="info"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Element info"}),s.jsxs("div",{className:"omni-info-table",children:[s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Type"}),s.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&s.jsxs("div",{className:"omni-info-row",children:[s.jsx("span",{className:"omni-info-key",children:"Text"}),s.jsx("span",{className:"omni-info-value",children:f.text})]}),s.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[s.jsx("span",{className:"omni-info-key",children:"Path"}),s.jsx(Kl,{path:(l==null?void 0:l.hierarchy)&&Xt(l.hierarchy,f.xpath)||[f],onSelect:xr,focusCurrent:z.current},f.xpath)]})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Layout"}),s.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(j=>s.jsxs("div",{className:"omni-layout-item",children:[s.jsx("span",{className:"omni-layout-label",children:j.toUpperCase()}),s.jsx("span",{className:"omni-layout-value",children:f.rect[j]})]},j))})]}),s.jsxs("div",{className:"omni-section",children:[s.jsxs("div",{className:"omni-section-header",children:["Locators",s.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(pe!=null&&pe.sessionId)&&((ln=f.suggestedLocators)==null?void 0:ln.length)>0&&s.jsxs("p",{className:"omni-locators-note",children:[s.jsx(ni,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),s.jsxs("div",{className:"omni-locators-list",children:[!((cn=f.suggestedLocators)!=null&&cn.length)&&s.jsx("div",{className:"omni-locators-empty",children:f===(l==null?void 0:l.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),(dn=f.suggestedLocators)==null?void 0:dn.map(j=>{const R=zs(j.strategy,j.value),$=br[R.level],P=Se[j.strategy];let J=null;return P&&(P.kind==="unsupported"?J=s.jsxs("span",{className:"omni-match-badge unsupported",title:P.reason||"Cannot evaluate without a real driver",children:[s.jsx(pi,{size:10})," preview unavailable"]}):P.nodes.length===0?J=s.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[s.jsx(ft,{size:10})," 0 matches"]}):P.nodes.length===1?J=s.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[s.jsx(Pt,{size:10})," unique"]}):J=s.jsxs("span",{className:"omni-match-badge multi",title:`${P.nodes.length} elements match — selector is not unique`,children:[s.jsx(Be,{size:10})," ",P.nodes.length," matches"]})),s.jsx("div",{className:`omni-locator-row ${(q==null?void 0:q.strategy)===j.strategy?"selected-for-code":""}`,onClick:()=>ae(j),title:"Click to use in Code gen",children:s.jsxs("div",{className:"omni-locator-left",children:[s.jsxs("div",{className:"omni-locator-top",children:[s.jsx("span",{className:"omni-locator-strategy",children:j.strategy}),s.jsxs("span",{className:`omni-stability-badge ${$.cls}`,title:R.reason,children:[$.icon,R.level]}),J]}),s.jsx("code",{className:"omni-locator-value",children:j.value}),s.jsx("span",{className:"omni-stability-reason",children:R.reason}),(()=>{const B=ve[j.strategy];return B?B.error?s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(ft,{size:10})," Appium error: ",B.error]}):B.found?B.count>1?s.jsxs("span",{className:"omni-verify-line is-warn",children:[s.jsx(Be,{size:10})," Ambiguous — Appium found"," ",B.count," elements",B.actionError?` · ${B.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-ok",children:[s.jsx(Pt,{size:10})," Appium found 1 element",B.elapsedMs!=null?` in ${B.elapsedMs}ms`:"",B.actionPerformed&&B.actionPerformed!=="none"?` · ${B.actionPerformed} ok`:"",B.actionError?` · action failed: ${B.actionError}`:""]}):s.jsxs("span",{className:"omni-verify-line is-error",children:[s.jsx(ft,{size:10})," Appium found 0 elements"]}):null})(),s.jsxs("div",{className:"omni-locator-actions",children:[s.jsxs(U,{type:"button",variant:Le===j.strategy?"tonal":"secondary",size:"sm",onClick:B=>{B.stopPropagation(),H(j.strategy,j.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[s.jsx(Na,{size:12,"aria-hidden":"true"}),"Test"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",disabled:!(pe!=null&&pe.sessionId)||_e===j.strategy,onClick:B=>{B.stopPropagation(),ge(j.strategy,j.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[_e===j.strategy?s.jsx(Et,{size:12,className:"animate-spin","aria-hidden":"true"}):s.jsx(Pt,{size:12,"aria-hidden":"true"}),"Verify"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",disabled:!(pe!=null&&pe.sessionId)||_e===j.strategy,onClick:B=>{B.stopPropagation(),ge(j.strategy,j.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[s.jsx(ui,{size:12,"aria-hidden":"true"}),"Tap"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:B=>{B.stopPropagation(),Zs(j.value,j.strategy)},title:"Copy the locator's value","aria-label":T===j.strategy?"Copied":"Copy locator",children:[T===j.strategy?s.jsx(At,{size:12,"aria-hidden":"true"}):s.jsx($e,{size:12,"aria-hidden":"true"}),T===j.strategy?"Copied":"Copy"]})]})]})},j.strategy)})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Attributes"}),s.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([j,R])=>R!=null&&R!=="").map(([j,R])=>s.jsxs("div",{className:"omni-attr-row",children:[s.jsx("span",{className:"omni-attr-key",children:j}),s.jsx("span",{className:"omni-attr-value",children:String(R)})]},j))})]})]}),E==="checks"&&Ot&&nt&&s.jsxs("div",{className:"omni-checks-panel",children:[s.jsxs("p",{className:"omni-checks-summary",children:[s.jsxs("span",{className:"is-pass",children:[s.jsx(hi,{size:12,"aria-hidden":"true"})," ",nt.pass," passed"]}),nt.warn>0&&s.jsxs("span",{className:"is-warn",children:[s.jsx(Be,{size:12,"aria-hidden":"true"})," ",nt.warn," ",nt.warn===1?"warning":"warnings"]}),nt.fail>0&&s.jsxs("span",{className:"is-fail",children:[s.jsx(mi,{size:12,"aria-hidden":"true"})," ",nt.fail," failed"]})]}),s.jsx("ul",{className:"omni-checks-list",children:Ot.map(j=>s.jsxs("li",{className:`omni-check is-${j.status}`,children:[s.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:ec[j.status]}),s.jsxs("div",{className:"omni-check-body",children:[s.jsxs("div",{className:"omni-check-label",children:[j.label,s.jsxs("span",{className:"sr-only",children:[": ",tc[j.status]]})]}),s.jsx("div",{className:"omni-check-detail",children:j.detail})]})]},j.id))})]}),E==="code"&&s.jsxs("div",{className:"omni-codegen-panel",children:[s.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(j=>s.jsx("button",{className:`omni-fw-btn ${K===j?"active":""}`,onClick:()=>_(j),children:sc[j]},j))}),q?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"omni-codegen-locator-selector",children:[s.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),s.jsx(oi,{selectSize:"sm",value:q.strategy,onChange:j=>{var $;const R=($=f.suggestedLocators)==null?void 0:$.find(P=>P.strategy===j.target.value);R&&ae(R)},className:"flex-1",children:(un=f.suggestedLocators)==null?void 0:un.map(j=>s.jsxs("option",{value:j.strategy,children:[j.strategy," — ",zs(j.strategy,j.value).level]},j.strategy))})]}),s.jsxs("div",{className:"omni-codegen-output",children:[s.jsxs("div",{className:"omni-codegen-header",children:[s.jsx("span",{className:"omni-codegen-lang",children:K==="java"?"Java / TestNG":K==="python"?"Python / unittest":K==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),s.jsx("button",{className:"omni-copy-btn",onClick:()=>Zs(Mn(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",K,q),"code"),children:T==="code"?s.jsx(At,{size:12}):s.jsx($e,{size:12})})]}),s.jsx("pre",{className:"omni-codegen-pre theme-dark",children:s.jsx("code",{children:Mn(f,(l==null?void 0:l.platform)==="android"?"android":(l==null?void 0:l.platform)==="ios"?"ios":"unknown",K,q)})})]})]}):s.jsxs("div",{className:"omni-empty-state small",children:[s.jsx(kn,{size:24}),s.jsx("span",{children:"No locators available for this element"})]})]})]}):l!=null&&l.hierarchy?s.jsxs("div",{className:"omni-summary-panel",children:[s.jsxs("div",{className:"omni-summary-hero",children:[s.jsx(ps,{size:28}),s.jsxs("div",{children:[s.jsx("div",{className:"omni-summary-title",children:"No element selected"}),s.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),s.jsxs("div",{className:"omni-summary-stats",children:[s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),s.jsx("span",{className:"omni-summary-stat__value",children:ds})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),s.jsx("span",{className:"omni-summary-stat__value",children:((an=l.metadata)==null?void 0:an.screenWidth)??X.width??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),s.jsx("span",{className:"omni-summary-stat__value",children:((on=l.metadata)==null?void 0:on.screenHeight)??X.height??"—"})]}),s.jsxs("div",{className:"omni-summary-stat",children:[s.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),s.jsx("span",{className:"omni-summary-stat__value",children:l.platform||"—"})]})]})]}),rn.length>0&&s.jsxs("div",{className:"omni-section",children:[s.jsx("div",{className:"omni-section-header",children:"By role"}),s.jsx("div",{className:"omni-summary-roles",children:rn.slice(0,8).map(j=>s.jsxs("div",{className:"omni-summary-role",children:[s.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:$i[j.key]}),s.jsx("span",{className:"omni-summary-role__name",children:j.role}),s.jsx("span",{className:"omni-summary-role__count",children:j.count})]},j.role))})]})]}):s.jsxs("div",{className:"omni-empty-state",children:[s.jsx(ps,{size:32}),s.jsx("span",{children:d?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},zn=5e3;function ic(e,t=!0){const[n,i]=u.useState("unknown"),r=u.useRef("unknown");return u.useEffect(()=>{if(!e||!t){i("unknown"),r.current="unknown";return}let a=!1,o;const d=h=>{a||h===r.current||(r.current=h,i(h))},c=async()=>{if(!a){if(o&&(clearTimeout(o),o=void 0),typeof document<"u"&&document.visibilityState==="hidden"){o=setTimeout(c,zn);return}try{const h=await Y.getDisplayState(e);d((h==null?void 0:h.state)??"unknown")}catch{}a||(o=setTimeout(c,zn))}};c();const l=()=>{document.visibilityState==="visible"&&c()};return document.addEventListener("visibilitychange",l),()=>{a=!0,o&&clearTimeout(o),document.removeEventListener("visibilitychange",l)}},[e,t]),n}function rc(e,t){const n=u.useRef(e),i=u.useRef(t);n.current=e,i.current=t,u.useEffect(()=>{const r=()=>n.current(),a=o=>{var d;o.persisted&&((d=i.current)==null||d.call(i))};return window.addEventListener("pagehide",r),window.addEventListener("pageshow",a),()=>{window.removeEventListener("pagehide",r),window.removeEventListener("pageshow",a)}},[])}const ac=/^(INPUT|TEXTAREA|SELECT)$/,Hs=u.createContext(null);function oc(e){const t=u.useContext(Hs),n=u.useRef(e);n.current=e;const i=e!==null;u.useEffect(()=>{if(!(!t||!i))return t.register(()=>{var r;return((r=n.current)==null?void 0:r.call(n))??!1})},[t,i])}function Pi(e){const t=u.useContext(Hs),n=u.useRef(e);return n.current=e,u.useCallback(()=>t?t.close():n.current(),[t])}function lc({labelledBy:e,onClose:t,children:n,style:i,...r}){const a=u.useRef(null),o=u.useRef(t);o.current=t;const d=u.useMemo(()=>{const l=new Set;return{register(h){return l.add(h),()=>{l.delete(h)}},close(){for(const h of Array.from(l))if(h())return;o.current()}}},[]),c=u.useRef(d);return u.useEffect(()=>{const l=a.current;if(!l)return;const h=document.activeElement,m=[];for(let f=l;f.parentElement&&f!==document.body;f=f.parentElement)for(const v of Array.from(f.parentElement.children))v===f||v.hasAttribute("inert")||v.matches("[aria-live], script, style, link, template")||(v.setAttribute("inert",""),m.push(v));l.contains(document.activeElement)||l.focus();const g=f=>{if(f.key!=="Escape"||f.defaultPrevented)return;const v=f.target;ac.test(v.tagName)||v.isContentEditable||(f.preventDefault(),c.current.close())};return l.addEventListener("keydown",g),()=>{l.removeEventListener("keydown",g),m.forEach(f=>f.removeAttribute("inert")),h&&h.isConnected&&h!==document.body&&h.focus()}},[]),s.jsx("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,style:{outline:"none",...i},...r,children:s.jsx(Hs.Provider,{value:d,children:n})})}const Ui="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Ks(e){var t;try{return(t=navigator.clipboard)!=null&&t.writeText?(await navigator.clipboard.writeText(e),!0):!1}catch{return!1}}const $n=5e3,cc=500,dc=1e4,uc=10,hc=50;function mc(e,t,n){const i=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,a]=u.useState([]),[o,d]=u.useState(!1),[c,l]=u.useState(null),[h,m]=u.useState(!1),g=u.useRef(null),f=u.useRef(0),v=u.useRef(void 0),S=u.useRef(()=>{}),b=u.useRef([]),z=u.useRef(void 0),k=u.useRef(0),y=u.useRef(void 0),C=u.useCallback(()=>{if(b.current.length===0)return;const T=b.current;b.current=[],a(p=>{const E=p.concat(T);return E.length>$n?E.slice(-$n):E})},[]),x=u.useCallback(()=>{z.current===void 0&&(z.current=window.setTimeout(()=>{z.current=void 0,C()},hc))},[C]),A=u.useCallback(()=>{b.current=[],a([])},[]);u.useEffect(()=>{if(!t){d(!1),l(null),m(!1);return}l(null),m(!1),f.current=0;const T={cancelled:!1},p=()=>{if(T.cancelled)return;if(f.current>=uc){m(!0);return}const D=Math.min(cc*2**f.current,dc);f.current+=1,v.current=window.setTimeout(E,D)},E=async()=>{if(!T.cancelled)try{const D=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if(T.cancelled)return;if(!D.ok){p();return}const{ticket:F}=await D.json();if(T.cancelled)return;if(!F){p();return}const L=window.location.protocol==="https:"?"wss":"ws",[W,G]=i.split("|"),ee=(W?`&levels=${encodeURIComponent(W)}`:"")+(G?`&process=${encodeURIComponent(G)}`:""),V=new WebSocket(`${L}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(F)}${ee}`);g.current=V,V.onopen=()=>{f.current=0,y.current!==1012&&(b.current=[],a([])),y.current=void 0,d(!0)},V.onmessage=w=>{try{const O=JSON.parse(w.data);b.current.push({...O,seq:k.current++}),x()}catch{}},V.onclose=w=>{if(d(!1),y.current=w.code,C(),w.code===1008){T.cancelled=!0,l(w.reason||"access denied");return}if(w.code===1012){p();return}console.warn(`[logcat] WS closed unexpectedly (code ${w.code}) — retrying`),p()},V.onerror=()=>V.close()}catch{p()}};return S.current=()=>{T.cancelled=!1,f.current=0,l(null),m(!1),E()},E(),()=>{var D;T.cancelled=!0,v.current!==void 0&&window.clearTimeout(v.current),z.current!==void 0&&(window.clearTimeout(z.current),z.current=void 0),C(),(D=g.current)==null||D.close(),g.current=null}},[e,t,i,C,x]);const N=u.useCallback(()=>{S.current()},[]);return{records:r,connected:o,clear:A,deniedReason:c,exhausted:h,retry:N}}const zt=["V","D","I","W","E","F"];function fc(e){const t=[];let n="",i=!1,r=!1;for(const a of e){if(a==='"'){i=!i,r=!0;continue}if(!i&&/\s/.test(a)){(r||n)&&t.push(n),n="",r=!1;continue}n+=a,r=!0}return(r||n)&&t.push(n),t.filter(a=>a.length>0)}function Bi(e,t={}){const n=t.caseSensitive===!0,i=o=>n?o:o.toLowerCase(),r=n?{caseSensitive:!0}:{},a=[];for(const o of fc(e)){const[d,...c]=o.split(":"),l=c.join(":"),h=d.toLowerCase();l&&h==="level"?r.minLevel=l.toUpperCase():l&&h==="tag"?r.tag=i(l):l&&h==="package"?r.pkg=i(l):l&&h==="-tag"?(r.excludeTags=r.excludeTags||[]).push(i(l)):l&&h==="-package"?(r.excludePkgs=r.excludePkgs||[]).push(i(l)):a.push(o)}return a.length&&(r.text=i(a.join(" "))),r}function Wi(e,t){if(e.synthetic)return!0;if(t.minLevel){const i=zt.indexOf(t.minLevel),r=zt.indexOf(e.level);if(i>=0&&r>=0&&r<i)return!1}const n=i=>t.caseSensitive?i:i.toLowerCase();if(t.tag&&!n(e.tag).includes(t.tag)||t.pkg&&!n(e.pkg??"").includes(t.pkg)||t.text&&!n(e.message).includes(t.text))return!1;if(t.excludeTags){const i=n(e.tag);if(t.excludeTags.some(r=>i.includes(r)))return!1}if(t.excludePkgs){const i=n(e.pkg??"");if(i&&t.excludePkgs.some(r=>i.includes(r)))return!1}return!0}function Vi(e){const t=[];let n="",i=!1;for(const r of e){if(r==='"'&&(i=!i),!i&&/\s/.test(r)){n&&t.push(n),n="";continue}n+=r}return n&&t.push(n),t}function Hi(e){const[t,...n]=e.replace(/"/g,"").split(":");return{key:t.toLowerCase(),value:n.join(":")}}function Ki(e){const t=e.split('"').map(n=>n.trim()).reduce((n,i)=>i.length>n.length?i:n,"");return/\s/.test(t)?`"${t}"`:t}function In(e,t,n){const i=Ki(n);if(!i)return e;const r=`${t}:${i}`,a=[];let o=!1;for(const d of Vi(e)){const c=Hi(d);if(c.key===t&&c.value){o||a.push(r),o=!0;continue}a.push(d)}return o||a.push(r),a.join(" ")}function pc(e,t,n){const i=Ki(n);if(!i)return e;const r=i.replace(/"/g,""),a=Vi(e);return a.some(d=>{const c=Hi(d);return c.key===`-${t}`&&c.value===r})?e:[...a,`-${t}:${i}`].join(" ")}function gc(e,t){const n=e.trim().split(/\s+/).filter(Boolean).filter(i=>{const[r,...a]=i.split(":");return!(a.join(":")&&r.toLowerCase()==="level")});return t?["level:"+t.toUpperCase(),...n].join(" "):n.join(" ")}const xs=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],_n=["V","D","I","W","E","F"];function vc(e){if(!e)return xs.filter(n=>n.ios!=="Debug").map(n=>n.ios);const t=_n.indexOf(e.toUpperCase());return t<0?xs.map(n=>n.ios):xs.filter(n=>_n.indexOf(n.android)>=t).map(n=>n.ios)}function yc(e){const t=Bi(e,{caseSensitive:!0});return{levels:vc(t.minLevel),process:t.pkg||void 0}}const Dn=zt,xc={V:"Verbose",D:"Debug",I:"Info",W:"Warning",E:"Error",F:"Fatal"};function bc(e,t){const n={V:0,D:0,I:0,W:0,E:0,F:0},i={...t,minLevel:void 0};for(let r=0;r<e.length;r++){const a=e[r];a.synthetic||Object.prototype.hasOwnProperty.call(n,a.level)&&Wi(a,i)&&(n[a.level]+=1)}return n}function jc(e,t,n){return(e==="ios"?["D","I","E","F"]:t.F>0||(n||"").toUpperCase()==="F"?["V","D","I","W","E","F"]:["V","D","I","W","E"]).map(r=>({level:r,name:qi(r,e)}))}function wc(e,t){if(!t)return null;const n=Dn.indexOf(t.toUpperCase());if(n<0)return null;const i=e.find(r=>Dn.indexOf(r.level)>=n);return i?i.level:null}function qi(e,t){return e==="F"?t==="ios"?"Fault":"Fatal":xc[e]??e}const $s=5e5;function es(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function kc(e){return{lines:[],startedAt:e,dropped:0}}function Sc(e,t){for(const n of t){if(e.lines.length>=$s){e.dropped+=1;continue}e.lines.push(es(n))}return e}function Cc(e,t,n){const i=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(t).toISOString()}`,`# duration: ${((t-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&i.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${$s}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
|
|
271
|
+
`),a=e.dropped>0?`
|
|
272
|
+
# --- TRUNCATED: ${e.dropped} line(s) not captured (cap ${$s}) ---`:"";return`${i.join(`
|
|
273
|
+
`)}
|
|
274
|
+
|
|
275
|
+
${r}${a}
|
|
276
|
+
`}function Nc(e,t){const n=new Date(t).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const bs={selected:new Set,anchor:null,active:null};function Xi(e,t,n){const i=e.indexOf(t),r=e.indexOf(n);return i<0||r<0?null:e.slice(Math.min(i,r),Math.max(i,r)+1)}function Yi(e){return{selected:new Set([e]),anchor:e,active:e}}function Ec(e,t,n,i){if(i.range&&e.anchor!==null){const r=Xi(n,e.anchor,t);if(r)return{selected:new Set(r),anchor:e.anchor,active:t}}if(i.toggle){const r=new Set(Array.from(e.selected));return r.has(t)?r.delete(t):r.add(t),{selected:r,anchor:t,active:t}}return Yi(t)}function Tc(e,t,n,i){if(!t.length)return e;const r=e.active===null?-1:t.indexOf(e.active),a=r<0?n===1?0:t.length-1:Math.max(0,Math.min(t.length-1,r+n)),o=t[a];if(!i)return Yi(o);const d=e.anchor!==null&&t.indexOf(e.anchor)>=0?e.anchor:e.active??o,c=Xi(t,d,o)??[o];return{selected:new Set(c),anchor:d,active:o}}function Ac(e,t){const n=[];if(t.size)for(let i=0;i<e.length;i++)t.has(e[i].seq)&&n.push(es(e[i]));return{text:n.join(`
|
|
277
|
+
`),count:n.length}}const Gi=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"});function Je(e){return e.toLocaleString("en-US")}function Rc(e){return Gi.format(e)}function Mc(e){const t=(Math.floor(e)%1e3+1e3)%1e3;return`${Gi.format(e)}.${String(t).padStart(3,"0")}`}const zc=[["tag:Wifi","lines whose tag contains Wifi"],["package:com.example","lines from that app"],["level:W","warnings and above"],["-tag:chatty","hide a tag"]];function $c(e){const t=u.useRef(null),n=u.useRef(null),i=u.useRef(null),[r,a]=u.useState(!1),[o,d]=u.useState(!1);u.useEffect(()=>{var m,g;o&&((g=(m=i.current)==null?void 0:m.querySelector('[role^="menuitem"]:not(:disabled)'))==null||g.focus())},[o]);const c=()=>{var m;d(!1),(m=n.current)==null||m.focus()},l=m=>()=>{c(),m()},h=e.status==="Offline"||e.status==="Denied";return s.jsxs("div",{className:"log-toolbar",children:[s.jsxs("div",{className:"log-status",role:"status",title:e.statusDetail??void 0,children:[s.jsx("span",{className:`log-live-dot${e.status==="Live"?" active":""}${h?" is-error":""}`,"aria-hidden":"true"}),e.status]}),s.jsxs("div",{className:"log-filter",children:[s.jsx(jn,{ref:e.filterRef,type:"text",className:"log-field log-filter-input",placeholder:"tag:Wifi package:com.example text",value:e.query,onChange:m=>e.onQueryChange(m.target.value),"aria-label":"Filter logs",spellCheck:!1,autoComplete:"off"}),s.jsxs("span",{className:"log-field-buttons",children:[e.query&&s.jsx("button",{type:"button",className:"log-field-btn",onClick:()=>e.onQueryChange(""),"aria-label":"Clear filter",title:"Clear filter",children:s.jsx(Fs,{size:12,"aria-hidden":"true"})}),s.jsx("button",{ref:t,type:"button",className:"log-field-btn",onClick:()=>a(m=>!m),"aria-label":"Filter syntax","aria-haspopup":"dialog","aria-expanded":r,title:"Filter syntax",children:s.jsx(pi,{size:13,"aria-hidden":"true"})})]}),s.jsx(Yt,{open:r,onClose:()=>a(!1),anchorRef:t,placement:"bottom-start",children:s.jsxs("div",{className:"log-syntax",children:[s.jsxs("p",{children:["Terms are combined. Quote a value with spaces: ",s.jsx("code",{children:'package:"Food Truck"'}),"."]}),s.jsx("dl",{children:zc.map(([m,g])=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:m})}),s.jsx("dd",{children:g})]},m))}),s.jsx("p",{children:"Other words search the message."})]})})]}),s.jsxs("div",{className:"log-find",children:[s.jsx(jn,{ref:e.findRef,type:"text",className:"log-field log-find-input",placeholder:"Find",value:e.find,onChange:m=>e.onFindChange(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),e.onStep(m.shiftKey?-1:1))},"aria-label":"Find in logs",spellCheck:!1,autoComplete:"off"}),e.find&&s.jsx("span",{className:"log-find-count","aria-live":"polite",children:e.hitCount?`${e.activeHit+1}/${e.hitCount}`:"0/0"})]}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(-1),disabled:!e.hitCount,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:s.jsx(Ws,{size:14,"aria-hidden":"true"})}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>e.onStep(1),disabled:!e.hitCount,"aria-label":"Next match",title:"Next match (Enter)",children:s.jsx(Bs,{size:14,"aria-hidden":"true"})}),s.jsx("span",{className:"log-toolbar-divider","aria-hidden":"true"}),s.jsxs("div",{className:"log-actions",children:[s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:e.onTogglePause,children:[e.following?s.jsx(Yr,{size:13,"aria-hidden":"true"}):s.jsx(Gr,{size:13,"aria-hidden":"true"}),e.following?"Pause":"Resume"]}),s.jsxs(U,{type:"button",variant:"secondary",size:"sm",className:`log-record${e.recording?" is-recording":""}`,onClick:e.onToggleRecording,"aria-pressed":e.recording,children:[e.recording?s.jsx(ai,{size:12,"aria-hidden":"true"}):s.jsx(Dr,{size:12,"aria-hidden":"true"}),e.recording?`Stop · ${Je(e.recordedLines)} lines`:"Record"]}),s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:e.onExport,"aria-label":"Export shown lines",title:"Export shown lines",children:s.jsx(fi,{size:14,"aria-hidden":"true"})}),s.jsx(U,{ref:n,type:"button",variant:"ghost",size:"icon",className:"log-icon-btn",onClick:()=>d(m=>!m),"aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,title:"More options",children:s.jsx(gi,{size:14,"aria-hidden":"true"})}),s.jsx(Yt,{open:o,onClose:c,anchorRef:n,placement:"bottom-end",children:s.jsx("div",{ref:i,children:s.jsxs(Us,{children:[s.jsx(je,{checkbox:!0,checked:e.caseSensitive,onClick:l(e.onToggleCase),children:"Match case"}),s.jsx(je,{checkbox:!0,checked:e.wrap,onClick:l(e.onToggleWrap),children:"Wrap long lines"}),s.jsx(li,{}),e.canCopySelected&&s.jsx(je,{onClick:l(e.onCopySelected),children:"Copy selected lines"}),s.jsx(je,{onClick:l(e.onClearLines),children:"Clear lines"})]})})})]})]})}function Ic({platform:e,counts:t,minLevel:n,shown:i,total:r,onChoose:a}){const o=jc(e,t,n),d=wc(o,n),c=d===null?-1:zt.indexOf(d);return s.jsxs("div",{className:"log-levels",children:[s.jsxs("div",{className:"log-level-buttons",role:"group","aria-label":"Log levels",children:[s.jsx(U,{type:"button",variant:"ghost",size:"sm",className:"log-level-btn","aria-label":"All levels","aria-pressed":d===null,onClick:()=>a(""),children:"All"}),o.map(({level:l,name:h})=>{const m=t[l],f=`${h} ${l==="F"?"only":"and above"}, ${Je(m)} ${h.toLowerCase()} line${m===1?"":"s"}`,v=c>=0&&zt.indexOf(l)>=c;return s.jsxs(U,{type:"button",variant:"ghost",size:"sm",className:`log-level-btn lvl-${l}${v?" is-included":""}${m?" has-lines":""}`,"aria-label":f,"aria-pressed":d===l,onClick:()=>a(d===l?"":l),children:[h,s.jsx("span",{className:"log-level-count",children:Je(m)})]},l)})]}),s.jsxs("span",{className:"log-shown",children:[Je(i)," of ",Je(r)," shown"]})]})}function _c(e){return typeof e=="object"?e.key:e}function Dc(e,t){const n=e.length;return new Proxy(e,{get(i,r,a){if(typeof r=="string"){const o=r.charCodeAt(0);if(o>=48&&o<=57){const d=+r;if(Number.isInteger(d)&&d>=0&&d<n){let c=i[d];if(typeof c!="object"){const l=t[d*2];c=i[d]={index:d,key:c,start:l,size:t[d*2+1],end:l+t[d*2+1],lane:0}}return c}}if(r==="length")return n}return Reflect.get(i,r,a)}})}function gt(e,t,n){let i=n.initialDeps??[],r,a=!0;function o(){const d=e();return(d.length!==i.length||d.some((l,h)=>i[h]!==l))&&(i=d,r=t(...d),n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(r),a=!1),r}return o.updateDeps=d=>{i=d},o}function Ln(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const On=(e,t)=>Math.abs(e-t)<1.01,Lc=(e,t,n)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(i)}})};let kt;const js=()=>{if(kt!==void 0)return kt;if(typeof navigator>"u")return kt=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return kt=!0;const e=navigator.maxTouchPoints;return kt=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Fn=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Oc=e=>e,Ji=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(i);for(let a=0;a<i;a++)r[a]=t+a;return r},Fc=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=o=>{const{width:d,height:c}=o;t({width:Math.round(d),height:Math.round(c)})};if(r(Fn(n)),!i.ResizeObserver)return()=>{};const a=new i.ResizeObserver(o=>{const d=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const l=c.borderBoxSize[0];if(l){r({width:l.inlineSize,height:l.blockSize});return}}r(Fn(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(d):d()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},ts={passive:!0},Pc=typeof window>"u"?!0:"onscrollend"in window,Uc=(e,t,n)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&Pc;let o=0;const d=a?null:Lc(r,()=>t(n(i),!1),e.options.isScrollingResetDelay),c=m=>()=>{o=n(i),d==null||d(),t(o,m)},l=c(!0),h=c(!1);return i.addEventListener("scroll",l,ts),a&&i.addEventListener("scrollend",h,ts),()=>{i.removeEventListener("scroll",l),a&&i.removeEventListener("scrollend",h),d==null||d.cancel()}},Bc=(e,t)=>Uc(e,t,n=>{const{horizontal:i,isRtl:r}=e.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),Wc=(e,t,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(e),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=n.indexFromElement(e),r=n.options.getItemKey(i),a=n.itemSizeCache.get(r);if(a!==void 0)return a}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},Vc=(e,{adjustments:t=0,behavior:n},i)=>{var r,a;(a=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[i.options.horizontal?"left":"top"]:e+t,behavior:n})},Zi=Vc;function Hc(e,t,n,i){if(t===0)return!1;const r=i(0),a=new Set;let o=0;for(;o<e;){const c=n(o);if(c===r)break;a.add(c),o++}const d=e-o;if(d===0||d>=t)return!1;for(let c=0;c<d;c++)if(i(c)!==n(o+c))return!1;for(let c=d;c<t;c++)if(a.has(i(c)))return!1;return!0}class Kc{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const o=()=>{const d=a.target,c=this.indexFromElement(d);if(!d.isConnected){this.observer.unobserve(d);for(const[l,h]of this.elementsCache)if(h===d){this.elementsCache.delete(l);break}return}this.isIndexInRange(c)&&this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(d,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var a;return(a=i())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=i())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Oc,rangeExtractor:Ji,onChange:()=>{},measureElement:Wc,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const g=n[m];g!==void 0&&(r[m]=g)}const a=this.options;let o=null,d=null,c=!1;if(a!==void 0&&a.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,g=r.count,f=this.getMeasurements(),v=((i=this._singleLaneMeasurements)==null?void 0:i.items)??f,S=C=>_c(v[C]),b=m>0?S(0):null,z=m>0?S(m-1):null;if(g!==m||m>0&&g>0&&(r.getItemKey(0)!==b||r.getItemKey(g-1)!==z)){c=!0;const C=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??f[0]:null;C&&(o=[C.key,this.getScrollOffset()-C.start]);const x=r.followOnAppend===!0?"auto":r.followOnAppend||null;x&&g>0&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||r.getItemKey(g-1)!==z)&&(g>m||Hc(m,g,S,r.getItemKey))&&(d=x)}}this.options=r,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let l=!1,h=0;if(o&&this.scrollOffset!==null){const[m,g]=o,f=this.getMeasurements(),{count:v,getItemKey:S}=this.options;let b=0;for(;b<v&&S(b)!==m;)b++;if(b<v){const z=f[b];if(z){const k=Math.max(0,z.start+g);!d&&k!==this.scrollOffset&&(h=k-this.scrollOffset,this.scrollOffset=k,l=!0)}}}(l||d)&&(this.pendingScrollAnchor=[l?o[0]:null,l?o[1]:0,d,h])},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=gt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n,i;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,d)=>{if(d&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(o-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=d?c===o?this.scrollDirection:c<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=d,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,d=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!js()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",d,ts),o.addEventListener("touchend",c,ts),this.unsubs.push(()=>{o.removeEventListener("touchstart",d),o.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[o,d,c,l]=a;o!==null&&!c&&(js()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):((i=this.scrollState)==null?void 0:i.behavior)==="smooth"&&!On(this.getScrollOffset()-l,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:n,maxAtWrite:i}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>i+.5&&(this._clampedAdjustment=n>r+.5?{target:n,maxAtWrite:r}:null,this._scrollToOffset(n,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;if(this._iosDeferredAdjustment<0&&n>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=gt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,a,o,d,c,l)=>(this.prevLanes!==void 0&&this.prevLanes!==d&&(this.lanesChangedFlag=!0),this.prevLanes=d,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=gt(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:a,enabled:o,lanes:d,laneAssignmentMode:c,gap:l},h)=>{var m;const g=this.itemSizeCache;if(!o)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const k of this.laneAssignments.keys())k>=n&&this.laneAssignments.delete(k);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(k=>{this.itemSizeCache.set(k.key,k.size)}));const f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),d===1){const k=n*2;let y=(m=this._singleLaneMeasurements)==null?void 0:m.flat;if(!y||y.length<k){const N=new Float64Array(k);y&&f>0&&N.set(y.subarray(0,f*2)),y=N}const C=f===0?new Array(n):this._singleLaneMeasurements.items.slice();let x;if(f===0)x=i+r;else{const N=f-1;x=y[N*2]+y[N*2+1]+l}for(let N=f;N<n;N++){const T=a(N);C[N]=T;const p=g.get(T),E=typeof p=="number"?p:this.options.estimateSize(N);y[N*2]=x,y[N*2+1]=E,x+=E+l}this._singleLaneMeasurements={flat:y,items:C};const A=Dc(C,y);return this.measurementsCache=A,A}const v=this.measurementsCache.slice(0,f),S=new Array(d).fill(void 0),b=new Float64Array(d);let z=0;for(let k=0;k<f;k++){const y=v[k];y&&(S[y.lane]===void 0&&z++,S[y.lane]=k,b[y.lane]=y.end)}for(let k=f;k<n;k++){const y=a(k),C=this.laneAssignments.get(k);let x,A;const N=c==="estimate"||g.has(y);if(C!==void 0&&this.options.lanes>1){x=C;const D=S[x],F=D!==void 0?v[D]:void 0;A=F?F.end+l:i+r}else if(z===d){let D=0,F=b[0],L=S[0];for(let W=1;W<d;W++){const G=b[W];(G<F||G===F&&S[W]<L)&&(D=W,F=G,L=S[W])}x=D,A=F+l,N&&this.laneAssignments.set(k,x)}else x=k%this.options.lanes,A=i+r,N&&this.laneAssignments.set(k,x);const T=g.get(y),p=typeof T=="number"?T:this.options.estimateSize(k),E=A+p;v[k]={index:k,start:A,size:p,end:E,key:y,lane:x},S[x]===void 0&&z++,S[x]=k,b[x]=E}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=gt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,a)=>n.length===0||i===0?(this.range=null,null):(this.range=Xc(n,i,r,a,a===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=gt(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,a,o)=>a===null||o===null?[]:n({startIndex:a,endIndex:o,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-a),d=Math.min(this.options.count-1,r+a);return n>=o&&n<=d}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,d)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(d))});return}const i=this.indexFromElement(n);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),a=this.elementsCache.get(r);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,a,o;if(!this.isIndexInRange(n))return;let d,c,l;const h=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&h!=null)l=this.options.getItemKey(n),c=h[n*2],d=h[n*2+1];else{const f=this.measurementsCache[n];if(!f)return;l=f.key,c=f.start,d=f.size}const m=this.itemSizeCache.get(l)??d,g=i-m;if(g!==0){const f=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=f?this.getTotalSize():0,S=this.getScrollOffset()+this.scrollAdjustments,z=!this.itemSizeCache.has(l)?c<S:c+m<=S&&this.scrollDirection!=="backward",k=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:l,start:c,size:d,end:c+d,lane:0},g,this):z);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(l,i),this.itemSizeCacheVersion++;let y=!1;f?y=this.applyScrollAdjustment(this.getTotalSize()-v):k&&(y=this.applyScrollAdjustment(g)),this.notify(y),this._retryClampedAdjustment()}},this.getVirtualItems=gt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let a=0,o=n.length;a<o;a++){const d=n[a],c=i[d];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{var i;const r=this.getMeasurements();if(r.length===0)return;const a=(i=this._singleLaneMeasurements)==null?void 0:i.flat,o=this.options.lanes===1&&a!=null,d=Qi(0,r.length-1,o?c=>a[c*2]:c=>Ln(r[c]).start,n);return Ln(r[d])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=n>=o+a?"end":"start"),i==="center"?n+=(r-a)/2:i==="end"&&(n-=a);const d=this.getMaxScrollOffset();return Math.max(Math.min(d,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(i==="auto")if(o.end>=a+r-this.options.scrollPaddingEnd)i="end";else if(o.start<=a+this.options.scrollPaddingStart)i="start";else return[a,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const d=i==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(d,i,o.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const a=this.getOffsetForAlignment(n,i),o=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getOffsetForIndex(n,i);if(!a)return;const[o,d]=a,c=this.now();this.scrollState={index:n,align:d,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,a=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n,i;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,d=(n=this._singleLaneMeasurements)==null?void 0:n.flat;d!=null?a=d[o*2]+d[o*2+1]:a=((i=r[o])==null?void 0:i.end)??0}else{const o=Array(this.options.lanes).fill(null);let d=r.length-1;for(;d>=0&&o.some(c=>c===null);){const c=r[d];o[c.lane]===null&&(o[c.lane]=c.end),d--}a=Math.max(...o.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){if(t===0)return!1;if(js()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=t,!1;{const i=this.getScrollOffset()+this.scrollAdjustments+t,r=this.scrollElement,a=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=a!==null&&i>a+.5?{target:i,maxAtWrite:a}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,a=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&On(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const d=this.getSize()||600,c=Math.abs(r-this.getScrollOffset()),l=this.scrollState.behavior==="smooth"&&c>d;this.scrollState.lastTargetOffset=r,l||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:l?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Qi=(e,t,n,i)=>{for(;e<=t;){const r=(e+t)/2|0,a=n(r);if(a<i)e=r+1;else if(a>i)t=r-1;else return r}return e>0?e-1:0};function qc(e,t,n){let i=0;for(;i<=t;){const r=(i+t)/2|0,a=e[r*2];if(a<n)i=r+1;else if(a>n)t=r-1;else return r}return i>0?i-1:0}function Xc(e,t,n,i,r){const a=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:a};if(i===1&&r!==null){const l=qc(r,a,n);let h=l;const m=n+t;for(;h<a&&r[h*2]+r[h*2+1]<m;)h++;return{startIndex:l,endIndex:h}}let d=Qi(0,a,l=>e[l].start,n),c=d;if(i===1)for(;c<a&&e[c].end<n+t;)c++;else if(i>1){const l=Array(i).fill(0);for(;c<a&&l.some(m=>m<n+t);){const m=e[c];l[m.lane]=m.end,c++}const h=Array(i).fill(n+t);for(;d>=0&&h.some(m=>m>=n);){const m=e[d];h[m.lane]=m.start,d--}d=Math.max(0,d-d%i),c=Math.min(a,c+(i-1-c%i))}return{startIndex:d,endIndex:c}}const ws=typeof document<"u"?u.useLayoutEffect:u.useEffect;function Yc({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...i}){const r=u.useReducer(m=>m+1,0)[1],a=u.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;const o=u.useRef(!1),d=m=>{const g=a.current;if(!g.enabled||!g.container)return;const f=m.getTotalSize();if(f!==g.lastSize){g.lastSize=f;const v=m.options.horizontal?"width":"height";g.container.style[v]=`${f}px`}},c=m=>{const g=a.current;if(!g.enabled||!g.container)return;d(m);const f=!!m.options.horizontal,v=g.mode==="transform",S=f?"left":"top",b=m.options.scrollMargin,z=m.getVirtualItems();for(const k of z){const y=k.start-b,C=m.elementsCache.get(k.key);C&&g.lastPositions.get(C)!==y&&(g.lastPositions.set(C,y),v?C.style.transform=f?`translate3d(${y}px, 0, 0)`:`translate3d(0, ${y}px, 0)`:C.style[S]=`${y}px`)}},l={...i,onChange:(m,g)=>{var f;const v=a.current;let S=!0;if(v.enabled){c(m);const b=m.range,z=v.prevRange;S=!z||z.isScrolling!==m.isScrolling||z.startIndex!==(b==null?void 0:b.startIndex)||z.endIndex!==(b==null?void 0:b.endIndex),S&&(v.prevRange=b?{startIndex:b.startIndex,endIndex:b.endIndex,isScrolling:m.isScrolling}:null)}S&&(e&&g&&!o.current?Es.flushSync(r):r()),(f=i.onChange)==null||f.call(i,m,g)}},[h]=u.useState(()=>{const m=new Kc(l),g=m.measureElement;return m.measureElement=f=>{o.current=!0;try{g(f)}finally{o.current=!1}},Object.assign(m,{containerRef:f=>{const v=a.current;if(v.container=f,v.lastSize=null,f&&v.enabled){const S=m.getTotalSize();v.lastSize=S;const b=m.options.horizontal?"width":"height";f.style[b]=`${S}px`}}})});return h.setOptions(l),ws(()=>h._didMount(),[]),ws(()=>(d(h),h._willUpdate())),ws(()=>{c(h)}),h}function Gc(e){return Yc({observeElementRect:Fc,observeElementOffset:Bc,scrollToFn:Zi,...e})}const Jc=/[.*+?^${}()|[\]\\]/g;function Zc(e,t,n){if(!t||!e)return[{text:e,hit:!1}];const i=new RegExp(t.replace(Jc,"\\$&"),n?"g":"gi"),r=[];let a=0,o;for(;(o=i.exec(e))!==null;)o.index>a&&r.push({text:e.slice(a,o.index),hit:!1}),r.push({text:o[0],hit:!0}),a=o.index+o[0].length;return r.length?(a<e.length&&r.push({text:e.slice(a),hit:!1}),r):[{text:e,hit:!1}]}const Pn=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Qc(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t>>>0}function ed(e){return e?Pn[Qc(e)%Pn.length]:"var(--text-muted)"}function Un({text:e,find:t,caseSensitive:n}){if(!t)return s.jsx(s.Fragment,{children:e});const i=Zc(e,t,n);return i.length===1&&!i[0].hit?s.jsx(s.Fragment,{children:e}):s.jsx(s.Fragment,{children:i.map((r,a)=>r.hit?s.jsx("mark",{className:"log-mark",children:r.text},a):s.jsx(u.Fragment,{children:r.text},a))})}const td=u.memo(function({record:t,index:n,setSize:i,start:r,id:a,selected:o,active:d,hit:c,activeHit:l,find:h,caseSensitive:m,measureRef:g}){const f=["log-row",`lvl-${t.level}`,t.synthetic?"is-synthetic":"",c?"is-hit":"",l?"is-active-hit":"",d?"is-active":""].filter(Boolean).join(" ");return s.jsxs("div",{ref:g,role:"option",id:a,"aria-selected":o,"aria-setsize":i,"aria-posinset":n+1,"data-index":n,"data-seq":t.seq,className:f,style:{transform:`translateY(${r}px)`},children:[s.jsx("span",{className:"log-time",children:Rc(t.ts)}),s.jsx("span",{className:"log-badge",children:t.level}),!t.synthetic&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"log-tag",title:t.tag,style:{color:ed(t.tag)},children:s.jsx(Un,{text:t.tag,find:h,caseSensitive:m})}),s.jsx("span",{className:"log-pkg",title:t.pkg,children:t.pkg??""})]}),s.jsx("span",{className:"log-msg",children:s.jsx(Un,{text:t.message,find:h,caseSensitive:m})})]})}),Bn=24,sd=1e3,nd=250,id=20,rd=38,Wn=720,ad=["PageUp","PageDown","Home"," "];let od=0;function ld(e){const[t,n]=u.useState(!0);return u.useLayoutEffect(()=>{const i=e.current;if(!i)return;n(i.offsetWidth>=Wn);const r=window.ResizeObserver;if(!r)return;const a=new r(o=>n(o[0].contentRect.width>=Wn));return a.observe(i),()=>a.disconnect()},[e]),t}const cd=u.forwardRef(function(t,n){const{records:i,wrap:r,find:a,caseSensitive:o,hits:d,activeHit:c,following:l,newLines:h}=t,m=u.useRef(null),[g]=u.useState(()=>`log-lines-${++od}`),f=u.useRef(null),v=u.useRef(l);v.current=l;const S=u.useRef(t);S.current=t;const b=ld(m),z=t.selection.active,k=u.useMemo(()=>z===null?-1:i.findIndex(w=>w.seq===z),[i,z]),y=Gc({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>b?id:rd,getItemKey:w=>i[w].seq,overscan:10,rangeExtractor:w=>{const O=Ji(w);return k>=0&&O.indexOf(k)<0&&(O.push(k),O.sort((K,_)=>K-_)),O},anchorTo:l?"start":"end",scrollToFn:(w,O,K)=>{const _=K.scrollElement,q=w+(O.adjustments??0);f.current=_?Math.max(0,Math.min(q,_.scrollHeight-_.clientHeight)):q,Zi(w,O,K)}}),C=u.useRef(`${r}|${b}`);u.useLayoutEffect(()=>{var O;const w=`${r}|${b}`;C.current!==w&&(C.current=w,y.measure(),(O=m.current)==null||O.querySelectorAll("[data-index]").forEach(K=>y.measureElement(K)))},[r,b,y]);const x=y.getTotalSize(),A=i.length?i[i.length-1].seq:-1,N=u.useRef(i);N.current=i;const T=u.useRef(null),[p,E]=u.useState(!1),D=u.useRef(()=>{});D.current=()=>{const w=m.current,O=N.current,K=w&&O.length?y.getVirtualItemForOffset(w.scrollTop):void 0;T.current=K&&O[K.index]?O[K.index].seq:null},u.useLayoutEffect(()=>{const w=T.current,O=t.oldestSeq;!v.current&&w!==null&&O!==null&&w<O&&(E(!0),y.scrollToOffset(0)),D.current()},[i,t.oldestSeq,y]),u.useEffect(()=>{l&&E(!1)},[l]);const F=u.useRef(0),L=u.useRef(!1);u.useLayoutEffect(()=>{!l||!i.length||L.current||Date.now()-F.current<nd||y.scrollToOffset(x)},[l,A,i.length,x,y]),u.useEffect(()=>{const w=m.current;if(!w)return;let O=w.scrollTop;const K=()=>{F.current=Date.now()},_=oe=>{oe.target===w&&(L.current=!0,K())},q=()=>{L.current&&K(),L.current=!1},ae=oe=>{ad.indexOf(oe.key)>=0&&K()},X=()=>{D.current();const oe=w.scrollTop,ue=oe>O;if(O=oe,f.current!==null&&Math.abs(oe-f.current)<2||(f.current=null,!L.current&&Date.now()-F.current>sd))return;const M=w.scrollHeight-w.clientHeight-oe;v.current&&M>Bn?S.current.onPause():!v.current&&ue&&M<=Bn&&S.current.onFollow()},ne={passive:!0};return w.addEventListener("wheel",K,ne),w.addEventListener("touchstart",K,ne),w.addEventListener("touchmove",K,ne),w.addEventListener("pointerdown",_),window.addEventListener("pointerup",q),w.addEventListener("keydown",ae),w.addEventListener("scroll",X,ne),()=>{w.removeEventListener("wheel",K),w.removeEventListener("touchstart",K),w.removeEventListener("touchmove",K),w.removeEventListener("pointerdown",_),window.removeEventListener("pointerup",q),w.removeEventListener("keydown",ae),w.removeEventListener("scroll",X)}},[]),u.useImperativeHandle(n,()=>({reveal:w=>y.scrollToIndex(w,{align:"center"}),focus:()=>{var w;return(w=m.current)==null?void 0:w.focus({preventScroll:!0})}}),[y]);const W=w=>`${g}-${w}`,G=w=>{var q,ae,X,ne;const O=w.target.closest("[data-seq]");if(!O||!((q=m.current)!=null&&q.contains(O))||(((X=(ae=window.getSelection)==null?void 0:ae.call(window))==null?void 0:X.toString())??"")!=="")return;const K=Number(O.getAttribute("data-seq")),_=Ec(t.selection,K,i.map(oe=>oe.seq),{range:w.shiftKey,toggle:w.metaKey||w.ctrlKey});t.onSelect(_,i.find(oe=>oe.seq===K)??null,"click"),_.selected.size&&v.current&&t.onPause(),w.shiftKey&&((ne=m.current)==null||ne.focus({preventScroll:!0}))},ee=w=>{w.shiftKey&&w.preventDefault()},V=w=>{var K,_;const O=w.metaKey||w.ctrlKey;if((w.key==="ArrowDown"||w.key==="ArrowUp")&&!O&&!w.altKey){w.preventDefault();const q=i.map(ne=>ne.seq);if(!q.length)return;const ae=Tc(t.selection,q,w.key==="ArrowDown"?1:-1,w.shiftKey),X=ae.active===null?-1:q.indexOf(ae.active);if(t.onSelect(ae,X>=0?i[X]:null,"key"),X<0)return;X!==q.length-1&&v.current&&t.onPause(),y.scrollToIndex(X,{align:"auto"})}else if(w.key==="Enter"&&!O){const q=k>=0?i[k]:void 0;if(!q)return;w.preventDefault(),t.onOpenDetails(q)}else if(w.key==="End"&&!O)w.preventDefault(),t.onFollow(),y.scrollToOffset(x);else if(O&&!w.altKey&&(w.key==="c"||w.key==="C")){if(!t.selection.selected.size||(((_=(K=window.getSelection)==null?void 0:K.call(window))==null?void 0:_.toString())??"")!=="")return;w.preventDefault(),t.onCopy()}};return s.jsxs("div",{className:"log-list-wrap",children:[p&&!l&&s.jsx("div",{className:"log-dropped-note",children:"Older lines were dropped while paused"}),s.jsx("div",{ref:m,role:"listbox","aria-label":"Log lines","aria-multiselectable":"true",tabIndex:0,"aria-activedescendant":k>=0?W(i[k].seq):void 0,className:`log-list${r?"":" is-nowrap"}`,onClick:G,onMouseDown:ee,onKeyDown:V,children:s.jsx("div",{className:"log-list-sizer",style:{height:x},children:y.getVirtualItems().map(w=>{const O=i[w.index];return s.jsx(td,{record:O,index:w.index,setSize:i.length,start:w.start,id:W(O.seq),selected:t.selection.selected.has(O.seq),active:t.selection.active===O.seq,hit:d.has(w.index),activeHit:c===w.index,find:a,caseSensitive:o,measureRef:y.measureElement},O.seq)})})}),!l&&s.jsx(U,{type:"button",variant:"secondary",size:"sm",className:"log-new-pill",onClick:()=>S.current.onFollow(),children:h>0?`${Je(h)} new line${h===1?"":"s"} · Jump to latest`:"Jump to latest"})]})});function dd({record:e,platform:t,inBuffer:n,onCopyLine:i,onCopyMessage:r,onShowOnlyTag:a,onHideTag:o,onShowOnlyApp:d,onClose:c}){const l=!!e.synthetic;return s.jsxs("section",{className:"log-details","aria-label":"Line details",children:[s.jsxs("header",{className:"log-details-head",children:[s.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"log-details-close","aria-label":"Close details",title:"Close details (Esc)",onClick:c,children:s.jsx(Fs,{size:14,"aria-hidden":"true"})}),s.jsx("h3",{className:"log-details-title",children:l?"Added by Xenon":`${qi(e.level,t)} · ${e.tag}`})]}),l&&s.jsx("p",{className:"log-details-note",children:"Xenon added this line. It didn’t come from the phone."}),s.jsxs("dl",{className:"log-details-fields",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Time"}),s.jsx("dd",{children:Mc(e.ts)})]}),!l&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"App"}),s.jsx("dd",{children:e.pkg??"Unknown"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Process ID"}),s.jsx("dd",{children:e.pid})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Thread ID"}),s.jsx("dd",{children:e.tid})]})]})]}),!n&&s.jsx("p",{className:"log-details-left",children:"This line has left the buffer"}),s.jsx("pre",{className:"log-details-msg",children:e.message}),s.jsxs("div",{className:"log-details-actions",children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:i,children:"Copy line"}),!l&&s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:r,children:"Copy message"}),e.tag&&s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:a,children:"Show only this tag"}),s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:o,children:"Hide this tag"})]}),e.pkg&&s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:d,children:"Show only this app"})]})]})]})}function Vn(e,t){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),i=document.createElement("a");i.href=n,i.download=t,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),0)}async function ud(e){var i;if(await Ks(e))return!0;if(typeof document.execCommand!="function")return!1;const t=document.activeElement,n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n),(i=t==null?void 0:t.focus)==null||i.call(t,{preventScroll:!0})}}const hd=e=>e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.isContentEditable;function md({udid:e,platform:t}){const n=(t||"").toLowerCase(),i=n==="ios",r=n==="android"||i,a=i?"ios":"android",{toast:o}=Ie(),[d,c]=u.useState(""),l=u.useMemo(()=>i?yc(d):void 0,[i,d]),{records:h,connected:m,clear:g,deniedReason:f,exhausted:v,retry:S}=mc(e,r,l),[b,z]=u.useState(!1),[k,y]=u.useState(!0),[C,x]=u.useState(""),[A,N]=u.useState(0),[T,p]=u.useState(bs),[E,D]=u.useState(null),F=u.useRef(null),L=u.useRef(null),W=u.useRef(null),G=u.useRef(null),ee=u.useRef(h);ee.current=h;const[V,w]=u.useState(!0),[O,K]=u.useState(null),_=u.useRef(V);_.current=V;const q=u.useCallback(()=>{if(!_.current)return;_.current=!1;const I=ee.current;K(I.length?I[I.length-1].seq:-1),w(!1)},[]),ae=u.useCallback(()=>{_.current=!0,K(null),w(!0)},[]),X=u.useRef(null),[ne,oe]=u.useState(!1),[ue,M]=u.useState(0),le=u.useRef(-1),Q=u.useMemo(()=>Bi(d,{caseSensitive:b}),[d,b]),ie=u.useMemo(()=>h.filter(I=>Wi(I,Q)),[h,Q]),Se=u.useMemo(()=>bc(h,Q),[h,Q]),he=u.useMemo(()=>{if(!C)return[];const I=b?C:C.toLowerCase(),H=[];return ie.forEach((te,me)=>{(b?`${te.tag} ${te.message}`:`${te.tag} ${te.message}`.toLowerCase()).includes(I)&&H.push(me)}),H},[ie,C,b]),ve=he.length?Math.min(A,he.length-1):0,Ne=u.useMemo(()=>new Set(he),[he]),_e=u.useCallback(I=>{var te;if(!he.length)return;const H=(ve+I+he.length)%he.length;N(H),q(),(te=G.current)==null||te.reveal(he[H])},[he,ve,q]),De=u.useMemo(()=>{if(O===null)return 0;let I=0;for(let H=ie.length-1;H>=0&&ie[H].seq>O;H--)I++;return I},[ie,O]),pe=u.useCallback(()=>{if(!ie.length){o("No lines to export","info");return}Vn(ie.map(es).join(`
|
|
278
|
+
`),`logcat-${e}-${Date.now()}.txt`)},[ie,e,o]);u.useEffect(()=>{const I=X.current;if(!I||!h.length)return;const H=h.filter(me=>me.seq>le.current);if(!H.length)return;const te=le.current+1;le.current>=0&&H[0].seq>te&&(I.dropped+=H[0].seq-te),Sc(I,H),le.current=H[H.length-1].seq,M(I.lines.length)},[h]);const et=u.useCallback(()=>{const I=X.current;if(!I){le.current=h.length?h[h.length-1].seq:-1,X.current=kc(Date.now()),M(0),oe(!0);return}const H=Cc(I,Date.now(),e);X.current=null,oe(!1),M(0),Vn(H,Nc(e,I.startedAt))},[h,e]),[Le,Ee]=u.useState(!1),He=Pi(()=>{});oc(ne?()=>X.current?(Ee(!0),!0):!1:null);const xt=()=>{Ee(!1),X.current&&et(),He()},Ke=u.useCallback(async(I,H)=>{await ud(I)?o(H,"success"):o("Your browser blocked copying here.","error")},[o]),qe=u.useMemo(()=>{if(!T.selected.size)return 0;let I=0;for(let H=0;H<ie.length;H++)T.selected.has(ie[H].seq)&&I++;return I},[ie,T.selected]),Xe=u.useCallback(()=>{const{text:I,count:H}=Ac(ie,T.selected);H&&Ke(I,`Copied ${Je(H)} line${H===1?"":"s"}`)},[ie,T.selected,Ke]),bt=u.useCallback((I,H,te)=>{p(I),D(te==="click"?H:me=>me&&H?H:me)},[]),ht=u.useCallback(()=>{g(),p(bs)},[g]),tt=I=>{var te,me,fe;const H=I.metaKey||I.ctrlKey;I.key==="/"&&!H&&!hd(I.target)?(I.preventDefault(),(te=L.current)==null||te.focus()):H&&!I.altKey&&(I.key==="f"||I.key==="F")?(I.preventDefault(),(me=W.current)==null||me.focus(),(fe=W.current)==null||fe.select()):I.key==="Escape"&&(E?(I.preventDefault(),D(null)):T.selected.size&&(I.preventDefault(),p(bs)))},mt=u.useRef(tt);if(mt.current=tt,u.useEffect(()=>{const I=F.current;if(!I)return;const H=te=>mt.current(te);return I.addEventListener("keydown",H),()=>I.removeEventListener("keydown",H)},[r]),!r)return s.jsx("div",{className:"logcat-root",children:s.jsx(Xr,{title:"Live logs are not available here",description:"Live logs work on Android and iOS phones."})});const Me=f?"Denied":v?"Offline":m?"Live":"Connecting",re=!!E&&h.length>0&&E.seq>=h[0].seq&&E.seq<=h[h.length-1].seq;let se=null;ie.length||(h.length?se=s.jsxs("div",{className:"log-state",children:[s.jsxs("p",{children:["No lines match ",s.jsx("code",{children:d})]}),s.jsx(U,{type:"button",variant:"secondary",size:"sm",onClick:()=>c(""),children:"Clear filter"})]}):Me==="Connecting"?se=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Waiting for the phone’s first log line…"})}):Me==="Live"&&(se=s.jsx("div",{className:"log-state",children:s.jsx("p",{children:"Connected. Lines appear here as the phone logs them."})})));const ge=s.jsxs(U,{type:"button",variant:"secondary",size:"sm",onClick:S,children:[s.jsx(Et,{size:13,"aria-hidden":"true"})," Reconnect"]});return s.jsxs("div",{className:"logcat-root",ref:F,children:[s.jsx($c,{status:Me,statusDetail:f,query:d,onQueryChange:c,filterRef:L,find:C,onFindChange:I=>{x(I),N(0)},findRef:W,hitCount:he.length,activeHit:ve,onStep:_e,following:V,onTogglePause:V?q:ae,recording:ne,recordedLines:ue,onToggleRecording:et,onExport:pe,caseSensitive:b,onToggleCase:()=>z(I=>!I),wrap:k,onToggleWrap:()=>y(I=>!I),canCopySelected:qe>0,onCopySelected:Xe,onClearLines:ht}),s.jsx(Ic,{platform:a,counts:Se,minLevel:Q.minLevel,shown:ie.length,total:h.length,onChoose:I=>c(gc(d,I))}),s.jsxs("div",{className:"log-body theme-dark",children:[f&&s.jsxs("div",{className:"log-banner is-denied",role:"alert",children:[s.jsx(Be,{size:14,"aria-hidden":"true"}),s.jsxs("span",{children:["Access denied — ",f]}),ge]}),!f&&v&&s.jsxs("div",{className:"log-banner is-exhausted",role:"alert",children:[s.jsx(Be,{size:14,"aria-hidden":"true"}),s.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect to try again."}),ge]}),s.jsxs("div",{className:"log-main",children:[s.jsx(cd,{ref:G,records:ie,oldestSeq:h.length?h[0].seq:null,wrap:k,find:C,caseSensitive:b,hits:Ne,activeHit:he.length?he[ve]:null,following:V,newLines:De,onPause:q,onFollow:ae,selection:T,onSelect:bt,onOpenDetails:D,onCopy:Xe}),se]}),E&&s.jsx(dd,{record:E,platform:a,inBuffer:re,onCopyLine:()=>Ke(es(E),"Copied the line"),onCopyMessage:()=>Ke(E.message,"Copied the message"),onShowOnlyTag:()=>c(In(d,"tag",E.tag)),onHideTag:()=>c(pc(d,"tag",E.tag)),onShowOnlyApp:()=>c(In(d,"package",E.pkg??"")),onClose:()=>D(null)})]}),s.jsx(rs,{open:Le,title:"Stop recording?",onClose:()=>Ee(!1),footer:s.jsxs(s.Fragment,{children:[s.jsx(U,{type:"button",variant:"secondary",onClick:()=>Ee(!1),autoFocus:!0,children:"Keep recording"}),s.jsx(U,{type:"button",onClick:xt,children:"Save and close"})]}),children:s.jsxs("p",{children:[Je(ue)," line",ue===1?"":"s"," recorded so far. Closing device control ends the recording. Save and close downloads it first."]})})]})}function er(e){const t=e==null?void 0:e.message;return typeof t=="string"?t.trim():""}function Ae(e,t){const n=er(t);return n?`Couldn’t ${e}: ${n}`:`Couldn’t ${e}.`}function fd(e,t){return e==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Ae("read the clipboard",t)}function pd(e,t){const n=t.trim().toLowerCase();return[...e].sort((i,r)=>i.localeCompare(r)).filter(i=>!n||i.toLowerCase().includes(n))}const gd=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function vd(e){return gd.test(e.trim())}function qs(e){const t=(e||"").toLowerCase();return t==="android"?"android":t==="ios"||t==="tvos"?"ios":null}function yd(e,t){const n=qs(t);return n?e.filter(i=>(i.platform||"").toLowerCase()===n):[]}function xd(e){return[e.version,e.packageName].filter(Boolean).join(" · ")}function bd(e){return qs(e)==="android"?"Android":"iOS"}function jd(e){return qs(e)==="android"?".apk":".ipa,.app"}function wd({udid:e,platform:t,deviceName:n}){const{toast:i,removeToast:r}=Ie(),a=$t(),[o,d]=u.useState([]),[c,l]=u.useState("loading"),[h,m]=u.useState(""),[g,f]=u.useState(""),[v,S]=u.useState(!1),[b,z]=u.useState(!1),[k,y]=u.useState([]),[C,x]=u.useState("loading"),[A,N]=u.useState(null),[T,p]=u.useState(null),E=u.useRef(null),D=u.useRef(null),F=u.useRef(null),L=u.useCallback(async()=>{l("loading");try{const M=await Y.listApps(e);d(Array.isArray(M)?M:[]),l("ready")}catch(M){m(er(M)),l("error")}},[e]);u.useEffect(()=>{L()},[L]);const W=M=>setTimeout(L,M);u.useEffect(()=>{if(!T)return;const M=setTimeout(()=>p(null),1500);return()=>clearTimeout(M)},[T]);const G=async()=>{x("loading");try{const M=await Y.getApps();y(Array.isArray(M)?M:[]),x("ready")}catch{x("error")}},ee=()=>{v||(z(!0),G())},V=()=>{var M;z(!1),(M=E.current)==null||M.focus()};u.useEffect(()=>{var le;if(!b||C==="loading")return;const M=(le=D.current)==null?void 0:le.querySelector('[role="menuitem"]:not(:disabled)');M==null||M.focus()},[b,C]);const w=async(M,le)=>{S(!0);const Q=i(`Installing ${M} on ${n}…`,"loading",0);try{const ie=await le();ie!=null&&ie.success?(i(`Installed ${M} on ${n}`,"success"),W(5e3)):i(Ae(`install ${M}`,{message:ie==null?void 0:ie.error}),"error")}catch(ie){i(Ae(`install ${M}`,ie),"error")}finally{r(Q),S(!1)}},O=M=>{V(),w(M.name,()=>Y.installRepositoryApp(e,M.id))},K=M=>{var Q;const le=(Q=M.target.files)==null?void 0:Q[0];M.target.value="",le&&w(le.name,()=>Y.uploadAndInstallApp(e,le))},_=async()=>{const M=A;if(N(null),!M)return;const le=i(`Uninstalling ${M} from ${n}…`,"loading",0);try{await Y.uninstallApp(e,M),i(`Uninstalled ${M} from ${n}`,"success"),W(3e3)}catch(Q){i(Ae(`uninstall ${M}`,Q),"error")}finally{r(le)}},q=async(M,le)=>{var ie,Se;if(await Ks(M)){p(M);return}const Q=(ie=le.closest("li"))==null?void 0:ie.querySelector(".actions-app-id");Q&&((Se=window.getSelection())==null||Se.selectAllChildren(Q)),i(Ui,"info")},ae=pd(o,g),X=g.trim(),ne=c==="ready"&&ae.length===0&&vd(X)&&!o.includes(X),oe=yd(k,t),ue=(M,le)=>s.jsxs("li",{className:"actions-app-row",children:[s.jsx("span",{className:"actions-app-id",children:M}),le&&s.jsx("span",{className:"actions-app-note",children:le}),s.jsxs("span",{className:"actions-app-tools",children:[s.jsx(U,{variant:"ghost",size:"icon","aria-label":T===M?"Copied":`Copy ${M}`,title:T===M?"Copied":"Copy package ID",onClick:Q=>q(M,Q.currentTarget),children:T===M?s.jsx(At,{size:13,"aria-hidden":"true"}):s.jsx($e,{size:13,"aria-hidden":"true"})}),s.jsx(U,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${M}`,onClick:()=>N(M),children:"Uninstall"})]})]},M);return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[s.jsxs("div",{className:"actions-section-head",children:[s.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[s.jsx(Qa,{size:15,"aria-hidden":"true"})," Apps"]}),s.jsxs("div",{className:"actions-section-tools",children:[s.jsxs(U,{ref:E,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":b,"aria-disabled":v||void 0,onClick:ee,children:[v?s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(La,{size:13,"aria-hidden":"true"}),"Install from library"]}),s.jsxs(U,{variant:"secondary",size:"sm","aria-disabled":v||void 0,onClick:()=>{var M;return!v&&((M=F.current)==null?void 0:M.click())},children:[s.jsx(Jr,{size:13,"aria-hidden":"true"})," Upload file"]}),s.jsx("input",{ref:F,type:"file",hidden:!0,"aria-label":"App file to upload",accept:jd(t),onChange:K})]})]}),s.jsx(Yt,{open:b,onClose:V,anchorRef:E,placement:"bottom-end",children:s.jsx("div",{ref:D,className:"actions-library-menu",children:s.jsxs(Us,{children:[C==="loading"&&s.jsx(je,{disabled:!0,onClick:()=>{},children:"Loading…"}),C==="error"&&s.jsx(je,{onClick:G,children:"Couldn’t load the library. Retry"}),C==="ready"&&oe.length===0&&s.jsxs(s.Fragment,{children:[s.jsxs(je,{disabled:!0,onClick:()=>{},children:["No ",bd(t)," apps in the library yet"]}),s.jsx(je,{onClick:()=>a("/apps"),children:"Open the Apps library"})]}),C==="ready"&&oe.map(M=>s.jsx(je,{note:xd(M)||void 0,onClick:()=>O(M),children:M.name},M.id))]})})}),s.jsxs("div",{className:"actions-apps-tools",children:[s.jsxs("div",{className:"actions-search",children:[s.jsx(Ps,{size:13,className:"actions-search-icon","aria-hidden":"true"}),s.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${o.length} installed apps`,value:g,onChange:M=>f(M.target.value)})]}),s.jsx(U,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:L,children:s.jsx(Vt,{size:13,"aria-hidden":"true"})})]}),c==="loading"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),c==="error"&&s.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",h?`: ${h}`:".",s.jsx(U,{variant:"secondary",size:"sm",onClick:L,children:"Retry"})]}),c==="ready"&&o.length===0&&s.jsx("p",{className:"actions-list-note",children:"No apps installed"}),c==="ready"&&o.length>0&&ae.length===0&&!ne&&s.jsxs("p",{className:"actions-list-note",children:["No apps match “",X,"”"]}),s.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[ae.map(M=>ue(M)),ne&&ue(X,"Not in the list")]}),s.jsx(rs,{open:A!==null,title:"Uninstall app?",onClose:()=>N(null),footer:s.jsxs(s.Fragment,{children:[s.jsx(U,{variant:"secondary",onClick:()=>N(null),children:"Cancel"}),s.jsx(U,{variant:"danger",onClick:_,children:"Uninstall"})]}),children:s.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",s.jsx("code",{children:A})," from"," ",s.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const kd=[{direction:"up",Icon:Ws},{direction:"down",Icon:Bs},{direction:"left",Icon:Qr},{direction:"right",Icon:ea}];function Sd({onSwipe:e}){return s.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[s.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[s.jsx(Ma,{size:15,"aria-hidden":"true"})," Swipe"]}),s.jsx("div",{className:"actions-swipe-buttons",children:kd.map(({direction:t,Icon:n})=>s.jsx(U,{variant:"secondary",size:"icon","aria-label":`Swipe ${t}`,title:`Swipe ${t}`,onClick:()=>e(t),children:s.jsx(n,{size:14,"aria-hidden":"true"})},t))})]})}function Cd(e,t,n){const i=t/2,r=n/2,a=t*.4,o=n*.4,[d,c,l,h]={up:[i,r+o,i,r-o],down:[i,r-o,i,r+o],left:[i+a,r,i-a,r],right:[i-a,r,i+a,r]}[e].map(Math.round);return{startX:d,startY:c,endX:l,endY:h}}function Nd({udid:e,platform:t}){const n=t!=="android",{toast:i}=Ie(),[r,a]=u.useState(""),[o,d]=u.useState(!1),[c,l]=u.useState(""),[h,m]=u.useState(null),[g,f]=u.useState(""),[v,S]=u.useState(!1),b=u.useRef(null);u.useEffect(()=>{if(!g)return;const x=setTimeout(()=>f(""),2e3);return()=>clearTimeout(x)},[g]),u.useEffect(()=>{if(!v)return;const x=setTimeout(()=>S(!1),1500);return()=>clearTimeout(x)},[v]);const z=async()=>{if(!(!r.trim()||o)){d(!0);try{await Y.typeText(e,r),a(""),f("Sent")}catch(x){i(Ae("send the text",x),"error")}finally{d(!1)}}},k=async()=>{m("read");try{const x=await Y.getClipboard(e),A=typeof(x==null?void 0:x.content)=="string"?x.content:"";l(A),A||f("The device clipboard is empty")}catch(x){i(fd(t,x),"error")}finally{m(null)}},y=async()=>{if(c){m("write");try{await Y.setClipboard(e,c),f("Written to the device")}catch(x){i(Ae("write the clipboard",x),"error")}finally{m(null)}}},C=async()=>{var x;if(await Ks(c)){S(!0);return}(x=b.current)==null||x.select(),i(Ui,"info")};return s.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[s.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[s.jsx(_a,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),s.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:r,onChange:x=>a(x.target.value),onKeyDown:x=>x.key==="Enter"&&z()}),s.jsxs(U,{variant:"secondary",size:"md",onClick:z,disabled:!r.trim()||o,children:[o&&s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),s.jsxs("div",{className:"actions-field-row",children:[s.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),s.jsx("input",{id:"actions-clipboard",ref:b,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:c,onChange:x=>l(x.target.value)}),s.jsxs(U,{variant:"secondary",size:"md",onClick:k,disabled:h!==null,children:[h==="read"&&s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&s.jsxs(U,{variant:"secondary",size:"md",onClick:y,disabled:!c||h!==null,children:[h==="write"&&s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),s.jsx(U,{variant:"ghost",size:"icon","aria-label":v?"Copied":"Copy clipboard text",title:v?"Copied":"Copy to your clipboard",onClick:C,disabled:!c,children:v?s.jsx(At,{size:14,"aria-hidden":"true"}):s.jsx($e,{size:14,"aria-hidden":"true"})})]}),!n&&s.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),s.jsx("p",{className:"actions-status",role:"status",children:g})]})}function Ed({udid:e,platform:t,deviceName:n,screenWidth:i,screenHeight:r}){const{toast:a}=Ie(),o=async d=>{const c=Cd(d,i,r);try{await Y.swipe(e,c.startX,c.startY,c.endX,c.endY)}catch(l){a(Ae(`swipe ${d}`,l),"error")}};return s.jsxs("div",{className:"actions-panel",children:[s.jsx(wd,{udid:e,platform:t,deviceName:n}),s.jsx(Nd,{udid:e,platform:t}),s.jsx(Sd,{onSwipe:o})]})}const Td=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];function Ad({shape:e,color:t,marks:n,saving:i,onShape:r,onColor:a,onUndo:o,onClear:d,onCancel:c,onSave:l}){return s.jsxs("div",{className:"shots-actions",role:"toolbar","aria-label":"Annotate",children:[s.jsxs("div",{className:"shots-shapes",children:[Td.map(h=>s.jsx(U,{variant:"secondary",size:"sm","aria-pressed":e===h.id,className:e===h.id?"is-pressed":void 0,onClick:()=>r(h.id),children:h.label},h.id)),s.jsx("input",{type:"color",className:"shots-color",value:t,onChange:h=>a(h.target.value),"aria-label":"Mark colour",title:"Mark colour"})]}),s.jsx(U,{variant:"ghost",size:"sm",onClick:o,disabled:!n||i,children:"Undo mark"}),s.jsx(U,{variant:"ghost",size:"sm",onClick:d,disabled:!n||i,children:"Clear marks"}),s.jsx("span",{className:"shots-actions-gap"}),s.jsx(U,{variant:"secondary",size:"sm",onClick:c,disabled:i,children:"Cancel"}),s.jsxs(U,{size:"sm",onClick:l,disabled:!n||i,children:[i&&s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Save copy"]})]})}function dt(e){return`Screenshot ${e.n}`}const Ze=e=>String(e).padStart(2,"0");function Hn(e){return`${Ze(e.getHours())}:${Ze(e.getMinutes())}:${Ze(e.getSeconds())}`}function Rd(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Is(e,t=Date.now()){const n=new Date(e);return Rd(n,new Date(t))?`Today ${Hn(n)}`:`${n.toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})} ${Hn(n)}`}function Md(e,t){return!e||!t?"":e>t?"Landscape":"Portrait"}function zd(e){return e<1024?`${Math.round(e)} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function tr(e,t=Date.now()){const n=[dt(e)];e.markedFrom!==void 0&&n.push(`marked copy of ${e.markedFrom}`),n.push(Is(e.takenAt,t));const i=Md(e.width,e.height);return i&&n.push(i,`${e.width} × ${e.height}`),n.push(zd(e.bytes)),n.join(" · ")}function sr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"device"}function nr(e){const t=new Date(e);return`${t.getFullYear()}-${Ze(t.getMonth()+1)}-${Ze(t.getDate())}`}function ir(e,t){const n=new Date(t.takenAt),i=`${Ze(n.getHours())}-${Ze(n.getMinutes())}-${Ze(n.getSeconds())}`,r=t.markedFrom!==void 0?"-marked":"";return`${sr(e)}-screenshot-${t.n}${r}-${nr(t.takenAt)}-${i}.png`}function $d(e,t=Date.now()){return`${sr(e)}-screenshots-${nr(t)}.zip`}async function Id(e){const t=globalThis.ClipboardItem,n=navigator.clipboard;if(!t||typeof(n==null?void 0:n.write)!="function")return!1;try{const i=e.type==="image/png"?e:new Blob([e],{type:"image/png"});return await n.write([new t({"image/png":i})]),!0}catch{return!1}}var we=Uint8Array,Ce=Uint16Array,Xs=Int32Array,Ys=new we([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Gs=new we([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Kn=new we([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rr=function(e,t){for(var n=new Ce(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];for(var r=new Xs(n[30]),i=1;i<30;++i)for(var a=n[i];a<n[i+1];++a)r[a]=a-n[i]<<5|i;return{b:n,r}},ar=rr(Ys,2),_d=ar.b,_s=ar.r;_d[28]=258,_s[258]=28;var Dd=rr(Gs,0),qn=Dd.r,Ds=new Ce(32768);for(var de=0;de<32768;++de){var Ge=(de&43690)>>1|(de&21845)<<1;Ge=(Ge&52428)>>2|(Ge&13107)<<2,Ge=(Ge&61680)>>4|(Ge&3855)<<4,Ds[de]=((Ge&65280)>>8|(Ge&255)<<8)>>1}var Tt=function(e,t,n){for(var i=e.length,r=0,a=new Ce(t);r<i;++r)e[r]&&++a[e[r]-1];var o=new Ce(t);for(r=1;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;var d;if(n){d=new Ce(1<<t);var c=15-t;for(r=0;r<i;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],m=o[e[r]-1]++<<h,g=m|(1<<h)-1;m<=g;++m)d[Ds[m]>>c]=l}else for(d=new Ce(i),r=0;r<i;++r)e[r]&&(d[r]=Ds[o[e[r]-1]++]>>15-e[r]);return d},ut=new we(288);for(var de=0;de<144;++de)ut[de]=8;for(var de=144;de<256;++de)ut[de]=9;for(var de=256;de<280;++de)ut[de]=7;for(var de=280;de<288;++de)ut[de]=8;var ss=new we(32);for(var de=0;de<32;++de)ss[de]=5;var Ld=Tt(ut,9,0),Od=Tt(ss,5,0),or=function(e){return(e+7)/8|0},lr=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new we(e.subarray(t,n))},Fd=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],as=function(e,t,n){var i=new Error(t||Fd[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,as),!n)throw i;return i},Ue=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8},St=function(e,t,n){n<<=t&7;var i=t/8|0;e[i]|=n,e[i+1]|=n>>8,e[i+2]|=n>>16},ks=function(e,t){for(var n=[],i=0;i<e.length;++i)e[i]&&n.push({s:i,f:e[i]});var r=n.length,a=n.slice();if(!r)return{t:dr,l:0};if(r==1){var o=new we(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(x,A){return x.f-A.f}),n.push({s:-1,f:25001});var d=n[0],c=n[1],l=0,h=1,m=2;for(n[0]={s:-1,f:d.f+c.f,l:d,r:c};h!=r-1;)d=n[n[l].f<n[m].f?l++:m++],c=n[l!=h&&n[l].f<n[m].f?l++:m++],n[h++]={s:-1,f:d.f+c.f,l:d,r:c};for(var g=a[0].s,i=1;i<r;++i)a[i].s>g&&(g=a[i].s);var f=new Ce(g+1),v=Ls(n[h-1],f,0);if(v>t){var i=0,S=0,b=v-t,z=1<<b;for(a.sort(function(A,N){return f[N.s]-f[A.s]||A.f-N.f});i<r;++i){var k=a[i].s;if(f[k]>t)S+=z-(1<<v-f[k]),f[k]=t;else break}for(S>>=b;S>0;){var y=a[i].s;f[y]<t?S-=1<<t-f[y]++-1:++i}for(;i>=0&&S;--i){var C=a[i].s;f[C]==t&&(--f[C],++S)}v=t}return{t:new we(f),l:v}},Ls=function(e,t,n){return e.s==-1?Math.max(Ls(e.l,t,n+1),Ls(e.r,t,n+1)):t[e.s]=n},Xn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Ce(++t),i=0,r=e[0],a=1,o=function(c){n[i++]=c},d=1;d<=t;++d)if(e[d]==r&&d!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(r),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(r);a=1,r=e[d]}return{c:n.subarray(0,i),n:t}},Ct=function(e,t){for(var n=0,i=0;i<t.length;++i)n+=e[i]*t[i];return n},cr=function(e,t,n){var i=n.length,r=or(t+2);e[r]=i&255,e[r+1]=i>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<i;++a)e[r+a+4]=n[a];return(r+4+i)*8},Yn=function(e,t,n,i,r,a,o,d,c,l,h){Ue(t,h++,n),++r[256];for(var m=ks(r,15),g=m.t,f=m.l,v=ks(a,15),S=v.t,b=v.l,z=Xn(g),k=z.c,y=z.n,C=Xn(S),x=C.c,A=C.n,N=new Ce(19),T=0;T<k.length;++T)++N[k[T]&31];for(var T=0;T<x.length;++T)++N[x[T]&31];for(var p=ks(N,7),E=p.t,D=p.l,F=19;F>4&&!E[Kn[F-1]];--F);var L=l+5<<3,W=Ct(r,ut)+Ct(a,ss)+o,G=Ct(r,g)+Ct(a,S)+o+14+3*F+Ct(N,E)+2*N[16]+3*N[17]+7*N[18];if(c>=0&&L<=W&&L<=G)return cr(t,h,e.subarray(c,c+l));var ee,V,w,O;if(Ue(t,h,1+(G<W)),h+=2,G<W){ee=Tt(g,f,0),V=g,w=Tt(S,b,0),O=S;var K=Tt(E,D,0);Ue(t,h,y-257),Ue(t,h+5,A-1),Ue(t,h+10,F-4),h+=14;for(var T=0;T<F;++T)Ue(t,h+3*T,E[Kn[T]]);h+=3*F;for(var _=[k,x],q=0;q<2;++q)for(var ae=_[q],T=0;T<ae.length;++T){var X=ae[T]&31;Ue(t,h,K[X]),h+=E[X],X>15&&(Ue(t,h,ae[T]>>5&127),h+=ae[T]>>12)}}else ee=Ld,V=ut,w=Od,O=ss;for(var T=0;T<d;++T){var ne=i[T];if(ne>255){var X=ne>>18&31;St(t,h,ee[X+257]),h+=V[X+257],X>7&&(Ue(t,h,ne>>23&31),h+=Ys[X]);var oe=ne&31;St(t,h,w[oe]),h+=O[oe],oe>3&&(St(t,h,ne>>5&8191),h+=Gs[oe])}else St(t,h,ee[ne]),h+=V[ne]}return St(t,h,ee[256]),h+V[256]},Pd=new Xs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),dr=new we(0),Ud=function(e,t,n,i,r,a){var o=a.z||e.length,d=new we(i+o+5*(1+Math.ceil(o/7e3))+r),c=d.subarray(i,d.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var m=Pd[t-1],g=m>>13,f=m&8191,v=(1<<n)-1,S=a.p||new Ce(32768),b=a.h||new Ce(v+1),z=Math.ceil(n/3),k=2*z,y=function(ve){return(e[ve]^e[ve+1]<<z^e[ve+2]<<k)&v},C=new Xs(25e3),x=new Ce(288),A=new Ce(32),N=0,T=0,p=a.i||0,E=0,D=a.w||0,F=0;p+2<o;++p){var L=y(p),W=p&32767,G=b[L];if(S[W]=G,b[L]=W,D<=p){var ee=o-p;if((N>7e3||E>24576)&&(ee>423||!l)){h=Yn(e,c,0,C,x,A,T,E,F,p-F,h),E=N=T=0,F=p;for(var V=0;V<286;++V)x[V]=0;for(var V=0;V<30;++V)A[V]=0}var w=2,O=0,K=f,_=W-G&32767;if(ee>2&&L==y(p-_))for(var q=Math.min(g,ee)-1,ae=Math.min(32767,p),X=Math.min(258,ee);_<=ae&&--K&&W!=G;){if(e[p+w]==e[p+w-_]){for(var ne=0;ne<X&&e[p+ne]==e[p+ne-_];++ne);if(ne>w){if(w=ne,O=_,ne>q)break;for(var oe=Math.min(_,ne-2),ue=0,V=0;V<oe;++V){var M=p-_+V&32767,le=S[M],Q=M-le&32767;Q>ue&&(ue=Q,G=M)}}}W=G,G=S[W],_+=W-G&32767}if(O){C[E++]=268435456|_s[w]<<18|qn[O];var ie=_s[w]&31,Se=qn[O]&31;T+=Ys[ie]+Gs[Se],++x[257+ie],++A[Se],D=p+w,++N}else C[E++]=e[p],++x[e[p]]}}for(p=Math.max(p,D);p<o;++p)C[E++]=e[p],++x[e[p]];h=Yn(e,c,l,C,x,A,T,E,F,p-F,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=b,a.p=S,a.i=p,a.w=D)}else{for(var p=a.w||0;p<o+l;p+=65535){var he=p+65535;he>=o&&(c[h/8|0]=l,he=o),h=cr(c,h+1,e.subarray(p,he))}a.i=o}return lr(d,0,i+or(h)+r)},Bd=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,i=9;--i;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Wd=function(){var e=-1;return{p:function(t){for(var n=e,i=0;i<t.length;++i)n=Bd[n&255^t[i]]^n>>>8;e=n},d:function(){return~e}}},Vd=function(e,t,n,i,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new we(a.length+e.length);o.set(a),o.set(e,a.length),e=o,r.w=a.length}return Ud(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,i,r)},ur=function(e,t){var n={};for(var i in e)n[i]=e[i];for(var i in t)n[i]=t[i];return n},be=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Hd(e,t){return Vd(e,t||{},0,0)}var hr=function(e,t,n,i){for(var r in e){var a=e[r],o=t+r,d=i;Array.isArray(a)&&(d=ur(i,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,d]:(n[o+="/"]=[new we(0),d],hr(a,o,n,i))}},Gn=typeof TextEncoder<"u"&&new TextEncoder,Kd=typeof TextDecoder<"u"&&new TextDecoder,qd=0;try{Kd.decode(dr,{stream:!0}),qd=1}catch{}function Jn(e,t){var n;if(Gn)return Gn.encode(e);for(var i=e.length,r=new we(e.length+(e.length>>1)),a=0,o=function(l){r[a++]=l},n=0;n<i;++n){if(a+5>r.length){var d=new we(a+8+(i-n<<1));d.set(r),r=d}var c=e.charCodeAt(n);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return lr(r,0,a)}var Os=function(e){var t=0;if(e)for(var n in e){var i=e[n].length;i>65535&&as(9),t+=i+4}return t},Zn=function(e,t,n,i,r,a,o,d){var c=i.length,l=n.extra,h=d&&d.length,m=Os(l);be(e,t,o!=null?33639248:67324752),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var g=new Date(n.mtime==null?Date.now():n.mtime),f=g.getFullYear()-1980;if((f<0||f>119)&&as(10),be(e,t,f<<25|g.getMonth()+1<<21|g.getDate()<<16|g.getHours()<<11|g.getMinutes()<<5|g.getSeconds()>>1),t+=4,a!=-1&&(be(e,t,n.crc),be(e,t+4,a<0?-a-2:a),be(e,t+8,n.size)),be(e,t+12,c),be(e,t+14,m),t+=16,o!=null&&(be(e,t,h),be(e,t+6,n.attrs),be(e,t+10,o),t+=14),e.set(i,t),t+=c,m)for(var v in l){var S=l[v],b=S.length;be(e,t,+v),be(e,t+2,b),e.set(S,t+4),t+=4+b}return h&&(e.set(d,t),t+=h),t},Xd=function(e,t,n,i,r){be(e,t,101010256),be(e,t+8,n),be(e,t+10,n),be(e,t+12,i),be(e,t+16,r)};function Yd(e,t){t||(t={});var n={},i=[];hr(e,"",n,t);var r=0,a=0;for(var o in n){var d=n[o],c=d[0],l=d[1],h=l.level==0?0:8,m=Jn(o),g=m.length,f=l.comment,v=f&&Jn(f),S=v&&v.length,b=Os(l.extra);g>65535&&as(11);var z=h?Hd(c,l):c,k=z.length,y=Wd();y.p(c),i.push(ur(l,{size:c.length,crc:y.d(),c:z,f:m,m:v,u:g!=o.length||v&&f.length!=S,o:r,compression:h})),r+=30+g+b+k,a+=76+2*(g+b)+(S||0)+k}for(var C=new we(a+22),x=r,A=a-r,N=0;N<i.length;++N){var m=i[N];Zn(C,m.o,m,m.f,m.u,m.c.length);var T=30+m.f.length+Os(m.extra);C.set(m.c,m.o+T),Zn(C,r,m,m.f,m.u,m.c.length,m.o,m.m),r+=16+T+(m.m?m.m.length:0)}return Xd(C,r,i.length,A,x),C}function Gd(e,t="image/png"){const n=atob(e),i=new Uint8Array(n.length);for(let r=0;r<n.length;r++)i[r]=n.charCodeAt(r);return new Blob([i],{type:t})}async function Jd(e){return typeof e.arrayBuffer=="function"?new Uint8Array(await e.arrayBuffer()):new Promise((t,n)=>{const i=new FileReader;i.onload=()=>t(new Uint8Array(i.result)),i.onerror=()=>n(i.error),i.readAsArrayBuffer(e)})}function Zd(e){return new Promise((t,n)=>{const i=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(i),t(r)},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("the picture could not be read"))},r.src=i})}function Qd(e,t){return Promise.race([e,new Promise((n,i)=>setTimeout(()=>i(new Error("timed out")),t))])}async function Js(e){if(typeof createImageBitmap=="function"){const n=await createImageBitmap(e);return{source:n,width:n.width,height:n.height}}const t=await Qd(Zd(e),3e3);return{source:t,width:t.naturalWidth,height:t.naturalHeight}}async function eu(e){try{const{width:t,height:n}=await Js(e);return{width:t,height:n}}catch{return{width:0,height:0}}}function mr(e,t,n){return new Promise((i,r)=>{e.toBlob(a=>a?i(a):r(new Error("the picture could not be made")),t,n)})}const tu=320;async function su(e,t=tu){try{const{source:n,width:i,height:r}=await Js(e);if(!i||!r)return e;const a=Math.min(1,t/Math.max(i,r)),o=document.createElement("canvas");o.width=Math.max(1,Math.round(i*a)),o.height=Math.max(1,Math.round(r*a));const d=o.getContext("2d");return d?(d.drawImage(n,0,0,o.width,o.height),await mr(o,"image/jpeg",.8)):e}catch{return e}}async function nu(e,t){const{source:n,width:i,height:r}=await Js(e);if(!i||!r)throw new Error("the picture could not be read");const a=document.createElement("canvas");a.width=i,a.height=r;const o=a.getContext("2d");if(!o)throw new Error("this browser cannot draw here");return o.drawImage(n,0,0,i,r),t.forEach(d=>ta(o,i,r,d)),mr(a,"image/png")}function iu(e){const t=new Map;return e.map(n=>{const i=(t.get(n)??0)+1;if(t.set(n,i),i===1)return n;const r=n.lastIndexOf(".");return r>0?`${n.slice(0,r)}-${i}${n.slice(r)}`:`${n}-${i}`})}async function ru(e,t){const n=iu(t.map(o=>ir(e,o))),i={},r=await Promise.all(t.map(o=>Jd(o.png)));n.forEach((o,d)=>{i[o]=r[d]});const a=Yd(i,{level:0});return new Blob([a],{type:"application/zip"})}function Qn(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}function fr({capture:e,actualSize:t,onToggleSize:n,annotate:i}){const r=e.width&&e.height?e.width/e.height:void 0;return s.jsx("div",{className:`shots-picture${t&&!i?" is-actual":""}`,children:s.jsxs("div",{className:"shots-picture-frame",children:[s.jsx("img",{src:e.url,alt:dt(e),draggable:!1,onClick:i?void 0:n,className:n&&!i?"is-zoomable":void 0}),i&&s.jsx(sa,{enabled:!0,shape:i.shape,color:i.color,committed:i.marks,onCommittedChange:i.onMarksChange,onCommit:()=>{},mediaAspect:r})]})})}function au({a:e,b:t}){return s.jsx("div",{className:"shots-compare",children:[e,t].map((n,i)=>s.jsxs("figure",{className:"shots-compare-side",children:[s.jsx("span",{className:"shots-compare-tag","aria-hidden":"true",children:i===0?"A":"B"}),n?s.jsxs(s.Fragment,{children:[s.jsx(fr,{capture:n}),s.jsx("figcaption",{className:"shots-details",children:tr(n)})]}):s.jsx("p",{className:"shots-compare-empty",children:"Pick a screenshot in the list to compare with."})]},i))})}function ou({captures:e,activeId:t,compare:n,taking:i,onTake:r,onPick:a,onDelete:o}){const d=u.useRef(null),c=Date.now(),l=g=>{var v,S;const f=(v=d.current)==null?void 0:v.querySelector(`[data-capture="${g}"]`);f==null||f.focus(),(S=f==null?void 0:f.scrollIntoView)==null||S.call(f,{block:"nearest"})},h=g=>{if(!e.length)return;const f=Math.max(0,e.findIndex(S=>S.id===t));let v=null;if(g.key==="ArrowDown"||g.key==="ArrowRight")v=Math.min(e.length-1,f+1);else if(g.key==="ArrowUp"||g.key==="ArrowLeft")v=Math.max(0,f-1);else if(g.key==="Home")v=0;else if(g.key==="End")v=e.length-1;else if((g.key==="Delete"||g.key==="Backspace")&&t&&!n){g.preventDefault(),o(t);return}v!==null&&(g.preventDefault(),a(e[v].id),l(e[v].id))},m=g=>n?n.a===g?"A":n.b===g?"B":null:null;return s.jsxs("div",{className:"shots-rail",children:[s.jsxs(U,{className:"shots-take",size:"md",onClick:r,disabled:i,children:[i?s.jsx(ct,{className:"animate-spin",size:14,"aria-hidden":"true"}):s.jsx(Nt,{size:14,"aria-hidden":"true"}),i?"Taking screenshot…":"Take screenshot"]}),s.jsxs("div",{ref:d,className:"shots-list",role:"listbox","aria-label":n?"Screenshots, pick the right side":"Screenshots",onKeyDown:h,children:[i&&s.jsx("div",{className:"shots-thumb is-pending","aria-hidden":"true"}),e.map(g=>{const f=g.id===t,v=m(g.id);return s.jsxs("div",{"data-capture":g.id,role:"option","aria-selected":f,tabIndex:f||!t&&g===e[0]?0:-1,className:`shots-thumb${f?" is-active":""}${v?" is-compared":""}`,"aria-label":`${dt(g)}${g.markedFrom!==void 0?`, marked copy of ${g.markedFrom}`:""}, ${Is(g.takenAt,c)}${v?`, side ${v}`:""}`,onClick:()=>a(g.id),children:[s.jsx("img",{src:g.thumbUrl,alt:"",draggable:!1}),v&&s.jsx("span",{className:"shots-thumb-side",children:v}),s.jsxs("span",{className:"shots-thumb-label",children:[s.jsxs("span",{className:"shots-thumb-n",children:[g.markedFrom!==void 0&&s.jsx(vi,{size:10,"aria-hidden":"true"}),g.n]}),s.jsx("span",{className:"shots-thumb-time",children:Is(g.takenAt,c).replace("Today ","")})]})]},g.id)})]})]})}var Bt,lu=new Uint8Array(16);function cu(){if(!Bt&&(Bt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Bt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Bt(lu)}const du=/^(?:[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 uu(e){return typeof e=="string"&&du.test(e)}var xe=[];for(var Ss=0;Ss<256;++Ss)xe.push((Ss+256).toString(16).substr(1));function hu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(xe[e[t+0]]+xe[e[t+1]]+xe[e[t+2]]+xe[e[t+3]]+"-"+xe[e[t+4]]+xe[e[t+5]]+"-"+xe[e[t+6]]+xe[e[t+7]]+"-"+xe[e[t+8]]+xe[e[t+9]]+"-"+xe[e[t+10]]+xe[e[t+11]]+xe[e[t+12]]+xe[e[t+13]]+xe[e[t+14]]+xe[e[t+15]]).toLowerCase();if(!uu(n))throw TypeError("Stringified UUID is invalid");return n}function mu(e,t,n){e=e||{};var i=e.random||(e.rng||cu)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,hu(i)}const lt=50,ei=6e3;function Cs(e){const t=URL.createObjectURL(e.png),n=e.thumb===e.png?t:URL.createObjectURL(e.thumb);return{...e,url:t,thumbUrl:n}}function Wt(e){URL.revokeObjectURL(e.url),e.thumbUrl!==e.url&&URL.revokeObjectURL(e.thumbUrl)}function ti({url:e,thumbUrl:t,...n}){return n}function fu(e,t){return t.takenAt-e.takenAt||t.n-e.n}function pu(e,t=Cr){const{toast:n}=Ie(),[i,r]=u.useState([]),[a,o]=u.useState(null),[d,c]=u.useState(!1),[l,h]=u.useState(!0),[m,g]=u.useState(!1),f=u.useRef(null),v=u.useRef([]);v.current=i;const S=u.useRef(0),b=u.useRef(!0);u.useEffect(()=>{b.current=!0;let p=!1;return c(!1),r([]),o(null),S.current=0,(async()=>{var L;const E=await t();let D=[];try{D=await E.list(e)}catch{D=[]}if(p)return;f.current=E;const F=D.slice(0,lt).map(Cs);S.current=F.reduce((W,G)=>Math.max(W,G.n),0),h(E.persistent),r(F),o(((L=F[0])==null?void 0:L.id)??null),c(!0)})(),()=>{p=!0}},[e]),u.useEffect(()=>()=>{b.current=!1,v.current.forEach(Wt)},[]);const z=u.useCallback(async p=>{const E=f.current;if(E)try{await E.put(p)}catch{n(`Couldn’t keep ${dt(p)} in this browser. It’s here until you leave the page.`,"error")}},[n]),k=u.useCallback((p,E)=>{var W,G;const D=[...p,...v.current].sort(fu),F=D.slice(lt),L=D.slice(0,lt);F.forEach(Wt),F.length&&((W=f.current)==null||W.delete(F.map(ee=>ee.id)).catch(()=>{})),v.current=L,r(L),o(L.some(ee=>ee.id===E)?E:((G=L[0])==null?void 0:G.id)??null)},[]),y=u.useCallback(async(p,E={})=>{const[D,F]=await Promise.all([eu(p),su(p)]);if(!b.current)return;S.current+=1;const L={id:mu(),udid:e,n:S.current,takenAt:Date.now(),width:D.width,height:D.height,bytes:p.size,png:p,thumb:F,...E};k([Cs(L)],L.id),await z(L)},[e,k,z]),C=u.useCallback(async()=>{g(!0);try{let p;try{p=await Y.getScreenshot(e)}catch(E){n(Ae("take a screenshot",E),"error");return}if(!(p!=null&&p.screenshot)){const E=(p==null?void 0:p.error)||(p==null?void 0:p.message);n(E?Ae("take a screenshot",{message:E}):"Couldn’t take a screenshot. The phone sent no picture.","error");return}await y(Gd(p.screenshot))}finally{b.current&&g(!1)}},[e,n,y]),x=u.useCallback((p,E)=>y(E,{markedFrom:p.n}),[y]),A=u.useCallback(async p=>{if(!b.current||!p.length)return;const E=p.filter(F=>!v.current.some(L=>L.id===F.id));k(E.map(Cs),p[0].id);const D=f.current;await Promise.all(E.map(F=>D==null?void 0:D.put(F).catch(()=>{})))},[k]),N=u.useCallback(async p=>{var G;const E=v.current,D=E.findIndex(ee=>ee.id===p);if(D<0)return;const F=E[D],L=E.filter(ee=>ee.id!==p);v.current=L,r(L),o(ee=>{var V;return ee===p?((V=L[D]??L[D-1])==null?void 0:V.id)??null:ee}),Wt(F);const W=ti(F);n(`Deleted ${dt(F)}`,"info",ei,{label:"Undo",onClick:()=>void A([W])}),await((G=f.current)==null?void 0:G.delete([p]).catch(()=>{}))},[n,A]),T=u.useCallback(async()=>{var D;const p=v.current;if(!p.length)return;v.current=[],r([]),o(null),p.forEach(Wt);const E=p.map(ti);n(`Cleared ${p.length} screenshot${p.length===1?"":"s"}`,"info",ei,{label:"Undo",onClick:()=>void A(E)}),await((D=f.current)==null?void 0:D.clear(e).catch(()=>{}))},[e,n,A]);return{captures:i,selectedId:a,select:o,ready:d,persistent:l,taking:m,take:C,addMarkedCopy:x,remove:N,clearAll:T}}function gu({udid:e,deviceName:t,openStore:n}){const{toast:i}=Ie(),r=pu(e,n),{captures:a,selectedId:o,select:d}=r,c=a.find(_=>_.id===o)??null,[l,h]=u.useState("view"),[m,g]=u.useState(null),[f,v]=u.useState(!1),[S,b]=u.useState("RECT"),[z,k]=u.useState(Lr.color),[y,C]=u.useState([]),[x,A]=u.useState(!1),[N,T]=u.useState(!1),p=u.useCallback(()=>{h("view"),C([]),g(null)},[]);u.useEffect(()=>{l!=="view"&&(c?l==="compare"&&m&&!a.some(_=>_.id===m)&&g(null):p())},[l,c,m,a,p]);const E=u.useRef(null),D=u.useRef(l);D.current=l,u.useEffect(()=>{const _=E.current;if(!_)return;const q=ae=>{ae.key!=="Escape"||ae.defaultPrevented||D.current==="view"||(ae.preventDefault(),p())};return _.addEventListener("keydown",q),()=>_.removeEventListener("keydown",q)},[p]);const F=_=>{if(l==="compare"){_!==o&&g(_);return}l==="annotate"&&_!==o&&p(),d(_)},L=()=>{if(!c)return;const _=a.indexOf(c),q=a[_+1]??a[_-1]??null;C([]),g((q==null?void 0:q.id)??null),h("compare")},W=async()=>{c&&(await Id(c.png)?i(`Copied ${dt(c)}`,"success"):i("Your browser can’t copy pictures on this address. Use Download instead.","error"))},G=()=>{c&&Qn(c.png,ir(t,c))},ee=async()=>{T(!0);try{Qn(await ru(t,a),$d(t))}catch(_){i(Ae("make the zip",_),"error")}finally{T(!1)}},V=async()=>{if(!(!c||!y.length)){A(!0);try{const _=await nu(c.png,y);await r.addMarkedCopy(c,_),i(`Saved a marked copy of ${dt(c)}`,"success"),p()}catch(_){i(Ae("save the marked copy",_),"error")}finally{A(!1)}}},w=a.length,O=r.persistent?w>=lt?`${w} of ${lt} kept · the oldest goes when you take another`:`${w} of ${lt} kept`:"Kept until you leave this page",K=a.find(_=>_.id===m)??null;return s.jsxs("div",{ref:E,className:"shots-root",children:[s.jsxs("header",{className:"shots-head",children:[s.jsxs("h4",{className:"shots-title",children:[s.jsx(Nt,{size:14,"aria-hidden":"true"}),"Screenshots"]}),r.ready&&s.jsx("span",{className:"shots-kept",title:r.persistent?"This browser keeps the newest 50 screenshots of each phone.":"This browser isn’t saving screenshots here, for example in a private window.",children:O}),s.jsx("span",{className:"shots-actions-gap"}),l==="compare"?s.jsx(U,{variant:"secondary",size:"sm",onClick:p,children:"Done"}):s.jsxs(U,{variant:"secondary",size:"sm",onClick:L,disabled:w<2||l==="annotate",children:[s.jsx(Sa,{size:13,"aria-hidden":"true"}),"Compare"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:ee,disabled:!w||N,children:[N?s.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):s.jsx(Aa,{size:13,"aria-hidden":"true"}),"Download all"]}),s.jsx(U,{variant:"secondary",size:"sm",onClick:()=>{p(),r.clearAll()},disabled:!w,children:"Clear all"})]}),r.ready&&!w&&!r.taking?s.jsxs("div",{className:"shots-empty",children:[s.jsx(Nt,{size:22,"aria-hidden":"true"}),s.jsx("p",{className:"shots-empty-title",children:"No screenshots yet"}),s.jsxs("p",{className:"shots-empty-hint",children:["Take one to keep it here. This browser keeps the newest ",lt," for this phone."]}),s.jsxs(U,{size:"md",onClick:()=>void r.take(),children:[s.jsx(Nt,{size:14,"aria-hidden":"true"}),"Take screenshot"]})]}):r.ready?s.jsxs("div",{className:"shots-body",children:[s.jsx(ou,{captures:a,activeId:l==="compare"?m??o:o,compare:l==="compare"&&o?{a:o,b:m}:void 0,taking:r.taking,onTake:()=>void r.take(),onPick:F,onDelete:_=>void r.remove(_)}),s.jsx("section",{className:"shots-preview","aria-label":"Preview",children:c&&l==="compare"?s.jsx(au,{a:c,b:K}):c?s.jsxs(s.Fragment,{children:[s.jsx(fr,{capture:c,actualSize:f,onToggleSize:()=>v(_=>!_),annotate:l==="annotate"?{shape:S,color:z,marks:y,onMarksChange:C}:void 0}),s.jsxs("footer",{className:"shots-footer",children:[s.jsx("p",{className:"shots-details",children:tr(c)}),l==="annotate"?s.jsx(Ad,{shape:S,color:z,marks:y.length,saving:x,onShape:b,onColor:k,onUndo:()=>C(_=>_.slice(0,-1)),onClear:()=>C([]),onCancel:p,onSave:()=>void V()}):s.jsxs("div",{className:"shots-actions",children:[s.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>void W(),children:[s.jsx($e,{size:13,"aria-hidden":"true"}),"Copy"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>{v(!1),h("annotate")},children:[s.jsx(vi,{size:13,"aria-hidden":"true"}),"Annotate"]}),s.jsxs(U,{variant:"secondary",size:"sm",onClick:G,children:[s.jsx(fi,{size:13,"aria-hidden":"true"}),"Download"]}),s.jsxs(U,{variant:"ghost",size:"sm","aria-pressed":f,onClick:()=>v(_=>!_),children:[f?s.jsx(qa,{size:13,"aria-hidden":"true"}):s.jsx(Wa,{size:13,"aria-hidden":"true"}),"Actual size"]}),s.jsx("span",{className:"shots-actions-gap"}),s.jsxs(U,{variant:"ghost",size:"sm",className:"shots-delete",onClick:()=>void r.remove(c.id),children:[s.jsx(na,{size:13,"aria-hidden":"true"}),"Delete"]})]})]})]}):null})]}):null]})}function vu({device:e,onClose:t,titleId:n}){const i=Pi(t),{toast:r}=Ie(),a=re=>se=>{Tr(se)||r(Ae(re,se),"error")},o=$t(),{tab:d}=ii(),c=ns(),l=u.useRef(null),[h,m]=u.useState({width:0,height:0}),[g,f]=u.useState("inspect"),[v,S]=u.useState(null),[b,z]=u.useState(d||"actions"),k=b==="omni"&&g==="inspect",[y,C]=u.useState(!0),[x,A]=u.useState(!1),[N,T]=u.useState(0),[p,E]=u.useState(e),[D,F]=u.useState(0),L=u.useCallback(()=>F(Date.now()),[]),W=Qe(p);u.useEffect(()=>{Nr(p.udid,W),document.title=Er(c.pathname)},[p.udid,W,c.pathname]);const[G,ee]=u.useState(!1),[V,w]=u.useState(!1),O=10,[K,_]=u.useState(!1),[q,ae]=u.useState(!1),X=ic(p==null?void 0:p.udid,!V),ne=()=>{navigator.clipboard.writeText(p.udid).catch(()=>{}),_(!0),setTimeout(()=>_(!1),1500)},oe=u.useRef(""),ue=u.useRef(null),[M,le]=u.useState(!1);u.useEffect(()=>{b&&(!d||d!==b)&&o(`/devices/${e.udid}/control/${b}${c.search}`,{replace:!0})},[b,d,e.udid,o,c.search]);const[Q,ie]=u.useState(0);rc(()=>{Y.leaveStream(p.udid).catch(()=>{})},()=>ie(re=>re+1)),u.useEffect(()=>((async()=>{try{A(!0),await Y.startStream(p.udid);const ge=(await Y.getDevices()).find(I=>I.udid===p.udid);ge&&E(ge)}catch(se){console.error("Auto-start stream failed:",se)}finally{A(!1)}})(),()=>{Y.leaveStream(p.udid).catch(()=>{})}),[e.udid,Q]);const Se=parseInt(p.screenWidth||"1080",10),he=parseInt(p.screenHeight||"1920",10),ve=Math.min(Se,he),Ne=Math.max(Se,he),_e=ve/Ne,De=u.useCallback(()=>{const re=!y,se=re?window.innerHeight*.55:window.innerHeight*.7,ge=620,H=window.innerWidth>900;let te;re?te=H?Math.min(window.innerWidth*.8,window.innerWidth-ge):window.innerWidth*.8:te=window.innerWidth*.45;const me=y?_e:1/_e;let fe,ye;y?(fe=se,ye=fe*me,ye>te&&(ye=te,fe=ye/me)):(ye=te,fe=ye/me,fe>se&&(fe=se,ye=fe*me)),m({width:ye,height:fe})},[_e,y]);u.useEffect(()=>(De(),window.addEventListener("resize",De),()=>window.removeEventListener("resize",De)),[De]),u.useEffect(()=>{const re=async()=>{if(oe.current.length>0){const ge=oe.current;oe.current="";try{await Y.typeText(p.udid,ge)}catch(I){console.error("Keyboard buffering flush failed:",I)}finally{L()}}},se=ge=>{const I=document.activeElement;if(I&&(I.tagName==="INPUT"||I.tagName==="TEXTAREA"||I.isContentEditable)||!M&&b!=="terminal")return;const te=ge.key;te==="Enter"?(ue.current&&clearTimeout(ue.current),re(),Y.pressKey(p.udid,p.platform==="android"?66:"enter").finally(L)):te==="Backspace"?(ue.current&&clearTimeout(ue.current),re(),Y.pressKey(p.udid,p.platform==="android"?67:"backspace").finally(L)):te.length===1&&(oe.current+=te,ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{re()},50))};return window.addEventListener("keydown",se),()=>{window.removeEventListener("keydown",se),ue.current&&clearTimeout(ue.current)}},[p.udid,p.platform,M,b,L]);const[pe,et]=u.useState(Date.now()),Le=()=>{const re=N>0?`r=${N}&`:"";return p.session_id&&!String(p.session_id).startsWith("manual_")?`/xenon/api/session/${p.session_id}/live_video?${re}t=${pe}`:`/xenon/api/control/${p.udid}/stream?${re}t=${pe}`};u.useEffect(()=>{N>0&&et(Date.now())},[N]),u.useEffect(()=>{if(G||V)return;const re=setTimeout(()=>w(!0),3e4);return()=>clearTimeout(re)},[G,V,N]);const Ee=u.useRef(null),He=re=>{const se=re.currentTarget.getBoundingClientRect();return{x:re.clientX-se.left,y:re.clientY-se.top}},xt=re=>{const se=He(re);Ee.current={x:se.x,y:se.y,time:Date.now()}},Ke=async re=>{var _t;if(!Ee.current)return;const se=Ee.current,ge=He(re),I=Date.now()-se.time,H=(_t=l.current)==null?void 0:_t.getBoundingClientRect(),te=(H==null?void 0:H.width)||h.width,me=(H==null?void 0:H.height)||h.height;let fe,ye,Oe,st;y?(fe=se.x/te*ve,ye=se.y/me*Ne,Oe=ge.x/te*ve,st=ge.y/me*Ne):(fe=se.x/te*Ne,ye=se.y/me*ve,Oe=ge.x/te*Ne,st=ge.y/me*ve);const jt=Math.abs(Oe-fe),It=Math.abs(st-ye);try{I<500&&jt<10&&It<10?await Y.tap(p.udid,Math.round(fe),Math.round(ye)):I>=500&&jt<10&&It<10?await Y.touchAndHold(p.udid,Math.round(fe),Math.round(ye),I):await Y.swipe(p.udid,Math.round(fe),Math.round(ye),Math.round(Oe),Math.round(st))}catch(os){console.error("Action failed:",os)}finally{L()}Ee.current=null},qe=()=>Y.pressKey(p.udid,p.platform==="android"?wt.HOME:fs.HOME).catch(a("press Home")).finally(L),Xe=()=>Y.pressKey(p.udid,wt.BACK).catch(a("press Back")).finally(L),bt=()=>Y.pressKey(p.udid,wt.APP_SWITCH).catch(a("open the app switcher")).finally(L),ht=()=>Y.pressKey(p.udid,p.platform==="android"?wt.VOLUME_UP:fs.VOLUME_UP).catch(a("press Volume up")).finally(L),tt=()=>Y.pressKey(p.udid,p.platform==="android"?wt.VOLUME_DOWN:fs.VOLUME_DOWN).catch(a("press Volume down")).finally(L),mt=()=>Y.lock(p.udid).catch(a("lock the device")).finally(L),Me=async()=>{ae(!0);try{await Y.unlock(p.udid).catch(a("unlock the device"))}finally{L(),setTimeout(()=>ae(!1),2500)}};return s.jsxs("div",{className:"device-control-view",children:[s.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),s.jsxs("header",{className:"control-view-top-bar",children:[s.jsxs("button",{className:"back-to-devices-btn",onClick:i,children:[s.jsx(yn,{size:18})," DEVICES"]}),s.jsxs("div",{className:"device-info-mini",children:[s.jsx("span",{className:`device-pill platform-pill ${p.platform}`,children:p.platform==="ios"?"Apple":"Android"}),s.jsxs("span",{className:"device-pill version-pill",children:["v",p.sdk]}),p.reservedUntil&&Date.now()<p.reservedUntil&&s.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${p.reservedBy}${p.reservationReason?`: ${p.reservationReason}`:""}`,children:["Reserved by ",p.reservedBy||"someone"]}),s.jsx("h2",{id:n,className:"device-name-text",children:W}),s.jsxs("span",{className:"udid-chip",title:p.udid,children:[s.jsx("span",{className:"udid-chip__value",children:p.udid}),s.jsx("button",{type:"button",className:"udid-chip__copy",onClick:ne,"aria-label":"Copy UDID",title:K?"Copied!":"Copy UDID",children:K?s.jsx(At,{size:12}):s.jsx($e,{size:12})})]})]})]}),s.jsxs("div",{className:`control-view-main ${y?"":"is-landscape"} ${b==="omni"?"omni-mode":""}`,children:[s.jsxs("div",{className:"device-preview-column",children:[s.jsx("div",{className:"device-screen-wrapper",children:s.jsxs("div",{ref:re=>{l.current=re,S(re)},className:`device-stream-canvas ${y?"":"landscape"} ${M?"focused":""} ${k?"is-inspecting":""}`,style:{width:h.width,height:h.height,background:"var(--black)"},tabIndex:0,onFocus:()=>le(!0),onBlur:()=>le(!1),onMouseDown:k?void 0:xt,onMouseUp:k?void 0:Ke,children:[V?s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(Be,{size:40,color:"var(--red, #f87171)"}),s.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),s.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{w(!1),T(0)},children:"Retry"})]}):(x||!G)&&s.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[s.jsx(Et,{size:40,className:"animate-spin",color:"var(--color-accent)"}),s.jsx("p",{style:{marginTop:16},children:x?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!V&&s.jsx(ri,{src:Le(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>ee(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),ee(!1),N>=O){w(!0);return}setTimeout(()=>T(re=>re+1),2e3)}}),X==="off"&&!V&&s.jsxs("div",{className:"device-screen-off",role:"status",children:[s.jsx(Ya,{size:32}),s.jsx("p",{children:"Display is off"}),s.jsx("span",{children:"The stream is fine — the device is asleep."}),s.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:Me,disabled:q,children:q?"Waking…":"Wake device"})]})]})}),s.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":y?"vertical":"horizontal",children:[s.jsx("button",{className:`footer-action-btn ${y?"active":""}`,onClick:()=>C(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":y,children:s.jsx(ao,{size:18})}),s.jsx("button",{className:`footer-action-btn ${y?"":"active"}`,onClick:()=>C(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!y,children:s.jsx(io,{size:18})}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:qe,title:"Home","aria-label":"Home",children:s.jsx(Or,{size:18})}),p.platform==="android"&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"footer-action-btn",onClick:Xe,title:"Back","aria-label":"Back",children:s.jsx(yn,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:bt,title:"App switcher","aria-label":"App switcher",children:s.jsx(ai,{size:18})})]}),s.jsx("div",{className:"footer-divider"}),s.jsx("button",{className:"footer-action-btn",onClick:ht,title:"Volume up","aria-label":"Volume up",children:s.jsx(No,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:tt,title:"Volume down","aria-label":"Volume down",children:s.jsx(So,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:mt,title:"Lock device","aria-label":"Lock device",children:s.jsx(ia,{size:18})}),s.jsx("button",{className:"footer-action-btn",onClick:Me,title:"Unlock device","aria-label":"Unlock device",children:s.jsx(Fa,{size:18})})]})]}),s.jsxs("div",{className:"device-interactions-column",children:[s.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[s.jsxs("button",{className:`tab-btn ${b==="actions"?"active":""}`,onClick:()=>z("actions"),role:"tab","aria-selected":b==="actions",children:[s.jsx(ui,{size:13}),s.jsx("span",{children:"Actions"})]}),s.jsxs("button",{className:`tab-btn ${b==="screenshot"?"active":""}`,onClick:()=>z("screenshot"),role:"tab","aria-selected":b==="screenshot",children:[s.jsx(Nt,{size:13}),s.jsx("span",{children:"Screenshot"})]}),s.jsxs("button",{className:`tab-btn ${b==="logs"?"active":""}`,onClick:()=>z("logs"),role:"tab","aria-selected":b==="logs",children:[s.jsx(yi,{size:13}),s.jsx("span",{children:"Logs"})]}),s.jsxs("button",{className:`tab-btn ${b==="terminal"?"active":""}`,onClick:()=>z("terminal"),role:"tab","aria-selected":b==="terminal",children:[s.jsx(Zr,{size:13}),s.jsx("span",{children:"Shell"})]}),s.jsxs("button",{className:`tab-btn ${b==="omni"?"active":""}`,onClick:()=>z("omni"),role:"tab","aria-selected":b==="omni",children:[s.jsx(zr,{size:13}),s.jsx("span",{children:"Omni-Vision"})]})]}),s.jsx("div",{className:`interactions-scroll-area ${b==="terminal"?"terminal-mode":""} ${b==="screenshot"||b==="logs"?"screenshot-mode":""}`,children:s.jsxs("div",{className:"tab-content",children:[b==="omni"&&s.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:s.jsx(nc,{sessionId:p.session_id?String(p.session_id):null,udid:p.udid,streamUrl:Le(),embedded:!0,overlayTarget:v,onModeChange:f,deviceActionAt:D})}),b==="actions"&&s.jsx(Ed,{udid:p.udid,platform:p.platform,deviceName:W,screenWidth:ve,screenHeight:Ne}),b==="screenshot"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(gu,{udid:p.udid,deviceName:W})}),b==="logs"&&s.jsx("div",{className:"action-card screenshot-card",children:s.jsx(md,{udid:p.udid,platform:p.platform})}),b==="terminal"&&s.jsx("div",{className:"action-card full-height",children:s.jsx(yl,{platform:(p.platform||"").toLowerCase(),prompt:`${(p.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${W} (${p.udid}).
|
|
279
|
+
Internal Shell Environment.`,onCommand:async re=>{const se=await Y.executeShell(p.udid,re);if(se.error)throw new Error(se.error);return se.output}})})]})})]})]}),p.session_id&&!String(p.session_id).startsWith("manual_")&&s.jsx($r,{sessionId:String(p.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const pr="xenon.devices.view";function gr(){try{return window.localStorage}catch{return null}}function yu(e,t){const n=e.get("view");return n==="table"||n==="cards"?n:t}function xu(e,t,n){t==="table"||t!==n?e.set("view",t):e.delete("view")}function si(e=gr()){try{return(e==null?void 0:e.getItem(pr))==="table"?"table":"cards"}catch{return"cards"}}function bu(e,t=gr()){try{t==null||t.setItem(pr,e)}catch{}}class ju extends at.Component{constructor(t){super(t),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=at.createRef(),this.containerRef=at.createRef(),this.stickyGroupRef=at.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,i=this.containerRef.current;!n||!i||(this.stickyObserver=new ResizeObserver(()=>{i.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var a,o;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const i=n.target;(a=i==null?void 0:i.closest)!=null&&a.call(i,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(o=this.searchRef.current)==null||o.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(tl),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const t=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(t,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var t;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(t=this.stickyObserver)==null||t.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(t){return t.filter(n=>n.busy).length}async fetchDevices(){try{const t=await Y.getDevices(),n=this.getBusyDevicesCount(t),i=await Y.getPendingSessionsCount(),r=await Y.getQueueSummary();this.setState({devices:t,activeSessionsCount:n,pendingSessionsCount:i,queueSummary:r,loaded:!0})}catch(t){console.log(t),this.setState({loaded:!0})}}setFilters(t){this.props.onFiltersChange({...this.props.filters,...t})}getFiltered(){const t=Date.now();return this.state.devices.filter(n=>qt(n,this.props.filters,t))}render(){const t=this.getFiltered(),{udid:n}=this.props.params,i=n?this.state.devices.find(l=>l.udid===n):null,{filters:r}=this.props,a=rl(this.state.devices,r,Date.now()),o=[{value:"all",label:"Any platform",count:a.platform.all},{value:"android",label:"Android",count:a.platform.android},{value:"ios",label:"iOS",count:a.platform.ios}];(al(this.state.devices)||r.platform==="tvos")&&o.push({value:"tvos",label:"tvOS",count:a.platform.tvos});const d=[{value:"all",label:"Any type",count:a.type.all},{value:"real",label:"Real devices",count:a.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:a.type.virtual}],c=`/devices${this.props.locationSearch}`;return s.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[s.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[s.jsx(Mr,{icon:Ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),s.jsxs("div",{className:"de2-toolbar",children:[s.jsx(xn,{size:"sm",label:"Status",value:r.status,onChange:l=>this.setFilters({status:l}),segments:[{value:"all",label:"All",count:a.status.all},{value:"ready",label:"Ready",tone:"ready",count:a.status.ready},{value:"busy",label:"Busy",tone:"busy",count:a.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:a.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:a.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:a.status.offline}]}),s.jsxs("div",{className:"de2-toolbar-row",children:[s.jsxs("div",{className:"de2-search-wrap",children:[s.jsx(Ps,{size:13,className:"de2-search-icon","aria-hidden":"true"}),s.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:r.q,onChange:l=>this.setFilters({q:l.target.value})}),s.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),s.jsx(wn,{name:"Platform",value:r.platform,anyValue:"all",options:o,onChange:l=>this.setFilters({platform:l})}),s.jsx(wn,{name:"Type",value:r.type,anyValue:"all",options:d,onChange:l=>this.setFilters({type:l})}),ol(r)&&s.jsx(U,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),s.jsxs("div",{className:"de2-result",children:[s.jsx(xn,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&s.jsx("span",{"aria-live":"polite",children:ll(t.length,this.state.devices.length)}),s.jsx(U,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:s.jsx(Vt,{size:13,"aria-hidden":"true"})})]})]})]})]}),t.length>0?this.props.view==="table"?s.jsx(vl,{devices:t,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):s.jsx(el,{devices:t,reloadDevices:()=>this.fetchDevices()}):s.jsxs("div",{className:"device-explorer-empty stagger-1",children:[s.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?s.jsx(Ns,{size:32}):s.jsx(Vt,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Global Device Registry Empty"}),s.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),s.jsxs(U,{variant:"primary",onClick:()=>this.fetchDevices(),children:[s.jsx(Vt,{size:14}),"Manual sync"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"No devices match these filters"}),s.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),s.jsx(U,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Loading devices…"}),s.jsx("p",{children:"Syncing the global device registry."})]})]}),i&&s.jsx(lc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(c),children:s.jsx("div",{className:"device-control-modal",children:s.jsx(vu,{device:i,titleId:"device-control-title",onClose:()=>this.props.navigate(c)})})})]})}}function rh(){const e=ii(),t=$t(),n=ns(),[i,r]=Ar(),{on:a}=Rr(),o=sl(i),d=yu(i,si()),c=ml(i),l=(h,m,g)=>{const f=nl(h);xu(f,m,si()),fl(f,g),r(f,{replace:!0})};return s.jsx(ju,{params:e,navigate:t,onSocketEvent:a,filters:o,onFiltersChange:h=>l(h,d,c),view:d,onViewChange:h=>{bu(h),l(o,h,c)},sort:c,onSortChange:h=>l(o,d,h),locationSearch:n.search})}export{ju as DeviceExplorer,rh as default};
|