@xenon-device-management/xenon 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{AnnotationOverlay-CpoWcXKP.js → AnnotationOverlay-PMj0TMCJ.js} +1 -1
  3. package/lib/public/assets/{ApiKeyGate-DAYuoJDl.js → ApiKeyGate-DXo-ecxe.js} +1 -1
  4. package/lib/public/assets/BugReportButton-DY9ltq27.js +15 -0
  5. package/lib/public/assets/{DeviceMosaicView-C-sJRz63.js → DeviceMosaicView-CT7nA_re.js} +1 -1
  6. package/lib/public/assets/{EmptyState-B_JRYedM.js → EmptyState-DX4jwZ9l.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-CorXlSLU.js → FieldGroup-Czk8gPhv.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-BKv95DEc.js → FilterMenu-DTblXm4v.js} +1 -1
  9. package/lib/public/assets/{Menu-Cpy5yMwg.js → Menu-CdGgXICe.js} +1 -1
  10. package/lib/public/assets/{Modal-Djp4NvyZ.js → Modal-CtzTciQY.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-CP57OKw9.js → RecordingPage-BjJH7AyA.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-BjrTit38.js → RecordingsPage-BkgX2xkA.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-MGTzJhBf.js → SegmentedControl-DEXgl8Qw.js} +1 -1
  14. package/lib/public/assets/{SettingCard-CYBPhKPe.js → SettingCard-BnwAoJhk.js} +1 -1
  15. package/lib/public/assets/{Table-CdKQ9hnU.js → Table-hmNY-ICS.js} +1 -1
  16. package/lib/public/assets/{activity-QsRK21QF.js → activity-Bmuu2fcZ.js} +1 -1
  17. package/lib/public/assets/{ai-settings-Dn6DtRn7.js → ai-settings-uAzHwRK_.js} +1 -1
  18. package/lib/public/assets/{api-keys-DYyf17eU.js → api-keys-CFZeXLs7.js} +1 -1
  19. package/lib/public/assets/{apps-HKFKTe1J.js → apps-DgwQRGg6.js} +1 -1
  20. package/lib/public/assets/{arrow-left-BkA7oMRe.js → arrow-left-D5x8OLs-.js} +1 -1
  21. package/lib/public/assets/{arrow-right-BsSr58EU.js → arrow-right-DRYGEjl5.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-B7TEV_Gr.js → arrow-up-right-DLtHJsd6.js} +1 -1
  23. package/lib/public/assets/{auth-shell-BlmNHGcG.js → auth-shell-D_TLCi0Y.js} +2 -2
  24. package/lib/public/assets/builds-page-CwKR7w5o.js +11 -0
  25. package/lib/public/assets/{button-BIwCF2bR.js → button-CbVMa9PL.js} +1 -1
  26. package/lib/public/assets/{calendar-CMLnXC7N.js → calendar-DgmwU-Oq.js} +1 -1
  27. package/lib/public/assets/{check-zugO3p5U.js → check-Du5vvLoJ.js} +1 -1
  28. package/lib/public/assets/{chevron-left-sCqxpTY6.js → chevron-left-CiRlzB7w.js} +1 -1
  29. package/lib/public/assets/{chevron-right-Bb59xwZc.js → chevron-right-i93nTPHX.js} +1 -1
  30. package/lib/public/assets/{circle-check-DsvxbnTg.js → circle-check-DxYO7yp5.js} +1 -1
  31. package/lib/public/assets/{circle-x-w69AbmbW.js → circle-x-Dw1DFg0I.js} +1 -1
  32. package/lib/public/assets/{clock-C6XOs4bc.js → clock-0q-GqRU0.js} +1 -1
  33. package/lib/public/assets/{copy-pHk-SWBM.js → copy-Ds-F075f.js} +1 -1
  34. package/lib/public/assets/{device-explorer-BDq38IcO.js → device-explorer-Dsldlx2g.js} +54 -64
  35. package/lib/public/assets/{download-CAHtPZmY.js → download-BdJEWL8b.js} +1 -1
  36. package/lib/public/assets/{forgot-password-cmvhGOUu.js → forgot-password-D7eNuw-V.js} +1 -1
  37. package/lib/public/assets/{funnel-BrDuhOtM.js → funnel-CY3Ovebz.js} +1 -1
  38. package/lib/public/assets/{index-C-Q4QkXb.js → index-BpJwb7cQ.js} +1 -1
  39. package/lib/public/assets/{index-hymrhlEZ.css → index-C8pvxG1f.css} +1 -1
  40. package/lib/public/assets/{index-BQCXPOXt.js → index-tW_VASh2.js} +2 -2
  41. package/lib/public/assets/{input-DnUVHYax.js → input-DvCYrL_q.js} +1 -1
  42. package/lib/public/assets/{keycodes-CmOptFVa.js → keycodes-CyOBCkU6.js} +1 -1
  43. package/lib/public/assets/{layers-DRtz_bzF.js → layers-ChEcsAc2.js} +1 -1
  44. package/lib/public/assets/list-checks-EWcywAEC.js +6 -0
  45. package/lib/public/assets/{lock-DF2VnPFm.js → lock-DmkRlmQB.js} +1 -1
  46. package/lib/public/assets/{login-DHYffYa4.js → login-BXeYWAn-.js} +1 -1
  47. package/lib/public/assets/{maintenance-settings-r0uPsJ6n.js → maintenance-settings-Cd37WZ5e.js} +1 -1
  48. package/lib/public/assets/{monitor-7nt9oGNx.js → monitor-BTqiDmvk.js} +1 -1
  49. package/lib/public/assets/{mouse-pointer-2-ys1MKVr2.js → mouse-pointer-2-BrwX4M5d.js} +1 -1
  50. package/lib/public/assets/{network-B8m-F79k.js → network-8uySyPSM.js} +1 -1
  51. package/lib/public/assets/{overview-BHEntlXz.js → overview-CdBGYC95.js} +1 -1
  52. package/lib/public/assets/{page-header-CuFXVUop.js → page-header-BYzd5kfp.js} +1 -1
  53. package/lib/public/assets/{plus-DUSlMac2.js → plus-BIekJsya.js} +1 -1
  54. package/lib/public/assets/{profile-page-CBamPy_h.js → profile-page-a-nQ7xFX.js} +1 -1
  55. package/lib/public/assets/{reset-password-DG0vZl-o.js → reset-password-7Gbj29w1.js} +1 -1
  56. package/lib/public/assets/{runbook-page-5S3T-I4g.js → runbook-page-Bgd9u7W6.js} +1 -1
  57. package/lib/public/assets/{select-f0ci1QC7.js → select-DEpRzm_3.js} +1 -1
  58. package/lib/public/assets/{selector-detail-page-BXA9LUf9.js → selector-detail-page-CvqjXfvp.js} +1 -1
  59. package/lib/public/assets/{selector-health-TyMPgAWo.js → selector-health-BEzkwE_K.js} +1 -1
  60. package/lib/public/assets/{selector-health-page-uBlXy33G.js → selector-health-page-Dl_IE1Je.js} +1 -1
  61. package/lib/public/assets/session-detail-page-CuF_EwRE.js +4 -0
  62. package/lib/public/assets/{settings-IfOFbqtv.js → settings-CxLw5tlF.js} +1 -1
  63. package/lib/public/assets/stat-tile-DFuoxV5Y.js +6 -0
  64. package/lib/public/assets/{tablet-lmFk4qxW.js → tablet-DJBOerD6.js} +1 -1
  65. package/lib/public/assets/{teams-CwMSjVVW.js → teams-CDQQdVRl.js} +1 -1
  66. package/lib/public/assets/{trash-2-BKsgmBS6.js → trash-2-B_zQvjI3.js} +1 -1
  67. package/lib/public/assets/{upload-DXH47sQS.js → upload-9FV8q3NB.js} +1 -1
  68. package/lib/public/assets/{use-password-reset-mode-DU98dxpc.js → use-password-reset-mode-Cx5GHMnk.js} +1 -1
  69. package/lib/public/assets/{users-V5O64rVx.js → users-DC0IoOuZ.js} +1 -1
  70. package/lib/public/assets/{users-eXWwQZjX.js → users-ep-SOGaV.js} +1 -1
  71. package/lib/public/assets/{video-off-BuoIHEYy.js → video-off-BmUg-gKW.js} +1 -1
  72. package/lib/public/assets/{webhook-settings-ClsxsKnC.js → webhook-settings-CwUBzLGC.js} +1 -1
  73. package/lib/public/assets/{zap-I10vdQXd.js → zap-CBld_5xf.js} +1 -1
  74. package/lib/public/index.html +2 -2
  75. package/lib/src/app/routers/dashboard.js +45 -3
  76. package/lib/src/app/routers/sessionInsights.js +221 -0
  77. package/lib/test/unit/session-list-insights.spec.js +354 -0
  78. package/lib/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +1 -1
  80. package/lib/public/assets/BugReportButton-DEXyENUv.js +0 -10
  81. package/lib/public/assets/builds-page-E4WIKtl8.js +0 -6
  82. package/lib/public/assets/session-detail-page-DECim5lh.js +0 -3
  83. package/lib/public/assets/status-pill-outline-grXLf8I8.js +0 -1
