@xenon-device-management/xenon 2.9.2 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{AnnotationOverlay-B87n4pUu.js → AnnotationOverlay-LzfXiiZJ.js} +1 -1
  3. package/lib/public/assets/{ApiKeyGate-CNZJH6Cs.js → ApiKeyGate-BzFDp4mK.js} +1 -1
  4. package/lib/public/assets/{BugReportButton-DQ-R87ZV.js → BugReportButton-BpgWvmZo.js} +1 -1
  5. package/lib/public/assets/{DeviceMosaicView-dX3e7O-w.js → DeviceMosaicView-CCB-egSH.js} +2 -2
  6. package/lib/public/assets/{EmptyState-D3fG2GHY.js → EmptyState-DkUVmANo.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-CUmbJZxI.js → FieldGroup-mbfnfTql.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-Dm2c-UCk.js → FilterMenu-BH5usz4Y.js} +1 -1
  9. package/lib/public/assets/{Menu-Dl4uXMkH.js → Menu-Cbo9mdTk.js} +1 -1
  10. package/lib/public/assets/{Modal-DNmn2RDs.js → Modal-D6XfQHPr.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-Dn3By34o.js → RecordingPage-CmFPkWqH.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-lCUIM4pm.js → RecordingsPage-CSlKk2qC.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-BdA_mHiZ.js → SegmentedControl-BFW9Dlqd.js} +1 -1
  14. package/lib/public/assets/{SettingCard-Dx3WhK7w.js → SettingCard-C4DioTTi.js} +1 -1
  15. package/lib/public/assets/{Table-D_2lhvRM.js → Table-DrKjlL00.js} +1 -1
  16. package/lib/public/assets/{activity-cNHHOKx5.js → activity-C9bE7Jm8.js} +1 -1
  17. package/lib/public/assets/{ai-settings-t6RMrDkg.js → ai-settings-DRYic4oO.js} +1 -1
  18. package/lib/public/assets/{api-keys-CK_qyQvW.js → api-keys-CaQU0g7c.js} +1 -1
  19. package/lib/public/assets/{apps-DCiI3UOb.js → apps-c1gUFmmK.js} +1 -1
  20. package/lib/public/assets/{arrow-left-CnYs8HVw.js → arrow-left-DMvAWA8r.js} +1 -1
  21. package/lib/public/assets/{arrow-right-Cc9qm6UG.js → arrow-right-BEQgxmKT.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-e7yBOb-c.js → arrow-up-right-Ba0e2GeU.js} +1 -1
  23. package/lib/public/assets/{auth-shell-DKrtcIjG.js → auth-shell-COODQnc7.js} +2 -2
  24. package/lib/public/assets/{builds-page-CRd5oEz6.js → builds-page-DZQgWBUs.js} +4 -4
  25. package/lib/public/assets/{button-C0caCjJB.js → button-WW9j43wR.js} +1 -1
  26. package/lib/public/assets/{calendar-BqOOkln_.js → calendar-COUs9VxF.js} +1 -1
  27. package/lib/public/assets/{check-DYSXRG79.js → check-D8ifHIJR.js} +1 -1
  28. package/lib/public/assets/{chevron-right-hCNu0CA-.js → chevron-right-BjKVUlB_.js} +1 -1
  29. package/lib/public/assets/{circle-check-DnQ263fa.js → circle-check-CfP79QE2.js} +1 -1
  30. package/lib/public/assets/{circle-x-BaRKZyz9.js → circle-x-BZbFCixZ.js} +1 -1
  31. package/lib/public/assets/{clock-XP3iBAhg.js → clock-BuTm35Qg.js} +1 -1
  32. package/lib/public/assets/{copy-D8d9UzWE.js → copy-W00zUBwN.js} +1 -1
  33. package/lib/public/assets/{device-explorer-pdM3L9TC.js → device-explorer-BEpS-Y-_.js} +5 -5
  34. package/lib/public/assets/{download-SaN9-umX.js → download-CGz-MS3y.js} +1 -1
  35. package/lib/public/assets/{forgot-password-DfUhEZW5.js → forgot-password-DG7SqVgU.js} +1 -1
  36. package/lib/public/assets/{index-C8pvxG1f.css → index-DQa193-A.css} +1 -1
  37. package/lib/public/assets/{index-IefGCFQQ.js → index-DWHTp1YP.js} +1 -1
  38. package/lib/public/assets/{index-CzaIyL9t.js → index-EkaQM1DK.js} +2 -2
  39. package/lib/public/assets/{input-BqFzAQT3.js → input-ChaTXeCq.js} +1 -1
  40. package/lib/public/assets/{keycodes-DDV2OlpQ.js → keycodes-BhbgeW_r.js} +10 -5
  41. package/lib/public/assets/line-chart-9P3RxScy.js +1 -0
  42. package/lib/public/assets/list-checks-_23IIEEL.js +11 -0
  43. package/lib/public/assets/{lock-Eye1CG8p.js → lock-B2JaqqRI.js} +1 -1
  44. package/lib/public/assets/{login-Co1IXuen.js → login-BEWIfLfC.js} +1 -1
  45. package/lib/public/assets/{maintenance-settings-D1fw6iqm.js → maintenance-settings-BGJIJQ-k.js} +1 -1
  46. package/lib/public/assets/{monitor-U5Y-PxW5.js → monitor-BrwMY4G0.js} +1 -1
  47. package/lib/public/assets/{mouse-pointer-2-CDAwphUm.js → mouse-pointer-2-DsWDMyrY.js} +1 -1
  48. package/lib/public/assets/{network-BP_U4iDZ.js → network-DfIhNVJv.js} +1 -1
  49. package/lib/public/assets/overview-B1mePY2_.js +6 -0
  50. package/lib/public/assets/{page-header-ZdzNEJp9.js → page-header-DoD3TOzZ.js} +1 -1
  51. package/lib/public/assets/{plus-1k0sxXyU.js → plus-BGvWvpBB.js} +1 -1
  52. package/lib/public/assets/{profile-page-B_GWKRy3.js → profile-page-CvV5aWvl.js} +1 -1
  53. package/lib/public/assets/{reset-password-DizCTkdw.js → reset-password-CGVd31LR.js} +1 -1
  54. package/lib/public/assets/{runbook-page-DWzRiOLZ.js → runbook-page-Bq2cvwb5.js} +1 -1
  55. package/lib/public/assets/{select-CiRW6v17.js → select-CTcD4jWR.js} +1 -1
  56. package/lib/public/assets/selector-detail-redirect-19odlD4B.js +1 -0
  57. package/lib/public/assets/selector-health-page-LqIsLrjW.js +11 -0
  58. package/lib/public/assets/session-detail-page-DQzb8_fq.js +4 -0
  59. package/lib/public/assets/{settings-DhwZoWv7.js → settings-C-EnGIqs.js} +1 -1
  60. package/lib/public/assets/stat-tile-BY0RDTRm.js +1 -0
  61. package/lib/public/assets/{tablet-CPJV3dBq.js → tablet-B4cFM-5B.js} +1 -1
  62. package/lib/public/assets/{teams-D0IBa2Ov.js → teams-BFe-RpYd.js} +1 -1
  63. package/lib/public/assets/time-D-gjmE1o.js +1 -0
  64. package/lib/public/assets/{trash-2-u8MlXUBD.js → trash-2-CJCKBOP9.js} +1 -1
  65. package/lib/public/assets/{upload-Cq8L3kpw.js → upload-DidWkbld.js} +1 -1
  66. package/lib/public/assets/use-builds-data-fnfxatOd.js +8 -0
  67. package/lib/public/assets/{use-password-reset-mode-Dbr2HEfw.js → use-password-reset-mode-iPen3tmC.js} +1 -1
  68. package/lib/public/assets/{users-CZqCE511.js → users-CrcjmRdf.js} +1 -1
  69. package/lib/public/assets/{users-DxLHYmFm.js → users-DBUv0CJx.js} +1 -1
  70. package/lib/public/assets/{video-off-mh1EEzP9.js → video-off-eh69-FKB.js} +1 -1
  71. package/lib/public/assets/view-state-CP9dE1UI.js +1 -0
  72. package/lib/public/assets/{webhook-settings-BYuOib-Q.js → webhook-settings-CQoSshBn.js} +1 -1
  73. package/lib/public/assets/{zap-BOpUur0M.js → zap-CICtWiLn.js} +1 -1
  74. package/lib/public/index.html +2 -2
  75. package/lib/schema.json +5 -0
  76. package/lib/src/app/routers/dashboard.js +86 -40
  77. package/lib/src/app/routers/selector-health.js +75 -0
  78. package/lib/src/app/swagger-docs.js +77 -8
  79. package/lib/src/dashboard/event-manager.js +15 -99
  80. package/lib/src/generated/client/edge.js +27 -3
  81. package/lib/src/generated/client/index-browser.js +24 -0
  82. package/lib/src/generated/client/index.d.ts +8207 -5283
  83. package/lib/src/generated/client/index.js +27 -3
  84. package/lib/src/generated/client/package.json +1 -1
  85. package/lib/src/generated/client/schema.prisma +43 -9
  86. package/lib/src/generated/client/wasm.js +24 -0
  87. package/lib/src/prisma.js +2 -0
  88. package/lib/src/services/CleanupService.js +1 -0
  89. package/lib/src/services/NotificationService.js +3 -4
  90. package/lib/src/services/SelectorStateService.js +151 -113
  91. package/lib/src/services/SelectorVerificationJob.js +14 -9
  92. package/lib/src/services/metrics/AndroidMetricsSampler.js +94 -0
  93. package/lib/src/services/metrics/IOSMetricsSampler.js +120 -0
  94. package/lib/src/services/metrics/SessionMetricsService.js +238 -0
  95. package/lib/src/services/metrics/androidMetrics.js +94 -0
  96. package/lib/src/services/metrics/iosMetrics.js +26 -0
  97. package/lib/src/services/metrics/metricsBody.js +37 -0
  98. package/lib/src/services/metrics/types.js +19 -0
  99. package/lib/src/services/selector-health/access.js +66 -0
  100. package/lib/src/services/selector-health/healingTrend.js +49 -0
  101. package/lib/src/services/selector-health/people.js +27 -0
  102. package/lib/src/services/selector-health/selectorDetail.js +198 -0
  103. package/lib/src/services/selector-health/selectorKeys.js +36 -0
  104. package/lib/src/services/selector-health/selectorList.js +333 -0
  105. package/lib/src/services/selector-health/stateView.js +67 -0
  106. package/lib/test/helpers/scratch-database.js +2 -0
  107. package/lib/test/helpers/selector-health-fixture.js +216 -0
  108. package/lib/test/integration/team-visibility-sessions.spec.js +1 -0
  109. package/lib/test/unit/CleanupService.spec.js +28 -2
  110. package/lib/test/unit/dashboard-events-metrics.spec.js +146 -0
  111. package/lib/test/unit/healing-no-cost.spec.js +134 -0
  112. package/lib/test/unit/healing-state-endpoints.spec.js +70 -0
  113. package/lib/test/unit/healing-trend.spec.js +118 -0
  114. package/lib/test/unit/selector-event-model.spec.js +47 -0
  115. package/lib/test/unit/selector-health-actions.spec.js +106 -0
  116. package/lib/test/unit/selector-health-detail.spec.js +131 -0
  117. package/lib/test/unit/selector-health-list.spec.js +185 -0
  118. package/lib/test/unit/selector-state-service.spec.js +74 -1
  119. package/lib/test/unit/selector-verification-job.spec.js +38 -0
  120. package/lib/test/unit/session-metrics-parse.spec.js +138 -0
  121. package/lib/test/unit/session-metrics-route.spec.js +140 -0
  122. package/lib/test/unit/session-metrics-samplers.spec.js +248 -0
  123. package/lib/test/unit/session-metrics-service.spec.js +215 -0
  124. package/lib/tsconfig.tsbuildinfo +1 -1
  125. package/package.json +1 -1
  126. package/prisma/migrations/20261002120000_session_metric/migration.sql +17 -0
  127. package/prisma/migrations/20261002130000_selector_event/migration.sql +13 -0
  128. package/prisma/schema.prisma +43 -9
  129. package/schema.json +5 -0
  130. package/lib/public/assets/chevron-left-BSG6mcpo.js +0 -6
  131. package/lib/public/assets/funnel-OefHE-54.js +0 -6
  132. package/lib/public/assets/layers-a3GNz2DA.js +0 -6
  133. package/lib/public/assets/list-checks-DMrMAFDt.js +0 -6
  134. package/lib/public/assets/overview-CsPyPv10.js +0 -1
  135. package/lib/public/assets/selector-detail-page-pA913STP.js +0 -1
  136. package/lib/public/assets/selector-health-BlICzZlk.css +0 -1
  137. package/lib/public/assets/selector-health-CHLX8KqY.js +0 -16
  138. package/lib/public/assets/selector-health-page-vVkg8Mii.js +0 -16
  139. package/lib/public/assets/session-detail-page-BCD49zDi.js +0 -4
  140. package/lib/public/assets/stat-tile-BaE76cnK.js +0 -8
  141. package/lib/public/assets/time-B8FIgwPE.js +0 -1
  142. package/lib/src/profiling/AndroidAppProfiler.js +0 -213
  143. /package/lib/public/assets/{session-detail-page-Bzzc3bMl.css → line-chart-Bzzc3bMl.css} +0 -0
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-CzaIyL9t.js";/**
1
+ import{c as e}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-CzaIyL9t.js";/**
1
+ import{c as e}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-CzaIyL9t.js";/**
1
+ import{c as e}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,6 @@
1
+ import{c as y,r as h,p as E,X as p,j as e,u as R,T as H,q as L,s as M}from"./index-EkaQM1DK.js";import{p as T}from"./labels-C21SA4JG.js";import{A as O}from"./arrow-right-BEQgxmKT.js";import{T as B}from"./tablet-B4cFM-5B.js";import{M as P}from"./monitor-BrwMY4G0.js";import{A as U}from"./activity-C9bE7Jm8.js";import{P as X}from"./page-header-DoD3TOzZ.js";/**
2
+ * @license lucide-react v0.555.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const z=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],G=y("funnel",z),k=20;function K(s){return s.deviceName||(s.deviceUdid?s.deviceUdid.slice(0,8):"device")}function C(s){const n=s.commandName||"selector",i=K(s);return s.tier?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:s.tier})," healed ",e.jsx("strong",{children:n})," on ",e.jsx("strong",{children:i})]}):e.jsxs(e.Fragment,{children:["Healed ",e.jsx("strong",{children:n})," on ",e.jsx("strong",{children:i})]})}function Q(){const[s,n]=h.useState([]),[i,x]=h.useState([]),[u,g]=h.useState(0),[a,j]=h.useState([]),{on:m}=E(),I=h.useRef(0);h.useEffect(()=>{let o=!1;const f=()=>{p.getDevices().then(c=>{!o&&Array.isArray(c)&&n(c)}).catch(()=>{})};f();const w=setInterval(f,3e4);return p.getSessions().then(c=>{!o&&Array.isArray(c)&&x(c)}).catch(()=>{}),p.getPendingSessionsCount().then(c=>{if(o)return;const b=typeof c=="number"?c:typeof(c==null?void 0:c.count)=="number"?c.count:0;g(b)}).catch(()=>{}),p.getRecentHealingEvents().then(c=>{if(o||!c)return;const b=Array.isArray(c.events)?c.events:[];b.length!==0&&j(N=>{const S=new Set(N.map(r=>r.id));return[...b.filter(r=>!S.has(r.id)).map(r=>({id:r.id,ts:Date.parse(r.createdAt)||Date.now(),kind:"heal",message:C(r)})),...N].sort((r,l)=>l.ts-r.ts).slice(0,k)})}).catch(()=>{}),()=>{o=!0,clearInterval(w)}},[]),h.useEffect(()=>{const o=[],f=(t,r)=>{I.current+=1;const l={id:`${Date.now()}-${I.current}`,ts:Date.now(),kind:t,message:r};j(d=>[l,...d].slice(0,k))},w=t=>{var d;t&&t.session&&x(v=>v.find($=>$.id===t.session.id)?v:[t.session,...v]);const r=((d=t==null?void 0:t.session)==null?void 0:d.id)||(t==null?void 0:t.sessionId)||"",l=r?r.slice(0,6):"";f("session",e.jsxs(e.Fragment,{children:["Session ",e.jsx("strong",{children:l||"—"})," started"]}))},c=t=>{var v,A;const r=((v=t==null?void 0:t.session)==null?void 0:v.id)||(t==null?void 0:t.sessionId)||"",l=!!((A=t==null?void 0:t.session)!=null&&A.failure_reason||t!=null&&t.failure_reason);r&&x($=>$.map(D=>D.id===r?{...D,status:l?"failed":"finished"}:D));const d=r?r.slice(0,6):"";f(l?"session-failed":"session-end",l?e.jsxs(e.Fragment,{children:["Session ",e.jsx("strong",{children:d||"—"})," failed"]}):e.jsxs(e.Fragment,{children:["Session ",e.jsx("strong",{children:d||"—"})," ended"]}))},b=t=>{const r=(t==null?void 0:t.nodeId)||(t==null?void 0:t.id)||"node";f("node",e.jsxs(e.Fragment,{children:["Node ",e.jsx("strong",{children:String(r)})," connected"]}))},N=t=>{const r=(t==null?void 0:t.nodeId)||(t==null?void 0:t.id)||"node";f("node",e.jsxs(e.Fragment,{children:["Node ",e.jsx("strong",{children:String(r)})," disconnected"]}))},S=t=>{const r=t;if(!r||!r.id)return;const l={id:r.id,ts:Date.parse(r.createdAt)||Date.now(),kind:"heal",message:C(r)};j(d=>d.some(v=>v.id===l.id)?d:[l,...d].slice(0,k))};return o.push(m("session_started",w)),o.push(m("session_stopped",c)),o.push(m("node_connected",b)),o.push(m("node_disconnected",N)),o.push(m("healing_event",S)),()=>{o.forEach(t=>t&&t())}},[m]);const q=i.filter(o=>o.status==="running");return{devices:s,activeSessions:q,queuedSessions:u,activity:a}}const V={healthy:"bg-[var(--color-success)]",neutral:"bg-[var(--border-strong)]",warn:"bg-[var(--amber)]",critical:"bg-[var(--red)]"},Y={healthy:"bg-[var(--color-success)]",neutral:"bg-[var(--text-dim)]",warn:"bg-[var(--amber)]",critical:"bg-[var(--red)]"},J={healthy:"text-[var(--color-success)]",neutral:"text-[var(--text-muted)]",warn:"text-[var(--amber)]",critical:"text-[var(--red)]"},F=({label:s,value:n,secondaryValue:i,subtitle:x,state:u="neutral"})=>e.jsxs("div",{className:"relative overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--surface)] p-4 hover:border-[var(--border-strong)] transition-colors",children:[e.jsx("span",{className:`absolute left-0 top-0 bottom-0 w-[2px] ${V[u]}`}),e.jsx("div",{className:"text-[11px] font-semibold text-[var(--text-muted)]",children:s}),e.jsxs("div",{className:"mt-3 flex items-baseline gap-2",children:[e.jsx("span",{className:"text-3xl font-semibold text-[var(--text)] tabular-nums",children:n}),i!=null&&e.jsxs("span",{className:"text-sm font-mono text-[var(--text-dim)]",children:["/ ",i]})]}),e.jsxs("div",{className:`mt-3 flex items-center gap-1.5 text-xs ${J[u]}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${Y[u]}`}),e.jsx("span",{children:x})]})]});function _(s){return s.offline?"offline":s.reservedBy?"reserved":s.busy?"busy":"ready"}function W(s){const n=(s.platform||"").toLowerCase();return n==="tvos"?H:/pad|tablet/i.test(s.name||"")?B:n==="ios"||n==="android"?L:P}const Z={ready:{dot:"bg-[var(--color-success)]",text:"text-[var(--color-success)]",label:"Ready"},busy:{dot:"bg-[var(--amber)]",text:"text-[var(--amber)]",label:"Busy"},reserved:{dot:"bg-[var(--blue)]",text:"text-[var(--blue)]",label:"Reserved"},offline:{dot:"bg-[var(--text-dim)]",text:"text-[var(--text-dim)]",label:"Offline"}};function ee(s){return s?s.length<=16?s:`${s.slice(0,8)}…${s.slice(-4)}`:""}const te=({devices:s,maxRows:n=6})=>{const[i,x]=h.useState("all"),u=R(),g=(i==="all"?s:s.filter(a=>_(a)!=="ready")).slice(0,n);return e.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] flex flex-col",children:[e.jsxs("header",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Fleet status"}),e.jsxs("span",{className:"text-xs font-mono text-[var(--text-dim)]",children:[s.length," devices"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{role:"group","aria-label":"Filter devices",className:"flex items-center gap-0.5 bg-[var(--surface-2)] border border-[var(--border)] rounded-md p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>x("all"),"aria-pressed":i==="all",className:`px-2 py-1 text-[11px] rounded transition-colors ${i==="all"?"bg-[var(--border-strong)] text-[var(--text)]":"text-[var(--text-dim)] hover:text-[var(--text)]"}`,children:"All"}),e.jsxs("button",{type:"button",onClick:()=>x("issues"),"aria-pressed":i==="issues",className:`px-2 py-1 text-[11px] rounded transition-colors flex items-center gap-1 ${i==="issues"?"bg-[var(--border-strong)] text-[var(--text)]":"text-[var(--text-dim)] hover:text-[var(--text)]"}`,children:[e.jsx(G,{className:"h-3 w-3"}),"Non-ready"]})]}),e.jsxs("button",{type:"button",onClick:()=>u("/devices"),className:"ml-1 inline-flex items-center gap-1 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:["View all ",e.jsx(O,{className:"h-3 w-3"})]})]})]}),e.jsx("div",{className:"divide-y divide-[var(--border)]",children:g.length===0?e.jsx("div",{className:"px-4 py-8 text-center text-xs text-[var(--text-dim)]",children:i==="issues"?"All devices are ready.":"No devices registered."}):g.map(a=>{const j=W(a),m=Z[_(a)];return e.jsxs("button",{type:"button",onClick:()=>a.udid&&u(`/devices/${a.udid}/control/screen`),className:"w-full flex items-center gap-3 px-4 py-2.5 hover:bg-[var(--surface-2)] transition-colors text-left",children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${m.dot}`}),e.jsx(j,{className:"h-4 w-4 text-[var(--text-dim)] shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-3",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"text-xs text-[var(--text)] truncate",children:a.name||a.udid})}),e.jsxs("div",{className:"hidden md:block text-[11px] font-mono text-[var(--text-dim)] w-24 text-right",children:[T(a.platform)," ",a.sdk||""]}),e.jsx("div",{className:"hidden lg:block text-[11px] font-mono text-[var(--text-dim)] w-32 text-right",children:ee(a.udid)})]}),e.jsx("span",{className:`font-mono text-[10px] font-semibold tracking-wider w-20 text-right ${m.text}`,children:m.label})]},a.udid||a.name)})})]})},se={session:"bg-[var(--color-accent)]","session-end":"bg-[var(--text-dim)]","session-failed":"bg-[var(--red)]",node:"bg-[var(--blue)]",heal:"bg-[var(--amber)]"};function re(s){const n=new Date(s);return`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}const ne=({events:s,live:n=!0})=>e.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] flex flex-col",children:[e.jsx("header",{className:"flex items-center justify-between px-4 py-3 border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Recent activity"}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-[var(--text-dim)]",children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n?"bg-[var(--color-success)] pulse-dot":"bg-[var(--text-dim)]"}`}),n?"Live":"Offline"]})]})}),s.length===0?e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 py-10 text-center gap-2",children:[e.jsx("div",{className:"h-10 w-10 rounded-full bg-[var(--surface-2)] border border-[var(--border)] flex items-center justify-center",children:e.jsx(U,{className:"h-5 w-5 text-[var(--text-dim)]"})}),e.jsx("div",{className:"text-sm font-medium text-[var(--text)]",children:"No activity yet"}),e.jsx("div",{className:"text-xs text-[var(--text-dim)] max-w-xs",children:"Session and heal events will appear here as they happen."})]}):e.jsx("div",{className:"flex-1 overflow-y-auto divide-y divide-[var(--border)]",children:s.map(i=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx("span",{className:"font-mono text-[10px] text-[var(--text-dim)] w-10 shrink-0",children:re(i.ts)}),e.jsx("span",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${se[i.kind]}`}),e.jsx("span",{className:"text-xs text-[var(--text-muted)] truncate",children:i.message})]},i.id))})]}),ie="—",me=()=>{const s=Q(),n=s.devices.length,i=s.devices.filter(g=>!g.offline).length,x=n===0?"neutral":i===n?"healthy":"warn",u=s.activeSessions.length>0?"healthy":s.queuedSessions>0?"warn":"neutral";return e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",children:[e.jsx(X,{icon:M,title:"Overview",subtitle:"Devices, sessions and healing activity across your lab."}),e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-6",children:[e.jsx(F,{label:"Devices online",value:n===0?ie:i,secondaryValue:n===0?void 0:n,subtitle:n===0?"No devices registered":`${i} of ${n} online`,state:x}),e.jsx(F,{label:"Active sessions",value:s.activeSessions.length,subtitle:s.queuedSessions>0?`${s.queuedSessions} queued`:"No queue",state:u})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:[e.jsx(te,{devices:s.devices}),e.jsx(ne,{events:s.activity,live:!0})]})]})]})};export{me as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-CzaIyL9t.js";const i=({icon:s,children:t})=>e.jsxs("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight text-[var(--text)]",children:[s&&e.jsx(s,{className:"h-5 w-5 text-[var(--color-accent)] shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:t})]}),l=({icon:s,eyebrow:t,title:x,subtitle:a,action:r})=>e.jsx("header",{className:"px-6 pt-6 pb-4 border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[t&&e.jsx("div",{className:"text-[11px] font-semibold text-[var(--text-dim)] mb-1.5",children:t}),e.jsx(i,{icon:s,children:x}),a&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--text-muted)] max-w-3xl",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})]})});export{l as P,i as a};
1
+ import{j as e}from"./index-EkaQM1DK.js";const i=({icon:s,children:t})=>e.jsxs("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight text-[var(--text)]",children:[s&&e.jsx(s,{className:"h-5 w-5 text-[var(--color-accent)] shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:t})]}),l=({icon:s,eyebrow:t,title:x,subtitle:a,action:r})=>e.jsx("header",{className:"px-6 pt-6 pb-4 border-b border-[var(--border)]",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[t&&e.jsx("div",{className:"text-[11px] font-semibold text-[var(--text-dim)] mb-1.5",children:t}),e.jsx(i,{icon:s,children:x}),a&&e.jsx("p",{className:"mt-1.5 text-sm text-[var(--text-muted)] max-w-3xl",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})]})});export{l as P,i as a};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-CzaIyL9t.js";/**
1
+ import{c as e}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as S,b as N,r as n,j as e,_ as E,A as T}from"./index-CzaIyL9t.js";import{P as A}from"./page-header-ZdzNEJp9.js";import{a as y,f as w}from"./time-B8FIgwPE.js";import{S as C}from"./select-CiRW6v17.js";import{C as $}from"./copy-D8d9UzWE.js";import{T as D}from"./trash-2-u8MlXUBD.js";import"./utils-CDN07tui.js";/**
1
+ import{c as S,b as N,r as n,j as e,_ as E,A as T}from"./index-EkaQM1DK.js";import{P as A}from"./page-header-DoD3TOzZ.js";import{a as y,f as w}from"./time-D-gjmE1o.js";import{S as C}from"./select-CTcD4jWR.js";import{C as $}from"./copy-W00zUBwN.js";import{T as D}from"./trash-2-CJCKBOP9.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.
@@ -1 +1 @@
1
- import{i as f,r as s,u as w,k as v,j as e,e as g,m as j}from"./index-CzaIyL9t.js";import{A as d}from"./auth-shell-DKrtcIjG.js";import"./network-BP_U4iDZ.js";function k(i){return window.location.hash.replace(/^#/,"")||i||void 0}function S(){const i=f(),[r]=s.useState(()=>k(i.token)),u=w(),[a,o]=s.useState("checking"),[n,x]=s.useState(""),[c,h]=s.useState(""),[m,l]=s.useState(null);s.useEffect(()=>{(window.location.hash||i.token)&&window.history.replaceState(null,"","/xenon/reset-password")},[]),s.useEffect(()=>{if(!r){o("invalid");return}v(r).then(t=>o(t?"ready":"invalid"))},[r]);async function p(t){if(t.preventDefault(),l(null),n!==c){l("Passwords do not match.");return}if(n.length<8){l("Password must be at least 8 characters.");return}o("submitting");try{await j(r,n),o("done"),setTimeout(()=>u("/login",{replace:!0}),1500)}catch(b){l(b.message||"Reset failed"),o("ready")}}return a==="checking"?e.jsx(d,{children:e.jsx("div",{className:"text-sm text-[var(--text-muted)] text-center",children:"Checking link…"})}):a==="invalid"?e.jsx(d,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"This link is invalid or expired"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Reset links are good for 1 hour and single-use. Request a new one."}),e.jsx(g,{to:"/forgot-password",className:"inline-block h-10 px-4 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] text-sm font-medium leading-10",children:"Request a new link"})]})}):a==="done"?e.jsx(d,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"Password updated"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Redirecting to sign in…"})]})}):e.jsx(d,{children:e.jsxs("form",{onSubmit:p,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Reset your password"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Choose a new password to sign in with."}),e.jsx("label",{htmlFor:"reset-password",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"New password"}),e.jsx("input",{id:"reset-password",type:"password",autoComplete:"new-password",value:n,onChange:t=>x(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-3 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),e.jsx("label",{htmlFor:"reset-confirm",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"Confirm new password"}),e.jsx("input",{id:"reset-confirm",type:"password",autoComplete:"new-password",value:c,onChange:t=>h(t.target.value),required:!0,className:"w-full mb-3 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),m&&e.jsx("div",{role:"alert",className:"text-sm text-[var(--red)] mb-3",children:m}),e.jsx("button",{type:"submit",disabled:a==="submitting"||n.length<8,className:"mt-5 w-full h-10 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] font-medium text-sm disabled:opacity-50",children:a==="submitting"?"Updating…":"Update password"})]})})}export{S as default};
1
+ import{i as f,r as s,u as w,k as v,j as e,e as g,m as j}from"./index-EkaQM1DK.js";import{A as d}from"./auth-shell-COODQnc7.js";import"./network-DfIhNVJv.js";function k(i){return window.location.hash.replace(/^#/,"")||i||void 0}function S(){const i=f(),[r]=s.useState(()=>k(i.token)),u=w(),[a,o]=s.useState("checking"),[n,x]=s.useState(""),[c,h]=s.useState(""),[m,l]=s.useState(null);s.useEffect(()=>{(window.location.hash||i.token)&&window.history.replaceState(null,"","/xenon/reset-password")},[]),s.useEffect(()=>{if(!r){o("invalid");return}v(r).then(t=>o(t?"ready":"invalid"))},[r]);async function p(t){if(t.preventDefault(),l(null),n!==c){l("Passwords do not match.");return}if(n.length<8){l("Password must be at least 8 characters.");return}o("submitting");try{await j(r,n),o("done"),setTimeout(()=>u("/login",{replace:!0}),1500)}catch(b){l(b.message||"Reset failed"),o("ready")}}return a==="checking"?e.jsx(d,{children:e.jsx("div",{className:"text-sm text-[var(--text-muted)] text-center",children:"Checking link…"})}):a==="invalid"?e.jsx(d,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"This link is invalid or expired"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Reset links are good for 1 hour and single-use. Request a new one."}),e.jsx(g,{to:"/forgot-password",className:"inline-block h-10 px-4 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] text-sm font-medium leading-10",children:"Request a new link"})]})}):a==="done"?e.jsx(d,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold mb-3",children:"Password updated"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Redirecting to sign in…"})]})}):e.jsx(d,{children:e.jsxs("form",{onSubmit:p,children:[e.jsx("h1",{className:"text-2xl font-semibold mb-1",children:"Reset your password"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)] mb-6",children:"Choose a new password to sign in with."}),e.jsx("label",{htmlFor:"reset-password",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"New password"}),e.jsx("input",{id:"reset-password",type:"password",autoComplete:"new-password",value:n,onChange:t=>x(t.target.value),autoFocus:!0,required:!0,className:"w-full mb-3 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),e.jsx("label",{htmlFor:"reset-confirm",className:"block text-sm font-medium text-[var(--text)] mb-1.5",children:"Confirm new password"}),e.jsx("input",{id:"reset-confirm",type:"password",autoComplete:"new-password",value:c,onChange:t=>h(t.target.value),required:!0,className:"w-full mb-3 h-10 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border-strong)] text-sm text-[var(--text)] outline-none focus:border-[var(--color-accent)] focus:shadow-[0_0_0_3px_var(--accent-subtle)]"}),m&&e.jsx("div",{role:"alert",className:"text-sm text-[var(--red)] mb-3",children:m}),e.jsx("button",{type:"submit",disabled:a==="submitting"||n.length<8,className:"mt-5 w-full h-10 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] font-medium text-sm disabled:opacity-50",children:a==="submitting"?"Updating…":"Update password"})]})})}export{S as default};
@@ -1,4 +1,4 @@
1
- import{F as Me,R as Ie,i as Ir,u as Tr,j as J,G as Or}from"./index-CzaIyL9t.js";import{A as vr}from"./arrow-left-CnYs8HVw.js";const qn=["http","https","mailto","tel"];function Lr(e){const n=(e||"").trim(),t=n.charAt(0);if(t==="#"||t==="/")return n;const r=n.indexOf(":");if(r===-1)return n;let i=-1;for(;++i<qn.length;){const l=qn[i];if(r===l.length&&n.slice(0,l.length).toLowerCase()===l)return n}return i=n.indexOf("?"),i!==-1&&r>i||(i=n.indexOf("#"),i!==-1&&r>i)?n:"javascript:void(0)"}/*!
1
+ import{F as Me,R as Ie,i as Ir,u as Tr,j as J,G as Or}from"./index-EkaQM1DK.js";import{A as vr}from"./arrow-left-DMvAWA8r.js";const qn=["http","https","mailto","tel"];function Lr(e){const n=(e||"").trim(),t=n.charAt(0);if(t==="#"||t==="/")return n;const r=n.indexOf(":");if(r===-1)return n;let i=-1;for(;++i<qn.length;){const l=qn[i];if(r===l.length&&n.slice(0,l.length).toLowerCase()===l)return n}return i=n.indexOf("?"),i!==-1&&r>i||(i=n.indexOf("#"),i!==-1&&r>i)?n:"javascript:void(0)"}/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1 +1 @@
1
- import{r as c,j as m}from"./index-CzaIyL9t.js";import{c as o}from"./utils-CDN07tui.js";const l=c.forwardRef(({className:s,selectSize:e="md",children:t,...a},r)=>m.jsx("select",{ref:r,className:o("select-base",e==="sm"&&"select-sm",s),...a,children:t}));l.displayName="Select";export{l as S};
1
+ import{r as c,j as m}from"./index-EkaQM1DK.js";import{c as o}from"./utils-CDN07tui.js";const l=c.forwardRef(({className:s,selectSize:e="md",children:t,...a},r)=>m.jsx("select",{ref:r,className:o("select-base",e==="sm"&&"select-sm",s),...a,children:t}));l.displayName="Select";export{l as S};
@@ -0,0 +1 @@
1
+ import{E as e,j as t,N as r}from"./index-EkaQM1DK.js";import{l as s}from"./view-state-CP9dE1UI.js";const i=()=>{const[a]=e();return t.jsx(r,{to:s(a),replace:!0})};export{i as SelectorDetailRedirect,i as default};
@@ -0,0 +1,11 @@
1
+ import{c as ae,p as ne,u as pe,r as d,j as t,A as ve,v as re,z as ge,w as be,t as le,X as I,e as ye,E as je,b as Ne,K as Se}from"./index-EkaQM1DK.js";import{P as ke}from"./page-header-DoD3TOzZ.js";import{a as we}from"./SegmentedControl-BFW9Dlqd.js";import{B as N}from"./button-WW9j43wR.js";import{S as Ce}from"./stat-tile-BY0RDTRm.js";import{L as ie,n as Ae,C as $e}from"./line-chart-9P3RxScy.js";import{E as Me}from"./EmptyState-DkUVmANo.js";import{I as Ee}from"./input-ChaTXeCq.js";import{S as O}from"./select-CTcD4jWR.js";import{s as _,r as Y,w as Te,P as _e}from"./view-state-CP9dE1UI.js";import{p as Le}from"./labels-C21SA4JG.js";import{M as R}from"./Modal-D6XfQHPr.js";import{C as Ie}from"./check-D8ifHIJR.js";import{C as oe}from"./copy-W00zUBwN.js";import"./utils-CDN07tui.js";import"./index-DWHTp1YP.js";/**
2
+ * @license lucide-react v0.555.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const De=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Be=ae("link-2",De);/**
7
+ * @license lucide-react v0.555.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const Pe=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Re=ae("send",Pe),Fe=3e4,ze=5*6e4;function Oe(){const{on:e}=ne(),n=pe(),[s,r]=d.useState([]);if(d.useEffect(()=>{const o=e("selector_regressed",l=>{r(i=>{const u=Date.now()-ze;return[...i.filter(b=>b.receivedAt>=u),{selector:(l==null?void 0:l.original_selector)??"",receivedAt:Date.now()}]})});return()=>{o&&o()}},[e]),d.useEffect(()=>{if(s.length===0)return;const o=setTimeout(()=>r([]),Fe);return()=>clearTimeout(o)},[s]),s.length===0)return null;const c=s.length===1?s[0]:null;return t.jsxs("div",{role:"alert",className:"flex items-center gap-3 rounded-lg border border-[var(--color-warning)] bg-[var(--surface)] px-4 py-2.5 text-sm text-[var(--text)]",children:[t.jsx(ve,{size:14,className:"shrink-0 text-[var(--color-warning)]","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:c?t.jsxs(t.Fragment,{children:["A selector you fixed broke again:"," ",t.jsx("code",{className:"font-mono text-xs",title:c.selector,children:c.selector})]}):`${s.length} selectors you fixed broke again in the last 5 minutes.`}),t.jsx(N,{variant:"secondary",size:"sm",onClick:()=>{n("/selector-health"),r([])},children:"Show selectors to fix"}),t.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r([]),className:"rounded p-1 text-[var(--text-muted)] hover:text-[var(--text)]",children:t.jsx(re,{size:13})})]})}const He={"accessibility id":"Accessibility ID",xpath:"XPath",id:"ID",name:"Name","class name":"Class Name","-android uiautomator":"UiAutomator","-ios predicate string":"iOS Predicate","-ios class chain":"iOS Class Chain","xenon:visual":"Visual AI (coords)"};function Ue(e){return e?He[e]??e:"(unknown strategy)"}const Xe={fix:"To fix",verifying:"Being verified",fixed:"Fixed",muted:"Muted"},qe={heals:"Most heals",recent:"Most recent",time:"Most time spent healing"},Ve=["Resilio","Native","Fuzzy XML","OCR","Visual AI","LLM"],P={Resilio:"Found it from its saved fingerprint",Native:"Found it again with the original selector","Fuzzy XML":"Found the closest match in the screen's structure",OCR:"Found it by reading the text on screen","Visual AI":"Found it in a screenshot with AI",LLM:"Asked a language model to find it"},Ke=[{value:"android",label:"Android"},{value:"ios",label:"iOS"},{value:"tvos",label:"tvOS"}];function J(e){if(!(e>0))return"0 s";const n=e/1e3;if(n<1)return"<1 s";if(Math.round(n)<60)return`${Math.round(n)} s`;const s=n/60;if(Math.round(s)<60)return`${Math.round(s)} min`;const r=s/60;return`${r<10?r.toFixed(1):Math.round(r)} h`}function q(e,n=Date.now()){if(!e)return"—";const s=Date.parse(e);if(!Number.isFinite(s))return"—";const r=Math.floor(Math.max(0,n-s)/6e4);if(r<1)return"just now";if(r<60)return`${r} min ago`;const c=Math.floor(r/60);if(c<24)return`${c} h ago`;const o=Math.floor(c/24);return o===1?"yesterday":`${o} days ago`}function ce(e){return new Date(e).toLocaleDateString(void 0,{weekday:"short",day:"numeric",month:"short"})}function V(e){if(!e)return"—";const n=Date.parse(e);return Number.isFinite(n)?new Date(n).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"}):"—"}function Ge(e,n,s,r){const c=`the ${s} days before`;if(e===n)return{text:`Same as ${c}`,tone:"neutral"};if(n===0)return{text:`None ${c}`,tone:"bad"};const o=e>n,l=o?"bad":"good";if(r==="count")return{text:`${Math.abs(e-n)} ${o?"more":"fewer"} than ${c}`,tone:l};if(r==="duration")return{text:`${J(Math.abs(e-n))} ${o?"more":"less"} than ${c}`,tone:l};const i=Math.round(Math.abs(e-n)/n*100);return i===0?{text:`About the same as ${c}`,tone:"neutral"}:{text:`${i}% ${o?"more":"fewer"} than ${c}`,tone:l}}function de(e){return`${Math.round(e*100)}% of heals`}function K(e){return e?Ue(e):"Unknown type"}function Je(e){switch(e==null?void 0:e.status){case"pending":return`Being verified, ${e.cleanBuilds} of 3 clean builds`;case"resolved":return"Fixed";case"muted":return"Muted";default:return"To fix"}}function G(e){return e!=null&&e.name?` by ${e.name}`:""}const We={marked_fixed:"Marked fixed",verification_cancelled:"Verification cancelled",verified:"Verified after 3 clean builds",broke_again:"Broke again",muted:"Muted",unmuted:"Unmuted"};function Ye(e){return`${We[e.action]??"Changed"}${G(e.by)}`}const H=e=>e.toLocaleString(),Qe=({summary:e,days:n})=>{const s=e==null?void 0:e.current,r=e==null?void 0:e.prior,c=[{label:"Selectors that needed healing",value:s==null?void 0:s.distinctSelectors,before:r==null?void 0:r.distinctSelectors,kind:"count",show:H},{label:"Heals",value:s==null?void 0:s.totalHeals,before:r==null?void 0:r.totalHeals,kind:"percent",show:H},{label:"Sessions affected",value:s==null?void 0:s.sessionsTouched,before:r==null?void 0:r.sessionsTouched,kind:"percent",show:H},{label:"Time spent healing",value:s==null?void 0:s.timeSpentMs,before:r==null?void 0:r.timeSpentMs,kind:"duration",show:J}];return t.jsx("div",{className:"grid grid-cols-4 gap-3",children:c.map(o=>{const l=o.value!==void 0&&o.before!==void 0?Ge(o.value,o.before,n,o.kind):null;return t.jsx(Ce,{label:o.label,value:o.value!==void 0?o.show(o.value):"—",note:l==null?void 0:l.text,noteTone:(l==null?void 0:l.tone)??"neutral"},o.label)})})},Q="var(--color-info)",Z="var(--color-warning)",ee=({color:e,label:n,total:s})=>t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-0.5 w-3",style:{background:e}}),t.jsx("span",{children:n}),t.jsx("span",{className:"tabular-nums text-[var(--text)]",children:s.toLocaleString()})]}),Ze=({trend:e,days:n,failed:s})=>{var h;const r=d.useMemo(()=>e??[],[e]),c=((h=r[0])==null?void 0:h.t)??0,o=r.reduce((m,y)=>m+y.heals,0),l=r.reduce((m,y)=>m+y.aiHeals,0),i=d.useMemo(()=>r.map(m=>m.t-c),[r,c]),u=d.useMemo(()=>[{key:"heals",label:"All heals",color:Q,values:r.map(m=>m.heals)},{key:"ai",label:"Heals that used AI",color:Z,values:r.map(m=>m.aiHeals)}],[r]),b=r.reduce((m,y)=>Math.max(m,y.heals),0);let f;return e===null&&s?f=t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:"Couldn't load heals per day. Try again in a moment."}):e===null?f=t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:"Loading…"}):o===0?f=t.jsxs("div",{className:"text-xs text-[var(--text-dim)]",children:["No heals in the last ",n," days."]}):f=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-2 flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-[var(--text-muted)]",children:[t.jsx(ee,{color:Q,label:"All heals",total:o}),t.jsx(ee,{color:Z,label:"Heals that used AI",total:l})]}),t.jsx(ie,{times:i,series:u,yMax:Ae(b),formatValue:m=>String(Math.round(m)),formatTime:m=>ce(c+m),ariaLabel:"Heals per day",height:120})]}),t.jsx($e,{header:"Heals per day",children:f})},D=({title:e,tone:n="neutral",children:s})=>t.jsx("span",{title:e,className:`inline-block max-w-full truncate rounded px-1.5 py-px text-[10px] font-medium ${n==="warning"?"border border-[var(--color-warning)] text-[var(--color-warning)]":"bg-[rgb(var(--rgb-fg)/0.06)] text-[var(--text-muted)]"}`,children:s}),te=({strategy:e,text:n,extra:s})=>t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"mb-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsx(D,{children:K(e)}),s]}),t.jsx("code",{className:"line-clamp-2 break-all font-mono text-[11px] leading-snug text-[var(--text)]",title:n,children:n})]}),et=300,tt=["fix","verifying","fixed","muted"],st=["heals","recent","time"],E=e=>t.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:e});function at(e,n,s){const r={key:"selector",label:"Selector",cell:l=>t.jsx(te,{strategy:l.strategy,text:l.selector,extra:e==="fix"&&l.state&&l.state.brokeAgain>0?t.jsx(D,{tone:"warning",children:"Broke again"}):null})},c=l=>({key:"heals",label:l,width:"96px",cell:i=>t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold tabular-nums text-[var(--text)]",children:i.heals.toLocaleString()}),t.jsxs("div",{className:"text-[11px] text-[var(--text-muted)]",children:[i.sessions," ",i.sessions===1?"session":"sessions"]})]})}),o={key:"last",label:"Last healed",width:"104px",cell:l=>E(q(l.lastHealedAt))};switch(e){case"fix":return n?[r,c("Heals"),o]:[r,c("Heals"),o,{key:"method",label:"Healed by",width:"112px",cell:l=>l.topMethod?t.jsx(D,{title:P[l.topMethod],children:l.topMethod}):E("—")},{key:"fix",label:"Suggested fix",width:"34%",cell:l=>l.suggestion?t.jsx(te,{strategy:l.suggestion.strategy,text:l.suggestion.selector,extra:t.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:de(l.suggestion.share)})}):E("None yet")}];case"verifying":{const l={key:"progress",label:"Progress",width:"150px",cell:i=>{var u;return t.jsxs("span",{className:"text-xs text-[var(--text)]",children:[((u=i.state)==null?void 0:u.cleanBuilds)??0," of 3 clean builds"]})}};return n?[r,l]:[r,l,{key:"marked",label:"Marked fixed",width:"180px",cell:i=>{var u,b;return E(`${q(((u=i.state)==null?void 0:u.fixedAt)??null)}${G(((b=i.state)==null?void 0:b.fixedBy)??null)}`)}},c(`Heals, ${s} days`)]}case"fixed":{const l={key:"verified",label:"Verified",width:"140px",cell:i=>{var u;return E(V(((u=i.state)==null?void 0:u.resolvedAt)??null))}};return n?[r,l]:[r,l,c(`Heals, ${s} days`)]}case"muted":{const l={key:"muted",label:"Muted",width:"180px",cell:i=>{var u,b;return E(`${V(((u=i.state)==null?void 0:u.mutedAt)??null)}${G(((b=i.state)==null?void 0:b.mutedBy)??null)}`)}};return n?[r,l]:[r,l,{key:"reason",label:"Reason",width:"26%",cell:i=>{var u;return(u=i.state)!=null&&u.muteReason?t.jsx("span",{className:"line-clamp-2 text-xs text-[var(--text)]",children:i.state.muteReason}):E("No reason given")}},c(`Heals, ${s} days`)]}}}function nt(e,n,s){if(n)return{title:`No selectors match “${n}”`,description:"Try fewer or different words."};switch(e){case"fix":return{title:`Nothing to fix in the last ${s} days`,description:"Every selector your tests used was found without healing."};case"verifying":return{title:"Nothing being verified",description:"When you mark a selector fixed, Xenon watches its next 3 clean builds here."};case"fixed":return{title:`Nothing fixed in the last ${s} days`,description:"Selectors that pass 3 clean builds after being marked fixed show here."};case"muted":return{title:"Nothing muted",description:"A muted selector is left out of this list, the CI gate and the digest."}}}const rt=({view:e,data:n,loading:s,compact:r,selectedKey:c,onView:o,onOpen:l,error:i})=>{const[u,b]=d.useState(e.q);d.useEffect(()=>b(e.q),[e.q]),d.useEffect(()=>{if(u===e.q)return;const a=setTimeout(()=>o({q:u,page:1}),et);return()=>clearTimeout(a)},[u,e.q,o]);const f=at(e.tab,r,e.days),h=n&&n.tab===e.tab?n:null,m=(h==null?void 0:h.items)??[],y=(h==null?void 0:h.total)??0,k=(h==null?void 0:h.page)??e.page,w=(h==null?void 0:h.pageSize)??50,T=Math.max(1,Math.ceil(y/w)),A=y===0?0:(k-1)*w+1,C=Math.min(y,k*w),$=nt(e.tab,e.q,e.days);return t.jsxs("section",{"aria-label":"Selectors",className:"rounded-lg border border-[var(--border)] bg-[var(--surface)]",children:[t.jsx("div",{role:"tablist","aria-label":"Selector status",className:"flex gap-1 border-b border-[var(--border)] px-3",children:tt.map(a=>{var j;const g=e.tab===a,p=(j=n==null?void 0:n.counts)==null?void 0:j[a];return t.jsxs("button",{type:"button",role:"tab","aria-selected":g,onClick:()=>{g||o({tab:a,page:1})},className:`-mb-px flex items-center gap-2 border-b-2 px-3 py-2.5 text-sm ${g?"border-[var(--color-accent)] font-medium text-[var(--text)]":"border-transparent text-[var(--text-muted)] hover:text-[var(--text)]"}`,children:[Xe[a],t.jsx("span",{className:"rounded-full bg-[rgb(var(--rgb-fg)/0.08)] px-1.5 text-[11px] tabular-nums",children:typeof p=="number"?p.toLocaleString():"–"})]},a)})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-[var(--border)] px-3 py-2.5",children:[t.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[t.jsx(ge,{size:14,"aria-hidden":"true",className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-dim)]"}),t.jsx(Ee,{type:"search","aria-label":"Search",value:u,onChange:a=>b(a.target.value),placeholder:e.tab==="fix"?"Search selectors and fixes":"Search selectors",className:"h-8 w-full pl-8 pr-2 text-xs"})]}),e.tab==="fix"&&t.jsxs(t.Fragment,{children:[t.jsxs(O,{selectSize:"sm",className:"!w-auto shrink-0","aria-label":"Platform",value:e.platform,onChange:a=>o({platform:a.target.value,page:1}),children:[t.jsx("option",{value:"",children:"All platforms"}),Ke.map(a=>t.jsx("option",{value:a.value,children:a.label},a.value))]}),t.jsxs(O,{selectSize:"sm",className:"!w-auto shrink-0","aria-label":"Healing method",value:e.method,onChange:a=>o({method:a.target.value,page:1}),children:[t.jsx("option",{value:"",children:"All healing methods"}),Ve.map(a=>t.jsx("option",{value:a,title:P[a],children:a},a))]}),t.jsx(O,{selectSize:"sm",className:"!w-auto shrink-0","aria-label":"Sort",value:e.sort,onChange:a=>o({sort:a.target.value,page:1}),children:st.map(a=>t.jsx("option",{value:a,children:qe[a]},a))})]})]}),h?m.length===0?t.jsx(Me,{title:$.title,description:$.description}):t.jsxs("table",{className:"w-full table-fixed text-left",children:[t.jsx("colgroup",{children:f.map(a=>t.jsx("col",{style:a.width?{width:a.width}:void 0},a.key))}),t.jsx("thead",{children:t.jsx("tr",{children:f.map(a=>t.jsx("th",{scope:"col",className:"px-3 py-2 text-[11px] font-medium text-[var(--text-muted)]",children:a.label},a.key))})}),t.jsx("tbody",{children:m.map(a=>{const g=_(a),p=g===c,j=()=>l({strategy:a.strategy,selector:a.selector});return t.jsx("tr",{tabIndex:0,"data-selector-row":"","data-key":g,"aria-current":p?"true":void 0,onClick:j,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),j())},className:`cursor-pointer border-t border-[var(--border)] align-top outline-none hover:bg-[rgb(var(--rgb-fg)/0.03)] focus-visible:bg-[rgb(var(--rgb-fg)/0.05)] ${p?"bg-[rgb(var(--rgb-fg)/0.06)]":""}`,children:f.map(M=>t.jsx("td",{className:"px-3 py-2.5 text-xs",children:M.cell(a)},M.key))},g)})})]}):t.jsx("div",{className:"px-4 py-10 text-center text-xs text-[var(--text-dim)]",children:i&&!s?"Couldn't load selectors. Try again in a moment.":"Loading selectors…"}),y>0&&t.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--border)] px-3 py-2 text-xs text-[var(--text-muted)]",children:[t.jsxs("span",{className:"tabular-nums",children:[A,"–",C," of ",y.toLocaleString()]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(N,{variant:"secondary",size:"sm",disabled:k<=1,onClick:()=>o({page:k-1}),children:"Previous"}),t.jsx(N,{variant:"secondary",size:"sm",disabled:k>=T,onClick:()=>o({page:k+1}),children:"Next"})]})]})]})},lt={javascript:{"accessibility id":e=>`await driver.findElement('accessibility id', '${e}')`,xpath:e=>`await driver.findElement('xpath', '${e}')`,id:e=>`await driver.findElement('id', '${e}')`,name:e=>`await driver.findElement('name', '${e}')`,"class name":e=>`await driver.findElement('class name', '${e}')`,"-android uiautomator":e=>`await driver.findElement('-android uiautomator', '${e}')`,"-ios predicate string":e=>`await driver.findElement('-ios predicate string', '${e}')`,"-ios class chain":e=>`await driver.findElement('-ios class chain', '${e}')`},java:{"accessibility id":e=>`driver.findElement(AppiumBy.accessibilityId("${e}"))`,xpath:e=>`driver.findElement(AppiumBy.xpath("${e}"))`,id:e=>`driver.findElement(AppiumBy.id("${e}"))`,name:e=>`driver.findElement(AppiumBy.name("${e}"))`,"class name":e=>`driver.findElement(AppiumBy.className("${e}"))`,"-android uiautomator":e=>`driver.findElement(AppiumBy.androidUIAutomator("${e}"))`,"-ios predicate string":e=>`driver.findElement(AppiumBy.iOSNsPredicateString("${e}"))`,"-ios class chain":e=>`driver.findElement(AppiumBy.iOSClassChain("${e}"))`},python:{"accessibility id":e=>`driver.find_element(AppiumBy.ACCESSIBILITY_ID, '${e}')`,xpath:e=>`driver.find_element(AppiumBy.XPATH, '${e}')`,id:e=>`driver.find_element(AppiumBy.ID, '${e}')`,name:e=>`driver.find_element(AppiumBy.NAME, '${e}')`,"class name":e=>`driver.find_element(AppiumBy.CLASS_NAME, '${e}')`,"-android uiautomator":e=>`driver.find_element(AppiumBy.ANDROID_UIAUTOMATOR, '${e}')`,"-ios predicate string":e=>`driver.find_element(AppiumBy.IOS_PREDICATE, '${e}')`,"-ios class chain":e=>`driver.find_element(AppiumBy.IOS_CLASS_CHAIN, '${e}')`},csharp:{"accessibility id":e=>`driver.FindElement(MobileBy.AccessibilityId("${e}"))`,xpath:e=>`driver.FindElement(By.XPath("${e}"))`,id:e=>`driver.FindElement(By.Id("${e}"))`,name:e=>`driver.FindElement(By.Name("${e}"))`,"class name":e=>`driver.FindElement(By.ClassName("${e}"))`},ruby:{"accessibility id":e=>`driver.find_element(:accessibility_id, '${e}')`,xpath:e=>`driver.find_element(:xpath, '${e}')`,id:e=>`driver.find_element(:id, '${e}')`,name:e=>`driver.find_element(:name, '${e}')`,"class name":e=>`driver.find_element(:class_name, '${e}')`}};function it(e,n){const s=e==="java"||e==="csharp",r=n.replace(/\\/g,"\\\\");return s?r.replace(/"/g,'\\"'):r.replace(/'/g,"\\'")}function ue(e,n,s){var c;if(n==="xenon:visual")return"/* Visual AI (coordinates) — no portable Appium snippet. Use snapshot view to find a stable native locator. */";const r=(c=lt[e])==null?void 0:c[n];return r?r(it(e,s)):`${(n??"").toString().toUpperCase()}: ${s}`}const W=[{value:"javascript",short:"JS",label:"JavaScript (WebdriverIO)"},{value:"java",short:"Java",label:"Java (Appium-Java)"},{value:"python",short:"Py",label:"Python (Appium-Python)"},{value:"csharp",short:"C#",label:"C# (.NET)"},{value:"ruby",short:"Rb",label:"Ruby"}],me="xenon.copyLang";function ot(){try{const e=localStorage.getItem(me);return e&&W.find(n=>n.value===e)?e:null}catch{return null}}function ct(e){try{localStorage.setItem(me,e)}catch{}}function xe(e){var n;return((n=W.find(s=>s.value===e))==null?void 0:n.short)??e}function dt({open:e,initialLang:n,strategy:s,value:r,onCopy:c,onClose:o}){const[l,i]=d.useState(n??"javascript"),[u,b]=d.useState(!0),f=ue(l,s,r),h=async()=>{try{await navigator.clipboard.writeText(f)}catch{}u&&ct(l),c(l,f),o()};return t.jsxs(R,{open:e,onClose:o,title:"Choose your default copy language",width:520,footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"secondary",onClick:o,children:"Cancel"}),t.jsxs(N,{onClick:h,children:["Copy as ",xe(l)]})]}),children:[t.jsx("p",{className:"mb-3 text-xs text-[var(--text-muted)]",children:"Snippets will be copied in this language until you change it."}),t.jsx("ul",{className:"mb-3 space-y-1",children:W.map(m=>t.jsx("li",{children:t.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text)]",children:[t.jsx("input",{type:"radio",name:"copy-lang",value:m.value,checked:l===m.value,onChange:()=>i(m.value)}),m.label]})},m.value))}),t.jsx("div",{className:"mb-1 text-[11px] font-semibold text-[var(--text-dim)]",children:"Preview"}),t.jsx("pre",{className:"mb-3 overflow-x-auto rounded-md border border-[var(--border)] bg-[var(--surface-sunken)] p-3 font-mono text-[11px] text-[var(--text)]",children:t.jsx("code",{children:f})}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-[var(--text-muted)]",children:[t.jsx("input",{type:"checkbox",checked:u,onChange:m=>b(m.target.checked)}),"Remember my choice"]})]})}function ut({strategy:e,value:n,onCopied:s}){const[r,c]=d.useState(!1),[o,l]=d.useState(!1),i=ot(),u=e==="xenon:visual",b=async()=>{if(!i){c(!0);return}try{await navigator.clipboard.writeText(ue(i,e,n))}catch{}l(!0),s(i),setTimeout(()=>l(!1),1500)},f=i?`Copy as ${xe(i)}`:"Copy as code";return t.jsxs("span",{className:"inline-flex shrink-0",children:[t.jsxs(N,{type:"button",variant:"secondary",size:"sm",className:"rounded-r-none",onClick:h=>{h.stopPropagation(),b()},disabled:u&&!n,"aria-label":f,title:u?"Found by its place on screen: there is no selector to copy":f,children:[o?t.jsx(Ie,{size:12}):t.jsx(oe,{size:12}),t.jsx("span",{children:o?"Copied":i?f:"Copy as…"})]}),t.jsx(N,{type:"button",variant:"secondary",size:"sm",className:"rounded-l-none border-l-0 px-1.5",onClick:h=>{h.stopPropagation(),c(!0)},title:"Choose copy language","aria-label":"Choose copy language",children:t.jsx(be,{size:12})}),t.jsx(dt,{open:r,initialLang:i??void 0,strategy:e,value:n,onCopy:h=>{l(!0),s(h),setTimeout(()=>l(!1),1500)},onClose:()=>c(!1)})]})}const se=500,mt=({open:e,busy:n,onClose:s,onConfirm:r})=>t.jsx(R,{open:e,onClose:s,title:"Mark this selector fixed?",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"secondary",onClick:s,children:"Cancel"}),t.jsx(N,{onClick:r,disabled:n,children:"Mark fixed"})]}),children:t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Xenon watches the next 3 clean builds. If this selector heals again, it goes back to To fix."})}),xt=({open:e,busy:n,onClose:s,onConfirm:r})=>t.jsx(R,{open:e,onClose:s,title:"Cancel verification?",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"secondary",onClick:s,children:"Keep verifying"}),t.jsx(N,{onClick:r,disabled:n,children:"Cancel verification"})]}),children:t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"The selector goes back to To fix, and its clean builds start again from zero."})}),ht=({open:e,busy:n,onClose:s,onConfirm:r})=>{const[c,o]=d.useState("");return d.useEffect(()=>{e&&o("")},[e]),t.jsxs(R,{open:e,onClose:s,title:"Mute this selector?",footer:t.jsxs(t.Fragment,{children:[t.jsx(N,{variant:"secondary",onClick:s,children:"Cancel"}),t.jsx(N,{onClick:()=>r(c.trim()),disabled:n,children:"Mute"})]}),children:[t.jsx("p",{className:"mb-3 text-sm text-[var(--text-muted)]",children:"A muted selector is left out of this list, the CI gate and the digest, for everyone, until someone unmutes it."}),t.jsx("label",{htmlFor:"mute-reason",className:"block text-xs font-medium text-[var(--text)]",children:"Reason (optional)"}),t.jsx("textarea",{id:"mute-reason",value:c,maxLength:se,rows:3,placeholder:"Screen being redesigned",onChange:l=>o(l.target.value),className:"mt-1 w-full rounded-md border border-[var(--border-strong)] bg-[var(--surface)] px-2 py-1.5 text-sm text-[var(--text)]"}),t.jsxs("div",{className:"mt-1 text-right text-[11px] tabular-nums text-[var(--text-dim)]",children:[c.length,"/",se]})]})},ft={mark_fixed:"Marked fixed. Xenon is watching the next 3 clean builds.",mute:"Muted.",unmute:"Unmuted.",cancel_verification:"Verification cancelled."},pt={pending:"border-[var(--color-info)] text-[var(--color-info)]",resolved:"border-[var(--color-success)] text-[var(--color-success)]",muted:"border-[var(--border-strong)] text-[var(--text-muted)]"},vt=({state:e})=>t.jsx("span",{className:`rounded-full border px-2 py-0.5 text-[11px] font-medium ${pt[(e==null?void 0:e.status)??""]??"border-[var(--color-danger)] text-[var(--color-danger)]"}`,children:Je(e)}),U=({label:e,onClick:n,children:s})=>t.jsx("button",{type:"button","aria-label":e,title:e,onClick:n,className:"rounded p-1.5 text-[var(--text-muted)] hover:bg-[rgb(var(--rgb-fg)/0.06)] hover:text-[var(--text)]",children:s}),L=({title:e,children:n})=>t.jsxs("section",{"aria-label":e,children:[t.jsx("h3",{className:"mb-2 text-xs font-semibold text-[var(--text)]",children:e}),n]}),X=({title:e,rows:n})=>n.length===0?null:t.jsxs("div",{className:"mb-3",children:[t.jsx("div",{className:"mb-1 text-[11px] text-[var(--text-dim)]",children:e}),n.map(s=>t.jsxs("div",{className:"flex justify-between gap-3 py-0.5 text-xs",children:[t.jsx("span",{className:"min-w-0 truncate text-[var(--text)]",title:s.label,children:s.label}),t.jsx("span",{className:"shrink-0 tabular-nums text-[var(--text-muted)]",children:s.count.toLocaleString()})]},s.key))]}),gt=({activity:e})=>t.jsx(L,{title:"Activity",children:e.length===0?t.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"No changes recorded yet."}):t.jsx("ul",{children:e.map((n,s)=>t.jsxs("li",{className:"flex justify-between gap-3 py-1 text-[11px]",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"text-[var(--text)]",children:Ye(n)}),n.reason&&t.jsxs("span",{className:"text-[var(--text-muted)]",children:[": “",n.reason,"”"]})]}),t.jsx("span",{className:"shrink-0 text-[var(--text-dim)]",children:V(n.at)})]},`${n.at}-${s}`))})}),bt=({target:e,days:n,tz:s,refreshKey:r,onClose:c,onChanged:o})=>{var $;const{toast:l}=le(),[i,u]=d.useState(null),[b,f]=d.useState("loading"),[h,m]=d.useState(null),[y,k]=d.useState(!1);d.useEffect(()=>{u(null),f("loading")},[e.strategy,e.selector]),d.useEffect(()=>{let a=!0;return I.getSelectorPanel(e.strategy,e.selector,n,s).then(({status:g,body:p})=>{a&&(g===404?(u(null),f("missing")):g===200&&p?(u(p),f("ready")):f("failed"))}).catch(()=>{a&&f("failed")}),()=>{a=!1}},[e.strategy,e.selector,n,s,r]);const w=async(a,g)=>{k(!0);try{await I.postSelectorStateAction({original_strategy:e.strategy,original_selector:e.selector,action:a,...g?{reason:g}:{}}),l(ft[a],"success")}catch(p){const j=p.status;l(j===409?"Someone changed this selector just now. It has been refreshed.":j===404?"This selector isn't available any more.":"That didn't work. Try again.","error")}finally{k(!1),m(null),o()}},T=async(a,g)=>{try{await navigator.clipboard.writeText(a),l(g,"success")}catch{l("Couldn't copy: your browser blocked it.","error")}},A=(($=i==null?void 0:i.state)==null?void 0:$.status)??"active",C=d.useMemo(()=>{var p;const a=(i==null?void 0:i.daily)??[],g=((p=a[0])==null?void 0:p.t)??0;return{start:g,times:a.map(j=>j.t-g),values:a.map(j=>j.heals)}},[i]);return t.jsxs("aside",{"aria-label":"Selector details",className:"sticky top-4 flex max-h-[calc(100vh-7rem)] w-[480px] shrink-0 flex-col overflow-hidden rounded-lg border border-[var(--border)] bg-[var(--surface)]",children:[t.jsxs("header",{className:"border-b border-[var(--border)] p-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(D,{children:K(e.strategy)}),i&&t.jsx(vt,{state:i.state}),t.jsxs("span",{className:"ml-auto flex items-center gap-0.5",children:[t.jsx(U,{label:"Copy selector",onClick:()=>void T(e.selector,"Selector copied"),children:t.jsx(oe,{size:14})}),t.jsx(U,{label:"Copy link to this selector",onClick:()=>void T(window.location.href,"Link copied"),children:t.jsx(Be,{size:14})}),t.jsx(U,{label:"Close",onClick:c,children:t.jsx(re,{size:14})})]})]}),t.jsx("code",{className:"mt-2 block break-all font-mono text-xs leading-relaxed text-[var(--text)]",children:e.selector}),(i==null?void 0:i.canAct)&&t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[A==="active"&&e.strategy!==""&&t.jsx(N,{size:"sm",onClick:()=>m("mark_fixed"),children:"Mark fixed"}),A==="pending"&&t.jsx(N,{size:"sm",variant:"secondary",onClick:()=>m("cancel_verification"),children:"Cancel verification"}),A!=="muted"&&t.jsx(N,{size:"sm",variant:"secondary",onClick:()=>m("mute"),children:"Mute…"}),A==="muted"&&t.jsx(N,{size:"sm",variant:"secondary",disabled:y,onClick:()=>void w("unmute"),children:"Unmute"})]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-5 overflow-y-auto p-4",children:[b==="loading"&&t.jsx("p",{className:"text-xs text-[var(--text-dim)]",children:"Loading…"}),b==="missing"&&t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"This selector isn't available. It may belong to another team, or Xenon has no heals on record for it."}),b==="failed"&&t.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Couldn't load this selector. Try again in a moment."}),i&&i.heals===0&&t.jsxs("p",{className:"text-sm text-[var(--text-muted)]",children:["No heals in the last ",n," days."]}),i&&i.heals>0&&t.jsxs(t.Fragment,{children:[t.jsx(L,{title:"Suggested fix",children:i.suggestions.length===0?t.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:"Xenon found the element without a selector it can suggest."}):t.jsx("ul",{className:"space-y-2",children:i.suggestions.map((a,g)=>t.jsx("li",{className:`rounded-md border p-2.5 ${g===0?"border-[var(--color-success)]":"border-[var(--border)]"}`,children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--text-muted)]",children:[t.jsx(D,{children:K(a.strategy)}),t.jsx("span",{children:de(a.share)}),a.methods.length>0&&t.jsxs("span",{title:a.methods.map(p=>P[p]??p).join(". "),children:["· ",a.methods.join(", ")]}),a.averageConfidence!==null&&t.jsxs("span",{children:["· ",Math.round(a.averageConfidence*100),"% confidence"]})]}),t.jsx("code",{className:"mt-1 block break-all font-mono text-[11px] text-[var(--text)]",children:a.selector})]}),t.jsx(ut,{strategy:a.strategy??e.strategy,value:a.selector,onCopied:p=>l(`Copied as ${p}`,"success")})]})},`${a.strategy??""}\0${a.selector}`))})}),t.jsxs(L,{title:`In the last ${n} days`,children:[t.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{label:i.heals===1?"heal":"heals",value:i.heals.toLocaleString()},{label:i.sessions===1?"session":"sessions",value:i.sessions.toLocaleString()},{label:"spent healing",value:J(i.timeSpentMs)}].map(a=>t.jsxs("div",{className:"rounded-md bg-[rgb(var(--rgb-fg)/0.04)] px-2.5 py-2",children:[t.jsx("div",{className:"text-sm font-semibold tabular-nums text-[var(--text)]",children:a.value}),t.jsx("div",{className:"text-[11px] text-[var(--text-muted)]",children:a.label})]},a.label))}),C.times.length>1&&t.jsx("div",{className:"mt-3",children:t.jsx(ie,{times:C.times,series:[{key:"heals",label:"Heals",color:"var(--color-info)",values:C.values}],formatValue:a=>String(Math.round(a)),formatTime:a=>ce(C.start+a),ariaLabel:"Heals per day for this selector",height:56})})]}),t.jsxs(L,{title:"Where it happens",children:[t.jsx(X,{title:"Platforms",rows:i.platforms.map(a=>({key:a.name,label:Le(a.name),count:a.count}))}),t.jsx(X,{title:"Builds",rows:i.builds.map(a=>({key:a.id??"",label:a.name,count:a.count}))}),t.jsx(X,{title:"Devices",rows:i.devices.map(a=>({key:a.udid,label:a.name,count:a.count}))})]}),t.jsx(L,{title:"Recent heals",children:t.jsx("ul",{className:"divide-y divide-[var(--border)]",children:i.recent.map(a=>t.jsxs("li",{className:"py-2 text-[11px]",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[var(--text-muted)]",children:[t.jsx("span",{children:q(a.at)}),a.device&&t.jsxs("span",{className:"min-w-0 truncate",children:["· ",a.device]}),a.method&&t.jsxs("span",{title:P[a.method],children:["· ",a.method,a.confidence!==null?` ${Math.round(a.confidence*100)}%`:""]}),t.jsx(ye,{className:"ml-auto shrink-0 text-[var(--color-accent)] hover:underline",to:`/builds/${encodeURIComponent(a.buildId??"none")}/sessions/${encodeURIComponent(a.sessionId)}`,children:"Session"})]}),a.healedSelector&&t.jsx("code",{className:"mt-0.5 block truncate font-mono text-[var(--text)]",title:a.healedSelector,children:a.healedSelector})]},a.id))})})]}),i&&t.jsx(gt,{activity:i.activity})]}),t.jsx(mt,{open:h==="mark_fixed",busy:y,onClose:()=>m(null),onConfirm:()=>void w("mark_fixed")}),t.jsx(xt,{open:h==="cancel_verification",busy:y,onClose:()=>m(null),onConfirm:()=>void w("cancel_verification")}),t.jsx(ht,{open:h==="mute",busy:y,onClose:()=>m(null),onConfirm:a=>void w("mute",a||void 0)})]})},yt=1e3,jt=["healing_event","selector_fixed","selector_resolved","selector_regressed","selector_cancelled","selector_muted","selector_unmuted","selector_progress"],Nt=e=>!!e&&(["INPUT","TEXTAREA","SELECT"].includes(e.tagName)||e.isContentEditable),Ft=()=>{const[e,n]=je(),s=d.useMemo(()=>Y(e),[e]),r=d.useMemo(()=>-new Date().getTimezoneOffset(),[]),{on:c}=ne(),{toast:o}=le(),{me:l}=Ne(),i=!!l&&(l.role==="ADMIN"||l.role==="SUPER_ADMIN"||!!l.authDisabled),[u,b]=d.useState(null),[f,h]=d.useState(null),[m,y]=d.useState(!1),[k,w]=d.useState(!1),[T,A]=d.useState(!0),[C,$]=d.useState(0),[a,g]=d.useState(!1),p=d.useCallback((x,v=!1)=>n(Te({...Y(e),...x}),{replace:v}),[e,n]);d.useEffect(()=>{let x=!0;return I.getHealingSummary(s.days,r).then(v=>{x&&(b(v??null),w(!1))}).catch(()=>{x&&w(!0)}),()=>{x=!1}},[s.days,r,C]),d.useEffect(()=>{let x=!0;return A(!0),I.getHealingSelectors({tab:s.tab,days:s.days,q:s.q,platform:s.platform,method:s.method,sort:s.sort,page:s.page}).then(v=>{x&&(h(v??null),y(!1))}).catch(()=>{x&&y(!0)}).finally(()=>{x&&A(!1)}),()=>{x=!1}},[s.tab,s.days,s.q,s.platform,s.method,s.sort,s.page,C]);const j=d.useRef(null);d.useEffect(()=>{const x=()=>{j.current||(j.current=setTimeout(()=>{j.current=null,$(S=>S+1)},yt))},v=jt.map(S=>c(S,x));return()=>{v.forEach(S=>S&&S()),j.current&&clearTimeout(j.current),j.current=null}},[c]);const M=d.useCallback(x=>p({open:x}),[p]),F=d.useCallback(()=>{const x=s.open?_(s.open):null;p({open:null}),setTimeout(()=>{var S;(S=Array.from(document.querySelectorAll("[data-selector-row]")).find(B=>B.dataset.key===x))==null||S.focus()},0)},[s.open,p]),z=d.useCallback(x=>{const v=(f==null?void 0:f.items)??[];if(v.length===0)return;const S=s.open?v.findIndex(fe=>_(fe)===_(s.open)):-1,B=v[S<0?0:Math.min(v.length-1,Math.max(0,S+x))];p({open:{strategy:B.strategy,selector:B.selector}},!0)},[f,s.open,p]);d.useEffect(()=>{if(!s.open)return;const x=v=>{v.defaultPrevented||Nt(document.activeElement)||document.querySelector('[role="dialog"]')||(v.key==="Escape"?(v.preventDefault(),F()):v.key==="ArrowDown"?(v.preventDefault(),z(1)):v.key==="ArrowUp"&&(v.preventDefault(),z(-1)))};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[s.open,F,z]);const he=async()=>{g(!0);try{const x=await I.sendHealingDigest({windowDays:s.days,limit:5,minHealCount:2}),v=(x==null?void 0:x.sent)??0;v===0?o("No webhook gets the digest yet. Add one in Notifications.","error"):o(`Digest sent to ${v} webhook${v===1?"":"s"}.`,"success")}catch{o("Couldn't send the digest. Try again.","error")}finally{g(!1)}};return t.jsxs("div",{children:[t.jsx(ke,{icon:Se,eyebrow:"Test quality",title:"Selector health",subtitle:"Selectors your tests could only find with self-healing. Fix the ones that heal most.",action:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{size:"sm",label:"Period",value:String(s.days),onChange:x=>p({days:Number(x),page:1}),segments:_e.map(x=>({value:String(x),label:`${x} days`}))}),i&&t.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>void he(),disabled:a,children:[t.jsx(Re,{size:14})," Send digest"]})]})}),t.jsxs("div",{className:"space-y-4 px-6 pb-8 pt-4",children:[t.jsx(Oe,{}),t.jsx(Qe,{summary:u,days:s.days}),t.jsx(Ze,{trend:u?u.trend??[]:null,days:s.days,failed:k&&!u}),t.jsxs("div",{className:"flex items-start gap-4",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(rt,{view:s,data:f,loading:T,compact:!!s.open,selectedKey:s.open?_(s.open):null,onView:p,onOpen:M,error:m})}),s.open&&t.jsx(bt,{target:s.open,days:s.days,tz:r,refreshKey:C,onClose:F,onChanged:()=>$(x=>x+1)})]})]})]})};export{yt as LIVE_REFRESH_MS,Ft as default};
@@ -0,0 +1,4 @@
1
+ import{r as x,X as k,j as t,e as Q,f as Se,t as P,y as _e,R as Ce,p as Re,i as Te,u as $e}from"./index-EkaQM1DK.js";import{C as Ae,d as Me,p as ve,e as De,r as be,f as Ee,j as ge,k as V,c as Oe,h as Z,u as Le,b as Pe,q as Fe}from"./use-builds-data-fnfxatOd.js";import{A as Be}from"./arrow-left-DMvAWA8r.js";import{C as I}from"./chevron-right-BjKVUlB_.js";import{s as He}from"./labels-C21SA4JG.js";import{B as Ue,S as je,P as _}from"./BugReportButton-BpgWvmZo.js";import{C as Ie}from"./circle-x-BZbFCixZ.js";import{C as Je}from"./circle-check-CfP79QE2.js";import{S as E}from"./stat-tile-BY0RDTRm.js";import{C as z}from"./copy-W00zUBwN.js";import{A as Ve}from"./arrow-up-right-Ba0e2GeU.js";import{A as ze}from"./arrow-right-BEQgxmKT.js";import{f as Ke,a as ee,C as Ne,b as We,s as Xe,L as Ye,n as te}from"./line-chart-9P3RxScy.js";import{E as M}from"./EmptyState-DkUVmANo.js";import{A as qe}from"./activity-C9bE7Jm8.js";import{V as Ge}from"./video-off-eh69-FKB.js";import{D as ye}from"./download-CGz-MS3y.js";import{T as Qe,a as Ze,b as re,c as T,d as et,e as $}from"./Table-DrKjlL00.js";import{M as tt}from"./Modal-D6XfQHPr.js";import{N as rt}from"./network-DfIhNVJv.js";import"./time-D-gjmE1o.js";import"./index-DWHTp1YP.js";const st=4e3,se=e=>!!e&&typeof e=="object"&&typeof e.id=="string"&&typeof e.status=="string";function at(e){const[r,s]=x.useState(null),[a,n]=x.useState([]),[l,c]=x.useState([]),[i,d]=x.useState([]),[u,N]=x.useState([]),[p,v]=x.useState(!0),[g,j]=x.useState(null),[y,w]=x.useState(!1),[A,C]=x.useState(0),b=x.useRef(null);x.useEffect(()=>{if(!e){s(null),n([]),c([]),d([]),N([]),w(!1),v(!1);return}let m=!0;return b.current!==e&&v(!0),Promise.all([k.getSession(e),k.getSessionLogs(e),k.getDeviceLogs(e),k.getDebugLogs(e),k.getProfilingData(e).catch(()=>[])]).then(([f,h,R,D,q])=>{if(!m)return;const G=se(f);s(G?f:null),G?(b.current=e,w(!1),j(null)):(w(!!f&&typeof f=="object"&&(f.error===!0||typeof f.message=="string")),j(typeof(f==null?void 0:f.message)=="string"?f.message:"Session not found")),n(Array.isArray(h)?h:[]),c(Array.isArray(R)?R:[]),d(Array.isArray(D)?D:[]),N(Array.isArray(q)?q:[])}).catch(f=>{m&&j(f instanceof Error?f.message:String(f))}).finally(()=>{m&&v(!1)}),()=>{m=!1}},[e,A]);const o=(r==null?void 0:r.status)==="running";return x.useEffect(()=>{if(!e||!o)return;let m=!0;const f=setInterval(async()=>{try{const[h,R]=await Promise.all([k.getSession(e),k.getSessionLogs(e)]);if(!m||!se(h))return;s(h),Array.isArray(R)&&n(R),h.status!=="running"&&C(D=>D+1)}catch{}},st);return()=>{m=!1,clearInterval(f)}},[e,o]),{session:r,sessionLogs:a,deviceLogs:l,debugLogs:i,profiling:u,loading:p,error:g,notFound:y,refresh:()=>C(m=>m+1)}}const ae=({buildId:e,buildName:r,sessionId:s})=>t.jsxs("nav",{"aria-label":"Breadcrumb",className:"flex items-center gap-2 px-4 py-2 border-b border-[var(--border)] bg-[var(--surface)]",children:[t.jsxs(Q,{to:"/builds",className:"inline-flex items-center gap-1.5 text-xs text-[var(--text-muted)] hover:text-[var(--text)] transition-colors",children:[t.jsx(Be,{className:"h-3.5 w-3.5"}),"Sessions"]}),t.jsx(I,{className:"h-3 w-3 text-[var(--text-dim)]"}),r&&t.jsxs(t.Fragment,{children:[t.jsx(Q,{to:`/builds/${e}`,className:"text-[11px] text-[var(--color-accent)] hover:underline",children:r}),t.jsx(I,{className:"h-3 w-3 text-[var(--text-dim)]"})]}),t.jsxs("span",{className:"font-mono text-[11px] text-[var(--text-muted)]",title:s,children:["#",s.slice(0,8)]})]}),nt={passed:{label:"Passed",Icon:Je,cls:"text-[var(--color-success)]"},failed:{label:"Failed",Icon:Ie,cls:"text-[var(--color-danger)]"},running:{label:"Running",Icon:Se,cls:"text-[var(--color-warning)]"},other:{Icon:Ae,cls:"text-[var(--text-dim)]"}};function K(e){const r=Oe(e),s=nt[r];return{bucket:r,...s,label:s.label??He(e||"unknown")}}const it=({session:e})=>{var l,c;const r=K(e.status),s=Me(e),a=[ve(e),e.device_version].filter(i=>i&&i!=="—").join(" "),n=[[De(e),a].filter(Boolean).join(" · "),be(e.ranOn),(l=e.owner)==null?void 0:l.name,Ee(e.startTime),ge(V(e))].filter(i=>i&&i!=="—");return t.jsxs("header",{className:"flex items-start justify-between gap-4 px-4 py-4 border-b border-[var(--border)] bg-[var(--surface)]",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium shrink-0 ${r.cls}`,children:[t.jsx(r.Icon,{className:`h-3.5 w-3.5 ${r.bucket==="running"?"animate-spin":""}`,"aria-hidden":"true"}),r.label]}),t.jsx("h1",{className:`text-lg font-semibold truncate ${s.source==="name"?"text-[var(--text)]":"text-[var(--text-muted)]"}`,title:s.source==="name"?s.text:`${s.text}
2
+ Unnamed session. Set xe:options.name in its capabilities to name it.`,children:s.text})]}),t.jsx("p",{"data-testid":"outcome-meta",className:"mt-1 text-xs text-[var(--text-muted)] tabular-nums truncate",title:((c=e.owner)==null?void 0:c.email)??void 0,children:n.join(" · ")})]}),t.jsx("div",{className:"shrink-0",children:t.jsx(Ue,{sessionId:e.id,mode:"full",variant:"inline"})})]})};function ot(e,r=8){if(!e)return[];const s=e.split(/\r?\n/),a=[];for(const n of s){const l=n.trim();if(/^at\s+/.test(l)&&(a.push(l),a.length>=r))break}return a}function W(e){return e?e.split(/[_\s]+/).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" "):""}function ne(e){if(!e)return{};try{const r=JSON.parse(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}function ie(e,r=200){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{const s=JSON.stringify(e);return s.length>r?s.slice(0,r)+"…":s}catch{return String(e)}}const F=e=>e.command_name||e.title||"command",J=e=>{const r=e.createdAt?Date.parse(e.createdAt):NaN;return Number.isFinite(r)?r:0},X=e=>[...e].sort((r,s)=>J(r)-J(s));function B(e){return e.is_success===!1||e.is_error===!0}function we(e){const r=[];let s=null;for(const a of X(e))a.is_healed&&a.healing_tier&&!r.includes(a.healing_tier)&&r.push(a.healing_tier),typeof a.duration=="number"&&(!s||a.duration>s.ms)&&(s={name:F(a),ms:a.duration});return{total:e.length,failed:e.filter(B).length,healed:e.filter(a=>a.is_healed).length,healedTiers:r,slowest:s,screenshots:e.filter(a=>a.screenshot).length}}const oe=(e,r)=>r?e?`${e}=${r}`:r:null;function lt(e){return X(e.filter(r=>r.is_healed)).map(r=>({id:r.id,command:F(r),original:oe(r.original_strategy,r.original_selector),healed:oe(r.healed_strategy,r.healed_selector),tier:r.healing_tier??null,confidence:typeof r.healing_confidence=="number"?Math.round(r.healing_confidence*100):null,at:r.createdAt}))}function ct(e){var r;if(!e.response)return null;try{const s=(r=JSON.parse(e.response))==null?void 0:r.value;if(!s||typeof s!="object")return null;const a=typeof s.message=="string"?s.message.trim():"";return a||(typeof s.error=="string"&&s.error?s.error:null)}catch{return null}}function dt(e){if(e.length===0)return{spanMs:0,bars:[]};const r=e.map(n=>{const l=J(n),c=typeof n.duration=="number"&&n.duration>0?n.duration:0;return{l:n,start:l-c,end:l,durationMs:c}}),s=Math.min(...r.map(n=>n.start)),a=Math.max(...r.map(n=>n.end));return{spanMs:Math.max(1,a-s),bars:r.sort((n,l)=>n.start-l.start).map(({l:n,start:l,durationMs:c})=>({id:n.id,label:F(n),startMs:l-s,durationMs:c,failed:B(n),healed:!!n.is_healed}))}}function xt(e){return X(e.filter(r=>r.screenshot)).map(r=>({id:r.id,path:r.screenshot,command:F(r),at:r.createdAt,failed:B(r)}))}function L(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const r=Math.round(e/1e3);return`${Math.floor(r/60)}m ${r%60}s`}const mt=({session:e,commands:r})=>{var c,i;const s=K(e.status),a=we(r),n=ge(V(e)),l=s.bucket==="failed"?W(e.failure_category)||"No category recorded":s.bucket==="running"?`Running for ${n}`:`Ran ${n}`;return t.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[t.jsx(E,{label:"Result",value:s.label,valueCls:s.cls,note:l,noteTone:s.bucket==="failed"?"bad":"neutral"}),t.jsx(E,{label:"Commands",value:a.total,note:a.failed>0?`${a.failed} failed`:"None failed",noteTone:a.failed>0?"bad":"neutral"}),t.jsx(E,{label:"Self-healing",value:a.healed>0?`${a.healed} healed`:"None",note:a.healed>0?a.healedTiers.join(", ")||"Tier not recorded":"No selector needed healing"}),t.jsx(E,{label:"Slowest command",value:L((c=a.slowest)==null?void 0:c.ms),note:((i=a.slowest)==null?void 0:i.name)??"No timings recorded"})]})};function ut(e){const r=e.filter(B),s=r[r.length-1];return s?{command:s.command_name||s.title||"command",message:ct(s)}:null}function ht(e,r,s,a,n){var u;const l=W(e.failure_category),c=((u=e.device_name)==null?void 0:u.trim())||"Unknown Device",i=e.device_version?` ${e.device_version}`:"",d=n?`${n.command}${n.message?`: ${n.message}`:""}`:"(no failed command recorded)";return[`**Session:** ${e.id}`,`**Build:** ${r} (#${s})`,`**Device:** ${c} (${e.node_id||"unknown-node"}) · ${e.device_platform||"unknown"}${i}`,`**Duration:** ${a}`,`**Failure category:** ${l||"(uncategorized)"}`,`**Failure reason:** ${e.failure_reason||"(not set)"}`,`**First failed command:** ${d}`,...e.ai_analysis?[`**AI analysis:** ${e.ai_analysis}`]:[]].join(`
3
+ `)}function ft({text:e}){return t.jsx(t.Fragment,{children:e.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((r,s)=>/^\*\*[^*]+\*\*$/.test(r)?t.jsx("strong",{children:r.slice(2,-2)},s):/^`[^`]+`$/.test(r)?t.jsx("code",{className:"font-mono text-[11px] px-1 rounded bg-[var(--surface-2)]",children:r.slice(1,-1)},s):t.jsx(Ce.Fragment,{children:r},s))})}const O=({children:e})=>t.jsx("div",{className:"text-[11px] font-semibold text-[var(--text-dim)] mb-1",children:e}),pt=({session:e,buildName:r,buildId:s,commands:a,durationText:n})=>{var y;const{toast:l}=P(),[c,i]=x.useState(!1),d=W(e.failure_category),u=ut(a),N=ot(e.failure_reason),p=(y=e.ai_analysis)==null?void 0:y.trim(),v=!!p&&p.length>480,g=async()=>{const w=ht(e,r,s,n,u);try{await navigator.clipboard.writeText(w),l("Failure report copied","success")}catch{l("Clipboard unavailable","error")}},j=e.failure_category?`/xenon/runbooks/${encodeURIComponent(e.failure_category.toLowerCase())}`:void 0;return t.jsxs("section",{className:"rounded-lg border border-[var(--red)]/30 bg-[var(--surface)] overflow-hidden",children:[t.jsxs("header",{className:"flex items-center justify-between gap-4 px-4 py-3 border-b border-[var(--border)] bg-[var(--red)]/5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(_e,{className:"h-4 w-4 text-[var(--red)]","aria-hidden":"true"}),t.jsx("h2",{className:"text-sm font-semibold text-[var(--red)]",children:"Why it failed"}),d&&t.jsx("span",{className:"text-[11px] text-[var(--text-dim)] ml-2",children:d})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:g,className:"inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors",children:[t.jsx(z,{className:"h-3 w-3"}),"Copy"]}),t.jsxs("a",{...j?{href:j,target:"_blank",rel:"noreferrer"}:{"aria-disabled":!0,onClick:w=>w.preventDefault()},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors ${j?"":"opacity-50 cursor-not-allowed"}`,title:j?"Open runbook in new tab":"No runbook — failure category not set",children:[t.jsx(Ve,{className:"h-3 w-3"}),"Open runbook"]})]})]}),t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx(O,{children:"Reason"}),t.jsx("div",{className:"text-sm text-[var(--text)] break-words",children:e.failure_reason||t.jsx("span",{className:"text-[var(--text-dim)]",children:"(not set)"})})]}),t.jsxs("div",{children:[t.jsx(O,{children:"First failed command"}),u?t.jsxs("div",{className:"flex items-baseline gap-2 min-w-0 text-sm",children:[t.jsx("span",{className:"font-mono text-xs text-[var(--color-danger)] shrink-0",children:u.command}),u.message&&t.jsx("span",{className:"text-[var(--text-muted)] break-words min-w-0",children:u.message})]}):t.jsx("span",{className:"text-sm text-[var(--text-dim)]",children:"No failed command recorded."})]}),p&&t.jsxs("div",{"data-testid":"ai-analysis",children:[t.jsx(O,{children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(je,{className:"h-3 w-3","aria-hidden":"true"}),"AI analysis"]})}),t.jsx("div",{className:`text-sm text-[var(--text)] whitespace-pre-wrap break-words ${v&&!c?"line-clamp-6":""}`,children:t.jsx(ft,{text:p})}),v&&t.jsx("button",{type:"button",onClick:()=>i(w=>!w),"aria-expanded":c,className:"mt-1 text-xs text-[var(--color-accent)] hover:underline",children:c?"Show less":"Show all"})]}),N.length>0&&t.jsxs("div",{children:[t.jsx(O,{children:"Stack trace"}),t.jsx("pre",{className:"rounded-md border border-[var(--border)] bg-[var(--bg)] p-3 font-mono text-[11px] leading-relaxed text-[var(--color-accent)] overflow-x-auto",children:N.join(`
4
+ `)})]})]})]})};function vt(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}k`:String(e)}function H(e){const r=e.timestamp;if(!r){const c=e.createdAt;return c?H({timestamp:c}):"--:--:--"}const s=typeof r=="number"?new Date(r):new Date(String(r));if(Number.isNaN(s.getTime()))return"--:--:--";const a=String(s.getHours()).padStart(2,"0"),n=String(s.getMinutes()).padStart(2,"0"),l=String(s.getSeconds()).padStart(2,"0");return`${a}:${n}:${l}`}function bt(e){if(e.is_healed===!0)return{label:String(e.command_name||"healed"),tone:"amber"};if(e.is_success===!1||e.is_error===!0)return{label:String(e.command_name||e.title||"error"),tone:"red"};if(e.is_success===!0)return{label:String(e.command_name||e.title||"ok"),tone:"green"};const r=e.title||e.event||e.command_name;return typeof r=="string"?/stop|fail|error/i.test(r)?{label:r,tone:"red"}:/start|begin|init/i.test(r)?{label:r,tone:"green"}:{label:r,tone:"blue"}:{label:"log",tone:"neutral"}}function gt(e){if(e==null)return"";if(typeof e=="string")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return String(e)}}function jt(e){if(!e||typeof e!="string")return[{text:String(e??""),kind:"plain"}];const r=[],s=/("(?:\\.|[^"\\])*")(\s*:)|("(?:\\.|[^"\\])*")|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|\b(true|false)\b|\b(null)\b|([{}[\],])/g;let a=0,n;for(;(n=s.exec(e))!==null;)n.index>a&&r.push({text:e.slice(a,n.index),kind:"plain"}),n[1]&&n[2]!==void 0?(r.push({text:n[1],kind:"key"}),r.push({text:n[2],kind:"punct"})):n[3]?r.push({text:n[3],kind:"string"}):n[4]?r.push({text:n[4],kind:"number"}):n[5]?r.push({text:n[5],kind:"boolean"}):n[6]?r.push({text:n[6],kind:"null"}):n[7]&&r.push({text:n[7],kind:"punct"}),a=s.lastIndex;return a<e.length&&r.push({text:e.slice(a),kind:"plain"}),r}function Nt(e){const r=e,s=typeof r.title=="string"&&r.title.trim()?r.title.trim():null,a=typeof r.command_name=="string"&&r.command_name.trim()?r.command_name.trim():null;return s??a??"Command"}function le(e){const r=e.subtitle;return typeof r=="string"&&r.trim()?r.trim():null}function yt(e,r){return r?e.filter(s=>s.is_success===!1||s.is_error===!0):e}const wt=({commands:e})=>{const r=lt(e);return r.length===0?null:t.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[t.jsxs("header",{className:"flex items-center gap-2 px-4 py-3 border-b border-[var(--border)]",children:[t.jsx(je,{className:"h-4 w-4 text-[var(--color-warning)]","aria-hidden":"true"}),t.jsx("h2",{className:"text-sm font-semibold text-[var(--text)]",children:"Self-healing"}),t.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:[r.length," selector",r.length===1?"":"s"," healed. Update the test so the next run doesn't need to."]})]}),t.jsxs("table",{className:"w-full table-fixed text-left",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-[var(--border)] text-[11px] text-[var(--text-dim)]",children:[t.jsx("th",{className:"px-4 py-2 font-medium w-[88px]",children:"Time"}),t.jsx("th",{className:"px-3 py-2 font-medium w-[128px]",children:"Command"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Asked for"}),t.jsx("th",{className:"w-[28px]",children:t.jsx("span",{className:"sr-only",children:"healed to"})}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Healed to"}),t.jsx("th",{className:"px-3 py-2 font-medium w-[112px]",children:"Tier"}),t.jsx("th",{className:"px-4 py-2 font-medium w-[96px] text-right",children:"Confidence"})]})}),t.jsx("tbody",{children:r.map((s,a)=>t.jsxs("tr",{className:"border-b border-[var(--border)] last:border-b-0 align-top",children:[t.jsx("td",{className:"px-4 py-2 text-xs text-[var(--text-muted)] tabular-nums",children:H({timestamp:s.at??null})}),t.jsx("td",{className:"px-3 py-2 text-xs text-[var(--text)] truncate",children:s.command}),t.jsx("td",{className:"px-3 py-2 font-mono text-[11px] text-[var(--text-muted)] break-all",children:s.original??"—"}),t.jsx("td",{className:"py-2 text-[var(--text-dim)]",children:t.jsx(ze,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),t.jsx("td",{className:"px-3 py-2 font-mono text-[11px] text-[var(--text)] break-all",children:s.healed??"—"}),t.jsx("td",{className:"px-3 py-2 text-xs text-[var(--text)]",children:s.tier??"—"}),t.jsx("td",{className:"px-4 py-2 text-xs text-[var(--text)] tabular-nums text-right",children:s.confidence===null?"—":`${s.confidence}%`})]},s.id??a))})]})]})},kt=1e4,ce="var(--color-info)",de="var(--color-accent)",St="var(--border-strong)";function xe(e){return e>=1024?te(e/1024)*1024:te(e)}const me=e=>{let r=0;for(const s of e)for(const a of s.values)a!==null&&a>r&&(r=a);return r},U=({title:e,series:r,times:s,yMax:a,format:n,ariaLabel:l})=>t.jsxs("section",{"aria-label":e,children:[t.jsxs("div",{className:"mb-2 flex flex-wrap items-baseline gap-x-4 gap-y-1",children:[t.jsx("h3",{className:"text-xs font-semibold text-[var(--text)]",children:e}),r.map(c=>{const i=Xe(c.values);return t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] tabular-nums text-[var(--text-muted)]",children:[t.jsx("span",{className:"inline-block h-0.5 w-3 shrink-0",style:{background:c.color}}),t.jsx("span",{className:"max-w-[16rem] truncate",title:c.label,children:c.label}),i&&(c.dashed?t.jsx("span",{children:n(i.peak)}):t.jsxs("span",{children:["peak ",n(i.peak)," · avg ",n(i.average)]}))]},c.key)})]}),t.jsx(Ye,{times:s,series:r,yMax:a,formatValue:n,ariaLabel:l})]}),_t=({sessionId:e,running:r,hasTrace:s})=>{const[a,n]=x.useState(null),[l,c]=x.useState(!1);x.useEffect(()=>{let o=!0;const m=()=>k.getSessionMetrics(e).then(h=>{o&&(n(We(h)),c(!0))}).catch(()=>{o&&c(!0)});if(m(),!r)return()=>{o=!1};const f=setInterval(()=>void m(),kt);return()=>{o=!1,clearInterval(f)}},[e,r]);const i=(a==null?void 0:a.samples)??[],d=x.useMemo(()=>i.map(o=>{var m;return o.t-(((m=i[0])==null?void 0:m.t)??0)}),[i]),u=new Set(i.map(o=>o.app).filter(o=>!!o)),N=u.size>1?"Foreground app":Array.from(u)[0]??(a==null?void 0:a.appId)??"App",p=i.map(o=>o.app??null),v=o=>o>0&&!!p[o]&&!!p[o-1]&&p[o]!==p[o-1],g=[],j=[],y=[];a&&(a.series.deviceCpu&&g.push({key:"deviceCpu",label:"Device",color:ce,values:i.map(o=>o.deviceCpu)}),a.series.appCpu&&g.push({key:"appCpu",label:N,color:de,values:i.map((o,m)=>v(m)?null:o.appCpu),pointLabels:p}),a.series.appMem&&j.push({key:"appMem",label:N,color:de,values:i.map((o,m)=>v(m)?null:o.appMemMb),pointLabels:p}),a.series.deviceMem&&(y.push({key:"deviceMem",label:"Device used",color:ce,values:i.map(o=>o.deviceMemMb)}),y.push({key:"deviceTotal",label:"Device total",color:St,values:i.map(o=>o.deviceMemTotalMb),dashed:!0})));const w=r&&(a==null?void 0:a.recording)==="off",A=(a==null?void 0:a.recording)==="stopped",C="Recording stopped: the device stopped responding.";let b;return l?w?b=t.jsx(M,{title:"Performance isn't recorded for this session",description:"CPU and memory are recorded for Android devices and iPhones connected to this server. This session runs on an iOS simulator or on a device connected to another machine, or recording is turned off."}):i.length===0&&!r?b=t.jsx(M,{title:"No performance data for this session",description:"CPU and memory are recorded for Android devices and iPhones connected to this server. This session ran on an iOS simulator or on a device connected to another machine, before recording was available, or with recording turned off."}):i.length<2?b=t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:A?C:r?"Collecting… The first figures appear within 10 seconds.":"Too few figures were recorded to draw a chart."}):b=t.jsxs("div",{className:"space-y-4",children:[A&&t.jsxs("p",{className:"text-xs text-[var(--color-warning)]",children:[C," The data ends there."]}),(a==null?void 0:a.platform)==="ios"&&t.jsxs("p",{className:"text-xs text-[var(--text-dim)]",children:["On iPhones, only the device's overall CPU is recorded.",s?" For more detail, download the Performance trace under Details.":""]}),g.length>0&&t.jsx(U,{title:"CPU",series:g,times:d,yMax:100,format:Ke,ariaLabel:"CPU over the session"}),j.length>0&&t.jsx(U,{title:"App memory",series:j,times:d,yMax:xe(me(j)),format:ee,ariaLabel:"App memory over the session"}),y.length>0&&t.jsx(U,{title:"Device memory",series:y,times:d,yMax:xe(me(y)),format:ee,ariaLabel:"Device memory over the session"})]}):b=t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:"Loading performance…"}),t.jsx(Ne,{header:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(qe,{size:14})," Performance"]}),children:b})},Ct=({session:e})=>{const r=e.status==="running",s=!!e.video_recording;return t.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[t.jsxs("header",{className:"px-3 py-2 border-b border-[var(--border)] flex items-center justify-between",children:[t.jsx("span",{className:"text-[11px] font-semibold text-[var(--text-dim)]",children:"Recording"}),r&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-[var(--red)]",children:[t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-[var(--red)] pulse-dot"}),"Live"]})]}),t.jsx("div",{className:"aspect-video bg-[var(--bg)] flex items-center justify-center",children:r&&e.has_live_video?t.jsx("img",{src:k.getSessionLiveVideoUrl(e.id),alt:`Live view of session ${e.id}`,className:"w-full h-full object-contain"}):s?t.jsx("video",{controls:!0,src:k.getAssetUrl(e.video_recording),className:"w-full h-full object-contain"}):t.jsxs("div",{className:"flex flex-col items-center text-center px-6 py-8 gap-2",children:[t.jsx("div",{className:"h-10 w-10 rounded-full bg-[var(--surface-2)] border border-[var(--border)] flex items-center justify-center",children:t.jsx(Ge,{className:"h-5 w-5 text-[var(--text-dim)]"})}),t.jsx("div",{className:"text-sm text-[var(--text)] font-medium",children:"No video available"}),t.jsx("div",{className:"text-xs text-[var(--text-dim)] max-w-xs",children:e.status==="failed"?"Session failed before recording started.":e.video_recording_enabled===!1?"Recording was disabled for this session.":"No recording was captured."})]})})]})},S=({label:e,children:r,title:s,mono:a})=>t.jsxs("div",{className:"flex items-baseline justify-between gap-3 px-3 py-2",children:[t.jsx("dt",{className:"text-xs text-[var(--text-muted)] shrink-0",children:e}),t.jsx("dd",{className:`text-xs text-[var(--text)] text-right min-w-0 break-all ${a?"font-mono text-[11px]":""}`,title:s,children:r})]}),Rt=({session:e,buildName:r})=>{var c,i;const{toast:s}=P(),a=be(e.ranOn),n=e.performance_trace?k.getAssetUrl(e.performance_trace):"",l=async()=>{try{await navigator.clipboard.writeText(e.id),s("Session ID copied","success")}catch{s("Clipboard unavailable","error")}};return t.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[t.jsx("header",{className:"px-3 py-2 border-b border-[var(--border)]",children:t.jsx("h2",{className:"text-[11px] font-semibold text-[var(--text-dim)]",children:"Details"})}),t.jsxs("dl",{className:"divide-y divide-[var(--border)]",children:[t.jsx(S,{label:"Session ID",mono:!0,children:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:e.id}),t.jsx("button",{type:"button",onClick:l,"aria-label":"Copy session ID",className:"p-0.5 rounded text-[var(--text-dim)] hover:text-[var(--text)]",children:t.jsx(z,{className:"h-3 w-3"})})]})}),r&&t.jsx(S,{label:"Build",children:r}),t.jsx(S,{label:"Device UDID",mono:!0,children:e.device_udid||"—"}),t.jsx(S,{label:"Platform",children:[ve(e),e.device_version].filter(d=>d&&d!=="—").join(" ")||"—"}),t.jsx(S,{label:"Ran on",title:e.node_id?`Node ${e.node_id}`:void 0,children:a??"Not known"}),t.jsx(S,{label:"Run by",title:(c=e.owner)==null?void 0:c.email,children:((i=e.owner)==null?void 0:i.name)??"Not recorded"}),t.jsx(S,{label:"Started",children:Z(e.startTime)}),t.jsx(S,{label:"Ended",children:e.endTime?Z(e.endTime):"—"}),e.tags&&t.jsx(S,{label:"Tags",children:e.tags}),n&&t.jsx(S,{label:"iOS trace",children:t.jsxs("a",{href:n,className:"inline-flex items-center gap-1 text-[var(--color-accent)] hover:underline",children:[t.jsx(ye,{className:"h-3 w-3","aria-hidden":"true"}),"Performance trace"]})})]})]})},ue={desired:"Requested",session:"Actual"},Tt=({session:e})=>{const[r,s]=x.useState("desired"),a=ne(e.desired_capabilities),n=ne(e.session_capabilities),c=Object.entries(r==="desired"?a:n);return t.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] overflow-hidden",children:[t.jsx("header",{className:"flex items-center border-b border-[var(--border)]",children:["desired","session"].map(i=>t.jsx("button",{type:"button",onClick:()=>s(i),"aria-pressed":r===i,className:`flex-1 h-9 text-[11px] font-semibold transition-colors border-b-2 ${r===i?"border-[var(--color-accent)] text-[var(--text)]":"border-transparent text-[var(--text-muted)] hover:text-[var(--text)]"}`,children:ue[i]},i))}),c.length===0?t.jsxs("div",{className:"px-3 py-6 text-center text-xs text-[var(--text-dim)]",children:["No ",ue[r].toLowerCase()," capabilities recorded for this session."]}):t.jsx("dl",{className:"divide-y divide-[var(--border)]",children:c.map(([i,d])=>t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] items-baseline gap-3 px-3 py-2",children:[t.jsx("dt",{className:"text-xs text-[var(--text-muted)] break-all",children:i}),t.jsx("dd",{className:"font-mono text-xs text-[var(--text)] truncate text-right min-w-0",title:ie(d,500),children:ie(d)})]},i))})]})},$t=({tabs:e,active:r,onChange:s,errorsOnly:a,onErrorsOnlyChange:n,showErrorsOnly:l=!0})=>{const c=e.filter(i=>!(i.hideWhenEmpty&&i.count===0));return t.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 border-b border-[var(--border)] bg-[var(--surface)]",children:[t.jsx("div",{className:"flex items-center gap-1 overflow-x-auto",children:c.map(i=>{const d=i.key===r;return t.jsxs("button",{type:"button",onClick:()=>s(i.key),"aria-pressed":d,"data-empty":i.count===0?"true":"false",className:`relative inline-flex items-center gap-1.5 h-9 px-3 text-xs whitespace-nowrap transition-colors ${d?"text-[var(--text)]":i.count===0?"text-[var(--text-dim)] hover:text-[var(--text-muted)]":"text-[var(--text-muted)] hover:text-[var(--text)]"}`,children:[t.jsx("span",{children:i.label}),i.count>0&&t.jsx("span",{className:`text-[10px] tabular-nums ${d?"text-[var(--text-muted)]":"text-[var(--text-dim)]"}`,children:vt(i.count)}),d&&t.jsx("span",{className:"absolute left-2 right-2 bottom-0 h-[2px] bg-[var(--color-accent)] rounded-t"})]},i.key)})}),l&&t.jsxs("label",{className:"inline-flex items-center gap-2 text-[11px] text-[var(--text-muted)] cursor-pointer select-none whitespace-nowrap",children:[t.jsx("input",{type:"checkbox",checked:a,onChange:i=>n(i.target.checked),"aria-label":"Show only error rows"}),"Errors only"]})]})},At={key:"text-[var(--blue)]",string:"text-[var(--color-accent)]",number:"text-[var(--amber)]",boolean:"text-[var(--amber)]",null:"text-[var(--text-dim)] italic",punct:"text-[var(--text-muted)]",plain:"text-[var(--text)]"},Mt=({value:e,maxHeightPx:r})=>{const s=gt(e);if(!s)return t.jsx("span",{className:"text-[var(--text-dim)] text-xs",children:"(empty)"});let a;try{a=jt(s)}catch{a=[{text:s,kind:"plain"}]}return t.jsx("pre",{className:"font-mono text-[11px] leading-relaxed bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 overflow-x-auto whitespace-pre",style:r?{maxHeight:r,overflowY:"auto"}:void 0,children:a.map((n,l)=>t.jsx("span",{className:At[n.kind],children:n.text},l))})},Dt={green:"bg-[var(--color-success)]",red:"bg-[var(--red)]",amber:"bg-[var(--amber)]",blue:"bg-[var(--blue)]",neutral:"bg-[var(--text-dim)]"},Et={green:"text-[var(--color-success)]",red:"text-[var(--red)]",amber:"text-[var(--amber)]",blue:"text-[var(--blue)]",neutral:"text-[var(--text-muted)]"},Ot=({log:e})=>{const[r,s]=x.useState(!1),{toast:a}=P(),n=H(e),l=bt(e),c=async i=>{i.stopPropagation();try{const d=e.body??e,u=typeof d=="string"?d:JSON.stringify(d,null,2);await navigator.clipboard.writeText(u),a("Log entry copied","success")}catch{a("Clipboard unavailable","error")}};return t.jsxs("div",{className:"border-b border-[var(--border)] last:border-b-0",children:[t.jsxs("button",{type:"button",onClick:()=>s(i=>!i),"aria-expanded":r,className:"group w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-[var(--surface-2)]/60 transition-colors",children:[t.jsx(I,{className:`h-3 w-3 text-[var(--text-dim)] transition-transform shrink-0 ${r?"rotate-90":""}`}),t.jsx("span",{className:"font-mono text-[11px] text-[var(--text-muted)] w-[64px] shrink-0",children:n}),t.jsx("span",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${Dt[l.tone]}`}),t.jsx("span",{className:`font-mono text-[11px] font-medium shrink-0 ${Et[l.tone]}`,children:l.label}),t.jsxs("span",{className:"min-w-0 flex-1 flex items-baseline gap-2 truncate",children:[t.jsx("span",{className:"text-[12px] text-[var(--text)] shrink-0",children:Nt(e)}),le(e)&&t.jsx("span",{className:"font-mono text-[11px] text-[var(--text-dim)] truncate min-w-0",children:le(e)})]}),typeof e.duration=="number"&&t.jsx("span",{className:"text-[11px] tabular-nums text-[var(--text-muted)] shrink-0",children:L(e.duration)}),t.jsx("span",{role:"button",tabIndex:0,onClick:c,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&c(i)},"aria-label":"Copy log entry",className:"opacity-0 group-hover:opacity-100 p-1 rounded text-[var(--text-dim)] hover:text-[var(--text)] transition-opacity shrink-0",children:t.jsx(z,{className:"h-3 w-3"})})]}),r&&t.jsx("div",{className:"px-3 pb-3 pl-9",children:t.jsx(Mt,{value:e.body??e,maxHeightPx:400})})]})},Lt=(e,r)=>e?"bg-[var(--color-danger)]":r?"bg-[var(--color-warning)]":"bg-[var(--color-success)]",Pt=({commands:e})=>{const{spanMs:r,bars:s}=dt(e);return s.length===0?t.jsx("div",{className:"px-4 py-10 text-center text-xs text-[var(--text-dim)]",children:"No commands recorded for this session."}):t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-center justify-between pb-2 text-[11px] text-[var(--text-dim)] tabular-nums",children:[t.jsxs("span",{children:[s.length," command",s.length===1?"":"s"," over ",L(r)]}),t.jsxs("span",{className:"inline-flex items-center gap-3",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"h-2 w-2 rounded-sm bg-[var(--color-danger)]"})," Failed"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"h-2 w-2 rounded-sm bg-[var(--color-warning)]"})," Healed"]})]})]}),t.jsx("ol",{className:"space-y-1",children:s.map((a,n)=>t.jsxs("li",{"data-testid":"timeline-bar","data-command":a.label,"data-failed":a.failed?"true":"false",className:"grid grid-cols-[128px_minmax(0,1fr)_64px] items-center gap-2",children:[t.jsx("span",{className:"truncate text-[11px] font-mono text-[var(--text-muted)]",title:a.label,children:a.label}),t.jsx("span",{className:"relative h-3 rounded-sm bg-[rgb(var(--rgb-fg)/0.05)]",children:t.jsx("span",{className:`absolute inset-y-0 rounded-sm ${Lt(a.failed,a.healed)}`,style:{left:`${a.startMs/r*100}%`,width:`max(2px, ${a.durationMs/r*100}%)`}})}),t.jsx("span",{className:"text-right text-[11px] tabular-nums text-[var(--text-muted)]",children:a.durationMs>0?L(a.durationMs):"—"})]},a.id??n))})]})},Ft=({commands:e})=>{const r=xt(e);return r.length===0?t.jsxs("div",{className:"px-4 py-10 text-center text-xs text-[var(--text-dim)]",children:["No screenshots were kept. A failed command keeps one unless"," ",t.jsx("code",{className:"font-mono",children:"xe:options.screenshotOnFailure"})," is false; set"," ",t.jsx("code",{className:"font-mono",children:"xe:options.screenshotOnEveryCommand"})," to keep one for every command."]}):t.jsx("ul",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-3 p-3",children:r.map((s,a)=>{const n=k.getAssetUrl(s.path),l=H({timestamp:s.at??null});return t.jsx("li",{children:t.jsxs("a",{href:n,target:"_blank",rel:"noreferrer",className:`block rounded-md border overflow-hidden hover:border-[var(--border-strong)] ${s.failed?"border-[var(--color-danger)]":"border-[var(--border)]"}`,children:[t.jsx("img",{src:n,alt:`${s.command} at ${l}`,loading:"lazy",className:"block w-full aspect-[9/16] object-contain bg-[rgb(var(--rgb-fg)/0.03)]"}),t.jsxs("span",{className:"flex items-center justify-between gap-2 px-2 py-1 text-[11px]",children:[t.jsx("span",{className:`truncate font-mono ${s.failed?"text-[var(--color-danger)]":"text-[var(--text)]"}`,children:s.command}),t.jsx("span",{className:"tabular-nums text-[var(--text-dim)] shrink-0",children:l})]})]})},s.id??a)})})},he=["commands","device","debug","profiling"],Bt=({sessionLogs:e,deviceLogs:r,debugLogs:s,profiling:a})=>{const[n,l]=x.useState("commands"),[c,i]=x.useState(!1),d=e,u=x.useMemo(()=>we(d).screenshots,[d]),N=x.useMemo(()=>[{key:"commands",label:"Commands",count:e.length},{key:"timeline",label:"Timeline",count:e.length},{key:"screenshots",label:"Screenshots",count:u},{key:"device",label:"Device logs",count:r.length},{key:"debug",label:"Debug logs",count:s.length},{key:"profiling",label:"System profiling",count:a.length,hideWhenEmpty:!0}],[e.length,u,r.length,s.length,a.length]),p=x.useMemo(()=>{let v=[];return n==="commands"?v=e:n==="device"?v=r:n==="debug"?v=s:n==="profiling"&&(v=a),yt(v,c)},[n,e,r,s,a,c]);return t.jsxs("section",{className:"rounded-lg border border-[var(--border)] bg-[var(--surface)] flex flex-col min-h-[280px] max-h-[640px]",children:[t.jsx($t,{tabs:N,active:n,onChange:l,errorsOnly:c,onErrorsOnlyChange:i,showErrorsOnly:he.includes(n)}),t.jsxs("div",{className:"flex-1 overflow-y-auto",children:[n==="timeline"&&t.jsx(Pt,{commands:d}),n==="screenshots"&&t.jsx(Ft,{commands:d}),he.includes(n)&&(p.length===0?t.jsx("div",{className:"px-4 py-10 text-center text-xs text-[var(--text-dim)]",children:c?"No error rows in this tab.":"No log entries in this tab."}):p.map((v,g)=>t.jsx(Ot,{log:v},v.id??g)))]})]})};function ke(e){if(!e)return"failed";switch(e){case"HTTPS_CLIENT_ERROR":case"HTTPS_SERVER_ERROR":case"OPEN_HTTPS_SERVER_ERROR":case"ON_CONNECT_ERROR":return"tls";case"PROXY_TO_SERVER_REQUEST_ERROR":return"net";default:return"failed"}}const Y="/xenon/api/interceptor";async function Ht(e){const r=await fetch(`${Y}/sessions/${encodeURIComponent(e)}/requests`);if(r.status===404){const a=await r.json().catch(()=>({}));return{active:!1,error:a==null?void 0:a.error}}return r.ok?{active:!0,requests:(await r.json()).requests||[]}:{active:!1,error:`request failed (${r.status})`}}async function Ut(e,r){const s=await fetch(`${Y}/sessions/${encodeURIComponent(e)}/requests/${encodeURIComponent(r)}`);return s.ok?s.json():null}function It(e){return`${Y}/sessions/${encodeURIComponent(e)}/har`}function Jt(e){return e>=200&&e<300?"ready":e>=300&&e<400?"neutral":e>=400&&e<500?"busy":e>=500?"error":"neutral"}const fe=({headers:e})=>{const r=Object.entries(e||{});return r.length===0?t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:"No headers"}):t.jsx("div",{className:"space-y-0.5 font-mono text-xs",children:r.map(([s,a])=>t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("span",{className:"text-[var(--text-dim)] shrink-0",children:[s,":"]}),t.jsx("span",{className:"break-all",children:a})]},s))})},pe=({body:e})=>{if(e==null||e==="")return t.jsx("div",{className:"text-xs text-[var(--text-dim)]",children:"No body"});let r=e;try{r=JSON.stringify(JSON.parse(e),null,2)}catch{}return t.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-all bg-[var(--surface-2,var(--surface))] rounded p-2 max-h-64 overflow-auto",children:r})},Vt=({request:e,onClose:r})=>{if(!e)return null;const s=t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(_,{tone:"accent",children:e.method}),e.failed?t.jsx(_,{tone:"error",children:ke(e.failureKind)}):t.jsx(_,{tone:Jt(e.resStatus),children:e.resStatus||"—"}),t.jsx("span",{className:"font-mono text-xs truncate",title:e.url,children:e.url})]});return t.jsx(tt,{open:!!e,title:s,onClose:r,width:720,children:t.jsxs("div",{className:"space-y-4 text-xs",children:[e.failed&&t.jsxs("div",{className:"border border-[var(--red)] rounded p-2 bg-[rgb(var(--rgb-red-600)/0.08)]",children:[t.jsx("div",{className:"text-[var(--red)] text-[11px] mb-1",children:"Failure"}),t.jsx("div",{className:"text-xs",children:e.failureReason||"Request failed"}),e.failureKind&&t.jsx("div",{className:"font-mono text-[10px] text-[var(--text-dim)] mt-1",children:e.failureKind})]}),!e.failed&&t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Duration"}),t.jsxs("div",{className:"font-mono",children:[e.durationMs," ms"]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Flags"}),t.jsxs("div",{className:"flex gap-1",children:[e.mocked&&t.jsx(_,{tone:"accent",children:"mocked"}),e.modified&&t.jsx(_,{tone:"busy",children:"modified"}),!e.mocked&&!e.modified&&t.jsx("span",{className:"text-[var(--text-dim)]",children:"passthrough"})]})]})]}),e.commandHint&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Triggered by"}),t.jsx("div",{className:"font-mono",children:e.commandHint.commandName})]}),!e.failed&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Request Headers"}),t.jsx(fe,{headers:e.reqHeaders})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Request Body"}),t.jsx(pe,{body:e.reqBody})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Response Headers"}),t.jsx(fe,{headers:e.resHeaders})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[var(--text-dim)] text-[11px] mb-1",children:"Response Body"}),t.jsx(pe,{body:e.resBody})]})]})]})})};function zt(e){return e?new Date(e).toLocaleTimeString(void 0,{hour12:!1}):"—"}function Kt(e){return e>=200&&e<300?"ready":e>=300&&e<400?"neutral":e>=400&&e<500?"busy":e>=500?"error":"neutral"}const Wt=({sessionId:e,sessionEnded:r})=>{const[s,a]=x.useState(null),[n,l]=x.useState(null),[c,i]=x.useState([]),[d,u]=x.useState(!0),[N,p]=x.useState(null),v=x.useRef(new Set),{on:g,isConnected:j}=Re();x.useEffect(()=>{let o=!0;return u(!0),Ht(e).then(m=>{if(!o)return;a(m.active),l(m.error||null);const f=m.requests||[];i(f),v.current=new Set(f.map(h=>h.id))}).finally(()=>{o&&u(!1)}),()=>{o=!1}},[e]),x.useEffect(()=>{if(r)return;const o=g("interceptor_request",h=>{!h||h.sessionId!==e||v.current.has(h.id)||(v.current.add(h.id),i(R=>[h,...R]),a(!0))}),m=g("interceptor_session_started",h=>{(h==null?void 0:h.sessionId)===e&&a(!0)}),f=g("interceptor_session_stopped",h=>{(h==null?void 0:h.sessionId)===e&&a(!1)});return()=>{o(),m(),f()}},[g,e,r,j]);const y=x.useMemo(()=>[...c].sort((o,m)=>m.ts-o.ts),[c]),w=async o=>{if(p(o),s){const m=await Ut(e,o.id);m&&p(m)}},A=s&&c.length>0?t.jsxs("a",{href:It(e),className:"inline-flex items-center gap-1 text-xs text-[var(--text-dim)] hover:text-[var(--text)]",title:"Download HAR",children:[t.jsx(ye,{className:"h-3 w-3"}),"HAR"]}):null,C=t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(rt,{className:"h-3.5 w-3.5 text-[var(--text-dim)]"}),t.jsx("span",{children:"Network"}),s&&c.length>0&&t.jsxs("span",{className:"text-xs text-[var(--text-dim)]",children:["(",c.length,")"]})]});let b;return d?b=t.jsx("div",{className:"p-4 text-xs text-[var(--text-dim)]",children:"Loading…"}):s===!1&&r?b=t.jsx(M,{title:"No network capture",description:"Network interception was not enabled for this session."}):s===!1?b=t.jsx(M,{title:"Network interception disabled",description:"Enable interceptor.enabled in plugin config to capture requests for Android sessions."}):n?b=t.jsxs("div",{className:"p-4 text-xs text-[var(--red)]",children:["Failed to load requests: ",n]}):y.length===0?b=t.jsx(M,{title:"Waiting for requests",description:r?"No HTTP traffic was captured during this session.":"Captured requests will appear here as the device makes calls."}):b=t.jsx("div",{className:"overflow-auto max-h-96",children:t.jsxs(Qe,{children:[t.jsx(Ze,{children:t.jsxs(re,{children:[t.jsx(T,{style:{width:80},children:"Time"}),t.jsx(T,{style:{width:70},children:"Method"}),t.jsx(T,{style:{width:70},children:"Status"}),t.jsx(T,{children:"Host"}),t.jsx(T,{children:"Path"}),t.jsx(T,{style:{width:80},children:"Duration"}),t.jsx(T,{style:{width:90},children:"Flags"})]})}),t.jsx(et,{children:y.map(o=>t.jsxs(re,{onClick:()=>w(o),style:{cursor:"pointer"},title:o.failed?o.failureReason:void 0,children:[t.jsx($,{className:"font-mono text-[11px]",children:zt(o.ts)}),t.jsx($,{children:t.jsx(_,{tone:"accent",children:o.method})}),t.jsx($,{children:o.failed?t.jsx(_,{tone:"error",children:ke(o.failureKind)}):t.jsx(_,{tone:Kt(o.resStatus),children:o.resStatus||"—"})}),t.jsx($,{className:"font-mono text-[11px] truncate",title:o.host,children:o.host}),t.jsx($,{className:"font-mono text-[11px] truncate",title:o.path,children:o.failed?"—":o.path}),t.jsx($,{className:"font-mono text-[11px]",children:o.failed?"—":`${o.durationMs}ms`}),t.jsx($,{children:t.jsxs("div",{className:"flex gap-1",children:[o.mocked&&t.jsx(_,{tone:"accent",children:"mock"}),o.modified&&t.jsx(_,{tone:"busy",children:"mod"})]})})]},o.id))})]})}),t.jsxs(t.Fragment,{children:[t.jsx(Ne,{header:C,action:A,padded:!1,children:b}),t.jsx(Vt,{request:N,onClose:()=>p(null)})]})},pr=()=>{const{buildId:e="",sessionId:r=""}=Te(),{toast:s}=P(),a=$e(),n=Le(),l=at(r||null),c=x.useMemo(()=>n.builds.find(p=>p.id===e)??null,[n.builds,e]),i=c?Pe(c):"Build";if(x.useEffect(()=>{!l.loading&&l.notFound&&(s("Session not available — it may belong to a team you are not on.","info"),a("/builds",{replace:!0}))},[l.loading,l.notFound,a,s]),l.loading)return t.jsx("div",{className:"p-6 text-xs text-[var(--text-dim)]",children:"Loading session…"});if(l.error||!l.session)return t.jsxs("div",{className:"p-6 space-y-2",children:[t.jsx(ae,{buildId:e,buildName:c?i:null,sessionId:r}),t.jsx("div",{className:"mt-6 rounded-md border border-[var(--red)]/30 bg-[var(--surface)] p-4 text-xs text-[var(--red)]",children:l.error||"Session not found."})]});const d=l.session,u=l.sessionLogs,N=K(d.status).bucket==="failed";return t.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[t.jsx(ae,{buildId:e,buildName:c?i:null,sessionId:d.id}),t.jsx(it,{session:d}),t.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden",children:t.jsxs("div",{className:"px-4 py-4 space-y-4",children:[t.jsx(mt,{session:d,commands:u}),N&&t.jsx(pt,{session:d,buildName:i,buildId:e,commands:u,durationText:Fe(V(d))}),t.jsx(wt,{commands:u}),t.jsx(_t,{sessionId:d.id,running:d.status==="running",hasTrace:!!d.performance_trace}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_340px] gap-4",children:[t.jsx("div",{className:"min-w-0",children:t.jsx(Bt,{sessionLogs:l.sessionLogs,deviceLogs:l.deviceLogs,debugLogs:l.debugLogs,profiling:l.profiling})}),t.jsxs("div",{className:"flex flex-col gap-4 min-w-0",children:[t.jsx(Ct,{session:d}),t.jsx(Rt,{session:d,buildName:c?i:null}),t.jsx(Tt,{session:d})]})]}),t.jsx(Wt,{sessionId:d.id,sessionEnded:d.status!=="running"})]})})]})};export{pr as SessionDetailPage,pr as default};
@@ -1,4 +1,4 @@
1
- import{c as q,t as B,r,p as P,X as g,j as e,A as V,O as X,C as G,e as O,P as U,Q as K}from"./index-CzaIyL9t.js";/* empty css */import{S as j,A as Q}from"./SettingCard-Dx3WhK7w.js";import{M as W}from"./Modal-DNmn2RDs.js";import{B as A}from"./button-C0caCjJB.js";import{P as J}from"./page-header-ZdzNEJp9.js";import{C as I}from"./circle-check-DnQ263fa.js";import{C as Y}from"./clock-XP3iBAhg.js";import{M as Z}from"./mouse-pointer-2-CDAwphUm.js";import{C as ee}from"./check-DYSXRG79.js";import{A as ae}from"./activity-cNHHOKx5.js";import{C as se}from"./calendar-BqOOkln_.js";import{A as te}from"./arrow-up-right-e7yBOb-c.js";import"./index-IefGCFQQ.js";import"./utils-CDN07tui.js";/**
1
+ import{c as q,t as B,r,p as P,X as g,j as e,A as V,O as X,C as G,e as O,P as U,Q as K}from"./index-EkaQM1DK.js";/* empty css */import{S as j,A as Q}from"./SettingCard-C4DioTTi.js";import{M as W}from"./Modal-D6XfQHPr.js";import{B as A}from"./button-WW9j43wR.js";import{P as J}from"./page-header-DoD3TOzZ.js";import{C as I}from"./circle-check-CfP79QE2.js";import{C as Y}from"./clock-BuTm35Qg.js";import{M as Z}from"./mouse-pointer-2-DsWDMyrY.js";import{C as ee}from"./check-D8ifHIJR.js";import{A as ae}from"./activity-C9bE7Jm8.js";import{C as se}from"./calendar-COUs9VxF.js";import{A as te}from"./arrow-up-right-Ba0e2GeU.js";import"./index-DWHTp1YP.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.
@@ -0,0 +1 @@
1
+ import{j as t}from"./index-EkaQM1DK.js";const d={neutral:"text-[var(--text-muted)]",good:"text-[var(--color-success)]",bad:"text-[var(--color-danger)]"},o=({label:e,value:r,valueCls:a="text-[var(--text)]",note:s,noteTone:x="neutral"})=>t.jsxs("div",{className:"min-w-0 rounded-lg border border-[var(--border)] bg-[var(--surface)] px-4 py-3",children:[t.jsx("div",{className:"text-xs text-[var(--text-muted)]",children:e}),t.jsx("div",{className:`mt-1 text-2xl font-semibold tabular-nums leading-tight truncate ${a}`,children:r}),t.jsx("div",{className:`mt-0.5 text-[11px] truncate ${d[x]}`,children:s??" "})]});export{o as S};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-CzaIyL9t.js";/**
1
+ import{c as e}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{t as A,r as n,j as e,A as I,W as f,q as $}from"./index-CzaIyL9t.js";/* empty css */import{a as F}from"./time-B8FIgwPE.js";import{T as E,a as M,b as T,c as u,d as U,e as p}from"./Table-D_2lhvRM.js";import{F as Y}from"./FieldGroup-CUmbJZxI.js";import{P as R}from"./page-header-ZdzNEJp9.js";import{M as K}from"./Modal-DNmn2RDs.js";import{B as D}from"./button-C0caCjJB.js";import{I as Q}from"./input-BqFzAQT3.js";import{S as P}from"./select-CiRW6v17.js";import{l as V}from"./users-CZqCE511.js";import{P as N}from"./plus-1k0sxXyU.js";import{A as X}from"./arrow-left-CnYs8HVw.js";import{T as L}from"./trash-2-u8MlXUBD.js";import"./index-IefGCFQQ.js";import"./utils-CDN07tui.js";const B={SUPER_ADMIN:"Super admin",ADMIN:"Admin",MEMBER:"Member"};async function j(i,r){const t=await fetch(i,{credentials:"include",...r});if(!t.ok){const c=await t.json().catch(()=>({}));throw Object.assign(new Error(c.error||`HTTP ${t.status}`),{status:t.status})}return t.json()}const ve=()=>{const{toast:i}=A(),[r,t]=n.useState([]),[c,m]=n.useState(!0),[l,h]=n.useState(!1),[x,d]=n.useState(!1),[_,C]=n.useState(null),v=async()=>{m(!0);try{const a=await j("/xenon/api/teams");t(a),h(!1)}catch(a){a.status===403?h(!0):i(`Failed to load teams: ${a.message}`,"error")}finally{m(!1)}};if(n.useEffect(()=>{v()},[]),c)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(I,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading teams…"})]});if(l)return e.jsx("div",{className:"settings-container",children:e.jsx(R,{icon:f,title:"Teams",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to promote your key before you can manage teams."]})})});if(_)return e.jsx(se,{team:_,onBack:()=>{C(null),v()}});const S=r.reduce((a,o)=>a+o.deviceCount,0),y=r.reduce((a,o)=>a+o.memberCount,0);return e.jsxs("div",{className:"settings-container",children:[e.jsx(R,{icon:f,title:"Teams",subtitle:"Group devices and members by team. Devices with no team assignment stay in the shared pool — visible to every authenticated user.",action:r.length>0?e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"New team"})]}):void 0}),e.jsxs("div",{className:"settings-content",children:[r.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:r.length}),e.jsx("div",{className:"stat-strip__label",children:"Teams"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:y}),e.jsx("div",{className:"stat-strip__label",children:"Members"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:S}),e.jsx("div",{className:"stat-strip__label",children:"Devices assigned"})]})]}),r.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx(f,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No teams yet"}),e.jsx("p",{className:"empty-state__copy",children:"Every device is in the shared pool until you create a team and assign it. Teams let you scope an API key to a subset of devices — useful for separating CI runners, staging fleets, or per-team device pools."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"Create your first team"})]})]}):e.jsx("div",{className:"team-grid",children:r.map(a=>e.jsxs("button",{type:"button",className:"team-card",onClick:()=>C(a),children:[e.jsxs("div",{className:"team-card__header",children:[e.jsx("div",{className:"team-card__icon",children:e.jsx(f,{size:16})}),e.jsxs("div",{className:"team-card__title",children:[e.jsx("div",{className:"team-card__name",children:a.name}),e.jsx("div",{className:"team-card__id",children:a.id.slice(0,8)})]}),e.jsx("span",{className:"team-card__delete",role:"button",tabIndex:0,onClick:o=>o.stopPropagation(),children:e.jsx(ee,{team:a,onDeleted:v})})]}),e.jsxs("div",{className:"team-card__metrics",children:[e.jsxs("div",{className:"team-card__metric",children:[e.jsx($,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.deviceCount}),e.jsx("span",{className:"team-card__metric-label",children:"devices"})]}),e.jsxs("div",{className:"team-card__metric",children:[e.jsx(f,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.memberCount}),e.jsx("span",{className:"team-card__metric-label",children:"members"})]})]}),e.jsxs("div",{className:"team-card__footer",children:["Created ",F(a.createdAt)]})]},a.id))})]}),x&&e.jsx(Z,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},Z=({onClose:i,onCreated:r})=>{const{toast:t}=A(),[c,m]=n.useState(""),[l,h]=n.useState(!1),x=async()=>{if(!c.trim())return t("Name required","error");h(!0);try{await j("/xenon/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.trim()})}),t("Team created","success"),r()}catch(d){t(d.message,"error")}finally{h(!1)}};return e.jsx(K,{open:!0,onClose:i,title:"New team",footer:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:i,disabled:l,children:"Cancel"}),e.jsxs(D,{variant:"primary",onClick:x,disabled:l,children:[l?e.jsx(I,{className:"animate-spin",size:18}):e.jsx(N,{size:18}),l?"Creating…":"Create"]})]}),children:e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.jsx(Y,{label:"Name",htmlFor:"team-name",children:e.jsx(Q,{id:"team-name",type:"text",value:c,onChange:d=>m(d.target.value),placeholder:"android-team, qa-ios, …",className:"w-full",autoFocus:!0})})})})},ee=({team:i,onDeleted:r})=>{const{toast:t}=A(),[c,m]=n.useState(!1),l=async h=>{if(h.stopPropagation(),!!window.confirm(`Delete team "${i.name}"? It must have no devices, members or apps.`)){m(!0);try{await j(`/xenon/api/teams/${i.id}`,{method:"DELETE"}),t("Team deleted","success"),r()}catch(x){t(x.message,"error")}finally{m(!1)}}};return e.jsxs("button",{className:"reset-btn",disabled:c,onClick:l,style:{color:"var(--status-error-fg)"},children:[e.jsx(L,{size:14}),c?"Deleting…":"Delete"]})},se=({team:i,onBack:r})=>{const{toast:t}=A(),[c,m]=n.useState([]),[l,h]=n.useState([]),[x,d]=n.useState([]),[_,C]=n.useState([]),[v,S]=n.useState(!0),[y,a]=n.useState(""),[o,k]=n.useState(""),b=async()=>{S(!0);try{const[s,g,W]=await Promise.all([j(`/xenon/api/teams/${i.id}/members`),V(),j("/xenon/api/device")]);m(s),h(g);const z=W;d(z.filter(w=>w.teamId===i.id)),C(z.filter(w=>!w.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{S(!1)}};n.useEffect(()=>{b()},[i.id]);const O=async()=>{if(y)try{await j(`/xenon/api/teams/${i.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:y})}),t("Member added","success"),a(""),b()}catch(s){t(s.message,"error")}},H=async s=>{if(window.confirm("Remove this member from the team?"))try{await j(`/xenon/api/teams/${i.id}/members/${encodeURIComponent(s)}`,{method:"DELETE"}),t("Member removed","success"),b()}catch(g){t(g.message,"error")}},J=async()=>{if(o)try{await j(`/xenon/api/device/${encodeURIComponent(o)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:i.id})}),t("Device assigned","success"),k(""),b()}catch(s){t(s.message,"error")}},q=async s=>{if(window.confirm("Return this device to the shared pool?"))try{await j(`/xenon/api/device/${encodeURIComponent(s)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:null})}),t("Device unassigned","success"),b()}catch(g){t(g.message,"error")}},G=l.filter(s=>!c.some(g=>g.userId===s.id));return e.jsxs("div",{className:"settings-container mesh-gradient-infra",children:[e.jsxs("div",{className:"settings-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:r,className:"reset-btn",style:{padding:"4px 8px"},"aria-label":"Back",children:e.jsx(X,{size:18})}),e.jsxs("div",{className:"settings-title-group",children:[e.jsx(f,{className:"settings-icon infra-icon",size:28}),e.jsx("h2",{children:i.name})]})]}),e.jsx("p",{className:"settings-subtitle",children:'Manage members and devices assigned to this team. To add a device, go to Devices and use "Assign to team."'})]}),v?e.jsx("div",{className:"settings-loading",children:e.jsx(I,{className:"animate-spin",size:32})}):e.jsxs("div",{className:"settings-content",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Members (",c.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs(P,{value:y,onChange:s=>a(s.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"Select a user to add…"}),G.map(s=>e.jsxs("option",{value:s.id,children:[s.name," (",s.email,") — ",B[s.role]]},s.id))]}),e.jsxs(D,{variant:"primary",onClick:O,disabled:!y,children:[e.jsx(N,{size:16})," Add"]})]}),c.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No members yet. Add a user above."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Email"}),e.jsx(u,{children:"Role"}),e.jsx(u,{children:"Added"}),e.jsx(u,{style:{textAlign:"right"},children:"Action"})]})}),e.jsx(U,{children:c.map(s=>e.jsxs(T,{children:[e.jsx(p,{children:s.name}),e.jsx(p,{children:e.jsx("code",{style:{fontSize:"11px",color:"var(--text-muted)"},children:s.email})}),e.jsx(p,{children:B[s.role]}),e.jsx(p,{children:F(s.addedAt)}),e.jsx(p,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>H(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(L,{size:14})})})]},s.userId))})]})]})]}),e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Devices (",x.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs(P,{value:o,onChange:s=>k(s.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"Select a shared-pool device to assign…"}),_.map(s=>e.jsxs("option",{value:s.udid,children:[s.name," (",s.platform,") — ",s.udid.slice(0,12),"…"]},s.udid))]}),e.jsxs(D,{variant:"primary",onClick:J,disabled:!o,children:[e.jsx(N,{size:16})," Assign"]})]}),x.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No devices assigned. Use the Devices page to move devices into this team."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Platform"}),e.jsx(u,{children:"UDID"}),e.jsx(u,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(U,{children:x.map(s=>e.jsxs(T,{children:[e.jsxs(p,{children:[e.jsx($,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),s.name]}),e.jsx(p,{children:s.platform}),e.jsx(p,{children:e.jsxs("code",{style:{fontSize:"11px"},children:[s.udid.slice(0,14),"…"]})}),e.jsx(p,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>q(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})};export{ve as Teams};
1
+ import{t as A,r as n,j as e,A as I,W as f,q as $}from"./index-EkaQM1DK.js";/* empty css */import{a as F}from"./time-D-gjmE1o.js";import{T as E,a as M,b as T,c as u,d as U,e as p}from"./Table-DrKjlL00.js";import{F as Y}from"./FieldGroup-mbfnfTql.js";import{P as R}from"./page-header-DoD3TOzZ.js";import{M as K}from"./Modal-D6XfQHPr.js";import{B as D}from"./button-WW9j43wR.js";import{I as Q}from"./input-ChaTXeCq.js";import{S as P}from"./select-CTcD4jWR.js";import{l as V}from"./users-CrcjmRdf.js";import{P as N}from"./plus-BGvWvpBB.js";import{A as X}from"./arrow-left-DMvAWA8r.js";import{T as L}from"./trash-2-CJCKBOP9.js";import"./index-DWHTp1YP.js";import"./utils-CDN07tui.js";const B={SUPER_ADMIN:"Super admin",ADMIN:"Admin",MEMBER:"Member"};async function j(i,r){const t=await fetch(i,{credentials:"include",...r});if(!t.ok){const c=await t.json().catch(()=>({}));throw Object.assign(new Error(c.error||`HTTP ${t.status}`),{status:t.status})}return t.json()}const ve=()=>{const{toast:i}=A(),[r,t]=n.useState([]),[c,m]=n.useState(!0),[l,h]=n.useState(!1),[x,d]=n.useState(!1),[_,C]=n.useState(null),v=async()=>{m(!0);try{const a=await j("/xenon/api/teams");t(a),h(!1)}catch(a){a.status===403?h(!0):i(`Failed to load teams: ${a.message}`,"error")}finally{m(!1)}};if(n.useEffect(()=>{v()},[]),c)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(I,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading teams…"})]});if(l)return e.jsx("div",{className:"settings-container",children:e.jsx(R,{icon:f,title:"Teams",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to promote your key before you can manage teams."]})})});if(_)return e.jsx(se,{team:_,onBack:()=>{C(null),v()}});const S=r.reduce((a,o)=>a+o.deviceCount,0),y=r.reduce((a,o)=>a+o.memberCount,0);return e.jsxs("div",{className:"settings-container",children:[e.jsx(R,{icon:f,title:"Teams",subtitle:"Group devices and members by team. Devices with no team assignment stay in the shared pool — visible to every authenticated user.",action:r.length>0?e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"New team"})]}):void 0}),e.jsxs("div",{className:"settings-content",children:[r.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:r.length}),e.jsx("div",{className:"stat-strip__label",children:"Teams"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:y}),e.jsx("div",{className:"stat-strip__label",children:"Members"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:S}),e.jsx("div",{className:"stat-strip__label",children:"Devices assigned"})]})]}),r.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx(f,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No teams yet"}),e.jsx("p",{className:"empty-state__copy",children:"Every device is in the shared pool until you create a team and assign it. Teams let you scope an API key to a subset of devices — useful for separating CI runners, staging fleets, or per-team device pools."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(N,{size:16}),e.jsx("span",{children:"Create your first team"})]})]}):e.jsx("div",{className:"team-grid",children:r.map(a=>e.jsxs("button",{type:"button",className:"team-card",onClick:()=>C(a),children:[e.jsxs("div",{className:"team-card__header",children:[e.jsx("div",{className:"team-card__icon",children:e.jsx(f,{size:16})}),e.jsxs("div",{className:"team-card__title",children:[e.jsx("div",{className:"team-card__name",children:a.name}),e.jsx("div",{className:"team-card__id",children:a.id.slice(0,8)})]}),e.jsx("span",{className:"team-card__delete",role:"button",tabIndex:0,onClick:o=>o.stopPropagation(),children:e.jsx(ee,{team:a,onDeleted:v})})]}),e.jsxs("div",{className:"team-card__metrics",children:[e.jsxs("div",{className:"team-card__metric",children:[e.jsx($,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.deviceCount}),e.jsx("span",{className:"team-card__metric-label",children:"devices"})]}),e.jsxs("div",{className:"team-card__metric",children:[e.jsx(f,{size:13}),e.jsx("span",{className:"team-card__metric-value",children:a.memberCount}),e.jsx("span",{className:"team-card__metric-label",children:"members"})]})]}),e.jsxs("div",{className:"team-card__footer",children:["Created ",F(a.createdAt)]})]},a.id))})]}),x&&e.jsx(Z,{onClose:()=>d(!1),onCreated:()=>{d(!1),v()}})]})},Z=({onClose:i,onCreated:r})=>{const{toast:t}=A(),[c,m]=n.useState(""),[l,h]=n.useState(!1),x=async()=>{if(!c.trim())return t("Name required","error");h(!0);try{await j("/xenon/api/teams",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.trim()})}),t("Team created","success"),r()}catch(d){t(d.message,"error")}finally{h(!1)}};return e.jsx(K,{open:!0,onClose:i,title:"New team",footer:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"secondary",onClick:i,disabled:l,children:"Cancel"}),e.jsxs(D,{variant:"primary",onClick:x,disabled:l,children:[l?e.jsx(I,{className:"animate-spin",size:18}):e.jsx(N,{size:18}),l?"Creating…":"Create"]})]}),children:e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:e.jsx(Y,{label:"Name",htmlFor:"team-name",children:e.jsx(Q,{id:"team-name",type:"text",value:c,onChange:d=>m(d.target.value),placeholder:"android-team, qa-ios, …",className:"w-full",autoFocus:!0})})})})},ee=({team:i,onDeleted:r})=>{const{toast:t}=A(),[c,m]=n.useState(!1),l=async h=>{if(h.stopPropagation(),!!window.confirm(`Delete team "${i.name}"? It must have no devices, members or apps.`)){m(!0);try{await j(`/xenon/api/teams/${i.id}`,{method:"DELETE"}),t("Team deleted","success"),r()}catch(x){t(x.message,"error")}finally{m(!1)}}};return e.jsxs("button",{className:"reset-btn",disabled:c,onClick:l,style:{color:"var(--status-error-fg)"},children:[e.jsx(L,{size:14}),c?"Deleting…":"Delete"]})},se=({team:i,onBack:r})=>{const{toast:t}=A(),[c,m]=n.useState([]),[l,h]=n.useState([]),[x,d]=n.useState([]),[_,C]=n.useState([]),[v,S]=n.useState(!0),[y,a]=n.useState(""),[o,k]=n.useState(""),b=async()=>{S(!0);try{const[s,g,W]=await Promise.all([j(`/xenon/api/teams/${i.id}/members`),V(),j("/xenon/api/device")]);m(s),h(g);const z=W;d(z.filter(w=>w.teamId===i.id)),C(z.filter(w=>!w.teamId))}catch(s){t(`Failed to load team detail: ${s.message}`,"error")}finally{S(!1)}};n.useEffect(()=>{b()},[i.id]);const O=async()=>{if(y)try{await j(`/xenon/api/teams/${i.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:y})}),t("Member added","success"),a(""),b()}catch(s){t(s.message,"error")}},H=async s=>{if(window.confirm("Remove this member from the team?"))try{await j(`/xenon/api/teams/${i.id}/members/${encodeURIComponent(s)}`,{method:"DELETE"}),t("Member removed","success"),b()}catch(g){t(g.message,"error")}},J=async()=>{if(o)try{await j(`/xenon/api/device/${encodeURIComponent(o)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:i.id})}),t("Device assigned","success"),k(""),b()}catch(s){t(s.message,"error")}},q=async s=>{if(window.confirm("Return this device to the shared pool?"))try{await j(`/xenon/api/device/${encodeURIComponent(s)}/team`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({teamId:null})}),t("Device unassigned","success"),b()}catch(g){t(g.message,"error")}},G=l.filter(s=>!c.some(g=>g.userId===s.id));return e.jsxs("div",{className:"settings-container mesh-gradient-infra",children:[e.jsxs("div",{className:"settings-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:r,className:"reset-btn",style:{padding:"4px 8px"},"aria-label":"Back",children:e.jsx(X,{size:18})}),e.jsxs("div",{className:"settings-title-group",children:[e.jsx(f,{className:"settings-icon infra-icon",size:28}),e.jsx("h2",{children:i.name})]})]}),e.jsx("p",{className:"settings-subtitle",children:'Manage members and devices assigned to this team. To add a device, go to Devices and use "Assign to team."'})]}),v?e.jsx("div",{className:"settings-loading",children:e.jsx(I,{className:"animate-spin",size:32})}):e.jsxs("div",{className:"settings-content",style:{display:"flex",flexDirection:"column",gap:24},children:[e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Members (",c.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs(P,{value:y,onChange:s=>a(s.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"Select a user to add…"}),G.map(s=>e.jsxs("option",{value:s.id,children:[s.name," (",s.email,") — ",B[s.role]]},s.id))]}),e.jsxs(D,{variant:"primary",onClick:O,disabled:!y,children:[e.jsx(N,{size:16})," Add"]})]}),c.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No members yet. Add a user above."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Email"}),e.jsx(u,{children:"Role"}),e.jsx(u,{children:"Added"}),e.jsx(u,{style:{textAlign:"right"},children:"Action"})]})}),e.jsx(U,{children:c.map(s=>e.jsxs(T,{children:[e.jsx(p,{children:s.name}),e.jsx(p,{children:e.jsx("code",{style:{fontSize:"11px",color:"var(--text-muted)"},children:s.email})}),e.jsx(p,{children:B[s.role]}),e.jsx(p,{children:F(s.addedAt)}),e.jsx(p,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>H(s.userId),style:{color:"var(--status-error-fg)"},"aria-label":"Remove member",title:"Remove member",children:e.jsx(L,{size:14})})})]},s.userId))})]})]})]}),e.jsxs("section",{children:[e.jsxs("h3",{style:{marginBottom:12},children:["Devices (",x.length,")"]}),e.jsxs("div",{className:"surface-card",style:{padding:12},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12},children:[e.jsxs(P,{value:o,onChange:s=>k(s.target.value),className:"flex-1",children:[e.jsx("option",{value:"",children:"Select a shared-pool device to assign…"}),_.map(s=>e.jsxs("option",{value:s.udid,children:[s.name," (",s.platform,") — ",s.udid.slice(0,12),"…"]},s.udid))]}),e.jsxs(D,{variant:"primary",onClick:J,disabled:!o,children:[e.jsx(N,{size:16})," Assign"]})]}),x.length===0?e.jsx("p",{style:{opacity:.6,textAlign:"center",padding:24},children:"No devices assigned. Use the Devices page to move devices into this team."}):e.jsxs(E,{children:[e.jsx(M,{children:e.jsxs(T,{children:[e.jsx(u,{children:"Name"}),e.jsx(u,{children:"Platform"}),e.jsx(u,{children:"UDID"}),e.jsx(u,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(U,{children:x.map(s=>e.jsxs(T,{children:[e.jsxs(p,{children:[e.jsx($,{size:14,style:{marginRight:6,verticalAlign:"middle"}}),s.name]}),e.jsx(p,{children:s.platform}),e.jsx(p,{children:e.jsxs("code",{style:{fontSize:"11px"},children:[s.udid.slice(0,14),"…"]})}),e.jsx(p,{style:{textAlign:"right"},children:e.jsx("button",{className:"reset-btn",onClick:()=>q(s.udid),children:"Return to shared pool"})})]},s.udid))})]})]})]})]})]})};export{ve as Teams};
@@ -0,0 +1 @@
1
+ const a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function u(t){if(t==null||t==="")return"—";const e=t instanceof Date?t:new Date(t);if(Number.isNaN(e.getTime()))return"—";const n=r=>String(r).padStart(2,"0");return`${a[e.getMonth()]} ${e.getDate()}, ${n(e.getHours())}:${n(e.getMinutes())}:${n(e.getSeconds())}`}function g(t){if(t==null||t==="")return"—";const e=t instanceof Date?t:new Date(t);return Number.isNaN(e.getTime())?"—":`${a[e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`}export{g as a,u as f};
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-CzaIyL9t.js";/**
1
+ import{c as a}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-CzaIyL9t.js";/**
1
+ import{c as a}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1,8 @@
1
+ import{c as G,r as o,p as V,X as v}from"./index-EkaQM1DK.js";import{f as Z}from"./time-D-gjmE1o.js";/**
2
+ * @license lucide-react v0.555.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const K=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],fe=G("circle-dashed",K);function N(e){switch(e){case"success":case"passed":case"ended":return"passed";case"failed":case"error":case"timeout":return"failed";case"running":return"running";default:return"other"}}function de(e){const t={all:e.length,passed:0,failed:0,running:0};for(const n of e){const r=N(n.status);r!=="other"&&(t[r]+=1)}return t}function Q(e,t){return t==="all"?!0:N(e.status)===t}function pe(e,t,n){const r=n.trim().toLowerCase();return e.filter(s=>{var c,d;return!(!Q(s,t)||r&&![s.id,H(s).text,s.name,s.failure_reason,s.device_name,s.device_platform,s.device_version,s.node_id,s.ranOn,(c=s.owner)==null?void 0:c.name,(d=s.owner)==null?void 0:d.email].filter(Boolean).join(" ").toLowerCase().includes(r))})}function W(e){var n;const t=(n=e.device_name)==null?void 0:n.trim();return t&&t.length>0?t:"Unknown Device"}function ee(e){const t=e.device_platform??"";if(!t)return"—";const n=t.toLowerCase();return n==="ios"?"iOS":n==="tvos"?"tvOS":n.charAt(0).toUpperCase()+n.slice(1)}function me(e){return Z(e)}function he(e){if(!e.startTime)return null;const t=Date.parse(e.startTime);if(!Number.isFinite(t))return null;const n=e.endTime?Date.parse(e.endTime):Date.now();return Number.isFinite(n)?Math.max(0,n-t):null}function ge(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3,n=Math.floor(t/3600),r=Math.floor(t%3600/60),c=(t-n*3600-r*60).toFixed(1);return n>0?`${n}h ${r}m ${c}s`:r>0?`${r}m ${c}s`:`${c}s`}const j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_=e=>String(e).padStart(2,"0");function w(e,t){const n=e[`appium:${t}`]??e[t];return typeof n=="string"&&n.trim()?n.trim():null}function te(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;let n=t;if(n.capabilities&&typeof n.capabilities=="object"&&(n=n.capabilities),n.alwaysMatch||n.firstMatch){const r=Array.isArray(n.firstMatch)?n.firstMatch[0]:void 0;return{...n.alwaysMatch||{},...r||{}}}return n}function O(e){const t=te(e);if(!t)return null;const n=w(t,"appPackage")??w(t,"bundleId");if(n)return n;const r=w(t,"app");if(r){const s=r.split(/[?#]/)[0].split(/[\\/]/).pop()??"";if(s&&s!=="download")return s}return w(t,"browserName")}function H(e){var r;const t=(r=e.name)==null?void 0:r.trim();if(t)return{text:t,source:"name"};const n=O(e.session_capabilities)??O(e.desired_capabilities);return n?{text:n,source:"app"}:{text:`Session ${e.id.slice(0,8)}`,source:"id"}}function L(e){return`${j[e.getMonth()]} ${e.getDate()}, ${_(e.getHours())}:${_(e.getMinutes())}`}function Se(e){const t=e?new Date(e):null;return t&&!Number.isNaN(t.getTime())?L(t):"—"}function ne(e){var n;const t=(n=e.name)==null?void 0:n.trim();return!t||t==="Default Build"}function Me(e){if(!ne(e))return e.name.trim();const t=new Date(e.createdAt);return Number.isNaN(t.getTime())?"Build":`Build · ${L(t)}`}const ye={all:"All time","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days"},re={"24h":864e5,"7d":7*864e5,"30d":30*864e5};function se(e,t){return e==="all"?null:new Date(t-re[e]).toISOString()}function be(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e<1e3)return"<1s";const t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),s=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${s}s`:`${s}s`}function $e(e,t=new Date){if(!e)return"—";const n=new Date(e);if(Number.isNaN(n.getTime()))return"—";const r=`${_(n.getHours())}:${_(n.getMinutes())}`;return n.getFullYear()!==t.getFullYear()?`${j[n.getMonth()]} ${n.getDate()}, ${n.getFullYear()} ${r}`:n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()?r:L(n)}function R(e){const t=e.passed+e.failed;return t>0?e.passed/t*100:null}function ve(e,t){const n=R(e),r=t?R(t):null;return n===null||r===null?null:n-r}function Ae(e){return e?e==="here"?"This server":e:null}function we(e,t,n){var p,m;const r=n&&n.size>0?t.filter(i=>n.has(i.id)):t,s=r.filter(i=>N(i.status)==="failed").reverse();if(s.length===0)return{count:0,text:""};const c=n&&n.size>0?`${r.length} selected session${r.length===1?"":"s"}`:`${r.length} session${r.length===1?"":"s"}`,d=[`Failed tests in ${e}: ${s.length} of ${c}`,""];for(const i of s){const E=((m=(p=i.failure_reason)==null?void 0:p.split(`
7
+ `)[0])==null?void 0:m.trim())||"No reason recorded",S=[ee(i),i.device_version].filter(h=>h&&h!=="—").join(" ");d.push(`- ${H(i).text}`,` ${E}`,` ${[W(i),S,`session ${i.id}`].filter(Boolean).join(" · ")}`)}return{count:s.length,text:d.join(`
8
+ `)}}const ae=3e3,D=200,ie=2e3,oe=200,ue=(e,t)=>e.createdAt===t.createdAt?e.id<t.id?1:-1:e.createdAt<t.createdAt?1:-1;function P(e,t){const n=new Map;for(const r of t)n.set(r.id,r);for(const r of e)n.set(r.id,r);return Array.from(n.values()).sort(ue)}function De(e={}){const{withSessions:t=!1,timeFilter:n="all"}=e,[r,s]=o.useState([]),[c,d]=o.useState([]),[p,m]=o.useState([]),i=o.useRef([]),[E,S]=o.useState(!1),[h,F]=o.useState(!1),[M,q]=o.useState(null),[J,X]=o.useState(!0),[z,T]=o.useState(null),l=o.useRef(!0),{on:y}=V(),b=o.useCallback(()=>M?{buildId:M}:{since:se(n,Date.now())??void 0},[M,n]);o.useEffect(()=>{i.current=[],m([]),S(!1)},[M,n]);const x=o.useCallback(async()=>{if(!t)return[];const a=i.current;if(a.length===0){const f=await v.getSessions({...b(),limit:D});return Array.isArray(f)&&S(f.length===D),f}const{since:u,...k}=b(),B=a[0].createdAt,C=a.filter(f=>N(f.status)==="running").slice(0,oe).map(f=>f.id),[Y,I]=await Promise.all([v.getSessions({...k,since:u&&u>B?u:B,limit:ie}),C.length?v.getSessions({ids:C}):Promise.resolve([])]);if(l.current&&Array.isArray(I)&&I.length){const f=new Map(I.map($=>[$.id,$]));i.current=i.current.map($=>f.get($.id)??$),m(i.current)}return Y},[t,b]),g=o.useCallback(async()=>{try{const[a,u]=await Promise.all([v.getBuilds(),x()]);if(!l.current)return;s(Array.isArray(a)?a:[]),d(Array.isArray(u)?u:[]),T(null)}catch(a){if(!l.current)return;T(a instanceof Error?a.message:String(a))}finally{l.current&&X(!1)}},[x]);o.useEffect(()=>{l.current=!0,g();const a=setInterval(g,ae);return()=>{l.current=!1,clearInterval(a)}},[g]),o.useEffect(()=>{const a=()=>g(),u=[y("session_started",a),y("session_stopped",a),y("device_added",a),y("device_removed",a)];return()=>{for(const k of u)k()}},[y,g]);const A=o.useMemo(()=>P(c,p),[c,p]),U=o.useCallback(async()=>{const a=A[A.length-1];if(!(!t||h||!a)){F(!0);try{const u=await v.getSessions({...b(),before:a.createdAt,beforeId:a.id,limit:D});if(!l.current||!Array.isArray(u))return;i.current=P([],[...i.current,...u]),m(i.current),S(u.length===D)}catch(u){l.current&&T(u instanceof Error?u.message:String(u))}finally{l.current&&F(!1)}}},[A,t,h,b]);return{builds:r,selectedBuildId:M,sessions:A,loading:J,error:z,selectBuild:q,refresh:g,hasMore:E,loadingMore:h,showMore:U}}export{fe as C,re as P,D as S,ye as T,de as a,Me as b,N as c,H as d,W as e,Se as f,$e as g,me as h,ne as i,be as j,he as k,pe as l,R as m,ve as n,we as o,ee as p,ge as q,Ae as r,se as s,De as u};
@@ -1 +1 @@
1
- import{r as t,h as u}from"./index-CzaIyL9t.js";function n(){const[s,r]=t.useState(null);return t.useEffect(()=>{let e=!0;return u().then(o=>e&&r(o.passwordReset)),()=>{e=!1}},[]),s}export{n as u};
1
+ import{r as t,h as u}from"./index-EkaQM1DK.js";function n(){const[s,r]=t.useState(null);return t.useEffect(()=>{let e=!0;return u().then(o=>e&&r(o.passwordReset)),()=>{e=!1}},[]),s}export{n as u};
@@ -1 +1 @@
1
- import{o as s}from"./index-CzaIyL9t.js";const o="/xenon/api/users";async function c(){const t=await fetch(`${o}/`,{credentials:"include"});if(!t.ok)throw new Error(`listUsers failed (${t.status})`);return t.json()}async function i(t){const e=await fetch(`${o}/`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.error||`createUser failed (${e.status})`)}return e.json()}async function d(t,e){const n=await fetch(`${o}/${encodeURIComponent(t)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`updateUser failed (${n.status})`)}return n.json()}async function l(t){const e=await fetch(`${o}/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include"});if(!e.ok&&e.status!==204){const n=await e.json().catch(()=>({}));throw new Error(n.error||`deleteUser failed (${e.status})`)}}async function u(t){const e=await fetch(`${o}/${encodeURIComponent(t)}/reset-link`,{method:"POST",credentials:"include"}),n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error||`Reset link failed (${e.status})`);return n}export{i as a,u as c,l as d,c as l,d as u};
1
+ import{o as s}from"./index-EkaQM1DK.js";const o="/xenon/api/users";async function c(){const t=await fetch(`${o}/`,{credentials:"include"});if(!t.ok)throw new Error(`listUsers failed (${t.status})`);return t.json()}async function i(t){const e=await fetch(`${o}/`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(t)});if(!e.ok){const n=await e.json().catch(()=>({}));throw new Error(n.error||`createUser failed (${e.status})`)}return e.json()}async function d(t,e){const n=await fetch(`${o}/${encodeURIComponent(t)}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`updateUser failed (${n.status})`)}return n.json()}async function l(t){const e=await fetch(`${o}/${encodeURIComponent(t)}`,{method:"DELETE",credentials:"include"});if(!e.ok&&e.status!==204){const n=await e.json().catch(()=>({}));throw new Error(n.error||`deleteUser failed (${e.status})`)}}async function u(t){const e=await fetch(`${o}/${encodeURIComponent(t)}/reset-link`,{method:"POST",credentials:"include"}),n=await e.json().catch(()=>({}));if(!e.ok)throw new Error(n.error||`Reset link failed (${e.status})`);return n}export{i as a,u as c,l as d,c as l,d as u};
@@ -1,4 +1,4 @@
1
- import{c as w,b as k,r as a,j as e,$ as C}from"./index-CzaIyL9t.js";import{l as M,d as R,c as I,a as A,u as D}from"./users-CZqCE511.js";import{f as U}from"./time-B8FIgwPE.js";import{P}from"./page-header-ZdzNEJp9.js";import{B as y}from"./button-C0caCjJB.js";import{I as N}from"./input-BqFzAQT3.js";import{S as g}from"./select-CiRW6v17.js";import{P as B}from"./plus-1k0sxXyU.js";import{T as L}from"./trash-2-u8MlXUBD.js";import"./utils-CDN07tui.js";/**
1
+ import{c as w,b as k,r as a,j as e,$ as C}from"./index-EkaQM1DK.js";import{l as M,d as R,c as I,a as A,u as D}from"./users-CrcjmRdf.js";import{f as U}from"./time-D-gjmE1o.js";import{P}from"./page-header-DoD3TOzZ.js";import{B as y}from"./button-WW9j43wR.js";import{I as N}from"./input-ChaTXeCq.js";import{S as g}from"./select-CTcD4jWR.js";import{P as B}from"./plus-BGvWvpBB.js";import{T as L}from"./trash-2-CJCKBOP9.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.
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-CzaIyL9t.js";/**
1
+ import{c as o}from"./index-EkaQM1DK.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ const c=[7,30,90],s={tab:"fix",days:30,q:"",platform:"",method:"",sort:"heals",page:1,open:null},l=["fix","verifying","fixed","muted"],d=["heals","recent","time"],f={active:"fix",pending:"verifying",resolved:"fixed",muted:"muted"},g=t=>c.find(e=>String(e)===t)??s.days;function y(t){const e=t.get("tab")??"",r=t.get("sort")??"",o=Number(t.get("page")),a=t.get("selector");return{tab:l.find(n=>n===e)??f[e]??s.tab,days:g(t.get("days")),q:t.get("q")??"",platform:t.get("platform")??"",method:t.get("method")??"",sort:d.find(n=>n===r)??s.sort,page:Number.isInteger(o)&&o>=1?o:1,open:a?{strategy:t.get("strategy")??"",selector:a}:null}}function i(t){const e=new URLSearchParams;return t.tab!==s.tab&&e.set("tab",t.tab),t.days!==s.days&&e.set("days",String(t.days)),t.q&&e.set("q",t.q),t.platform&&e.set("platform",t.platform),t.method&&e.set("method",t.method),t.sort!==s.sort&&e.set("sort",t.sort),t.page!==1&&e.set("page",String(t.page)),t.open&&(e.set("strategy",t.open.strategy),e.set("selector",t.open.selector)),e}function u(t){const e=t.get("value")??"",r=t.get("strategy"),o=g(t.get("windowDays")),a=e?r!==null?{...s,days:o,open:{strategy:r,selector:e}}:{...s,days:o,q:e}:{...s,days:o},n=i(a).toString();return n?`/selector-health?${n}`:"/selector-health"}const h=t=>`${t.strategy}\0${t.selector}`;export{c as P,u as l,y as r,h as s,i as w};