@xenon-device-management/xenon 1.20.0 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{ApiKeyGate-BABGSy1i.js → ApiKeyGate-DZb6NwEl.js} +1 -1
  3. package/lib/public/assets/{BugReportButton-4m4Y_LS3.js → BugReportButton-CXMTmp4u.js} +1 -1
  4. package/lib/public/assets/{DeviceMosaicView-CTILyDMn.js → DeviceMosaicView-D18a1AYh.js} +1 -1
  5. package/lib/public/assets/{EmptyState-DQjkAs6E.js → EmptyState-DdKOWe90.js} +1 -1
  6. package/lib/public/assets/{FieldGroup-B5HSkoxj.js → FieldGroup-CeFDx8aU.js} +1 -1
  7. package/lib/public/assets/{Modal-D1DIlPgm.js → Modal-BeDHd61x.js} +1 -1
  8. package/lib/public/assets/{SegmentedControl-DtHDTd9m.js → SegmentedControl-ClGNBJqP.js} +1 -1
  9. package/lib/public/assets/{SettingCard-DtkCn4q0.js → SettingCard-D5Ljar8F.js} +1 -1
  10. package/lib/public/assets/{Table-BQLHmVyw.js → Table-CVoYIFrV.js} +1 -1
  11. package/lib/public/assets/{activity-BUVdIHTH.js → activity-C8kSwV4x.js} +1 -1
  12. package/lib/public/assets/{ai-settings-Cc3aNAs0.js → ai-settings-mZn3VsgO.js} +1 -1
  13. package/lib/public/assets/{api-keys-BKk5N0Fs.js → api-keys-BN4ZdSKI.js} +1 -1
  14. package/lib/public/assets/{apps-CqcnrTiP.js → apps--1DGQgSd.js} +1 -1
  15. package/lib/public/assets/{arrow-left-CeW6MRNG.js → arrow-left-Bx1-ExQr.js} +1 -1
  16. package/lib/public/assets/{arrow-up-right-DYQjtRzb.js → arrow-up-right-C06pFukR.js} +1 -1
  17. package/lib/public/assets/{auth-shell-3rXgmBRG.js → auth-shell-Bzztd971.js} +1 -1
  18. package/lib/public/assets/{builds-page-DMznORfV.js → builds-page-uchHuZzS.js} +1 -1
  19. package/lib/public/assets/{button-Bi5H-gGT.js → button-BD0qp0wO.js} +1 -1
  20. package/lib/public/assets/{check-1auudctF.js → check-DfuIwbk5.js} +1 -1
  21. package/lib/public/assets/{chevron-right-BHn4RCoz.js → chevron-right-Bnhlh4jC.js} +1 -1
  22. package/lib/public/assets/{circle-check-BAIn7YvX.js → circle-check-BYavFzCx.js} +1 -1
  23. package/lib/public/assets/{circle-x-D-_UjXlI.js → circle-x-D0e-HLLy.js} +1 -1
  24. package/lib/public/assets/{clock-BzHhw-xm.js → clock-Y9Spj4eZ.js} +1 -1
  25. package/lib/public/assets/{copy-DG1R6680.js → copy-D2H_l8Za.js} +1 -1
  26. package/lib/public/assets/{device-explorer-7JD8N-_n.js → device-explorer-wIzpD8uj.js} +12 -12
  27. package/lib/public/assets/{download-Cx9WDlI2.js → download-DXRyWZTc.js} +1 -1
  28. package/lib/public/assets/{forgot-password-Byqmzw_O.js → forgot-password-D1hanmCa.js} +1 -1
  29. package/lib/public/assets/{funnel-BFyZ7G9z.js → funnel-_KldywHh.js} +1 -1
  30. package/lib/public/assets/{index-BFS4wF31.js → index-D9hpVxoi.js} +2 -2
  31. package/lib/public/assets/{input-CbAP0tgk.js → input-DNFrhBhx.js} +1 -1
  32. package/lib/public/assets/{layers-Dw6KDmWo.js → layers-y9zk6puF.js} +1 -1
  33. package/lib/public/assets/{lock-C6S_QcG7.js → lock-D8MCyBaM.js} +1 -1
  34. package/lib/public/assets/{login-Blcmuu4J.js → login-DKWKvs3G.js} +1 -1
  35. package/lib/public/assets/{maintenance-settings-BFISTbRy.js → maintenance-settings-CjVfi491.js} +1 -1
  36. package/lib/public/assets/{mouse-pointer-2-DABeHy09.js → mouse-pointer-2-x4iFczMu.js} +1 -1
  37. package/lib/public/assets/{overview-ZuJdRhQx.js → overview-C6ZfEbkx.js} +1 -1
  38. package/lib/public/assets/{page-header-uEn6xivM.js → page-header-B4fWZ7PA.js} +1 -1
  39. package/lib/public/assets/{plus-Sd_byQ7-.js → plus-D6xpkCEm.js} +1 -1
  40. package/lib/public/assets/{profile-page-DzD6YAPL.js → profile-page-C5a037Qf.js} +1 -1
  41. package/lib/public/assets/{reset-password-BnUFqdVO.js → reset-password-C4Ive_lM.js} +1 -1
  42. package/lib/public/assets/{runbook-page-DwJttGLl.js → runbook-page-81jN3TdY.js} +1 -1
  43. package/lib/public/assets/{select-CtlQcJFr.js → select-BscNeBV4.js} +1 -1
  44. package/lib/public/assets/{selector-detail-page-C3lWoByr.js → selector-detail-page-RO6D6fu3.js} +1 -1
  45. package/lib/public/assets/{selector-health-page-D0lBB0T7.js → selector-health-page-BNqjAYVM.js} +1 -1
  46. package/lib/public/assets/{selector-health-CCotmR5q.js → selector-health-rV92V-Zl.js} +1 -1
  47. package/lib/public/assets/{session-detail-page-BnvfQhJM.js → session-detail-page-BgRonRhj.js} +1 -1
  48. package/lib/public/assets/{settings--bXEQ9dN.js → settings-CUtTT1jN.js} +1 -1
  49. package/lib/public/assets/{shield-B6DFMhSp.js → shield-CexzwYTz.js} +1 -1
  50. package/lib/public/assets/{shield-alert-DE_SfjOV.js → shield-alert-BIv3SNUv.js} +1 -1
  51. package/lib/public/assets/{status-pill-outline-8mPSR7wJ.js → status-pill-outline-CkiBdQ0F.js} +1 -1
  52. package/lib/public/assets/{tablet-BpjnQ_rz.js → tablet-D8v87f0D.js} +1 -1
  53. package/lib/public/assets/{teams-Dg5Wv2bk.js → teams-B-H7q6dd.js} +1 -1
  54. package/lib/public/assets/{trash-2-DMTAWEgU.js → trash-2-B3JVmViZ.js} +1 -1
  55. package/lib/public/assets/{upload-CQj0W4Es.js → upload-BLZQPsul.js} +1 -1
  56. package/lib/public/assets/{useSocket-CsIluyB5.js → useSocket-DsmPkV7G.js} +1 -1
  57. package/lib/public/assets/{users-BTPG8x-E.js → users-CQh4bnF2.js} +1 -1
  58. package/lib/public/assets/{webhook-settings-BOVemyZr.js → webhook-settings-BlK9CsG0.js} +1 -1
  59. package/lib/public/assets/{zap-DQQn_Np-.js → zap-o6UsCI-y.js} +1 -1
  60. package/lib/public/index.html +1 -1
  61. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{g as W,j as t,r as d,h as hn,R as Jn,i as Qn,k as je,C as Os,U as ei,X as B,m as Zt,n as fn,u as ks,b as ti,o as si,p as tt,q as Ot,s as pn,c as gn,t as is,S as Ps,v as rs}from"./index-BFS4wF31.js";import{P as ni}from"./page-header-uEn6xivM.js";import{B as st}from"./button-Bi5H-gGT.js";import{S as Jt}from"./select-CtlQcJFr.js";import{P as Pe,B as ii}from"./BugReportButton-4m4Y_LS3.js";import{P as wt,u as Vt,a as vt,b as xn,c as As,d as ri,D as oi,e as zs,f as ai,g as nt,h as ci,M as yn}from"./Modal-D1DIlPgm.js";import{F as Ut}from"./FieldGroup-B5HSkoxj.js";import{C as vn}from"./clock-BzHhw-xm.js";import{P as li}from"./plus-Sd_byQ7-.js";import{A as di}from"./activity-BUVdIHTH.js";import{C as Xe}from"./copy-DG1R6680.js";import{T as bn,P as ui,U as mi}from"./upload-CQj0W4Es.js";import{f as hi}from"./time-B8FIgwPE.js";import{M as Fs,F as fi}from"./mouse-pointer-2-DABeHy09.js";import{L as pi,C as os}from"./layers-Dw6KDmWo.js";import{S as et}from"./shield-alert-DE_SfjOV.js";import{Z as xs}from"./zap-DQQn_Np-.js";import{C as Bt}from"./check-1auudctF.js";import{C as wn}from"./chevron-right-BHn4RCoz.js";import{A as xt,I as as}from"./keycodes-bIEJfQzr.js";import{D as gi}from"./download-Cx9WDlI2.js";import{T as Ht}from"./trash-2-DMTAWEgU.js";import{L as xi}from"./lock-C6S_QcG7.js";import{S as yi}from"./SegmentedControl-DtHDTd9m.js";import{u as vi}from"./useSocket-CsIluyB5.js";import"./utils-CDN07tui.js";/**
1
+ import{g as W,j as t,r as d,h as hn,R as Jn,i as Qn,k as je,C as Os,U as ei,X as B,m as Zt,n as fn,u as ks,b as ti,o as si,p as tt,q as Ot,s as pn,c as gn,t as is,S as Ps,v as rs}from"./index-D9hpVxoi.js";import{P as ni}from"./page-header-B4fWZ7PA.js";import{B as st}from"./button-BD0qp0wO.js";import{S as Jt}from"./select-BscNeBV4.js";import{P as Pe,B as ii}from"./BugReportButton-CXMTmp4u.js";import{P as wt,u as Vt,a as vt,b as xn,c as As,d as ri,D as oi,e as zs,f as ai,g as nt,h as ci,M as yn}from"./Modal-BeDHd61x.js";import{F as Ut}from"./FieldGroup-CeFDx8aU.js";import{C as vn}from"./clock-Y9Spj4eZ.js";import{P as li}from"./plus-D6xpkCEm.js";import{A as di}from"./activity-C8kSwV4x.js";import{C as Xe}from"./copy-D2H_l8Za.js";import{T as bn,P as ui,U as mi}from"./upload-BLZQPsul.js";import{f as hi}from"./time-B8FIgwPE.js";import{M as Fs,F as fi}from"./mouse-pointer-2-x4iFczMu.js";import{L as pi,C as os}from"./layers-y9zk6puF.js";import{S as et}from"./shield-alert-BIv3SNUv.js";import{Z as xs}from"./zap-o6UsCI-y.js";import{C as Bt}from"./check-DfuIwbk5.js";import{C as wn}from"./chevron-right-Bnhlh4jC.js";import{A as xt,I as as}from"./keycodes-bIEJfQzr.js";import{D as gi}from"./download-DXRyWZTc.js";import{T as Ht}from"./trash-2-B3JVmViZ.js";import{L as xi}from"./lock-D8MCyBaM.js";import{S as yi}from"./SegmentedControl-ClGNBJqP.js";import{u as vi}from"./useSocket-DsmPkV7G.js";import"./utils-CDN07tui.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -193,7 +193,7 @@ import{g as W,j as t,r as d,h as hn,R as Jn,i as Qn,k as je,C as Os,U as ei,X as
193
193
  *
194
194
  * This source code is licensed under the ISC license.
195
195
  * See the LICENSE file in the root directory of this source tree.
196
- */const Ir=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],_r=W("wifi",Ir);function Or(e){if(typeof e!="number")throw new TypeError("Expected a number");const s=e>0?Math.floor:Math.ceil;return{days:s(e/864e5),hours:s(e/36e5)%24,minutes:s(e/6e4)%60,seconds:s(e/1e3)%60,milliseconds:s(e)%1e3,microseconds:s(e*1e3)%1e3,nanoseconds:s(e*1e6)%1e3}}const Pr=(e,s)=>s===1?e:`${e}s`,zr=1e-7;function Hs(e,s={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],i=(c,l)=>{const o=Math.floor(c*10**l+zr);return(Math.round(o)/10**l).toFixed(l)},r=(c,l,o,u)=>{if((n.length===0||!s.colonNotation)&&c===0&&!(s.colonNotation&&o==="m"))return;u=(u||c||"0").toString();let m,x;if(s.colonNotation){m=n.length>0?":":"",x="";const g=u.includes(".")?u.split(".")[0].length:u.length,f=n.length>0?2:1;u="0".repeat(Math.max(0,f-g))+u}else m="",x=s.verbose?" "+Pr(l,c):o;n.push(m+u+x)},a=Or(e);if(r(Math.trunc(a.days/365),"year","y"),r(a.days%365,"day","d"),r(a.hours,"hour","h"),r(a.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&e<1e3)if(r(a.seconds,"second","s"),s.formatSubMilliseconds)r(a.milliseconds,"millisecond","ms"),r(a.microseconds,"microsecond","µs"),r(a.nanoseconds,"nanosecond","ns");else{const c=a.milliseconds+a.microseconds/1e3+a.nanoseconds/1e6,l=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,o=c>=1?Math.round(c):Math.ceil(c),u=l?c.toFixed(l):o;r(Number.parseFloat(u),"millisecond","ms",u)}else{const c=e/1e3%60,l=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,o=i(c,l),u=s.keepDecimalsOnWholeSeconds?o:o.replace(/\.0+$/,"");r(Number.parseFloat(u),"second","s",u)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const c=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(c)}return s.colonNotation?n.join(""):n.join(" ")}const Fr=({kind:e,size:s=6,className:n})=>t.jsx("span",{className:`status-dot status-dot-${e}${n?" "+n:""}`,style:{width:s,height:s},"aria-hidden":!0}),Ur=({kind:e,showDot:s,children:n})=>t.jsxs("span",{className:`status-code status-code-${e}`,children:[s&&t.jsx(Fr,{kind:e}),t.jsx("span",{className:"status-code-label",children:String(n).toUpperCase()})]}),ds=({label:e,value:s,mono:n,valueClassName:i})=>t.jsxs("div",{className:"kv-row",children:[t.jsx("span",{className:"kv-label",children:e}),t.jsx("span",{className:`kv-value${n?" kv-value-mono":""}${i?" "+i:""}`,children:s})]}),Br=["top","right","bottom","left"],ze=Math.min,le=Math.max,qt=Math.round,Pt=Math.floor,Ce=e=>({x:e,y:e}),Hr={left:"right",right:"left",bottom:"top",top:"bottom"};function vs(e,s,n){return le(e,ze(s,n))}function De(e,s){return typeof e=="function"?e(s):e}function Te(e){return e.split("-")[0]}function at(e){return e.split("-")[1]}function Rs(e){return e==="x"?"y":"x"}function Es(e){return e==="y"?"height":"width"}function Ne(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function $s(e){return Rs(Ne(e))}function Wr(e,s,n){n===void 0&&(n=!1);const i=at(e),r=$s(e),a=Es(r);let c=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return s.reference[a]>s.floating[a]&&(c=Xt(c)),[c,Xt(c)]}function Vr(e){const s=Xt(e);return[bs(e),s,bs(s)]}function bs(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ws=["left","right"],Vs=["right","left"],qr=["top","bottom"],Xr=["bottom","top"];function Kr(e,s,n){switch(e){case"top":case"bottom":return n?s?Vs:Ws:s?Ws:Vs;case"left":case"right":return s?qr:Xr;default:return[]}}function Gr(e,s,n,i){const r=at(e);let a=Kr(Te(e),n==="start",i);return r&&(a=a.map(c=>c+"-"+r),s&&(a=a.concat(a.map(bs)))),a}function Xt(e){const s=Te(e);return Hr[s]+e.slice(s.length)}function Yr(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nn(e){return typeof e!="number"?Yr(e):{top:e,right:e,bottom:e,left:e}}function Kt(e){const{x:s,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:s,right:s+i,bottom:n+r,x:s,y:n}}function qs(e,s,n){let{reference:i,floating:r}=e;const a=Ne(s),c=$s(s),l=Es(c),o=Te(s),u=a==="y",m=i.x+i.width/2-r.width/2,x=i.y+i.height/2-r.height/2,g=i[l]/2-r[l]/2;let f;switch(o){case"top":f={x:m,y:i.y-r.height};break;case"bottom":f={x:m,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:x};break;case"left":f={x:i.x-r.width,y:x};break;default:f={x:i.x,y:i.y}}switch(at(s)){case"start":f[c]-=g*(n&&u?-1:1);break;case"end":f[c]+=g*(n&&u?-1:1);break}return f}async function Zr(e,s){var n;s===void 0&&(s={});const{x:i,y:r,platform:a,rects:c,elements:l,strategy:o}=e,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:x="floating",altBoundary:g=!1,padding:f=0}=De(s,e),v=Nn(f),b=l[g?x==="floating"?"reference":"floating":x],k=Kt(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(b)))==null||n?b:b.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:m,strategy:o})),C=x==="floating"?{x:i,y:r,width:c.floating.width,height:c.floating.height}:c.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),j=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},$=Kt(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:C,offsetParent:N,strategy:o}):C);return{top:(k.top-$.top+v.top)/j.y,bottom:($.bottom-k.bottom+v.bottom)/j.y,left:(k.left-$.left+v.left)/j.x,right:($.right-k.right+v.right)/j.x}}const Jr=50,Qr=async(e,s,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:a=[],platform:c}=n,l=c.detectOverflow?c:{...c,detectOverflow:Zr},o=await(c.isRTL==null?void 0:c.isRTL(s));let u=await c.getElementRects({reference:e,floating:s,strategy:r}),{x:m,y:x}=qs(u,i,o),g=i,f=0;const v={};for(let w=0;w<a.length;w++){const b=a[w];if(!b)continue;const{name:k,fn:C}=b,{x:N,y:j,data:$,reset:R}=await C({x:m,y:x,initialPlacement:i,placement:g,strategy:r,middlewareData:v,rects:u,platform:l,elements:{reference:e,floating:s}});m=N??m,x=j??x,v[k]={...v[k],...$},R&&f<Jr&&(f++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(u=R.rects===!0?await c.getElementRects({reference:e,floating:s,strategy:r}):R.rects),{x:m,y:x}=qs(u,g,o)),w=-1)}return{x:m,y:x,placement:g,strategy:r,middlewareData:v}},eo=e=>({name:"arrow",options:e,async fn(s){const{x:n,y:i,placement:r,rects:a,platform:c,elements:l,middlewareData:o}=s,{element:u,padding:m=0}=De(e,s)||{};if(u==null)return{};const x=Nn(m),g={x:n,y:i},f=$s(r),v=Es(f),w=await c.getDimensions(u),b=f==="y",k=b?"top":"left",C=b?"bottom":"right",N=b?"clientHeight":"clientWidth",j=a.reference[v]+a.reference[f]-g[f]-a.floating[v],$=g[f]-a.reference[f],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let I=R?R[N]:0;(!I||!await(c.isElement==null?void 0:c.isElement(R)))&&(I=l.floating[N]||a.floating[v]);const D=j/2-$/2,H=I/2-w[v]/2-1,T=ze(x[k],H),_=ze(x[C],H),z=T,G=I-w[v]-_,V=I/2-w[v]/2+D,J=vs(z,V,G),F=!o.arrow&&at(r)!=null&&V!==J&&a.reference[v]/2-(V<z?T:_)-w[v]/2<0,U=F?V<z?V-z:V-G:0;return{[f]:g[f]+U,data:{[f]:J,centerOffset:V-J-U,...F&&{alignmentOffset:U}},reset:F}}}),to=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var n,i;const{placement:r,middlewareData:a,rects:c,initialPlacement:l,platform:o,elements:u}=s,{mainAxis:m=!0,crossAxis:x=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:w=!0,...b}=De(e,s);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const k=Te(r),C=Ne(l),N=Te(l)===l,j=await(o.isRTL==null?void 0:o.isRTL(u.floating)),$=g||(N||!w?[Xt(l)]:Vr(l)),R=v!=="none";!g&&R&&$.push(...Gr(l,w,v,j));const I=[l,...$],D=await o.detectOverflow(s,b),H=[];let T=((i=a.flip)==null?void 0:i.overflows)||[];if(m&&H.push(D[k]),x){const V=Wr(r,c,j);H.push(D[V[0]],D[V[1]])}if(T=[...T,{placement:r,overflows:H}],!H.every(V=>V<=0)){var _,z;const V=(((_=a.flip)==null?void 0:_.index)||0)+1,J=I[V];if(J&&(!(x==="alignment"?C!==Ne(J):!1)||T.every(p=>Ne(p.placement)===C?p.overflows[0]>0:!0)))return{data:{index:V,overflows:T},reset:{placement:J}};let F=(z=T.filter(U=>U.overflows[0]<=0).sort((U,p)=>U.overflows[1]-p.overflows[1])[0])==null?void 0:z.placement;if(!F)switch(f){case"bestFit":{var G;const U=(G=T.filter(p=>{if(R){const Q=Ne(p.placement);return Q===C||Q==="y"}return!0}).map(p=>[p.placement,p.overflows.filter(Q=>Q>0).reduce((Q,ie)=>Q+ie,0)]).sort((p,Q)=>p[1]-Q[1])[0])==null?void 0:G[0];U&&(F=U);break}case"initialPlacement":F=l;break}if(r!==F)return{reset:{placement:F}}}return{}}}};function Xs(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function Ks(e){return Br.some(s=>e[s]>=0)}const so=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:n,platform:i}=s,{strategy:r="referenceHidden",...a}=De(e,s);switch(r){case"referenceHidden":{const c=await i.detectOverflow(s,{...a,elementContext:"reference"}),l=Xs(c,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ks(l)}}}case"escaped":{const c=await i.detectOverflow(s,{...a,altBoundary:!0}),l=Xs(c,n.floating);return{data:{escapedOffsets:l,escaped:Ks(l)}}}default:return{}}}}},Cn=new Set(["left","top"]);async function no(e,s){const{placement:n,platform:i,elements:r}=e,a=await(i.isRTL==null?void 0:i.isRTL(r.floating)),c=Te(n),l=at(n),o=Ne(n)==="y",u=Cn.has(c)?-1:1,m=a&&o?-1:1,x=De(s,e);let{mainAxis:g,crossAxis:f,alignmentAxis:v}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return l&&typeof v=="number"&&(f=l==="end"?v*-1:v),o?{x:f*m,y:g*u}:{x:g*u,y:f*m}}const io=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var n,i;const{x:r,y:a,placement:c,middlewareData:l}=s,o=await no(s,e);return c===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+o.x,y:a+o.y,data:{...o,placement:c}}}}},ro=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:n,y:i,placement:r,platform:a}=s,{mainAxis:c=!0,crossAxis:l=!1,limiter:o={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...u}=De(e,s),m={x:n,y:i},x=await a.detectOverflow(s,u),g=Ne(Te(r)),f=Rs(g);let v=m[f],w=m[g];if(c){const k=f==="y"?"top":"left",C=f==="y"?"bottom":"right",N=v+x[k],j=v-x[C];v=vs(N,v,j)}if(l){const k=g==="y"?"top":"left",C=g==="y"?"bottom":"right",N=w+x[k],j=w-x[C];w=vs(N,w,j)}const b=o.fn({...s,[f]:v,[g]:w});return{...b,data:{x:b.x-n,y:b.y-i,enabled:{[f]:c,[g]:l}}}}}},oo=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:n,y:i,placement:r,rects:a,middlewareData:c}=s,{offset:l=0,mainAxis:o=!0,crossAxis:u=!0}=De(e,s),m={x:n,y:i},x=Ne(r),g=Rs(x);let f=m[g],v=m[x];const w=De(l,s),b=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(o){const N=g==="y"?"height":"width",j=a.reference[g]-a.floating[N]+b.mainAxis,$=a.reference[g]+a.reference[N]-b.mainAxis;f<j?f=j:f>$&&(f=$)}if(u){var k,C;const N=g==="y"?"width":"height",j=Cn.has(Te(r)),$=a.reference[x]-a.floating[N]+(j&&((k=c.offset)==null?void 0:k[x])||0)+(j?0:b.crossAxis),R=a.reference[x]+a.reference[N]+(j?0:((C=c.offset)==null?void 0:C[x])||0)-(j?b.crossAxis:0);v<$?v=$:v>R&&(v=R)}return{[g]:f,[x]:v}}}},ao=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var n,i;const{placement:r,rects:a,platform:c,elements:l}=s,{apply:o=()=>{},...u}=De(e,s),m=await c.detectOverflow(s,u),x=Te(r),g=at(r),f=Ne(r)==="y",{width:v,height:w}=a.floating;let b,k;x==="top"||x==="bottom"?(b=x,k=g===(await(c.isRTL==null?void 0:c.isRTL(l.floating))?"start":"end")?"left":"right"):(k=x,b=g==="end"?"top":"bottom");const C=w-m.top-m.bottom,N=v-m.left-m.right,j=ze(w-m[b],C),$=ze(v-m[k],N),R=!s.middlewareData.shift;let I=j,D=$;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&(D=N),(i=s.middlewareData.shift)!=null&&i.enabled.y&&(I=C),R&&!g){const T=le(m.left,0),_=le(m.right,0),z=le(m.top,0),G=le(m.bottom,0);f?D=v-2*(T!==0||_!==0?T+_:le(m.left,m.right)):I=w-2*(z!==0||G!==0?z+G:le(m.top,m.bottom))}await o({...s,availableWidth:D,availableHeight:I});const H=await c.getDimensions(l.floating);return v!==H.width||w!==H.height?{reset:{rects:!0}}:{}}}};function Qt(){return typeof window<"u"}function ct(e){return Sn(e)?(e.nodeName||"").toLowerCase():"#document"}function de(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function Se(e){var s;return(s=(Sn(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function Sn(e){return Qt()?e instanceof Node||e instanceof de(e).Node:!1}function ge(e){return Qt()?e instanceof Element||e instanceof de(e).Element:!1}function Le(e){return Qt()?e instanceof HTMLElement||e instanceof de(e).HTMLElement:!1}function Gs(e){return!Qt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof de(e).ShadowRoot}function jt(e){const{overflow:s,overflowX:n,overflowY:i,display:r}=xe(e);return/auto|scroll|overlay|hidden|clip/.test(s+i+n)&&r!=="inline"&&r!=="contents"}function co(e){return/^(table|td|th)$/.test(ct(e))}function es(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const lo=/transform|translate|scale|rotate|perspective|filter/,uo=/paint|layout|strict|content/,qe=e=>!!e&&e!=="none";let us;function Ds(e){const s=ge(e)?xe(e):e;return qe(s.transform)||qe(s.translate)||qe(s.scale)||qe(s.rotate)||qe(s.perspective)||!Ts()&&(qe(s.backdropFilter)||qe(s.filter))||lo.test(s.willChange||"")||uo.test(s.contain||"")}function mo(e){let s=Fe(e);for(;Le(s)&&!rt(s);){if(Ds(s))return s;if(es(s))return null;s=Fe(s)}return null}function Ts(){return us==null&&(us=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),us}function rt(e){return/^(html|body|#document)$/.test(ct(e))}function xe(e){return de(e).getComputedStyle(e)}function ts(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fe(e){if(ct(e)==="html")return e;const s=e.assignedSlot||e.parentNode||Gs(e)&&e.host||Se(e);return Gs(s)?s.host:s}function kn(e){const s=Fe(e);return rt(s)?e.ownerDocument?e.ownerDocument.body:e.body:Le(s)&&jt(s)?s:kn(s)}function bt(e,s,n){var i;s===void 0&&(s=[]),n===void 0&&(n=!0);const r=kn(e),a=r===((i=e.ownerDocument)==null?void 0:i.body),c=de(r);if(a){const l=ws(c);return s.concat(c,c.visualViewport||[],jt(r)?r:[],l&&n?bt(l):[])}else return s.concat(r,bt(r,[],n))}function ws(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function An(e){const s=xe(e);let n=parseFloat(s.width)||0,i=parseFloat(s.height)||0;const r=Le(e),a=r?e.offsetWidth:n,c=r?e.offsetHeight:i,l=qt(n)!==a||qt(i)!==c;return l&&(n=a,i=c),{width:n,height:i,$:l}}function Ms(e){return ge(e)?e:e.contextElement}function it(e){const s=Ms(e);if(!Le(s))return Ce(1);const n=s.getBoundingClientRect(),{width:i,height:r,$:a}=An(s);let c=(a?qt(n.width):n.width)/i,l=(a?qt(n.height):n.height)/r;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}const ho=Ce(0);function Rn(e){const s=de(e);return!Ts()||!s.visualViewport?ho:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function fo(e,s,n){return s===void 0&&(s=!1),!n||s&&n!==de(e)?!1:s}function Ke(e,s,n,i){s===void 0&&(s=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Ms(e);let c=Ce(1);s&&(i?ge(i)&&(c=it(i)):c=it(e));const l=fo(a,n,i)?Rn(a):Ce(0);let o=(r.left+l.x)/c.x,u=(r.top+l.y)/c.y,m=r.width/c.x,x=r.height/c.y;if(a){const g=de(a),f=i&&ge(i)?de(i):i;let v=g,w=ws(v);for(;w&&i&&f!==v;){const b=it(w),k=w.getBoundingClientRect(),C=xe(w),N=k.left+(w.clientLeft+parseFloat(C.paddingLeft))*b.x,j=k.top+(w.clientTop+parseFloat(C.paddingTop))*b.y;o*=b.x,u*=b.y,m*=b.x,x*=b.y,o+=N,u+=j,v=de(w),w=ws(v)}}return Kt({width:m,height:x,x:o,y:u})}function ss(e,s){const n=ts(e).scrollLeft;return s?s.left+n:Ke(Se(e)).left+n}function En(e,s){const n=e.getBoundingClientRect(),i=n.left+s.scrollLeft-ss(e,n),r=n.top+s.scrollTop;return{x:i,y:r}}function po(e){let{elements:s,rect:n,offsetParent:i,strategy:r}=e;const a=r==="fixed",c=Se(i),l=s?es(s.floating):!1;if(i===c||l&&a)return n;let o={scrollLeft:0,scrollTop:0},u=Ce(1);const m=Ce(0),x=Le(i);if((x||!x&&!a)&&((ct(i)!=="body"||jt(c))&&(o=ts(i)),x)){const f=Ke(i);u=it(i),m.x=f.x+i.clientLeft,m.y=f.y+i.clientTop}const g=c&&!x&&!a?En(c,o):Ce(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-o.scrollLeft*u.x+m.x+g.x,y:n.y*u.y-o.scrollTop*u.y+m.y+g.y}}function go(e){return Array.from(e.getClientRects())}function xo(e){const s=Se(e),n=ts(e),i=e.ownerDocument.body,r=le(s.scrollWidth,s.clientWidth,i.scrollWidth,i.clientWidth),a=le(s.scrollHeight,s.clientHeight,i.scrollHeight,i.clientHeight);let c=-n.scrollLeft+ss(e);const l=-n.scrollTop;return xe(i).direction==="rtl"&&(c+=le(s.clientWidth,i.clientWidth)-r),{width:r,height:a,x:c,y:l}}const Ys=25;function yo(e,s){const n=de(e),i=Se(e),r=n.visualViewport;let a=i.clientWidth,c=i.clientHeight,l=0,o=0;if(r){a=r.width,c=r.height;const m=Ts();(!m||m&&s==="fixed")&&(l=r.offsetLeft,o=r.offsetTop)}const u=ss(i);if(u<=0){const m=i.ownerDocument,x=m.body,g=getComputedStyle(x),f=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,v=Math.abs(i.clientWidth-x.clientWidth-f);v<=Ys&&(a-=v)}else u<=Ys&&(a+=u);return{width:a,height:c,x:l,y:o}}function vo(e,s){const n=Ke(e,!0,s==="fixed"),i=n.top+e.clientTop,r=n.left+e.clientLeft,a=Le(e)?it(e):Ce(1),c=e.clientWidth*a.x,l=e.clientHeight*a.y,o=r*a.x,u=i*a.y;return{width:c,height:l,x:o,y:u}}function Zs(e,s,n){let i;if(s==="viewport")i=yo(e,n);else if(s==="document")i=xo(Se(e));else if(ge(s))i=vo(s,n);else{const r=Rn(e);i={x:s.x-r.x,y:s.y-r.y,width:s.width,height:s.height}}return Kt(i)}function $n(e,s){const n=Fe(e);return n===s||!ge(n)||rt(n)?!1:xe(n).position==="fixed"||$n(n,s)}function bo(e,s){const n=s.get(e);if(n)return n;let i=bt(e,[],!1).filter(l=>ge(l)&&ct(l)!=="body"),r=null;const a=xe(e).position==="fixed";let c=a?Fe(e):e;for(;ge(c)&&!rt(c);){const l=xe(c),o=Ds(c);!o&&l.position==="fixed"&&(r=null),(a?!o&&!r:!o&&l.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||jt(c)&&!o&&$n(e,c))?i=i.filter(m=>m!==c):r=l,c=Fe(c)}return s.set(e,i),i}function wo(e){let{element:s,boundary:n,rootBoundary:i,strategy:r}=e;const c=[...n==="clippingAncestors"?es(s)?[]:bo(s,this._c):[].concat(n),i],l=Zs(s,c[0],r);let o=l.top,u=l.right,m=l.bottom,x=l.left;for(let g=1;g<c.length;g++){const f=Zs(s,c[g],r);o=le(f.top,o),u=ze(f.right,u),m=ze(f.bottom,m),x=le(f.left,x)}return{width:u-x,height:m-o,x,y:o}}function jo(e){const{width:s,height:n}=An(e);return{width:s,height:n}}function No(e,s,n){const i=Le(s),r=Se(s),a=n==="fixed",c=Ke(e,!0,a,s);let l={scrollLeft:0,scrollTop:0};const o=Ce(0);function u(){o.x=ss(r)}if(i||!i&&!a)if((ct(s)!=="body"||jt(r))&&(l=ts(s)),i){const f=Ke(s,!0,a,s);o.x=f.x+s.clientLeft,o.y=f.y+s.clientTop}else r&&u();a&&!i&&r&&u();const m=r&&!i&&!a?En(r,l):Ce(0),x=c.left+l.scrollLeft-o.x-m.x,g=c.top+l.scrollTop-o.y-m.y;return{x,y:g,width:c.width,height:c.height}}function ms(e){return xe(e).position==="static"}function Js(e,s){if(!Le(e)||xe(e).position==="fixed")return null;if(s)return s(e);let n=e.offsetParent;return Se(e)===n&&(n=n.ownerDocument.body),n}function Dn(e,s){const n=de(e);if(es(e))return n;if(!Le(e)){let r=Fe(e);for(;r&&!rt(r);){if(ge(r)&&!ms(r))return r;r=Fe(r)}return n}let i=Js(e,s);for(;i&&co(i)&&ms(i);)i=Js(i,s);return i&&rt(i)&&ms(i)&&!Ds(i)?n:i||mo(e)||n}const Co=async function(e){const s=this.getOffsetParent||Dn,n=this.getDimensions,i=await n(e.floating);return{reference:No(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function So(e){return xe(e).direction==="rtl"}const ko={convertOffsetParentRelativeRectToViewportRelativeRect:po,getDocumentElement:Se,getClippingRect:wo,getOffsetParent:Dn,getElementRects:Co,getClientRects:go,getDimensions:jo,getScale:it,isElement:ge,isRTL:So};function Tn(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function Ao(e,s){let n=null,i;const r=Se(e);function a(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}function c(l,o){l===void 0&&(l=!1),o===void 0&&(o=1),a();const u=e.getBoundingClientRect(),{left:m,top:x,width:g,height:f}=u;if(l||s(),!g||!f)return;const v=Pt(x),w=Pt(r.clientWidth-(m+g)),b=Pt(r.clientHeight-(x+f)),k=Pt(m),N={rootMargin:-v+"px "+-w+"px "+-b+"px "+-k+"px",threshold:le(0,ze(1,o))||1};let j=!0;function $(R){const I=R[0].intersectionRatio;if(I!==o){if(!j)return c();I?c(!1,I):i=setTimeout(()=>{c(!1,1e-7)},1e3)}I===1&&!Tn(u,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver($,{...N,root:r.ownerDocument})}catch{n=new IntersectionObserver($,N)}n.observe(e)}return c(!0),a}function Ro(e,s,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:o=!1}=i,u=Ms(e),m=r||a?[...u?bt(u):[],...s?bt(s):[]]:[];m.forEach(k=>{r&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const x=u&&l?Ao(u,n):null;let g=-1,f=null;c&&(f=new ResizeObserver(k=>{let[C]=k;C&&C.target===u&&f&&s&&(f.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=f)==null||N.observe(s)})),n()}),u&&!o&&f.observe(u),s&&f.observe(s));let v,w=o?Ke(e):null;o&&b();function b(){const k=Ke(e);w&&!Tn(w,k)&&n(),w=k,v=requestAnimationFrame(b)}return n(),()=>{var k;m.forEach(C=>{r&&C.removeEventListener("scroll",n),a&&C.removeEventListener("resize",n)}),x==null||x(),(k=f)==null||k.disconnect(),f=null,o&&cancelAnimationFrame(v)}}const Eo=io,$o=ro,Do=to,To=ao,Mo=so,Qs=eo,Lo=oo,Io=(e,s,n)=>{const i=new Map,r={platform:ko,...n},a={...r.platform,_c:i};return Qr(e,s,{...r,platform:a})};var _o=typeof document<"u",Oo=function(){},Wt=_o?d.useLayoutEffect:Oo;function Gt(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let n,i,r;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==s.length)return!1;for(i=n;i--!==0;)if(!Gt(e[i],s[i]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(s).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(s,r[i]))return!1;for(i=n;i--!==0;){const a=r[i];if(!(a==="_owner"&&e.$$typeof)&&!Gt(e[a],s[a]))return!1}return!0}return e!==e&&s!==s}function Mn(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function en(e,s){const n=Mn(e);return Math.round(s*n)/n}function hs(e){const s=d.useRef(e);return Wt(()=>{s.current=e}),s}function Po(e){e===void 0&&(e={});const{placement:s="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:a,floating:c}={},transform:l=!0,whileElementsMounted:o,open:u}=e,[m,x]=d.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[g,f]=d.useState(i);Gt(g,i)||f(i);const[v,w]=d.useState(null),[b,k]=d.useState(null),C=d.useCallback(p=>{p!==R.current&&(R.current=p,w(p))},[]),N=d.useCallback(p=>{p!==I.current&&(I.current=p,k(p))},[]),j=a||v,$=c||b,R=d.useRef(null),I=d.useRef(null),D=d.useRef(m),H=o!=null,T=hs(o),_=hs(r),z=hs(u),G=d.useCallback(()=>{if(!R.current||!I.current)return;const p={placement:s,strategy:n,middleware:g};_.current&&(p.platform=_.current),Io(R.current,I.current,p).then(Q=>{const ie={...Q,isPositioned:z.current!==!1};V.current&&!Gt(D.current,ie)&&(D.current=ie,hn.flushSync(()=>{x(ie)}))})},[g,s,n,_,z]);Wt(()=>{u===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,x(p=>({...p,isPositioned:!1})))},[u]);const V=d.useRef(!1);Wt(()=>(V.current=!0,()=>{V.current=!1}),[]),Wt(()=>{if(j&&(R.current=j),$&&(I.current=$),j&&$){if(T.current)return T.current(j,$,G);G()}},[j,$,G,T,H]);const J=d.useMemo(()=>({reference:R,floating:I,setReference:C,setFloating:N}),[C,N]),F=d.useMemo(()=>({reference:j,floating:$}),[j,$]),U=d.useMemo(()=>{const p={position:n,left:0,top:0};if(!F.floating)return p;const Q=en(F.floating,m.x),ie=en(F.floating,m.y);return l?{...p,transform:"translate("+Q+"px, "+ie+"px)",...Mn(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Q,top:ie}},[n,l,F.floating,m.x,m.y]);return d.useMemo(()=>({...m,update:G,refs:J,elements:F,floatingStyles:U}),[m,G,J,F,U])}const zo=e=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:i,padding:r}=typeof e=="function"?e(n):e;return i&&s(i)?i.current!=null?Qs({element:i.current,padding:r}).fn(n):{}:i?Qs({element:i,padding:r}).fn(n):{}}}},Fo=(e,s)=>{const n=Eo(e);return{name:n.name,fn:n.fn,options:[e,s]}},Uo=(e,s)=>{const n=$o(e);return{name:n.name,fn:n.fn,options:[e,s]}},Bo=(e,s)=>({fn:Lo(e).fn,options:[e,s]}),Ho=(e,s)=>{const n=Do(e);return{name:n.name,fn:n.fn,options:[e,s]}},Wo=(e,s)=>{const n=To(e);return{name:n.name,fn:n.fn,options:[e,s]}},Vo=(e,s)=>{const n=Mo(e);return{name:n.name,fn:n.fn,options:[e,s]}},qo=(e,s)=>{const n=zo(e);return{name:n.name,fn:n.fn,options:[e,s]}};var Xo="Arrow",Ln=d.forwardRef((e,s)=>{const{children:n,width:i=10,height:r=5,...a}=e;return t.jsx(wt.svg,{...a,ref:s,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ln.displayName=Xo;var Ko=Ln;function Go(e){const[s,n]=d.useState(void 0);return Vt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let c,l;if("borderBoxSize"in a){const o=a.borderBoxSize,u=Array.isArray(o)?o[0]:o;c=u.inlineSize,l=u.blockSize}else c=e.offsetWidth,l=e.offsetHeight;n({width:c,height:l})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else n(void 0)},[e]),s}var Ls="Popper",[In]=As(Ls),[Yo,_n]=In(Ls),On=e=>{const{__scopePopper:s,children:n}=e,[i,r]=d.useState(null);return t.jsx(Yo,{scope:s,anchor:i,onAnchorChange:r,children:n})};On.displayName=Ls;var Pn="PopperAnchor",zn=d.forwardRef((e,s)=>{const{__scopePopper:n,virtualRef:i,...r}=e,a=_n(Pn,n),c=d.useRef(null),l=vt(s,c),o=d.useRef(null);return d.useEffect(()=>{const u=o.current;o.current=(i==null?void 0:i.current)||c.current,u!==o.current&&a.onAnchorChange(o.current)}),i?null:t.jsx(wt.div,{...r,ref:l})});zn.displayName=Pn;var Is="PopperContent",[Zo,Jo]=In(Is),Fn=d.forwardRef((e,s)=>{var P,Z,ne,se,Ae,Ge;const{__scopePopper:n,side:i="bottom",sideOffset:r=0,align:a="center",alignOffset:c=0,arrowPadding:l=0,avoidCollisions:o=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:x="partial",hideWhenDetached:g=!1,updatePositionStrategy:f="optimized",onPlaced:v,...w}=e,b=_n(Is,n),[k,C]=d.useState(null),N=vt(s,ae=>C(ae)),[j,$]=d.useState(null),R=Go(j),I=(R==null?void 0:R.width)??0,D=(R==null?void 0:R.height)??0,H=i+(a!=="center"?"-"+a:""),T=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},_=Array.isArray(u)?u:[u],z=_.length>0,G={padding:T,boundary:_.filter(ta),altBoundary:z},{refs:V,floatingStyles:J,placement:F,isPositioned:U,middlewareData:p}=Po({strategy:"fixed",placement:H,whileElementsMounted:(...ae)=>Ro(...ae,{animationFrame:f==="always"}),elements:{reference:b.anchor},middleware:[Fo({mainAxis:r+D,alignmentAxis:c}),o&&Uo({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?Bo():void 0,...G}),o&&Ho({...G}),Wo({...G,apply:({elements:ae,rects:be,availableWidth:Ue,availableHeight:Ye})=>{const{width:Ie,height:lt}=be.reference,he=ae.floating.style;he.setProperty("--radix-popper-available-width",`${Ue}px`),he.setProperty("--radix-popper-available-height",`${Ye}px`),he.setProperty("--radix-popper-anchor-width",`${Ie}px`),he.setProperty("--radix-popper-anchor-height",`${lt}px`)}}),j&&qo({element:j,padding:l}),sa({arrowWidth:I,arrowHeight:D}),g&&Vo({strategy:"referenceHidden",...G})]}),[Q,ie]=Bn(F),oe=xn(v);Vt(()=>{U&&(oe==null||oe())},[U,oe]);const ye=(P=p.arrow)==null?void 0:P.x,ue=(Z=p.arrow)==null?void 0:Z.y,ve=((ne=p.arrow)==null?void 0:ne.centerOffset)!==0,[ke,Y]=d.useState();return Vt(()=>{k&&Y(window.getComputedStyle(k).zIndex)},[k]),t.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:U?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(se=p.transformOrigin)==null?void 0:se.x,(Ae=p.transformOrigin)==null?void 0:Ae.y].join(" "),...((Ge=p.hide)==null?void 0:Ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Zo,{scope:n,placedSide:Q,onArrowChange:$,arrowX:ye,arrowY:ue,shouldHideArrow:ve,children:t.jsx(wt.div,{"data-side":Q,"data-align":ie,...w,ref:N,style:{...w.style,animation:U?void 0:"none"}})})})});Fn.displayName=Is;var Un="PopperArrow",Qo={top:"bottom",right:"left",bottom:"top",left:"right"},ea=d.forwardRef(function(s,n){const{__scopePopper:i,...r}=s,a=Jo(Un,i),c=Qo[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(Ko,{...r,ref:n,style:{...r.style,display:"block"}})})});ea.displayName=Un;function ta(e){return e!==null}var sa=e=>({name:"transformOrigin",options:e,fn(s){var b,k,C;const{placement:n,rects:i,middlewareData:r}=s,c=((b=r.arrow)==null?void 0:b.centerOffset)!==0,l=c?0:e.arrowWidth,o=c?0:e.arrowHeight,[u,m]=Bn(n),x={start:"0%",center:"50%",end:"100%"}[m],g=(((k=r.arrow)==null?void 0:k.x)??0)+l/2,f=(((C=r.arrow)==null?void 0:C.y)??0)+o/2;let v="",w="";return u==="bottom"?(v=c?x:`${g}px`,w=`${-o}px`):u==="top"?(v=c?x:`${g}px`,w=`${i.floating.height+o}px`):u==="right"?(v=`${-o}px`,w=c?x:`${f}px`):u==="left"&&(v=`${i.floating.width+o}px`,w=c?x:`${f}px`),{data:{x:v,y:w}}}});function Bn(e){const[s,n="center"]=e.split("-");return[s,n]}var na=On,ia=zn,ra=Fn,oa=Symbol.for("react.lazy"),Yt=Jn[" use ".trim().toString()];function aa(e){return typeof e=="object"&&e!==null&&"then"in e}function Hn(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===oa&&"_payload"in e&&aa(e._payload)}function ca(e){const s=la(e),n=d.forwardRef((i,r)=>{let{children:a,...c}=i;Hn(a)&&typeof Yt=="function"&&(a=Yt(a._payload));const l=d.Children.toArray(a),o=l.find(ua);if(o){const u=o.props.children,m=l.map(x=>x===o?d.Children.count(u)>1?d.Children.only(null):d.isValidElement(u)?u.props.children:null:x);return t.jsx(s,{...c,ref:r,children:d.isValidElement(u)?d.cloneElement(u,void 0,m):null})}return t.jsx(s,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function la(e){const s=d.forwardRef((n,i)=>{let{children:r,...a}=n;if(Hn(r)&&typeof Yt=="function"&&(r=Yt(r._payload)),d.isValidElement(r)){const c=ha(r),l=ma(a,r.props);return r.type!==d.Fragment&&(l.ref=i?ri(i,c):c),d.cloneElement(r,l)}return d.Children.count(r)>1?d.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var da=Symbol("radix.slottable");function ua(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===da}function ma(e,s){const n={...s};for(const i in s){const r=e[i],a=s[i];/^on[A-Z]/.test(i)?r&&a?n[i]=(...l)=>{const o=a(...l);return r(...l),o}:r&&(n[i]=r):i==="style"?n[i]={...r,...a}:i==="className"&&(n[i]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function ha(e){var i,r;let s=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?e.ref:(s=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pa=fa.reduce((e,s)=>{const n=ca(`Primitive.${s}`),i=d.forwardRef((r,a)=>{const{asChild:c,...l}=r,o=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...l,ref:a})});return i.displayName=`Primitive.${s}`,{...e,[s]:i}},{}),ga="Portal",Wn=d.forwardRef((e,s)=>{var l;const{container:n,...i}=e,[r,a]=d.useState(!1);Vt(()=>a(!0),[]);const c=n||r&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return c?Qn.createPortal(t.jsx(pa.div,{...i,ref:s}),c):null});Wn.displayName=ga;const xa=({open:e,onClose:s,anchorRef:n,placement:i="bottom-end",children:r})=>{const a=d.useRef(null);if(d.useEffect(()=>{if(!e)return;const u=m=>{var x,g;e&&((x=a.current)!=null&&x.contains(m.target)||(g=n.current)!=null&&g.contains(m.target)||s())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,s,n]),!e)return null;const c=i.startsWith("top")?"top":"bottom",l=i.endsWith("end")?"end":"start",o=i.startsWith("top")?8:4;return t.jsxs(na,{children:[t.jsx(ia,{virtualRef:n}),t.jsx(Wn,{children:t.jsx(oi,{onEscapeKeyDown:u=>{u.preventDefault(),s()},onPointerDownOutside:u=>{var m;if((m=n.current)!=null&&m.contains(u.target)){u.preventDefault();return}s()},children:t.jsx(ra,{ref:a,side:c,align:l,sideOffset:o,className:`popover popover-${i}`,role:"dialog",children:r})})})]})};function ya(e){const s=e+"CollectionProvider",[n,i]=As(s),[r,a]=n(s,{collectionRef:{current:null},itemMap:new Map}),c=w=>{const{scope:b,children:k}=w,C=je.useRef(null),N=je.useRef(new Map).current;return t.jsx(r,{scope:b,itemMap:N,collectionRef:C,children:k})};c.displayName=s;const l=e+"CollectionSlot",o=zs(l),u=je.forwardRef((w,b)=>{const{scope:k,children:C}=w,N=a(l,k),j=vt(b,N.collectionRef);return t.jsx(o,{ref:j,children:C})});u.displayName=l;const m=e+"CollectionItemSlot",x="data-radix-collection-item",g=zs(m),f=je.forwardRef((w,b)=>{const{scope:k,children:C,...N}=w,j=je.useRef(null),$=vt(b,j),R=a(m,k);return je.useEffect(()=>(R.itemMap.set(j,{ref:j,...N}),()=>void R.itemMap.delete(j))),t.jsx(g,{[x]:"",ref:$,children:C})});f.displayName=m;function v(w){const b=a(e+"CollectionConsumer",w);return je.useCallback(()=>{const C=b.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${x}]`));return Array.from(b.itemMap.values()).sort((R,I)=>N.indexOf(R.ref.current)-N.indexOf(I.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:c,Slot:u,ItemSlot:f},v,i]}var va=d.createContext(void 0);function ba(e){const s=d.useContext(va);return e||s||"ltr"}var fs="rovingFocusGroup.onEntryFocus",wa={bubbles:!1,cancelable:!0},Nt="RovingFocusGroup",[js,Vn,ja]=ya(Nt),[Na]=As(Nt,[ja]),[Ca,Sa]=Na(Nt),qn=d.forwardRef((e,s)=>t.jsx(js.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(js.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(ka,{...e,ref:s})})}));qn.displayName=Nt;var ka=d.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:o,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...x}=e,g=d.useRef(null),f=vt(s,g),v=ba(a),[w,b]=ci({prop:c,defaultProp:l??null,onChange:o,caller:Nt}),[k,C]=d.useState(!1),N=xn(u),j=Vn(n),$=d.useRef(!1),[R,I]=d.useState(0);return d.useEffect(()=>{const D=g.current;if(D)return D.addEventListener(fs,N),()=>D.removeEventListener(fs,N)},[N]),t.jsx(Ca,{scope:n,orientation:i,dir:v,loop:r,currentTabStopId:w,onItemFocus:d.useCallback(D=>b(D),[b]),onItemShiftTab:d.useCallback(()=>C(!0),[]),onFocusableItemAdd:d.useCallback(()=>I(D=>D+1),[]),onFocusableItemRemove:d.useCallback(()=>I(D=>D-1),[]),children:t.jsx(wt.div,{tabIndex:k||R===0?-1:0,"data-orientation":i,...x,ref:f,style:{outline:"none",...e.style},onMouseDown:nt(e.onMouseDown,()=>{$.current=!0}),onFocus:nt(e.onFocus,D=>{const H=!$.current;if(D.target===D.currentTarget&&H&&!k){const T=new CustomEvent(fs,wa);if(D.currentTarget.dispatchEvent(T),!T.defaultPrevented){const _=j().filter(F=>F.focusable),z=_.find(F=>F.active),G=_.find(F=>F.id===w),J=[z,G,..._].filter(Boolean).map(F=>F.ref.current);Gn(J,m)}}$.current=!1}),onBlur:nt(e.onBlur,()=>C(!1))})})}),Xn="RovingFocusGroupItem",Kn=d.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:a,children:c,...l}=e,o=ai(),u=a||o,m=Sa(Xn,n),x=m.currentTabStopId===u,g=Vn(n),{onFocusableItemAdd:f,onFocusableItemRemove:v,currentTabStopId:w}=m;return d.useEffect(()=>{if(i)return f(),()=>v()},[i,f,v]),t.jsx(js.ItemSlot,{scope:n,id:u,focusable:i,active:r,children:t.jsx(wt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...l,ref:s,onMouseDown:nt(e.onMouseDown,b=>{i?m.onItemFocus(u):b.preventDefault()}),onFocus:nt(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:nt(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){m.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const k=Ea(b,m.orientation,m.dir);if(k!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let N=g().filter(j=>j.focusable).map(j=>j.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const j=N.indexOf(b.currentTarget);N=m.loop?$a(N,j+1):N.slice(j+1)}setTimeout(()=>Gn(N))}}),children:typeof c=="function"?c({isCurrentTabStop:x,hasTabStop:w!=null}):c})})});Kn.displayName=Xn;var Aa={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ra(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ea(e,s,n){const i=Ra(e.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return Aa[i]}function Gn(e,s=!1){const n=document.activeElement;for(const i of e)if(i===n||(i.focus({preventScroll:s}),document.activeElement!==n))return}function $a(e,s){return e.map((n,i)=>e[(s+i)%e.length])}var Da=qn,Ta=Kn;const zt=({icon:e,children:s,onClick:n,danger:i,disabled:r})=>t.jsx(Ta,{asChild:!0,focusable:!r,active:!1,children:t.jsxs("button",{type:"button",role:"menuitem",className:`menu-item${i?" menu-item-danger":""}`,onClick:n,disabled:r,children:[e&&t.jsx("span",{className:"menu-item-icon",children:e}),t.jsx("span",{className:"menu-item-label",children:s})]})}),Ma=({children:e})=>t.jsx(Da,{asChild:!0,orientation:"vertical",loop:!0,children:t.jsx("div",{className:"menu",role:"menu",children:e})}),La=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],Ia=({device:e,onClose:s,onReserved:n})=>{const[i,r]=d.useState(""),[a,c]=d.useState("1h"),[l,o]=d.useState(""),[u,m]=d.useState(!1),[x,g]=d.useState(null),[f,v]=d.useState(null),w=async()=>{if(!i.trim()){g("Please enter your name/ID");return}m(!0),g(null),v(null);try{const b=await B.reserveDevice(e.udid,e.host,i,a,l);b.success?(n(),s()):v(b.error||"Failed to reserve device")}catch(b){v(b.message||"An unexpected error occurred")}finally{m(!1)}};return t.jsx(yn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Mi,{size:16,className:"title-icon"}),"Reserve Device"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,disabled:u,children:"Cancel"}),t.jsx("button",{className:"btn-reserve",onClick:w,disabled:u||!i.trim(),children:u?"Reserving...":"Confirm Reservation"})]}),children:t.jsxs("div",{className:"reservation-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsxs("p",{children:["Reserve ",t.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(ei,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reserved By"]}),htmlFor:"reservation-reserved-by",error:x?t.jsxs(t.Fragment,{children:[t.jsx(Os,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),x]}):void 0,children:t.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:i,onChange:b=>{r(b.target.value),x&&g(null)},disabled:u})}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(vn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Duration"]}),children:t.jsx("div",{className:"duration-selector",children:La.map(b=>t.jsx("div",{className:`duration-option ${a===b.value?"active":""}`,onClick:()=>c(b.value),children:b.label},b.value))})}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(ar,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reason (Optional)"]}),htmlFor:"reservation-reason",error:f?t.jsxs(t.Fragment,{children:[t.jsx(Os,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:t.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:l,onChange:b=>o(b.target.value),disabled:u})})]})})},_a=({device:e,onClose:s,onUpdated:n})=>{const{toast:i}=Zt(),[r,a]=d.useState(e.tags||[]),[c,l]=d.useState(""),[o,u]=d.useState(!1),m=d.useRef(null);d.useEffect(()=>{m.current&&m.current.focus()},[]);const x=()=>{const w=c.trim();w&&!r.includes(w)&&(a([...r,w]),l(""))},g=w=>{a(r.filter(b=>b!==w))},f=w=>{w.key==="Enter"&&x()},v=async()=>{u(!0);try{await B.updateDeviceTags(e.udid,e.host,r),n(),s()}catch(w){console.error("Failed to update tags",w),i("Error saving tags. Please try again.","error")}finally{u(!1)}};return t.jsx(yn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Cr,{size:16,className:"title-icon"}),"Manage Device Tags"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),t.jsx("button",{className:"btn-save",onClick:v,disabled:o,children:o?"Saving...":"Apply Changes"})]}),children:t.jsxs("div",{className:"tag-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsx(Ut,{label:"Add New Tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:t.jsxs("div",{className:"input-with-button",children:[t.jsx("input",{ref:m,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:c,onChange:w=>l(w.target.value),onKeyDown:f}),t.jsx("button",{className:"add-inline-btn",onClick:x,disabled:!c.trim(),children:t.jsx(li,{size:16})})]})}),t.jsxs("div",{className:"tags-display-section",children:[t.jsx("label",{children:"Current Tags"}),t.jsx("div",{className:"tags-list",children:r.length>0?r.map(w=>t.jsxs("div",{className:"tag-pill-editable",children:[w,t.jsx("button",{className:"remove-tag",onClick:()=>g(w),children:t.jsx(fn,{size:12})})]},w)):t.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})};function Oa(e){return e>=50?"ready":e>=20?"reserved":"error"}function Pa(e){return e>=50?t.jsx(Ei,{size:10}):e>=20?t.jsx(Si,{size:10}):t.jsx(Ai,{size:10})}function za(e){return e==="Normal"?"ready":e==="Critical"?"error":"reserved"}const Fa=({device:e})=>{const s=typeof e.batteryLevel=="number",n=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!s&&!n?t.jsx("div",{className:"dc2-health",children:t.jsxs(Pe,{tone:"neutral",title:"Device does not report battery or thermal data",children:[t.jsx(di,{size:10}),"No telemetry"]})}):t.jsxs("div",{className:"dc2-health",children:[s&&t.jsxs(Pe,{tone:Oa(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[Pa(e.batteryLevel),e.batteryLevel,"%"]}),n&&t.jsxs(Pe,{tone:za(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[t.jsx(Er,{size:10}),e.thermalStatus]})]})},Ua=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,Ba=/^(?:\d{1,3}\.){3}\d{1,3}$/;function Ha(e){const s=e.trim();return!s||Ua.test(s)||!Ba.test(s)?!1:s.split(".").every(n=>{const i=Number(n);return Number.isInteger(i)&&i>=0&&i<=255})}function Wa(e){return e==="127.0.0.1"||e==="localhost"||e==="0.0.0.0"}function Va(e){if(!e)return null;try{const s=new URL(e.includes("://")?e:`http://${e}`);return s.port?`${s.hostname}:${s.port}`:s.hostname}catch{return e}}function qa(e){if(e.ip&&Ha(e.ip))return e.ip;const s=Va(e.host);if(!s)return"—";const n=s.split(":")[0];return Wa(n)?"—":s}const Xa="/wd/hub";function Ka(e){return e==="android"?"UiAutomator2":"XCUITest"}function Ga(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Ya(e,s=Xa){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),i=s.startsWith("/")?s:`/${s}`,r=n.pathname.replace(/\/$/,"");return r===i||r.endsWith(i)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${i}`}catch{return e}}function Za(e){const s={platformName:Ga(e.platform),"appium:automationName":Ka(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(s["appium:platformVersion"]=e.sdk),e.name&&(s["appium:deviceName"]=e.name),s}function Ja(e){return JSON.stringify(Za(e),null,2)}function Qa(e){return e==="real"?"Real":e==="simulator"?"Simulator":e==="emulator"?"Emulator":null}const tn="Shared",ec="Shared pool — visible to all authenticated users",tc=({udid:e,currentTeamId:s,resolvedTeamName:n,teams:i,canEdit:r,onChanged:a})=>{const{toast:c}=Zt(),[l,o]=d.useState(!1),[u,m]=d.useState(!1),x=s?i.get(s)??n??`Team ${s.slice(0,6)}`:tn;async function g(f){m(!0);try{await B.setDeviceTeam(e,f),c(f?"Device assigned":"Device returned to shared pool","success"),a(),o(!1)}catch(v){c((v==null?void 0:v.message)||"Failed to update team","error")}finally{m(!1)}}return r?l?t.jsxs(Jt,{selectSize:"sm",autoFocus:!0,disabled:u,defaultValue:s??"",onBlur:()=>o(!1),onChange:f=>g(f.target.value||null),children:[t.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(i.entries()).map(([f,v])=>t.jsx("option",{value:f,children:v},f))]}):t.jsx("button",{type:"button",onClick:()=>o(!0),className:"dc2-team-pill",title:s?"Click to change team":"Click to assign to a team",children:x}):s?t.jsx(Pe,{tone:"accent",title:`Team: ${x}`,children:x}):t.jsx(Pe,{tone:"neutral",title:ec,children:tn})};function sc(e){return e.offline?"offline":e.userBlocked?"error":e.busy?"busy":e.reservedUntil&&Date.now()<e.reservedUntil?"reserved":"ready"}function nc(e,s=10,n=4){return!e||e.length<=s+n+1?e:`${e.slice(0,s)}…${e.slice(-n)}`}const ic=({device:e,reloadDevices:s,navigate:n,teams:i})=>{var I,D,H;const[r,a]=d.useState(!1),[c,l]=d.useState(!1),[o,u]=d.useState(!1),m=d.useRef(null),{me:x}=ti(),{toast:g}=Zt(),f=(x==null?void 0:x.role)==="ADMIN"||(x==null?void 0:x.role)==="SUPER_ADMIN",v=sc(e),w=v==="reserved",b=!!(e.busy&&e.session_id&&!String(e.session_id).startsWith("manual_")),k=async(T,_)=>{var z;try{await((z=navigator.clipboard)==null?void 0:z.writeText(T)),g(_,"success")}catch{g("Failed to copy","error")}},C=Ya(e.host),N=Qa(e.deviceType),j=async()=>{await B.releaseReservation(e.udid,e.host),s()},$=async()=>{await B.blockDevice(e.udid,e.host),s()},R=async()=>{await B.unblockDevice(e.udid,e.host),s()};return t.jsxs("div",{className:`dc2 dc2-${v}`,children:[t.jsx("div",{className:"dc2-stripe"}),t.jsxs("div",{className:"dc2-header",children:[t.jsxs("span",{className:"dc2-platform",children:[e.platform.toUpperCase()," · ",e.sdk]}),t.jsx(Ur,{kind:v,showDot:!0,children:v})]}),t.jsx("div",{className:"dc2-name",title:e.name,children:e.name}),t.jsxs("div",{className:"dc2-udid-row",children:[t.jsx("div",{className:"dc2-udid",title:e.udid,children:nc(e.udid)}),t.jsx("button",{type:"button",className:"dc2-udid-copy",onClick:()=>k(e.udid,"UDID copied"),"aria-label":"Copy UDID",title:"Copy UDID",children:t.jsx(Xe,{size:12})})]}),t.jsx(Fa,{device:e}),t.jsxs("div",{className:"dc2-tags",children:[N&&t.jsx(Pe,{tone:"neutral",title:`Device type: ${N}`,children:N}),t.jsx(tc,{udid:e.udid,currentTeamId:e.teamId??null,resolvedTeamName:e.teamName??null,teams:i??new Map,canEdit:f,onChanged:s}),(I=e.tags)==null?void 0:I.slice(0,3).map(T=>t.jsx(Pe,{tone:"neutral",title:T,children:T},T)),(((D=e.tags)==null?void 0:D.length)||0)>3&&t.jsxs(Pe,{tone:"neutral",children:["+",(((H=e.tags)==null?void 0:H.length)||0)-3]})]}),t.jsxs("div",{className:"dc2-metrics",children:[w?t.jsxs("div",{className:"dc2-banner dc2-banner-reserved",children:[t.jsx(vn,{size:12}),t.jsxs("span",{children:["RES · ",e.reservedBy||"anon",e.reservedUntil?` (${Hs(e.reservedUntil-Date.now(),{compact:!0})})`:""]})]}):e.session_id?t.jsxs("div",{className:"dc2-banner dc2-banner-session",children:[t.jsx(bn,{size:12}),t.jsxs("span",{children:["SID · ",String(e.session_id).slice(0,10)]})]}):t.jsx(ds,{label:"Time in use",value:e.totalUtilizationTimeMilliSec?Hs(e.totalUtilizationTimeMilliSec,{compact:!0}):"—"}),t.jsx(ds,{label:"Network",value:qa(e),mono:!0}),t.jsx(ds,{label:"Server",mono:!0,value:t.jsxs("span",{className:"dc2-copyable",children:[t.jsx("span",{className:"dc2-copyable-text",title:C,children:C}),C!=="—"&&t.jsx("button",{type:"button",className:"dc2-udid-copy",onClick:()=>k(C,"Server URL copied"),"aria-label":"Copy Appium server URL",title:"Copy Appium server URL",children:t.jsx(Xe,{size:12})})]})})]}),t.jsxs("div",{className:"dc2-actions",children:[t.jsx(st,{variant:"primary",size:"sm",disabled:b,onClick:()=>{b||n(`/devices/${e.udid}/control`)},title:b?"Locked: Appium session running":"Take control",className:"dc2-primary",children:"Control"}),w?t.jsx(st,{variant:"secondary",size:"sm",onClick:j,children:"Release"}):!e.userBlocked&&!e.busy?t.jsx(st,{variant:"secondary",size:"sm",onClick:()=>a(!0),children:"Reserve"}):null,t.jsx("button",{ref:m,type:"button",className:"dc2-more",onClick:()=>u(T=>!T),"aria-label":"More actions",children:t.jsx(Gi,{size:14})}),t.jsx(xa,{open:o,onClose:()=>u(!1),anchorRef:m,children:t.jsxs(Ma,{children:[t.jsx(zt,{icon:t.jsx(Xe,{size:12}),onClick:()=>{u(!1),k(Ja(e),"Session capabilities copied")},children:"Copy caps…"}),t.jsx(zt,{onClick:()=>{u(!1),l(!0)},children:"Manage tags…"}),e.userBlocked?t.jsx(zt,{onClick:()=>{u(!1),R()},children:"Exit maintenance"}):t.jsx(zt,{onClick:()=>{u(!1),$()},children:"Enter maintenance"})]})})]}),r&&t.jsx(Ia,{device:e,onClose:()=>a(!1),onReserved:()=>s()}),c&&t.jsx(_a,{device:e,onClose:()=>l(!1),onUpdated:()=>s()})]})};function rc(e){const s=ks();return t.jsx(ic,{device:e.device,reloadDevices:e.reloadDevices,navigate:s,teams:e.teams})}class oc extends je.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){B.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return t.jsx("div",{className:"device-explorer-card-container",children:je.Children.toArray(this.props.devices.map(s=>t.jsx(rc,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}var Ft,ac=new Uint8Array(16);function cc(){if(!Ft&&(Ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ft(ac)}const lc=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function dc(e){return typeof e=="string"&&lc.test(e)}var re=[];for(var ps=0;ps<256;++ps)re.push((ps+256).toString(16).substr(1));function uc(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(re[e[s+0]]+re[e[s+1]]+re[e[s+2]]+re[e[s+3]]+"-"+re[e[s+4]]+re[e[s+5]]+"-"+re[e[s+6]]+re[e[s+7]]+"-"+re[e[s+8]]+re[e[s+9]]+"-"+re[e[s+10]]+re[e[s+11]]+re[e[s+12]]+re[e[s+13]]+re[e[s+14]]+re[e[s+15]]).toLowerCase();if(!dc(n))throw TypeError("Stringified UUID is invalid");return n}function mc(e,s,n){e=e||{};var i=e.random||(e.rng||cc)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,uc(i)}const hc=({onCommand:e,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:i})=>{const[r,a]=d.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[c,l]=d.useState(""),[o,u]=d.useState([]),[m,x]=d.useState(-1),[g,f]=d.useState(!1),v=d.useRef(null),w=d.useRef(null);d.useEffect(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[r]);const b=C=>{const N=C.trim();if((N.startsWith("{")||N.startsWith("["))&&(N.endsWith("}")||N.endsWith("]")))try{const j=JSON.parse(N);return JSON.stringify(j,null,2)}catch{}return C},k=async C=>{if(C.key==="Enter"&&!g){const N=c.trim();if(!N)return;if(l(""),a(j=>[...j,{type:"command",content:`${s} ${N}`,timestamp:Date.now()}]),u(j=>[...j,N]),x(-1),f(!0),N==="clear"){a([]),f(!1);return}if(N==="help"){let j="";i==="android"?j=`
196
+ */const Ir=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],_r=W("wifi",Ir);function Or(e){if(typeof e!="number")throw new TypeError("Expected a number");const s=e>0?Math.floor:Math.ceil;return{days:s(e/864e5),hours:s(e/36e5)%24,minutes:s(e/6e4)%60,seconds:s(e/1e3)%60,milliseconds:s(e)%1e3,microseconds:s(e*1e3)%1e3,nanoseconds:s(e*1e6)%1e3}}const Pr=(e,s)=>s===1?e:`${e}s`,zr=1e-7;function Hs(e,s={}){if(!Number.isFinite(e))throw new TypeError("Expected a finite number");s.colonNotation&&(s.compact=!1,s.formatSubMilliseconds=!1,s.separateMilliseconds=!1,s.verbose=!1),s.compact&&(s.secondsDecimalDigits=0,s.millisecondsDecimalDigits=0);const n=[],i=(c,l)=>{const o=Math.floor(c*10**l+zr);return(Math.round(o)/10**l).toFixed(l)},r=(c,l,o,u)=>{if((n.length===0||!s.colonNotation)&&c===0&&!(s.colonNotation&&o==="m"))return;u=(u||c||"0").toString();let m,x;if(s.colonNotation){m=n.length>0?":":"",x="";const g=u.includes(".")?u.split(".")[0].length:u.length,f=n.length>0?2:1;u="0".repeat(Math.max(0,f-g))+u}else m="",x=s.verbose?" "+Pr(l,c):o;n.push(m+u+x)},a=Or(e);if(r(Math.trunc(a.days/365),"year","y"),r(a.days%365,"day","d"),r(a.hours,"hour","h"),r(a.minutes,"minute","m"),s.separateMilliseconds||s.formatSubMilliseconds||!s.colonNotation&&e<1e3)if(r(a.seconds,"second","s"),s.formatSubMilliseconds)r(a.milliseconds,"millisecond","ms"),r(a.microseconds,"microsecond","µs"),r(a.nanoseconds,"nanosecond","ns");else{const c=a.milliseconds+a.microseconds/1e3+a.nanoseconds/1e6,l=typeof s.millisecondsDecimalDigits=="number"?s.millisecondsDecimalDigits:0,o=c>=1?Math.round(c):Math.ceil(c),u=l?c.toFixed(l):o;r(Number.parseFloat(u),"millisecond","ms",u)}else{const c=e/1e3%60,l=typeof s.secondsDecimalDigits=="number"?s.secondsDecimalDigits:1,o=i(c,l),u=s.keepDecimalsOnWholeSeconds?o:o.replace(/\.0+$/,"");r(Number.parseFloat(u),"second","s",u)}if(n.length===0)return"0"+(s.verbose?" milliseconds":"ms");if(s.compact)return n[0];if(typeof s.unitCount=="number"){const c=s.colonNotation?"":" ";return n.slice(0,Math.max(s.unitCount,1)).join(c)}return s.colonNotation?n.join(""):n.join(" ")}const Fr=({kind:e,size:s=6,className:n})=>t.jsx("span",{className:`status-dot status-dot-${e}${n?" "+n:""}`,style:{width:s,height:s},"aria-hidden":!0}),Ur=({kind:e,showDot:s,children:n})=>t.jsxs("span",{className:`status-code status-code-${e}`,children:[s&&t.jsx(Fr,{kind:e}),t.jsx("span",{className:"status-code-label",children:String(n).toUpperCase()})]}),ds=({label:e,value:s,mono:n,valueClassName:i})=>t.jsxs("div",{className:"kv-row",children:[t.jsx("span",{className:"kv-label",children:e}),t.jsx("span",{className:`kv-value${n?" kv-value-mono":""}${i?" "+i:""}`,children:s})]}),Br=["top","right","bottom","left"],ze=Math.min,le=Math.max,qt=Math.round,Pt=Math.floor,Ce=e=>({x:e,y:e}),Hr={left:"right",right:"left",bottom:"top",top:"bottom"};function vs(e,s,n){return le(e,ze(s,n))}function De(e,s){return typeof e=="function"?e(s):e}function Te(e){return e.split("-")[0]}function at(e){return e.split("-")[1]}function Rs(e){return e==="x"?"y":"x"}function Es(e){return e==="y"?"height":"width"}function Ne(e){const s=e[0];return s==="t"||s==="b"?"y":"x"}function $s(e){return Rs(Ne(e))}function Wr(e,s,n){n===void 0&&(n=!1);const i=at(e),r=$s(e),a=Es(r);let c=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return s.reference[a]>s.floating[a]&&(c=Xt(c)),[c,Xt(c)]}function Vr(e){const s=Xt(e);return[bs(e),s,bs(s)]}function bs(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Ws=["left","right"],Vs=["right","left"],qr=["top","bottom"],Xr=["bottom","top"];function Kr(e,s,n){switch(e){case"top":case"bottom":return n?s?Vs:Ws:s?Ws:Vs;case"left":case"right":return s?qr:Xr;default:return[]}}function Gr(e,s,n,i){const r=at(e);let a=Kr(Te(e),n==="start",i);return r&&(a=a.map(c=>c+"-"+r),s&&(a=a.concat(a.map(bs)))),a}function Xt(e){const s=Te(e);return Hr[s]+e.slice(s.length)}function Yr(e){return{top:0,right:0,bottom:0,left:0,...e}}function Nn(e){return typeof e!="number"?Yr(e):{top:e,right:e,bottom:e,left:e}}function Kt(e){const{x:s,y:n,width:i,height:r}=e;return{width:i,height:r,top:n,left:s,right:s+i,bottom:n+r,x:s,y:n}}function qs(e,s,n){let{reference:i,floating:r}=e;const a=Ne(s),c=$s(s),l=Es(c),o=Te(s),u=a==="y",m=i.x+i.width/2-r.width/2,x=i.y+i.height/2-r.height/2,g=i[l]/2-r[l]/2;let f;switch(o){case"top":f={x:m,y:i.y-r.height};break;case"bottom":f={x:m,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:x};break;case"left":f={x:i.x-r.width,y:x};break;default:f={x:i.x,y:i.y}}switch(at(s)){case"start":f[c]-=g*(n&&u?-1:1);break;case"end":f[c]+=g*(n&&u?-1:1);break}return f}async function Zr(e,s){var n;s===void 0&&(s={});const{x:i,y:r,platform:a,rects:c,elements:l,strategy:o}=e,{boundary:u="clippingAncestors",rootBoundary:m="viewport",elementContext:x="floating",altBoundary:g=!1,padding:f=0}=De(s,e),b=Nn(f),v=l[g?x==="floating"?"reference":"floating":x],k=Kt(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(v)))==null||n?v:v.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(l.floating)),boundary:u,rootBoundary:m,strategy:o})),C=x==="floating"?{x:i,y:r,width:c.floating.width,height:c.floating.height}:c.reference,N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(l.floating)),j=await(a.isElement==null?void 0:a.isElement(N))?await(a.getScale==null?void 0:a.getScale(N))||{x:1,y:1}:{x:1,y:1},D=Kt(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:C,offsetParent:N,strategy:o}):C);return{top:(k.top-D.top+b.top)/j.y,bottom:(D.bottom-k.bottom+b.bottom)/j.y,left:(k.left-D.left+b.left)/j.x,right:(D.right-k.right+b.right)/j.x}}const Jr=50,Qr=async(e,s,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:a=[],platform:c}=n,l=c.detectOverflow?c:{...c,detectOverflow:Zr},o=await(c.isRTL==null?void 0:c.isRTL(s));let u=await c.getElementRects({reference:e,floating:s,strategy:r}),{x:m,y:x}=qs(u,i,o),g=i,f=0;const b={};for(let w=0;w<a.length;w++){const v=a[w];if(!v)continue;const{name:k,fn:C}=v,{x:N,y:j,data:D,reset:R}=await C({x:m,y:x,initialPlacement:i,placement:g,strategy:r,middlewareData:b,rects:u,platform:l,elements:{reference:e,floating:s}});m=N??m,x=j??x,b[k]={...b[k],...D},R&&f<Jr&&(f++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(u=R.rects===!0?await c.getElementRects({reference:e,floating:s,strategy:r}):R.rects),{x:m,y:x}=qs(u,g,o)),w=-1)}return{x:m,y:x,placement:g,strategy:r,middlewareData:b}},eo=e=>({name:"arrow",options:e,async fn(s){const{x:n,y:i,placement:r,rects:a,platform:c,elements:l,middlewareData:o}=s,{element:u,padding:m=0}=De(e,s)||{};if(u==null)return{};const x=Nn(m),g={x:n,y:i},f=$s(r),b=Es(f),w=await c.getDimensions(u),v=f==="y",k=v?"top":"left",C=v?"bottom":"right",N=v?"clientHeight":"clientWidth",j=a.reference[b]+a.reference[f]-g[f]-a.floating[b],D=g[f]-a.reference[f],R=await(c.getOffsetParent==null?void 0:c.getOffsetParent(u));let I=R?R[N]:0;(!I||!await(c.isElement==null?void 0:c.isElement(R)))&&(I=l.floating[N]||a.floating[b]);const $=j/2-D/2,H=I/2-w[b]/2-1,T=ze(x[k],H),O=ze(x[C],H),z=T,G=I-w[b]-O,V=I/2-w[b]/2+$,J=vs(z,V,G),F=!o.arrow&&at(r)!=null&&V!==J&&a.reference[b]/2-(V<z?T:O)-w[b]/2<0,U=F?V<z?V-z:V-G:0;return{[f]:g[f]+U,data:{[f]:J,centerOffset:V-J-U,...F&&{alignmentOffset:U}},reset:F}}}),to=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(s){var n,i;const{placement:r,middlewareData:a,rects:c,initialPlacement:l,platform:o,elements:u}=s,{mainAxis:m=!0,crossAxis:x=!0,fallbackPlacements:g,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...v}=De(e,s);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const k=Te(r),C=Ne(l),N=Te(l)===l,j=await(o.isRTL==null?void 0:o.isRTL(u.floating)),D=g||(N||!w?[Xt(l)]:Vr(l)),R=b!=="none";!g&&R&&D.push(...Gr(l,w,b,j));const I=[l,...D],$=await o.detectOverflow(s,v),H=[];let T=((i=a.flip)==null?void 0:i.overflows)||[];if(m&&H.push($[k]),x){const V=Wr(r,c,j);H.push($[V[0]],$[V[1]])}if(T=[...T,{placement:r,overflows:H}],!H.every(V=>V<=0)){var O,z;const V=(((O=a.flip)==null?void 0:O.index)||0)+1,J=I[V];if(J&&(!(x==="alignment"?C!==Ne(J):!1)||T.every(p=>Ne(p.placement)===C?p.overflows[0]>0:!0)))return{data:{index:V,overflows:T},reset:{placement:J}};let F=(z=T.filter(U=>U.overflows[0]<=0).sort((U,p)=>U.overflows[1]-p.overflows[1])[0])==null?void 0:z.placement;if(!F)switch(f){case"bestFit":{var G;const U=(G=T.filter(p=>{if(R){const Q=Ne(p.placement);return Q===C||Q==="y"}return!0}).map(p=>[p.placement,p.overflows.filter(Q=>Q>0).reduce((Q,ie)=>Q+ie,0)]).sort((p,Q)=>p[1]-Q[1])[0])==null?void 0:G[0];U&&(F=U);break}case"initialPlacement":F=l;break}if(r!==F)return{reset:{placement:F}}}return{}}}};function Xs(e,s){return{top:e.top-s.height,right:e.right-s.width,bottom:e.bottom-s.height,left:e.left-s.width}}function Ks(e){return Br.some(s=>e[s]>=0)}const so=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(s){const{rects:n,platform:i}=s,{strategy:r="referenceHidden",...a}=De(e,s);switch(r){case"referenceHidden":{const c=await i.detectOverflow(s,{...a,elementContext:"reference"}),l=Xs(c,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Ks(l)}}}case"escaped":{const c=await i.detectOverflow(s,{...a,altBoundary:!0}),l=Xs(c,n.floating);return{data:{escapedOffsets:l,escaped:Ks(l)}}}default:return{}}}}},Cn=new Set(["left","top"]);async function no(e,s){const{placement:n,platform:i,elements:r}=e,a=await(i.isRTL==null?void 0:i.isRTL(r.floating)),c=Te(n),l=at(n),o=Ne(n)==="y",u=Cn.has(c)?-1:1,m=a&&o?-1:1,x=De(s,e);let{mainAxis:g,crossAxis:f,alignmentAxis:b}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return l&&typeof b=="number"&&(f=l==="end"?b*-1:b),o?{x:f*m,y:g*u}:{x:g*u,y:f*m}}const io=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(s){var n,i;const{x:r,y:a,placement:c,middlewareData:l}=s,o=await no(s,e);return c===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+o.x,y:a+o.y,data:{...o,placement:c}}}}},ro=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(s){const{x:n,y:i,placement:r,platform:a}=s,{mainAxis:c=!0,crossAxis:l=!1,limiter:o={fn:k=>{let{x:C,y:N}=k;return{x:C,y:N}}},...u}=De(e,s),m={x:n,y:i},x=await a.detectOverflow(s,u),g=Ne(Te(r)),f=Rs(g);let b=m[f],w=m[g];if(c){const k=f==="y"?"top":"left",C=f==="y"?"bottom":"right",N=b+x[k],j=b-x[C];b=vs(N,b,j)}if(l){const k=g==="y"?"top":"left",C=g==="y"?"bottom":"right",N=w+x[k],j=w-x[C];w=vs(N,w,j)}const v=o.fn({...s,[f]:b,[g]:w});return{...v,data:{x:v.x-n,y:v.y-i,enabled:{[f]:c,[g]:l}}}}}},oo=function(e){return e===void 0&&(e={}),{options:e,fn(s){const{x:n,y:i,placement:r,rects:a,middlewareData:c}=s,{offset:l=0,mainAxis:o=!0,crossAxis:u=!0}=De(e,s),m={x:n,y:i},x=Ne(r),g=Rs(x);let f=m[g],b=m[x];const w=De(l,s),v=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(o){const N=g==="y"?"height":"width",j=a.reference[g]-a.floating[N]+v.mainAxis,D=a.reference[g]+a.reference[N]-v.mainAxis;f<j?f=j:f>D&&(f=D)}if(u){var k,C;const N=g==="y"?"width":"height",j=Cn.has(Te(r)),D=a.reference[x]-a.floating[N]+(j&&((k=c.offset)==null?void 0:k[x])||0)+(j?0:v.crossAxis),R=a.reference[x]+a.reference[N]+(j?0:((C=c.offset)==null?void 0:C[x])||0)-(j?v.crossAxis:0);b<D?b=D:b>R&&(b=R)}return{[g]:f,[x]:b}}}},ao=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(s){var n,i;const{placement:r,rects:a,platform:c,elements:l}=s,{apply:o=()=>{},...u}=De(e,s),m=await c.detectOverflow(s,u),x=Te(r),g=at(r),f=Ne(r)==="y",{width:b,height:w}=a.floating;let v,k;x==="top"||x==="bottom"?(v=x,k=g===(await(c.isRTL==null?void 0:c.isRTL(l.floating))?"start":"end")?"left":"right"):(k=x,v=g==="end"?"top":"bottom");const C=w-m.top-m.bottom,N=b-m.left-m.right,j=ze(w-m[v],C),D=ze(b-m[k],N),R=!s.middlewareData.shift;let I=j,$=D;if((n=s.middlewareData.shift)!=null&&n.enabled.x&&($=N),(i=s.middlewareData.shift)!=null&&i.enabled.y&&(I=C),R&&!g){const T=le(m.left,0),O=le(m.right,0),z=le(m.top,0),G=le(m.bottom,0);f?$=b-2*(T!==0||O!==0?T+O:le(m.left,m.right)):I=w-2*(z!==0||G!==0?z+G:le(m.top,m.bottom))}await o({...s,availableWidth:$,availableHeight:I});const H=await c.getDimensions(l.floating);return b!==H.width||w!==H.height?{reset:{rects:!0}}:{}}}};function Qt(){return typeof window<"u"}function ct(e){return Sn(e)?(e.nodeName||"").toLowerCase():"#document"}function de(e){var s;return(e==null||(s=e.ownerDocument)==null?void 0:s.defaultView)||window}function Se(e){var s;return(s=(Sn(e)?e.ownerDocument:e.document)||window.document)==null?void 0:s.documentElement}function Sn(e){return Qt()?e instanceof Node||e instanceof de(e).Node:!1}function ge(e){return Qt()?e instanceof Element||e instanceof de(e).Element:!1}function Le(e){return Qt()?e instanceof HTMLElement||e instanceof de(e).HTMLElement:!1}function Gs(e){return!Qt()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof de(e).ShadowRoot}function jt(e){const{overflow:s,overflowX:n,overflowY:i,display:r}=xe(e);return/auto|scroll|overlay|hidden|clip/.test(s+i+n)&&r!=="inline"&&r!=="contents"}function co(e){return/^(table|td|th)$/.test(ct(e))}function es(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const lo=/transform|translate|scale|rotate|perspective|filter/,uo=/paint|layout|strict|content/,qe=e=>!!e&&e!=="none";let us;function Ds(e){const s=ge(e)?xe(e):e;return qe(s.transform)||qe(s.translate)||qe(s.scale)||qe(s.rotate)||qe(s.perspective)||!Ts()&&(qe(s.backdropFilter)||qe(s.filter))||lo.test(s.willChange||"")||uo.test(s.contain||"")}function mo(e){let s=Fe(e);for(;Le(s)&&!rt(s);){if(Ds(s))return s;if(es(s))return null;s=Fe(s)}return null}function Ts(){return us==null&&(us=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),us}function rt(e){return/^(html|body|#document)$/.test(ct(e))}function xe(e){return de(e).getComputedStyle(e)}function ts(e){return ge(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Fe(e){if(ct(e)==="html")return e;const s=e.assignedSlot||e.parentNode||Gs(e)&&e.host||Se(e);return Gs(s)?s.host:s}function kn(e){const s=Fe(e);return rt(s)?e.ownerDocument?e.ownerDocument.body:e.body:Le(s)&&jt(s)?s:kn(s)}function bt(e,s,n){var i;s===void 0&&(s=[]),n===void 0&&(n=!0);const r=kn(e),a=r===((i=e.ownerDocument)==null?void 0:i.body),c=de(r);if(a){const l=ws(c);return s.concat(c,c.visualViewport||[],jt(r)?r:[],l&&n?bt(l):[])}else return s.concat(r,bt(r,[],n))}function ws(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function An(e){const s=xe(e);let n=parseFloat(s.width)||0,i=parseFloat(s.height)||0;const r=Le(e),a=r?e.offsetWidth:n,c=r?e.offsetHeight:i,l=qt(n)!==a||qt(i)!==c;return l&&(n=a,i=c),{width:n,height:i,$:l}}function Ms(e){return ge(e)?e:e.contextElement}function it(e){const s=Ms(e);if(!Le(s))return Ce(1);const n=s.getBoundingClientRect(),{width:i,height:r,$:a}=An(s);let c=(a?qt(n.width):n.width)/i,l=(a?qt(n.height):n.height)/r;return(!c||!Number.isFinite(c))&&(c=1),(!l||!Number.isFinite(l))&&(l=1),{x:c,y:l}}const ho=Ce(0);function Rn(e){const s=de(e);return!Ts()||!s.visualViewport?ho:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function fo(e,s,n){return s===void 0&&(s=!1),!n||s&&n!==de(e)?!1:s}function Ke(e,s,n,i){s===void 0&&(s=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Ms(e);let c=Ce(1);s&&(i?ge(i)&&(c=it(i)):c=it(e));const l=fo(a,n,i)?Rn(a):Ce(0);let o=(r.left+l.x)/c.x,u=(r.top+l.y)/c.y,m=r.width/c.x,x=r.height/c.y;if(a){const g=de(a),f=i&&ge(i)?de(i):i;let b=g,w=ws(b);for(;w&&i&&f!==b;){const v=it(w),k=w.getBoundingClientRect(),C=xe(w),N=k.left+(w.clientLeft+parseFloat(C.paddingLeft))*v.x,j=k.top+(w.clientTop+parseFloat(C.paddingTop))*v.y;o*=v.x,u*=v.y,m*=v.x,x*=v.y,o+=N,u+=j,b=de(w),w=ws(b)}}return Kt({width:m,height:x,x:o,y:u})}function ss(e,s){const n=ts(e).scrollLeft;return s?s.left+n:Ke(Se(e)).left+n}function En(e,s){const n=e.getBoundingClientRect(),i=n.left+s.scrollLeft-ss(e,n),r=n.top+s.scrollTop;return{x:i,y:r}}function po(e){let{elements:s,rect:n,offsetParent:i,strategy:r}=e;const a=r==="fixed",c=Se(i),l=s?es(s.floating):!1;if(i===c||l&&a)return n;let o={scrollLeft:0,scrollTop:0},u=Ce(1);const m=Ce(0),x=Le(i);if((x||!x&&!a)&&((ct(i)!=="body"||jt(c))&&(o=ts(i)),x)){const f=Ke(i);u=it(i),m.x=f.x+i.clientLeft,m.y=f.y+i.clientTop}const g=c&&!x&&!a?En(c,o):Ce(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-o.scrollLeft*u.x+m.x+g.x,y:n.y*u.y-o.scrollTop*u.y+m.y+g.y}}function go(e){return Array.from(e.getClientRects())}function xo(e){const s=Se(e),n=ts(e),i=e.ownerDocument.body,r=le(s.scrollWidth,s.clientWidth,i.scrollWidth,i.clientWidth),a=le(s.scrollHeight,s.clientHeight,i.scrollHeight,i.clientHeight);let c=-n.scrollLeft+ss(e);const l=-n.scrollTop;return xe(i).direction==="rtl"&&(c+=le(s.clientWidth,i.clientWidth)-r),{width:r,height:a,x:c,y:l}}const Ys=25;function yo(e,s){const n=de(e),i=Se(e),r=n.visualViewport;let a=i.clientWidth,c=i.clientHeight,l=0,o=0;if(r){a=r.width,c=r.height;const m=Ts();(!m||m&&s==="fixed")&&(l=r.offsetLeft,o=r.offsetTop)}const u=ss(i);if(u<=0){const m=i.ownerDocument,x=m.body,g=getComputedStyle(x),f=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,b=Math.abs(i.clientWidth-x.clientWidth-f);b<=Ys&&(a-=b)}else u<=Ys&&(a+=u);return{width:a,height:c,x:l,y:o}}function vo(e,s){const n=Ke(e,!0,s==="fixed"),i=n.top+e.clientTop,r=n.left+e.clientLeft,a=Le(e)?it(e):Ce(1),c=e.clientWidth*a.x,l=e.clientHeight*a.y,o=r*a.x,u=i*a.y;return{width:c,height:l,x:o,y:u}}function Zs(e,s,n){let i;if(s==="viewport")i=yo(e,n);else if(s==="document")i=xo(Se(e));else if(ge(s))i=vo(s,n);else{const r=Rn(e);i={x:s.x-r.x,y:s.y-r.y,width:s.width,height:s.height}}return Kt(i)}function $n(e,s){const n=Fe(e);return n===s||!ge(n)||rt(n)?!1:xe(n).position==="fixed"||$n(n,s)}function bo(e,s){const n=s.get(e);if(n)return n;let i=bt(e,[],!1).filter(l=>ge(l)&&ct(l)!=="body"),r=null;const a=xe(e).position==="fixed";let c=a?Fe(e):e;for(;ge(c)&&!rt(c);){const l=xe(c),o=Ds(c);!o&&l.position==="fixed"&&(r=null),(a?!o&&!r:!o&&l.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||jt(c)&&!o&&$n(e,c))?i=i.filter(m=>m!==c):r=l,c=Fe(c)}return s.set(e,i),i}function wo(e){let{element:s,boundary:n,rootBoundary:i,strategy:r}=e;const c=[...n==="clippingAncestors"?es(s)?[]:bo(s,this._c):[].concat(n),i],l=Zs(s,c[0],r);let o=l.top,u=l.right,m=l.bottom,x=l.left;for(let g=1;g<c.length;g++){const f=Zs(s,c[g],r);o=le(f.top,o),u=ze(f.right,u),m=ze(f.bottom,m),x=le(f.left,x)}return{width:u-x,height:m-o,x,y:o}}function jo(e){const{width:s,height:n}=An(e);return{width:s,height:n}}function No(e,s,n){const i=Le(s),r=Se(s),a=n==="fixed",c=Ke(e,!0,a,s);let l={scrollLeft:0,scrollTop:0};const o=Ce(0);function u(){o.x=ss(r)}if(i||!i&&!a)if((ct(s)!=="body"||jt(r))&&(l=ts(s)),i){const f=Ke(s,!0,a,s);o.x=f.x+s.clientLeft,o.y=f.y+s.clientTop}else r&&u();a&&!i&&r&&u();const m=r&&!i&&!a?En(r,l):Ce(0),x=c.left+l.scrollLeft-o.x-m.x,g=c.top+l.scrollTop-o.y-m.y;return{x,y:g,width:c.width,height:c.height}}function ms(e){return xe(e).position==="static"}function Js(e,s){if(!Le(e)||xe(e).position==="fixed")return null;if(s)return s(e);let n=e.offsetParent;return Se(e)===n&&(n=n.ownerDocument.body),n}function Dn(e,s){const n=de(e);if(es(e))return n;if(!Le(e)){let r=Fe(e);for(;r&&!rt(r);){if(ge(r)&&!ms(r))return r;r=Fe(r)}return n}let i=Js(e,s);for(;i&&co(i)&&ms(i);)i=Js(i,s);return i&&rt(i)&&ms(i)&&!Ds(i)?n:i||mo(e)||n}const Co=async function(e){const s=this.getOffsetParent||Dn,n=this.getDimensions,i=await n(e.floating);return{reference:No(e.reference,await s(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function So(e){return xe(e).direction==="rtl"}const ko={convertOffsetParentRelativeRectToViewportRelativeRect:po,getDocumentElement:Se,getClippingRect:wo,getOffsetParent:Dn,getElementRects:Co,getClientRects:go,getDimensions:jo,getScale:it,isElement:ge,isRTL:So};function Tn(e,s){return e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height}function Ao(e,s){let n=null,i;const r=Se(e);function a(){var l;clearTimeout(i),(l=n)==null||l.disconnect(),n=null}function c(l,o){l===void 0&&(l=!1),o===void 0&&(o=1),a();const u=e.getBoundingClientRect(),{left:m,top:x,width:g,height:f}=u;if(l||s(),!g||!f)return;const b=Pt(x),w=Pt(r.clientWidth-(m+g)),v=Pt(r.clientHeight-(x+f)),k=Pt(m),N={rootMargin:-b+"px "+-w+"px "+-v+"px "+-k+"px",threshold:le(0,ze(1,o))||1};let j=!0;function D(R){const I=R[0].intersectionRatio;if(I!==o){if(!j)return c();I?c(!1,I):i=setTimeout(()=>{c(!1,1e-7)},1e3)}I===1&&!Tn(u,e.getBoundingClientRect())&&c(),j=!1}try{n=new IntersectionObserver(D,{...N,root:r.ownerDocument})}catch{n=new IntersectionObserver(D,N)}n.observe(e)}return c(!0),a}function Ro(e,s,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:o=!1}=i,u=Ms(e),m=r||a?[...u?bt(u):[],...s?bt(s):[]]:[];m.forEach(k=>{r&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const x=u&&l?Ao(u,n):null;let g=-1,f=null;c&&(f=new ResizeObserver(k=>{let[C]=k;C&&C.target===u&&f&&s&&(f.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var N;(N=f)==null||N.observe(s)})),n()}),u&&!o&&f.observe(u),s&&f.observe(s));let b,w=o?Ke(e):null;o&&v();function v(){const k=Ke(e);w&&!Tn(w,k)&&n(),w=k,b=requestAnimationFrame(v)}return n(),()=>{var k;m.forEach(C=>{r&&C.removeEventListener("scroll",n),a&&C.removeEventListener("resize",n)}),x==null||x(),(k=f)==null||k.disconnect(),f=null,o&&cancelAnimationFrame(b)}}const Eo=io,$o=ro,Do=to,To=ao,Mo=so,Qs=eo,Lo=oo,Io=(e,s,n)=>{const i=new Map,r={platform:ko,...n},a={...r.platform,_c:i};return Qr(e,s,{...r,platform:a})};var _o=typeof document<"u",Oo=function(){},Wt=_o?d.useLayoutEffect:Oo;function Gt(e,s){if(e===s)return!0;if(typeof e!=typeof s)return!1;if(typeof e=="function"&&e.toString()===s.toString())return!0;let n,i,r;if(e&&s&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==s.length)return!1;for(i=n;i--!==0;)if(!Gt(e[i],s[i]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(s).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(s,r[i]))return!1;for(i=n;i--!==0;){const a=r[i];if(!(a==="_owner"&&e.$$typeof)&&!Gt(e[a],s[a]))return!1}return!0}return e!==e&&s!==s}function Mn(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function en(e,s){const n=Mn(e);return Math.round(s*n)/n}function hs(e){const s=d.useRef(e);return Wt(()=>{s.current=e}),s}function Po(e){e===void 0&&(e={});const{placement:s="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:a,floating:c}={},transform:l=!0,whileElementsMounted:o,open:u}=e,[m,x]=d.useState({x:0,y:0,strategy:n,placement:s,middlewareData:{},isPositioned:!1}),[g,f]=d.useState(i);Gt(g,i)||f(i);const[b,w]=d.useState(null),[v,k]=d.useState(null),C=d.useCallback(p=>{p!==R.current&&(R.current=p,w(p))},[]),N=d.useCallback(p=>{p!==I.current&&(I.current=p,k(p))},[]),j=a||b,D=c||v,R=d.useRef(null),I=d.useRef(null),$=d.useRef(m),H=o!=null,T=hs(o),O=hs(r),z=hs(u),G=d.useCallback(()=>{if(!R.current||!I.current)return;const p={placement:s,strategy:n,middleware:g};O.current&&(p.platform=O.current),Io(R.current,I.current,p).then(Q=>{const ie={...Q,isPositioned:z.current!==!1};V.current&&!Gt($.current,ie)&&($.current=ie,hn.flushSync(()=>{x(ie)}))})},[g,s,n,O,z]);Wt(()=>{u===!1&&$.current.isPositioned&&($.current.isPositioned=!1,x(p=>({...p,isPositioned:!1})))},[u]);const V=d.useRef(!1);Wt(()=>(V.current=!0,()=>{V.current=!1}),[]),Wt(()=>{if(j&&(R.current=j),D&&(I.current=D),j&&D){if(T.current)return T.current(j,D,G);G()}},[j,D,G,T,H]);const J=d.useMemo(()=>({reference:R,floating:I,setReference:C,setFloating:N}),[C,N]),F=d.useMemo(()=>({reference:j,floating:D}),[j,D]),U=d.useMemo(()=>{const p={position:n,left:0,top:0};if(!F.floating)return p;const Q=en(F.floating,m.x),ie=en(F.floating,m.y);return l?{...p,transform:"translate("+Q+"px, "+ie+"px)",...Mn(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Q,top:ie}},[n,l,F.floating,m.x,m.y]);return d.useMemo(()=>({...m,update:G,refs:J,elements:F,floatingStyles:U}),[m,G,J,F,U])}const zo=e=>{function s(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:i,padding:r}=typeof e=="function"?e(n):e;return i&&s(i)?i.current!=null?Qs({element:i.current,padding:r}).fn(n):{}:i?Qs({element:i,padding:r}).fn(n):{}}}},Fo=(e,s)=>{const n=Eo(e);return{name:n.name,fn:n.fn,options:[e,s]}},Uo=(e,s)=>{const n=$o(e);return{name:n.name,fn:n.fn,options:[e,s]}},Bo=(e,s)=>({fn:Lo(e).fn,options:[e,s]}),Ho=(e,s)=>{const n=Do(e);return{name:n.name,fn:n.fn,options:[e,s]}},Wo=(e,s)=>{const n=To(e);return{name:n.name,fn:n.fn,options:[e,s]}},Vo=(e,s)=>{const n=Mo(e);return{name:n.name,fn:n.fn,options:[e,s]}},qo=(e,s)=>{const n=zo(e);return{name:n.name,fn:n.fn,options:[e,s]}};var Xo="Arrow",Ln=d.forwardRef((e,s)=>{const{children:n,width:i=10,height:r=5,...a}=e;return t.jsx(wt.svg,{...a,ref:s,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});Ln.displayName=Xo;var Ko=Ln;function Go(e){const[s,n]=d.useState(void 0);return Vt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let c,l;if("borderBoxSize"in a){const o=a.borderBoxSize,u=Array.isArray(o)?o[0]:o;c=u.inlineSize,l=u.blockSize}else c=e.offsetWidth,l=e.offsetHeight;n({width:c,height:l})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else n(void 0)},[e]),s}var Ls="Popper",[In]=As(Ls),[Yo,_n]=In(Ls),On=e=>{const{__scopePopper:s,children:n}=e,[i,r]=d.useState(null);return t.jsx(Yo,{scope:s,anchor:i,onAnchorChange:r,children:n})};On.displayName=Ls;var Pn="PopperAnchor",zn=d.forwardRef((e,s)=>{const{__scopePopper:n,virtualRef:i,...r}=e,a=_n(Pn,n),c=d.useRef(null),l=vt(s,c),o=d.useRef(null);return d.useEffect(()=>{const u=o.current;o.current=(i==null?void 0:i.current)||c.current,u!==o.current&&a.onAnchorChange(o.current)}),i?null:t.jsx(wt.div,{...r,ref:l})});zn.displayName=Pn;var Is="PopperContent",[Zo,Jo]=In(Is),Fn=d.forwardRef((e,s)=>{var P,Z,ne,se,Ae,Ge;const{__scopePopper:n,side:i="bottom",sideOffset:r=0,align:a="center",alignOffset:c=0,arrowPadding:l=0,avoidCollisions:o=!0,collisionBoundary:u=[],collisionPadding:m=0,sticky:x="partial",hideWhenDetached:g=!1,updatePositionStrategy:f="optimized",onPlaced:b,...w}=e,v=_n(Is,n),[k,C]=d.useState(null),N=vt(s,ae=>C(ae)),[j,D]=d.useState(null),R=Go(j),I=(R==null?void 0:R.width)??0,$=(R==null?void 0:R.height)??0,H=i+(a!=="center"?"-"+a:""),T=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},O=Array.isArray(u)?u:[u],z=O.length>0,G={padding:T,boundary:O.filter(ta),altBoundary:z},{refs:V,floatingStyles:J,placement:F,isPositioned:U,middlewareData:p}=Po({strategy:"fixed",placement:H,whileElementsMounted:(...ae)=>Ro(...ae,{animationFrame:f==="always"}),elements:{reference:v.anchor},middleware:[Fo({mainAxis:r+$,alignmentAxis:c}),o&&Uo({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?Bo():void 0,...G}),o&&Ho({...G}),Wo({...G,apply:({elements:ae,rects:be,availableWidth:Ue,availableHeight:Ye})=>{const{width:Ie,height:lt}=be.reference,he=ae.floating.style;he.setProperty("--radix-popper-available-width",`${Ue}px`),he.setProperty("--radix-popper-available-height",`${Ye}px`),he.setProperty("--radix-popper-anchor-width",`${Ie}px`),he.setProperty("--radix-popper-anchor-height",`${lt}px`)}}),j&&qo({element:j,padding:l}),sa({arrowWidth:I,arrowHeight:$}),g&&Vo({strategy:"referenceHidden",...G})]}),[Q,ie]=Bn(F),oe=xn(b);Vt(()=>{U&&(oe==null||oe())},[U,oe]);const ye=(P=p.arrow)==null?void 0:P.x,ue=(Z=p.arrow)==null?void 0:Z.y,ve=((ne=p.arrow)==null?void 0:ne.centerOffset)!==0,[ke,Y]=d.useState();return Vt(()=>{k&&Y(window.getComputedStyle(k).zIndex)},[k]),t.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:U?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ke,"--radix-popper-transform-origin":[(se=p.transformOrigin)==null?void 0:se.x,(Ae=p.transformOrigin)==null?void 0:Ae.y].join(" "),...((Ge=p.hide)==null?void 0:Ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(Zo,{scope:n,placedSide:Q,onArrowChange:D,arrowX:ye,arrowY:ue,shouldHideArrow:ve,children:t.jsx(wt.div,{"data-side":Q,"data-align":ie,...w,ref:N,style:{...w.style,animation:U?void 0:"none"}})})})});Fn.displayName=Is;var Un="PopperArrow",Qo={top:"bottom",right:"left",bottom:"top",left:"right"},ea=d.forwardRef(function(s,n){const{__scopePopper:i,...r}=s,a=Jo(Un,i),c=Qo[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[c]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(Ko,{...r,ref:n,style:{...r.style,display:"block"}})})});ea.displayName=Un;function ta(e){return e!==null}var sa=e=>({name:"transformOrigin",options:e,fn(s){var v,k,C;const{placement:n,rects:i,middlewareData:r}=s,c=((v=r.arrow)==null?void 0:v.centerOffset)!==0,l=c?0:e.arrowWidth,o=c?0:e.arrowHeight,[u,m]=Bn(n),x={start:"0%",center:"50%",end:"100%"}[m],g=(((k=r.arrow)==null?void 0:k.x)??0)+l/2,f=(((C=r.arrow)==null?void 0:C.y)??0)+o/2;let b="",w="";return u==="bottom"?(b=c?x:`${g}px`,w=`${-o}px`):u==="top"?(b=c?x:`${g}px`,w=`${i.floating.height+o}px`):u==="right"?(b=`${-o}px`,w=c?x:`${f}px`):u==="left"&&(b=`${i.floating.width+o}px`,w=c?x:`${f}px`),{data:{x:b,y:w}}}});function Bn(e){const[s,n="center"]=e.split("-");return[s,n]}var na=On,ia=zn,ra=Fn,oa=Symbol.for("react.lazy"),Yt=Jn[" use ".trim().toString()];function aa(e){return typeof e=="object"&&e!==null&&"then"in e}function Hn(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===oa&&"_payload"in e&&aa(e._payload)}function ca(e){const s=la(e),n=d.forwardRef((i,r)=>{let{children:a,...c}=i;Hn(a)&&typeof Yt=="function"&&(a=Yt(a._payload));const l=d.Children.toArray(a),o=l.find(ua);if(o){const u=o.props.children,m=l.map(x=>x===o?d.Children.count(u)>1?d.Children.only(null):d.isValidElement(u)?u.props.children:null:x);return t.jsx(s,{...c,ref:r,children:d.isValidElement(u)?d.cloneElement(u,void 0,m):null})}return t.jsx(s,{...c,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function la(e){const s=d.forwardRef((n,i)=>{let{children:r,...a}=n;if(Hn(r)&&typeof Yt=="function"&&(r=Yt(r._payload)),d.isValidElement(r)){const c=ha(r),l=ma(a,r.props);return r.type!==d.Fragment&&(l.ref=i?ri(i,c):c),d.cloneElement(r,l)}return d.Children.count(r)>1?d.Children.only(null):null});return s.displayName=`${e}.SlotClone`,s}var da=Symbol("radix.slottable");function ua(e){return d.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===da}function ma(e,s){const n={...s};for(const i in s){const r=e[i],a=s[i];/^on[A-Z]/.test(i)?r&&a?n[i]=(...l)=>{const o=a(...l);return r(...l),o}:r&&(n[i]=r):i==="style"?n[i]={...r,...a}:i==="className"&&(n[i]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function ha(e){var i,r;let s=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=s&&"isReactWarning"in s&&s.isReactWarning;return n?e.ref:(s=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=s&&"isReactWarning"in s&&s.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var fa=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],pa=fa.reduce((e,s)=>{const n=ca(`Primitive.${s}`),i=d.forwardRef((r,a)=>{const{asChild:c,...l}=r,o=c?n:s;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(o,{...l,ref:a})});return i.displayName=`Primitive.${s}`,{...e,[s]:i}},{}),ga="Portal",Wn=d.forwardRef((e,s)=>{var l;const{container:n,...i}=e,[r,a]=d.useState(!1);Vt(()=>a(!0),[]);const c=n||r&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return c?Qn.createPortal(t.jsx(pa.div,{...i,ref:s}),c):null});Wn.displayName=ga;const xa=({open:e,onClose:s,anchorRef:n,placement:i="bottom-end",children:r})=>{const a=d.useRef(null);if(d.useEffect(()=>{if(!e)return;const u=m=>{var x,g;e&&((x=a.current)!=null&&x.contains(m.target)||(g=n.current)!=null&&g.contains(m.target)||s())};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[e,s,n]),!e)return null;const c=i.startsWith("top")?"top":"bottom",l=i.endsWith("end")?"end":"start",o=i.startsWith("top")?8:4;return t.jsxs(na,{children:[t.jsx(ia,{virtualRef:n}),t.jsx(Wn,{children:t.jsx(oi,{onEscapeKeyDown:u=>{u.preventDefault(),s()},onPointerDownOutside:u=>{var m;if((m=n.current)!=null&&m.contains(u.target)){u.preventDefault();return}s()},children:t.jsx(ra,{ref:a,side:c,align:l,sideOffset:o,className:`popover popover-${i}`,role:"dialog",children:r})})})]})};function ya(e){const s=e+"CollectionProvider",[n,i]=As(s),[r,a]=n(s,{collectionRef:{current:null},itemMap:new Map}),c=w=>{const{scope:v,children:k}=w,C=je.useRef(null),N=je.useRef(new Map).current;return t.jsx(r,{scope:v,itemMap:N,collectionRef:C,children:k})};c.displayName=s;const l=e+"CollectionSlot",o=zs(l),u=je.forwardRef((w,v)=>{const{scope:k,children:C}=w,N=a(l,k),j=vt(v,N.collectionRef);return t.jsx(o,{ref:j,children:C})});u.displayName=l;const m=e+"CollectionItemSlot",x="data-radix-collection-item",g=zs(m),f=je.forwardRef((w,v)=>{const{scope:k,children:C,...N}=w,j=je.useRef(null),D=vt(v,j),R=a(m,k);return je.useEffect(()=>(R.itemMap.set(j,{ref:j,...N}),()=>void R.itemMap.delete(j))),t.jsx(g,{[x]:"",ref:D,children:C})});f.displayName=m;function b(w){const v=a(e+"CollectionConsumer",w);return je.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const N=Array.from(C.querySelectorAll(`[${x}]`));return Array.from(v.itemMap.values()).sort((R,I)=>N.indexOf(R.ref.current)-N.indexOf(I.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:c,Slot:u,ItemSlot:f},b,i]}var va=d.createContext(void 0);function ba(e){const s=d.useContext(va);return e||s||"ltr"}var fs="rovingFocusGroup.onEntryFocus",wa={bubbles:!1,cancelable:!0},Nt="RovingFocusGroup",[js,Vn,ja]=ya(Nt),[Na]=As(Nt,[ja]),[Ca,Sa]=Na(Nt),qn=d.forwardRef((e,s)=>t.jsx(js.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(js.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(ka,{...e,ref:s})})}));qn.displayName=Nt;var ka=d.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:a,currentTabStopId:c,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:o,onEntryFocus:u,preventScrollOnEntryFocus:m=!1,...x}=e,g=d.useRef(null),f=vt(s,g),b=ba(a),[w,v]=ci({prop:c,defaultProp:l??null,onChange:o,caller:Nt}),[k,C]=d.useState(!1),N=xn(u),j=Vn(n),D=d.useRef(!1),[R,I]=d.useState(0);return d.useEffect(()=>{const $=g.current;if($)return $.addEventListener(fs,N),()=>$.removeEventListener(fs,N)},[N]),t.jsx(Ca,{scope:n,orientation:i,dir:b,loop:r,currentTabStopId:w,onItemFocus:d.useCallback($=>v($),[v]),onItemShiftTab:d.useCallback(()=>C(!0),[]),onFocusableItemAdd:d.useCallback(()=>I($=>$+1),[]),onFocusableItemRemove:d.useCallback(()=>I($=>$-1),[]),children:t.jsx(wt.div,{tabIndex:k||R===0?-1:0,"data-orientation":i,...x,ref:f,style:{outline:"none",...e.style},onMouseDown:nt(e.onMouseDown,()=>{D.current=!0}),onFocus:nt(e.onFocus,$=>{const H=!D.current;if($.target===$.currentTarget&&H&&!k){const T=new CustomEvent(fs,wa);if($.currentTarget.dispatchEvent(T),!T.defaultPrevented){const O=j().filter(F=>F.focusable),z=O.find(F=>F.active),G=O.find(F=>F.id===w),J=[z,G,...O].filter(Boolean).map(F=>F.ref.current);Gn(J,m)}}D.current=!1}),onBlur:nt(e.onBlur,()=>C(!1))})})}),Xn="RovingFocusGroupItem",Kn=d.forwardRef((e,s)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:a,children:c,...l}=e,o=ai(),u=a||o,m=Sa(Xn,n),x=m.currentTabStopId===u,g=Vn(n),{onFocusableItemAdd:f,onFocusableItemRemove:b,currentTabStopId:w}=m;return d.useEffect(()=>{if(i)return f(),()=>b()},[i,f,b]),t.jsx(js.ItemSlot,{scope:n,id:u,focusable:i,active:r,children:t.jsx(wt.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...l,ref:s,onMouseDown:nt(e.onMouseDown,v=>{i?m.onItemFocus(u):v.preventDefault()}),onFocus:nt(e.onFocus,()=>m.onItemFocus(u)),onKeyDown:nt(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){m.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const k=Ea(v,m.orientation,m.dir);if(k!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let N=g().filter(j=>j.focusable).map(j=>j.ref.current);if(k==="last")N.reverse();else if(k==="prev"||k==="next"){k==="prev"&&N.reverse();const j=N.indexOf(v.currentTarget);N=m.loop?$a(N,j+1):N.slice(j+1)}setTimeout(()=>Gn(N))}}),children:typeof c=="function"?c({isCurrentTabStop:x,hasTabStop:w!=null}):c})})});Kn.displayName=Xn;var Aa={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ra(e,s){return s!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ea(e,s,n){const i=Ra(e.key,n);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return Aa[i]}function Gn(e,s=!1){const n=document.activeElement;for(const i of e)if(i===n||(i.focus({preventScroll:s}),document.activeElement!==n))return}function $a(e,s){return e.map((n,i)=>e[(s+i)%e.length])}var Da=qn,Ta=Kn;const zt=({icon:e,children:s,onClick:n,danger:i,disabled:r})=>t.jsx(Ta,{asChild:!0,focusable:!r,active:!1,children:t.jsxs("button",{type:"button",role:"menuitem",className:`menu-item${i?" menu-item-danger":""}`,onClick:n,disabled:r,children:[e&&t.jsx("span",{className:"menu-item-icon",children:e}),t.jsx("span",{className:"menu-item-label",children:s})]})}),Ma=({children:e})=>t.jsx(Da,{asChild:!0,orientation:"vertical",loop:!0,children:t.jsx("div",{className:"menu",role:"menu",children:e})}),La=[{label:"1 Hour",value:"1h"},{label:"2 Hours",value:"2h"},{label:"4 Hours",value:"4h"},{label:"8 Hours",value:"8h"}],Ia=({device:e,onClose:s,onReserved:n})=>{const[i,r]=d.useState(""),[a,c]=d.useState("1h"),[l,o]=d.useState(""),[u,m]=d.useState(!1),[x,g]=d.useState(null),[f,b]=d.useState(null),w=async()=>{if(!i.trim()){g("Please enter your name/ID");return}m(!0),g(null),b(null);try{const v=await B.reserveDevice(e.udid,e.host,i,a,l);v.success?(n(),s()):b(v.error||"Failed to reserve device")}catch(v){b(v.message||"An unexpected error occurred")}finally{m(!1)}};return t.jsx(yn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Mi,{size:16,className:"title-icon"}),"Reserve Device"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,disabled:u,children:"Cancel"}),t.jsx("button",{className:"btn-reserve",onClick:w,disabled:u||!i.trim(),children:u?"Reserving...":"Confirm Reservation"})]}),children:t.jsxs("div",{className:"reservation-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsxs("p",{children:["Reserve ",t.jsx("strong",{children:e.name||e.udid})," for exclusive use. This will prevent CI sessions from using this device."]}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(ei,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reserved By"]}),htmlFor:"reservation-reserved-by",error:x?t.jsxs(t.Fragment,{children:[t.jsx(Os,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),x]}):void 0,children:t.jsx("input",{id:"reservation-reserved-by",type:"text",className:"reservation-input",placeholder:"Enter your name or ID",value:i,onChange:v=>{r(v.target.value),x&&g(null)},disabled:u})}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(vn,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Duration"]}),children:t.jsx("div",{className:"duration-selector",children:La.map(v=>t.jsx("div",{className:`duration-option ${a===v.value?"active":""}`,onClick:()=>c(v.value),children:v.label},v.value))})}),t.jsx(Ut,{label:t.jsxs(t.Fragment,{children:[t.jsx(ar,{size:14,style:{marginRight:6,verticalAlign:"middle",color:"var(--green)"}}),"Reason (Optional)"]}),htmlFor:"reservation-reason",error:f?t.jsxs(t.Fragment,{children:[t.jsx(Os,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),f]}):void 0,children:t.jsx("input",{id:"reservation-reason",type:"text",className:"reservation-input",placeholder:"e.g., Debugging flaky login test",value:l,onChange:v=>o(v.target.value),disabled:u})})]})})},_a=({device:e,onClose:s,onUpdated:n})=>{const{toast:i}=Zt(),[r,a]=d.useState(e.tags||[]),[c,l]=d.useState(""),[o,u]=d.useState(!1),m=d.useRef(null);d.useEffect(()=>{m.current&&m.current.focus()},[]);const x=()=>{const w=c.trim();w&&!r.includes(w)&&(a([...r,w]),l(""))},g=w=>{a(r.filter(v=>v!==w))},f=w=>{w.key==="Enter"&&x()},b=async()=>{u(!0);try{await B.updateDeviceTags(e.udid,e.host,r),n(),s()}catch(w){console.error("Failed to update tags",w),i("Error saving tags. Please try again.","error")}finally{u(!1)}};return t.jsx(yn,{open:!0,onClose:s,width:520,title:t.jsxs(t.Fragment,{children:[t.jsx(Cr,{size:16,className:"title-icon"}),"Manage Device Tags"]}),footer:t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"btn-cancel",onClick:s,children:"Cancel"}),t.jsx("button",{className:"btn-save",onClick:b,disabled:o,children:o?"Saving...":"Apply Changes"})]}),children:t.jsxs("div",{className:"tag-modal-body",children:[t.jsxs("div",{className:"device-id-badge",children:[t.jsx("span",{className:"label",children:"Device:"}),t.jsx("span",{className:"value",children:e.udid})]}),t.jsx(Ut,{label:"Add New Tag",description:"Press Enter to add multiple tags",htmlFor:"tag-input",children:t.jsxs("div",{className:"input-with-button",children:[t.jsx("input",{ref:m,id:"tag-input",type:"text",placeholder:"e.g. stable, team-a, ios-17",value:c,onChange:w=>l(w.target.value),onKeyDown:f}),t.jsx("button",{className:"add-inline-btn",onClick:x,disabled:!c.trim(),children:t.jsx(li,{size:16})})]})}),t.jsxs("div",{className:"tags-display-section",children:[t.jsx("label",{children:"Current Tags"}),t.jsx("div",{className:"tags-list",children:r.length>0?r.map(w=>t.jsxs("div",{className:"tag-pill-editable",children:[w,t.jsx("button",{className:"remove-tag",onClick:()=>g(w),children:t.jsx(fn,{size:12})})]},w)):t.jsx("div",{className:"empty-tags",children:"No tags assigned to this device."})})]})]})})};function Oa(e){return e>=50?"ready":e>=20?"reserved":"error"}function Pa(e){return e>=50?t.jsx(Ei,{size:10}):e>=20?t.jsx(Si,{size:10}):t.jsx(Ai,{size:10})}function za(e){return e==="Normal"?"ready":e==="Critical"?"error":"reserved"}const Fa=({device:e})=>{const s=typeof e.batteryLevel=="number",n=typeof e.thermalStatus=="string"&&e.thermalStatus.length>0&&e.thermalStatus!=="Unknown";return!s&&!n?t.jsx("div",{className:"dc2-health",children:t.jsxs(Pe,{tone:"neutral",title:"Device does not report battery or thermal data",children:[t.jsx(di,{size:10}),"No telemetry"]})}):t.jsxs("div",{className:"dc2-health",children:[s&&t.jsxs(Pe,{tone:Oa(e.batteryLevel),title:`Battery ${e.batteryLevel}%`,children:[Pa(e.batteryLevel),e.batteryLevel,"%"]}),n&&t.jsxs(Pe,{tone:za(e.thermalStatus),title:`Thermal: ${e.thermalStatus}`,children:[t.jsx(Er,{size:10}),e.thermalStatus]})]})},Ua=/^([0-9a-f]{2}:){5}[0-9a-f]{2}$/i,Ba=/^(?:\d{1,3}\.){3}\d{1,3}$/;function Ha(e){const s=e.trim();return!s||Ua.test(s)||!Ba.test(s)?!1:s.split(".").every(n=>{const i=Number(n);return Number.isInteger(i)&&i>=0&&i<=255})}function Wa(e){return e==="127.0.0.1"||e==="localhost"||e==="0.0.0.0"}function Va(e){if(!e)return null;try{const s=new URL(e.includes("://")?e:`http://${e}`);return s.port?`${s.hostname}:${s.port}`:s.hostname}catch{return e}}function qa(e){if(e.ip&&Ha(e.ip))return e.ip;const s=Va(e.host);if(!s)return"—";const n=s.split(":")[0];return Wa(n)?"—":s}const Xa="/wd/hub";function Ka(e){return e==="android"?"UiAutomator2":"XCUITest"}function Ga(e){return e==="android"?"Android":e==="tvos"?"tvOS":"iOS"}function Ya(e,s=Xa){if(!e)return"—";try{const n=new URL(e.includes("://")?e:`http://${e}`),i=s.startsWith("/")?s:`/${s}`,r=n.pathname.replace(/\/$/,"");return r===i||r.endsWith(i)?`${n.protocol}//${n.host}${r}`:`${n.protocol}//${n.host}${i}`}catch{return e}}function Za(e){const s={platformName:Ga(e.platform),"appium:automationName":Ka(e.platform),"appium:udid":e.udid};return e.sdk&&e.sdk!=="Unknown"&&e.sdk!=="unknown"&&(s["appium:platformVersion"]=e.sdk),e.name&&(s["appium:deviceName"]=e.name),s}function Ja(e){return JSON.stringify(Za(e),null,2)}function Qa(e){return e==="real"?"Real":e==="simulator"?"Simulator":e==="emulator"?"Emulator":null}const tn="Shared",ec="Shared pool — visible to all authenticated users",tc=({udid:e,currentTeamId:s,resolvedTeamName:n,teams:i,canEdit:r,onChanged:a})=>{const{toast:c}=Zt(),[l,o]=d.useState(!1),[u,m]=d.useState(!1),x=s?i.get(s)??n??`Team ${s.slice(0,6)}`:tn;async function g(f){m(!0);try{await B.setDeviceTeam(e,f),c(f?"Device assigned":"Device returned to shared pool","success"),a(),o(!1)}catch(b){c((b==null?void 0:b.message)||"Failed to update team","error")}finally{m(!1)}}return r?l?t.jsxs(Jt,{selectSize:"sm",autoFocus:!0,disabled:u,defaultValue:s??"",onBlur:()=>o(!1),onChange:f=>g(f.target.value||null),children:[t.jsx("option",{value:"",children:"(Shared pool)"}),Array.from(i.entries()).map(([f,b])=>t.jsx("option",{value:f,children:b},f))]}):t.jsx("button",{type:"button",onClick:()=>o(!0),className:"dc2-team-pill",title:s?"Click to change team":"Click to assign to a team",children:x}):s?t.jsx(Pe,{tone:"accent",title:`Team: ${x}`,children:x}):t.jsx(Pe,{tone:"neutral",title:ec,children:tn})};function sc(e){return e.offline?"offline":e.userBlocked?"error":e.busy?"busy":e.reservedUntil&&Date.now()<e.reservedUntil?"reserved":"ready"}function nc(e,s=10,n=4){return!e||e.length<=s+n+1?e:`${e.slice(0,s)}…${e.slice(-n)}`}const ic=({device:e,reloadDevices:s,navigate:n,teams:i})=>{var I,$,H;const[r,a]=d.useState(!1),[c,l]=d.useState(!1),[o,u]=d.useState(!1),m=d.useRef(null),{me:x}=ti(),{toast:g}=Zt(),f=(x==null?void 0:x.role)==="ADMIN"||(x==null?void 0:x.role)==="SUPER_ADMIN",b=sc(e),w=b==="reserved",v=!!(e.busy&&e.session_id&&!String(e.session_id).startsWith("manual_")),k=async(T,O)=>{var z;try{await((z=navigator.clipboard)==null?void 0:z.writeText(T)),g(O,"success")}catch{g("Failed to copy","error")}},C=Ya(e.host),N=Qa(e.deviceType),j=async()=>{await B.releaseReservation(e.udid,e.host),s()},D=async()=>{await B.blockDevice(e.udid,e.host),s()},R=async()=>{await B.unblockDevice(e.udid,e.host),s()};return t.jsxs("div",{className:`dc2 dc2-${b}`,children:[t.jsx("div",{className:"dc2-stripe"}),t.jsxs("div",{className:"dc2-header",children:[t.jsxs("span",{className:"dc2-platform",children:[e.platform.toUpperCase()," · ",e.sdk]}),t.jsx(Ur,{kind:b,showDot:!0,children:b})]}),t.jsx("div",{className:"dc2-name",title:e.name,children:e.name}),t.jsxs("div",{className:"dc2-udid-row",children:[t.jsx("div",{className:"dc2-udid",title:e.udid,children:nc(e.udid)}),t.jsx("button",{type:"button",className:"dc2-udid-copy",onClick:()=>k(e.udid,"UDID copied"),"aria-label":"Copy UDID",title:"Copy UDID",children:t.jsx(Xe,{size:12})})]}),t.jsx(Fa,{device:e}),t.jsxs("div",{className:"dc2-tags",children:[N&&t.jsx(Pe,{tone:"neutral",title:`Device type: ${N}`,children:N}),t.jsx(tc,{udid:e.udid,currentTeamId:e.teamId??null,resolvedTeamName:e.teamName??null,teams:i??new Map,canEdit:f,onChanged:s}),(I=e.tags)==null?void 0:I.slice(0,3).map(T=>t.jsx(Pe,{tone:"neutral",title:T,children:T},T)),((($=e.tags)==null?void 0:$.length)||0)>3&&t.jsxs(Pe,{tone:"neutral",children:["+",(((H=e.tags)==null?void 0:H.length)||0)-3]})]}),t.jsxs("div",{className:"dc2-metrics",children:[w?t.jsxs("div",{className:"dc2-banner dc2-banner-reserved",children:[t.jsx(vn,{size:12}),t.jsxs("span",{children:["RES · ",e.reservedBy||"anon",e.reservedUntil?` (${Hs(e.reservedUntil-Date.now(),{compact:!0})})`:""]})]}):e.session_id?t.jsxs("div",{className:"dc2-banner dc2-banner-session",children:[t.jsx(bn,{size:12}),t.jsxs("span",{children:["SID · ",String(e.session_id).slice(0,10)]})]}):t.jsx(ds,{label:"Time in use",value:e.totalUtilizationTimeMilliSec?Hs(e.totalUtilizationTimeMilliSec,{compact:!0}):"—"}),t.jsx(ds,{label:"Network",value:qa(e),mono:!0}),t.jsx(ds,{label:"Server",mono:!0,value:t.jsxs("span",{className:"dc2-copyable",children:[t.jsx("span",{className:"dc2-copyable-text",title:C,children:C}),C!=="—"&&t.jsx("button",{type:"button",className:"dc2-udid-copy",onClick:()=>k(C,"Server URL copied"),"aria-label":"Copy Appium server URL",title:"Copy Appium server URL",children:t.jsx(Xe,{size:12})})]})})]}),t.jsxs("div",{className:"dc2-actions",children:[t.jsx(st,{variant:"primary",size:"sm",disabled:v,onClick:()=>{v||n(`/devices/${e.udid}/control`)},title:v?"Locked: Appium session running":"Take control",className:"dc2-primary",children:"Control"}),w?t.jsx(st,{variant:"secondary",size:"sm",onClick:j,children:"Release"}):!e.userBlocked&&!e.busy?t.jsx(st,{variant:"secondary",size:"sm",onClick:()=>a(!0),children:"Reserve"}):null,t.jsx("button",{ref:m,type:"button",className:"dc2-more",onClick:()=>u(T=>!T),"aria-label":"More actions",children:t.jsx(Gi,{size:14})}),t.jsx(xa,{open:o,onClose:()=>u(!1),anchorRef:m,children:t.jsxs(Ma,{children:[t.jsx(zt,{icon:t.jsx(Xe,{size:12}),onClick:()=>{u(!1),k(Ja(e),"Session capabilities copied")},children:"Copy caps…"}),t.jsx(zt,{onClick:()=>{u(!1),l(!0)},children:"Manage tags…"}),e.userBlocked?t.jsx(zt,{onClick:()=>{u(!1),R()},children:"Exit maintenance"}):t.jsx(zt,{onClick:()=>{u(!1),D()},children:"Enter maintenance"})]})})]}),r&&t.jsx(Ia,{device:e,onClose:()=>a(!1),onReserved:()=>s()}),c&&t.jsx(_a,{device:e,onClose:()=>l(!1),onUpdated:()=>s()})]})};function rc(e){const s=ks();return t.jsx(ic,{device:e.device,reloadDevices:e.reloadDevices,navigate:s,teams:e.teams})}class oc extends je.Component{constructor(){super(...arguments),this.state={teamsMap:new Map}}componentDidMount(){B.listTeams().then(s=>{this.setState({teamsMap:new Map(s.map(n=>[n.id,n.name]))})}).catch(()=>{})}render(){return t.jsx("div",{className:"device-explorer-card-container",children:je.Children.toArray(this.props.devices.map(s=>t.jsx(rc,{device:s,reloadDevices:this.props.reloadDevices,teams:this.state.teamsMap})))})}}var Ft,ac=new Uint8Array(16);function cc(){if(!Ft&&(Ft=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Ft))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ft(ac)}const lc=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function dc(e){return typeof e=="string"&&lc.test(e)}var re=[];for(var ps=0;ps<256;++ps)re.push((ps+256).toString(16).substr(1));function uc(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(re[e[s+0]]+re[e[s+1]]+re[e[s+2]]+re[e[s+3]]+"-"+re[e[s+4]]+re[e[s+5]]+"-"+re[e[s+6]]+re[e[s+7]]+"-"+re[e[s+8]]+re[e[s+9]]+"-"+re[e[s+10]]+re[e[s+11]]+re[e[s+12]]+re[e[s+13]]+re[e[s+14]]+re[e[s+15]]).toLowerCase();if(!dc(n))throw TypeError("Stringified UUID is invalid");return n}function mc(e,s,n){e=e||{};var i=e.random||(e.rng||cc)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,uc(i)}const hc=({onCommand:e,prompt:s="$",welcomeMessage:n="Interactive Shell (Restricted Mode)",platform:i})=>{const[r,a]=d.useState([{type:"system",content:n,timestamp:Date.now()},{type:"system",content:'Type "help" for allowed commands.',timestamp:Date.now()}]),[c,l]=d.useState(""),[o,u]=d.useState([]),[m,x]=d.useState(-1),[g,f]=d.useState(!1),b=d.useRef(null),w=d.useRef(null);d.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[r]);const v=C=>{const N=C.trim();if((N.startsWith("{")||N.startsWith("["))&&(N.endsWith("}")||N.endsWith("]")))try{const j=JSON.parse(N);return JSON.stringify(j,null,2)}catch{}return C},k=async C=>{if(C.key==="Enter"&&!g){const N=c.trim();if(!N)return;if(l(""),a(j=>[...j,{type:"command",content:`${s} ${N}`,timestamp:Date.now()}]),u(j=>[...j,N]),x(-1),f(!0),N==="clear"){a([]),f(!1);return}if(N==="help"){let j="";i==="android"?j=`
197
197
  Android Allowed Commands:
198
198
  • System Info: getprop, ip addr, date, uptime, cat /proc/meminfo, cat /proc/cpuinfo
199
199
  • Process Mgmt: ps, top
@@ -208,9 +208,9 @@ iOS Allowed Commands:
208
208
  listapps, get_app_container, list, getenv
209
209
  • Simulator System:
210
210
  ls, ps, top, date, uptime, whoami
211
- `),a($=>[...$,{type:"output",content:j.trim(),timestamp:Date.now()}]),f(!1);return}try{const j=await e(N),$=b(j||"(No output)");a(R=>[...R,{type:"output",content:$,timestamp:Date.now()}])}catch(j){a($=>[...$,{type:"error",content:j.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var j;return(j=w.current)==null?void 0:j.focus()},10)}}else if(C.key==="ArrowUp"){if(C.preventDefault(),o.length>0){const N=m===-1?o.length-1:Math.max(0,m-1);x(N),l(o[N])}}else if(C.key==="ArrowDown"&&(C.preventDefault(),m!==-1)){const N=m+1;N>=o.length?(x(-1),l("")):(x(N),l(o[N]))}};return t.jsxs("div",{className:"terminal-container",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"terminal-header",children:[t.jsxs("div",{className:"terminal-controls",children:[t.jsx("div",{className:"dot red"}),t.jsx("div",{className:"dot yellow"}),t.jsx("div",{className:"dot green"})]}),t.jsxs("div",{className:"terminal-title",children:[i.toUpperCase()," INTERNAL SHELL"]}),t.jsx("div",{className:"terminal-actions",children:t.jsx("button",{className:"terminal-action-btn",onClick:()=>a([]),title:"Clear Terminal",children:"CLEAR"})})]}),t.jsxs("div",{className:"terminal-history",ref:v,onClick:()=>{var C;return(C=w.current)==null?void 0:C.focus()},children:[r.map((C,N)=>t.jsx("div",{className:`terminal-line ${C.type}`,children:C.content},N)),g&&t.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),t.jsxs("div",{className:"terminal-input-area",children:[t.jsx("span",{className:"terminal-prompt",children:s}),t.jsx("input",{ref:w,className:"terminal-input",value:c,onChange:C=>l(C.target.value),onKeyDown:k,disabled:g,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Me(e,s){var n;s(e),(n=e.children)==null||n.forEach(i=>Me(i,s))}function $e(e,...s){var n;for(const i of s){const r=(n=e.attributes)==null?void 0:n[i];if(r!=null&&r!=="")return String(r)}}function ot(e){var s;return((s=e.type)==null?void 0:s.split(".").pop())||e.type||""}function fc(e,s){const n=[];return Me(e,i=>{$e(i,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(i)}),n}function pc(e,s){const n=[];return Me(e,i=>{$e(i,"resource-id","resourceId","identifier")===s&&n.push(i)}),n}function Ns(e,s){const n=[];return Me(e,i=>{(i.type===s||ot(i)===s)&&n.push(i)}),n}function gc(e,s){const n=[];return Me(e,i=>{$e(i,"name")===s&&n.push(i)}),n}function xc(e){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function yc(e,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const i=[];for(const a of n){const c=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(a);if(!c)return null;i.push({type:c[1],index:parseInt(c[2],10)})}if(i[0].type!==e.type&&i[0].type!==ot(e)||i[0].index!==1)return null;let r=e;for(let a=1;a<i.length&&r;a++){const{type:c,index:l}=i[a];let o=0,u;for(const m of r.children||[])if((m.type===c||ot(m)===c)&&(o+=1,o===l)){u=m;break}r=u}return r?[r]:[]}function vc(e,s){const n=yc(e,s);if(n!==null)return{kind:"matched",nodes:n};const i=xc(s);if(i){const r=[];return Me(e,a=>{if(i.tag&&a.type!==i.tag&&ot(a)!==i.tag)return;$e(a,i.attrKey)===i.attrValue&&r.push(a)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function bc(e,s){const n=s.trim(),i=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(i){const[,c,l,o]=i,u=[];return Me(e,m=>{if(m.type!==c&&ot(m)!==c)return;$e(m,l)===o&&u.push(m)}),{kind:"matched",nodes:u}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,c,l]=r,o=parseInt(l,10),u=[];return Me(e,m=>{(m.type===c||ot(m)===c)&&u.push(m)}),{kind:"matched",nodes:u[o-1]?[u[o-1]]:[]}}const a=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return a?Ns(e,a[1]).length>0?{kind:"matched",nodes:Ns(e,a[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function wc(e,s){const i=s.trim().split(/\s+AND\s+/i).map(c=>c.trim()),r=[];for(const c of i){const l=/^(\w+)\s*==\s*"([^"]*)"$/.exec(c);if(!l)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:l[1],value:l[2]})}const a=[];return Me(e,c=>{for(const l of r){let o;if(l.key==="type"?o=c.type:l.key==="label"?o=$e(c,"label")??c.label:l.key==="name"?o=$e(c,"name")??c.name:l.key==="value"?o=$e(c,"value")??c.value:o=$e(c,l.key),o!==l.value)return}a.push(c)}),{kind:"matched",nodes:a}}function jc(e,s,n){const i=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(i){case"accessibility id":return{kind:"matched",nodes:fc(e,n)};case"id":return{kind:"matched",nodes:pc(e,n)};case"class name":return{kind:"matched",nodes:Ns(e,n)};case"name":return{kind:"matched",nodes:gc(e,n)};case"xpath":return vc(e,n);case"-ios class chain":return bc(e,n);case"-ios predicate string":return wc(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function sn(e,s){const n=e.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 i=(s.match(/\//g)||[]).length;return i>7?{level:"fragile",reason:`${i}-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 nn(e,s,n,i){var C,N,j,$,R,I,D;const{strategy:r,value:a}=i,c=(e.text||e.name||((C=e.type)==null?void 0:C.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",l=c.charAt(0).toLowerCase()+c.slice(1),o=((N=e.type)==null?void 0:N.toLowerCase().includes("edit"))||((j=e.type)==null?void 0:j.toLowerCase().includes("input"))||(($=e.type)==null?void 0:$.toLowerCase().includes("field"))||((R=e.type)==null?void 0:R.toLowerCase().includes("textfield")),u=((I=e.attributes)==null?void 0:I.scrollable)==="true"||((D=e.attributes)==null?void 0:D.scrollable)===!0,m=r.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
211
+ `),a(D=>[...D,{type:"output",content:j.trim(),timestamp:Date.now()}]),f(!1);return}try{const j=await e(N),D=v(j||"(No output)");a(R=>[...R,{type:"output",content:D,timestamp:Date.now()}])}catch(j){a(D=>[...D,{type:"error",content:j.message||"Unknown error",timestamp:Date.now()}])}finally{f(!1),setTimeout(()=>{var j;return(j=w.current)==null?void 0:j.focus()},10)}}else if(C.key==="ArrowUp"){if(C.preventDefault(),o.length>0){const N=m===-1?o.length-1:Math.max(0,m-1);x(N),l(o[N])}}else if(C.key==="ArrowDown"&&(C.preventDefault(),m!==-1)){const N=m+1;N>=o.length?(x(-1),l("")):(x(N),l(o[N]))}};return t.jsxs("div",{className:"terminal-container",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"terminal-header",children:[t.jsxs("div",{className:"terminal-controls",children:[t.jsx("div",{className:"dot red"}),t.jsx("div",{className:"dot yellow"}),t.jsx("div",{className:"dot green"})]}),t.jsxs("div",{className:"terminal-title",children:[i.toUpperCase()," INTERNAL SHELL"]}),t.jsx("div",{className:"terminal-actions",children:t.jsx("button",{className:"terminal-action-btn",onClick:()=>a([]),title:"Clear Terminal",children:"CLEAR"})})]}),t.jsxs("div",{className:"terminal-history",ref:b,onClick:()=>{var C;return(C=w.current)==null?void 0:C.focus()},children:[r.map((C,N)=>t.jsx("div",{className:`terminal-line ${C.type}`,children:C.content},N)),g&&t.jsx("div",{className:"terminal-line system animate-pulse",children:"Executing command..."})]}),t.jsxs("div",{className:"terminal-input-area",children:[t.jsx("span",{className:"terminal-prompt",children:s}),t.jsx("input",{ref:w,className:"terminal-input",value:c,onChange:C=>l(C.target.value),onKeyDown:k,disabled:g,autoFocus:!0,spellCheck:!1,autoComplete:"off",placeholder:"Type a command..."})]})]})};function Me(e,s){var n;s(e),(n=e.children)==null||n.forEach(i=>Me(i,s))}function $e(e,...s){var n;for(const i of s){const r=(n=e.attributes)==null?void 0:n[i];if(r!=null&&r!=="")return String(r)}}function ot(e){var s;return((s=e.type)==null?void 0:s.split(".").pop())||e.type||""}function fc(e,s){const n=[];return Me(e,i=>{$e(i,"content-desc","contentDescription","accessibilityId","name","label")===s&&n.push(i)}),n}function pc(e,s){const n=[];return Me(e,i=>{$e(i,"resource-id","resourceId","identifier")===s&&n.push(i)}),n}function Ns(e,s){const n=[];return Me(e,i=>{(i.type===s||ot(i)===s)&&n.push(i)}),n}function gc(e,s){const n=[];return Me(e,i=>{$e(i,"name")===s&&n.push(i)}),n}function xc(e){const s=/^\/\/(\*|[A-Za-z_][\w.-]*)\[@([\w-]+)=(["'])(.*?)\3\]$/.exec(e.trim());return s?{tag:s[1]==="*"?null:s[1],attrKey:s[2],attrValue:s[4]}:null}function yc(e,s){const n=s.split("/").filter(Boolean);if(n.length===0)return null;const i=[];for(const a of n){const c=/^([A-Za-z_][\w.-]*)\[(\d+)\]$/.exec(a);if(!c)return null;i.push({type:c[1],index:parseInt(c[2],10)})}if(i[0].type!==e.type&&i[0].type!==ot(e)||i[0].index!==1)return null;let r=e;for(let a=1;a<i.length&&r;a++){const{type:c,index:l}=i[a];let o=0,u;for(const m of r.children||[])if((m.type===c||ot(m)===c)&&(o+=1,o===l)){u=m;break}r=u}return r?[r]:[]}function vc(e,s){const n=yc(e,s);if(n!==null)return{kind:"matched",nodes:n};const i=xc(s);if(i){const r=[];return Me(e,a=>{if(i.tag&&a.type!==i.tag&&ot(a)!==i.tag)return;$e(a,i.attrKey)===i.attrValue&&r.push(a)}),{kind:"matched",nodes:r}}return{kind:"unsupported",nodes:[],reason:"Complex XPath (axes, multiple predicates, functions) — use a real driver to verify"}}function bc(e,s){const n=s.trim(),i=/^\*\*\/([A-Za-z_]\w*)\[`(\w+)\s*==\s*"([^"]*)"`\]$/.exec(n);if(i){const[,c,l,o]=i,u=[];return Me(e,m=>{if(m.type!==c&&ot(m)!==c)return;$e(m,l)===o&&u.push(m)}),{kind:"matched",nodes:u}}const r=/^\*\*\/([A-Za-z_]\w*)\[(\d+)\]$/.exec(n);if(r){const[,c,l]=r,o=parseInt(l,10),u=[];return Me(e,m=>{(m.type===c||ot(m)===c)&&u.push(m)}),{kind:"matched",nodes:u[o-1]?[u[o-1]]:[]}}const a=/^\*\*\/([A-Za-z_]\w*)$/.exec(n);return a?Ns(e,a[1]).length>0?{kind:"matched",nodes:Ns(e,a[1])}:{kind:"matched",nodes:[]}:{kind:"unsupported",nodes:[],reason:"Multi-segment class chain — use a real driver to verify"}}function wc(e,s){const i=s.trim().split(/\s+AND\s+/i).map(c=>c.trim()),r=[];for(const c of i){const l=/^(\w+)\s*==\s*"([^"]*)"$/.exec(c);if(!l)return{kind:"unsupported",nodes:[],reason:"Predicate uses unsupported operator (only ==, AND) — use a real driver"};r.push({key:l[1],value:l[2]})}const a=[];return Me(e,c=>{for(const l of r){let o;if(l.key==="type"?o=c.type:l.key==="label"?o=$e(c,"label")??c.label:l.key==="name"?o=$e(c,"name")??c.name:l.key==="value"?o=$e(c,"value")??c.value:o=$e(c,l.key),o!==l.value)return}a.push(c)}),{kind:"matched",nodes:a}}function jc(e,s,n){const i=s.toLowerCase();if(!n)return{kind:"matched",nodes:[]};switch(i){case"accessibility id":return{kind:"matched",nodes:fc(e,n)};case"id":return{kind:"matched",nodes:pc(e,n)};case"class name":return{kind:"matched",nodes:Ns(e,n)};case"name":return{kind:"matched",nodes:gc(e,n)};case"xpath":return vc(e,n);case"-ios class chain":return bc(e,n);case"-ios predicate string":return wc(e,n);default:return{kind:"unsupported",nodes:[],reason:`Strategy "${s}" not yet supported by snapshot matcher`}}}function sn(e,s){const n=e.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 i=(s.match(/\//g)||[]).length;return i>7?{level:"fragile",reason:`${i}-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 nn(e,s,n,i){var C,N,j,D,R,I,$;const{strategy:r,value:a}=i,c=(e.text||e.name||((C=e.type)==null?void 0:C.split(".").pop())||"element").replace(/[^a-zA-Z0-9]/g,"_").replace(/^_+/,"").slice(0,24)||"element",l=c.charAt(0).toLowerCase()+c.slice(1),o=((N=e.type)==null?void 0:N.toLowerCase().includes("edit"))||((j=e.type)==null?void 0:j.toLowerCase().includes("input"))||((D=e.type)==null?void 0:D.toLowerCase().includes("field"))||((R=e.type)==null?void 0:R.toLowerCase().includes("textfield")),u=((I=e.attributes)==null?void 0:I.scrollable)==="true"||(($=e.attributes)==null?void 0:$.scrollable)===!0,m=r.toLowerCase().startsWith("-ios")&&s!=="ios"?`// ⚠️ -ios predicate/class chain ONLY work with XCUITest (iOS)
212
212
  `:r.toLowerCase().startsWith("-android")&&s!=="android"?`// ⚠️ -android uiautomator ONLY works with UIAutomator2 (Android)
213
- `:"",x={"accessibility id":`~${a}`,id:s==="ios"?`-ios predicate string:label == "${a}"`:`android=new UiSelector().resourceId("${a}")`,xpath:`${a}`,"-ios predicate string":`-ios predicate string:${a}`,"-ios class chain":`-ios class chain:${a}`,"-android uiautomator":`android=${a}`},g={"accessibility id":`AppiumBy.accessibilityId("${a}")`,id:`AppiumBy.id("${a}")`,xpath:`AppiumBy.xpath("${a}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${a}")`,"-ios class chain":`AppiumBy.iOSClassChain("${a}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${a}")`,"class name":`AppiumBy.className("${a}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${a}"`,id:`AppiumBy.ID, "${a}"`,xpath:`AppiumBy.XPATH, "${a}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${a}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${a}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${a}'`,"class name":`AppiumBy.CLASS_NAME, "${a}"`},v=g[r.toLowerCase()],w=f[r.toLowerCase()],b=x[r.toLowerCase()];return n==="java"?v?`${m}// Appium Java Client 9.x + Selenium 4 + TestNG
213
+ `:"",x={"accessibility id":`~${a}`,id:s==="ios"?`-ios predicate string:label == "${a}"`:`android=new UiSelector().resourceId("${a}")`,xpath:`${a}`,"-ios predicate string":`-ios predicate string:${a}`,"-ios class chain":`-ios class chain:${a}`,"-android uiautomator":`android=${a}`},g={"accessibility id":`AppiumBy.accessibilityId("${a}")`,id:`AppiumBy.id("${a}")`,xpath:`AppiumBy.xpath("${a}")`,"-ios predicate string":`AppiumBy.iOSNsPredicateString("${a}")`,"-ios class chain":`AppiumBy.iOSClassChain("${a}")`,"-android uiautomator":`AppiumBy.androidUIAutomator("${a}")`,"class name":`AppiumBy.className("${a}")`},f={"accessibility id":`AppiumBy.ACCESSIBILITY_ID, "${a}"`,id:`AppiumBy.ID, "${a}"`,xpath:`AppiumBy.XPATH, "${a}"`,"-ios predicate string":`AppiumBy.IOS_PREDICATE, "${a}"`,"-ios class chain":`AppiumBy.IOS_CLASS_CHAIN, "${a}"`,"-android uiautomator":`AppiumBy.ANDROID_UIAUTOMATOR, '${a}'`,"class name":`AppiumBy.CLASS_NAME, "${a}"`},b=g[r.toLowerCase()],w=f[r.toLowerCase()],v=x[r.toLowerCase()];return n==="java"?b?`${m}// Appium Java Client 9.x + Selenium 4 + TestNG
214
214
  import io.appium.java_client.AppiumBy;
215
215
  import io.appium.java_client.${s==="android"?"AndroidDriver":s==="ios"?"IOSDriver":"AppiumDriver"};
216
216
  import org.openqa.selenium.WebElement;
@@ -218,7 +218,7 @@ import org.testng.annotations.Test;
218
218
 
219
219
  @Test
220
220
  public void test_${l}() {
221
- WebElement element = driver.findElement(${v});
221
+ WebElement element = driver.findElement(${b});
222
222
  ${u?'((Scrollable) element).scrollTo("target text");':o?`element.clear();
223
223
  element.sendKeys("your text here");`:"element.click();"}
224
224
  // Add assertions here via TestNG Assert or Hamcrest
@@ -230,26 +230,26 @@ def test_${l}(self):
230
230
  element = self.driver.find_element(${w})
231
231
  ${o?`element.clear()
232
232
  element.send_keys("your text here")`:"element.click()"}
233
- # Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?b?`${m}// WebdriverIO 9.x + @wdio/appium-service
233
+ # Add assertions here via assert or pytest.assert`:`# Strategy "${r}" not supported in Appium Python Client`:n==="javascript"?v?`${m}// WebdriverIO 9.x + @wdio/appium-service
234
234
  describe('${l} test', () => {
235
235
  it('should interact with ${l}', async () => {
236
- const element = await $('${b}');
236
+ const element = await $('${v}');
237
237
  await element.waitForDisplayed({ timeout: 5000 });
238
238
  ${o?`await element.clearValue();
239
239
  await element.addValue("your text here");`:"await element.click();"}
240
240
  // Add assertions here via expect(element)
241
241
  });
242
- });`:`// Strategy "${r}" not supported in WebdriverIO mobile`:b?`${m}// WebdriverIO 9.x standalone
243
- const element = await driver.$('${b}');
242
+ });`:`// Strategy "${r}" not supported in WebdriverIO mobile`:v?`${m}// WebdriverIO 9.x standalone
243
+ const element = await driver.$('${v}');
244
244
  await element.waitForExist({ timeout: 5000 });
245
245
  ${o?`await driver.$('target').clearValue();
246
246
  await element.addValue("your text here");`:"await element.click();"}
247
- // Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}function rn(e){var f,v,w,b,k,C,N,j,$,R,I;const s=(e.type||"").toLowerCase(),n=((f=e.attributes)==null?void 0:f.clickable)==="true"||((v=e.attributes)==null?void 0:v.clickable)===!0,i=((w=e.attributes)==null?void 0:w.enabled)!=="false"&&((b=e.attributes)==null?void 0:b.enabled)!==!1,r=((k=e.attributes)==null?void 0:k.scrollable)==="true"||((C=e.attributes)==null?void 0:C.scrollable)===!0,a=e.text||e.label||e.value||"",c=((N=e.children)==null?void 0:N.length)||0;let l="Element",o="📦";s.includes("button")||s.includes("btn")||n&&c===0?(l="Button",o="🔘"):s.includes("edit")||s.includes("input")||s.includes("field")?(l="Text Input",o="✏️"):s.includes("image")||s.includes("img")||s.includes("imageview")?(l="Image",o="🖼️"):s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||r?(l="Scrollable List",o="📜"):s.includes("text")||s.includes("label")?(l="Text Label",o="📝"):s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?(l="Toggle / Checkbox",o="☑️"):s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?(l="Navigation Bar",o="🧭"):c>0&&(l=`Container (${c} children)`,o="🗂️");const u=((j=e.suggestedLocators)==null?void 0:j.find(D=>D.strategy==="accessibility id"||D.strategy==="id"))||(($=e.suggestedLocators)==null?void 0:$[0]),m=i?((R=e.rect)==null?void 0:R.width)===0||((I=e.rect)==null?void 0:I.height)===0?"⚠️ Zero-size element — may not be interactable":void 0:"⚠️ Element is disabled",x=a?` with text "${a.slice(0,30)}"`:"",g=`This is a ${l.toLowerCase()}${x}. ${n?"It can be tapped/clicked.":r?"It supports scrolling.":"It is a visual container."}${c>0?` Contains ${c} child element${c>1?"s":""}.`:""}`;return{role:l,description:g,interactable:n||i,bestLocator:u,warning:m,emoji:o}}function on(e,s){if(!s)return!0;const n=s.toLowerCase().trim(),i={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},r=(e.type||"").toLowerCase(),a=(e.text||e.label||e.value||"").toLowerCase(),c=(e.name||"").toLowerCase(),l=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[o,u]of Object.entries(i))if(n.includes(o)&&u.some(m=>r.includes(m)))return!0;return r.includes(n)||a.includes(n)||c.includes(n)||l.includes(n)}const Nc=({sessionId:e,udid:s,streamUrl:n,embedded:i=!1,overlayTarget:r=null,onModeChange:a})=>{var Et,$t,pt,Dt,Tt,Mt,gt,Lt,It,We;const[c,l]=d.useState(!0),[o,u]=d.useState(null),[m,x]=d.useState(null),[g,f]=d.useState(null),[v,w]=d.useState(null),[b,k]=d.useState(new Set(["/"])),[C,N]=d.useState(""),[j,$]=d.useState(null),[R,I]=d.useState("info"),[D,H]=d.useState("java"),[T,_]=d.useState(null),[z,G]=d.useState({width:0,height:0}),[V,J]=d.useState({width:0,height:0}),[F,U]=d.useState(!1),[p,Q]=d.useState("inspect");d.useEffect(()=>{a==null||a(p)},[p,a]);const[ie,oe]=d.useState({}),[ye,ue]=d.useState({}),[ve,ke]=d.useState(null),[Y,P]=d.useState(null),[Z,ne]=d.useState(null),se=d.useRef(null),Ae=d.useRef(null),Ge=d.useRef(null),ae=d.useRef(null),be=d.useCallback(()=>{var ee,X,K;if(!se.current)return;const h=se.current.getBoundingClientRect(),A=h.width,L=h.height,y=(ee=o==null?void 0:o.hierarchy)==null?void 0:ee.rect;let S=((X=o==null?void 0:o.metadata)==null?void 0:X.screenWidth)||z.width||1,E=((K=o==null?void 0:o.metadata)==null?void 0:K.screenHeight)||z.height||1;y&&y.width>0&&y.height>0&&(S=y.width,E=y.height);const M=S/E;let q,O;A/L>M?(O=L,q=O*M):(q=A,O=q/M),J({width:q,height:O})},[o,z]);d.useEffect(()=>(be(),window.addEventListener("resize",be),()=>window.removeEventListener("resize",be)),[be]),d.useEffect(()=>{s&&Ie()},[s]),d.useEffect(()=>{if(!s)return;let h=!1;return B.getAppiumSession(s).then(A=>{h||P({sessionId:(A==null?void 0:A.sessionId)??null,basePath:(A==null?void 0:A.basePath)??""})}).catch(()=>{h||P({sessionId:null,basePath:""})}),()=>{h=!0}},[s]);const Ue=d.useCallback(async(h,A,L)=>{if(Y!=null&&Y.sessionId){ke(h);try{const y=await B.verifyLocator(Y.basePath,Y.sessionId,{strategy:h,selector:A,action:L});ue(S=>({...S,[h]:y}))}catch(y){ue(S=>({...S,[h]:{found:!1,count:0,error:(y==null?void 0:y.message)||String(y)}}))}finally{ke(null)}}},[Y]);d.useEffect(()=>{var h;if((h=g==null?void 0:g.suggestedLocators)!=null&&h.length){const A=g.suggestedLocators.find(L=>L.strategy==="accessibility id"||L.strategy==="id")||g.suggestedLocators[0];_(A)}else _(null);oe({}),ue({}),ne(null)},[g]);const Ye=d.useCallback((h,A)=>{if(!(o!=null&&o.hierarchy))return;const L=jc(o.hierarchy,h,A);oe(y=>({...y,[h]:L})),ne(h)},[o]),Ie=async()=>{if(s){l(!0),x(null);try{const h=await B.getInspectorSnapshot(s);if(!(h!=null&&h.hierarchy)){u(null),x((h==null?void 0:h.error)||"Failed to capture snapshot");return}u(h);const A=new Set(["/"]),L=(y,S)=>{var E;S<3&&(A.add(y.xpath),(E=y.children)==null||E.forEach(M=>L(M,S+1)))};L(h.hierarchy,0),k(A)}catch(h){u(null),x(h.message||"Failed to capture snapshot")}finally{l(!1)}}},lt=h=>{const{naturalWidth:A,naturalHeight:L}=h.currentTarget;G({width:A,height:L})},he=()=>U(!0),fe=h=>{U(!1);const{naturalWidth:A,naturalHeight:L}=h.currentTarget;A>0&&L>0&&G({width:A,height:L})},_e=n&&!F,dt=h=>{if(p!=="interact"||!s)return;const A=h.currentTarget.getBoundingClientRect();ae.current={x:h.clientX-A.left,y:h.clientY-A.top,time:Date.now()}},Be=async h=>{var me,Oe,Ve;if(p!=="interact"||!s||!ae.current)return;const A=ae.current,L=h.currentTarget.getBoundingClientRect(),y=h.clientX-L.left,S=h.clientY-L.top,E=Date.now()-A.time,M=V.width,q=V.height,O=(me=o==null?void 0:o.hierarchy)==null?void 0:me.rect;let ee=((Oe=o==null?void 0:o.metadata)==null?void 0:Oe.screenWidth)||z.width,X=((Ve=o==null?void 0:o.metadata)==null?void 0:Ve.screenHeight)||z.height;if(O&&O.width>0&&O.height>0&&(ee=O.width,X=O.height),!ee||!X||M===0||q===0)return;const K=(_t,_s)=>({x:Math.round(_t/M*ee),y:Math.round(_s/q*X),px:_t/M,py:_s/q}),te=K(A.x,A.y),we=K(y,S),Ee=Math.sqrt(Math.pow(y-A.x,2)+Math.pow(S-A.y,2));if(!(te.px<0||te.px>1||te.py<0||te.py>1)){try{E<500&&Ee<10?await B.tap(s,te.x,te.y):E>=500&&Ee<10?await B.touchAndHold(s,te.x,te.y,E):Ee>=10&&await B.swipe(s,te.x,te.y,we.x,we.y)}catch(_t){console.error("Interaction failed:",_t)}ae.current=null}},Ct=h=>{const A=new Set(b);A.has(h)?A.delete(h):A.add(h),k(A)},St=()=>{const h=new Set,A=L=>{var y;h.add(L.xpath),(y=L.children)==null||y.forEach(A)};o!=null&&o.hierarchy&&A(o.hierarchy),k(h)},Re=()=>k(new Set(["/"])),pe=(h,A)=>{navigator.clipboard.writeText(h),$(A),setTimeout(()=>$(null),2e3)},Ze=h=>{var L;let A=1;return(L=h.children)==null||L.forEach(y=>A+=Ze(y)),A},Je=h=>{if(!h)return[];const A={},L=y=>{var M;const S=rn(y),E=S.role.replace(/\s*\(.*?\)\s*/,"");A[E]||(A[E]={emoji:S.emoji,count:0}),A[E].count+=1,(M=y.children)==null||M.forEach(L)};return L(h),Object.entries(A).map(([y,S])=>({role:y,emoji:S.emoji,count:S.count})).sort((y,S)=>S.count-y.count)},kt=h=>h.xpath.split("/").filter(Boolean).slice(-3),At=(h,A=0)=>{var K,te,we,Ee;if(!h)return null;const L=b.has(h.xpath),y=((K=h.children)==null?void 0:K.length)>0,S=(g==null?void 0:g.xpath)===h.xpath,E=(v==null?void 0:v.xpath)===h.xpath,M=((te=h.type)==null?void 0:te.split(".").pop())||"Element",q=h.label||((we=h.attributes)==null?void 0:we["content-desc"])||((Ee=h.attributes)==null?void 0:Ee["resource-id"])||h.name,O=typeof q=="string"&&q&&q!==M&&q!==h.type?q:null,ee=O||M,X=!C||on(h,C);if(!X&&!y)return null;if(C&&!X){const me=Oe=>{var Ve;return on(Oe,C)?!0:((Ve=Oe.children)==null?void 0:Ve.some(me))||!1};if(!me(h))return null}return t.jsxs("div",{className:"tree-node",children:[t.jsxs("div",{className:`tree-item ${S?"selected":""} ${E&&!S?"hovered":""}`,onClick:()=>{f(h),I("info")},onMouseEnter:()=>w(h),onMouseLeave:()=>w(null),children:[t.jsx("div",{className:"tree-item-indent",style:{width:`${A*14}px`}}),y?t.jsx("button",{onClick:me=>{me.stopPropagation(),Ct(h.xpath)},className:"tree-toggle",children:L?t.jsx(pn,{size:11}):t.jsx(wn,{size:11})}):t.jsx("span",{className:"tree-toggle-spacer"}),t.jsx(Di,{size:11,className:"tree-icon"}),t.jsx("span",{className:"tree-label",title:`${M}${O?` — ${O}`:""}`,children:ee}),O&&t.jsx("span",{className:"tree-type-tag",title:M,children:M}),h.text&&t.jsxs("span",{className:"tree-text-preview",children:['"',h.text.slice(0,20),'"']}),y&&t.jsx("span",{className:"tree-badge",children:h.children.length})]}),L&&y&&t.jsx("div",{className:"tree-children",children:h.children.map(me=>At(me,A+1))})]},h.xpath)},ut=()=>{var y,S,E;const h=(y=o==null?void 0:o.hierarchy)==null?void 0:y.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const A=((S=o==null?void 0:o.metadata)==null?void 0:S.screenWidth)||z.width,L=((E=o==null?void 0:o.metadata)==null?void 0:E.screenHeight)||z.height;return A>0&&L>0?{w:A,h:L}:null},He=h=>{const A=ut();if(!A)return[];const L=[],{w:y,h:S}=A,E=(M,q)=>{var ee,X,K;const O=!M.children||M.children.length===0;((ee=M.rect)==null?void 0:ee.width)>0&&((X=M.rect)==null?void 0:X.height)>0&&O&&L.push(t.jsx("div",{className:"omni-hit-area",style:{left:`${M.rect.x/y*100}%`,top:`${M.rect.y/S*100}%`,width:`${M.rect.width/y*100}%`,height:`${M.rect.height/S*100}%`,zIndex:q},onClick:te=>{te.stopPropagation(),f(M),I("info")},onMouseEnter:()=>w(M),onMouseLeave:()=>w(null)},M.xpath)),(K=M.children)==null||K.forEach(te=>E(te,q+1))};return o!=null&&o.hierarchy&&E(o.hierarchy,1),L},mt=()=>{var E,M,q;if(!Z||!z.width)return[];const h=ie[Z];if(!h||h.kind!=="matched"||h.nodes.length===0)return[];const A=(E=o==null?void 0:o.hierarchy)==null?void 0:E.rect;let L=((M=o==null?void 0:o.metadata)==null?void 0:M.screenWidth)||z.width,y=((q=o==null?void 0:o.metadata)==null?void 0:q.screenHeight)||z.height;A&&A.width>0&&A.height>0&&(L=A.width,y=A.height);const S=h.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return h.nodes.filter(O=>O.rect&&O.rect.width>0&&O.rect.height>0).map((O,ee)=>t.jsx("div",{className:S,style:{left:`${O.rect.x/L*100}%`,top:`${O.rect.y/y*100}%`,width:`${O.rect.width/L*100}%`,height:`${O.rect.height/y*100}%`}},`match-${Z}-${ee}`))},Qe=(h,A)=>{const L=ut();if(!(h!=null&&h.rect)||!L)return null;const{w:y,h:S}=L;return t.jsx("div",{className:`omni-frame-${A}`,style:{left:`${h.rect.x/y*100}%`,top:`${h.rect.y/S*100}%`,width:`${h.rect.width/y*100}%`,height:`${h.rect.height/S*100}%`}})},ht=o!=null&&o.hierarchy?Ze(o.hierarchy):0,ce=g?rn(g):null,ft=o!=null&&o.hierarchy&&p==="inspect"?t.jsxs("div",{className:"omni-overlay",children:[He(o.hierarchy),mt(),Qe(v,"hover"),Qe(g,"select")]}):null,ns={stable:{icon:t.jsx(Ot,{size:10}),cls:"stable"},moderate:{icon:t.jsx(tt,{size:10}),cls:"moderate"},fragile:{icon:t.jsx(et,{size:10}),cls:"fragile"},"very-fragile":{icon:t.jsx(et,{size:10}),cls:"very-fragile"}},Rt=i&&(o!=null&&o.hierarchy)?Je(o.hierarchy):[];return t.jsxs("div",{className:`omni-inspector-container ${i?"omni-embedded":""}`,children:[i&&r&&ft?hn.createPortal(ft,r):null,t.jsxs("div",{className:"omni-main-content",children:[!i&&t.jsxs("div",{className:"omni-screenshot-panel",children:[t.jsxs("div",{className:"omni-screenshot-header",children:[t.jsxs("div",{className:"omni-header-left",children:[t.jsx("span",{className:"omni-screenshot-title",children:"Device Preview"}),t.jsxs("div",{className:"omni-mode-toggle",children:[t.jsxs("button",{className:`omni-mode-btn ${p==="inspect"?"active":""}`,onClick:()=>Q("inspect"),title:"Inspection Mode (Highlight Elements)",children:[t.jsx(Fs,{size:12}),t.jsx("span",{children:"Inspect"})]}),t.jsxs("button",{className:`omni-mode-btn ${p==="interact"?"active":""}`,onClick:()=>Q("interact"),title:"Interaction Mode (Direct Control)",children:[t.jsx(Bs,{size:12}),t.jsx("span",{children:"Interact"})]})]})]}),t.jsxs("button",{className:"omni-refresh-btn",onClick:Ie,disabled:c,children:[t.jsx(yt,{size:12,className:c?"animate-spin":""}),c?"Capturing...":"Refresh"]})]}),t.jsxs("div",{className:"omni-screenshot-container",ref:se,children:[c&&!_e&&t.jsxs("div",{className:"omni-loading-overlay",children:[t.jsx("div",{className:"omni-spinner"}),t.jsx("span",{children:"Capturing screen..."})]}),!o&&!c&&!_e&&t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ls,{size:40}),t.jsx("span",{children:"Click Refresh to capture"})]}),_e&&t.jsxs("div",{className:`omni-screenshot-wrapper ${p==="interact"?"interactable":""}`,onMouseDown:dt,onMouseUp:Be,children:[t.jsx("img",{ref:Ge,src:n,onLoad:fe,onError:he,className:"omni-screenshot-img",style:p==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),ft]}),!_e&&(o==null?void 0:o.screenshot)&&t.jsxs("div",{className:`omni-screenshot-wrapper ${p==="interact"?"interactable":""}`,onMouseDown:dt,onMouseUp:Be,children:[t.jsx("img",{ref:Ae,src:`data:image/png;base64,${o.screenshot}`,onLoad:lt,className:"omni-screenshot-img",style:p==="interact"?{pointerEvents:"none"}:{},draggable:!1}),p==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[He(o.hierarchy),mt(),Qe(v,"hover"),Qe(g,"select")]})]})]})]}),t.jsxs("div",{className:"omni-tree-panel",children:[t.jsxs("div",{className:"omni-tree-header",children:[t.jsxs("div",{className:"omni-tree-title",children:[t.jsx(pi,{size:14}),t.jsx("span",{children:"Source"}),ht>0&&t.jsxs("span",{className:"omni-count-badge",children:[ht," elements"]}),(o==null?void 0:o.hierarchySource)&&t.jsx("span",{className:`omni-source-badge ${o.hierarchySource==="appium-session"?"is-session":"is-device"}`,title:o.hierarchySource==="appium-session"?`From Appium session ${o.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:o.hierarchySource==="appium-session"?"Session":"Device"})]}),t.jsxs("div",{className:"omni-tree-actions",children:[t.jsx("button",{onClick:St,className:"omni-action-btn",title:"Expand All",children:t.jsx(Zi,{size:12})}),t.jsx("button",{onClick:Re,className:"omni-action-btn",title:"Collapse All",children:t.jsx(hr,{size:12})}),i&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Q(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-pressed":p==="inspect",children:p==="inspect"?t.jsx(Fs,{size:12}):t.jsx(Bs,{size:12})}),t.jsx("button",{onClick:Ie,className:"omni-action-btn",title:c?"Capturing…":"Refresh snapshot",disabled:c,children:t.jsx(yt,{size:12,className:c?"animate-spin":""})})]})]})]}),m&&!c&&t.jsxs("div",{className:"omni-tree-error",role:"alert",children:[t.jsx(et,{size:12}),t.jsx("span",{children:m}),t.jsx("button",{type:"button",onClick:Ie,className:"omni-tree-error-retry",children:"Retry"})]}),t.jsxs("div",{className:"omni-tree-search",children:[t.jsx(si,{size:14}),t.jsx("input",{type:"text",placeholder:"Search elements... (try 'login button' or 'text field')",value:C,onChange:h=>N(h.target.value),"aria-label":"Search elements"}),C&&t.jsx("button",{onClick:()=>N(""),className:"omni-clear-btn",children:"×"})]}),C&&t.jsxs("div",{className:"omni-search-hint",children:[t.jsx(ys,{size:10}),' Smart search active — try "button", "input", "image"']}),t.jsx("div",{className:"omni-tree-content",children:o!=null&&o.hierarchy?At(o.hierarchy):t.jsx("div",{className:"omni-empty-state small",children:t.jsx("span",{children:"No hierarchy loaded"})})})]}),t.jsxs("div",{className:"omni-details-panel",children:[t.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[t.jsxs("button",{className:`omni-details-tab ${R==="info"?"active":""}`,onClick:()=>I("info"),role:"tab","aria-selected":R==="info",children:[t.jsx(rr,{size:12})," ",t.jsx("span",{children:"Info"})]}),t.jsxs("button",{className:`omni-details-tab ${R==="insight"?"active":""}`,onClick:()=>I("insight"),disabled:!g,title:"AI Element Analysis",role:"tab","aria-selected":R==="insight",children:[t.jsx(tr,{size:12})," ",t.jsx("span",{children:"AI Insight"})]}),t.jsxs("button",{className:`omni-details-tab ${R==="code"?"active":""}`,onClick:()=>I("code"),disabled:!g,title:"Generate Test Code",role:"tab","aria-selected":R==="code",children:[t.jsx(Us,{size:12})," ",t.jsx("span",{children:"Code Gen"})]})]}),t.jsx("div",{className:"omni-details-content",children:g?t.jsxs(t.Fragment,{children:[R==="info"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Element Info"}),t.jsxs("div",{className:"omni-info-table",children:[t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Type"}),t.jsx("span",{className:"omni-info-value mono",children:g.type})]}),g.text&&t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Text"}),t.jsx("span",{className:"omni-info-value",children:g.text})]}),t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Path"}),t.jsx("span",{className:"omni-info-value mono small",children:kt(g).join(" › ")})]})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Layout"}),t.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>t.jsxs("div",{className:"omni-layout-item",children:[t.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),t.jsx("span",{className:"omni-layout-value",children:g.rect[h]})]},h))})]}),t.jsxs("div",{className:"omni-section",children:[t.jsxs("div",{className:"omni-section-header",children:["Locators",t.jsx("span",{className:"omni-section-badge",children:"Stability Scored"})]}),t.jsxs("div",{className:"omni-locators-list",children:[!((pt=g.suggestedLocators)!=null&&pt.length)&&t.jsx("div",{className:"omni-locators-empty",children:g===(o==null?void 0:o.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."}),(Dt=g.suggestedLocators)==null?void 0:Dt.map(h=>{const A=sn(h.strategy,h.value),L=ns[A.level],y=ie[h.strategy];let S=null;return y&&(y.kind==="unsupported"?S=t.jsxs("span",{className:"omni-match-badge unsupported",title:y.reason||"Cannot evaluate without a real driver",children:[t.jsx(Fi,{size:10})," preview unavailable"]}):y.nodes.length===0?S=t.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[t.jsx(et,{size:10})," 0 matches"]}):y.nodes.length===1?S=t.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[t.jsx(Ot,{size:10})," unique"]}):S=t.jsxs("span",{className:"omni-match-badge multi",title:`${y.nodes.length} elements match — selector is not unique`,children:[t.jsx(tt,{size:10})," ",y.nodes.length," matches"]})),t.jsxs("div",{className:`omni-locator-row ${(T==null?void 0:T.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>_(h),title:"Click to use in Code Generator",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsxs("div",{className:"omni-locator-top",children:[t.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),t.jsxs("span",{className:`omni-stability-badge ${L.cls}`,title:A.reason,children:[L.icon,A.level]}),S]}),t.jsx("code",{className:"omni-locator-value",children:h.value}),t.jsx("span",{className:"omni-stability-reason",children:A.reason}),(()=>{const E=ye[h.strategy];return E?E.error?t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(et,{size:10})," Appium error: ",E.error]}):E.found?E.count>1?t.jsxs("span",{className:"omni-verify-line is-warn",children:[t.jsx(tt,{size:10})," Ambiguous — Appium found"," ",E.count," elements",E.actionError?` · ${E.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-ok",children:[t.jsx(Ot,{size:10})," Appium found 1 element",E.elapsedMs!=null?` in ${E.elapsedMs}ms`:"",E.actionPerformed&&E.actionPerformed!=="none"?` · ${E.actionPerformed} ok`:"",E.actionError?` · action failed: ${E.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(et,{size:10})," Appium found 0 elements"]}):null})()]}),t.jsxs("div",{className:"omni-locator-actions",children:[t.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),Ye(h.strategy,h.value)},className:`omni-test-btn ${Z===h.strategy?"active":""}`,title:"Test this locator against the current snapshot",children:t.jsx(Xi,{size:12})}),t.jsx("button",{type:"button",disabled:!(Y!=null&&Y.sessionId)||ve===h.strategy,onClick:E=>{E.stopPropagation(),Ue(h.strategy,h.value,"none")},className:"omni-test-btn",title:Y!=null&&Y.sessionId?"Verify with Appium — does the driver actually find this?":"Needs an active Appium session on this device",children:ve===h.strategy?t.jsx(yt,{size:12,className:"animate-spin"}):t.jsx(Ot,{size:12})}),t.jsx("button",{type:"button",disabled:!(Y!=null&&Y.sessionId)||ve===h.strategy,onClick:E=>{E.stopPropagation(),Ue(h.strategy,h.value,"tap")},className:"omni-test-btn",title:Y!=null&&Y.sessionId?"Find with Appium and tap the element it returns":"Needs an active Appium session on this device",children:t.jsx(xs,{size:12})}),t.jsx("button",{onClick:E=>{E.stopPropagation(),pe(h.value,h.strategy)},className:`omni-copy-btn ${j===h.strategy?"copied":""}`,children:j===h.strategy?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]},h.strategy)})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Attributes"}),t.jsx("div",{className:"omni-attributes-table",children:Object.entries(g.attributes||{}).filter(([h,A])=>A!=null&&A!=="").map(([h,A])=>t.jsxs("div",{className:"omni-attr-row",children:[t.jsx("span",{className:"omni-attr-key",children:h}),t.jsx("span",{className:"omni-attr-value",children:String(A)})]},h))})]})]}),R==="insight"&&ce&&t.jsxs("div",{className:"omni-insight-panel",children:[t.jsxs("div",{className:"omni-insight-role",children:[t.jsx("span",{className:"omni-insight-emoji",children:ce.emoji}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-insight-role-name",children:ce.role}),t.jsx("div",{className:"omni-insight-interactable",children:ce.interactable?t.jsxs("span",{className:"omni-badge-green",children:[t.jsx(xs,{size:10})," Interactable"]}):t.jsx("span",{className:"omni-badge-gray",children:"Visual Only"})})]})]}),ce.warning&&t.jsx("div",{className:"omni-insight-warning",children:ce.warning}),t.jsxs("div",{className:"omni-insight-description",children:[t.jsx(ys,{size:12,className:"omni-insight-icon"}),t.jsx("p",{children:ce.description})]}),ce.bestLocator&&t.jsxs("div",{className:"omni-insight-best-locator",children:[t.jsx("div",{className:"omni-section-header",children:"Recommended Locator"}),t.jsxs("div",{className:"omni-locator-row",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsx("span",{className:"omni-locator-strategy",children:ce.bestLocator.strategy}),t.jsx("code",{className:"omni-locator-value",children:ce.bestLocator.value})]}),t.jsx("button",{onClick:()=>pe(ce.bestLocator.value,"best"),className:`omni-copy-btn ${j==="best"?"copied":""}`,children:j==="best"?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]}),t.jsxs("div",{className:"omni-insight-attributes",children:[t.jsx("div",{className:"omni-section-header",children:"Quick Facts"}),t.jsx("div",{className:"omni-quick-facts",children:[{label:"Clickable",value:(Tt=g.attributes)==null?void 0:Tt.clickable},{label:"Enabled",value:(Mt=g.attributes)==null?void 0:Mt.enabled},{label:"Scrollable",value:(gt=g.attributes)==null?void 0:gt.scrollable},{label:"Focusable",value:(Lt=g.attributes)==null?void 0:Lt.focusable},{label:"Children",value:((It=g.children)==null?void 0:It.length)||0}].map(({label:h,value:A})=>t.jsxs("div",{className:"omni-quick-fact-row",children:[t.jsx("span",{className:"omni-quick-fact-label",children:h}),t.jsx("span",{className:`omni-quick-fact-value ${A==="true"||A===!0?"true":""}`,children:String(A??"—")})]},h))})]})]}),R==="code"&&t.jsxs("div",{className:"omni-codegen-panel",children:[t.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>t.jsx("button",{className:`omni-fw-btn ${D===h?"active":""}`,onClick:()=>H(h),children:h==="java"?"☕ Java":h==="python"?"🐍 Python":h==="javascript"?"🟨 JS":"🔷 WD.io"},h))}),T?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-codegen-locator-selector",children:[t.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),t.jsx(Jt,{selectSize:"sm",value:T.strategy,onChange:h=>{var L;const A=(L=g.suggestedLocators)==null?void 0:L.find(y=>y.strategy===h.target.value);A&&_(A)},className:"flex-1",children:(We=g.suggestedLocators)==null?void 0:We.map(h=>t.jsxs("option",{value:h.strategy,children:[h.strategy," — ",sn(h.strategy,h.value).level]},h.strategy))})]}),t.jsxs("div",{className:"omni-codegen-output",children:[t.jsxs("div",{className:"omni-codegen-header",children:[t.jsx("span",{className:"omni-codegen-lang",children:D==="java"?"Java / TestNG":D==="python"?"Python / unittest":D==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),t.jsx("button",{className:"omni-copy-btn",onClick:()=>pe(nn(g,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",D,T),"code"),children:j==="code"?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]}),t.jsx("pre",{className:"omni-codegen-pre",children:t.jsx("code",{children:nn(g,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",D,T)})})]})]}):t.jsxs("div",{className:"omni-empty-state small",children:[t.jsx(Us,{size:24}),t.jsx("span",{children:"No locators available for this element"})]})]})]}):o!=null&&o.hierarchy?t.jsxs("div",{className:"omni-summary-panel",children:[t.jsxs("div",{className:"omni-summary-hero",children:[t.jsx(ls,{size:28}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-summary-title",children:"No element selected"}),t.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Snapshot Stats"}),t.jsxs("div",{className:"omni-summary-stats",children:[t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),t.jsx("span",{className:"omni-summary-stat__value",children:ht})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),t.jsx("span",{className:"omni-summary-stat__value",children:((Et=o.metadata)==null?void 0:Et.screenWidth)??z.width??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),t.jsx("span",{className:"omni-summary-stat__value",children:(($t=o.metadata)==null?void 0:$t.screenHeight)??z.height??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),t.jsx("span",{className:"omni-summary-stat__value",children:o.platform||"—"})]})]})]}),Rt.length>0&&t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"By Role"}),t.jsx("div",{className:"omni-summary-roles",children:Rt.slice(0,8).map(h=>t.jsxs("div",{className:"omni-summary-role",children:[t.jsx("span",{className:"omni-summary-role__emoji",children:h.emoji}),t.jsx("span",{className:"omni-summary-role__name",children:h.role}),t.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ls,{size:32}),t.jsx("span",{children:c?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})},an=5e3;function Cc(e,s=!0){const[n,i]=d.useState("unknown"),r=d.useRef("unknown");return d.useEffect(()=>{if(!e||!s){i("unknown"),r.current="unknown";return}let a=!1,c;const l=m=>{a||m===r.current||(r.current=m,i(m))},o=async()=>{if(!a){if(c&&(clearTimeout(c),c=void 0),typeof document<"u"&&document.visibilityState==="hidden"){c=setTimeout(o,an);return}try{const m=await B.getDisplayState(e);l((m==null?void 0:m.state)??"unknown")}catch{}a||(c=setTimeout(o,an))}};o();const u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,c&&clearTimeout(c),document.removeEventListener("visibilitychange",u)}},[e,s]),n}const cn=5e3,Sc=500,kc=1e4,Ac=10,Rc=50;function Ec(e,s,n){const i=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,a]=d.useState([]),[c,l]=d.useState(!1),[o,u]=d.useState(null),[m,x]=d.useState(!1),g=d.useRef(null),f=d.useRef(0),v=d.useRef(!1),w=d.useRef(void 0),b=d.useRef(()=>{}),k=d.useRef([]),C=d.useRef(void 0),N=d.useRef(0),j=d.useRef(void 0),$=d.useCallback(()=>{if(k.current.length===0)return;const H=k.current;k.current=[],a(T=>{const _=T.concat(H);return _.length>cn?_.slice(-cn):_})},[]),R=d.useCallback(()=>{C.current===void 0&&(C.current=window.setTimeout(()=>{C.current=void 0,$()},Rc))},[$]),I=d.useCallback(()=>{k.current=[],a([])},[]);d.useEffect(()=>{if(!s){l(!1),u(null),x(!1);return}v.current=!1,u(null),x(!1),f.current=0;const H=()=>{if(v.current)return;if(f.current>=Ac){x(!0);return}const _=Math.min(Sc*2**f.current,kc);f.current+=1,w.current=window.setTimeout(T,_)},T=async()=>{if(!v.current)try{const _=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if(v.current)return;if(!_.ok){H();return}const{ticket:z}=await _.json();if(v.current)return;if(!z){H();return}const G=window.location.protocol==="https:"?"wss":"ws",[V,J]=i.split("|"),F=(V?`&levels=${encodeURIComponent(V)}`:"")+(J?`&process=${encodeURIComponent(J)}`:""),U=new WebSocket(`${G}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(z)}${F}`);g.current=U,U.onopen=()=>{f.current=0,j.current!==1012&&(k.current=[],a([])),j.current=void 0,l(!0)},U.onmessage=p=>{try{const Q=JSON.parse(p.data);k.current.push({...Q,seq:N.current++}),R()}catch{}},U.onclose=p=>{if(l(!1),j.current=p.code,$(),p.code===1008){v.current=!0,u(p.reason||"access denied");return}if(p.code===1012){H();return}console.warn(`[logcat] WS closed unexpectedly (code ${p.code}) — retrying`),H()},U.onerror=()=>U.close()}catch{H()}};return b.current=()=>{v.current=!1,f.current=0,u(null),x(!1),T()},T(),()=>{var _;v.current=!0,w.current!==void 0&&window.clearTimeout(w.current),C.current!==void 0&&(window.clearTimeout(C.current),C.current=void 0),$(),(_=g.current)==null||_.close(),g.current=null}},[e,s,i,$,R]);const D=d.useCallback(()=>{b.current()},[]);return{records:r,connected:c,clear:I,deniedReason:o,exhausted:m,retry:D}}const Cs=["V","D","I","W","E","F"];function $c(e){const s=[];let n="",i=!1,r=!1;for(const a of e){if(a==='"'){i=!i,r=!0;continue}if(!i&&/\s/.test(a)){(r||n)&&s.push(n),n="",r=!1;continue}n+=a,r=!0}return(r||n)&&s.push(n),s.filter(a=>a.length>0)}function Yn(e,s={}){const n=s.caseSensitive===!0,i=c=>n?c:c.toLowerCase(),r=n?{caseSensitive:!0}:{},a=[];for(const c of $c(e)){const[l,...o]=c.split(":"),u=o.join(":");u&&l.toLowerCase()==="level"?r.minLevel=u.toUpperCase():u&&l.toLowerCase()==="tag"?r.tag=i(u):u&&l.toLowerCase()==="package"?r.pkg=i(u):a.push(c)}return a.length&&(r.text=i(a.join(" "))),r}function Dc(e,s){if(e.synthetic)return!0;if(s.minLevel){const i=Cs.indexOf(s.minLevel),r=Cs.indexOf(e.level);if(i>=0&&r>=0&&r<i)return!1}const n=i=>s.caseSensitive?i:i.toLowerCase();return!(s.tag&&!n(e.tag).includes(s.tag)||s.pkg&&!n(e.pkg??"").includes(s.pkg)||s.text&&!n(e.message).includes(s.text))}function Tc(e,s){const n=e.trim().split(/\s+/).filter(Boolean).filter(i=>{const[r,...a]=i.split(":");return!(a.join(":")&&r.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const gs=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],ln=["V","D","I","W","E","F"];function Mc(e){if(!e)return gs.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=ln.indexOf(e.toUpperCase());return s<0?gs.map(n=>n.ios):gs.filter(n=>ln.indexOf(n.android)>=s).map(n=>n.ios)}function Lc(e){const s=Yn(e,{caseSensitive:!0});return{levels:Mc(s.minLevel),process:s.pkg||void 0}}const dn=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Ic(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function _c(e){return e?dn[Ic(e)%dn.length]:"var(--text-muted)"}const Ss=5e5;function Zn(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function Oc(e){return{lines:[],startedAt:e,dropped:0}}function Pc(e,s){for(const n of s){if(e.lines.length>=Ss){e.dropped+=1;continue}e.lines.push(Zn(n))}return e}function zc(e,s,n){const i=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&i.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${Ss}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
247
+ // Assert with expect(element).toBeDisplayed()`:`// Strategy "${r}" not supported in WebdriverIO mobile`}function rn(e){var f,b,w,v,k,C,N,j,D,R,I;const s=(e.type||"").toLowerCase(),n=((f=e.attributes)==null?void 0:f.clickable)==="true"||((b=e.attributes)==null?void 0:b.clickable)===!0,i=((w=e.attributes)==null?void 0:w.enabled)!=="false"&&((v=e.attributes)==null?void 0:v.enabled)!==!1,r=((k=e.attributes)==null?void 0:k.scrollable)==="true"||((C=e.attributes)==null?void 0:C.scrollable)===!0,a=e.text||e.label||e.value||"",c=((N=e.children)==null?void 0:N.length)||0;let l="Element",o="📦";s.includes("button")||s.includes("btn")||n&&c===0?(l="Button",o="🔘"):s.includes("edit")||s.includes("input")||s.includes("field")?(l="Text Input",o="✏️"):s.includes("image")||s.includes("img")||s.includes("imageview")?(l="Image",o="🖼️"):s.includes("scroll")||s.includes("recyclerview")||s.includes("listview")||r?(l="Scrollable List",o="📜"):s.includes("text")||s.includes("label")?(l="Text Label",o="📝"):s.includes("switch")||s.includes("toggle")||s.includes("checkbox")?(l="Toggle / Checkbox",o="☑️"):s.includes("nav")||s.includes("toolbar")||s.includes("tabbar")?(l="Navigation Bar",o="🧭"):c>0&&(l=`Container (${c} children)`,o="🗂️");const u=((j=e.suggestedLocators)==null?void 0:j.find($=>$.strategy==="accessibility id"||$.strategy==="id"))||((D=e.suggestedLocators)==null?void 0:D[0]),m=i?((R=e.rect)==null?void 0:R.width)===0||((I=e.rect)==null?void 0:I.height)===0?"⚠️ Zero-size element — may not be interactable":void 0:"⚠️ Element is disabled",x=a?` with text "${a.slice(0,30)}"`:"",g=`This is a ${l.toLowerCase()}${x}. ${n?"It can be tapped/clicked.":r?"It supports scrolling.":"It is a visual container."}${c>0?` Contains ${c} child element${c>1?"s":""}.`:""}`;return{role:l,description:g,interactable:n||i,bestLocator:u,warning:m,emoji:o}}function on(e,s){if(!s)return!0;const n=s.toLowerCase().trim(),i={button:["button","btn","clickable","tapable"],input:["edittext","input","field","textfield","textinput","edit"],image:["image","imageview","img","picture","photo","icon"],text:["textview","label","text","statictext"],list:["listview","recyclerview","scrollview","tableview","collectionview","scroll"],toggle:["switch","checkbox","toggle","radiobutton"],nav:["toolbar","navigationbar","tabbar","actionbar","navbar"]},r=(e.type||"").toLowerCase(),a=(e.text||e.label||e.value||"").toLowerCase(),c=(e.name||"").toLowerCase(),l=Object.values(e.attributes||{}).join(" ").toLowerCase();for(const[o,u]of Object.entries(i))if(n.includes(o)&&u.some(m=>r.includes(m)))return!0;return r.includes(n)||a.includes(n)||c.includes(n)||l.includes(n)}const Nc=({sessionId:e,udid:s,streamUrl:n,embedded:i=!1,overlayTarget:r=null,onModeChange:a})=>{var Et,$t,pt,Dt,Tt,Mt,gt,Lt,It,We;const[c,l]=d.useState(!0),[o,u]=d.useState(null),[m,x]=d.useState(null),[g,f]=d.useState(null),[b,w]=d.useState(null),[v,k]=d.useState(new Set(["/"])),[C,N]=d.useState(""),[j,D]=d.useState(null),[R,I]=d.useState("info"),[$,H]=d.useState("java"),[T,O]=d.useState(null),[z,G]=d.useState({width:0,height:0}),[V,J]=d.useState({width:0,height:0}),[F,U]=d.useState(!1),[p,Q]=d.useState("inspect");d.useEffect(()=>{a==null||a(p)},[p,a]);const[ie,oe]=d.useState({}),[ye,ue]=d.useState({}),[ve,ke]=d.useState(null),[Y,P]=d.useState(null),[Z,ne]=d.useState(null),se=d.useRef(null),Ae=d.useRef(null),Ge=d.useRef(null),ae=d.useRef(null),be=d.useCallback(()=>{var ee,X,K;if(!se.current)return;const h=se.current.getBoundingClientRect(),A=h.width,L=h.height,y=(ee=o==null?void 0:o.hierarchy)==null?void 0:ee.rect;let S=((X=o==null?void 0:o.metadata)==null?void 0:X.screenWidth)||z.width||1,E=((K=o==null?void 0:o.metadata)==null?void 0:K.screenHeight)||z.height||1;y&&y.width>0&&y.height>0&&(S=y.width,E=y.height);const M=S/E;let q,_;A/L>M?(_=L,q=_*M):(q=A,_=q/M),J({width:q,height:_})},[o,z]);d.useEffect(()=>(be(),window.addEventListener("resize",be),()=>window.removeEventListener("resize",be)),[be]),d.useEffect(()=>{s&&Ie()},[s]),d.useEffect(()=>{if(!s)return;let h=!1;return B.getAppiumSession(s).then(A=>{h||P({sessionId:(A==null?void 0:A.sessionId)??null,basePath:(A==null?void 0:A.basePath)??""})}).catch(()=>{h||P({sessionId:null,basePath:""})}),()=>{h=!0}},[s]);const Ue=d.useCallback(async(h,A,L)=>{if(Y!=null&&Y.sessionId){ke(h);try{const y=await B.verifyLocator(Y.basePath,Y.sessionId,{strategy:h,selector:A,action:L});ue(S=>({...S,[h]:y}))}catch(y){ue(S=>({...S,[h]:{found:!1,count:0,error:(y==null?void 0:y.message)||String(y)}}))}finally{ke(null)}}},[Y]);d.useEffect(()=>{var h;if((h=g==null?void 0:g.suggestedLocators)!=null&&h.length){const A=g.suggestedLocators.find(L=>L.strategy==="accessibility id"||L.strategy==="id")||g.suggestedLocators[0];O(A)}else O(null);oe({}),ue({}),ne(null)},[g]);const Ye=d.useCallback((h,A)=>{if(!(o!=null&&o.hierarchy))return;const L=jc(o.hierarchy,h,A);oe(y=>({...y,[h]:L})),ne(h)},[o]),Ie=async()=>{if(s){l(!0),x(null);try{const h=await B.getInspectorSnapshot(s);if(!(h!=null&&h.hierarchy)){u(null),x((h==null?void 0:h.error)||"Failed to capture snapshot");return}u(h);const A=new Set(["/"]),L=(y,S)=>{var E;S<3&&(A.add(y.xpath),(E=y.children)==null||E.forEach(M=>L(M,S+1)))};L(h.hierarchy,0),k(A)}catch(h){u(null),x(h.message||"Failed to capture snapshot")}finally{l(!1)}}},lt=h=>{const{naturalWidth:A,naturalHeight:L}=h.currentTarget;G({width:A,height:L})},he=()=>U(!0),fe=h=>{U(!1);const{naturalWidth:A,naturalHeight:L}=h.currentTarget;A>0&&L>0&&G({width:A,height:L})},_e=n&&!F,dt=h=>{if(p!=="interact"||!s)return;const A=h.currentTarget.getBoundingClientRect();ae.current={x:h.clientX-A.left,y:h.clientY-A.top,time:Date.now()}},Be=async h=>{var me,Oe,Ve;if(p!=="interact"||!s||!ae.current)return;const A=ae.current,L=h.currentTarget.getBoundingClientRect(),y=h.clientX-L.left,S=h.clientY-L.top,E=Date.now()-A.time,M=V.width,q=V.height,_=(me=o==null?void 0:o.hierarchy)==null?void 0:me.rect;let ee=((Oe=o==null?void 0:o.metadata)==null?void 0:Oe.screenWidth)||z.width,X=((Ve=o==null?void 0:o.metadata)==null?void 0:Ve.screenHeight)||z.height;if(_&&_.width>0&&_.height>0&&(ee=_.width,X=_.height),!ee||!X||M===0||q===0)return;const K=(_t,_s)=>({x:Math.round(_t/M*ee),y:Math.round(_s/q*X),px:_t/M,py:_s/q}),te=K(A.x,A.y),we=K(y,S),Ee=Math.sqrt(Math.pow(y-A.x,2)+Math.pow(S-A.y,2));if(!(te.px<0||te.px>1||te.py<0||te.py>1)){try{E<500&&Ee<10?await B.tap(s,te.x,te.y):E>=500&&Ee<10?await B.touchAndHold(s,te.x,te.y,E):Ee>=10&&await B.swipe(s,te.x,te.y,we.x,we.y)}catch(_t){console.error("Interaction failed:",_t)}ae.current=null}},Ct=h=>{const A=new Set(v);A.has(h)?A.delete(h):A.add(h),k(A)},St=()=>{const h=new Set,A=L=>{var y;h.add(L.xpath),(y=L.children)==null||y.forEach(A)};o!=null&&o.hierarchy&&A(o.hierarchy),k(h)},Re=()=>k(new Set(["/"])),pe=(h,A)=>{navigator.clipboard.writeText(h),D(A),setTimeout(()=>D(null),2e3)},Ze=h=>{var L;let A=1;return(L=h.children)==null||L.forEach(y=>A+=Ze(y)),A},Je=h=>{if(!h)return[];const A={},L=y=>{var M;const S=rn(y),E=S.role.replace(/\s*\(.*?\)\s*/,"");A[E]||(A[E]={emoji:S.emoji,count:0}),A[E].count+=1,(M=y.children)==null||M.forEach(L)};return L(h),Object.entries(A).map(([y,S])=>({role:y,emoji:S.emoji,count:S.count})).sort((y,S)=>S.count-y.count)},kt=h=>h.xpath.split("/").filter(Boolean).slice(-3),At=(h,A=0)=>{var K,te,we,Ee;if(!h)return null;const L=v.has(h.xpath),y=((K=h.children)==null?void 0:K.length)>0,S=(g==null?void 0:g.xpath)===h.xpath,E=(b==null?void 0:b.xpath)===h.xpath,M=((te=h.type)==null?void 0:te.split(".").pop())||"Element",q=h.label||((we=h.attributes)==null?void 0:we["content-desc"])||((Ee=h.attributes)==null?void 0:Ee["resource-id"])||h.name,_=typeof q=="string"&&q&&q!==M&&q!==h.type?q:null,ee=_||M,X=!C||on(h,C);if(!X&&!y)return null;if(C&&!X){const me=Oe=>{var Ve;return on(Oe,C)?!0:((Ve=Oe.children)==null?void 0:Ve.some(me))||!1};if(!me(h))return null}return t.jsxs("div",{className:"tree-node",children:[t.jsxs("div",{className:`tree-item ${S?"selected":""} ${E&&!S?"hovered":""}`,onClick:()=>{f(h),I("info")},onMouseEnter:()=>w(h),onMouseLeave:()=>w(null),children:[t.jsx("div",{className:"tree-item-indent",style:{width:`${A*14}px`}}),y?t.jsx("button",{onClick:me=>{me.stopPropagation(),Ct(h.xpath)},className:"tree-toggle",children:L?t.jsx(pn,{size:11}):t.jsx(wn,{size:11})}):t.jsx("span",{className:"tree-toggle-spacer"}),t.jsx(Di,{size:11,className:"tree-icon"}),t.jsx("span",{className:"tree-label",title:`${M}${_?` — ${_}`:""}`,children:ee}),_&&t.jsx("span",{className:"tree-type-tag",title:M,children:M}),h.text&&t.jsxs("span",{className:"tree-text-preview",children:['"',h.text.slice(0,20),'"']}),y&&t.jsx("span",{className:"tree-badge",children:h.children.length})]}),L&&y&&t.jsx("div",{className:"tree-children",children:h.children.map(me=>At(me,A+1))})]},h.xpath)},ut=()=>{var y,S,E;const h=(y=o==null?void 0:o.hierarchy)==null?void 0:y.rect;if(h&&h.width>0&&h.height>0)return{w:h.width,h:h.height};const A=((S=o==null?void 0:o.metadata)==null?void 0:S.screenWidth)||z.width,L=((E=o==null?void 0:o.metadata)==null?void 0:E.screenHeight)||z.height;return A>0&&L>0?{w:A,h:L}:null},He=h=>{const A=ut();if(!A)return[];const L=[],{w:y,h:S}=A,E=(M,q)=>{var ee,X,K;const _=!M.children||M.children.length===0;((ee=M.rect)==null?void 0:ee.width)>0&&((X=M.rect)==null?void 0:X.height)>0&&_&&L.push(t.jsx("div",{className:"omni-hit-area",style:{left:`${M.rect.x/y*100}%`,top:`${M.rect.y/S*100}%`,width:`${M.rect.width/y*100}%`,height:`${M.rect.height/S*100}%`,zIndex:q},onClick:te=>{te.stopPropagation(),f(M),I("info")},onMouseEnter:()=>w(M),onMouseLeave:()=>w(null)},M.xpath)),(K=M.children)==null||K.forEach(te=>E(te,q+1))};return o!=null&&o.hierarchy&&E(o.hierarchy,1),L},mt=()=>{var E,M,q;if(!Z||!z.width)return[];const h=ie[Z];if(!h||h.kind!=="matched"||h.nodes.length===0)return[];const A=(E=o==null?void 0:o.hierarchy)==null?void 0:E.rect;let L=((M=o==null?void 0:o.metadata)==null?void 0:M.screenWidth)||z.width,y=((q=o==null?void 0:o.metadata)==null?void 0:q.screenHeight)||z.height;A&&A.width>0&&A.height>0&&(L=A.width,y=A.height);const S=h.nodes.length===1?"omni-frame-match unique":"omni-frame-match multi";return h.nodes.filter(_=>_.rect&&_.rect.width>0&&_.rect.height>0).map((_,ee)=>t.jsx("div",{className:S,style:{left:`${_.rect.x/L*100}%`,top:`${_.rect.y/y*100}%`,width:`${_.rect.width/L*100}%`,height:`${_.rect.height/y*100}%`}},`match-${Z}-${ee}`))},Qe=(h,A)=>{const L=ut();if(!(h!=null&&h.rect)||!L)return null;const{w:y,h:S}=L;return t.jsx("div",{className:`omni-frame-${A}`,style:{left:`${h.rect.x/y*100}%`,top:`${h.rect.y/S*100}%`,width:`${h.rect.width/y*100}%`,height:`${h.rect.height/S*100}%`}})},ht=o!=null&&o.hierarchy?Ze(o.hierarchy):0,ce=g?rn(g):null,ft=o!=null&&o.hierarchy&&p==="inspect"?t.jsxs("div",{className:"omni-overlay",children:[He(o.hierarchy),mt(),Qe(b,"hover"),Qe(g,"select")]}):null,ns={stable:{icon:t.jsx(Ot,{size:10}),cls:"stable"},moderate:{icon:t.jsx(tt,{size:10}),cls:"moderate"},fragile:{icon:t.jsx(et,{size:10}),cls:"fragile"},"very-fragile":{icon:t.jsx(et,{size:10}),cls:"very-fragile"}},Rt=i&&(o!=null&&o.hierarchy)?Je(o.hierarchy):[];return t.jsxs("div",{className:`omni-inspector-container ${i?"omni-embedded":""}`,children:[i&&r&&ft?hn.createPortal(ft,r):null,t.jsxs("div",{className:"omni-main-content",children:[!i&&t.jsxs("div",{className:"omni-screenshot-panel",children:[t.jsxs("div",{className:"omni-screenshot-header",children:[t.jsxs("div",{className:"omni-header-left",children:[t.jsx("span",{className:"omni-screenshot-title",children:"Device Preview"}),t.jsxs("div",{className:"omni-mode-toggle",children:[t.jsxs("button",{className:`omni-mode-btn ${p==="inspect"?"active":""}`,onClick:()=>Q("inspect"),title:"Inspection Mode (Highlight Elements)",children:[t.jsx(Fs,{size:12}),t.jsx("span",{children:"Inspect"})]}),t.jsxs("button",{className:`omni-mode-btn ${p==="interact"?"active":""}`,onClick:()=>Q("interact"),title:"Interaction Mode (Direct Control)",children:[t.jsx(Bs,{size:12}),t.jsx("span",{children:"Interact"})]})]})]}),t.jsxs("button",{className:"omni-refresh-btn",onClick:Ie,disabled:c,children:[t.jsx(yt,{size:12,className:c?"animate-spin":""}),c?"Capturing...":"Refresh"]})]}),t.jsxs("div",{className:"omni-screenshot-container",ref:se,children:[c&&!_e&&t.jsxs("div",{className:"omni-loading-overlay",children:[t.jsx("div",{className:"omni-spinner"}),t.jsx("span",{children:"Capturing screen..."})]}),!o&&!c&&!_e&&t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ls,{size:40}),t.jsx("span",{children:"Click Refresh to capture"})]}),_e&&t.jsxs("div",{className:`omni-screenshot-wrapper ${p==="interact"?"interactable":""}`,onMouseDown:dt,onMouseUp:Be,children:[t.jsx("img",{ref:Ge,src:n,onLoad:fe,onError:he,className:"omni-screenshot-img",style:p==="interact"?{pointerEvents:"none"}:{},draggable:!1,alt:"Live Device Stream"}),ft]}),!_e&&(o==null?void 0:o.screenshot)&&t.jsxs("div",{className:`omni-screenshot-wrapper ${p==="interact"?"interactable":""}`,onMouseDown:dt,onMouseUp:Be,children:[t.jsx("img",{ref:Ae,src:`data:image/png;base64,${o.screenshot}`,onLoad:lt,className:"omni-screenshot-img",style:p==="interact"?{pointerEvents:"none"}:{},draggable:!1}),p==="inspect"&&t.jsxs("div",{className:"omni-overlay",children:[He(o.hierarchy),mt(),Qe(b,"hover"),Qe(g,"select")]})]})]})]}),t.jsxs("div",{className:"omni-tree-panel",children:[t.jsxs("div",{className:"omni-tree-header",children:[t.jsxs("div",{className:"omni-tree-title",children:[t.jsx(pi,{size:14}),t.jsx("span",{children:"Source"}),ht>0&&t.jsxs("span",{className:"omni-count-badge",children:[ht," elements"]}),(o==null?void 0:o.hierarchySource)&&t.jsx("span",{className:`omni-source-badge ${o.hierarchySource==="appium-session"?"is-session":"is-device"}`,title:o.hierarchySource==="appium-session"?`From Appium session ${o.sessionId} — the same tree the driver resolves locators against`:"Read from the device. No Appium session is driving it.",children:o.hierarchySource==="appium-session"?"Session":"Device"})]}),t.jsxs("div",{className:"omni-tree-actions",children:[t.jsx("button",{onClick:St,className:"omni-action-btn",title:"Expand All",children:t.jsx(Zi,{size:12})}),t.jsx("button",{onClick:Re,className:"omni-action-btn",title:"Collapse All",children:t.jsx(hr,{size:12})}),i&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>Q(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-pressed":p==="inspect",children:p==="inspect"?t.jsx(Fs,{size:12}):t.jsx(Bs,{size:12})}),t.jsx("button",{onClick:Ie,className:"omni-action-btn",title:c?"Capturing…":"Refresh snapshot",disabled:c,children:t.jsx(yt,{size:12,className:c?"animate-spin":""})})]})]})]}),m&&!c&&t.jsxs("div",{className:"omni-tree-error",role:"alert",children:[t.jsx(et,{size:12}),t.jsx("span",{children:m}),t.jsx("button",{type:"button",onClick:Ie,className:"omni-tree-error-retry",children:"Retry"})]}),t.jsxs("div",{className:"omni-tree-search",children:[t.jsx(si,{size:14}),t.jsx("input",{type:"text",placeholder:"Search elements... (try 'login button' or 'text field')",value:C,onChange:h=>N(h.target.value),"aria-label":"Search elements"}),C&&t.jsx("button",{onClick:()=>N(""),className:"omni-clear-btn",children:"×"})]}),C&&t.jsxs("div",{className:"omni-search-hint",children:[t.jsx(ys,{size:10}),' Smart search active — try "button", "input", "image"']}),t.jsx("div",{className:"omni-tree-content",children:o!=null&&o.hierarchy?At(o.hierarchy):t.jsx("div",{className:"omni-empty-state small",children:t.jsx("span",{children:"No hierarchy loaded"})})})]}),t.jsxs("div",{className:"omni-details-panel",children:[t.jsxs("div",{className:"omni-details-tabs",role:"tablist",children:[t.jsxs("button",{className:`omni-details-tab ${R==="info"?"active":""}`,onClick:()=>I("info"),role:"tab","aria-selected":R==="info",children:[t.jsx(rr,{size:12})," ",t.jsx("span",{children:"Info"})]}),t.jsxs("button",{className:`omni-details-tab ${R==="insight"?"active":""}`,onClick:()=>I("insight"),disabled:!g,title:"AI Element Analysis",role:"tab","aria-selected":R==="insight",children:[t.jsx(tr,{size:12})," ",t.jsx("span",{children:"AI Insight"})]}),t.jsxs("button",{className:`omni-details-tab ${R==="code"?"active":""}`,onClick:()=>I("code"),disabled:!g,title:"Generate Test Code",role:"tab","aria-selected":R==="code",children:[t.jsx(Us,{size:12})," ",t.jsx("span",{children:"Code Gen"})]})]}),t.jsx("div",{className:"omni-details-content",children:g?t.jsxs(t.Fragment,{children:[R==="info"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Element Info"}),t.jsxs("div",{className:"omni-info-table",children:[t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Type"}),t.jsx("span",{className:"omni-info-value mono",children:g.type})]}),g.text&&t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Text"}),t.jsx("span",{className:"omni-info-value",children:g.text})]}),t.jsxs("div",{className:"omni-info-row",children:[t.jsx("span",{className:"omni-info-key",children:"Path"}),t.jsx("span",{className:"omni-info-value mono small",children:kt(g).join(" › ")})]})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Layout"}),t.jsx("div",{className:"omni-layout-grid",children:["x","y","width","height"].map(h=>t.jsxs("div",{className:"omni-layout-item",children:[t.jsx("span",{className:"omni-layout-label",children:h.toUpperCase()}),t.jsx("span",{className:"omni-layout-value",children:g.rect[h]})]},h))})]}),t.jsxs("div",{className:"omni-section",children:[t.jsxs("div",{className:"omni-section-header",children:["Locators",t.jsx("span",{className:"omni-section-badge",children:"Stability Scored"})]}),t.jsxs("div",{className:"omni-locators-list",children:[!((pt=g.suggestedLocators)!=null&&pt.length)&&t.jsx("div",{className:"omni-locators-empty",children:g===(o==null?void 0:o.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."}),(Dt=g.suggestedLocators)==null?void 0:Dt.map(h=>{const A=sn(h.strategy,h.value),L=ns[A.level],y=ie[h.strategy];let S=null;return y&&(y.kind==="unsupported"?S=t.jsxs("span",{className:"omni-match-badge unsupported",title:y.reason||"Cannot evaluate without a real driver",children:[t.jsx(Fi,{size:10})," preview unavailable"]}):y.nodes.length===0?S=t.jsxs("span",{className:"omni-match-badge zero",title:"No element matches this selector in the current snapshot",children:[t.jsx(et,{size:10})," 0 matches"]}):y.nodes.length===1?S=t.jsxs("span",{className:"omni-match-badge unique",title:"Selector is unique in the current snapshot",children:[t.jsx(Ot,{size:10})," unique"]}):S=t.jsxs("span",{className:"omni-match-badge multi",title:`${y.nodes.length} elements match — selector is not unique`,children:[t.jsx(tt,{size:10})," ",y.nodes.length," matches"]})),t.jsxs("div",{className:`omni-locator-row ${(T==null?void 0:T.strategy)===h.strategy?"selected-for-code":""}`,onClick:()=>O(h),title:"Click to use in Code Generator",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsxs("div",{className:"omni-locator-top",children:[t.jsx("span",{className:"omni-locator-strategy",children:h.strategy}),t.jsxs("span",{className:`omni-stability-badge ${L.cls}`,title:A.reason,children:[L.icon,A.level]}),S]}),t.jsx("code",{className:"omni-locator-value",children:h.value}),t.jsx("span",{className:"omni-stability-reason",children:A.reason}),(()=>{const E=ye[h.strategy];return E?E.error?t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(et,{size:10})," Appium error: ",E.error]}):E.found?E.count>1?t.jsxs("span",{className:"omni-verify-line is-warn",children:[t.jsx(tt,{size:10})," Ambiguous — Appium found"," ",E.count," elements",E.actionError?` · ${E.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-ok",children:[t.jsx(Ot,{size:10})," Appium found 1 element",E.elapsedMs!=null?` in ${E.elapsedMs}ms`:"",E.actionPerformed&&E.actionPerformed!=="none"?` · ${E.actionPerformed} ok`:"",E.actionError?` · action failed: ${E.actionError}`:""]}):t.jsxs("span",{className:"omni-verify-line is-error",children:[t.jsx(et,{size:10})," Appium found 0 elements"]}):null})()]}),t.jsxs("div",{className:"omni-locator-actions",children:[t.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),Ye(h.strategy,h.value)},className:`omni-test-btn ${Z===h.strategy?"active":""}`,title:"Test this locator against the current snapshot",children:t.jsx(Xi,{size:12})}),t.jsx("button",{type:"button",disabled:!(Y!=null&&Y.sessionId)||ve===h.strategy,onClick:E=>{E.stopPropagation(),Ue(h.strategy,h.value,"none")},className:"omni-test-btn",title:Y!=null&&Y.sessionId?"Verify with Appium — does the driver actually find this?":"Needs an active Appium session on this device",children:ve===h.strategy?t.jsx(yt,{size:12,className:"animate-spin"}):t.jsx(Ot,{size:12})}),t.jsx("button",{type:"button",disabled:!(Y!=null&&Y.sessionId)||ve===h.strategy,onClick:E=>{E.stopPropagation(),Ue(h.strategy,h.value,"tap")},className:"omni-test-btn",title:Y!=null&&Y.sessionId?"Find with Appium and tap the element it returns":"Needs an active Appium session on this device",children:t.jsx(xs,{size:12})}),t.jsx("button",{onClick:E=>{E.stopPropagation(),pe(h.value,h.strategy)},className:`omni-copy-btn ${j===h.strategy?"copied":""}`,children:j===h.strategy?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]},h.strategy)})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Attributes"}),t.jsx("div",{className:"omni-attributes-table",children:Object.entries(g.attributes||{}).filter(([h,A])=>A!=null&&A!=="").map(([h,A])=>t.jsxs("div",{className:"omni-attr-row",children:[t.jsx("span",{className:"omni-attr-key",children:h}),t.jsx("span",{className:"omni-attr-value",children:String(A)})]},h))})]})]}),R==="insight"&&ce&&t.jsxs("div",{className:"omni-insight-panel",children:[t.jsxs("div",{className:"omni-insight-role",children:[t.jsx("span",{className:"omni-insight-emoji",children:ce.emoji}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-insight-role-name",children:ce.role}),t.jsx("div",{className:"omni-insight-interactable",children:ce.interactable?t.jsxs("span",{className:"omni-badge-green",children:[t.jsx(xs,{size:10})," Interactable"]}):t.jsx("span",{className:"omni-badge-gray",children:"Visual Only"})})]})]}),ce.warning&&t.jsx("div",{className:"omni-insight-warning",children:ce.warning}),t.jsxs("div",{className:"omni-insight-description",children:[t.jsx(ys,{size:12,className:"omni-insight-icon"}),t.jsx("p",{children:ce.description})]}),ce.bestLocator&&t.jsxs("div",{className:"omni-insight-best-locator",children:[t.jsx("div",{className:"omni-section-header",children:"Recommended Locator"}),t.jsxs("div",{className:"omni-locator-row",children:[t.jsxs("div",{className:"omni-locator-left",children:[t.jsx("span",{className:"omni-locator-strategy",children:ce.bestLocator.strategy}),t.jsx("code",{className:"omni-locator-value",children:ce.bestLocator.value})]}),t.jsx("button",{onClick:()=>pe(ce.bestLocator.value,"best"),className:`omni-copy-btn ${j==="best"?"copied":""}`,children:j==="best"?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]}),t.jsxs("div",{className:"omni-insight-attributes",children:[t.jsx("div",{className:"omni-section-header",children:"Quick Facts"}),t.jsx("div",{className:"omni-quick-facts",children:[{label:"Clickable",value:(Tt=g.attributes)==null?void 0:Tt.clickable},{label:"Enabled",value:(Mt=g.attributes)==null?void 0:Mt.enabled},{label:"Scrollable",value:(gt=g.attributes)==null?void 0:gt.scrollable},{label:"Focusable",value:(Lt=g.attributes)==null?void 0:Lt.focusable},{label:"Children",value:((It=g.children)==null?void 0:It.length)||0}].map(({label:h,value:A})=>t.jsxs("div",{className:"omni-quick-fact-row",children:[t.jsx("span",{className:"omni-quick-fact-label",children:h}),t.jsx("span",{className:`omni-quick-fact-value ${A==="true"||A===!0?"true":""}`,children:String(A??"—")})]},h))})]})]}),R==="code"&&t.jsxs("div",{className:"omni-codegen-panel",children:[t.jsx("div",{className:"omni-codegen-frameworks",children:["java","python","javascript","wdio"].map(h=>t.jsx("button",{className:`omni-fw-btn ${$===h?"active":""}`,onClick:()=>H(h),children:h==="java"?"☕ Java":h==="python"?"🐍 Python":h==="javascript"?"🟨 JS":"🔷 WD.io"},h))}),T?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"omni-codegen-locator-selector",children:[t.jsx("span",{className:"omni-codegen-label",children:"Locator:"}),t.jsx(Jt,{selectSize:"sm",value:T.strategy,onChange:h=>{var L;const A=(L=g.suggestedLocators)==null?void 0:L.find(y=>y.strategy===h.target.value);A&&O(A)},className:"flex-1",children:(We=g.suggestedLocators)==null?void 0:We.map(h=>t.jsxs("option",{value:h.strategy,children:[h.strategy," — ",sn(h.strategy,h.value).level]},h.strategy))})]}),t.jsxs("div",{className:"omni-codegen-output",children:[t.jsxs("div",{className:"omni-codegen-header",children:[t.jsx("span",{className:"omni-codegen-lang",children:$==="java"?"Java / TestNG":$==="python"?"Python / unittest":$==="javascript"?"JavaScript / Mocha":"WebdriverIO"}),t.jsx("button",{className:"omni-copy-btn",onClick:()=>pe(nn(g,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",$,T),"code"),children:j==="code"?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]}),t.jsx("pre",{className:"omni-codegen-pre",children:t.jsx("code",{children:nn(g,(o==null?void 0:o.platform)==="android"?"android":(o==null?void 0:o.platform)==="ios"?"ios":"unknown",$,T)})})]})]}):t.jsxs("div",{className:"omni-empty-state small",children:[t.jsx(Us,{size:24}),t.jsx("span",{children:"No locators available for this element"})]})]})]}):o!=null&&o.hierarchy?t.jsxs("div",{className:"omni-summary-panel",children:[t.jsxs("div",{className:"omni-summary-hero",children:[t.jsx(ls,{size:28}),t.jsxs("div",{children:[t.jsx("div",{className:"omni-summary-title",children:"No element selected"}),t.jsx("div",{className:"omni-summary-subtitle",children:"Click any node in the tree (or use Inspect mode on the device) to drill in."})]})]}),t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"Snapshot Stats"}),t.jsxs("div",{className:"omni-summary-stats",children:[t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Elements"}),t.jsx("span",{className:"omni-summary-stat__value",children:ht})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Width"}),t.jsx("span",{className:"omni-summary-stat__value",children:((Et=o.metadata)==null?void 0:Et.screenWidth)??z.width??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Height"}),t.jsx("span",{className:"omni-summary-stat__value",children:(($t=o.metadata)==null?void 0:$t.screenHeight)??z.height??"—"})]}),t.jsxs("div",{className:"omni-summary-stat",children:[t.jsx("span",{className:"omni-summary-stat__label",children:"Platform"}),t.jsx("span",{className:"omni-summary-stat__value",children:o.platform||"—"})]})]})]}),Rt.length>0&&t.jsxs("div",{className:"omni-section",children:[t.jsx("div",{className:"omni-section-header",children:"By Role"}),t.jsx("div",{className:"omni-summary-roles",children:Rt.slice(0,8).map(h=>t.jsxs("div",{className:"omni-summary-role",children:[t.jsx("span",{className:"omni-summary-role__emoji",children:h.emoji}),t.jsx("span",{className:"omni-summary-role__name",children:h.role}),t.jsx("span",{className:"omni-summary-role__count",children:h.count})]},h.role))})]})]}):t.jsxs("div",{className:"omni-empty-state",children:[t.jsx(ls,{size:32}),t.jsx("span",{children:c?"Capturing snapshot…":"Select an element from the tree or screenshot"})]})})]})]})]})},an=5e3;function Cc(e,s=!0){const[n,i]=d.useState("unknown"),r=d.useRef("unknown");return d.useEffect(()=>{if(!e||!s){i("unknown"),r.current="unknown";return}let a=!1,c;const l=m=>{a||m===r.current||(r.current=m,i(m))},o=async()=>{if(!a){if(c&&(clearTimeout(c),c=void 0),typeof document<"u"&&document.visibilityState==="hidden"){c=setTimeout(o,an);return}try{const m=await B.getDisplayState(e);l((m==null?void 0:m.state)??"unknown")}catch{}a||(c=setTimeout(o,an))}};o();const u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),()=>{a=!0,c&&clearTimeout(c),document.removeEventListener("visibilitychange",u)}},[e,s]),n}const cn=5e3,Sc=500,kc=1e4,Ac=10,Rc=50;function Ec(e,s,n){const i=`${((n==null?void 0:n.levels)??[]).join(",")}|${(n==null?void 0:n.process)??""}`,[r,a]=d.useState([]),[c,l]=d.useState(!1),[o,u]=d.useState(null),[m,x]=d.useState(!1),g=d.useRef(null),f=d.useRef(0),b=d.useRef(void 0),w=d.useRef(()=>{}),v=d.useRef([]),k=d.useRef(void 0),C=d.useRef(0),N=d.useRef(void 0),j=d.useCallback(()=>{if(v.current.length===0)return;const $=v.current;v.current=[],a(H=>{const T=H.concat($);return T.length>cn?T.slice(-cn):T})},[]),D=d.useCallback(()=>{k.current===void 0&&(k.current=window.setTimeout(()=>{k.current=void 0,j()},Rc))},[j]),R=d.useCallback(()=>{v.current=[],a([])},[]);d.useEffect(()=>{if(!s){l(!1),u(null),x(!1);return}u(null),x(!1),f.current=0;const $={cancelled:!1},H=()=>{if($.cancelled)return;if(f.current>=Ac){x(!0);return}const O=Math.min(Sc*2**f.current,kc);f.current+=1,b.current=window.setTimeout(T,O)},T=async()=>{if(!$.cancelled)try{const O=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/ticket`,{method:"POST",credentials:"include"});if($.cancelled)return;if(!O.ok){H();return}const{ticket:z}=await O.json();if($.cancelled)return;if(!z){H();return}const G=window.location.protocol==="https:"?"wss":"ws",[V,J]=i.split("|"),F=(V?`&levels=${encodeURIComponent(V)}`:"")+(J?`&process=${encodeURIComponent(J)}`:""),U=new WebSocket(`${G}://${window.location.host}/xenon/api/control/${encodeURIComponent(e)}/logcat?ticket=${encodeURIComponent(z)}${F}`);g.current=U,U.onopen=()=>{f.current=0,N.current!==1012&&(v.current=[],a([])),N.current=void 0,l(!0)},U.onmessage=p=>{try{const Q=JSON.parse(p.data);v.current.push({...Q,seq:C.current++}),D()}catch{}},U.onclose=p=>{if(l(!1),N.current=p.code,j(),p.code===1008){$.cancelled=!0,u(p.reason||"access denied");return}if(p.code===1012){H();return}console.warn(`[logcat] WS closed unexpectedly (code ${p.code}) — retrying`),H()},U.onerror=()=>U.close()}catch{H()}};return w.current=()=>{$.cancelled=!1,f.current=0,u(null),x(!1),T()},T(),()=>{var O;$.cancelled=!0,b.current!==void 0&&window.clearTimeout(b.current),k.current!==void 0&&(window.clearTimeout(k.current),k.current=void 0),j(),(O=g.current)==null||O.close(),g.current=null}},[e,s,i,j,D]);const I=d.useCallback(()=>{w.current()},[]);return{records:r,connected:c,clear:R,deniedReason:o,exhausted:m,retry:I}}const Cs=["V","D","I","W","E","F"];function $c(e){const s=[];let n="",i=!1,r=!1;for(const a of e){if(a==='"'){i=!i,r=!0;continue}if(!i&&/\s/.test(a)){(r||n)&&s.push(n),n="",r=!1;continue}n+=a,r=!0}return(r||n)&&s.push(n),s.filter(a=>a.length>0)}function Yn(e,s={}){const n=s.caseSensitive===!0,i=c=>n?c:c.toLowerCase(),r=n?{caseSensitive:!0}:{},a=[];for(const c of $c(e)){const[l,...o]=c.split(":"),u=o.join(":");u&&l.toLowerCase()==="level"?r.minLevel=u.toUpperCase():u&&l.toLowerCase()==="tag"?r.tag=i(u):u&&l.toLowerCase()==="package"?r.pkg=i(u):a.push(c)}return a.length&&(r.text=i(a.join(" "))),r}function Dc(e,s){if(e.synthetic)return!0;if(s.minLevel){const i=Cs.indexOf(s.minLevel),r=Cs.indexOf(e.level);if(i>=0&&r>=0&&r<i)return!1}const n=i=>s.caseSensitive?i:i.toLowerCase();return!(s.tag&&!n(e.tag).includes(s.tag)||s.pkg&&!n(e.pkg??"").includes(s.pkg)||s.text&&!n(e.message).includes(s.text))}function Tc(e,s){const n=e.trim().split(/\s+/).filter(Boolean).filter(i=>{const[r,...a]=i.split(":");return!(a.join(":")&&r.toLowerCase()==="level")});return s?["level:"+s.toUpperCase(),...n].join(" "):n.join(" ")}const gs=[{ios:"Debug",android:"D"},{ios:"Info",android:"I"},{ios:"Default",android:"I"},{ios:"Error",android:"E"},{ios:"Fault",android:"F"}],ln=["V","D","I","W","E","F"];function Mc(e){if(!e)return gs.filter(n=>n.ios!=="Debug").map(n=>n.ios);const s=ln.indexOf(e.toUpperCase());return s<0?gs.map(n=>n.ios):gs.filter(n=>ln.indexOf(n.android)>=s).map(n=>n.ios)}function Lc(e){const s=Yn(e,{caseSensitive:!0});return{levels:Mc(s.minLevel),process:s.pkg||void 0}}const dn=["#7dd3fc","#c4b5fd","#5eead4","#f0abfc","#93c5fd","#a5b4fc","#67e8f9","#d8b4fe","#f9a8d4","#99f6e4","#bae6fd","#e9d5ff"];function Ic(e){let s=2166136261;for(let n=0;n<e.length;n++)s^=e.charCodeAt(n),s=Math.imul(s,16777619)>>>0;return s>>>0}function _c(e){return e?dn[Ic(e)%dn.length]:"var(--text-muted)"}const Ss=5e5;function Zn(e){return`${new Date(e.ts).toISOString()} ${e.pid} ${e.level}/${e.tag}: ${e.message}`}function Oc(e){return{lines:[],startedAt:e,dropped:0}}function Pc(e,s){for(const n of s){if(e.lines.length>=Ss){e.dropped+=1;continue}e.lines.push(Zn(n))}return e}function zc(e,s,n){const i=["# Xenon logcat recording",`# device: ${n}`,`# started: ${new Date(e.startedAt).toISOString()}`,`# stopped: ${new Date(s).toISOString()}`,`# duration: ${((s-e.startedAt)/1e3).toFixed(1)}s`,`# lines: ${e.lines.length}`];e.dropped>0&&i.push(`# TRUNCATED: ${e.dropped} further line(s) were dropped after the ${Ss}-line cap. This capture is INCOMPLETE.`);const r=e.lines.join(`
248
248
  `),a=e.dropped>0?`
249
249
  # --- TRUNCATED: ${e.dropped} line(s) not captured (cap ${Ss}) ---`:"";return`${i.join(`
250
250
  `)}
251
251
 
252
252
  ${r}${a}
253
- `}function Fc(e,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const un=Cs.filter(e=>e!=="V").map(e=>({value:e,label:e==="F"?"F only":`${e} and above`})),Uc=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function mn(e,s){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),i=document.createElement("a");i.href=n,i.download=s,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),0)}const Bc=d.memo(function({record:s,index:n,isHit:i,isActiveHit:r}){return t.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${i?"is-hit":""} ${r?"is-active-hit":""}`,children:[t.jsx("span",{className:"logcat-time",children:Uc.format(s.ts)}),t.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),t.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:_c(s.tag)},children:s.tag}),t.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),t.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),t.jsx("span",{className:"logcat-msg",children:s.message})]})});function Hc({udid:e,platform:s}){const n=(s||"").toLowerCase(),i=n==="ios",r=n==="android"||i,[a,c]=d.useState(""),l=d.useMemo(()=>i?Lc(a):void 0,[i,a]),{records:o,connected:u,clear:m,deniedReason:x,exhausted:g,retry:f}=Ec(e,r,l),[v,w]=d.useState(!0),[b,k]=d.useState(!1),[C,N]=d.useState(!0),[j,$]=d.useState(""),[R,I]=d.useState(0),D=d.useRef(null),H=d.useRef(null),T=d.useRef(null),[_,z]=d.useState(!1),[G,V]=d.useState(0),J=d.useRef(-1),F=d.useMemo(()=>Yn(a,{caseSensitive:b}),[a,b]),U=d.useMemo(()=>o.filter(P=>Dc(P,F)),[o,F]),p=d.useMemo(()=>{if(!j)return[];const P=b?j:j.toLowerCase(),Z=[];return U.forEach((ne,se)=>{(b?`${ne.tag} ${ne.message}`:`${ne.tag} ${ne.message}`.toLowerCase()).includes(P)&&Z.push(se)}),Z},[U,j,b]),Q=p.length?Math.min(R,p.length-1):0,ie=d.useMemo(()=>new Set(p),[p]),oe=d.useCallback(P=>{var ne,se;if(!p.length)return;const Z=(Q+P+p.length)%p.length;I(Z),w(!1),(se=(ne=H.current)==null?void 0:ne.querySelector(`[data-row-index="${p[Z]}"]`))==null||se.scrollIntoView({block:"center"})},[p,Q]),ye=un.some(P=>P.value===F.minLevel)?F.minLevel:"",ue=d.useCallback(()=>{mn(U.map(Zn).join(`
254
- `),`logcat-${e}-${Date.now()}.txt`)},[U,e]);d.useEffect(()=>{const P=T.current;if(!P||!o.length)return;const Z=o.filter(se=>se.seq>J.current);if(!Z.length)return;const ne=J.current+1;J.current>=0&&Z[0].seq>ne&&(P.dropped+=Z[0].seq-ne),Pc(P,Z),J.current=Z[Z.length-1].seq,V(P.lines.length)},[o]);const ve=d.useCallback(()=>{const P=T.current;if(!P){J.current=o.length?o[o.length-1].seq:-1,T.current=Oc(Date.now()),V(0),z(!0);return}const Z=zc(P,Date.now(),e);T.current=null,z(!1),V(0),mn(Z,Fc(e,P.startedAt))},[o,e]);if(d.useEffect(()=>{var P;v&&((P=D.current)==null||P.scrollIntoView({block:"end"}))},[U.length,v]),!r)return t.jsxs("div",{className:"log-empty-state",children:[t.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),t.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 ke=x?"DENIED":g?"OFFLINE":u?"LIVE":"CONNECTING",Y=!u&&(!!x||g);return t.jsxs("div",{className:"logcat-root",children:[t.jsxs("div",{className:"log-toolbar",children:[t.jsxs("div",{className:"log-filter-group",children:[t.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[t.jsx("span",{className:`log-live-dot ${u?"active":""} ${Y?"is-error":""}`}),ke]}),t.jsxs("div",{className:"log-stat-pill logcat-count",children:[U.length," / ",o.length]}),t.jsxs(Jt,{selectSize:"sm",value:ye,onChange:P=>c(Tc(a,P.target.value)),"aria-label":"Minimum log level",children:[t.jsx("option",{value:"",children:"All levels"}),un.map(P=>t.jsx("option",{value:P.value,children:P.label},P.value))]}),t.jsxs("div",{className:"logcat-input-wrap",children:[t.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:a,onChange:P=>c(P.target.value),"aria-label":"Filter logs"}),a&&t.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>c(""),"aria-label":"Clear filter",title:"Clear filter",children:t.jsx(fn,{size:12})})]}),t.jsxs("div",{className:"logcat-input-wrap",children:[t.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:j,onChange:P=>{$(P.target.value),I(0)},onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),oe(P.shiftKey?-1:1))},"aria-label":"Find in logs"}),j&&t.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:p.length?`${Q+1}/${p.length}`:"0/0"})]}),t.jsx("button",{type:"button",className:"btn-secondary btn-sm logcat-icon-btn",onClick:()=>oe(-1),disabled:!p.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:t.jsx(Ni,{size:14})}),t.jsx("button",{type:"button",className:"btn-secondary btn-sm logcat-icon-btn",onClick:()=>oe(1),disabled:!p.length,"aria-label":"Next match",title:"Next match (Enter)",children:t.jsx(wi,{size:14})}),t.jsx("button",{type:"button",className:`btn-secondary btn-sm logcat-icon-btn ${b?"active":""}`,onClick:()=>k(!b),"aria-pressed":b,"aria-label":"Match case",title:"Match case",children:t.jsx(_i,{size:15})}),t.jsx("button",{type:"button",className:`btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>N(!C),"aria-pressed":C,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:t.jsx(Ar,{size:14})})]}),t.jsxs("div",{className:"log-actions-group",children:[(x||g)&&t.jsxs("button",{className:"btn-secondary btn-sm",onClick:f,children:[t.jsx(yt,{size:14})," RECONNECT"]}),t.jsxs("button",{className:`btn-secondary btn-sm ${v?"active":""}`,onClick:()=>w(!v),children:[t.jsx(_r,{size:14})," ",v?"FREEZE":"FOLLOW"]}),t.jsxs("button",{className:`btn-secondary btn-sm ${_?"is-recording":""}`,onClick:ve,"aria-pressed":_,title:_?"Stop recording and download the capture":"Record the raw log stream to a file",children:[_?t.jsx(jn,{size:12}):t.jsx(Bi,{size:12})," ",_?`STOP · ${G.toLocaleString()}`:"RECORD"]}),t.jsxs("button",{className:"btn-premium btn-sm",disabled:U.length===0,onClick:ue,children:[t.jsx(gi,{size:14})," EXPORT"]}),t.jsxs("button",{className:"btn-secondary btn-sm",onClick:m,children:[t.jsx(Ht,{size:14})," CLEAR"]})]})]}),t.jsxs("div",{className:`logcat-rows ${C?"":"no-wrap"}`,ref:H,children:[x&&t.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[t.jsx(tt,{size:14}),t.jsxs("span",{children:["Access denied — ",x]})]}),!x&&g&&t.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[t.jsx(tt,{size:14}),t.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),U.map((P,Z)=>t.jsx(Bc,{record:P,index:Z,isHit:ie.has(Z),isActiveHit:p.length>0&&p[Q]===Z},P.seq)),t.jsx("div",{ref:D})]})]})}function Wc({device:e,onClose:s}){var L;const{toast:n,removeToast:i}=Zt(),r=ks(),{tab:a}=gn(),c=d.useRef(null),[l,o]=d.useState({width:0,height:0}),[u,m]=d.useState("inspect"),[x,g]=d.useState(null),[f,v]=d.useState(a||"actions"),w=f==="omni"&&u==="inspect",[b,k]=d.useState(""),[C,N]=d.useState(""),[j,$]=d.useState(""),[R,I]=d.useState(!0),[D,H]=d.useState([]),[T,_]=d.useState(null),[z,G]=d.useState(!1),[V,J]=d.useState(!1),[F,U]=d.useState(0),[p,Q]=d.useState(e),[ie,oe]=d.useState([]),[ye,ue]=d.useState(!1),[ve,ke]=d.useState(!1),[Y,P]=d.useState(null),[Z,ne]=d.useState(!1),[se,Ae]=d.useState(!1),Ge=10,[ae,be]=d.useState(!1),[Ue,Ye]=d.useState(!1),Ie=Cc(p==null?void 0:p.udid,!se),lt=()=>{navigator.clipboard.writeText(p.udid).catch(()=>{}),be(!0),setTimeout(()=>be(!1),1500)},he=d.useRef(""),fe=d.useRef(null),[_e,dt]=d.useState(!1);d.useEffect(()=>{f&&(!a||a!==f)&&r(`/devices/${e.udid}/control/${f}`,{replace:!0})},[f,a,e.udid,r]),d.useEffect(()=>((async()=>{try{J(!0),await B.startStream(p.udid);const E=(await B.getDevices()).find(M=>M.udid===p.udid);E&&Q(E)}catch(S){console.error("Auto-start stream failed:",S)}finally{J(!1)}})(),()=>{B.stopStream(p.udid).catch(()=>{})}),[e.udid]);const Be=d.useCallback(async()=>{try{ue(!0);const y=await B.listApps(p.udid);Array.isArray(y)&&oe(y)}catch(y){console.error("Failed to load apps:",y)}finally{ue(!1)}},[p.udid]);d.useEffect(()=>{f==="actions"&&Be()},[f,Be]);const Ct=parseInt(p.screenWidth||"1080",10),St=parseInt(p.screenHeight||"1920",10),Re=Math.min(Ct,St),pe=Math.max(Ct,St),Ze=Re/pe,Je=d.useCallback(()=>{const y=!R,S=y?window.innerHeight*.55:window.innerHeight*.7,E=620,q=window.innerWidth>900;let O;y?O=q?Math.min(window.innerWidth*.8,window.innerWidth-E):window.innerWidth*.8:O=window.innerWidth*.45;const ee=R?Ze:1/Ze;let X,K;R?(X=S,K=X*ee,K>O&&(K=O,X=K/ee)):(K=O,X=K/ee,X>S&&(X=S,K=X*ee)),o({width:K,height:X})},[Ze,R]);d.useEffect(()=>(Je(),window.addEventListener("resize",Je),()=>window.removeEventListener("resize",Je)),[Je]),d.useEffect(()=>{const y=async()=>{if(he.current.length>0){const E=he.current;he.current="";try{await B.typeText(p.udid,E)}catch(M){console.error("Keyboard buffering flush failed:",M)}}},S=E=>{const M=document.activeElement;if(M&&(M.tagName==="INPUT"||M.tagName==="TEXTAREA"||M.isContentEditable)||!_e&&f!=="terminal")return;const O=E.key;O==="Enter"?(fe.current&&clearTimeout(fe.current),y(),B.pressKey(p.udid,p.platform==="android"?66:"enter")):O==="Backspace"?(fe.current&&clearTimeout(fe.current),y(),B.pressKey(p.udid,p.platform==="android"?67:"backspace")):O.length===1&&(he.current+=O,fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{y()},50))};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S),fe.current&&clearTimeout(fe.current)}},[p.udid,p.platform,_e,f]);const[kt,At]=d.useState(Date.now()),ut=()=>{const y=F>0?`r=${F}&`:"";return p.session_id&&!String(p.session_id).startsWith("manual_")?`/xenon/api/session/${p.session_id}/live_video?${y}t=${kt}`:`/xenon/api/control/${p.udid}/stream?${y}t=${kt}`};d.useEffect(()=>{F>0&&At(Date.now())},[F]),d.useEffect(()=>{if(Z||se)return;const y=setTimeout(()=>Ae(!0),3e4);return()=>clearTimeout(y)},[Z,se,F]);const He=d.useRef(null),mt=y=>{const S=y.currentTarget.getBoundingClientRect();return{x:y.clientX-S.left,y:y.clientY-S.top}},Qe=y=>{const S=mt(y);He.current={x:S.x,y:S.y,time:Date.now()}},ht=async y=>{var Oe;if(!He.current)return;const S=He.current,E=mt(y),M=Date.now()-S.time,q=(Oe=c.current)==null?void 0:Oe.getBoundingClientRect(),O=(q==null?void 0:q.width)||l.width,ee=(q==null?void 0:q.height)||l.height;let X,K,te,we;R?(X=S.x/O*Re,K=S.y/ee*pe,te=E.x/O*Re,we=E.y/ee*pe):(X=S.x/O*pe,K=S.y/ee*Re,te=E.x/O*pe,we=E.y/ee*Re);const Ee=Math.abs(te-X),me=Math.abs(we-K);try{M<500&&Ee<10&&me<10?await B.tap(p.udid,Math.round(X),Math.round(K)):M>=500&&Ee<10&&me<10?await B.touchAndHold(p.udid,Math.round(X),Math.round(K),M):await B.swipe(p.udid,Math.round(X),Math.round(K),Math.round(te),Math.round(we))}catch(Ve){console.error("Action failed:",Ve)}He.current=null},ce=()=>B.pressKey(p.udid,p.platform==="android"?xt.HOME:as.HOME),ft=()=>B.pressKey(p.udid,xt.BACK),ns=()=>B.pressKey(p.udid,xt.APP_SWITCH),Rt=()=>B.pressKey(p.udid,p.platform==="android"?xt.VOLUME_UP:as.VOLUME_UP),Et=()=>B.pressKey(p.udid,p.platform==="android"?xt.VOLUME_DOWN:as.VOLUME_DOWN),$t=()=>B.lock(p.udid),pt=async()=>{Ye(!0);try{await B.unlock(p.udid)}finally{setTimeout(()=>Ye(!1),2500)}},Dt=async()=>{b.trim()&&(await B.typeText(p.udid,b),k(""))},Tt=async()=>{try{N("Fetching...");const y=await B.getClipboard(p.udid);y&&y.content!==void 0?N(y.content||"(Clipboard is empty)"):N("No content received")}catch{N("Error: Check Appium Settings app")}},Mt=async()=>{G(!0);try{const y=await B.getScreenshot(p.udid);if(y!=null&&y.screenshot){const S={id:mc(),base64:y.screenshot,timestamp:Date.now()};H(E=>[S,...E]),_(0)}}catch(y){console.error("Failed to take screenshot:",y)}finally{G(!1)}},gt=y=>{H(S=>{const E=S.filter(M=>M.id!==y);return E.length===0?_(null):T!==null&&T>=E.length&&_(0),E})},Lt=()=>{H([]),_(null),n("Cleared all captured evidence.","success")},It=y=>{const S=document.createElement("a");S.href=`data:image/png;base64,${y}`,S.download=`screenshot-${p.udid}-${Date.now()}.png`,S.click()},We=async y=>{const S=Re/2,E=pe/2,M=Re*.4,q=pe*.4;let O,ee,X,K;switch(y){case"left":O=S+M,ee=E,X=S-M,K=E;break;case"right":O=S-M,ee=E,X=S+M,K=E;break;case"up":O=S,ee=E+q,X=S,K=E-q;break;case"down":O=S,ee=E-q,X=S,K=E+q;break}try{await B.swipe(p.udid,Math.round(O),Math.round(ee),Math.round(X),Math.round(K))}catch(te){console.error(`Quick swipe ${y} failed:`,te)}},h=async()=>{if(j.trim()){const y=n(`Uninstalling ${j}...`,"loading",0);try{ue(!0),await B.uninstallApp(p.udid,j),$(""),n(`Request sent for ${j}`,"success"),setTimeout(Be,3e3)}catch{n("Uninstall failed. Check logs.","error")}finally{ue(!1),i(y)}}},A=async()=>{if(!Y)return;let y;try{ke(!0),y=n(`Installing app to ${p.udid}...`,"loading",0);const S=await B.uploadAndInstallApp(p.udid,Y);S.success?(n(S.message||"App installed successfully","success"),P(null),setTimeout(Be,5e3)):n("Installation failed: "+(S.error||"Unknown error"),"error")}catch(S){n("Installation failed: "+S.message,"error")}finally{y&&i(y),ke(!1)}};return t.jsxs("div",{className:"device-control-view",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"control-view-top-bar",children:[t.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[t.jsx(os,{size:18})," DEVICES"]}),t.jsxs("div",{className:"device-info-mini",children:[t.jsx("span",{className:`device-pill platform-pill ${p.platform}`,children:p.platform==="ios"?"Apple":"Android"}),t.jsxs("span",{className:"device-pill version-pill",children:["v",p.sdk]}),p.reservedUntil&&Date.now()<p.reservedUntil&&t.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${p.reservedBy}${p.reservationReason?`: ${p.reservationReason}`:""}`,children:["RESERVED BY ",((L=p.reservedBy)==null?void 0:L.toUpperCase())||"ANONYMOUS"]}),t.jsx("h2",{className:"device-name-text",children:p.name}),t.jsxs("span",{className:"udid-chip",title:p.udid,children:[t.jsx("span",{className:"udid-chip__value",children:p.udid}),t.jsx("button",{type:"button",className:"udid-chip__copy",onClick:lt,"aria-label":"Copy UDID",title:ae?"Copied!":"Copy UDID",children:ae?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]})]}),t.jsxs("div",{className:`control-view-main ${R?"":"is-landscape"} ${f==="omni"?"omni-mode":""}`,children:[t.jsxs("div",{className:"device-preview-column",children:[t.jsx("div",{className:"device-screen-wrapper",children:t.jsxs("div",{ref:y=>{c.current=y,g(y)},className:`device-stream-canvas ${R?"":"landscape"} ${_e?"focused":""} ${w?"is-inspecting":""}`,style:{width:l.width,height:l.height,background:"#000"},tabIndex:0,onFocus:()=>dt(!0),onBlur:()=>dt(!1),onMouseDown:w?void 0:Qe,onMouseUp:w?void 0:ht,children:[se?t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(tt,{size:40,color:"var(--red, #f87171)"}),t.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),t.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{Ae(!1),U(0)},children:"Retry"})]}):(V||!Z)&&t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(yt,{size:40,className:"animate-spin",color:"var(--green)"}),t.jsx("p",{style:{marginTop:16},children:V?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!se&&t.jsx("img",{src:ut(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>ne(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),ne(!1),F>=Ge){Ae(!0);return}setTimeout(()=>U(y=>y+1),2e3)}}),Ie==="off"&&!se&&t.jsxs("div",{className:"device-screen-off",role:"status",children:[t.jsx(lr,{size:32}),t.jsx("p",{children:"Display is off"}),t.jsx("span",{children:"The stream is fine — the device is asleep."}),t.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:pt,disabled:Ue,children:Ue?"Waking…":"Wake device"})]})]})}),t.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":R?"vertical":"horizontal",children:[t.jsx("button",{className:`footer-action-btn ${R?"active":""}`,onClick:()=>I(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":R,children:t.jsx(xr,{size:18})}),t.jsx("button",{className:`footer-action-btn ${R?"":"active"}`,onClick:()=>I(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!R,children:t.jsx(pr,{size:18})}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:ce,title:"Home","aria-label":"Home",children:t.jsx(Qi,{size:18})}),p.platform==="android"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"footer-action-btn",onClick:ft,title:"Back","aria-label":"Back",children:t.jsx(os,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:ns,title:"App Switcher","aria-label":"App switcher",children:t.jsx(jn,{size:18})})]}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:Rt,title:"Volume Up","aria-label":"Volume up",children:t.jsx(Lr,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:Et,title:"Volume Down","aria-label":"Volume down",children:t.jsx(Tr,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:$t,title:"Lock Device","aria-label":"Lock device",children:t.jsx(xi,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:pt,title:"Unlock Device","aria-label":"Unlock device",children:t.jsx(nr,{size:18})})]})]}),t.jsxs("div",{className:"device-interactions-column",children:[t.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[t.jsxs("button",{className:`tab-btn ${f==="actions"?"active":""}`,onClick:()=>v("actions"),role:"tab","aria-selected":f==="actions",children:[t.jsx(xs,{size:13}),t.jsx("span",{children:"Actions"})]}),t.jsxs("button",{className:`tab-btn ${f==="screenshot"?"active":""}`,onClick:()=>v("screenshot"),role:"tab","aria-selected":f==="screenshot",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:"Screenshot"})]}),t.jsxs("button",{className:`tab-btn ${f==="logs"?"active":""}`,onClick:()=>v("logs"),role:"tab","aria-selected":f==="logs",children:[t.jsx(br,{size:13}),t.jsx("span",{children:"Debug Logs"})]}),t.jsxs("button",{className:`tab-btn ${f==="terminal"?"active":""}`,onClick:()=>v("terminal"),role:"tab","aria-selected":f==="terminal",children:[t.jsx(bn,{size:13}),t.jsx("span",{children:"Shell"})]}),t.jsxs("button",{className:`tab-btn ${f==="omni"?"active":""}`,onClick:()=>v("omni"),role:"tab","aria-selected":f==="omni",children:[t.jsx(ys,{size:13}),t.jsx("span",{children:"Omni-Vision"})]})]}),t.jsx("div",{className:`interactions-scroll-area ${f==="terminal"?"terminal-mode":""} ${f==="screenshot"||f==="logs"?"screenshot-mode":""}`,children:t.jsxs("div",{className:"tab-content",children:[f==="omni"&&t.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:t.jsx(Nc,{sessionId:p.session_id?String(p.session_id):null,udid:p.udid,streamUrl:ut(),embedded:!0,overlayTarget:x,onModeChange:m})}),f==="actions"&&t.jsxs("div",{className:"actions-grid",children:[t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(fi,{size:18,color:"var(--green)"})," Smart Input"]}),t.jsx("p",{className:"action-card-hint",children:"Relay keystrokes to the focused element on the device."}),t.jsx("input",{type:"text",className:"type-input-field compact",placeholder:"Type and press Enter to send…",value:b,onChange:y=>k(y.target.value),onKeyDown:y=>y.key==="Enter"&&Dt()})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ui,{size:18,color:"var(--green)"})," App Management"]}),t.jsxs("div",{className:"app-mgmt-content",children:[t.jsxs("div",{className:"install-section",children:[t.jsx("p",{className:"compact-label",children:"Install Package"}),t.jsxs("div",{className:"upload-box-row",children:[t.jsxs("label",{className:"file-upload-launcher",title:Y?Y.name:"Select an .apk, .ipa or .app file",children:[t.jsx(mi,{size:14}),t.jsx("span",{children:Y?Y.name:"Select File"}),t.jsx("input",{type:"file",accept:".apk,.ipa,.app",onChange:y=>{var S;return P(((S=y.target.files)==null?void 0:S[0])||null)},hidden:!0})]}),t.jsx("button",{className:"btn-premium btn-sm",disabled:!Y||ve,onClick:A,children:ve?t.jsx(is,{className:"animate-spin",size:14}):"INSTALL"})]}),t.jsx("p",{className:"hint-text",children:"Accepts .apk, .ipa or .app"})]}),t.jsx("div",{className:"divider-v"}),t.jsxs("div",{className:"uninstall-section",children:[t.jsx("p",{className:"compact-label",children:"Quick Uninstall"}),t.jsxs("div",{className:"uninstall-controls-row",children:[t.jsxs("div",{className:"select-wrapper",children:[t.jsxs(Jt,{selectSize:"sm",className:"w-full",value:j,onChange:y=>$(y.target.value),disabled:ye,children:[t.jsx("option",{value:"",children:ye?"Loading apps...":"-- Select App to Remove --"}),ie.map(y=>t.jsx("option",{value:y,children:y},y))]}),ye&&t.jsx(is,{className:"animate-spin select-loader",size:12})]}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:h,disabled:!j||ye,children:[t.jsx(Ht,{size:14})," UNINSTALL"]})]}),t.jsxs("div",{className:"manual-input-box",children:[t.jsx("p",{className:"hint-text",children:"Or enter manually:"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"com.example.app",value:j,onChange:y=>$(y.target.value)})]})]})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Wi,{size:18,color:"var(--green)"})," Clipboard"]}),t.jsxs("div",{className:"clipboard-row",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:Tt,children:"FETCH VALUE"}),t.jsx("div",{className:"clipboard-display compact",children:C})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ur,{size:18,color:"var(--green)"})," Directional Gestures"]}),t.jsxs("div",{className:"gestures-grid-container",children:[t.jsxs("div",{className:"gestures-dpad",children:[t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("up"),children:t.jsx(Pi,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("left"),children:t.jsx(os,{size:24})}),t.jsx("div",{className:"dpad-center"}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("right"),children:t.jsx(wn,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("down"),children:t.jsx(pn,{size:24})}),t.jsx("div",{})]}),t.jsx("p",{className:"compact-label dpad-caption",children:"Quick swipe in a direction"})]})]})]}),f==="screenshot"&&t.jsxs("div",{className:"action-card screenshot-card",children:[D.length>0&&t.jsx("header",{className:"action-card-header",children:t.jsx("button",{className:"btn-text-only",onClick:Lt,children:"CLEAR ALL"})}),t.jsxs("div",{className:`screenshot-workspace ${D.length===0?"is-empty":""}`,children:[t.jsxs("div",{className:"screenshot-gallery-sidebar",children:[t.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Mt,disabled:z,children:[z?t.jsx(is,{className:"animate-spin",size:16}):t.jsx(cs,{size:16}),t.jsx("span",{children:z?"CAPTURING...":"NEW CAPTURE"})]}),t.jsxs("div",{className:"screenshot-thumbnails-list",children:[D.length===0&&!z&&t.jsxs("div",{className:"empty-gallery-state",children:[t.jsx(cs,{size:20,className:"empty-gallery-icon"}),t.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),t.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),D.map((y,S)=>t.jsxs("div",{className:`screenshot-thumb-item ${T===S?"active":""}`,onClick:()=>_(S),children:[t.jsx("img",{src:`data:image/png;base64,${y.base64}`,alt:"Thumb"}),t.jsx("span",{className:"thumb-time",children:new Date(y.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),t.jsx("button",{className:"thumb-delete-btn",onClick:E=>{E.stopPropagation(),gt(y.id)},children:t.jsx(Ht,{size:12})})]},y.id))]})]}),t.jsx("div",{className:"screenshot-main-preview",children:T!==null&&D[T]?t.jsxs("div",{className:"preview-container",children:[t.jsx("div",{className:"preview-image-wrapper",children:t.jsx("img",{src:`data:image/png;base64,${D[T].base64}`,alt:"Selected Evidence"})}),t.jsxs("footer",{className:"preview-footer",children:[t.jsxs("div",{className:"preview-meta",children:[t.jsx("span",{className:"meta-label",children:"ID:"}),t.jsx("span",{className:"meta-value",children:D[T].id.substring(0,8)}),t.jsx("span",{className:"meta-divider",children:"|"}),t.jsx("span",{className:"meta-value",children:hi(D[T].timestamp)})]}),t.jsxs("div",{className:"preview-actions",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:()=>It(D[T].base64),children:"DOWNLOAD PNG"}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>gt(D[T].id),children:[t.jsx(Ht,{size:14})," DELETE"]})]})]})]}):null})]})]}),f==="logs"&&t.jsx("div",{className:"action-card screenshot-card",children:t.jsx(Hc,{udid:p.udid,platform:p.platform})}),f==="terminal"&&t.jsx("div",{className:"action-card full-height",children:t.jsx(hc,{platform:(p.platform||"").toLowerCase(),prompt:`${(p.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${p.name} (${p.udid}).
253
+ `}function Fc(e,s){const n=new Date(s).toISOString().replace(/[:.]/g,"-").replace(/Z$/,"");return`logcat-${e}-${n}.txt`}const un=Cs.filter(e=>e!=="V").map(e=>({value:e,label:e==="F"?"F only":`${e} and above`})),Uc=new Intl.DateTimeFormat([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function mn(e,s){const n=URL.createObjectURL(new Blob([e],{type:"text/plain"})),i=document.createElement("a");i.href=n,i.download=s,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),0)}const Bc=d.memo(function({record:s,index:n,isHit:i,isActiveHit:r}){return t.jsxs("div",{"data-row-index":n,className:`logcat-row ${s.synthetic?"is-synthetic":""} ${i?"is-hit":""} ${r?"is-active-hit":""}`,children:[t.jsx("span",{className:"logcat-time",children:Uc.format(s.ts)}),t.jsxs("span",{className:"logcat-pid",children:[s.pid,"-",s.tid]}),t.jsx("span",{className:"logcat-tag",title:s.tag,style:{color:_c(s.tag)},children:s.tag}),t.jsx("span",{className:"logcat-pkg",title:s.pkg,children:s.pkg??""}),t.jsx("span",{className:`logcat-level lvl-${s.level}`,children:s.level}),t.jsx("span",{className:"logcat-msg",children:s.message})]})});function Hc({udid:e,platform:s}){const n=(s||"").toLowerCase(),i=n==="ios",r=n==="android"||i,[a,c]=d.useState(""),l=d.useMemo(()=>i?Lc(a):void 0,[i,a]),{records:o,connected:u,clear:m,deniedReason:x,exhausted:g,retry:f}=Ec(e,r,l),[b,w]=d.useState(!0),[v,k]=d.useState(!1),[C,N]=d.useState(!0),[j,D]=d.useState(""),[R,I]=d.useState(0),$=d.useRef(null),H=d.useRef(null),T=d.useRef(null),[O,z]=d.useState(!1),[G,V]=d.useState(0),J=d.useRef(-1),F=d.useMemo(()=>Yn(a,{caseSensitive:v}),[a,v]),U=d.useMemo(()=>o.filter(P=>Dc(P,F)),[o,F]),p=d.useMemo(()=>{if(!j)return[];const P=v?j:j.toLowerCase(),Z=[];return U.forEach((ne,se)=>{(v?`${ne.tag} ${ne.message}`:`${ne.tag} ${ne.message}`.toLowerCase()).includes(P)&&Z.push(se)}),Z},[U,j,v]),Q=p.length?Math.min(R,p.length-1):0,ie=d.useMemo(()=>new Set(p),[p]),oe=d.useCallback(P=>{var ne,se;if(!p.length)return;const Z=(Q+P+p.length)%p.length;I(Z),w(!1),(se=(ne=H.current)==null?void 0:ne.querySelector(`[data-row-index="${p[Z]}"]`))==null||se.scrollIntoView({block:"center"})},[p,Q]),ye=un.some(P=>P.value===F.minLevel)?F.minLevel:"",ue=d.useCallback(()=>{mn(U.map(Zn).join(`
254
+ `),`logcat-${e}-${Date.now()}.txt`)},[U,e]);d.useEffect(()=>{const P=T.current;if(!P||!o.length)return;const Z=o.filter(se=>se.seq>J.current);if(!Z.length)return;const ne=J.current+1;J.current>=0&&Z[0].seq>ne&&(P.dropped+=Z[0].seq-ne),Pc(P,Z),J.current=Z[Z.length-1].seq,V(P.lines.length)},[o]);const ve=d.useCallback(()=>{const P=T.current;if(!P){J.current=o.length?o[o.length-1].seq:-1,T.current=Oc(Date.now()),V(0),z(!0);return}const Z=zc(P,Date.now(),e);T.current=null,z(!1),V(0),mn(Z,Fc(e,P.startedAt))},[o,e]);if(d.useEffect(()=>{var P;b&&((P=$.current)==null||P.scrollIntoView({block:"end"}))},[U.length,b]),!r)return t.jsxs("div",{className:"log-empty-state",children:[t.jsx("p",{className:"log-empty-title",children:"Live logs are not available here"}),t.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 ke=x?"DENIED":g?"OFFLINE":u?"LIVE":"CONNECTING",Y=!u&&(!!x||g);return t.jsxs("div",{className:"logcat-root",children:[t.jsxs("div",{className:"log-toolbar",children:[t.jsxs("div",{className:"log-filter-group",children:[t.jsxs("div",{className:"log-stat-pill",title:x??void 0,children:[t.jsx("span",{className:`log-live-dot ${u?"active":""} ${Y?"is-error":""}`}),ke]}),t.jsxs("div",{className:"log-stat-pill logcat-count",children:[U.length," / ",o.length]}),t.jsxs(Jt,{selectSize:"sm",value:ye,onChange:P=>c(Tc(a,P.target.value)),"aria-label":"Minimum log level",children:[t.jsx("option",{value:"",children:"All levels"}),un.map(P=>t.jsx("option",{value:P.value,children:P.label},P.value))]}),t.jsxs("div",{className:"logcat-input-wrap",children:[t.jsx("input",{type:"text",className:"type-input-field tiny logcat-query",placeholder:"tag:Wifi package:com.android.systemui free text",value:a,onChange:P=>c(P.target.value),"aria-label":"Filter logs"}),a&&t.jsx("button",{type:"button",className:"logcat-input-btn",onClick:()=>c(""),"aria-label":"Clear filter",title:"Clear filter",children:t.jsx(fn,{size:12})})]}),t.jsxs("div",{className:"logcat-input-wrap",children:[t.jsx("input",{type:"text",className:"type-input-field tiny logcat-find",placeholder:"Find…",value:j,onChange:P=>{D(P.target.value),I(0)},onKeyDown:P=>{P.key==="Enter"&&(P.preventDefault(),oe(P.shiftKey?-1:1))},"aria-label":"Find in logs"}),j&&t.jsx("span",{className:"logcat-hit-count","aria-live":"polite",children:p.length?`${Q+1}/${p.length}`:"0/0"})]}),t.jsx("button",{type:"button",className:"btn-secondary btn-sm logcat-icon-btn",onClick:()=>oe(-1),disabled:!p.length,"aria-label":"Previous match",title:"Previous match (Shift+Enter)",children:t.jsx(Ni,{size:14})}),t.jsx("button",{type:"button",className:"btn-secondary btn-sm logcat-icon-btn",onClick:()=>oe(1),disabled:!p.length,"aria-label":"Next match",title:"Next match (Enter)",children:t.jsx(wi,{size:14})}),t.jsx("button",{type:"button",className:`btn-secondary btn-sm logcat-icon-btn ${v?"active":""}`,onClick:()=>k(!v),"aria-pressed":v,"aria-label":"Match case",title:"Match case",children:t.jsx(_i,{size:15})}),t.jsx("button",{type:"button",className:`btn-secondary btn-sm logcat-icon-btn ${C?"active":""}`,onClick:()=>N(!C),"aria-pressed":C,"aria-label":"Soft wrap",title:"Soft wrap long messages",children:t.jsx(Ar,{size:14})})]}),t.jsxs("div",{className:"log-actions-group",children:[(x||g)&&t.jsxs("button",{className:"btn-secondary btn-sm",onClick:f,children:[t.jsx(yt,{size:14})," RECONNECT"]}),t.jsxs("button",{className:`btn-secondary btn-sm ${b?"active":""}`,onClick:()=>w(!b),children:[t.jsx(_r,{size:14})," ",b?"FREEZE":"FOLLOW"]}),t.jsxs("button",{className:`btn-secondary btn-sm ${O?"is-recording":""}`,onClick:ve,"aria-pressed":O,title:O?"Stop recording and download the capture":"Record the raw log stream to a file",children:[O?t.jsx(jn,{size:12}):t.jsx(Bi,{size:12})," ",O?`STOP · ${G.toLocaleString()}`:"RECORD"]}),t.jsxs("button",{className:"btn-premium btn-sm",disabled:U.length===0,onClick:ue,children:[t.jsx(gi,{size:14})," EXPORT"]}),t.jsxs("button",{className:"btn-secondary btn-sm",onClick:m,children:[t.jsx(Ht,{size:14})," CLEAR"]})]})]}),t.jsxs("div",{className:`logcat-rows ${C?"":"no-wrap"}`,ref:H,children:[x&&t.jsxs("div",{className:"logcat-status-banner is-denied",role:"alert",children:[t.jsx(tt,{size:14}),t.jsxs("span",{children:["Access denied — ",x]})]}),!x&&g&&t.jsxs("div",{className:"logcat-status-banner is-exhausted",role:"alert",children:[t.jsx(tt,{size:14}),t.jsx("span",{children:"Connection lost after repeated attempts. Use Reconnect above to try again."})]}),U.map((P,Z)=>t.jsx(Bc,{record:P,index:Z,isHit:ie.has(Z),isActiveHit:p.length>0&&p[Q]===Z},P.seq)),t.jsx("div",{ref:$})]})]})}function Wc({device:e,onClose:s}){var L;const{toast:n,removeToast:i}=Zt(),r=ks(),{tab:a}=gn(),c=d.useRef(null),[l,o]=d.useState({width:0,height:0}),[u,m]=d.useState("inspect"),[x,g]=d.useState(null),[f,b]=d.useState(a||"actions"),w=f==="omni"&&u==="inspect",[v,k]=d.useState(""),[C,N]=d.useState(""),[j,D]=d.useState(""),[R,I]=d.useState(!0),[$,H]=d.useState([]),[T,O]=d.useState(null),[z,G]=d.useState(!1),[V,J]=d.useState(!1),[F,U]=d.useState(0),[p,Q]=d.useState(e),[ie,oe]=d.useState([]),[ye,ue]=d.useState(!1),[ve,ke]=d.useState(!1),[Y,P]=d.useState(null),[Z,ne]=d.useState(!1),[se,Ae]=d.useState(!1),Ge=10,[ae,be]=d.useState(!1),[Ue,Ye]=d.useState(!1),Ie=Cc(p==null?void 0:p.udid,!se),lt=()=>{navigator.clipboard.writeText(p.udid).catch(()=>{}),be(!0),setTimeout(()=>be(!1),1500)},he=d.useRef(""),fe=d.useRef(null),[_e,dt]=d.useState(!1);d.useEffect(()=>{f&&(!a||a!==f)&&r(`/devices/${e.udid}/control/${f}`,{replace:!0})},[f,a,e.udid,r]),d.useEffect(()=>((async()=>{try{J(!0),await B.startStream(p.udid);const E=(await B.getDevices()).find(M=>M.udid===p.udid);E&&Q(E)}catch(S){console.error("Auto-start stream failed:",S)}finally{J(!1)}})(),()=>{B.stopStream(p.udid).catch(()=>{})}),[e.udid]);const Be=d.useCallback(async()=>{try{ue(!0);const y=await B.listApps(p.udid);Array.isArray(y)&&oe(y)}catch(y){console.error("Failed to load apps:",y)}finally{ue(!1)}},[p.udid]);d.useEffect(()=>{f==="actions"&&Be()},[f,Be]);const Ct=parseInt(p.screenWidth||"1080",10),St=parseInt(p.screenHeight||"1920",10),Re=Math.min(Ct,St),pe=Math.max(Ct,St),Ze=Re/pe,Je=d.useCallback(()=>{const y=!R,S=y?window.innerHeight*.55:window.innerHeight*.7,E=620,q=window.innerWidth>900;let _;y?_=q?Math.min(window.innerWidth*.8,window.innerWidth-E):window.innerWidth*.8:_=window.innerWidth*.45;const ee=R?Ze:1/Ze;let X,K;R?(X=S,K=X*ee,K>_&&(K=_,X=K/ee)):(K=_,X=K/ee,X>S&&(X=S,K=X*ee)),o({width:K,height:X})},[Ze,R]);d.useEffect(()=>(Je(),window.addEventListener("resize",Je),()=>window.removeEventListener("resize",Je)),[Je]),d.useEffect(()=>{const y=async()=>{if(he.current.length>0){const E=he.current;he.current="";try{await B.typeText(p.udid,E)}catch(M){console.error("Keyboard buffering flush failed:",M)}}},S=E=>{const M=document.activeElement;if(M&&(M.tagName==="INPUT"||M.tagName==="TEXTAREA"||M.isContentEditable)||!_e&&f!=="terminal")return;const _=E.key;_==="Enter"?(fe.current&&clearTimeout(fe.current),y(),B.pressKey(p.udid,p.platform==="android"?66:"enter")):_==="Backspace"?(fe.current&&clearTimeout(fe.current),y(),B.pressKey(p.udid,p.platform==="android"?67:"backspace")):_.length===1&&(he.current+=_,fe.current&&clearTimeout(fe.current),fe.current=setTimeout(()=>{y()},50))};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S),fe.current&&clearTimeout(fe.current)}},[p.udid,p.platform,_e,f]);const[kt,At]=d.useState(Date.now()),ut=()=>{const y=F>0?`r=${F}&`:"";return p.session_id&&!String(p.session_id).startsWith("manual_")?`/xenon/api/session/${p.session_id}/live_video?${y}t=${kt}`:`/xenon/api/control/${p.udid}/stream?${y}t=${kt}`};d.useEffect(()=>{F>0&&At(Date.now())},[F]),d.useEffect(()=>{if(Z||se)return;const y=setTimeout(()=>Ae(!0),3e4);return()=>clearTimeout(y)},[Z,se,F]);const He=d.useRef(null),mt=y=>{const S=y.currentTarget.getBoundingClientRect();return{x:y.clientX-S.left,y:y.clientY-S.top}},Qe=y=>{const S=mt(y);He.current={x:S.x,y:S.y,time:Date.now()}},ht=async y=>{var Oe;if(!He.current)return;const S=He.current,E=mt(y),M=Date.now()-S.time,q=(Oe=c.current)==null?void 0:Oe.getBoundingClientRect(),_=(q==null?void 0:q.width)||l.width,ee=(q==null?void 0:q.height)||l.height;let X,K,te,we;R?(X=S.x/_*Re,K=S.y/ee*pe,te=E.x/_*Re,we=E.y/ee*pe):(X=S.x/_*pe,K=S.y/ee*Re,te=E.x/_*pe,we=E.y/ee*Re);const Ee=Math.abs(te-X),me=Math.abs(we-K);try{M<500&&Ee<10&&me<10?await B.tap(p.udid,Math.round(X),Math.round(K)):M>=500&&Ee<10&&me<10?await B.touchAndHold(p.udid,Math.round(X),Math.round(K),M):await B.swipe(p.udid,Math.round(X),Math.round(K),Math.round(te),Math.round(we))}catch(Ve){console.error("Action failed:",Ve)}He.current=null},ce=()=>B.pressKey(p.udid,p.platform==="android"?xt.HOME:as.HOME),ft=()=>B.pressKey(p.udid,xt.BACK),ns=()=>B.pressKey(p.udid,xt.APP_SWITCH),Rt=()=>B.pressKey(p.udid,p.platform==="android"?xt.VOLUME_UP:as.VOLUME_UP),Et=()=>B.pressKey(p.udid,p.platform==="android"?xt.VOLUME_DOWN:as.VOLUME_DOWN),$t=()=>B.lock(p.udid),pt=async()=>{Ye(!0);try{await B.unlock(p.udid)}finally{setTimeout(()=>Ye(!1),2500)}},Dt=async()=>{v.trim()&&(await B.typeText(p.udid,v),k(""))},Tt=async()=>{try{N("Fetching...");const y=await B.getClipboard(p.udid);y&&y.content!==void 0?N(y.content||"(Clipboard is empty)"):N("No content received")}catch{N("Error: Check Appium Settings app")}},Mt=async()=>{G(!0);try{const y=await B.getScreenshot(p.udid);if(y!=null&&y.screenshot){const S={id:mc(),base64:y.screenshot,timestamp:Date.now()};H(E=>[S,...E]),O(0)}}catch(y){console.error("Failed to take screenshot:",y)}finally{G(!1)}},gt=y=>{H(S=>{const E=S.filter(M=>M.id!==y);return E.length===0?O(null):T!==null&&T>=E.length&&O(0),E})},Lt=()=>{H([]),O(null),n("Cleared all captured evidence.","success")},It=y=>{const S=document.createElement("a");S.href=`data:image/png;base64,${y}`,S.download=`screenshot-${p.udid}-${Date.now()}.png`,S.click()},We=async y=>{const S=Re/2,E=pe/2,M=Re*.4,q=pe*.4;let _,ee,X,K;switch(y){case"left":_=S+M,ee=E,X=S-M,K=E;break;case"right":_=S-M,ee=E,X=S+M,K=E;break;case"up":_=S,ee=E+q,X=S,K=E-q;break;case"down":_=S,ee=E-q,X=S,K=E+q;break}try{await B.swipe(p.udid,Math.round(_),Math.round(ee),Math.round(X),Math.round(K))}catch(te){console.error(`Quick swipe ${y} failed:`,te)}},h=async()=>{if(j.trim()){const y=n(`Uninstalling ${j}...`,"loading",0);try{ue(!0),await B.uninstallApp(p.udid,j),D(""),n(`Request sent for ${j}`,"success"),setTimeout(Be,3e3)}catch{n("Uninstall failed. Check logs.","error")}finally{ue(!1),i(y)}}},A=async()=>{if(!Y)return;let y;try{ke(!0),y=n(`Installing app to ${p.udid}...`,"loading",0);const S=await B.uploadAndInstallApp(p.udid,Y);S.success?(n(S.message||"App installed successfully","success"),P(null),setTimeout(Be,5e3)):n("Installation failed: "+(S.error||"Unknown error"),"error")}catch(S){n("Installation failed: "+S.message,"error")}finally{y&&i(y),ke(!1)}};return t.jsxs("div",{className:"device-control-view",children:[t.jsx("div",{className:"scanline",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:.05,zIndex:1001}}),t.jsxs("header",{className:"control-view-top-bar",children:[t.jsxs("button",{className:"back-to-devices-btn",onClick:s,children:[t.jsx(os,{size:18})," DEVICES"]}),t.jsxs("div",{className:"device-info-mini",children:[t.jsx("span",{className:`device-pill platform-pill ${p.platform}`,children:p.platform==="ios"?"Apple":"Android"}),t.jsxs("span",{className:"device-pill version-pill",children:["v",p.sdk]}),p.reservedUntil&&Date.now()<p.reservedUntil&&t.jsxs("span",{className:"device-pill reserved-pill",title:`Reserved by ${p.reservedBy}${p.reservationReason?`: ${p.reservationReason}`:""}`,children:["RESERVED BY ",((L=p.reservedBy)==null?void 0:L.toUpperCase())||"ANONYMOUS"]}),t.jsx("h2",{className:"device-name-text",children:p.name}),t.jsxs("span",{className:"udid-chip",title:p.udid,children:[t.jsx("span",{className:"udid-chip__value",children:p.udid}),t.jsx("button",{type:"button",className:"udid-chip__copy",onClick:lt,"aria-label":"Copy UDID",title:ae?"Copied!":"Copy UDID",children:ae?t.jsx(Bt,{size:12}):t.jsx(Xe,{size:12})})]})]})]}),t.jsxs("div",{className:`control-view-main ${R?"":"is-landscape"} ${f==="omni"?"omni-mode":""}`,children:[t.jsxs("div",{className:"device-preview-column",children:[t.jsx("div",{className:"device-screen-wrapper",children:t.jsxs("div",{ref:y=>{c.current=y,g(y)},className:`device-stream-canvas ${R?"":"landscape"} ${_e?"focused":""} ${w?"is-inspecting":""}`,style:{width:l.width,height:l.height,background:"#000"},tabIndex:0,onFocus:()=>dt(!0),onBlur:()=>dt(!1),onMouseDown:w?void 0:Qe,onMouseUp:w?void 0:ht,children:[se?t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(tt,{size:40,color:"var(--red, #f87171)"}),t.jsx("p",{style:{marginTop:16},children:"Stream unavailable"}),t.jsx("button",{className:"btn-premium btn-sm",style:{marginTop:12},onClick:()=>{Ae(!1),U(0)},children:"Retry"})]}):(V||!Z)&&t.jsxs("div",{className:"device-stream-placeholder",style:{position:"absolute",zIndex:10},children:[t.jsx(yt,{size:40,className:"animate-spin",color:"var(--green)"}),t.jsx("p",{style:{marginTop:16},children:V?"ESTABLISHING TRACE...":"Waiting for stream…"})]}),!se&&t.jsx("img",{src:ut(),alt:"Device Stream",className:"device-stream-image",style:{width:"100%",height:"100%",objectFit:"contain"},onLoad:()=>ne(!0),onError:()=>{if(console.warn("Stream failed to load, retrying..."),ne(!1),F>=Ge){Ae(!0);return}setTimeout(()=>U(y=>y+1),2e3)}}),Ie==="off"&&!se&&t.jsxs("div",{className:"device-screen-off",role:"status",children:[t.jsx(lr,{size:32}),t.jsx("p",{children:"Display is off"}),t.jsx("span",{children:"The stream is fine — the device is asleep."}),t.jsx("button",{type:"button",className:"btn-premium btn-sm",onClick:pt,disabled:Ue,children:Ue?"Waking…":"Wake device"})]})]})}),t.jsxs("aside",{className:"device-footer-actions",role:"toolbar","aria-label":"Device controls","aria-orientation":R?"vertical":"horizontal",children:[t.jsx("button",{className:`footer-action-btn ${R?"active":""}`,onClick:()=>I(!0),title:"Portrait","aria-label":"Portrait orientation","aria-pressed":R,children:t.jsx(xr,{size:18})}),t.jsx("button",{className:`footer-action-btn ${R?"":"active"}`,onClick:()=>I(!1),title:"Landscape","aria-label":"Landscape orientation","aria-pressed":!R,children:t.jsx(pr,{size:18})}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:ce,title:"Home","aria-label":"Home",children:t.jsx(Qi,{size:18})}),p.platform==="android"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{className:"footer-action-btn",onClick:ft,title:"Back","aria-label":"Back",children:t.jsx(os,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:ns,title:"App Switcher","aria-label":"App switcher",children:t.jsx(jn,{size:18})})]}),t.jsx("div",{className:"footer-divider"}),t.jsx("button",{className:"footer-action-btn",onClick:Rt,title:"Volume Up","aria-label":"Volume up",children:t.jsx(Lr,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:Et,title:"Volume Down","aria-label":"Volume down",children:t.jsx(Tr,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:$t,title:"Lock Device","aria-label":"Lock device",children:t.jsx(xi,{size:18})}),t.jsx("button",{className:"footer-action-btn",onClick:pt,title:"Unlock Device","aria-label":"Unlock device",children:t.jsx(nr,{size:18})})]})]}),t.jsxs("div",{className:"device-interactions-column",children:[t.jsxs("div",{className:"interaction-tabs",role:"tablist",children:[t.jsxs("button",{className:`tab-btn ${f==="actions"?"active":""}`,onClick:()=>b("actions"),role:"tab","aria-selected":f==="actions",children:[t.jsx(xs,{size:13}),t.jsx("span",{children:"Actions"})]}),t.jsxs("button",{className:`tab-btn ${f==="screenshot"?"active":""}`,onClick:()=>b("screenshot"),role:"tab","aria-selected":f==="screenshot",children:[t.jsx(cs,{size:13}),t.jsx("span",{children:"Screenshot"})]}),t.jsxs("button",{className:`tab-btn ${f==="logs"?"active":""}`,onClick:()=>b("logs"),role:"tab","aria-selected":f==="logs",children:[t.jsx(br,{size:13}),t.jsx("span",{children:"Logs"})]}),t.jsxs("button",{className:`tab-btn ${f==="terminal"?"active":""}`,onClick:()=>b("terminal"),role:"tab","aria-selected":f==="terminal",children:[t.jsx(bn,{size:13}),t.jsx("span",{children:"Shell"})]}),t.jsxs("button",{className:`tab-btn ${f==="omni"?"active":""}`,onClick:()=>b("omni"),role:"tab","aria-selected":f==="omni",children:[t.jsx(ys,{size:13}),t.jsx("span",{children:"Omni-Vision"})]})]}),t.jsx("div",{className:`interactions-scroll-area ${f==="terminal"?"terminal-mode":""} ${f==="screenshot"||f==="logs"?"screenshot-mode":""}`,children:t.jsxs("div",{className:"tab-content",children:[f==="omni"&&t.jsx("div",{className:"omni-inspector-tab-wrapper animate-fade-in",children:t.jsx(Nc,{sessionId:p.session_id?String(p.session_id):null,udid:p.udid,streamUrl:ut(),embedded:!0,overlayTarget:x,onModeChange:m})}),f==="actions"&&t.jsxs("div",{className:"actions-grid",children:[t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(fi,{size:18,color:"var(--green)"})," Smart Input"]}),t.jsx("p",{className:"action-card-hint",children:"Relay keystrokes to the focused element on the device."}),t.jsx("input",{type:"text",className:"type-input-field compact",placeholder:"Type and press Enter to send…",value:v,onChange:y=>k(y.target.value),onKeyDown:y=>y.key==="Enter"&&Dt()})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ui,{size:18,color:"var(--green)"})," App Management"]}),t.jsxs("div",{className:"app-mgmt-content",children:[t.jsxs("div",{className:"install-section",children:[t.jsx("p",{className:"compact-label",children:"Install Package"}),t.jsxs("div",{className:"upload-box-row",children:[t.jsxs("label",{className:"file-upload-launcher",title:Y?Y.name:"Select an .apk, .ipa or .app file",children:[t.jsx(mi,{size:14}),t.jsx("span",{children:Y?Y.name:"Select File"}),t.jsx("input",{type:"file",accept:".apk,.ipa,.app",onChange:y=>{var S;return P(((S=y.target.files)==null?void 0:S[0])||null)},hidden:!0})]}),t.jsx("button",{className:"btn-premium btn-sm",disabled:!Y||ve,onClick:A,children:ve?t.jsx(is,{className:"animate-spin",size:14}):"INSTALL"})]}),t.jsx("p",{className:"hint-text",children:"Accepts .apk, .ipa or .app"})]}),t.jsx("div",{className:"divider-v"}),t.jsxs("div",{className:"uninstall-section",children:[t.jsx("p",{className:"compact-label",children:"Quick Uninstall"}),t.jsxs("div",{className:"uninstall-controls-row",children:[t.jsxs("div",{className:"select-wrapper",children:[t.jsxs(Jt,{selectSize:"sm",className:"w-full",value:j,onChange:y=>D(y.target.value),disabled:ye,children:[t.jsx("option",{value:"",children:ye?"Loading apps...":"-- Select App to Remove --"}),ie.map(y=>t.jsx("option",{value:y,children:y},y))]}),ye&&t.jsx(is,{className:"animate-spin select-loader",size:12})]}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:h,disabled:!j||ye,children:[t.jsx(Ht,{size:14})," UNINSTALL"]})]}),t.jsxs("div",{className:"manual-input-box",children:[t.jsx("p",{className:"hint-text",children:"Or enter manually:"}),t.jsx("input",{type:"text",className:"type-input-field tiny",placeholder:"com.example.app",value:j,onChange:y=>D(y.target.value)})]})]})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(Wi,{size:18,color:"var(--green)"})," Clipboard"]}),t.jsxs("div",{className:"clipboard-row",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:Tt,children:"FETCH VALUE"}),t.jsx("div",{className:"clipboard-display compact",children:C})]})]}),t.jsxs("div",{className:"action-card full-width",children:[t.jsxs("h4",{className:"action-card-title",children:[t.jsx(ur,{size:18,color:"var(--green)"})," Directional Gestures"]}),t.jsxs("div",{className:"gestures-grid-container",children:[t.jsxs("div",{className:"gestures-dpad",children:[t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("up"),children:t.jsx(Pi,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("left"),children:t.jsx(os,{size:24})}),t.jsx("div",{className:"dpad-center"}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("right"),children:t.jsx(wn,{size:24})}),t.jsx("div",{}),t.jsx("button",{className:"dpad-btn",onClick:()=>We("down"),children:t.jsx(pn,{size:24})}),t.jsx("div",{})]}),t.jsx("p",{className:"compact-label dpad-caption",children:"Quick swipe in a direction"})]})]})]}),f==="screenshot"&&t.jsxs("div",{className:"action-card screenshot-card",children:[$.length>0&&t.jsx("header",{className:"action-card-header",children:t.jsx("button",{className:"btn-text-only",onClick:Lt,children:"CLEAR ALL"})}),t.jsxs("div",{className:`screenshot-workspace ${$.length===0?"is-empty":""}`,children:[t.jsxs("div",{className:"screenshot-gallery-sidebar",children:[t.jsxs("button",{className:"btn-premium take-screenshot-btn",onClick:Mt,disabled:z,children:[z?t.jsx(is,{className:"animate-spin",size:16}):t.jsx(cs,{size:16}),t.jsx("span",{children:z?"CAPTURING...":"NEW CAPTURE"})]}),t.jsxs("div",{className:"screenshot-thumbnails-list",children:[$.length===0&&!z&&t.jsxs("div",{className:"empty-gallery-state",children:[t.jsx(cs,{size:20,className:"empty-gallery-icon"}),t.jsx("p",{className:"empty-gallery-title",children:"No captures yet"}),t.jsx("p",{className:"empty-gallery-hint",children:"Grab a screenshot of the device to begin analysis."})]}),$.map((y,S)=>t.jsxs("div",{className:`screenshot-thumb-item ${T===S?"active":""}`,onClick:()=>O(S),children:[t.jsx("img",{src:`data:image/png;base64,${y.base64}`,alt:"Thumb"}),t.jsx("span",{className:"thumb-time",children:new Date(y.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),t.jsx("button",{className:"thumb-delete-btn",onClick:E=>{E.stopPropagation(),gt(y.id)},children:t.jsx(Ht,{size:12})})]},y.id))]})]}),t.jsx("div",{className:"screenshot-main-preview",children:T!==null&&$[T]?t.jsxs("div",{className:"preview-container",children:[t.jsx("div",{className:"preview-image-wrapper",children:t.jsx("img",{src:`data:image/png;base64,${$[T].base64}`,alt:"Selected Evidence"})}),t.jsxs("footer",{className:"preview-footer",children:[t.jsxs("div",{className:"preview-meta",children:[t.jsx("span",{className:"meta-label",children:"ID:"}),t.jsx("span",{className:"meta-value",children:$[T].id.substring(0,8)}),t.jsx("span",{className:"meta-divider",children:"|"}),t.jsx("span",{className:"meta-value",children:hi($[T].timestamp)})]}),t.jsxs("div",{className:"preview-actions",children:[t.jsx("button",{className:"btn-premium btn-sm",onClick:()=>It($[T].base64),children:"DOWNLOAD PNG"}),t.jsxs("button",{className:"btn-destructive btn-sm",onClick:()=>gt($[T].id),children:[t.jsx(Ht,{size:14})," DELETE"]})]})]})]}):null})]})]}),f==="logs"&&t.jsx("div",{className:"action-card screenshot-card",children:t.jsx(Hc,{udid:p.udid,platform:p.platform})}),f==="terminal"&&t.jsx("div",{className:"action-card full-height",children:t.jsx(hc,{platform:(p.platform||"").toLowerCase(),prompt:`${(p.platform||"").toLowerCase()==="ios"?"ios":"adb"} $`,welcomeMessage:`Connected to ${p.name} (${p.udid}).
255
255
  Internal Shell Environment.`,onCommand:async y=>{const S=await B.executeShell(p.udid,y);if(S.error)throw new Error(S.error);return S.output}})})]})})]})]}),p.session_id&&!String(p.session_id).startsWith("manual_")&&t.jsx(ii,{sessionId:String(p.session_id),mode:"slice",windowSec:60,variant:"floating"})]})}class Vc extends je.Component{constructor(s){super(s),this.socketCleanups=[],this.refreshTimeout=null,this.state={devices:[],activeSessionsCount:0,pendingSessionsCount:0,queueSummary:null,statusFilter:"all",search:"",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)}componentWillUnmount(){this.devicePolling&&(clearInterval(this.devicePolling),this.devicePolling=void 0),this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),this.socketCleanups.forEach(s=>s())}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 B.getDevices(),n=this.getBusyDevicesCount(s),i=await B.getPendingSessionsCount(),r=await B.getQueueSummary();this.setState({devices:s,activeSessionsCount:n,pendingSessionsCount:i,queueSummary:r,loaded:!0})}catch(s){console.log(s),this.setState({loaded:!0})}}getFiltered(){const s=Date.now(),n=r=>!!(r.reservedUntil&&s<r.reservedUntil),i=this.state.search.trim().toLowerCase();return this.state.devices.filter(r=>{if(i&&!`${r.name} ${r.udid}`.toLowerCase().includes(i))return!1;switch(this.state.statusFilter){case"all":return!0;case"offline":return r.offline;case"busy":return r.busy&&!r.offline;case"reserved":return n(r)&&!r.busy&&!r.offline;case"ready":return!r.offline&&!r.busy&&!n(r)&&!r.userBlocked;default:return!0}})}statusCount(s){const n=Date.now(),i=r=>!!(r.reservedUntil&&n<r.reservedUntil);switch(s){case"all":return this.state.devices.length;case"offline":return this.state.devices.filter(r=>r.offline).length;case"busy":return this.state.devices.filter(r=>r.busy&&!r.offline).length;case"reserved":return this.state.devices.filter(r=>i(r)&&!r.busy&&!r.offline).length;case"ready":return this.state.devices.filter(r=>!r.offline&&!r.busy&&!i(r)&&!r.userBlocked).length}}render(){const s=this.getFiltered(),{udid:n}=this.props.params,i=n?this.state.devices.find(r=>r.udid===n):null;return t.jsxs("div",{className:"device-explorer-container",children:[t.jsxs("div",{className:"de2-sticky-group",children:[t.jsx(ni,{icon:Ps,title:"Devices",subtitle:`${this.state.devices.length} device${this.state.devices.length===1?"":"s"} registered across the global pool.`}),t.jsxs("div",{className:"de2-toolbar",children:[t.jsx(yi,{size:"sm",value:this.state.statusFilter,onChange:r=>this.setState({statusFilter:r}),segments:[{value:"all",label:"All",count:this.statusCount("all")},{value:"ready",label:"Ready",count:this.statusCount("ready")},{value:"busy",label:"Busy",count:this.statusCount("busy")},{value:"reserved",label:"Reserved",count:this.statusCount("reserved")},{value:"offline",label:"Offline",count:this.statusCount("offline")}]}),t.jsx("input",{type:"text",className:"de2-search",placeholder:"Search by name or UDID…",value:this.state.search,onChange:r=>this.setState({search:r.target.value})}),t.jsxs(st,{variant:"secondary",size:"sm",onClick:()=>this.fetchDevices(),children:[t.jsx(rs,{size:12})," Refresh"]})]})]}),s.length>0?t.jsx(oc,{devices:s,reloadDevices:()=>this.fetchDevices()}):t.jsxs("div",{className:"device-explorer-empty stagger-1",children:[t.jsx("div",{className:"device-explorer-empty-icon",children:this.state.loaded?t.jsx(Ps,{size:32}):t.jsx(rs,{size:32,className:"animate-spin"})}),this.state.loaded?this.state.devices.length===0?t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Global Device Registry Empty"}),t.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."}),t.jsxs(st,{variant:"primary",onClick:()=>this.fetchDevices(),children:[t.jsx(rs,{size:14}),"Manual Sync"]})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"No Devices Found"}),t.jsx("p",{children:"Deployment configuration mismatch. Adjust your platform or state filters to find the appropriate testing target."}),t.jsx(st,{variant:"secondary",onClick:()=>this.setState({statusFilter:"all",search:""}),children:"Reset filters"})]}):t.jsxs(t.Fragment,{children:[t.jsx("h3",{children:"Loading devices…"}),t.jsx("p",{children:"Syncing the global device registry."})]})]}),i&&t.jsx("div",{className:"device-control-modal-overlay",children:t.jsx("div",{className:"device-control-modal",children:t.jsx(Wc,{device:i,onClose:()=>this.props.navigate("/devices")})})})]})}}function yl(){const e=gn(),s=ks(),{on:n}=vi();return t.jsx(Vc,{params:e,navigate:s,onSocketEvent:n})}export{Vc as DeviceExplorer,yl as default};