@@ -1,221 +1,211 @@
1
- import{c as P,j as e,r as c,C as Ms,U as Hn,X as M,t as Ve,v as sn,b as Wn,u as mt,a as Mt,T as qn,q as ns,R as Fe,w as Kn,x as _s,y as $e,z as hs,I as nn,S as Nt,f as ct,A as St,i as an,B as Xn,D as Gn,E as Yn,p as Zn}from"./index-BQCXPOXt.js";import{P as Jn}from"./page-header-CuFXVUop.js";import{P as Ct,B as Qn}from"./BugReportButton-DEXyENUv.js";import{A as ea}from"./activity-QsRK21QF.js";import{h as ta,S as rn,C as sa,H as na,a as Gt,A as ot,I as Yt}from"./keycodes-CmOptFVa.js";import{p as _t}from"./labels-C21SA4JG.js";import{B as Y}from"./button-BIwCF2bR.js";import{S as ms}from"./select-f0ci1QC7.js";import{P as on,M as cn,a as pe,b as aa}from"./Menu-Cpy5yMwg.js";import{M as ps}from"./Modal-Djp4NvyZ.js";import{F as $t}from"./FieldGroup-CorXlSLU.js";import{C as ia}from"./clock-C6XOs4bc.js";import{P as ra}from"./plus-DUSlMac2.js";import{C as Te}from"./copy-pHk-SWBM.js";import{T as oa}from"./tablet-lmFk4qxW.js";import{S as ca,a as zs}from"./SegmentedControl-MGTzJhBf.js";import{T as la,a as da,b as ln,c as At,d as ua,e as Oe}from"./Table-CdKQ9hnU.js";import{f as ha}from"./time-B8FIgwPE.js";import{L as dn}from"./layers-DRtz_bzF.js";import{C as ma}from"./chevron-right-Bb59xwZc.js";import{M as Ls}from"./mouse-pointer-2-ys1MKVr2.js";import{Z as un}from"./zap-I10vdQXd.js";import{C as dt}from"./check-zugO3p5U.js";import{C as hn}from"./circle-check-DsvxbnTg.js";import{C as mn}from"./circle-x-w69AbmbW.js";import{D as pa}from"./download-CAHtPZmY.js";import{T as as}from"./trash-2-BKsgmBS6.js";import{U as fa,T as ya}from"./upload-DXH47sQS.js";import{A as xa}from"./arrow-left-BkA7oMRe.js";import{A as va}from"./arrow-right-BsSr58EU.js";import{C as Os}from"./chevron-left-sCqxpTY6.js";import{L as ga}from"./lock-DF2VnPFm.js";import{F as Ps}from"./FilterMenu-BKv95DEc.js";import"./utils-CDN07tui.js";import"./index-C-Q4QkXb.js";/**
1
+ import{c as U,j as e,r as c,C as Ms,U as Hn,X as M,t as Ve,v as sn,b as Wn,u as ht,a as Mt,T as qn,q as ns,R as Fe,w as Kn,x as _s,y as $e,z as ms,I as nn,S as Nt,f as ct,A as St,i as an,B as Xn,D as Gn,E as Yn,p as Zn}from"./index-tW_VASh2.js";import{P as Jn}from"./page-header-BYzd5kfp.js";import{P as Ct,S as Qn,B as ea}from"./BugReportButton-DY9ltq27.js";import{A as ta}from"./activity-Bmuu2fcZ.js";import{h as sa,S as rn,C as na,H as aa,a as Gt,A as ot,I as Yt}from"./keycodes-CyOBCkU6.js";import{p as _t}from"./labels-C21SA4JG.js";import{B as Y}from"./button-CbVMa9PL.js";import{S as hs}from"./select-DEpRzm_3.js";import{P as on,M as cn,a as pe,b as ia}from"./Menu-CdGgXICe.js";import{M as ps}from"./Modal-CtzTciQY.js";import{F as $t}from"./FieldGroup-Czk8gPhv.js";import{C as ra}from"./clock-0q-GqRU0.js";import{P as oa}from"./plus-BIekJsya.js";import{C as Te}from"./copy-Ds-F075f.js";import{T as ca}from"./tablet-DJBOerD6.js";import{S as la,a as zs}from"./SegmentedControl-DEXgl8Qw.js";import{T as da,a as ua,b as ln,c as At,d as ma,e as Oe}from"./Table-hmNY-ICS.js";import{f as ha}from"./time-B8FIgwPE.js";import{L as dn}from"./layers-ChEcsAc2.js";import{C as pa}from"./chevron-right-i93nTPHX.js";import{M as Ls}from"./mouse-pointer-2-BrwX4M5d.js";import{L as fa}from"./list-checks-EWcywAEC.js";import{Z as un}from"./zap-CBld_5xf.js";import{C as dt}from"./check-Du5vvLoJ.js";import{C as mn}from"./circle-check-DxYO7yp5.js";import{C as hn}from"./circle-x-Dw1DFg0I.js";import{D as ya}from"./download-BdJEWL8b.js";import{T as as}from"./trash-2-B_zQvjI3.js";import{U as xa,T as va}from"./upload-9FV8q3NB.js";import{A as ga}from"./arrow-left-D5x8OLs-.js";import{A as ba}from"./arrow-right-DRYGEjl5.js";import{C as Os}from"./chevron-left-CiRlzB7w.js";import{L as ja}from"./lock-DmkRlmQB.js";import{F as Ps}from"./FilterMenu-DTblXm4v.js";import"./utils-CDN07tui.js";import"./index-BpJwb7cQ.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ba=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],fs=P("arrow-down",ba);/**
6
+ */const Na=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],fs=U("arrow-down",Na);/**
7
7
  * @license lucide-react v0.555.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const ja=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ys=P("arrow-up",ja);/**
11
+ */const ka=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ys=U("arrow-up",ka);/**
12
12
  * @license lucide-react v0.555.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Na=[["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"}]],ka=P("battery-low",Na);/**
16
+ */const wa=[["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"}]],Sa=U("battery-low",wa);/**
17
17
  * @license lucide-react v0.555.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const wa=[["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"}]],Sa=P("battery-warning",wa);/**
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"}]],$a=U("battery-warning",Ca);/**
22
22
  * @license lucide-react v0.555.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const Ca=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],$a=P("battery",Ca);/**
26
+ */const Ta=[["path",{d:"M 22 14 L 22 10",key:"nqc4tb"}],["rect",{x:"2",y:"6",width:"16",height:"12",rx:"2",key:"13zb55"}]],Ra=U("battery",Ta);/**
27
27
  * @license lucide-react v0.555.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const Ta=[["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"}]],Ra=P("box",Ta);/**
31
+ */const Aa=[["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"}]],Ea=U("box",Aa);/**
32
32
  * @license lucide-react v0.555.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Aa=[["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"}]],Ea=P("calendar-plus",Aa);/**
36
+ */const Da=[["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"}]],Ia=U("calendar-plus",Da);/**
37
37
  * @license lucide-react v0.555.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const Da=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],Ia=P("case-sensitive",Da);/**
41
+ */const Ma=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],_a=U("case-sensitive",Ma);/**
42
42
  * @license lucide-react v0.555.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const Ma=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],_a=P("chevrons-down-up",Ma);/**
46
+ */const za=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],La=U("chevrons-down-up",za);/**
47
47
  * @license lucide-react v0.555.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const za=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],La=P("chevrons-up-down",za);/**
51
+ */const Oa=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Pa=U("chevrons-up-down",Oa);/**
52
52
  * @license lucide-react v0.555.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const Oa=[["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"}]],Pa=P("circle-question-mark",Oa);/**
56
+ */const Fa=[["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"}]],Ua=U("circle-question-mark",Fa);/**
57
57
  * @license lucide-react v0.555.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const Fa=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Fs=P("code-xml",Fa);/**
61
+ */const Ba=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Fs=U("code-xml",Ba);/**
62
62
  * @license lucide-react v0.555.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const Ua=[["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"}]],Ba=P("crosshair",Ua);/**
66
+ */const Va=[["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"}]],Ha=U("crosshair",Va);/**
67
67
  * @license lucide-react v0.555.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const Va=[["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"}]],Ha=P("ellipsis",Va);/**
71
+ */const Wa=[["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"}]],qa=U("ellipsis",Wa);/**
72
72
  * @license lucide-react v0.555.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const Wa=[["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"}]],qa=P("hand",Wa);/**
76
+ */const Ka=[["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"}]],Xa=U("hand",Ka);/**
77
77
  * @license lucide-react v0.555.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const Ka=[["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"}]],Xa=P("image",Ka);/**
81
+ */const Ga=[["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"}]],Ya=U("image",Ga);/**
82
82
  * @license lucide-react v0.555.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const Ga=[["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"}]],Ya=P("keyboard",Ga);/**
86
+ */const Za=[["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"}]],Ja=U("keyboard",Za);/**
87
87
  * @license lucide-react v0.555.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Za=[["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"}]],Ja=P("library",Za);/**
91
+ */const Qa=[["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"}]],ei=U("library",Qa);/**
92
92
  * @license lucide-react v0.555.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const Qa=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],ei=P("list-checks",Qa);/**
96
+ */const ti=[["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"}]],si=U("lock-open",ti);/**
97
97
  * @license lucide-react v0.555.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
100
100
  * See the LICENSE file in the root directory of this source tree.
101
- */const ti=[["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"}]],si=P("lock-open",ti);/**
101
+ */const ni=[["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"}]],ai=U("map-pin",ni);/**
102
102
  * @license lucide-react v0.555.0 - ISC
103
103
  *
104
104
  * This source code is licensed under the ISC license.
105
105
  * See the LICENSE file in the root directory of this source tree.
106
- */const ni=[["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"}]],ai=P("map-pin",ni);/**
106
+ */const ii=[["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"}]],ri=U("message-square",ii);/**
107
107
  * @license lucide-react v0.555.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const ii=[["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"}]],ri=P("message-square",ii);/**
111
+ */const oi=[["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"}]],ci=U("moon-star",oi);/**
112
112
  * @license lucide-react v0.555.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const oi=[["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"}]],ci=P("moon-star",oi);/**
116
+ */const li=[["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"}]],di=U("mouse-pointer-click",li);/**
117
117
  * @license lucide-react v0.555.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const li=[["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"}]],di=P("mouse-pointer-click",li);/**
121
+ */const ui=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],mi=U("package",ui);/**
122
122
  * @license lucide-react v0.555.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const ui=[["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"}]],hi=P("package",ui);/**
126
+ */const hi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],pi=U("panel-top",hi);/**
127
127
  * @license lucide-react v0.555.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const mi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],pi=P("panel-top",mi);/**
131
+ */const fi=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],yi=U("rectangle-horizontal",fi);/**
132
132
  * @license lucide-react v0.555.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const fi=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]],yi=P("rectangle-horizontal",fi);/**
136
+ */const xi=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],vi=U("rectangle-vertical",xi);/**
137
137
  * @license lucide-react v0.555.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const xi=[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]],vi=P("rectangle-vertical",xi);/**
141
+ */const gi=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],lt=U("rotate-cw",gi);/**
142
142
  * @license lucide-react v0.555.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const gi=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],lt=P("rotate-cw",gi);/**
146
+ */const bi=[["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"}]],pn=U("scroll-text",bi);/**
147
147
  * @license lucide-react v0.555.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const bi=[["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"}]],pn=P("scroll-text",bi);/**
151
+ */const ji=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ze=U("shield-alert",ji);/**
152
152
  * @license lucide-react v0.555.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const ji=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Ze=P("shield-alert",ji);/**
156
+ */const Ni=[["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"}]],ki=U("tag",Ni);/**
157
157
  * @license lucide-react v0.555.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Ni=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],ki=P("sparkles",Ni);/**
161
+ */const wi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Zt=U("target",wi);/**
162
162
  * @license lucide-react v0.555.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const wi=[["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"}]],Si=P("tag",wi);/**
166
+ */const Si=[["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"}]],Ci=U("text-cursor-input",Si);/**
167
167
  * @license lucide-react v0.555.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const Ci=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Zt=P("target",Ci);/**
171
+ */const $i=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Ti=U("text-wrap",$i);/**
172
172
  * @license lucide-react v0.555.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const $i=[["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"}]],Ti=P("text-cursor-input",$i);/**
176
+ */const Ri=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ai=U("thermometer",Ri);/**
177
177
  * @license lucide-react v0.555.0 - ISC
178
178
  *
179
179
  * This source code is licensed under the ISC license.
180
180
  * See the LICENSE file in the root directory of this source tree.
181
- */const Ri=[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],Ai=P("text-wrap",Ri);/**
181
+ */const Ei=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Di=U("toggle-left",Ei);/**
182
182
  * @license lucide-react v0.555.0 - ISC
183
183
  *
184
184
  * This source code is licensed under the ISC license.
185
185
  * See the LICENSE file in the root directory of this source tree.
186
- */const Ei=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Di=P("thermometer",Ei);/**
186
+ */const Ii=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]],Us=U("touchpad",Ii);/**
187
187
  * @license lucide-react v0.555.0 - ISC
188
188
  *
189
189
  * This source code is licensed under the ISC license.
190
190
  * See the LICENSE file in the root directory of this source tree.
191
- */const Ii=[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Mi=P("toggle-left",Ii);/**
191
+ */const Mi=[["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"}]],_i=U("type",Mi);/**
192
192
  * @license lucide-react v0.555.0 - ISC
193
193
  *
194
194
  * This source code is licensed under the ISC license.
195
195
  * See the LICENSE file in the root directory of this source tree.
196
- */const _i=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"M2 14h20",key:"myj16y"}],["path",{d:"M12 20v-6",key:"1rm09r"}]],Us=P("touchpad",_i);/**
196
+ */const zi=[["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"}]],Li=U("volume-1",zi);/**
197
197
  * @license lucide-react v0.555.0 - ISC
198
198
  *
199
199
  * This source code is licensed under the ISC license.
200
200
  * See the LICENSE file in the root directory of this source tree.
201
- */const zi=[["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"}]],Li=P("type",zi);/**
201
+ */const Oi=[["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"}]],Pi=U("volume-2",Oi);/**
202
202
  * @license lucide-react v0.555.0 - ISC
203
203
  *
204
204
  * This source code is licensed under the ISC license.
205
205
  * See the LICENSE file in the root directory of this source tree.
206
- */const Oi=[["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"}]],Pi=P("volume-1",Oi);/**
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 Fi=[["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"}]],Ui=P("volume-2",Fi);/**
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 Bi=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Vi=P("wifi",Bi);function Hi(t){return t>=50?"ready":t>=20?"warning":"error"}function Wi(t){return t>=50?e.jsx($a,{size:10}):t>=20?e.jsx(ka,{size:10}):e.jsx(Sa,{size:10})}function qi(t){return t==="Normal"?"ready":t==="Critical"?"error":"warning"}const Ki=({device:t})=>{if(t.deviceType==="emulator"||t.deviceType==="simulator"||t.offline)return null;const n=typeof t.batteryLevel=="number",a=typeof t.thermalStatus=="string"&&t.thermalStatus.length>0&&t.thermalStatus!=="Unknown";return!n&&!a?e.jsx("div",{className:"dc2-health",children:e.jsxs(Ct,{tone:"neutral",title:"Device does not report battery or thermal data",children:[e.jsx(ea,{size:10}),"No telemetry"]})}):e.jsxs("div",{className:"dc2-health",children:[n&&e.jsxs(Ct,{tone:Hi(t.batteryLevel),title:`Battery ${t.batteryLevel}%`,children:[Wi(t.batteryLevel),t.batteryLevel,"%"]}),a&&e.jsxs(Ct,{tone:qi(t.thermalStatus),title:`Thermal: ${t.thermalStatus}`,children:[e.jsx(Di,{size:10}),t.thermalStatus]})]})};function Xi(t){if(typeof t!="number")throw new TypeError("Expected a number");const s=t>0?Math.floor:Math.ceil;return{days:s(t/864e5),hours:s(t/36e5)%24,minutes:s(t/6e4)%60,seconds:s(t/1e3)%60,milliseconds:s(t)%1e3,microseconds:s(t*1e3)%1e3,nanoseconds:s(t*1e6)%1e3}}const Gi=(t,s)=>s===1?t:`${t}s`,Yi=1e-7;function fn(t,s={}){if(!Number.isFinite(t))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],a=(l,u)=>{const d=Math.floor(l*10**u+Yi);return(Math.round(d)/10**u).toFixed(u)},o=(l,u,d,i)=>{if((n.length===0||!s.colonNotation)&&l===0&&!(s.colonNotation&&d==="m"))return;i=(i||l||"0").toString();let m,x;if(s.colonNotation){m=n.length>0?":":"",x="";const k=i.includes(".")?i.split(".")[0].length:i.length,f=n.length>0?2:1;i="0".repeat(Math.max(0,f-k))+i}else m="",x=s.verbose?" "+Gi(u,l):d;n.push(m+i+x)},r=Xi(t);if(o(Math.trunc(r.days/365),"year","y"),o(r.days%365,"day","d"),o(r.hours,"hour","h"),o(r.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&t<1e3)if(o(r.seconds,"second","s"),s.formatSubMilliseconds)o(r.milliseconds,"millisecond","ms"),o(r.microseconds,"microsecond","µs"),o(r.nanoseconds,"nanosecond","ns");else{const l=r.milliseconds+r.microseconds/1e3+r.nanoseconds/1e6,u=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=l>=1?Math.round(l):Math.ceil(l),i=u?l.toFixed(u):d;o(Number.parseFloat(i),"millisecond","ms",i)}else{const l=t/1e3%60,u=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=a(l,u),i=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");o(Number.parseFloat(i),"second","s",i)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const l=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(l)}return s.colonNotation?n.join(""):n.join(" ")}const Jt=6e4;function Zi(t){return!Number.isFinite(t)||t<=0?"expiring":t<Jt?"under 1m":fn(Math.floor(t/Jt)*Jt,{unitCount:2})}const is=["ready","busy","reserved","maintenance","offline"],yn={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function ut(t,s){return t.offline?"offline":t.userBlocked?"maintenance":t.busy?"busy":t.reservedUntil&&s<t.reservedUntil?"reserved":"ready"}function xn(t,s){const n=ta(t);if(!t.busy||!n)return null;const a=String(n);return a.startsWith("manual_")?s!=null&&s.userId&&a===`manual_${s.userId}_${t.udid}`?"self":"other":"session"}const Bs=t=>(t==null?void 0:t.role)==="ADMIN"||(t==null?void 0:t.role)==="SUPER_ADMIN";function Ji(t,s,n){switch(xn(t,s)){case"session":return t.sessionStartTime&&t.sessionStartTime>0&&n>t.sessionStartTime?`Test session · ${fn(n-t.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(t.reservedUntil&&n<t.reservedUntil){const o=!!t.reservedBy&&(t.reservedBy===(s==null?void 0:s.email)||t.reservedBy===(s==null?void 0:s.name))?"you":t.reservedBy||"another user";return`${Zi(t.reservedUntil-n)} left · by ${o}`}return null}function Qi(t,s){if(t.offline)return{enabled:!1,reason:"Device is offline"};if(t.userBlocked&&!Bs(s))return{enabled:!1,reason:"In maintenance"};const n=xn(t,s);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!Bs(s)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function Me(t){var s;return((s=t.marketingName)==null?void 0:s.trim())||t.name}function vn(t){const s=[_t(t.platform),t.sdk].filter(Boolean).join(" ");if(t.deviceType==="emulator")return`Emulator · ${s}`;if(t.deviceType==="simulator")return`Simulator · ${s}`;const a=[t.manufacturer?t.manufacturer.charAt(0).toUpperCase()+t.manufacturer.slice(1):"",t.model].filter(Boolean).join(" ");return a?`${a} · ${s}`:s}function er(t){return t.formFactor==="tablet"||t.formFactor==="tv"?t.formFactor:"phone"}function Qe(t,s){return t.teamId?(s==null?void 0:s.get(t.teamId))??t.teamName??`Team ${t.teamId.slice(0,6)}`:null}const tr=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],sr=({device:t,onClose:s,onReserved:n})=>{const[a,o]=c.useState(""),[r,l]=c.useState("1h"),[u,d]=c.useState(""),[i,m]=c.useState(!1),[x,k]=c.useState(null),[f,y]=c.useState(null),S=async()=>{if(!a.trim()){k("Please enter your name/ID");return}m(!0),k(null),y(null);try{const C=await M.reserveDevice(t.udid,t.host,a,r,u);C.success?(n(),s()):y(C.error||"Failed to reserve device")}catch(C){y(C.message||"An unexpected error occurred")}finally{m(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(Ea,{size:16,className:"title-icon"}),"Reserve device"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,disabled:i,children:"Cancel"}),e.jsx("button",{className:"btn-reserve",onClick:S,disabled:i||!a.trim(),children:i?"Reserving...":"Confirm Reservation"})]}),children:e.jsxs("div",{className:"reservation-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsxs("p",{children:["Reserve ",e.jsx("strong",{children:t.name||t.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(Hn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:x?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),x]}):void 0,children:e.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:a,onChange:C=>{o(C.target.value),x&&k(null)},disabled:i})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(ia,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:e.jsx("div",{className:"duration-selector",children:tr.map(C=>e.jsx("div",{className:`duration-option ${r===C.value?"active":""}`,onClick:()=>l(C.value),children:C.label},C.value))})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(ri,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:e.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:u,onChange:C=>d(C.target.value),disabled:i})})]})})},nr=({device:t,onClose:s,onUpdated:n})=>{const{toast:a}=Ve(),[o,r]=c.useState(t.tags||[]),[l,u]=c.useState(""),[d,i]=c.useState(!1),m=c.useRef(null);c.useEffect(()=>{m.current&&m.current.focus()},[]);const x=()=>{const S=l.trim();S&&!o.includes(S)&&(r([...o,S]),u(""))},k=S=>{r(o.filter(C=>C!==S))},f=S=>{S.key==="Enter"&&x()},y=async()=>{i(!0);try{await M.updateDeviceTags(t.udid,t.host,o),n(),s()}catch(S){console.error("Failed to update tags",S),a("Error saving tags. Please try again.","error")}finally{i(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(Si,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),e.jsx("button",{className:"btn-save",onClick:y,disabled:d,children:d?"Saving...":"Apply Changes"})]}),children:e.jsxs("div",{className:"tag-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsx($t,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:e.jsxs("div",{className:"input-with-button",children:[e.jsx("input",{ref:m,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:l,onChange:S=>u(S.target.value),onKeyDown:f}),e.jsx("button",{className:"add-inline-btn",onClick:x,disabled:!l.trim(),children:e.jsx(ra,{size:16})})]})}),e.jsxs("div",{className:"tags-display-section",children:[e.jsx("label",{children:"Current Tags"}),e.jsx("div",{className:"tags-list",children:o.length>0?o.map(S=>e.jsxs("div",{className:"tag-pill-editable",children:[S,e.jsx("button",{className:"remove-tag",onClick:()=>k(S),children:e.jsx(sn,{size:12})})]},S)):e.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},ar="/wd/hub";function ir(t){return t==="android"?"UiAutomator2":"XCUITest"}function rr(t){return t==="android"?"Android":t==="tvos"?"tvOS":"iOS"}function or(t,s=ar){if(!t)return"—";try{const n=new URL(t.includes("://")?t:`http://${t}`),a=s.startsWith("/")?s:`/${s}`,o=n.pathname.replace(/\/$/,"");return o===a||o.endsWith(a)?`${n.protocol}//${n.host}${o}`:`${n.protocol}//${n.host}${a}`}catch{return t}}function cr(t){const s={platformName:rr(t.platform),"appium:automationName":ir(t.platform),"appium:udid":t.udid};return t.sdk&&t.sdk!=="Unknown"&&t.sdk!=="unknown"&&(s["appium:platformVersion"]=t.sdk),t.name&&(s["appium:deviceName"]=t.name),s}function lr(t){return JSON.stringify(cr(t),null,2)}const dr=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,ur=/^(?:\d{1,3}\.){3}\d{1,3}$/;function hr(t){const s=t.trim();return!s||dr.test(s)||!ur.test(s)?!1:s.split(".").every(n=>{const a=Number(n);return Number.isInteger(a)&&a>=0&&a<=255})}function mr(t){return t.ip&&hr(t.ip)?t.ip.trim():null}const gn=({udid:t,currentTeamId:s,teams:n,onDone:a,className:o})=>{const{toast:r}=Ve(),[l,u]=c.useState(!1);async function d(i){u(!0);try{await M.setDeviceTeam(t,i),r(i?"Device assigned":"Device returned to shared pool","success"),a(!0)}catch(m){r((m==null?void 0:m.message)||"Failed to update team","error")}finally{u(!1)}}return e.jsxs(ms,{selectSize:"sm",className:o,autoFocus:!0,"aria-label":"Team",disabled:l,defaultValue:s??"",onBlur:()=>a(!1),onChange:i=>d(i.target.value||null),children:[e.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([i,m])=>e.jsx("option",{value:i,children:m},i))]})};function bn(t,s){const[n,a]=c.useState(!1),[o,r]=c.useState(!1),[l,u]=c.useState(!1),{me:d}=Wn(),{toast:i}=Ve(),m=(d==null?void 0:d.role)==="ADMIN"||(d==null?void 0:d.role)==="SUPER_ADMIN",x=Date.now(),k=ut(t,x),f=k==="reserved",y=Ji(t,d,x),S=Qi(t,d),C=or(t.host),L=mr(t),w=async(O,W)=>{var V;try{await((V=navigator.clipboard)==null?void 0:V.writeText(O)),i(W,"success")}catch{i("Failed to copy","error")}},j=async()=>{await M.releaseReservation(t.udid,t.host),s()},$=async()=>{await M.blockDevice(t.udid,t.host),s()},p=async()=>{await M.unblockDevice(t.udid,t.host),s()},D=async()=>{t.userBlocked?await p():await $()},A=e.jsxs(e.Fragment,{children:[n&&e.jsx(sr,{device:t,onClose:()=>a(!1),onReserved:()=>s()}),o&&e.jsx(nr,{device:t,onClose:()=>r(!1),onUpdated:()=>s()})]});return{kind:k,reserved:f,activity:y,control:S,isAdmin:m,editingTeam:l,setEditingTeam:u,openReservation:()=>a(!0),openTagManager:()=>r(!0),release:j,toggleMaintenance:D,copy:w,serverUrl:C,ip:L,dialogs:A}}const jn=({device:t,actions:s,navigate:n,reasonId:a})=>{const{kind:o,reserved:r,control:l}=s;return e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"tonal",size:"sm",disabled:!l.enabled,"aria-describedby":l.enabled?void 0:a,onClick:()=>{l.enabled&&n(`/devices/${t.udid}/control`)},children:"Control"}),r?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.release,children:"Release"}):o==="ready"?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.openReservation,children:"Reserve"}):null]})},Nn=({device:t,actions:s})=>{const[n,a]=c.useState(!1),o=c.useRef(null),{isAdmin:r,serverUrl:l,ip:u,copy:d}=s;return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:o,type:"button",className:"dc2-more",onClick:()=>a(i=>!i),"aria-label":"More actions",children:e.jsx(Ha,{size:14})}),e.jsx(on,{open:n,onClose:()=>a(!1),anchorRef:o,children:e.jsxs(cn,{children:[e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(t.udid,"UDID copied")},children:"Copy UDID"}),l!=="—"&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(l,"Server URL copied")},children:"Copy server URL"}),u&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(u,"IP address copied")},children:"Copy IP address"}),e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(lr(t),"Session capabilities copied")},children:"Copy capabilities"}),r&&e.jsxs(e.Fragment,{children:[e.jsx(aa,{}),e.jsx(pe,{onClick:()=>{a(!1),s.openTagManager()},children:"Manage tags…"}),e.jsx(pe,{onClick:()=>{a(!1),s.setEditingTeam(!0)},children:"Assign team…"}),e.jsx(pe,{onClick:()=>{a(!1),s.toggleMaintenance()},children:t.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},pr=({device:t})=>{const s={phone:ns,tablet:oa,tv:qn}[er(t)],n=t.deviceType==="emulator"||t.deviceType==="simulator";return e.jsx(s,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},fr=({device:t,reloadDevices:s,navigate:n,teams:a})=>{var x,k,f;const o=bn(t,s),{kind:r,activity:l,control:u}=o,d=`dc2-reason-${t.udid}`,i=Me(t),m=Qe(t,a);return e.jsxs("div",{className:`dc2 dc2-${r}`,children:[e.jsxs("div",{className:`dc2-band dc2-band-${r}`,children:[e.jsxs("span",{className:"dc2-band-label",children:[e.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),yn[r]]}),l&&e.jsx("span",{className:"dc2-band-activity",title:l,children:l})]}),e.jsxs("div",{className:`dc2-body${r==="offline"?" dc2-dim":""}`,children:[e.jsxs("div",{className:"dc2-head",children:[e.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:e.jsx(pr,{device:t})}),e.jsxs("div",{className:"dc2-id",children:[e.jsx("div",{className:"dc2-title",title:`${i}
217
- ${t.udid}`,children:i}),e.jsx("div",{className:"dc2-subtitle",children:vn(t)})]})]}),e.jsxs("div",{className:"dc2-meta",children:[e.jsx(Ki,{device:t}),o.editingTeam?e.jsx(gn,{className:"dc2-team-picker",udid:t.udid,currentTeamId:t.teamId??null,teams:a??new Map,onDone:y=>{o.setEditingTeam(!1),y&&s()}}):m&&e.jsx(Ct,{tone:"accent",className:"dc2-team",title:`Team: ${m}`,children:m}),(x=t.tags)==null?void 0:x.slice(0,2).map(y=>e.jsxs("span",{className:"dc2-tag",title:y,children:["#",y]},y)),(((k=t.tags)==null?void 0:k.length)||0)>2&&e.jsxs("span",{className:"dc2-tag",children:["+",(((f=t.tags)==null?void 0:f.length)||0)-2]})]})]}),e.jsxs("div",{className:"dc2-foot",children:[e.jsx(jn,{device:t,actions:o,navigate:n,reasonId:d}),!u.enabled&&e.jsx("span",{id:d,className:"dc2-unavailable",title:u.reason,children:u.reason}),e.jsx("span",{className:"dc2-spacer"}),e.jsx(Nn,{device:t,actions:o})]}),o.dialogs]})};function yr(t){const s=mt(),{search:n}=Mt();return e.jsx(fr,{device:t.device,reloadDevices:t.reloadDevices,navigate:a=>s(`${a}${n}`),teams:t.teams})}class xr extends Fe.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){M.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return e.jsx("div",{className:"device-explorer-card-container",children:Fe.Children.toArray(this.props.devices.map(s=>e.jsx(yr,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const vr={status:"all",platform:"all",type:"all",q:""},kn=["all",...is],wn=["all","android","ios","tvos"],Sn=["all","real","virtual"];function Qt(t,s){return s.includes(t)?t:s[0]}function gr(t){const s=t.get("q")??"";return{status:Qt(t.get("status"),kn),platform:Qt(t.get("platform"),wn),type:Qt(t.get("type"),Sn),q:s.trim()?s:""}}function br(t){const s=new URLSearchParams;return t.status!=="all"&&s.set("status",t.status),t.platform!=="all"&&s.set("platform",t.platform),t.type!=="all"&&s.set("type",t.type),t.q.trim()&&s.set("q",t.q),s}function ht(t){return t.deviceType==="simulator"||t.deviceType==="emulator"?!0:!t.deviceType&&t.realDevice===!1}function xs(t){const s=(t.platform||"").toLowerCase();return s==="android"||s==="ios"||s==="tvos"?s:null}function jr(t){const s=t.deviceType==="emulator"?"Emulator":t.deviceType==="simulator"?"Simulator":"";return[Me(t),t.name,t.manufacturer,t.model,_t(t.platform),t.sdk,s,t.teamName,t.udid].filter(Boolean).join(" ").toLowerCase()}function Tt(t,s,n,a){if(a!=="status"&&s.status!=="all"&&ut(t,n)!==s.status||a!=="platform"&&s.platform!=="all"&&xs(t)!==s.platform||a!=="type"&&s.type!=="all"&&s.type==="virtual"!==ht(t))return!1;const o=s.q.toLowerCase().split(/\s+/).filter(Boolean);if(o.length===0)return!0;const r=jr(t);return o.every(l=>r.includes(l))}const es=t=>Object.fromEntries(t.map(s=>[s,0]));function Nr(t,s,n){const a=es(kn),o=es(wn),r=es(Sn);for(const l of t){if(Tt(l,s,n,"status")&&(a.all+=1,a[ut(l,n)]+=1),Tt(l,s,n,"platform")){o.all+=1;const u=xs(l);u&&(o[u]+=1)}Tt(l,s,n,"type")&&(r.all+=1,r[ht(l)?"virtual":"real"]+=1)}return{status:a,platform:o,type:r}}function kr(t){return t.some(s=>xs(s)==="tvos")}function wr(t){return t.status!=="all"||t.platform!=="all"||t.type!=="all"||t.q.trim()!==""}function Sr(t,s){const n=a=>a===1?"device":"devices";return t===s?`${s} ${n(s)}`:`${t} of ${s} ${n(s)}`}const rs={key:"status",dir:"asc"},Cr=["status","device","platform","type","team","host"],$r=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),Pe=(t,s)=>$r.compare(t,s);function Tr(t,s,n,a){switch(n){case"status":return is.indexOf(ut(t,a.now))-is.indexOf(ut(s,a.now));case"device":return Pe(Me(t),Me(s));case"platform":return Pe(t.platform||"",s.platform||"")||Pe(t.sdk||"",s.sdk||"");case"type":return Number(ht(t))-Number(ht(s));case"team":return Pe(Qe(t,a.teams)??"",Qe(s,a.teams)??"");case"host":return Pe(t.host||"",s.host||"")}}function Rr(t,s,n){const a=s.dir==="desc"?-1:1;return t.slice().sort((o,r)=>{if(s.key==="team"){const l=Qe(o,n.teams)===null,u=Qe(r,n.teams)===null;if(l!==u)return l?1:-1}return a*Tr(o,r,s.key,n)||Pe(Me(o),Me(r))||Pe(o.udid,r.udid)})}function Ar(t){const s=t.get("sort");return!s||!Cr.includes(s)?rs:{key:s,dir:t.get("dir")==="desc"?"desc":"asc"}}function Er(t,s){t.delete("sort"),t.delete("dir"),!(s.key===rs.key&&s.dir===rs.dir)&&(t.set("sort",s.key),s.dir==="desc"&&t.set("dir","desc"))}const Je=({sortKey:t,label:s,sort:n,onSortChange:a})=>{const o=n.key===t,r=o?n.dir:"asc";return e.jsx(At,{scope:"col","aria-sort":o?r==="asc"?"ascending":"descending":"none",children:e.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>a(o?{key:t,dir:r==="asc"?"desc":"asc"}:{key:t,dir:"asc"}),children:[s,o&&(r==="asc"?e.jsx(ys,{size:12,"aria-hidden":"true"}):e.jsx(fs,{size:12,"aria-hidden":"true"}))]})})},Dr=({device:t,reloadDevices:s,navigate:n,teams:a,showHost:o})=>{const r=bn(t,s),{kind:l,activity:u,control:d}=r,i=Me(t),m=vn(t),x=Qe(t,a),k=`${_t(t.platform)} ${t.sdk??""}`,f=t.tags??[],y=`devtable-reason-${t.udid}`;return e.jsxs(ln,{className:`devtable-row${l==="offline"?" is-offline":""}`,children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"devtable-line",children:[e.jsx(ca,{kind:l,className:"devtable-status-dot"})," ",yn[l]]}),u&&e.jsx("div",{className:"devtable-muted devtable-line",title:u,children:u})]}),e.jsxs(At,{scope:"row",className:"devtable-rowheader",title:`${i}
218
- ${t.udid}`,children:[e.jsx("div",{className:"devtable-title devtable-line",children:i}),e.jsx("div",{className:"devtable-muted devtable-line",title:m,children:m})]}),e.jsx(Oe,{title:k,children:k}),e.jsx(Oe,{children:ht(t)?"Virtual":"Real"}),e.jsx(Oe,{title:r.editingTeam?void 0:x??"Shared",children:r.editingTeam?e.jsx(gn,{udid:t.udid,currentTeamId:t.teamId??null,teams:a,onDone:S=>{r.setEditingTeam(!1),S&&s()}}):x??"Shared"}),e.jsxs(Oe,{title:f.join(", "),children:[f.slice(0,2).map(S=>e.jsxs("span",{className:"devtable-tag",children:["#",S]},S)),f.length>2&&e.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),o&&e.jsx(Oe,{title:t.host,children:t.host}),e.jsx(Oe,{className:"devtable-actions",title:d.enabled?void 0:d.reason,children:e.jsxs("div",{className:"devtable-actions-inner",children:[e.jsx(jn,{device:t,actions:r,navigate:n,reasonId:y}),!d.enabled&&e.jsx("span",{id:y,className:"sr-only",children:d.reason}),e.jsx(Nn,{device:t,actions:r})]})}),r.dialogs]})};function Ir({devices:t,reloadDevices:s,sort:n,onSortChange:a,navigate:o,teams:r}){const l=new Set(t.map(d=>d.host)).size>1||n.key==="host",u=Rr(t,n,{now:Date.now(),teams:r});return e.jsxs(la,{className:"devtable",children:[e.jsxs("caption",{className:"sr-only",children:["Devices, ",t.length," shown"]}),e.jsxs("colgroup",{children:[e.jsx("col",{className:"devtable-col-status"}),e.jsx("col",{}),e.jsx("col",{className:"devtable-col-platform"}),e.jsx("col",{className:"devtable-col-type"}),e.jsx("col",{className:"devtable-col-team"}),e.jsx("col",{className:"devtable-col-tags"}),l&&e.jsx("col",{className:"devtable-col-host"}),e.jsx("col",{className:"devtable-col-actions"})]}),e.jsx(da,{children:e.jsxs(ln,{children:[e.jsx(Je,{sortKey:"status",label:"Status",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"device",label:"Device",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"platform",label:"Platform",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"type",label:"Type",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"team",label:"Team",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Tags"}),l&&e.jsx(Je,{sortKey:"host",label:"Host",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Actions"})]})}),e.jsx(ua,{children:u.map(d=>e.jsx(Dr,{device:d,reloadDevices:s,navigate:o,teams:r,showHost:l},d.udid))})]})}function Mr(t){const s=mt(),{search:n}=Mt(),[a,o]=c.useState(new Map);return c.useEffect(()=>{M.listTeams().then(r=>o(new Map(r.map(l=>[l.id,l.name])))).catch(()=>{})},[]),e.jsx(Ir,{devices:t.devices,reloadDevices:t.reloadDevices,sort:t.sort,onSortChange:t.onSortChange,navigate:r=>s(`${r}${n}`),teams:a})}var kt,_r=new Uint8Array(16);function zr(){if(!kt&&(kt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!kt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kt(_r)}const Lr=/^(?:[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 Or(t){return typeof t=="string"&&Lr.test(t)}var re=[];for(var ts=0;ts<256;++ts)re.push((ts+256).toString(16).substr(1));function Pr(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(re[t[s+0]]+re[t[s+1]]+re[t[s+2]]+re[t[s+3]]+"-"+re[t[s+4]]+re[t[s+5]]+"-"+re[t[s+6]]+re[t[s+7]]+"-"+re[t[s+8]]+re[t[s+9]]+"-"+re[t[s+10]]+re[t[s+11]]+re[t[s+12]]+re[t[s+13]]+re[t[s+14]]+re[t[s+15]]).toLowerCase();if(!Or(n))throw TypeError("Stringified UUID is invalid");return n}function Fr(t,s,n){t=t||{};var a=t.random||(t.rng||zr)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Pr(a)}const Ur=({onCommand:t,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:a})=>{const[o,r]=c.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[l,u]=c.useState(""),[d,i]=c.useState([]),[m,x]=c.useState(-1),[k,f]=c.useState(!1),y=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[o]);const C=w=>{const j=w.trim();if((j.startsWith("{")||j.startsWith("["))&&(j.endsWith("}")||j.endsWith("]")))try{const $=JSON.parse(j);return JSON.stringify($,null,2)}catch{}return w},L=async w=>{if(w.key==="Enter"&&!k){const j=l.trim();if(!j)return;if(u(""),r($=>[...$,{type:"command",content:`${s} ${j}`,timestamp:Date.now()}]),i($=>[...$,j]),x(-1),f(!0),j==="clear"){r([]),f(!1);return}if(j==="help"){let $="";a==="android"?$=`
206
+ */const Fi=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Ui=U("wifi",Fi);function Bi(t){return t>=50?"ready":t>=20?"warning":"error"}function Vi(t){return t>=50?e.jsx(Ra,{size:10}):t>=20?e.jsx(Sa,{size:10}):e.jsx($a,{size:10})}function Hi(t){return t==="Normal"?"ready":t==="Critical"?"error":"warning"}const Wi=({device:t})=>{if(t.deviceType==="emulator"||t.deviceType==="simulator"||t.offline)return null;const n=typeof t.batteryLevel=="number",a=typeof t.thermalStatus=="string"&&t.thermalStatus.length>0&&t.thermalStatus!=="Unknown";return!n&&!a?e.jsx("div",{className:"dc2-health",children:e.jsxs(Ct,{tone:"neutral",title:"Device does not report battery or thermal data",children:[e.jsx(ta,{size:10}),"No telemetry"]})}):e.jsxs("div",{className:"dc2-health",children:[n&&e.jsxs(Ct,{tone:Bi(t.batteryLevel),title:`Battery ${t.batteryLevel}%`,children:[Vi(t.batteryLevel),t.batteryLevel,"%"]}),a&&e.jsxs(Ct,{tone:Hi(t.thermalStatus),title:`Thermal: ${t.thermalStatus}`,children:[e.jsx(Ai,{size:10}),t.thermalStatus]})]})};function qi(t){if(typeof t!="number")throw new TypeError("Expected a number");const s=t>0?Math.floor:Math.ceil;return{days:s(t/864e5),hours:s(t/36e5)%24,minutes:s(t/6e4)%60,seconds:s(t/1e3)%60,milliseconds:s(t)%1e3,microseconds:s(t*1e3)%1e3,nanoseconds:s(t*1e6)%1e3}}const Ki=(t,s)=>s===1?t:`${t}s`,Xi=1e-7;function fn(t,s={}){if(!Number.isFinite(t))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],a=(l,u)=>{const d=Math.floor(l*10**u+Xi);return(Math.round(d)/10**u).toFixed(u)},o=(l,u,d,i)=>{if((n.length===0||!s.colonNotation)&&l===0&&!(s.colonNotation&&d==="m"))return;i=(i||l||"0").toString();let h,x;if(s.colonNotation){h=n.length>0?":":"",x="";const k=i.includes(".")?i.split(".")[0].length:i.length,f=n.length>0?2:1;i="0".repeat(Math.max(0,f-k))+i}else h="",x=s.verbose?" "+Ki(u,l):d;n.push(h+i+x)},r=qi(t);if(o(Math.trunc(r.days/365),"year","y"),o(r.days%365,"day","d"),o(r.hours,"hour","h"),o(r.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&t<1e3)if(o(r.seconds,"second","s"),s.formatSubMilliseconds)o(r.milliseconds,"millisecond","ms"),o(r.microseconds,"microsecond","µs"),o(r.nanoseconds,"nanosecond","ns");else{const l=r.milliseconds+r.microseconds/1e3+r.nanoseconds/1e6,u=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,d=l>=1?Math.round(l):Math.ceil(l),i=u?l.toFixed(u):d;o(Number.parseFloat(i),"millisecond","ms",i)}else{const l=t/1e3%60,u=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,d=a(l,u),i=s.keepDecimalsOnWholeSeconds?d:d.replace(/\.0+$/,"");o(Number.parseFloat(i),"second","s",i)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const l=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(l)}return s.colonNotation?n.join(""):n.join(" ")}const Jt=6e4;function Gi(t){return!Number.isFinite(t)||t<=0?"expiring":t<Jt?"under 1m":fn(Math.floor(t/Jt)*Jt,{unitCount:2})}const is=["ready","busy","reserved","maintenance","offline"],yn={ready:"Ready",busy:"Busy",reserved:"Reserved",maintenance:"Maintenance",offline:"Offline"};function ut(t,s){return t.offline?"offline":t.userBlocked?"maintenance":t.busy?"busy":t.reservedUntil&&s<t.reservedUntil?"reserved":"ready"}function xn(t,s){const n=sa(t);if(!t.busy||!n)return null;const a=String(n);return a.startsWith("manual_")?s!=null&&s.userId&&a===`manual_${s.userId}_${t.udid}`?"self":"other":"session"}const Bs=t=>(t==null?void 0:t.role)==="ADMIN"||(t==null?void 0:t.role)==="SUPER_ADMIN";function Yi(t,s,n){switch(xn(t,s)){case"session":return t.sessionStartTime&&t.sessionStartTime>0&&n>t.sessionStartTime?`Test session · ${fn(n-t.sessionStartTime,{compact:!0})}`:"Test session running";case"self":return"Live control by you";case"other":return"Live control by another user"}if(t.reservedUntil&&n<t.reservedUntil){const o=!!t.reservedBy&&(t.reservedBy===(s==null?void 0:s.email)||t.reservedBy===(s==null?void 0:s.name))?"you":t.reservedBy||"another user";return`${Gi(t.reservedUntil-n)} left · by ${o}`}return null}function Zi(t,s){if(t.offline)return{enabled:!1,reason:"Device is offline"};if(t.userBlocked&&!Bs(s))return{enabled:!1,reason:"In maintenance"};const n=xn(t,s);return n==="session"?{enabled:!1,reason:"A test is running"}:n==="other"&&!Bs(s)?{enabled:!1,reason:"Another user has control"}:{enabled:!0}}function Me(t){var s;return((s=t.marketingName)==null?void 0:s.trim())||t.name}function vn(t){const s=[_t(t.platform),t.sdk].filter(Boolean).join(" ");if(t.deviceType==="emulator")return`Emulator · ${s}`;if(t.deviceType==="simulator")return`Simulator · ${s}`;const a=[t.manufacturer?t.manufacturer.charAt(0).toUpperCase()+t.manufacturer.slice(1):"",t.model].filter(Boolean).join(" ");return a?`${a} · ${s}`:s}function Ji(t){return t.formFactor==="tablet"||t.formFactor==="tv"?t.formFactor:"phone"}function Qe(t,s){return t.teamId?(s==null?void 0:s.get(t.teamId))??t.teamName??`Team ${t.teamId.slice(0,6)}`:null}const Qi=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],er=({device:t,onClose:s,onReserved:n})=>{const[a,o]=c.useState(""),[r,l]=c.useState("1h"),[u,d]=c.useState(""),[i,h]=c.useState(!1),[x,k]=c.useState(null),[f,y]=c.useState(null),S=async()=>{if(!a.trim()){k("Please enter your name/ID");return}h(!0),k(null),y(null);try{const C=await M.reserveDevice(t.udid,t.host,a,r,u);C.success?(n(),s()):y(C.error||"Failed to reserve device")}catch(C){y(C.message||"An unexpected error occurred")}finally{h(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(Ia,{size:16,className:"title-icon"}),"Reserve device"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,disabled:i,children:"Cancel"}),e.jsx("button",{className:"btn-reserve",onClick:S,disabled:i||!a.trim(),children:i?"Reserving...":"Confirm Reservation"})]}),children:e.jsxs("div",{className:"reservation-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsxs("p",{children:["Reserve ",e.jsx("strong",{children:t.name||t.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(Hn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reserved by"]}),htmlFor:"reservation-reserved-by",error:x?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),x]}):void 0,children:e.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:a,onChange:C=>{o(C.target.value),x&&k(null)},disabled:i})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(ra,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Duration"]}),children:e.jsx("div",{className:"duration-selector",children:Qi.map(C=>e.jsx("div",{className:`duration-option ${r===C.value?"active":""}`,onClick:()=>l(C.value),children:C.label},C.value))})}),e.jsx($t,{label:e.jsxs(e.Fragment,{children:[e.jsx(ri,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--color-accent)"}}),"Reason (optional)"]}),htmlFor:"reservation-reason",error:f?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:e.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:u,onChange:C=>d(C.target.value),disabled:i})})]})})},tr=({device:t,onClose:s,onUpdated:n})=>{const{toast:a}=Ve(),[o,r]=c.useState(t.tags||[]),[l,u]=c.useState(""),[d,i]=c.useState(!1),h=c.useRef(null);c.useEffect(()=>{h.current&&h.current.focus()},[]);const x=()=>{const S=l.trim();S&&!o.includes(S)&&(r([...o,S]),u(""))},k=S=>{r(o.filter(C=>C!==S))},f=S=>{S.key==="Enter"&&x()},y=async()=>{i(!0);try{await M.updateDeviceTags(t.udid,t.host,o),n(),s()}catch(S){console.error("Failed to update tags",S),a("Error saving tags. Please try again.","error")}finally{i(!1)}};return e.jsx(ps,{open:!0,onClose:s,width:520,title:e.jsxs(e.Fragment,{children:[e.jsx(ki,{size:16,className:"title-icon"}),"Manage device tags"]}),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),e.jsx("button",{className:"btn-save",onClick:y,disabled:d,children:d?"Saving...":"Apply Changes"})]}),children:e.jsxs("div",{className:"tag-modal-body",children:[e.jsxs("div",{className:"device-id-badge",children:[e.jsx("span",{className:"label",children:"Device:"}),e.jsx("span",{className:"value",children:t.udid})]}),e.jsx($t,{label:"Add new tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:e.jsxs("div",{className:"input-with-button",children:[e.jsx("input",{ref:h,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:l,onChange:S=>u(S.target.value),onKeyDown:f}),e.jsx("button",{className:"add-inline-btn",onClick:x,disabled:!l.trim(),children:e.jsx(oa,{size:16})})]})}),e.jsxs("div",{className:"tags-display-section",children:[e.jsx("label",{children:"Current Tags"}),e.jsx("div",{className:"tags-list",children:o.length>0?o.map(S=>e.jsxs("div",{className:"tag-pill-editable",children:[S,e.jsx("button",{className:"remove-tag",onClick:()=>k(S),children:e.jsx(sn,{size:12})})]},S)):e.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})},sr="/wd/hub";function nr(t){return t==="android"?"UiAutomator2":"XCUITest"}function ar(t){return t==="android"?"Android":t==="tvos"?"tvOS":"iOS"}function ir(t,s=sr){if(!t)return"—";try{const n=new URL(t.includes("://")?t:`http://${t}`),a=s.startsWith("/")?s:`/${s}`,o=n.pathname.replace(/\/$/,"");return o===a||o.endsWith(a)?`${n.protocol}//${n.host}${o}`:`${n.protocol}//${n.host}${a}`}catch{return t}}function rr(t){const s={platformName:ar(t.platform),"appium:automationName":nr(t.platform),"appium:udid":t.udid};return t.sdk&&t.sdk!=="Unknown"&&t.sdk!=="unknown"&&(s["appium:platformVersion"]=t.sdk),t.name&&(s["appium:deviceName"]=t.name),s}function or(t){return JSON.stringify(rr(t),null,2)}const cr=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,lr=/^(?:\d{1,3}\.){3}\d{1,3}$/;function dr(t){const s=t.trim();return!s||cr.test(s)||!lr.test(s)?!1:s.split(".").every(n=>{const a=Number(n);return Number.isInteger(a)&&a>=0&&a<=255})}function ur(t){return t.ip&&dr(t.ip)?t.ip.trim():null}const gn=({udid:t,currentTeamId:s,teams:n,onDone:a,className:o})=>{const{toast:r}=Ve(),[l,u]=c.useState(!1);async function d(i){u(!0);try{await M.setDeviceTeam(t,i),r(i?"Device assigned":"Device returned to shared pool","success"),a(!0)}catch(h){r((h==null?void 0:h.message)||"Failed to update team","error")}finally{u(!1)}}return e.jsxs(hs,{selectSize:"sm",className:o,autoFocus:!0,"aria-label":"Team",disabled:l,defaultValue:s??"",onBlur:()=>a(!1),onChange:i=>d(i.target.value||null),children:[e.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(n.entries()).map(([i,h])=>e.jsx("option",{value:i,children:h},i))]})};function bn(t,s){const[n,a]=c.useState(!1),[o,r]=c.useState(!1),[l,u]=c.useState(!1),{me:d}=Wn(),{toast:i}=Ve(),h=(d==null?void 0:d.role)==="ADMIN"||(d==null?void 0:d.role)==="SUPER_ADMIN",x=Date.now(),k=ut(t,x),f=k==="reserved",y=Yi(t,d,x),S=Zi(t,d),C=ir(t.host),L=ur(t),w=async(O,W)=>{var V;try{await((V=navigator.clipboard)==null?void 0:V.writeText(O)),i(W,"success")}catch{i("Failed to copy","error")}},j=async()=>{await M.releaseReservation(t.udid,t.host),s()},$=async()=>{await M.blockDevice(t.udid,t.host),s()},p=async()=>{await M.unblockDevice(t.udid,t.host),s()},D=async()=>{t.userBlocked?await p():await $()},A=e.jsxs(e.Fragment,{children:[n&&e.jsx(er,{device:t,onClose:()=>a(!1),onReserved:()=>s()}),o&&e.jsx(tr,{device:t,onClose:()=>r(!1),onUpdated:()=>s()})]});return{kind:k,reserved:f,activity:y,control:S,isAdmin:h,editingTeam:l,setEditingTeam:u,openReservation:()=>a(!0),openTagManager:()=>r(!0),release:j,toggleMaintenance:D,copy:w,serverUrl:C,ip:L,dialogs:A}}const jn=({device:t,actions:s,navigate:n,reasonId:a})=>{const{kind:o,reserved:r,control:l}=s;return e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"tonal",size:"sm",disabled:!l.enabled,"aria-describedby":l.enabled?void 0:a,onClick:()=>{l.enabled&&n(`/devices/${t.udid}/control`)},children:"Control"}),r?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.release,children:"Release"}):o==="ready"?e.jsx(Y,{variant:"secondary",size:"sm",onClick:s.openReservation,children:"Reserve"}):null]})},Nn=({device:t,actions:s})=>{const[n,a]=c.useState(!1),o=c.useRef(null),{isAdmin:r,serverUrl:l,ip:u,copy:d}=s;return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:o,type:"button",className:"dc2-more",onClick:()=>a(i=>!i),"aria-label":"More actions",children:e.jsx(qa,{size:14})}),e.jsx(on,{open:n,onClose:()=>a(!1),anchorRef:o,children:e.jsxs(cn,{children:[e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(t.udid,"UDID copied")},children:"Copy UDID"}),l!=="—"&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(l,"Server URL copied")},children:"Copy server URL"}),u&&e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(u,"IP address copied")},children:"Copy IP address"}),e.jsx(pe,{icon:e.jsx(Te,{size:12}),onClick:()=>{a(!1),d(or(t),"Session capabilities copied")},children:"Copy capabilities"}),r&&e.jsxs(e.Fragment,{children:[e.jsx(ia,{}),e.jsx(pe,{onClick:()=>{a(!1),s.openTagManager()},children:"Manage tags…"}),e.jsx(pe,{onClick:()=>{a(!1),s.setEditingTeam(!0)},children:"Assign team…"}),e.jsx(pe,{onClick:()=>{a(!1),s.toggleMaintenance()},children:t.userBlocked?"Exit maintenance":"Enter maintenance"})]})]})})]})},mr=({device:t})=>{const s={phone:ns,tablet:ca,tv:qn}[Ji(t)],n=t.deviceType==="emulator"||t.deviceType==="simulator";return e.jsx(s,{size:26,strokeWidth:1.5,strokeDasharray:n?"3 2":void 0})},hr=({device:t,reloadDevices:s,navigate:n,teams:a})=>{var x,k,f;const o=bn(t,s),{kind:r,activity:l,control:u}=o,d=`dc2-reason-${t.udid}`,i=Me(t),h=Qe(t,a);return e.jsxs("div",{className:`dc2 dc2-${r}`,children:[e.jsxs("div",{className:`dc2-band dc2-band-${r}`,children:[e.jsxs("span",{className:"dc2-band-label",children:[e.jsx("span",{className:"dc2-band-dot","aria-hidden":!0}),yn[r]]}),l&&e.jsx("span",{className:"dc2-band-activity",title:l,children:l})]}),e.jsxs("div",{className:`dc2-body${r==="offline"?" dc2-dim":""}`,children:[e.jsxs("div",{className:"dc2-head",children:[e.jsx("div",{className:"dc2-icon","aria-hidden":!0,children:e.jsx(mr,{device:t})}),e.jsxs("div",{className:"dc2-id",children:[e.jsx("div",{className:"dc2-title",title:`${i}
207
+ ${t.udid}`,children:i}),e.jsx("div",{className:"dc2-subtitle",children:vn(t)})]})]}),e.jsxs("div",{className:"dc2-meta",children:[e.jsx(Wi,{device:t}),o.editingTeam?e.jsx(gn,{className:"dc2-team-picker",udid:t.udid,currentTeamId:t.teamId??null,teams:a??new Map,onDone:y=>{o.setEditingTeam(!1),y&&s()}}):h&&e.jsx(Ct,{tone:"accent",className:"dc2-team",title:`Team: ${h}`,children:h}),(x=t.tags)==null?void 0:x.slice(0,2).map(y=>e.jsxs("span",{className:"dc2-tag",title:y,children:["#",y]},y)),(((k=t.tags)==null?void 0:k.length)||0)>2&&e.jsxs("span",{className:"dc2-tag",children:["+",(((f=t.tags)==null?void 0:f.length)||0)-2]})]})]}),e.jsxs("div",{className:"dc2-foot",children:[e.jsx(jn,{device:t,actions:o,navigate:n,reasonId:d}),!u.enabled&&e.jsx("span",{id:d,className:"dc2-unavailable",title:u.reason,children:u.reason}),e.jsx("span",{className:"dc2-spacer"}),e.jsx(Nn,{device:t,actions:o})]}),o.dialogs]})};function pr(t){const s=ht(),{search:n}=Mt();return e.jsx(hr,{device:t.device,reloadDevices:t.reloadDevices,navigate:a=>s(`${a}${n}`),teams:t.teams})}class fr extends Fe.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){M.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return e.jsx("div",{className:"device-explorer-card-container",children:Fe.Children.toArray(this.props.devices.map(s=>e.jsx(pr,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}const yr={status:"all",platform:"all",type:"all",q:""},kn=["all",...is],wn=["all","android","ios","tvos"],Sn=["all","real","virtual"];function Qt(t,s){return s.includes(t)?t:s[0]}function xr(t){const s=t.get("q")??"";return{status:Qt(t.get("status"),kn),platform:Qt(t.get("platform"),wn),type:Qt(t.get("type"),Sn),q:s.trim()?s:""}}function vr(t){const s=new URLSearchParams;return t.status!=="all"&&s.set("status",t.status),t.platform!=="all"&&s.set("platform",t.platform),t.type!=="all"&&s.set("type",t.type),t.q.trim()&&s.set("q",t.q),s}function mt(t){return t.deviceType==="simulator"||t.deviceType==="emulator"?!0:!t.deviceType&&t.realDevice===!1}function xs(t){const s=(t.platform||"").toLowerCase();return s==="android"||s==="ios"||s==="tvos"?s:null}function gr(t){const s=t.deviceType==="emulator"?"Emulator":t.deviceType==="simulator"?"Simulator":"";return[Me(t),t.name,t.manufacturer,t.model,_t(t.platform),t.sdk,s,t.teamName,t.udid].filter(Boolean).join(" ").toLowerCase()}function Tt(t,s,n,a){if(a!=="status"&&s.status!=="all"&&ut(t,n)!==s.status||a!=="platform"&&s.platform!=="all"&&xs(t)!==s.platform||a!=="type"&&s.type!=="all"&&s.type==="virtual"!==mt(t))return!1;const o=s.q.toLowerCase().split(/\s+/).filter(Boolean);if(o.length===0)return!0;const r=gr(t);return o.every(l=>r.includes(l))}const es=t=>Object.fromEntries(t.map(s=>[s,0]));function br(t,s,n){const a=es(kn),o=es(wn),r=es(Sn);for(const l of t){if(Tt(l,s,n,"status")&&(a.all+=1,a[ut(l,n)]+=1),Tt(l,s,n,"platform")){o.all+=1;const u=xs(l);u&&(o[u]+=1)}Tt(l,s,n,"type")&&(r.all+=1,r[mt(l)?"virtual":"real"]+=1)}return{status:a,platform:o,type:r}}function jr(t){return t.some(s=>xs(s)==="tvos")}function Nr(t){return t.status!=="all"||t.platform!=="all"||t.type!=="all"||t.q.trim()!==""}function kr(t,s){const n=a=>a===1?"device":"devices";return t===s?`${s} ${n(s)}`:`${t} of ${s} ${n(s)}`}const rs={key:"status",dir:"asc"},wr=["status","device","platform","type","team","host"],Sr=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),Pe=(t,s)=>Sr.compare(t,s);function Cr(t,s,n,a){switch(n){case"status":return is.indexOf(ut(t,a.now))-is.indexOf(ut(s,a.now));case"device":return Pe(Me(t),Me(s));case"platform":return Pe(t.platform||"",s.platform||"")||Pe(t.sdk||"",s.sdk||"");case"type":return Number(mt(t))-Number(mt(s));case"team":return Pe(Qe(t,a.teams)??"",Qe(s,a.teams)??"");case"host":return Pe(t.host||"",s.host||"")}}function $r(t,s,n){const a=s.dir==="desc"?-1:1;return t.slice().sort((o,r)=>{if(s.key==="team"){const l=Qe(o,n.teams)===null,u=Qe(r,n.teams)===null;if(l!==u)return l?1:-1}return a*Cr(o,r,s.key,n)||Pe(Me(o),Me(r))||Pe(o.udid,r.udid)})}function Tr(t){const s=t.get("sort");return!s||!wr.includes(s)?rs:{key:s,dir:t.get("dir")==="desc"?"desc":"asc"}}function Rr(t,s){t.delete("sort"),t.delete("dir"),!(s.key===rs.key&&s.dir===rs.dir)&&(t.set("sort",s.key),s.dir==="desc"&&t.set("dir","desc"))}const Je=({sortKey:t,label:s,sort:n,onSortChange:a})=>{const o=n.key===t,r=o?n.dir:"asc";return e.jsx(At,{scope:"col","aria-sort":o?r==="asc"?"ascending":"descending":"none",children:e.jsxs("button",{type:"button",className:"devtable-sort",onClick:()=>a(o?{key:t,dir:r==="asc"?"desc":"asc"}:{key:t,dir:"asc"}),children:[s,o&&(r==="asc"?e.jsx(ys,{size:12,"aria-hidden":"true"}):e.jsx(fs,{size:12,"aria-hidden":"true"}))]})})},Ar=({device:t,reloadDevices:s,navigate:n,teams:a,showHost:o})=>{const r=bn(t,s),{kind:l,activity:u,control:d}=r,i=Me(t),h=vn(t),x=Qe(t,a),k=`${_t(t.platform)} ${t.sdk??""}`,f=t.tags??[],y=`devtable-reason-${t.udid}`;return e.jsxs(ln,{className:`devtable-row${l==="offline"?" is-offline":""}`,children:[e.jsxs(Oe,{children:[e.jsxs("div",{className:"devtable-line",children:[e.jsx(la,{kind:l,className:"devtable-status-dot"})," ",yn[l]]}),u&&e.jsx("div",{className:"devtable-muted devtable-line",title:u,children:u})]}),e.jsxs(At,{scope:"row",className:"devtable-rowheader",title:`${i}
208
+ ${t.udid}`,children:[e.jsx("div",{className:"devtable-title devtable-line",children:i}),e.jsx("div",{className:"devtable-muted devtable-line",title:h,children:h})]}),e.jsx(Oe,{title:k,children:k}),e.jsx(Oe,{children:mt(t)?"Virtual":"Real"}),e.jsx(Oe,{title:r.editingTeam?void 0:x??"Shared",children:r.editingTeam?e.jsx(gn,{udid:t.udid,currentTeamId:t.teamId??null,teams:a,onDone:S=>{r.setEditingTeam(!1),S&&s()}}):x??"Shared"}),e.jsxs(Oe,{title:f.join(", "),children:[f.slice(0,2).map(S=>e.jsxs("span",{className:"devtable-tag",children:["#",S]},S)),f.length>2&&e.jsxs("span",{className:"devtable-tag",children:["+",f.length-2]})]}),o&&e.jsx(Oe,{title:t.host,children:t.host}),e.jsx(Oe,{className:"devtable-actions",title:d.enabled?void 0:d.reason,children:e.jsxs("div",{className:"devtable-actions-inner",children:[e.jsx(jn,{device:t,actions:r,navigate:n,reasonId:y}),!d.enabled&&e.jsx("span",{id:y,className:"sr-only",children:d.reason}),e.jsx(Nn,{device:t,actions:r})]})}),r.dialogs]})};function Er({devices:t,reloadDevices:s,sort:n,onSortChange:a,navigate:o,teams:r}){const l=new Set(t.map(d=>d.host)).size>1||n.key==="host",u=$r(t,n,{now:Date.now(),teams:r});return e.jsxs(da,{className:"devtable",children:[e.jsxs("caption",{className:"sr-only",children:["Devices, ",t.length," shown"]}),e.jsxs("colgroup",{children:[e.jsx("col",{className:"devtable-col-status"}),e.jsx("col",{}),e.jsx("col",{className:"devtable-col-platform"}),e.jsx("col",{className:"devtable-col-type"}),e.jsx("col",{className:"devtable-col-team"}),e.jsx("col",{className:"devtable-col-tags"}),l&&e.jsx("col",{className:"devtable-col-host"}),e.jsx("col",{className:"devtable-col-actions"})]}),e.jsx(ua,{children:e.jsxs(ln,{children:[e.jsx(Je,{sortKey:"status",label:"Status",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"device",label:"Device",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"platform",label:"Platform",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"type",label:"Type",sort:n,onSortChange:a}),e.jsx(Je,{sortKey:"team",label:"Team",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Tags"}),l&&e.jsx(Je,{sortKey:"host",label:"Host",sort:n,onSortChange:a}),e.jsx(At,{scope:"col",children:"Actions"})]})}),e.jsx(ma,{children:u.map(d=>e.jsx(Ar,{device:d,reloadDevices:s,navigate:o,teams:r,showHost:l},d.udid))})]})}function Dr(t){const s=ht(),{search:n}=Mt(),[a,o]=c.useState(new Map);return c.useEffect(()=>{M.listTeams().then(r=>o(new Map(r.map(l=>[l.id,l.name])))).catch(()=>{})},[]),e.jsx(Er,{devices:t.devices,reloadDevices:t.reloadDevices,sort:t.sort,onSortChange:t.onSortChange,navigate:r=>s(`${r}${n}`),teams:a})}var kt,Ir=new Uint8Array(16);function Mr(){if(!kt&&(kt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!kt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kt(Ir)}const _r=/^(?:[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 zr(t){return typeof t=="string"&&_r.test(t)}var re=[];for(var ts=0;ts<256;++ts)re.push((ts+256).toString(16).substr(1));function Lr(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(re[t[s+0]]+re[t[s+1]]+re[t[s+2]]+re[t[s+3]]+"-"+re[t[s+4]]+re[t[s+5]]+"-"+re[t[s+6]]+re[t[s+7]]+"-"+re[t[s+8]]+re[t[s+9]]+"-"+re[t[s+10]]+re[t[s+11]]+re[t[s+12]]+re[t[s+13]]+re[t[s+14]]+re[t[s+15]]).toLowerCase();if(!zr(n))throw TypeError("Stringified UUID is invalid");return n}function Or(t,s,n){t=t||{};var a=t.random||(t.rng||Mr)();return a[6]=a[6]&15|64,a[8]=a[8]&63|128,Lr(a)}const Pr=({onCommand:t,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:a})=>{const[o,r]=c.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[l,u]=c.useState(""),[d,i]=c.useState([]),[h,x]=c.useState(-1),[k,f]=c.useState(!1),y=c.useRef(null),S=c.useRef(null);c.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[o]);const C=w=>{const j=w.trim();if((j.startsWith("{")||j.startsWith("["))&&(j.endsWith("}")||j.endsWith("]")))try{const $=JSON.parse(j);return JSON.stringify($,null,2)}catch{}return w},L=async w=>{if(w.key==="Enter"&&!k){const j=l.trim();if(!j)return;if(u(""),r($=>[...$,{type:"command",content:`${s} ${j}`,timestamp:Date.now()}]),i($=>[...$,j]),x(-1),f(!0),j==="clear"){r([]),f(!1);return}if(j==="help"){let $="";a==="android"?$=`
219
209
  Android Allowed Commands:
220
210
  • System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
221
211
  • Process Mgmt: ps, top
@@ -230,10 +220,10 @@ iOS Allowed Commands:
230
220
  listapps, get_app_container, list, getenv
231
221
  • Simulator System:
232
222
  ls, ps, top, date, uptime, whoami
233
- `),r(p=>[...p,{type:"output",content:$.trim(),timestamp:Date.now()}]),f(!1);return}try{const $=await t(j),p=C($||"(No output)");r(D=>[...D,{type:"output",content:p,timestamp:Date.now()}])}catch($){r(p=>[...p,{type:"error",content:$.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var $;return($=S.current)==null?void 0:$.focus()},10)}}else if(w.key==="ArrowUp"){if(w.preventDefault(),d.length>0){const j=m===-1?d.length-1:Math.max(0,m-1);x(j),u(d[j])}}else if(w.key==="ArrowDown"&&(w.preventDefault(),m!==-1)){const j=m+1;j>=d.length?(x(-1),u("")):(x(j),u(d[j]))}};return e.jsxs("div",{className:"terminal-container theme-dark",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"terminal-header",children:[e.jsxs("div",{className:"terminal-controls",children:[e.jsx("div",{className:"dot red"}),e.jsx("div",{className:"dot yellow"}),e.jsx("div",{className:"dot green"})]}),e.jsxs("div",{className:"terminal-title",children:[_t(a)," shell"]}),e.jsx("div",{className:"terminal-actions",children:e.jsx("button",{className:"terminal-action-btn",onClick:()=>r([]),title:"Clear terminal",children:"CLEAR"})})]}),e.jsxs("div",{className:"terminal-history",ref:y,onClick:()=>{var w;return(w=S.current)==null?void 0:w.focus()},children:[o.map((w,j)=>e.jsx("div",{className:`terminal-line ${w.type}`,children:w.content},j)),k&&e.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),e.jsxs("div",{className:"terminal-input-area",children:[e.jsx("span",{className:"terminal-prompt",children:s}),e.jsx("input",{ref:S,className:"terminal-input",value:l,onChange:w=>u(w.target.value),onKeyDown:L,disabled:k,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ae(t,s){var n;s(t),(n=t.children)==null||n.forEach(a=>Ae(a,s))}function Re(t,...s){var n;for(const a of s){const o=(n=t.attributes)==null?void 0:n[a];if(o!=null&&o!=="")return String(o)}}function et(t){var s;return((s=t.type)==null?void 0:s.split(".").pop())||t.type||""}function Br(t,s){const n=[];return Ae(t,a=>{Re(a,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(a)}),n}function Vr(t,s){const n=[];return Ae(t,a=>{Re(a,"resource-id","resourceId","identifier")===s&&n.push(a)}),n}function os(t,s){const n=[];return Ae(t,a=>{(a.type===s||et(a)===s)&&n.push(a)}),n}function Hr(t,s){const n=[];return Ae(t,a=>{Re(a,"name")===s&&n.push(a)}),n}function Wr(t){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(t.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function qr(t,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const a=[];for(const r of n){const l=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(r);if(!l)return null;a.push({type:l[1],index:parseInt(l[2],10)})}if(a[0].type!==t.type&&a[0].type!==et(t)||a[0].index!==1)return null;let o=t;for(let r=1;r<a.length&&o;r++){const{type:l,index:u}=a[r];let d=0,i;for(const m of o.children||[])if((m.type===l||et(m)===l)&&(d+=1,d===u)){i=m;break}o=i}return o?[o]:[]}function Kr(t,s){const n=qr(t,s);if(n!==null)return{kind:"matched",nodes:n};const a=Wr(s);if(a){const o=[];return Ae(t,r=>{if(a.tag&&r.type!==a.tag&&et(r)!==a.tag)return;Re(r,a.attrKey)===a.attrValue&&o.push(r)}),{kind:"matched",nodes:o}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Xr(t,s){const n=s.trim(),a=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(a){const[,l,u,d]=a,i=[];return Ae(t,m=>{if(m.type!==l&&et(m)!==l)return;Re(m,u)===d&&i.push(m)}),{kind:"matched",nodes:i}}const o=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(o){const[,l,u]=o,d=parseInt(u,10),i=[];return Ae(t,m=>{(m.type===l||et(m)===l)&&i.push(m)}),{kind:"matched",nodes:i[d-1]?[i[d-1]]:[]}}const r=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return r?os(t,r[1]).length>0?{kind:"matched",nodes:os(t,r[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Gr(t,s){const a=s.trim().split(/\s+AND\s+/i).map(l=>l.trim()),o=[];for(const l of a){const u=/^(\w+)\s*==\s*"([^"]*)"$/.exec(l);if(!u)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};o.push({key:u[1],value:u[2]})}const r=[];return Ae(t,l=>{for(const u of o){let d;if(u.key==="type"?d=l.type:u.key==="label"?d=Re(l,"label")??l.label:u.key==="name"?d=Re(l,"name")??l.name:u.key==="value"?d=Re(l,"value")??l.value:d=Re(l,u.key),d!==u.value)return}r.push(l)}),{kind:"matched",nodes:r}}function cs(t,s,n){const a=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(a){case"accessibility id":return{kind:"matched",nodes:Br(t,n)};case"id":return{kind:"matched",nodes:Vr(t,n)};case"class name":return{kind:"matched",nodes:os(t,n)};case"name":return{kind:"matched",nodes:Hr(t,n)};case"xpath":return Kr(t,n);case"-ios class chain":return Xr(t,n);case"-ios predicate string":return Gr(t,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Vs(t){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[t.toLowerCase()]??7}function ls(t,s){const n=t.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const a=(s.match(/\//g)||[]).length;return a>7?{level:"fragile",reason:`${a}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function Cn(t){return[...t].sort((s,n)=>Vs(s.strategy)-Vs(n.strategy))}const wt=t=>t===!0||t==="true",Yr=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Zr=/(EditText|AutoCompleteTextView)$/;function $n(t){const s=t.attributes||{};return wt(s.clickable)||wt(s["long-clickable"])||wt(s.checkable)||wt(s.scrollable)||Zr.test(t.type||"")||Yr.test(t.type||"")}function Jr(t){const s=t.attributes||{};return String(t.text||s["content-desc"]||t.label||s.label||s.name||"").trim()}function Qr(t,s){const n="Unique locator",a=Cn(t.suggestedLocators||[]),o=a[0];if(!o)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const r=cs(s.hierarchy,o.strategy,o.value),l=`${o.strategy} ${o.value}`;if(r.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${o.strategy} locators here`};const u=k=>k.length===1&&k[0].xpath===t.xpath;if(u(r.nodes))return{id:"unique",label:n,status:"pass",detail:`${l} matches only this element`};const d=a.slice(1).find(k=>{const f=cs(s.hierarchy,k.strategy,k.value);return f.kind==="matched"&&u(f.nodes)}),i=d?`; use ${d.strategy} ${d.value} instead`:"",m=r.nodes.length,x=m===0?"matches nothing in this capture":`matches ${m} elements`;return{id:"unique",label:n,status:"fail",detail:`${l} ${x}${i}`}}function eo(t){const s=Cn(t.suggestedLocators||[])[0];if(!s)return null;const{level:n,reason:a}=ls(s.strategy,s.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:a}}function to(t,s){const{screenWidth:n,screenHeight:a}=s.metadata||{screenWidth:0,screenHeight:0};if(!n||!a)return null;const{x:o,y:r,width:l,height:u}=t.rect,d="On screen";return o+l<=0||r+u<=0||o>=n||r>=a?{id:"onscreen",label:d,status:"warn",detail:"Off screen — scroll it into view first"}:o<0||r<0||o+l>n||r+u>a?{id:"onscreen",label:d,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:d,status:"pass",detail:"Fully inside the screen"}}function so(t,s){var u,d;const n=$n(t),a=!(((u=t.attributes)==null?void 0:u.enabled)===!1||((d=t.attributes)==null?void 0:d.enabled)==="false"),o=t.rect.width>0&&t.rect.height>0,r=Jr(t);return[Qr(t,s),eo(t),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},a?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},o?{id:"size",label:"Has size",status:"pass",detail:`${t.rect.width} × ${t.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},to(t,s),n?r?{id:"name",label:"Accessible name",status:"pass",detail:`“${r.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(i=>i!==null)}function no(t){return{pass:t.filter(s=>s.status==="pass").length,warn:t.filter(s=>s.status==="warn").length,fail:t.filter(s=>s.status==="fail").length}}function ao(t,s){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const a=Math.floor(n/60);return a<60?`Captured ${a} min ago`:`Captured ${Math.floor(a/60)} h ago`}function io(t,s){return t>0&&s>t}function Tn(t){var r,l,u,d,i;const s=(t.type||"").toLowerCase(),n=((r=t.attributes)==null?void 0:r.clickable)==="true"||((l=t.attributes)==null?void 0:l.clickable)===!0,a=((u=t.attributes)==null?void 0:u.scrollable)==="true"||((d=t.attributes)==null?void 0:d.scrollable)===!0,o=((i=t.children)==null?void 0:i.length)||0;return s.includes("button")||s.includes("btn")||n&&o===0?{role:"Button",key:"button"}:s.includes("edit")||s.includes("input")||s.includes("field")?{role:"Text input",key:"input"}:s.includes("image")||s.includes("img")||s.includes("imageview")?{role:"Image",key:"image"}:s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?{role:"Scrollable list",key:"list"}:s.includes("text")||s.includes("label")?{role:"Text label",key:"text"}:s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?{role:"Navigation bar",key:"nav"}:o>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const Rn={button:e.jsx(di,{size:13}),input:e.jsx(Ti,{size:13}),image:e.jsx(Xa,{size:13}),list:e.jsx(pn,{size:13}),text:e.jsx(Li,{size:13}),toggle:e.jsx(Mi,{size:13}),nav:e.jsx(pi,{size:13}),container:e.jsx(dn,{size:13}),element:e.jsx(Ra,{size:13})};function An(t,s){if(!s)return!0;const n=s.toLowerCase().trim(),a={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},o=(t.type||"").toLowerCase(),r=(t.text||t.label||t.value||"").toLowerCase(),l=(t.name||"").toLowerCase(),u=Object.values(t.attributes||{}).join(" ").toLowerCase();for(const[d,i]of Object.entries(a))if(n.includes(d)&&i.some(m=>o.includes(m)))return!0;return o.includes(n)||r.includes(n)||l.includes(n)||u.includes(n)}const je=t=>typeof t=="string"?t.trim():typeof t=="number"?String(t):"";function ro(t){const s=je(t),n=s.indexOf(":id/");return n>=0?s.slice(n+4):s}function En(t){return(t.type||"").split(".").pop()||""}function Et(t){var s;return[t.type,(s=t.attributes)==null?void 0:s["resource-id"],t.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
234
- `)}function Ue(t){const s=t.attributes||{};return je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label)||ro(s["resource-id"])||je(s.name)||En(t)||"Element"}const oo=t=>{const s=t.attributes||{};return!!(je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label))};function co(t){var s;return(((s=t.children)==null?void 0:s.length)??0)===1&&!$n(t)&&!oo(t)}function Dn(t){const s=[t];let n=t;for(;co(n);)n=n.children[0],s.push(n);return s}function In(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{var r;An(o,s)&&n.add(o.xpath),(r=o.children)==null||r.forEach(a)};return a(t),n}function lo(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{let r=!1;for(const l of o.children||[])a(l)&&(r=!0);return r&&n.add(o.xpath),r||An(o,s)};return a(t),n}function uo(t,s,n=""){if(!t)return[];const a=!!n.trim(),o=a?In(t,n):null,r=a?lo(t,n):null,l=i=>!a||i.some(m=>o.has(m.xpath)||r.has(m.xpath)),u=[],d=(i,m,x)=>{const k=i.map(Dn).filter(l);k.forEach((f,y)=>{var j;const S=f[f.length-1],C=(((j=S.children)==null?void 0:j.length)??0)>0,L=a&&r.has(S.xpath),w=C&&(s.has(S.xpath)||L);u.push({key:S.xpath,nodes:f,level:m,setSize:k.length,posInSet:y+1,hasChildren:C,expanded:w,collapsible:w&&!L,parentKey:x}),w&&d(S.children,m+1,S.xpath)})};return d([t],1,null),u}function ho(t,s=3){const n=new Set,a=(o,r)=>{var d;const l=Dn(o),u=l[l.length-1];r>s||!((d=u.children)!=null&&d.length)||(n.add(u.xpath),u.children.forEach(i=>a(i,r+1)))};return t&&a(t,1),n}function Rt(t,s){if(!t)return null;if(t.xpath===s)return[t];for(const n of t.children||[]){const a=Rt(n,s);if(a)return[t,...a]}return null}function Hs(t,s){return t.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function mo(t,s,n){var o;const a=t[s];if(!a)return null;switch(n){case"ArrowDown":return s<t.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((o=t[s+1])==null?void 0:o.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const r=t.findIndex(l=>l.key===a.parentKey);return r>=0?{focus:r}:null}case"Home":return{focus:0};case"End":return{focus:t.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const po=10;function fo({rows:t,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:o,onSelect:r,onHover:l,revealSeq:u=0}){const d=c.useRef(null),[i,m]=c.useState(null),x=c.useRef(0),k=c.useRef(null),f=s?Hs(t,s):-1,y=i?t.findIndex(p=>p.key===i):-1,S=y>=0?y:Math.max(f,0),C=p=>{var D;return((D=d.current)==null?void 0:D.querySelector(`[data-row="${p}"]`))??null},L=p=>p.nodes[p.nodes.length-1],w=p=>{var O;const D=t[p];if(!D)return;m(D.key),x.current=p;const A=C(p);A==null||A.focus({preventScroll:!0}),(O=A==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"})};c.useEffect(()=>{k.current=s},[s,u]),c.useEffect(()=>{var A,O;const p=k.current;if(!p)return;const D=Hs(t,p);D<0||((O=(A=C(D))==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"}),k.current=null)}),c.useEffect(()=>{var A,O;if(!i||t.some(W=>W.key===i))return;const p=Math.min(x.current,t.length-1),D=!document.activeElement||document.activeElement===document.body;m(((A=t[p])==null?void 0:A.key)??null),D&&p>=0&&((O=C(p))==null||O.focus({preventScroll:!0}))});const j=p=>{const D=p.target;if(D.getAttribute("role")!=="treeitem")return;const A=mo(t,Number(D.dataset.row),p.key);A&&(p.preventDefault(),"focus"in A?w(A.focus):"toggle"in A?o(A.toggle):r(A.select))},$=p=>{var D;(D=d.current)!=null&&D.contains(p.relatedTarget)||(l(null),m(null))};return e.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:j,onBlur:$,children:t.map((p,D)=>{const A=L(p),O=E=>!!E&&p.nodes.some(J=>J.xpath===E),W=O(s),V=!W&&O(n),q=Ue(A),Q=En(A),b=!!Q&&Q!==q,oe=p.nodes.map(E=>Ue(E)).join(", "),te=b?`${oe}, ${Q}`:oe,ce=p.expanded&&!p.collapsible,B=(E,J)=>`omni-tree-row__part${J?" is-target":""}${a.has(E.xpath)?" is-match":""}${E.xpath===s?" is-current":""}`;return e.jsxs("div",{"data-row":D,role:"treeitem","aria-level":p.level,"aria-setsize":p.setSize,"aria-posinset":p.posInSet,"aria-selected":W,"aria-expanded":p.hasChildren?p.expanded:void 0,"aria-label":te,tabIndex:D===S?0:-1,className:`omni-tree-row${W?" is-selected":""}${V?" is-hovered":""}`,onClick:()=>r(A),onFocus:E=>{E.target===E.currentTarget&&(m(p.key),x.current=D,l(A))},onMouseEnter:()=>l(A),onMouseLeave:()=>l(null),children:[e.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[e.jsx("span",{className:"omni-tree-row__indent",style:{width:(p.level-1)*po}}),e.jsx("span",{className:`omni-tree-row__caret${ce?" is-locked":""}`,onClick:p.hasChildren?E=>{E.stopPropagation(),ce||o(p.key)}:void 0,children:p.hasChildren&&(p.expanded?e.jsx(Kn,{size:12}):e.jsx(ma,{size:12}))}),e.jsx("span",{className:"omni-tree-row__icon",children:Rn[Tn(A).key]})]}),e.jsxs("span",{className:"omni-tree-row__label",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__head",children:p.nodes.slice(0,-1).map((E,J)=>e.jsxs(Fe.Fragment,{children:[J>0&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsx("span",{className:B(E,!1),title:Et(E),onClick:le=>{le.stopPropagation(),r(E)},onMouseEnter:()=>l(E),onMouseLeave:()=>l(A),children:Ue(E)})]},E.xpath))}),e.jsxs("span",{className:"omni-tree-row__tail",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsxs("span",{className:"omni-tree-row__name",children:[e.jsx("span",{className:B(A,!0),title:Et(A),children:Ue(A)}),b&&e.jsx("span",{className:"omni-tree-row__type",children:Q})]})]})]}),p.hasChildren&&!p.expanded&&e.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:A.children.length})]},p.key)})})}const Ws=4;function yo({path:t,onSelect:s,focusCurrent:n=!1}){const[a,o]=c.useState(!1),r=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{var m;n&&((m=l.current)==null||m.focus())},[]),c.useEffect(()=>{var m;a&&((m=r.current)==null||m.focus())},[a]),!t.length)return null;const u=t[t.length-1],d=t.slice(0,-1),i=!a&&d.length>Ws?d.length-Ws:0;return e.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:e.jsxs("ol",{children:[i>0&&e.jsx("li",{children:e.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>o(!0),children:"…"})}),d.slice(i).map((m,x)=>e.jsx("li",{children:e.jsx("button",{ref:x===0?r:void 0,type:"button",className:"omni-crumb",title:Et(m),"aria-label":Ue(m),onClick:()=>s(m),children:Ue(m)})},m.xpath)),e.jsx("li",{children:e.jsx("span",{ref:l,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Et(u),children:Ue(u)})})]})})}const Dt=.4,xo=240,vo=340,qs=.02,It=12,Mn="xenon.omni.split";function _n(t){if(!(t>0))return{min:0,max:1};const s=Math.min(1,xo/t);return{min:s,max:Math.max(s,(t-vo)/t)}}function go(t,s){const{min:n,max:a}=_n(s),o=Number.isFinite(t)?t:Dt;return Math.min(a,Math.max(n,o))}function bo(t){try{const s=Number.parseFloat((t==null?void 0:t.getItem(Mn))??"");return s>0&&s<1?s:Dt}catch{return Dt}}function jo(t,s){try{t==null||t.setItem(Mn,String(Math.round(s*1e3)/1e3))}catch{}}function Ks(){try{return window.localStorage}catch{return null}}const No=3;function ko({share:t,limits:s,containerRef:n,onChange:a,onCommit:o,onReset:r}){const[l,u]=c.useState(!1),d=c.useRef(t);d.current=t;const i=c.useRef(!0),m=c.useRef(!1),x=c.useRef(0),k=c.useRef(t),f=w=>Math.min(s.max,Math.max(s.min,w)),y=w=>Math.round(w*100),S=()=>{i.current||(i.current=!0,u(!1),m.current&&o(d.current))},C=w=>{var $;const j=($=n.current)==null?void 0:$.getBoundingClientRect();return!j||j.width<=It?d.current:f(k.current+(w-x.current)/(j.width-It))},L=w=>{const j=w.key==="ArrowLeft"?t-qs:w.key==="ArrowRight"?t+qs:w.key==="Home"?s.min:w.key==="End"?s.max:null;j!==null&&(w.preventDefault(),o(f(Math.round(j*1e3)/1e3)))};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":y(t),"aria-valuemin":y(s.min),"aria-valuemax":y(s.max),tabIndex:0,className:`omni-split-divider${l?" is-dragging":""}`,onKeyDown:L,onDoubleClick:r,onPointerDown:w=>{var j,$;($=(j=w.currentTarget).setPointerCapture)==null||$.call(j,w.pointerId),i.current=!1,m.current=!1,x.current=w.clientX,k.current=d.current,u(!0)},onPointerMove:w=>{if(!l||!m.current&&Math.abs(w.clientX-x.current)<No)return;const j=C(w.clientX);j!==d.current&&(m.current=!0,a(j))},onPointerUp:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onPointerCancel:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onLostPointerCapture:S,children:e.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Xs(t,s,n,a){var w,j,$,p,D,A,O;const{strategy:o,value:r}=a,l=(t.text||t.name||((w=t.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",u=l.charAt(0).toLowerCase()+l.slice(1),d=((j=t.type)==null?void 0:j.toLowerCase().includes("edit"))||(($=t.type)==null?void 0:$.toLowerCase().includes("input"))||((p=t.type)==null?void 0:p.toLowerCase().includes("field"))||((D=t.type)==null?void 0:D.toLowerCase().includes("textfield")),i=((A=t.attributes)==null?void 0:A.scrollable)==="true"||((O=t.attributes)==null?void 0:O.scrollable)===!0,m=o.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
223
+ `),r(p=>[...p,{type:"output",content:$.trim(),timestamp:Date.now()}]),f(!1);return}try{const $=await t(j),p=C($||"(No output)");r(D=>[...D,{type:"output",content:p,timestamp:Date.now()}])}catch($){r(p=>[...p,{type:"error",content:$.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var $;return($=S.current)==null?void 0:$.focus()},10)}}else if(w.key==="ArrowUp"){if(w.preventDefault(),d.length>0){const j=h===-1?d.length-1:Math.max(0,h-1);x(j),u(d[j])}}else if(w.key==="ArrowDown"&&(w.preventDefault(),h!==-1)){const j=h+1;j>=d.length?(x(-1),u("")):(x(j),u(d[j]))}};return e.jsxs("div",{className:"terminal-container theme-dark",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"terminal-header",children:[e.jsxs("div",{className:"terminal-controls",children:[e.jsx("div",{className:"dot red"}),e.jsx("div",{className:"dot yellow"}),e.jsx("div",{className:"dot green"})]}),e.jsxs("div",{className:"terminal-title",children:[_t(a)," shell"]}),e.jsx("div",{className:"terminal-actions",children:e.jsx("button",{className:"terminal-action-btn",onClick:()=>r([]),title:"Clear terminal",children:"CLEAR"})})]}),e.jsxs("div",{className:"terminal-history",ref:y,onClick:()=>{var w;return(w=S.current)==null?void 0:w.focus()},children:[o.map((w,j)=>e.jsx("div",{className:`terminal-line ${w.type}`,children:w.content},j)),k&&e.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),e.jsxs("div",{className:"terminal-input-area",children:[e.jsx("span",{className:"terminal-prompt",children:s}),e.jsx("input",{ref:S,className:"terminal-input",value:l,onChange:w=>u(w.target.value),onKeyDown:L,disabled:k,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ae(t,s){var n;s(t),(n=t.children)==null||n.forEach(a=>Ae(a,s))}function Re(t,...s){var n;for(const a of s){const o=(n=t.attributes)==null?void 0:n[a];if(o!=null&&o!=="")return String(o)}}function et(t){var s;return((s=t.type)==null?void 0:s.split(".").pop())||t.type||""}function Fr(t,s){const n=[];return Ae(t,a=>{Re(a,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(a)}),n}function Ur(t,s){const n=[];return Ae(t,a=>{Re(a,"resource-id","resourceId","identifier")===s&&n.push(a)}),n}function os(t,s){const n=[];return Ae(t,a=>{(a.type===s||et(a)===s)&&n.push(a)}),n}function Br(t,s){const n=[];return Ae(t,a=>{Re(a,"name")===s&&n.push(a)}),n}function Vr(t){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(t.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function Hr(t,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const a=[];for(const r of n){const l=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(r);if(!l)return null;a.push({type:l[1],index:parseInt(l[2],10)})}if(a[0].type!==t.type&&a[0].type!==et(t)||a[0].index!==1)return null;let o=t;for(let r=1;r<a.length&&o;r++){const{type:l,index:u}=a[r];let d=0,i;for(const h of o.children||[])if((h.type===l||et(h)===l)&&(d+=1,d===u)){i=h;break}o=i}return o?[o]:[]}function Wr(t,s){const n=Hr(t,s);if(n!==null)return{kind:"matched",nodes:n};const a=Vr(s);if(a){const o=[];return Ae(t,r=>{if(a.tag&&r.type!==a.tag&&et(r)!==a.tag)return;Re(r,a.attrKey)===a.attrValue&&o.push(r)}),{kind:"matched",nodes:o}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function qr(t,s){const n=s.trim(),a=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(a){const[,l,u,d]=a,i=[];return Ae(t,h=>{if(h.type!==l&&et(h)!==l)return;Re(h,u)===d&&i.push(h)}),{kind:"matched",nodes:i}}const o=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(o){const[,l,u]=o,d=parseInt(u,10),i=[];return Ae(t,h=>{(h.type===l||et(h)===l)&&i.push(h)}),{kind:"matched",nodes:i[d-1]?[i[d-1]]:[]}}const r=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return r?os(t,r[1]).length>0?{kind:"matched",nodes:os(t,r[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Kr(t,s){const a=s.trim().split(/\s+AND\s+/i).map(l=>l.trim()),o=[];for(const l of a){const u=/^(\w+)\s*==\s*"([^"]*)"$/.exec(l);if(!u)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};o.push({key:u[1],value:u[2]})}const r=[];return Ae(t,l=>{for(const u of o){let d;if(u.key==="type"?d=l.type:u.key==="label"?d=Re(l,"label")??l.label:u.key==="name"?d=Re(l,"name")??l.name:u.key==="value"?d=Re(l,"value")??l.value:d=Re(l,u.key),d!==u.value)return}r.push(l)}),{kind:"matched",nodes:r}}function cs(t,s,n){const a=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(a){case"accessibility id":return{kind:"matched",nodes:Fr(t,n)};case"id":return{kind:"matched",nodes:Ur(t,n)};case"class name":return{kind:"matched",nodes:os(t,n)};case"name":return{kind:"matched",nodes:Br(t,n)};case"xpath":return Wr(t,n);case"-ios class chain":return qr(t,n);case"-ios predicate string":return Kr(t,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Vs(t){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[t.toLowerCase()]??7}function ls(t,s){const n=t.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const a=(s.match(/\//g)||[]).length;return a>7?{level:"fragile",reason:`${a}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function Cn(t){return[...t].sort((s,n)=>Vs(s.strategy)-Vs(n.strategy))}const wt=t=>t===!0||t==="true",Xr=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Gr=/(EditText|AutoCompleteTextView)$/;function $n(t){const s=t.attributes||{};return wt(s.clickable)||wt(s["long-clickable"])||wt(s.checkable)||wt(s.scrollable)||Gr.test(t.type||"")||Xr.test(t.type||"")}function Yr(t){const s=t.attributes||{};return String(t.text||s["content-desc"]||t.label||s.label||s.name||"").trim()}function Zr(t,s){const n="Unique locator",a=Cn(t.suggestedLocators||[]),o=a[0];if(!o)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const r=cs(s.hierarchy,o.strategy,o.value),l=`${o.strategy} ${o.value}`;if(r.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${o.strategy} locators here`};const u=k=>k.length===1&&k[0].xpath===t.xpath;if(u(r.nodes))return{id:"unique",label:n,status:"pass",detail:`${l} matches only this element`};const d=a.slice(1).find(k=>{const f=cs(s.hierarchy,k.strategy,k.value);return f.kind==="matched"&&u(f.nodes)}),i=d?`; use ${d.strategy} ${d.value} instead`:"",h=r.nodes.length,x=h===0?"matches nothing in this capture":`matches ${h} elements`;return{id:"unique",label:n,status:"fail",detail:`${l} ${x}${i}`}}function Jr(t){const s=Cn(t.suggestedLocators||[])[0];if(!s)return null;const{level:n,reason:a}=ls(s.strategy,s.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:a}}function Qr(t,s){const{screenWidth:n,screenHeight:a}=s.metadata||{screenWidth:0,screenHeight:0};if(!n||!a)return null;const{x:o,y:r,width:l,height:u}=t.rect,d="On screen";return o+l<=0||r+u<=0||o>=n||r>=a?{id:"onscreen",label:d,status:"warn",detail:"Off screen — scroll it into view first"}:o<0||r<0||o+l>n||r+u>a?{id:"onscreen",label:d,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:d,status:"pass",detail:"Fully inside the screen"}}function eo(t,s){var u,d;const n=$n(t),a=!(((u=t.attributes)==null?void 0:u.enabled)===!1||((d=t.attributes)==null?void 0:d.enabled)==="false"),o=t.rect.width>0&&t.rect.height>0,r=Yr(t);return[Zr(t,s),Jr(t),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},a?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},o?{id:"size",label:"Has size",status:"pass",detail:`${t.rect.width} × ${t.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},Qr(t,s),n?r?{id:"name",label:"Accessible name",status:"pass",detail:`“${r.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(i=>i!==null)}function to(t){return{pass:t.filter(s=>s.status==="pass").length,warn:t.filter(s=>s.status==="warn").length,fail:t.filter(s=>s.status==="fail").length}}function so(t,s){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const a=Math.floor(n/60);return a<60?`Captured ${a} min ago`:`Captured ${Math.floor(a/60)} h ago`}function no(t,s){return t>0&&s>t}function Tn(t){var r,l,u,d,i;const s=(t.type||"").toLowerCase(),n=((r=t.attributes)==null?void 0:r.clickable)==="true"||((l=t.attributes)==null?void 0:l.clickable)===!0,a=((u=t.attributes)==null?void 0:u.scrollable)==="true"||((d=t.attributes)==null?void 0:d.scrollable)===!0,o=((i=t.children)==null?void 0:i.length)||0;return s.includes("button")||s.includes("btn")||n&&o===0?{role:"Button",key:"button"}:s.includes("edit")||s.includes("input")||s.includes("field")?{role:"Text input",key:"input"}:s.includes("image")||s.includes("img")||s.includes("imageview")?{role:"Image",key:"image"}:s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?{role:"Scrollable list",key:"list"}:s.includes("text")||s.includes("label")?{role:"Text label",key:"text"}:s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?{role:"Navigation bar",key:"nav"}:o>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const Rn={button:e.jsx(di,{size:13}),input:e.jsx(Ci,{size:13}),image:e.jsx(Ya,{size:13}),list:e.jsx(pn,{size:13}),text:e.jsx(_i,{size:13}),toggle:e.jsx(Di,{size:13}),nav:e.jsx(pi,{size:13}),container:e.jsx(dn,{size:13}),element:e.jsx(Ea,{size:13})};function An(t,s){if(!s)return!0;const n=s.toLowerCase().trim(),a={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},o=(t.type||"").toLowerCase(),r=(t.text||t.label||t.value||"").toLowerCase(),l=(t.name||"").toLowerCase(),u=Object.values(t.attributes||{}).join(" ").toLowerCase();for(const[d,i]of Object.entries(a))if(n.includes(d)&&i.some(h=>o.includes(h)))return!0;return o.includes(n)||r.includes(n)||l.includes(n)||u.includes(n)}const je=t=>typeof t=="string"?t.trim():typeof t=="number"?String(t):"";function ao(t){const s=je(t),n=s.indexOf(":id/");return n>=0?s.slice(n+4):s}function En(t){return(t.type||"").split(".").pop()||""}function Et(t){var s;return[t.type,(s=t.attributes)==null?void 0:s["resource-id"],t.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
224
+ `)}function Ue(t){const s=t.attributes||{};return je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label)||ao(s["resource-id"])||je(s.name)||En(t)||"Element"}const io=t=>{const s=t.attributes||{};return!!(je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label))};function ro(t){var s;return(((s=t.children)==null?void 0:s.length)??0)===1&&!$n(t)&&!io(t)}function Dn(t){const s=[t];let n=t;for(;ro(n);)n=n.children[0],s.push(n);return s}function In(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{var r;An(o,s)&&n.add(o.xpath),(r=o.children)==null||r.forEach(a)};return a(t),n}function oo(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{let r=!1;for(const l of o.children||[])a(l)&&(r=!0);return r&&n.add(o.xpath),r||An(o,s)};return a(t),n}function co(t,s,n=""){if(!t)return[];const a=!!n.trim(),o=a?In(t,n):null,r=a?oo(t,n):null,l=i=>!a||i.some(h=>o.has(h.xpath)||r.has(h.xpath)),u=[],d=(i,h,x)=>{const k=i.map(Dn).filter(l);k.forEach((f,y)=>{var j;const S=f[f.length-1],C=(((j=S.children)==null?void 0:j.length)??0)>0,L=a&&r.has(S.xpath),w=C&&(s.has(S.xpath)||L);u.push({key:S.xpath,nodes:f,level:h,setSize:k.length,posInSet:y+1,hasChildren:C,expanded:w,collapsible:w&&!L,parentKey:x}),w&&d(S.children,h+1,S.xpath)})};return d([t],1,null),u}function lo(t,s=3){const n=new Set,a=(o,r)=>{var d;const l=Dn(o),u=l[l.length-1];r>s||!((d=u.children)!=null&&d.length)||(n.add(u.xpath),u.children.forEach(i=>a(i,r+1)))};return t&&a(t,1),n}function Rt(t,s){if(!t)return null;if(t.xpath===s)return[t];for(const n of t.children||[]){const a=Rt(n,s);if(a)return[t,...a]}return null}function Hs(t,s){return t.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function uo(t,s,n){var o;const a=t[s];if(!a)return null;switch(n){case"ArrowDown":return s<t.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((o=t[s+1])==null?void 0:o.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const r=t.findIndex(l=>l.key===a.parentKey);return r>=0?{focus:r}:null}case"Home":return{focus:0};case"End":return{focus:t.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const mo=10;function ho({rows:t,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:o,onSelect:r,onHover:l,revealSeq:u=0}){const d=c.useRef(null),[i,h]=c.useState(null),x=c.useRef(0),k=c.useRef(null),f=s?Hs(t,s):-1,y=i?t.findIndex(p=>p.key===i):-1,S=y>=0?y:Math.max(f,0),C=p=>{var D;return((D=d.current)==null?void 0:D.querySelector(`[data-row="${p}"]`))??null},L=p=>p.nodes[p.nodes.length-1],w=p=>{var O;const D=t[p];if(!D)return;h(D.key),x.current=p;const A=C(p);A==null||A.focus({preventScroll:!0}),(O=A==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"})};c.useEffect(()=>{k.current=s},[s,u]),c.useEffect(()=>{var A,O;const p=k.current;if(!p)return;const D=Hs(t,p);D<0||((O=(A=C(D))==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"}),k.current=null)}),c.useEffect(()=>{var A,O;if(!i||t.some(W=>W.key===i))return;const p=Math.min(x.current,t.length-1),D=!document.activeElement||document.activeElement===document.body;h(((A=t[p])==null?void 0:A.key)??null),D&&p>=0&&((O=C(p))==null||O.focus({preventScroll:!0}))});const j=p=>{const D=p.target;if(D.getAttribute("role")!=="treeitem")return;const A=uo(t,Number(D.dataset.row),p.key);A&&(p.preventDefault(),"focus"in A?w(A.focus):"toggle"in A?o(A.toggle):r(A.select))},$=p=>{var D;(D=d.current)!=null&&D.contains(p.relatedTarget)||(l(null),h(null))};return e.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:j,onBlur:$,children:t.map((p,D)=>{const A=L(p),O=E=>!!E&&p.nodes.some(J=>J.xpath===E),W=O(s),V=!W&&O(n),q=Ue(A),Q=En(A),b=!!Q&&Q!==q,oe=p.nodes.map(E=>Ue(E)).join(", "),te=b?`${oe}, ${Q}`:oe,ce=p.expanded&&!p.collapsible,B=(E,J)=>`omni-tree-row__part${J?" is-target":""}${a.has(E.xpath)?" is-match":""}${E.xpath===s?" is-current":""}`;return e.jsxs("div",{"data-row":D,role:"treeitem","aria-level":p.level,"aria-setsize":p.setSize,"aria-posinset":p.posInSet,"aria-selected":W,"aria-expanded":p.hasChildren?p.expanded:void 0,"aria-label":te,tabIndex:D===S?0:-1,className:`omni-tree-row${W?" is-selected":""}${V?" is-hovered":""}`,onClick:()=>r(A),onFocus:E=>{E.target===E.currentTarget&&(h(p.key),x.current=D,l(A))},onMouseEnter:()=>l(A),onMouseLeave:()=>l(null),children:[e.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[e.jsx("span",{className:"omni-tree-row__indent",style:{width:(p.level-1)*mo}}),e.jsx("span",{className:`omni-tree-row__caret${ce?" is-locked":""}`,onClick:p.hasChildren?E=>{E.stopPropagation(),ce||o(p.key)}:void 0,children:p.hasChildren&&(p.expanded?e.jsx(Kn,{size:12}):e.jsx(pa,{size:12}))}),e.jsx("span",{className:"omni-tree-row__icon",children:Rn[Tn(A).key]})]}),e.jsxs("span",{className:"omni-tree-row__label",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__head",children:p.nodes.slice(0,-1).map((E,J)=>e.jsxs(Fe.Fragment,{children:[J>0&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsx("span",{className:B(E,!1),title:Et(E),onClick:le=>{le.stopPropagation(),r(E)},onMouseEnter:()=>l(E),onMouseLeave:()=>l(A),children:Ue(E)})]},E.xpath))}),e.jsxs("span",{className:"omni-tree-row__tail",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsxs("span",{className:"omni-tree-row__name",children:[e.jsx("span",{className:B(A,!0),title:Et(A),children:Ue(A)}),b&&e.jsx("span",{className:"omni-tree-row__type",children:Q})]})]})]}),p.hasChildren&&!p.expanded&&e.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:A.children.length})]},p.key)})})}const Ws=4;function po({path:t,onSelect:s,focusCurrent:n=!1}){const[a,o]=c.useState(!1),r=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{var h;n&&((h=l.current)==null||h.focus())},[]),c.useEffect(()=>{var h;a&&((h=r.current)==null||h.focus())},[a]),!t.length)return null;const u=t[t.length-1],d=t.slice(0,-1),i=!a&&d.length>Ws?d.length-Ws:0;return e.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:e.jsxs("ol",{children:[i>0&&e.jsx("li",{children:e.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>o(!0),children:"…"})}),d.slice(i).map((h,x)=>e.jsx("li",{children:e.jsx("button",{ref:x===0?r:void 0,type:"button",className:"omni-crumb",title:Et(h),"aria-label":Ue(h),onClick:()=>s(h),children:Ue(h)})},h.xpath)),e.jsx("li",{children:e.jsx("span",{ref:l,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Et(u),children:Ue(u)})})]})})}const Dt=.4,fo=240,yo=340,qs=.02,It=12,Mn="xenon.omni.split";function _n(t){if(!(t>0))return{min:0,max:1};const s=Math.min(1,fo/t);return{min:s,max:Math.max(s,(t-yo)/t)}}function xo(t,s){const{min:n,max:a}=_n(s),o=Number.isFinite(t)?t:Dt;return Math.min(a,Math.max(n,o))}function vo(t){try{const s=Number.parseFloat((t==null?void 0:t.getItem(Mn))??"");return s>0&&s<1?s:Dt}catch{return Dt}}function go(t,s){try{t==null||t.setItem(Mn,String(Math.round(s*1e3)/1e3))}catch{}}function Ks(){try{return window.localStorage}catch{return null}}const bo=3;function jo({share:t,limits:s,containerRef:n,onChange:a,onCommit:o,onReset:r}){const[l,u]=c.useState(!1),d=c.useRef(t);d.current=t;const i=c.useRef(!0),h=c.useRef(!1),x=c.useRef(0),k=c.useRef(t),f=w=>Math.min(s.max,Math.max(s.min,w)),y=w=>Math.round(w*100),S=()=>{i.current||(i.current=!0,u(!1),h.current&&o(d.current))},C=w=>{var $;const j=($=n.current)==null?void 0:$.getBoundingClientRect();return!j||j.width<=It?d.current:f(k.current+(w-x.current)/(j.width-It))},L=w=>{const j=w.key==="ArrowLeft"?t-qs:w.key==="ArrowRight"?t+qs:w.key==="Home"?s.min:w.key==="End"?s.max:null;j!==null&&(w.preventDefault(),o(f(Math.round(j*1e3)/1e3)))};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":y(t),"aria-valuemin":y(s.min),"aria-valuemax":y(s.max),tabIndex:0,className:`omni-split-divider${l?" is-dragging":""}`,onKeyDown:L,onDoubleClick:r,onPointerDown:w=>{var j,$;($=(j=w.currentTarget).setPointerCapture)==null||$.call(j,w.pointerId),i.current=!1,h.current=!1,x.current=w.clientX,k.current=d.current,u(!0)},onPointerMove:w=>{if(!l||!h.current&&Math.abs(w.clientX-x.current)<bo)return;const j=C(w.clientX);j!==d.current&&(h.current=!0,a(j))},onPointerUp:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onPointerCancel:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onLostPointerCapture:S,children:e.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Xs(t,s,n,a){var w,j,$,p,D,A,O;const{strategy:o,value:r}=a,l=(t.text||t.name||((w=t.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",u=l.charAt(0).toLowerCase()+l.slice(1),d=((j=t.type)==null?void 0:j.toLowerCase().includes("edit"))||(($=t.type)==null?void 0:$.toLowerCase().includes("input"))||((p=t.type)==null?void 0:p.toLowerCase().includes("field"))||((D=t.type)==null?void 0:D.toLowerCase().includes("textfield")),i=((A=t.attributes)==null?void 0:A.scrollable)==="true"||((O=t.attributes)==null?void 0:O.scrollable)===!0,h=o.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
235
225
  `:o.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
236
- `:"",x={"accessibility id":`~${r}`,id:s==="ios"?`-ios predicate string:label == "${r}"`:`android=new UiSelector().resourceId("${r}")`,xpath:`${r}`,"-ios predicate string":`-ios predicate string:${r}`,"-ios class chain":`-ios class chain:${r}`,"-android uiautomator":`android=${r}`},k={"accessibility id":`AppiumBy.accessibilityId("${r}")`,id:`AppiumBy.id("${r}")`,xpath:`AppiumBy.xpath("${r}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${r}")`,"-ios class chain":`AppiumBy.iOSClassChain("${r}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${r}")`,"class name":`AppiumBy.className("${r}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${r}"`,id:`AppiumBy.ID, "${r}"`,xpath:`AppiumBy.XPATH, "${r}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${r}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${r}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${r}'`,"class name":`AppiumBy.CLASS_NAME, "${r}"`},y=k[o.toLowerCase()],S=f[o.toLowerCase()],C=x[o.toLowerCase()];return n==="java"?y?`${m}// Appium Java Client 9.x + Selenium 4 + TestNG
226
+ `:"",x={"accessibility id":`~${r}`,id:s==="ios"?`-ios predicate string:label == "${r}"`:`android=new UiSelector().resourceId("${r}")`,xpath:`${r}`,"-ios predicate string":`-ios predicate string:${r}`,"-ios class chain":`-ios class chain:${r}`,"-android uiautomator":`android=${r}`},k={"accessibility id":`AppiumBy.accessibilityId("${r}")`,id:`AppiumBy.id("${r}")`,xpath:`AppiumBy.xpath("${r}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${r}")`,"-ios class chain":`AppiumBy.iOSClassChain("${r}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${r}")`,"class name":`AppiumBy.className("${r}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${r}"`,id:`AppiumBy.ID, "${r}"`,xpath:`AppiumBy.XPATH, "${r}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${r}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${r}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${r}'`,"class name":`AppiumBy.CLASS_NAME, "${r}"`},y=k[o.toLowerCase()],S=f[o.toLowerCase()],C=x[o.toLowerCase()];return n==="java"?y?`${h}// Appium Java Client 9.x + Selenium 4 + TestNG
237
227
  import io.appium.java_client.AppiumBy;
238
228
  import io.appium.java_client.${s==="android"?"AndroidDriver":s==="ios"?"IOSDriver":"AppiumDriver"};
239
229
  import org.openqa.selenium.WebElement;
@@ -245,7 +235,7 @@ public void test_${u}() {
245
235
  ${i?'((Scrollable) element).scrollTo("target text");':d?`element.clear();
246
236
  element.sendKeys("your text here");`:"element.click();"}
247
237
  // Add assertions here via TestNG Assert or Hamcrest
248
- }`:`// Strategy "${o}" not supported in Appium Java Client`:n==="python"?S?`${m}# Appium Python Client 4.x + pytest
238
+ }`:`// Strategy "${o}" not supported in Appium Java Client`:n==="python"?S?`${h}# Appium Python Client 4.x + pytest
249
239
  from appium.webdriver.common.appiumby import AppiumBy
250
240
  import pytest
251
241
 
@@ -253,7 +243,7 @@ def test_${u}(self):
253
243
  element = self.driver.find_element(${S})
254
244
  ${d?`element.clear()
255
245
  element.send_keys("your text here")`:"element.click()"}
256
- # Add assertions here via assert or pytest.assert`:`# Strategy "${o}" not supported in Appium Python Client`:n==="javascript"?C?`${m}// WebdriverIO 9.x + @wdio/appium-service
246
+ # Add assertions here via assert or pytest.assert`:`# Strategy "${o}" not supported in Appium Python Client`:n==="javascript"?C?`${h}// WebdriverIO 9.x + @wdio/appium-service
257
247
  describe('${u} test', () => {
258
248
  it('should interact with ${u}', async () => {
259
249
  const element = await $('${C}');
@@ -262,17 +252,17 @@ describe('${u} test', () => {
262
252
  await element.addValue("your text here");`:"await element.click();"}
263
253
  // Add assertions here via expect(element)
264
254
  });
265
- });`:`// Strategy "${o}" not supported in WebdriverIO mobile`:C?`${m}// WebdriverIO 9.x standalone
255
+ });`:`// Strategy "${o}" not supported in WebdriverIO mobile`:C?`${h}// WebdriverIO 9.x standalone
266
256
  const element = await driver.$('${C}');
267
257
  await element.waitForExist({ timeout: 5000 });
268
258
  ${d?`await driver.$('target').clearValue();
269
259
  await element.addValue("your text here");`:"await element.click();"}
270
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${o}" not supported in WebdriverIO mobile`}const wo={pass:e.jsx(hn,{size:13}),warn:e.jsx($e,{size:13}),fail:e.jsx(mn,{size:13}),info:e.jsx(nn,{size:13})},So={pass:"passed",warn:"warning",fail:"failed",info:"note"},Co={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},$o=({sessionId:t,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:o=null,onModeChange:r,deviceActionAt:l=0})=>{var ks,ws,Ss,Cs,$s,Ts;const[u,d]=c.useState(!0),[i,m]=c.useState(null),[x,k]=c.useState(null),[f,y]=c.useState(null),[S,C]=c.useState(0),L=c.useRef(!1),[w,j]=c.useState(null),[$,p]=c.useState(()=>new Set),[D,A]=c.useState(""),[O,W]=c.useState(null),[V,q]=c.useState("info"),[Q,b]=c.useState(0),[oe,te]=c.useState(0),[ce,B]=c.useState(()=>Date.now()),E=c.useRef(0),J=c.useRef(null),[le,ue]=c.useState("java"),[de,fe]=c.useState(null),[ee,ge]=c.useState({width:0,height:0}),[be,_]=c.useState({width:0,height:0}),[v,H]=c.useState(!1),[F,K]=c.useState("inspect");c.useEffect(()=>{r==null||r(F)},[F,r]);const[Ne,tt]=c.useState({}),[zt,st]=c.useState({}),[He,nt]=c.useState(null),[Z,ke]=c.useState(null),[Ee,_e]=c.useState(null),We=c.useRef(null),Lt=c.useRef(null),pt=c.useRef(null),we=c.useRef(null),qe=c.useRef(null),[Ot,ft]=c.useState(()=>bo(Ks())),[yt,Pt]=c.useState(0);c.useEffect(()=>{const h=qe.current;if(!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(([N])=>Pt(Math.max(0,N.contentRect.width-It)));return g.observe(h),()=>g.disconnect()},[]);const at=go(Ot,yt),xt=h=>{ft(h),jo(Ks(),h)},Ke=c.useCallback(()=>{var Se,Ce,Ie;if(!We.current)return;const h=We.current.getBoundingClientRect(),g=h.width,N=h.height,T=(Se=i==null?void 0:i.hierarchy)==null?void 0:Se.rect;let z=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.screenWidth)||ee.width||1,R=((Ie=i==null?void 0:i.metadata)==null?void 0:Ie.screenHeight)||ee.height||1;T&&T.width>0&&T.height>0&&(z=T.width,R=T.height);const X=z/R;let ve,me;g/N>X?(me=N,ve=me*X):(ve=g,me=ve/X),_({width:ve,height:me})},[i,ee]);c.useEffect(()=>(Ke(),window.addEventListener("resize",Ke),()=>window.removeEventListener("resize",Ke)),[Ke]),c.useEffect(()=>{s&&De()},[s]);const vt=c.useCallback(async(h,g,N)=>{if(Z!=null&&Z.sessionId){nt(h);try{const T=await M.verifyLocator(Z.basePath,Z.sessionId,{strategy:h,selector:g,action:N});st(z=>({...z,[h]:T})),N==="tap"&&te(Date.now())}catch(T){st(z=>({...z,[h]:{found:!1,count:0,error:(T==null?void 0:T.message)||String(T)}}))}finally{nt(null)}}},[Z]),it=c.useRef(null);c.useEffect(()=>{const h=!!f&&f.xpath===it.current;it.current=(f==null?void 0:f.xpath)??null;const g=(f==null?void 0:f.suggestedLocators)??[];fe(N=>{const T=h&&N?g.find(R=>R.strategy===N.strategy):null,z=g.find(R=>R.strategy==="accessibility id"||R.strategy==="id");return T||z||g[0]||null}),tt({}),st({}),_e(null)},[f]);const Ft=c.useCallback((h,g)=>{if(!(i!=null&&i.hierarchy))return;const N=cs(i.hierarchy,h,g);tt(T=>({...T,[h]:N})),_e(h)},[i]),De=async()=>{if(!s)return;const h=++E.current,g=()=>h===E.current;d(!0),k(null),M.getAppiumSession(s).then(N=>{g()&&ke({sessionId:(N==null?void 0:N.sessionId)??null,basePath:(N==null?void 0:N.basePath)??""})}).catch(()=>{g()&&ke({sessionId:null,basePath:""})});try{const N=await M.getInspectorSnapshot(s);if(!g())return;if(!(N!=null&&N.hierarchy)){m(null),k((N==null?void 0:N.error)||"Failed to capture snapshot");return}const T=N.udid||s,z=T===J.current;J.current=T,_s.unstable_batchedUpdates(()=>{m(N),b(Date.now()),p(ho(N.hierarchy)),y(R=>{var X;return R&&z?((X=Rt(N.hierarchy,R.xpath))==null?void 0:X.pop())??null:null}),C(R=>R+1)})}catch(N){if(!g())return;m(null),k(N.message||"Failed to capture snapshot")}finally{g()&&d(!1)}};c.useEffect(()=>{const h=setInterval(()=>B(Date.now()),1e4);return()=>clearInterval(h)},[]);const Ut=h=>{const{naturalWidth:g,naturalHeight:N}=h.currentTarget;ge({width:g,height:N})},Bt=()=>H(!0),I=h=>{H(!1);const{naturalWidth:g,naturalHeight:N}=h.currentTarget;g>0&&N>0&&ge({width:g,height:N})},U=n&&!v,G=h=>{if(F!=="interact"||!s)return;const g=h.currentTarget.getBoundingClientRect();we.current={x:h.clientX-g.left,y:h.clientY-g.top,time:Date.now()}},se=async h=>{var As,Es,Ds;if(F!=="interact"||!s||!we.current)return;const g=we.current,N=h.currentTarget.getBoundingClientRect(),T=h.clientX-N.left,z=h.clientY-N.top,R=Date.now()-g.time,X=be.width,ve=be.height,me=(As=i==null?void 0:i.hierarchy)==null?void 0:As.rect;let Se=((Es=i==null?void 0:i.metadata)==null?void 0:Es.screenWidth)||ee.width,Ce=((Ds=i==null?void 0:i.metadata)==null?void 0:Ds.screenHeight)||ee.height;if(me&&me.width>0&&me.height>0&&(Se=me.width,Ce=me.height),!Se||!Ce||X===0||ve===0)return;const Ie=(jt,Is)=>({x:Math.round(jt/X*Se),y:Math.round(Is/ve*Ce),px:jt/X,py:Is/ve}),he=Ie(g.x,g.y),Rs=Ie(T,z),Xt=Math.sqrt(Math.pow(T-g.x,2)+Math.pow(z-g.y,2));if(!(he.px<0||he.px>1||he.py<0||he.py>1)){try{R<500&&Xt<10?await M.tap(s,he.x,he.y):R>=500&&Xt<10?await M.touchAndHold(s,he.x,he.y,R):Xt>=10&&await M.swipe(s,he.x,he.y,Rs.x,Rs.y),te(Date.now())}catch(jt){console.error("Interaction failed:",jt)}we.current=null}},ye=h=>{p(g=>{const N=new Set(g);return N.has(h)?N.delete(h):N.add(h),N})},ie=()=>{const h=new Set,g=N=>{var T;h.add(N.xpath),(T=N.children)==null||T.forEach(g)};i!=null&&i.hierarchy&&g(i.hierarchy),p(h)},xe=()=>p(new Set),ne=(h,g)=>{navigator.clipboard.writeText(h),W(g),setTimeout(()=>W(null),2e3)},ae=h=>{var N;let g=1;return(N=h.children)==null||N.forEach(T=>g+=ae(T)),g},Xe=h=>{if(!h)return[];const g={},N=T=>{var R;const z=Tn(T);g[z.role]||(g[z.role]={key:z.key,count:0}),g[z.role].count+=1,(R=T.children)==null||R.forEach(N)};return N(h),Object.entries(g).map(([T,z])=>({role:T,key:z.key,count:z.count})).sort((T,z)=>z.count-T.count)},Ge=c.useMemo(()=>uo(i==null?void 0:i.hierarchy,$,D),[i,$,D]),ze=c.useMemo(()=>In(i==null?void 0:i.hierarchy,D),[i,D]),rt=ze.size===0?"No matches":ze.size===1?"1 match":`${ze.size} matches`;c.useEffect(()=>{if(!f||!(i!=null&&i.hierarchy))return;const h=Rt(i.hierarchy,f.xpath);!h||h.length<2||p(g=>{const N=h.slice(0,-1).filter(z=>!g.has(z.xpath));if(!N.length)return g;const T=new Set(g);return N.forEach(z=>T.add(z.xpath)),T})},[S]),c.useEffect(()=>{L.current=!1});const Ye=h=>{y(h),C(g=>g+1),q("info")},Vt=h=>{L.current=!0,Ye(h)},gs=h=>{D.trim()&&!h.trim()&&C(g=>g+1),A(h)},Ht=()=>{var T,z,R;const h=(T=i==null?void 0:i.hierarchy)==null?void 0:T.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const g=((z=i==null?void 0:i.metadata)==null?void 0:z.screenWidth)||ee.width,N=((R=i==null?void 0:i.metadata)==null?void 0:R.screenHeight)||ee.height;return g>0&&N>0?{w:g,h:N}:null},bs=h=>{const g=Ht();if(!g)return[];const N=[],{w:T,h:z}=g,R=(X,ve)=>{var Se,Ce,Ie;const me=!X.children||X.children.length===0;((Se=X.rect)==null?void 0:Se.width)>0&&((Ce=X.rect)==null?void 0:Ce.height)>0&&me&&N.push(e.jsx("div",{className:"omni-hit-area",style:{left:`${X.rect.x/T*100}%`,top:`${X.rect.y/z*100}%`,width:`${X.rect.width/T*100}%`,height:`${X.rect.height/z*100}%`,zIndex:ve},onClick:he=>{he.stopPropagation(),Ye(X)},onMouseEnter:()=>j(X),onMouseLeave:()=>j(null)},X.xpath)),(Ie=X.children)==null||Ie.forEach(he=>R(he,ve+1))};return i!=null&&i.hierarchy&&R(i.hierarchy,1),N},js=()=>{const h=Ht();if(!Ee||!h)return[];const g=Ne[Ee];if(!g||g.kind!=="matched"||g.nodes.length===0)return[];const{w:N,h:T}=h,z=g.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return g.nodes.filter(R=>R.rect&&R.rect.width>0&&R.rect.height>0).map((R,X)=>e.jsx("div",{className:z,style:{left:`${R.rect.x/N*100}%`,top:`${R.rect.y/T*100}%`,width:`${R.rect.width/N*100}%`,height:`${R.rect.height/T*100}%`}},`match-${Ee}-${X}`))},gt=(h,g)=>{const N=Ht();if(!(h!=null&&h.rect)||!N)return null;const{w:T,h:z}=N;return e.jsx("div",{className:`omni-frame-${g}`,style:{left:`${h.rect.x/T*100}%`,top:`${h.rect.y/z*100}%`,width:`${h.rect.width/T*100}%`,height:`${h.rect.height/z*100}%`}})},Wt=i!=null&&i.hierarchy?ae(i.hierarchy):0,bt=f&&(i!=null&&i.hierarchy)?so(f,i):null,Le=bt?no(bt):null,qt=io(Q,Math.max(l,oe)),Kt=i!=null&&i.hierarchy&&F==="inspect"?e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]}):null,Vn={stable:{icon:e.jsx(Nt,{size:10}),cls:"stable"},moderate:{icon:e.jsx($e,{size:10}),cls:"moderate"},fragile:{icon:e.jsx(Ze,{size:10}),cls:"fragile"},"very-fragile":{icon:e.jsx(Ze,{size:10}),cls:"very-fragile"}},Ns=a&&(i!=null&&i.hierarchy)?Xe(i.hierarchy):[];return e.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&o&&Kt?_s.createPortal(Kt,o):null,e.jsxs("div",{className:"omni-main-content",children:[!a&&e.jsxs("div",{className:"omni-screenshot-panel",children:[e.jsxs("div",{className:"omni-screenshot-header",children:[e.jsxs("div",{className:"omni-header-left",children:[e.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),e.jsxs("div",{className:"omni-mode-toggle",children:[e.jsxs("button",{className:`omni-mode-btn ${F==="inspect"?"active":""}`,onClick:()=>K("inspect"),title:"Inspection mode (highlight elements)",children:[e.jsx(Ls,{size:12}),e.jsx("span",{children:"Inspect"})]}),e.jsxs("button",{className:`omni-mode-btn ${F==="interact"?"active":""}`,onClick:()=>K("interact"),title:"Interaction mode (direct control)",children:[e.jsx(Us,{size:12}),e.jsx("span",{children:"Interact"})]})]})]}),e.jsxs("button",{className:"omni-refresh-btn",onClick:De,disabled:u,children:[e.jsx(lt,{size:12,className:u?"animate-spin":""}),u?"Capturing...":"Refresh"]})]}),e.jsxs("div",{className:"omni-screenshot-container",ref:We,children:[u&&!U&&e.jsxs("div",{className:"omni-loading-overlay",children:[e.jsx("div",{className:"omni-spinner"}),e.jsx("span",{children:"Capturing screen..."})]}),!i&&!u&&!U&&e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:40}),e.jsx("span",{children:"Click Refresh to capture"})]}),U&&e.jsxs("div",{className:`omni-screenshot-wrapper ${F==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:pt,src:n,onLoad:I,onError:Bt,className:"omni-screenshot-img",style:F==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),Kt]}),!U&&(i==null?void 0:i.screenshot)&&e.jsxs("div",{className:`omni-screenshot-wrapper ${F==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:Lt,src:`data:image/png;base64,${i.screenshot}`,onLoad:Ut,className:"omni-screenshot-img",style:F==="interact"?{pointerEvents:"none"}:{},draggable:!1}),F==="inspect"&&e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]})]})]})]}),e.jsxs("div",{className:"omni-split",ref:qe,children:[e.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${at*100}% - ${at*It}px)`},children:[e.jsxs("div",{className:"omni-tree-header",children:[e.jsxs("div",{className:"omni-tree-title",children:[e.jsx(dn,{size:14}),e.jsx("span",{children:"Source"})]}),e.jsxs("div",{className:"omni-tree-actions",children:[e.jsx("button",{onClick:ie,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:e.jsx(La,{size:12})}),e.jsx("button",{onClick:xe,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:e.jsx(_a,{size:12})}),a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(F==="inspect"?"interact":"inspect"),className:`omni-action-btn ${F==="inspect"?"active":""}`,title:F==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":F==="inspect"?"Inspect mode":"Interact mode","aria-pressed":F==="inspect",children:F==="inspect"?e.jsx(Ls,{size:12}):e.jsx(Us,{size:12})}),e.jsx("button",{onClick:De,className:"omni-action-btn",title:u?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:u,children:e.jsx(lt,{size:12,className:u?"animate-spin":""})})]})]})]}),x&&!u&&e.jsxs("div",{className:"omni-tree-error",role:"alert",children:[e.jsx(Ze,{size:12}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",onClick:De,className:"omni-tree-error-retry",children:"Retry"})]}),i&&!u&&!x&&(qt?e.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[e.jsx($e,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"The screen may have changed since this capture."}),e.jsx("button",{type:"button",onClick:De,className:"omni-capture-refresh",children:"Refresh"})]}):e.jsxs("div",{className:"omni-capture-meta",children:[e.jsxs("span",{children:[Wt," ",Wt===1?"element":"elements"]}),i.hierarchySource&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"omni-capture-source",title:i.hierarchySource==="appium-session"?`From Appium session ${i.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:i.hierarchySource==="appium-session"?"Session":"Device"})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:ao(Q,ce)})]})),e.jsxs("div",{className:"omni-tree-search",children:[e.jsx(hs,{size:14}),e.jsx("input",{type:"text",placeholder:"Search elements",value:D,onChange:h=>gs(h.target.value),"aria-label":"Search elements"}),D&&e.jsx("button",{onClick:()=>gs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),e.jsx("div",{role:"status",className:"sr-only",children:D.trim()?rt:""}),D.trim()&&e.jsxs("div",{className:"omni-search-hint",children:[rt," · try a role: button, input, image"]}),e.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?e.jsx(fo,{rows:Ge,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:ze,onToggle:ye,onSelect:Ye,onHover:j,revealSeq:S}):e.jsx("div",{className:"omni-empty-state small",children:e.jsx("span",{children:"No hierarchy loaded"})})})]}),e.jsx(ko,{share:at,limits:_n(yt),containerRef:qe,onChange:ft,onCommit:xt,onReset:()=>xt(Dt)}),e.jsxs("div",{className:"omni-details-panel",children:[e.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[e.jsxs("button",{className:`omni-details-tab ${V==="info"?"active":""}`,onClick:()=>q("info"),role:"tab","aria-selected":V==="info",children:[e.jsx(ai,{size:12})," ",e.jsx("span",{children:"Info"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="checks"?"active":""}`,onClick:()=>q("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":V==="checks",children:[e.jsx(ei,{size:12})," ",e.jsx("span",{children:"Checks"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="code"?"active":""}`,onClick:()=>q("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":V==="code",children:[e.jsx(Fs,{size:12})," ",e.jsx("span",{children:"Code gen"})]})]}),e.jsx("div",{className:"omni-details-content",children:f?e.jsxs(e.Fragment,{children:[V==="info"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Element info"}),e.jsxs("div",{className:"omni-info-table",children:[e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Type"}),e.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Text"}),e.jsx("span",{className:"omni-info-value",children:f.text})]}),e.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[e.jsx("span",{className:"omni-info-key",children:"Path"}),e.jsx(yo,{path:(i==null?void 0:i.hierarchy)&&Rt(i.hierarchy,f.xpath)||[f],onSelect:Vt,focusCurrent:L.current},f.xpath)]})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Layout"}),e.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>e.jsxs("div",{className:"omni-layout-item",children:[e.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),e.jsx("span",{className:"omni-layout-value",children:f.rect[h]})]},h))})]}),e.jsxs("div",{className:"omni-section",children:[e.jsxs("div",{className:"omni-section-header",children:["Locators",e.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(Z!=null&&Z.sessionId)&&((Ss=f.suggestedLocators)==null?void 0:Ss.length)>0&&e.jsxs("p",{className:"omni-locators-note",children:[e.jsx(nn,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),e.jsxs("div",{className:"omni-locators-list",children:[!((Cs=f.suggestedLocators)!=null&&Cs.length)&&e.jsx("div",{className:"omni-locators-empty",children:f===(i==null?void 0:i.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),($s=f.suggestedLocators)==null?void 0:$s.map(h=>{const g=ls(h.strategy,h.value),N=Vn[g.level],T=Ne[h.strategy];let z=null;return T&&(T.kind==="unsupported"?z=e.jsxs("span",{className:"omni-match-badge unsupported",title:T.reason||"Cannot evaluate without a real driver",children:[e.jsx(Pa,{size:10})," preview unavailable"]}):T.nodes.length===0?z=e.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[e.jsx(Ze,{size:10})," 0 matches"]}):T.nodes.length===1?z=e.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[e.jsx(Nt,{size:10})," unique"]}):z=e.jsxs("span",{className:"omni-match-badge multi",title:`${T.nodes.length} elements match — selector is not unique`,children:[e.jsx($e,{size:10})," ",T.nodes.length," matches"]})),e.jsx("div",{className:`omni-locator-row ${(de==null?void 0:de.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>fe(h),title:"Click to use in Code gen",children:e.jsxs("div",{className:"omni-locator-left",children:[e.jsxs("div",{className:"omni-locator-top",children:[e.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),e.jsxs("span",{className:`omni-stability-badge ${N.cls}`,title:g.reason,children:[N.icon,g.level]}),z]}),e.jsx("code",{className:"omni-locator-value",children:h.value}),e.jsx("span",{className:"omni-stability-reason",children:g.reason}),(()=>{const R=zt[h.strategy];return R?R.error?e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium error: ",R.error]}):R.found?R.count>1?e.jsxs("span",{className:"omni-verify-line is-warn",children:[e.jsx($e,{size:10})," Ambiguous — Appium found"," ",R.count," elements",R.actionError?` · ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-ok",children:[e.jsx(Nt,{size:10})," Appium found 1 element",R.elapsedMs!=null?` in ${R.elapsedMs}ms`:"",R.actionPerformed&&R.actionPerformed!=="none"?` · ${R.actionPerformed} ok`:"",R.actionError?` · action failed: ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium found 0 elements"]}):null})(),e.jsxs("div",{className:"omni-locator-actions",children:[e.jsxs(Y,{type:"button",variant:Ee===h.strategy?"tonal":"secondary",size:"sm",onClick:R=>{R.stopPropagation(),Ft(h.strategy,h.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[e.jsx(Ba,{size:12,"aria-hidden":"true"}),"Test"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[He===h.strategy?e.jsx(lt,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(Nt,{size:12,"aria-hidden":"true"}),"Verify"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[e.jsx(un,{size:12,"aria-hidden":"true"}),"Tap"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",onClick:R=>{R.stopPropagation(),ne(h.value,h.strategy)},title:"Copy the locator's value","aria-label":O===h.strategy?"Copied":"Copy locator",children:[O===h.strategy?e.jsx(dt,{size:12,"aria-hidden":"true"}):e.jsx(Te,{size:12,"aria-hidden":"true"}),O===h.strategy?"Copied":"Copy"]})]})]})},h.strategy)})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Attributes"}),e.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([h,g])=>g!=null&&g!=="").map(([h,g])=>e.jsxs("div",{className:"omni-attr-row",children:[e.jsx("span",{className:"omni-attr-key",children:h}),e.jsx("span",{className:"omni-attr-value",children:String(g)})]},h))})]})]}),V==="checks"&&bt&&Le&&e.jsxs("div",{className:"omni-checks-panel",children:[e.jsxs("p",{className:"omni-checks-summary",children:[e.jsxs("span",{className:"is-pass",children:[e.jsx(hn,{size:12,"aria-hidden":"true"})," ",Le.pass," passed"]}),Le.warn>0&&e.jsxs("span",{className:"is-warn",children:[e.jsx($e,{size:12,"aria-hidden":"true"})," ",Le.warn," ",Le.warn===1?"warning":"warnings"]}),Le.fail>0&&e.jsxs("span",{className:"is-fail",children:[e.jsx(mn,{size:12,"aria-hidden":"true"})," ",Le.fail," failed"]})]}),e.jsx("ul",{className:"omni-checks-list",children:bt.map(h=>e.jsxs("li",{className:`omni-check is-${h.status}`,children:[e.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:wo[h.status]}),e.jsxs("div",{className:"omni-check-body",children:[e.jsxs("div",{className:"omni-check-label",children:[h.label,e.jsxs("span",{className:"sr-only",children:[": ",So[h.status]]})]}),e.jsx("div",{className:"omni-check-detail",children:h.detail})]})]},h.id))})]}),V==="code"&&e.jsxs("div",{className:"omni-codegen-panel",children:[e.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>e.jsx("button",{className:`omni-fw-btn ${le===h?"active":""}`,onClick:()=>ue(h),children:Co[h]},h))}),de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-codegen-locator-selector",children:[e.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),e.jsx(ms,{selectSize:"sm",value:de.strategy,onChange:h=>{var N;const g=(N=f.suggestedLocators)==null?void 0:N.find(T=>T.strategy===h.target.value);g&&fe(g)},className:"flex-1",children:(Ts=f.suggestedLocators)==null?void 0:Ts.map(h=>e.jsxs("option",{value:h.strategy,children:[h.strategy," — ",ls(h.strategy,h.value).level]},h.strategy))})]}),e.jsxs("div",{className:"omni-codegen-output",children:[e.jsxs("div",{className:"omni-codegen-header",children:[e.jsx("span",{className:"omni-codegen-lang",children:le==="java"?"Java / TestNG":le==="python"?"Python / unittest":le==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),e.jsx("button",{className:"omni-copy-btn",onClick:()=>ne(Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de),"code"),children:O==="code"?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]}),e.jsx("pre",{className:"omni-codegen-pre theme-dark",children:e.jsx("code",{children:Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de)})})]})]}):e.jsxs("div",{className:"omni-empty-state small",children:[e.jsx(Fs,{size:24}),e.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?e.jsxs("div",{className:"omni-summary-panel",children:[e.jsxs("div",{className:"omni-summary-hero",children:[e.jsx(Zt,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"omni-summary-title",children:"No element selected"}),e.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),e.jsxs("div",{className:"omni-summary-stats",children:[e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),e.jsx("span",{className:"omni-summary-stat__value",children:Wt})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ks=i.metadata)==null?void 0:ks.screenWidth)??ee.width??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ws=i.metadata)==null?void 0:ws.screenHeight)??ee.height??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),e.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),Ns.length>0&&e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"By role"}),e.jsx("div",{className:"omni-summary-roles",children:Ns.slice(0,8).map(h=>e.jsxs("div",{className:"omni-summary-role",children:[e.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:Rn[h.key]}),e.jsx("span",{className:"omni-summary-role__name",children:h.role}),e.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:32}),e.jsx("span",{children:u?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Gs=5e3;function To(t,s=!0){const[n,a]=c.useState("unknown"),o=c.useRef("unknown");return c.useEffect(()=>{if(!t||!s){a("unknown"),o.current="unknown";return}let r=!1,l;const u=m=>{r||m===o.current||(o.current=m,a(m))},d=async()=>{if(!r){if(l&&(clearTimeout(l),l=void 0),typeof document<"u"&&document.visibilityState==="hidden"){l=setTimeout(d,Gs);return}try{const m=await M.getDisplayState(t);u((m==null?void 0:m.state)??"unknown")}catch{}r||(l=setTimeout(d,Gs))}};d();const i=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",i),()=>{r=!0,l&&clearTimeout(l),document.removeEventListener("visibilitychange",i)}},[t,s]),n}function Ro(t,s){const n=c.useRef(t),a=c.useRef(s);n.current=t,a.current=s,c.useEffect(()=>{const o=()=>n.current(),r=l=>{var u;l.persisted&&((u=a.current)==null||u.call(a))};return window.addEventListener("pagehide",o),window.addEventListener("pageshow",r),()=>{window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",r)}},[])}const Ys=5e3,Ao=500,Eo=1e4,Do=10,Io=50;function Mo(t,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[o,r]=c.useState([]),[l,u]=c.useState(!1),[d,i]=c.useState(null),[m,x]=c.useState(!1),k=c.useRef(null),f=c.useRef(0),y=c.useRef(void 0),S=c.useRef(()=>{}),C=c.useRef([]),L=c.useRef(void 0),w=c.useRef(0),j=c.useRef(void 0),$=c.useCallback(()=>{if(C.current.length===0)return;const O=C.current;C.current=[],r(W=>{const V=W.concat(O);return V.length>Ys?V.slice(-Ys):V})},[]),p=c.useCallback(()=>{L.current===void 0&&(L.current=window.setTimeout(()=>{L.current=void 0,$()},Io))},[$]),D=c.useCallback(()=>{C.current=[],r([])},[]);c.useEffect(()=>{if(!s){u(!1),i(null),x(!1);return}i(null),x(!1),f.current=0;const O={cancelled:!1},W=()=>{if(O.cancelled)return;if(f.current>=Do){x(!0);return}const q=Math.min(Ao*2**f.current,Eo);f.current+=1,y.current=window.setTimeout(V,q)},V=async()=>{if(!O.cancelled)try{const q=await fetch(`/xenon/api/control/${encodeURIComponent(t)}/stream/ticket`,{method:"POST",credentials:"include"});if(O.cancelled)return;if(!q.ok){W();return}const{ticket:Q}=await q.json();if(O.cancelled)return;if(!Q){W();return}const b=window.location.protocol==="https:"?"wss":"ws",[oe,te]=a.split("|"),ce=(oe?`&levels=${encodeURIComponent(oe)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),B=new WebSocket(`${b}://${window.location.host}/xenon/api/control/${encodeURIComponent(t)}/logcat?ticket=${encodeURIComponent(Q)}${ce}`);k.current=B,B.onopen=()=>{f.current=0,j.current!==1012&&(C.current=[],r([])),j.current=void 0,u(!0)},B.onmessage=E=>{try{const J=JSON.parse(E.data);C.current.push({...J,seq:w.current++}),p()}catch{}},B.onclose=E=>{if(u(!1),j.current=E.code,$(),E.code===1008){O.cancelled=!0,i(E.reason||"access denied");return}if(E.code===1012){W();return}console.warn(`[logcat] WS closed unexpectedly (code ${E.code}) — retrying`),W()},B.onerror=()=>B.close()}catch{W()}};return S.current=()=>{O.cancelled=!1,f.current=0,i(null),x(!1),V()},V(),()=>{var q;O.cancelled=!0,y.current!==void 0&&window.clearTimeout(y.current),L.current!==void 0&&(window.clearTimeout(L.current),L.current=void 0),$(),(q=k.current)==null||q.close(),k.current=null}},[t,s,a,$,p]);const A=c.useCallback(()=>{S.current()},[]);return{records:o,connected:l,clear:D,deniedReason:d,exhausted:m,retry:A}}const ds=["V","D","I","W","E","F"];function _o(t){const s=[];let n="",a=!1,o=!1;for(const r of t){if(r==='"'){a=!a,o=!0;continue}if(!a&&/\s/.test(r)){(o||n)&&s.push(n),n="",o=!1;continue}n+=r,o=!0}return(o||n)&&s.push(n),s.filter(r=>r.length>0)}function zn(t,s={}){const n=s.caseSensitive===!0,a=l=>n?l:l.toLowerCase(),o=n?{caseSensitive:!0}:{},r=[];for(const l of _o(t)){const[u,...d]=l.split(":"),i=d.join(":");i&&u.toLowerCase()==="level"?o.minLevel=i.toUpperCase():i&&u.toLowerCase()==="tag"?o.tag=a(i):i&&u.toLowerCase()==="package"?o.pkg=a(i):r.push(l)}return r.length&&(o.text=a(r.join(" "))),o}function zo(t,s){if(t.synthetic)return!0;if(s.minLevel){const a=ds.indexOf(s.minLevel),o=ds.indexOf(t.level);if(a>=0&&o>=0&&o<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();return!(s.tag&&!n(t.tag).includes(s.tag)||s.pkg&&!n(t.pkg??"").includes(s.pkg)||s.text&&!n(t.message).includes(s.text))}function Lo(t,s){const n=t.trim().split(/\s+/).filter(Boolean).filter(a=>{const[o,...r]=a.split(":");return!(r.join(":")&&o.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const ss=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],Zs=["V","D","I","W","E","F"];function Oo(t){if(!t)return ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=Zs.indexOf(t.toUpperCase());return s<0?ss.map(n=>n.ios):ss.filter(n=>Zs.indexOf(n.android)>=s).map(n=>n.ios)}function Po(t){const s=zn(t,{caseSensitive:!0});return{levels:Oo(s.minLevel),process:s.pkg||void 0}}const Js=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Fo(t){let s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Uo(t){return t?Js[Fo(t)%Js.length]:"var(--text-muted)"}const us=5e5;function Ln(t){return`${new Date(t.ts).toISOString()} ${t.pid} ${t.level}/${t.tag}: ${t.message}`}function Bo(t){return{lines:[],startedAt:t,dropped:0}}function Vo(t,s){for(const n of s){if(t.lines.length>=us){t.dropped+=1;continue}t.lines.push(Ln(n))}return t}function Ho(t,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(t.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-t.startedAt)/1e3).toFixed(1)}s`,`# lines: ${t.lines.length}`];t.dropped>0&&a.push(`# TRUNCATED: ${t.dropped} further line(s) were dropped after the ${us}-line cap. This capture is INCOMPLETE.`);const o=t.lines.join(`
260
+ // Assert with expect(element).toBeDisplayed()`:`// Strategy "${o}" not supported in WebdriverIO mobile`}const No={pass:e.jsx(mn,{size:13}),warn:e.jsx($e,{size:13}),fail:e.jsx(hn,{size:13}),info:e.jsx(nn,{size:13})},ko={pass:"passed",warn:"warning",fail:"failed",info:"note"},wo={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},So=({sessionId:t,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:o=null,onModeChange:r,deviceActionAt:l=0})=>{var ks,ws,Ss,Cs,$s,Ts;const[u,d]=c.useState(!0),[i,h]=c.useState(null),[x,k]=c.useState(null),[f,y]=c.useState(null),[S,C]=c.useState(0),L=c.useRef(!1),[w,j]=c.useState(null),[$,p]=c.useState(()=>new Set),[D,A]=c.useState(""),[O,W]=c.useState(null),[V,q]=c.useState("info"),[Q,b]=c.useState(0),[oe,te]=c.useState(0),[ce,B]=c.useState(()=>Date.now()),E=c.useRef(0),J=c.useRef(null),[le,ue]=c.useState("java"),[de,fe]=c.useState(null),[ee,ge]=c.useState({width:0,height:0}),[be,_]=c.useState({width:0,height:0}),[v,H]=c.useState(!1),[P,K]=c.useState("inspect");c.useEffect(()=>{r==null||r(P)},[P,r]);const[Ne,tt]=c.useState({}),[zt,st]=c.useState({}),[He,nt]=c.useState(null),[Z,ke]=c.useState(null),[Ee,_e]=c.useState(null),We=c.useRef(null),Lt=c.useRef(null),pt=c.useRef(null),we=c.useRef(null),qe=c.useRef(null),[Ot,ft]=c.useState(()=>vo(Ks())),[yt,Pt]=c.useState(0);c.useEffect(()=>{const m=qe.current;if(!m||typeof ResizeObserver>"u")return;const g=new ResizeObserver(([N])=>Pt(Math.max(0,N.contentRect.width-It)));return g.observe(m),()=>g.disconnect()},[]);const at=xo(Ot,yt),xt=m=>{ft(m),go(Ks(),m)},Ke=c.useCallback(()=>{var Se,Ce,Ie;if(!We.current)return;const m=We.current.getBoundingClientRect(),g=m.width,N=m.height,T=(Se=i==null?void 0:i.hierarchy)==null?void 0:Se.rect;let z=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.screenWidth)||ee.width||1,R=((Ie=i==null?void 0:i.metadata)==null?void 0:Ie.screenHeight)||ee.height||1;T&&T.width>0&&T.height>0&&(z=T.width,R=T.height);const X=z/R;let ve,he;g/N>X?(he=N,ve=he*X):(ve=g,he=ve/X),_({width:ve,height:he})},[i,ee]);c.useEffect(()=>(Ke(),window.addEventListener("resize",Ke),()=>window.removeEventListener("resize",Ke)),[Ke]),c.useEffect(()=>{s&&De()},[s]);const vt=c.useCallback(async(m,g,N)=>{if(Z!=null&&Z.sessionId){nt(m);try{const T=await M.verifyLocator(Z.basePath,Z.sessionId,{strategy:m,selector:g,action:N});st(z=>({...z,[m]:T})),N==="tap"&&te(Date.now())}catch(T){st(z=>({...z,[m]:{found:!1,count:0,error:(T==null?void 0:T.message)||String(T)}}))}finally{nt(null)}}},[Z]),it=c.useRef(null);c.useEffect(()=>{const m=!!f&&f.xpath===it.current;it.current=(f==null?void 0:f.xpath)??null;const g=(f==null?void 0:f.suggestedLocators)??[];fe(N=>{const T=m&&N?g.find(R=>R.strategy===N.strategy):null,z=g.find(R=>R.strategy==="accessibility id"||R.strategy==="id");return T||z||g[0]||null}),tt({}),st({}),_e(null)},[f]);const Ft=c.useCallback((m,g)=>{if(!(i!=null&&i.hierarchy))return;const N=cs(i.hierarchy,m,g);tt(T=>({...T,[m]:N})),_e(m)},[i]),De=async()=>{if(!s)return;const m=++E.current,g=()=>m===E.current;d(!0),k(null),M.getAppiumSession(s).then(N=>{g()&&ke({sessionId:(N==null?void 0:N.sessionId)??null,basePath:(N==null?void 0:N.basePath)??""})}).catch(()=>{g()&&ke({sessionId:null,basePath:""})});try{const N=await M.getInspectorSnapshot(s);if(!g())return;if(!(N!=null&&N.hierarchy)){h(null),k((N==null?void 0:N.error)||"Failed to capture snapshot");return}const T=N.udid||s,z=T===J.current;J.current=T,_s.unstable_batchedUpdates(()=>{h(N),b(Date.now()),p(lo(N.hierarchy)),y(R=>{var X;return R&&z?((X=Rt(N.hierarchy,R.xpath))==null?void 0:X.pop())??null:null}),C(R=>R+1)})}catch(N){if(!g())return;h(null),k(N.message||"Failed to capture snapshot")}finally{g()&&d(!1)}};c.useEffect(()=>{const m=setInterval(()=>B(Date.now()),1e4);return()=>clearInterval(m)},[]);const Ut=m=>{const{naturalWidth:g,naturalHeight:N}=m.currentTarget;ge({width:g,height:N})},Bt=()=>H(!0),I=m=>{H(!1);const{naturalWidth:g,naturalHeight:N}=m.currentTarget;g>0&&N>0&&ge({width:g,height:N})},F=n&&!v,G=m=>{if(P!=="interact"||!s)return;const g=m.currentTarget.getBoundingClientRect();we.current={x:m.clientX-g.left,y:m.clientY-g.top,time:Date.now()}},se=async m=>{var As,Es,Ds;if(P!=="interact"||!s||!we.current)return;const g=we.current,N=m.currentTarget.getBoundingClientRect(),T=m.clientX-N.left,z=m.clientY-N.top,R=Date.now()-g.time,X=be.width,ve=be.height,he=(As=i==null?void 0:i.hierarchy)==null?void 0:As.rect;let Se=((Es=i==null?void 0:i.metadata)==null?void 0:Es.screenWidth)||ee.width,Ce=((Ds=i==null?void 0:i.metadata)==null?void 0:Ds.screenHeight)||ee.height;if(he&&he.width>0&&he.height>0&&(Se=he.width,Ce=he.height),!Se||!Ce||X===0||ve===0)return;const Ie=(jt,Is)=>({x:Math.round(jt/X*Se),y:Math.round(Is/ve*Ce),px:jt/X,py:Is/ve}),me=Ie(g.x,g.y),Rs=Ie(T,z),Xt=Math.sqrt(Math.pow(T-g.x,2)+Math.pow(z-g.y,2));if(!(me.px<0||me.px>1||me.py<0||me.py>1)){try{R<500&&Xt<10?await M.tap(s,me.x,me.y):R>=500&&Xt<10?await M.touchAndHold(s,me.x,me.y,R):Xt>=10&&await M.swipe(s,me.x,me.y,Rs.x,Rs.y),te(Date.now())}catch(jt){console.error("Interaction failed:",jt)}we.current=null}},ye=m=>{p(g=>{const N=new Set(g);return N.has(m)?N.delete(m):N.add(m),N})},ie=()=>{const m=new Set,g=N=>{var T;m.add(N.xpath),(T=N.children)==null||T.forEach(g)};i!=null&&i.hierarchy&&g(i.hierarchy),p(m)},xe=()=>p(new Set),ne=(m,g)=>{navigator.clipboard.writeText(m),W(g),setTimeout(()=>W(null),2e3)},ae=m=>{var N;let g=1;return(N=m.children)==null||N.forEach(T=>g+=ae(T)),g},Xe=m=>{if(!m)return[];const g={},N=T=>{var R;const z=Tn(T);g[z.role]||(g[z.role]={key:z.key,count:0}),g[z.role].count+=1,(R=T.children)==null||R.forEach(N)};return N(m),Object.entries(g).map(([T,z])=>({role:T,key:z.key,count:z.count})).sort((T,z)=>z.count-T.count)},Ge=c.useMemo(()=>co(i==null?void 0:i.hierarchy,$,D),[i,$,D]),ze=c.useMemo(()=>In(i==null?void 0:i.hierarchy,D),[i,D]),rt=ze.size===0?"No matches":ze.size===1?"1 match":`${ze.size} matches`;c.useEffect(()=>{if(!f||!(i!=null&&i.hierarchy))return;const m=Rt(i.hierarchy,f.xpath);!m||m.length<2||p(g=>{const N=m.slice(0,-1).filter(z=>!g.has(z.xpath));if(!N.length)return g;const T=new Set(g);return N.forEach(z=>T.add(z.xpath)),T})},[S]),c.useEffect(()=>{L.current=!1});const Ye=m=>{y(m),C(g=>g+1),q("info")},Vt=m=>{L.current=!0,Ye(m)},gs=m=>{D.trim()&&!m.trim()&&C(g=>g+1),A(m)},Ht=()=>{var T,z,R;const m=(T=i==null?void 0:i.hierarchy)==null?void 0:T.rect;if(m&&m.width>0&&m.height>0)return{w:m.width,h:m.height};const g=((z=i==null?void 0:i.metadata)==null?void 0:z.screenWidth)||ee.width,N=((R=i==null?void 0:i.metadata)==null?void 0:R.screenHeight)||ee.height;return g>0&&N>0?{w:g,h:N}:null},bs=m=>{const g=Ht();if(!g)return[];const N=[],{w:T,h:z}=g,R=(X,ve)=>{var Se,Ce,Ie;const he=!X.children||X.children.length===0;((Se=X.rect)==null?void 0:Se.width)>0&&((Ce=X.rect)==null?void 0:Ce.height)>0&&he&&N.push(e.jsx("div",{className:"omni-hit-area",style:{left:`${X.rect.x/T*100}%`,top:`${X.rect.y/z*100}%`,width:`${X.rect.width/T*100}%`,height:`${X.rect.height/z*100}%`,zIndex:ve},onClick:me=>{me.stopPropagation(),Ye(X)},onMouseEnter:()=>j(X),onMouseLeave:()=>j(null)},X.xpath)),(Ie=X.children)==null||Ie.forEach(me=>R(me,ve+1))};return i!=null&&i.hierarchy&&R(i.hierarchy,1),N},js=()=>{const m=Ht();if(!Ee||!m)return[];const g=Ne[Ee];if(!g||g.kind!=="matched"||g.nodes.length===0)return[];const{w:N,h:T}=m,z=g.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return g.nodes.filter(R=>R.rect&&R.rect.width>0&&R.rect.height>0).map((R,X)=>e.jsx("div",{className:z,style:{left:`${R.rect.x/N*100}%`,top:`${R.rect.y/T*100}%`,width:`${R.rect.width/N*100}%`,height:`${R.rect.height/T*100}%`}},`match-${Ee}-${X}`))},gt=(m,g)=>{const N=Ht();if(!(m!=null&&m.rect)||!N)return null;const{w:T,h:z}=N;return e.jsx("div",{className:`omni-frame-${g}`,style:{left:`${m.rect.x/T*100}%`,top:`${m.rect.y/z*100}%`,width:`${m.rect.width/T*100}%`,height:`${m.rect.height/z*100}%`}})},Wt=i!=null&&i.hierarchy?ae(i.hierarchy):0,bt=f&&(i!=null&&i.hierarchy)?eo(f,i):null,Le=bt?to(bt):null,qt=no(Q,Math.max(l,oe)),Kt=i!=null&&i.hierarchy&&P==="inspect"?e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]}):null,Vn={stable:{icon:e.jsx(Nt,{size:10}),cls:"stable"},moderate:{icon:e.jsx($e,{size:10}),cls:"moderate"},fragile:{icon:e.jsx(Ze,{size:10}),cls:"fragile"},"very-fragile":{icon:e.jsx(Ze,{size:10}),cls:"very-fragile"}},Ns=a&&(i!=null&&i.hierarchy)?Xe(i.hierarchy):[];return e.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&o&&Kt?_s.createPortal(Kt,o):null,e.jsxs("div",{className:"omni-main-content",children:[!a&&e.jsxs("div",{className:"omni-screenshot-panel",children:[e.jsxs("div",{className:"omni-screenshot-header",children:[e.jsxs("div",{className:"omni-header-left",children:[e.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),e.jsxs("div",{className:"omni-mode-toggle",children:[e.jsxs("button",{className:`omni-mode-btn ${P==="inspect"?"active":""}`,onClick:()=>K("inspect"),title:"Inspection mode (highlight elements)",children:[e.jsx(Ls,{size:12}),e.jsx("span",{children:"Inspect"})]}),e.jsxs("button",{className:`omni-mode-btn ${P==="interact"?"active":""}`,onClick:()=>K("interact"),title:"Interaction mode (direct control)",children:[e.jsx(Us,{size:12}),e.jsx("span",{children:"Interact"})]})]})]}),e.jsxs("button",{className:"omni-refresh-btn",onClick:De,disabled:u,children:[e.jsx(lt,{size:12,className:u?"animate-spin":""}),u?"Capturing...":"Refresh"]})]}),e.jsxs("div",{className:"omni-screenshot-container",ref:We,children:[u&&!F&&e.jsxs("div",{className:"omni-loading-overlay",children:[e.jsx("div",{className:"omni-spinner"}),e.jsx("span",{children:"Capturing screen..."})]}),!i&&!u&&!F&&e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:40}),e.jsx("span",{children:"Click Refresh to capture"})]}),F&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:pt,src:n,onLoad:I,onError:Bt,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),Kt]}),!F&&(i==null?void 0:i.screenshot)&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:Lt,src:`data:image/png;base64,${i.screenshot}`,onLoad:Ut,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1}),P==="inspect"&&e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]})]})]})]}),e.jsxs("div",{className:"omni-split",ref:qe,children:[e.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${at*100}% - ${at*It}px)`},children:[e.jsxs("div",{className:"omni-tree-header",children:[e.jsxs("div",{className:"omni-tree-title",children:[e.jsx(dn,{size:14}),e.jsx("span",{children:"Source"})]}),e.jsxs("div",{className:"omni-tree-actions",children:[e.jsx("button",{onClick:ie,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:e.jsx(Pa,{size:12})}),e.jsx("button",{onClick:xe,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:e.jsx(La,{size:12})}),a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(P==="inspect"?"interact":"inspect"),className:`omni-action-btn ${P==="inspect"?"active":""}`,title:P==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":P==="inspect"?"Inspect mode":"Interact mode","aria-pressed":P==="inspect",children:P==="inspect"?e.jsx(Ls,{size:12}):e.jsx(Us,{size:12})}),e.jsx("button",{onClick:De,className:"omni-action-btn",title:u?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:u,children:e.jsx(lt,{size:12,className:u?"animate-spin":""})})]})]})]}),x&&!u&&e.jsxs("div",{className:"omni-tree-error",role:"alert",children:[e.jsx(Ze,{size:12}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",onClick:De,className:"omni-tree-error-retry",children:"Retry"})]}),i&&!u&&!x&&(qt?e.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[e.jsx($e,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"The screen may have changed since this capture."}),e.jsx("button",{type:"button",onClick:De,className:"omni-capture-refresh",children:"Refresh"})]}):e.jsxs("div",{className:"omni-capture-meta",children:[e.jsxs("span",{children:[Wt," ",Wt===1?"element":"elements"]}),i.hierarchySource&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"omni-capture-source",title:i.hierarchySource==="appium-session"?`From Appium session ${i.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:i.hierarchySource==="appium-session"?"Session":"Device"})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:so(Q,ce)})]})),e.jsxs("div",{className:"omni-tree-search",children:[e.jsx(ms,{size:14}),e.jsx("input",{type:"text",placeholder:"Search elements",value:D,onChange:m=>gs(m.target.value),"aria-label":"Search elements"}),D&&e.jsx("button",{onClick:()=>gs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),e.jsx("div",{role:"status",className:"sr-only",children:D.trim()?rt:""}),D.trim()&&e.jsxs("div",{className:"omni-search-hint",children:[rt," · try a role: button, input, image"]}),e.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?e.jsx(ho,{rows:Ge,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:ze,onToggle:ye,onSelect:Ye,onHover:j,revealSeq:S}):e.jsx("div",{className:"omni-empty-state small",children:e.jsx("span",{children:"No hierarchy loaded"})})})]}),e.jsx(jo,{share:at,limits:_n(yt),containerRef:qe,onChange:ft,onCommit:xt,onReset:()=>xt(Dt)}),e.jsxs("div",{className:"omni-details-panel",children:[e.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[e.jsxs("button",{className:`omni-details-tab ${V==="info"?"active":""}`,onClick:()=>q("info"),role:"tab","aria-selected":V==="info",children:[e.jsx(ai,{size:12})," ",e.jsx("span",{children:"Info"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="checks"?"active":""}`,onClick:()=>q("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":V==="checks",children:[e.jsx(fa,{size:12})," ",e.jsx("span",{children:"Checks"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="code"?"active":""}`,onClick:()=>q("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":V==="code",children:[e.jsx(Fs,{size:12})," ",e.jsx("span",{children:"Code gen"})]})]}),e.jsx("div",{className:"omni-details-content",children:f?e.jsxs(e.Fragment,{children:[V==="info"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Element info"}),e.jsxs("div",{className:"omni-info-table",children:[e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Type"}),e.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Text"}),e.jsx("span",{className:"omni-info-value",children:f.text})]}),e.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[e.jsx("span",{className:"omni-info-key",children:"Path"}),e.jsx(po,{path:(i==null?void 0:i.hierarchy)&&Rt(i.hierarchy,f.xpath)||[f],onSelect:Vt,focusCurrent:L.current},f.xpath)]})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Layout"}),e.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(m=>e.jsxs("div",{className:"omni-layout-item",children:[e.jsx("span",{className:"omni-layout-label",children:m.toUpperCase()}),e.jsx("span",{className:"omni-layout-value",children:f.rect[m]})]},m))})]}),e.jsxs("div",{className:"omni-section",children:[e.jsxs("div",{className:"omni-section-header",children:["Locators",e.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(Z!=null&&Z.sessionId)&&((Ss=f.suggestedLocators)==null?void 0:Ss.length)>0&&e.jsxs("p",{className:"omni-locators-note",children:[e.jsx(nn,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),e.jsxs("div",{className:"omni-locators-list",children:[!((Cs=f.suggestedLocators)!=null&&Cs.length)&&e.jsx("div",{className:"omni-locators-empty",children:f===(i==null?void 0:i.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),($s=f.suggestedLocators)==null?void 0:$s.map(m=>{const g=ls(m.strategy,m.value),N=Vn[g.level],T=Ne[m.strategy];let z=null;return T&&(T.kind==="unsupported"?z=e.jsxs("span",{className:"omni-match-badge unsupported",title:T.reason||"Cannot evaluate without a real driver",children:[e.jsx(Ua,{size:10})," preview unavailable"]}):T.nodes.length===0?z=e.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[e.jsx(Ze,{size:10})," 0 matches"]}):T.nodes.length===1?z=e.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[e.jsx(Nt,{size:10})," unique"]}):z=e.jsxs("span",{className:"omni-match-badge multi",title:`${T.nodes.length} elements match — selector is not unique`,children:[e.jsx($e,{size:10})," ",T.nodes.length," matches"]})),e.jsx("div",{className:`omni-locator-row ${(de==null?void 0:de.strategy)===m.strategy?"selected-for-code":""}`,onClick:()=>fe(m),title:"Click to use in Code gen",children:e.jsxs("div",{className:"omni-locator-left",children:[e.jsxs("div",{className:"omni-locator-top",children:[e.jsx("span",{className:"omni-locator-strategy",children:m.strategy}),e.jsxs("span",{className:`omni-stability-badge ${N.cls}`,title:g.reason,children:[N.icon,g.level]}),z]}),e.jsx("code",{className:"omni-locator-value",children:m.value}),e.jsx("span",{className:"omni-stability-reason",children:g.reason}),(()=>{const R=zt[m.strategy];return R?R.error?e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium error: ",R.error]}):R.found?R.count>1?e.jsxs("span",{className:"omni-verify-line is-warn",children:[e.jsx($e,{size:10})," Ambiguous — Appium found"," ",R.count," elements",R.actionError?` · ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-ok",children:[e.jsx(Nt,{size:10})," Appium found 1 element",R.elapsedMs!=null?` in ${R.elapsedMs}ms`:"",R.actionPerformed&&R.actionPerformed!=="none"?` · ${R.actionPerformed} ok`:"",R.actionError?` · action failed: ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium found 0 elements"]}):null})(),e.jsxs("div",{className:"omni-locator-actions",children:[e.jsxs(Y,{type:"button",variant:Ee===m.strategy?"tonal":"secondary",size:"sm",onClick:R=>{R.stopPropagation(),Ft(m.strategy,m.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[e.jsx(Ha,{size:12,"aria-hidden":"true"}),"Test"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===m.strategy,onClick:R=>{R.stopPropagation(),vt(m.strategy,m.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[He===m.strategy?e.jsx(lt,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(Nt,{size:12,"aria-hidden":"true"}),"Verify"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===m.strategy,onClick:R=>{R.stopPropagation(),vt(m.strategy,m.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[e.jsx(un,{size:12,"aria-hidden":"true"}),"Tap"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",onClick:R=>{R.stopPropagation(),ne(m.value,m.strategy)},title:"Copy the locator's value","aria-label":O===m.strategy?"Copied":"Copy locator",children:[O===m.strategy?e.jsx(dt,{size:12,"aria-hidden":"true"}):e.jsx(Te,{size:12,"aria-hidden":"true"}),O===m.strategy?"Copied":"Copy"]})]})]})},m.strategy)})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Attributes"}),e.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([m,g])=>g!=null&&g!=="").map(([m,g])=>e.jsxs("div",{className:"omni-attr-row",children:[e.jsx("span",{className:"omni-attr-key",children:m}),e.jsx("span",{className:"omni-attr-value",children:String(g)})]},m))})]})]}),V==="checks"&&bt&&Le&&e.jsxs("div",{className:"omni-checks-panel",children:[e.jsxs("p",{className:"omni-checks-summary",children:[e.jsxs("span",{className:"is-pass",children:[e.jsx(mn,{size:12,"aria-hidden":"true"})," ",Le.pass," passed"]}),Le.warn>0&&e.jsxs("span",{className:"is-warn",children:[e.jsx($e,{size:12,"aria-hidden":"true"})," ",Le.warn," ",Le.warn===1?"warning":"warnings"]}),Le.fail>0&&e.jsxs("span",{className:"is-fail",children:[e.jsx(hn,{size:12,"aria-hidden":"true"})," ",Le.fail," failed"]})]}),e.jsx("ul",{className:"omni-checks-list",children:bt.map(m=>e.jsxs("li",{className:`omni-check is-${m.status}`,children:[e.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:No[m.status]}),e.jsxs("div",{className:"omni-check-body",children:[e.jsxs("div",{className:"omni-check-label",children:[m.label,e.jsxs("span",{className:"sr-only",children:[": ",ko[m.status]]})]}),e.jsx("div",{className:"omni-check-detail",children:m.detail})]})]},m.id))})]}),V==="code"&&e.jsxs("div",{className:"omni-codegen-panel",children:[e.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(m=>e.jsx("button",{className:`omni-fw-btn ${le===m?"active":""}`,onClick:()=>ue(m),children:wo[m]},m))}),de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-codegen-locator-selector",children:[e.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),e.jsx(hs,{selectSize:"sm",value:de.strategy,onChange:m=>{var N;const g=(N=f.suggestedLocators)==null?void 0:N.find(T=>T.strategy===m.target.value);g&&fe(g)},className:"flex-1",children:(Ts=f.suggestedLocators)==null?void 0:Ts.map(m=>e.jsxs("option",{value:m.strategy,children:[m.strategy," — ",ls(m.strategy,m.value).level]},m.strategy))})]}),e.jsxs("div",{className:"omni-codegen-output",children:[e.jsxs("div",{className:"omni-codegen-header",children:[e.jsx("span",{className:"omni-codegen-lang",children:le==="java"?"Java / TestNG":le==="python"?"Python / unittest":le==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),e.jsx("button",{className:"omni-copy-btn",onClick:()=>ne(Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de),"code"),children:O==="code"?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]}),e.jsx("pre",{className:"omni-codegen-pre theme-dark",children:e.jsx("code",{children:Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de)})})]})]}):e.jsxs("div",{className:"omni-empty-state small",children:[e.jsx(Fs,{size:24}),e.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?e.jsxs("div",{className:"omni-summary-panel",children:[e.jsxs("div",{className:"omni-summary-hero",children:[e.jsx(Zt,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"omni-summary-title",children:"No element selected"}),e.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),e.jsxs("div",{className:"omni-summary-stats",children:[e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),e.jsx("span",{className:"omni-summary-stat__value",children:Wt})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ks=i.metadata)==null?void 0:ks.screenWidth)??ee.width??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ws=i.metadata)==null?void 0:ws.screenHeight)??ee.height??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),e.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),Ns.length>0&&e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"By role"}),e.jsx("div",{className:"omni-summary-roles",children:Ns.slice(0,8).map(m=>e.jsxs("div",{className:"omni-summary-role",children:[e.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:Rn[m.key]}),e.jsx("span",{className:"omni-summary-role__name",children:m.role}),e.jsx("span",{className:"omni-summary-role__count",children:m.count})]},m.role))})]})]}):e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:32}),e.jsx("span",{children:u?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Gs=5e3;function Co(t,s=!0){const[n,a]=c.useState("unknown"),o=c.useRef("unknown");return c.useEffect(()=>{if(!t||!s){a("unknown"),o.current="unknown";return}let r=!1,l;const u=h=>{r||h===o.current||(o.current=h,a(h))},d=async()=>{if(!r){if(l&&(clearTimeout(l),l=void 0),typeof document<"u"&&document.visibilityState==="hidden"){l=setTimeout(d,Gs);return}try{const h=await M.getDisplayState(t);u((h==null?void 0:h.state)??"unknown")}catch{}r||(l=setTimeout(d,Gs))}};d();const i=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",i),()=>{r=!0,l&&clearTimeout(l),document.removeEventListener("visibilitychange",i)}},[t,s]),n}function $o(t,s){const n=c.useRef(t),a=c.useRef(s);n.current=t,a.current=s,c.useEffect(()=>{const o=()=>n.current(),r=l=>{var u;l.persisted&&((u=a.current)==null||u.call(a))};return window.addEventListener("pagehide",o),window.addEventListener("pageshow",r),()=>{window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",r)}},[])}const Ys=5e3,To=500,Ro=1e4,Ao=10,Eo=50;function Do(t,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[o,r]=c.useState([]),[l,u]=c.useState(!1),[d,i]=c.useState(null),[h,x]=c.useState(!1),k=c.useRef(null),f=c.useRef(0),y=c.useRef(void 0),S=c.useRef(()=>{}),C=c.useRef([]),L=c.useRef(void 0),w=c.useRef(0),j=c.useRef(void 0),$=c.useCallback(()=>{if(C.current.length===0)return;const O=C.current;C.current=[],r(W=>{const V=W.concat(O);return V.length>Ys?V.slice(-Ys):V})},[]),p=c.useCallback(()=>{L.current===void 0&&(L.current=window.setTimeout(()=>{L.current=void 0,$()},Eo))},[$]),D=c.useCallback(()=>{C.current=[],r([])},[]);c.useEffect(()=>{if(!s){u(!1),i(null),x(!1);return}i(null),x(!1),f.current=0;const O={cancelled:!1},W=()=>{if(O.cancelled)return;if(f.current>=Ao){x(!0);return}const q=Math.min(To*2**f.current,Ro);f.current+=1,y.current=window.setTimeout(V,q)},V=async()=>{if(!O.cancelled)try{const q=await fetch(`/xenon/api/control/${encodeURIComponent(t)}/stream/ticket`,{method:"POST",credentials:"include"});if(O.cancelled)return;if(!q.ok){W();return}const{ticket:Q}=await q.json();if(O.cancelled)return;if(!Q){W();return}const b=window.location.protocol==="https:"?"wss":"ws",[oe,te]=a.split("|"),ce=(oe?`&levels=${encodeURIComponent(oe)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),B=new WebSocket(`${b}://${window.location.host}/xenon/api/control/${encodeURIComponent(t)}/logcat?ticket=${encodeURIComponent(Q)}${ce}`);k.current=B,B.onopen=()=>{f.current=0,j.current!==1012&&(C.current=[],r([])),j.current=void 0,u(!0)},B.onmessage=E=>{try{const J=JSON.parse(E.data);C.current.push({...J,seq:w.current++}),p()}catch{}},B.onclose=E=>{if(u(!1),j.current=E.code,$(),E.code===1008){O.cancelled=!0,i(E.reason||"access denied");return}if(E.code===1012){W();return}console.warn(`[logcat] WS closed unexpectedly (code ${E.code}) — retrying`),W()},B.onerror=()=>B.close()}catch{W()}};return S.current=()=>{O.cancelled=!1,f.current=0,i(null),x(!1),V()},V(),()=>{var q;O.cancelled=!0,y.current!==void 0&&window.clearTimeout(y.current),L.current!==void 0&&(window.clearTimeout(L.current),L.current=void 0),$(),(q=k.current)==null||q.close(),k.current=null}},[t,s,a,$,p]);const A=c.useCallback(()=>{S.current()},[]);return{records:o,connected:l,clear:D,deniedReason:d,exhausted:h,retry:A}}const ds=["V","D","I","W","E","F"];function Io(t){const s=[];let n="",a=!1,o=!1;for(const r of t){if(r==='"'){a=!a,o=!0;continue}if(!a&&/\s/.test(r)){(o||n)&&s.push(n),n="",o=!1;continue}n+=r,o=!0}return(o||n)&&s.push(n),s.filter(r=>r.length>0)}function zn(t,s={}){const n=s.caseSensitive===!0,a=l=>n?l:l.toLowerCase(),o=n?{caseSensitive:!0}:{},r=[];for(const l of Io(t)){const[u,...d]=l.split(":"),i=d.join(":");i&&u.toLowerCase()==="level"?o.minLevel=i.toUpperCase():i&&u.toLowerCase()==="tag"?o.tag=a(i):i&&u.toLowerCase()==="package"?o.pkg=a(i):r.push(l)}return r.length&&(o.text=a(r.join(" "))),o}function Mo(t,s){if(t.synthetic)return!0;if(s.minLevel){const a=ds.indexOf(s.minLevel),o=ds.indexOf(t.level);if(a>=0&&o>=0&&o<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();return!(s.tag&&!n(t.tag).includes(s.tag)||s.pkg&&!n(t.pkg??"").includes(s.pkg)||s.text&&!n(t.message).includes(s.text))}function _o(t,s){const n=t.trim().split(/\s+/).filter(Boolean).filter(a=>{const[o,...r]=a.split(":");return!(r.join(":")&&o.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const ss=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],Zs=["V","D","I","W","E","F"];function zo(t){if(!t)return ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=Zs.indexOf(t.toUpperCase());return s<0?ss.map(n=>n.ios):ss.filter(n=>Zs.indexOf(n.android)>=s).map(n=>n.ios)}function Lo(t){const s=zn(t,{caseSensitive:!0});return{levels:zo(s.minLevel),process:s.pkg||void 0}}const Js=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Oo(t){let s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Po(t){return t?Js[Oo(t)%Js.length]:"var(--text-muted)"}const us=5e5;function Ln(t){return`${new Date(t.ts).toISOString()} ${t.pid} ${t.level}/${t.tag}: ${t.message}`}function Fo(t){return{lines:[],startedAt:t,dropped:0}}function Uo(t,s){for(const n of s){if(t.lines.length>=us){t.dropped+=1;continue}t.lines.push(Ln(n))}return t}function Bo(t,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(t.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-t.startedAt)/1e3).toFixed(1)}s`,`# lines: ${t.lines.length}`];t.dropped>0&&a.push(`# TRUNCATED: ${t.dropped} further line(s) were dropped after the ${us}-line cap. This capture is INCOMPLETE.`);const o=t.lines.join(`
271
261
  `),r=t.dropped>0?`
272
262
  # --- TRUNCATED: ${t.dropped} line(s) not captured (cap ${us}) ---`:"";return`${a.join(`
273
263
  `)}
274
264
 
275
265
  ${o}${r}
276
- `}function Wo(t,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${t}-${n}.txt`}const Qs=ds.filter(t=>t!=="V").map(t=>({value:t,label:t==="F"?"F only":`${t} and above`})),qo=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function en(t,s){const n=URL.createObjectURL(new Blob([t],{type:"text/plain"})),a=document.createElement("a");a.href=n,a.download=s,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(n),0)}const Ko=c.memo(function({record:s,index:n,isHit:a,isActiveHit:o}){return e.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${a?"is-hit":""} ${o?"is-active-hit":""}`,children:[e.jsx("span",{className:"logcat-time",children:qo.format(s.ts)}),e.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),e.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:Uo(s.tag)},children:s.tag}),e.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),e.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),e.jsx("span",{className:"logcat-msg",children:s.message})]})});function Xo({udid:t,platform:s}){const n=(s||"").toLowerCase(),a=n==="ios",o=n==="android"||a,[r,l]=c.useState(""),u=c.useMemo(()=>a?Po(r):void 0,[a,r]),{records:d,connected:i,clear:m,deniedReason:x,exhausted:k,retry:f}=Mo(t,o,u),[y,S]=c.useState(!0),[C,L]=c.useState(!1),[w,j]=c.useState(!0),[$,p]=c.useState(""),[D,A]=c.useState(0),O=c.useRef(null),W=c.useRef(null),V=c.useRef(null),[q,Q]=c.useState(!1),[b,oe]=c.useState(0),te=c.useRef(-1),ce=c.useMemo(()=>zn(r,{caseSensitive:C}),[r,C]),B=c.useMemo(()=>d.filter(_=>zo(_,ce)),[d,ce]),E=c.useMemo(()=>{if(!$)return[];const _=C?$:$.toLowerCase(),v=[];return B.forEach((H,F)=>{(C?`${H.tag} ${H.message}`:`${H.tag} ${H.message}`.toLowerCase()).includes(_)&&v.push(F)}),v},[B,$,C]),J=E.length?Math.min(D,E.length-1):0,le=c.useMemo(()=>new Set(E),[E]),ue=c.useCallback(_=>{var H,F;if(!E.length)return;const v=(J+_+E.length)%E.length;A(v),S(!1),(F=(H=W.current)==null?void 0:H.querySelector(`[data-row-index="${E[v]}"]`))==null||F.scrollIntoView({block:"center"})},[E,J]),de=Qs.some(_=>_.value===ce.minLevel)?ce.minLevel:"",fe=c.useCallback(()=>{en(B.map(Ln).join(`
277
- `),`logcat-${t}-${Date.now()}.txt`)},[B,t]);c.useEffect(()=>{const _=V.current;if(!_||!d.length)return;const v=d.filter(F=>F.seq>te.current);if(!v.length)return;const H=te.current+1;te.current>=0&&v[0].seq>H&&(_.dropped+=v[0].seq-H),Vo(_,v),te.current=v[v.length-1].seq,oe(_.lines.length)},[d]);const ee=c.useCallback(()=>{const _=V.current;if(!_){te.current=d.length?d[d.length-1].seq:-1,V.current=Bo(Date.now()),oe(0),Q(!0);return}const v=Ho(_,Date.now(),t);V.current=null,Q(!1),oe(0),en(v,Wo(t,_.startedAt))},[d,t]);if(c.useEffect(()=>{var _;y&&((_=O.current)==null||_.scrollIntoView({block:"end"}))},[B.length,y]),!o)return e.jsxs("div",{className:"log-empty-state",children:[e.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),e.jsx("p",{className:"log-empty-subtitle",children:"Streaming is wired up for Android (logcat) and iOS (os_trace), not for this device's platform."})]});const ge=x?"Denied":k?"Offline":i?"Live":"Connecting",be=!i&&(!!x||k);return e.jsxs("div",{className:"logcat-root",children:[e.jsxs("div",{className:"log-toolbar",children:[e.jsxs("div",{className:"log-filter-group",children:[e.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[e.jsx("span",{className:`log-live-dot ${i?"active":""} ${be?"is-error":""}`}),ge]}),e.jsxs("div",{className:"log-stat-pill logcat-count",children:[B.length," / ",d.length]}),e.jsxs(ms,{selectSize:"sm",value:de,onChange:_=>l(Lo(r,_.target.value)),"aria-label":"Minimum log level",children:[e.jsx("option",{value:"",children:"All levels"}),Qs.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:r,onChange:_=>l(_.target.value),"aria-label":"Filter logs"}),r&&e.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>l(""),"aria-label":"Clear filter",title:"Clear filter",children:e.jsx(sn,{size:12})})]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:$,onChange:_=>{p(_.target.value),A(0)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),ue(_.shiftKey?-1:1))},"aria-label":"Find in logs"}),$&&e.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:E.length?`${J+1}/${E.length}`:"0/0"})]}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(-1),disabled:!E.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:e.jsx(ys,{size:14})}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(1),disabled:!E.length,"aria-label":"Next match",title:"Next match (Enter)",children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>L(!C),"aria-pressed":C,"aria-label":"Match case",title:"Match case",children:e.jsx(Ia,{size:15})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${w?"active":""}`,onClick:()=>j(!w),"aria-pressed":w,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:e.jsx(Ai,{size:14})})]}),e.jsxs("div",{className:"log-actions-group",children:[(x||k)&&e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:f,children:[e.jsx(lt,{size:14})," RECONNECT"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${y?"active":""}`,onClick:()=>S(!y),children:[e.jsx(Vi,{size:14})," ",y?"FREEZE":"FOLLOW"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${q?"is-recording":""}`,onClick:ee,"aria-pressed":q,title:q?"Stop recording and download the capture":"Record the raw log stream to a file",children:[q?e.jsx(rn,{size:12}):e.jsx(sa,{size:12})," ",q?`STOP · ${b.toLocaleString()}`:"RECORD"]}),e.jsxs("button",{className:"btn-premium btn-sm",disabled:B.length===0,onClick:fe,children:[e.jsx(pa,{size:14})," EXPORT"]}),e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:m,children:[e.jsx(as,{size:14})," CLEAR"]})]})]}),e.jsxs("div",{className:`logcat-rows theme-dark ${w?"":"no-wrap"}`,ref:W,children:[x&&e.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[e.jsx($e,{size:14}),e.jsxs("span",{children:["Access denied — ",x]})]}),!x&&k&&e.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[e.jsx($e,{size:14}),e.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),B.map((_,v)=>e.jsx(Ko,{record:_,index:v,isHit:le.has(v),isActiveHit:E.length>0&&E[J]===v},_.seq)),e.jsx("div",{ref:O})]})]})}function On(t){const s=t==null?void 0:t.message;return typeof s=="string"?s.trim():""}function Be(t,s){const n=On(s);return n?`Couldn’t ${t}: ${n}`:`Couldn’t ${t}.`}function Go(t,s){return t==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Be("read the clipboard",s)}function Yo(t,s){const n=s.trim().toLowerCase();return[...t].sort((a,o)=>a.localeCompare(o)).filter(a=>!n||a.toLowerCase().includes(n))}const Zo=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Jo(t){return Zo.test(t.trim())}function vs(t){const s=(t||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Qo(t,s){const n=vs(s);return n?t.filter(a=>(a.platform||"").toLowerCase()===n):[]}function ec(t){return[t.version,t.packageName].filter(Boolean).join(" · ")}function tc(t){return vs(t)==="android"?"Android":"iOS"}function sc(t){return vs(t)==="android"?".apk":".ipa,.app"}const Pn="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Fn(t){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(t),!0):!1}catch{return!1}}function nc({udid:t,platform:s,deviceName:n}){const{toast:a,removeToast:o}=Ve(),r=mt(),[l,u]=c.useState([]),[d,i]=c.useState("loading"),[m,x]=c.useState(""),[k,f]=c.useState(""),[y,S]=c.useState(!1),[C,L]=c.useState(!1),[w,j]=c.useState([]),[$,p]=c.useState("loading"),[D,A]=c.useState(null),[O,W]=c.useState(null),V=c.useRef(null),q=c.useRef(null),Q=c.useRef(null),b=c.useCallback(async()=>{i("loading");try{const v=await M.listApps(t);u(Array.isArray(v)?v:[]),i("ready")}catch(v){x(On(v)),i("error")}},[t]);c.useEffect(()=>{b()},[b]);const oe=v=>setTimeout(b,v);c.useEffect(()=>{if(!O)return;const v=setTimeout(()=>W(null),1500);return()=>clearTimeout(v)},[O]);const te=async()=>{p("loading");try{const v=await M.getApps();j(Array.isArray(v)?v:[]),p("ready")}catch{p("error")}},ce=()=>{y||(L(!0),te())},B=()=>{var v;L(!1),(v=V.current)==null||v.focus()};c.useEffect(()=>{var H;if(!C||$==="loading")return;const v=(H=q.current)==null?void 0:H.querySelector('[role="menuitem"]:not(:disabled)');v==null||v.focus()},[C,$]);const E=async(v,H)=>{S(!0);const F=a(`Installing ${v} on ${n}…`,"loading",0);try{const K=await H();K!=null&&K.success?(a(`Installed ${v} on ${n}`,"success"),oe(5e3)):a(Be(`install ${v}`,{message:K==null?void 0:K.error}),"error")}catch(K){a(Be(`install ${v}`,K),"error")}finally{o(F),S(!1)}},J=v=>{B(),E(v.name,()=>M.installRepositoryApp(t,v.id))},le=v=>{var F;const H=(F=v.target.files)==null?void 0:F[0];v.target.value="",H&&E(H.name,()=>M.uploadAndInstallApp(t,H))},ue=async()=>{const v=D;if(A(null),!v)return;const H=a(`Uninstalling ${v} from ${n}…`,"loading",0);try{await M.uninstallApp(t,v),a(`Uninstalled ${v} from ${n}`,"success"),oe(3e3)}catch(F){a(Be(`uninstall ${v}`,F),"error")}finally{o(H)}},de=async(v,H)=>{var K,Ne;if(await Fn(v)){W(v);return}const F=(K=H.closest("li"))==null?void 0:K.querySelector(".actions-app-id");F&&((Ne=window.getSelection())==null||Ne.selectAllChildren(F)),a(Pn,"info")},fe=Yo(l,k),ee=k.trim(),ge=d==="ready"&&fe.length===0&&Jo(ee)&&!l.includes(ee),be=Qo(w,s),_=(v,H)=>e.jsxs("li",{className:"actions-app-row",children:[e.jsx("span",{className:"actions-app-id",children:v}),H&&e.jsx("span",{className:"actions-app-note",children:H}),e.jsxs("span",{className:"actions-app-tools",children:[e.jsx(Y,{variant:"ghost",size:"icon","aria-label":O===v?"Copied":`Copy ${v}`,title:O===v?"Copied":"Copy package ID",onClick:F=>de(v,F.currentTarget),children:O===v?e.jsx(dt,{size:13,"aria-hidden":"true"}):e.jsx(Te,{size:13,"aria-hidden":"true"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${v}`,onClick:()=>A(v),children:"Uninstall"})]})]},v);return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[e.jsxs("div",{className:"actions-section-head",children:[e.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[e.jsx(hi,{size:15,"aria-hidden":"true"})," Apps"]}),e.jsxs("div",{className:"actions-section-tools",children:[e.jsxs(Y,{ref:V,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":y||void 0,onClick:ce,children:[y?e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):e.jsx(Ja,{size:13,"aria-hidden":"true"}),"Install from library"]}),e.jsxs(Y,{variant:"secondary",size:"sm","aria-disabled":y||void 0,onClick:()=>{var v;return!y&&((v=Q.current)==null?void 0:v.click())},children:[e.jsx(fa,{size:13,"aria-hidden":"true"})," Upload file"]}),e.jsx("input",{ref:Q,type:"file",hidden:!0,"aria-label":"App file to upload",accept:sc(s),onChange:le})]})]}),e.jsx(on,{open:C,onClose:B,anchorRef:V,placement:"bottom-end",children:e.jsx("div",{ref:q,className:"actions-library-menu",children:e.jsxs(cn,{children:[$==="loading"&&e.jsx(pe,{disabled:!0,onClick:()=>{},children:"Loading…"}),$==="error"&&e.jsx(pe,{onClick:te,children:"Couldn’t load the library. Retry"}),$==="ready"&&be.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs(pe,{disabled:!0,onClick:()=>{},children:["No ",tc(s)," apps in the library yet"]}),e.jsx(pe,{onClick:()=>r("/apps"),children:"Open the Apps library"})]}),$==="ready"&&be.map(v=>e.jsx(pe,{note:ec(v)||void 0,onClick:()=>J(v),children:v.name},v.id))]})})}),e.jsxs("div",{className:"actions-apps-tools",children:[e.jsxs("div",{className:"actions-search",children:[e.jsx(hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${l.length} installed apps`,value:k,onChange:v=>f(v.target.value)})]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:b,children:e.jsx(St,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&e.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",m?`: ${m}`:".",e.jsx(Y,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),d==="ready"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&l.length>0&&fe.length===0&&!ge&&e.jsxs("p",{className:"actions-list-note",children:["No apps match “",ee,"”"]}),e.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[fe.map(v=>_(v)),ge&&_(ee,"Not in the list")]}),e.jsx(ps,{open:D!==null,title:"Uninstall app?",onClose:()=>A(null),footer:e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",onClick:()=>A(null),children:"Cancel"}),e.jsx(Y,{variant:"danger",onClick:ue,children:"Uninstall"})]}),children:e.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",e.jsx("code",{children:D})," from"," ",e.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const ac=[{direction:"up",Icon:ys},{direction:"down",Icon:fs},{direction:"left",Icon:xa},{direction:"right",Icon:va}];function ic({onSwipe:t}){return e.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[e.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[e.jsx(qa,{size:15,"aria-hidden":"true"})," Swipe"]}),e.jsx("div",{className:"actions-swipe-buttons",children:ac.map(({direction:s,Icon:n})=>e.jsx(Y,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>t(s),children:e.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function rc(t,s,n){const a=s/2,o=n/2,r=s*.4,l=n*.4,[u,d,i,m]={up:[a,o+l,a,o-l],down:[a,o-l,a,o+l],left:[a+r,o,a-r,o],right:[a-r,o,a+r,o]}[t].map(Math.round);return{startX:u,startY:d,endX:i,endY:m}}function oc({udid:t,platform:s}){const n=s!=="android",{toast:a}=Ve(),[o,r]=c.useState(""),[l,u]=c.useState(!1),[d,i]=c.useState(""),[m,x]=c.useState(null),[k,f]=c.useState(""),[y,S]=c.useState(!1),C=c.useRef(null);c.useEffect(()=>{if(!k)return;const p=setTimeout(()=>f(""),2e3);return()=>clearTimeout(p)},[k]),c.useEffect(()=>{if(!y)return;const p=setTimeout(()=>S(!1),1500);return()=>clearTimeout(p)},[y]);const L=async()=>{if(!(!o.trim()||l)){u(!0);try{await M.typeText(t,o),r(""),f("Sent")}catch(p){a(Be("send the text",p),"error")}finally{u(!1)}}},w=async()=>{x("read");try{const p=await M.getClipboard(t),D=typeof(p==null?void 0:p.content)=="string"?p.content:"";i(D),D||f("The device clipboard is empty")}catch(p){a(Go(s,p),"error")}finally{x(null)}},j=async()=>{if(d){x("write");try{await M.setClipboard(t,d),f("Written to the device")}catch(p){a(Be("write the clipboard",p),"error")}finally{x(null)}}},$=async()=>{var p;if(await Fn(d)){S(!0);return}(p=C.current)==null||p.select(),a(Pn,"info")};return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[e.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[e.jsx(Ya,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),e.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:o,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&L()}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:L,disabled:!o.trim()||l,children:[l&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),e.jsx("input",{id:"actions-clipboard",ref:C,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:d,onChange:p=>i(p.target.value)}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:w,disabled:m!==null,children:[m==="read"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&e.jsxs(Y,{variant:"secondary",size:"md",onClick:j,disabled:!d||m!==null,children:[m==="write"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":y?"Copied":"Copy clipboard text",title:y?"Copied":"Copy to your clipboard",onClick:$,disabled:!d,children:y?e.jsx(dt,{size:14,"aria-hidden":"true"}):e.jsx(Te,{size:14,"aria-hidden":"true"})})]}),!n&&e.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),e.jsx("p",{className:"actions-status",role:"status",children:k})]})}function cc({udid:t,platform:s,deviceName:n,screenWidth:a,screenHeight:o}){const{toast:r}=Ve(),l=async u=>{const d=rc(u,a,o);try{await M.swipe(t,d.startX,d.startY,d.endX,d.endY)}catch(i){r(Be(`swipe ${u}`,i),"error")}};return e.jsxs("div",{className:"actions-panel",children:[e.jsx(nc,{udid:t,platform:s,deviceName:n}),e.jsx(oc,{udid:t,platform:s}),e.jsx(ic,{onSwipe:l})]})}function lc({device:t,onClose:s,titleId:n}){const{toast:a}=Ve(),o=mt(),{tab:r}=an(),l=Mt(),u=c.useRef(null),[d,i]=c.useState({width:0,height:0}),[m,x]=c.useState("inspect"),[k,f]=c.useState(null),[y,S]=c.useState(r||"actions"),C=y==="omni"&&m==="inspect",[L,w]=c.useState(!0),[j,$]=c.useState([]),[p,D]=c.useState(null),[A,O]=c.useState(!1),[W,V]=c.useState(!1),[q,Q]=c.useState(0),[b,oe]=c.useState(t),[te,ce]=c.useState(0),B=c.useCallback(()=>ce(Date.now()),[]),E=Me(b);c.useEffect(()=>{Xn(b.udid,E),document.title=Gn(l.pathname)},[b.udid,E,l.pathname]);const[J,le]=c.useState(!1),[ue,de]=c.useState(!1),fe=10,[ee,ge]=c.useState(!1),[be,_]=c.useState(!1),v=To(b==null?void 0:b.udid,!ue),H=()=>{navigator.clipboard.writeText(b.udid).catch(()=>{}),ge(!0),setTimeout(()=>ge(!1),1500)},F=c.useRef(""),K=c.useRef(null),[Ne,tt]=c.useState(!1);c.useEffect(()=>{y&&(!r||r!==y)&&o(`/devices/${t.udid}/control/${y}${l.search}`,{replace:!0})},[y,r,t.udid,o,l.search]);const[zt,st]=c.useState(0);Ro(()=>{M.leaveStream(b.udid).catch(()=>{})},()=>st(I=>I+1)),c.useEffect(()=>((async()=>{try{V(!0),await M.startStream(b.udid);const G=(await M.getDevices()).find(se=>se.udid===b.udid);G&&oe(G)}catch(U){console.error("Auto-start stream failed:",U)}finally{V(!1)}})(),()=>{M.leaveStream(b.udid).catch(()=>{})}),[t.udid,zt]);const He=parseInt(b.screenWidth||"1080",10),nt=parseInt(b.screenHeight||"1920",10),Z=Math.min(He,nt),ke=Math.max(He,nt),Ee=Z/ke,_e=c.useCallback(()=>{const I=!L,U=I?window.innerHeight*.55:window.innerHeight*.7,G=620,ye=window.innerWidth>900;let ie;I?ie=ye?Math.min(window.innerWidth*.8,window.innerWidth-G):window.innerWidth*.8:ie=window.innerWidth*.45;const xe=L?Ee:1/Ee;let ne,ae;L?(ne=U,ae=ne*xe,ae>ie&&(ae=ie,ne=ae/xe)):(ae=ie,ne=ae/xe,ne>U&&(ne=U,ae=ne*xe)),i({width:ae,height:ne})},[Ee,L]);c.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),c.useEffect(()=>{const I=async()=>{if(F.current.length>0){const G=F.current;F.current="";try{await M.typeText(b.udid,G)}catch(se){console.error("Keyboard buffering flush failed:",se)}finally{B()}}},U=G=>{const se=document.activeElement;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||!Ne&&y!=="terminal")return;const ie=G.key;ie==="Enter"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?66:"enter").finally(B)):ie==="Backspace"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?67:"backspace").finally(B)):ie.length===1&&(F.current+=ie,K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{I()},50))};return window.addEventListener("keydown",U),()=>{window.removeEventListener("keydown",U),K.current&&clearTimeout(K.current)}},[b.udid,b.platform,Ne,y,B]);const[We,Lt]=c.useState(Date.now()),pt=()=>{const I=q>0?`r=${q}&`:"";return b.session_id&&!String(b.session_id).startsWith("manual_")?`/xenon/api/session/${b.session_id}/live_video?${I}t=${We}`:`/xenon/api/control/${b.udid}/stream?${I}t=${We}`};c.useEffect(()=>{q>0&&Lt(Date.now())},[q]),c.useEffect(()=>{if(J||ue)return;const I=setTimeout(()=>de(!0),3e4);return()=>clearTimeout(I)},[J,ue,q]);const we=c.useRef(null),qe=I=>{const U=I.currentTarget.getBoundingClientRect();return{x:I.clientX-U.left,y:I.clientY-U.top}},Ot=I=>{const U=qe(I);we.current={x:U.x,y:U.y,time:Date.now()}},ft=async I=>{var Ye;if(!we.current)return;const U=we.current,G=qe(I),se=Date.now()-U.time,ye=(Ye=u.current)==null?void 0:Ye.getBoundingClientRect(),ie=(ye==null?void 0:ye.width)||d.width,xe=(ye==null?void 0:ye.height)||d.height;let ne,ae,Xe,Ge;L?(ne=U.x/ie*Z,ae=U.y/xe*ke,Xe=G.x/ie*Z,Ge=G.y/xe*ke):(ne=U.x/ie*ke,ae=U.y/xe*Z,Xe=G.x/ie*ke,Ge=G.y/xe*Z);const ze=Math.abs(Xe-ne),rt=Math.abs(Ge-ae);try{se<500&&ze<10&&rt<10?await M.tap(b.udid,Math.round(ne),Math.round(ae)):se>=500&&ze<10&&rt<10?await M.touchAndHold(b.udid,Math.round(ne),Math.round(ae),se):await M.swipe(b.udid,Math.round(ne),Math.round(ae),Math.round(Xe),Math.round(Ge))}catch(Vt){console.error("Action failed:",Vt)}finally{B()}we.current=null},yt=()=>M.pressKey(b.udid,b.platform==="android"?ot.HOME:Yt.HOME).finally(B),Pt=()=>M.pressKey(b.udid,ot.BACK).finally(B),at=()=>M.pressKey(b.udid,ot.APP_SWITCH).finally(B),xt=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_UP:Yt.VOLUME_UP).finally(B),Ke=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_DOWN:Yt.VOLUME_DOWN).finally(B),vt=()=>M.lock(b.udid).finally(B),it=async()=>{_(!0);try{await M.unlock(b.udid)}finally{B(),setTimeout(()=>_(!1),2500)}},Ft=async()=>{O(!0);try{const I=await M.getScreenshot(b.udid);if(I!=null&&I.screenshot){const U={id:Fr(),base64:I.screenshot,timestamp:Date.now()};$(G=>[U,...G]),D(0)}}catch(I){console.error("Failed to take screenshot:",I)}finally{O(!1)}},De=I=>{$(U=>{const G=U.filter(se=>se.id!==I);return G.length===0?D(null):p!==null&&p>=G.length&&D(0),G})},Ut=()=>{$([]),D(null),a("Cleared all captured evidence.","success")},Bt=I=>{const U=document.createElement("a");U.href=`data:image/png;base64,${I}`,U.download=`screenshot-${b.udid}-${Date.now()}.png`,U.click()};return e.jsxs("div",{className:"device-control-view",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"control-view-top-bar",children:[e.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[e.jsx(Os,{size:18})," DEVICES"]}),e.jsxs("div",{className:"device-info-mini",children:[e.jsx("span",{className:`device-pill platform-pill ${b.platform}`,children:b.platform==="ios"?"Apple":"Android"}),e.jsxs("span",{className:"device-pill version-pill",children:["v",b.sdk]}),b.reservedUntil&&Date.now()<b.reservedUntil&&e.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${b.reservedBy}${b.reservationReason?`: ${b.reservationReason}`:""}`,children:["Reserved by ",b.reservedBy||"someone"]}),e.jsx("h2",{id:n,className:"device-name-text",children:E}),e.jsxs("span",{className:"udid-chip",title:b.udid,children:[e.jsx("span",{className:"udid-chip__value",children:b.udid}),e.jsx("button",{type:"button",className:"udid-chip__copy",onClick:H,"aria-label":"Copy UDID",title:ee?"Copied!":"Copy UDID",children:ee?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]})]})]}),e.jsxs("div",{className:`control-view-main ${L?"":"is-landscape"} ${y==="omni"?"omni-mode":""}`,children:[e.jsxs("div",{className:"device-preview-column",children:[e.jsx("div",{className:"device-screen-wrapper",children:e.jsxs("div",{ref:I=>{u.current=I,f(I)},className:`device-stream-canvas ${L?"":"landscape"} ${Ne?"focused":""} ${C?"is-inspecting":""}`,style:{width:d.width,height:d.height,background:"var(--black)"},tabIndex:0,onFocus:()=>tt(!0),onBlur:()=>tt(!1),onMouseDown:C?void 0:Ot,onMouseUp:C?void 0:ft,children:[ue?e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx($e,{size:40,color:"var(--red, #f87171)"}),e.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),e.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{de(!1),Q(0)},children:"Retry"})]}):(W||!J)&&e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx(lt,{size:40,className:"animate-spin",color:"var(--color-accent)"}),e.jsx("p",{style:{marginTop:16},children:W?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!ue&&e.jsx("img",{src:pt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>le(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),le(!1),q>=fe){de(!0);return}setTimeout(()=>Q(I=>I+1),2e3)}}),v==="off"&&!ue&&e.jsxs("div",{className:"device-screen-off",role:"status",children:[e.jsx(ci,{size:32}),e.jsx("p",{children:"Display is off"}),e.jsx("span",{children:"The stream is fine — the device is asleep."}),e.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:it,disabled:be,children:be?"Waking…":"Wake device"})]})]})}),e.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":L?"vertical":"horizontal",children:[e.jsx("button",{className:`footer-action-btn ${L?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":L,children:e.jsx(vi,{size:18})}),e.jsx("button",{className:`footer-action-btn ${L?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!L,children:e.jsx(yi,{size:18})}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:e.jsx(na,{size:18})}),b.platform==="android"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"footer-action-btn",onClick:Pt,title:"Back","aria-label":"Back",children:e.jsx(Os,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:at,title:"App switcher","aria-label":"App switcher",children:e.jsx(rn,{size:18})})]}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume up","aria-label":"Volume up",children:e.jsx(Ui,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume down","aria-label":"Volume down",children:e.jsx(Pi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:vt,title:"Lock device","aria-label":"Lock device",children:e.jsx(ga,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:it,title:"Unlock device","aria-label":"Unlock device",children:e.jsx(si,{size:18})})]})]}),e.jsxs("div",{className:"device-interactions-column",children:[e.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[e.jsxs("button",{className:`tab-btn ${y==="actions"?"active":""}`,onClick:()=>S("actions"),role:"tab","aria-selected":y==="actions",children:[e.jsx(un,{size:13}),e.jsx("span",{children:"Actions"})]}),e.jsxs("button",{className:`tab-btn ${y==="screenshot"?"active":""}`,onClick:()=>S("screenshot"),role:"tab","aria-selected":y==="screenshot",children:[e.jsx(Gt,{size:13}),e.jsx("span",{children:"Screenshot"})]}),e.jsxs("button",{className:`tab-btn ${y==="logs"?"active":""}`,onClick:()=>S("logs"),role:"tab","aria-selected":y==="logs",children:[e.jsx(pn,{size:13}),e.jsx("span",{children:"Logs"})]}),e.jsxs("button",{className:`tab-btn ${y==="terminal"?"active":""}`,onClick:()=>S("terminal"),role:"tab","aria-selected":y==="terminal",children:[e.jsx(ya,{size:13}),e.jsx("span",{children:"Shell"})]}),e.jsxs("button",{className:`tab-btn ${y==="omni"?"active":""}`,onClick:()=>S("omni"),role:"tab","aria-selected":y==="omni",children:[e.jsx(ki,{size:13}),e.jsx("span",{children:"Omni-Vision"})]})]}),e.jsx("div",{className:`interactions-scroll-area ${y==="terminal"?"terminal-mode":""} ${y==="screenshot"||y==="logs"?"screenshot-mode":""}`,children:e.jsxs("div",{className:"tab-content",children:[y==="omni"&&e.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:e.jsx($o,{sessionId:b.session_id?String(b.session_id):null,udid:b.udid,streamUrl:pt(),embedded:!0,overlayTarget:k,onModeChange:x,deviceActionAt:te})}),y==="actions"&&e.jsx(cc,{udid:b.udid,platform:b.platform,deviceName:E,screenWidth:Z,screenHeight:ke}),y==="screenshot"&&e.jsxs("div",{className:"action-card screenshot-card",children:[j.length>0&&e.jsx("header",{className:"action-card-header",children:e.jsx("button",{className:"btn-text-only",onClick:Ut,children:"CLEAR ALL"})}),e.jsxs("div",{className:`screenshot-workspace ${j.length===0?"is-empty":""}`,children:[e.jsxs("div",{className:"screenshot-gallery-sidebar",children:[e.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Ft,disabled:A,children:[A?e.jsx(ct,{className:"animate-spin",size:16}):e.jsx(Gt,{size:16}),e.jsx("span",{children:A?"CAPTURING...":"NEW CAPTURE"})]}),e.jsxs("div",{className:"screenshot-thumbnails-list",children:[j.length===0&&!A&&e.jsxs("div",{className:"empty-gallery-state",children:[e.jsx(Gt,{size:20,className:"empty-gallery-icon"}),e.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),e.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),j.map((I,U)=>e.jsxs("div",{className:`screenshot-thumb-item ${p===U?"active":""}`,onClick:()=>D(U),children:[e.jsx("img",{src:`data:image/png;base64,${I.base64}`,alt:"Thumb"}),e.jsx("span",{className:"thumb-time",children:new Date(I.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("button",{className:"thumb-delete-btn",onClick:G=>{G.stopPropagation(),De(I.id)},children:e.jsx(as,{size:12})})]},I.id))]})]}),e.jsx("div",{className:"screenshot-main-preview",children:p!==null&&j[p]?e.jsxs("div",{className:"preview-container",children:[e.jsx("div",{className:"preview-image-wrapper",children:e.jsx("img",{src:`data:image/png;base64,${j[p].base64}`,alt:"Selected Evidence"})}),e.jsxs("footer",{className:"preview-footer",children:[e.jsxs("div",{className:"preview-meta",children:[e.jsx("span",{className:"meta-label",children:"ID:"}),e.jsx("span",{className:"meta-value",children:j[p].id.substring(0,8)}),e.jsx("span",{className:"meta-divider",children:"|"}),e.jsx("span",{className:"meta-value",children:ha(j[p].timestamp)})]}),e.jsxs("div",{className:"preview-actions",children:[e.jsx("button",{className:"btn-premium btn-sm",onClick:()=>Bt(j[p].base64),children:"DOWNLOAD PNG"}),e.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>De(j[p].id),children:[e.jsx(as,{size:14})," DELETE"]})]})]})]}):null})]})]}),y==="logs"&&e.jsx("div",{className:"action-card screenshot-card",children:e.jsx(Xo,{udid:b.udid,platform:b.platform})}),y==="terminal"&&e.jsx("div",{className:"action-card full-height",children:e.jsx(Ur,{platform:(b.platform||"").toLowerCase(),prompt:`${(b.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${E} (${b.udid}).
278
- Internal Shell Environment.`,onCommand:async I=>{const U=await M.executeShell(b.udid,I);if(U.error)throw new Error(U.error);return U.output}})})]})})]})]}),b.session_id&&!String(b.session_id).startsWith("manual_")&&e.jsx(Qn,{sessionId:String(b.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const dc=/^(INPUT|TEXTAREA|SELECT)$/;function uc({labelledBy:t,onClose:s,children:n,style:a,...o}){const r=c.useRef(null),l=c.useRef(s);return l.current=s,c.useEffect(()=>{const u=r.current;if(!u)return;const d=document.activeElement,i=[];for(let x=u;x.parentElement&&x!==document.body;x=x.parentElement)for(const k of Array.from(x.parentElement.children))k===x||k.hasAttribute("inert")||k.matches("[aria-live], script, style, link, template")||(k.setAttribute("inert",""),i.push(k));u.contains(document.activeElement)||u.focus();const m=x=>{if(x.key!=="Escape"||x.defaultPrevented)return;const k=x.target;dc.test(k.tagName)||k.isContentEditable||(x.preventDefault(),l.current())};return u.addEventListener("keydown",m),()=>{u.removeEventListener("keydown",m),i.forEach(x=>x.removeAttribute("inert")),d&&d.isConnected&&d!==document.body&&d.focus()}},[]),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,style:{outline:"none",...a},...o,children:n})}const Un="xenon.devices.view";function Bn(){try{return window.localStorage}catch{return null}}function hc(t,s){const n=t.get("view");return n==="table"||n==="cards"?n:s}function mc(t,s,n){s==="table"||s!==n?t.set("view",s):t.delete("view")}function tn(t=Bn()){try{return(t==null?void 0:t.getItem(Un))==="table"?"table":"cards"}catch{return"cards"}}function pc(t,s=Bn()){try{s==null||s.setItem(Un,t)}catch{}}class fc extends Fe.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=Fe.createRef(),this.containerRef=Fe.createRef(),this.stickyGroupRef=Fe.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var r,l;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(r=a==null?void 0:a.closest)!=null&&r.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(l=this.searchRef.current)==null||l.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(vr),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(s=this.stickyObserver)==null||s.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await M.getDevices(),n=this.getBusyDevicesCount(s),a=await M.getPendingSessionsCount(),o=await M.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:o,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>Tt(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(i=>i.udid===n):null,{filters:o}=this.props,r=Nr(this.state.devices,o,Date.now()),l=[{value:"all",label:"Any platform",count:r.platform.all},{value:"android",label:"Android",count:r.platform.android},{value:"ios",label:"iOS",count:r.platform.ios}];(kr(this.state.devices)||o.platform==="tvos")&&l.push({value:"tvos",label:"tvOS",count:r.platform.tvos});const u=[{value:"all",label:"Any type",count:r.type.all},{value:"real",label:"Real devices",count:r.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:r.type.virtual}],d=`/devices${this.props.locationSearch}`;return e.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[e.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[e.jsx(Jn,{icon:ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),e.jsxs("div",{className:"de2-toolbar",children:[e.jsx(zs,{size:"sm",label:"Status",value:o.status,onChange:i=>this.setFilters({status:i}),segments:[{value:"all",label:"All",count:r.status.all},{value:"ready",label:"Ready",tone:"ready",count:r.status.ready},{value:"busy",label:"Busy",tone:"busy",count:r.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:r.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:r.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:r.status.offline}]}),e.jsxs("div",{className:"de2-toolbar-row",children:[e.jsxs("div",{className:"de2-search-wrap",children:[e.jsx(hs,{size:13,className:"de2-search-icon","aria-hidden":"true"}),e.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:o.q,onChange:i=>this.setFilters({q:i.target.value})}),e.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),e.jsx(Ps,{name:"Platform",value:o.platform,anyValue:"all",options:l,onChange:i=>this.setFilters({platform:i})}),e.jsx(Ps,{name:"Type",value:o.type,anyValue:"all",options:u,onChange:i=>this.setFilters({type:i})}),wr(o)&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),e.jsxs("div",{className:"de2-result",children:[e.jsx(zs,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&e.jsx("span",{"aria-live":"polite",children:Sr(s.length,this.state.devices.length)}),e.jsx(Y,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:e.jsx(St,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?e.jsx(Mr,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):e.jsx(xr,{devices:s,reloadDevices:()=>this.fetchDevices()}):e.jsxs("div",{className:"device-explorer-empty stagger-1",children:[e.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?e.jsx(ns,{size:32}):e.jsx(St,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Global Device Registry Empty"}),e.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),e.jsxs(Y,{variant:"primary",onClick:()=>this.fetchDevices(),children:[e.jsx(St,{size:14}),"Manual sync"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"No devices match these filters"}),e.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),e.jsx(Y,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Loading devices…"}),e.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&e.jsx(uc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:e.jsx("div",{className:"device-control-modal",children:e.jsx(lc,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Zc(){const t=an(),s=mt(),n=Mt(),[a,o]=Yn(),{on:r}=Zn(),l=gr(a),u=hc(a,tn()),d=Ar(a),i=(m,x,k)=>{const f=br(m);mc(f,x,tn()),Er(f,k),o(f,{replace:!0})};return e.jsx(fc,{params:t,navigate:s,onSocketEvent:r,filters:l,onFiltersChange:m=>i(m,u,d),view:u,onViewChange:m=>{pc(m),i(l,m,d)},sort:d,onSortChange:m=>i(l,u,m),locationSearch:n.search})}export{fc as DeviceExplorer,Zc as default};
266
+ `}function Vo(t,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${t}-${n}.txt`}const Qs=ds.filter(t=>t!=="V").map(t=>({value:t,label:t==="F"?"F only":`${t} and above`})),Ho=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function en(t,s){const n=URL.createObjectURL(new Blob([t],{type:"text/plain"})),a=document.createElement("a");a.href=n,a.download=s,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(n),0)}const Wo=c.memo(function({record:s,index:n,isHit:a,isActiveHit:o}){return e.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${a?"is-hit":""} ${o?"is-active-hit":""}`,children:[e.jsx("span",{className:"logcat-time",children:Ho.format(s.ts)}),e.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),e.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:Po(s.tag)},children:s.tag}),e.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),e.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),e.jsx("span",{className:"logcat-msg",children:s.message})]})});function qo({udid:t,platform:s}){const n=(s||"").toLowerCase(),a=n==="ios",o=n==="android"||a,[r,l]=c.useState(""),u=c.useMemo(()=>a?Lo(r):void 0,[a,r]),{records:d,connected:i,clear:h,deniedReason:x,exhausted:k,retry:f}=Do(t,o,u),[y,S]=c.useState(!0),[C,L]=c.useState(!1),[w,j]=c.useState(!0),[$,p]=c.useState(""),[D,A]=c.useState(0),O=c.useRef(null),W=c.useRef(null),V=c.useRef(null),[q,Q]=c.useState(!1),[b,oe]=c.useState(0),te=c.useRef(-1),ce=c.useMemo(()=>zn(r,{caseSensitive:C}),[r,C]),B=c.useMemo(()=>d.filter(_=>Mo(_,ce)),[d,ce]),E=c.useMemo(()=>{if(!$)return[];const _=C?$:$.toLowerCase(),v=[];return B.forEach((H,P)=>{(C?`${H.tag} ${H.message}`:`${H.tag} ${H.message}`.toLowerCase()).includes(_)&&v.push(P)}),v},[B,$,C]),J=E.length?Math.min(D,E.length-1):0,le=c.useMemo(()=>new Set(E),[E]),ue=c.useCallback(_=>{var H,P;if(!E.length)return;const v=(J+_+E.length)%E.length;A(v),S(!1),(P=(H=W.current)==null?void 0:H.querySelector(`[data-row-index="${E[v]}"]`))==null||P.scrollIntoView({block:"center"})},[E,J]),de=Qs.some(_=>_.value===ce.minLevel)?ce.minLevel:"",fe=c.useCallback(()=>{en(B.map(Ln).join(`
267
+ `),`logcat-${t}-${Date.now()}.txt`)},[B,t]);c.useEffect(()=>{const _=V.current;if(!_||!d.length)return;const v=d.filter(P=>P.seq>te.current);if(!v.length)return;const H=te.current+1;te.current>=0&&v[0].seq>H&&(_.dropped+=v[0].seq-H),Uo(_,v),te.current=v[v.length-1].seq,oe(_.lines.length)},[d]);const ee=c.useCallback(()=>{const _=V.current;if(!_){te.current=d.length?d[d.length-1].seq:-1,V.current=Fo(Date.now()),oe(0),Q(!0);return}const v=Bo(_,Date.now(),t);V.current=null,Q(!1),oe(0),en(v,Vo(t,_.startedAt))},[d,t]);if(c.useEffect(()=>{var _;y&&((_=O.current)==null||_.scrollIntoView({block:"end"}))},[B.length,y]),!o)return e.jsxs("div",{className:"log-empty-state",children:[e.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),e.jsx("p",{className:"log-empty-subtitle",children:"Streaming is wired up for Android (logcat) and iOS (os_trace), not for this device's platform."})]});const ge=x?"Denied":k?"Offline":i?"Live":"Connecting",be=!i&&(!!x||k);return e.jsxs("div",{className:"logcat-root",children:[e.jsxs("div",{className:"log-toolbar",children:[e.jsxs("div",{className:"log-filter-group",children:[e.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[e.jsx("span",{className:`log-live-dot ${i?"active":""} ${be?"is-error":""}`}),ge]}),e.jsxs("div",{className:"log-stat-pill logcat-count",children:[B.length," / ",d.length]}),e.jsxs(hs,{selectSize:"sm",value:de,onChange:_=>l(_o(r,_.target.value)),"aria-label":"Minimum log level",children:[e.jsx("option",{value:"",children:"All levels"}),Qs.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:r,onChange:_=>l(_.target.value),"aria-label":"Filter logs"}),r&&e.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>l(""),"aria-label":"Clear filter",title:"Clear filter",children:e.jsx(sn,{size:12})})]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:$,onChange:_=>{p(_.target.value),A(0)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),ue(_.shiftKey?-1:1))},"aria-label":"Find in logs"}),$&&e.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:E.length?`${J+1}/${E.length}`:"0/0"})]}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(-1),disabled:!E.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:e.jsx(ys,{size:14})}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(1),disabled:!E.length,"aria-label":"Next match",title:"Next match (Enter)",children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>L(!C),"aria-pressed":C,"aria-label":"Match case",title:"Match case",children:e.jsx(_a,{size:15})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${w?"active":""}`,onClick:()=>j(!w),"aria-pressed":w,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:e.jsx(Ti,{size:14})})]}),e.jsxs("div",{className:"log-actions-group",children:[(x||k)&&e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:f,children:[e.jsx(lt,{size:14})," RECONNECT"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${y?"active":""}`,onClick:()=>S(!y),children:[e.jsx(Ui,{size:14})," ",y?"FREEZE":"FOLLOW"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${q?"is-recording":""}`,onClick:ee,"aria-pressed":q,title:q?"Stop recording and download the capture":"Record the raw log stream to a file",children:[q?e.jsx(rn,{size:12}):e.jsx(na,{size:12})," ",q?`STOP · ${b.toLocaleString()}`:"RECORD"]}),e.jsxs("button",{className:"btn-premium btn-sm",disabled:B.length===0,onClick:fe,children:[e.jsx(ya,{size:14})," EXPORT"]}),e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:h,children:[e.jsx(as,{size:14})," CLEAR"]})]})]}),e.jsxs("div",{className:`logcat-rows theme-dark ${w?"":"no-wrap"}`,ref:W,children:[x&&e.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[e.jsx($e,{size:14}),e.jsxs("span",{children:["Access denied — ",x]})]}),!x&&k&&e.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[e.jsx($e,{size:14}),e.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),B.map((_,v)=>e.jsx(Wo,{record:_,index:v,isHit:le.has(v),isActiveHit:E.length>0&&E[J]===v},_.seq)),e.jsx("div",{ref:O})]})]})}function On(t){const s=t==null?void 0:t.message;return typeof s=="string"?s.trim():""}function Be(t,s){const n=On(s);return n?`Couldn’t ${t}: ${n}`:`Couldn’t ${t}.`}function Ko(t,s){return t==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Be("read the clipboard",s)}function Xo(t,s){const n=s.trim().toLowerCase();return[...t].sort((a,o)=>a.localeCompare(o)).filter(a=>!n||a.toLowerCase().includes(n))}const Go=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Yo(t){return Go.test(t.trim())}function vs(t){const s=(t||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Zo(t,s){const n=vs(s);return n?t.filter(a=>(a.platform||"").toLowerCase()===n):[]}function Jo(t){return[t.version,t.packageName].filter(Boolean).join(" · ")}function Qo(t){return vs(t)==="android"?"Android":"iOS"}function ec(t){return vs(t)==="android"?".apk":".ipa,.app"}const Pn="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Fn(t){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(t),!0):!1}catch{return!1}}function tc({udid:t,platform:s,deviceName:n}){const{toast:a,removeToast:o}=Ve(),r=ht(),[l,u]=c.useState([]),[d,i]=c.useState("loading"),[h,x]=c.useState(""),[k,f]=c.useState(""),[y,S]=c.useState(!1),[C,L]=c.useState(!1),[w,j]=c.useState([]),[$,p]=c.useState("loading"),[D,A]=c.useState(null),[O,W]=c.useState(null),V=c.useRef(null),q=c.useRef(null),Q=c.useRef(null),b=c.useCallback(async()=>{i("loading");try{const v=await M.listApps(t);u(Array.isArray(v)?v:[]),i("ready")}catch(v){x(On(v)),i("error")}},[t]);c.useEffect(()=>{b()},[b]);const oe=v=>setTimeout(b,v);c.useEffect(()=>{if(!O)return;const v=setTimeout(()=>W(null),1500);return()=>clearTimeout(v)},[O]);const te=async()=>{p("loading");try{const v=await M.getApps();j(Array.isArray(v)?v:[]),p("ready")}catch{p("error")}},ce=()=>{y||(L(!0),te())},B=()=>{var v;L(!1),(v=V.current)==null||v.focus()};c.useEffect(()=>{var H;if(!C||$==="loading")return;const v=(H=q.current)==null?void 0:H.querySelector('[role="menuitem"]:not(:disabled)');v==null||v.focus()},[C,$]);const E=async(v,H)=>{S(!0);const P=a(`Installing ${v} on ${n}…`,"loading",0);try{const K=await H();K!=null&&K.success?(a(`Installed ${v} on ${n}`,"success"),oe(5e3)):a(Be(`install ${v}`,{message:K==null?void 0:K.error}),"error")}catch(K){a(Be(`install ${v}`,K),"error")}finally{o(P),S(!1)}},J=v=>{B(),E(v.name,()=>M.installRepositoryApp(t,v.id))},le=v=>{var P;const H=(P=v.target.files)==null?void 0:P[0];v.target.value="",H&&E(H.name,()=>M.uploadAndInstallApp(t,H))},ue=async()=>{const v=D;if(A(null),!v)return;const H=a(`Uninstalling ${v} from ${n}…`,"loading",0);try{await M.uninstallApp(t,v),a(`Uninstalled ${v} from ${n}`,"success"),oe(3e3)}catch(P){a(Be(`uninstall ${v}`,P),"error")}finally{o(H)}},de=async(v,H)=>{var K,Ne;if(await Fn(v)){W(v);return}const P=(K=H.closest("li"))==null?void 0:K.querySelector(".actions-app-id");P&&((Ne=window.getSelection())==null||Ne.selectAllChildren(P)),a(Pn,"info")},fe=Xo(l,k),ee=k.trim(),ge=d==="ready"&&fe.length===0&&Yo(ee)&&!l.includes(ee),be=Zo(w,s),_=(v,H)=>e.jsxs("li",{className:"actions-app-row",children:[e.jsx("span",{className:"actions-app-id",children:v}),H&&e.jsx("span",{className:"actions-app-note",children:H}),e.jsxs("span",{className:"actions-app-tools",children:[e.jsx(Y,{variant:"ghost",size:"icon","aria-label":O===v?"Copied":`Copy ${v}`,title:O===v?"Copied":"Copy package ID",onClick:P=>de(v,P.currentTarget),children:O===v?e.jsx(dt,{size:13,"aria-hidden":"true"}):e.jsx(Te,{size:13,"aria-hidden":"true"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${v}`,onClick:()=>A(v),children:"Uninstall"})]})]},v);return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[e.jsxs("div",{className:"actions-section-head",children:[e.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[e.jsx(mi,{size:15,"aria-hidden":"true"})," Apps"]}),e.jsxs("div",{className:"actions-section-tools",children:[e.jsxs(Y,{ref:V,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":y||void 0,onClick:ce,children:[y?e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):e.jsx(ei,{size:13,"aria-hidden":"true"}),"Install from library"]}),e.jsxs(Y,{variant:"secondary",size:"sm","aria-disabled":y||void 0,onClick:()=>{var v;return!y&&((v=Q.current)==null?void 0:v.click())},children:[e.jsx(xa,{size:13,"aria-hidden":"true"})," Upload file"]}),e.jsx("input",{ref:Q,type:"file",hidden:!0,"aria-label":"App file to upload",accept:ec(s),onChange:le})]})]}),e.jsx(on,{open:C,onClose:B,anchorRef:V,placement:"bottom-end",children:e.jsx("div",{ref:q,className:"actions-library-menu",children:e.jsxs(cn,{children:[$==="loading"&&e.jsx(pe,{disabled:!0,onClick:()=>{},children:"Loading…"}),$==="error"&&e.jsx(pe,{onClick:te,children:"Couldn’t load the library. Retry"}),$==="ready"&&be.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs(pe,{disabled:!0,onClick:()=>{},children:["No ",Qo(s)," apps in the library yet"]}),e.jsx(pe,{onClick:()=>r("/apps"),children:"Open the Apps library"})]}),$==="ready"&&be.map(v=>e.jsx(pe,{note:Jo(v)||void 0,onClick:()=>J(v),children:v.name},v.id))]})})}),e.jsxs("div",{className:"actions-apps-tools",children:[e.jsxs("div",{className:"actions-search",children:[e.jsx(ms,{size:13,className:"actions-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${l.length} installed apps`,value:k,onChange:v=>f(v.target.value)})]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:b,children:e.jsx(St,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&e.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",h?`: ${h}`:".",e.jsx(Y,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),d==="ready"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&l.length>0&&fe.length===0&&!ge&&e.jsxs("p",{className:"actions-list-note",children:["No apps match “",ee,"”"]}),e.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[fe.map(v=>_(v)),ge&&_(ee,"Not in the list")]}),e.jsx(ps,{open:D!==null,title:"Uninstall app?",onClose:()=>A(null),footer:e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",onClick:()=>A(null),children:"Cancel"}),e.jsx(Y,{variant:"danger",onClick:ue,children:"Uninstall"})]}),children:e.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",e.jsx("code",{children:D})," from"," ",e.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const sc=[{direction:"up",Icon:ys},{direction:"down",Icon:fs},{direction:"left",Icon:ga},{direction:"right",Icon:ba}];function nc({onSwipe:t}){return e.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[e.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[e.jsx(Xa,{size:15,"aria-hidden":"true"})," Swipe"]}),e.jsx("div",{className:"actions-swipe-buttons",children:sc.map(({direction:s,Icon:n})=>e.jsx(Y,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>t(s),children:e.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function ac(t,s,n){const a=s/2,o=n/2,r=s*.4,l=n*.4,[u,d,i,h]={up:[a,o+l,a,o-l],down:[a,o-l,a,o+l],left:[a+r,o,a-r,o],right:[a-r,o,a+r,o]}[t].map(Math.round);return{startX:u,startY:d,endX:i,endY:h}}function ic({udid:t,platform:s}){const n=s!=="android",{toast:a}=Ve(),[o,r]=c.useState(""),[l,u]=c.useState(!1),[d,i]=c.useState(""),[h,x]=c.useState(null),[k,f]=c.useState(""),[y,S]=c.useState(!1),C=c.useRef(null);c.useEffect(()=>{if(!k)return;const p=setTimeout(()=>f(""),2e3);return()=>clearTimeout(p)},[k]),c.useEffect(()=>{if(!y)return;const p=setTimeout(()=>S(!1),1500);return()=>clearTimeout(p)},[y]);const L=async()=>{if(!(!o.trim()||l)){u(!0);try{await M.typeText(t,o),r(""),f("Sent")}catch(p){a(Be("send the text",p),"error")}finally{u(!1)}}},w=async()=>{x("read");try{const p=await M.getClipboard(t),D=typeof(p==null?void 0:p.content)=="string"?p.content:"";i(D),D||f("The device clipboard is empty")}catch(p){a(Ko(s,p),"error")}finally{x(null)}},j=async()=>{if(d){x("write");try{await M.setClipboard(t,d),f("Written to the device")}catch(p){a(Be("write the clipboard",p),"error")}finally{x(null)}}},$=async()=>{var p;if(await Fn(d)){S(!0);return}(p=C.current)==null||p.select(),a(Pn,"info")};return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[e.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[e.jsx(Ja,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),e.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:o,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&L()}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:L,disabled:!o.trim()||l,children:[l&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),e.jsx("input",{id:"actions-clipboard",ref:C,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:d,onChange:p=>i(p.target.value)}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:w,disabled:h!==null,children:[h==="read"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&e.jsxs(Y,{variant:"secondary",size:"md",onClick:j,disabled:!d||h!==null,children:[h==="write"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":y?"Copied":"Copy clipboard text",title:y?"Copied":"Copy to your clipboard",onClick:$,disabled:!d,children:y?e.jsx(dt,{size:14,"aria-hidden":"true"}):e.jsx(Te,{size:14,"aria-hidden":"true"})})]}),!n&&e.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),e.jsx("p",{className:"actions-status",role:"status",children:k})]})}function rc({udid:t,platform:s,deviceName:n,screenWidth:a,screenHeight:o}){const{toast:r}=Ve(),l=async u=>{const d=ac(u,a,o);try{await M.swipe(t,d.startX,d.startY,d.endX,d.endY)}catch(i){r(Be(`swipe ${u}`,i),"error")}};return e.jsxs("div",{className:"actions-panel",children:[e.jsx(tc,{udid:t,platform:s,deviceName:n}),e.jsx(ic,{udid:t,platform:s}),e.jsx(nc,{onSwipe:l})]})}function oc({device:t,onClose:s,titleId:n}){const{toast:a}=Ve(),o=ht(),{tab:r}=an(),l=Mt(),u=c.useRef(null),[d,i]=c.useState({width:0,height:0}),[h,x]=c.useState("inspect"),[k,f]=c.useState(null),[y,S]=c.useState(r||"actions"),C=y==="omni"&&h==="inspect",[L,w]=c.useState(!0),[j,$]=c.useState([]),[p,D]=c.useState(null),[A,O]=c.useState(!1),[W,V]=c.useState(!1),[q,Q]=c.useState(0),[b,oe]=c.useState(t),[te,ce]=c.useState(0),B=c.useCallback(()=>ce(Date.now()),[]),E=Me(b);c.useEffect(()=>{Xn(b.udid,E),document.title=Gn(l.pathname)},[b.udid,E,l.pathname]);const[J,le]=c.useState(!1),[ue,de]=c.useState(!1),fe=10,[ee,ge]=c.useState(!1),[be,_]=c.useState(!1),v=Co(b==null?void 0:b.udid,!ue),H=()=>{navigator.clipboard.writeText(b.udid).catch(()=>{}),ge(!0),setTimeout(()=>ge(!1),1500)},P=c.useRef(""),K=c.useRef(null),[Ne,tt]=c.useState(!1);c.useEffect(()=>{y&&(!r||r!==y)&&o(`/devices/${t.udid}/control/${y}${l.search}`,{replace:!0})},[y,r,t.udid,o,l.search]);const[zt,st]=c.useState(0);$o(()=>{M.leaveStream(b.udid).catch(()=>{})},()=>st(I=>I+1)),c.useEffect(()=>((async()=>{try{V(!0),await M.startStream(b.udid);const G=(await M.getDevices()).find(se=>se.udid===b.udid);G&&oe(G)}catch(F){console.error("Auto-start stream failed:",F)}finally{V(!1)}})(),()=>{M.leaveStream(b.udid).catch(()=>{})}),[t.udid,zt]);const He=parseInt(b.screenWidth||"1080",10),nt=parseInt(b.screenHeight||"1920",10),Z=Math.min(He,nt),ke=Math.max(He,nt),Ee=Z/ke,_e=c.useCallback(()=>{const I=!L,F=I?window.innerHeight*.55:window.innerHeight*.7,G=620,ye=window.innerWidth>900;let ie;I?ie=ye?Math.min(window.innerWidth*.8,window.innerWidth-G):window.innerWidth*.8:ie=window.innerWidth*.45;const xe=L?Ee:1/Ee;let ne,ae;L?(ne=F,ae=ne*xe,ae>ie&&(ae=ie,ne=ae/xe)):(ae=ie,ne=ae/xe,ne>F&&(ne=F,ae=ne*xe)),i({width:ae,height:ne})},[Ee,L]);c.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),c.useEffect(()=>{const I=async()=>{if(P.current.length>0){const G=P.current;P.current="";try{await M.typeText(b.udid,G)}catch(se){console.error("Keyboard buffering flush failed:",se)}finally{B()}}},F=G=>{const se=document.activeElement;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||!Ne&&y!=="terminal")return;const ie=G.key;ie==="Enter"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?66:"enter").finally(B)):ie==="Backspace"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?67:"backspace").finally(B)):ie.length===1&&(P.current+=ie,K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{I()},50))};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),K.current&&clearTimeout(K.current)}},[b.udid,b.platform,Ne,y,B]);const[We,Lt]=c.useState(Date.now()),pt=()=>{const I=q>0?`r=${q}&`:"";return b.session_id&&!String(b.session_id).startsWith("manual_")?`/xenon/api/session/${b.session_id}/live_video?${I}t=${We}`:`/xenon/api/control/${b.udid}/stream?${I}t=${We}`};c.useEffect(()=>{q>0&&Lt(Date.now())},[q]),c.useEffect(()=>{if(J||ue)return;const I=setTimeout(()=>de(!0),3e4);return()=>clearTimeout(I)},[J,ue,q]);const we=c.useRef(null),qe=I=>{const F=I.currentTarget.getBoundingClientRect();return{x:I.clientX-F.left,y:I.clientY-F.top}},Ot=I=>{const F=qe(I);we.current={x:F.x,y:F.y,time:Date.now()}},ft=async I=>{var Ye;if(!we.current)return;const F=we.current,G=qe(I),se=Date.now()-F.time,ye=(Ye=u.current)==null?void 0:Ye.getBoundingClientRect(),ie=(ye==null?void 0:ye.width)||d.width,xe=(ye==null?void 0:ye.height)||d.height;let ne,ae,Xe,Ge;L?(ne=F.x/ie*Z,ae=F.y/xe*ke,Xe=G.x/ie*Z,Ge=G.y/xe*ke):(ne=F.x/ie*ke,ae=F.y/xe*Z,Xe=G.x/ie*ke,Ge=G.y/xe*Z);const ze=Math.abs(Xe-ne),rt=Math.abs(Ge-ae);try{se<500&&ze<10&&rt<10?await M.tap(b.udid,Math.round(ne),Math.round(ae)):se>=500&&ze<10&&rt<10?await M.touchAndHold(b.udid,Math.round(ne),Math.round(ae),se):await M.swipe(b.udid,Math.round(ne),Math.round(ae),Math.round(Xe),Math.round(Ge))}catch(Vt){console.error("Action failed:",Vt)}finally{B()}we.current=null},yt=()=>M.pressKey(b.udid,b.platform==="android"?ot.HOME:Yt.HOME).finally(B),Pt=()=>M.pressKey(b.udid,ot.BACK).finally(B),at=()=>M.pressKey(b.udid,ot.APP_SWITCH).finally(B),xt=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_UP:Yt.VOLUME_UP).finally(B),Ke=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_DOWN:Yt.VOLUME_DOWN).finally(B),vt=()=>M.lock(b.udid).finally(B),it=async()=>{_(!0);try{await M.unlock(b.udid)}finally{B(),setTimeout(()=>_(!1),2500)}},Ft=async()=>{O(!0);try{const I=await M.getScreenshot(b.udid);if(I!=null&&I.screenshot){const F={id:Or(),base64:I.screenshot,timestamp:Date.now()};$(G=>[F,...G]),D(0)}}catch(I){console.error("Failed to take screenshot:",I)}finally{O(!1)}},De=I=>{$(F=>{const G=F.filter(se=>se.id!==I);return G.length===0?D(null):p!==null&&p>=G.length&&D(0),G})},Ut=()=>{$([]),D(null),a("Cleared all captured evidence.","success")},Bt=I=>{const F=document.createElement("a");F.href=`data:image/png;base64,${I}`,F.download=`screenshot-${b.udid}-${Date.now()}.png`,F.click()};return e.jsxs("div",{className:"device-control-view",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"control-view-top-bar",children:[e.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[e.jsx(Os,{size:18})," DEVICES"]}),e.jsxs("div",{className:"device-info-mini",children:[e.jsx("span",{className:`device-pill platform-pill ${b.platform}`,children:b.platform==="ios"?"Apple":"Android"}),e.jsxs("span",{className:"device-pill version-pill",children:["v",b.sdk]}),b.reservedUntil&&Date.now()<b.reservedUntil&&e.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${b.reservedBy}${b.reservationReason?`: ${b.reservationReason}`:""}`,children:["Reserved by ",b.reservedBy||"someone"]}),e.jsx("h2",{id:n,className:"device-name-text",children:E}),e.jsxs("span",{className:"udid-chip",title:b.udid,children:[e.jsx("span",{className:"udid-chip__value",children:b.udid}),e.jsx("button",{type:"button",className:"udid-chip__copy",onClick:H,"aria-label":"Copy UDID",title:ee?"Copied!":"Copy UDID",children:ee?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]})]})]}),e.jsxs("div",{className:`control-view-main ${L?"":"is-landscape"} ${y==="omni"?"omni-mode":""}`,children:[e.jsxs("div",{className:"device-preview-column",children:[e.jsx("div",{className:"device-screen-wrapper",children:e.jsxs("div",{ref:I=>{u.current=I,f(I)},className:`device-stream-canvas ${L?"":"landscape"} ${Ne?"focused":""} ${C?"is-inspecting":""}`,style:{width:d.width,height:d.height,background:"var(--black)"},tabIndex:0,onFocus:()=>tt(!0),onBlur:()=>tt(!1),onMouseDown:C?void 0:Ot,onMouseUp:C?void 0:ft,children:[ue?e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx($e,{size:40,color:"var(--red, #f87171)"}),e.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),e.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{de(!1),Q(0)},children:"Retry"})]}):(W||!J)&&e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx(lt,{size:40,className:"animate-spin",color:"var(--color-accent)"}),e.jsx("p",{style:{marginTop:16},children:W?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!ue&&e.jsx("img",{src:pt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>le(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),le(!1),q>=fe){de(!0);return}setTimeout(()=>Q(I=>I+1),2e3)}}),v==="off"&&!ue&&e.jsxs("div",{className:"device-screen-off",role:"status",children:[e.jsx(ci,{size:32}),e.jsx("p",{children:"Display is off"}),e.jsx("span",{children:"The stream is fine — the device is asleep."}),e.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:it,disabled:be,children:be?"Waking…":"Wake device"})]})]})}),e.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":L?"vertical":"horizontal",children:[e.jsx("button",{className:`footer-action-btn ${L?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":L,children:e.jsx(vi,{size:18})}),e.jsx("button",{className:`footer-action-btn ${L?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!L,children:e.jsx(yi,{size:18})}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:e.jsx(aa,{size:18})}),b.platform==="android"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"footer-action-btn",onClick:Pt,title:"Back","aria-label":"Back",children:e.jsx(Os,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:at,title:"App switcher","aria-label":"App switcher",children:e.jsx(rn,{size:18})})]}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume up","aria-label":"Volume up",children:e.jsx(Pi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume down","aria-label":"Volume down",children:e.jsx(Li,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:vt,title:"Lock device","aria-label":"Lock device",children:e.jsx(ja,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:it,title:"Unlock device","aria-label":"Unlock device",children:e.jsx(si,{size:18})})]})]}),e.jsxs("div",{className:"device-interactions-column",children:[e.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[e.jsxs("button",{className:`tab-btn ${y==="actions"?"active":""}`,onClick:()=>S("actions"),role:"tab","aria-selected":y==="actions",children:[e.jsx(un,{size:13}),e.jsx("span",{children:"Actions"})]}),e.jsxs("button",{className:`tab-btn ${y==="screenshot"?"active":""}`,onClick:()=>S("screenshot"),role:"tab","aria-selected":y==="screenshot",children:[e.jsx(Gt,{size:13}),e.jsx("span",{children:"Screenshot"})]}),e.jsxs("button",{className:`tab-btn ${y==="logs"?"active":""}`,onClick:()=>S("logs"),role:"tab","aria-selected":y==="logs",children:[e.jsx(pn,{size:13}),e.jsx("span",{children:"Logs"})]}),e.jsxs("button",{className:`tab-btn ${y==="terminal"?"active":""}`,onClick:()=>S("terminal"),role:"tab","aria-selected":y==="terminal",children:[e.jsx(va,{size:13}),e.jsx("span",{children:"Shell"})]}),e.jsxs("button",{className:`tab-btn ${y==="omni"?"active":""}`,onClick:()=>S("omni"),role:"tab","aria-selected":y==="omni",children:[e.jsx(Qn,{size:13}),e.jsx("span",{children:"Omni-Vision"})]})]}),e.jsx("div",{className:`interactions-scroll-area ${y==="terminal"?"terminal-mode":""} ${y==="screenshot"||y==="logs"?"screenshot-mode":""}`,children:e.jsxs("div",{className:"tab-content",children:[y==="omni"&&e.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:e.jsx(So,{sessionId:b.session_id?String(b.session_id):null,udid:b.udid,streamUrl:pt(),embedded:!0,overlayTarget:k,onModeChange:x,deviceActionAt:te})}),y==="actions"&&e.jsx(rc,{udid:b.udid,platform:b.platform,deviceName:E,screenWidth:Z,screenHeight:ke}),y==="screenshot"&&e.jsxs("div",{className:"action-card screenshot-card",children:[j.length>0&&e.jsx("header",{className:"action-card-header",children:e.jsx("button",{className:"btn-text-only",onClick:Ut,children:"CLEAR ALL"})}),e.jsxs("div",{className:`screenshot-workspace ${j.length===0?"is-empty":""}`,children:[e.jsxs("div",{className:"screenshot-gallery-sidebar",children:[e.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Ft,disabled:A,children:[A?e.jsx(ct,{className:"animate-spin",size:16}):e.jsx(Gt,{size:16}),e.jsx("span",{children:A?"CAPTURING...":"NEW CAPTURE"})]}),e.jsxs("div",{className:"screenshot-thumbnails-list",children:[j.length===0&&!A&&e.jsxs("div",{className:"empty-gallery-state",children:[e.jsx(Gt,{size:20,className:"empty-gallery-icon"}),e.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),e.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),j.map((I,F)=>e.jsxs("div",{className:`screenshot-thumb-item ${p===F?"active":""}`,onClick:()=>D(F),children:[e.jsx("img",{src:`data:image/png;base64,${I.base64}`,alt:"Thumb"}),e.jsx("span",{className:"thumb-time",children:new Date(I.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("button",{className:"thumb-delete-btn",onClick:G=>{G.stopPropagation(),De(I.id)},children:e.jsx(as,{size:12})})]},I.id))]})]}),e.jsx("div",{className:"screenshot-main-preview",children:p!==null&&j[p]?e.jsxs("div",{className:"preview-container",children:[e.jsx("div",{className:"preview-image-wrapper",children:e.jsx("img",{src:`data:image/png;base64,${j[p].base64}`,alt:"Selected Evidence"})}),e.jsxs("footer",{className:"preview-footer",children:[e.jsxs("div",{className:"preview-meta",children:[e.jsx("span",{className:"meta-label",children:"ID:"}),e.jsx("span",{className:"meta-value",children:j[p].id.substring(0,8)}),e.jsx("span",{className:"meta-divider",children:"|"}),e.jsx("span",{className:"meta-value",children:ha(j[p].timestamp)})]}),e.jsxs("div",{className:"preview-actions",children:[e.jsx("button",{className:"btn-premium btn-sm",onClick:()=>Bt(j[p].base64),children:"DOWNLOAD PNG"}),e.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>De(j[p].id),children:[e.jsx(as,{size:14})," DELETE"]})]})]})]}):null})]})]}),y==="logs"&&e.jsx("div",{className:"action-card screenshot-card",children:e.jsx(qo,{udid:b.udid,platform:b.platform})}),y==="terminal"&&e.jsx("div",{className:"action-card full-height",children:e.jsx(Pr,{platform:(b.platform||"").toLowerCase(),prompt:`${(b.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${E} (${b.udid}).
268
+ Internal Shell Environment.`,onCommand:async I=>{const F=await M.executeShell(b.udid,I);if(F.error)throw new Error(F.error);return F.output}})})]})})]})]}),b.session_id&&!String(b.session_id).startsWith("manual_")&&e.jsx(ea,{sessionId:String(b.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const cc=/^(INPUT|TEXTAREA|SELECT)$/;function lc({labelledBy:t,onClose:s,children:n,style:a,...o}){const r=c.useRef(null),l=c.useRef(s);return l.current=s,c.useEffect(()=>{const u=r.current;if(!u)return;const d=document.activeElement,i=[];for(let x=u;x.parentElement&&x!==document.body;x=x.parentElement)for(const k of Array.from(x.parentElement.children))k===x||k.hasAttribute("inert")||k.matches("[aria-live], script, style, link, template")||(k.setAttribute("inert",""),i.push(k));u.contains(document.activeElement)||u.focus();const h=x=>{if(x.key!=="Escape"||x.defaultPrevented)return;const k=x.target;cc.test(k.tagName)||k.isContentEditable||(x.preventDefault(),l.current())};return u.addEventListener("keydown",h),()=>{u.removeEventListener("keydown",h),i.forEach(x=>x.removeAttribute("inert")),d&&d.isConnected&&d!==document.body&&d.focus()}},[]),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,style:{outline:"none",...a},...o,children:n})}const Un="xenon.devices.view";function Bn(){try{return window.localStorage}catch{return null}}function dc(t,s){const n=t.get("view");return n==="table"||n==="cards"?n:s}function uc(t,s,n){s==="table"||s!==n?t.set("view",s):t.delete("view")}function tn(t=Bn()){try{return(t==null?void 0:t.getItem(Un))==="table"?"table":"cards"}catch{return"cards"}}function mc(t,s=Bn()){try{s==null||s.setItem(Un,t)}catch{}}class hc extends Fe.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=Fe.createRef(),this.containerRef=Fe.createRef(),this.stickyGroupRef=Fe.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var r,l;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(r=a==null?void 0:a.closest)!=null&&r.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(l=this.searchRef.current)==null||l.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(yr),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(s=this.stickyObserver)==null||s.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await M.getDevices(),n=this.getBusyDevicesCount(s),a=await M.getPendingSessionsCount(),o=await M.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:o,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>Tt(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(i=>i.udid===n):null,{filters:o}=this.props,r=br(this.state.devices,o,Date.now()),l=[{value:"all",label:"Any platform",count:r.platform.all},{value:"android",label:"Android",count:r.platform.android},{value:"ios",label:"iOS",count:r.platform.ios}];(jr(this.state.devices)||o.platform==="tvos")&&l.push({value:"tvos",label:"tvOS",count:r.platform.tvos});const u=[{value:"all",label:"Any type",count:r.type.all},{value:"real",label:"Real devices",count:r.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:r.type.virtual}],d=`/devices${this.props.locationSearch}`;return e.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[e.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[e.jsx(Jn,{icon:ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),e.jsxs("div",{className:"de2-toolbar",children:[e.jsx(zs,{size:"sm",label:"Status",value:o.status,onChange:i=>this.setFilters({status:i}),segments:[{value:"all",label:"All",count:r.status.all},{value:"ready",label:"Ready",tone:"ready",count:r.status.ready},{value:"busy",label:"Busy",tone:"busy",count:r.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:r.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:r.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:r.status.offline}]}),e.jsxs("div",{className:"de2-toolbar-row",children:[e.jsxs("div",{className:"de2-search-wrap",children:[e.jsx(ms,{size:13,className:"de2-search-icon","aria-hidden":"true"}),e.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:o.q,onChange:i=>this.setFilters({q:i.target.value})}),e.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),e.jsx(Ps,{name:"Platform",value:o.platform,anyValue:"all",options:l,onChange:i=>this.setFilters({platform:i})}),e.jsx(Ps,{name:"Type",value:o.type,anyValue:"all",options:u,onChange:i=>this.setFilters({type:i})}),Nr(o)&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),e.jsxs("div",{className:"de2-result",children:[e.jsx(zs,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&e.jsx("span",{"aria-live":"polite",children:kr(s.length,this.state.devices.length)}),e.jsx(Y,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:e.jsx(St,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?e.jsx(Dr,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):e.jsx(fr,{devices:s,reloadDevices:()=>this.fetchDevices()}):e.jsxs("div",{className:"device-explorer-empty stagger-1",children:[e.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?e.jsx(ns,{size:32}):e.jsx(St,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Global Device Registry Empty"}),e.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),e.jsxs(Y,{variant:"primary",onClick:()=>this.fetchDevices(),children:[e.jsx(St,{size:14}),"Manual sync"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"No devices match these filters"}),e.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),e.jsx(Y,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Loading devices…"}),e.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&e.jsx(lc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:e.jsx("div",{className:"device-control-modal",children:e.jsx(oc,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Yc(){const t=an(),s=ht(),n=Mt(),[a,o]=Yn(),{on:r}=Zn(),l=xr(a),u=dc(a,tn()),d=Tr(a),i=(h,x,k)=>{const f=vr(h);uc(f,x,tn()),Rr(f,k),o(f,{replace:!0})};return e.jsx(hc,{params:t,navigate:s,onSocketEvent:r,filters:l,onFiltersChange:h=>i(h,u,d),view:u,onViewChange:h=>{mc(h),i(l,h,d)},sort:d,onSortChange:h=>i(l,u,h),locationSearch:n.search})}export{hc as DeviceExplorer,Yc as default};