@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.
- package/README.md +3 -1
- package/bin/testver.js +1 -1
- package/dist/index.js +1943 -1190
- package/package.json +2 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-CHaHfmu4.js} +5 -5
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-jNkQJA1P.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/Dashboard-BaIj_IdQ.js +1 -0
- package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-mU3JloJ6.js} +5 -5
- package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/KpiTile-BHLE3HVj.js +1 -0
- package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +1 -0
- package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/ReportCard-D4EElEe9.js +2 -0
- package/src/ui/static/assets/ReportFullView-2w2ysKRg.js +1 -0
- package/src/ui/static/assets/ReportsPage-9Fx-IEwV.js +48 -0
- package/src/ui/static/assets/ResultsPage-DPkfGh-K.js +115 -0
- package/src/ui/static/assets/RunState-CRuS_bC2.js +1 -0
- package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/SharedReportView-ig5hECRk.js +1 -0
- package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-DJiWpCne.js} +1 -1
- package/src/ui/static/assets/TestPlansPage-G1lvK1C0.js +5 -0
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-BACdnU-1.js} +17 -17
- package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/reportMeta-3kxT7BIT.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/useTestResults-yjH1aUy-.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +0 -40
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +0 -19
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +0 -2
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +0 -2
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
- package/src/ui/static/assets/index-B0klHYbO.css +0 -1
- package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +0 -1
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +0 -1
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as m,r as a,j as e}from"./vendor-react-CTbHBddL.js";import{a as l}from"./formatDate-T65-Y6Mi.js";import{io as p}from"./index-DtBWNlVD.js";import{R as h}from"./ReportCard-BbNfk85h.js";import{a3 as f,l as g,ap as u}from"./vendor-icons-B0wLOBoh.js";import"./vendor-query-BrzmPFT3.js";import"./vendor-charts-DWFQlmCz.js";import"./AIStreamUI-BsxKziYG.js";function R(){const{token:t}=m(),[r,c]=a.useState(null),[x,n]=a.useState(!0),[d,o]=a.useState(null);return a.useEffect(()=>{if(!t){o("No share token provided"),n(!1);return}p(t).then(s=>c(s)).catch(s=>{const i=s instanceof Error?s.message:String(s);o(i.includes("not found")||i.includes("revoked")?"This share link is no longer valid — it expired or was revoked. Ask the report owner for a fresh link.":i)}).finally(()=>n(!1))},[t]),x?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-surface-0",children:e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[e.jsx(f,{size:18,className:"animate-spin"}),e.jsx("span",{children:"Loading shared report…"})]})}):d||!r?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-surface-0 px-6",children:e.jsxs("div",{className:"max-w-md w-full rounded-xl border border-rose-500/30 bg-white dark:bg-white/[0.03] p-6 text-center",children:[e.jsx(g,{size:24,className:"text-rose-500 mx-auto mb-3"}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Share link unavailable"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:d||"Share link not found"})]})}):e.jsx("div",{className:"min-h-screen bg-gray-50 dark:bg-surface-0",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 py-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 text-[11px] text-gray-500 dark:text-gray-500",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"font-semibold tracking-wide uppercase",children:"Testver"}),e.jsx(u,{size:10,className:"opacity-50"}),e.jsx("span",{children:"Shared Report"})]}),e.jsxs("div",{children:["Read-only view · ",l(r.updatedAt||r.createdAt),r.shareExpiresAt&&e.jsxs(e.Fragment,{children:[" · link expires ",l(r.shareExpiresAt)]})]})]}),e.jsx(h,{spec:r.spec,savedId:r.id,initialShareToken:t,readonly:!0}),e.jsx("div",{className:"text-center text-[11px] text-gray-400 dark:text-gray-600 mt-6",children:"Generated by Testver"})]})})}export{R as SharedReportView};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as o,j as e,b as at,u as rt,n as Bt}from"./vendor-react-CTbHBddL.js";import{o as ys,w as Ut}from"./excel-BrxuVus5.js";import{a as Vt,b as Ht,c as _t,u as nt}from"./useTestExplorer-HqvURJAc.js";import{u as Ss,o as os,a as qt,b as Kt}from"./useOwnership-eW6Egd7X.js";import{L as ve,a as cs,u as lt,l as Vs}from"./useTestLifecycle-CL7-zz0Q.js";import{y as zs,b as ms,x as Ze,v as Gt,E as Wt,c as Ts,bM as Qt,k as Yt,bN as it,bO as Xt,s as ns,bP as Jt,bQ as Zt,bR as ea,bS as sa,bT as ta,L as aa,bU as ra}from"./index-DtBWNlVD.js";import{u as $s,a as ls,b as ot}from"./useTabParam-ChbOedP1.js";import{f as is}from"./formatDate-T65-Y6Mi.js";import{t as Ce,f as be}from"./formatTestName-BKd2Uqhs.js";import{v as Ge,X as Se,y as Me,t as ze,F as na,a7 as Te,r as xe,cd as la,m as ia,A as oa,bM as ca,a5 as Rs,f as $e,b3 as Ps,a2 as ne,ba as Ee,a0 as ke,an as ct,g as He,_ as Le,S as dt,ak as us,al as xt,q as da,a$ as xa,a3 as pe,ae as ds,bB as ma,o as Xe,C as ua,ce as pa,b0 as mt,J as Hs,u as _e,cf as Ms,cg as ha,d as fa,T as xs,aG as ga,ch as ba,ci as ja,aK as ya,N as Na,bA as Ae,h as va,cj as ks,ar as ut,ck as wa,cl as ka,by as Ca,b9 as Sa,bD as za,cm as Ta,aa as _s,ax as pt,b6 as Ls,bz as qs,bP as $a,U as Ra,bu as Ks,a9 as Pa,R as Ma}from"./vendor-icons-B0wLOBoh.js";import{F as La}from"./index-DpQhqcHv.js";import{e as Aa}from"./useTestResults-Bm-JyMhB.js";import{u as As,T as qe,B as ss}from"./RunTargets-C7Vqd4TU.js";import{S as Ea,T as Oa,C as Fa,a as Ia,t as Da}from"./ResultsPage-B4LwZH-R.js";import{u as Ke,a as ht}from"./vendor-query-BrzmPFT3.js";import{u as Ba}from"./useChartTheme-BFz2QcND.js";import{p as Ua,s as Va}from"./ansiToHtml-DYRzYQV1.js";import{h as Ha}from"./aiHandoff-vhtR29Fh.js";import{M as Es}from"./MobileRunPicker-BNs2lZFf.js";import{R as ft}from"./MobileRunTarget-D2Nqcj10.js";import{L as gt}from"./LiveExecutionView-BD0wE8sz.js";import{u as bt,a as Re,b as jt}from"./useSuites-CvtMGakZ.js";import{C as yt}from"./ConfirmDialog-DNU3qoAP.js";import{C as _a}from"./CronBuilder-DsnX-vRr.js";import{E as Gs}from"./EmptyState-BH_aDO0P.js";import{b as qa}from"./runSelected-WlgnZcSF.js";import"./vendor-excel-BFHGVHVC.js";import"./MediaModal-DiSINwmh.js";import"./SearchableDevicePicker-CFJ_DUAA.js";const Ka={playwright:{label:"Playwright",color:"bg-purple-500/20 text-purple-300"},jest:{label:"Jest",color:"bg-red-500/20 text-red-300"},vitest:{label:"Vitest",color:"bg-yellow-500/20 text-yellow-300"},cypress:{label:"Cypress",color:"bg-green-500/20 text-green-300"},cucumber:{label:"Cucumber",color:"bg-amber-500/20 text-amber-300"},mocha:{label:"Mocha",color:"bg-orange-500/20 text-orange-300"},webdriverio:{label:"WebdriverIO",color:"bg-orange-500/20 text-orange-300"},pytest:{label:"Pytest",color:"bg-blue-500/20 text-blue-300"},junit:{label:"JUnit",color:"bg-cyan-500/20 text-cyan-300"},testng:{label:"TestNG",color:"bg-teal-500/20 text-teal-300"},nunit:{label:"NUnit",color:"bg-indigo-500/20 text-indigo-300"},xunit:{label:"xUnit",color:"bg-indigo-500/20 text-indigo-300"},mstest:{label:"MSTest",color:"bg-blue-500/20 text-blue-300"},rspec:{label:"RSpec",color:"bg-rose-500/20 text-rose-300"},robot:{label:"Robot",color:"bg-sky-500/20 text-sky-300"}};function Ga({framework:s}){const t=Ka[s]||{label:s.slice(0,3).toUpperCase(),color:"bg-gray-500/20 text-gray-300"};return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-medium flex-shrink-0 ${t.color}`,children:t.label})}function Wa({status:s,size:t=14}){switch(s){case"passed":return e.jsx(xe,{size:t,className:"text-emerald-400"});case"failed":return e.jsx(ne,{size:t,className:"text-red-400"});case"skipped":return e.jsx(Ps,{size:t,className:"text-gray-500"});default:return e.jsx($e,{size:t,className:"text-gray-600"})}}function Qa({passed:s,failed:t,total:r}){if(r===0)return e.jsx("div",{className:"w-16 h-1.5 rounded-full bg-surface-2"});const a=s/r*100,n=t/r*100;return e.jsxs("div",{className:"w-16 h-1.5 rounded-full bg-surface-2 overflow-hidden flex",children:[a>0&&e.jsx("div",{className:"h-full bg-emerald-500 transition-all",style:{width:`${a}%`}}),n>0&&e.jsx("div",{className:"h-full bg-red-500 transition-all",style:{width:`${n}%`}})]})}function Ya({test:s}){if(s.runCount===0)return null;const t=Math.min(s.runCount,6),r=Math.min(s.failCount,t),a=t-r,n=[];for(let l=0;l<a;l++)n.push("passed");for(let l=0;l<r;l++)n.push("failed");return n.reverse(),e.jsx("div",{className:"flex items-center gap-0.5",children:n.map((l,m)=>e.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${l==="passed"?"bg-emerald-400":"bg-red-400"}`},m))})}function Ws(s){return`${s.file}::${s.name}`}function Xa(s,t){return t==="all"?!0:t==="passed"?s.lastStatus==="passed":t==="failed"?s.lastStatus==="failed":t==="norun"?s.runCount===0:!0}function Ja(s){return s.tests.filter(t=>t.lastStatus==="passed").length}function Za(s){return s.tests.filter(t=>t.lastStatus==="failed").length}function er({suites:s,statusFilter:t,frameworkFilter:r,searchQuery:a,tagFilters:n,sortField:l,sortDir:m,selectedTests:i,onSearchChange:u,onSelectTest:x,onRunTest:c,onRunSuite:p,runDisabledReason:d,onSortChange:b,onToggleSelect:g,onSelectAll:P,onDeselectAll:C,onRunSelected:N,onOwnerClick:O,ownershipMap:R,ownerFilter:v=[],lifecycleStatusOf:f,onSetLifecycle:M,lifecycleFilter:A="all"}){const[W,L]=o.useState(new Set),{data:_}=Ss(),X=!!(_!=null&&_.hideNames),U=o.useDeferredValue(a),q=o.useMemo(()=>{let w=s;if(r!=="all"&&(w=w.filter(y=>y.framework===r)),U.trim()){const y=U.toLowerCase();w=w.map($=>({...$,tests:$.tests.filter(S=>{var B;return Ce(S.name,U)||Ce($.name,U)||((B=S.tags)==null?void 0:B.some(Z=>Z.toLowerCase().includes(y)))})})).filter($=>$.tests.length>0)}t!=="all"&&(w=w.map(y=>({...y,tests:y.tests.filter($=>Xa($,t))})).filter(y=>y.tests.length>0)),n.length>0&&(w=w.map(y=>({...y,tests:y.tests.filter($=>n.some(S=>{var B;return(B=$.tags)==null?void 0:B.includes(S)}))})).filter(y=>y.tests.length>0)),v.length>0&&(w=w.map(y=>({...y,tests:y.tests.filter($=>{var B,Z;const S=(Z=(B=R==null?void 0:R[os(y.file,$.name)])==null?void 0:B.owner)==null?void 0:Z.name;return S?v.includes(S):!1})})).filter(y=>y.tests.length>0)),A!=="all"&&(w=w.map(y=>({...y,tests:y.tests.filter($=>(f?f(y.file,$.name):"draft")===A)})).filter(y=>y.tests.length>0));const J={failed:0,passed:1,skipped:2},Q=y=>J[y.lastStatus||""]??3,K=y=>y.runCount>0?y.passCount/y.runCount:-1,ie=y=>{var $;switch(l){case"status":return Q(y);case"runs":return y.runCount||0;case"passrate":return K(y);case"tags":return(($=y.tags)==null?void 0:$.length)||0;default:return 0}},re=(y,$)=>{let S=l==="name"?y.name.localeCompare($.name):ie(y)-ie($);return S===0&&(S=y.name.localeCompare($.name)),m==="desc"?-S:S},le=y=>{const $=y.tests;switch(l){case"status":return $.length?Math.min(...$.map(Q)):3;case"runs":return $.reduce((S,B)=>S+(B.runCount||0),0);case"passrate":{const S=$.reduce((Z,se)=>Z+(se.runCount||0),0),B=$.reduce((Z,se)=>Z+(se.passCount||0),0);return S>0?B/S:-1}case"tags":return $.reduce((S,B)=>{var Z;return S+(((Z=B.tags)==null?void 0:Z.length)||0)},0);default:return 0}},oe=(y,$)=>{let S=l==="name"?y.name.localeCompare($.name):le(y)-le($);return S===0&&(S=y.name.localeCompare($.name)),m==="desc"?-S:S};return w=w.map(y=>({...y,tests:[...y.tests].sort(re)})).sort(oe),w},[s,r,U,t,n,l,m,v,R,A,f]),ae=o.useMemo(()=>q.reduce((w,J)=>w+J.tests.length,0),[q]),D=o.useMemo(()=>U.trim()||t!=="all"||A!=="all"?new Set(q.map(w=>Ws(w))):W,[U,t,A,q,W]),z=w=>{L(J=>{const Q=new Set(J);return Q.has(w)?Q.delete(w):Q.add(w),Q})},F=({field:w})=>l!==w?e.jsx(la,{size:10,className:"text-gray-700"}):m==="asc"?e.jsx(ia,{size:10,className:"text-brand-400"}):e.jsx(oa,{size:10,className:"text-brand-400"});return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"px-4 py-3 flex-shrink-0 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ge,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{type:"text",placeholder:"Search suites, tests, or tags...",value:a,onChange:w=>u(w.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-9 pr-8 py-2 text-xs text-gray-200 placeholder-gray-500 outline-none focus:border-brand-500/50 transition-colors"}),a&&e.jsx("button",{onClick:()=>u(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300",children:e.jsx(Se,{size:12})})]}),e.jsx("div",{className:"flex items-center gap-1",children:["name","status","runs","passrate"].map(w=>e.jsxs("button",{onClick:()=>b(w),className:`flex items-center gap-1 px-2 py-1.5 rounded-lg text-[10px] font-medium transition-colors ${l===w?"bg-brand-500/10 text-brand-300":"text-gray-600 hover:text-gray-400 hover:bg-white/5"}`,children:[w==="passrate"?"Rate":w.charAt(0).toUpperCase()+w.slice(1),e.jsx(F,{field:w})]},w))})]}),i.size>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"text-gray-400",children:[i.size," selected"]}),e.jsxs("button",{onClick:()=>{const w=q.flatMap(J=>J.tests.map((Q,K)=>({key:`${J.file}::${Q.name}::${K}`})));P(w)},className:"text-brand-400 hover:text-brand-300",children:["Select All (",ae,")"]}),e.jsx("button",{onClick:C,className:"text-gray-500 hover:text-gray-300",children:"Deselect All"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-2",children:q.length===0?e.jsx("div",{className:"py-12 text-center",children:e.jsx("p",{className:"text-sm text-gray-500",children:U?"No tests match your search":"No tests match the current filters"})}):q.map(w=>{const J=Ws(w),Q=D.has(J),K=Ja(w),ie=Za(w),re=w.tests.length,le=K===re&&re>0,oe=ie>0,y=le?"border-l-emerald-500/40":oe?"border-l-red-500/40":"border-l-transparent";return e.jsxs("div",{className:`bg-surface-1 border border-white/5 rounded-lg overflow-hidden border-l-2 ${y} transition-all`,children:[e.jsxs("button",{onClick:()=>z(J),className:"w-full flex items-center gap-2.5 px-3 py-3 text-left hover:bg-white/[0.03] transition-colors group",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:Q?e.jsx(Me,{size:16}):e.jsx(ze,{size:16})}),e.jsx(na,{size:15,className:"text-amber-400/70 flex-shrink-0"}),e.jsx("span",{className:"flex-1 text-sm font-medium text-gray-200 truncate",title:w.name,children:be(w.name)}),e.jsxs("span",{className:`text-[11px] font-medium flex-shrink-0 ${le?"text-emerald-400":oe?"text-gray-400":"text-gray-500"}`,children:[K,"/",re]}),e.jsx(Qa,{passed:K,failed:ie,total:re}),p&&e.jsx("span",{onClick:d?void 0:$=>{$.stopPropagation(),p(w)},className:`opacity-0 group-hover:opacity-100 p-1 rounded transition-all flex-shrink-0 ${d?"text-gray-600 cursor-not-allowed":"hover:bg-brand-500/20 text-gray-500 hover:text-brand-300"}`,title:d||"Run all tests in suite",children:e.jsx(Te,{size:12})})]}),Q&&w.tests.length>0&&e.jsx("div",{className:"border-t border-white/5",children:w.tests.map(($,S)=>{const B=`${w.file}::${$.name}::${S}`;return e.jsx(ar,{rowKey:B,test:$,suite:w,isLast:S===w.tests.length-1,isSelected:i.has(B),onSelectTest:x,onRunTest:c,runDisabledReason:d,onToggleSelect:g,ownership:R==null?void 0:R[os(w.file,$.name)],hideNames:X,onOwnerClick:O,lifecycle:f?f(w.file,$.name):void 0,onSetLifecycle:M},B)})})]},J)})})]})}function Nt({status:s,onChange:t}){const[r,a]=o.useState(!1),[n,l]=o.useState(null),m=o.useRef(null),i=ve[s],u=128,x=()=>{if(t){if(!r&&m.current){const c=m.current.getBoundingClientRect();l({top:c.bottom+4,left:Math.max(8,c.right-u)})}a(c=>!c)}};return o.useEffect(()=>{if(!r)return;const c=()=>a(!1);return window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[r]),e.jsxs("span",{className:"relative flex-shrink-0",onClick:c=>c.stopPropagation(),children:[e.jsxs("button",{ref:m,onClick:x,title:t?"Change status":i.label,className:`inline-flex items-center gap-0.5 pl-1.5 pr-1 py-0.5 rounded text-[10px] font-medium ${i.cls} ${t?"cursor-pointer hover:brightness-110":""}`,children:[i.label,t&&e.jsx(Me,{size:11,className:`opacity-70 transition-transform ${r?"rotate-180":""}`})]}),r&&t&&n&&at.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[60]",onClick:()=>a(!1)}),e.jsx("div",{className:"fixed z-[61] w-32 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1",style:{top:n.top,left:n.left},onClick:c=>c.stopPropagation(),children:cs.map(c=>e.jsxs("button",{onClick:()=>{a(!1),c!==s&&t(c)},className:`w-full flex items-center gap-2 px-2.5 py-1.5 text-left text-[11px] transition-colors ${c===s?"bg-black/5 dark:bg-white/5":"hover:bg-black/5 dark:hover:bg-white/5"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ve[c].dot}`}),e.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:ve[c].label}),c===s&&e.jsx(xe,{size:12,className:"ml-auto text-brand-400"})]},c))})]}),document.body)]})}function sr({ownership:s,onOwnerClick:t}){if(!s)return null;if(s.uncommitted&&!s.owner)return e.jsx("span",{className:"text-[9px] font-medium text-amber-600 dark:text-amber-300 flex-shrink-0",children:"uncommitted"});if(!s.owner)return null;const r=s.owner.name;return e.jsxs("span",{onClick:t?a=>{a.stopPropagation(),t(r)}:void 0,title:`Owner: ${r}${s.lastModifiedBy?` · last modified by ${s.lastModifiedBy}`:""}`,className:`inline-flex items-center gap-1 flex-shrink-0 max-w-[140px] ${t?"cursor-pointer hover:opacity-80":""}`,children:[e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded-full bg-brand-500/20 text-brand-300 text-[8px] font-semibold uppercase flex-shrink-0",children:r.charAt(0)}),e.jsx("span",{className:"text-[10px] text-gray-400 truncate",children:r})]})}function tr(s){if(!s)return"";const t=Math.floor((Date.now()-new Date(s).getTime())/864e5);return t<1?"today":t<30?`${t}d`:t<365?`${Math.floor(t/30)}mo`:`${Math.floor(t/365)}y`}const ar=o.memo(function({rowKey:t,test:r,suite:a,isLast:n,isSelected:l,onSelectTest:m,onRunTest:i,runDisabledReason:u,onToggleSelect:x,ownership:c,hideNames:p,onOwnerClick:d,lifecycle:b,onSetLifecycle:g}){var O,R,v;const P=()=>m(r,a),C=i?()=>i(r,a):void 0,N=g?f=>g(a.file,r.name,f):void 0;return e.jsxs("div",{onClick:P,className:`w-full flex items-center gap-2 px-4 pl-5 py-2.5 text-left hover:bg-white/[0.04] transition-colors group cursor-pointer ${n?"":"border-b border-white/[0.03]"}`,children:[e.jsx("span",{onClick:f=>{f.stopPropagation(),x(t)},className:"flex-shrink-0 cursor-pointer text-gray-600 hover:text-gray-400",children:l?e.jsx(ca,{size:13,className:"text-brand-400"}):e.jsx(Rs,{size:13,className:"opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("span",{className:"flex-shrink-0",children:e.jsx(Wa,{status:r.lastStatus,size:13})}),e.jsx("span",{className:"flex-1 min-w-0",children:e.jsxs("span",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-[13px] text-gray-300 truncate",title:r.name,children:be(r.name)}),r.skip&&e.jsx("span",{className:"px-1.5 py-0 rounded text-[9px] font-semibold bg-amber-500/15 text-amber-400",children:"SKIP"}),(O=r.modifiers)==null?void 0:O.map(f=>e.jsx("span",{className:`px-1.5 py-0 rounded text-[9px] font-medium ${f==="only"?"bg-blue-500/10 text-blue-400":f==="todo"?"bg-purple-500/10 text-purple-400":f==="fixme"?"bg-red-500/10 text-red-400":f==="slow"?"bg-amber-500/10 text-amber-400":"bg-gray-500/10 text-gray-400"}`,children:f},f)),(R=r.tags)==null?void 0:R.slice(0,3).map(f=>e.jsx("span",{className:"px-1.5 py-0 rounded-full text-[9px] font-medium bg-cyan-500/10 text-cyan-400 border border-cyan-500/15",children:f},f)),(((v=r.tags)==null?void 0:v.length)||0)>3&&e.jsxs("span",{className:"text-[9px] text-gray-600",children:["+",r.tags.length-3]})]})}),e.jsx("div",{className:"w-[104px] flex-shrink-0 flex justify-start",children:b&&e.jsx(Nt,{status:b,onChange:N})}),!p&&e.jsxs("div",{className:"w-[104px] flex-shrink-0 flex items-center gap-1.5 overflow-hidden",children:[e.jsx(sr,{ownership:c,onOwnerClick:d}),(c==null?void 0:c.lastModifiedAt)&&e.jsx("span",{className:"text-[9px] text-gray-600 flex-shrink-0 tabular-nums hidden sm:inline",title:`Last modified ${is(c.lastModifiedAt)}`,children:tr(c.lastModifiedAt)})]}),e.jsxs("div",{className:"w-[72px] flex-shrink-0 flex items-center justify-end gap-1.5",children:[e.jsx(Ya,{test:r}),r.lastStatus&&r.runCount>0&&e.jsxs("span",{className:"text-[10px] text-gray-600 tabular-nums",children:[r.runCount,"x"]})]}),e.jsx("div",{className:"w-6 flex-shrink-0 flex justify-center",children:C&&e.jsx("span",{onClick:u?void 0:f=>{f.stopPropagation(),C()},className:`opacity-0 group-hover:opacity-100 p-1 rounded transition-all ${u?"text-gray-600 cursor-not-allowed":"hover:bg-brand-500/20 text-gray-500 hover:text-brand-300"}`,title:u||"Run this test",children:e.jsx(Te,{size:11})})})]})}),rr={browserstack:"BrowserStack",saucelabs:"Sauce Labs",lambdatest:"LambdaTest","testver-grid":"Testver Grid"};function nr({disabled:s,onChange:t}){const[r,a]=o.useState([]),[n,l]=o.useState("local"),[m,i]=o.useState(!1);if(o.useEffect(()=>{zs().then(x=>a(x.providers.filter(c=>c.enabled))).catch(()=>a([]))},[]),o.useEffect(()=>{if(n==="local"){t({});return}t({cloudProvider:n,...n==="testver-grid"&&m?{gridTunnel:!0}:{}})},[n,m]),r.length===0)return null;const u=(x,c)=>`flex items-center gap-1.5 px-2.5 h-7 text-xs rounded-lg border transition-colors disabled:opacity-50 ${x?c==="brand"?"border-brand-500/50 bg-brand-500/10 text-brand-400 font-medium":"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"}`;return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Run on"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>l("local"),disabled:s,className:u(n==="local","brand"),children:[e.jsx(Ee,{size:12})," Local"]}),r.map(x=>e.jsxs("button",{type:"button",onClick:()=>l(x.id),disabled:s,className:u(n===x.id,"blue"),children:[e.jsx(ke,{size:12})," ",rr[x.id]??x.id]},x.id))]})]}),n==="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:m,onChange:x=>i(x.target.checked),disabled:s,className:"rounded border-gray-600 bg-surface-2 text-brand-500 focus:ring-brand-500"}),"Local tunnel"]})})]})}function lr({test:s,suite:t,subscribe:r,onBack:a}){var Qe,fs,he;const{toast:n}=ms(),l=rt(),m=lt(),{data:i,refetch:u}=Vt(s.name,t.file),[x,c]=o.useState(!1),[p,d]=o.useState(null),{showsMobile:b,mode:g}=Ze(),P=/appium/i.test(s.framework||"")||s.mobile===!0,C=b&&(g==="mobile"||P),[N,O]=o.useState({}),[R,v]=o.useState({payload:null,active:!1,blocked:!1}),{browserOpts:f,envOpts:M,browserDefault:A,envDefault:W}=As(),[L,_]=o.useState(""),[X,U]=o.useState(""),q=o.useRef(!1);o.useEffect(()=>{q.current||(A&&_(A),W&&U(W),(A||W)&&(q.current=!0))},[A,W]);const ae=C&&R.active,[D,z]=o.useState([]),[F,w]=o.useState(""),[J,Q]=o.useState(null),[K,ie]=$s("detail",["steps","source","runs","output","mapping","methods"],"steps"),re=o.useRef(null),le=o.useRef(null),{data:oe}=Ke({queryKey:["run-commands-config"],queryFn:Gt,staleTime:6e4}),y=!!((Qe=oe==null?void 0:oe.configured)!=null&&Qe.singleTest),$=s.framework==="cucumber",S=s.steps&&s.steps.length>0,{data:B,isLoading:Z}=Ht(t.file,s.line??null,s.endLine??null,s.framework),{data:se}=_t(S?s.steps:null,$),ge=(i==null?void 0:i.history)||[],Y=s.runCount>0?Math.round(s.passCount/s.runCount*100):null,te=(p==null?void 0:p.status)==="running";o.useEffect(()=>{te&&ie("output")},[te]),o.useEffect(()=>{re.current&&(re.current.scrollTop=re.current.scrollHeight)},[p==null?void 0:p.output.length]),o.useEffect(()=>(te&&(le.current=setInterval(()=>{d(T=>T&&T.status==="running"?{...T,elapsedMs:Date.now()-T.startTime}:T)},500)),()=>{le.current&&(clearInterval(le.current),le.current=null)}),[te]),o.useEffect(()=>{if(!p||p.status!=="running")return;const T=p.runId;return r(H=>{if(H.type==="output"&&H.runId===T&&d(E=>E&&{...E,output:[...E.output,{stream:H.stream,data:H.data}]}),H.type==="test-progress"&&H.runId===T&&d(E=>E&&{...E,progress:{...E.progress,current:H.current,total:H.total||E.progress.total,currentTestName:H.testName}}),H.type==="test-passed"&&H.runId===T&&d(E=>E&&{...E,progress:{...E.progress,passed:E.progress.passed+1}}),H.type==="test-failed"&&H.runId===T&&d(E=>E&&{...E,progress:{...E.progress,failed:E.progress.failed+1}}),H.type==="test-results"&&H.runId===T){const E=H.summary;d(De=>De&&{...De,summary:E})}H.type==="complete"&&H.runId===T&&(d(E=>E&&{...E,status:H.exitCode===0?"completed":"failed",elapsedMs:Date.now()-E.startTime}),setTimeout(()=>u(),1500),setTimeout(async()=>{try{const E=await Wt(T);E!=null&&E.tests&&Array.isArray(E.tests)&&z(E.tests),E!=null&&E.projectPath&&w(E.projectPath)}catch{}},500))})},[r,p==null?void 0:p.runId,p==null?void 0:p.status,u]);const es=async()=>{s.runCommand&&(await navigator.clipboard.writeText(s.runCommand),c(!0),setTimeout(()=>c(!1),2e3))},ps=Ts(),je=()=>ps(()=>We(),{files:t.file?[t.file]:[]}),We=async()=>{if(!(!s.runCommand||te)&&!(C&&!R.ready))try{const T=await ns({command:s.runCommand,...C&&R.payload?R.payload:{},...C?{}:{browser:L||void 0,environment:X||void 0,...N}});d({runId:T.runId,command:T.command,status:"running",output:[],progress:{current:0,total:0,passed:0,failed:0,currentTestName:""},summary:null,startTime:Date.now(),elapsedMs:0})}catch(T){n("error",T.message||"The run could not be started")}},hs=async()=>{p&&te&&(await Yt(p.runId),d(T=>T&&{...T,status:"failed"}))},ye=()=>{d(null),z([]),w("")},{data:Oe}=Ke({queryKey:["tm-mapping-search",t.file],queryFn:()=>Qt(t.file),enabled:!!t.file}),Fe=(Oe==null?void 0:Oe.mappings)||[],Ie=[{id:"steps",label:"Steps"},{id:"source",label:"Source"},{id:"runs",label:"Runs"},{id:"output",label:"Output",badge:te?e.jsx("span",{className:"w-2 h-2 rounded-full bg-brand-400 animate-pulse ml-1.5"}):p&&p.status!=="running"?p.status==="completed"?e.jsx(xe,{size:10,className:"text-emerald-400 ml-1"}):e.jsx(ne,{size:10,className:"text-red-400 ml-1"}):null},{id:"mapping",label:"Mapped TCs",badge:Fe.length>0?e.jsx("span",{className:"ml-1.5 min-w-[18px] h-[18px] rounded-full bg-brand-500/20 text-brand-300 text-[10px] font-medium flex items-center justify-center px-1",children:Fe.length}):null},{id:"methods",label:"Methods"}];return e.jsxs("div",{className:"h-full flex animate-fade-in",children:[e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:a,className:"flex items-center gap-1.5 text-xs text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(ct,{size:14}),e.jsx("span",{children:"Back to Tests"})]}),e.jsx("span",{className:"text-gray-600 text-xs",children:"|"}),e.jsxs("span",{className:"text-xs text-gray-500 truncate flex items-center gap-1",title:t.name,children:[e.jsx(He,{size:11}),be(t.name)]})]}),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-start gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${s.lastStatus==="passed"?"bg-emerald-500/15":s.lastStatus==="failed"?"bg-red-500/15":"bg-gray-500/15"}`,children:e.jsx(vt,{status:s.lastStatus,size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-100 leading-snug",title:s.name,children:be(s.name)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-xs text-gray-500 flex-wrap",children:[e.jsx(Nt,{status:m.statusOf(t.file,s.name),onChange:T=>m.setStatus(t.file,s.name,T)}),e.jsxs("button",{onClick:()=>window.open(`/explorer?file=${encodeURIComponent(t.file)}${s.line?`&line=${s.line}`:""}`,"_blank","noopener"),className:"group flex items-center gap-1 text-gray-500 hover:text-gray-400 transition-colors",title:"Open in Project Explorer (new tab)",children:[e.jsx(He,{size:11,className:"shrink-0"}),e.jsxs("span",{className:"group-hover:underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[t.file,s.line?`:${s.line}`:""]}),e.jsx(Le,{size:11,className:"shrink-0"})]}),s.runCount>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-gray-600"}),e.jsxs("span",{children:[s.runCount," runs"]}),Y!==null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-gray-600"}),e.jsxs("span",{className:Y>=90?"text-emerald-400":Y>=70?"text-amber-400":"text-red-400",children:[Y,"% pass rate"]})]})]})]}),(s.tags&&s.tags.length>0||s.modifiers&&s.modifiers.length>0||s.skip)&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap",children:[s.skip&&e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-semibold bg-amber-500/15 text-amber-400 border border-amber-500/20",children:"SKIP"}),(fs=s.modifiers)==null?void 0:fs.map(T=>e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-medium border ${T==="only"?"bg-blue-500/10 text-blue-400 border-blue-500/20":T==="todo"?"bg-purple-500/10 text-purple-400 border-purple-500/20":T==="fixme"?"bg-red-500/10 text-red-400 border-red-500/20":T==="slow"?"bg-amber-500/10 text-amber-400 border-amber-500/20":"bg-gray-500/10 text-gray-400 border-gray-500/20"}`,children:T},T)),(he=s.tags)==null?void 0:he.map(T=>e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-medium bg-cyan-500/10 text-cyan-400 border border-cyan-500/20",children:T},T))]}),s.description&&e.jsx("p",{className:"text-xs text-gray-500 mt-1.5 italic",children:s.description}),e.jsx(ir,{file:t.file,name:s.name,startLine:s.line,endLine:s.endLine})]}),e.jsxs("button",{onClick:()=>{const T={name:s.name,file:t.file,framework:s.framework,line:s.line,endLine:s.endLine,lastStatus:s.lastStatus,runCount:s.runCount,passCount:s.passCount,tags:s.tags};Ha(l,{attachedTest:T})},className:"ask-ai-test-btn flex-shrink-0 inline-flex items-center gap-1.5 px-2.5 py-1.5 text-xs font-medium rounded-lg bg-brand-500/10 text-brand-300 border border-brand-500/20 hover:bg-brand-500/20 transition-colors",title:"Open the AI Assistant with this test attached",children:[e.jsx(dt,{size:12})," Ask AI about this test"]})]}),s.runCommand&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-start gap-2 mt-4",children:[te?e.jsxs("button",{onClick:hs,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-red-500/15 text-red-300 hover:bg-red-500/25 transition-colors flex-shrink-0",children:[e.jsx(Rs,{size:12})," Stop"]}):e.jsxs("button",{onClick:je,disabled:C&&!R.ready,title:C&&R.blocked?"Connect a local device or enable a cloud grid in Connectors first":C&&!R.ready?"Select a device and an app first":void 0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors disabled:opacity-60 disabled:cursor-not-allowed flex-shrink-0",children:[e.jsx(Te,{size:12})," Run Test"]}),e.jsxs("div",{className:"flex flex-col gap-2 min-w-0",children:[e.jsxs("div",{className:"test-run-cmd-box flex items-center gap-1.5 px-2.5 py-1.5 bg-surface-2 rounded-lg border border-white/5 max-w-md overflow-hidden",children:[y?e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-cyan-500/10 text-cyan-400 border border-cyan-500/20 flex-shrink-0",children:"Custom"}):e.jsx("span",{className:"text-[9px] px-1 py-0.5 rounded bg-gray-500/10 text-gray-500 border border-gray-500/20 flex-shrink-0",children:"Auto"}),e.jsx("code",{className:"text-[11px] text-gray-400 font-mono truncate",title:s.runCommand,children:s.runCommand}),e.jsx("button",{onClick:es,className:"text-gray-500 hover:text-gray-300 p-0.5 rounded transition-colors flex-shrink-0",title:"Copy command",children:x?e.jsx(us,{size:11,className:"text-emerald-400"}):e.jsx(xt,{size:11})})]}),!C&&e.jsx(nr,{disabled:te,onChange:O}),!C&&(f.length>0||M.length>0)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[f.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Browser"}),e.jsx("div",{className:"min-w-[120px]",children:e.jsx(qe,{isEnv:!1,value:L,onChange:_,options:f,size:"sm",variant:"inline"})})]}),M.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-500",children:"Environment"}),e.jsx("div",{className:"min-w-[120px]",children:e.jsx(qe,{isEnv:!0,value:X,onChange:U,options:M,size:"sm",variant:"inline"})})]})]})]})]}),C&&e.jsx(Es,{disabled:te,onChange:v})]})]}),e.jsx("div",{className:"flex items-center border-b border-white/5 bg-surface-1/50 px-6 flex-shrink-0",children:Ie.map(T=>e.jsxs("button",{onClick:()=>ie(T.id),className:`flex items-center px-3 py-2.5 text-xs font-medium transition-colors relative ${K===T.id?"text-brand-300":"text-gray-500 hover:text-gray-300"}`,children:[T.label,T.badge,K===T.id&&e.jsx("span",{className:"absolute bottom-0 left-0 right-0 h-0.5 bg-brand-400 rounded-t"})]},T.id))}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[K==="steps"&&e.jsx(or,{test:s,sourceData:B,sourceLoading:Z}),K==="source"&&e.jsx(cr,{test:s,suite:t,sourceData:B,sourceLoading:Z,stepDefMatches:se==null?void 0:se.matches}),K==="runs"&&e.jsx(xr,{test:s,history:ge,passRate:Y}),K==="output"&&e.jsx(mr,{runState:p,runTestDetails:D,runProjectPath:F,isRunning:te,outputRef:re,onDismiss:ye,onScreenshot:(T,H)=>Q({path:T,name:H}),onViewResults:()=>l(p!=null&&p.runId?`/results?runId=${encodeURIComponent(p.runId)}`:"/results")}),K==="mapping"&&e.jsx(jr,{mappedTestCases:Fe,scriptFile:t.file,testName:s.name}),K==="methods"&&e.jsx(yr,{testName:s.name,testFile:s.file||t.file})]}),J&&e.jsx(Ea,{url:Ye(J.path),testName:J.name,onClose:()=>Q(null)})]}),ae&&te&&e.jsx("div",{className:"w-[340px] flex-shrink-0 border-l border-white/10",children:e.jsx(ft,{testRunning:te})})]})}function vt({status:s,size:t=14}){switch(s){case"passed":return e.jsx(xe,{size:t,className:"text-emerald-400"});case"failed":return e.jsx(ne,{size:t,className:"text-red-400"});case"skipped":return e.jsx(Ps,{size:t,className:"text-gray-500"});default:return e.jsx($e,{size:t,className:"text-gray-600"})}}function ir({file:s,name:t,startLine:r,endLine:a}){const{data:n}=Ss(),{data:l,isLoading:m}=qt(s,t,r,a);if(n!=null&&n.hideNames)return null;if(m)return e.jsx("div",{className:"mt-2 h-4 w-48 rounded bg-white/5 animate-pulse"});if(!l||!l.owner&&!l.lastModifiedBy&&!l.uncommitted)return null;const i=u=>{if(!u)return"";const x=Date.now()-new Date(u).getTime(),c=Math.floor(x/864e5);return c<1?"today":c<30?`${c}d ago`:c<365?`${Math.floor(c/30)}mo ago`:`${Math.floor(c/365)}y ago`};return e.jsx("div",{className:"flex items-center gap-x-3 gap-y-1 mt-2 flex-wrap text-[11px] text-gray-400",children:l.uncommitted&&!l.owner?e.jsx("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-amber-500/15 text-amber-600 dark:text-amber-300 border border-amber-500/30",children:"Uncommitted"}):e.jsxs(e.Fragment,{children:[l.owner&&e.jsxs("span",{className:"inline-flex items-center gap-1",title:l.owner.email||void 0,children:[e.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center rounded-full bg-brand-500/20 text-brand-300 text-[8px] font-semibold uppercase",children:l.owner.name.charAt(0)}),e.jsx("span",{className:"text-gray-500",children:"Owner"}),e.jsx("span",{className:"text-gray-300 font-medium",children:l.owner.name})]}),l.lastModifiedBy&&e.jsxs("span",{className:"inline-flex items-center gap-1",title:l.lastModifiedAt||void 0,children:[e.jsx(da,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"text-gray-500",children:"Modified by"}),e.jsx("span",{className:"text-gray-300",children:l.lastModifiedBy}),l.lastModifiedAt&&e.jsxs("span",{className:"text-gray-500",children:["· ",i(l.lastModifiedAt)]})]}),l.lastCommitSha&&e.jsxs("span",{className:"inline-flex items-center gap-1 min-w-0",title:l.lastCommitMessage||void 0,children:[e.jsx(xa,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"font-mono text-gray-400",children:l.lastCommitSha}),l.lastCommitMessage&&e.jsx("span",{className:"text-gray-500 truncate max-w-[260px]",children:l.lastCommitMessage})]})]})})}function or({test:s,sourceData:t,sourceLoading:r}){const a=s.steps&&s.steps.length>0;return e.jsxs("div",{className:"p-6 space-y-4 max-w-3xl",children:[a&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-3",children:["Scenario Steps (",s.steps.length,")"]}),e.jsx("div",{className:"space-y-1",children:s.steps.map((n,l)=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start gap-3 group",children:[e.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-surface-2 border border-white/10 flex items-center justify-center text-[10px] text-gray-500 font-medium",children:l+1}),(l<s.steps.length-1||n.dataTable)&&e.jsx("span",{className:"w-px h-4 bg-white/10 mt-1"})]}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-lg bg-surface-2/40 flex-1 min-w-0",children:[e.jsx(wt,{keyword:n.keyword}),e.jsx("span",{className:"text-[13px] text-gray-300 leading-relaxed",children:n.name})]})]}),n.dataTable&&n.dataTable.length>0&&e.jsx("div",{className:"ml-9 mt-1 mb-2",children:e.jsx("table",{className:"text-[11px] border-collapse",children:n.dataTable.map((m,i)=>e.jsx("tr",{children:m.map((u,x)=>i===0?e.jsx("th",{className:"px-3 py-1 bg-surface-2 border border-white/10 font-semibold text-gray-400",children:u},x):e.jsx("td",{className:"px-3 py-1 border border-white/10 text-gray-300",children:u},x))},i))})})]},l))}),s.examples&&s.examples.headers.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-2 flex items-center gap-1.5",children:["Examples (",s.examples.rows.length," combinations)"]}),e.jsx("div",{className:"rounded-lg border border-white/10 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-surface-2",children:s.examples.headers.map((n,l)=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-gray-400 border-b border-white/10",children:n},l))})}),e.jsx("tbody",{children:s.examples.rows.map((n,l)=>e.jsx("tr",{className:"border-b border-white/[0.03] hover:bg-white/[0.02]",children:n.map((m,i)=>e.jsx("td",{className:"px-3 py-1.5 text-gray-300",children:m},i))},l))})]})})]})]}),!a&&e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-gray-500 text-xs",children:[e.jsx(pe,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Loading test steps..."})]}),t&&!r&&t.humanSteps.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-3 flex items-center gap-1.5",children:[e.jsx(ds,{size:12}),"Test Steps (",t.humanSteps.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.humanSteps.map((n,l)=>e.jsxs("div",{className:"flex items-start gap-3 group",children:[e.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[e.jsx("span",{className:"w-6 h-6 rounded-full bg-surface-2 border border-white/10 flex items-center justify-center text-[10px] text-gray-500 font-medium",children:l+1}),l<t.humanSteps.length-1&&e.jsx("span",{className:"w-px h-4 bg-white/10 mt-1"})]}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-lg bg-surface-2/40 flex-1 min-w-0",children:[e.jsx(ur,{keyword:n.keyword}),e.jsx("span",{className:"text-[13px] text-gray-300 leading-relaxed",children:n.name})]})]},l))})]}),t&&!r&&t.humanSteps.length===0&&e.jsx("div",{className:"py-8 text-center text-gray-500 text-sm",children:"No steps detected for this test. Check the Source tab to view the test code."})]})]})}function cr({test:s,suite:t,sourceData:r,sourceLoading:a,stepDefMatches:n}){const l=rt(),m=s.framework==="cucumber",i=s.steps&&s.steps.length>0,u=(x,c)=>{let p=`/explorer?file=${encodeURIComponent(x)}`;c&&c>0&&(p+=`&line=${c}`),l(p)};if(m&&i){const x=n?Object.keys(n).length:0;return e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"bg-surface-2/50 rounded-lg px-4 py-3 text-xs text-gray-300 flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ma,{size:12,className:"text-gray-500"}),e.jsx("span",{className:"text-gray-500",children:"Step Definitions"})]}),e.jsxs("span",{className:"text-gray-500",children:[x," of ",s.steps.length," steps resolved"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Feature:"}),e.jsx("span",{className:"font-mono",children:t.file})]})]}),s.steps.map((c,p)=>{const d=`${c.keyword}:${c.name}`,b=n==null?void 0:n[d];return e.jsxs("div",{className:"rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-surface-1 border-b border-white/5",children:[e.jsx("span",{className:"w-5 h-5 rounded-full bg-surface-2 border border-white/10 flex items-center justify-center text-[9px] text-gray-500 font-medium flex-shrink-0",children:p+1}),e.jsx(wt,{keyword:c.keyword}),e.jsx("span",{className:"text-[13px] text-gray-300 flex-1 truncate",children:c.name})]}),b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-surface-2/30 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 flex-1 min-w-0",children:[e.jsx(He,{size:11,className:"flex-shrink-0"}),e.jsxs("span",{className:"font-mono truncate",children:[b.file,":",b.line]}),b.method&&e.jsxs("span",{className:"text-gray-500",children:["· ",e.jsxs("span",{className:"font-mono text-brand-400/70",children:[b.method,"()"]})]})]}),e.jsxs("button",{onClick:()=>u(b.file,b.line),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-brand-400 hover:text-brand-300 bg-brand-500/10 hover:bg-brand-500/20 transition-colors flex-shrink-0",title:`Open ${b.file} in Project Explorer and highlight line ${b.line}`,children:[e.jsx(Le,{size:10}),"Go to Definition"]})]}),e.jsx(Ys,{source:b.source,language:b.language,startLine:b.line})]}):e.jsxs("div",{className:"px-4 py-4 text-center text-gray-600 text-xs flex items-center justify-center gap-1.5",children:[e.jsx(Xe,{size:12}),e.jsx("span",{children:"Step definition not found"})]})]},p)})]})}return a?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-gray-500 text-xs",children:[e.jsx(pe,{size:14,className:"animate-spin"}),e.jsx("span",{children:"Loading source code..."})]}):r?e.jsxs("div",{className:"p-6 space-y-3",children:[e.jsxs("div",{className:"bg-surface-2/50 rounded-lg px-4 py-3 text-xs text-gray-300 flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{size:11,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"font-mono",children:t.file})]}),s.line&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Lines:"}),e.jsxs("span",{className:"font-mono",children:[s.line,s.endLine?` - ${s.endLine}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Framework:"}),e.jsx(Ga,{framework:s.framework})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>u(t.file,s.line??void 0),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-brand-400 hover:text-brand-300 bg-brand-500/10 hover:bg-brand-500/20 transition-colors flex-shrink-0",title:`Open ${t.file}${s.line?`:${s.line}`:""} in Project Explorer`,children:[e.jsx(Le,{size:10}),"Go to Definition"]})]}),e.jsx(Ys,{source:r.source,language:r.language,startLine:r.startLine})]}):e.jsx("div",{className:"py-12 text-center text-gray-500 text-sm",children:"Source code not available for this test."})}const Qs={saucelabs:"Sauce Labs",browserstack:"BrowserStack",lambdatest:"LambdaTest","local-appium":"Local Device"};function dr(s){const t=new Date(s),r=new Date,a=m=>new Date(m.getFullYear(),m.getMonth(),m.getDate()).getTime(),n=Math.round((a(r)-a(t))/864e5);if(n===0){const m=Math.max(0,Math.floor((r.getTime()-t.getTime())/6e4)),i=Math.floor(m/60);return`Today (${m<1?"just now":m<60?`${m} ${m===1?"min":"mins"} ago`:`${i} ${i===1?"hr":"hrs"} ago`})`}if(n===1)return"Yesterday";const l={weekday:"short",month:"short",day:"numeric"};return t.getFullYear()!==r.getFullYear()&&(l.year="numeric"),t.toLocaleDateString("en-US",l)}const ts=20;function xr({test:s,history:t,passRate:r}){const[a,n]=o.useState(null),[l,m]=o.useState(0),[i,u]=o.useState(0),[x,c]=o.useState(null),{data:p,isLoading:d}=Aa(a),[b,g]=o.useState(new Set),P=f=>{g(M=>{const A=new Set(M);return A.has(f)?A.delete(f):A.add(f),A}),u(0)},C=o.useMemo(()=>{const f=new Set;for(const M of t)M.source==="cloud"&&M.cloudProvider?f.add(M.cloudProvider):f.add("local");return f},[t]),N=o.useMemo(()=>b.size===0?t:t.filter(f=>{const M=f.source==="cloud"&&f.cloudProvider?f.cloudProvider:"local";return b.has(M)}),[t,b]),O=a?t.find(f=>{var M;return((M=f.runId)==null?void 0:M.toLowerCase())===a.toLowerCase()}):null,R=o.useMemo(()=>p!=null&&p.tests?p.tests.filter(f=>f.name===s.name):[],[p,s.name]),v=o.useMemo(()=>R.length===0?null:R.length===1?R[0]:l<R.length?R[l]:R[0],[R,l]);return o.useEffect(()=>{m(0)},[a]),a?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>n(null),className:"flex items-center gap-1.5 text-sm text-gray-400 hover:text-gray-200 transition-colors",children:[e.jsx(ct,{size:15}),"Back to History"]}),O&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-700",children:"|"}),e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-lg ${O.status==="passed"?"bg-emerald-500/15 text-emerald-400":O.status==="failed"?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}`,children:O.status}),e.jsx("span",{className:"text-xs text-gray-500",children:is(O.timestamp)})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[d&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-16 text-gray-400",children:[e.jsx(pe,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading execution details..."})]}),!d&&v&&e.jsxs(e.Fragment,{children:[R.length>1&&(()=>{const M=R.some(A=>A.parameters&&Object.keys(A.parameters).length>0)?"Examples:":"Runs:";return e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-2 border-b border-white/5 bg-surface-1/50 flex-shrink-0 overflow-x-auto",children:[e.jsx("span",{className:"text-[10px] text-gray-500 uppercase tracking-wider mr-1 flex-shrink-0",children:M}),R.map((A,W)=>{const L=A.parameters?Object.values(A.parameters):[],_=W===l;return e.jsx("button",{onClick:()=>m(W),className:`px-2.5 py-1 rounded-lg text-xs font-medium transition-colors flex-shrink-0 flex items-center gap-1 ${_?"bg-brand-500/15 text-brand-300 border border-brand-500/30":"text-gray-500 hover:text-gray-300 hover:bg-white/5 border border-transparent"}`,children:L.length>0?L.map((X,U)=>e.jsx("span",{className:`px-1 py-0 rounded ${_?"bg-brand-500/20":"bg-white/5"}`,children:X},U)):A.browser?e.jsxs(e.Fragment,{children:[e.jsx(ss,{browser:A.browser,size:11}),e.jsx("span",{children:A.browser})]}):`#${W+1}`},W)})]})})(),e.jsx(Oa,{test:v,projectPath:p==null?void 0:p.projectPath,runId:a||void 0,onClose:()=>n(null),onOpenVideo:f=>{c(it(f))}}),e.jsx(Fa,{url:x,onClose:()=>c(null)})]}),!d&&!v&&p&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-gray-500",children:[e.jsx(Xe,{size:20}),e.jsx("p",{className:"text-sm",children:"Test details not found in this run."}),e.jsx("p",{className:"text-xs text-gray-600",children:"The test may have been renamed or removed since this execution."}),e.jsx("button",{onClick:()=>n(null),className:"mt-2 text-xs text-brand-400 hover:text-brand-300",children:"Back to History"})]}),!d&&!p&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 text-gray-500",children:[e.jsx(Xe,{size:20}),e.jsx("p",{className:"text-sm",children:"Run data is no longer available."}),e.jsx("button",{onClick:()=>n(null),className:"mt-2 text-xs text-brand-400 hover:text-brand-300",children:"Back to History"})]})]})]}):e.jsxs("div",{className:"p-6 space-y-5 max-w-3xl",children:[s.runCount>0&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(Ns,{icon:e.jsx(ua,{size:13}),label:"Total Runs",value:s.runCount.toString()}),e.jsx(Ns,{icon:e.jsx(pa,{size:13}),label:"Pass Rate",value:r!==null?`${r}%`:"N/A",color:r!==null?r>=90?"emerald":r>=70?"amber":"red":void 0}),e.jsx(Ns,{icon:e.jsx(ne,{size:13}),label:"Failures",value:s.failCount.toString(),color:s.failCount>0?"red":"emerald"})]}),s.lastBrowser&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2/50",children:[e.jsx(ss,{browser:s.lastBrowser,size:14}),e.jsxs("span",{className:"text-xs text-gray-300",children:["Last run: ",s.lastBrowser]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 mb-3 flex items-center gap-1.5",children:[e.jsx(mt,{size:12}),"Execution History"]}),t.length>0&&e.jsx("div",{className:"flex items-center gap-1 mb-4 flex-wrap",children:t.slice(0,20).map((f,M)=>e.jsx("span",{className:`w-3.5 h-3.5 rounded-full flex-shrink-0 transition-colors cursor-pointer hover:ring-2 hover:ring-white/30 ${f.status==="passed"?"bg-emerald-400":f.status==="failed"?"bg-red-400":"bg-gray-500"}`,title:`${f.status} — ${is(f.timestamp)} — Click to view details`,onClick:()=>f.runId&&n(f.runId)},M))}),t.length>0&&C.size>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-gray-600",children:"Filter:"}),["local","local-appium","saucelabs","browserstack","lambdatest"].filter(f=>C.has(f)).map(f=>{const M=b.has(f),A=f==="local"?"Local":Qs[f]||f;return e.jsxs("button",{onClick:()=>P(f),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium border transition-colors ${M?"bg-brand-500/15 text-brand-300 border-brand-500/30":"bg-surface-2/40 text-gray-400 border-white/5 hover:bg-surface-2/70 hover:text-gray-200"}`,children:[f==="local"?e.jsx(Te,{size:11}):f==="local-appium"?e.jsx(Hs,{size:11}):e.jsx(ke,{size:11}),A]},f)})]}),N.length>0?(()=>{const f=Math.max(1,Math.ceil(N.length/ts)),M=Math.min(i,f-1),A=M*ts,W=N.slice(A,A+ts);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:W.map((L,_)=>{const X=L.source==="cloud"&&L.cloudProvider,U=L.cloudProvider==="local-appium",q=X?Qs[L.cloudProvider]||L.cloudProvider:"Local",ae=Array.isArray(L.browsers)?L.browsers:[],D=L.instanceCount||ae.length||1,z=D>1;return e.jsxs("div",{onClick:()=>L.runId&&n(L.runId),className:`flex items-center gap-3 py-2.5 px-3 rounded-lg bg-surface-2/30 text-[13px] transition-colors ${L.runId?"cursor-pointer hover:bg-surface-2/60":""}`,children:[e.jsx(vt,{status:L.status,size:14}),e.jsx("span",{className:`font-medium w-16 ${L.status==="passed"?"text-emerald-400":L.status==="failed"?"text-red-400":"text-gray-400"}`,children:L.status}),L.duration!=null&&e.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[e.jsx(_e,{size:11}),(L.duration/1e3).toFixed(1),"s"]}),e.jsxs("span",{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium border ${X&&!U?"text-blue-300 bg-blue-500/10 border-blue-500/20":"text-gray-300 bg-surface-2/60 border-white/5"}`,title:U?"Ran on a local device":X?`Ran on ${q}`:"Ran locally",children:[U?e.jsx(Hs,{size:10}):X?e.jsx(ke,{size:10}):e.jsx(Te,{size:10}),q]}),z?e.jsxs("span",{className:"flex items-center gap-1.5 text-gray-400",children:[e.jsxs("span",{className:"text-[10px] text-gray-500",children:[D," runs"]}),e.jsx("span",{className:"flex items-center gap-1",children:ae.map(F=>e.jsx("span",{title:F,className:"flex items-center",children:e.jsx(ss,{browser:F,size:11})},F))})]}):L.browser?e.jsxs("span",{className:"flex items-center gap-1 text-gray-500",children:[e.jsx(ss,{browser:L.browser,size:11}),e.jsx("span",{className:"text-xs",children:L.browser})]}):null,e.jsxs("span",{className:"ml-auto text-gray-600 text-xs flex items-center gap-2",title:is(L.timestamp),children:[dr(L.timestamp),L.runId&&e.jsx(ze,{size:13,className:"text-gray-600"})]})]},_)})}),f>1&&e.jsxs("div",{className:"flex items-center justify-between pt-3",children:[e.jsxs("span",{className:"text-xs text-gray-600",children:["Showing ",A+1,"–",Math.min(A+ts,N.length)," of ",N.length," runs"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("button",{onClick:()=>u(Math.max(0,M-1)),disabled:M===0,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs border border-white/10 text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:[e.jsx(Ms,{size:12})," Prev"]}),e.jsxs("span",{className:"text-xs text-gray-500 px-1.5 tabular-nums",children:[M+1," / ",f]}),e.jsxs("button",{onClick:()=>u(Math.min(f-1,M+1)),disabled:M>=f-1,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs border border-white/10 text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",children:["Next ",e.jsx(ze,{size:12})]})]})]})]})})():t.length>0?e.jsx("p",{className:"text-sm text-gray-600 italic py-4",children:"No runs match the selected filter."}):e.jsx("p",{className:"text-sm text-gray-600 italic py-4",children:"No execution history yet. Run this test to see results here."})]})]})}function mr({runState:s,runTestDetails:t,runProjectPath:r,isRunning:a,outputRef:n,onDismiss:l,onScreenshot:m,onViewResults:i}){return s?e.jsxs("div",{className:"h-full flex flex-col",children:[a&&e.jsx("div",{className:"px-4 pt-3 flex-shrink-0",children:e.jsx(gt,{runId:s.runId,layout:"inline"})}),(a||!s.summary)&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-white/5 flex-shrink-0",children:[a?e.jsx(pe,{size:14,className:"text-brand-400 animate-spin"}):s.status==="completed"?e.jsx(xe,{size:14,className:"text-emerald-400"}):e.jsx(ne,{size:14,className:"text-red-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-200",children:a?"Running...":s.status==="completed"?"Run Complete":"Run Failed"}),e.jsxs("span",{className:"text-xs text-gray-500 ml-auto",children:[Math.round(s.elapsedMs/1e3),"s"]}),!a&&e.jsx("button",{onClick:l,className:"text-gray-500 hover:text-gray-300 p-0.5 rounded transition-colors",title:"Dismiss",children:e.jsx(ne,{size:12})})]}),a&&e.jsxs("div",{className:"px-4 py-2.5 border-b border-white/5 flex-shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3 mb-1.5",children:e.jsx("div",{className:"flex-1 bg-surface-2 rounded-full h-1.5 overflow-hidden",children:s.progress.passed+s.progress.failed>0&&e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"bg-emerald-500 transition-all",style:{width:`${s.progress.passed/Math.max(s.progress.passed+s.progress.failed,1)*100}%`}}),e.jsx("div",{className:"bg-red-500 transition-all",style:{width:`${s.progress.failed/Math.max(s.progress.passed+s.progress.failed,1)*100}%`}})]})})}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px]",children:[s.progress.current>0&&e.jsxs("span",{className:"text-gray-400",children:["Test #",s.progress.current]}),e.jsxs("span",{className:"text-emerald-400 flex items-center gap-0.5",children:[e.jsx(xe,{size:10})," ",s.progress.passed]}),e.jsxs("span",{className:"text-red-400 flex items-center gap-0.5",children:[e.jsx(ne,{size:10})," ",s.progress.failed]}),s.progress.currentTestName&&e.jsxs("span",{className:"text-gray-500 flex items-center gap-1 truncate ml-auto",children:[e.jsx(pe,{size:10,className:"animate-spin flex-shrink-0"}),e.jsx("span",{className:"truncate",children:be(s.progress.currentTestName)})]})]})]}),!a&&s.summary&&e.jsxs("div",{className:`px-4 py-2.5 border-b border-white/5 flex-shrink-0 flex items-center gap-x-4 gap-y-2 flex-wrap ${s.summary.passRate>=90?"bg-emerald-500/10":s.summary.passRate>=70?"bg-amber-500/10":"bg-red-500/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.summary.failed===0?e.jsx(xe,{size:16,className:"text-emerald-400"}):e.jsx(ne,{size:16,className:"text-red-400"}),e.jsx("span",{className:"text-sm font-semibold text-gray-200",children:s.status==="completed"?"Run Complete":"Run Failed"}),e.jsxs("span",{className:"text-xs text-gray-500",children:["· ",Math.round(s.elapsedMs/1e3),"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:s.summary.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(xe,{size:13})," ",s.summary.passed]}),e.jsxs("span",{className:`flex items-center gap-1 ${s.summary.failed>0?"text-red-400":"text-gray-500"}`,title:"Failed",children:[e.jsx(ne,{size:13})," ",s.summary.failed]}),e.jsxs("span",{className:"flex items-center gap-1 text-gray-500",title:"Skipped",children:[e.jsx(Ps,{size:13})," ",s.summary.skipped]}),e.jsxs("span",{className:`font-bold ${s.summary.passRate>=90?"text-emerald-400":s.summary.passRate>=70?"text-amber-400":"text-red-400"}`,children:[s.summary.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:[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-white/10 transition-colors",children:[e.jsx(Le,{size:12})," View Full Results"]}),e.jsx("button",{onClick:l,className:"text-gray-500 hover:text-gray-300 p-1 rounded transition-colors",title:"Dismiss",children:e.jsx(ne,{size:14})})]})]}),e.jsx(hr,{output:s.output,isRunning:a,outputRef:n}),!a&&t.length>0&&e.jsx(gr,{tests:t,projectPath:r,onScreenshot:m})]}):e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(Te,{size:32,className:"mx-auto text-gray-700 mb-3"}),e.jsx("p",{className:"text-sm text-gray-500",children:"No test output yet"}),e.jsx("p",{className:"text-xs text-gray-600 mt-1",children:"Run the test to see live output here"})]})}function wt({keyword:s}){const r={Given:"bg-sky-500/20 text-sky-300",When:"bg-amber-500/20 text-amber-300",Then:"bg-emerald-500/20 text-emerald-300",And:"bg-gray-500/20 text-gray-300",But:"bg-red-500/20 text-red-300"}[s]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[11px] font-mono font-medium flex-shrink-0 ${r}`,children:s})}function ur({keyword:s}){const r={Action:"bg-amber-500/20 text-amber-300",Assert:"bg-emerald-500/20 text-emerald-300",Comment:"bg-gray-500/20 text-gray-400",Setup:"bg-sky-500/20 text-sky-300"}[s]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-[11px] font-mono font-medium flex-shrink-0 ${r}`,children:s})}function Ns({icon:s,label:t,value:r,color:a}){const n=a==="emerald"?"text-emerald-400":a==="amber"?"text-amber-400":a==="red"?"text-red-400":"text-gray-200";return e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-lg p-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1 text-gray-500 mb-1.5",children:[s,e.jsx("span",{className:"text-xs",children:t})]}),e.jsx("div",{className:`text-lg font-bold ${n}`,children:r})]})}function Ye(s,t){const r=new URLSearchParams({path:s.replace(/\\/g,"/")});return it(`/api/results/artifact?${r.toString()}`)}function pr(s){const t=[];let r="",a="stdout";for(const n of s){if(n.stream!==a&&r){const l=r.split(`
|
|
2
|
-
`);for(const m of l)m&&t.push({stream:a,data:m});r=""}a=n.stream,r+=n.data}if(r){const n=r.split(`
|
|
3
|
-
`);for(const l of n)l&&t.push({stream:a,data:l})}return t}function hr({output:s,isRunning:t,outputRef:r}){const a=o.useMemo(()=>pr(s),[s]);return e.jsxs("div",{ref:r,className:"flex-1 min-h-0 overflow-auto bg-black/40 p-3 font-mono text-[11px] leading-5",children:[a.length===0&&t&&e.jsx("span",{className:"text-gray-600",children:"Waiting for output..."}),a.map((n,l)=>e.jsx(fr,{data:n.data,stream:n.stream},l))]})}function fr({data:s,stream:t}){var n,l,m;const r=o.useMemo(()=>Ua(s),[s]),a=t==="stderr"?"text-red-400":"text-gray-200";return r.length<=1&&!((n=r[0])!=null&&n.style.color)&&!((l=r[0])!=null&&l.style.bold)&&!((m=r[0])!=null&&m.style.dim)?e.jsx("div",{className:a,children:s}):e.jsx("div",{className:a,children:r.map((i,u)=>{const x=Va(i.style);return Object.keys(x).length>0?e.jsx("span",{style:x,children:i.text},u):e.jsx("span",{children:i.text},u)})})}function gr({tests:s,projectPath:t,onScreenshot:r}){const a=s.filter(d=>d.status==="failed"||d.status==="error"),[n,l]=o.useState(()=>new Set(a.length<=3?a.map((d,b)=>b):[0])),[m,i]=o.useState(null),[u,x]=o.useState(null);if(a.length===0){const d=s.filter(b=>b.screenshotPath);return d.length===0?null:e.jsxs("div",{className:"border-t border-white/5 px-4 py-3",children:[e.jsxs("h5",{className:"text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-2 flex items-center gap-1.5",children:[e.jsx(ga,{size:11}),"Screenshots (",d.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.map((b,g)=>e.jsxs("button",{onClick:()=>r(b.screenshotPath,b.name),className:"group relative w-20 h-14 rounded-md overflow-hidden border border-white/10 hover:border-brand-400/50 transition-colors",children:[e.jsx("img",{src:Ye(b.screenshotPath),alt:b.name,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx(ds,{size:12,className:"text-white"})})]},g))})]})}const c=d=>{l(b=>{const g=new Set(b);return g.has(d)?g.delete(d):g.add(d),g})},p=async(d,b)=>{await navigator.clipboard.writeText(d),i(b),setTimeout(()=>i(null),2e3)};return e.jsxs("div",{className:"border-t border-white/5 px-4 py-3 space-y-2",children:[u&&e.jsx(Ia,{url:u,onClose:()=>x(null)}),e.jsxs("h5",{className:"text-[11px] font-semibold uppercase tracking-wider text-gray-500 flex items-center gap-1.5",children:[e.jsx(Xe,{size:11,className:"text-red-400"}),"Failed Tests (",a.length,")"]}),a.map((d,b)=>{const g=n.has(b);return e.jsxs("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 overflow-hidden",children:[e.jsxs("button",{onClick:()=>c(b),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-red-500/10 transition-colors",children:[g?e.jsx(Me,{size:12,className:"text-gray-500"}):e.jsx(ze,{size:12,className:"text-gray-500"}),e.jsx(ne,{size:12,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-gray-200 truncate flex-1",title:d.name,children:be(d.name)}),d.duration!=null&&e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[(d.duration/1e3).toFixed(1),"s"]})]}),g&&e.jsxs("div",{className:"px-3 pb-3 space-y-2 animate-fade-in",children:[d.screenshotPath&&e.jsxs("button",{onClick:()=>r(d.screenshotPath,d.name),className:"group relative w-full max-w-xs h-24 rounded-md overflow-hidden border border-white/10 hover:border-brand-400/50 transition-colors",children:[e.jsx("img",{src:Ye(d.screenshotPath),alt:"Failure screenshot",className:"w-full h-full object-cover object-top"}),e.jsxs("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-1.5",children:[e.jsx(ds,{size:14,className:"text-white"}),e.jsx("span",{className:"text-white text-xs",children:"View Screenshot"})]})]}),d.errorMessage&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] font-medium text-red-300",children:"Error"}),e.jsx("button",{onClick:()=>p(d.errorMessage+(d.stackTrace?`
|
|
4
|
-
`+d.stackTrace:""),b),className:"text-gray-500 hover:text-gray-300 p-0.5 rounded transition-colors",title:"Copy error",children:m===b?e.jsx(us,{size:10,className:"text-emerald-400"}):e.jsx(ba,{size:10})})]}),e.jsx("pre",{className:"text-[11px] text-red-300 bg-red-500/10 rounded-md px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-words max-h-32 overflow-y-auto font-mono leading-relaxed",children:d.errorMessage})]}),d.stackTrace&&e.jsxs("details",{className:"group/stack",children:[e.jsx("summary",{className:"text-[10px] font-medium text-gray-500 cursor-pointer hover:text-gray-300 select-none",children:"Stack Trace"}),e.jsx("pre",{className:"mt-1 text-[10px] text-gray-500 bg-black/30 rounded-md px-2 py-1.5 overflow-x-auto whitespace-pre-wrap break-words max-h-40 overflow-y-auto font-mono leading-relaxed",children:d.stackTrace})]}),d.steps&&d.steps.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-medium text-gray-500",children:"Steps"}),e.jsx("div",{className:"mt-1 space-y-0.5",children:d.steps.map((P,C)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[11px]",children:[e.jsx("span",{className:`flex-shrink-0 ${P.status==="passed"?"text-emerald-400":P.status==="failed"?"text-red-400":"text-gray-500"}`,children:P.status==="passed"?"✓":P.status==="failed"?"✗":"-"}),e.jsx("span",{className:"text-gray-500 font-mono",children:P.keyword}),e.jsx("span",{className:"text-gray-300",children:P.name})]},C))})]}),d.tracePath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("a",{href:Ye(d.tracePath)+"&download=true",className:"text-[10px] text-brand-400 hover:text-brand-300 flex items-center gap-1",children:[e.jsx(Le,{size:10})," Download Trace"]}),e.jsxs("button",{onClick:()=>x(Da(Ye(d.tracePath))),className:"text-[10px] text-brand-400 hover:text-brand-300 flex items-center gap-1",children:[e.jsx(ja,{size:10})," Open in Trace Viewer"]})]})]})]},b)})]})}const br={typescript:"typescript",javascript:"javascript",python:"python",java:"java",csharp:"csharp",ruby:"ruby",robot:"plaintext",gherkin:"plaintext"};function Ys({source:s,language:t,startLine:r}){const a=Ba(),n=s.split(`
|
|
5
|
-
`).length,l=Math.min(n*20+24,500),m=br[t]||t||"plaintext";return e.jsx("div",{className:"rounded-lg border border-white/5 overflow-hidden",children:e.jsx(La,{height:l,language:m,value:s,theme:a.monacoTheme,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:i=>String(i+r-1),scrollBeyondLastLine:!1,fontSize:12,lineHeight:20,folding:!1,renderLineHighlight:"none",overviewRulerLanes:0,hideCursorInOverviewRuler:!0,scrollbar:{vertical:"auto",horizontal:"auto",verticalScrollbarSize:6,horizontalScrollbarSize:6},domReadOnly:!0,contextmenu:!1,padding:{top:8,bottom:8}}})})}const vs={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},Xs={synced:{bg:"bg-emerald-500/15 text-emerald-300",label:"Synced"},case_updated:{bg:"bg-blue-500/15 text-blue-300",label:"Case Updated"},script_updated:{bg:"bg-amber-500/15 text-amber-300",label:"Script Updated"},script_missing:{bg:"bg-red-500/15 text-red-300",label:"Script Missing"}};function jr({mappedTestCases:s,scriptFile:t,testName:r}){const[a,n]=o.useState(null),l=async x=>{n({tc:null,steps:[],loading:!0});try{const[c,p]=await Promise.all([Jt(x),Zt(x)]),d=(c==null?void 0:c.testCase)||c||{},b=(p==null?void 0:p.steps)||[];n({tc:d,steps:b,loading:!1})}catch{n({tc:{title:"Error loading test case"},steps:[],loading:!1})}},m=s.filter(x=>x.testName===r),i=s.filter(x=>x.testName!==r);if(s.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(ha,{className:"w-10 h-10 text-gray-600 mb-3"}),e.jsx("p",{className:"text-sm font-medium text-gray-300",children:"No Mapped Test Cases"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 text-center max-w-sm",children:"This script is not mapped to any test cases yet. Go to Script Mapping to create mappings."})]});const u=(x,c)=>{const p=x.testCase||{},d=x.syncStatus||"synced",b=Xs[d]||Xs.synced,g=vs[p.priority]||vs.medium;return e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3 border-b border-white/5 last:border-b-0 hover:bg-surface-2/30 transition-colors",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/10 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(xs,{size:14,className:"text-brand-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:p.title||x.testCaseId||"Unknown Test Case"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1.5",children:[p.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${g}`,children:p.priority.charAt(0).toUpperCase()+p.priority.slice(1)}),p.type&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-gray-500/20 text-gray-300",children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${b.bg}`,children:b.label}),p.automationStatus&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.automationStatus==="automated"?"bg-emerald-500/15 text-emerald-300":"bg-gray-500/15 text-gray-400"}`,children:p.automationStatus==="automated"?"Automated":"Manual"})]}),x.testName&&e.jsxs("p",{className:"text-[11px] font-mono text-gray-500 mt-1.5",children:["Test: ",x.testName]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>l(p.id||x.testCaseId),className:"p-2 rounded-md hover:bg-surface-2 text-gray-500 hover:text-brand-400 transition-colors",title:"View test case details",children:e.jsx(ds,{size:18})}),e.jsx("span",{className:"text-xs font-mono text-gray-500",children:p.id||x.testCaseId||""})]})]},x.id||c)};return e.jsxs("div",{className:"divide-y divide-white/10",children:[m.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 py-2.5 bg-surface-2/50 flex items-center gap-2",children:[e.jsx(fa,{size:12,className:"text-brand-400"}),e.jsxs("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:["Mapped to this test (",m.length,")"]})]}),m.map(u)]}),i.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 py-2.5 bg-surface-2/50 flex items-center gap-2",children:[e.jsx(He,{size:12,className:"text-gray-400"}),e.jsxs("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:["Other mappings in ",t.split("/").pop()," (",i.length,")"]})]}),i.map(u)]}),a&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>n(null),children:e.jsx("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-2xl w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden mx-4",onClick:x=>x.stopPropagation(),children:a.loading?e.jsxs("div",{className:"flex items-center justify-center py-20 gap-2 text-gray-400",children:[e.jsx(pe,{size:18,className:"animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading test case..."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/10 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/10 flex items-center justify-center shrink-0",children:e.jsx(xs,{size:16,className:"text-brand-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-200 truncate",children:a.tc.title||"Test Case"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[10px] font-mono text-gray-500",children:a.tc.id}),a.tc.priority&&e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${vs[a.tc.priority]||""}`,children:a.tc.priority}),a.tc.type&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium bg-gray-500/20 text-gray-300",children:a.tc.type})]})]})]}),e.jsx("button",{onClick:()=>n(null),className:"p-1.5 rounded-lg hover:bg-white/10 text-gray-400 hover:text-gray-200",children:e.jsx(ne,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[a.tc.preconditions&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider mb-1.5",children:"Preconditions"}),e.jsx("p",{className:"text-sm text-gray-300 bg-surface-2 rounded-lg p-3 border border-white/5",children:a.tc.preconditions})]}),a.steps.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider mb-2",children:["Test Steps (",a.steps.length,")"]}),e.jsx("div",{className:"bg-surface-2 rounded-lg border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-left",children:[e.jsx("th",{className:"px-3 py-2 text-gray-500 font-medium w-8",children:"#"}),e.jsx("th",{className:"px-3 py-2 text-gray-500 font-medium",children:"Action"}),e.jsx("th",{className:"px-3 py-2 text-gray-500 font-medium",children:"Expected Result"}),e.jsx("th",{className:"px-3 py-2 text-gray-500 font-medium",children:"Test Data"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:a.steps.map((x,c)=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-3 py-2 text-gray-500 font-mono",children:x.stepNumber||c+1}),e.jsx("td",{className:"px-3 py-2 text-gray-200",children:x.action}),e.jsx("td",{className:"px-3 py-2 text-teal-200",children:x.expectedResult||"-"}),e.jsx("td",{className:"px-3 py-2 text-sky-200 font-mono",children:x.testData||"-"})]},x.id||c))})]})})]}),a.steps.length===0&&!a.tc.preconditions&&e.jsx("p",{className:"text-sm text-gray-500 text-center py-8",children:"No steps or preconditions defined for this test case."})]})]})})})]})}function yr({testName:s,testFile:t}){const[r,a]=o.useState(null),[n,l]=o.useState(!0),[m,i]=o.useState(null);return o.useEffect(()=>{let u=!0;return l(!0),i(null),Xt({name:s,file:t}).then(x=>{u&&a(x.methods)}).catch(x=>{u&&i(String(x))}).finally(()=>{u&&l(!1)}),()=>{u=!1}},[s,t]),n?e.jsx("div",{className:"p-4 text-sm text-gray-500",children:"Analyzing usage…"}):m?e.jsx("div",{className:"p-4 text-sm text-red-400",children:m}):!r||r.length===0?e.jsx("div",{className:"p-4 text-sm text-gray-500",children:"No framework methods detected for this test. (Tests that only use built-in framework calls, or whose helpers aren't resolvable statically, show nothing here.)"}):e.jsx(Nr,{methods:r})}function Nr({methods:s}){const[t,r]=o.useState(""),a=o.useMemo(()=>{const n=t.trim().toLowerCase();return n?s.filter(l=>l.name.toLowerCase().includes(n)||(l.className||"").toLowerCase().includes(n)||l.file.toLowerCase().includes(n)):s},[s,t]);return e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:[s.length," method(s) used by this test (direct or transitive):"]}),s.length>4&&e.jsxs("div",{className:"relative mb-2",children:[e.jsx(Ge,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:t,onChange:n=>r(n.target.value),placeholder:"Filter methods by name, class, or file…",className:"w-full pl-9 pr-3 py-1.5 rounded-lg text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"})]}),e.jsx("div",{className:"rounded-lg border border-white/5 divide-y divide-white/5 bg-surface-1 overflow-hidden",children:a.length===0?e.jsxs("div",{className:"px-3 py-3 text-xs text-gray-500",children:["No methods match “",t,"”."]}):a.map(n=>e.jsx(vr,{mth:n},n.id))})]})}function vr({mth:s}){const[t,r]=o.useState(!1),a=()=>window.open(`/explorer?file=${encodeURIComponent(s.file)}&line=${s.startLine}`,"_blank","noopener"),n=()=>window.open(`/code-map?symbol=${encodeURIComponent(s.id)}&name=${encodeURIComponent(s.name)}`,"_blank","noopener"),l=()=>{var i;return(i=navigator.clipboard)==null?void 0:i.writeText(s.name).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})},m=({onClick:i,title:u,children:x,active:c})=>e.jsx("button",{type:"button",onClick:i,title:u,className:`p-1.5 rounded-md border transition-colors ${c?"text-emerald-400 border-emerald-500/30 bg-emerald-500/10":"text-gray-500 hover:text-gray-100 border-white/5 bg-surface-2/60 hover:bg-surface-3"}`,children:x});return e.jsxs("div",{className:"group px-3 py-2.5 hover:bg-white/[0.02] transition-colors flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200",children:s.name}),s.className&&e.jsxs("span",{className:"text-xs text-gray-500",children:["· ",s.className]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10",children:s.role})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 font-mono truncate mt-0.5",children:[s.file,":",s.startLine]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(m,{onClick:a,title:"Open in Project Explorer (new tab)",children:e.jsx(ya,{size:14})}),e.jsx(m,{onClick:n,title:"Open in Code Map · Inventory (new tab)",children:e.jsx(Na,{size:14})}),e.jsx(m,{onClick:l,title:"Copy method name",active:t,children:t?e.jsx(us,{size:14}):e.jsx(xt,{size:14})})]})]})}function Je(s){if(!s||s<0)return"";if(s<1e3)return`${s}ms`;const t=s/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function Os(s){return s?new Date(s).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):""}function kt(s){if(!s)return"";const t=(Date.now()-s)/1e3;return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:Os(s)}function Js({status:s,size:t=15}){switch(s){case"passed":return e.jsx(xe,{size:t,className:"text-emerald-400 flex-shrink-0"});case"failed":return e.jsx(ne,{size:t,className:"text-red-400 flex-shrink-0"});case"running":return e.jsx(pe,{size:t,className:"text-brand-400 animate-spin flex-shrink-0"});case"cancelled":return e.jsx(pt,{size:t,className:"text-gray-500 flex-shrink-0"});default:return e.jsx($e,{size:t,className:"text-gray-600 flex-shrink-0"})}}function wr(s){return s?s.status==="running"?"border-l-brand-400/50":s.summary.failed>0?"border-l-red-500/60":"border-l-emerald-500/55":"border-l-transparent"}function Zs(s){s&&window.open(`/results?runId=${encodeURIComponent(s)}`,"_blank","noopener")}function Fs({run:s,w:t="w-[74px]"}){const r=s==null?void 0:s.summary,a=(r==null?void 0:r.total)||0,n=a?r.passed/a*100:0,l=a?r.failed/a*100:0;return e.jsxs("span",{className:`${t} h-1.5 rounded-full bg-surface-3 overflow-hidden flex flex-shrink-0`,children:[e.jsx("span",{className:"h-full bg-emerald-400",style:{width:`${n}%`}}),e.jsx("span",{className:"h-full bg-red-400",style:{width:`${l}%`}})]})}function Ct({run:s}){if(!s)return e.jsx("span",{className:"text-[13px] text-gray-600",children:"Not run yet"});const t=s.summary;return e.jsxs("span",{className:"flex items-center gap-2 text-[13px]",children:[s.status==="running"&&e.jsxs("span",{className:"text-brand-300 inline-flex items-center gap-1.5",children:[e.jsx(pe,{size:13,className:"animate-spin"})," running"]}),s.status==="cancelled"&&e.jsx("span",{className:"text-gray-400",children:"cancelled"}),e.jsxs("span",{className:"text-emerald-400",children:[t.passed," passed"]}),t.failed>0&&e.jsxs("span",{className:"text-red-400",children:[t.failed," failed"]}),e.jsxs("span",{className:"text-gray-600",children:["of ",t.total]}),s.target==="cloud"?e.jsxs("span",{className:"text-cyan-400 inline-flex items-center gap-1.5",children:[e.jsx(ke,{size:13})," cloud"]}):e.jsxs("span",{className:"text-gray-500 inline-flex items-center gap-1.5",children:[e.jsx(Ee,{size:13})," local"]}),s.concurrency>1&&e.jsxs("span",{className:"text-gray-600",children:["×",s.concurrency]})]})}function kr({suite:s,onRun:t,onClose:r}){const a=s.runDefaults||{},n=Ze().mode==="mobile",[l,m]=o.useState(null),[i,u]=o.useState(a.target||"local"),[x,c]=o.useState(a.concurrency||1),[p,d]=o.useState(a.retries||0),[b,g]=o.useState(!!a.headless),[P,C]=o.useState(a.extraArgs||""),[N,O]=o.useState(a.cloudProvider||""),[R,v]=o.useState(a.deviceName||""),{data:f}=Ke({queryKey:["cloud-providers"],queryFn:zs,staleTime:3e4}),M=((f==null?void 0:f.providers)||[]).filter(z=>z.enabled),{browserOpts:A,envOpts:W,browserDefault:L,envDefault:_}=As(),[X,U]=o.useState(a.browser||""),[q,ae]=o.useState(a.environment||""),D=o.useRef(!1);return o.useEffect(()=>{D.current||(!a.browser&&L&&U(L),!a.environment&&_&&ae(_),(L||_)&&(D.current=!0))},[L,_]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:r}),e.jsxs("div",{className:`absolute right-0 top-full mt-1 z-50 ${n?"w-[26rem]":"w-72"} rounded-xl bg-surface-1 border border-white/10 shadow-2xl p-3 space-y-3 text-left`,children:[n?e.jsx(Es,{compact:!0,initial:{cloudProvider:a.cloudProvider,deviceName:a.deviceName,platformName:a.platformName,platformVersion:a.platformVersion,appId:a.appId,appPath:a.appPath},onChange:m}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:"Where"}),e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden",children:[e.jsxs("button",{onClick:()=>u("local"),className:`flex-1 px-2 py-1.5 text-xs inline-flex items-center justify-center gap-1.5 ${i==="local"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(Ee,{size:12})," Local"]}),e.jsxs("button",{onClick:()=>u("cloud"),className:`flex-1 px-2 py-1.5 text-xs inline-flex items-center justify-center gap-1.5 border-l border-white/10 ${i==="cloud"?"bg-cyan-500/15 text-cyan-300":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(ke,{size:12})," Cloud"]})]})]}),i==="cloud"&&e.jsxs("div",{className:"space-y-2",children:[M.length===0?e.jsx("p",{className:"text-[11px] text-amber-400/80",children:"No cloud providers configured. Add one in Settings → Connectors."}):e.jsxs("select",{value:N,onChange:z=>O(z.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 text-xs text-gray-200 outline-none",children:[e.jsx("option",{value:"",children:"Select provider…"}),M.map(z=>e.jsx("option",{value:z.id,children:z.id.charAt(0).toUpperCase()+z.id.slice(1)},z.id))]}),e.jsx("input",{value:R,onChange:z=>v(z.target.value),placeholder:"Device / browser (optional)",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 text-xs text-gray-200 outline-none placeholder-gray-600"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:["Concurrency (",x," at a time)"]}),e.jsx("input",{type:"range",min:1,max:8,value:x,onChange:z=>c(Number(z.target.value)),className:"w-full accent-brand-500"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:["Auto-retry failed (",p===0?"off":`${p}×`,")"]}),e.jsx("input",{type:"range",min:0,max:3,value:p,onChange:z=>d(Number(z.target.value)),className:"w-full accent-brand-500"})]}),i==="local"&&!n&&e.jsxs("label",{className:"flex items-center justify-between cursor-pointer",children:[e.jsxs("span",{className:"text-xs text-gray-300",children:["Headless ",e.jsx("span",{className:"text-gray-600",children:"(hide browser)"})]}),e.jsx("input",{type:"checkbox",checked:b,onChange:z=>g(z.target.checked),className:"accent-brand-500"})]}),A.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:"Browser"}),e.jsx(qe,{isEnv:!1,value:X,onChange:U,options:A,size:"sm"})]}),W.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:"Environment"}),e.jsx(qe,{isEnv:!0,value:q,onChange:ae,options:W,size:"sm"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-500 mb-1",children:"Extra CLI args"}),e.jsx("input",{value:P,onChange:z=>C(z.target.value),placeholder:"e.g. -DbaseUrl=… -Dbrowser=firefox",className:"w-full bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 text-xs text-gray-200 outline-none placeholder-gray-600 font-mono"})]}),e.jsxs("button",{onClick:()=>{var z;if(n){const F=l==null?void 0:l.payload;t({target:"cloud",concurrency:x,retries:p,extraArgs:P.trim()||void 0,environment:q||void 0,cloudProvider:F==null?void 0:F.cloudProvider,deviceName:(F==null?void 0:F.deviceName)||void 0,platformName:(F==null?void 0:F.platformName)||void 0,platformVersion:(F==null?void 0:F.platformVersion)||void 0,appId:(F==null?void 0:F.appId)||void 0,appPath:((z=F==null?void 0:F.appPath)==null?void 0:z.trim())||void 0})}else t({target:i,concurrency:x,retries:p,headless:b,extraArgs:P.trim()||void 0,browser:X||void 0,environment:q||void 0,cloudProvider:i==="cloud"&&N||void 0,deviceName:i==="cloud"&&R||void 0});r()},disabled:n?!(l!=null&&l.ready):i==="cloud"&&M.length>0&&!N,className:"w-full inline-flex items-center justify-center gap-1.5 px-3 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-40",children:[e.jsx(Te,{size:13})," Run now"]})]})]})}function St({suite:s,liveRun:t,isRunning:r,onRun:a,onCancel:n,size:l="sm"}){const m=Ts(),i=d=>m(()=>a(d)),[u,x]=o.useState(!1),c=(t==null?void 0:t.results.filter(d=>d.status==="failed").length)??0,p=l==="md"?"px-3 py-1.5 text-sm":"px-2.5 py-1.5 text-xs";return r?e.jsxs("button",{onClick:d=>{d.stopPropagation(),n()},className:`inline-flex items-center gap-1.5 ${p} font-medium rounded-lg text-red-300 bg-red-500/10 border border-red-500/30 hover:bg-red-500/20`,children:[e.jsx(Rs,{size:12})," Stop"]}):e.jsxs("div",{className:"flex items-center gap-1.5",onClick:d=>d.stopPropagation(),children:[c>0&&e.jsxs("button",{onClick:()=>i({...s.runDefaults,onlyFailed:!0}),title:"Re-run only the failed tests",className:`inline-flex items-center gap-1.5 ${p} font-medium rounded-lg text-amber-300 bg-amber-500/10 border border-amber-500/30 hover:bg-amber-500/20`,children:[e.jsx(ut,{size:12})," Re-run failed (",c,")"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>x(d=>!d),disabled:s.tests.length===0,className:`inline-flex items-center gap-1.5 ${p} font-medium rounded-lg text-brand-300 bg-brand-500/15 border border-brand-500/30 hover:bg-brand-500/25 disabled:opacity-40`,children:[e.jsx(Te,{size:12})," Run ",e.jsx(ze,{size:11,className:"rotate-90"})]}),u&&e.jsx(kr,{suite:s,onRun:i,onClose:()=>x(!1)})]})]})}function zt({r:s,onRemove:t}){const r=s.file.split(/[/\\]/).pop()||s.file,[a,n]=o.useState(!1),l=s.attemptRuns&&s.attemptRuns.length>1?s.attemptRuns:null,m=l?l.length-1:0;return e.jsxs("div",{className:"border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 hover:bg-surface-2/30 group",children:[e.jsx(Js,{status:s.status}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:`text-sm truncate ${s.isHook?"text-brand-300 font-medium":"text-gray-200"}`,title:s.name,children:s.isHook?s.name:be(s.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[s.isHook?"lifecycle hook":`${r} · ${s.framework}`,s.message?e.jsxs("span",{className:"text-red-400/80",children:[" · ",s.message]}):""]})]}),m>0&&e.jsxs("button",{onClick:()=>n(i=>!i),title:"Show each retry attempt",className:"inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full bg-amber-500/10 text-amber-300 border border-amber-500/30 flex-shrink-0 hover:bg-amber-500/20",children:[e.jsx(ut,{size:10})," ",m," ",m===1?"retry":"retries",e.jsx(ze,{size:10,className:`transition-transform ${a?"rotate-90":""}`})]}),s.durationMs?e.jsx("span",{className:"text-[11px] text-gray-500 tabular-nums flex-shrink-0",children:Je(s.durationMs)}):s.status==="running"?e.jsx("span",{className:"text-[11px] text-brand-400 flex-shrink-0",children:"running…"}):s.status==="pending"?e.jsx("span",{className:"text-[11px] text-gray-600 flex-shrink-0",children:"queued"}):null,s.runId&&e.jsxs("button",{onClick:()=>Zs(s.runId),title:"Open this test's run (logs, screenshots, trace)",className:"text-[11px] text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:["View Result ",e.jsx(Le,{size:11})]}),t&&e.jsx("button",{onClick:t,title:"Remove this test from the suite",className:"text-gray-600 hover:text-red-400 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Se,{size:14})})]}),s.status==="running"&&s.runId&&e.jsx(gt,{runId:s.runId,layout:"strip"}),a&&l&&e.jsx("div",{className:"bg-surface-2/20 border-t border-white/5",children:l.map((i,u)=>e.jsxs("div",{className:"flex items-center gap-3 pl-11 pr-4 py-2 border-b border-white/5 last:border-0",children:[e.jsx(Js,{status:i.status,size:13}),e.jsxs("span",{className:"text-[12px] text-gray-400 flex-shrink-0",children:["Attempt ",u+1,u===l.length-1?" · final":""]}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate flex-1",children:i.status==="passed"?"Passed":i.message||(i.status==="failed"?"Failed":i.status)}),i.durationMs?e.jsx("span",{className:"text-[11px] text-gray-500 tabular-nums flex-shrink-0",children:Je(i.durationMs)}):null,i.runId&&e.jsxs("button",{onClick:()=>Zs(i.runId),title:"Open this attempt's run (logs, screenshots, trace)",className:"text-[11px] text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1 flex-shrink-0",children:["View Result ",e.jsx(Le,{size:11})]})]},u))})]})}function Cr({suite:s,onOpen:t}){var c,p;const r=ht(),{run:a,cancel:n}=Re(),l=((c=s.lastRun)==null?void 0:c.status)==="running",{data:m}=jt(s.id,l),i=(m==null?void 0:m.run)??s.lastRun,u=(m==null?void 0:m.running)??l,x=()=>{r.invalidateQueries({queryKey:["suite-run-status",s.id]}),setTimeout(()=>r.invalidateQueries({queryKey:["suites"]}),500)};return e.jsxs("div",{onClick:t,className:`bg-surface-1 border border-white/5 border-l-[3px] ${wr(i)} rounded-xl flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-surface-2/30 transition-colors`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.color&&e.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:s.color}}),e.jsx("span",{className:"text-sm font-semibold text-gray-100 truncate",children:s.name}),((p=s.schedule)==null?void 0:p.enabled)&&e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded bg-brand-500/10 text-brand-300 border border-brand-500/20 inline-flex items-center gap-1",children:[e.jsx(_e,{size:11})," Scheduled"]}),e.jsxs("span",{className:"text-[13px] text-gray-500 flex-shrink-0",children:["· ",s.tests.length," test",s.tests.length===1?"":"s"]})]}),s.description&&e.jsx("div",{className:"text-xs text-gray-500 truncate mt-1",title:s.description,children:s.description}),e.jsxs("div",{className:"flex items-center gap-2.5 mt-1.5",children:[e.jsx(Fs,{run:i}),e.jsx(Ct,{run:i})]})]}),e.jsx(St,{suite:s,liveRun:i,isRunning:u,onRun:d=>a.mutate({id:s.id,options:d},{onSuccess:x}),onCancel:()=>n.mutate(s.id,{onSuccess:x})}),e.jsx(ze,{size:16,className:"text-gray-600 flex-shrink-0"})]})}function Sr({suite:s,liveRun:t}){const{removeTest:r}=Re(),[a,n]=o.useState(null),[l,m]=o.useState(""),u=Ze().mode==="mobile"&&(t==null?void 0:t.status)==="running"&&(t.concurrency??1)===1,x=t&&t.summary.total?Math.round(t.summary.passed/t.summary.total*100):0,c=(t==null?void 0:t.results)??[],p=new Set(s.tests.map(N=>`${N.file}::${N.name}`)),d=c.filter(N=>N.isHook||p.has(`${N.file}::${N.name}`)),b=l.trim().toLowerCase(),g=(N,O)=>!b||Ce(N,b)||O.toLowerCase().includes(b),P=d.filter(N=>N.isHook||g(N.name,N.file)),C=s.tests.filter(N=>g(N.name,N.file));return e.jsxs("div",{className:u?"lg:flex lg:items-start lg:gap-4":void 0,children:[e.jsxs("div",{className:u?"flex-1 min-w-0":void 0,children:[t&&t.summary.total>0&&e.jsxs("div",{className:"flex items-center gap-4 bg-surface-1 border border-white/5 rounded-xl px-4 py-3.5 mb-3.5",children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100 tabular-nums leading-none",children:[x,"%",e.jsx("span",{className:"text-xs text-gray-500 font-medium",children:" pass"})]}),e.jsx("div",{className:"flex-1",children:e.jsx(Fs,{run:t,w:"w-full"})}),e.jsx(Ct,{run:t}),e.jsx("span",{className:"text-[11px] text-gray-600 hidden sm:inline",children:t.status==="running"?"running…":kt(t.finishedAt)})]}),s.tests.length>0&&e.jsxs("div",{className:"relative mb-3",children:[e.jsx(Ge,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:l,onChange:N=>m(N.target.value),placeholder:`Search ${s.tests.length} test${s.tests.length===1?"":"s"}…`,className:"w-full bg-surface-2 border border-white/10 rounded-xl pl-9 pr-3 py-2 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50"})]}),s.tests.length===0?e.jsx("div",{className:"text-sm text-gray-600 py-10 text-center",children:"This suite has no tests. Add them from the Tests tab (+ Suite)."}):d.length>0?P.length===0?e.jsxs("div",{className:"text-sm text-gray-600 py-10 text-center",children:["No tests match “",l,"”."]}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:P.map((N,O)=>e.jsx(zt,{r:N,onRemove:N.isHook?void 0:()=>n({file:N.file,name:N.name})},`${N.file}::${N.name}::${O}`))}):C.length===0?e.jsxs("div",{className:"text-sm text-gray-600 py-10 text-center",children:["No tests match “",l,"”."]}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:C.map((N,O)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 border-b border-white/5 last:border-0 hover:bg-surface-2/30 group",children:[e.jsx($e,{size:15,className:"text-gray-600 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",title:N.name,children:be(N.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[N.file.split(/[/\\]/).pop()||N.file," · ",N.framework]})]}),e.jsx("button",{onClick:()=>n({file:N.file,name:N.name}),title:"Remove this test from the suite",className:"text-gray-600 hover:text-red-400 flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(Se,{size:14})})]},`${N.file}::${N.name}::${O}`))}),e.jsx(yt,{open:!!a,title:"Remove test from suite",description:a?`Remove "${a.name}" from "${s.name}"? The test file itself is not deleted — it's only dropped from this suite.`:"",confirmLabel:"Remove test",onCancel:()=>n(null),onConfirm:()=>{a&&r.mutate({id:s.id,file:a.file,name:a.name}),n(null)}})]}),u&&e.jsx("div",{className:"hidden lg:block w-[300px] flex-shrink-0 sticky top-4 h-[calc(100vh-140px)] rounded-xl border border-white/10 overflow-hidden shadow-lg",children:e.jsx(ft,{testRunning:!0})})]})}function Cs(s){return(s.finishedAt||s.startedAt)-s.startedAt}function Tt({run:s,size:t=17}){return s.status==="cancelled"?e.jsx(pt,{size:t,className:"text-gray-500 flex-shrink-0"}):s.summary.failed>0?e.jsx(ne,{size:t,className:"text-red-400 flex-shrink-0"}):s.summary.passed>0?e.jsx(xe,{size:t,className:"text-emerald-400 flex-shrink-0"}):e.jsx($e,{size:t,className:"text-gray-500 flex-shrink-0"})}function Ne({label:s,value:t,color:r}){return e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("span",{className:`text-[15px] font-bold tabular-nums ${r||"text-gray-200"}`,children:t}),e.jsx("span",{className:"text-[13px] text-gray-500",children:s})]})}function zr({run:s,onBack:t}){const r=s.summary,a=r.total?Math.round(r.passed/r.total*100):0,n=a>=90?"text-emerald-400":a>=60?"text-amber-400":"text-red-400";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3.5",children:[e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-sm rounded-lg bg-surface-2 text-gray-400 border border-white/5 hover:text-gray-200 transition-colors",children:[e.jsx(Ms,{size:14})," All runs"]}),e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(Tt,{run:s}),e.jsx("span",{className:"text-[15px] font-semibold text-gray-100 truncate",children:Os(s.startedAt)}),s.target==="cloud"?e.jsxs("span",{className:"text-[13px] text-cyan-400 inline-flex items-center gap-1.5",children:[e.jsx(ke,{size:13})," ",s.cloudProvider||"cloud"," ×",s.concurrency]}):e.jsxs("span",{className:"text-[13px] text-gray-500 inline-flex items-center gap-1.5",children:[e.jsx(Ee,{size:13})," local ×",s.concurrency]}),s.status==="cancelled"&&e.jsx("span",{className:"text-[13px] text-gray-500",children:"· cancelled"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-3.5",children:[e.jsx(Ne,{label:"Total",value:r.total}),e.jsx(Ne,{label:"Passed",value:r.passed,color:"text-emerald-400"}),e.jsx(Ne,{label:"Failed",value:r.failed,color:r.failed>0?"text-red-400":"text-gray-500"}),r.skipped>0&&e.jsx(Ne,{label:"Skipped",value:r.skipped,color:"text-amber-400"}),e.jsx(Ne,{label:"Pass Rate",value:`${a}%`,color:n}),e.jsx(Ne,{label:"Duration",value:Je(Cs(s))||"—"})]}),e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2 border-b border-white/5 text-[11px] uppercase tracking-wide text-gray-500",children:"Tests"}),s.results.map((l,m)=>e.jsx(zt,{r:l},`${l.file}::${l.name}::${m}`))]})]})}function Tr({suite:s}){const t=s.history||[],[r,a]=o.useState(null),n=t.find(i=>i.id===r),l=o.useMemo(()=>{if(t.length<2)return null;const[i,u]=[t[0],t[1]],x=P=>new Map(P.results.map(C=>[`${C.file}::${C.name}`,C.status])),c=x(u),p=x(i);let d=0,b=0,g=0;for(const[P,C]of p){const N=c.get(P);C==="failed"&&N!=="failed"?d++:C==="passed"&&N==="failed"?b++:C==="failed"&&N==="failed"&&g++}return{nf:d,np:b,sf:g}},[t]),m=o.useMemo(()=>{if(t.length===0)return null;const i=Math.round(t.reduce((p,d)=>p+(d.summary.total?d.summary.passed/d.summary.total:0),0)/t.length*100),u=t.filter(p=>p.summary.failed>0).length,x=t.map(Cs).filter(p=>p>0),c=x.length?Math.round(x.reduce((p,d)=>p+d,0)/x.length):0;return{total:t.length,avgRate:i,failedRuns:u,avgDur:c}},[t]);return t.length===0?e.jsx("div",{className:"text-sm text-gray-600 py-10 text-center",children:"No past runs yet."}):n?e.jsx(zr,{run:n,onBack:()=>a(null)}):e.jsxs("div",{children:[m&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 mb-3.5",children:[e.jsx(Ne,{label:"Total Runs",value:m.total}),e.jsx(Ne,{label:"Avg Pass Rate",value:`${m.avgRate}%`,color:m.avgRate>=90?"text-emerald-400":m.avgRate>=60?"text-amber-400":"text-red-400"}),e.jsx(Ne,{label:"Failed Runs",value:m.failedRuns,color:m.failedRuns>0?"text-red-400":"text-gray-500"}),e.jsx(Ne,{label:"Avg Duration",value:Je(m.avgDur)||"—"})]}),l&&e.jsxs("div",{className:"flex items-center gap-3.5 bg-surface-1 border border-white/5 rounded-xl px-4 py-3 mb-3.5 text-sm",children:[e.jsx(wa,{size:14,className:"text-gray-500"}),e.jsx("span",{className:"text-gray-500",children:"Latest vs previous:"}),e.jsxs("span",{className:"text-red-400",children:["+",l.nf," newly failed"]}),e.jsxs("span",{className:"text-emerald-400",children:["+",l.np," fixed"]}),e.jsxs("span",{className:"text-amber-400",children:[l.sf," still failing"]})]}),e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:t.map(i=>e.jsxs("button",{onClick:()=>a(i.id),className:"w-full flex items-center gap-6 px-4 py-3 border-b border-white/5 last:border-0 text-left hover:bg-surface-2/30",children:[e.jsx(Tt,{run:i,size:16}),e.jsx("span",{className:"text-sm text-gray-300 w-[120px] tabular-nums flex-shrink-0",children:Os(i.startedAt)}),e.jsxs("div",{className:"flex items-center gap-2.5 w-[240px] flex-shrink-0",children:[e.jsx(Fs,{run:i,w:"w-16"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[13px] whitespace-nowrap",children:[e.jsx(xe,{size:14,className:"text-emerald-400"}),e.jsx("span",{className:"text-emerald-400 tabular-nums",children:i.summary.passed}),e.jsx(ne,{size:14,className:`${i.summary.failed>0?"text-red-400":"text-gray-600"} ml-1`}),e.jsx("span",{className:`tabular-nums ${i.summary.failed>0?"text-red-400":"text-gray-600"}`,children:i.summary.failed}),e.jsxs("span",{className:"text-gray-500 ml-1",children:["· ",i.summary.total," total"]})]})]}),e.jsx("span",{className:"w-[120px] flex-shrink-0",children:i.target==="cloud"?e.jsxs("span",{className:"text-[13px] text-cyan-400 inline-flex items-center gap-1.5",children:[e.jsx(ke,{size:13})," cloud ×",i.concurrency]}):e.jsxs("span",{className:"text-[13px] text-gray-500 inline-flex items-center gap-1.5",children:[e.jsx(Ee,{size:13})," local ×",i.concurrency]})}),e.jsxs("span",{className:"text-[13px] text-gray-500 tabular-nums inline-flex items-center gap-1.5 w-[90px] flex-shrink-0",children:[e.jsx(_e,{size:13})," ",Je(Cs(i))]}),i.status==="cancelled"&&e.jsx("span",{className:"text-[13px] text-gray-500",children:"cancelled"}),e.jsx(ze,{size:14,className:"ml-auto text-gray-600 flex-shrink-0"})]},i.id))})]})}function et({value:s,onChange:t}){const{data:r}=nt(),[a,n]=o.useState(!1),[l,m]=o.useState(!1),[i,u]=o.useState(""),x=o.useRef(null),c=()=>{n(g=>{if(!g&&x.current){const P=window.innerHeight-x.current.getBoundingClientRect().bottom;m(P<320)}return!g}),u("")},p=o.useMemo(()=>{const g=[];for(const P of(r==null?void 0:r.suites)||[])for(const C of P.tests)g.push({file:P.file,name:C.name,command:C.runCommand||"",suiteName:P.name});return g},[r]),d=i.trim()?p.filter(g=>Ce(g.name,i)||`${g.suiteName} ${g.file}`.toLowerCase().includes(i.trim().toLowerCase())):p,b=!!(s!=null&&s.testName);return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:x,className:"flex items-center gap-2 bg-surface-2 border border-white/10 rounded-lg pl-2 pr-1.5 py-1 min-h-[40px] focus-within:border-brand-500/50",children:[e.jsx("div",{className:"flex-1 min-w-0 flex items-center",children:b?e.jsxs("span",{className:"flex items-center gap-1.5 bg-surface-3 border border-white/15 rounded-md pl-2 pr-1 py-1 text-xs text-gray-100 min-w-0 max-w-full shadow-sm",children:[e.jsx($e,{size:9,className:"text-cyan-400 fill-current flex-shrink-0"}),e.jsx("span",{className:"truncate font-medium",title:s.testName,children:be(s.testName)}),e.jsx("button",{onClick:()=>t(null),title:"Remove test",className:"text-gray-500 hover:text-red-400 flex-shrink-0",children:e.jsx(Se,{size:13})})]}):e.jsx("input",{value:(s==null?void 0:s.command)||"",onChange:g=>t(g.target.value.trim()?{command:g.target.value}:null),placeholder:"Type a command… or pick a test →",className:"w-full bg-transparent text-xs text-gray-200 outline-none font-mono placeholder-gray-600"})}),e.jsxs("button",{onClick:c,title:"Pick a project test",className:"text-[11px] font-medium text-gray-400 hover:text-gray-100 inline-flex items-center gap-1 flex-shrink-0 border border-white/10 rounded-md px-2 py-1 hover:bg-surface-3",children:[e.jsx(Ls,{size:12})," test"]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>n(!1)}),e.jsxs("div",{className:`absolute right-0 z-50 w-80 rounded-xl bg-surface-1 border border-white/10 shadow-2xl p-2 ${l?"bottom-full mb-1":"top-full mt-1"}`,children:[e.jsxs("div",{className:"relative mb-1.5",children:[e.jsx(Ge,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:i,onChange:g=>u(g.target.value),placeholder:"Search all project tests…",autoFocus:!0,className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-2 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600"})]}),e.jsx("div",{className:"max-h-64 overflow-auto",children:d.length===0?e.jsx("div",{className:"text-xs text-gray-600 py-6 text-center",children:p.length===0?"No tests found in this project.":`No tests match “${i}”.`}):d.slice(0,200).map((g,P)=>e.jsxs("button",{onClick:()=>{t({command:g.command,testName:g.name,file:g.file}),n(!1)},className:"w-full text-left px-2.5 py-1.5 rounded-lg hover:bg-surface-2/60",children:[e.jsx("div",{className:"text-sm text-gray-200 truncate",title:g.name,children:be(g.name)}),e.jsxs("div",{className:"text-[11px] text-gray-500 truncate",children:[g.suiteName," · ",g.file.split(/[/\\]/).pop()||g.file]})]},`${g.file}::${g.name}::${P}`))})]})]})]})}function Ve({on:s,onChange:t}){return e.jsx("button",{role:"switch","aria-checked":s,onClick:()=>t(!s),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${s?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${s?"translate-x-4":""}`})})}function Pe({title:s,icon:t,children:r}){return e.jsxs("section",{className:"bg-surface-1 border border-white/5 rounded-xl p-6",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2.5 mb-2",children:[e.jsx("span",{className:"text-brand-400 flex-shrink-0",children:t}),s]}),e.jsx("div",{className:"divide-y divide-white/5",children:r})]})}function ee({label:s,desc:t,children:r,alignTop:a}){return e.jsxs("div",{className:`flex flex-col md:flex-row gap-1.5 md:gap-8 py-4 ${a?"md:items-start":"md:items-center"}`,children:[e.jsxs("div",{className:"md:w-56 flex-shrink-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200",children:s}),t&&e.jsx("div",{className:"text-[13px] text-gray-500 mt-0.5 leading-snug",children:t})]}),e.jsx("div",{className:"flex-1 min-w-0",children:r})]})}function $r({suite:s,onDelete:t}){const{update:r}=Re(),{toast:a}=ms(),[n,l]=o.useState(s.name),[m,i]=o.useState(s.description||""),u=s.runDefaults||{},x=Ze().mode==="mobile",[c,p]=o.useState(null),[d,b]=o.useState(u.target||"local"),[g,P]=o.useState(u.concurrency||1),[C,N]=o.useState(u.retries||0),[O,R]=o.useState(!!u.headless),[v,f]=o.useState(u.extraArgs||""),[M,A]=o.useState(u.cloudProvider||""),[W,L]=o.useState(u.browser||""),[_,X]=o.useState(u.environment||""),[U,q]=o.useState(s.beforeRun||null),[ae,D]=o.useState(s.afterRun||null),[z,F]=o.useState(s.abortOnSetupFailure??!0),[w,J]=o.useState(s.autoHeal||"inherit"),{data:Q}=Ke({queryKey:["auto-heal-config"],queryFn:ea,staleTime:6e4}),K=Q==null?void 0:Q.mode,{data:ie}=Ke({queryKey:["cloud-providers"],queryFn:zs,staleTime:3e4}),re=((ie==null?void 0:ie.providers)||[]).filter(S=>S.enabled),{browserOpts:le,envOpts:oe}=As(),y=()=>{var S,B,Z,se,ge,Y,te;r.mutate({id:s.id,patch:{name:n.trim()||s.name,description:m,runDefaults:x?{target:"cloud",concurrency:g,retries:C,extraArgs:v.trim()||void 0,environment:_||void 0,cloudProvider:((S=c==null?void 0:c.payload)==null?void 0:S.cloudProvider)||u.cloudProvider,deviceName:((B=c==null?void 0:c.payload)==null?void 0:B.deviceName)||u.deviceName,platformName:((Z=c==null?void 0:c.payload)==null?void 0:Z.platformName)||u.platformName,platformVersion:((se=c==null?void 0:c.payload)==null?void 0:se.platformVersion)||u.platformVersion,appId:((ge=c==null?void 0:c.payload)==null?void 0:ge.appId)||u.appId,appPath:((te=(Y=c==null?void 0:c.payload)==null?void 0:Y.appPath)==null?void 0:te.trim())||u.appPath}:{target:d,concurrency:g,retries:C,headless:O,extraArgs:v.trim()||void 0,cloudProvider:d==="cloud"&&M||void 0,browser:W||void 0,environment:_||void 0},beforeRun:U,afterRun:ae,abortOnSetupFailure:z,autoHeal:w}},{onSuccess:()=>a("success","Suite settings saved"),onError:()=>a("error","Failed to save settings")})},$="w-full bg-surface-2 border border-white/10 rounded-lg px-3.5 py-2.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50";return e.jsxs("div",{className:"max-w-3xl mx-auto space-y-4 pb-2",children:[e.jsxs(Pe,{title:"Details",icon:e.jsx(He,{size:16}),children:[e.jsx(ee,{label:"Name",children:e.jsx("input",{value:n,onChange:S=>l(S.target.value),className:$})}),e.jsx(ee,{label:"Description",children:e.jsx("input",{value:m,onChange:S=>i(S.target.value),placeholder:"Optional",className:$})})]}),e.jsxs(Pe,{title:"Default run options",icon:e.jsx(ka,{size:16}),children:[x?e.jsx(ee,{label:"Device & App",desc:"Default device + app for this suite — runs execute on your selected local or cloud device.",children:e.jsx(Es,{compact:!0,initial:{cloudProvider:u.cloudProvider,deviceName:u.deviceName,platformName:u.platformName,platformVersion:u.platformVersion,appId:u.appId,appPath:u.appPath},onChange:p})}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{label:"Where",desc:"Run locally or on a cloud device grid.",children:e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden max-w-xs",children:[e.jsxs("button",{onClick:()=>b("local"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 ${d==="local"?"bg-brand-500/15 text-brand-300":"text-gray-400"}`,children:[e.jsx(Ee,{size:12})," Local"]}),e.jsxs("button",{onClick:()=>b("cloud"),className:`flex-1 px-2 py-2 text-xs inline-flex items-center justify-center gap-1.5 border-l border-white/10 ${d==="cloud"?"bg-cyan-500/15 text-cyan-300":"text-gray-400"}`,children:[e.jsx(ke,{size:12})," Cloud"]})]})}),d==="cloud"&&e.jsx(ee,{label:"Provider",children:e.jsxs("select",{value:M,onChange:S=>A(S.target.value),className:`${$} max-w-xs`,children:[e.jsx("option",{value:"",children:"Select…"}),re.map(S=>e.jsx("option",{value:S.id,children:S.id.charAt(0).toUpperCase()+S.id.slice(1)},S.id))]})})]}),e.jsx(ee,{label:"Concurrency",desc:"How many tests run at once.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:1,max:8,value:g,onChange:S=>P(Number(S.target.value)),className:"flex-1 accent-brand-500"}),e.jsxs("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:[g," at a time"]})]})}),e.jsx(ee,{label:"Auto-retry failed",desc:"Re-runs a failed test immediately. Timeouts are not retried.",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"range",min:0,max:3,value:C,onChange:S=>N(Number(S.target.value)),className:"flex-1 accent-brand-500"}),e.jsx("span",{className:"text-sm text-gray-300 tabular-nums w-20 text-right",children:C===0?"off":`${C}×`})]})}),!x&&e.jsx(ee,{label:"Headless",desc:"Hide the browser window during the run.",children:e.jsx(Ve,{on:O,onChange:R})}),le.length>0&&e.jsx(ee,{label:"Browser",desc:"Default browser for this suite (from Settings → Run Commands).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(qe,{isEnv:!1,value:W,onChange:L,options:le})})}),oe.length>0&&e.jsx(ee,{label:"Environment",desc:"Default environment for this suite (from Settings → Run Commands).",children:e.jsx("div",{className:"max-w-xs",children:e.jsx(qe,{isEnv:!0,value:_,onChange:X,options:oe})})}),e.jsxs(ee,{label:"Extra CLI args",alignTop:!0,desc:"Appended to every test's command — pass a base URL, browser, or any flag.",children:[e.jsx("input",{value:v,onChange:S=>f(S.target.value),placeholder:"-DbaseUrl=https://staging.example.com -Dbrowser=firefox",className:`${$} font-mono text-xs`}),e.jsxs("p",{className:"text-[11px] text-gray-600 mt-1.5",children:[e.jsx("span",{className:"text-gray-500",children:"Maven/TestNG"})," ",e.jsx("span",{className:"font-mono",children:"-DbaseUrl=… -Dbrowser=firefox"})," · ",e.jsx("span",{className:"text-gray-500",children:"pytest"})," ",e.jsx("span",{className:"font-mono",children:"--base-url=…"})," · ",e.jsx("span",{className:"text-gray-500",children:"Playwright"})," ",e.jsx("span",{className:"font-mono",children:"--workers=1"})]})]})]}),e.jsxs(Pe,{title:"Setup & teardown",icon:e.jsx(Ca,{size:16}),children:[e.jsx(ee,{label:"Before run",desc:"One test, runs once before the suite.",children:e.jsx(et,{value:U,onChange:q})}),e.jsx(ee,{label:"After run",desc:"One test, runs last — even if tests fail.",children:e.jsx(et,{value:ae,onChange:D})}),e.jsx(ee,{label:"Abort on setup failure",desc:"Skip the tests if the before-run test fails.",children:e.jsx(Ve,{on:z,onChange:F})})]}),e.jsx(Pe,{title:"Auto-Heal",icon:e.jsx(dt,{size:16}),children:e.jsx(ee,{label:"Locator repair",desc:`Overrides the workspace setting (currently ${K==="off"?"Off":K==="suggest"?"Suggest":K==="auto"?"Auto":"…"}) for this suite only — a suite can enable healing even when the workspace default is off.`,children:e.jsx("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 overflow-hidden",children:["inherit","off","suggest","auto"].map((S,B)=>e.jsx("button",{type:"button",onClick:()=>J(S),className:`px-3 py-1.5 text-xs font-medium transition-colors capitalize ${B>0?"border-l border-white/10":""} ${w===S?"bg-purple-500/15 text-purple-600 dark:text-purple-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,"aria-pressed":w===S,children:S==="inherit"&&K?`inherit (${K})`:S},S))})})}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-2 px-3 py-2 text-sm rounded-lg text-red-400 border border-red-500/30 hover:bg-red-500/10",children:[e.jsx(Sa,{size:14})," Delete suite"]}),e.jsxs("button",{onClick:y,disabled:r.isPending,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-50",children:[r.isPending?e.jsx(pe,{size:14,className:"animate-spin"}):null," Save changes"]})]})]})}function Rr({suite:s}){var u,x;const{update:t}=Re(),{toast:r}=ms(),[a,n]=o.useState(!!((u=s.schedule)!=null&&u.enabled)),[l,m]=o.useState(((x=s.schedule)==null?void 0:x.cron)||"0 2 * * *"),i=()=>t.mutate({id:s.id,patch:{schedule:a?{enabled:!0,cron:l}:null}},{onSuccess:()=>r("success",a?"Schedule saved":"Schedule turned off"),onError:()=>r("error","Failed to save schedule")});return e.jsxs("div",{className:"max-w-3xl mx-auto space-y-4 pb-2",children:[e.jsx(Pe,{title:"Schedule",icon:e.jsx(_e,{size:16}),children:e.jsx(ee,{label:"Run on a schedule",desc:"Runs the suite automatically on a recurring schedule.",alignTop:a,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ve,{on:a,onChange:n}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(_a,{value:l,onChange:m}),e.jsx("p",{className:"text-[13px] text-gray-500",children:"Uses each test's saved default run options."})]})]})})}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsxs("button",{onClick:i,disabled:t.isPending,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-50",children:[t.isPending?e.jsx(pe,{size:14,className:"animate-spin"}):null," Save changes"]})})]})}function Pr({value:s,onChange:t}){const[r,a]=o.useState(""),n=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,l=i=>{const u=i.split(/[,;\s]+/).map(c=>c.trim()).filter(Boolean);if(!u.length)return;const x=[...s];for(const c of u)n.test(c)&&!x.includes(c)&&x.push(c);t(x),a("")},m=i=>{i.key==="Enter"||i.key===","||i.key===";"?(i.preventDefault(),l(r)):i.key==="Backspace"&&!r&&s.length&&t(s.slice(0,-1))};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 bg-surface-2 border border-white/10 rounded-lg px-2 py-1.5 min-h-[40px] focus-within:border-brand-500/50",children:[s.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-surface-3 border border-white/15 rounded-md pl-2 pr-1 py-0.5 text-xs text-gray-100",children:[i,e.jsx("button",{onClick:()=>t(s.filter(u=>u!==i)),title:"Remove",className:"text-gray-500 hover:text-red-400",children:e.jsx(Se,{size:12})})]},i)),e.jsx("input",{value:r,onChange:i=>a(i.target.value),onKeyDown:m,onBlur:()=>l(r),placeholder:s.length?"Add another…":"alice@example.com — press Enter to add",className:"flex-1 min-w-[140px] bg-transparent text-sm text-gray-200 outline-none placeholder-gray-600 py-0.5"})]})}function Mr({suite:s}){var ae,D;const{update:t}=Re(),{toast:r}=ms(),a=s.notifications,[n,l]=o.useState(!!(a!=null&&a.enabled)),[m,i]=o.useState((a==null?void 0:a.applyTo)||"both"),[u,x]=o.useState((a==null?void 0:a.trigger)||"on_failure"),[c,p]=o.useState((a==null?void 0:a.thresholdPct)??80),[d,b]=o.useState(!!(a!=null&&a.email)),[g,P]=o.useState(!!(a!=null&&a.slack)),[C,N]=o.useState((a==null?void 0:a.emailRecipients)||[]),[O,R]=o.useState(!1),{data:v}=Ke({queryKey:["connectors"],queryFn:sa,staleTime:3e4}),f=Array.isArray(v)?v:(v==null?void 0:v.connectors)||[],M=f.find(z=>z.type==="email"&&z.status==="connected"),A=f.find(z=>z.type==="slack"&&z.status==="connected"),W=!M&&!A,L="w-full bg-surface-2 border border-white/10 rounded-lg px-3.5 py-2.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50",_=()=>({enabled:n,applyTo:m,trigger:u,thresholdPct:u==="threshold"?c:void 0,email:d,slack:g,emailRecipients:C}),X=()=>t.mutate({id:s.id,patch:{notifications:_()}},{onSuccess:()=>r("success",n?"Notifications saved":"Notifications turned off"),onError:()=>r("error","Failed to save notifications")}),U=async()=>{if(!d&&!g){r("error","Enable email or Slack first");return}R(!0);try{const z=await ta(s.id,_());z.sent>0?r("success",`Test notification sent (${z.sent})`):r("error",z.error||"No connected connector received the test")}catch(z){r("error",(z==null?void 0:z.message)||"Failed to send test notification")}finally{R(!1)}},q=(z,F)=>e.jsx("button",{onClick:()=>i(z),className:`flex-1 px-2 py-2 text-xs ${m===z?"bg-brand-500/15 text-brand-300":"text-gray-400"} ${z!=="manual"?"border-l border-white/10":""}`,children:F});return e.jsxs("div",{className:"max-w-3xl mx-auto space-y-4 pb-2",children:[W&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl px-4 py-3 text-[13px] text-amber-200 flex items-start gap-2.5",children:[e.jsx(ks,{size:15,className:"flex-shrink-0 mt-0.5"}),e.jsxs("span",{children:["No email or Slack connector is connected. Set one up in ",e.jsx("span",{className:"font-medium",children:"Settings → Connectors"})," to receive notifications. You can still configure and save your preferences here."]})]}),e.jsxs(Pe,{title:"Notifications",icon:e.jsx(ks,{size:16}),children:[e.jsx(ee,{label:"Enable notifications",desc:"Send a summary when this suite finishes a run.",children:e.jsx(Ve,{on:n,onChange:l})}),e.jsx(ee,{label:"Apply to",desc:"Which runs should notify.",children:e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden max-w-xs",children:[q("manual","Manual"),q("scheduled","Scheduled"),q("both","Both")]})}),e.jsx(ee,{label:"When to send",desc:"Choose the condition that triggers a notification.",alignTop:!0,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("select",{value:u,onChange:z=>x(z.target.value),className:`${L} max-w-xs`,children:[e.jsx("option",{value:"on_failure",children:"On failure"}),e.jsx("option",{value:"always",children:"On every completion"}),e.jsx("option",{value:"on_status_change",children:"On status change (pass ↔ fail)"}),e.jsx("option",{value:"threshold",children:"When pass-rate drops below…"})]}),u==="threshold"&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-300",children:[e.jsx("input",{type:"number",min:0,max:100,value:c,onChange:z=>p(Math.max(0,Math.min(100,Number(z.target.value)||0))),className:"w-20 bg-surface-2 border border-white/10 rounded-lg px-2.5 py-1.5 text-sm outline-none focus:border-brand-500/50"}),e.jsx("span",{className:"text-gray-500",children:"% pass rate"})]})]})})]}),e.jsxs(Pe,{title:"Channels",icon:e.jsx(_s,{size:16}),children:[e.jsx(ee,{label:"Email",desc:M?e.jsxs("span",{className:"text-emerald-400",children:["Connected: ",((ae=M.config)==null?void 0:ae.email)||"email connector"]}):"No email connector connected.",alignTop:d,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(za,{size:14,className:"text-gray-400"}),e.jsx(Ve,{on:d,onChange:b})]}),d&&e.jsx(Pr,{value:C,onChange:N})]})}),e.jsx(ee,{label:"Slack",desc:A?e.jsxs("span",{className:"text-emerald-400",children:["Connected: ",((D=A.config)==null?void 0:D.channelName)||A.name||"Slack webhook"]}):"No Slack connector connected.",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ta,{size:14,className:"text-gray-400"}),e.jsx(Ve,{on:g,onChange:P})]})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-1",children:[e.jsxs("button",{onClick:U,disabled:O||!d&&!g,className:"inline-flex items-center gap-2 px-3 py-2 text-sm rounded-lg text-gray-200 border border-white/10 hover:bg-surface-2 disabled:opacity-50",children:[O?e.jsx(pe,{size:14,className:"animate-spin"}):e.jsx(_s,{size:14})," Send test notification"]}),e.jsxs("button",{onClick:X,disabled:t.isPending,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg text-brand-200 bg-brand-500/20 border border-brand-500/40 hover:bg-brand-500/30 disabled:opacity-50",children:[t.isPending?e.jsx(pe,{size:14,className:"animate-spin"}):null," Save changes"]})]})]})}function Lr({suite:s,onBack:t}){var N,O,R;const r=ht(),{run:a,cancel:n,remove:l}=Re(),[m,i]=$s("stab",["tests","history","settings","schedule","notifications"],"tests"),[u,x]=o.useState(!1),c=((N=s.lastRun)==null?void 0:N.status)==="running",{data:p}=jt(s.id,m==="tests"||c),d=(p==null?void 0:p.run)??s.lastRun,b=(p==null?void 0:p.running)??c,g=()=>{r.invalidateQueries({queryKey:["suite-run-status",s.id]}),setTimeout(()=>r.invalidateQueries({queryKey:["suites"]}),500)},P=d?d.status==="running"?"bg-brand-500/12 text-brand-300":d.summary.failed>0?"bg-red-500/12 text-red-400":"bg-emerald-500/12 text-emerald-400":"bg-surface-2 text-gray-500",C=[{id:"tests",label:"Tests",n:s.tests.length,icon:e.jsx(Ae,{size:14})},{id:"history",label:"History",n:((O=s.history)==null?void 0:O.length)||0,icon:e.jsx(mt,{size:14})},{id:"settings",label:"Settings",icon:e.jsx(va,{size:14})},{id:"schedule",label:"Schedule",icon:e.jsx(_e,{size:14})},{id:"notifications",label:"Notifications",icon:e.jsx(ks,{size:14})}];return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-2.5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("button",{onClick:t,className:"inline-flex items-center gap-1.5 px-2.5 py-1.5 text-sm rounded-lg bg-surface-2 text-gray-400 border border-white/5 hover:text-gray-200 transition-colors",children:[e.jsx(Ms,{size:14})," Suites"]}),e.jsx("span",{className:"text-gray-600",children:"/"}),e.jsx("span",{className:"text-sm text-gray-300 truncate",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${P}`,children:e.jsx(Ae,{size:22})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[17px] font-bold text-gray-100 truncate",children:s.name}),((R=s.schedule)==null?void 0:R.enabled)&&e.jsxs("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded bg-brand-500/10 text-brand-300 border border-brand-500/20 inline-flex items-center gap-1",children:[e.jsx(_e,{size:11})," Scheduled"]})]}),s.description&&e.jsx("div",{className:"text-[13px] text-gray-400 mt-1 truncate",title:s.description,children:s.description}),e.jsx("div",{className:"text-[13px] text-gray-500 mt-1 flex items-center gap-2 flex-wrap",children:d?e.jsxs(e.Fragment,{children:[d.status==="running"?"Running…":`Last run ${kt(d.finishedAt)}`,d.target==="cloud"?e.jsxs("span",{className:"text-cyan-400 inline-flex items-center gap-1.5",children:["· ",e.jsx(ke,{size:13})," Cloud",d.cloudProvider?` · ${d.cloudProvider}`:""]}):e.jsxs("span",{className:"text-gray-500 inline-flex items-center gap-1.5",children:["· ",e.jsx(Ee,{size:13})," Local"]}),e.jsxs("span",{children:["· ×",d.concurrency]})]}):e.jsxs(e.Fragment,{children:[s.tests.length," test",s.tests.length===1?"":"s"," · never run"]})})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(St,{suite:s,liveRun:d,isRunning:b,size:"md",onRun:v=>a.mutate({id:s.id,options:v},{onSuccess:()=>{i("tests"),g()}}),onCancel:()=>n.mutate(s.id,{onSuccess:g})})})]}),e.jsx("div",{className:"flex items-center px-5 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:C.map(v=>e.jsxs("button",{onClick:()=>i(v.id),className:`px-4 py-2.5 text-[13.5px] font-medium border-b-2 transition-colors inline-flex items-center gap-1.5 ${m===v.id?"text-gray-100 border-brand-400 font-semibold":"text-gray-500 border-transparent hover:text-gray-300"}`,children:[e.jsx("span",{className:m===v.id?"text-brand-400":"",children:v.icon}),v.label,v.n!==void 0&&e.jsx("span",{className:"text-[11px] text-gray-600 ml-0.5",children:v.n})]},v.id))}),e.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4 bg-surface-0",children:[m==="tests"&&e.jsx(Sr,{suite:s,liveRun:d}),m==="history"&&e.jsx(Tr,{suite:s}),m==="settings"&&e.jsx($r,{suite:s,onDelete:()=>x(!0)}),m==="schedule"&&e.jsx(Rr,{suite:s}),m==="notifications"&&e.jsx(Mr,{suite:s})]}),e.jsx(yt,{open:u,title:"Delete suite",description:`Delete "${s.name}"? This removes the suite and its run history. The tests themselves are not affected.`,confirmLabel:"Delete suite",onCancel:()=>x(!1),onConfirm:()=>{x(!1),l.mutate(s.id,{onSuccess:t})}})]})}function Ar(){const{data:s,isLoading:t}=bt(),r=o.useMemo(()=>(s==null?void 0:s.suites)??[],[s]),[a]=ls("suite"),n=ot(),[l,m]=o.useState(""),i=r.find(c=>c.id===a);if(o.useEffect(()=>{a&&!t&&!i&&n({suite:null,stab:null})},[a,i,t,n]),i)return e.jsx(Lr,{suite:i,onBack:()=>n({suite:null,stab:null})});const u=l.trim()?r.filter(c=>c.name.toLowerCase().includes(l.trim().toLowerCase())):r,x=r.filter(c=>{var p;return((p=c.lastRun)==null?void 0:p.status)==="running"}).length;return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(Ae,{size:22,className:"text-brand-400 flex-shrink-0"}),e.jsx("h2",{className:"text-xl font-bold text-gray-100 flex-shrink-0",children:"Suites"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[r.length," suite",r.length===1?"":"s",x>0?` · ${x} running`:""]}),e.jsx("div",{className:"ml-auto flex items-center gap-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(Ge,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:l,onChange:c=>m(c.target.value),placeholder:"Search suites…",className:"w-56 bg-surface-2 border border-white/10 rounded-xl pl-9 pr-3 py-1.5 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50"})]})})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"px-5 py-5 space-y-3",children:t?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-10 justify-center",children:[e.jsx(pe,{size:16,className:"animate-spin"})," Loading suites…"]}):r.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center text-gray-500",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center mb-3",children:e.jsx(Ae,{size:22})}),e.jsx("p",{className:"text-sm text-gray-400",children:"No suites yet."}),e.jsxs("p",{className:"text-xs text-gray-600 mt-1 max-w-sm",children:["Go to the ",e.jsx("span",{className:"text-gray-400",children:"Tests"})," tab, select tests, and click ",e.jsx("span",{className:"text-brand-300",children:"+ Suite"})," to create one."]})]}):u.length===0?e.jsxs("div",{className:"text-sm text-gray-600 py-10 text-center",children:["No suites match “",l,"”."]}):u.map(c=>e.jsx(Cr,{suite:c,onOpen:()=>n({suite:c.id,stab:null})},c.id))})})]})}function Er({tests:s,onClose:t,onDone:r}){const{data:a}=bt(),{create:n,addTests:l}=Re(),m=o.useMemo(()=>(a==null?void 0:a.suites)??[],[a]),[i,u]=o.useState("new"),[x,c]=o.useState(`Suite (${s.length} test${s.length===1?"":"s"})`),[p,d]=o.useState(""),[b,g]=o.useState(null),P=p.trim()?m.filter(v=>v.name.toLowerCase().includes(p.trim().toLowerCase())):m,C=n.isPending||l.isPending,N=async()=>{if(s.length!==0)try{if(i==="new"){if(!x.trim())return;const v=await n.mutateAsync({name:x.trim(),tests:s});r(v.id)}else{if(!b)return;await l.mutateAsync({id:b,tests:s}),r(b)}}catch{}},O="w-full bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50",R=i==="new"?!!x.trim():!!b;return at.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:t}),e.jsxs("div",{className:"relative z-10 w-full max-w-md rounded-2xl bg-surface-1 border border-white/10 shadow-2xl flex flex-col max-h-[80vh]",children:[e.jsxs("div",{className:"flex items-center gap-2 px-5 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ae,{size:17,className:"text-brand-400"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100 leading-tight",children:"Add to suite"}),e.jsxs("p",{className:"text-xs text-gray-500",children:[s.length," test",s.length===1?"":"s"," selected"]})]}),e.jsx("button",{onClick:t,className:"ml-auto text-gray-500 hover:text-gray-300",children:e.jsx(Se,{size:18})})]}),e.jsx("div",{className:"px-5 pt-4",children:e.jsxs("div",{className:"flex rounded-lg border border-white/10 overflow-hidden",children:[e.jsxs("button",{onClick:()=>u("new"),className:`flex-1 px-3 py-2 text-sm font-medium inline-flex items-center justify-center gap-1.5 ${i==="new"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(Ae,{size:13})," Create new"]}),e.jsxs("button",{onClick:()=>u("existing"),disabled:m.length===0,className:`flex-1 px-3 py-2 text-sm font-medium inline-flex items-center justify-center gap-1.5 border-l border-white/10 disabled:opacity-40 ${i==="existing"?"bg-brand-500/15 text-brand-300":"text-gray-400 hover:text-gray-200"}`,children:[e.jsx(Ls,{size:13})," Add to existing"]})]})}),e.jsx("div",{className:"px-5 py-4 flex-1 min-h-0 flex flex-col",children:i==="new"?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Suite name"}),e.jsx("input",{value:x,onChange:v=>c(v.target.value),autoFocus:!0,onKeyDown:v=>{v.key==="Enter"&&R&&N()},className:O})]}):m.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-6 text-center",children:"No existing suites yet. Switch to “Create new”."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative mb-2 flex-shrink-0",children:[e.jsx(Ge,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:v=>d(v.target.value),placeholder:"Search suites…",autoFocus:!0,className:`${O} pl-9`})]}),e.jsx("div",{className:"border border-white/5 rounded-lg overflow-auto h-56 flex-shrink-0",children:P.length===0?e.jsxs("p",{className:"text-sm text-gray-600 py-8 text-center",children:["No suites match “",p,"”."]}):P.map(v=>{const f=b===v.id;return e.jsxs("button",{onClick:()=>g(f?null:v.id),className:`w-full flex items-center gap-2.5 px-3 py-2.5 border-b border-white/5 last:border-0 text-left transition-colors ${f?"bg-brand-500/15":"hover:bg-surface-2/40"}`,children:[e.jsx("span",{className:`w-4 h-4 rounded-full border flex items-center justify-center flex-shrink-0 ${f?"border-brand-400 bg-brand-500/30":"border-white/15"}`,children:f&&e.jsx(us,{size:11,className:"text-brand-200"})}),v.color&&e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:v.color}}),e.jsx("span",{className:"text-sm text-gray-200 truncate flex-1",children:v.name}),e.jsxs("span",{className:"text-[11px] text-gray-500 flex-shrink-0",children:[v.tests.length," test",v.tests.length===1?"":"s"]})]},v.id)})})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-white/5",children:[e.jsxs("button",{onClick:N,disabled:!R||C,className:"flex-1 inline-flex items-center justify-center gap-1.5 px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 disabled:opacity-40",children:[C&&e.jsx(pe,{size:14,className:"animate-spin"}),i==="new"?"Create suite":"Add to suite"]}),e.jsx("button",{onClick:t,className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200",children:"Cancel"})]})]})]}),document.body)}const st=s=>s.replace(/\\/g,"/").toLowerCase(),ws=s=>s.toLowerCase().replace(/\s*\[[^\]]*\]\s*$/,"").replace(/[\s_\-.:›>·|/\\]+/g,"");function Or(s,t,r){if(!t||s.length===0)return null;const a=st(t),n=s.filter(m=>{const i=st(m.file);return i===a||i.endsWith(`/${a}`)||a.endsWith(`/${i}`)||i.endsWith(a)||a.endsWith(i)});if(r){const m=r.toLowerCase(),i=ws(r),u=[x=>x.name.toLowerCase()===m,x=>!!i&&ws(x.name)===i,x=>{const c=ws(x.name);return c.length>=6&&i.length>=6&&(i.endsWith(c)||c.endsWith(i))}];for(const x of[n,s])for(const c of u)for(const p of x){const d=p.tests.find(c);if(d)return{kind:"test",test:d,suite:p}}return n.length?{kind:"missing",testName:r,file:n[0].file,suites:n}:null}const l=n[0];return l!=null&&l.tests[0]?{kind:"test",test:l.tests[0],suite:l}:null}const Fr=!1;function tt({view:s,setView:t}){const r=(a,n,l)=>e.jsxs("button",{onClick:()=>t(a),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${s===a?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[l,n]});return e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[r("tests","Tests",e.jsx(xs,{size:15})),r("suites","Suites",e.jsx(Ae,{size:15}))]})}function Ir(s){let t=0,r=0,a=0,n=0;for(const i of s)for(const u of i.tests)t++,u.runCount===0?n++:u.lastStatus==="passed"?r++:u.lastStatus==="failed"&&a++;const l=t-n,m=l>0?Math.round(r/l*100*10)/10:0;return{total:t,passed:r,failed:a,noRun:n,passRate:m}}function Dr(s){const t=new Set;for(const r of s)t.add(r.framework);return Array.from(t).sort()}function gn(){const{subscribe:s}=Bt(),{mode:t}=Ze(),r=t==="mobile"?ra:void 0,{data:a,isLoading:n,error:l,refetch:m}=nt(),[i]=ls("file"),[u]=ls("test"),[x,,c]=ls("lifecycle"),p=ot(),[d,b]=o.useState("all"),[g,P]=o.useState("all"),[C,N]=o.useState("all");o.useEffect(()=>{x&&cs.includes(x)&&(N(x),c())},[x,c]);const[O,R]=o.useState(""),v=o.useDeferredValue(O),[f,M]=o.useState([]),[A,W]=o.useState(!1),[L,_]=o.useState(!1),[X,U]=o.useState("name"),[q,ae]=o.useState("asc"),[D,z]=o.useState(new Set),[F,w]=$s("view",["tests","suites"],"tests"),[J,Q]=o.useState(null),K=Re(),[ie,re]=o.useState(!1),[le,oe]=o.useState(!1),[y,$]=o.useState([]),[S,B]=o.useState(!1),Z=(a==null?void 0:a.suites)||[],se=o.useMemo(()=>Or(Z,i,u),[i,u,Z]),ge=(se==null?void 0:se.kind)==="missing"?se:null,Y=ge?ge.suites:Z,te=o.useMemo(()=>Ir(Y),[Y]),es=o.useMemo(()=>Dr(Y),[Y]),ps=o.useMemo(()=>{const h=[];for(const j of Y)for(const k of j.tests)typeof k.line=="number"&&h.push({testKey:os(j.file,k.name),file:j.file,startLine:k.line,endLine:k.endLine});return h},[Y]),{data:je}=Kt(ps),{data:We}=Ss(),hs=!!(We!=null&&We.hideNames),ye=lt(),Oe=o.useMemo(()=>{var j;const h=new Map;if(je)for(const k of Object.values(je)){const I=(j=k.owner)==null?void 0:j.name;I&&h.set(I,(h.get(I)??0)+1)}return[...h.entries()].map(([k,I])=>({name:k,count:I})).sort((k,I)=>I.count-k.count)},[je]),Fe=o.useCallback(h=>{$(j=>j.includes(h)?j.filter(k=>k!==h):[...j,h])},[]),Ie=o.useCallback((h,j)=>{var k,I;return(I=(k=je==null?void 0:je[os(h,j)])==null?void 0:k.owner)==null?void 0:I.name},[je]),Qe=d!=="all"||g!=="all"||v.trim()!==""||f.length>0||y.length>0||C!=="all",he=o.useMemo(()=>{var we;if(!Qe)return te;let h=0,j=0,k=0,I=0;for(const G of Y)if(!(g!=="all"&&G.framework!==g)){for(const de of G.tests)if(!(d==="passed"&&de.lastStatus!=="passed")&&!(d==="failed"&&de.lastStatus!=="failed")&&!(d==="norun"&&de.runCount>0)&&!(f.length>0&&!f.some(ue=>{var Be;return(Be=de.tags)==null?void 0:Be.includes(ue)}))&&!(y.length>0&&!y.includes(Ie(G.file,de.name)??""))&&!(C!=="all"&&(ye.map[Vs(G.file,de.name)]||"draft")!==C)){if(v.trim()){const ue=v.toLowerCase();if(!Ce(de.name,v)&&!Ce(G.name,v)&&!((we=de.tags)!=null&&we.some(Be=>Be.toLowerCase().includes(ue))))continue}h++,de.runCount===0?I++:de.lastStatus==="passed"?j++:de.lastStatus==="failed"&&k++}}const me=h-I,ce=me>0?Math.round(j/me*100*10)/10:0;return{total:h,passed:j,failed:k,noRun:I,passRate:ce}},[Y,d,g,v,f,y,Ie,Qe,te,C,ye.map]),T=o.useMemo(()=>{const h=new Map;for(const j of Y)for(const k of j.tests)if(k.tags)for(const I of k.tags)h.set(I,(h.get(I)||0)+1);return Array.from(h.entries()).sort((j,k)=>k[1]-j[1]).map(([j,k])=>({tag:j,count:k}))},[Y]),H=o.useCallback(()=>{var j;const h=[];for(const k of Y)for(const I of k.tests)if(!(g!=="all"&&k.framework!==g)&&!(d==="passed"&&I.lastStatus!=="passed")&&!(d==="failed"&&I.lastStatus!=="failed")&&!(d==="norun"&&I.runCount>0)&&!(f.length>0&&!f.some(me=>{var ce;return(ce=I.tags)==null?void 0:ce.includes(me)}))&&!(y.length>0&&!y.includes(Ie(k.file,I.name)??""))&&!(C!=="all"&&(ye.map[Vs(k.file,I.name)]||"draft")!==C)){if(v.trim()){const me=v.toLowerCase();if(!Ce(I.name,v)&&!Ce(k.name,v)&&!((j=I.tags)!=null&&j.some(ce=>ce.toLowerCase().includes(me))))continue}h.push({...I,suiteName:k.name,suiteFile:k.file})}return h},[Y,d,g,f,y,Ie,v,C,ye.map]),E=o.useCallback(h=>{X===h?ae(j=>j==="asc"?"desc":"asc"):(U(h),ae("asc"))},[X]),De=o.useCallback(h=>{M(j=>j.includes(h)?j.filter(k=>k!==h):[...j,h])},[]),$t=o.useCallback(h=>{z(j=>{const k=new Set(j);return k.has(h)?k.delete(h):k.add(h),k})},[]),Rt=o.useCallback(h=>{z(new Set(h.map(j=>j.key)))},[]),Pt=o.useCallback(()=>z(new Set),[]),fe=o.useCallback(()=>{const h=H();if(D.size===0)return h;const j=new Set(Array.from(D).map(k=>{const I=k.lastIndexOf("::"),me=k.slice(0,I),ce=me.indexOf("::");return`${me.slice(0,ce)}\0${me.slice(ce+2)}`}));return h.filter(k=>j.has(`${k.suiteFile}\0${k.name}`))},[H,D]),Is=o.useMemo(()=>D.size>0?fe().length:H().length,[D,fe,H]),Mt=o.useCallback(async h=>{const j=fe().map(k=>({file:k.suiteFile,name:k.name}));j.length!==0&&await ye.setBulk(j,h)},[fe,ye]),Lt=o.useCallback(()=>{const h=fe().map(j=>({file:j.suiteFile,name:j.name,framework:j.framework,line:j.line,suite:j.suiteName,command:j.runCommand}));h.length!==0&&Q(h)},[fe]),At=o.useCallback(async()=>{const h=fe();if(h.length===0)return;const j=qa(h);try{await ns({command:j})}catch{}z(new Set)},[fe]),Et=o.useCallback(()=>{const h=fe(),j=["Test Name","Suite","File","Framework","Status","Run Count","Pass Count","Fail Count","Pass Rate","Tags","Description","Modifiers"],k=h.map(G=>[G.name,G.suiteName,G.suiteFile,G.framework,G.lastStatus||"no run",G.runCount,G.passCount,G.failCount,G.runCount>0?Math.round(G.passCount/G.runCount*100)+"%":"-",(G.tags||[]).join("; "),G.description||"",(G.modifiers||[]).join("; ")]),I=[j,...k].map(G=>G.map(de=>{const ue=String(de);return ue.includes(",")||ue.includes('"')||ue.includes(`
|
|
6
|
-
`)?`"${ue.replace(/"/g,'""')}"`:ue}).join(",")).join(`
|
|
7
|
-
`),me=new Blob([I],{type:"text/csv"}),ce=URL.createObjectURL(me),we=document.createElement("a");we.href=ce,we.download=`testver-tests-${new Date().toISOString().slice(0,10)}.csv`,we.click(),URL.revokeObjectURL(ce),re(!1)},[fe]),Ot=o.useCallback(async()=>{const h=fe(),j=[],k=h.map(V=>({"Test Name":V.name,Suite:V.suiteName,File:V.suiteFile,Framework:V.framework,Status:V.lastStatus||"no run","Run Count":V.runCount,"Pass Count":V.passCount,"Fail Count":V.failCount,"Pass Rate":V.runCount>0?`${Math.round(V.passCount/V.runCount*100)}%`:"-",Tags:(V.tags||[]).join(", "),Description:V.description||"",Modifiers:(V.modifiers||[]).join(", ")}));j.push({name:"Tests",rows:ys(k)});const I=h.filter(V=>V.lastStatus==="passed").length,me=h.filter(V=>V.lastStatus==="failed").length,ce=h.filter(V=>V.runCount===0).length,we=h.length-ce,G=we>0?Math.round(I/we*100*10)/10:0,de=[{Metric:"Total Tests",Value:h.length},{Metric:"Passed",Value:I},{Metric:"Failed",Value:me},{Metric:"No Run",Value:ce},{Metric:"Pass Rate",Value:`${G}%`},{Metric:"Frameworks",Value:[...new Set(h.map(V=>V.framework))].join(", ")}];j.push({name:"Summary",rows:ys(de)});const ue=new Map;for(const V of h)if(V.tags)for(const Ue of V.tags)ue.set(Ue,(ue.get(Ue)||0)+1);if(ue.size>0){const V=Array.from(ue.entries()).sort((Ue,js)=>js[1]-Ue[1]).map(([Ue,js])=>({Tag:Ue,"Test Count":js}));j.push({name:"Tags",rows:ys(V)})}const Be=await Ut(j),Us=URL.createObjectURL(Be),bs=document.createElement("a");bs.href=Us,bs.download=`testver-tests-${new Date().toISOString().slice(0,10)}.xlsx`,bs.click(),URL.revokeObjectURL(Us),re(!1)},[fe]),gs=(se==null?void 0:se.kind)==="test"?se:null,Ft=o.useCallback((h,j)=>{p({file:j.file,test:h.name})},[p]),Ds=o.useCallback(()=>{p({file:null,test:null,detail:null})},[p]),It=o.useCallback(async(h,j)=>{h.runCommand&&p({file:j.file,test:h.name})},[p]),Bs=Ts(),Dt=o.useCallback(h=>Bs(async()=>{try{if(h.file)await ns({files:[h.file],framework:h.framework});else{const j=h.tests.find(k=>k.runCommand);j!=null&&j.runCommand&&await ns({command:j.runCommand})}}catch{}},{files:h.file?[h.file]:[]}),[Bs]);return F==="suites"?e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(tt,{view:F,setView:w}),e.jsx(Ar,{})]}):n?e.jsx(aa,{text:"Scanning test files..."}):l?e.jsx(Gs,{title:"Error loading tests",description:String(l),icon:e.jsx(qs,{size:20})}):gs?e.jsx(lr,{test:gs.test,suite:gs.suite,subscribe:s,onBack:Ds}):e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(tt,{view:F,setView:w}),ge&&e.jsxs("div",{role:"status",className:"flex items-start gap-3 px-5 py-3 border-b border-amber-500/30 bg-amber-500/10 text-sm flex-shrink-0",children:[e.jsx(Xe,{size:16,className:"text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0 text-gray-300",children:[e.jsxs("span",{className:"font-semibold text-gray-100",children:["“",be(ge.testName),"”"]})," is no longer in"," ",e.jsx("span",{className:"font-mono text-xs",children:ge.file})," — it may have been renamed or removed."," ","Showing the ",ge.suites.reduce((h,j)=>h+j.tests.length,0)," tests in this file."]}),e.jsx("button",{onClick:Ds,className:"flex-shrink-0 px-3 py-1.5 rounded-lg border border-white/10 text-gray-300 text-xs font-medium hover:bg-white/5 transition-colors",children:"Show all tests"})]}),e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(xs,{size:22,className:"text-brand-400 flex-shrink-0"}),e.jsx("h2",{className:"text-xl font-bold text-gray-100 flex-shrink-0",children:"Tests"}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-4",children:[e.jsx(as,{label:"All",active:d==="all",onClick:()=>b("all")}),e.jsx(as,{label:"Passed",icon:e.jsx(xe,{size:12}),active:d==="passed",onClick:()=>b("passed"),activeColor:"text-emerald-300 bg-emerald-500/15 border-emerald-500/30"}),e.jsx(as,{label:"Failed",icon:e.jsx(ne,{size:12}),active:d==="failed",onClick:()=>b("failed"),activeColor:"text-red-300 bg-red-500/15 border-red-500/30"}),e.jsx(as,{label:"No Run",icon:e.jsx($e,{size:12}),active:d==="norun",onClick:()=>b("norun"),activeColor:"text-gray-300 bg-gray-500/15 border-gray-500/30"})]}),es.length>1&&e.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[e.jsx($a,{size:13,className:"text-gray-600"}),e.jsxs("select",{value:g,onChange:h=>P(h.target.value),className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer",children:[e.jsx("option",{value:"all",children:"All Frameworks"}),es.map(h=>e.jsx("option",{value:h,children:h},h))]})]}),e.jsx("div",{className:"ml-2",children:e.jsx(Br,{value:C,onChange:N})}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[!hs&&Oe.length>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>B(h=>!h),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${y.length>0?"bg-brand-500/10 text-brand-300 border-brand-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:[e.jsx(Ra,{size:13}),"Owner",y.length>0?` (${y.length})`:"",e.jsx(Me,{size:11})]}),S&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>B(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-64 max-h-80 overflow-y-auto rounded-lg bg-surface-1 border border-white/10 shadow-xl py-1",children:[y.length>0&&e.jsxs("button",{onClick:()=>$([]),className:"w-full text-left px-3 py-1.5 text-[10px] text-gray-500 hover:text-gray-300 border-b border-white/5",children:["Clear (",y.length,")"]}),Oe.map(({name:h,count:j})=>{const k=y.includes(h);return e.jsxs("button",{onClick:()=>Fe(h),className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${k?"bg-brand-500/10 text-brand-300":"text-gray-300 hover:bg-white/5"}`,children:[e.jsx("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full bg-brand-500/20 text-brand-300 text-[9px] font-semibold uppercase flex-shrink-0",children:h.charAt(0)}),e.jsx("span",{className:"flex-1 truncate",children:h}),e.jsx("span",{className:"text-[10px] text-gray-500",children:j}),k&&e.jsx(xe,{size:12,className:"text-brand-400 flex-shrink-0"})]},h)})]})]})]}),T.length>0&&e.jsxs("button",{onClick:()=>_(h=>!h),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${L||f.length>0?"bg-cyan-500/10 text-cyan-300 border-cyan-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:text-gray-200"}`,children:[e.jsx(Ks,{size:13}),"Tags",f.length>0?` (${f.length})`:""]}),D.size>0&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>oe(h=>!h),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-brand-500/10 text-brand-300 border border-brand-500/30 hover:bg-brand-500/20 transition-colors",children:["Set status (",D.size,")",e.jsx(Me,{size:11,className:`transition-transform ${le?"rotate-180":""}`})]}),le&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>oe(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-44 rounded-lg bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-xl py-1",children:[e.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-brand-400 font-semibold uppercase tracking-wider border-b border-gray-100 dark:border-white/5",children:["Set ",D.size," test",D.size>1?"s":""," to"]}),cs.map(h=>e.jsxs("button",{onClick:()=>{oe(!1),Mt(h)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-sm hover:bg-black/5 dark:hover:bg-white/5 transition-colors",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ve[h].dot}`}),e.jsx("span",{className:ve[h].cls.split(" ").filter(j=>j.startsWith("text-")).join(" "),children:ve[h].label})]},h))]})]})]}),D.size>0&&e.jsxs("button",{onClick:Lt,disabled:K.create.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-brand-500/15 text-brand-300 border border-brand-500/30 hover:bg-brand-500/25 transition-colors disabled:opacity-50",title:"Save the selected tests as a runnable Suite",children:[e.jsx(Ls,{size:13})," Suite (",D.size,")"]}),J&&e.jsx(Er,{tests:J,onClose:()=>Q(null),onDone:()=>{Q(null),z(new Set),w("suites")}}),Fr,e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>re(!ie),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-400 hover:text-gray-200 border border-white/5 transition-colors",children:[e.jsx(Pa,{size:13}),"Export",e.jsx(Me,{size:11})]}),ie&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>re(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 w-52 rounded-lg bg-surface-1 border border-white/10 shadow-xl py-1",children:[D.size>0&&e.jsxs("div",{className:"px-3 py-1.5 text-[10px] text-brand-400 font-semibold uppercase tracking-wider border-b border-white/5",children:[D.size," selected"]}),e.jsxs("button",{onClick:Et,className:"w-full text-left px-3 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors",children:["CSV (",Is," tests)"]}),e.jsxs("button",{onClick:()=>{Ot().catch(h=>console.error("[export] Excel export failed",h))},className:"w-full text-left px-3 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors",children:["Excel (",Is," tests)"]})]})]})]}),e.jsx("button",{onClick:()=>m(),className:"p-2 rounded-xl hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Refresh",children:e.jsx(Ma,{size:16})})]})]}),L&&T.length>0&&e.jsx("div",{className:"px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider mr-1",children:"Filter by tags:"}),T.map(({tag:h,count:j})=>{const k=f.includes(h);return e.jsxs("button",{onClick:()=>De(h),className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${k?"bg-cyan-500/20 text-cyan-300 border border-cyan-500/30":"bg-surface-2 text-gray-400 border border-white/5 hover:bg-white/5 hover:text-gray-300"}`,children:[h,e.jsxs("span",{className:`text-[10px] ${k?"text-cyan-400":"text-gray-600"}`,children:["(",j,")"]}),k&&e.jsx(Se,{size:9,className:"ml-0.5"})]},h)}),f.length>0&&e.jsx("button",{onClick:()=>M([]),className:"text-[10px] text-gray-500 hover:text-gray-300 ml-2",children:"Clear all"})]})}),!L&&f.length>0&&e.jsxs("div",{className:"px-5 py-2 border-b border-white/5 bg-surface-1/50 flex-shrink-0 flex items-center gap-1.5",children:[e.jsx(Ks,{size:11,className:"text-cyan-400 flex-shrink-0"}),f.map(h=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-cyan-500/15 text-cyan-300 border border-cyan-500/20 cursor-pointer hover:bg-cyan-500/25",onClick:()=>De(h),children:[h," ",e.jsx(Se,{size:8})]},h)),e.jsx("button",{onClick:()=>M([]),className:"text-[10px] text-gray-500 hover:text-gray-300 ml-1",children:"Clear"})]}),e.jsxs("div",{className:"flex items-stretch gap-2 px-4 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsx(rs,{label:"Total",value:he.total}),e.jsx(rs,{label:"Passed",value:he.passed,icon:e.jsx(xe,{size:11}),color:"text-emerald-400"}),e.jsx(rs,{label:"Failed",value:he.failed,icon:e.jsx(ne,{size:11}),color:"text-red-400"}),e.jsx(rs,{label:"No Run",value:he.noRun,icon:e.jsx($e,{size:11}),color:"text-gray-500"}),e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[e.jsx("span",{className:`text-[15px] font-bold ${he.passRate>=90?"text-emerald-400":he.passRate>=70?"text-amber-400":he.total===0?"text-gray-500":"text-red-400"}`,children:he.total>0?`${he.passRate}%`:"-"}),e.jsx("span",{className:"text-[10px] text-gray-500",children:"Pass Rate"})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:Y.length===0?e.jsx(Gs,{title:"No tests found",description:"No test files found in the project. Add test files (.spec.ts, .test.ts, .feature, test_*.py, *Test.java, etc.) to see them here.",icon:e.jsx(qs,{size:24})}):e.jsx(er,{suites:Y,statusFilter:d,frameworkFilter:g,searchQuery:O,tagFilters:f,sortField:X,sortDir:q,selectedTests:D,onSearchChange:R,onSelectTest:Ft,onRunTest:It,onRunSuite:Dt,runDisabledReason:r,onSortChange:E,onToggleSelect:$t,onSelectAll:Rt,onDeselectAll:Pt,onRunSelected:D.size>0?At:void 0,ownershipMap:je,ownerFilter:y,onOwnerClick:Fe,lifecycleStatusOf:ye.statusOf,onSetLifecycle:ye.setStatus,lifecycleFilter:C})})]})}function as({label:s,icon:t,active:r,onClick:a,activeColor:n}){return e.jsxs("button",{onClick:a,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium border transition-colors ${r?n||"text-brand-300 bg-brand-500/15 border-brand-500/30":"text-gray-500 bg-transparent border-transparent hover:text-gray-300 hover:bg-white/5"}`,children:[t,s]})}function rs({label:s,value:t,icon:r,color:a}){return e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-surface-2/50 border border-white/5",children:[r&&e.jsx("span",{className:a||"text-gray-400",children:r}),e.jsx("span",{className:`text-[15px] font-bold ${a||"text-gray-200"}`,children:t}),e.jsx("span",{className:"text-xs text-gray-500",children:s})]})}function Br({value:s,onChange:t}){const[r,a]=o.useState(!1),n=s==="all"?null:ve[s],l=s==="all"?"All Statuses":n.label,m=n?n.cls:"bg-white dark:bg-surface-2 text-gray-600 dark:text-gray-300 border border-gray-200 dark:border-white/10",i=(u,x,c,p)=>e.jsxs("button",{onClick:()=>{a(!1),t(u)},className:`w-full flex items-center gap-2 px-2.5 py-1.5 text-left text-[12px] transition-colors ${s===u?"bg-black/5 dark:bg-white/5":"hover:bg-black/5 dark:hover:bg-white/5"}`,children:[c?e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}):e.jsx("span",{className:"w-1.5 h-1.5"}),e.jsx("span",{className:p,children:x}),s===u&&e.jsx(xe,{size:12,className:"ml-auto text-brand-400"})]},u);return e.jsxs("span",{className:"relative inline-block",children:[e.jsxs("button",{onClick:()=>a(u=>!u),title:"Filter by script status",className:`inline-flex items-center gap-1 rounded-xl pl-3 pr-2 py-1.5 text-sm font-medium cursor-pointer transition-colors ${m}`,children:[l,e.jsx(Me,{size:14,className:`opacity-70 transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),e.jsxs("span",{className:"absolute left-0 top-full mt-1 z-50 w-40 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-xl py-1",children:[i("all","All Statuses",null,"text-gray-700 dark:text-gray-200"),cs.map(u=>i(u,ve[u].label,ve[u].dot,ve[u].cls.split(" ").filter(x=>x.startsWith("text-")).join(" ")))]})]})]})}export{gn as TestExplorerPage};
|