@testver/testver 1.4.1 → 1.4.3

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 (102) hide show
  1. package/README.md +3 -1
  2. package/bin/testver.js +1 -1
  3. package/dist/index.js +1943 -1190
  4. package/package.json +2 -1
  5. package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
  6. package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
  7. package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
  8. package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-CHaHfmu4.js} +5 -5
  9. package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
  10. package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CDa24SCJ.js} +1 -1
  11. package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +3 -0
  12. package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-Lm8noJqC.js} +1 -1
  13. package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BvldSIik.js} +1 -1
  14. package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
  15. package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-uEjuo3fk.js} +3 -3
  16. package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-DtotgVmI.js} +1 -1
  17. package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-jNkQJA1P.js} +2 -2
  18. package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-D2fERHt9.js} +1 -1
  19. package/src/ui/static/assets/Dashboard-BaIj_IdQ.js +1 -0
  20. package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-DH0njYFG.js} +3 -3
  21. package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-utxlJ0fu.js} +1 -1
  22. package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-ouKqn9CU.js} +1 -1
  23. package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-mU3JloJ6.js} +5 -5
  24. package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-TrX-RqNC.js} +5 -5
  25. package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-CIhK_raX.js} +1 -1
  26. package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-DgEZS-0u.js} +1 -1
  27. package/src/ui/static/assets/KpiTile-BHLE3HVj.js +1 -0
  28. package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-CaIf7Jux.js} +1 -1
  29. package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
  30. package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-DNM45Uz2.js} +1 -1
  31. package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-DFKm6_nU.js} +1 -1
  32. package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
  33. package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-rni7JbsL.js} +1 -1
  34. package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-Cn2WCpJ6.js} +1 -1
  35. package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +1 -0
  36. package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-BKNdkSnx.js} +1 -1
  37. package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-5e7J8t-o.js} +1 -1
  38. package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-C1S2aclP.js} +1 -1
  39. package/src/ui/static/assets/ReportCard-D4EElEe9.js +2 -0
  40. package/src/ui/static/assets/ReportFullView-2w2ysKRg.js +1 -0
  41. package/src/ui/static/assets/ReportsPage-9Fx-IEwV.js +48 -0
  42. package/src/ui/static/assets/ResultsPage-DPkfGh-K.js +115 -0
  43. package/src/ui/static/assets/RunState-CRuS_bC2.js +1 -0
  44. package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-CPKBrefj.js} +1 -1
  45. package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
  46. package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-DubIldKj.js} +1 -1
  47. package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-BuZrrlW2.js} +1 -1
  48. package/src/ui/static/assets/SharedReportView-ig5hECRk.js +1 -0
  49. package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-BPkqRqkC.js} +1 -1
  50. package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +7 -0
  51. package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-DJiWpCne.js} +1 -1
  52. package/src/ui/static/assets/TestPlansPage-G1lvK1C0.js +5 -0
  53. package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
  54. package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
  55. package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
  56. package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-gDGhaHE4.js} +3 -3
  57. package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-BACdnU-1.js} +17 -17
  58. package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
  59. package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
  60. package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
  61. package/src/ui/static/assets/index-aInN0yoR.css +1 -0
  62. package/src/ui/static/assets/reportMeta-3kxT7BIT.js +1 -0
  63. package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
  64. package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
  65. package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DrhvBp0C.js} +1 -1
  66. package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-Dwj69Rfh.js} +1 -1
  67. package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
  68. package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
  69. package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
  70. package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-CUqC18DV.js} +1 -1
  71. package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-C2S_vaX2.js} +1 -1
  72. package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-DW6AW2mt.js} +2 -2
  73. package/src/ui/static/assets/useTestResults-yjH1aUy-.js +1 -0
  74. package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
  75. package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
  76. package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-D_Dmmj8d.js} +277 -282
  77. package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
  78. package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
  79. package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
  80. package/src/ui/static/index.html +5 -5
  81. package/src/ui/static/assets/AIPanel-D09Ni3a4.js +0 -32
  82. package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +0 -40
  83. package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +0 -9
  84. package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +0 -19
  85. package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
  86. package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +0 -2
  87. package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
  88. package/src/ui/static/assets/DiffViewer-DPglzjPH.js +0 -2
  89. package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
  90. package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
  91. package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
  92. package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
  93. package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
  94. package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
  95. package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
  96. package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
  97. package/src/ui/static/assets/index-B0klHYbO.css +0 -1
  98. package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
  99. package/src/ui/static/assets/useOwnership-eW6Egd7X.js +0 -1
  100. package/src/ui/static/assets/useSuites-CvtMGakZ.js +0 -1
  101. package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
  102. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
