@xenon-device-management/xenon 2.9.2 → 2.10.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 (143) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{AnnotationOverlay-B87n4pUu.js → AnnotationOverlay-LzfXiiZJ.js} +1 -1
  3. package/lib/public/assets/{ApiKeyGate-CNZJH6Cs.js → ApiKeyGate-BzFDp4mK.js} +1 -1
  4. package/lib/public/assets/{BugReportButton-DQ-R87ZV.js → BugReportButton-BpgWvmZo.js} +1 -1
  5. package/lib/public/assets/{DeviceMosaicView-dX3e7O-w.js → DeviceMosaicView-CCB-egSH.js} +2 -2
  6. package/lib/public/assets/{EmptyState-D3fG2GHY.js → EmptyState-DkUVmANo.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-CUmbJZxI.js → FieldGroup-mbfnfTql.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-Dm2c-UCk.js → FilterMenu-BH5usz4Y.js} +1 -1
  9. package/lib/public/assets/{Menu-Dl4uXMkH.js → Menu-Cbo9mdTk.js} +1 -1
  10. package/lib/public/assets/{Modal-DNmn2RDs.js → Modal-D6XfQHPr.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-Dn3By34o.js → RecordingPage-CmFPkWqH.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-lCUIM4pm.js → RecordingsPage-CSlKk2qC.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-BdA_mHiZ.js → SegmentedControl-BFW9Dlqd.js} +1 -1
  14. package/lib/public/assets/{SettingCard-Dx3WhK7w.js → SettingCard-C4DioTTi.js} +1 -1
  15. package/lib/public/assets/{Table-D_2lhvRM.js → Table-DrKjlL00.js} +1 -1
  16. package/lib/public/assets/{activity-cNHHOKx5.js → activity-C9bE7Jm8.js} +1 -1
  17. package/lib/public/assets/{ai-settings-t6RMrDkg.js → ai-settings-DRYic4oO.js} +1 -1
  18. package/lib/public/assets/{api-keys-CK_qyQvW.js → api-keys-CaQU0g7c.js} +1 -1
  19. package/lib/public/assets/{apps-DCiI3UOb.js → apps-c1gUFmmK.js} +1 -1
  20. package/lib/public/assets/{arrow-left-CnYs8HVw.js → arrow-left-DMvAWA8r.js} +1 -1
  21. package/lib/public/assets/{arrow-right-Cc9qm6UG.js → arrow-right-BEQgxmKT.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-e7yBOb-c.js → arrow-up-right-Ba0e2GeU.js} +1 -1
  23. package/lib/public/assets/{auth-shell-DKrtcIjG.js → auth-shell-COODQnc7.js} +2 -2
  24. package/lib/public/assets/{builds-page-CRd5oEz6.js → builds-page-DZQgWBUs.js} +4 -4
  25. package/lib/public/assets/{button-C0caCjJB.js → button-WW9j43wR.js} +1 -1
  26. package/lib/public/assets/{calendar-BqOOkln_.js → calendar-COUs9VxF.js} +1 -1
  27. package/lib/public/assets/{check-DYSXRG79.js → check-D8ifHIJR.js} +1 -1
  28. package/lib/public/assets/{chevron-right-hCNu0CA-.js → chevron-right-BjKVUlB_.js} +1 -1
  29. package/lib/public/assets/{circle-check-DnQ263fa.js → circle-check-CfP79QE2.js} +1 -1
  30. package/lib/public/assets/{circle-x-BaRKZyz9.js → circle-x-BZbFCixZ.js} +1 -1
  31. package/lib/public/assets/{clock-XP3iBAhg.js → clock-BuTm35Qg.js} +1 -1
  32. package/lib/public/assets/{copy-D8d9UzWE.js → copy-W00zUBwN.js} +1 -1
  33. package/lib/public/assets/{device-explorer-pdM3L9TC.js → device-explorer-BEpS-Y-_.js} +5 -5
  34. package/lib/public/assets/{download-SaN9-umX.js → download-CGz-MS3y.js} +1 -1
  35. package/lib/public/assets/{forgot-password-DfUhEZW5.js → forgot-password-DG7SqVgU.js} +1 -1
  36. package/lib/public/assets/{index-C8pvxG1f.css → index-DQa193-A.css} +1 -1
  37. package/lib/public/assets/{index-IefGCFQQ.js → index-DWHTp1YP.js} +1 -1
  38. package/lib/public/assets/{index-CzaIyL9t.js → index-EkaQM1DK.js} +2 -2
  39. package/lib/public/assets/{input-BqFzAQT3.js → input-ChaTXeCq.js} +1 -1
  40. package/lib/public/assets/{keycodes-DDV2OlpQ.js → keycodes-BhbgeW_r.js} +10 -5
  41. package/lib/public/assets/line-chart-9P3RxScy.js +1 -0
  42. package/lib/public/assets/list-checks-_23IIEEL.js +11 -0
  43. package/lib/public/assets/{lock-Eye1CG8p.js → lock-B2JaqqRI.js} +1 -1
  44. package/lib/public/assets/{login-Co1IXuen.js → login-BEWIfLfC.js} +1 -1
  45. package/lib/public/assets/{maintenance-settings-D1fw6iqm.js → maintenance-settings-BGJIJQ-k.js} +1 -1
  46. package/lib/public/assets/{monitor-U5Y-PxW5.js → monitor-BrwMY4G0.js} +1 -1
  47. package/lib/public/assets/{mouse-pointer-2-CDAwphUm.js → mouse-pointer-2-DsWDMyrY.js} +1 -1
  48. package/lib/public/assets/{network-BP_U4iDZ.js → network-DfIhNVJv.js} +1 -1
  49. package/lib/public/assets/overview-B1mePY2_.js +6 -0
  50. package/lib/public/assets/{page-header-ZdzNEJp9.js → page-header-DoD3TOzZ.js} +1 -1
  51. package/lib/public/assets/{plus-1k0sxXyU.js → plus-BGvWvpBB.js} +1 -1
  52. package/lib/public/assets/{profile-page-B_GWKRy3.js → profile-page-CvV5aWvl.js} +1 -1
  53. package/lib/public/assets/{reset-password-DizCTkdw.js → reset-password-CGVd31LR.js} +1 -1
  54. package/lib/public/assets/{runbook-page-DWzRiOLZ.js → runbook-page-Bq2cvwb5.js} +1 -1
  55. package/lib/public/assets/{select-CiRW6v17.js → select-CTcD4jWR.js} +1 -1
  56. package/lib/public/assets/selector-detail-redirect-19odlD4B.js +1 -0
  57. package/lib/public/assets/selector-health-page-LqIsLrjW.js +11 -0
  58. package/lib/public/assets/session-detail-page-DQzb8_fq.js +4 -0
  59. package/lib/public/assets/{settings-DhwZoWv7.js → settings-C-EnGIqs.js} +1 -1
  60. package/lib/public/assets/stat-tile-BY0RDTRm.js +1 -0
  61. package/lib/public/assets/{tablet-CPJV3dBq.js → tablet-B4cFM-5B.js} +1 -1
  62. package/lib/public/assets/{teams-D0IBa2Ov.js → teams-BFe-RpYd.js} +1 -1
  63. package/lib/public/assets/time-D-gjmE1o.js +1 -0
  64. package/lib/public/assets/{trash-2-u8MlXUBD.js → trash-2-CJCKBOP9.js} +1 -1
  65. package/lib/public/assets/{upload-Cq8L3kpw.js → upload-DidWkbld.js} +1 -1
  66. package/lib/public/assets/use-builds-data-fnfxatOd.js +8 -0
  67. package/lib/public/assets/{use-password-reset-mode-Dbr2HEfw.js → use-password-reset-mode-iPen3tmC.js} +1 -1
  68. package/lib/public/assets/{users-CZqCE511.js → users-CrcjmRdf.js} +1 -1
  69. package/lib/public/assets/{users-DxLHYmFm.js → users-DBUv0CJx.js} +1 -1
  70. package/lib/public/assets/{video-off-mh1EEzP9.js → video-off-eh69-FKB.js} +1 -1
  71. package/lib/public/assets/view-state-CP9dE1UI.js +1 -0
  72. package/lib/public/assets/{webhook-settings-BYuOib-Q.js → webhook-settings-CQoSshBn.js} +1 -1
  73. package/lib/public/assets/{zap-BOpUur0M.js → zap-CICtWiLn.js} +1 -1
  74. package/lib/public/index.html +2 -2
  75. package/lib/schema.json +5 -0
  76. package/lib/src/app/routers/dashboard.js +86 -40
  77. package/lib/src/app/routers/selector-health.js +75 -0
  78. package/lib/src/app/swagger-docs.js +77 -8
  79. package/lib/src/dashboard/event-manager.js +15 -99
  80. package/lib/src/generated/client/edge.js +27 -3
  81. package/lib/src/generated/client/index-browser.js +24 -0
  82. package/lib/src/generated/client/index.d.ts +8207 -5283
  83. package/lib/src/generated/client/index.js +27 -3
  84. package/lib/src/generated/client/package.json +1 -1
  85. package/lib/src/generated/client/schema.prisma +43 -9
  86. package/lib/src/generated/client/wasm.js +24 -0
  87. package/lib/src/prisma.js +2 -0
  88. package/lib/src/services/CleanupService.js +1 -0
  89. package/lib/src/services/NotificationService.js +3 -4
  90. package/lib/src/services/SelectorStateService.js +151 -113
  91. package/lib/src/services/SelectorVerificationJob.js +14 -9
  92. package/lib/src/services/metrics/AndroidMetricsSampler.js +94 -0
  93. package/lib/src/services/metrics/IOSMetricsSampler.js +120 -0
  94. package/lib/src/services/metrics/SessionMetricsService.js +238 -0
  95. package/lib/src/services/metrics/androidMetrics.js +94 -0
  96. package/lib/src/services/metrics/iosMetrics.js +26 -0
  97. package/lib/src/services/metrics/metricsBody.js +37 -0
  98. package/lib/src/services/metrics/types.js +19 -0
  99. package/lib/src/services/selector-health/access.js +66 -0
  100. package/lib/src/services/selector-health/healingTrend.js +49 -0
  101. package/lib/src/services/selector-health/people.js +27 -0
  102. package/lib/src/services/selector-health/selectorDetail.js +198 -0
  103. package/lib/src/services/selector-health/selectorKeys.js +36 -0
  104. package/lib/src/services/selector-health/selectorList.js +333 -0
  105. package/lib/src/services/selector-health/stateView.js +67 -0
  106. package/lib/test/helpers/scratch-database.js +2 -0
  107. package/lib/test/helpers/selector-health-fixture.js +216 -0
  108. package/lib/test/integration/team-visibility-sessions.spec.js +1 -0
  109. package/lib/test/unit/CleanupService.spec.js +28 -2
  110. package/lib/test/unit/dashboard-events-metrics.spec.js +146 -0
  111. package/lib/test/unit/healing-no-cost.spec.js +134 -0
  112. package/lib/test/unit/healing-state-endpoints.spec.js +70 -0
  113. package/lib/test/unit/healing-trend.spec.js +118 -0
  114. package/lib/test/unit/selector-event-model.spec.js +47 -0
  115. package/lib/test/unit/selector-health-actions.spec.js +106 -0
  116. package/lib/test/unit/selector-health-detail.spec.js +131 -0
  117. package/lib/test/unit/selector-health-list.spec.js +185 -0
  118. package/lib/test/unit/selector-state-service.spec.js +74 -1
  119. package/lib/test/unit/selector-verification-job.spec.js +38 -0
  120. package/lib/test/unit/session-metrics-parse.spec.js +138 -0
  121. package/lib/test/unit/session-metrics-route.spec.js +140 -0
  122. package/lib/test/unit/session-metrics-samplers.spec.js +248 -0
  123. package/lib/test/unit/session-metrics-service.spec.js +215 -0
  124. package/lib/tsconfig.tsbuildinfo +1 -1
  125. package/package.json +1 -1
  126. package/prisma/migrations/20261002120000_session_metric/migration.sql +17 -0
  127. package/prisma/migrations/20261002130000_selector_event/migration.sql +13 -0
  128. package/prisma/schema.prisma +43 -9
  129. package/schema.json +5 -0
  130. package/lib/public/assets/chevron-left-BSG6mcpo.js +0 -6
  131. package/lib/public/assets/funnel-OefHE-54.js +0 -6
  132. package/lib/public/assets/layers-a3GNz2DA.js +0 -6
  133. package/lib/public/assets/list-checks-DMrMAFDt.js +0 -6
  134. package/lib/public/assets/overview-CsPyPv10.js +0 -1
  135. package/lib/public/assets/selector-detail-page-pA913STP.js +0 -1
  136. package/lib/public/assets/selector-health-BlICzZlk.css +0 -1
  137. package/lib/public/assets/selector-health-CHLX8KqY.js +0 -16
  138. package/lib/public/assets/selector-health-page-vVkg8Mii.js +0 -16
  139. package/lib/public/assets/session-detail-page-BCD49zDi.js +0 -4
  140. package/lib/public/assets/stat-tile-BaE76cnK.js +0 -8
  141. package/lib/public/assets/time-B8FIgwPE.js +0 -1
  142. package/lib/src/profiling/AndroidAppProfiler.js +0 -213
  143. /package/lib/public/assets/{session-detail-page-Bzzc3bMl.css → line-chart-Bzzc3bMl.css} +0 -0