@@ -1,3 +0,0 @@
1
- import{r as n,j as e,u as at,n as wt}from"./vendor-react-CTbHBddL.js";import{u as kt}from"./useTabParam-ChbOedP1.js";import{u as fe,a as Ct}from"./vendor-query-BrzmPFT3.js";import{s as St,k as rt,l as Rt,m as Pt,n as zt,o as Tt,p as Et,q as It,t as At,v as Le,w as $t,b as nt,c as Dt,d as Lt,x as lt,y as ot,z as it,R as Ft,A as Mt,C as qt,D as Bt,E as Vt,F as Kt,G as _t,H as Ht,I as Ot,J as We,K as Gt,M as Ut}from"./index-DtBWNlVD.js";import{p as Wt,s as Qt}from"./ansiToHtml-DYRzYQV1.js";import{ax as Xt,u as ct,a2 as ie,k as ae,a3 as ue,b3 as Jt,b4 as Yt,ar as Zt,_ as es,a0 as oe,X as Fe,b5 as ts,S as Ie,o as ss,a as dt,y as as,v as rs,b6 as xe,ak as Qe,b7 as ns,b8 as ls,b9 as Ae,a7 as pe,a5 as Xe,ba as $e,J as De,G as os,a1 as Ce,bb as Je,bc as is}from"./vendor-icons-B0wLOBoh.js";import{M as mt,R as cs}from"./MobileRunTarget-D2Nqcj10.js";import{L as ds}from"./LiveExecutionView-BD0wE8sz.js";import{h as ms}from"./aiHandoff-vhtR29Fh.js";import{e as us,b as we}from"./runSelected-WlgnZcSF.js";import{C as xs}from"./ConfirmDialog-DNU3qoAP.js";import{s as ps}from"./visibleInterval-BKsLfJZ3.js";import{f as Ye}from"./formatDate-T65-Y6Mi.js";import{C as fs,i as hs}from"./CronBuilder-DsnX-vRr.js";import"./SearchableDevicePicker-CFJ_DUAA.js";const ke=5e3;function bs(o){const[t,i]=n.useState(null),[r,m]=n.useState([]),[u,c]=n.useState(null),[f,y]=n.useState(null),p=n.useRef([]),g=n.useRef(null),h=n.useCallback(()=>{const d=g.current;(d==null?void 0:d.raf)!=null&&cancelAnimationFrame(d.raf),(d==null?void 0:d.timer)!=null&&clearTimeout(d.timer),g.current=null;const P=p.current;P.length!==0&&(p.current=[],m(L=>{const A=L.concat(P);return A.length>ke?A.slice(A.length-ke):A}))},[]),N=n.useCallback(()=>{g.current||(g.current=typeof document<"u"&&document.hidden?{timer:setTimeout(h,100)}:{raf:requestAnimationFrame(h)})},[h]),E=n.useCallback(()=>{const d=g.current;(d==null?void 0:d.raf)!=null&&cancelAnimationFrame(d.raf),(d==null?void 0:d.timer)!=null&&clearTimeout(d.timer),g.current=null,p.current=[],m([])},[]);n.useEffect(()=>()=>{const d=g.current;(d==null?void 0:d.raf)!=null&&cancelAnimationFrame(d.raf),(d==null?void 0:d.timer)!=null&&clearTimeout(d.timer)},[]),n.useEffect(()=>{const d=()=>{document.hidden||h()};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[h]),n.useEffect(()=>o(d=>{d.type==="output"&&d.runId===(t==null?void 0:t.runId)&&(y(null),p.current.push({stream:d.stream,data:d.data}),p.current.length>ke&&(p.current=p.current.slice(p.current.length-ke)),N()),d.type==="run-waiting-input"&&d.runId===(t==null?void 0:t.runId)&&y(d.prompt),d.type==="complete"&&d.runId===(t==null?void 0:t.runId)&&(h(),c({runId:t.runId,command:t.command,startTime:"",status:d.exitCode===0?"completed":"failed",exitCode:d.exitCode,duration:d.duration}),i(null),y(null))}),[o,t,h,N]);const $=n.useCallback(async d=>{E(),c(null);const P=await St(d);return i({runId:P.runId,command:P.command}),P},[E]),D=n.useCallback(async()=>{t&&(await rt(t.runId),i(null),y(null))},[t]),x=n.useCallback(async(d,P=!1)=>{t&&(y(null),await Rt(t.runId,P?{eof:!0}:{data:d}))},[t]),b=n.useCallback((d,P)=>{E(),c(null),i({runId:d,command:P})},[E]);return{activeRun:t,output:r,runResult:u,run:$,cancel:D,attachToRun:b,waitingPrompt:f,sendInput:x}}function gs(){return fe({queryKey:["runHistory"],queryFn:Pt,refetchInterval:5e3})}function ys(o,t){const[i,r]=n.useState({current:0,total:0,currentTestName:"",passed:0,failed:0,tests:[],elapsedMs:0,summary:null}),m=n.useRef(null),u=n.useRef(null),c=n.useCallback(()=>{m.current=null,u.current&&(clearInterval(u.current),u.current=null),r({current:0,total:0,currentTestName:"",passed:0,failed:0,tests:[],elapsedMs:0,summary:null})},[]);return n.useEffect(()=>(t?(r({current:0,total:0,currentTestName:"",passed:0,failed:0,tests:[],elapsedMs:0,summary:null}),m.current=Date.now(),u.current=setInterval(()=>{m.current&&r(f=>({...f,elapsedMs:Date.now()-m.current}))},500)):!t&&m.current&&u.current&&(clearInterval(u.current),u.current=null),()=>{u.current&&(clearInterval(u.current),u.current=null)}),[t]),n.useEffect(()=>{if(t)return o(f=>{const y=f.runId;if(!(y&&y!==t)&&(f.type==="test-progress"&&r(p=>({...p,current:f.current,total:f.total||p.total,currentTestName:f.testName})),f.type==="test-passed"&&r(p=>({...p,passed:p.passed+1,tests:[...p.tests,{name:f.testName,status:"passed",duration:f.duration}]})),f.type==="test-failed"&&r(p=>({...p,failed:p.failed+1,tests:[...p.tests,{name:f.testName,status:"failed",duration:f.duration}]})),f.type==="test-results")){const p=f.summary;r(g=>({...g,summary:{runId:t,...p}}))}})},[o,t]),{...i,reset:c}}function js(o){const t=[];let i="",r="stdout";for(const m of o){if(m.stream!==r&&i){const u=i.split(`
2
- `);for(const c of u)c&&t.push({stream:r,data:c});i=""}r=m.stream,i+=m.data}if(i){const m=i.split(`
3
- `);for(const u of m)u&&t.push({stream:r,data:u})}return t}function vs({output:o}){const t=n.useRef(null);n.useEffect(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},[o]);const i=n.useMemo(()=>js(o),[o]);return e.jsxs("div",{ref:t,className:"flex-1 overflow-auto bg-black/40 rounded-lg p-4 font-mono text-xs leading-5",children:[i.length===0&&e.jsx("span",{className:"text-gray-600",children:"Waiting for output..."}),i.map((r,m)=>e.jsx(Ns,{data:r.data,stream:r.stream},m))]})}const Ns=n.memo(function({data:t,stream:i}){var u,c,f;const r=n.useMemo(()=>Wt(t),[t]),m=i==="stderr"?"text-red-400":i==="stdin"?"text-cyan-300":"text-gray-200";return i==="stdin"?e.jsxs("div",{className:m,children:[e.jsx("span",{className:"text-cyan-500/70 select-none",children:"› "}),t==="^D"?"^D (end of input)":t]}):r.length<=1&&!((u=r[0])!=null&&u.style.color)&&!((c=r[0])!=null&&c.style.bold)&&!((f=r[0])!=null&&f.style.dim)?e.jsx("div",{className:m,children:t}):e.jsx("div",{className:m,children:r.map((y,p)=>{const g=Qt(y.style);return Object.keys(g).length>0?e.jsx("span",{style:g,children:y.text},p):e.jsx("span",{children:y.text},p)})})});function ws(){const{data:o,isLoading:t}=gs(),i=(o==null?void 0:o.history)??[];return t?e.jsx("div",{className:"text-xs text-gray-500 p-3",children:"Loading history..."}):i.length===0?e.jsx("div",{className:"text-xs text-gray-500 p-4 text-center",children:"No previous runs"}):e.jsx("div",{className:"space-y-1.5 max-h-72 overflow-y-auto",children:i.map(r=>e.jsx(ks,{run:r},r.runId))})}function ks({run:o}){const t={completed:e.jsx(ae,{size:14,className:"text-emerald-400"}),failed:e.jsx(ie,{size:14,className:"text-red-400"}),running:e.jsx(ct,{size:14,className:"text-amber-400 animate-pulse"}),cancelled:e.jsx(Xt,{size:14,className:"text-gray-400"})};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2 border border-white/5 text-xs",children:[t[o.status],e.jsx("span",{className:"font-mono text-gray-300 flex-1 truncate",children:o.command}),o.duration!=null&&e.jsxs("span",{className:"text-gray-500",children:[(o.duration/1e3).toFixed(1),"s"]}),o.startTime&&e.jsx("span",{className:"text-gray-600 text-[10px]",children:new Date(o.startTime).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})}function Cs({current:o,passed:t,failed:i,currentTestName:r,tests:m,elapsedMs:u}){const c=t+i,f=Math.round(u/1e3);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 bg-surface-2 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"h-full flex",children:c>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-emerald-500 transition-all",style:{width:`${t/Math.max(c,1)*100}%`}}),e.jsx("div",{className:"bg-red-500 transition-all",style:{width:`${i/Math.max(c,1)*100}%`}})]})})}),e.jsxs("span",{className:"text-xs text-gray-500 flex-shrink-0",children:[f,"s"]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("span",{className:"text-gray-400",children:["Test #",o]}),e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1",children:[e.jsx(ae,{size:12})," ",t]}),e.jsxs("span",{className:"text-red-400 flex items-center gap-1",children:[e.jsx(ie,{size:12})," ",i]}),r&&e.jsxs("span",{className:"text-gray-500 flex items-center gap-1 truncate",children:[e.jsx(ue,{size:12,className:"animate-spin"}),e.jsx("span",{className:"truncate",children:r})]})]}),e.jsx("div",{className:"max-h-64 overflow-y-auto space-y-0.5",children:m.slice(-30).map((y,p)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-0.5 animate-slide-in",children:[y.status==="passed"?e.jsx(ae,{size:12,className:"text-emerald-400 flex-shrink-0"}):e.jsx(ie,{size:12,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`truncate ${y.status==="passed"?"text-gray-400":"text-red-300"}`,children:y.name})]},p))})]})}function Ss({runId:o,summary:t,onRerunFailed:i}){const r=at(),m=t.passRate>=90?"text-emerald-400":t.passRate>=70?"text-amber-400":"text-red-400",u=t.passRate>=90?"bg-emerald-500/10":t.passRate>=70?"bg-amber-500/10":"bg-red-500/10",c=t.failed===0,f=()=>r(`/results?runId=${encodeURIComponent(o)}`);return e.jsxs("div",{className:`rounded-xl border border-white/5 px-4 py-2.5 ${u} flex items-center gap-x-4 gap-y-2 flex-wrap`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[c?e.jsx(ae,{size:16,className:"text-emerald-400"}):e.jsx(ie,{size:16,className:"text-red-400"}),e.jsx("span",{className:"text-sm font-semibold text-gray-200",children:"Run Complete"}),e.jsxs("span",{className:"text-xs text-gray-500",children:["· ",(t.duration/1e3).toFixed(1),"s"]})]}),e.jsx("span",{className:"w-px h-5 bg-white/10 hidden sm:block"}),e.jsxs("div",{className:"flex items-center gap-3.5 text-sm tabular-nums",children:[e.jsxs("span",{className:"text-gray-300",children:[e.jsx("span",{className:"font-bold text-gray-100",children:t.total})," ",e.jsx("span",{className:"text-gray-500 text-xs",children:"total"})]}),e.jsxs("span",{className:"flex items-center gap-1 text-emerald-400",title:"Passed",children:[e.jsx(ae,{size:13})," ",t.passed]}),e.jsxs("span",{className:`flex items-center gap-1 ${t.failed>0?"text-red-400":"text-gray-500"}`,title:"Failed",children:[e.jsx(ie,{size:13})," ",t.failed]}),e.jsxs("span",{className:"flex items-center gap-1 text-gray-500",title:"Skipped",children:[e.jsx(Jt,{size:13})," ",t.skipped]}),e.jsxs("span",{className:`font-bold ${m}`,children:[t.passRate,"%",e.jsx("span",{className:"text-gray-500 text-xs font-normal ml-1",children:"pass"})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2 flex-shrink-0",children:[t.failed>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:f,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-purple-500/15 text-purple-300 text-xs font-medium hover:bg-purple-500/25 transition-colors",children:[e.jsx(Yt,{size:12})," Analyze"]}),i&&e.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-surface-2 text-gray-300 text-xs font-medium hover:bg-surface-3 transition-colors",children:[e.jsx(Zt,{size:12})," Re-run Failed"]})]}),e.jsxs("button",{onClick:f,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-surface-2 text-gray-300 text-xs font-medium hover:bg-surface-3 transition-colors",children:[e.jsx(es,{size:12})," View Details"]})]})]})}function Rs({open:o,analysis:t,providerLabel:i,onAiFix:r,onSkipAndRun:m,onCancel:u}){return o?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:u}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-0 w-[760px] max-w-[92vw] max-h-[85vh] animate-fade-in flex flex-col",children:[e.jsx("div",{className:"px-6 pt-5 pb-4 border-b border-white/5",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 bg-amber-500/15",children:e.jsx(oe,{size:20,className:"text-amber-400"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100",children:["Not connected to ",i," yet"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:"This project's driver setup doesn't honor Testver's cloud settings — the run would silently execute on a local browser."})]})]}),e.jsx("button",{onClick:u,className:"text-gray-500 hover:text-gray-300 p-1",children:e.jsx(Fe,{size:18})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4 space-y-4",children:[e.jsxs("div",{className:"bg-surface-2 rounded-lg p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-gray-400 uppercase tracking-wide",children:[e.jsx(ts,{size:14}),"Detection Summary"]}),e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-x-4 gap-y-1.5 text-sm",children:[e.jsx("div",{className:"text-gray-500",children:"Framework:"}),e.jsx("div",{className:"text-gray-200",children:t.framework||"Unknown"}),e.jsx("div",{className:"text-gray-500",children:"Language:"}),e.jsx("div",{className:"text-gray-200",children:t.language||"Unknown"}),e.jsx("div",{className:"text-gray-500",children:"Driver file (guess):"}),e.jsx("div",{className:"text-gray-200 font-mono text-xs break-all",children:t.hookFile||"Not located"})]}),e.jsx("p",{className:"text-[11px] text-gray-500 pt-1",children:"The driver file is a best-guess from a code scan — the AI Assistant verifies it (and looks for other driver-creation sites) before touching anything."})]}),e.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg p-4 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-brand-300",children:[e.jsx(Ie,{size:15}),"Fix with AI Assistant"]}),e.jsxs("p",{className:"text-sm text-gray-300",children:["The AI Assistant makes the smallest change that connects this framework to ",i,", runs one test to verify, and confirms real cloud execution from the run's ground-truth verdict — self-correcting if verification fails, and undoing everything if it can't succeed."]}),e.jsx("p",{className:"text-xs text-gray-500",children:"You'll see every edit and the verification run in the AI Assistance screen. Requires an AI provider (Settings → LLM). Verification runs use a small amount of cloud minutes."})]}),e.jsxs("div",{className:"bg-surface-2 rounded-lg p-3 flex items-start gap-2",children:[e.jsx(ss,{size:14,className:"text-gray-500 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-xs text-gray-500",children:'"Run anyway" injects the cloud environment variables and runs as-is — if your code already reads them this works, otherwise the run lands locally and its result will carry a "executed locally" warning.'})]})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-white/5 flex justify-end gap-2",children:[e.jsx("button",{onClick:u,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:"Cancel"}),e.jsx("button",{onClick:m,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5",children:"Run Anyway"}),e.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 px-4 py-2 text-sm rounded-lg bg-brand-600 hover:bg-brand-500 text-white font-medium",children:[e.jsx(Ie,{size:14}),"Fix with AI Assistant"]})]})]})]}):null}const Ps="testver-runner-recent",Ze="testver-runner-recent",zs=10;try{localStorage.getItem(Ze)!==null&&localStorage.removeItem(Ze)}catch{}function Ts(o){return`${Ps}:${o||"unknown"}`}function et(o){try{const t=localStorage.getItem(o),i=t?JSON.parse(t):[];return Array.isArray(i)?i.filter(r=>typeof r=="string"):[]}catch{return[]}}function ut(){const o=Ct(),{data:t}=fe({queryKey:["runner-commands"],queryFn:zt,staleTime:3e4}),i=(t==null?void 0:t.commands)||[],{data:r}=Tt(),m=Ts(r==null?void 0:r.rootPath),u=n.useCallback(async(g,h)=>{const N=await Et(g,h);o.setQueryData(["runner-commands"],N)},[o]),c=n.useCallback(async(g,h)=>{const N=await It(g,h);o.setQueryData(["runner-commands"],N)},[o]),f=n.useCallback(async g=>{const h=await At(g);o.setQueryData(["runner-commands"],h)},[o]),y=n.useCallback(g=>{const h=g.trim();if(!h)return;const N=[h,...et(m).filter(E=>E!==h)].slice(0,zs);try{localStorage.setItem(m,JSON.stringify(N))}catch{}},[m]);return{saved:[...i].sort((g,h)=>(h.pinned?1:0)-(g.pinned?1:0)||g.label.localeCompare(h.label)),add:u,update:c,remove:f,pushRecent:y,recent:et(m)}}function Es({framework:o,saved:t,recent:i,disabled:r,onPick:m,onRun:u,onSave:c,onUpdate:f,onDelete:y}){var X,w,ne;const[p,g]=n.useState(!1),[h,N]=n.useState(""),[E,$]=n.useState(!1),[D,x]=n.useState(""),[b,d]=n.useState(""),[P,L]=n.useState(null),[A,q]=n.useState(""),[z,U]=n.useState(""),[T,B]=n.useState(null),V=n.useRef(null);n.useEffect(()=>{if(!p)return;const l=S=>{T||V.current&&!V.current.contains(S.target)&&g(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[p,T]);const{data:_}=fe({queryKey:["run-commands-config"],queryFn:Le,staleTime:1e4}),W=(((w=(X=_==null?void 0:_.configured)==null?void 0:X.fullRun)==null?void 0:w.trim())||((ne=_==null?void 0:_.autoDetected)==null?void 0:ne.fullRun)||"").trim(),F=W?[{label:"Run All",command:W}]:[],a=h.trim().toLowerCase(),v=(l,S)=>!a||l.toLowerCase().includes(a)||S.toLowerCase().includes(a),I=t.filter(l=>v(l.label,l.command)),J=F.filter(l=>v(l.label,l.command)),H=i.filter(l=>v(l,l)),Y=l=>{m(l),g(!1)},O=l=>{u(l),g(!1)},re=()=>{$(!1),x(""),d("")},Q=()=>{const l=D.trim(),S=b.trim();l&&S&&(c(l,S),re())},he=l=>{L(l.id),q(l.label),U(l.command)},te=l=>{A.trim()&&z.trim()&&(f(l,{label:A.trim(),command:z.trim()}),L(null))};return e.jsxs("div",{className:"relative flex-shrink-0",ref:V,children:[e.jsxs("button",{type:"button",onClick:()=>g(l=>!l),disabled:r,title:"Saved commands, presets & recent",className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm font-medium text-gray-300 hover:text-gray-100 hover:border-white/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(dt,{size:15}),e.jsx("span",{children:"Commands"}),e.jsx(as,{size:13,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&e.jsxs("div",{className:"absolute right-0 top-full mt-2 z-50 w-[420px] max-h-[70vh] overflow-hidden flex flex-col rounded-xl bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-2xl",children:[e.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-white/5",children:e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg bg-gray-100 dark:bg-surface-2",children:[e.jsx(rs,{size:13,className:"text-gray-400"}),e.jsx("input",{autoFocus:!0,value:h,onChange:l=>N(l.target.value),placeholder:"Search commands…",className:"flex-1 bg-transparent text-sm text-gray-700 dark:text-gray-200 outline-none placeholder-gray-400"}),h&&e.jsx("button",{onClick:()=>N(""),children:e.jsx(Fe,{size:13,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200"})})]})}),e.jsxs("div",{className:"overflow-y-auto",children:[e.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-white/5",children:E?e.jsxs("div",{className:"space-y-2 px-1 py-1",children:[e.jsx("input",{autoFocus:!0,value:D,onChange:l=>x(l.target.value),onKeyDown:l=>{l.key==="Escape"&&re()},placeholder:"Command name (e.g. Smoke — headed)",className:"w-full bg-gray-100 dark:bg-surface-2 rounded-lg px-2.5 py-1.5 text-sm text-gray-700 dark:text-gray-200 outline-none placeholder-gray-400"}),e.jsx("input",{value:b,onChange:l=>d(l.target.value),onKeyDown:l=>{l.key==="Enter"&&Q(),l.key==="Escape"&&re()},placeholder:"Command (e.g. npx playwright test --headed)",className:"w-full bg-gray-100 dark:bg-surface-2 rounded-lg px-2.5 py-1.5 text-sm font-mono text-gray-700 dark:text-gray-200 outline-none placeholder-gray-400"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:re,className:"px-2.5 py-1.5 rounded-lg text-sm text-gray-500 hover:bg-black/5 dark:hover:bg-white/5",children:"Cancel"}),e.jsxs("button",{onClick:Q,disabled:!D.trim()||!b.trim(),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-sm font-medium bg-brand-500/15 text-brand-500 hover:bg-brand-500/25 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Qe,{size:14})," Add"]})]})]}):e.jsxs("button",{onClick:()=>$(!0),className:"w-full flex items-center gap-2 px-2.5 py-2 rounded-lg text-sm font-medium text-brand-600 dark:text-brand-300 hover:bg-brand-500/10 transition-colors",children:[e.jsx(xe,{size:14})," Add Command"]})}),I.length>0&&e.jsx(Te,{title:"Saved",children:I.map(l=>P===l.id?e.jsxs("div",{className:"space-y-2 px-3 py-2 bg-white dark:bg-surface-1",children:[e.jsx("input",{autoFocus:!0,value:A,onChange:S=>q(S.target.value),onKeyDown:S=>{S.key==="Escape"&&L(null)},placeholder:"Command name",className:"w-full bg-gray-100 dark:bg-surface-2 rounded-lg px-2.5 py-1.5 text-sm text-gray-700 dark:text-gray-200 outline-none placeholder-gray-400"}),e.jsx("input",{value:z,onChange:S=>U(S.target.value),onKeyDown:S=>{S.key==="Enter"&&te(l.id),S.key==="Escape"&&L(null)},placeholder:"Command",className:"w-full bg-gray-100 dark:bg-surface-2 rounded-lg px-2.5 py-1.5 text-sm font-mono text-gray-700 dark:text-gray-200 outline-none placeholder-gray-400"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>L(null),className:"px-2.5 py-1.5 rounded-lg text-sm text-gray-500 hover:bg-black/5 dark:hover:bg-white/5",children:"Cancel"}),e.jsxs("button",{onClick:()=>te(l.id),disabled:!A.trim()||!z.trim(),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-sm font-medium bg-brand-500/15 text-brand-500 hover:bg-brand-500/25 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Qe,{size:14})," Save"]})]})]},l.id):e.jsx(Ee,{label:l.label,command:l.command,onPick:()=>Y(l.command),onRun:()=>O(l.command),actions:e.jsxs(e.Fragment,{children:[e.jsx(le,{title:l.pinned?"Unpin":"Pin",onClick:()=>f(l.id,{pinned:!l.pinned}),children:e.jsx(ns,{size:13,className:l.pinned?"fill-amber-400 text-amber-400":""})}),e.jsx(le,{title:"Edit",onClick:()=>he(l),children:e.jsx(ls,{size:13})}),e.jsx(le,{title:"Delete",onClick:()=>B(l),children:e.jsx(Ae,{size:13})})]})},l.id))}),J.length>0&&e.jsx(Te,{title:"Presets",children:J.map(l=>e.jsx(Ee,{label:l.label,command:l.command,onPick:()=>Y(l.command),onRun:()=>O(l.command),actions:e.jsx(le,{title:"Save to my commands",onClick:()=>c(l.label,l.command),children:e.jsx(xe,{size:13})})},l.label))}),H.length>0&&e.jsx(Te,{title:"Recent",children:H.map((l,S)=>e.jsx(Ee,{label:l,command:l,mono:!0,onPick:()=>Y(l),onRun:()=>O(l),actions:e.jsx(le,{title:"Save to my commands",onClick:()=>c(l.length>40?l.slice(0,40)+"…":l,l),children:e.jsx(xe,{size:13})})},`${l}-${S}`))}),I.length===0&&J.length===0&&H.length===0&&e.jsxs("p",{className:"px-4 py-6 text-center text-sm text-gray-400",children:["No commands match “",h,"”."]})]})]}),e.jsx(xs,{open:!!T,title:"Delete command?",description:T?`“${T.label}” (${T.command}) will be permanently removed from your saved commands. This can’t be undone.`:"",confirmLabel:"Delete",onConfirm:()=>{T&&y(T.id),B(null)},onCancel:()=>B(null)})]})}function Te({title:o,children:t}){return e.jsxs("div",{className:"py-1",children:[e.jsx("p",{className:"px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 capitalize",children:o}),t]})}function le({title:o,onClick:t,children:i}){return e.jsx("button",{type:"button",title:o,onClick:r=>{r.stopPropagation(),t()},className:"p-1.5 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-black/5 dark:hover:bg-white/10 transition-colors",children:i})}function Ee({label:o,command:t,mono:i,onPick:r,onRun:m,actions:u}){return e.jsxs("div",{className:"group flex items-center gap-1 pl-3 pr-2 py-1.5 hover:bg-black/[0.04] dark:hover:bg-white/5 transition-colors",children:[e.jsxs("button",{type:"button",onClick:r,className:"flex-1 min-w-0 text-left",title:t,children:[e.jsx("span",{className:`block text-sm text-gray-700 dark:text-gray-200 truncate ${i?"font-mono text-[13px]":"font-medium"}`,children:o}),!i&&e.jsx("span",{className:"block text-[11px] text-gray-400 font-mono truncate",children:t})]}),e.jsxs("div",{className:"flex items-center flex-shrink-0",children:[u,e.jsx(le,{title:"Run now",onClick:m,children:e.jsx(pe,{size:13,className:"text-brand-500"})})]})]})}const se={browserstack:"BrowserStack",lambdatest:"LambdaTest",saucelabs:"Sauce Labs","local-appium":"Local Devices","testver-grid":"Testver Grid"};function Is(){var He,Oe,Ge,Ue;const{project:o,subscribe:t}=wt(),{runs:i}=$t(),{toast:r}=nt(),m=Dt(),u=at(),{activeRun:c,output:f,runResult:y,run:p,cancel:g,attachToRun:h,waitingPrompt:N,sendInput:E}=bs(t),[$,D]=n.useState(""),[x,b]=n.useState(!1),[d,P]=n.useState(null),L=n.useRef(null);n.useEffect(()=>{var s;N&&((s=L.current)==null||s.focus())},[N]),n.useEffect(()=>{c||(D(""),P(null))},[c]);const A=async(s=!1)=>{var j;if(!(!c||x)){b(!0),P(null);try{await E(s?"":$,s),s||D("")}catch(k){P(String((k==null?void 0:k.message)||k))}finally{b(!1),(j=L.current)==null||j.focus()}}},q=(i??[]).filter(s=>s.runId!==(c==null?void 0:c.runId)),z=ys(t,(c==null?void 0:c.runId)??null),{data:U}=Lt(),T=ut(),[B,V]=n.useState(""),[_,W]=n.useState(!1),{data:F}=fe({queryKey:["run-commands-config"],queryFn:Le,staleTime:1e4}),a=(((Oe=(He=F==null?void 0:F.configured)==null?void 0:He.fullRun)==null?void 0:Oe.trim())||((Ge=F==null?void 0:F.autoDetected)==null?void 0:Ge.fullRun)||"").trim(),v=((Ue=F==null?void 0:F.autoDetected)==null?void 0:Ue.wdioSuites)??[],I=new Set(v.map(s=>s.config)).size>1,J=[...a?[{id:"preset-run-all",label:"Run All",command:a,preset:!0}]:[],...v.map(s=>({id:`preset-wdio-suite-${s.config}-${s.name}`,label:`Suite: ${s.name}${I?` (${s.config.split("/").pop()})`:""}`,command:s.command,preset:!0})),...T.saved.map(s=>({id:s.id,label:s.label,command:s.command}))],H=B.trim().toLowerCase(),Y=H?J.filter(s=>s.command.toLowerCase()!==H&&(s.command.toLowerCase().includes(H)||s.label.toLowerCase().includes(H))):J,[O,re]=n.useState([]),[Q,he]=n.useState(!1),[te,X]=n.useState("local"),w=te,[ne,l]=n.useState(""),[S,xt]=n.useState(!1),[M,pt]=n.useState({deviceName:"",platformName:"Android",platformVersion:"",appId:"",appPath:""}),{showsMobile:Se,mode:Me}=lt(),ft=Me!=="mobile"&&/\bplaywright(\.cmd)?\s+test\b|\bcypress\s+run\b/i.test(B),K=Se&&!ft&&w!=="local"&&w!=="testver-grid",be=Me==="mobile",ge=be&&O.length===0&&!Q,Re=!K||!!M.deviceName&&(!!M.appId||!!M.appPath.trim()),[Z,qe]=n.useState(null);n.useEffect(()=>{if(!K){qe(null);return}let s=!1;const j=()=>{Mt().then(C=>{s||qe(C.ticket)}).catch(()=>{})};j();const k=ps(j,5e3);return()=>{s=!0,k()}},[K]);const[Be,ye]=n.useState(!1),[ce,je]=n.useState(null),[Ve,Ke]=n.useState(!1);n.useEffect(()=>{ot().then(s=>{const j=s.providers.filter(k=>k.enabled);re(j)}).catch(()=>{}),it().then(({config:s})=>he(!!s.enabled)).catch(()=>he(!1))},[]),n.useEffect(()=>{if(!(!be||w!=="local"))if(Q)X("local-appium");else{const s=O.filter(j=>j.id!=="testver-grid");s.length>0&&X(s[0].id)}},[be,Q,O,w]);const de=async(s,j)=>{const k=(s??B).trim(),C=j??te;try{const R={command:k,asTyped:!0,fromRunner:!0,...C==="local"?{plainCommand:!0}:{}};C!=="local"&&(R.cloudProvider=C,ne.trim()&&(R.buildName=ne.trim()),C==="testver-grid"&&S&&(R.gridTunnel=!0),K&&!j&&(M.deviceName&&(R.deviceName=M.deviceName),M.platformName&&(R.platformName=M.platformName),M.platformVersion&&(R.platformVersion=M.platformVersion),M.appId&&(R.appId=M.appId),M.appPath.trim()&&(R.appPath=M.appPath.trim()),Z&&!Z.claimed&&Date.now()<Z.expiresAt&&(R.reuseSessionId=Z.sessionId))),await p(R),T.pushRecent(k);const ee=C==="local"?"locally":`on ${se[C]||C}`;r("info",`Test run started ${ee}`)}catch(R){r("error",R.message||"The run could not be started")}},me=(s,j)=>m(()=>ht(s,j),{files:(s??B).split(/\s+/).filter(k=>/\.(spec|test)\.|\.(ts|tsx|js|jsx|py|java|cs|feature|robot)$/.test(k))}),ht=async(s,j)=>{const k=(s??B).trim(),C=j??te;if(!k){r("error","Please enter a run command");return}if(s!==void 0&&V(s),ge){r("error","Connect a device or enable a cloud grid in Connectors first");return}if(K&&!j&&!Re){r("error","Select a device and an app first");return}if(C==="local"){await de(k,j);return}if(K&&!j){await de(k,j);return}Ke(!0);try{const R=await Kt(C,k);je(R),R.cloudReady||R.alreadyPatched?await de(k,j):ye(!0)}catch(R){r("error",`Cloud analysis failed: ${R}`),await de(k,j)}finally{Ke(!1)}},bt=async s=>{try{const[{tests:j},k,C]=await Promise.all([qt(s),Bt(),Vt(s).catch(()=>null)]),R=j.filter(Ne=>Ne.status==="failed"||Ne.status==="error"),{tests:ee,unmatched:Pe}=us(R,k.suites);if(ee.length===0){r("error","The failed tests were not found in Test Explorer — run them from there.");return}Pe>0&&r("info",`${Pe} failed test${Pe===1?" was":"s were"} not found in Test Explorer — re-running the other ${ee.length}.`);const G=C?C.source==="cloud"&&C.cloudProvider?String(C.cloudProvider):C.source==="local"||!C.source?"local":void 0:void 0;if(G&&G!==te){const Ne=G==="local"||(G==="local-appium"?Q:O.some(Nt=>Nt.id===G)),ze=G==="local"?"this machine":se[G]||G;if(!Ne){r("error",`That run ran on ${ze}, which is not set up now — pick a target and run the failed tests from the Run Command field.`),V(we(ee));return}if(C!=null&&C.targetDevice){X(G),V(we(ee)),r("info",`That run ran on ${ze} — check the device and app, then press Run.`);return}r("info",`Re-running on ${ze}, where the run executed.`),me(we(ee),G);return}me(we(ee))}catch(j){r("error",j.message||"The failed tests could not be re-run")}},gt=()=>{const s=(ce==null?void 0:ce.aiFixPrompt)||`Make this project run on ${se[w]||w} through Testver's cloud environment variables without changing local behavior, then verify with one test run and check the run's cloudExecution verdict.`;ye(!1),je(null),ms(u,{prompt:s,mode:"web"})},yt=async()=>{ye(!1),je(null),await de()},jt=()=>{ye(!1),je(null)},vt=s=>{s.key==="Enter"&&!c&&me()},_e=!K&&w==="testver-grid"&&!!c,ve=K&&!!c||_e;return e.jsxs("div",{className:`h-full flex animate-fade-in ${ve?"":"flex-col"}`,children:[e.jsxs("div",{className:ve?"flex-1 flex flex-col overflow-hidden":"contents",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-2.5",children:[e.jsx(dt,{size:22,className:"text-brand-400"}),"Runner"]}),e.jsx(Es,{saved:T.saved,recent:T.recent,onPick:s=>V(s),onRun:s=>{if(c){r("error","A run is already in progress — stop it first");return}me(s)},onSave:T.add,onUpdate:T.update,onDelete:T.remove})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx("label",{className:"text-sm font-medium text-gray-400 block mb-1",children:"Enter any run command to execute on the connected server"}),e.jsx("input",{value:B,onChange:s=>{V(s.target.value),W(!0)},onKeyDown:vt,onFocus:()=>W(!0),onBlur:()=>setTimeout(()=>W(!1),120),placeholder:"e.g., npm install or npx playwright test --headed",className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-200 font-mono outline-none placeholder-gray-600 focus:border-brand-500/50",disabled:!!c}),_&&!c&&Y.length>0&&e.jsxs("div",{className:"absolute left-0 right-0 top-full mt-1 z-30 rounded-xl bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-2xl py-1 overflow-hidden",children:[e.jsx("p",{className:"px-3 pt-1.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:"Commands"}),e.jsx("div",{className:"max-h-[228px] overflow-y-auto",children:Y.map(s=>e.jsxs("button",{onMouseDown:j=>{j.preventDefault(),V(s.command),W(!1)},className:"w-full text-left px-3 py-1.5 hover:bg-black/[0.04] dark:hover:bg-white/5 transition-colors",title:s.command,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 truncate",children:s.label}),s.preset&&e.jsx("span",{className:"px-1.5 py-0 rounded text-[9px] font-semibold bg-brand-500/15 text-brand-500 flex-shrink-0",children:"preset"})]}),e.jsx("span",{className:"block text-[11px] font-mono text-gray-400 truncate",children:s.command})]},s.id))})]})]}),e.jsx("div",{className:"flex items-end gap-2",children:c?e.jsxs("button",{onClick:g,className:"flex items-center justify-center gap-2 px-5 py-2.5 rounded-xl bg-red-600 hover:bg-red-500 text-white text-[15px] font-medium",children:[e.jsx(Xe,{size:14}),"Stop"]}):e.jsx("button",{onClick:()=>me(),disabled:Ve||ge||K&&!Re,title:ge?"Connect a local device or enable a cloud grid in Connectors first":K&&!Re?"Select a device and an app first":void 0,className:"flex items-center justify-center gap-2 px-5 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:Ve?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:14,className:"animate-pulse"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{size:14}),"Run"]})})})]}),(O.length>0||Se&&Q)&&e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Run on:"}),e.jsxs("div",{className:"flex gap-1.5",children:[!be&&e.jsxs("button",{onClick:()=>X("local"),disabled:!!c,className:`flex items-center gap-1.5 px-2.5 h-8 text-xs rounded-lg border transition-colors ${w==="local"?"border-brand-500/50 bg-brand-500/10 text-brand-400 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[e.jsx($e,{size:12}),"Local"]}),O.map(s=>e.jsxs("button",{onClick:()=>X(s.id),disabled:!!c,className:`flex items-center gap-1.5 px-2.5 h-8 text-xs rounded-lg border transition-colors ${w===s.id?"border-blue-500/50 bg-blue-500/10 text-blue-300 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[e.jsx(oe,{size:12}),se[s.id]]},s.id)),Se&&Q&&e.jsxs("button",{onClick:()=>X("local-appium"),disabled:!!c,className:`flex items-center gap-1.5 px-2.5 h-8 text-xs rounded-lg border transition-colors ${w==="local-appium"?"border-gray-300 dark:border-white/25 bg-gray-100/70 dark:bg-white/[0.08] text-gray-800 dark:text-gray-100 font-medium":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300 hover:border-white/10"} disabled:opacity-50`,children:[e.jsx(De,{size:12}),"Local Devices"]})]}),w==="testver-grid"&&e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-400 cursor-pointer select-none",title:"Let grid browsers reach your localhost / private apps — outbound tunnel, scoped to localhost + your baseURL host, closed when the run ends",children:[e.jsx("input",{type:"checkbox",checked:S,onChange:s=>xt(s.target.checked),disabled:!!c,className:"rounded border-gray-600 bg-surface-2 text-brand-500 focus:ring-brand-500"}),"Local tunnel"]})}),w!=="local"&&w!=="local-appium"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-gray-500",children:"Build:"}),e.jsx("input",{value:ne,onChange:s=>l(s.target.value),placeholder:"auto",className:"w-36 bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none placeholder-gray-600 focus:border-brand-500/50",disabled:!!c})]})]}),ge&&e.jsxs("div",{className:"mt-3 flex items-start gap-2.5 px-3.5 py-3 rounded-xl border border-amber-500/25 bg-amber-500/10 text-sm text-amber-700 dark:text-amber-200",children:[e.jsx(De,{size:15,className:"mt-0.5 flex-shrink-0 text-amber-600 dark:text-amber-300"}),e.jsxs("span",{children:["No device target available. To run mobile tests, connect a local device or enable a cloud device grid in"," ",e.jsx("span",{className:"font-semibold",children:"Connectors"}),"."]})]}),K&&!c&&e.jsxs(e.Fragment,{children:[e.jsx(mt,{providerId:w,disabled:!!c,value:M,onChange:pt}),Z&&!Z.claimed&&Date.now()<Z.expiresAt&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 px-3 py-1.5 rounded-lg bg-emerald-500/10 border border-emerald-500/25 text-xs",children:[e.jsx(Ie,{size:12,className:"text-emerald-300 flex-shrink-0"}),e.jsx("span",{className:"text-emerald-200",children:"Reusing live recording session"}),e.jsxs("span",{className:"text-emerald-400/70 ml-auto",children:["saves ~45s · expires in ",Math.max(0,Math.round((Z.expiresAt-Date.now())/1e3)),"s"]})]})]}),e.jsxs("div",{className:"mt-2 text-sm text-gray-500 flex items-center gap-3 flex-wrap",children:[(U==null?void 0:U.branch)&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-sky-400/70",children:[e.jsx(os,{size:10})," ",U.branch]}),w!=="local"&&!c&&e.jsxs("span",{className:w==="local-appium"?"text-gray-400":"text-blue-400",children:[w==="local-appium"?"Target":"Cloud",": ",se[w]||w]}),c&&e.jsxs("span",{className:"text-amber-400 animate-pulse",children:["Running: ",c.command]}),y&&!c&&e.jsxs("span",{className:y.status==="completed"?"text-emerald-400":"text-red-400",children:["Last run: ",y.status,typeof y.exitCode=="number"?` · exit code ${y.exitCode}`:""," ",y.duration?`(${(y.duration/1e3).toFixed(1)}s)`:""]})]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col p-4 gap-3 overflow-hidden",children:[c&&z.current>0&&e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-400 uppercase mb-2",children:"Live Progress"}),e.jsx(Cs,{current:z.current,passed:z.passed,failed:z.failed,currentTestName:z.currentTestName,tests:z.tests,elapsedMs:z.elapsedMs})]}),!c&&z.summary&&e.jsx(Ss,{summary:z.summary,runId:z.summary.runId,onRerunFailed:()=>void bt(z.summary.runId)}),e.jsx("h3",{className:"text-sm font-semibold text-gray-400 uppercase",children:"Output"}),e.jsx(vs,{output:f}),c&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[N&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-300",children:[e.jsx(ue,{size:12,className:"animate-pulse"}),e.jsxs("span",{children:["The command looks like it is waiting for an answer: ",e.jsx("span",{className:"font-mono text-amber-200",children:N})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-cyan-500/70 text-sm select-none",children:"›"}),e.jsx("input",{ref:L,type:"text",value:$,onChange:s=>D(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),A(!1))},disabled:x,placeholder:N?"Type your answer and press Enter (empty Enter accepts the default)":"Send a line to the running command — press Enter","aria-label":"Input to the running command",spellCheck:!1,autoComplete:"off",className:"flex-1 h-9 px-3 rounded-lg bg-black/40 border border-white/10 focus:border-cyan-500/40 focus:outline-none font-mono text-sm text-gray-100 placeholder:text-gray-600 placeholder:font-sans disabled:opacity-60"}),e.jsx("button",{onClick:()=>void A(!1),disabled:x,className:"h-9 px-3 rounded-lg bg-cyan-600/20 text-cyan-300 border border-cyan-500/30 hover:bg-cyan-600/30 text-sm font-medium disabled:opacity-50",title:"Send the line followed by Enter",children:"Enter"}),e.jsx("button",{onClick:()=>void A(!0),disabled:x,className:"h-9 px-3 rounded-lg border border-white/10 text-gray-400 hover:text-gray-200 hover:bg-white/5 text-sm disabled:opacity-50",title:"Close the command's input (Ctrl-D) — for programs that read until input ends",children:"Send EOF"})]}),e.jsx("p",{className:"text-[11px] text-gray-600",children:d?e.jsx("span",{className:"text-red-400",children:d}):"What you type is echoed into the log above, so passwords will be visible there. Use Stop for Ctrl-C."})]})]}),!ve&&e.jsxs("div",{className:"w-80 border-l border-white/5 bg-surface-1 p-4 overflow-y-auto flex-shrink-0",children:[q.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-amber-400 uppercase mb-3",children:"Current Runs"}),e.jsx("div",{className:"space-y-1.5",children:q.map(s=>e.jsxs("div",{className:"px-3 py-2.5 rounded-lg bg-amber-500/5 border border-amber-500/20 cursor-pointer hover:bg-amber-500/10 transition-colors",onClick:()=>h(s.runId,s.command),title:"Click to view output",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"relative flex h-2 w-2 flex-shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-400"})]}),e.jsx("span",{className:"font-mono text-gray-300 text-xs flex-1 truncate",children:s.command})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[s.cloudProvider&&e.jsxs("span",{className:"flex items-center gap-0.5 text-blue-400",children:[e.jsx(oe,{size:8}),se[s.cloudProvider]||s.cloudProvider]}),s.source==="scheduler"&&e.jsxs("span",{className:"flex items-center gap-0.5 text-gray-500",children:[e.jsx(Ce,{size:8})," Scheduled"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-emerald-400 flex items-center gap-0.5",children:[e.jsx(ae,{size:8})," ",s.passed]}),e.jsxs("span",{className:"text-red-400 flex items-center gap-0.5",children:[e.jsx(ie,{size:8})," ",s.failed]}),e.jsx("span",{className:"text-gray-500 tabular-nums font-mono",children:e.jsx(Ft,{run:s,format:j=>`${Math.floor(j/1e3)}s`})}),e.jsx("button",{onClick:j=>{j.stopPropagation(),rt(s.runId).catch(()=>{})},className:"text-red-400 hover:text-red-300 p-0.5",title:"Cancel run",children:e.jsx(Xe,{size:8})})]})]},s.runId))})]}),e.jsx("h3",{className:"text-sm font-semibold text-gray-400 uppercase mb-3",children:"Run History"}),e.jsx(ws,{})]})]})]}),ve&&e.jsx("div",{className:"w-[35%] min-w-[380px] max-w-[560px] border-l border-white/5 bg-surface-1 flex-shrink-0",children:_e?e.jsx(ds,{runId:(c==null?void 0:c.runId)??null,layout:"panel"}):e.jsx(cs,{testRunning:!!c})}),Be&&ce&&e.jsx(Rs,{open:Be,analysis:ce,providerLabel:se[w]||w,onAiFix:gt,onSkipAndRun:yt,onCancel:jt})]})}const As="w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-200 font-mono outline-none placeholder-gray-600 focus:border-brand-500/50";function $s({value:o,onChange:t,placeholder:i,disabled:r,className:m,hint:u}){var $,D,x;const[c,f]=n.useState(!1),{saved:y}=ut(),{data:p}=fe({queryKey:["run-commands-config"],queryFn:Le,staleTime:1e4}),g=(((D=($=p==null?void 0:p.configured)==null?void 0:$.fullRun)==null?void 0:D.trim())||((x=p==null?void 0:p.autoDetected)==null?void 0:x.fullRun)||"").trim(),h=[...g?[{id:"preset-run-all",label:"Run All",command:g,preset:!0}]:[],...y.map(b=>({id:b.id,label:b.label,command:b.command}))],N=o.trim().toLowerCase(),E=N?h.filter(b=>b.command.toLowerCase()!==N&&(b.command.toLowerCase().includes(N)||b.label.toLowerCase().includes(N))):h;return e.jsxs("div",{className:"relative",children:[e.jsx("input",{value:o,disabled:r,onChange:b=>{t(b.target.value),f(!0)},onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!1),120),placeholder:i,className:m||As}),c&&!r&&E.length>0&&e.jsxs("div",{className:"absolute left-0 right-0 top-full mt-1 z-30 rounded-xl bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-2xl py-1 overflow-hidden",children:[e.jsxs("p",{className:"px-3 pt-1.5 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400",children:["Commands",u&&e.jsxs("span",{className:"ml-1.5 normal-case font-normal tracking-normal text-gray-400/80",children:["· ",u]})]}),e.jsx("div",{className:"max-h-[228px] overflow-y-auto",children:E.map(b=>e.jsxs("button",{type:"button",onMouseDown:d=>{d.preventDefault(),t(b.command),f(!1)},className:"w-full text-left px-3 py-1.5 hover:bg-black/[0.04] dark:hover:bg-white/5 transition-colors",title:b.command,children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-200 truncate",children:b.label}),b.preset&&e.jsx("span",{className:"px-1.5 py-0 rounded text-[9px] font-semibold bg-brand-500/15 text-brand-500 flex-shrink-0",children:"preset"})]}),e.jsx("span",{className:"block text-[11px] font-mono text-gray-400 truncate",children:b.command})]},b.id))})]})]})}const Ds=[{label:"Every 5 minutes",cron:"*/5 * * * *"},{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Every 30 minutes",cron:"*/30 * * * *"},{label:"Every hour",cron:"0 * * * *"},{label:"Every 2 hours",cron:"0 */2 * * *"},{label:"Daily at 8 AM",cron:"0 8 * * *"},{label:"Daily at 10 PM",cron:"0 22 * * *"},{label:"Weekdays at 9 AM",cron:"0 9 * * 1-5"},{label:"Weekly Sunday midnight",cron:"0 0 * * 0"},{label:"Custom",cron:""}],tt={browserstack:"BrowserStack",lambdatest:"LambdaTest",saucelabs:"Sauce Labs","local-appium":"Local Devices","testver-grid":"Testver Grid"},st=()=>({name:"",command:"",cron:"0 8 * * *",cloudProvider:"",enabled:!0,appPath:"",appId:"",deviceName:"",platformName:"Android",platformVersion:""});function Ls(o){const t=o.trim().split(/\s+/);if(t.length!==5)return o;const[i,r,m,u,c]=t;return i==="*"&&r==="*"&&m==="*"&&u==="*"&&c==="*"?"Every minute":i!=null&&i.startsWith("*/")&&r==="*"&&m==="*"&&u==="*"&&c==="*"?`Every ${i.slice(2)} min`:/^\d+$/.test(i)&&r==="*"&&m==="*"&&u==="*"&&c==="*"?`Hourly at :${i.padStart(2,"0")}`:/^\d+$/.test(i)&&/^\d+$/.test(r)&&m==="*"&&u==="*"&&c==="*"?`Daily ${r.padStart(2,"0")}:${i.padStart(2,"0")}`:/^\d+$/.test(i)&&/^\d+$/.test(r)&&m==="*"&&u==="*"&&hs(c)?`Weekdays ${r.padStart(2,"0")}:${i.padStart(2,"0")}`:/^\d+$/.test(i)&&/^\d+$/.test(r)&&m==="*"&&u==="*"&&c==="0"?`Sundays ${r.padStart(2,"0")}:${i.padStart(2,"0")}`:/^\d+$/.test(i)&&(r!=null&&r.startsWith("*/"))&&m==="*"&&u==="*"&&c==="*"?`Every ${r.slice(2)}h at :${i.padStart(2,"0")}`:o}function Fs(){const{toast:o}=nt(),[t,i]=n.useState([]),[r,m]=n.useState([]),[u,c]=n.useState(!1),{showsMobile:f}=lt(),[y,p]=n.useState(!0),[g,h]=n.useState(!1),[N,E]=n.useState(null),[$,D]=n.useState(null),[x,b]=n.useState(st()),[d,P]=n.useState(!1),[L,A]=n.useState({}),q=n.useCallback(async()=>{var a,v;try{const[I,J,H]=await Promise.all([_t().catch(()=>Ht()),ot().catch(()=>({providers:[]})),it().catch(()=>({config:{enabled:!1}}))]);i(I.schedules||[]),m(((a=J.providers)==null?void 0:a.filter(Y=>Y.enabled))||[]),c(!!((v=H.config)!=null&&v.enabled))}catch{}finally{p(!1)}},[]);n.useEffect(()=>{q()},[q]);const z=()=>{D(null),b(st()),h(!0)},U=a=>{D(a.id),b({name:a.name,command:a.command,cron:a.cron,cloudProvider:a.cloudProvider||"",enabled:a.enabled,appPath:a.appPath??"",appId:a.appId??"",deviceName:a.deviceName??"",platformName:a.platformName??"Android",platformVersion:a.platformVersion??""}),h(!0)},T=async()=>{if(!x.name.trim()){o("error","Name is required");return}if(!x.command.trim()){o("error","Command is required");return}if(!x.cron.trim()){o("error","Cron expression is required");return}P(!0);try{const v=f&&!!x.cloudProvider?{appPath:x.appPath.trim()||void 0,appId:x.appId||void 0,deviceName:x.deviceName||void 0,platformName:x.deviceName?x.platformName:void 0,platformVersion:x.platformVersion||void 0}:{};$?(await We($,{name:x.name.trim(),command:x.command.trim(),cron:x.cron.trim(),cloudProvider:x.cloudProvider||void 0,enabled:x.enabled,...v}),o("success","Schedule updated")):(await Ut({id:"",name:x.name.trim(),command:x.command.trim(),cron:x.cron.trim(),cloudProvider:x.cloudProvider||void 0,enabled:x.enabled,...v}),o("success","Schedule created")),h(!1),await q()}catch(a){o("error",`Save failed: ${a}`)}finally{P(!1)}},B=(a,v)=>{E({id:a,name:v})},V=async()=>{if(N){try{await Gt(N.id),o("info",`Schedule '${N.name}' deleted`),await q()}catch(a){o("error",`Delete failed: ${a}`)}E(null)}},_=async a=>{try{await We(a.id,{enabled:!a.enabled}),await q()}catch(v){o("error",`Toggle failed: ${v}`)}},W=async(a,v)=>{A(I=>({...I,[a]:!0}));try{const I=await Ot(a);I.runId?o("success",`'${v}' triggered (run: ${I.runId.slice(0,8)}...)`):o("info",I.message),await q()}catch(I){o("error",`Run failed: ${I}`)}finally{A(I=>({...I,[a]:!1}))}},F=Ds.find(a=>a.cron===x.cron);return!F||F.label,e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200 animate-fade-in",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Ce,{size:24,className:"text-brand-300"}),"Schedules",e.jsxs("span",{className:"text-sm font-normal bg-brand-500/15 text-brand-300 px-2.5 py-0.5 rounded-full",children:[t.length," schedules"]})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Schedule any run command to execute automatically on the connected server."})]}),e.jsxs("button",{onClick:z,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(xe,{size:16}),"Add Schedule"]})]})})}),e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:y?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ue,{size:20,className:"animate-spin text-gray-500"})}):t.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(Ce,{size:40,className:"text-gray-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-400 text-[15px]",children:"No schedules configured yet."}),e.jsx("p",{className:"text-gray-600 text-sm mt-1",children:"Create a schedule to automatically run tests on a recurring basis."}),e.jsxs("button",{onClick:z,className:"mt-4 flex items-center gap-1.5 px-5 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium mx-auto",children:[e.jsx(xe,{size:14}),"Create Schedule"]})]}):e.jsx("div",{className:"space-y-3",children:t.map(a=>e.jsx("div",{className:`bg-surface-1 rounded-xl border border-white/5 p-4 transition-opacity ${a.enabled?"":"opacity-50"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200 truncate",children:a.name}),a.enabled?e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-emerald-500/15 text-emerald-400",children:[e.jsx(ae,{size:8})," Active"]}):e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-500/15 text-gray-500",children:[e.jsx(Je,{size:8})," Paused"]}),a.cloudProvider?e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-blue-500/15 text-blue-400",children:[e.jsx(oe,{size:8})," ",tt[a.cloudProvider]||a.cloudProvider]}):e.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-gray-500/15 text-gray-400",children:[e.jsx($e,{size:8})," Local"]})]}),e.jsx("p",{className:"text-xs text-gray-400 font-mono truncate mb-1",children:a.command}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ct,{size:10}),Ls(a.cron),e.jsxs("span",{className:"text-gray-600",children:["(",a.cron,")"]})]}),a.lastRunTime&&e.jsxs("span",{children:["Last: ",Ye(a.lastRunTime)]}),a.nextRunTime&&e.jsxs("span",{className:"text-brand-400",children:["Next: ",Ye(a.nextRunTime)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>W(a.id,a.name),disabled:L[a.id],className:"flex items-center gap-1 px-2.5 py-1.5 rounded-lg bg-brand-600/20 hover:bg-brand-600/30 text-brand-400 text-xs border border-brand-500/20 disabled:opacity-50",title:"Run Now",children:[L[a.id]?e.jsx(ue,{size:12,className:"animate-spin"}):e.jsx(pe,{size:12}),"Run"]}),e.jsx("button",{onClick:()=>_(a),className:"px-2.5 py-1.5 rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-400 text-xs border border-white/5",title:a.enabled?"Pause":"Enable",children:a.enabled?e.jsx(Je,{size:12}):e.jsx(pe,{size:12})}),e.jsx("button",{onClick:()=>U(a),className:"px-2.5 py-1.5 rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-400 text-xs border border-white/5",title:"Edit",children:e.jsx(is,{size:12})}),e.jsx("button",{onClick:()=>B(a.id,a.name),className:"px-2.5 py-1.5 rounded-lg bg-red-600/20 hover:bg-red-600/30 text-red-400 text-xs border border-red-500/20",title:"Delete",children:e.jsx(Ae,{size:12})})]})]})},a.id))})}),N&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 animate-fade-in",children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-sm mx-4 p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ae,{size:18,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Delete Schedule"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"This action cannot be undone"})]})]}),e.jsxs("p",{className:"text-sm text-gray-400 mb-5",children:["Are you sure you want to delete ",e.jsxs("span",{className:"font-medium text-gray-200",children:['"',N.name,'"']}),"? All scheduled runs for this schedule will be cancelled."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>E(null),className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:V,className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-500 transition-colors",children:"Delete"})]})]})}),g&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 animate-fade-in overflow-y-auto py-6",children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 w-full max-w-lg mx-4 my-auto max-h-[calc(100vh-48px)] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-200",children:$?"Edit Schedule":"New Schedule"}),e.jsx("button",{onClick:()=>h(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(Fe,{size:16})})]}),e.jsxs("div",{className:"p-4 space-y-4 overflow-y-auto flex-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-400 block mb-1",children:"Schedule Name"}),e.jsx("input",{value:x.name,onChange:a=>b(v=>({...v,name:a.target.value})),placeholder:"e.g., Nightly Regression",className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-400 block mb-1",children:"Run Command"}),e.jsx($s,{value:x.command,onChange:a=>b(v=>({...v,command:a})),placeholder:"e.g., npx playwright test --headed",hint:"Add commands from the Runner screen"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-400 block mb-2",children:"Schedule"}),e.jsx(fs,{value:x.cron,onChange:a=>b(v=>({...v,cron:a}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-400 block mb-1",children:"Run On"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("button",{onClick:()=>b(a=>({...a,cloudProvider:""})),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border transition-colors ${x.cloudProvider?"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300":"border-brand-500/50 bg-brand-500/10 text-brand-400"}`,children:[e.jsx($e,{size:12})," Local"]}),r.map(a=>e.jsxs("button",{onClick:()=>b(v=>({...v,cloudProvider:a.id})),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border transition-colors ${x.cloudProvider===a.id?"border-blue-500/60 bg-blue-500/15 text-blue-300 font-medium shadow-[0_0_0_1px_rgba(59,130,246,0.15)]":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[e.jsx(oe,{size:12})," ",tt[a.id]||a.id]},a.id)),f&&u&&e.jsxs("button",{onClick:()=>b(a=>({...a,cloudProvider:"local-appium"})),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-lg border transition-colors ${x.cloudProvider==="local-appium"?"border-gray-400 dark:border-white/30 bg-gray-100 dark:bg-white/10 text-gray-800 dark:text-gray-100 font-medium shadow-sm":"border-white/5 bg-surface-2 text-gray-400 hover:text-gray-300"}`,children:[e.jsx(De,{size:12})," Local Devices"]})]})]}),f&&x.cloudProvider&&e.jsx(mt,{providerId:x.cloudProvider,value:{deviceName:x.deviceName,platformName:x.platformName,platformVersion:x.platformVersion,appId:x.appId,appPath:x.appPath},onChange:a=>b(v=>({...v,deviceName:a.deviceName,platformName:a.platformName,platformVersion:a.platformVersion,appId:a.appId,appPath:a.appPath}))}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x.enabled,onChange:a=>b(v=>({...v,enabled:a.target.checked})),className:"rounded border-gray-600 bg-surface-2 text-brand-500 focus:ring-brand-500"}),"Enable schedule immediately"]})]}),e.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>h(!1),className:"px-5 py-2.5 text-[15px] rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5",children:"Cancel"}),e.jsxs("button",{onClick:T,disabled:d,className:"flex items-center gap-1.5 px-5 py-2.5 text-[15px] rounded-xl bg-brand-600 hover:bg-brand-500 text-white font-medium disabled:opacity-50",children:[d&&e.jsx(ue,{size:14,className:"animate-spin"}),$?"Update":"Create"]})]})]})})]})}function Zs(){const[o,t]=kt("tab",["runner","schedules"],"runner"),i=(r,m,u)=>e.jsxs("button",{onClick:()=>t(r),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${o===r?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[u,m]});return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[i("runner","Runner",e.jsx(pe,{size:15})),i("schedules","Schedules",e.jsx(Ce,{size:15}))]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:o==="runner"?e.jsx(Is,{}):e.jsx(Fs,{})})]})}export{Zs as AdvancedPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DtBWNlVD.js","assets/vendor-react-CTbHBddL.js","assets/vendor-query-BrzmPFT3.js","assets/vendor-icons-B0wLOBoh.js","assets/index-B0klHYbO.css"])))=>i.map(i=>d[i]);
2
- import{r as s,j as e,n as yt,b as wt,u as Lt}from"./vendor-react-CTbHBddL.js";import{bv as Ft,aA as vt,b6 as ct,bw as Wt,bx as Ot,aN as Bt,a$ as Ut,aB as Ht,by as Xt,bz as Vt,bA as Yt,aV as Gt,aT as Kt,b4 as dt,bB as qt,bC as Jt,V as Qt,T as Zt,bD as es,a4 as ts}from"./index-DtBWNlVD.js";import{u as ss}from"./useTabParam-ChbOedP1.js";import{N as ut,a as st,A as rs,b9 as ns,bP as as,X as je,e as is,I as os,o as ls,a2 as jt,K as kt,a7 as rt,bb as Fe,ae as ot,bQ as cs,q as ds,bR as us,bS as xs,an as hs,ap as fs,bT as ps,ba as We,y as Be,J as lt,bU as ms,bV as gs,bW as bs,bX as ys,W as ws,w as vs,bY as js,bZ as ks,aV as Ns,aW as Cs,a3 as ve,a5 as Ss,aa as Nt,l as Rs,r as nt,aK as xt,b_ as Es,ag as Ts,ak as Ct,t as Ue,ad as Ms,bu as $s,aL as Ps,bx as As,S as zs,c as _s,f as Ds,_ as Is,aE as St,by as Ls,Q as Fs,C as Ws,bz as Os,b$ as Bs,c0 as Rt,af as Et,c1 as Tt,v as Us,F as Hs,g as Xs,c2 as Vs,c3 as Mt,G as $t}from"./vendor-icons-B0wLOBoh.js";import{f as Ys}from"./formatDate-T65-Y6Mi.js";import{C as Gs}from"./ConfirmDialog-DNU3qoAP.js";import{a as Pt}from"./DiffViewer-DPglzjPH.js";import{M as Ks}from"./MediaModal-DiSINwmh.js";function qs({subscribe:t,send:i,isStreaming:a}){const[r,x]=ss("nctab",["network","console"],"console"),[n,f]=s.useState([]),[c,l]=s.useState([]),[d,p]=s.useState(!1),[E,m]=s.useState(!1),[v,T]=s.useState(""),[R,_]=s.useState("all"),[h,w]=s.useState(!0),u=s.useRef(null),b=s.useRef(null),y=s.useCallback(k=>{if(k.type==="screencast-network-request"){const L=k.entry;f(M=>{const C=M.findIndex(W=>W.id===L.id);if(C>=0){const W=[...M];return W[C]={...W[C],...L},W}const H=[...M,L];return H.length>500?H.slice(-500):H});return}if(k.type==="screencast-network-response"){const L=k.entry;f(M=>{const C=M.findIndex(W=>W.id===L.id);if(C>=0){const W=[...M];return W[C]={...W[C],...L},W}const H=[...M,L];return H.length>500?H.slice(-500):H});return}if(k.type==="screencast-console-message"){const L=k.entry;l(M=>{const C=[...M,L];return C.length>500?C.slice(-500):C});return}},[]);s.useEffect(()=>t(y),[t,y]),s.useEffect(()=>{if(!h)return;const k=r==="network"?u:b;k.current&&(k.current.scrollTop=k.current.scrollHeight)},[n,c,r,h]);const A=()=>{d?(i({type:"screencast-network-disable"}),p(!1)):(i({type:"screencast-network-enable"}),p(!0))},z=()=>{E?(i({type:"screencast-console-disable"}),m(!1)):(i({type:"screencast-console-enable"}),m(!0))};s.useEffect(()=>{a&&!d&&(i({type:"screencast-network-enable"}),p(!0)),a&&!E&&(i({type:"screencast-console-enable"}),m(!0))},[a]);const X=v?n.filter(k=>k.url.toLowerCase().includes(v.toLowerCase())||k.method.toLowerCase().includes(v.toLowerCase())):n,F=R==="all"?c:c.filter(k=>k.level===R);return e.jsxs("div",{className:"flex flex-col h-full bg-surface-0 border-t border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>x("network"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors ${r==="network"?"bg-blue-500/15 text-blue-300":"text-gray-500 hover:text-gray-400"}`,children:[e.jsx(ut,{size:11}),"Network",n.length>0&&e.jsx("span",{className:"text-[9px] px-1 rounded-full bg-blue-500/20 text-blue-400",children:n.length})]}),e.jsxs("button",{onClick:()=>x("console"),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-[11px] font-medium transition-colors ${r==="console"?"bg-purple-500/15 text-purple-300":"text-gray-500 hover:text-gray-400"}`,children:[e.jsx(st,{size:11}),"Console",c.filter(k=>k.level==="error").length>0&&e.jsx("span",{className:"text-[9px] px-1 rounded-full bg-red-500/20 text-red-400",children:c.filter(k=>k.level==="error").length})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[r==="network"&&e.jsx("button",{onClick:A,className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${d?"text-emerald-400 bg-emerald-500/10":"text-gray-500 hover:text-gray-400"}`,children:d?"ON":"OFF"}),r==="console"&&e.jsx("button",{onClick:z,className:`text-[10px] px-1.5 py-0.5 rounded transition-colors ${E?"text-emerald-400 bg-emerald-500/10":"text-gray-500 hover:text-gray-400"}`,children:E?"ON":"OFF"}),e.jsx("button",{onClick:()=>w(!h),className:`p-1 rounded transition-colors ${h?"text-brand-400":"text-gray-600"}`,title:h?"Auto-scroll ON":"Auto-scroll OFF",children:e.jsx(rs,{size:10})}),e.jsx("button",{onClick:()=>{r==="network"?f([]):l([])},className:"p-1 rounded text-gray-600 hover:text-gray-400 transition-colors",title:"Clear",children:e.jsx(ns,{size:10})})]})]}),r==="network"&&e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 border-b border-white/5 bg-surface-1/50",children:[e.jsx(as,{size:10,className:"text-gray-600"}),e.jsx("input",{type:"text",value:v,onChange:k=>T(k.target.value),placeholder:"Filter by URL or method...",className:"flex-1 bg-transparent text-[11px] text-gray-300 placeholder-gray-600 outline-none"}),v&&e.jsx("button",{onClick:()=>T(""),className:"text-gray-500 hover:text-gray-400",children:e.jsx(je,{size:10})})]}),r==="console"&&e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b border-white/5 bg-surface-1/50",children:[e.jsx(Ee,{label:"All",active:R==="all",onClick:()=>_("all")}),e.jsx(Ee,{label:"Errors",active:R==="error",onClick:()=>_("error"),color:"red"}),e.jsx(Ee,{label:"Warnings",active:R==="warn",onClick:()=>_("warn"),color:"amber"}),e.jsx(Ee,{label:"Info",active:R==="info",onClick:()=>_("info"),color:"blue"}),e.jsx(Ee,{label:"Log",active:R==="log",onClick:()=>_("log")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:r==="network"?e.jsx("div",{ref:u,className:"h-full overflow-y-auto",children:X.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-2",children:[e.jsx(ut,{size:20}),e.jsx("span",{className:"text-[11px]",children:d?"Waiting for requests...":"Enable network monitoring to capture requests"})]}):e.jsxs("table",{className:"w-full text-[11px]",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-gray-500 text-left",children:[e.jsx("th",{className:"px-2 py-1 font-medium w-14",children:"Method"}),e.jsx("th",{className:"px-2 py-1 font-medium w-14",children:"Status"}),e.jsx("th",{className:"px-2 py-1 font-medium",children:"URL"}),e.jsx("th",{className:"px-2 py-1 font-medium w-16",children:"Type"}),e.jsx("th",{className:"px-2 py-1 font-medium w-16 text-right",children:"Time"})]})}),e.jsx("tbody",{children:X.map(k=>e.jsx(Js,{entry:k},k.id+(k.status||"")))})]})}):e.jsx("div",{ref:b,className:"h-full overflow-y-auto font-mono",children:F.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-2",children:[e.jsx(st,{size:20}),e.jsx("span",{className:"text-[11px] font-sans",children:E?"Waiting for console output...":"Enable console monitoring to capture logs"})]}):F.map((k,L)=>e.jsx(Qs,{entry:k},`${k.timestamp}-${L}`))})})]})}function Js({entry:t}){const i=t.failed||t.status&&t.status>=400?"text-red-400":t.status&&t.status>=300?"text-amber-400":t.status?"text-emerald-400":"text-gray-500",a=t.method==="POST"?"text-amber-400":t.method==="PUT"?"text-blue-400":t.method==="DELETE"?"text-red-400":t.method==="PATCH"?"text-purple-400":"text-gray-400";let r=t.url;try{const n=new URL(t.url);r=n.pathname+n.search}catch{}const x=t.mimeType?t.mimeType.replace("application/","").replace("text/","").split(";")[0]:"";return e.jsxs("tr",{className:"border-b border-white/[0.02] hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:`px-2 py-0.5 font-medium ${a}`,children:t.method}),e.jsx("td",{className:`px-2 py-0.5 ${i}`,children:t.failed?"ERR":t.status||"..."}),e.jsx("td",{className:"px-2 py-0.5 text-gray-300 truncate max-w-0",title:t.url,children:r}),e.jsx("td",{className:"px-2 py-0.5 text-gray-600 truncate",children:x}),e.jsx("td",{className:"px-2 py-0.5 text-gray-500 text-right",children:t.duration!=null?`${t.duration}ms`:"..."})]})}function Qs({entry:t}){const i={error:{bg:"bg-red-500/5",border:"border-red-500/20",text:"text-red-300",icon:e.jsx(jt,{size:10})},warn:{bg:"bg-amber-500/5",border:"border-amber-500/20",text:"text-amber-300",icon:e.jsx(ls,{size:10})},info:{bg:"bg-blue-500/5",border:"border-blue-500/10",text:"text-blue-300",icon:e.jsx(os,{size:10})},debug:{bg:"bg-gray-500/5",border:"border-white/5",text:"text-gray-400",icon:e.jsx(is,{size:10})},log:{bg:"",border:"border-white/[0.02]",text:"text-gray-300",icon:null}},a=i[t.level]||i.log,r=new Date(t.timestamp).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{className:`flex items-start gap-2 px-2 py-0.5 border-b ${a.border} ${a.bg} text-[11px]`,children:[e.jsx("span",{className:"text-gray-600 flex-shrink-0 tabular-nums",children:r}),a.icon&&e.jsx("span",{className:a.text+" flex-shrink-0 mt-0.5",children:a.icon}),e.jsx("span",{className:`${a.text} break-all flex-1 whitespace-pre-wrap`,children:t.text}),t.source&&e.jsxs("span",{className:"text-gray-700 flex-shrink-0 truncate max-w-[120px]",title:t.source,children:[t.source.split("/").pop(),t.lineNumber!=null?`:${t.lineNumber}`:""]})]})}function Ee({label:t,active:i,onClick:a,color:r}){const n=r?{red:i?"bg-red-500/20 text-red-300":"text-gray-500",amber:i?"bg-amber-500/20 text-amber-300":"text-gray-500",blue:i?"bg-blue-500/20 text-blue-300":"text-gray-500"}[r]||"":i?"bg-white/10 text-gray-300":"text-gray-500";return e.jsx("button",{onClick:a,className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors hover:text-gray-300 ${n}`,children:t})}const Zs=800,er=2e3,ht=3e3;function tr({subscribe:t,canvasWidth:i,canvasHeight:a,viewportWidth:r,viewportHeight:x,enabled:n}){const f=s.useRef(null),c=s.useRef([]),[l,d]=s.useState(null),[p,E]=s.useState(null),m=s.useRef(0),v=s.useRef(0),T=s.useCallback((h,w)=>{const u=i/r,b=a/x;return{x:h*u,y:w*b}},[i,a,r,x]),R=s.useCallback(h=>{if(n&&h.type==="ai-cursor-action"){const w={id:`action-${Date.now()}-${Math.random()}`,type:h.action||"action",toolName:h.toolName,selector:h.selector,text:h.text,url:h.url,x:h.x,y:h.y,timestamp:Date.now()};if(d(w),setTimeout(()=>{d(u=>(u==null?void 0:u.id)===w.id?null:u)},er),w.type==="click"&&w.x!==void 0&&w.y!==void 0){const u=T(w.x,w.y);c.current.push({id:w.id,x:u.x,y:u.y,startTime:Date.now(),duration:Zs}),E({x:w.x,y:w.y}),m.current=Date.now()}["hover","type","select"].includes(w.type)&&w.x!==void 0&&w.y!==void 0&&(E({x:w.x,y:w.y}),m.current=Date.now())}},[n,T]);if(s.useEffect(()=>t(R),[t,R]),s.useEffect(()=>{if(!n)return;const h=()=>{const w=f.current;if(!w){v.current=requestAnimationFrame(h);return}(w.width!==i||w.height!==a)&&(w.width=i,w.height=a);const u=w.getContext("2d");if(!u){v.current=requestAnimationFrame(h);return}u.clearRect(0,0,w.width,w.height);const b=Date.now();c.current=c.current.filter(y=>b-y.startTime<y.duration);for(const y of c.current){const z=(b-y.startTime)/y.duration,F=30*z,k=1-z;u.beginPath(),u.arc(y.x,y.y,F,0,Math.PI*2),u.strokeStyle=`rgba(168, 85, 247, ${k*.8})`,u.lineWidth=2.5,u.stroke(),u.beginPath(),u.arc(y.x,y.y,F*.4,0,Math.PI*2),u.fillStyle=`rgba(168, 85, 247, ${k*.3})`,u.fill(),z<.3&&(u.beginPath(),u.arc(y.x,y.y,3,0,Math.PI*2),u.fillStyle=`rgba(168, 85, 247, ${(1-z/.3)*.9})`,u.fill())}if(p){const y=b-m.current;if(y<ht){const A=Math.max(0,1-y/ht),z=T(p.x,p.y),X=12;u.strokeStyle=`rgba(168, 85, 247, ${A*.9})`,u.lineWidth=1.5,u.beginPath(),u.moveTo(z.x-X,z.y),u.lineTo(z.x+X,z.y),u.stroke(),u.beginPath(),u.moveTo(z.x,z.y-X),u.lineTo(z.x,z.y+X),u.stroke();const F=b%1e3/1e3,k=6+Math.sin(F*Math.PI*2)*2;u.beginPath(),u.arc(z.x,z.y,k,0,Math.PI*2),u.strokeStyle=`rgba(168, 85, 247, ${A*.5})`,u.lineWidth=1,u.stroke()}}v.current=requestAnimationFrame(h)};return v.current=requestAnimationFrame(h),()=>{v.current&&cancelAnimationFrame(v.current)}},[n,i,a,p,T]),!n)return null;const _=h=>{switch(h.type){case"click":return`Click ${h.selector||""}`.trim();case"type":return`Type "${(h.text||"").slice(0,30)}${(h.text||"").length>30?"...":""}"`;case"hover":return`Hover ${h.selector||""}`.trim();case"navigate":return`Navigate → ${(h.url||"").slice(0,40)}`;case"select":return`Select ${h.selector||""}`.trim();case"key":return`Press ${h.text||"key"}`;case"screenshot":return"Taking screenshot";case"scroll":return"Scrolling";case"wait":return`Waiting for ${h.selector||"element"}`;case"launch":return"Launching browser";case"close":return"Closing browser";default:return h.toolName}};return e.jsxs(e.Fragment,{children:[e.jsx("canvas",{ref:f,className:"absolute inset-0 pointer-events-none z-10",style:{width:"100%",height:"100%"}}),l&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20 pointer-events-none animate-in fade-in slide-in-from-top-1 duration-200",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-gray-900/95 border border-purple-400/40 shadow-lg shadow-black/40 backdrop-blur-md",children:[e.jsx(sr,{type:l.type}),e.jsx("span",{className:"text-[11px] font-semibold text-white whitespace-nowrap max-w-[280px] truncate drop-shadow-sm",children:_(l)})]})})]})}function sr({type:t}){const a="text-purple-300";switch(t){case"click":return e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:[e.jsx("circle",{cx:"8",cy:"8",r:"3"}),e.jsx("circle",{cx:"8",cy:"8",r:"7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})]});case"type":return e.jsxs("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:[e.jsx("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("line",{x1:"5",y1:"7",x2:"11",y2:"7",stroke:"currentColor",strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"9",x2:"9",y2:"9",stroke:"currentColor",strokeWidth:"1"})]});case"navigate":return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("path",{d:"M3 8h10M10 5l3 3-3 3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});case"hover":return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("path",{d:"M4 2l8 6-4 1-2 4z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})});default:return e.jsx("svg",{width:12,height:12,viewBox:"0 0 16 16",className:a,fill:"currentColor",children:e.jsx("circle",{cx:"8",cy:"8",r:"2"})})}}const rr=[{label:"Mobile",icon:lt,width:375,height:812},{label:"Tablet",icon:ms,width:768,height:1024},{label:"Desktop",icon:We,width:1280,height:720},{label:"Full HD",icon:We,width:1920,height:1080}],at="testver-live-view-focus";function Fr(){window.dispatchEvent(new Event(at))}function At({browserStatus:t,sessionEpoch:i=0,subscribe:a,send:r,isPiP:x,onTogglePiP:n,onCloseBrowser:f,userControlOnly:c=!1}){var B,K;const[l,d]=s.useState(!1),[p,E]=s.useState(!1),[m,v]=s.useState({width:1280,height:720}),[T,R]=s.useState(""),[_,h]=s.useState(""),[w,u]=s.useState(0),[b,y]=s.useState(c?"user":"ai"),A=s.useRef(b);A.current=b;const[z,X]=s.useState(!1),[F,k]=s.useState(null),[L,M]=s.useState("default"),[C,H]=s.useState(!1),[W,Q]=s.useState(!1),[O,ke]=s.useState(200),[U,He]=s.useState(!c),[Y,Ne]=s.useState(!1),[J,Ce]=s.useState(!1),G=s.useRef(null),ce=s.useRef(null),Z=s.useRef(null),he=s.useRef(null),ee=s.useRef(0),pe=s.useRef(null),de=s.useRef(null);s.useEffect(()=>{const o=()=>{var $;A.current==="user"&&(($=de.current)==null||$.focus({preventScroll:!0}))};return window.addEventListener(at,o),()=>window.removeEventListener(at,o)},[]);const ne=s.useRef(0);s.useEffect(()=>{he.current||(he.current=new Image)},[]),s.useEffect(()=>(pe.current=setInterval(()=>{u(ee.current),ee.current=0},1e3),()=>{pe.current&&clearInterval(pe.current)}),[]);const Se=s.useRef(0),me=s.useRef(i),Me=s.useRef(t.active);Me.current=t.active;const $e=s.useRef(l);$e.current=l;const Pe=s.useCallback(()=>{var S,I;Se.current++;const o=G.current;o&&((S=o.getContext("2d"))==null||S.clearRect(0,0,o.width,o.height));const $=ce.current;$&&((I=$.getContext("2d"))==null||I.clearRect(0,0,$.width,$.height)),k(null)},[]);s.useEffect(()=>{const o=i!==me.current;me.current=i,t.active?o?(Pe(),fe()):!l&&!p&&fe():l&&(ae(),Pe())},[t.active,i]);const fe=s.useCallback(async()=>{E(!0);try{const o=await Ft();v({width:o.width,height:o.height}),r({type:"screencast-start",options:{quality:50}}),d(!0)}catch{r({type:"screencast-start",options:{quality:50}}),d(!0)}E(!1)},[r]),ae=s.useCallback(()=>{r({type:"screencast-stop"}),d(!1),u(0)},[r]),se=s.useRef(null),Ae=s.useCallback(()=>{se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{se.current=null,Me.current&&!$e.current&&fe()},600)},[fe]);s.useEffect(()=>()=>{se.current&&clearTimeout(se.current)},[]);const ze=s.useCallback(o=>{if(o.type==="screencast-frame"){const $=o.data,S=o.metadata;S&&v(V=>V.width!==S.width||V.height!==S.height?{width:S.width,height:S.height}:V);const I=he.current;if(!I)return;const re=Se.current;I.onload=()=>{var oe;if(re!==Se.current)return;const V=G.current;V&&((V.width!==((S==null?void 0:S.width)||m.width)||V.height!==((S==null?void 0:S.height)||m.height))&&(V.width=(S==null?void 0:S.width)||m.width,V.height=(S==null?void 0:S.height)||m.height),Z.current||(Z.current=V.getContext("2d")),(oe=Z.current)==null||oe.drawImage(I,0,0,V.width,V.height),ee.current++)},I.src=`data:image/jpeg;base64,${$}`;return}if(o.type==="screencast-viewport"){v({width:o.width,height:o.height});return}if(o.type==="screencast-stopped"){d(!1),u(0),Ae();return}if(o.type==="screencast-error"){d(!1),E(!1),Ae();return}if(o.type==="screencast-highlight"){k(o.highlight);return}if(o.type==="browser-tab-switched"){o.url&&R(o.url),h("");return}if(o.type==="screencast-url-changed"){o.url&&R(o.url),o.title&&h(o.title);return}if(o.type==="screencast-cursor"){M(o.cursor||"default");return}if(o.type==="ai-orchestrator-paused"){Ne(!0);return}if(o.type==="ai-orchestrator-resumed"){Ne(!1);return}if(o.type==="ai-fix-tool"){Ce(!0);return}if(o.type==="ai-fix-done"||o.type==="ai-fix-error"){Ce(!1),Ne(!1);return}},[m]);s.useEffect(()=>a(ze),[a,ze]),s.useEffect(()=>{t.url&&R(t.url)},[t.url]),s.useEffect(()=>{h("")},[i,t.active]),s.useEffect(()=>{const o=ce.current;if(!o)return;const $=G.current;if(!$)return;(o.width!==$.width||o.height!==$.height)&&(o.width=$.width,o.height=$.height);const S=o.getContext("2d");if(S&&(S.clearRect(0,0,o.width,o.height),F&&z)){const I=F;S.fillStyle="rgba(59, 130, 246, 0.1)",S.fillRect(I.x,I.y,I.width,I.height),S.strokeStyle="rgba(59, 130, 246, 0.7)",S.lineWidth=2,S.setLineDash([]),S.strokeRect(I.x,I.y,I.width,I.height);const re=`${I.tagName}${I.id?"#"+I.id:""}${I.className?"."+I.className.split(" ")[0]:""}`;S.font="11px monospace";const V=S.measureText(re).width,oe=I.x,be=I.y>18?I.y-4:I.y+I.height+14;S.fillStyle="rgba(30, 41, 59, 0.9)",S.fillRect(oe,be-12,V+8,16),S.fillStyle="#93c5fd",S.fillText(re,oe+4,be)}},[F,z]);const q=s.useCallback((o,$)=>{const S=G.current;if(!S)return{x:0,y:0};const I=S.getBoundingClientRect(),re=o-I.left,V=$-I.top,oe=m.width/I.width,be=m.height/I.height;return{x:Math.round(re*oe),y:Math.round(V*be)}},[m]),te=o=>{let $=0;return o.altKey&&($|=1),o.ctrlKey&&($|=2),o.metaKey&&($|=4),o.shiftKey&&($|=8),$},Re=o=>o.button===2?"right":o.button===1?"middle":"left",Xe=s.useCallback(o=>{var I;if(b!=="user")return;o.preventDefault(),(I=de.current)==null||I.focus();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mousePressed",x:$,y:S,button:Re(o),clickCount:o.detail||1,modifiers:te(o)})},[b,q,r]),Ve=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mouseReleased",x:$,y:S,button:Re(o),clickCount:o.detail||1,modifiers:te(o)})},[b,q,r]),Ye=s.useCallback(o=>{if(b!=="user")return;const $=Date.now();if($-ne.current<50)return;ne.current=$;const{x:S,y:I}=q(o.clientX,o.clientY);z&&r({type:"screencast-hover",x:S,y:I}),r({type:"screencast-mouse",mouseType:"mouseMoved",x:S,y:I,button:"none",modifiers:te(o)})},[b,q,r,z]),ie=s.useCallback(()=>{z&&k(null)},[z]),ge=s.useCallback(o=>{o.preventDefault()},[]),Ge=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-mouse",mouseType:"mousePressed",x:$,y:S,button:"left",clickCount:2,modifiers:te(o)}),r({type:"screencast-mouse",mouseType:"mouseReleased",x:$,y:S,button:"left",clickCount:2,modifiers:te(o)})},[b,q,r]),Ke=s.useCallback(o=>{b==="user"&&o.target.tagName!=="INPUT"&&(o.preventDefault(),r({type:"screencast-key",keyType:"keyDown",key:o.key,code:o.code,text:o.key.length===1?o.key:void 0,modifiers:te(o)}))},[b,r]),qe=s.useCallback(o=>{b==="user"&&o.target.tagName!=="INPUT"&&(o.preventDefault(),r({type:"screencast-key",keyType:"keyUp",key:o.key,code:o.code,modifiers:te(o)}))},[b,r]),Je=s.useCallback(o=>{if(b!=="user")return;o.preventDefault();const{x:$,y:S}=q(o.clientX,o.clientY);r({type:"screencast-scroll",x:$,y:S,deltaX:o.deltaX,deltaY:o.deltaY})},[b,q,r]),_e=o=>{if(o.preventDefault(),!T.trim())return;let $=T.trim();$.match(/^https?:\/\//)||($=`https://${$}`),r({type:"screencast-navigate",url:$})},g=o=>{r({type:"screencast-tab",index:o})},N=(o,$)=>{r({type:"screencast-resize-viewport",width:o,height:$}),H(!1)},j=s.useRef(!1);s.useEffect(()=>{const o=S=>{if(!j.current||!de.current)return;const re=de.current.getBoundingClientRect().bottom-S.clientY;ke(Math.min(400,Math.max(100,re)))},$=()=>{j.current=!1,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",o),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",$)}},[]);const P=t.tabs||[],D=m.width/m.height;return e.jsxs("div",{ref:de,className:"flex flex-col h-full bg-surface-0 outline-none",tabIndex:0,onKeyDown:Ke,onKeyUp:qe,children:[e.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0 overflow-x-auto",children:[P.map(o=>e.jsxs("button",{onClick:()=>g(o.index),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-t-lg text-[11px] max-w-[150px] truncate flex-shrink-0 transition-colors ${o.active?"bg-surface-0 text-gray-200 border-t border-x border-white/10":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,title:o.url,children:[e.jsx(kt,{size:10,className:"flex-shrink-0"}),e.jsx("span",{className:"truncate",children:o.active&&_||o.title||`Tab ${o.index+1}`})]},o.index)),P.length===0&&e.jsx("span",{className:"text-[11px] text-gray-600 px-2",children:"No tabs"}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 flex-shrink-0",children:[J&&e.jsx("button",{onClick:()=>{r(Y?{type:"screencast-resume"}:{type:"screencast-pause"})},className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-colors ${Y?"bg-emerald-600 text-white border border-emerald-400/50 hover:bg-emerald-500 shadow-sm shadow-emerald-500/20":"bg-orange-600 text-white border border-orange-400/50 hover:bg-orange-500 shadow-sm shadow-orange-500/20"}`,title:Y?"Resume AI execution":"Pause AI execution",children:Y?e.jsxs(e.Fragment,{children:[e.jsx(rt,{size:10})," Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{size:10})," Pause"]})}),!c&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>He(!U),className:`p-1 rounded transition-colors ${U?"text-purple-400 bg-purple-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:U?"Disable watch mode overlay":"Enable watch mode overlay",children:e.jsx(ot,{size:11})}),e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("button",{onClick:()=>y("ai"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${b==="ai"?"bg-purple-500/20 text-purple-300 border border-purple-500/30":"text-gray-500 hover:text-gray-400"}`,title:"AI is controlling the browser",children:[e.jsx(cs,{size:10})," AI"]}),e.jsxs("button",{onClick:()=>y("user"),className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${b==="user"?"bg-brand-500/20 text-brand-300 border border-brand-500/30":"text-gray-500 hover:text-gray-400"}`,title:"You are controlling the browser",children:[e.jsx(ds,{size:10})," User"]})]}),n&&e.jsxs("button",{onClick:n,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${x?"text-brand-400 bg-brand-500/15":"text-gray-500 hover:text-gray-400"}`,title:x?"Exit Picture-in-Picture":"Picture-in-Picture",children:[e.jsx(us,{size:11})," PiP"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-3 bg-white/10"}),e.jsxs("button",{onClick:f,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] font-medium text-red-400/70 hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Close browser session",children:[e.jsx(xs,{size:10})," Close"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>r({type:"screencast-go-back"}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",title:"Go back",children:e.jsx(hs,{size:12})}),e.jsx("button",{onClick:()=>r({type:"screencast-go-forward"}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",title:"Go forward",children:e.jsx(fs,{size:12})}),e.jsx("button",{onClick:()=>r({type:"screencast-navigate",url:t.url||""}),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-400 transition-colors",children:e.jsx(ps,{size:12})}),e.jsx("form",{onSubmit:_e,className:"flex-1",children:e.jsx("input",{type:"text",value:T,onChange:o=>R(o.target.value),placeholder:"Enter URL...",className:"w-full px-2.5 py-1 rounded-lg bg-surface-2 border border-white/5 text-xs text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/30"})}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>H(!C),className:"flex items-center gap-1 px-1.5 py-1 rounded text-[10px] text-gray-500 hover:text-gray-400 hover:bg-white/5 transition-colors",title:"Viewport presets",children:[e.jsx(We,{size:11}),e.jsx(Be,{size:9})]}),C&&e.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-1 border border-white/10 rounded-lg z-50 py-1 w-40",children:rr.map(o=>{const $=o.icon,S=m.width===o.width&&m.height===o.height;return e.jsxs("button",{onClick:()=>N(o.width,o.height),className:`w-full text-left px-3 py-1.5 text-[11px] flex items-center gap-2 transition-colors ${S?"text-brand-300 bg-brand-500/10":"text-gray-300 hover:bg-white/5"}`,children:[e.jsx($,{size:11,className:"flex-shrink-0"}),e.jsx("span",{children:o.label}),e.jsxs("span",{className:"ml-auto text-gray-600 text-[10px]",children:[o.width,"x",o.height]})]},o.label)})})]}),e.jsx("button",{onClick:()=>X(!z),className:`p-1 rounded transition-colors ${z?"text-blue-400 bg-blue-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:z?"Disable element highlight":"Enable element highlight",children:e.jsx(gs,{size:12})}),e.jsx("button",{onClick:()=>Q(!W),className:`p-1 rounded transition-colors ${W?"text-purple-400 bg-purple-500/15":"text-gray-500 hover:text-gray-400 hover:bg-white/5"}`,title:W?"Hide DevTools":"Show DevTools",children:W?e.jsx(bs,{size:12}):e.jsx(ys,{size:12})})]}),e.jsx("div",{className:"flex-1 overflow-hidden bg-black/50 flex items-center justify-center relative min-h-0",children:l?e.jsxs("div",{className:"relative max-w-full max-h-full",style:{aspectRatio:`${D}`},children:[e.jsx("canvas",{ref:G,className:"max-w-full max-h-full block",style:{aspectRatio:`${D}`,cursor:b==="user"?L:"not-allowed"},onMouseDown:Xe,onMouseUp:Ve,onMouseMove:Ye,onMouseLeave:ie,onDoubleClick:Ge,onContextMenu:ge,onWheel:Je}),z&&e.jsx("canvas",{ref:ce,className:"absolute inset-0 pointer-events-none max-w-full max-h-full",style:{aspectRatio:`${D}`}}),U&&G.current&&e.jsx(tr,{subscribe:a,canvasWidth:((B=G.current)==null?void 0:B.width)||m.width,canvasHeight:((K=G.current)==null?void 0:K.height)||m.height,viewportWidth:m.width,viewportHeight:m.height,enabled:U}),Y&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-30",style:{pointerEvents:"none",background:"rgba(0, 0, 0, 0.15)"},children:e.jsxs("div",{className:"flex items-center gap-4 px-5 py-3 rounded-2xl border",style:{pointerEvents:"auto",background:"rgba(20, 20, 30, 0.7)",borderColor:"rgba(251, 191, 36, 0.5)",boxShadow:"0 4px 20px rgba(0,0,0,0.4)"},children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-orange-500/25 flex items-center justify-center flex-shrink-0",children:e.jsx(Fe,{size:20,className:"text-orange-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-bold text-white",children:"AI Paused"}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#ffffff"},children:"Execution paused before next action"})]}),e.jsxs("button",{onClick:()=>r({type:"screencast-resume"}),className:"ml-3 flex items-center gap-1.5 px-4 py-2 rounded-lg bg-emerald-600 text-white text-sm font-semibold hover:bg-emerald-500 transition-colors shadow-md shadow-emerald-500/20",children:[e.jsx(rt,{size:14})," Resume"]})]})})]}):p?e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-xs",children:"Connecting to browser..."})]}):e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-600",children:[e.jsx(We,{size:32}),e.jsx("span",{className:"text-xs",children:"No live view available"}),e.jsx("span",{className:"text-[10px] text-gray-700",children:"Launch a browser to see it here"})]})}),W&&l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onMouseDown:o=>{o.preventDefault(),j.current=!0,document.body.style.cursor="row-resize",document.body.style.userSelect="none"},className:"h-1 flex-shrink-0 cursor-row-resize bg-white/5 hover:bg-brand-500/40 active:bg-brand-500/40 transition-colors"}),e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{height:`${O}px`},children:e.jsx(qs,{subscribe:a,send:r,isStreaming:l})})]}),e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1 border-t border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[l?e.jsx(ws,{size:10,className:"text-emerald-400"}):e.jsx(vs,{size:10,className:"text-gray-600"}),e.jsx("span",{className:`text-[10px] ${l?"text-emerald-400":"text-gray-600"}`,children:l?"Live":"Offline"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[w," fps"]}),e.jsxs("span",{className:"text-[10px] text-gray-600",children:[m.width,"x",m.height]})]}),z&&F&&e.jsxs("span",{className:"text-[10px] text-blue-400 font-mono truncate max-w-[200px]",children:["<",F.tagName,F.id?`#${F.id}`:"",">"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Y&&e.jsx("span",{className:"text-[10px] text-orange-300 font-semibold animate-pulse",children:"AI Paused"}),J&&!Y&&e.jsx("span",{className:"text-[10px] text-purple-300 font-medium",children:"AI Working"}),b==="user"&&e.jsx("span",{className:"text-[10px] text-brand-400 font-medium",children:"Interactive Mode"}),l&&e.jsx("button",{onClick:ae,className:"text-[10px] text-gray-500 hover:text-gray-400 transition-colors",children:"Disconnect"}),!l&&t.active&&e.jsx("button",{onClick:fe,className:"text-[10px] text-brand-400 hover:text-brand-300 transition-colors",children:"Connect"})]})]})]})}function Wr({children:t,userControlOnly:i=!1}){const{subscribe:a,send:r}=yt(),[x,n]=s.useState({active:!1}),[f,c]=s.useState(50),[l,d]=s.useState(!1),[p,E]=s.useState({w:480,h:360}),[m,v]=s.useState({x:-1,y:-1}),[T,R]=s.useState(!1),[_,h]=s.useState(0),w=s.useRef(!1),u=s.useRef(null),b=s.useRef(null);s.useEffect(()=>{vt().then(()=>ct()).then(L=>{L.active&&n({active:!0,url:L.url||"",title:L.title||"",tabs:L.tabs||[]})}).catch(()=>{})},[]),s.useEffect(()=>{if(!x.active)return;const L=setInterval(()=>{Wt().catch(()=>{})},300*1e3);return()=>clearInterval(L)},[x.active]);const y=s.useCallback((L=0)=>{const M=()=>{ct().then(C=>{C.active&&n({active:!0,url:C.url||"",title:C.title||"",tabs:C.tabs||[]})}).catch(()=>{})};L>0?setTimeout(M,L):M()},[]);s.useEffect(()=>a(M=>{if(M.type==="browser-launched"){n(C=>({...C,active:!0,url:M.url||C.url||""})),h(C=>C+1),y(300);return}if(M.type==="browser-closed"){n({active:!1}),R(!0),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>R(!1),4e3);return}if(M.type==="browser-tab-switched"){n(C=>({...C,active:!0,url:M.url||C.url||"",title:M.title||C.title||"",tabs:M.tabs||C.tabs||[]}));return}if(M.type==="screencast-url-changed"){n(C=>({...C,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="ai-fix-browser-action"){n(C=>({...C,active:!0,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="ai-fix-screenshot"){M.url&&n(C=>({...C,url:M.url||C.url||"",title:M.title||C.title||""}));return}if(M.type==="recorder-status"&&M.status==="recording"){n(C=>({...C,active:!0,url:M.url||C.url||""})),y(500);return}if(M.type==="recorder-status"&&M.status==="reset"){y(200);return}if(M.type==="ai-fix-tool"&&M.phase==="complete"){if(M.toolName==="browser_launch"){n(C=>({...C,active:!0})),h(C=>C+1),y(300);return}if(M.toolName==="browser_close"){n({active:!1});return}}}),[a,y]);const A=s.useCallback(L=>{L.preventDefault(),w.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const L=C=>{if(!w.current||!u.current)return;const H=u.current.getBoundingClientRect(),Q=100-(C.clientX-H.left)/H.width*100;c(Math.min(75,Math.max(25,Q)))},M=()=>{w.current&&(w.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",M),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",M)}},[]);const z=s.useCallback(()=>{d(L=>!L)},[]),X=s.useCallback(async()=>{try{await Ot()}catch{r({type:"screencast-close-browser"})}},[r]);s.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const F=x.active,k=F&&!l;return e.jsxs("div",{ref:u,className:"flex h-full overflow-hidden relative",children:[e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{width:k?`${100-f}%`:"100%"},children:t}),k&&e.jsx("div",{onMouseDown:A,className:"w-1 flex-shrink-0 cursor-col-resize bg-white/5 hover:bg-brand-500/40 active:bg-brand-500/40 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),k&&e.jsx("div",{className:"flex-shrink-0 overflow-hidden flex flex-col",style:{width:`${f}%`},children:e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(At,{browserStatus:x,sessionEpoch:_,subscribe:a,send:r,isPiP:!1,onTogglePiP:z,onCloseBrowser:X,userControlOnly:i})})}),F&&l&&e.jsx(nr,{browserStatus:x,sessionEpoch:_,subscribe:a,send:r,size:p,onSizeChange:E,pos:m,onPosChange:v,onTogglePiP:z,onCloseBrowser:X,containerRef:u,userControlOnly:i}),T&&e.jsx("div",{className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-50 animate-fade-in",children:e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/10 shadow-lg shadow-black/30",children:[e.jsx(js,{size:16,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-300 font-medium",children:"Browser session closed"}),e.jsx("button",{onClick:()=>R(!1),className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors ml-1",children:e.jsx(je,{size:12})})]})})]})}function nr({browserStatus:t,sessionEpoch:i,subscribe:a,send:r,size:x,onSizeChange:n,pos:f,onPosChange:c,onTogglePiP:l,onCloseBrowser:d,containerRef:p,userControlOnly:E=!1}){const m=s.useRef(null),v=s.useRef(!1),T=s.useRef(!1),R=s.useRef({x:0,y:0}),[_,h]=s.useState(!1),w=s.useRef(x),u=s.useCallback(()=>{if(f.x>=0&&f.y>=0)return f;const F=p.current;if(!F)return{x:20,y:20};const k=F.getBoundingClientRect();return{x:k.width-x.w-16,y:k.height-x.h-16}},[f,x,p]),b=s.useCallback(F=>{if(_)return;F.preventDefault(),v.current=!0;const k=u();R.current={x:F.clientX-k.x,y:F.clientY-k.y},document.body.style.cursor="grabbing",document.body.style.userSelect="none"},[u,_]),y=s.useCallback(F=>{F.preventDefault(),F.stopPropagation(),T.current=!0,document.body.style.cursor="nwse-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const F=L=>{if(v.current){const M=p.current,C=L.clientX-R.current.x,H=L.clientY-R.current.y;if(M){const W=M.getBoundingClientRect(),Q=60,O=Math.min(Math.max(-x.w+Q,C),W.width-Q),ke=Math.min(Math.max(0,H),W.height-Q);c({x:O,y:ke})}else c({x:Math.max(0,C),y:Math.max(0,H)})}if(T.current&&m.current){const M=m.current.getBoundingClientRect(),C=p.current,H=C?C.getBoundingClientRect().width-16:1200,W=C?C.getBoundingClientRect().height-16:800,Q=Math.min(H,Math.max(320,L.clientX-M.left)),O=Math.min(W,Math.max(240,L.clientY-M.top));n({w:Q,h:O})}},k=()=>{v.current=!1,T.current=!1,document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("mousemove",F),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",F),window.removeEventListener("mouseup",k)}},[c,n]);const A=()=>{if(_)n(w.current),h(!1);else{w.current=x;const F=p.current;if(F){const k=F.getBoundingClientRect();n({w:k.width-32,h:k.height-32}),c({x:16,y:16})}h(!0)}},z=u(),X=x;return e.jsxs("div",{ref:m,className:"absolute z-50 rounded-xl overflow-hidden border border-white/10 shadow-2xl shadow-black/50 bg-surface-0",style:{left:z.x,top:z.y,width:X.w,height:X.h},children:[e.jsxs("div",{onMouseDown:b,className:"flex items-center gap-2 px-2 py-1 bg-surface-1 border-b border-white/5 cursor-grab active:cursor-grabbing flex-shrink-0",children:[e.jsx(ks,{size:10,className:"text-gray-600"}),e.jsx("span",{className:"text-[10px] text-gray-400 font-medium flex-1",children:"Live Browser"}),e.jsx("button",{onClick:A,className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors",children:_?e.jsx(Ns,{size:10}):e.jsx(Cs,{size:10})}),e.jsx("button",{onClick:l,className:"p-0.5 rounded hover:bg-white/10 text-gray-500 hover:text-gray-400 transition-colors",children:e.jsx(je,{size:10})})]}),e.jsx("div",{className:"h-[calc(100%-24px)]",children:e.jsx(At,{browserStatus:t,sessionEpoch:i,subscribe:a,send:r,isPiP:!0,onTogglePiP:l,onCloseBrowser:d,userControlOnly:E})}),!_&&e.jsx("div",{onMouseDown:y,className:"absolute bottom-0 right-0 w-4 h-4 cursor-nwse-resize",style:{background:"linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.1) 50%)"}})]})}function ar({actions:t,onActionAdded:i,onStopped:a,onCancel:r}){const[x,n]=s.useState(""),[f,c]=s.useState(!1),[l,d]=s.useState(null),p=async()=>{if(x.trim()){c(!0),d(null);try{const m=await Ut(x);i(m.action),n("")}catch(m){d(m.message)}finally{c(!1)}}},E=async()=>{c(!0),d(null);try{const m=await Bt({testName:`Recorded ${Ys(new Date)}`,formatter:"wdio-appium-ts"});a(m)}catch(m){d(m.message)}finally{c(!1)}};return e.jsxs("div",{className:"border-t border-white/[0.05] bg-surface-1 flex flex-col",style:{maxHeight:280},children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11px] border-b border-white/[0.05]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-red-500/15 text-red-300",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse"}),"REC"]}),e.jsxs("span",{className:"text-gray-400",children:[t.length," action",t.length===1?"":"s"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:r,disabled:f,className:"px-2 py-0.5 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5 disabled:opacity-40",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:E,disabled:f||t.length===0,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-emerald-500/15 text-emerald-300 hover:bg-emerald-500/25 disabled:opacity-40",title:"Stop recording and generate test file",children:[f?e.jsx(ve,{size:11,className:"animate-spin"}):e.jsx(Ss,{size:10}),"Stop & Generate"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2 space-y-1 text-[11px]",children:t.length===0?e.jsx("div",{className:"text-gray-500 italic",children:"Tap on the device screen above to record actions. Each tap finds the underlying element and stores a ranked locator set for the generated test."}):t.map(m=>e.jsx(ir,{action:m},m.index))}),e.jsxs("div",{className:"border-t border-white/[0.05] px-3 py-1.5 flex items-center gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:m=>n(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),p())},disabled:f,placeholder:"Type text into the last tapped field…",className:"flex-1 bg-transparent border border-white/10 rounded px-2 py-1 text-[11px] text-gray-200 placeholder-gray-600 focus:outline-none focus:border-indigo-400/50"}),e.jsx("button",{type:"button",onClick:p,disabled:f||!x.trim(),className:"p-1 rounded text-indigo-300 hover:text-indigo-200 hover:bg-indigo-500/10 disabled:opacity-40",title:"Send text (Enter)",children:f?e.jsx(ve,{size:11,className:"animate-spin"}):e.jsx(Nt,{size:11})})]}),l&&e.jsxs("div",{className:"px-3 py-1 border-t border-white/[0.05] text-[11px] text-red-300 flex items-center gap-1",children:[e.jsx(Rs,{size:11}),l]})]})}function ir({action:t}){const i=t.type==="tap"?"👆":t.type==="type"?"⌨️":t.type==="swipe"?"↔︎":"⏎";return e.jsxs("div",{className:"flex items-start gap-1.5 text-gray-300",children:[e.jsxs("span",{className:"text-gray-500 tabular-nums w-5 text-right",children:[t.index+1,"."]}),e.jsx("span",{children:i}),e.jsxs("span",{className:"flex-1 break-all",children:[t.description,t.primary&&e.jsxs("span",{className:"text-gray-500 ml-1",children:["(",t.primary.strategy,"=",t.primary.value.slice(0,32),t.primary.value.length>32?"…":"",")"]})]})]})}function or({result:t,onDismiss:i}){return e.jsxs("div",{className:"border-t border-white/[0.05] bg-surface-1 px-3 py-2 text-[11px] space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-300",children:[e.jsx(nt,{size:12}),e.jsx("span",{className:"font-medium",children:"Test generated"})]}),e.jsxs("div",{className:"text-gray-400 flex items-start gap-1.5",children:[e.jsx(xt,{size:11,className:"mt-0.5 flex-shrink-0"}),e.jsx("code",{className:"break-all text-[10px]",children:t.specPath})]}),e.jsxs("div",{className:"text-gray-400 flex items-start gap-1.5",children:[e.jsx(xt,{size:11,className:"mt-0.5 flex-shrink-0 opacity-60"}),e.jsx("code",{className:"break-all text-[10px] opacity-80",children:t.healingPath})]}),e.jsxs("div",{className:"text-gray-500",children:["Wrote ",t.actions.length," action",t.actions.length===1?"":"s"," as a WDIO + Appium TypeScript spec. The companion ",e.jsx("code",{children:".healing.json"})," stores the full ranked locator set so the healing pipeline can recover from UI changes."]}),e.jsx("div",{className:"flex gap-2 pt-1",children:e.jsxs("button",{type:"button",onClick:i,className:"px-2 py-0.5 rounded text-gray-300 hover:bg-white/5 inline-flex items-center gap-1",children:[e.jsx(Es,{size:10})," Done"]})})]})}function ft(t,i,a){let r=null;const x=[];let n=0;for(const f of t){if(n=Math.max(n,ye(f.bounds)),i<f.bounds.x1||i>=f.bounds.x2||a<f.bounds.y1||a>=f.bounds.y2)continue;x.push(f);const c=(f.bounds.x2-f.bounds.x1)*(f.bounds.y2-f.bounds.y1);(!r||f.depth>r.depth||f.depth===r.depth&&c<ye(r.bounds))&&(r=f)}if(r&&!Qe(r)){const f=r;let c=null;for(const d of x)d===f||!Qe(d)||n&&ye(d.bounds)>n*.4||(!c||d.depth>c.depth||d.depth===c.depth&&ye(d.bounds)<ye(c.bounds))&&(c=d);if(c)return c;const l=x.filter(d=>d!==f&&d.depth<f.depth&&d.depth>=f.depth-4&&f.path.startsWith(d.path+"/")).sort((d,p)=>p.depth-d.depth);for(const d of l){if(n&&ye(d.bounds)>n*.4)break;if(Qe(d)||d.attrs.clickable==="true")return d}}return r}function Qe(t){const i=t.attrs["resource-id"]||"",a=[t.attrs["content-desc"],t.attrs.text,t.attrs.name,t.attrs.label,t.attrs.accessibilityIdentifier];return i.includes(":id/")&&!i.startsWith("android:")||a.some(r=>!!(r&&r.trim()))}function ye(t){return Math.max(0,t.x2-t.x1)*Math.max(0,t.y2-t.y1)}function we(t,i){const a=i==="android"?t.attrs.text||t.attrs["content-desc"]:t.attrs.label||t.attrs.name;if(a&&a.trim())return`"${a.slice(0,40)}"`;const r=t.attrs["resource-id"];return r?`#${r.split("/").pop()||r}`:t.tag.split(".").pop()||t.tag}function lr(t,i){const a=[];let r=t.path;for(a.unshift(t);;){const x=r.lastIndexOf("/");if(x<=0)break;r=r.slice(0,x);const n=i.find(f=>f.path===r);if(!n||(a.unshift(n),a.length>12))break}return a}function pt(t,i,a){const r=[],x=(c,l)=>i.filter(d=>d.attrs[c]===l).length===1,n=c=>i.filter(l=>l.attrs.text===c).length===1;if(a==="android"){const c=t.attrs["content-desc"];c&&c.trim()&&x("content-desc",c)&&r.push({strategy:"accessibility-id",value:c});const l=t.attrs["resource-id"];l&&l.includes(":id/")&&x("resource-id",l)&&r.push({strategy:"id",value:l});const d=t.attrs.text;d&&d.trim()&&n(d)&&r.push({strategy:"xpath",value:`//${t.tag}[@text=${mt(d)}]`}),l&&l.includes(":id/")&&r.push({strategy:"-android-uiautomator",value:`new UiSelector().resourceId("${l.replace(/"/g,'\\"')}")`}),r.push({strategy:"xpath",value:t.path})}else{const c=t.attrs.name||t.attrs.accessibilityIdentifier;c&&c.trim()&&r.push({strategy:"accessibility-id",value:c});const l=t.attrs.label;l&&l.trim()&&r.push({strategy:"xpath",value:`//${t.tag}[@label=${mt(l)}]`}),c&&c.trim()&&r.push({strategy:"-ios-class-chain",value:`**/${t.tag}[\`name == "${c.replace(/"/g,'\\"')}"\`]`}),r.push({strategy:"xpath",value:t.path})}const f=new Set;return r.filter(c=>{const l=`${c.strategy}:${c.value}`;return f.has(l)?!1:(f.add(l),!0)})}function mt(t){return t.includes("'")?t.includes('"')?`concat(${t.split("'").map(i=>`'${i}'`).join(`, "'", `)})`:`"${t}"`:`'${t}'`}function cr(t,i){const a=[];a.push({type:"visible",label:"Is visible",group:"visibility",editable:!1}),a.push({type:"hidden",label:"Is hidden",group:"visibility",editable:!1}),(t.attrs.enabled==="true"||t.attrs.enabled==="false"||t.attrs.clickable)&&(a.push({type:"enabled",label:"Is enabled",group:"state",editable:!1}),a.push({type:"disabled",label:"Is disabled",group:"state",editable:!1}));const r=i==="android"?t.attrs.text||t.attrs["content-desc"]:t.attrs.label||t.attrs.name||t.attrs.value;return r&&r.trim()?a.push({type:"text",label:`Has text "${r.length>30?r.slice(0,30)+"…":r}"`,expectedValue:r,group:"text",editable:!0}):a.push({type:"text",label:"Has text (custom)…",expectedValue:"",group:"text",editable:!0}),a.push({type:"attribute",label:"Has attribute (custom)…",expectedValue:"",group:"attribute",editable:!0}),a}const Ze=300,et=440,ue=12;function dr({element:t,platform:i,anchorX:a,anchorY:r,onSubmit:x,onCancel:n}){const f=s.useRef(null),[c]=s.useState(()=>cr(t,i)),[l,d]=s.useState(null),[p,E]=s.useState(""),[m,v]=s.useState({left:a,top:r});s.useEffect(()=>{const u=A=>{var z;(z=f.current)!=null&&z.contains(A.target)||n()},b=A=>{A.key==="Escape"&&n()},y=setTimeout(()=>document.addEventListener("mousedown",u),0);return document.addEventListener("keydown",b),()=>{clearTimeout(y),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",b)}},[n]),s.useLayoutEffect(()=>{const u=window.innerWidth,b=window.innerHeight;let y=a+8,A=r+8;y+Ze+ue>u&&(y=Math.max(ue,a-Ze-8)),A+et+ue>b&&(A=Math.max(ue,r-et-8)),y<ue&&(y=ue),A<ue&&(A=ue),v({left:y,top:A})},[a,r]);const T={visibility:c.filter(u=>u.group==="visibility"),state:c.filter(u=>u.group==="state"),text:c.filter(u=>u.group==="text"),attribute:c.filter(u=>u.group==="attribute")},R=we(t,i),_=u=>{if(u.editable){d(u.type),E(u.expectedValue??"");return}x({type:u.type,expectedValue:u.expectedValue,label:R})},h=u=>{x({type:u.type,expectedValue:p,label:R})},w=e.jsxs("div",{ref:f,style:{position:"fixed",left:m.left,top:m.top,width:Ze,maxHeight:et},className:"z-[1000] rounded-xl border border-white/10 bg-surface-1 text-gray-200 shadow-2xl shadow-black/60 overflow-hidden flex flex-col backdrop-blur-md",role:"menu","aria-label":"Choose assertion",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-white/10 bg-gradient-to-r from-emerald-500/15 via-green-500/10 to-transparent",children:[e.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-md bg-emerald-500/20 border border-emerald-500/30 flex-shrink-0",children:e.jsx(Ts,{size:12,className:"text-emerald-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-200 font-bold leading-none",children:"Assert on"}),e.jsx("div",{className:"text-[12px] font-medium text-gray-100 truncate mt-0.5",children:R})]}),e.jsx("button",{onClick:n,className:"p-1 rounded-md text-gray-500 hover:text-gray-200 hover:bg-white/10 transition-colors","aria-label":"Close menu",children:e.jsx(je,{size:13})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1.5 bg-surface-1",children:["visibility","state","text","attribute"].map(u=>{const b=T[u];return b.length===0?null:e.jsxs("div",{className:"py-1",children:[e.jsx("div",{className:"px-3 pb-1 pt-1 text-[10px] uppercase tracking-wider text-gray-500 font-semibold",children:ur[u]}),b.map(y=>e.jsx("div",{children:l===y.type?e.jsxs("div",{className:"px-3 py-2.5 bg-emerald-500/[0.04] border-y border-emerald-500/10",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx(gt,{group:y.group}),e.jsx("span",{className:"text-[11px] text-gray-200 font-medium",children:y.type==="attribute"?"Attribute name → value":"Expected text"})]}),e.jsx("input",{type:"text",autoFocus:!0,value:p,onChange:A=>E(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),h(y)),A.key==="Escape"&&(A.preventDefault(),d(null))},placeholder:y.type==="attribute"?"e.g. enabled=true":"expected text…",className:"w-full bg-surface-0 border border-white/15 rounded-md px-2.5 py-1.5 text-[12px] text-gray-100 placeholder-gray-600 focus:outline-none focus:border-emerald-400/60 focus:ring-1 focus:ring-emerald-400/20"}),e.jsxs("div",{className:"flex justify-end gap-1.5 mt-1.5",children:[e.jsx("button",{onClick:()=>d(null),className:"px-2.5 py-1 rounded-md text-[11px] text-gray-400 hover:bg-white/5",children:"Cancel"}),e.jsxs("button",{onClick:()=>h(y),disabled:!p.trim()&&y.type!=="text",className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-[11px] bg-emerald-500/20 text-emerald-200 border border-emerald-500/30 hover:bg-emerald-500/30 disabled:opacity-40 transition-colors",children:[e.jsx(Ct,{size:10})," Record"]})]})]}):e.jsxs("button",{type:"button",onClick:()=>_(y),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-gray-200 hover:bg-emerald-500/10 hover:text-emerald-200 transition-colors group",children:[e.jsx(gt,{group:y.group}),e.jsx("span",{className:"flex-1 truncate",children:y.label}),e.jsx(Ue,{size:11,className:"text-gray-600 group-hover:text-emerald-300 opacity-0 group-hover:opacity-100 transition-opacity"})]})},y.type+y.label))]},u)})}),e.jsxs("div",{className:"px-3 py-1.5 border-t border-white/10 bg-surface-2/40 text-[10px] text-gray-500 flex items-center justify-between",children:[e.jsxs("span",{children:["Press ",e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-white/10 text-gray-300 text-[9px] font-mono",children:"Esc"})," to close"]}),e.jsxs("span",{className:"text-gray-600",children:[c.length," option",c.length===1?"":"s"]})]})]});return wt.createPortal(w,document.body)}const ur={visibility:"Visibility",state:"State",text:"Text content",attribute:"Attributes"};function gt({group:t}){const i="text-gray-500";return t==="visibility"?e.jsx(ot,{size:12,className:i}):t==="state"?e.jsx(Ms,{size:12,className:i}):t==="text"?e.jsx($s,{size:12,className:i}):e.jsx(Ps,{size:12,className:i})}const tt=400,De=520,le=16;function xr({element:t,allElements:i,platform:a,anchorX:r,anchorY:x,onSubmit:n,onCancel:f}){const c=s.useRef(null),[l,d]=s.useState(""),[p,E]=s.useState({left:r,top:x}),m=lr(t,i),v=we(t,a),T=m.map(h=>`${Ie(h.tag)}${we(h,a)===Ie(h.tag)?"":` ${we(h,a)}`}`).join(" > ");s.useEffect(()=>{const h=b=>{var y;(y=c.current)!=null&&y.contains(b.target)||f()},w=b=>{b.key==="Escape"&&f()},u=setTimeout(()=>document.addEventListener("mousedown",h),0);return document.addEventListener("keydown",w),()=>{clearTimeout(u),document.removeEventListener("mousedown",h),document.removeEventListener("keydown",w)}},[f]),s.useLayoutEffect(()=>{const h=window.innerWidth,w=window.innerHeight;let u=r+12,b=x+12;u+tt+le>h&&(u=Math.max(le,r-tt-12)),b+De+le>w&&(b=Math.max(le,Math.min(w-De-le,x-De/2))),u<le&&(u=le),b<le&&(b=le),E({left:u,top:b})},[r,x]);const R=()=>{const h=l.trim();h&&n(h,T,v)},_=e.jsx(e.Fragment,{children:e.jsxs("div",{ref:c,style:{position:"fixed",left:p.left,top:p.top,width:tt,maxHeight:De},className:"z-[1000] rounded-xl border border-white/10 bg-surface-1 text-gray-200 shadow-2xl shadow-black/70 overflow-hidden flex flex-col",role:"dialog","aria-label":"Annotate element",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-white/10 bg-gradient-to-r from-purple-500/15 via-violet-500/10 to-transparent",children:[e.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-md bg-purple-500/20 border border-purple-500/30 flex-shrink-0",children:e.jsx(As,{size:13,className:"text-purple-300"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-purple-200 font-bold leading-none",children:"Annotate element"}),e.jsx("div",{className:"text-[13px] font-medium text-gray-100 truncate mt-0.5",children:v})]}),e.jsx("button",{onClick:f,className:"p-1.5 rounded-md text-gray-500 hover:text-gray-200 hover:bg-white/10 transition-colors","aria-label":"Close dialog",children:e.jsx(je,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3.5 bg-surface-1",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx(zs,{size:10,className:"text-purple-400"}),"Selected"]}),e.jsxs("div",{className:"rounded-lg border border-white/10 bg-surface-2/60 p-2.5 space-y-1",children:[e.jsx("div",{className:"text-[12px] text-purple-200 font-medium",children:v}),e.jsx("div",{className:"text-[11px] text-gray-500 font-mono",children:t.tag}),e.jsx(hr,{attrs:t.attrs,platform:a})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx(_s,{size:10,className:"text-purple-400"}),"Hierarchy",e.jsxs("span",{className:"text-gray-600 font-normal normal-case tracking-normal",children:["(",m.length," level",m.length===1?"":"s",")"]})]}),e.jsx("div",{className:"rounded-lg border border-white/10 bg-surface-2/60 p-2.5 font-mono text-[11px] leading-relaxed",children:m.map((h,w)=>{const u=w===m.length-1,b=we(h,a),y=b!==Ie(h.tag);return e.jsxs("div",{style:{paddingLeft:w*12},className:`flex items-baseline gap-1 truncate ${u?"text-purple-200":"text-gray-400"}`,children:[e.jsx("span",{className:"text-gray-600",children:w===0?"":"└─"}),e.jsx("span",{className:u?"font-semibold":"",children:Ie(h.tag)}),y&&e.jsx("span",{className:"text-gray-500 truncate",children:b})]},h.path)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] uppercase tracking-wider text-gray-500 font-semibold mb-1.5",children:[e.jsx("span",{children:"Your note"}),e.jsx("span",{className:"text-gray-600 font-normal normal-case tracking-normal",children:"required"})]}),e.jsx("textarea",{autoFocus:!0,value:l,onChange:h=>d(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)&&(h.preventDefault(),R())},placeholder:"What about this element matters? (intent, edge case, expectation…)",rows:4,className:"w-full bg-surface-0 border border-white/15 rounded-lg px-3 py-2 text-[12px] text-gray-100 placeholder-gray-600 focus:outline-none focus:border-purple-400/60 focus:ring-1 focus:ring-purple-400/20 resize-none leading-relaxed"}),e.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:[e.jsx("kbd",{className:"px-1 py-0.5 rounded bg-white/10 text-gray-300 text-[9px] font-mono",children:"⌘/Ctrl + Enter"}),e.jsx("span",{className:"ml-1",children:"to save"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-2.5 border-t border-white/10 bg-surface-2/50",children:[e.jsx("button",{onClick:f,className:"px-3 py-1.5 rounded-md text-[12px] text-gray-300 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:R,disabled:!l.trim(),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-[12px] font-medium bg-purple-500/20 text-purple-200 border border-purple-500/30 hover:bg-purple-500/30 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Ct,{size:12})," Save annotation"]})]})]})});return wt.createPortal(_,document.body)}function Ie(t){return t.split(".").pop()||t}function hr({attrs:t,platform:i}){const r=(i==="android"?["text","content-desc","resource-id","class"]:["name","label","value","accessibilityIdentifier"]).filter(x=>t[x]);return r.length===0?null:e.jsx("div",{className:"space-y-0.5 mt-1 pt-1.5 border-t border-white/[0.05]",children:r.map(x=>e.jsxs("div",{className:"text-[10px] font-mono flex items-baseline gap-1",children:[e.jsx(Ue,{size:9,className:"text-gray-600 flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"text-gray-500",children:x}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 truncate",children:t[x]})]},x))})}const fr=60;function pr({session:t,onSessionEnded:i}){const[a,r]=s.useState(null),[x,n]=s.useState(!1),[f,c]=s.useState(null),[l,d]=s.useState(null),[p,E]=s.useState(null),[m,v]=s.useState(!1),[T,R]=s.useState(!1),[_,h]=s.useState([]),[w,u]=s.useState(null),[b,y]=s.useState(!1),[A,z]=s.useState(!1),X=s.useRef(!1),F=s.useRef(0),k=s.useRef(!1),L=s.useRef([]),M=s.useRef(null),C=s.useRef(null),H=s.useRef(null),W=s.useRef(!1),Q=s.useRef(null),[O,ke]=s.useState(!1),[U,He]=s.useState(!1),[Y,Ne]=s.useState([]),[J,Ce]=s.useState(null),[G,ce]=s.useState(null),[Z,he]=s.useState(null);s.useEffect(()=>{Ht().then(g=>{g.recording&&(R(!0),z(!0))}).catch(()=>{})},[]),s.useEffect(()=>{const g=N=>{const j=N.detail;j&&(R(j.recording),j.recording&&j.owner&&j.owner!=="mobile-live-view"&&z(!0),j.recording||z(!1))};return window.addEventListener("testver-mobile-recording-changed",g),()=>window.removeEventListener("testver-mobile-recording-changed",g)},[]);const ee=s.useCallback(async()=>{try{const g=await Xt();Ne(g.elements)}catch{}},[]),pe=s.useRef(!1),de=s.useRef(!1);s.useEffect(()=>{const g=()=>{const j=window.__testver_mobile_assert_mode===!0,P=window.__testver_mobile_annotate_mode===!0;ke(j),He(P),(j&&!pe.current||P&&!de.current)&&ee(),pe.current=j,de.current=P},N=setInterval(g,250);return g(),()=>clearInterval(N)},[ee]),s.useEffect(()=>{if(!O&&!U)return;const g=setInterval(()=>void ee(),3e3);return()=>clearInterval(g)},[O,U,ee]),s.useEffect(()=>{const g=()=>{!O&&!U||setTimeout(()=>void ee(),500)};return window.addEventListener("testver-mobile-action",g),()=>window.removeEventListener("testver-mobile-action",g)},[O,U,ee]);const ne=s.useCallback(async()=>{if(X.current)return;X.current=!0;const g=Date.now();try{const N=await Vt({timeoutMs:15e3,since:F.current||void 0});if(N.unchanged){d(null);return}F.current=N.capturedAt||0,r(N.image),c(null),d(null);const j=Date.now(),P=L.current;for(P.push(j);P.length>8;)P.shift();const D=P.length>1?(P[P.length-1]-P[0])/1e3:0,B=P.length>1&&D>0?(P.length-1)/D:0;E({lastMs:j-g,fps:B})}catch(N){const j=N.message;if(Yt(N)){c(null),d(N.status===503&&j?j:"The device is slow to respond — still waiting for a frame…");return}/HTTP 404/i.test(j)?(c("Session ended."),r(null),i()):c(j)}finally{X.current=!1}},[i]);s.useEffect(()=>{if(x)return;let g=!1,N=null;const j=t.providerId==="local-appium"&&t.platform==="android",P=async()=>{if(g)return;const D=typeof document<"u"&&document.visibilityState==="hidden"||X.current||!j&&(k.current||window.__testver_mobile_action_in_flight===!0);D||await ne(),!g&&(N=setTimeout(P,D?150:fr))};return P(),()=>{g=!0,N&&clearTimeout(N)}},[x,ne,t.providerId,t.platform]);const[Se,me]=s.useState(!1),Me=async()=>{v(!0);try{await Qt()}catch{}finally{i()}},$e=s.useCallback(async()=>{y(!0);try{const g=await Gt();R(!0),h(g.actions),u(null),window.dispatchEvent(new CustomEvent("testver-mobile-recording-changed",{detail:{recording:!0,owner:"mobile-live-view"}}))}catch(g){c(`Could not start recording: ${g.message}`)}finally{y(!1)}},[]),Pe=s.useCallback(()=>{R(!1),h([]),Kt().catch(()=>{})},[]),fe=s.useCallback(g=>{R(!1),u(g),h([])},[]),ae=s.useCallback(g=>{try{const j=Math.min(1,800/g.naturalWidth),P=Math.round(g.naturalWidth*j),D=Math.round(g.naturalHeight*j),B=document.createElement("canvas");B.width=P,B.height=D;const K=B.getContext("2d");return K?(K.drawImage(g,0,0,P,D),{dataUrl:B.toDataURL("image/jpeg",.55),width:P,height:D,deviceWidth:g.naturalWidth,deviceHeight:g.naturalHeight}):null}catch{return null}},[]);s.useEffect(()=>(window.__testver_capture_mobile_frame=()=>{const g=M.current;return g?ae(g):null},()=>{try{delete window.__testver_capture_mobile_frame}catch{}}),[ae]);const se=g=>{const N=M.current;if(!N)return null;const j=N.getBoundingClientRect(),P=(g.clientX-j.left)/j.width,D=(g.clientY-j.top)/j.height;return{deviceX:Math.round(P*N.naturalWidth),deviceY:Math.round(D*N.naturalHeight),imgRect:j}},Ae=s.useCallback(g=>{if(!O&&!U||Y.length===0)return;const N=se(g);if(!N)return;const j=ft(Y,N.deviceX,N.deviceY);(j==null?void 0:j.path)!==(J==null?void 0:J.path)&&Ce(j)},[O,U,Y,J]),ze=s.useCallback(()=>{Ce(null)},[]),q=s.useCallback(async()=>{const{getStoredToken:g,getClientId:N}=await dt(async()=>{const{getStoredToken:B,getClientId:K}=await import("./index-DtBWNlVD.js").then(o=>o.iF);return{getStoredToken:B,getClientId:K}},__vite__mapDeps([0,1,2,3,4])),j=g(),P=N(),D={"Content-Type":"application/json"};return j&&(D.Authorization=`Bearer ${j}`),P&&(D["X-Client-Id"]=P),D},[]),te=s.useCallback(()=>{T&&(Q.current&&clearTimeout(Q.current),Q.current=setTimeout(async()=>{try{const g=await q();await fetch("/api/mobile/recording/prime-source",{method:"POST",headers:g})}catch{}},450))},[T,q]);s.useEffect(()=>{T&&te()},[T,te]);const Re=s.useCallback(async(g,N)=>{k.current=!0,y(!0);try{const j=await q(),P=JSON.stringify({fromX:g.x,fromY:g.y,toX:N.x,toY:N.y,durationMs:300}),D=window.__testver_mobile_record_paused===!0,B=T&&!D,o=await fetch(B?"/api/mobile/recording/swipe":"/api/mobile/session/swipe",{method:"POST",headers:j,body:P}),$=await o.json().catch(()=>({}));if(!o.ok)throw new Error(($==null?void 0:$.error)||`HTTP ${o.status}`);B&&$.action&&(A||h(S=>[...S,$.action]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:$.action}})))}catch(j){c(`Swipe failed: ${j.message}`)}finally{y(!1),k.current=!1,await ne(),te()}},[T,A,q,ne,te]),Xe=s.useCallback(g=>{if(O||U)return;const N=se(g);N&&(H.current={deviceX:N.deviceX,deviceY:N.deviceY,clientX:g.clientX,clientY:g.clientY,t:Date.now()})},[O,U]),Ve=s.useCallback(g=>{const N=H.current;if(H.current=null,!N||O||U)return;const j=se(g);if(!j)return;const P=g.clientX-N.clientX,D=g.clientY-N.clientY;Math.hypot(P,D)>=12&&(W.current=!0,Re({x:N.deviceX,y:N.deviceY},{x:j.deviceX,y:j.deviceY}))},[O,U,Re]),Ye=s.useCallback(async g=>{if(W.current){W.current=!1;return}if(!T)return;const N=se(g);if(!N)return;if(window.__testver_mobile_record_paused===!0){k.current=!0,y(!0);try{const D=await q(),B=await fetch("/api/mobile/session/tap",{method:"POST",headers:D,body:JSON.stringify({x:N.deviceX,y:N.deviceY})}),K=await B.json().catch(()=>({}));if(!B.ok)throw new Error((K==null?void 0:K.error)||`HTTP ${B.status}`)}catch(D){c(`Tap failed: ${D.message}`)}finally{y(!1),k.current=!1,ne()}return}if(O||U){const D=Y.length>0?ft(Y,N.deviceX,N.deviceY):null;if(!D){c("No accessibility element at that point. Refreshing tree…"),await ee();return}O&&ce({el:D,x:g.clientX,y:g.clientY}),U&&he({el:D,x:g.clientX,y:g.clientY});return}const j=M.current,P=ae(j);k.current=!0,y(!0);try{const{getStoredToken:D,getClientId:B}=await dt(async()=>{const{getStoredToken:V,getClientId:oe}=await import("./index-DtBWNlVD.js").then(be=>be.iF);return{getStoredToken:V,getClientId:oe}},__vite__mapDeps([0,1,2,3,4])),K=D(),o=B(),$={"Content-Type":"application/json"};K&&($.Authorization=`Bearer ${K}`),o&&($["X-Client-Id"]=o);const S=await fetch("/api/mobile/recording/tap",{method:"POST",headers:$,body:JSON.stringify({x:N.deviceX,y:N.deviceY,screenshot:P==null?void 0:P.dataUrl,screenshotSize:P?{width:P.width,height:P.height}:void 0,deviceSize:P?{width:P.deviceWidth,height:P.deviceHeight}:void 0})}),I=await S.json();if(!S.ok)throw new Error((I==null?void 0:I.error)||`HTTP ${S.status}`);const re=I.action;A||h(V=>[...V,re]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:re}})),(O||U)&&ee()}catch(D){c(`Tap recording failed: ${D.message}`)}finally{y(!1),k.current=!1,ne(),te()}},[T,A,ne,ae,O,U,Y,ee,q]),ie=t.platform==="ios"?"ios":"android",ge=s.useCallback(g=>{const N=M.current;if(!N)return{screenshot:void 0,screenshotSize:void 0,elementRect:void 0};const j=ae(N);if(!j)return{screenshot:void 0,screenshotSize:void 0,elementRect:void 0};const P=j.width/j.deviceWidth,D=j.height/j.deviceHeight;return{screenshot:j.dataUrl,screenshotSize:{width:j.width,height:j.height},elementRect:{x:Math.round(g.bounds.x1*P),y:Math.round(g.bounds.y1*D),width:Math.round((g.bounds.x2-g.bounds.x1)*P),height:Math.round((g.bounds.y2-g.bounds.y1)*D)}}},[ae]),Ge=s.useCallback(async g=>{if(!G)return;const N=pt(G.el,Y,ie);if(N.length===0){c("Could not derive a stable locator for that element."),ce(null);return}k.current=!0;try{const j=ge(G.el),{action:P}=await qt({locator:N[0],ranked:N,elementAttrs:G.el.attrs,elementLabel:g.label,assertType:g.type,expectedValue:g.expectedValue,...j});A||h(D=>[...D,P]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:P}}))}catch(j){c(`Assertion failed: ${j.message}`)}finally{k.current=!1,ce(null)}},[G,Y,ie,A,ge]),Ke=s.useCallback(async(g,N,j)=>{if(!Z)return;const P=pt(Z.el,Y,ie);k.current=!0;try{const D=ge(Z.el),{action:B}=await Jt({text:g,locator:P[0],ranked:P,elementAttrs:Z.el.attrs,elementLabel:j,elementHierarchy:N,...D});A||h(K=>[...K,B]),window.dispatchEvent(new CustomEvent("testver-mobile-action",{detail:{action:B}}))}catch(D){c(`Annotation failed: ${D.message}`)}finally{k.current=!1,he(null)}},[Z,Y,ie,A,ge]),qe=s.useCallback(g=>{h(N=>[...N,g])},[]),Je=x,_e=s.useMemo(()=>a?`data:image/png;base64,${a}`:null,[a]);return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 border-l border-white/[0.05]",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-white/[0.05] bg-surface-1",children:[e.jsx(lt,{size:13,className:"text-indigo-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-200",children:t.device}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"·"}),e.jsx("span",{className:"text-[10px] text-gray-500 uppercase",children:t.platform}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-[10px] text-emerald-300 ml-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-emerald-400 animate-pulse"}),"LIVE"]}),e.jsx("div",{className:"flex-1"}),!A&&!T&&e.jsxs("button",{type:"button",onClick:$e,disabled:b,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-red-300 hover:bg-red-500/10 disabled:opacity-40",title:"Start AI Record — capture taps and types as a runnable test",children:[b?e.jsx(ve,{size:10,className:"animate-spin"}):e.jsx(Ds,{size:10,className:"fill-red-400 text-red-400"}),"Record"]}),T&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] bg-red-500/15 text-red-300",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse"}),"RECORDING"]}),t.liveViewUrl&&e.jsx("a",{href:t.liveViewUrl,target:"_blank",rel:"noreferrer",className:"p-1 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5",title:"Open provider dashboard in a new tab",children:e.jsx(Is,{size:11})}),e.jsx("button",{type:"button",onClick:()=>n(g=>!g),className:"p-1 rounded text-gray-400 hover:text-gray-200 hover:bg-white/5",title:x?"Resume live view":"Pause live view",children:x?e.jsx(rt,{size:11}):e.jsx(Fe,{size:11})}),e.jsx("button",{type:"button",onClick:()=>me(!0),disabled:m,className:"p-1 rounded text-red-300 hover:text-red-200 hover:bg-red-500/10 disabled:opacity-40",title:"End session",children:e.jsx(je,{size:11})}),e.jsx(Gs,{open:Se,title:"End mobile session?",description:(T?"A recording is in progress — ending the session stops it. Steps captured so far remain in the panel, but no further actions can be recorded. ":"")+`This disconnects "${t.device}" and closes the Appium session. `+(t.providerId==="local-appium"?"Starting again boots a fresh session on the device.":"Starting again boots a fresh cloud session, which takes a moment and consumes provider device minutes."),confirmLabel:"End session",cancelLabel:"Keep session",onConfirm:()=>{me(!1),Me()},onCancel:()=>me(!1)})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-1 overflow-hidden min-h-0",children:e.jsxs("div",{ref:C,className:`relative rounded-[18px] border ${T?O?"border-green-500/40":U?"border-purple-500/40":"border-red-500/40 shadow-red-500/10":"border-white/10"} bg-black overflow-hidden shadow-2xl shadow-black/40 inline-flex h-full max-w-full`,children:[_e?e.jsx("img",{ref:M,src:_e,alt:"Mobile device live view",className:`block h-full w-auto max-w-full max-h-full ${T?O||U?"cursor-pointer":"cursor-crosshair":"cursor-default"}`,style:{imageRendering:"auto"},draggable:!1,onClick:Ye,onMouseDown:Xe,onMouseUp:Ve,onMouseMove:Ae,onMouseLeave:ze}):e.jsx("div",{className:"flex flex-col items-center justify-center w-[200px] h-[400px] text-gray-500 text-xs gap-2",children:Je?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{size:20}),e.jsx("span",{children:"Paused"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{size:20,className:"animate-spin"}),e.jsx("span",{className:"text-center px-4",children:l??"Loading first frame…"})]})}),(O||U)&&J&&M.current&&(()=>{const g=M.current,N=g.clientWidth/g.naturalWidth,j=g.clientHeight/g.naturalHeight;return e.jsx("div",{className:`absolute pointer-events-none border-2 rounded-sm ${O?"border-green-400 bg-green-400/15 shadow-[0_0_0_2px_rgba(34,197,94,0.25)]":"border-purple-400 bg-purple-400/15 shadow-[0_0_0_2px_rgba(168,85,247,0.25)]"}`,style:{left:Math.round(J.bounds.x1*N),top:Math.round(J.bounds.y1*j),width:Math.round((J.bounds.x2-J.bounds.x1)*N),height:Math.round((J.bounds.y2-J.bounds.y1)*j)},children:e.jsxs("div",{className:`absolute -top-5 left-0 px-1.5 py-0.5 rounded text-[10px] font-medium whitespace-nowrap ${O?"bg-green-500 text-white":"bg-purple-500 text-white"}`,children:[we(J,ie)," · ",J.tag.split(".").pop()]})})})(),G&&e.jsx(dr,{element:G.el,platform:ie,anchorX:G.x,anchorY:G.y,onSubmit:Ge,onCancel:()=>ce(null)}),Z&&e.jsx(xr,{element:Z.el,allElements:Y,platform:ie,anchorX:Z.x,anchorY:Z.y,onSubmit:Ke,onCancel:()=>he(null)})]})}),e.jsx("div",{className:"px-3 py-1.5 border-t border-white/[0.05] bg-surface-1 text-[10px] flex items-center gap-2",children:f?e.jsx("span",{className:"text-red-400",children:f}):p&&!x?e.jsxs("span",{className:"text-gray-500 tabular-nums",children:[p.fps.toFixed(1)," fps · ",p.lastMs," ms",T&&(window.__testver_mobile_record_paused===!0?" · paused: taps are not recorded":" · click screen to capture tap")]}):e.jsx("span",{className:"text-gray-500",children:x?"Polling paused.":a?"Polling…":l?"Waiting for the device…":"Polling…"})}),T&&!A&&e.jsx(ar,{actions:_,onActionAdded:qe,onStopped:fe,onCancel:Pe}),w&&e.jsx(or,{result:w,onDismiss:()=>u(null)})]})}const mr=32,gr=24,br=60;function Or({children:t}){const i=yt(),[a,r]=s.useState(null),[x,n]=s.useState(mr),[f,c]=s.useState(null),[l,d]=s.useState(null),[p,E]=s.useState(()=>Date.now());s.useEffect(()=>{if(!l)return;const _=setInterval(()=>E(Date.now()),1e3);return()=>clearInterval(_)},[l]);const m=s.useRef(!1),v=s.useRef(null);s.useEffect(()=>{vt().then(()=>Zt()).then(_=>{_.session&&r(_.session)}).catch(()=>{})},[]),s.useEffect(()=>i!=null&&i.subscribe?i.subscribe(h=>{if(h.type==="mobile-session-started"){const w=h.session;w&&r(w);return}if(h.type==="mobile-session-closed"){r(null),c(null),d(null);return}if(h.type==="mobile-session-expiring"){const w=h,u=Math.max(1,Number(w.secondsLeft)||60);E(Date.now()),d({reason:w.reason==="lifetime"?"lifetime":"idle",endsAt:Date.now()+u*1e3});return}if(h.type==="mobile-session-locked"){const w=h;c({runId:String(w.runId||""),ownerLabel:String(w.ownerLabel||"Test run")});return}if(h.type==="mobile-session-unlocked"){c(null);return}}):void 0,[i]);const T=s.useCallback(_=>{_.preventDefault(),m.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);s.useEffect(()=>{const _=w=>{if(!m.current||!v.current)return;const u=v.current.getBoundingClientRect(),y=100-(w.clientX-u.left)/u.width*100;n(Math.min(br,Math.max(gr,y)))},h=()=>{m.current&&(m.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",h),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",h)}},[]);const R=a!==null;return e.jsxs("div",{ref:v,className:"flex h-full overflow-hidden relative",children:[e.jsx("div",{className:"flex-shrink-0 overflow-hidden",style:{width:R?`${100-x}%`:"100%"},children:t}),R&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onMouseDown:T,className:"w-1 flex-shrink-0 cursor-col-resize bg-white/5 hover:bg-indigo-500/40 active:bg-indigo-500/40 transition-colors relative",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsxs("div",{className:"flex-shrink-0 overflow-hidden relative",style:{width:`${x}%`},children:[e.jsx(pr,{session:a,onSessionEnded:()=>r(null)}),l&&e.jsxs("div",{role:"alert",className:"absolute left-2 right-2 top-2 z-40 px-3 py-2 rounded-lg bg-amber-500/20 border border-amber-500/40 text-amber-900 dark:text-amber-100 text-xs backdrop-blur flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-semibold",children:[l.reason==="idle"?"Idle cloud session":"Session time limit"," — closes in ",Math.max(0,Math.ceil((l.endsAt-p)/1e3)),"s"]}),e.jsx("div",{className:"text-[10px] opacity-80 mt-0.5",children:l.reason==="idle"?"Nothing was done on the device for a while, and cloud devices bill by the minute.":"This cloud session has reached its maximum duration. Start a new session to continue."})]}),l.reason==="idle"?e.jsx("button",{type:"button",onClick:()=>{es().catch(()=>{}),d(null)},className:"flex-shrink-0 px-2 py-1 rounded-md bg-amber-500/30 hover:bg-amber-500/40 font-medium",children:"Keep session open"}):e.jsx("button",{type:"button",onClick:()=>d(null),"aria-label":"Dismiss",className:"flex-shrink-0 px-1.5 py-0.5 rounded hover:bg-amber-500/30",children:"×"})]}),f&&e.jsxs("div",{className:"absolute inset-0 z-30 flex flex-col pointer-events-none",children:[e.jsxs("div",{className:"pointer-events-auto mx-2 mt-2 px-3 py-2 rounded-lg bg-amber-500/20 border border-amber-500/40 text-amber-100 text-xs backdrop-blur flex items-start gap-2",children:[e.jsxs("span",{className:"relative flex h-2 w-2 mt-1 flex-shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-amber-400"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-semibold",children:"Test driving this session"}),e.jsxs("div",{className:"text-[10px] opacity-80 mt-0.5",children:[f.ownerLabel," — your taps are paused so they don't conflict with the test's commands. Resumes automatically when the run ends."]})]})]}),e.jsx("div",{className:"flex-1 pointer-events-auto cursor-not-allowed"})]})]})]})]})}function Br({size:t=7,className:i=""}){return e.jsx("span",{role:"status","aria-label":"AI is working",className:`inline-flex items-center gap-[5px] ${i}`,children:[0,1,2].map(a=>e.jsx("span",{style:{width:t,height:t,animationDelay:`${a*.16}s`},className:"block rounded-full bg-[#8A8A8A] dark:bg-[#C8C8C8] ai-thinking-dot shadow-[0_0_4px_rgba(150,150,150,0.45)]"},a))})}function Ur({pending:t,queuedCount:i=0,onAllow:a,onAlwaysAllow:r,onDeny:x}){return e.jsx("div",{className:"rounded-xl border border-amber-500/40 bg-white dark:bg-surface-1 p-4 shadow-2xl",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(St,{size:18,className:"text-amber-500 dark:text-amber-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:t.prompt?"Over to you":"Permission required"}),i>0&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:["+",i," more queued"]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-1",children:t.prompt??e.jsxs(e.Fragment,{children:["AI wants to run ",e.jsx("span",{className:"font-mono text-amber-600 dark:text-amber-300",children:t.toolName})]})}),!t.prompt&&(t.fullPath||t.args)&&e.jsx("div",{className:"w-full text-[11px] text-gray-700 dark:text-gray-300 font-mono break-all max-h-20 overflow-auto mb-2 px-3 py-2 rounded-md bg-gray-100 dark:bg-gray-500/20",title:t.fullPath||t.args,children:t.fullPath||t.args}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx("button",{onClick:x,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-gray-100 hover:bg-gray-200 text-gray-700 border border-gray-300 dark:bg-gray-500/15 dark:text-gray-300 dark:border-gray-500/25 dark:hover:bg-gray-500/25 transition-colors",children:t.prompt?"Skip":"Deny"}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[t.allowRemember!==!1&&e.jsxs("button",{onClick:r,title:`Auto-approve all future ${t.toolName} calls in this session`,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 border border-brand-500/30 dark:bg-brand-500/15 dark:text-brand-300 dark:border-brand-500/25 dark:hover:bg-brand-500/25 transition-colors",children:["Always allow ",t.toolName]}),e.jsx("button",{onClick:a,className:"px-3 py-1.5 rounded-md text-xs font-medium bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-700 border border-emerald-500/40 dark:bg-emerald-500/20 dark:text-emerald-300 dark:border-emerald-500/30 dark:hover:bg-emerald-500/30 transition-colors",children:t.confirmLabel??"Allow"})]})]})]})]})})}const yr=(t,i=80)=>t.length>i?`${t.slice(0,i-1)}…`:t,xe=t=>t.replace(/^(browser|mobile|api)_/,"").replace(/_/g," ");function Te(t,i,a){const r=(i||"").trim(),x=r?yr(r):"",n=(f,c,l)=>({past:x?`${f} ${x}`:`${f} ${l}`,present:x?`${c} ${x}`:`${c} ${l}`});switch(t){case"read_file":return{category:"read",icon:"read",target:r,...n("Read","Reading","a file")};case"list_directory":return{category:"list",icon:"list",target:r,...n("Listed","Listing","a folder")};case"glob_search":return{category:"search",icon:"search",target:r,...n("Searched for","Searching for","files")};case"grep":return{category:"search",icon:"search",target:r,...n("Searched for","Searching for","text")};case"file_exists":return{category:"check",icon:"search",target:r,...n("Checked","Checking","a path")};case"write_file":return(a==null?void 0:a.diffType)==="new"?{category:"create",icon:"create",target:r,...n("Created","Creating","a file")}:a?{category:"edit",icon:"edit",target:r,...n("Edited","Editing","a file")}:{category:"edit",icon:"edit",target:r,...n("Wrote","Writing","a file")};case"edit_file":return{category:"edit",icon:"edit",target:r,...n("Edited","Editing","a file")};case"find_replace":return{category:"replace",icon:"edit",target:r,...n("Replaced text in","Replacing text in","files")};case"delete_file":return{category:"delete",icon:"delete",target:r,...n("Deleted","Deleting","a file")};case"create_directory":return{category:"mkdir",icon:"folder",target:r,...n("Created folder","Creating folder","")};case"run_command":return{category:"command",icon:"command",target:r,...n("Ran","Running","a command")};case"run_tests":return{category:"tests",icon:"tests",target:r,past:x?`Ran tests: ${x}`:"Ran the tests",present:x?`Running tests: ${x}`:"Running the tests"};case"browser_navigate":return{category:"browser",icon:"browser",target:r,...n("Opened","Opening","a page")};case"browser_click":return{category:"browser",icon:"browser",target:r,...n("Clicked","Clicking","an element")};case"browser_type":return{category:"browser",icon:"browser",target:r,...n("Typed into","Typing into","a field")};case"browser_snapshot":return{category:"browser",icon:"browser",target:r,past:"Read the page",present:"Reading the page"};case"browser_screenshot":return{category:"browser",icon:"browser",target:r,past:"Took a screenshot",present:"Taking a screenshot"};case"app_knowledge":return{category:"other",icon:"knowledge",target:r,past:"Looked up app knowledge",present:"Looking up app knowledge"};case"generate_test_code":return{category:"create",icon:"create",target:r,past:"Generated test code",present:"Generating test code"}}return t.startsWith("browser_")?{category:"browser",icon:"browser",target:r,past:`Browser: ${xe(t)}`,present:`Browser: ${xe(t)}`}:t.startsWith("mobile_")?{category:"mobile",icon:"mobile",target:r,past:`App: ${xe(t)}`,present:`App: ${xe(t)}`}:t.startsWith("api_")?{category:"api",icon:"api",target:r,past:`API: ${xe(t)}`,present:`API: ${xe(t)}`}:/report|dashboard|chart|document/.test(t)?{category:"report",icon:"report",target:r,past:`Built ${xe(t).replace(/^(build|generate|save|get) /,"")}`,present:`Building ${xe(t).replace(/^(build|generate|save|get) /,"")}`}:{category:"other",icon:"tool",target:r,past:`Used ${t}`,present:`Using ${t}`}}const wr=t=>t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||t;function vr(t){var f,c,l;const i=[],a=new Map,r=new Map;for(const d of t){const p=d.tool?Te(d.tool.toolName,d.tool.args,d.diff):{category:((f=d.diff)==null?void 0:f.diffType)==="new"?"create":((c=d.diff)==null?void 0:c.diffType)==="deleted"?"delete":"edit",target:(l=d.diff)==null?void 0:l.filePath};a.has(p.category)||i.push(p.category),a.set(p.category,(a.get(p.category)??0)+1),r.set(p.category,p.target||"")}const x=(d,p)=>{const E=r.get(d)?wr(r.get(d)):"",m=(v,T)=>p===1&&E?`${v} ${E}`:`${v} ${p} ${T}${p===1?"":"s"}`;switch(d){case"read":return m("read","file");case"list":return m("listed","folder");case"search":return`searched ${p} pattern${p===1?"":"s"}`;case"check":return`checked ${p} path${p===1?"":"s"}`;case"create":return m("created","file");case"edit":return m("edited","file");case"delete":return m("deleted","file");case"mkdir":return`created ${p} folder${p===1?"":"s"}`;case"replace":return`replaced text ${p===1?"once":`${p} times`}`;case"command":return`ran ${p} command${p===1?"":"s"}`;case"tests":return p===1?"ran the tests":`ran the tests ${p} times`;case"browser":return`took ${p} browser action${p===1?"":"s"}`;case"api":return`made ${p} API call${p===1?"":"s"}`;case"mobile":return`took ${p} app action${p===1?"":"s"}`;case"report":return`built ${p} report${p===1?"":"s"}`;default:return`used ${p} tool${p===1?"":"s"}`}},n=i.map(d=>x(d,a.get(d))).join(", ");return n?n.charAt(0).toUpperCase()+n.slice(1):"Worked"}function jr(t){var f,c;const i=new Map;let a=0,r=0;for(const l of t)l.diff&&!l.diff.netNoChange&&i.set(l.diff.filePath,l.diff),((f=l.tool)==null?void 0:f.phase)==="error"&&a++,((c=l.tool)==null?void 0:c.phase)==="denied"&&r++;let x=0,n=0;for(const l of i.values())x+=l.linesAdded??0,n+=l.linesRemoved??0;return{added:x,removed:n,failed:a,denied:r}}const kr=new Set(["write_file","edit_file","delete_file"]),bt=t=>t.replace(/\\/g,"/").replace(/^\.\//,"").trim();function Nr(t,i){const a=bt(t),r=bt(i);return!a||!r?!1:a===r||a.endsWith(`/${r}`)||r.endsWith(`/${a}`)}function Cr(t){const i=new Map;let a;for(const n of t){if(n.omitted){a={count:((a==null?void 0:a.count)??0)+n.omitted.count,examples:[...(a==null?void 0:a.examples)??[],...n.omitted.examples].slice(0,5)};continue}if(!n.filePath)continue;if(n.netNoChange){i.delete(n.filePath);continue}const f=i.get(n.filePath),c=(f==null?void 0:f.diffType)==="new"&&n.diffType!=="deleted"?"new":n.diffType==="new"||n.diffType==="deleted"?n.diffType:"modified";i.has(n.filePath)&&i.delete(n.filePath),i.set(n.filePath,{filePath:n.filePath,diffType:c,diff:n.diff,linesAdded:n.linesAdded??0,linesRemoved:n.linesRemoved??0,via:n.via,unavailable:n.unavailable})}const r=[];for(const n of t)n.filePath&&!r.includes(n.filePath)&&r.push(n.filePath);const x=r.filter(n=>i.has(n)).map(n=>i.get(n));return a?{files:x,omitted:a}:{files:x}}function Hr(t,i){var d,p;const a=[];let r=null,x=[],n=[],f=0;const c=()=>{r=null},l=E=>{if(c(),E&&n.length){const{files:m,omitted:v}=Cr(n);(m.length||v)&&a.push({kind:"changes",id:`changes-${f}`,files:m,...v?{omitted:v}:{}})}n=[],x=[],f++};for(const E of t){if(i.isTurnStart(E)){l(!0),a.push({kind:"entry",entry:E});continue}if((d=i.isInvisible)!=null&&d.call(i,E))continue;const m=i.toolOf(E);if(m&&!((p=i.isStandalone)!=null&&p.call(i,E))){r||(r={kind:"group",id:`group-${E.id}`,steps:[],running:!1},x.push(r),a.push(r)),r.steps.push({tool:m});continue}const v=i.diffOf(E);if(v){if(n.push(v),v.via==="detected"||v.omitted||v.netNoChange)continue;let T;for(let R=x.length-1;R>=0&&!T;R--){const _=x[R].steps;for(let h=_.length-1;h>=0;h--){const w=_[h];if(w.tool&&!w.diff&&kr.has(w.tool.toolName)&&Nr(w.tool.args,v.filePath)){T=w;break}}}T?T.diff=v:r?r.steps.push({diff:v}):(r={kind:"group",id:`group-${E.id}`,steps:[{diff:v}],running:!1},x.push(r),a.push(r));continue}c(),a.push({kind:"entry",entry:E})}if(l(!i.streaming),i.streaming)for(let E=a.length-1;E>=0;E--){const m=a[E];if(m.kind==="group"){m.running=m.steps.some(v=>{var T;return((T=v.tool)==null?void 0:T.phase)==="start"});break}}return a}const Sr={read:Xs,list:Hs,search:Us,create:Tt,edit:Et,delete:Rt,folder:Bs,command:st,tests:Os,browser:kt,api:Nt,mobile:lt,report:Ws,knowledge:Fs,tool:Ls},Rr=t=>{const i=Math.max(0,Math.round(t/1e3));return i<60?`${i} s`:`${Math.floor(i/60)}m ${String(i%60).padStart(2,"0")}s`};function zt({added:t,removed:i}){return!t&&!i?null:e.jsxs("span",{className:"flex items-center gap-1 text-[12px] font-mono tabular-nums flex-shrink-0",children:[e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",t]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["−",i]})]})}function Er({step:t,detail:i}){if(t.diff)return t.diff.unavailable||!t.diff.diff?e.jsx("div",{className:"ml-9 mr-4 mt-1 mb-1.5 rounded-lg border border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-black/20 px-3 py-2 text-[13px] text-gray-500",children:t.diff.unavailable==="binary"?"Binary file — no text diff to show.":t.diff.unavailable==="large"?"Too large to show here.":"No line changes."}):e.jsx("div",{className:"ml-9 mr-4 mt-1 mb-1.5 rounded-lg max-h-[360px] overflow-auto border border-gray-200 dark:border-white/5 bg-gray-50 dark:bg-black/30",children:e.jsx(Pt,{diff:t.diff.diff})});if(!t.tool)return null;if(i)return e.jsx(e.Fragment,{children:i(t.tool)});const a=t.tool;return e.jsxs("div",{className:"ml-9 mr-4 mt-1 mb-1.5 max-h-[240px] overflow-auto rounded-lg bg-gray-50 dark:bg-black/30 border border-gray-200 dark:border-white/5 p-2.5",children:[a.args&&e.jsx("div",{className:"text-[12px] font-mono text-gray-500 mb-1 break-all",children:a.args}),a.result&&e.jsx("div",{className:"text-[12px] font-mono text-gray-600 dark:text-gray-400 break-all whitespace-pre-wrap",children:a.result.slice(0,2e3)}),a.error&&e.jsx("div",{className:"text-[12px] font-mono text-red-500 dark:text-red-400 break-all",children:a.error})]})}function Tr({step:t,running:i,detail:a}){var m,v,T,R,_;const[r,x]=s.useState(!1),n=t.tool,f=n?Te(n.toolName,n.args,t.diff):{icon:((m=t.diff)==null?void 0:m.diffType)==="new"?"create":((v=t.diff)==null?void 0:v.diffType)==="deleted"?"delete":"edit",past:`${((T=t.diff)==null?void 0:T.diffType)==="new"?"Created":((R=t.diff)==null?void 0:R.diffType)==="deleted"?"Deleted":"Changed"} ${((_=t.diff)==null?void 0:_.filePath)??""}`,present:""},c=Sr[f.icon],l=(n==null?void 0:n.phase)==="start",d=l&&i?f.present:f.past,p=!!(t.diff||n!=null&&n.args||n!=null&&n.result||n!=null&&n.error),E=n?n.phase==="start"?i?e.jsx(ve,{size:14,className:"text-blue-500 dark:text-blue-400 animate-spin flex-shrink-0"}):e.jsx(Vs,{size:14,className:"text-gray-400 flex-shrink-0","aria-label":"Stopped"}):n.phase==="complete"?e.jsx(nt,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"}):n.phase==="error"?e.jsx(jt,{size:14,className:"text-red-500 dark:text-red-400 flex-shrink-0"}):e.jsx(St,{size:14,className:"text-amber-500 dark:text-amber-400 flex-shrink-0"}):e.jsx(nt,{size:14,className:"text-emerald-500 dark:text-emerald-400 flex-shrink-0"});return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>p&&!l&&x(h=>!h),className:`flex w-full max-w-full items-center gap-2 pl-9 pr-4 py-1 text-left rounded-md transition-colors ${p&&!l?"hover:bg-gray-100/70 dark:hover:bg-white/[0.03] cursor-pointer":"cursor-default"}`,children:[E,e.jsx(c,{size:14,className:"text-gray-400 dark:text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 truncate min-w-0",title:d,children:d}),t.diff&&!t.diff.unavailable&&e.jsx(zt,{added:t.diff.linesAdded??0,removed:t.diff.linesRemoved??0}),(n==null?void 0:n.phase)==="error"&&n.error&&e.jsx("span",{className:"text-[13px] text-red-500 dark:text-red-400 truncate max-w-[320px]",title:n.error,children:n.error}),(n==null?void 0:n.phase)==="denied"&&e.jsx("span",{className:"text-[13px] text-amber-600 dark:text-amber-400 flex-shrink-0",children:"not allowed"}),p&&!l&&(r?e.jsx(Be,{size:13,className:"text-gray-400 flex-shrink-0"}):e.jsx(Ue,{size:13,className:"text-gray-400 flex-shrink-0"}))]}),r&&e.jsx(Er,{step:t,detail:a})]})}function Xr({group:t,detail:i,className:a=""}){var h,w,u;const[r,x]=s.useState(!1),[n,f]=s.useState(()=>Date.now()),{running:c,steps:l}=t;s.useEffect(()=>{if(!c)return;const b=setInterval(()=>f(Date.now()),1e3);return()=>clearInterval(b)},[c]);const d=jr(l),p=(w=(h=l.find(b=>{var y;return(y=b.tool)==null?void 0:y.startedAt}))==null?void 0:h.tool)==null?void 0:w.startedAt,E=l.reduce((b,y)=>{var A;return(A=y.tool)!=null&&A.endedAt&&(!b||y.tool.endedAt>b)?y.tool.endedAt:b},void 0),m=p?(c?n:E??p)-p:void 0,v=l.filter(b=>!b.tool||b.tool.phase!=="start").length,T=(u=[...l].reverse().find(b=>{var y;return((y=b.tool)==null?void 0:y.phase)==="start"}))==null?void 0:u.tool,R=l.length===1?l[0]:null,_=R!=null&&R.tool?Te(R.tool.toolName,R.tool.args,R.diff).past:R!=null&&R.diff?`${R.diff.diffType==="new"?"Created":R.diff.diffType==="deleted"?"Deleted":"Changed"} ${R.diff.filePath}`:vr(l);return e.jsxs("div",{className:a,children:[e.jsxs("button",{type:"button",onClick:()=>x(b=>!b),"aria-expanded":r,className:"flex max-w-full items-center gap-2 px-4 py-1 rounded-lg text-left transition-colors hover:bg-gray-100/70 dark:hover:bg-white/[0.03]",children:[c?e.jsx(ve,{size:14,className:"text-blue-500 dark:text-blue-400 animate-spin flex-shrink-0"}):r?e.jsx(Be,{size:14,className:"text-gray-400 flex-shrink-0"}):e.jsx(Ue,{size:14,className:"text-gray-400 flex-shrink-0"}),c&&T?e.jsx("span",{className:"text-sm text-blue-600 dark:text-blue-300 truncate min-w-0",title:Te(T.toolName,T.args).present,children:Te(T.toolName,T.args).present}):e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 truncate min-w-0",title:_,children:_}),e.jsx(zt,{added:d.added,removed:d.removed}),d.failed>0&&e.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/20 flex-shrink-0",children:[d.failed," failed"]}),d.denied>0&&e.jsxs("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full bg-amber-500/10 text-amber-600 dark:text-amber-400 border border-amber-500/20 flex-shrink-0",children:[d.denied," not allowed"]}),(c||l.length>1||m!==void 0&&m>=1e3)&&e.jsxs("span",{className:"text-[13px] text-gray-400 dark:text-gray-500 flex-shrink-0 tabular-nums",children:[c?`· ${v} done`:l.length>1?`· ${l.length} steps`:"",m!==void 0&&m>=1e3?` · ${Rr(m)}`:""]})]}),r&&e.jsx("div",{className:"mt-0.5 mb-1 space-y-0.5",children:l.map((b,y)=>{var A,z;return e.jsx(Tr,{step:b,running:c,detail:i},((A=b.tool)==null?void 0:A.id)??((z=b.diff)==null?void 0:z.id)??y)})})]})}const Le=6,_t=t=>t.reduce((i,a)=>({added:i.added+a.linesAdded,removed:i.removed+a.linesRemoved}),{added:0,removed:0});function it({type:t,size:i=13}){return t==="new"?e.jsx(Tt,{size:i,className:"text-emerald-500 flex-shrink-0"}):t==="deleted"?e.jsx(Rt,{size:i,className:"text-red-500 flex-shrink-0"}):e.jsx(Et,{size:i,className:"text-amber-500 flex-shrink-0"})}function Dt({file:t}){return e.jsxs(e.Fragment,{children:[t.diffType!=="modified"&&e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded-full border flex-shrink-0 ${t.diffType==="new"?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-red-500/10 text-red-600 dark:text-red-400 border-red-500/20"}`,children:t.diffType==="new"?"New":"Deleted"}),t.via==="detected"&&e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded-full border border-gray-300 dark:border-white/10 text-gray-500 flex-shrink-0",title:"Changed by a command or a bulk replace the AI ran — found by comparing git status before and after",children:"by a command"})]})}function It({path:t,strong:i=!0}){const a=t.lastIndexOf("/"),r=a>=0?t.slice(0,a+1):"",x=a>=0?t.slice(a+1):t;return e.jsxs("span",{className:"font-mono text-[13px] truncate min-w-0",title:t,children:[r&&e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:r}),e.jsx("span",{className:i?"text-gray-800 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300",children:x})]})}function Oe({added:t,removed:i}){return e.jsxs("span",{className:"flex items-center gap-1 text-[12px] font-mono tabular-nums flex-shrink-0",children:[e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["+",t]}),e.jsxs("span",{className:"text-red-600 dark:text-red-400",children:["−",i]})]})}function Mr({files:t,omitted:i,initialPath:a,onClose:r,onOpenGit:x}){const[n,f]=s.useState(()=>Math.max(0,t.findIndex(d=>d.filePath===a))),c=_t(t),l=t[n];return s.useEffect(()=>{const d=p=>{p.key==="ArrowDown"?(f(E=>Math.min(t.length-1,E+1)),p.preventDefault()):p.key==="ArrowUp"&&(f(E=>Math.max(0,E-1)),p.preventDefault())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t.length]),e.jsx(Ks,{title:"Review changes",subtitle:`${t.length} file${t.length===1?"":"s"} · +${c.added} −${c.removed}`,icon:e.jsx("span",{className:"rounded-md bg-brand-500/15 p-1.5 text-brand-500 dark:text-brand-300",children:e.jsx(Mt,{size:14})}),onClose:r,toolbar:x&&e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",title:"Stage and commit these changes on the Git screen",children:[e.jsx($t,{size:14})," Open in Git"]}),footer:e.jsx(e.Fragment,{children:"↑ ↓ move between files · Esc closes"}),children:e.jsxs("div",{className:"absolute inset-0 flex",children:[e.jsxs("div",{className:"w-72 flex-shrink-0 overflow-y-auto border-r border-gray-200 dark:border-white/5 py-1.5",role:"listbox","aria-label":"Changed files",children:[t.map((d,p)=>e.jsxs("button",{role:"option","aria-selected":p===n,onClick:()=>f(p),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left transition-colors ${p===n?"bg-brand-500/10 dark:bg-brand-500/15":"hover:bg-gray-100 dark:hover:bg-white/[0.04]"}`,children:[e.jsx(it,{type:d.diffType,size:12}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[13px] text-gray-700 dark:text-gray-300",title:d.filePath,children:d.filePath.split("/").pop()}),!d.unavailable&&e.jsx(Oe,{added:d.linesAdded,removed:d.linesRemoved})]},d.filePath)),i&&i.count>0&&e.jsxs("p",{className:"px-3 py-2 text-[12px] text-gray-500",children:["…and ",i.count," more file",i.count===1?"":"s"," changed by commands, not listed."]})]}),e.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200 dark:border-white/5 px-4 py-2",children:[e.jsx(it,{type:l.diffType}),e.jsx(It,{path:l.filePath}),e.jsx(Dt,{file:l}),!l.unavailable&&e.jsx(Oe,{added:l.linesAdded,removed:l.linesRemoved})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-gray-50 dark:bg-black/20",children:l.unavailable||!l.diff?e.jsx("p",{className:"p-6 text-sm text-gray-500",children:l.unavailable==="binary"?"Binary file — there is no text diff to show.":l.unavailable==="large"?"This file is too large to show a diff here. Open it on the Git screen.":"No line changes."}):e.jsx(Pt,{diff:l.diff,className:"py-1"})})]}):e.jsx("p",{className:"p-6 text-sm text-gray-500",children:"No files."})})]})})}function Vr({item:t}){const i=Lt(),a=ts(),[r,x]=s.useState(!1),[n,f]=s.useState(null),{files:c,omitted:l}=t,d=s.useMemo(()=>_t(c),[c]),p=r?c:c.slice(0,Le),E=c.length+((l==null?void 0:l.count)??0),m=()=>{f(null),i("/git")};return e.jsxs("div",{className:"mx-4 my-2 max-w-3xl rounded-xl border border-gray-200 dark:border-white/10 bg-gray-50/70 dark:bg-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3.5 py-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-white dark:bg-white/[0.06] border border-gray-200 dark:border-white/10 flex-shrink-0",children:e.jsx(Mt,{size:16,className:"text-gray-600 dark:text-gray-300"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:["Changed ",E," file",E===1?"":"s"]}),e.jsx(Oe,{added:d.added,removed:d.removed})]}),a&&e.jsxs("button",{onClick:m,className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[13px] font-medium text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",title:"Stage and commit these changes on the Git screen",children:[e.jsx($t,{size:14})," Open in Git"]}),c.length>0&&e.jsxs("button",{onClick:()=>f({}),className:"flex items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 py-1.5 text-[13px] font-semibold text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-white/10 transition-colors",children:[e.jsx(ot,{size:14})," Review"]})]}),c.length>0&&e.jsxs("div",{className:"border-t border-gray-200 dark:border-white/5 py-1",children:[p.map(v=>e.jsxs("button",{onClick:()=>f({path:v.filePath}),className:"flex w-full items-center gap-2 px-3.5 py-1.5 text-left transition-colors hover:bg-gray-100/80 dark:hover:bg-white/[0.04]",title:"Review this file",children:[e.jsx(it,{type:v.diffType,size:14}),e.jsx(It,{path:v.filePath,strong:!1}),e.jsx(Dt,{file:v}),e.jsx("span",{className:"ml-auto flex items-center gap-2",children:v.unavailable?e.jsx("span",{className:"text-[12px] text-gray-400",children:v.unavailable==="binary"?"binary":"too large"}):e.jsx(Oe,{added:v.linesAdded,removed:v.linesRemoved})})]},v.filePath)),c.length>Le&&e.jsxs("button",{onClick:()=>x(v=>!v),className:"flex items-center gap-1 px-3.5 py-1 text-[13px] font-medium text-brand-500 dark:text-brand-300 hover:underline",children:[e.jsx(Be,{size:11,className:r?"rotate-180":""}),r?"Show fewer":`Show ${c.length-Le} more file${c.length-Le===1?"":"s"}`]})]}),l&&l.count>0&&e.jsxs("p",{className:"border-t border-gray-200 dark:border-white/5 px-3.5 py-1.5 text-[13px] text-gray-500",children:[c.length>0?"…and ":"",l.count," ",c.length>0?"more ":"","file",l.count===1?"":"s"," changed by commands",l.examples.length>0&&e.jsxs(e.Fragment,{children:[" (for example ",e.jsx("span",{className:"font-mono",children:l.examples.slice(0,2).join(", ")}),")"]}),a?e.jsxs(e.Fragment,{children:[" ","— see the Git screen for all of them."]}):"."]}),n&&e.jsx(Mr,{files:c,omitted:l,initialPath:n.path,onClose:()=>f(null),onOpenGit:a?m:void 0})]})}export{Br as A,Vr as C,Wr as L,Ur as P,Xr as T,Or as a,Hr as b,Fr as f};
@@ -1 +0,0 @@
1
- import{j as e,u as f,b as T,r as p,L as w,n as R}from"./vendor-react-CTbHBddL.js";import{u as $}from"./useTestExplorer-HqvURJAc.js";import{T as A,k as S,a2 as y,O as F,at as D,au as I,X as L,o as M,av as z,J as E,a0 as P,aw as O,a3 as _,ax as B,r as V,ay as K,S as q}from"./vendor-icons-B0wLOBoh.js";import{u as U,L as g}from"./useTestLifecycle-CL7-zz0Q.js";import{u as W,a as X,b as H,c as Y,d as G}from"./useTestResults-Bm-JyMhB.js";import{u as J}from"./useChartTheme-BFz2QcND.js";import{R as Q,C as Z,h as ee,X as te,Y as k,T as se,A as N,L as ae}from"./vendor-charts-DWFQlmCz.js";import{f as b}from"./formatTestName-BKd2Uqhs.js";import{u as re}from"./useSuites-CvtMGakZ.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import"./vendor-query-BrzmPFT3.js";import"./index-DtBWNlVD.js";function ne(){const{data:a,isLoading:s}=$(),l=(a==null?void 0:a.suites)??[],r=(a==null?void 0:a.totalTests)??0;let i=0,o=0,c=0,t=0;for(const n of l)for(const m of n.tests){const x=m.lastStatus;x==="passed"?i++:x==="failed"||x==="error"?o++:x==="skipped"?c++:t++}if(s&&r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"—"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Scanning project…"})]},n))});if(r===0)return e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:["Total Tests","Passing","Failing","No Run"].map(n=>e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:n}),e.jsx("p",{className:"text-3xl font-bold text-gray-600",children:"0"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"No tests detected"})]},n))});const d=r>0?Math.round(i/r*100):0,h=r>0?Math.round(o/r*100):0,u=r>0?Math.round(t/r*100):0;return e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Total Tests"}),e.jsx(A,{size:16,className:"text-orange-400"})]}),e.jsx("p",{className:"text-3xl font-bold text-gray-100",children:r}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:t})," never run",c>0&&e.jsxs(e.Fragment,{children:[", ",e.jsx("span",{className:"text-gray-400",children:c})," skipped"]})]}):c>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400",children:c})," skipped"]}):"All tests have executed"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Passing"}),e.jsx(S,{size:16,className:i>0?"text-emerald-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${i>0?"text-emerald-400":"text-gray-100"}`,children:i}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[d,"% of catalog"]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"Failing"}),o>0?e.jsx(y,{size:16,className:"text-red-400"}):e.jsx(F,{size:16,className:"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${o>0?"text-red-400":"text-gray-100"}`,children:o}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:o>0?`${h}% of catalog`:"No failing tests"})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 min-h-[110px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-gray-500",children:"No Run"}),e.jsx(D,{size:16,className:t>0?"text-amber-400":"text-gray-600"})]}),e.jsx("p",{className:`text-3xl font-bold ${t>0?"text-amber-400":"text-gray-100"}`,children:t}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:t>0?`${u}% of catalog`:"All tests have run"})]})]})}const C=["active","in_review","draft","deprecated"],ie={active:"#10b981",in_review:"#f59e0b",draft:"#3b82f6",deprecated:"#f43f5e"};function ce(){const a=f(),{data:s}=$(),l=U(),r=(s==null?void 0:s.suites)??[],i={draft:0,active:0,in_review:0,deprecated:0};let o=0;for(const t of r)for(const d of t.tests)i[l.statusOf(t.file,d.name)]++,o++;const c=t=>o>0?Math.round(t/o*100):0;return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex h-8 w-8 items-center justify-center rounded-lg bg-brand-500/10 text-brand-400",children:e.jsx(I,{size:16})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-100",children:"Test Status"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Authoring status across ",o," test",o===1?"":"s"]})]})]}),e.jsx("button",{onClick:()=>a("/tests"),className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"View in Test Explorer →"})]}),e.jsx("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-black/5 dark:bg-white/5 mb-5",children:o===0?null:C.map(t=>i[t]>0?e.jsx("div",{className:"h-full transition-all",style:{width:`${c(i[t])}%`,backgroundColor:ie[t]},title:`${g[t].label}: ${i[t]} (${c(i[t])}%)`},t):null)}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:C.map(t=>{const d=g[t].cls.split(" ").filter(h=>h.startsWith("text-")).join(" ");return e.jsxs("button",{onClick:()=>a(`/tests?lifecycle=${t}`),className:"group text-left rounded-lg border border-white/5 bg-surface-2/40 hover:bg-surface-2 hover:border-white/10 px-3.5 py-3 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${g[t].dot}`}),e.jsx("span",{className:`text-xs font-medium ${d}`,children:g[t].label})]}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-2xl font-bold text-gray-100",children:i[t]}),e.jsxs("span",{className:"text-xs text-gray-500",children:[c(i[t]),"%"]})]})]},t)})})]})}function oe(){const{data:a}=W(20),s=J(),l=(a==null?void 0:a.trends)||[];if(l.length===0)return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"h-52 flex items-center justify-center text-gray-600 text-sm",children:"No test runs yet. Run tests to see trends."})]});const r=l.map((i,o)=>({run:`#${o+1}`,passed:i.passed,failed:i.failed,skipped:i.skipped,passRate:i.passRate}));return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 flex flex-col",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200 mb-4",children:"Execution Trend"}),e.jsx("div",{className:"flex-1 min-h-[13rem]",children:e.jsx(Q,{width:"100%",height:"100%",children:e.jsxs(Z,{data:r,children:[e.jsx(ee,{strokeDasharray:"3 3",stroke:s.gridStroke}),e.jsx(te,{dataKey:"run",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"left",tick:{fontSize:11,fill:s.axisFill}}),e.jsx(k,{yAxisId:"right",orientation:"right",domain:[0,100],tick:{fontSize:11,fill:s.axisFill}}),e.jsx(se,{contentStyle:{background:s.tooltipBackground,border:s.tooltipBorder,borderRadius:8,fontSize:13},labelStyle:{color:s.tooltipLabelColor}}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"passed",stackId:"1",fill:"#22c55e",fillOpacity:.3,stroke:"#22c55e"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"failed",stackId:"1",fill:"#ef4444",fillOpacity:.3,stroke:"#ef4444"}),e.jsx(N,{yAxisId:"left",type:"monotone",dataKey:"skipped",stackId:"1",fill:"#64748b",fillOpacity:.2,stroke:"#64748b"}),e.jsx(ae,{yAxisId:"right",type:"monotone",dataKey:"passRate",stroke:"#a78bfa",strokeWidth:2,dot:!1})]})})})]})}function v({title:a,count:s,onClose:l,children:r}){return T.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:l}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 w-[640px] max-w-[92vw] max-h-[80vh] flex flex-col shadow-2xl",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-200",children:[a,typeof s=="number"&&e.jsxs("span",{className:"text-gray-500 font-normal",children:[" (",s,")"]})]}),e.jsx("button",{onClick:l,className:"text-gray-500 hover:text-gray-300 transition-colors","aria-label":"Close",children:e.jsx(L,{size:18})})]}),e.jsx("div",{className:"p-3 overflow-y-auto space-y-1",children:r})]})]}),document.body)}function de(){const{data:a}=X(50),s=(a==null?void 0:a.topFailures)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:t.lastError||t.testName,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(y,{size:16,className:"text-red-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.lastError||"No error details"})]}),e.jsxs("span",{className:"text-xs font-medium text-red-400 flex-shrink-0",children:[t.failureCount,"x"]})]},d);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Top Failures"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No failures recorded yet."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Top Failures",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function xe(){const{data:a}=H(),s=(a==null?void 0:a.flaky)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.testName),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>{var h;return e.jsxs("button",{onClick:()=>o(t),title:`Open ${t.testName} in Results`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(M,{size:16,className:"text-amber-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.testName)}),e.jsx("div",{className:"flex items-center gap-1 mt-1",children:(h=t.recentStatuses)==null?void 0:h.slice(0,10).map((u,n)=>e.jsx("span",{title:u,className:`w-2.5 h-2.5 rounded-full ${u==="passed"?"bg-emerald-400":u==="failed"?"bg-red-400":"bg-gray-600"}`},n))})]}),e.jsxs("span",{className:"text-xs font-medium text-amber-400 flex-shrink-0",children:[Math.round(t.flakinessRate*100),"%"]})]},d)};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Flaky Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No flaky tests detected."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Flaky Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function j(a){if(!a||a<0)return"—";if(a<1e3)return`${Math.round(a)}ms`;const s=a/1e3;return s<60?`${s.toFixed(s<10?1:0)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`}function me(a){if(!a)return"";const s=a.replace(/\\/g,"/");return s.slice(s.lastIndexOf("/")+1)}function he(){const{data:a}=Y(50),s=(a==null?void 0:a.slowest)||[],l=f(),[r,i]=p.useState(!1),o=t=>{if(t.file){const d=new URLSearchParams;d.set("file",t.file.replace(/\\/g,"/")),d.set("test",t.name),l(`/tests?${d.toString()}`)}else l("/tests")},c=(t,d)=>e.jsxs("button",{onClick:()=>o(t),title:`${t.name}${t.file?` — ${t.file}`:""} · avg ${j(t.avgDuration)}, max ${j(t.maxDuration)}`,className:"w-full flex items-start gap-2.5 p-2.5 rounded-lg hover:bg-surface-2 transition-colors text-left",children:[e.jsx(z,{size:16,className:"text-sky-400 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200 truncate",children:b(t.name)}),e.jsx("p",{className:"text-xs text-gray-500 truncate",children:t.file?me(t.file):`max ${j(t.maxDuration)}`})]}),e.jsx("span",{className:"text-xs font-medium text-sky-400 flex-shrink-0 tabular-nums",children:j(t.avgDuration)})]},d);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Slowest Tests"}),s.length>5&&e.jsx("button",{onClick:()=>i(!0),className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No timing data yet. Run tests to see the slowest."}):e.jsx("div",{className:"space-y-2",children:s.slice(0,5).map(c)}),r&&e.jsx(v,{title:"Slowest Tests",count:s.length,onClose:()=>i(!1),children:s.map(c)})]})}function ue(a){if(!a)return"";const s=Date.now()-a,l=Math.floor(s/6e4);if(l<1)return"just now";if(l<60)return`${l}m ago`;const r=Math.floor(l/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);return i<7?`${i}d ago`:new Date(a).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function fe(a){return a>=90?{fill:"bg-emerald-500",text:"text-emerald-400"}:a>=50?{fill:"bg-amber-500",text:"text-amber-400"}:{fill:"bg-red-500",text:"text-red-400"}}const pe="bg-surface-1 rounded-xl border border-white/5 p-5",ge=5;function je(){const{data:a,isLoading:s}=re(),l=(a==null?void 0:a.suites)??[],[r,i]=p.useState(!1);p.useEffect(()=>{if(!s&&l.length>0){const n=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(n)}},[s,l.length]);const o=n=>{var m;return((m=n.lastRun)==null?void 0:m.status)==="completed"?n.lastRun:(n.history||[]).find(x=>x.status==="completed")},c=n=>{var m,x;return(((x=(m=o(n))==null?void 0:m.summary)==null?void 0:x.total)??0)>0},t=l.filter(c).map(n=>{const m=o(n),x=m.summary;return{id:n.id,name:n.name,run:!0,rate:x.total?Math.round(x.passed/x.total*100):0,passed:x.passed??0,failed:x.failed??0,total:x.total??0,finishedAt:m.finishedAt}}).sort((n,m)=>n.rate-m.rate),d=l.filter(n=>!c(n)).map(n=>({id:n.id,name:n.name,run:!1})),h=[...t,...d].slice(0,ge),u=l.length;return e.jsxs("div",{className:pe,children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Pass rate by suite"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Latest run · lowest first"})]}),u>0&&e.jsx(w,{to:"/tests?view=suites",className:"text-xs text-brand-400 hover:text-brand-300 whitespace-nowrap",children:"View all →"})]}),s?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500",children:"Loading suites…"}):u===0?e.jsx("div",{className:"h-44 flex items-center justify-center text-sm text-gray-500 text-center px-4",children:"No suites yet. Create suites in Test Explorer to track their pass rates here."}):e.jsx("div",{className:"space-y-1",children:h.map(n=>{const m=n.run?fe(n.rate):null;return e.jsxs(w,{to:`/tests?view=suites&suite=${n.id}`,className:"grid grid-cols-[minmax(0,150px)_1fr_84px] items-center gap-3 py-1.5 px-1 -mx-1 rounded-lg hover:bg-white/5 transition-colors",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:`text-[13px] font-medium truncate ${n.run?"text-gray-200":"text-gray-400"}`,title:n.name,children:b(n.name)}),e.jsx("div",{className:"text-[11px] text-gray-500 truncate",children:n.run?`${ue(n.finishedAt)} · ${n.total} tests`:"Never run"})]}),e.jsx("div",{className:"h-2 rounded-full bg-surface-2 overflow-hidden",children:n.run&&e.jsx("div",{className:`h-full rounded-full ${m.fill} transition-[width] duration-700 ease-out`,style:{width:r?`${n.rate}%`:"0%"}})}),e.jsx("div",{className:"text-right",children:n.run?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`text-[15px] font-semibold ${m.text}`,children:[n.rate,"%"]}),e.jsxs("div",{className:"text-[11px] text-gray-500 tabular-nums",children:[n.passed," / ",n.failed]})]}):e.jsx("div",{className:"text-[11px] text-gray-500",children:"Not run yet"})})]},n.id)})})]})}function be(a){const s=Date.now()-new Date(a).getTime();if(!Number.isFinite(s)||s<0)return"just now";const l=Math.floor(s/1e3);if(l<60)return`${l}s ago`;const r=Math.floor(l/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Ne(a){if(!a)return"—";const s=Math.round(a/1e3);if(s<60)return`${s}s`;const l=Math.floor(s/60),r=s%60;return r===0?`${l}m`:`${l}m ${r}s`}function ye(a){return a.status==="running"?{Icon:_,tint:"text-sky-400",bg:"bg-sky-500/15",label:"Running",spin:!0}:a.status==="cancelled"?{Icon:B,tint:"text-gray-400",bg:"bg-gray-500/15",label:"Cancelled",spin:!1}:a.status==="completed"&&(a.exitCode??0)===0?{Icon:V,tint:"text-emerald-400",bg:"bg-emerald-500/15",label:"Passed",spin:!1}:{Icon:y,tint:"text-red-400",bg:"bg-red-500/15",label:"Failed",spin:!1}}function ve({runs:a}){const s=f(),l=a.slice(0,5);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Recent Executions"}),e.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["Last ",l.length," test executions with per-run breakdown"]})]}),e.jsx("button",{onClick:()=>s("/results"),className:"text-xs text-brand-400 hover:text-brand-300 transition-colors",children:"View all →"})]}),l.length===0?e.jsx("div",{className:"h-40 flex items-center justify-center text-sm text-gray-500",children:"No runs yet. Execute tests to see history."}):e.jsx("div",{className:"overflow-x-auto -mx-2",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium px-2 py-2",children:"Run"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Passed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Failed"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"Skipped"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Total"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Pass Rate"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Duration"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden sm:table-cell",children:"When"}),e.jsx("th",{className:"text-right font-medium px-2 py-2 hidden lg:table-cell",children:"Source"}),e.jsx("th",{className:"text-right font-medium px-2 py-2",children:"Status"})]})}),e.jsx("tbody",{children:l.map(r=>{const i=ye(r),o=i.Icon,c=r.summary,t=c?c.passRate>=90?"text-emerald-400":c.passRate>=70?"text-amber-400":"text-red-400":"text-gray-500";return e.jsxs("tr",{onClick:()=>s(`/results?runId=${encodeURIComponent(r.runId)}`),className:"border-b border-white/5 hover:bg-surface-2 cursor-pointer transition-colors",children:[e.jsx("td",{className:"px-2 py-2.5 min-w-0 max-w-xs",children:r.label?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-gray-200 truncate",title:r.label,children:r.label}),e.jsx("p",{className:"text-[11px] text-gray-500 truncate font-mono",title:r.command,children:r.command})]}):e.jsx("p",{className:"text-gray-200 truncate font-mono text-xs",title:r.command,children:r.command})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-emerald-400 font-medium",children:c.passed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:c.failed>0?"text-red-400 font-medium":"text-gray-500",children:c.failed}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden sm:table-cell",children:c?e.jsx("span",{className:"text-gray-500",children:c.skipped}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums",children:c?e.jsx("span",{className:"text-gray-300",children:c.total}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums hidden lg:table-cell",children:c?e.jsxs("span",{className:`${t} font-medium`,children:[c.passRate.toFixed(1),"%"]}):e.jsx("span",{className:"text-gray-600",children:"—"})}),e.jsx("td",{className:"px-2 py-2.5 text-right tabular-nums text-gray-400",children:Ne(r.duration)}),e.jsx("td",{className:"px-2 py-2.5 text-right text-gray-500 text-xs hidden sm:table-cell",title:le(r.startTime),children:be(r.startTime)}),e.jsx("td",{className:"px-2 py-2.5 text-right hidden lg:table-cell",children:r.source==="cloud"&&r.cloudProvider==="local-appium"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",title:"Local device (Appium)",children:[e.jsx(E,{size:11}),"local device"]}):r.source==="cloud"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-sky-300 px-1.5 py-0.5 bg-sky-500/10 rounded",title:r.cloudProvider,children:[e.jsx(P,{size:11}),r.cloudProvider||"cloud"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-gray-500",children:[e.jsx(O,{size:11}),"local"]})}),e.jsx("td",{className:"px-2 py-2.5 text-right",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-md text-xs font-medium ${i.bg} ${i.tint}`,children:[e.jsx(o,{size:12,className:i.spin?"animate-spin":""}),i.label]})})]},r.runId)})})]})})]})}function Me(){const{project:a}=R(),s=f(),{data:l}=G(10,0),r=(l==null?void 0:l.runs)??[];return e.jsxs("div",{className:"p-6 space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-100",children:"Automation Dashboard"}),e.jsxs("p",{className:"text-base text-gray-400 mt-0.5",children:[a.framework||"Auto-detect"," · ",a.stats.totalFiles," files · ",a.stats.totalModules," modules"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs("button",{onClick:()=>s("/ai-record"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-300 text-sm border border-white/5 transition-colors",title:"Record a flow with AI",children:[e.jsx(K,{size:15}),"AI Record"]}),e.jsxs("button",{onClick:()=>s("/ai"),className:"flex items-center gap-2 px-4 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium transition-colors",title:"Open the AI Assistant",children:[e.jsx(q,{size:15}),"AI Assistant"]})]})]}),e.jsx(ne,{}),e.jsx(ce,{}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(oe,{}),e.jsx(je,{})]}),e.jsx(ve,{runs:r}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(de,{}),e.jsx(xe,{}),e.jsx(he,{})]})]})}export{Me as Dashboard};
@@ -1,2 +0,0 @@
1
- import{r as m,j as e}from"./vendor-react-CTbHBddL.js";import{dW as u}from"./index-DtBWNlVD.js";import{y as b,t as N,c1 as w,c0 as j,af as y}from"./vendor-icons-B0wLOBoh.js";function g(){const[d,n]=m.useState(()=>u());return m.useEffect(()=>{const a=new MutationObserver(()=>n(u()));return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),d}function k(d){const n=[];let a=0,x=0,i=!1;for(const s of d.split(`
2
- `)){if(!i&&(s.startsWith("--- ")||s.startsWith("+++ ")||s.startsWith("diff ")||s.startsWith("index ")||s==="---"||s==="+++"))continue;if(s.startsWith("diff --git ")){i=!1;continue}const l=s.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);if(l){i=!0,a=parseInt(l[1],10),x=parseInt(l[2],10),n.push({kind:"hunk",oldNo:null,newNo:null,text:s});continue}s.startsWith("+")?n.push({kind:"add",oldNo:null,newNo:x++,text:s.slice(1)}):s.startsWith("-")?n.push({kind:"del",oldNo:a++,newNo:null,text:s.slice(1)}):n.push({kind:"ctx",oldNo:a++,newNo:x++,text:s.startsWith(" ")?s.slice(1):s})}const r=n[n.length-1];return r&&r.kind==="ctx"&&r.text===""&&n.pop(),n}function v({diff:d,className:n=""}){const a=g()==="light",x=k(d),i=r=>r==="hunk"?a?{row:"bg-indigo-50/70",gutter:"bg-indigo-50/70 text-indigo-400",text:"text-indigo-600"}:{row:"bg-indigo-500/[0.07]",gutter:"bg-indigo-500/[0.07] text-indigo-500/70",text:"text-indigo-300/80"}:r==="add"?a?{row:"bg-emerald-50",gutter:"bg-emerald-100/70 text-emerald-600/70",text:"text-emerald-800"}:{row:"bg-emerald-500/[0.09]",gutter:"bg-emerald-500/[0.14] text-emerald-400/60",text:"text-emerald-200"}:r==="del"?a?{row:"bg-red-50",gutter:"bg-red-100/70 text-red-600/70",text:"text-red-800"}:{row:"bg-red-500/[0.09]",gutter:"bg-red-500/[0.14] text-red-400/60",text:"text-red-200"}:a?{row:"",gutter:"bg-gray-50 text-gray-400",text:"text-gray-600"}:{row:"",gutter:"bg-white/[0.02] text-gray-600",text:"text-gray-400"};return e.jsx("div",{className:`min-w-max font-mono text-[11px] leading-[1.55] ${n}`,children:x.map((r,s)=>{const l=i(r.kind);if(r.kind==="hunk")return e.jsxs("div",{className:`flex ${l.row}`,children:[e.jsx("span",{className:`sticky left-0 w-[84px] flex-shrink-0 px-2 select-none ${l.gutter}`}),e.jsx("span",{className:`px-2 whitespace-pre ${l.text}`,children:r.text})]},s);const t=r.kind==="add"?"+":r.kind==="del"?"−":" ";return e.jsxs("div",{className:`flex ${l.row}`,children:[e.jsxs("span",{className:`sticky left-0 flex-shrink-0 flex select-none ${l.gutter}`,children:[e.jsx("span",{className:"w-10 text-right pr-2 tabular-nums",children:r.oldNo??""}),e.jsx("span",{className:"w-10 text-right pr-2 tabular-nums",children:r.newNo??""}),e.jsx("span",{className:"w-4 text-center",children:t})]}),e.jsx("span",{className:`pl-2 pr-4 whitespace-pre ${l.text}`,children:r.text||" "})]},s)})})}function P({diffs:d}){const[n,a]=m.useState({}),i=g()==="light";if(d.length===0)return null;const r=t=>{a(o=>({...o,[t]:!o[t]}))},s=i?"hover:bg-gray-100/70":"hover:bg-white/[0.04]",l=i?"bg-gray-50 border border-gray-200":"bg-black/30 border border-white/5";return e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"space-y-0.5",children:d.map((t,o)=>{const f=n[o]??!1,c=t.filePath.lastIndexOf("/"),h=c>=0?t.filePath.slice(0,c+1):"",p=c>=0?t.filePath.slice(c+1):t.filePath;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>r(o),className:`inline-flex max-w-full items-center gap-2 px-4 py-1.5 rounded-lg transition-colors text-left ${s}`,title:t.filePath,children:[f?e.jsx(b,{size:12,className:"text-gray-500 flex-shrink-0"}):e.jsx(N,{size:12,className:"text-gray-500 flex-shrink-0"}),t.diffType==="new"?e.jsx(w,{size:13,className:"text-emerald-500 flex-shrink-0"}):t.diffType==="deleted"?e.jsx(j,{size:13,className:"text-red-500 flex-shrink-0"}):e.jsx(y,{size:13,className:"text-amber-500 flex-shrink-0"}),e.jsxs("span",{className:"text-xs font-mono truncate min-w-0",children:[h&&e.jsx("span",{className:i?"text-gray-400":"text-gray-600",children:h}),e.jsx("span",{className:i?"text-gray-900 font-medium":"text-gray-100 font-medium",children:p})]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] font-mono tabular-nums flex-shrink-0",children:[t.linesAdded>0&&e.jsxs("span",{className:i?"text-emerald-600":"text-emerald-400",children:["+",t.linesAdded]}),t.linesRemoved>0&&e.jsxs("span",{className:i?"text-red-600":"text-red-400",children:["−",t.linesRemoved]})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full border flex-shrink-0 ${t.diffType==="new"?"bg-emerald-500/10 text-emerald-500 border-emerald-500/20":t.diffType==="deleted"?"bg-red-500/10 text-red-500 border-red-500/20":"bg-amber-500/10 text-amber-500 border-amber-500/20"}`,children:t.diffType==="new"?"New":t.diffType==="deleted"?"Deleted":"Modified"})]}),f&&e.jsx("div",{className:`mx-4 mt-1 mb-1 rounded-lg max-h-[420px] overflow-auto ${l}`,children:e.jsx(v,{diff:t.diff})})]},`${t.filePath}-${t.timestamp}`)})})})}export{P as D,v as a};