@@ -1,4 +1,4 @@
1
- import{c as U,j as e,r as c,C as Ms,U as Wn,X as M,t as Ve,v as sn,b as qn,u as mt,a as Mt,T as Kn,q as ns,R as Fe,w as Xn,x as _s,y as $e,z as hs,I as nn,S as Nt,f as ct,A as St,i as an,B as Gn,D as Yn,E as Zn,p as Jn}from"./index-CzaIyL9t.js";import{P as Qn}from"./page-header-ZdzNEJp9.js";import{P as Ct,S as ea,B as ta}from"./BugReportButton-DQ-R87ZV.js";import{A as sa}from"./activity-cNHHOKx5.js";import{h as na,M as rn,S as on,C as aa,H as ia,a as Gt,A as ot,I as Yt}from"./keycodes-DDV2OlpQ.js";import{p as _t}from"./labels-C21SA4JG.js";import{B as Y}from"./button-C0caCjJB.js";import{S as ms}from"./select-CiRW6v17.js";import{P as cn,M as ln,a as pe,b as ra}from"./Menu-Dl4uXMkH.js";import{M as ps}from"./Modal-DNmn2RDs.js";import{F as $t}from"./FieldGroup-CUmbJZxI.js";import{C as oa}from"./clock-XP3iBAhg.js";import{P as ca}from"./plus-1k0sxXyU.js";import{C as Te}from"./copy-D8d9UzWE.js";import{T as la}from"./tablet-CPJV3dBq.js";import{S as da,a as zs}from"./SegmentedControl-BdA_mHiZ.js";import{T as ua,a as ha,b as dn,c as At,d as ma,e as Oe}from"./Table-D_2lhvRM.js";import{f as pa}from"./time-B8FIgwPE.js";import{L as un}from"./layers-a3GNz2DA.js";import{C as fa}from"./chevron-right-hCNu0CA-.js";import{M as Ls}from"./mouse-pointer-2-CDAwphUm.js";import{L as ya}from"./list-checks-DMrMAFDt.js";import{Z as hn}from"./zap-BOpUur0M.js";import{C as dt}from"./check-DYSXRG79.js";import{C as mn}from"./circle-check-DnQ263fa.js";import{C as pn}from"./circle-x-BaRKZyz9.js";import{D as xa}from"./download-SaN9-umX.js";import{T as as}from"./trash-2-u8MlXUBD.js";import{U as va,T as ga}from"./upload-Cq8L3kpw.js";import{A as ba}from"./arrow-left-CnYs8HVw.js";import{A as ja}from"./arrow-right-Cc9qm6UG.js";import{C as Os}from"./chevron-left-BSG6mcpo.js";import{L as Na}from"./lock-Eye1CG8p.js";import{F as Ps}from"./FilterMenu-Dm2c-UCk.js";import"./utils-CDN07tui.js";import"./index-IefGCFQQ.js";/**
1
+ import{c as U,j as e,r as c,C as Ms,U as Wn,X as M,t as Ve,v as sn,b as qn,u as mt,a as Mt,T as Kn,q as ns,R as Fe,w as Xn,x as _s,y as $e,z as hs,I as nn,S as Nt,f as ct,A as St,i as an,B as Gn,D as Yn,E as Zn,p as Jn}from"./index-EkaQM1DK.js";import{P as Qn}from"./page-header-DoD3TOzZ.js";import{P as Ct,S as ea,B as ta}from"./BugReportButton-BpgWvmZo.js";import{A as sa}from"./activity-C9bE7Jm8.js";import{h as na,M as rn,S as on,C as aa,a as zs,H as ia,b as Gt,A as ot,I as Yt}from"./keycodes-BhbgeW_r.js";import{p as _t}from"./labels-C21SA4JG.js";import{B as Y}from"./button-WW9j43wR.js";import{S as ms}from"./select-CTcD4jWR.js";import{P as cn,M as ln,a as pe,b as ra}from"./Menu-Cbo9mdTk.js";import{M as ps}from"./Modal-D6XfQHPr.js";import{F as $t}from"./FieldGroup-mbfnfTql.js";import{C as oa}from"./clock-BuTm35Qg.js";import{P as ca}from"./plus-BGvWvpBB.js";import{C as Te}from"./copy-W00zUBwN.js";import{T as la}from"./tablet-B4cFM-5B.js";import{S as da,a as Ls}from"./SegmentedControl-BFW9Dlqd.js";import{T as ua,a as ha,b as dn,c as At,d as ma,e as Oe}from"./Table-DrKjlL00.js";import{f as pa}from"./time-D-gjmE1o.js";import{L as un,a as fa}from"./list-checks-_23IIEEL.js";import{C as ya}from"./chevron-right-BjKVUlB_.js";import{M as Os}from"./mouse-pointer-2-DsWDMyrY.js";import{Z as hn}from"./zap-CICtWiLn.js";import{C as dt}from"./check-D8ifHIJR.js";import{C as mn}from"./circle-check-CfP79QE2.js";import{C as pn}from"./circle-x-BZbFCixZ.js";import{D as xa}from"./download-CGz-MS3y.js";import{T as as}from"./trash-2-CJCKBOP9.js";import{U as va,T as ga}from"./upload-DidWkbld.js";import{A as ba}from"./arrow-left-DMvAWA8r.js";import{A as ja}from"./arrow-right-BEQgxmKT.js";import{L as Na}from"./lock-B2JaqqRI.js";import{F as Ps}from"./FilterMenu-BH5usz4Y.js";import"./utils-CDN07tui.js";import"./index-DWHTp1YP.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -221,7 +221,7 @@ iOS Allowed Commands:
221
221
  • Simulator System:
222
222
  ls, ps, top, date, uptime, whoami
223
223
  `),r(p=>[...p,{type:"output",content:$.trim(),timestamp:Date.now()}]),f(!1);return}try{const $=await t(j),p=C($||"(No output)");r(D=>[...D,{type:"output",content:p,timestamp:Date.now()}])}catch($){r(p=>[...p,{type:"error",content:$.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var $;return($=S.current)==null?void 0:$.focus()},10)}}else if(w.key==="ArrowUp"){if(w.preventDefault(),d.length>0){const j=m===-1?d.length-1:Math.max(0,m-1);x(j),u(d[j])}}else if(w.key==="ArrowDown"&&(w.preventDefault(),m!==-1)){const j=m+1;j>=d.length?(x(-1),u("")):(x(j),u(d[j]))}};return e.jsxs("div",{className:"terminal-container theme-dark",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"terminal-header",children:[e.jsxs("div",{className:"terminal-controls",children:[e.jsx("div",{className:"dot red"}),e.jsx("div",{className:"dot yellow"}),e.jsx("div",{className:"dot green"})]}),e.jsxs("div",{className:"terminal-title",children:[_t(a)," shell"]}),e.jsx("div",{className:"terminal-actions",children:e.jsx("button",{className:"terminal-action-btn",onClick:()=>r([]),title:"Clear terminal",children:"CLEAR"})})]}),e.jsxs("div",{className:"terminal-history",ref:y,onClick:()=>{var w;return(w=S.current)==null?void 0:w.focus()},children:[o.map((w,j)=>e.jsx("div",{className:`terminal-line ${w.type}`,children:w.content},j)),k&&e.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),e.jsxs("div",{className:"terminal-input-area",children:[e.jsx("span",{className:"terminal-prompt",children:s}),e.jsx("input",{ref:S,className:"terminal-input",value:l,onChange:w=>u(w.target.value),onKeyDown:L,disabled:k,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Ae(t,s){var n;s(t),(n=t.children)==null||n.forEach(a=>Ae(a,s))}function Re(t,...s){var n;for(const a of s){const o=(n=t.attributes)==null?void 0:n[a];if(o!=null&&o!=="")return String(o)}}function et(t){var s;return((s=t.type)==null?void 0:s.split(".").pop())||t.type||""}function Ur(t,s){const n=[];return Ae(t,a=>{Re(a,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(a)}),n}function Br(t,s){const n=[];return Ae(t,a=>{Re(a,"resource-id","resourceId","identifier")===s&&n.push(a)}),n}function os(t,s){const n=[];return Ae(t,a=>{(a.type===s||et(a)===s)&&n.push(a)}),n}function Vr(t,s){const n=[];return Ae(t,a=>{Re(a,"name")===s&&n.push(a)}),n}function Hr(t){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(t.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function Wr(t,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const a=[];for(const r of n){const l=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(r);if(!l)return null;a.push({type:l[1],index:parseInt(l[2],10)})}if(a[0].type!==t.type&&a[0].type!==et(t)||a[0].index!==1)return null;let o=t;for(let r=1;r<a.length&&o;r++){const{type:l,index:u}=a[r];let d=0,i;for(const m of o.children||[])if((m.type===l||et(m)===l)&&(d+=1,d===u)){i=m;break}o=i}return o?[o]:[]}function qr(t,s){const n=Wr(t,s);if(n!==null)return{kind:"matched",nodes:n};const a=Hr(s);if(a){const o=[];return Ae(t,r=>{if(a.tag&&r.type!==a.tag&&et(r)!==a.tag)return;Re(r,a.attrKey)===a.attrValue&&o.push(r)}),{kind:"matched",nodes:o}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function Kr(t,s){const n=s.trim(),a=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(a){const[,l,u,d]=a,i=[];return Ae(t,m=>{if(m.type!==l&&et(m)!==l)return;Re(m,u)===d&&i.push(m)}),{kind:"matched",nodes:i}}const o=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(o){const[,l,u]=o,d=parseInt(u,10),i=[];return Ae(t,m=>{(m.type===l||et(m)===l)&&i.push(m)}),{kind:"matched",nodes:i[d-1]?[i[d-1]]:[]}}const r=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return r?os(t,r[1]).length>0?{kind:"matched",nodes:os(t,r[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function Xr(t,s){const a=s.trim().split(/\s+AND\s+/i).map(l=>l.trim()),o=[];for(const l of a){const u=/^(\w+)\s*==\s*"([^"]*)"$/.exec(l);if(!u)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};o.push({key:u[1],value:u[2]})}const r=[];return Ae(t,l=>{for(const u of o){let d;if(u.key==="type"?d=l.type:u.key==="label"?d=Re(l,"label")??l.label:u.key==="name"?d=Re(l,"name")??l.name:u.key==="value"?d=Re(l,"value")??l.value:d=Re(l,u.key),d!==u.value)return}r.push(l)}),{kind:"matched",nodes:r}}function cs(t,s,n){const a=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(a){case"accessibility id":return{kind:"matched",nodes:Ur(t,n)};case"id":return{kind:"matched",nodes:Br(t,n)};case"class name":return{kind:"matched",nodes:os(t,n)};case"name":return{kind:"matched",nodes:Vr(t,n)};case"xpath":return qr(t,n);case"-ios class chain":return Kr(t,n);case"-ios predicate string":return Xr(t,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function Vs(t){return{"accessibility id":1,id:2,"-ios predicate string":3,"-ios class chain":4,"-android uiautomator":3,"class name":8,xpath:9,name:10,"link text":10}[t.toLowerCase()]??7}function ls(t,s){const n=t.toLowerCase();if(n==="accessibility id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in accessibility ID — dynamically generated, unreliable"}:{level:"stable",reason:"#1 recommended by Appium — portable across Android & iOS"};if(n==="id")return/[0-9a-f]{8}-[0-9a-f]{4}/i.test(s)?{level:"fragile",reason:"UUID in resource ID — dynamically generated"}:/\d{6,}/.test(s)&&!s.includes(":id/")?{level:"moderate",reason:"Long numeric ID without package prefix — may not be unique"}:/^[a-z][a-z0-9.]+:id\//.test(s)?{level:"stable",reason:"Android resource-id with package prefix — #2 by Appium priority"}:{level:"stable",reason:"Element ID — #2 by Appium 2.x recommended priority"};if(n==="xpath"){if(s.startsWith("/hierarchy")||s.startsWith("/")&&!s.startsWith("//"))return{level:"very-fragile",reason:"ABSOLUTE XPath — breaks on any layout change. Avoid entirely"};if(/\[\d+\]/.test(s))return{level:"very-fragile",reason:"Index-based XPath [n] — breaks when element order changes"};const a=(s.match(/\//g)||[]).length;return a>7?{level:"fragile",reason:`${a}-level deep XPath — brittle to layout changes, 10x slower on iOS`}:s.includes("@content-desc")||s.includes("@resource-id")||s.includes("@text")?{level:"moderate",reason:"XPath with semantic attribute — more stable, but still prefer ID/accessibility id"}:{level:"fragile",reason:"XPath is a LAST RESORT per Appium docs — 10x slower on iOS, breaks on UI changes"}}return n==="-ios predicate string"?{level:"stable",reason:"iOS NSPredicate — native engine, excellent performance on iOS"}:n==="-ios class chain"?{level:"stable",reason:"iOS Class Chain — native iOS, faster than XPath"}:n==="-android uiautomator"?s.includes("resourceId")||s.includes("description")?{level:"stable",reason:"UIAutomator2 with resourceId/description — Android native, very reliable"}:s.includes("textContains")||s.includes("text(")?{level:"moderate",reason:"UIAutomator2 with text matching — breaks if copy changes"}:{level:"stable",reason:"UIAutomator2 — Android native engine, preferred over XPath on Android"}:n==="class name"?{level:"fragile",reason:"Class name alone is almost never unique — use with explicit index or prefer accessibility id"}:n==="name"?{level:"fragile",reason:"⚠️ Deprecated in Appium 2.x — replace with accessibility id or id"}:n==="link text"?{level:"moderate",reason:"Text-based locator — breaks if copy/label changes"}:{level:"moderate",reason:"Verify reliability for your target platform"}}function $n(t){return[...t].sort((s,n)=>Vs(s.strategy)-Vs(n.strategy))}const wt=t=>t===!0||t==="true",Gr=/^XCUIElementType(Button|Cell|Switch|Slider|TextField|SecureTextField|SearchField|TextView|Link|Tab|SegmentedControl|Stepper|PickerWheel|Key|MenuItem)$/,Yr=/(EditText|AutoCompleteTextView)$/;function Tn(t){const s=t.attributes||{};return wt(s.clickable)||wt(s["long-clickable"])||wt(s.checkable)||wt(s.scrollable)||Yr.test(t.type||"")||Gr.test(t.type||"")}function Zr(t){const s=t.attributes||{};return String(t.text||s["content-desc"]||t.label||s.label||s.name||"").trim()}function Jr(t,s){const n="Unique locator",a=$n(t.suggestedLocators||[]),o=a[0];if(!o)return{id:"unique",label:n,status:"fail",detail:"No locator suggested"};const r=cs(s.hierarchy,o.strategy,o.value),l=`${o.strategy} ${o.value}`;if(r.kind==="unsupported")return{id:"unique",label:n,status:"info",detail:`Can’t check ${o.strategy} locators here`};const u=k=>k.length===1&&k[0].xpath===t.xpath;if(u(r.nodes))return{id:"unique",label:n,status:"pass",detail:`${l} matches only this element`};const d=a.slice(1).find(k=>{const f=cs(s.hierarchy,k.strategy,k.value);return f.kind==="matched"&&u(f.nodes)}),i=d?`; use ${d.strategy} ${d.value} instead`:"",m=r.nodes.length,x=m===0?"matches nothing in this capture":`matches ${m} elements`;return{id:"unique",label:n,status:"fail",detail:`${l} ${x}${i}`}}function Qr(t){const s=$n(t.suggestedLocators||[])[0];if(!s)return null;const{level:n,reason:a}=ls(s.strategy,s.value);return{id:"stable",label:"Stable locator",status:n==="stable"||n==="moderate"?"pass":"warn",detail:a}}function eo(t,s){const{screenWidth:n,screenHeight:a}=s.metadata||{screenWidth:0,screenHeight:0};if(!n||!a)return null;const{x:o,y:r,width:l,height:u}=t.rect,d="On screen";return o+l<=0||r+u<=0||o>=n||r>=a?{id:"onscreen",label:d,status:"warn",detail:"Off screen — scroll it into view first"}:o<0||r<0||o+l>n||r+u>a?{id:"onscreen",label:d,status:"warn",detail:"Partly off screen — scroll it into view first"}:{id:"onscreen",label:d,status:"pass",detail:"Fully inside the screen"}}function to(t,s){var u,d;const n=Tn(t),a=!(((u=t.attributes)==null?void 0:u.enabled)===!1||((d=t.attributes)==null?void 0:d.enabled)==="false"),o=t.rect.width>0&&t.rect.height>0,r=Zr(t);return[Jr(t,s),Qr(t),n?{id:"interactive",label:"Interactive",status:"pass",detail:"Can be tapped, typed into or scrolled"}:{id:"interactive",label:"Interactive",status:"info",detail:"Not interactive — a tap here goes to whatever is under it"},a?{id:"enabled",label:"Enabled",status:"pass",detail:"Enabled"}:{id:"enabled",label:"Enabled",status:"fail",detail:"Disabled — taps are ignored"},o?{id:"size",label:"Has size",status:"pass",detail:`${t.rect.width} × ${t.rect.height}`}:{id:"size",label:"Has size",status:"fail",detail:"Zero-size — it can’t be tapped or seen"},eo(t,s),n?r?{id:"name",label:"Accessible name",status:"pass",detail:`“${r.slice(0,40)}”`}:{id:"name",label:"Accessible name",status:"warn",detail:"No accessible name — screen readers and accessibility-id locators have nothing to use"}:null].filter(i=>i!==null)}function so(t){return{pass:t.filter(s=>s.status==="pass").length,warn:t.filter(s=>s.status==="warn").length,fail:t.filter(s=>s.status==="fail").length}}function no(t,s){const n=Math.max(0,Math.round((s-t)/1e3));if(n<5)return"Captured just now";if(n<60)return`Captured ${n} s ago`;const a=Math.floor(n/60);return a<60?`Captured ${a} min ago`:`Captured ${Math.floor(a/60)} h ago`}function ao(t,s){return t>0&&s>t}function Rn(t){var r,l,u,d,i;const s=(t.type||"").toLowerCase(),n=((r=t.attributes)==null?void 0:r.clickable)==="true"||((l=t.attributes)==null?void 0:l.clickable)===!0,a=((u=t.attributes)==null?void 0:u.scrollable)==="true"||((d=t.attributes)==null?void 0:d.scrollable)===!0,o=((i=t.children)==null?void 0:i.length)||0;return s.includes("button")||s.includes("btn")||n&&o===0?{role:"Button",key:"button"}:s.includes("edit")||s.includes("input")||s.includes("field")?{role:"Text input",key:"input"}:s.includes("image")||s.includes("img")||s.includes("imageview")?{role:"Image",key:"image"}:s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||a?{role:"Scrollable list",key:"list"}:s.includes("text")||s.includes("label")?{role:"Text label",key:"text"}:s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?{role:"Toggle or checkbox",key:"toggle"}:s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?{role:"Navigation bar",key:"nav"}:o>0?{role:"Container",key:"container"}:{role:"Element",key:"element"}}const An={button:e.jsx(ui,{size:13}),input:e.jsx($i,{size:13}),image:e.jsx(Za,{size:13}),list:e.jsx(fn,{size:13}),text:e.jsx(zi,{size:13}),toggle:e.jsx(Ii,{size:13}),nav:e.jsx(fi,{size:13}),container:e.jsx(un,{size:13}),element:e.jsx(Da,{size:13})};function En(t,s){if(!s)return!0;const n=s.toLowerCase().trim(),a={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},o=(t.type||"").toLowerCase(),r=(t.text||t.label||t.value||"").toLowerCase(),l=(t.name||"").toLowerCase(),u=Object.values(t.attributes||{}).join(" ").toLowerCase();for(const[d,i]of Object.entries(a))if(n.includes(d)&&i.some(m=>o.includes(m)))return!0;return o.includes(n)||r.includes(n)||l.includes(n)||u.includes(n)}const je=t=>typeof t=="string"?t.trim():typeof t=="number"?String(t):"";function io(t){const s=je(t),n=s.indexOf(":id/");return n>=0?s.slice(n+4):s}function Dn(t){return(t.type||"").split(".").pop()||""}function Et(t){var s;return[t.type,(s=t.attributes)==null?void 0:s["resource-id"],t.text].filter(n=>typeof n=="string"&&n.trim()!=="").join(`
224
- `)}function Ue(t){const s=t.attributes||{};return je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label)||io(s["resource-id"])||je(s.name)||Dn(t)||"Element"}const ro=t=>{const s=t.attributes||{};return!!(je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label))};function oo(t){var s;return(((s=t.children)==null?void 0:s.length)??0)===1&&!Tn(t)&&!ro(t)}function In(t){const s=[t];let n=t;for(;oo(n);)n=n.children[0],s.push(n);return s}function Mn(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{var r;En(o,s)&&n.add(o.xpath),(r=o.children)==null||r.forEach(a)};return a(t),n}function co(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{let r=!1;for(const l of o.children||[])a(l)&&(r=!0);return r&&n.add(o.xpath),r||En(o,s)};return a(t),n}function lo(t,s,n=""){if(!t)return[];const a=!!n.trim(),o=a?Mn(t,n):null,r=a?co(t,n):null,l=i=>!a||i.some(m=>o.has(m.xpath)||r.has(m.xpath)),u=[],d=(i,m,x)=>{const k=i.map(In).filter(l);k.forEach((f,y)=>{var j;const S=f[f.length-1],C=(((j=S.children)==null?void 0:j.length)??0)>0,L=a&&r.has(S.xpath),w=C&&(s.has(S.xpath)||L);u.push({key:S.xpath,nodes:f,level:m,setSize:k.length,posInSet:y+1,hasChildren:C,expanded:w,collapsible:w&&!L,parentKey:x}),w&&d(S.children,m+1,S.xpath)})};return d([t],1,null),u}function uo(t,s=3){const n=new Set,a=(o,r)=>{var d;const l=In(o),u=l[l.length-1];r>s||!((d=u.children)!=null&&d.length)||(n.add(u.xpath),u.children.forEach(i=>a(i,r+1)))};return t&&a(t,1),n}function Rt(t,s){if(!t)return null;if(t.xpath===s)return[t];for(const n of t.children||[]){const a=Rt(n,s);if(a)return[t,...a]}return null}function Hs(t,s){return t.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function ho(t,s,n){var o;const a=t[s];if(!a)return null;switch(n){case"ArrowDown":return s<t.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((o=t[s+1])==null?void 0:o.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const r=t.findIndex(l=>l.key===a.parentKey);return r>=0?{focus:r}:null}case"Home":return{focus:0};case"End":return{focus:t.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const mo=10;function po({rows:t,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:o,onSelect:r,onHover:l,revealSeq:u=0}){const d=c.useRef(null),[i,m]=c.useState(null),x=c.useRef(0),k=c.useRef(null),f=s?Hs(t,s):-1,y=i?t.findIndex(p=>p.key===i):-1,S=y>=0?y:Math.max(f,0),C=p=>{var D;return((D=d.current)==null?void 0:D.querySelector(`[data-row="${p}"]`))??null},L=p=>p.nodes[p.nodes.length-1],w=p=>{var O;const D=t[p];if(!D)return;m(D.key),x.current=p;const A=C(p);A==null||A.focus({preventScroll:!0}),(O=A==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"})};c.useEffect(()=>{k.current=s},[s,u]),c.useEffect(()=>{var A,O;const p=k.current;if(!p)return;const D=Hs(t,p);D<0||((O=(A=C(D))==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"}),k.current=null)}),c.useEffect(()=>{var A,O;if(!i||t.some(W=>W.key===i))return;const p=Math.min(x.current,t.length-1),D=!document.activeElement||document.activeElement===document.body;m(((A=t[p])==null?void 0:A.key)??null),D&&p>=0&&((O=C(p))==null||O.focus({preventScroll:!0}))});const j=p=>{const D=p.target;if(D.getAttribute("role")!=="treeitem")return;const A=ho(t,Number(D.dataset.row),p.key);A&&(p.preventDefault(),"focus"in A?w(A.focus):"toggle"in A?o(A.toggle):r(A.select))},$=p=>{var D;(D=d.current)!=null&&D.contains(p.relatedTarget)||(l(null),m(null))};return e.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:j,onBlur:$,children:t.map((p,D)=>{const A=L(p),O=E=>!!E&&p.nodes.some(J=>J.xpath===E),W=O(s),V=!W&&O(n),q=Ue(A),Q=Dn(A),b=!!Q&&Q!==q,oe=p.nodes.map(E=>Ue(E)).join(", "),te=b?`${oe}, ${Q}`:oe,ce=p.expanded&&!p.collapsible,B=(E,J)=>`omni-tree-row__part${J?" is-target":""}${a.has(E.xpath)?" is-match":""}${E.xpath===s?" is-current":""}`;return e.jsxs("div",{"data-row":D,role:"treeitem","aria-level":p.level,"aria-setsize":p.setSize,"aria-posinset":p.posInSet,"aria-selected":W,"aria-expanded":p.hasChildren?p.expanded:void 0,"aria-label":te,tabIndex:D===S?0:-1,className:`omni-tree-row${W?" is-selected":""}${V?" is-hovered":""}`,onClick:()=>r(A),onFocus:E=>{E.target===E.currentTarget&&(m(p.key),x.current=D,l(A))},onMouseEnter:()=>l(A),onMouseLeave:()=>l(null),children:[e.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[e.jsx("span",{className:"omni-tree-row__indent",style:{width:(p.level-1)*mo}}),e.jsx("span",{className:`omni-tree-row__caret${ce?" is-locked":""}`,onClick:p.hasChildren?E=>{E.stopPropagation(),ce||o(p.key)}:void 0,children:p.hasChildren&&(p.expanded?e.jsx(Xn,{size:12}):e.jsx(fa,{size:12}))}),e.jsx("span",{className:"omni-tree-row__icon",children:An[Rn(A).key]})]}),e.jsxs("span",{className:"omni-tree-row__label",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__head",children:p.nodes.slice(0,-1).map((E,J)=>e.jsxs(Fe.Fragment,{children:[J>0&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsx("span",{className:B(E,!1),title:Et(E),onClick:le=>{le.stopPropagation(),r(E)},onMouseEnter:()=>l(E),onMouseLeave:()=>l(A),children:Ue(E)})]},E.xpath))}),e.jsxs("span",{className:"omni-tree-row__tail",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsxs("span",{className:"omni-tree-row__name",children:[e.jsx("span",{className:B(A,!0),title:Et(A),children:Ue(A)}),b&&e.jsx("span",{className:"omni-tree-row__type",children:Q})]})]})]}),p.hasChildren&&!p.expanded&&e.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:A.children.length})]},p.key)})})}const Ws=4;function fo({path:t,onSelect:s,focusCurrent:n=!1}){const[a,o]=c.useState(!1),r=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{var m;n&&((m=l.current)==null||m.focus())},[]),c.useEffect(()=>{var m;a&&((m=r.current)==null||m.focus())},[a]),!t.length)return null;const u=t[t.length-1],d=t.slice(0,-1),i=!a&&d.length>Ws?d.length-Ws:0;return e.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:e.jsxs("ol",{children:[i>0&&e.jsx("li",{children:e.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>o(!0),children:"…"})}),d.slice(i).map((m,x)=>e.jsx("li",{children:e.jsx("button",{ref:x===0?r:void 0,type:"button",className:"omni-crumb",title:Et(m),"aria-label":Ue(m),onClick:()=>s(m),children:Ue(m)})},m.xpath)),e.jsx("li",{children:e.jsx("span",{ref:l,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Et(u),children:Ue(u)})})]})})}const Dt=.4,yo=240,xo=340,qs=.02,It=12,_n="xenon.omni.split";function zn(t){if(!(t>0))return{min:0,max:1};const s=Math.min(1,yo/t);return{min:s,max:Math.max(s,(t-xo)/t)}}function vo(t,s){const{min:n,max:a}=zn(s),o=Number.isFinite(t)?t:Dt;return Math.min(a,Math.max(n,o))}function go(t){try{const s=Number.parseFloat((t==null?void 0:t.getItem(_n))??"");return s>0&&s<1?s:Dt}catch{return Dt}}function bo(t,s){try{t==null||t.setItem(_n,String(Math.round(s*1e3)/1e3))}catch{}}function Ks(){try{return window.localStorage}catch{return null}}const jo=3;function No({share:t,limits:s,containerRef:n,onChange:a,onCommit:o,onReset:r}){const[l,u]=c.useState(!1),d=c.useRef(t);d.current=t;const i=c.useRef(!0),m=c.useRef(!1),x=c.useRef(0),k=c.useRef(t),f=w=>Math.min(s.max,Math.max(s.min,w)),y=w=>Math.round(w*100),S=()=>{i.current||(i.current=!0,u(!1),m.current&&o(d.current))},C=w=>{var $;const j=($=n.current)==null?void 0:$.getBoundingClientRect();return!j||j.width<=It?d.current:f(k.current+(w-x.current)/(j.width-It))},L=w=>{const j=w.key==="ArrowLeft"?t-qs:w.key==="ArrowRight"?t+qs:w.key==="Home"?s.min:w.key==="End"?s.max:null;j!==null&&(w.preventDefault(),o(f(Math.round(j*1e3)/1e3)))};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":y(t),"aria-valuemin":y(s.min),"aria-valuemax":y(s.max),tabIndex:0,className:`omni-split-divider${l?" is-dragging":""}`,onKeyDown:L,onDoubleClick:r,onPointerDown:w=>{var j,$;($=(j=w.currentTarget).setPointerCapture)==null||$.call(j,w.pointerId),i.current=!1,m.current=!1,x.current=w.clientX,k.current=d.current,u(!0)},onPointerMove:w=>{if(!l||!m.current&&Math.abs(w.clientX-x.current)<jo)return;const j=C(w.clientX);j!==d.current&&(m.current=!0,a(j))},onPointerUp:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onPointerCancel:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onLostPointerCapture:S,children:e.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Xs(t,s,n,a){var w,j,$,p,D,A,O;const{strategy:o,value:r}=a,l=(t.text||t.name||((w=t.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",u=l.charAt(0).toLowerCase()+l.slice(1),d=((j=t.type)==null?void 0:j.toLowerCase().includes("edit"))||(($=t.type)==null?void 0:$.toLowerCase().includes("input"))||((p=t.type)==null?void 0:p.toLowerCase().includes("field"))||((D=t.type)==null?void 0:D.toLowerCase().includes("textfield")),i=((A=t.attributes)==null?void 0:A.scrollable)==="true"||((O=t.attributes)==null?void 0:O.scrollable)===!0,m=o.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
224
+ `)}function Ue(t){const s=t.attributes||{};return je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label)||io(s["resource-id"])||je(s.name)||Dn(t)||"Element"}const ro=t=>{const s=t.attributes||{};return!!(je(t.text)||je(s["content-desc"])||je(t.label)||je(s.label))};function oo(t){var s;return(((s=t.children)==null?void 0:s.length)??0)===1&&!Tn(t)&&!ro(t)}function In(t){const s=[t];let n=t;for(;oo(n);)n=n.children[0],s.push(n);return s}function Mn(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{var r;En(o,s)&&n.add(o.xpath),(r=o.children)==null||r.forEach(a)};return a(t),n}function co(t,s){const n=new Set;if(!t||!s.trim())return n;const a=o=>{let r=!1;for(const l of o.children||[])a(l)&&(r=!0);return r&&n.add(o.xpath),r||En(o,s)};return a(t),n}function lo(t,s,n=""){if(!t)return[];const a=!!n.trim(),o=a?Mn(t,n):null,r=a?co(t,n):null,l=i=>!a||i.some(m=>o.has(m.xpath)||r.has(m.xpath)),u=[],d=(i,m,x)=>{const k=i.map(In).filter(l);k.forEach((f,y)=>{var j;const S=f[f.length-1],C=(((j=S.children)==null?void 0:j.length)??0)>0,L=a&&r.has(S.xpath),w=C&&(s.has(S.xpath)||L);u.push({key:S.xpath,nodes:f,level:m,setSize:k.length,posInSet:y+1,hasChildren:C,expanded:w,collapsible:w&&!L,parentKey:x}),w&&d(S.children,m+1,S.xpath)})};return d([t],1,null),u}function uo(t,s=3){const n=new Set,a=(o,r)=>{var d;const l=In(o),u=l[l.length-1];r>s||!((d=u.children)!=null&&d.length)||(n.add(u.xpath),u.children.forEach(i=>a(i,r+1)))};return t&&a(t,1),n}function Rt(t,s){if(!t)return null;if(t.xpath===s)return[t];for(const n of t.children||[]){const a=Rt(n,s);if(a)return[t,...a]}return null}function Hs(t,s){return t.findIndex(n=>n.nodes.some(a=>a.xpath===s))}function ho(t,s,n){var o;const a=t[s];if(!a)return null;switch(n){case"ArrowDown":return s<t.length-1?{focus:s+1}:null;case"ArrowUp":return s>0?{focus:s-1}:null;case"ArrowRight":return a.hasChildren?a.expanded?((o=t[s+1])==null?void 0:o.parentKey)===a.key?{focus:s+1}:null:{toggle:a.key}:null;case"ArrowLeft":{if(a.collapsible)return{toggle:a.key};const r=t.findIndex(l=>l.key===a.parentKey);return r>=0?{focus:r}:null}case"Home":return{focus:0};case"End":return{focus:t.length-1};case"Enter":case" ":return{select:a.nodes[a.nodes.length-1]};default:return null}}const mo=10;function po({rows:t,selectedXpath:s,hoveredXpath:n,matches:a,onToggle:o,onSelect:r,onHover:l,revealSeq:u=0}){const d=c.useRef(null),[i,m]=c.useState(null),x=c.useRef(0),k=c.useRef(null),f=s?Hs(t,s):-1,y=i?t.findIndex(p=>p.key===i):-1,S=y>=0?y:Math.max(f,0),C=p=>{var D;return((D=d.current)==null?void 0:D.querySelector(`[data-row="${p}"]`))??null},L=p=>p.nodes[p.nodes.length-1],w=p=>{var O;const D=t[p];if(!D)return;m(D.key),x.current=p;const A=C(p);A==null||A.focus({preventScroll:!0}),(O=A==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"})};c.useEffect(()=>{k.current=s},[s,u]),c.useEffect(()=>{var A,O;const p=k.current;if(!p)return;const D=Hs(t,p);D<0||((O=(A=C(D))==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"nearest"}),k.current=null)}),c.useEffect(()=>{var A,O;if(!i||t.some(W=>W.key===i))return;const p=Math.min(x.current,t.length-1),D=!document.activeElement||document.activeElement===document.body;m(((A=t[p])==null?void 0:A.key)??null),D&&p>=0&&((O=C(p))==null||O.focus({preventScroll:!0}))});const j=p=>{const D=p.target;if(D.getAttribute("role")!=="treeitem")return;const A=ho(t,Number(D.dataset.row),p.key);A&&(p.preventDefault(),"focus"in A?w(A.focus):"toggle"in A?o(A.toggle):r(A.select))},$=p=>{var D;(D=d.current)!=null&&D.contains(p.relatedTarget)||(l(null),m(null))};return e.jsx("div",{ref:d,role:"tree","aria-label":"Element tree",className:"omni-tree",onKeyDown:j,onBlur:$,children:t.map((p,D)=>{const A=L(p),O=E=>!!E&&p.nodes.some(J=>J.xpath===E),W=O(s),V=!W&&O(n),q=Ue(A),Q=Dn(A),b=!!Q&&Q!==q,oe=p.nodes.map(E=>Ue(E)).join(", "),te=b?`${oe}, ${Q}`:oe,ce=p.expanded&&!p.collapsible,B=(E,J)=>`omni-tree-row__part${J?" is-target":""}${a.has(E.xpath)?" is-match":""}${E.xpath===s?" is-current":""}`;return e.jsxs("div",{"data-row":D,role:"treeitem","aria-level":p.level,"aria-setsize":p.setSize,"aria-posinset":p.posInSet,"aria-selected":W,"aria-expanded":p.hasChildren?p.expanded:void 0,"aria-label":te,tabIndex:D===S?0:-1,className:`omni-tree-row${W?" is-selected":""}${V?" is-hovered":""}`,onClick:()=>r(A),onFocus:E=>{E.target===E.currentTarget&&(m(p.key),x.current=D,l(A))},onMouseEnter:()=>l(A),onMouseLeave:()=>l(null),children:[e.jsxs("span",{className:"omni-tree-row__lead","aria-hidden":"true",children:[e.jsx("span",{className:"omni-tree-row__indent",style:{width:(p.level-1)*mo}}),e.jsx("span",{className:`omni-tree-row__caret${ce?" is-locked":""}`,onClick:p.hasChildren?E=>{E.stopPropagation(),ce||o(p.key)}:void 0,children:p.hasChildren&&(p.expanded?e.jsx(Xn,{size:12}):e.jsx(ya,{size:12}))}),e.jsx("span",{className:"omni-tree-row__icon",children:An[Rn(A).key]})]}),e.jsxs("span",{className:"omni-tree-row__label",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__head",children:p.nodes.slice(0,-1).map((E,J)=>e.jsxs(Fe.Fragment,{children:[J>0&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsx("span",{className:B(E,!1),title:Et(E),onClick:le=>{le.stopPropagation(),r(E)},onMouseEnter:()=>l(E),onMouseLeave:()=>l(A),children:Ue(E)})]},E.xpath))}),e.jsxs("span",{className:"omni-tree-row__tail",children:[p.nodes.length>1&&e.jsx("span",{className:"omni-tree-row__sep","aria-hidden":"true",children:"›"}),e.jsxs("span",{className:"omni-tree-row__name",children:[e.jsx("span",{className:B(A,!0),title:Et(A),children:Ue(A)}),b&&e.jsx("span",{className:"omni-tree-row__type",children:Q})]})]})]}),p.hasChildren&&!p.expanded&&e.jsx("span",{className:"omni-tree-row__count","aria-hidden":"true",children:A.children.length})]},p.key)})})}const Ws=4;function fo({path:t,onSelect:s,focusCurrent:n=!1}){const[a,o]=c.useState(!1),r=c.useRef(null),l=c.useRef(null);if(c.useEffect(()=>{var m;n&&((m=l.current)==null||m.focus())},[]),c.useEffect(()=>{var m;a&&((m=r.current)==null||m.focus())},[a]),!t.length)return null;const u=t[t.length-1],d=t.slice(0,-1),i=!a&&d.length>Ws?d.length-Ws:0;return e.jsx("nav",{"aria-label":"Element path",className:"omni-crumbs",children:e.jsxs("ol",{children:[i>0&&e.jsx("li",{children:e.jsx("button",{type:"button",className:"omni-crumb","aria-label":`Show all ${d.length} ancestors`,onClick:()=>o(!0),children:"…"})}),d.slice(i).map((m,x)=>e.jsx("li",{children:e.jsx("button",{ref:x===0?r:void 0,type:"button",className:"omni-crumb",title:Et(m),"aria-label":Ue(m),onClick:()=>s(m),children:Ue(m)})},m.xpath)),e.jsx("li",{children:e.jsx("span",{ref:l,tabIndex:-1,className:"omni-crumb is-current","aria-current":"location",title:Et(u),children:Ue(u)})})]})})}const Dt=.4,yo=240,xo=340,qs=.02,It=12,_n="xenon.omni.split";function zn(t){if(!(t>0))return{min:0,max:1};const s=Math.min(1,yo/t);return{min:s,max:Math.max(s,(t-xo)/t)}}function vo(t,s){const{min:n,max:a}=zn(s),o=Number.isFinite(t)?t:Dt;return Math.min(a,Math.max(n,o))}function go(t){try{const s=Number.parseFloat((t==null?void 0:t.getItem(_n))??"");return s>0&&s<1?s:Dt}catch{return Dt}}function bo(t,s){try{t==null||t.setItem(_n,String(Math.round(s*1e3)/1e3))}catch{}}function Ks(){try{return window.localStorage}catch{return null}}const jo=3;function No({share:t,limits:s,containerRef:n,onChange:a,onCommit:o,onReset:r}){const[l,u]=c.useState(!1),d=c.useRef(t);d.current=t;const i=c.useRef(!0),m=c.useRef(!1),x=c.useRef(0),k=c.useRef(t),f=w=>Math.min(s.max,Math.max(s.min,w)),y=w=>Math.round(w*100),S=()=>{i.current||(i.current=!0,u(!1),m.current&&o(d.current))},C=w=>{var $;const j=($=n.current)==null?void 0:$.getBoundingClientRect();return!j||j.width<=It?d.current:f(k.current+(w-x.current)/(j.width-It))},L=w=>{const j=w.key==="ArrowLeft"?t-qs:w.key==="ArrowRight"?t+qs:w.key==="Home"?s.min:w.key==="End"?s.max:null;j!==null&&(w.preventDefault(),o(f(Math.round(j*1e3)/1e3)))};return e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize element tree","aria-valuenow":y(t),"aria-valuemin":y(s.min),"aria-valuemax":y(s.max),tabIndex:0,className:`omni-split-divider${l?" is-dragging":""}`,onKeyDown:L,onDoubleClick:r,onPointerDown:w=>{var j,$;($=(j=w.currentTarget).setPointerCapture)==null||$.call(j,w.pointerId),i.current=!1,m.current=!1,x.current=w.clientX,k.current=d.current,u(!0)},onPointerMove:w=>{if(!l||!m.current&&Math.abs(w.clientX-x.current)<jo)return;const j=C(w.clientX);j!==d.current&&(m.current=!0,a(j))},onPointerUp:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onPointerCancel:w=>{var j,$;($=(j=w.currentTarget).releasePointerCapture)==null||$.call(j,w.pointerId),S()},onLostPointerCapture:S,children:e.jsx("span",{className:"omni-split-divider__grip","aria-hidden":"true"})})}function Xs(t,s,n,a){var w,j,$,p,D,A,O;const{strategy:o,value:r}=a,l=(t.text||t.name||((w=t.type)==null?void 0:w.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",u=l.charAt(0).toLowerCase()+l.slice(1),d=((j=t.type)==null?void 0:j.toLowerCase().includes("edit"))||(($=t.type)==null?void 0:$.toLowerCase().includes("input"))||((p=t.type)==null?void 0:p.toLowerCase().includes("field"))||((D=t.type)==null?void 0:D.toLowerCase().includes("textfield")),i=((A=t.attributes)==null?void 0:A.scrollable)==="true"||((O=t.attributes)==null?void 0:O.scrollable)===!0,m=o.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
225
225
  `:o.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
226
226
  `:"",x={"accessibility id":`~${r}`,id:s==="ios"?`-ios predicate string:label == "${r}"`:`android=new UiSelector().resourceId("${r}")`,xpath:`${r}`,"-ios predicate string":`-ios predicate string:${r}`,"-ios class chain":`-ios class chain:${r}`,"-android uiautomator":`android=${r}`},k={"accessibility id":`AppiumBy.accessibilityId("${r}")`,id:`AppiumBy.id("${r}")`,xpath:`AppiumBy.xpath("${r}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${r}")`,"-ios class chain":`AppiumBy.iOSClassChain("${r}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${r}")`,"class name":`AppiumBy.className("${r}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${r}"`,id:`AppiumBy.ID, "${r}"`,xpath:`AppiumBy.XPATH, "${r}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${r}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${r}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${r}'`,"class name":`AppiumBy.CLASS_NAME, "${r}"`},y=k[o.toLowerCase()],S=f[o.toLowerCase()],C=x[o.toLowerCase()];return n==="java"?y?`${m}// Appium Java Client 9.x + Selenium 4 + TestNG
227
227
  import io.appium.java_client.AppiumBy;
@@ -257,12 +257,12 @@ const element = await driver.$('${C}');
257
257
  await element.waitForExist({ timeout: 5000 });
258
258
  ${d?`await driver.$('target').clearValue();
259
259
  await element.addValue("your text here");`:"await element.click();"}
260
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${o}" not supported in WebdriverIO mobile`}const ko={pass:e.jsx(mn,{size:13}),warn:e.jsx($e,{size:13}),fail:e.jsx(pn,{size:13}),info:e.jsx(nn,{size:13})},wo={pass:"passed",warn:"warning",fail:"failed",info:"note"},So={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},Co=({sessionId:t,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:o=null,onModeChange:r,deviceActionAt:l=0})=>{var ks,ws,Ss,Cs,$s,Ts;const[u,d]=c.useState(!0),[i,m]=c.useState(null),[x,k]=c.useState(null),[f,y]=c.useState(null),[S,C]=c.useState(0),L=c.useRef(!1),[w,j]=c.useState(null),[$,p]=c.useState(()=>new Set),[D,A]=c.useState(""),[O,W]=c.useState(null),[V,q]=c.useState("info"),[Q,b]=c.useState(0),[oe,te]=c.useState(0),[ce,B]=c.useState(()=>Date.now()),E=c.useRef(0),J=c.useRef(null),[le,ue]=c.useState("java"),[de,fe]=c.useState(null),[ee,ge]=c.useState({width:0,height:0}),[be,_]=c.useState({width:0,height:0}),[v,H]=c.useState(!1),[P,K]=c.useState("inspect");c.useEffect(()=>{r==null||r(P)},[P,r]);const[Ne,tt]=c.useState({}),[zt,st]=c.useState({}),[He,nt]=c.useState(null),[Z,ke]=c.useState(null),[Ee,_e]=c.useState(null),We=c.useRef(null),Lt=c.useRef(null),pt=c.useRef(null),we=c.useRef(null),qe=c.useRef(null),[Ot,ft]=c.useState(()=>go(Ks())),[yt,Pt]=c.useState(0);c.useEffect(()=>{const h=qe.current;if(!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(([N])=>Pt(Math.max(0,N.contentRect.width-It)));return g.observe(h),()=>g.disconnect()},[]);const at=vo(Ot,yt),xt=h=>{ft(h),bo(Ks(),h)},Ke=c.useCallback(()=>{var Se,Ce,Ie;if(!We.current)return;const h=We.current.getBoundingClientRect(),g=h.width,N=h.height,T=(Se=i==null?void 0:i.hierarchy)==null?void 0:Se.rect;let z=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.screenWidth)||ee.width||1,R=((Ie=i==null?void 0:i.metadata)==null?void 0:Ie.screenHeight)||ee.height||1;T&&T.width>0&&T.height>0&&(z=T.width,R=T.height);const X=z/R;let ve,me;g/N>X?(me=N,ve=me*X):(ve=g,me=ve/X),_({width:ve,height:me})},[i,ee]);c.useEffect(()=>(Ke(),window.addEventListener("resize",Ke),()=>window.removeEventListener("resize",Ke)),[Ke]),c.useEffect(()=>{s&&De()},[s]);const vt=c.useCallback(async(h,g,N)=>{if(Z!=null&&Z.sessionId){nt(h);try{const T=await M.verifyLocator(Z.basePath,Z.sessionId,{strategy:h,selector:g,action:N});st(z=>({...z,[h]:T})),N==="tap"&&te(Date.now())}catch(T){st(z=>({...z,[h]:{found:!1,count:0,error:(T==null?void 0:T.message)||String(T)}}))}finally{nt(null)}}},[Z]),it=c.useRef(null);c.useEffect(()=>{const h=!!f&&f.xpath===it.current;it.current=(f==null?void 0:f.xpath)??null;const g=(f==null?void 0:f.suggestedLocators)??[];fe(N=>{const T=h&&N?g.find(R=>R.strategy===N.strategy):null,z=g.find(R=>R.strategy==="accessibility id"||R.strategy==="id");return T||z||g[0]||null}),tt({}),st({}),_e(null)},[f]);const Ft=c.useCallback((h,g)=>{if(!(i!=null&&i.hierarchy))return;const N=cs(i.hierarchy,h,g);tt(T=>({...T,[h]:N})),_e(h)},[i]),De=async()=>{if(!s)return;const h=++E.current,g=()=>h===E.current;d(!0),k(null),M.getAppiumSession(s).then(N=>{g()&&ke({sessionId:(N==null?void 0:N.sessionId)??null,basePath:(N==null?void 0:N.basePath)??""})}).catch(()=>{g()&&ke({sessionId:null,basePath:""})});try{const N=await M.getInspectorSnapshot(s);if(!g())return;if(!(N!=null&&N.hierarchy)){m(null),k((N==null?void 0:N.error)||"Failed to capture snapshot");return}const T=N.udid||s,z=T===J.current;J.current=T,_s.unstable_batchedUpdates(()=>{m(N),b(Date.now()),p(uo(N.hierarchy)),y(R=>{var X;return R&&z?((X=Rt(N.hierarchy,R.xpath))==null?void 0:X.pop())??null:null}),C(R=>R+1)})}catch(N){if(!g())return;m(null),k(N.message||"Failed to capture snapshot")}finally{g()&&d(!1)}};c.useEffect(()=>{const h=setInterval(()=>B(Date.now()),1e4);return()=>clearInterval(h)},[]);const Ut=h=>{const{naturalWidth:g,naturalHeight:N}=h.currentTarget;ge({width:g,height:N})},Bt=()=>H(!0),I=h=>{H(!1);const{naturalWidth:g,naturalHeight:N}=h.currentTarget;g>0&&N>0&&ge({width:g,height:N})},F=n&&!v,G=h=>{if(P!=="interact"||!s)return;const g=h.currentTarget.getBoundingClientRect();we.current={x:h.clientX-g.left,y:h.clientY-g.top,time:Date.now()}},se=async h=>{var As,Es,Ds;if(P!=="interact"||!s||!we.current)return;const g=we.current,N=h.currentTarget.getBoundingClientRect(),T=h.clientX-N.left,z=h.clientY-N.top,R=Date.now()-g.time,X=be.width,ve=be.height,me=(As=i==null?void 0:i.hierarchy)==null?void 0:As.rect;let Se=((Es=i==null?void 0:i.metadata)==null?void 0:Es.screenWidth)||ee.width,Ce=((Ds=i==null?void 0:i.metadata)==null?void 0:Ds.screenHeight)||ee.height;if(me&&me.width>0&&me.height>0&&(Se=me.width,Ce=me.height),!Se||!Ce||X===0||ve===0)return;const Ie=(jt,Is)=>({x:Math.round(jt/X*Se),y:Math.round(Is/ve*Ce),px:jt/X,py:Is/ve}),he=Ie(g.x,g.y),Rs=Ie(T,z),Xt=Math.sqrt(Math.pow(T-g.x,2)+Math.pow(z-g.y,2));if(!(he.px<0||he.px>1||he.py<0||he.py>1)){try{R<500&&Xt<10?await M.tap(s,he.x,he.y):R>=500&&Xt<10?await M.touchAndHold(s,he.x,he.y,R):Xt>=10&&await M.swipe(s,he.x,he.y,Rs.x,Rs.y),te(Date.now())}catch(jt){console.error("Interaction failed:",jt)}we.current=null}},ye=h=>{p(g=>{const N=new Set(g);return N.has(h)?N.delete(h):N.add(h),N})},ie=()=>{const h=new Set,g=N=>{var T;h.add(N.xpath),(T=N.children)==null||T.forEach(g)};i!=null&&i.hierarchy&&g(i.hierarchy),p(h)},xe=()=>p(new Set),ne=(h,g)=>{navigator.clipboard.writeText(h),W(g),setTimeout(()=>W(null),2e3)},ae=h=>{var N;let g=1;return(N=h.children)==null||N.forEach(T=>g+=ae(T)),g},Xe=h=>{if(!h)return[];const g={},N=T=>{var R;const z=Rn(T);g[z.role]||(g[z.role]={key:z.key,count:0}),g[z.role].count+=1,(R=T.children)==null||R.forEach(N)};return N(h),Object.entries(g).map(([T,z])=>({role:T,key:z.key,count:z.count})).sort((T,z)=>z.count-T.count)},Ge=c.useMemo(()=>lo(i==null?void 0:i.hierarchy,$,D),[i,$,D]),ze=c.useMemo(()=>Mn(i==null?void 0:i.hierarchy,D),[i,D]),rt=ze.size===0?"No matches":ze.size===1?"1 match":`${ze.size} matches`;c.useEffect(()=>{if(!f||!(i!=null&&i.hierarchy))return;const h=Rt(i.hierarchy,f.xpath);!h||h.length<2||p(g=>{const N=h.slice(0,-1).filter(z=>!g.has(z.xpath));if(!N.length)return g;const T=new Set(g);return N.forEach(z=>T.add(z.xpath)),T})},[S]),c.useEffect(()=>{L.current=!1});const Ye=h=>{y(h),C(g=>g+1),q("info")},Vt=h=>{L.current=!0,Ye(h)},gs=h=>{D.trim()&&!h.trim()&&C(g=>g+1),A(h)},Ht=()=>{var T,z,R;const h=(T=i==null?void 0:i.hierarchy)==null?void 0:T.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const g=((z=i==null?void 0:i.metadata)==null?void 0:z.screenWidth)||ee.width,N=((R=i==null?void 0:i.metadata)==null?void 0:R.screenHeight)||ee.height;return g>0&&N>0?{w:g,h:N}:null},bs=h=>{const g=Ht();if(!g)return[];const N=[],{w:T,h:z}=g,R=(X,ve)=>{var Se,Ce,Ie;const me=!X.children||X.children.length===0;((Se=X.rect)==null?void 0:Se.width)>0&&((Ce=X.rect)==null?void 0:Ce.height)>0&&me&&N.push(e.jsx("div",{className:"omni-hit-area",style:{left:`${X.rect.x/T*100}%`,top:`${X.rect.y/z*100}%`,width:`${X.rect.width/T*100}%`,height:`${X.rect.height/z*100}%`,zIndex:ve},onClick:he=>{he.stopPropagation(),Ye(X)},onMouseEnter:()=>j(X),onMouseLeave:()=>j(null)},X.xpath)),(Ie=X.children)==null||Ie.forEach(he=>R(he,ve+1))};return i!=null&&i.hierarchy&&R(i.hierarchy,1),N},js=()=>{const h=Ht();if(!Ee||!h)return[];const g=Ne[Ee];if(!g||g.kind!=="matched"||g.nodes.length===0)return[];const{w:N,h:T}=h,z=g.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return g.nodes.filter(R=>R.rect&&R.rect.width>0&&R.rect.height>0).map((R,X)=>e.jsx("div",{className:z,style:{left:`${R.rect.x/N*100}%`,top:`${R.rect.y/T*100}%`,width:`${R.rect.width/N*100}%`,height:`${R.rect.height/T*100}%`}},`match-${Ee}-${X}`))},gt=(h,g)=>{const N=Ht();if(!(h!=null&&h.rect)||!N)return null;const{w:T,h:z}=N;return e.jsx("div",{className:`omni-frame-${g}`,style:{left:`${h.rect.x/T*100}%`,top:`${h.rect.y/z*100}%`,width:`${h.rect.width/T*100}%`,height:`${h.rect.height/z*100}%`}})},Wt=i!=null&&i.hierarchy?ae(i.hierarchy):0,bt=f&&(i!=null&&i.hierarchy)?to(f,i):null,Le=bt?so(bt):null,qt=ao(Q,Math.max(l,oe)),Kt=i!=null&&i.hierarchy&&P==="inspect"?e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]}):null,Hn={stable:{icon:e.jsx(Nt,{size:10}),cls:"stable"},moderate:{icon:e.jsx($e,{size:10}),cls:"moderate"},fragile:{icon:e.jsx(Ze,{size:10}),cls:"fragile"},"very-fragile":{icon:e.jsx(Ze,{size:10}),cls:"very-fragile"}},Ns=a&&(i!=null&&i.hierarchy)?Xe(i.hierarchy):[];return e.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&o&&Kt?_s.createPortal(Kt,o):null,e.jsxs("div",{className:"omni-main-content",children:[!a&&e.jsxs("div",{className:"omni-screenshot-panel",children:[e.jsxs("div",{className:"omni-screenshot-header",children:[e.jsxs("div",{className:"omni-header-left",children:[e.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),e.jsxs("div",{className:"omni-mode-toggle",children:[e.jsxs("button",{className:`omni-mode-btn ${P==="inspect"?"active":""}`,onClick:()=>K("inspect"),title:"Inspection mode (highlight elements)",children:[e.jsx(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(rn,{ref:pt,src:n,onLoad:I,onError:Bt,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),Kt]}),!F&&(i==null?void 0:i.screenshot)&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:Lt,src:`data:image/png;base64,${i.screenshot}`,onLoad:Ut,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1}),P==="inspect"&&e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]})]})]})]}),e.jsxs("div",{className:"omni-split",ref:qe,children:[e.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${at*100}% - ${at*It}px)`},children:[e.jsxs("div",{className:"omni-tree-header",children:[e.jsxs("div",{className:"omni-tree-title",children:[e.jsx(un,{size:14}),e.jsx("span",{children:"Source"})]}),e.jsxs("div",{className:"omni-tree-actions",children:[e.jsx("button",{onClick:ie,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:e.jsx(Fa,{size:12})}),e.jsx("button",{onClick:xe,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:e.jsx(Oa,{size:12})}),a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(P==="inspect"?"interact":"inspect"),className:`omni-action-btn ${P==="inspect"?"active":""}`,title:P==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":P==="inspect"?"Inspect mode":"Interact mode","aria-pressed":P==="inspect",children:P==="inspect"?e.jsx(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:no(Q,ce)})]})),e.jsxs("div",{className:"omni-tree-search",children:[e.jsx(hs,{size:14}),e.jsx("input",{type:"text",placeholder:"Search elements",value:D,onChange:h=>gs(h.target.value),"aria-label":"Search elements"}),D&&e.jsx("button",{onClick:()=>gs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),e.jsx("div",{role:"status",className:"sr-only",children:D.trim()?rt:""}),D.trim()&&e.jsxs("div",{className:"omni-search-hint",children:[rt," · try a role: button, input, image"]}),e.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?e.jsx(po,{rows:Ge,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:ze,onToggle:ye,onSelect:Ye,onHover:j,revealSeq:S}):e.jsx("div",{className:"omni-empty-state small",children:e.jsx("span",{children:"No hierarchy loaded"})})})]}),e.jsx(No,{share:at,limits:zn(yt),containerRef:qe,onChange:ft,onCommit:xt,onReset:()=>xt(Dt)}),e.jsxs("div",{className:"omni-details-panel",children:[e.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[e.jsxs("button",{className:`omni-details-tab ${V==="info"?"active":""}`,onClick:()=>q("info"),role:"tab","aria-selected":V==="info",children:[e.jsx(ii,{size:12})," ",e.jsx("span",{children:"Info"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="checks"?"active":""}`,onClick:()=>q("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":V==="checks",children:[e.jsx(ya,{size:12})," ",e.jsx("span",{children:"Checks"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="code"?"active":""}`,onClick:()=>q("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":V==="code",children:[e.jsx(Fs,{size:12})," ",e.jsx("span",{children:"Code gen"})]})]}),e.jsx("div",{className:"omni-details-content",children:f?e.jsxs(e.Fragment,{children:[V==="info"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Element info"}),e.jsxs("div",{className:"omni-info-table",children:[e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Type"}),e.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Text"}),e.jsx("span",{className:"omni-info-value",children:f.text})]}),e.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[e.jsx("span",{className:"omni-info-key",children:"Path"}),e.jsx(fo,{path:(i==null?void 0:i.hierarchy)&&Rt(i.hierarchy,f.xpath)||[f],onSelect:Vt,focusCurrent:L.current},f.xpath)]})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Layout"}),e.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>e.jsxs("div",{className:"omni-layout-item",children:[e.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),e.jsx("span",{className:"omni-layout-value",children:f.rect[h]})]},h))})]}),e.jsxs("div",{className:"omni-section",children:[e.jsxs("div",{className:"omni-section-header",children:["Locators",e.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(Z!=null&&Z.sessionId)&&((Ss=f.suggestedLocators)==null?void 0:Ss.length)>0&&e.jsxs("p",{className:"omni-locators-note",children:[e.jsx(nn,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),e.jsxs("div",{className:"omni-locators-list",children:[!((Cs=f.suggestedLocators)!=null&&Cs.length)&&e.jsx("div",{className:"omni-locators-empty",children:f===(i==null?void 0:i.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),($s=f.suggestedLocators)==null?void 0:$s.map(h=>{const g=ls(h.strategy,h.value),N=Hn[g.level],T=Ne[h.strategy];let z=null;return T&&(T.kind==="unsupported"?z=e.jsxs("span",{className:"omni-match-badge unsupported",title:T.reason||"Cannot evaluate without a real driver",children:[e.jsx(Ba,{size:10})," preview unavailable"]}):T.nodes.length===0?z=e.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[e.jsx(Ze,{size:10})," 0 matches"]}):T.nodes.length===1?z=e.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[e.jsx(Nt,{size:10})," unique"]}):z=e.jsxs("span",{className:"omni-match-badge multi",title:`${T.nodes.length} elements match — selector is not unique`,children:[e.jsx($e,{size:10})," ",T.nodes.length," matches"]})),e.jsx("div",{className:`omni-locator-row ${(de==null?void 0:de.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>fe(h),title:"Click to use in Code gen",children:e.jsxs("div",{className:"omni-locator-left",children:[e.jsxs("div",{className:"omni-locator-top",children:[e.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),e.jsxs("span",{className:`omni-stability-badge ${N.cls}`,title:g.reason,children:[N.icon,g.level]}),z]}),e.jsx("code",{className:"omni-locator-value",children:h.value}),e.jsx("span",{className:"omni-stability-reason",children:g.reason}),(()=>{const R=zt[h.strategy];return R?R.error?e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium error: ",R.error]}):R.found?R.count>1?e.jsxs("span",{className:"omni-verify-line is-warn",children:[e.jsx($e,{size:10})," Ambiguous — Appium found"," ",R.count," elements",R.actionError?` · ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-ok",children:[e.jsx(Nt,{size:10})," Appium found 1 element",R.elapsedMs!=null?` in ${R.elapsedMs}ms`:"",R.actionPerformed&&R.actionPerformed!=="none"?` · ${R.actionPerformed} ok`:"",R.actionError?` · action failed: ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium found 0 elements"]}):null})(),e.jsxs("div",{className:"omni-locator-actions",children:[e.jsxs(Y,{type:"button",variant:Ee===h.strategy?"tonal":"secondary",size:"sm",onClick:R=>{R.stopPropagation(),Ft(h.strategy,h.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[e.jsx(Wa,{size:12,"aria-hidden":"true"}),"Test"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[He===h.strategy?e.jsx(lt,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(Nt,{size:12,"aria-hidden":"true"}),"Verify"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[e.jsx(hn,{size:12,"aria-hidden":"true"}),"Tap"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",onClick:R=>{R.stopPropagation(),ne(h.value,h.strategy)},title:"Copy the locator's value","aria-label":O===h.strategy?"Copied":"Copy locator",children:[O===h.strategy?e.jsx(dt,{size:12,"aria-hidden":"true"}):e.jsx(Te,{size:12,"aria-hidden":"true"}),O===h.strategy?"Copied":"Copy"]})]})]})},h.strategy)})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Attributes"}),e.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([h,g])=>g!=null&&g!=="").map(([h,g])=>e.jsxs("div",{className:"omni-attr-row",children:[e.jsx("span",{className:"omni-attr-key",children:h}),e.jsx("span",{className:"omni-attr-value",children:String(g)})]},h))})]})]}),V==="checks"&&bt&&Le&&e.jsxs("div",{className:"omni-checks-panel",children:[e.jsxs("p",{className:"omni-checks-summary",children:[e.jsxs("span",{className:"is-pass",children:[e.jsx(mn,{size:12,"aria-hidden":"true"})," ",Le.pass," passed"]}),Le.warn>0&&e.jsxs("span",{className:"is-warn",children:[e.jsx($e,{size:12,"aria-hidden":"true"})," ",Le.warn," ",Le.warn===1?"warning":"warnings"]}),Le.fail>0&&e.jsxs("span",{className:"is-fail",children:[e.jsx(pn,{size:12,"aria-hidden":"true"})," ",Le.fail," failed"]})]}),e.jsx("ul",{className:"omni-checks-list",children:bt.map(h=>e.jsxs("li",{className:`omni-check is-${h.status}`,children:[e.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:ko[h.status]}),e.jsxs("div",{className:"omni-check-body",children:[e.jsxs("div",{className:"omni-check-label",children:[h.label,e.jsxs("span",{className:"sr-only",children:[": ",wo[h.status]]})]}),e.jsx("div",{className:"omni-check-detail",children:h.detail})]})]},h.id))})]}),V==="code"&&e.jsxs("div",{className:"omni-codegen-panel",children:[e.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>e.jsx("button",{className:`omni-fw-btn ${le===h?"active":""}`,onClick:()=>ue(h),children:So[h]},h))}),de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-codegen-locator-selector",children:[e.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),e.jsx(ms,{selectSize:"sm",value:de.strategy,onChange:h=>{var N;const g=(N=f.suggestedLocators)==null?void 0:N.find(T=>T.strategy===h.target.value);g&&fe(g)},className:"flex-1",children:(Ts=f.suggestedLocators)==null?void 0:Ts.map(h=>e.jsxs("option",{value:h.strategy,children:[h.strategy," — ",ls(h.strategy,h.value).level]},h.strategy))})]}),e.jsxs("div",{className:"omni-codegen-output",children:[e.jsxs("div",{className:"omni-codegen-header",children:[e.jsx("span",{className:"omni-codegen-lang",children:le==="java"?"Java / TestNG":le==="python"?"Python / unittest":le==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),e.jsx("button",{className:"omni-copy-btn",onClick:()=>ne(Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de),"code"),children:O==="code"?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]}),e.jsx("pre",{className:"omni-codegen-pre theme-dark",children:e.jsx("code",{children:Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de)})})]})]}):e.jsxs("div",{className:"omni-empty-state small",children:[e.jsx(Fs,{size:24}),e.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?e.jsxs("div",{className:"omni-summary-panel",children:[e.jsxs("div",{className:"omni-summary-hero",children:[e.jsx(Zt,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"omni-summary-title",children:"No element selected"}),e.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),e.jsxs("div",{className:"omni-summary-stats",children:[e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),e.jsx("span",{className:"omni-summary-stat__value",children:Wt})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ks=i.metadata)==null?void 0:ks.screenWidth)??ee.width??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ws=i.metadata)==null?void 0:ws.screenHeight)??ee.height??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),e.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),Ns.length>0&&e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"By role"}),e.jsx("div",{className:"omni-summary-roles",children:Ns.slice(0,8).map(h=>e.jsxs("div",{className:"omni-summary-role",children:[e.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:An[h.key]}),e.jsx("span",{className:"omni-summary-role__name",children:h.role}),e.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:32}),e.jsx("span",{children:u?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Gs=5e3;function $o(t,s=!0){const[n,a]=c.useState("unknown"),o=c.useRef("unknown");return c.useEffect(()=>{if(!t||!s){a("unknown"),o.current="unknown";return}let r=!1,l;const u=m=>{r||m===o.current||(o.current=m,a(m))},d=async()=>{if(!r){if(l&&(clearTimeout(l),l=void 0),typeof document<"u"&&document.visibilityState==="hidden"){l=setTimeout(d,Gs);return}try{const m=await M.getDisplayState(t);u((m==null?void 0:m.state)??"unknown")}catch{}r||(l=setTimeout(d,Gs))}};d();const i=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",i),()=>{r=!0,l&&clearTimeout(l),document.removeEventListener("visibilitychange",i)}},[t,s]),n}function To(t,s){const n=c.useRef(t),a=c.useRef(s);n.current=t,a.current=s,c.useEffect(()=>{const o=()=>n.current(),r=l=>{var u;l.persisted&&((u=a.current)==null||u.call(a))};return window.addEventListener("pagehide",o),window.addEventListener("pageshow",r),()=>{window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",r)}},[])}const Ys=5e3,Ro=500,Ao=1e4,Eo=10,Do=50;function Io(t,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[o,r]=c.useState([]),[l,u]=c.useState(!1),[d,i]=c.useState(null),[m,x]=c.useState(!1),k=c.useRef(null),f=c.useRef(0),y=c.useRef(void 0),S=c.useRef(()=>{}),C=c.useRef([]),L=c.useRef(void 0),w=c.useRef(0),j=c.useRef(void 0),$=c.useCallback(()=>{if(C.current.length===0)return;const O=C.current;C.current=[],r(W=>{const V=W.concat(O);return V.length>Ys?V.slice(-Ys):V})},[]),p=c.useCallback(()=>{L.current===void 0&&(L.current=window.setTimeout(()=>{L.current=void 0,$()},Do))},[$]),D=c.useCallback(()=>{C.current=[],r([])},[]);c.useEffect(()=>{if(!s){u(!1),i(null),x(!1);return}i(null),x(!1),f.current=0;const O={cancelled:!1},W=()=>{if(O.cancelled)return;if(f.current>=Eo){x(!0);return}const q=Math.min(Ro*2**f.current,Ao);f.current+=1,y.current=window.setTimeout(V,q)},V=async()=>{if(!O.cancelled)try{const q=await fetch(`/xenon/api/control/${encodeURIComponent(t)}/stream/ticket`,{method:"POST",credentials:"include"});if(O.cancelled)return;if(!q.ok){W();return}const{ticket:Q}=await q.json();if(O.cancelled)return;if(!Q){W();return}const b=window.location.protocol==="https:"?"wss":"ws",[oe,te]=a.split("|"),ce=(oe?`&levels=${encodeURIComponent(oe)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),B=new WebSocket(`${b}://${window.location.host}/xenon/api/control/${encodeURIComponent(t)}/logcat?ticket=${encodeURIComponent(Q)}${ce}`);k.current=B,B.onopen=()=>{f.current=0,j.current!==1012&&(C.current=[],r([])),j.current=void 0,u(!0)},B.onmessage=E=>{try{const J=JSON.parse(E.data);C.current.push({...J,seq:w.current++}),p()}catch{}},B.onclose=E=>{if(u(!1),j.current=E.code,$(),E.code===1008){O.cancelled=!0,i(E.reason||"access denied");return}if(E.code===1012){W();return}console.warn(`[logcat] WS closed unexpectedly (code ${E.code}) — retrying`),W()},B.onerror=()=>B.close()}catch{W()}};return S.current=()=>{O.cancelled=!1,f.current=0,i(null),x(!1),V()},V(),()=>{var q;O.cancelled=!0,y.current!==void 0&&window.clearTimeout(y.current),L.current!==void 0&&(window.clearTimeout(L.current),L.current=void 0),$(),(q=k.current)==null||q.close(),k.current=null}},[t,s,a,$,p]);const A=c.useCallback(()=>{S.current()},[]);return{records:o,connected:l,clear:D,deniedReason:d,exhausted:m,retry:A}}const ds=["V","D","I","W","E","F"];function Mo(t){const s=[];let n="",a=!1,o=!1;for(const r of t){if(r==='"'){a=!a,o=!0;continue}if(!a&&/\s/.test(r)){(o||n)&&s.push(n),n="",o=!1;continue}n+=r,o=!0}return(o||n)&&s.push(n),s.filter(r=>r.length>0)}function Ln(t,s={}){const n=s.caseSensitive===!0,a=l=>n?l:l.toLowerCase(),o=n?{caseSensitive:!0}:{},r=[];for(const l of Mo(t)){const[u,...d]=l.split(":"),i=d.join(":");i&&u.toLowerCase()==="level"?o.minLevel=i.toUpperCase():i&&u.toLowerCase()==="tag"?o.tag=a(i):i&&u.toLowerCase()==="package"?o.pkg=a(i):r.push(l)}return r.length&&(o.text=a(r.join(" "))),o}function _o(t,s){if(t.synthetic)return!0;if(s.minLevel){const a=ds.indexOf(s.minLevel),o=ds.indexOf(t.level);if(a>=0&&o>=0&&o<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();return!(s.tag&&!n(t.tag).includes(s.tag)||s.pkg&&!n(t.pkg??"").includes(s.pkg)||s.text&&!n(t.message).includes(s.text))}function zo(t,s){const n=t.trim().split(/\s+/).filter(Boolean).filter(a=>{const[o,...r]=a.split(":");return!(r.join(":")&&o.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const ss=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],Zs=["V","D","I","W","E","F"];function Lo(t){if(!t)return ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=Zs.indexOf(t.toUpperCase());return s<0?ss.map(n=>n.ios):ss.filter(n=>Zs.indexOf(n.android)>=s).map(n=>n.ios)}function Oo(t){const s=Ln(t,{caseSensitive:!0});return{levels:Lo(s.minLevel),process:s.pkg||void 0}}const Js=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Po(t){let s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Fo(t){return t?Js[Po(t)%Js.length]:"var(--text-muted)"}const us=5e5;function On(t){return`${new Date(t.ts).toISOString()} ${t.pid} ${t.level}/${t.tag}: ${t.message}`}function Uo(t){return{lines:[],startedAt:t,dropped:0}}function Bo(t,s){for(const n of s){if(t.lines.length>=us){t.dropped+=1;continue}t.lines.push(On(n))}return t}function Vo(t,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(t.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-t.startedAt)/1e3).toFixed(1)}s`,`# lines: ${t.lines.length}`];t.dropped>0&&a.push(`# TRUNCATED: ${t.dropped} further line(s) were dropped after the ${us}-line cap. This capture is INCOMPLETE.`);const o=t.lines.join(`
260
+ // Assert with expect(element).toBeDisplayed()`:`// Strategy "${o}" not supported in WebdriverIO mobile`}const ko={pass:e.jsx(mn,{size:13}),warn:e.jsx($e,{size:13}),fail:e.jsx(pn,{size:13}),info:e.jsx(nn,{size:13})},wo={pass:"passed",warn:"warning",fail:"failed",info:"note"},So={java:"Java",python:"Python",javascript:"JavaScript",wdio:"WebdriverIO"},Co=({sessionId:t,udid:s,streamUrl:n,embedded:a=!1,overlayTarget:o=null,onModeChange:r,deviceActionAt:l=0})=>{var ks,ws,Ss,Cs,$s,Ts;const[u,d]=c.useState(!0),[i,m]=c.useState(null),[x,k]=c.useState(null),[f,y]=c.useState(null),[S,C]=c.useState(0),L=c.useRef(!1),[w,j]=c.useState(null),[$,p]=c.useState(()=>new Set),[D,A]=c.useState(""),[O,W]=c.useState(null),[V,q]=c.useState("info"),[Q,b]=c.useState(0),[oe,te]=c.useState(0),[ce,B]=c.useState(()=>Date.now()),E=c.useRef(0),J=c.useRef(null),[le,ue]=c.useState("java"),[de,fe]=c.useState(null),[ee,ge]=c.useState({width:0,height:0}),[be,_]=c.useState({width:0,height:0}),[v,H]=c.useState(!1),[P,K]=c.useState("inspect");c.useEffect(()=>{r==null||r(P)},[P,r]);const[Ne,tt]=c.useState({}),[zt,st]=c.useState({}),[He,nt]=c.useState(null),[Z,ke]=c.useState(null),[Ee,_e]=c.useState(null),We=c.useRef(null),Lt=c.useRef(null),pt=c.useRef(null),we=c.useRef(null),qe=c.useRef(null),[Ot,ft]=c.useState(()=>go(Ks())),[yt,Pt]=c.useState(0);c.useEffect(()=>{const h=qe.current;if(!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(([N])=>Pt(Math.max(0,N.contentRect.width-It)));return g.observe(h),()=>g.disconnect()},[]);const at=vo(Ot,yt),xt=h=>{ft(h),bo(Ks(),h)},Ke=c.useCallback(()=>{var Se,Ce,Ie;if(!We.current)return;const h=We.current.getBoundingClientRect(),g=h.width,N=h.height,T=(Se=i==null?void 0:i.hierarchy)==null?void 0:Se.rect;let z=((Ce=i==null?void 0:i.metadata)==null?void 0:Ce.screenWidth)||ee.width||1,R=((Ie=i==null?void 0:i.metadata)==null?void 0:Ie.screenHeight)||ee.height||1;T&&T.width>0&&T.height>0&&(z=T.width,R=T.height);const X=z/R;let ve,me;g/N>X?(me=N,ve=me*X):(ve=g,me=ve/X),_({width:ve,height:me})},[i,ee]);c.useEffect(()=>(Ke(),window.addEventListener("resize",Ke),()=>window.removeEventListener("resize",Ke)),[Ke]),c.useEffect(()=>{s&&De()},[s]);const vt=c.useCallback(async(h,g,N)=>{if(Z!=null&&Z.sessionId){nt(h);try{const T=await M.verifyLocator(Z.basePath,Z.sessionId,{strategy:h,selector:g,action:N});st(z=>({...z,[h]:T})),N==="tap"&&te(Date.now())}catch(T){st(z=>({...z,[h]:{found:!1,count:0,error:(T==null?void 0:T.message)||String(T)}}))}finally{nt(null)}}},[Z]),it=c.useRef(null);c.useEffect(()=>{const h=!!f&&f.xpath===it.current;it.current=(f==null?void 0:f.xpath)??null;const g=(f==null?void 0:f.suggestedLocators)??[];fe(N=>{const T=h&&N?g.find(R=>R.strategy===N.strategy):null,z=g.find(R=>R.strategy==="accessibility id"||R.strategy==="id");return T||z||g[0]||null}),tt({}),st({}),_e(null)},[f]);const Ft=c.useCallback((h,g)=>{if(!(i!=null&&i.hierarchy))return;const N=cs(i.hierarchy,h,g);tt(T=>({...T,[h]:N})),_e(h)},[i]),De=async()=>{if(!s)return;const h=++E.current,g=()=>h===E.current;d(!0),k(null),M.getAppiumSession(s).then(N=>{g()&&ke({sessionId:(N==null?void 0:N.sessionId)??null,basePath:(N==null?void 0:N.basePath)??""})}).catch(()=>{g()&&ke({sessionId:null,basePath:""})});try{const N=await M.getInspectorSnapshot(s);if(!g())return;if(!(N!=null&&N.hierarchy)){m(null),k((N==null?void 0:N.error)||"Failed to capture snapshot");return}const T=N.udid||s,z=T===J.current;J.current=T,_s.unstable_batchedUpdates(()=>{m(N),b(Date.now()),p(uo(N.hierarchy)),y(R=>{var X;return R&&z?((X=Rt(N.hierarchy,R.xpath))==null?void 0:X.pop())??null:null}),C(R=>R+1)})}catch(N){if(!g())return;m(null),k(N.message||"Failed to capture snapshot")}finally{g()&&d(!1)}};c.useEffect(()=>{const h=setInterval(()=>B(Date.now()),1e4);return()=>clearInterval(h)},[]);const Ut=h=>{const{naturalWidth:g,naturalHeight:N}=h.currentTarget;ge({width:g,height:N})},Bt=()=>H(!0),I=h=>{H(!1);const{naturalWidth:g,naturalHeight:N}=h.currentTarget;g>0&&N>0&&ge({width:g,height:N})},F=n&&!v,G=h=>{if(P!=="interact"||!s)return;const g=h.currentTarget.getBoundingClientRect();we.current={x:h.clientX-g.left,y:h.clientY-g.top,time:Date.now()}},se=async h=>{var As,Es,Ds;if(P!=="interact"||!s||!we.current)return;const g=we.current,N=h.currentTarget.getBoundingClientRect(),T=h.clientX-N.left,z=h.clientY-N.top,R=Date.now()-g.time,X=be.width,ve=be.height,me=(As=i==null?void 0:i.hierarchy)==null?void 0:As.rect;let Se=((Es=i==null?void 0:i.metadata)==null?void 0:Es.screenWidth)||ee.width,Ce=((Ds=i==null?void 0:i.metadata)==null?void 0:Ds.screenHeight)||ee.height;if(me&&me.width>0&&me.height>0&&(Se=me.width,Ce=me.height),!Se||!Ce||X===0||ve===0)return;const Ie=(jt,Is)=>({x:Math.round(jt/X*Se),y:Math.round(Is/ve*Ce),px:jt/X,py:Is/ve}),he=Ie(g.x,g.y),Rs=Ie(T,z),Xt=Math.sqrt(Math.pow(T-g.x,2)+Math.pow(z-g.y,2));if(!(he.px<0||he.px>1||he.py<0||he.py>1)){try{R<500&&Xt<10?await M.tap(s,he.x,he.y):R>=500&&Xt<10?await M.touchAndHold(s,he.x,he.y,R):Xt>=10&&await M.swipe(s,he.x,he.y,Rs.x,Rs.y),te(Date.now())}catch(jt){console.error("Interaction failed:",jt)}we.current=null}},ye=h=>{p(g=>{const N=new Set(g);return N.has(h)?N.delete(h):N.add(h),N})},ie=()=>{const h=new Set,g=N=>{var T;h.add(N.xpath),(T=N.children)==null||T.forEach(g)};i!=null&&i.hierarchy&&g(i.hierarchy),p(h)},xe=()=>p(new Set),ne=(h,g)=>{navigator.clipboard.writeText(h),W(g),setTimeout(()=>W(null),2e3)},ae=h=>{var N;let g=1;return(N=h.children)==null||N.forEach(T=>g+=ae(T)),g},Xe=h=>{if(!h)return[];const g={},N=T=>{var R;const z=Rn(T);g[z.role]||(g[z.role]={key:z.key,count:0}),g[z.role].count+=1,(R=T.children)==null||R.forEach(N)};return N(h),Object.entries(g).map(([T,z])=>({role:T,key:z.key,count:z.count})).sort((T,z)=>z.count-T.count)},Ge=c.useMemo(()=>lo(i==null?void 0:i.hierarchy,$,D),[i,$,D]),ze=c.useMemo(()=>Mn(i==null?void 0:i.hierarchy,D),[i,D]),rt=ze.size===0?"No matches":ze.size===1?"1 match":`${ze.size} matches`;c.useEffect(()=>{if(!f||!(i!=null&&i.hierarchy))return;const h=Rt(i.hierarchy,f.xpath);!h||h.length<2||p(g=>{const N=h.slice(0,-1).filter(z=>!g.has(z.xpath));if(!N.length)return g;const T=new Set(g);return N.forEach(z=>T.add(z.xpath)),T})},[S]),c.useEffect(()=>{L.current=!1});const Ye=h=>{y(h),C(g=>g+1),q("info")},Vt=h=>{L.current=!0,Ye(h)},gs=h=>{D.trim()&&!h.trim()&&C(g=>g+1),A(h)},Ht=()=>{var T,z,R;const h=(T=i==null?void 0:i.hierarchy)==null?void 0:T.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const g=((z=i==null?void 0:i.metadata)==null?void 0:z.screenWidth)||ee.width,N=((R=i==null?void 0:i.metadata)==null?void 0:R.screenHeight)||ee.height;return g>0&&N>0?{w:g,h:N}:null},bs=h=>{const g=Ht();if(!g)return[];const N=[],{w:T,h:z}=g,R=(X,ve)=>{var Se,Ce,Ie;const me=!X.children||X.children.length===0;((Se=X.rect)==null?void 0:Se.width)>0&&((Ce=X.rect)==null?void 0:Ce.height)>0&&me&&N.push(e.jsx("div",{className:"omni-hit-area",style:{left:`${X.rect.x/T*100}%`,top:`${X.rect.y/z*100}%`,width:`${X.rect.width/T*100}%`,height:`${X.rect.height/z*100}%`,zIndex:ve},onClick:he=>{he.stopPropagation(),Ye(X)},onMouseEnter:()=>j(X),onMouseLeave:()=>j(null)},X.xpath)),(Ie=X.children)==null||Ie.forEach(he=>R(he,ve+1))};return i!=null&&i.hierarchy&&R(i.hierarchy,1),N},js=()=>{const h=Ht();if(!Ee||!h)return[];const g=Ne[Ee];if(!g||g.kind!=="matched"||g.nodes.length===0)return[];const{w:N,h:T}=h,z=g.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return g.nodes.filter(R=>R.rect&&R.rect.width>0&&R.rect.height>0).map((R,X)=>e.jsx("div",{className:z,style:{left:`${R.rect.x/N*100}%`,top:`${R.rect.y/T*100}%`,width:`${R.rect.width/N*100}%`,height:`${R.rect.height/T*100}%`}},`match-${Ee}-${X}`))},gt=(h,g)=>{const N=Ht();if(!(h!=null&&h.rect)||!N)return null;const{w:T,h:z}=N;return e.jsx("div",{className:`omni-frame-${g}`,style:{left:`${h.rect.x/T*100}%`,top:`${h.rect.y/z*100}%`,width:`${h.rect.width/T*100}%`,height:`${h.rect.height/z*100}%`}})},Wt=i!=null&&i.hierarchy?ae(i.hierarchy):0,bt=f&&(i!=null&&i.hierarchy)?to(f,i):null,Le=bt?so(bt):null,qt=ao(Q,Math.max(l,oe)),Kt=i!=null&&i.hierarchy&&P==="inspect"?e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]}):null,Hn={stable:{icon:e.jsx(Nt,{size:10}),cls:"stable"},moderate:{icon:e.jsx($e,{size:10}),cls:"moderate"},fragile:{icon:e.jsx(Ze,{size:10}),cls:"fragile"},"very-fragile":{icon:e.jsx(Ze,{size:10}),cls:"very-fragile"}},Ns=a&&(i!=null&&i.hierarchy)?Xe(i.hierarchy):[];return e.jsxs("div",{className:`omni-inspector-container ${a?"omni-embedded":""}`,children:[a&&o&&Kt?_s.createPortal(Kt,o):null,e.jsxs("div",{className:"omni-main-content",children:[!a&&e.jsxs("div",{className:"omni-screenshot-panel",children:[e.jsxs("div",{className:"omni-screenshot-header",children:[e.jsxs("div",{className:"omni-header-left",children:[e.jsx("span",{className:"omni-screenshot-title",children:"Device preview"}),e.jsxs("div",{className:"omni-mode-toggle",children:[e.jsxs("button",{className:`omni-mode-btn ${P==="inspect"?"active":""}`,onClick:()=>K("inspect"),title:"Inspection mode (highlight elements)",children:[e.jsx(Os,{size:12}),e.jsx("span",{children:"Inspect"})]}),e.jsxs("button",{className:`omni-mode-btn ${P==="interact"?"active":""}`,onClick:()=>K("interact"),title:"Interaction mode (direct control)",children:[e.jsx(Us,{size:12}),e.jsx("span",{children:"Interact"})]})]})]}),e.jsxs("button",{className:"omni-refresh-btn",onClick:De,disabled:u,children:[e.jsx(lt,{size:12,className:u?"animate-spin":""}),u?"Capturing...":"Refresh"]})]}),e.jsxs("div",{className:"omni-screenshot-container",ref:We,children:[u&&!F&&e.jsxs("div",{className:"omni-loading-overlay",children:[e.jsx("div",{className:"omni-spinner"}),e.jsx("span",{children:"Capturing screen..."})]}),!i&&!u&&!F&&e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:40}),e.jsx("span",{children:"Click Refresh to capture"})]}),F&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx(rn,{ref:pt,src:n,onLoad:I,onError:Bt,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),Kt]}),!F&&(i==null?void 0:i.screenshot)&&e.jsxs("div",{className:`omni-screenshot-wrapper ${P==="interact"?"interactable":""}`,onMouseDown:G,onMouseUp:se,children:[e.jsx("img",{ref:Lt,src:`data:image/png;base64,${i.screenshot}`,onLoad:Ut,className:"omni-screenshot-img",style:P==="interact"?{pointerEvents:"none"}:{},draggable:!1}),P==="inspect"&&e.jsxs("div",{className:`omni-overlay${qt?" is-stale":""}`,children:[bs(i.hierarchy),js(),gt(w,"hover"),gt(f,"select")]})]})]})]}),e.jsxs("div",{className:"omni-split",ref:qe,children:[e.jsxs("div",{className:"omni-tree-panel",style:{flexBasis:`calc(${at*100}% - ${at*It}px)`},children:[e.jsxs("div",{className:"omni-tree-header",children:[e.jsxs("div",{className:"omni-tree-title",children:[e.jsx(un,{size:14}),e.jsx("span",{children:"Source"})]}),e.jsxs("div",{className:"omni-tree-actions",children:[e.jsx("button",{onClick:ie,className:"omni-action-btn",title:"Expand all","aria-label":"Expand all",children:e.jsx(Fa,{size:12})}),e.jsx("button",{onClick:xe,className:"omni-action-btn",title:"Collapse all","aria-label":"Collapse all",children:e.jsx(Oa,{size:12})}),a&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>K(P==="inspect"?"interact":"inspect"),className:`omni-action-btn ${P==="inspect"?"active":""}`,title:P==="inspect"?"Inspect mode — click the device to select an element":"Interact mode — clicks control the device","aria-label":P==="inspect"?"Inspect mode":"Interact mode","aria-pressed":P==="inspect",children:P==="inspect"?e.jsx(Os,{size:12}):e.jsx(Us,{size:12})}),e.jsx("button",{onClick:De,className:"omni-action-btn",title:u?"Capturing…":"Refresh snapshot","aria-label":"Refresh snapshot",disabled:u,children:e.jsx(lt,{size:12,className:u?"animate-spin":""})})]})]})]}),x&&!u&&e.jsxs("div",{className:"omni-tree-error",role:"alert",children:[e.jsx(Ze,{size:12}),e.jsx("span",{children:x}),e.jsx("button",{type:"button",onClick:De,className:"omni-tree-error-retry",children:"Retry"})]}),i&&!u&&!x&&(qt?e.jsxs("div",{className:"omni-capture-meta is-stale",role:"status",children:[e.jsx($e,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"The screen may have changed since this capture."}),e.jsx("button",{type:"button",onClick:De,className:"omni-capture-refresh",children:"Refresh"})]}):e.jsxs("div",{className:"omni-capture-meta",children:[e.jsxs("span",{children:[Wt," ",Wt===1?"element":"elements"]}),i.hierarchySource&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{className:"omni-capture-source",title:i.hierarchySource==="appium-session"?`From Appium session ${i.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:i.hierarchySource==="appium-session"?"Session":"Device"})]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:no(Q,ce)})]})),e.jsxs("div",{className:"omni-tree-search",children:[e.jsx(hs,{size:14}),e.jsx("input",{type:"text",placeholder:"Search elements",value:D,onChange:h=>gs(h.target.value),"aria-label":"Search elements"}),D&&e.jsx("button",{onClick:()=>gs(""),className:"omni-clear-btn","aria-label":"Clear search",children:"×"})]}),e.jsx("div",{role:"status",className:"sr-only",children:D.trim()?rt:""}),D.trim()&&e.jsxs("div",{className:"omni-search-hint",children:[rt," · try a role: button, input, image"]}),e.jsx("div",{className:"omni-tree-content",children:i!=null&&i.hierarchy?e.jsx(po,{rows:Ge,selectedXpath:(f==null?void 0:f.xpath)??null,hoveredXpath:(w==null?void 0:w.xpath)??null,matches:ze,onToggle:ye,onSelect:Ye,onHover:j,revealSeq:S}):e.jsx("div",{className:"omni-empty-state small",children:e.jsx("span",{children:"No hierarchy loaded"})})})]}),e.jsx(No,{share:at,limits:zn(yt),containerRef:qe,onChange:ft,onCommit:xt,onReset:()=>xt(Dt)}),e.jsxs("div",{className:"omni-details-panel",children:[e.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[e.jsxs("button",{className:`omni-details-tab ${V==="info"?"active":""}`,onClick:()=>q("info"),role:"tab","aria-selected":V==="info",children:[e.jsx(ii,{size:12})," ",e.jsx("span",{children:"Info"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="checks"?"active":""}`,onClick:()=>q("checks"),disabled:!f,title:"Checks for this element","aria-label":"Checks",role:"tab","aria-selected":V==="checks",children:[e.jsx(fa,{size:12})," ",e.jsx("span",{children:"Checks"})]}),e.jsxs("button",{className:`omni-details-tab ${V==="code"?"active":""}`,onClick:()=>q("code"),disabled:!f,title:"Generate test code","aria-label":"Code gen",role:"tab","aria-selected":V==="code",children:[e.jsx(Fs,{size:12})," ",e.jsx("span",{children:"Code gen"})]})]}),e.jsx("div",{className:"omni-details-content",children:f?e.jsxs(e.Fragment,{children:[V==="info"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Element info"}),e.jsxs("div",{className:"omni-info-table",children:[e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Type"}),e.jsx("span",{className:"omni-info-value mono",children:f.type})]}),f.text&&e.jsxs("div",{className:"omni-info-row",children:[e.jsx("span",{className:"omni-info-key",children:"Text"}),e.jsx("span",{className:"omni-info-value",children:f.text})]}),e.jsxs("div",{className:"omni-info-row omni-info-row--path",children:[e.jsx("span",{className:"omni-info-key",children:"Path"}),e.jsx(fo,{path:(i==null?void 0:i.hierarchy)&&Rt(i.hierarchy,f.xpath)||[f],onSelect:Vt,focusCurrent:L.current},f.xpath)]})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Layout"}),e.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>e.jsxs("div",{className:"omni-layout-item",children:[e.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),e.jsx("span",{className:"omni-layout-value",children:f.rect[h]})]},h))})]}),e.jsxs("div",{className:"omni-section",children:[e.jsxs("div",{className:"omni-section-header",children:["Locators",e.jsx("span",{className:"omni-section-badge",children:"Stability scored"})]}),!(Z!=null&&Z.sessionId)&&((Ss=f.suggestedLocators)==null?void 0:Ss.length)>0&&e.jsxs("p",{className:"omni-locators-note",children:[e.jsx(nn,{size:12,"aria-hidden":"true"}),"Verify and Tap need an Appium test running on this device. Start the test first, then open this page: while it’s open, the live preview holds the device and a new test can’t start."]}),e.jsxs("div",{className:"omni-locators-list",children:[!((Cs=f.suggestedLocators)!=null&&Cs.length)&&e.jsx("div",{className:"omni-locators-empty",children:f===(i==null?void 0:i.hierarchy)?"This is the XML document root, not a UI element — no Appium locator can select it. Pick a node beneath it.":"No locator could be derived for this node."}),($s=f.suggestedLocators)==null?void 0:$s.map(h=>{const g=ls(h.strategy,h.value),N=Hn[g.level],T=Ne[h.strategy];let z=null;return T&&(T.kind==="unsupported"?z=e.jsxs("span",{className:"omni-match-badge unsupported",title:T.reason||"Cannot evaluate without a real driver",children:[e.jsx(Ba,{size:10})," preview unavailable"]}):T.nodes.length===0?z=e.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[e.jsx(Ze,{size:10})," 0 matches"]}):T.nodes.length===1?z=e.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[e.jsx(Nt,{size:10})," unique"]}):z=e.jsxs("span",{className:"omni-match-badge multi",title:`${T.nodes.length} elements match — selector is not unique`,children:[e.jsx($e,{size:10})," ",T.nodes.length," matches"]})),e.jsx("div",{className:`omni-locator-row ${(de==null?void 0:de.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>fe(h),title:"Click to use in Code gen",children:e.jsxs("div",{className:"omni-locator-left",children:[e.jsxs("div",{className:"omni-locator-top",children:[e.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),e.jsxs("span",{className:`omni-stability-badge ${N.cls}`,title:g.reason,children:[N.icon,g.level]}),z]}),e.jsx("code",{className:"omni-locator-value",children:h.value}),e.jsx("span",{className:"omni-stability-reason",children:g.reason}),(()=>{const R=zt[h.strategy];return R?R.error?e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium error: ",R.error]}):R.found?R.count>1?e.jsxs("span",{className:"omni-verify-line is-warn",children:[e.jsx($e,{size:10})," Ambiguous — Appium found"," ",R.count," elements",R.actionError?` · ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-ok",children:[e.jsx(Nt,{size:10})," Appium found 1 element",R.elapsedMs!=null?` in ${R.elapsedMs}ms`:"",R.actionPerformed&&R.actionPerformed!=="none"?` · ${R.actionPerformed} ok`:"",R.actionError?` · action failed: ${R.actionError}`:""]}):e.jsxs("span",{className:"omni-verify-line is-error",children:[e.jsx(Ze,{size:10})," Appium found 0 elements"]}):null})(),e.jsxs("div",{className:"omni-locator-actions",children:[e.jsxs(Y,{type:"button",variant:Ee===h.strategy?"tonal":"secondary",size:"sm",onClick:R=>{R.stopPropagation(),Ft(h.strategy,h.value)},title:"Match against this capture and outline the result on the phone","aria-label":"Test locator",children:[e.jsx(Wa,{size:12,"aria-hidden":"true"}),"Test"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"none")},title:"Ask the Appium driver whether it finds this element","aria-label":"Verify with Appium",children:[He===h.strategy?e.jsx(lt,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(Nt,{size:12,"aria-hidden":"true"}),"Verify"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",disabled:!(Z!=null&&Z.sessionId)||He===h.strategy,onClick:R=>{R.stopPropagation(),vt(h.strategy,h.value,"tap")},title:"Find it with Appium and tap it on the phone","aria-label":"Find and tap with Appium",children:[e.jsx(hn,{size:12,"aria-hidden":"true"}),"Tap"]}),e.jsxs(Y,{type:"button",variant:"secondary",size:"sm",onClick:R=>{R.stopPropagation(),ne(h.value,h.strategy)},title:"Copy the locator's value","aria-label":O===h.strategy?"Copied":"Copy locator",children:[O===h.strategy?e.jsx(dt,{size:12,"aria-hidden":"true"}):e.jsx(Te,{size:12,"aria-hidden":"true"}),O===h.strategy?"Copied":"Copy"]})]})]})},h.strategy)})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Attributes"}),e.jsx("div",{className:"omni-attributes-table",children:Object.entries(f.attributes||{}).filter(([h,g])=>g!=null&&g!=="").map(([h,g])=>e.jsxs("div",{className:"omni-attr-row",children:[e.jsx("span",{className:"omni-attr-key",children:h}),e.jsx("span",{className:"omni-attr-value",children:String(g)})]},h))})]})]}),V==="checks"&&bt&&Le&&e.jsxs("div",{className:"omni-checks-panel",children:[e.jsxs("p",{className:"omni-checks-summary",children:[e.jsxs("span",{className:"is-pass",children:[e.jsx(mn,{size:12,"aria-hidden":"true"})," ",Le.pass," passed"]}),Le.warn>0&&e.jsxs("span",{className:"is-warn",children:[e.jsx($e,{size:12,"aria-hidden":"true"})," ",Le.warn," ",Le.warn===1?"warning":"warnings"]}),Le.fail>0&&e.jsxs("span",{className:"is-fail",children:[e.jsx(pn,{size:12,"aria-hidden":"true"})," ",Le.fail," failed"]})]}),e.jsx("ul",{className:"omni-checks-list",children:bt.map(h=>e.jsxs("li",{className:`omni-check is-${h.status}`,children:[e.jsx("span",{className:"omni-check-icon","aria-hidden":"true",children:ko[h.status]}),e.jsxs("div",{className:"omni-check-body",children:[e.jsxs("div",{className:"omni-check-label",children:[h.label,e.jsxs("span",{className:"sr-only",children:[": ",wo[h.status]]})]}),e.jsx("div",{className:"omni-check-detail",children:h.detail})]})]},h.id))})]}),V==="code"&&e.jsxs("div",{className:"omni-codegen-panel",children:[e.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>e.jsx("button",{className:`omni-fw-btn ${le===h?"active":""}`,onClick:()=>ue(h),children:So[h]},h))}),de?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"omni-codegen-locator-selector",children:[e.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),e.jsx(ms,{selectSize:"sm",value:de.strategy,onChange:h=>{var N;const g=(N=f.suggestedLocators)==null?void 0:N.find(T=>T.strategy===h.target.value);g&&fe(g)},className:"flex-1",children:(Ts=f.suggestedLocators)==null?void 0:Ts.map(h=>e.jsxs("option",{value:h.strategy,children:[h.strategy," — ",ls(h.strategy,h.value).level]},h.strategy))})]}),e.jsxs("div",{className:"omni-codegen-output",children:[e.jsxs("div",{className:"omni-codegen-header",children:[e.jsx("span",{className:"omni-codegen-lang",children:le==="java"?"Java / TestNG":le==="python"?"Python / unittest":le==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),e.jsx("button",{className:"omni-copy-btn",onClick:()=>ne(Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de),"code"),children:O==="code"?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]}),e.jsx("pre",{className:"omni-codegen-pre theme-dark",children:e.jsx("code",{children:Xs(f,(i==null?void 0:i.platform)==="android"?"android":(i==null?void 0:i.platform)==="ios"?"ios":"unknown",le,de)})})]})]}):e.jsxs("div",{className:"omni-empty-state small",children:[e.jsx(Fs,{size:24}),e.jsx("span",{children:"No locators available for this element"})]})]})]}):i!=null&&i.hierarchy?e.jsxs("div",{className:"omni-summary-panel",children:[e.jsxs("div",{className:"omni-summary-hero",children:[e.jsx(Zt,{size:28}),e.jsxs("div",{children:[e.jsx("div",{className:"omni-summary-title",children:"No element selected"}),e.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"Snapshot stats"}),e.jsxs("div",{className:"omni-summary-stats",children:[e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),e.jsx("span",{className:"omni-summary-stat__value",children:Wt})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ks=i.metadata)==null?void 0:ks.screenWidth)??ee.width??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),e.jsx("span",{className:"omni-summary-stat__value",children:((ws=i.metadata)==null?void 0:ws.screenHeight)??ee.height??"—"})]}),e.jsxs("div",{className:"omni-summary-stat",children:[e.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),e.jsx("span",{className:"omni-summary-stat__value",children:i.platform||"—"})]})]})]}),Ns.length>0&&e.jsxs("div",{className:"omni-section",children:[e.jsx("div",{className:"omni-section-header",children:"By role"}),e.jsx("div",{className:"omni-summary-roles",children:Ns.slice(0,8).map(h=>e.jsxs("div",{className:"omni-summary-role",children:[e.jsx("span",{className:"omni-summary-role__icon","aria-hidden":"true",children:An[h.key]}),e.jsx("span",{className:"omni-summary-role__name",children:h.role}),e.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):e.jsxs("div",{className:"omni-empty-state",children:[e.jsx(Zt,{size:32}),e.jsx("span",{children:u?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})]})},Gs=5e3;function $o(t,s=!0){const[n,a]=c.useState("unknown"),o=c.useRef("unknown");return c.useEffect(()=>{if(!t||!s){a("unknown"),o.current="unknown";return}let r=!1,l;const u=m=>{r||m===o.current||(o.current=m,a(m))},d=async()=>{if(!r){if(l&&(clearTimeout(l),l=void 0),typeof document<"u"&&document.visibilityState==="hidden"){l=setTimeout(d,Gs);return}try{const m=await M.getDisplayState(t);u((m==null?void 0:m.state)??"unknown")}catch{}r||(l=setTimeout(d,Gs))}};d();const i=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",i),()=>{r=!0,l&&clearTimeout(l),document.removeEventListener("visibilitychange",i)}},[t,s]),n}function To(t,s){const n=c.useRef(t),a=c.useRef(s);n.current=t,a.current=s,c.useEffect(()=>{const o=()=>n.current(),r=l=>{var u;l.persisted&&((u=a.current)==null||u.call(a))};return window.addEventListener("pagehide",o),window.addEventListener("pageshow",r),()=>{window.removeEventListener("pagehide",o),window.removeEventListener("pageshow",r)}},[])}const Ys=5e3,Ro=500,Ao=1e4,Eo=10,Do=50;function Io(t,s,n){const a=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[o,r]=c.useState([]),[l,u]=c.useState(!1),[d,i]=c.useState(null),[m,x]=c.useState(!1),k=c.useRef(null),f=c.useRef(0),y=c.useRef(void 0),S=c.useRef(()=>{}),C=c.useRef([]),L=c.useRef(void 0),w=c.useRef(0),j=c.useRef(void 0),$=c.useCallback(()=>{if(C.current.length===0)return;const O=C.current;C.current=[],r(W=>{const V=W.concat(O);return V.length>Ys?V.slice(-Ys):V})},[]),p=c.useCallback(()=>{L.current===void 0&&(L.current=window.setTimeout(()=>{L.current=void 0,$()},Do))},[$]),D=c.useCallback(()=>{C.current=[],r([])},[]);c.useEffect(()=>{if(!s){u(!1),i(null),x(!1);return}i(null),x(!1),f.current=0;const O={cancelled:!1},W=()=>{if(O.cancelled)return;if(f.current>=Eo){x(!0);return}const q=Math.min(Ro*2**f.current,Ao);f.current+=1,y.current=window.setTimeout(V,q)},V=async()=>{if(!O.cancelled)try{const q=await fetch(`/xenon/api/control/${encodeURIComponent(t)}/stream/ticket`,{method:"POST",credentials:"include"});if(O.cancelled)return;if(!q.ok){W();return}const{ticket:Q}=await q.json();if(O.cancelled)return;if(!Q){W();return}const b=window.location.protocol==="https:"?"wss":"ws",[oe,te]=a.split("|"),ce=(oe?`&levels=${encodeURIComponent(oe)}`:"")+(te?`&process=${encodeURIComponent(te)}`:""),B=new WebSocket(`${b}://${window.location.host}/xenon/api/control/${encodeURIComponent(t)}/logcat?ticket=${encodeURIComponent(Q)}${ce}`);k.current=B,B.onopen=()=>{f.current=0,j.current!==1012&&(C.current=[],r([])),j.current=void 0,u(!0)},B.onmessage=E=>{try{const J=JSON.parse(E.data);C.current.push({...J,seq:w.current++}),p()}catch{}},B.onclose=E=>{if(u(!1),j.current=E.code,$(),E.code===1008){O.cancelled=!0,i(E.reason||"access denied");return}if(E.code===1012){W();return}console.warn(`[logcat] WS closed unexpectedly (code ${E.code}) — retrying`),W()},B.onerror=()=>B.close()}catch{W()}};return S.current=()=>{O.cancelled=!1,f.current=0,i(null),x(!1),V()},V(),()=>{var q;O.cancelled=!0,y.current!==void 0&&window.clearTimeout(y.current),L.current!==void 0&&(window.clearTimeout(L.current),L.current=void 0),$(),(q=k.current)==null||q.close(),k.current=null}},[t,s,a,$,p]);const A=c.useCallback(()=>{S.current()},[]);return{records:o,connected:l,clear:D,deniedReason:d,exhausted:m,retry:A}}const ds=["V","D","I","W","E","F"];function Mo(t){const s=[];let n="",a=!1,o=!1;for(const r of t){if(r==='"'){a=!a,o=!0;continue}if(!a&&/\s/.test(r)){(o||n)&&s.push(n),n="",o=!1;continue}n+=r,o=!0}return(o||n)&&s.push(n),s.filter(r=>r.length>0)}function Ln(t,s={}){const n=s.caseSensitive===!0,a=l=>n?l:l.toLowerCase(),o=n?{caseSensitive:!0}:{},r=[];for(const l of Mo(t)){const[u,...d]=l.split(":"),i=d.join(":");i&&u.toLowerCase()==="level"?o.minLevel=i.toUpperCase():i&&u.toLowerCase()==="tag"?o.tag=a(i):i&&u.toLowerCase()==="package"?o.pkg=a(i):r.push(l)}return r.length&&(o.text=a(r.join(" "))),o}function _o(t,s){if(t.synthetic)return!0;if(s.minLevel){const a=ds.indexOf(s.minLevel),o=ds.indexOf(t.level);if(a>=0&&o>=0&&o<a)return!1}const n=a=>s.caseSensitive?a:a.toLowerCase();return!(s.tag&&!n(t.tag).includes(s.tag)||s.pkg&&!n(t.pkg??"").includes(s.pkg)||s.text&&!n(t.message).includes(s.text))}function zo(t,s){const n=t.trim().split(/\s+/).filter(Boolean).filter(a=>{const[o,...r]=a.split(":");return!(r.join(":")&&o.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const ss=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],Zs=["V","D","I","W","E","F"];function Lo(t){if(!t)return ss.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=Zs.indexOf(t.toUpperCase());return s<0?ss.map(n=>n.ios):ss.filter(n=>Zs.indexOf(n.android)>=s).map(n=>n.ios)}function Oo(t){const s=Ln(t,{caseSensitive:!0});return{levels:Lo(s.minLevel),process:s.pkg||void 0}}const Js=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Po(t){let s=2166136261;for(let n=0;n<t.length;n++)s^=t.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function Fo(t){return t?Js[Po(t)%Js.length]:"var(--text-muted)"}const us=5e5;function On(t){return`${new Date(t.ts).toISOString()} ${t.pid} ${t.level}/${t.tag}: ${t.message}`}function Uo(t){return{lines:[],startedAt:t,dropped:0}}function Bo(t,s){for(const n of s){if(t.lines.length>=us){t.dropped+=1;continue}t.lines.push(On(n))}return t}function Vo(t,s,n){const a=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(t.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-t.startedAt)/1e3).toFixed(1)}s`,`# lines: ${t.lines.length}`];t.dropped>0&&a.push(`# TRUNCATED: ${t.dropped} further line(s) were dropped after the ${us}-line cap. This capture is INCOMPLETE.`);const o=t.lines.join(`
261
261
  `),r=t.dropped>0?`
262
262
  # --- TRUNCATED: ${t.dropped} line(s) not captured (cap ${us}) ---`:"";return`${a.join(`
263
263
  `)}
264
264
 
265
265
  ${o}${r}
266
266
  `}function Ho(t,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${t}-${n}.txt`}const Qs=ds.filter(t=>t!=="V").map(t=>({value:t,label:t==="F"?"F only":`${t} and above`})),Wo=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function en(t,s){const n=URL.createObjectURL(new Blob([t],{type:"text/plain"})),a=document.createElement("a");a.href=n,a.download=s,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),setTimeout(()=>URL.revokeObjectURL(n),0)}const qo=c.memo(function({record:s,index:n,isHit:a,isActiveHit:o}){return e.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${a?"is-hit":""} ${o?"is-active-hit":""}`,children:[e.jsx("span",{className:"logcat-time",children:Wo.format(s.ts)}),e.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),e.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:Fo(s.tag)},children:s.tag}),e.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),e.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),e.jsx("span",{className:"logcat-msg",children:s.message})]})});function Ko({udid:t,platform:s}){const n=(s||"").toLowerCase(),a=n==="ios",o=n==="android"||a,[r,l]=c.useState(""),u=c.useMemo(()=>a?Oo(r):void 0,[a,r]),{records:d,connected:i,clear:m,deniedReason:x,exhausted:k,retry:f}=Io(t,o,u),[y,S]=c.useState(!0),[C,L]=c.useState(!1),[w,j]=c.useState(!0),[$,p]=c.useState(""),[D,A]=c.useState(0),O=c.useRef(null),W=c.useRef(null),V=c.useRef(null),[q,Q]=c.useState(!1),[b,oe]=c.useState(0),te=c.useRef(-1),ce=c.useMemo(()=>Ln(r,{caseSensitive:C}),[r,C]),B=c.useMemo(()=>d.filter(_=>_o(_,ce)),[d,ce]),E=c.useMemo(()=>{if(!$)return[];const _=C?$:$.toLowerCase(),v=[];return B.forEach((H,P)=>{(C?`${H.tag} ${H.message}`:`${H.tag} ${H.message}`.toLowerCase()).includes(_)&&v.push(P)}),v},[B,$,C]),J=E.length?Math.min(D,E.length-1):0,le=c.useMemo(()=>new Set(E),[E]),ue=c.useCallback(_=>{var H,P;if(!E.length)return;const v=(J+_+E.length)%E.length;A(v),S(!1),(P=(H=W.current)==null?void 0:H.querySelector(`[data-row-index="${E[v]}"]`))==null||P.scrollIntoView({block:"center"})},[E,J]),de=Qs.some(_=>_.value===ce.minLevel)?ce.minLevel:"",fe=c.useCallback(()=>{en(B.map(On).join(`
267
- `),`logcat-${t}-${Date.now()}.txt`)},[B,t]);c.useEffect(()=>{const _=V.current;if(!_||!d.length)return;const v=d.filter(P=>P.seq>te.current);if(!v.length)return;const H=te.current+1;te.current>=0&&v[0].seq>H&&(_.dropped+=v[0].seq-H),Bo(_,v),te.current=v[v.length-1].seq,oe(_.lines.length)},[d]);const ee=c.useCallback(()=>{const _=V.current;if(!_){te.current=d.length?d[d.length-1].seq:-1,V.current=Uo(Date.now()),oe(0),Q(!0);return}const v=Vo(_,Date.now(),t);V.current=null,Q(!1),oe(0),en(v,Ho(t,_.startedAt))},[d,t]);if(c.useEffect(()=>{var _;y&&((_=O.current)==null||_.scrollIntoView({block:"end"}))},[B.length,y]),!o)return e.jsxs("div",{className:"log-empty-state",children:[e.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),e.jsx("p",{className:"log-empty-subtitle",children:"Streaming is wired up for Android (logcat) and iOS (os_trace), not for this device's platform."})]});const ge=x?"Denied":k?"Offline":i?"Live":"Connecting",be=!i&&(!!x||k);return e.jsxs("div",{className:"logcat-root",children:[e.jsxs("div",{className:"log-toolbar",children:[e.jsxs("div",{className:"log-filter-group",children:[e.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[e.jsx("span",{className:`log-live-dot ${i?"active":""} ${be?"is-error":""}`}),ge]}),e.jsxs("div",{className:"log-stat-pill logcat-count",children:[B.length," / ",d.length]}),e.jsxs(ms,{selectSize:"sm",value:de,onChange:_=>l(zo(r,_.target.value)),"aria-label":"Minimum log level",children:[e.jsx("option",{value:"",children:"All levels"}),Qs.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:r,onChange:_=>l(_.target.value),"aria-label":"Filter logs"}),r&&e.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>l(""),"aria-label":"Clear filter",title:"Clear filter",children:e.jsx(sn,{size:12})})]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:$,onChange:_=>{p(_.target.value),A(0)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),ue(_.shiftKey?-1:1))},"aria-label":"Find in logs"}),$&&e.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:E.length?`${J+1}/${E.length}`:"0/0"})]}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(-1),disabled:!E.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:e.jsx(ys,{size:14})}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(1),disabled:!E.length,"aria-label":"Next match",title:"Next match (Enter)",children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>L(!C),"aria-pressed":C,"aria-label":"Match case",title:"Match case",children:e.jsx(za,{size:15})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${w?"active":""}`,onClick:()=>j(!w),"aria-pressed":w,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:e.jsx(Ri,{size:14})})]}),e.jsxs("div",{className:"log-actions-group",children:[(x||k)&&e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:f,children:[e.jsx(lt,{size:14})," RECONNECT"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${y?"active":""}`,onClick:()=>S(!y),children:[e.jsx(Bi,{size:14})," ",y?"FREEZE":"FOLLOW"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${q?"is-recording":""}`,onClick:ee,"aria-pressed":q,title:q?"Stop recording and download the capture":"Record the raw log stream to a file",children:[q?e.jsx(on,{size:12}):e.jsx(aa,{size:12})," ",q?`STOP · ${b.toLocaleString()}`:"RECORD"]}),e.jsxs("button",{className:"btn-premium btn-sm",disabled:B.length===0,onClick:fe,children:[e.jsx(xa,{size:14})," EXPORT"]}),e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:m,children:[e.jsx(as,{size:14})," CLEAR"]})]})]}),e.jsxs("div",{className:`logcat-rows theme-dark ${w?"":"no-wrap"}`,ref:W,children:[x&&e.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[e.jsx($e,{size:14}),e.jsxs("span",{children:["Access denied — ",x]})]}),!x&&k&&e.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[e.jsx($e,{size:14}),e.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),B.map((_,v)=>e.jsx(qo,{record:_,index:v,isHit:le.has(v),isActiveHit:E.length>0&&E[J]===v},_.seq)),e.jsx("div",{ref:O})]})]})}function Pn(t){const s=t==null?void 0:t.message;return typeof s=="string"?s.trim():""}function Be(t,s){const n=Pn(s);return n?`Couldn’t ${t}: ${n}`:`Couldn’t ${t}.`}function Xo(t,s){return t==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Be("read the clipboard",s)}function Go(t,s){const n=s.trim().toLowerCase();return[...t].sort((a,o)=>a.localeCompare(o)).filter(a=>!n||a.toLowerCase().includes(n))}const Yo=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Zo(t){return Yo.test(t.trim())}function vs(t){const s=(t||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Jo(t,s){const n=vs(s);return n?t.filter(a=>(a.platform||"").toLowerCase()===n):[]}function Qo(t){return[t.version,t.packageName].filter(Boolean).join(" · ")}function ec(t){return vs(t)==="android"?"Android":"iOS"}function tc(t){return vs(t)==="android"?".apk":".ipa,.app"}const Fn="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Un(t){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(t),!0):!1}catch{return!1}}function sc({udid:t,platform:s,deviceName:n}){const{toast:a,removeToast:o}=Ve(),r=mt(),[l,u]=c.useState([]),[d,i]=c.useState("loading"),[m,x]=c.useState(""),[k,f]=c.useState(""),[y,S]=c.useState(!1),[C,L]=c.useState(!1),[w,j]=c.useState([]),[$,p]=c.useState("loading"),[D,A]=c.useState(null),[O,W]=c.useState(null),V=c.useRef(null),q=c.useRef(null),Q=c.useRef(null),b=c.useCallback(async()=>{i("loading");try{const v=await M.listApps(t);u(Array.isArray(v)?v:[]),i("ready")}catch(v){x(Pn(v)),i("error")}},[t]);c.useEffect(()=>{b()},[b]);const oe=v=>setTimeout(b,v);c.useEffect(()=>{if(!O)return;const v=setTimeout(()=>W(null),1500);return()=>clearTimeout(v)},[O]);const te=async()=>{p("loading");try{const v=await M.getApps();j(Array.isArray(v)?v:[]),p("ready")}catch{p("error")}},ce=()=>{y||(L(!0),te())},B=()=>{var v;L(!1),(v=V.current)==null||v.focus()};c.useEffect(()=>{var H;if(!C||$==="loading")return;const v=(H=q.current)==null?void 0:H.querySelector('[role="menuitem"]:not(:disabled)');v==null||v.focus()},[C,$]);const E=async(v,H)=>{S(!0);const P=a(`Installing ${v} on ${n}…`,"loading",0);try{const K=await H();K!=null&&K.success?(a(`Installed ${v} on ${n}`,"success"),oe(5e3)):a(Be(`install ${v}`,{message:K==null?void 0:K.error}),"error")}catch(K){a(Be(`install ${v}`,K),"error")}finally{o(P),S(!1)}},J=v=>{B(),E(v.name,()=>M.installRepositoryApp(t,v.id))},le=v=>{var P;const H=(P=v.target.files)==null?void 0:P[0];v.target.value="",H&&E(H.name,()=>M.uploadAndInstallApp(t,H))},ue=async()=>{const v=D;if(A(null),!v)return;const H=a(`Uninstalling ${v} from ${n}…`,"loading",0);try{await M.uninstallApp(t,v),a(`Uninstalled ${v} from ${n}`,"success"),oe(3e3)}catch(P){a(Be(`uninstall ${v}`,P),"error")}finally{o(H)}},de=async(v,H)=>{var K,Ne;if(await Un(v)){W(v);return}const P=(K=H.closest("li"))==null?void 0:K.querySelector(".actions-app-id");P&&((Ne=window.getSelection())==null||Ne.selectAllChildren(P)),a(Fn,"info")},fe=Go(l,k),ee=k.trim(),ge=d==="ready"&&fe.length===0&&Zo(ee)&&!l.includes(ee),be=Jo(w,s),_=(v,H)=>e.jsxs("li",{className:"actions-app-row",children:[e.jsx("span",{className:"actions-app-id",children:v}),H&&e.jsx("span",{className:"actions-app-note",children:H}),e.jsxs("span",{className:"actions-app-tools",children:[e.jsx(Y,{variant:"ghost",size:"icon","aria-label":O===v?"Copied":`Copy ${v}`,title:O===v?"Copied":"Copy package ID",onClick:P=>de(v,P.currentTarget),children:O===v?e.jsx(dt,{size:13,"aria-hidden":"true"}):e.jsx(Te,{size:13,"aria-hidden":"true"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${v}`,onClick:()=>A(v),children:"Uninstall"})]})]},v);return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[e.jsxs("div",{className:"actions-section-head",children:[e.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[e.jsx(mi,{size:15,"aria-hidden":"true"})," Apps"]}),e.jsxs("div",{className:"actions-section-tools",children:[e.jsxs(Y,{ref:V,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":y||void 0,onClick:ce,children:[y?e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):e.jsx(ti,{size:13,"aria-hidden":"true"}),"Install from library"]}),e.jsxs(Y,{variant:"secondary",size:"sm","aria-disabled":y||void 0,onClick:()=>{var v;return!y&&((v=Q.current)==null?void 0:v.click())},children:[e.jsx(va,{size:13,"aria-hidden":"true"})," Upload file"]}),e.jsx("input",{ref:Q,type:"file",hidden:!0,"aria-label":"App file to upload",accept:tc(s),onChange:le})]})]}),e.jsx(cn,{open:C,onClose:B,anchorRef:V,placement:"bottom-end",children:e.jsx("div",{ref:q,className:"actions-library-menu",children:e.jsxs(ln,{children:[$==="loading"&&e.jsx(pe,{disabled:!0,onClick:()=>{},children:"Loading…"}),$==="error"&&e.jsx(pe,{onClick:te,children:"Couldn’t load the library. Retry"}),$==="ready"&&be.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs(pe,{disabled:!0,onClick:()=>{},children:["No ",ec(s)," apps in the library yet"]}),e.jsx(pe,{onClick:()=>r("/apps"),children:"Open the Apps library"})]}),$==="ready"&&be.map(v=>e.jsx(pe,{note:Qo(v)||void 0,onClick:()=>J(v),children:v.name},v.id))]})})}),e.jsxs("div",{className:"actions-apps-tools",children:[e.jsxs("div",{className:"actions-search",children:[e.jsx(hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${l.length} installed apps`,value:k,onChange:v=>f(v.target.value)})]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:b,children:e.jsx(St,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&e.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",m?`: ${m}`:".",e.jsx(Y,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),d==="ready"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&l.length>0&&fe.length===0&&!ge&&e.jsxs("p",{className:"actions-list-note",children:["No apps match “",ee,"”"]}),e.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[fe.map(v=>_(v)),ge&&_(ee,"Not in the list")]}),e.jsx(ps,{open:D!==null,title:"Uninstall app?",onClose:()=>A(null),footer:e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",onClick:()=>A(null),children:"Cancel"}),e.jsx(Y,{variant:"danger",onClick:ue,children:"Uninstall"})]}),children:e.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",e.jsx("code",{children:D})," from"," ",e.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const nc=[{direction:"up",Icon:ys},{direction:"down",Icon:fs},{direction:"left",Icon:ba},{direction:"right",Icon:ja}];function ac({onSwipe:t}){return e.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[e.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[e.jsx(Ga,{size:15,"aria-hidden":"true"})," Swipe"]}),e.jsx("div",{className:"actions-swipe-buttons",children:nc.map(({direction:s,Icon:n})=>e.jsx(Y,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>t(s),children:e.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function ic(t,s,n){const a=s/2,o=n/2,r=s*.4,l=n*.4,[u,d,i,m]={up:[a,o+l,a,o-l],down:[a,o-l,a,o+l],left:[a+r,o,a-r,o],right:[a-r,o,a+r,o]}[t].map(Math.round);return{startX:u,startY:d,endX:i,endY:m}}function rc({udid:t,platform:s}){const n=s!=="android",{toast:a}=Ve(),[o,r]=c.useState(""),[l,u]=c.useState(!1),[d,i]=c.useState(""),[m,x]=c.useState(null),[k,f]=c.useState(""),[y,S]=c.useState(!1),C=c.useRef(null);c.useEffect(()=>{if(!k)return;const p=setTimeout(()=>f(""),2e3);return()=>clearTimeout(p)},[k]),c.useEffect(()=>{if(!y)return;const p=setTimeout(()=>S(!1),1500);return()=>clearTimeout(p)},[y]);const L=async()=>{if(!(!o.trim()||l)){u(!0);try{await M.typeText(t,o),r(""),f("Sent")}catch(p){a(Be("send the text",p),"error")}finally{u(!1)}}},w=async()=>{x("read");try{const p=await M.getClipboard(t),D=typeof(p==null?void 0:p.content)=="string"?p.content:"";i(D),D||f("The device clipboard is empty")}catch(p){a(Xo(s,p),"error")}finally{x(null)}},j=async()=>{if(d){x("write");try{await M.setClipboard(t,d),f("Written to the device")}catch(p){a(Be("write the clipboard",p),"error")}finally{x(null)}}},$=async()=>{var p;if(await Un(d)){S(!0);return}(p=C.current)==null||p.select(),a(Fn,"info")};return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[e.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[e.jsx(Qa,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),e.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:o,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&L()}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:L,disabled:!o.trim()||l,children:[l&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),e.jsx("input",{id:"actions-clipboard",ref:C,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:d,onChange:p=>i(p.target.value)}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:w,disabled:m!==null,children:[m==="read"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&e.jsxs(Y,{variant:"secondary",size:"md",onClick:j,disabled:!d||m!==null,children:[m==="write"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":y?"Copied":"Copy clipboard text",title:y?"Copied":"Copy to your clipboard",onClick:$,disabled:!d,children:y?e.jsx(dt,{size:14,"aria-hidden":"true"}):e.jsx(Te,{size:14,"aria-hidden":"true"})})]}),!n&&e.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),e.jsx("p",{className:"actions-status",role:"status",children:k})]})}function oc({udid:t,platform:s,deviceName:n,screenWidth:a,screenHeight:o}){const{toast:r}=Ve(),l=async u=>{const d=ic(u,a,o);try{await M.swipe(t,d.startX,d.startY,d.endX,d.endY)}catch(i){r(Be(`swipe ${u}`,i),"error")}};return e.jsxs("div",{className:"actions-panel",children:[e.jsx(sc,{udid:t,platform:s,deviceName:n}),e.jsx(rc,{udid:t,platform:s}),e.jsx(ac,{onSwipe:l})]})}function cc({device:t,onClose:s,titleId:n}){const{toast:a}=Ve(),o=mt(),{tab:r}=an(),l=Mt(),u=c.useRef(null),[d,i]=c.useState({width:0,height:0}),[m,x]=c.useState("inspect"),[k,f]=c.useState(null),[y,S]=c.useState(r||"actions"),C=y==="omni"&&m==="inspect",[L,w]=c.useState(!0),[j,$]=c.useState([]),[p,D]=c.useState(null),[A,O]=c.useState(!1),[W,V]=c.useState(!1),[q,Q]=c.useState(0),[b,oe]=c.useState(t),[te,ce]=c.useState(0),B=c.useCallback(()=>ce(Date.now()),[]),E=Me(b);c.useEffect(()=>{Gn(b.udid,E),document.title=Yn(l.pathname)},[b.udid,E,l.pathname]);const[J,le]=c.useState(!1),[ue,de]=c.useState(!1),fe=10,[ee,ge]=c.useState(!1),[be,_]=c.useState(!1),v=$o(b==null?void 0:b.udid,!ue),H=()=>{navigator.clipboard.writeText(b.udid).catch(()=>{}),ge(!0),setTimeout(()=>ge(!1),1500)},P=c.useRef(""),K=c.useRef(null),[Ne,tt]=c.useState(!1);c.useEffect(()=>{y&&(!r||r!==y)&&o(`/devices/${t.udid}/control/${y}${l.search}`,{replace:!0})},[y,r,t.udid,o,l.search]);const[zt,st]=c.useState(0);To(()=>{M.leaveStream(b.udid).catch(()=>{})},()=>st(I=>I+1)),c.useEffect(()=>((async()=>{try{V(!0),await M.startStream(b.udid);const G=(await M.getDevices()).find(se=>se.udid===b.udid);G&&oe(G)}catch(F){console.error("Auto-start stream failed:",F)}finally{V(!1)}})(),()=>{M.leaveStream(b.udid).catch(()=>{})}),[t.udid,zt]);const He=parseInt(b.screenWidth||"1080",10),nt=parseInt(b.screenHeight||"1920",10),Z=Math.min(He,nt),ke=Math.max(He,nt),Ee=Z/ke,_e=c.useCallback(()=>{const I=!L,F=I?window.innerHeight*.55:window.innerHeight*.7,G=620,ye=window.innerWidth>900;let ie;I?ie=ye?Math.min(window.innerWidth*.8,window.innerWidth-G):window.innerWidth*.8:ie=window.innerWidth*.45;const xe=L?Ee:1/Ee;let ne,ae;L?(ne=F,ae=ne*xe,ae>ie&&(ae=ie,ne=ae/xe)):(ae=ie,ne=ae/xe,ne>F&&(ne=F,ae=ne*xe)),i({width:ae,height:ne})},[Ee,L]);c.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),c.useEffect(()=>{const I=async()=>{if(P.current.length>0){const G=P.current;P.current="";try{await M.typeText(b.udid,G)}catch(se){console.error("Keyboard buffering flush failed:",se)}finally{B()}}},F=G=>{const se=document.activeElement;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||!Ne&&y!=="terminal")return;const ie=G.key;ie==="Enter"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?66:"enter").finally(B)):ie==="Backspace"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?67:"backspace").finally(B)):ie.length===1&&(P.current+=ie,K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{I()},50))};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),K.current&&clearTimeout(K.current)}},[b.udid,b.platform,Ne,y,B]);const[We,Lt]=c.useState(Date.now()),pt=()=>{const I=q>0?`r=${q}&`:"";return b.session_id&&!String(b.session_id).startsWith("manual_")?`/xenon/api/session/${b.session_id}/live_video?${I}t=${We}`:`/xenon/api/control/${b.udid}/stream?${I}t=${We}`};c.useEffect(()=>{q>0&&Lt(Date.now())},[q]),c.useEffect(()=>{if(J||ue)return;const I=setTimeout(()=>de(!0),3e4);return()=>clearTimeout(I)},[J,ue,q]);const we=c.useRef(null),qe=I=>{const F=I.currentTarget.getBoundingClientRect();return{x:I.clientX-F.left,y:I.clientY-F.top}},Ot=I=>{const F=qe(I);we.current={x:F.x,y:F.y,time:Date.now()}},ft=async I=>{var Ye;if(!we.current)return;const F=we.current,G=qe(I),se=Date.now()-F.time,ye=(Ye=u.current)==null?void 0:Ye.getBoundingClientRect(),ie=(ye==null?void 0:ye.width)||d.width,xe=(ye==null?void 0:ye.height)||d.height;let ne,ae,Xe,Ge;L?(ne=F.x/ie*Z,ae=F.y/xe*ke,Xe=G.x/ie*Z,Ge=G.y/xe*ke):(ne=F.x/ie*ke,ae=F.y/xe*Z,Xe=G.x/ie*ke,Ge=G.y/xe*Z);const ze=Math.abs(Xe-ne),rt=Math.abs(Ge-ae);try{se<500&&ze<10&&rt<10?await M.tap(b.udid,Math.round(ne),Math.round(ae)):se>=500&&ze<10&&rt<10?await M.touchAndHold(b.udid,Math.round(ne),Math.round(ae),se):await M.swipe(b.udid,Math.round(ne),Math.round(ae),Math.round(Xe),Math.round(Ge))}catch(Vt){console.error("Action failed:",Vt)}finally{B()}we.current=null},yt=()=>M.pressKey(b.udid,b.platform==="android"?ot.HOME:Yt.HOME).finally(B),Pt=()=>M.pressKey(b.udid,ot.BACK).finally(B),at=()=>M.pressKey(b.udid,ot.APP_SWITCH).finally(B),xt=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_UP:Yt.VOLUME_UP).finally(B),Ke=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_DOWN:Yt.VOLUME_DOWN).finally(B),vt=()=>M.lock(b.udid).finally(B),it=async()=>{_(!0);try{await M.unlock(b.udid)}finally{B(),setTimeout(()=>_(!1),2500)}},Ft=async()=>{O(!0);try{const I=await M.getScreenshot(b.udid);if(I!=null&&I.screenshot){const F={id:Pr(),base64:I.screenshot,timestamp:Date.now()};$(G=>[F,...G]),D(0)}}catch(I){console.error("Failed to take screenshot:",I)}finally{O(!1)}},De=I=>{$(F=>{const G=F.filter(se=>se.id!==I);return G.length===0?D(null):p!==null&&p>=G.length&&D(0),G})},Ut=()=>{$([]),D(null),a("Cleared all captured evidence.","success")},Bt=I=>{const F=document.createElement("a");F.href=`data:image/png;base64,${I}`,F.download=`screenshot-${b.udid}-${Date.now()}.png`,F.click()};return e.jsxs("div",{className:"device-control-view",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"control-view-top-bar",children:[e.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[e.jsx(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(rn,{src:pt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>le(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),le(!1),q>=fe){de(!0);return}setTimeout(()=>Q(I=>I+1),2e3)}}),v==="off"&&!ue&&e.jsxs("div",{className:"device-screen-off",role:"status",children:[e.jsx(li,{size:32}),e.jsx("p",{children:"Display is off"}),e.jsx("span",{children:"The stream is fine — the device is asleep."}),e.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:it,disabled:be,children:be?"Waking…":"Wake device"})]})]})}),e.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":L?"vertical":"horizontal",children:[e.jsx("button",{className:`footer-action-btn ${L?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":L,children:e.jsx(gi,{size:18})}),e.jsx("button",{className:`footer-action-btn ${L?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!L,children:e.jsx(xi,{size:18})}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:e.jsx(ia,{size:18})}),b.platform==="android"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"footer-action-btn",onClick:Pt,title:"Back","aria-label":"Back",children:e.jsx(Os,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:at,title:"App switcher","aria-label":"App switcher",children:e.jsx(on,{size:18})})]}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume up","aria-label":"Volume up",children:e.jsx(Fi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume down","aria-label":"Volume down",children:e.jsx(Oi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:vt,title:"Lock device","aria-label":"Lock device",children:e.jsx(Na,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:it,title:"Unlock device","aria-label":"Unlock device",children:e.jsx(ni,{size:18})})]})]}),e.jsxs("div",{className:"device-interactions-column",children:[e.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[e.jsxs("button",{className:`tab-btn ${y==="actions"?"active":""}`,onClick:()=>S("actions"),role:"tab","aria-selected":y==="actions",children:[e.jsx(hn,{size:13}),e.jsx("span",{children:"Actions"})]}),e.jsxs("button",{className:`tab-btn ${y==="screenshot"?"active":""}`,onClick:()=>S("screenshot"),role:"tab","aria-selected":y==="screenshot",children:[e.jsx(Gt,{size:13}),e.jsx("span",{children:"Screenshot"})]}),e.jsxs("button",{className:`tab-btn ${y==="logs"?"active":""}`,onClick:()=>S("logs"),role:"tab","aria-selected":y==="logs",children:[e.jsx(fn,{size:13}),e.jsx("span",{children:"Logs"})]}),e.jsxs("button",{className:`tab-btn ${y==="terminal"?"active":""}`,onClick:()=>S("terminal"),role:"tab","aria-selected":y==="terminal",children:[e.jsx(ga,{size:13}),e.jsx("span",{children:"Shell"})]}),e.jsxs("button",{className:`tab-btn ${y==="omni"?"active":""}`,onClick:()=>S("omni"),role:"tab","aria-selected":y==="omni",children:[e.jsx(ea,{size:13}),e.jsx("span",{children:"Omni-Vision"})]})]}),e.jsx("div",{className:`interactions-scroll-area ${y==="terminal"?"terminal-mode":""} ${y==="screenshot"||y==="logs"?"screenshot-mode":""}`,children:e.jsxs("div",{className:"tab-content",children:[y==="omni"&&e.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:e.jsx(Co,{sessionId:b.session_id?String(b.session_id):null,udid:b.udid,streamUrl:pt(),embedded:!0,overlayTarget:k,onModeChange:x,deviceActionAt:te})}),y==="actions"&&e.jsx(oc,{udid:b.udid,platform:b.platform,deviceName:E,screenWidth:Z,screenHeight:ke}),y==="screenshot"&&e.jsxs("div",{className:"action-card screenshot-card",children:[j.length>0&&e.jsx("header",{className:"action-card-header",children:e.jsx("button",{className:"btn-text-only",onClick:Ut,children:"CLEAR ALL"})}),e.jsxs("div",{className:`screenshot-workspace ${j.length===0?"is-empty":""}`,children:[e.jsxs("div",{className:"screenshot-gallery-sidebar",children:[e.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Ft,disabled:A,children:[A?e.jsx(ct,{className:"animate-spin",size:16}):e.jsx(Gt,{size:16}),e.jsx("span",{children:A?"CAPTURING...":"NEW CAPTURE"})]}),e.jsxs("div",{className:"screenshot-thumbnails-list",children:[j.length===0&&!A&&e.jsxs("div",{className:"empty-gallery-state",children:[e.jsx(Gt,{size:20,className:"empty-gallery-icon"}),e.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),e.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),j.map((I,F)=>e.jsxs("div",{className:`screenshot-thumb-item ${p===F?"active":""}`,onClick:()=>D(F),children:[e.jsx("img",{src:`data:image/png;base64,${I.base64}`,alt:"Thumb"}),e.jsx("span",{className:"thumb-time",children:new Date(I.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("button",{className:"thumb-delete-btn",onClick:G=>{G.stopPropagation(),De(I.id)},children:e.jsx(as,{size:12})})]},I.id))]})]}),e.jsx("div",{className:"screenshot-main-preview",children:p!==null&&j[p]?e.jsxs("div",{className:"preview-container",children:[e.jsx("div",{className:"preview-image-wrapper",children:e.jsx("img",{src:`data:image/png;base64,${j[p].base64}`,alt:"Selected Evidence"})}),e.jsxs("footer",{className:"preview-footer",children:[e.jsxs("div",{className:"preview-meta",children:[e.jsx("span",{className:"meta-label",children:"ID:"}),e.jsx("span",{className:"meta-value",children:j[p].id.substring(0,8)}),e.jsx("span",{className:"meta-divider",children:"|"}),e.jsx("span",{className:"meta-value",children:pa(j[p].timestamp)})]}),e.jsxs("div",{className:"preview-actions",children:[e.jsx("button",{className:"btn-premium btn-sm",onClick:()=>Bt(j[p].base64),children:"DOWNLOAD PNG"}),e.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>De(j[p].id),children:[e.jsx(as,{size:14})," DELETE"]})]})]})]}):null})]})]}),y==="logs"&&e.jsx("div",{className:"action-card screenshot-card",children:e.jsx(Ko,{udid:b.udid,platform:b.platform})}),y==="terminal"&&e.jsx("div",{className:"action-card full-height",children:e.jsx(Fr,{platform:(b.platform||"").toLowerCase(),prompt:`${(b.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${E} (${b.udid}).
268
- Internal Shell Environment.`,onCommand:async I=>{const F=await M.executeShell(b.udid,I);if(F.error)throw new Error(F.error);return F.output}})})]})})]})]}),b.session_id&&!String(b.session_id).startsWith("manual_")&&e.jsx(ta,{sessionId:String(b.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const lc=/^(INPUT|TEXTAREA|SELECT)$/;function dc({labelledBy:t,onClose:s,children:n,style:a,...o}){const r=c.useRef(null),l=c.useRef(s);return l.current=s,c.useEffect(()=>{const u=r.current;if(!u)return;const d=document.activeElement,i=[];for(let x=u;x.parentElement&&x!==document.body;x=x.parentElement)for(const k of Array.from(x.parentElement.children))k===x||k.hasAttribute("inert")||k.matches("[aria-live], script, style, link, template")||(k.setAttribute("inert",""),i.push(k));u.contains(document.activeElement)||u.focus();const m=x=>{if(x.key!=="Escape"||x.defaultPrevented)return;const k=x.target;lc.test(k.tagName)||k.isContentEditable||(x.preventDefault(),l.current())};return u.addEventListener("keydown",m),()=>{u.removeEventListener("keydown",m),i.forEach(x=>x.removeAttribute("inert")),d&&d.isConnected&&d!==document.body&&d.focus()}},[]),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,style:{outline:"none",...a},...o,children:n})}const Bn="xenon.devices.view";function Vn(){try{return window.localStorage}catch{return null}}function uc(t,s){const n=t.get("view");return n==="table"||n==="cards"?n:s}function hc(t,s,n){s==="table"||s!==n?t.set("view",s):t.delete("view")}function tn(t=Vn()){try{return(t==null?void 0:t.getItem(Bn))==="table"?"table":"cards"}catch{return"cards"}}function mc(t,s=Vn()){try{s==null||s.setItem(Bn,t)}catch{}}class pc extends Fe.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=Fe.createRef(),this.containerRef=Fe.createRef(),this.stickyGroupRef=Fe.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var r,l;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(r=a==null?void 0:a.closest)!=null&&r.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(l=this.searchRef.current)==null||l.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(xr),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(s=this.stickyObserver)==null||s.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await M.getDevices(),n=this.getBusyDevicesCount(s),a=await M.getPendingSessionsCount(),o=await M.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:o,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>Tt(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(i=>i.udid===n):null,{filters:o}=this.props,r=jr(this.state.devices,o,Date.now()),l=[{value:"all",label:"Any platform",count:r.platform.all},{value:"android",label:"Android",count:r.platform.android},{value:"ios",label:"iOS",count:r.platform.ios}];(Nr(this.state.devices)||o.platform==="tvos")&&l.push({value:"tvos",label:"tvOS",count:r.platform.tvos});const u=[{value:"all",label:"Any type",count:r.type.all},{value:"real",label:"Real devices",count:r.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:r.type.virtual}],d=`/devices${this.props.locationSearch}`;return e.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[e.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[e.jsx(Qn,{icon:ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),e.jsxs("div",{className:"de2-toolbar",children:[e.jsx(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})}),kr(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:wr(s.length,this.state.devices.length)}),e.jsx(Y,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:e.jsx(St,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?e.jsx(Ir,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):e.jsx(yr,{devices:s,reloadDevices:()=>this.fetchDevices()}):e.jsxs("div",{className:"device-explorer-empty stagger-1",children:[e.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?e.jsx(ns,{size:32}):e.jsx(St,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Global Device Registry Empty"}),e.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),e.jsxs(Y,{variant:"primary",onClick:()=>this.fetchDevices(),children:[e.jsx(St,{size:14}),"Manual sync"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"No devices match these filters"}),e.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),e.jsx(Y,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Loading devices…"}),e.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&e.jsx(dc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:e.jsx("div",{className:"device-control-modal",children:e.jsx(cc,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Zc(){const t=an(),s=mt(),n=Mt(),[a,o]=Zn(),{on:r}=Jn(),l=vr(a),u=uc(a,tn()),d=Rr(a),i=(m,x,k)=>{const f=gr(m);hc(f,x,tn()),Ar(f,k),o(f,{replace:!0})};return e.jsx(pc,{params:t,navigate:s,onSocketEvent:r,filters:l,onFiltersChange:m=>i(m,u,d),view:u,onViewChange:m=>{mc(m),i(l,m,d)},sort:d,onSortChange:m=>i(l,u,m),locationSearch:n.search})}export{pc as DeviceExplorer,Zc as default};
267
+ `),`logcat-${t}-${Date.now()}.txt`)},[B,t]);c.useEffect(()=>{const _=V.current;if(!_||!d.length)return;const v=d.filter(P=>P.seq>te.current);if(!v.length)return;const H=te.current+1;te.current>=0&&v[0].seq>H&&(_.dropped+=v[0].seq-H),Bo(_,v),te.current=v[v.length-1].seq,oe(_.lines.length)},[d]);const ee=c.useCallback(()=>{const _=V.current;if(!_){te.current=d.length?d[d.length-1].seq:-1,V.current=Uo(Date.now()),oe(0),Q(!0);return}const v=Vo(_,Date.now(),t);V.current=null,Q(!1),oe(0),en(v,Ho(t,_.startedAt))},[d,t]);if(c.useEffect(()=>{var _;y&&((_=O.current)==null||_.scrollIntoView({block:"end"}))},[B.length,y]),!o)return e.jsxs("div",{className:"log-empty-state",children:[e.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),e.jsx("p",{className:"log-empty-subtitle",children:"Streaming is wired up for Android (logcat) and iOS (os_trace), not for this device's platform."})]});const ge=x?"Denied":k?"Offline":i?"Live":"Connecting",be=!i&&(!!x||k);return e.jsxs("div",{className:"logcat-root",children:[e.jsxs("div",{className:"log-toolbar",children:[e.jsxs("div",{className:"log-filter-group",children:[e.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[e.jsx("span",{className:`log-live-dot ${i?"active":""} ${be?"is-error":""}`}),ge]}),e.jsxs("div",{className:"log-stat-pill logcat-count",children:[B.length," / ",d.length]}),e.jsxs(ms,{selectSize:"sm",value:de,onChange:_=>l(zo(r,_.target.value)),"aria-label":"Minimum log level",children:[e.jsx("option",{value:"",children:"All levels"}),Qs.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:r,onChange:_=>l(_.target.value),"aria-label":"Filter logs"}),r&&e.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>l(""),"aria-label":"Clear filter",title:"Clear filter",children:e.jsx(sn,{size:12})})]}),e.jsxs("div",{className:"logcat-input-wrap",children:[e.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:$,onChange:_=>{p(_.target.value),A(0)},onKeyDown:_=>{_.key==="Enter"&&(_.preventDefault(),ue(_.shiftKey?-1:1))},"aria-label":"Find in logs"}),$&&e.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:E.length?`${J+1}/${E.length}`:"0/0"})]}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(-1),disabled:!E.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:e.jsx(ys,{size:14})}),e.jsx("button",{type:"button",className:"dc-btn-secondary btn-sm logcat-icon-btn",onClick:()=>ue(1),disabled:!E.length,"aria-label":"Next match",title:"Next match (Enter)",children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>L(!C),"aria-pressed":C,"aria-label":"Match case",title:"Match case",children:e.jsx(za,{size:15})}),e.jsx("button",{type:"button",className:`dc-btn-secondary btn-sm logcat-icon-btn ${w?"active":""}`,onClick:()=>j(!w),"aria-pressed":w,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:e.jsx(Ri,{size:14})})]}),e.jsxs("div",{className:"log-actions-group",children:[(x||k)&&e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:f,children:[e.jsx(lt,{size:14})," RECONNECT"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${y?"active":""}`,onClick:()=>S(!y),children:[e.jsx(Bi,{size:14})," ",y?"FREEZE":"FOLLOW"]}),e.jsxs("button",{className:`dc-btn-secondary btn-sm ${q?"is-recording":""}`,onClick:ee,"aria-pressed":q,title:q?"Stop recording and download the capture":"Record the raw log stream to a file",children:[q?e.jsx(on,{size:12}):e.jsx(aa,{size:12})," ",q?`STOP · ${b.toLocaleString()}`:"RECORD"]}),e.jsxs("button",{className:"btn-premium btn-sm",disabled:B.length===0,onClick:fe,children:[e.jsx(xa,{size:14})," EXPORT"]}),e.jsxs("button",{className:"dc-btn-secondary btn-sm",onClick:m,children:[e.jsx(as,{size:14})," CLEAR"]})]})]}),e.jsxs("div",{className:`logcat-rows theme-dark ${w?"":"no-wrap"}`,ref:W,children:[x&&e.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[e.jsx($e,{size:14}),e.jsxs("span",{children:["Access denied — ",x]})]}),!x&&k&&e.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[e.jsx($e,{size:14}),e.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),B.map((_,v)=>e.jsx(qo,{record:_,index:v,isHit:le.has(v),isActiveHit:E.length>0&&E[J]===v},_.seq)),e.jsx("div",{ref:O})]})]})}function Pn(t){const s=t==null?void 0:t.message;return typeof s=="string"?s.trim():""}function Be(t,s){const n=Pn(s);return n?`Couldn’t ${t}: ${n}`:`Couldn’t ${t}.`}function Xo(t,s){return t==="android"?"Couldn’t read the clipboard. Check that the Appium Settings app is installed on the device.":Be("read the clipboard",s)}function Go(t,s){const n=s.trim().toLowerCase();return[...t].sort((a,o)=>a.localeCompare(o)).filter(a=>!n||a.toLowerCase().includes(n))}const Yo=/^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)+$/;function Zo(t){return Yo.test(t.trim())}function vs(t){const s=(t||"").toLowerCase();return s==="android"?"android":s==="ios"||s==="tvos"?"ios":null}function Jo(t,s){const n=vs(s);return n?t.filter(a=>(a.platform||"").toLowerCase()===n):[]}function Qo(t){return[t.version,t.packageName].filter(Boolean).join(" · ")}function ec(t){return vs(t)==="android"?"Android":"iOS"}function tc(t){return vs(t)==="android"?".apk":".ipa,.app"}const Fn="Your browser blocked copying here. The text is selected, so press ⌘C or Ctrl+C.";async function Un(t){var s;try{return(s=navigator.clipboard)!=null&&s.writeText?(await navigator.clipboard.writeText(t),!0):!1}catch{return!1}}function sc({udid:t,platform:s,deviceName:n}){const{toast:a,removeToast:o}=Ve(),r=mt(),[l,u]=c.useState([]),[d,i]=c.useState("loading"),[m,x]=c.useState(""),[k,f]=c.useState(""),[y,S]=c.useState(!1),[C,L]=c.useState(!1),[w,j]=c.useState([]),[$,p]=c.useState("loading"),[D,A]=c.useState(null),[O,W]=c.useState(null),V=c.useRef(null),q=c.useRef(null),Q=c.useRef(null),b=c.useCallback(async()=>{i("loading");try{const v=await M.listApps(t);u(Array.isArray(v)?v:[]),i("ready")}catch(v){x(Pn(v)),i("error")}},[t]);c.useEffect(()=>{b()},[b]);const oe=v=>setTimeout(b,v);c.useEffect(()=>{if(!O)return;const v=setTimeout(()=>W(null),1500);return()=>clearTimeout(v)},[O]);const te=async()=>{p("loading");try{const v=await M.getApps();j(Array.isArray(v)?v:[]),p("ready")}catch{p("error")}},ce=()=>{y||(L(!0),te())},B=()=>{var v;L(!1),(v=V.current)==null||v.focus()};c.useEffect(()=>{var H;if(!C||$==="loading")return;const v=(H=q.current)==null?void 0:H.querySelector('[role="menuitem"]:not(:disabled)');v==null||v.focus()},[C,$]);const E=async(v,H)=>{S(!0);const P=a(`Installing ${v} on ${n}…`,"loading",0);try{const K=await H();K!=null&&K.success?(a(`Installed ${v} on ${n}`,"success"),oe(5e3)):a(Be(`install ${v}`,{message:K==null?void 0:K.error}),"error")}catch(K){a(Be(`install ${v}`,K),"error")}finally{o(P),S(!1)}},J=v=>{B(),E(v.name,()=>M.installRepositoryApp(t,v.id))},le=v=>{var P;const H=(P=v.target.files)==null?void 0:P[0];v.target.value="",H&&E(H.name,()=>M.uploadAndInstallApp(t,H))},ue=async()=>{const v=D;if(A(null),!v)return;const H=a(`Uninstalling ${v} from ${n}…`,"loading",0);try{await M.uninstallApp(t,v),a(`Uninstalled ${v} from ${n}`,"success"),oe(3e3)}catch(P){a(Be(`uninstall ${v}`,P),"error")}finally{o(H)}},de=async(v,H)=>{var K,Ne;if(await Un(v)){W(v);return}const P=(K=H.closest("li"))==null?void 0:K.querySelector(".actions-app-id");P&&((Ne=window.getSelection())==null||Ne.selectAllChildren(P)),a(Fn,"info")},fe=Go(l,k),ee=k.trim(),ge=d==="ready"&&fe.length===0&&Zo(ee)&&!l.includes(ee),be=Jo(w,s),_=(v,H)=>e.jsxs("li",{className:"actions-app-row",children:[e.jsx("span",{className:"actions-app-id",children:v}),H&&e.jsx("span",{className:"actions-app-note",children:H}),e.jsxs("span",{className:"actions-app-tools",children:[e.jsx(Y,{variant:"ghost",size:"icon","aria-label":O===v?"Copied":`Copy ${v}`,title:O===v?"Copied":"Copy package ID",onClick:P=>de(v,P.currentTarget),children:O===v?e.jsx(dt,{size:13,"aria-hidden":"true"}):e.jsx(Te,{size:13,"aria-hidden":"true"})}),e.jsx(Y,{variant:"ghost",size:"sm",className:"actions-app-uninstall","aria-label":`Uninstall ${v}`,onClick:()=>A(v),children:"Uninstall"})]})]},v);return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-apps-title",children:[e.jsxs("div",{className:"actions-section-head",children:[e.jsxs("h4",{id:"actions-apps-title",className:"actions-section-title",children:[e.jsx(mi,{size:15,"aria-hidden":"true"})," Apps"]}),e.jsxs("div",{className:"actions-section-tools",children:[e.jsxs(Y,{ref:V,variant:"tonal",size:"sm","aria-haspopup":"menu","aria-expanded":C,"aria-disabled":y||void 0,onClick:ce,children:[y?e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}):e.jsx(ti,{size:13,"aria-hidden":"true"}),"Install from library"]}),e.jsxs(Y,{variant:"secondary",size:"sm","aria-disabled":y||void 0,onClick:()=>{var v;return!y&&((v=Q.current)==null?void 0:v.click())},children:[e.jsx(va,{size:13,"aria-hidden":"true"})," Upload file"]}),e.jsx("input",{ref:Q,type:"file",hidden:!0,"aria-label":"App file to upload",accept:tc(s),onChange:le})]})]}),e.jsx(cn,{open:C,onClose:B,anchorRef:V,placement:"bottom-end",children:e.jsx("div",{ref:q,className:"actions-library-menu",children:e.jsxs(ln,{children:[$==="loading"&&e.jsx(pe,{disabled:!0,onClick:()=>{},children:"Loading…"}),$==="error"&&e.jsx(pe,{onClick:te,children:"Couldn’t load the library. Retry"}),$==="ready"&&be.length===0&&e.jsxs(e.Fragment,{children:[e.jsxs(pe,{disabled:!0,onClick:()=>{},children:["No ",ec(s)," apps in the library yet"]}),e.jsx(pe,{onClick:()=>r("/apps"),children:"Open the Apps library"})]}),$==="ready"&&be.map(v=>e.jsx(pe,{note:Qo(v)||void 0,onClick:()=>J(v),children:v.name},v.id))]})})}),e.jsxs("div",{className:"actions-apps-tools",children:[e.jsxs("div",{className:"actions-search",children:[e.jsx(hs,{size:13,className:"actions-search-icon","aria-hidden":"true"}),e.jsx("input",{type:"search",className:"type-input-field compact","aria-label":"Search installed apps",placeholder:`Search ${l.length} installed apps`,value:k,onChange:v=>f(v.target.value)})]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Refresh installed apps",title:"Refresh",onClick:b,children:e.jsx(St,{size:13,"aria-hidden":"true"})})]}),d==="loading"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"Loading apps…"}),d==="error"&&e.jsxs("div",{className:"actions-list-note",role:"alert",children:["Couldn’t load the apps",m?`: ${m}`:".",e.jsx(Y,{variant:"secondary",size:"sm",onClick:b,children:"Retry"})]}),d==="ready"&&l.length===0&&e.jsx("p",{className:"actions-list-note",children:"No apps installed"}),d==="ready"&&l.length>0&&fe.length===0&&!ge&&e.jsxs("p",{className:"actions-list-note",children:["No apps match “",ee,"”"]}),e.jsxs("ul",{className:"actions-apps-list","aria-label":"Installed apps",children:[fe.map(v=>_(v)),ge&&_(ee,"Not in the list")]}),e.jsx(ps,{open:D!==null,title:"Uninstall app?",onClose:()=>A(null),footer:e.jsxs(e.Fragment,{children:[e.jsx(Y,{variant:"secondary",onClick:()=>A(null),children:"Cancel"}),e.jsx(Y,{variant:"danger",onClick:ue,children:"Uninstall"})]}),children:e.jsxs("p",{className:"actions-confirm-text",children:["Uninstall ",e.jsx("code",{children:D})," from"," ",e.jsx("span",{className:"actions-confirm-device",children:n}),"? The app and its data are removed from the device."]})})]})}const nc=[{direction:"up",Icon:ys},{direction:"down",Icon:fs},{direction:"left",Icon:ba},{direction:"right",Icon:ja}];function ac({onSwipe:t}){return e.jsxs("section",{className:"actions-section actions-swipe","aria-labelledby":"actions-swipe-title",children:[e.jsxs("h4",{id:"actions-swipe-title",className:"actions-section-title",children:[e.jsx(Ga,{size:15,"aria-hidden":"true"})," Swipe"]}),e.jsx("div",{className:"actions-swipe-buttons",children:nc.map(({direction:s,Icon:n})=>e.jsx(Y,{variant:"secondary",size:"icon","aria-label":`Swipe ${s}`,title:`Swipe ${s}`,onClick:()=>t(s),children:e.jsx(n,{size:14,"aria-hidden":"true"})},s))})]})}function ic(t,s,n){const a=s/2,o=n/2,r=s*.4,l=n*.4,[u,d,i,m]={up:[a,o+l,a,o-l],down:[a,o-l,a,o+l],left:[a+r,o,a-r,o],right:[a-r,o,a+r,o]}[t].map(Math.round);return{startX:u,startY:d,endX:i,endY:m}}function rc({udid:t,platform:s}){const n=s!=="android",{toast:a}=Ve(),[o,r]=c.useState(""),[l,u]=c.useState(!1),[d,i]=c.useState(""),[m,x]=c.useState(null),[k,f]=c.useState(""),[y,S]=c.useState(!1),C=c.useRef(null);c.useEffect(()=>{if(!k)return;const p=setTimeout(()=>f(""),2e3);return()=>clearTimeout(p)},[k]),c.useEffect(()=>{if(!y)return;const p=setTimeout(()=>S(!1),1500);return()=>clearTimeout(p)},[y]);const L=async()=>{if(!(!o.trim()||l)){u(!0);try{await M.typeText(t,o),r(""),f("Sent")}catch(p){a(Be("send the text",p),"error")}finally{u(!1)}}},w=async()=>{x("read");try{const p=await M.getClipboard(t),D=typeof(p==null?void 0:p.content)=="string"?p.content:"";i(D),D||f("The device clipboard is empty")}catch(p){a(Xo(s,p),"error")}finally{x(null)}},j=async()=>{if(d){x("write");try{await M.setClipboard(t,d),f("Written to the device")}catch(p){a(Be("write the clipboard",p),"error")}finally{x(null)}}},$=async()=>{var p;if(await Un(d)){S(!0);return}(p=C.current)==null||p.select(),a(Fn,"info")};return e.jsxs("section",{className:"actions-section","aria-labelledby":"actions-text-title",children:[e.jsxs("h4",{id:"actions-text-title",className:"actions-section-title",children:[e.jsx(Qa,{size:15,"aria-hidden":"true"})," Text and clipboard"]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-send-text",children:"Send text"}),e.jsx("input",{id:"actions-send-text",type:"text",className:"type-input-field compact",placeholder:"Type text for the focused field…",value:o,onChange:p=>r(p.target.value),onKeyDown:p=>p.key==="Enter"&&L()}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:L,disabled:!o.trim()||l,children:[l&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Send"]})]}),e.jsxs("div",{className:"actions-field-row",children:[e.jsx("label",{className:"actions-field-label",htmlFor:"actions-clipboard",children:"Clipboard"}),e.jsx("input",{id:"actions-clipboard",ref:C,type:"text",className:"type-input-field compact",placeholder:n?"Read the device clipboard, or type text to write":"Read the device clipboard","aria-describedby":n?void 0:"actions-clipboard-hint",value:d,onChange:p=>i(p.target.value)}),e.jsxs(Y,{variant:"secondary",size:"md",onClick:w,disabled:m!==null,children:[m==="read"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Read"]}),n&&e.jsxs(Y,{variant:"secondary",size:"md",onClick:j,disabled:!d||m!==null,children:[m==="write"&&e.jsx(ct,{className:"animate-spin",size:13,"aria-hidden":"true"}),"Write to device"]}),e.jsx(Y,{variant:"ghost",size:"icon","aria-label":y?"Copied":"Copy clipboard text",title:y?"Copied":"Copy to your clipboard",onClick:$,disabled:!d,children:y?e.jsx(dt,{size:14,"aria-hidden":"true"}):e.jsx(Te,{size:14,"aria-hidden":"true"})})]}),!n&&e.jsx("p",{id:"actions-clipboard-hint",className:"actions-field-hint",children:"Android lets Xenon read the clipboard, not write it."}),e.jsx("p",{className:"actions-status",role:"status",children:k})]})}function oc({udid:t,platform:s,deviceName:n,screenWidth:a,screenHeight:o}){const{toast:r}=Ve(),l=async u=>{const d=ic(u,a,o);try{await M.swipe(t,d.startX,d.startY,d.endX,d.endY)}catch(i){r(Be(`swipe ${u}`,i),"error")}};return e.jsxs("div",{className:"actions-panel",children:[e.jsx(sc,{udid:t,platform:s,deviceName:n}),e.jsx(rc,{udid:t,platform:s}),e.jsx(ac,{onSwipe:l})]})}function cc({device:t,onClose:s,titleId:n}){const{toast:a}=Ve(),o=mt(),{tab:r}=an(),l=Mt(),u=c.useRef(null),[d,i]=c.useState({width:0,height:0}),[m,x]=c.useState("inspect"),[k,f]=c.useState(null),[y,S]=c.useState(r||"actions"),C=y==="omni"&&m==="inspect",[L,w]=c.useState(!0),[j,$]=c.useState([]),[p,D]=c.useState(null),[A,O]=c.useState(!1),[W,V]=c.useState(!1),[q,Q]=c.useState(0),[b,oe]=c.useState(t),[te,ce]=c.useState(0),B=c.useCallback(()=>ce(Date.now()),[]),E=Me(b);c.useEffect(()=>{Gn(b.udid,E),document.title=Yn(l.pathname)},[b.udid,E,l.pathname]);const[J,le]=c.useState(!1),[ue,de]=c.useState(!1),fe=10,[ee,ge]=c.useState(!1),[be,_]=c.useState(!1),v=$o(b==null?void 0:b.udid,!ue),H=()=>{navigator.clipboard.writeText(b.udid).catch(()=>{}),ge(!0),setTimeout(()=>ge(!1),1500)},P=c.useRef(""),K=c.useRef(null),[Ne,tt]=c.useState(!1);c.useEffect(()=>{y&&(!r||r!==y)&&o(`/devices/${t.udid}/control/${y}${l.search}`,{replace:!0})},[y,r,t.udid,o,l.search]);const[zt,st]=c.useState(0);To(()=>{M.leaveStream(b.udid).catch(()=>{})},()=>st(I=>I+1)),c.useEffect(()=>((async()=>{try{V(!0),await M.startStream(b.udid);const G=(await M.getDevices()).find(se=>se.udid===b.udid);G&&oe(G)}catch(F){console.error("Auto-start stream failed:",F)}finally{V(!1)}})(),()=>{M.leaveStream(b.udid).catch(()=>{})}),[t.udid,zt]);const He=parseInt(b.screenWidth||"1080",10),nt=parseInt(b.screenHeight||"1920",10),Z=Math.min(He,nt),ke=Math.max(He,nt),Ee=Z/ke,_e=c.useCallback(()=>{const I=!L,F=I?window.innerHeight*.55:window.innerHeight*.7,G=620,ye=window.innerWidth>900;let ie;I?ie=ye?Math.min(window.innerWidth*.8,window.innerWidth-G):window.innerWidth*.8:ie=window.innerWidth*.45;const xe=L?Ee:1/Ee;let ne,ae;L?(ne=F,ae=ne*xe,ae>ie&&(ae=ie,ne=ae/xe)):(ae=ie,ne=ae/xe,ne>F&&(ne=F,ae=ne*xe)),i({width:ae,height:ne})},[Ee,L]);c.useEffect(()=>(_e(),window.addEventListener("resize",_e),()=>window.removeEventListener("resize",_e)),[_e]),c.useEffect(()=>{const I=async()=>{if(P.current.length>0){const G=P.current;P.current="";try{await M.typeText(b.udid,G)}catch(se){console.error("Keyboard buffering flush failed:",se)}finally{B()}}},F=G=>{const se=document.activeElement;if(se&&(se.tagName==="INPUT"||se.tagName==="TEXTAREA"||se.isContentEditable)||!Ne&&y!=="terminal")return;const ie=G.key;ie==="Enter"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?66:"enter").finally(B)):ie==="Backspace"?(K.current&&clearTimeout(K.current),I(),M.pressKey(b.udid,b.platform==="android"?67:"backspace").finally(B)):ie.length===1&&(P.current+=ie,K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{I()},50))};return window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F),K.current&&clearTimeout(K.current)}},[b.udid,b.platform,Ne,y,B]);const[We,Lt]=c.useState(Date.now()),pt=()=>{const I=q>0?`r=${q}&`:"";return b.session_id&&!String(b.session_id).startsWith("manual_")?`/xenon/api/session/${b.session_id}/live_video?${I}t=${We}`:`/xenon/api/control/${b.udid}/stream?${I}t=${We}`};c.useEffect(()=>{q>0&&Lt(Date.now())},[q]),c.useEffect(()=>{if(J||ue)return;const I=setTimeout(()=>de(!0),3e4);return()=>clearTimeout(I)},[J,ue,q]);const we=c.useRef(null),qe=I=>{const F=I.currentTarget.getBoundingClientRect();return{x:I.clientX-F.left,y:I.clientY-F.top}},Ot=I=>{const F=qe(I);we.current={x:F.x,y:F.y,time:Date.now()}},ft=async I=>{var Ye;if(!we.current)return;const F=we.current,G=qe(I),se=Date.now()-F.time,ye=(Ye=u.current)==null?void 0:Ye.getBoundingClientRect(),ie=(ye==null?void 0:ye.width)||d.width,xe=(ye==null?void 0:ye.height)||d.height;let ne,ae,Xe,Ge;L?(ne=F.x/ie*Z,ae=F.y/xe*ke,Xe=G.x/ie*Z,Ge=G.y/xe*ke):(ne=F.x/ie*ke,ae=F.y/xe*Z,Xe=G.x/ie*ke,Ge=G.y/xe*Z);const ze=Math.abs(Xe-ne),rt=Math.abs(Ge-ae);try{se<500&&ze<10&&rt<10?await M.tap(b.udid,Math.round(ne),Math.round(ae)):se>=500&&ze<10&&rt<10?await M.touchAndHold(b.udid,Math.round(ne),Math.round(ae),se):await M.swipe(b.udid,Math.round(ne),Math.round(ae),Math.round(Xe),Math.round(Ge))}catch(Vt){console.error("Action failed:",Vt)}finally{B()}we.current=null},yt=()=>M.pressKey(b.udid,b.platform==="android"?ot.HOME:Yt.HOME).finally(B),Pt=()=>M.pressKey(b.udid,ot.BACK).finally(B),at=()=>M.pressKey(b.udid,ot.APP_SWITCH).finally(B),xt=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_UP:Yt.VOLUME_UP).finally(B),Ke=()=>M.pressKey(b.udid,b.platform==="android"?ot.VOLUME_DOWN:Yt.VOLUME_DOWN).finally(B),vt=()=>M.lock(b.udid).finally(B),it=async()=>{_(!0);try{await M.unlock(b.udid)}finally{B(),setTimeout(()=>_(!1),2500)}},Ft=async()=>{O(!0);try{const I=await M.getScreenshot(b.udid);if(I!=null&&I.screenshot){const F={id:Pr(),base64:I.screenshot,timestamp:Date.now()};$(G=>[F,...G]),D(0)}}catch(I){console.error("Failed to take screenshot:",I)}finally{O(!1)}},De=I=>{$(F=>{const G=F.filter(se=>se.id!==I);return G.length===0?D(null):p!==null&&p>=G.length&&D(0),G})},Ut=()=>{$([]),D(null),a("Cleared all captured evidence.","success")},Bt=I=>{const F=document.createElement("a");F.href=`data:image/png;base64,${I}`,F.download=`screenshot-${b.udid}-${Date.now()}.png`,F.click()};return e.jsxs("div",{className:"device-control-view",children:[e.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),e.jsxs("header",{className:"control-view-top-bar",children:[e.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[e.jsx(zs,{size:18})," DEVICES"]}),e.jsxs("div",{className:"device-info-mini",children:[e.jsx("span",{className:`device-pill platform-pill ${b.platform}`,children:b.platform==="ios"?"Apple":"Android"}),e.jsxs("span",{className:"device-pill version-pill",children:["v",b.sdk]}),b.reservedUntil&&Date.now()<b.reservedUntil&&e.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${b.reservedBy}${b.reservationReason?`: ${b.reservationReason}`:""}`,children:["Reserved by ",b.reservedBy||"someone"]}),e.jsx("h2",{id:n,className:"device-name-text",children:E}),e.jsxs("span",{className:"udid-chip",title:b.udid,children:[e.jsx("span",{className:"udid-chip__value",children:b.udid}),e.jsx("button",{type:"button",className:"udid-chip__copy",onClick:H,"aria-label":"Copy UDID",title:ee?"Copied!":"Copy UDID",children:ee?e.jsx(dt,{size:12}):e.jsx(Te,{size:12})})]})]})]}),e.jsxs("div",{className:`control-view-main ${L?"":"is-landscape"} ${y==="omni"?"omni-mode":""}`,children:[e.jsxs("div",{className:"device-preview-column",children:[e.jsx("div",{className:"device-screen-wrapper",children:e.jsxs("div",{ref:I=>{u.current=I,f(I)},className:`device-stream-canvas ${L?"":"landscape"} ${Ne?"focused":""} ${C?"is-inspecting":""}`,style:{width:d.width,height:d.height,background:"var(--black)"},tabIndex:0,onFocus:()=>tt(!0),onBlur:()=>tt(!1),onMouseDown:C?void 0:Ot,onMouseUp:C?void 0:ft,children:[ue?e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx($e,{size:40,color:"var(--red, #f87171)"}),e.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),e.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{de(!1),Q(0)},children:"Retry"})]}):(W||!J)&&e.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[e.jsx(lt,{size:40,className:"animate-spin",color:"var(--color-accent)"}),e.jsx("p",{style:{marginTop:16},children:W?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!ue&&e.jsx(rn,{src:pt(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>le(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),le(!1),q>=fe){de(!0);return}setTimeout(()=>Q(I=>I+1),2e3)}}),v==="off"&&!ue&&e.jsxs("div",{className:"device-screen-off",role:"status",children:[e.jsx(li,{size:32}),e.jsx("p",{children:"Display is off"}),e.jsx("span",{children:"The stream is fine — the device is asleep."}),e.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:it,disabled:be,children:be?"Waking…":"Wake device"})]})]})}),e.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":L?"vertical":"horizontal",children:[e.jsx("button",{className:`footer-action-btn ${L?"active":""}`,onClick:()=>w(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":L,children:e.jsx(gi,{size:18})}),e.jsx("button",{className:`footer-action-btn ${L?"":"active"}`,onClick:()=>w(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!L,children:e.jsx(xi,{size:18})}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:yt,title:"Home","aria-label":"Home",children:e.jsx(ia,{size:18})}),b.platform==="android"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"footer-action-btn",onClick:Pt,title:"Back","aria-label":"Back",children:e.jsx(zs,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:at,title:"App switcher","aria-label":"App switcher",children:e.jsx(on,{size:18})})]}),e.jsx("div",{className:"footer-divider"}),e.jsx("button",{className:"footer-action-btn",onClick:xt,title:"Volume up","aria-label":"Volume up",children:e.jsx(Fi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:Ke,title:"Volume down","aria-label":"Volume down",children:e.jsx(Oi,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:vt,title:"Lock device","aria-label":"Lock device",children:e.jsx(Na,{size:18})}),e.jsx("button",{className:"footer-action-btn",onClick:it,title:"Unlock device","aria-label":"Unlock device",children:e.jsx(ni,{size:18})})]})]}),e.jsxs("div",{className:"device-interactions-column",children:[e.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[e.jsxs("button",{className:`tab-btn ${y==="actions"?"active":""}`,onClick:()=>S("actions"),role:"tab","aria-selected":y==="actions",children:[e.jsx(hn,{size:13}),e.jsx("span",{children:"Actions"})]}),e.jsxs("button",{className:`tab-btn ${y==="screenshot"?"active":""}`,onClick:()=>S("screenshot"),role:"tab","aria-selected":y==="screenshot",children:[e.jsx(Gt,{size:13}),e.jsx("span",{children:"Screenshot"})]}),e.jsxs("button",{className:`tab-btn ${y==="logs"?"active":""}`,onClick:()=>S("logs"),role:"tab","aria-selected":y==="logs",children:[e.jsx(fn,{size:13}),e.jsx("span",{children:"Logs"})]}),e.jsxs("button",{className:`tab-btn ${y==="terminal"?"active":""}`,onClick:()=>S("terminal"),role:"tab","aria-selected":y==="terminal",children:[e.jsx(ga,{size:13}),e.jsx("span",{children:"Shell"})]}),e.jsxs("button",{className:`tab-btn ${y==="omni"?"active":""}`,onClick:()=>S("omni"),role:"tab","aria-selected":y==="omni",children:[e.jsx(ea,{size:13}),e.jsx("span",{children:"Omni-Vision"})]})]}),e.jsx("div",{className:`interactions-scroll-area ${y==="terminal"?"terminal-mode":""} ${y==="screenshot"||y==="logs"?"screenshot-mode":""}`,children:e.jsxs("div",{className:"tab-content",children:[y==="omni"&&e.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:e.jsx(Co,{sessionId:b.session_id?String(b.session_id):null,udid:b.udid,streamUrl:pt(),embedded:!0,overlayTarget:k,onModeChange:x,deviceActionAt:te})}),y==="actions"&&e.jsx(oc,{udid:b.udid,platform:b.platform,deviceName:E,screenWidth:Z,screenHeight:ke}),y==="screenshot"&&e.jsxs("div",{className:"action-card screenshot-card",children:[j.length>0&&e.jsx("header",{className:"action-card-header",children:e.jsx("button",{className:"btn-text-only",onClick:Ut,children:"CLEAR ALL"})}),e.jsxs("div",{className:`screenshot-workspace ${j.length===0?"is-empty":""}`,children:[e.jsxs("div",{className:"screenshot-gallery-sidebar",children:[e.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Ft,disabled:A,children:[A?e.jsx(ct,{className:"animate-spin",size:16}):e.jsx(Gt,{size:16}),e.jsx("span",{children:A?"CAPTURING...":"NEW CAPTURE"})]}),e.jsxs("div",{className:"screenshot-thumbnails-list",children:[j.length===0&&!A&&e.jsxs("div",{className:"empty-gallery-state",children:[e.jsx(Gt,{size:20,className:"empty-gallery-icon"}),e.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),e.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),j.map((I,F)=>e.jsxs("div",{className:`screenshot-thumb-item ${p===F?"active":""}`,onClick:()=>D(F),children:[e.jsx("img",{src:`data:image/png;base64,${I.base64}`,alt:"Thumb"}),e.jsx("span",{className:"thumb-time",children:new Date(I.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),e.jsx("button",{className:"thumb-delete-btn",onClick:G=>{G.stopPropagation(),De(I.id)},children:e.jsx(as,{size:12})})]},I.id))]})]}),e.jsx("div",{className:"screenshot-main-preview",children:p!==null&&j[p]?e.jsxs("div",{className:"preview-container",children:[e.jsx("div",{className:"preview-image-wrapper",children:e.jsx("img",{src:`data:image/png;base64,${j[p].base64}`,alt:"Selected Evidence"})}),e.jsxs("footer",{className:"preview-footer",children:[e.jsxs("div",{className:"preview-meta",children:[e.jsx("span",{className:"meta-label",children:"ID:"}),e.jsx("span",{className:"meta-value",children:j[p].id.substring(0,8)}),e.jsx("span",{className:"meta-divider",children:"|"}),e.jsx("span",{className:"meta-value",children:pa(j[p].timestamp)})]}),e.jsxs("div",{className:"preview-actions",children:[e.jsx("button",{className:"btn-premium btn-sm",onClick:()=>Bt(j[p].base64),children:"DOWNLOAD PNG"}),e.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>De(j[p].id),children:[e.jsx(as,{size:14})," DELETE"]})]})]})]}):null})]})]}),y==="logs"&&e.jsx("div",{className:"action-card screenshot-card",children:e.jsx(Ko,{udid:b.udid,platform:b.platform})}),y==="terminal"&&e.jsx("div",{className:"action-card full-height",children:e.jsx(Fr,{platform:(b.platform||"").toLowerCase(),prompt:`${(b.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${E} (${b.udid}).
268
+ Internal Shell Environment.`,onCommand:async I=>{const F=await M.executeShell(b.udid,I);if(F.error)throw new Error(F.error);return F.output}})})]})})]})]}),b.session_id&&!String(b.session_id).startsWith("manual_")&&e.jsx(ta,{sessionId:String(b.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}const lc=/^(INPUT|TEXTAREA|SELECT)$/;function dc({labelledBy:t,onClose:s,children:n,style:a,...o}){const r=c.useRef(null),l=c.useRef(s);return l.current=s,c.useEffect(()=>{const u=r.current;if(!u)return;const d=document.activeElement,i=[];for(let x=u;x.parentElement&&x!==document.body;x=x.parentElement)for(const k of Array.from(x.parentElement.children))k===x||k.hasAttribute("inert")||k.matches("[aria-live], script, style, link, template")||(k.setAttribute("inert",""),i.push(k));u.contains(document.activeElement)||u.focus();const m=x=>{if(x.key!=="Escape"||x.defaultPrevented)return;const k=x.target;lc.test(k.tagName)||k.isContentEditable||(x.preventDefault(),l.current())};return u.addEventListener("keydown",m),()=>{u.removeEventListener("keydown",m),i.forEach(x=>x.removeAttribute("inert")),d&&d.isConnected&&d!==document.body&&d.focus()}},[]),e.jsx("div",{ref:r,role:"dialog","aria-modal":"true","aria-labelledby":t,tabIndex:-1,style:{outline:"none",...a},...o,children:n})}const Bn="xenon.devices.view";function Vn(){try{return window.localStorage}catch{return null}}function uc(t,s){const n=t.get("view");return n==="table"||n==="cards"?n:s}function hc(t,s,n){s==="table"||s!==n?t.set("view",s):t.delete("view")}function tn(t=Vn()){try{return(t==null?void 0:t.getItem(Bn))==="table"?"table":"cards"}catch{return"cards"}}function mc(t,s=Vn()){try{s==null||s.setItem(Bn,t)}catch{}}class pc extends Fe.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.searchRef=Fe.createRef(),this.containerRef=Fe.createRef(),this.stickyGroupRef=Fe.createRef(),this.stickyObserver=null,this.observeStickyGroup=()=>{if(typeof ResizeObserver>"u")return;const n=this.stickyGroupRef.current,a=this.containerRef.current;!n||!a||(this.stickyObserver=new ResizeObserver(()=>{a.style.setProperty("--de2-sticky-h",`${n.offsetHeight}px`)}),this.stickyObserver.observe(n))},this.onSlash=n=>{var r,l;if(n.key!=="/"||n.ctrlKey||n.altKey||n.metaKey||this.props.params.udid)return;const a=n.target;(r=a==null?void 0:a.closest)!=null&&r.call(a,'input, textarea, select, [contenteditable]:not([contenteditable="false"])')||(n.preventDefault(),(l=this.searchRef.current)==null||l.focus())},this.clearFilters=()=>{var n;this.props.onFiltersChange(xr),(n=this.searchRef.current)==null||n.focus()},this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,loaded:!1}}componentDidMount(){this.fetchDevices(),this.devicePolling=setInterval(()=>{this.fetchDevices()},1e4);const s=this.props.onSocketEvent("device_unblocked",()=>{this.fetchDevicesDebounced()}),n=this.props.onSocketEvent("device_blocked",()=>{this.fetchDevicesDebounced()});this.socketCleanups.push(s,n),document.addEventListener("keydown",this.onSlash),this.observeStickyGroup()}componentWillUnmount(){var s;this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(n=>n()),document.removeEventListener("keydown",this.onSlash),(s=this.stickyObserver)==null||s.disconnect()}fetchDevicesDebounced(){this.refreshTimeout&&clearTimeout(this.refreshTimeout),this.refreshTimeout=setTimeout(()=>{this.refreshTimeout=null,this.fetchDevices()},500)}getBusyDevicesCount(s){return s.filter(n=>n.busy).length}async fetchDevices(){try{const s=await M.getDevices(),n=this.getBusyDevicesCount(s),a=await M.getPendingSessionsCount(),o=await M.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:a,queueSummary:o,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}setFilters(s){this.props.onFiltersChange({...this.props.filters,...s})}getFiltered(){const s=Date.now();return this.state.devices.filter(n=>Tt(n,this.props.filters,s))}render(){const s=this.getFiltered(),{udid:n}=this.props.params,a=n?this.state.devices.find(i=>i.udid===n):null,{filters:o}=this.props,r=jr(this.state.devices,o,Date.now()),l=[{value:"all",label:"Any platform",count:r.platform.all},{value:"android",label:"Android",count:r.platform.android},{value:"ios",label:"iOS",count:r.platform.ios}];(Nr(this.state.devices)||o.platform==="tvos")&&l.push({value:"tvos",label:"tvOS",count:r.platform.tvos});const u=[{value:"all",label:"Any type",count:r.type.all},{value:"real",label:"Real devices",count:r.type.real},{value:"virtual",label:"Virtual",note:"Simulators and emulators",count:r.type.virtual}],d=`/devices${this.props.locationSearch}`;return e.jsxs("div",{className:"device-explorer-container",ref:this.containerRef,children:[e.jsxs("div",{className:"de2-sticky-group",ref:this.stickyGroupRef,children:[e.jsx(Qn,{icon:ns,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),e.jsxs("div",{className:"de2-toolbar",children:[e.jsx(Ls,{size:"sm",label:"Status",value:o.status,onChange:i=>this.setFilters({status:i}),segments:[{value:"all",label:"All",count:r.status.all},{value:"ready",label:"Ready",tone:"ready",count:r.status.ready},{value:"busy",label:"Busy",tone:"busy",count:r.status.busy},{value:"reserved",label:"Reserved",tone:"reserved",count:r.status.reserved},{value:"maintenance",label:"Maintenance",tone:"maintenance",count:r.status.maintenance},{value:"offline",label:"Offline",tone:"offline",count:r.status.offline}]}),e.jsxs("div",{className:"de2-toolbar-row",children:[e.jsxs("div",{className:"de2-search-wrap",children:[e.jsx(hs,{size:13,className:"de2-search-icon","aria-hidden":"true"}),e.jsx("input",{ref:this.searchRef,type:"text",className:"de2-search","aria-label":"Search devices",placeholder:"Search name, model or UDID…",value:o.q,onChange:i=>this.setFilters({q:i.target.value})}),e.jsx("kbd",{className:"de2-key","aria-hidden":"true",children:"/"})]}),e.jsx(Ps,{name:"Platform",value:o.platform,anyValue:"all",options:l,onChange:i=>this.setFilters({platform:i})}),e.jsx(Ps,{name:"Type",value:o.type,anyValue:"all",options:u,onChange:i=>this.setFilters({type:i})}),kr(o)&&e.jsx(Y,{variant:"ghost",size:"sm",onClick:this.clearFilters,children:"Clear"}),e.jsxs("div",{className:"de2-result",children:[e.jsx(Ls,{size:"sm",label:"View",value:this.props.view,onChange:this.props.onViewChange,segments:[{value:"cards",label:"Cards"},{value:"table",label:"Table"}]}),this.state.loaded&&e.jsx("span",{"aria-live":"polite",children:wr(s.length,this.state.devices.length)}),e.jsx(Y,{variant:"secondary",size:"icon","aria-label":"Refresh devices",title:"Refresh",onClick:()=>this.fetchDevices(),children:e.jsx(St,{size:13,"aria-hidden":"true"})})]})]})]})]}),s.length>0?this.props.view==="table"?e.jsx(Ir,{devices:s,reloadDevices:()=>this.fetchDevices(),sort:this.props.sort,onSortChange:this.props.onSortChange}):e.jsx(yr,{devices:s,reloadDevices:()=>this.fetchDevices()}):e.jsxs("div",{className:"device-explorer-empty stagger-1",children:[e.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?e.jsx(ns,{size:32}):e.jsx(St,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Global Device Registry Empty"}),e.jsx("p",{children:"Xenon hasn't detected any active device nodes in your infrastructure. Ensure your device farm is connected and heartbeat signals are active."}),e.jsxs(Y,{variant:"primary",onClick:()=>this.fetchDevices(),children:[e.jsx(St,{size:14}),"Manual sync"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"No devices match these filters"}),e.jsx("p",{children:"Try another filter or search, or clear them to see every device."}),e.jsx(Y,{variant:"secondary",onClick:this.clearFilters,children:"Clear filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Loading devices…"}),e.jsx("p",{children:"Syncing the global device registry."})]})]}),a&&e.jsx(dc,{className:"device-control-modal-overlay",labelledBy:"device-control-title",onClose:()=>this.props.navigate(d),children:e.jsx("div",{className:"device-control-modal",children:e.jsx(cc,{device:a,titleId:"device-control-title",onClose:()=>this.props.navigate(d)})})})]})}}function Gc(){const t=an(),s=mt(),n=Mt(),[a,o]=Zn(),{on:r}=Jn(),l=vr(a),u=uc(a,tn()),d=Rr(a),i=(m,x,k)=>{const f=gr(m);hc(f,x,tn()),Ar(f,k),o(f,{replace:!0})};return e.jsx(pc,{params:t,navigate:s,onSocketEvent:r,filters:l,onFiltersChange:m=>i(m,u,d),view:u,onViewChange:m=>{mc(m),i(l,m,d)},sort:d,onSortChange:m=>i(l,u,m),locationSearch:n.search})}export{pc as DeviceExplorer,Gc as default};
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-CzaIyL9t.js";/**
1
+ import{c as o}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as t,j as e,e as m,g as b}from"./index-CzaIyL9t.js";import{u as g}from"./use-password-reset-mode-Dbr2HEfw.js";import{A as c}from"./auth-shell-DKrtcIjG.js";import"./network-BP_U4iDZ.js";function N(){const[s,d]=t.useState(""),[a,o]=t.useState(!1),[u,x]=t.useState(!1),[n,l]=t.useState(null),i=g();async function f(r){r.preventDefault(),o(!0),l(null);try{await b(s),x(!0)}catch(h){l(h.message||"Request failed")}finally{o(!1)}}return i!=="email"?e.jsxs(c,{children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Forgot password?"}),i==="admin"&&e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"This Xenon server can't send email, so passwords are reset by an administrator. Ask a Xenon admin to send you a reset link from the Users page."}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx(m,{to:"/login",className:"text-sm text-[var(--color-accent)] underline-offset-4 hover:underline",children:"Back to sign in"})})]}):e.jsx(c,{children:e.jsxs("form",{onSubmit:f,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Forgot password?"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Enter your email and we'll send you a reset link if your account exists."}),u?e.jsx("div",{className:"text-sm text-[var(--text)] mb-6",children:"If your email is registered, you'll receive a reset link shortly. Check your spam folder if you don't see it within a minute."}):e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"Email"}),e.jsx("input",{id:"forgot-email",type:"email",autoComplete:"username",value:s,onChange:r=>d(r.target.value),autoFocus:!0,required:!0,className:"w-full mb-4 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),n&&e.jsx("div",{role:"alert",className:"text-sm text-[var(--red)] mb-3",children:n}),e.jsx("button",{type:"submit",disabled:a||!s,className:"mt-5 w-full h-10 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] font-medium text-sm disabled:opacity-50",children:a?"Sending…":"Send reset link"})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx(m,{to:"/login",className:"text-sm text-[var(--color-accent)] underline-offset-4 hover:underline",children:"Back to sign in"})})]})})}export{N as default};
1
+ import{r as t,j as e,e as m,g as b}from"./index-EkaQM1DK.js";import{u as g}from"./use-password-reset-mode-iPen3tmC.js";import{A as c}from"./auth-shell-COODQnc7.js";import"./network-DfIhNVJv.js";function N(){const[s,d]=t.useState(""),[a,o]=t.useState(!1),[u,x]=t.useState(!1),[n,l]=t.useState(null),i=g();async function f(r){r.preventDefault(),o(!0),l(null);try{await b(s),x(!0)}catch(h){l(h.message||"Request failed")}finally{o(!1)}}return i!=="email"?e.jsxs(c,{children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Forgot password?"}),i==="admin"&&e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"This Xenon server can't send email, so passwords are reset by an administrator. Ask a Xenon admin to send you a reset link from the Users page."}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx(m,{to:"/login",className:"text-sm text-[var(--color-accent)] underline-offset-4 hover:underline",children:"Back to sign in"})})]}):e.jsx(c,{children:e.jsxs("form",{onSubmit:f,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Forgot password?"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Enter your email and we'll send you a reset link if your account exists."}),u?e.jsx("div",{className:"text-sm text-[var(--text)] mb-6",children:"If your email is registered, you'll receive a reset link shortly. Check your spam folder if you don't see it within a minute."}):e.jsxs(e.Fragment,{children:[e.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"Email"}),e.jsx("input",{id:"forgot-email",type:"email",autoComplete:"username",value:s,onChange:r=>d(r.target.value),autoFocus:!0,required:!0,className:"w-full mb-4 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),n&&e.jsx("div",{role:"alert",className:"text-sm text-[var(--red)] mb-3",children:n}),e.jsx("button",{type:"submit",disabled:a||!s,className:"mt-5 w-full h-10 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] font-medium text-sm disabled:opacity-50",children:a?"Sending…":"Send reset link"})]}),e.jsx("div",{className:"mt-6 text-center",children:e.jsx(m,{to:"/login",className:"text-sm text-[var(--color-accent)] underline-offset-4 hover:underline",children:"Back to sign in"})})]})})}export{N as default};