@testver/testver 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +3 -1
  2. package/bin/testver.js +8 -5
  3. package/dist/index.js +1483 -1086
  4. package/dist/vendor/grpc.cjs +24914 -0
  5. package/package.json +9 -4
  6. package/src/ui/static/assets/{AIPanel-D09Ni3a4.js → AIPanel-B_R-CbrF.js} +2 -2
  7. package/src/ui/static/assets/{AIRecordPanel-DZtUZnRe.js → AIRecordPanel-BRQWIU5h.js} +3 -3
  8. package/src/ui/static/assets/{AIStreamUI-BsxKziYG.js → AIStreamUI-C3D989_6.js} +3 -3
  9. package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-D3t2gPAA.js} +5 -5
  10. package/src/ui/static/assets/{APITestingPage-Cdc8EZz2.js → APITestingPage-Cmwkiiys.js} +1 -1
  11. package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CjEqKB-q.js} +1 -1
  12. package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +3 -0
  13. package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-64mYNK2v.js} +1 -1
  14. package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BQjOzQje.js} +1 -1
  15. package/src/ui/static/assets/{ChangesSummary-C-7oi_sx.js → ChangesSummary-CY_Vb27i.js} +2 -2
  16. package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-B1ezmnlE.js} +3 -3
  17. package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-t7mpeeSN.js} +1 -1
  18. package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-YMmCbiBk.js} +2 -2
  19. package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-Nk-K-_8I.js} +1 -1
  20. package/src/ui/static/assets/Dashboard-BDVxO2V4.js +1 -0
  21. package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-l8yGeCyR.js} +1 -1
  22. package/src/ui/static/assets/{DiffViewer-DPglzjPH.js → DiffViewer-BIU09a_i.js} +1 -1
  23. package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-D1T3JWUr.js} +1 -1
  24. package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-Dt5RhL-h.js} +1 -1
  25. package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-CrKgh_cB.js} +5 -5
  26. package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-_4nCEzkJ.js} +5 -5
  27. package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-BcR7IQi9.js} +1 -1
  28. package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-C2sP4_4h.js} +1 -1
  29. package/src/ui/static/assets/KpiTile-inmeEsy3.js +1 -0
  30. package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-D5BRe9jq.js} +1 -1
  31. package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-C5n6sHYi.js} +1 -1
  32. package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-0h-N2c6d.js} +1 -1
  33. package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-Bo_xekig.js} +1 -1
  34. package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-VGcmK167.js} +1 -1
  35. package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-B_1nPPxE.js} +1 -1
  36. package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +1 -0
  37. package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-y7tJNNFd.js} +1 -1
  38. package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-DbfGhRq0.js} +1 -1
  39. package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-WuRKtx_h.js} +1 -1
  40. package/src/ui/static/assets/ReportCard-G52Q6-2i.js +2 -0
  41. package/src/ui/static/assets/ReportFullView-Bt8UFP2J.js +1 -0
  42. package/src/ui/static/assets/ReportsPage-DMtDi73Q.js +48 -0
  43. package/src/ui/static/assets/ResultsPage-BI9jpK2N.js +115 -0
  44. package/src/ui/static/assets/RunState-ifC4zi6M.js +1 -0
  45. package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-C7vpCbck.js} +1 -1
  46. package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-7vHuvhQw.js} +1 -1
  47. package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-BYxYJNWl.js} +1 -1
  48. package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-DSISg7r7.js} +1 -1
  49. package/src/ui/static/assets/SharedReportView-BOqKGJmR.js +1 -0
  50. package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-CgqtYGBi.js} +1 -1
  51. package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +7 -0
  52. package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-wqYTKP7W.js} +2 -2
  53. package/src/ui/static/assets/TestPlansPage-DOKX9p6z.js +5 -0
  54. package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-DpMzl3h7.js} +1 -1
  55. package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-BxS0zi-p.js} +1 -1
  56. package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-B5d0uDU_.js} +2 -2
  57. package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-Bk0DFnFS.js} +17 -17
  58. package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-CdhhNa5G.js} +1 -1
  59. package/src/ui/static/assets/index-BYVxKLrT.js +47 -0
  60. package/src/ui/static/assets/index-C2KJt7SI.css +1 -0
  61. package/src/ui/static/assets/reportMeta-AKcU_qwq.js +1 -0
  62. package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DNkIctil.js} +1 -1
  63. package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-D5ysBBvz.js} +1 -1
  64. package/src/ui/static/assets/{useOwnership-eW6Egd7X.js → useOwnership-U0AfKBRo.js} +1 -1
  65. package/src/ui/static/assets/{useSuites-CvtMGakZ.js → useSuites-DyfN9HVv.js} +1 -1
  66. package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-DT8frjCK.js} +1 -1
  67. package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-OcwQaB1s.js} +1 -1
  68. package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-Xm4Bcx3u.js} +2 -2
  69. package/src/ui/static/assets/useTestResults-D5EwGIX9.js +1 -0
  70. package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-BKPiFyYV.js} +1 -1
  71. package/src/ui/static/index.html +3 -3
  72. package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
  73. package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
  74. package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
  75. package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
  76. package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
  77. package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
  78. package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
  79. package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
  80. package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
  81. package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
  82. package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
  83. package/src/ui/static/assets/index-B0klHYbO.css +0 -1
  84. package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
  85. package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
@@ -1,3 +1,3 @@
1
- import{u as zt,e as ot,r as o,j as e,b as Xe}from"./vendor-react-CTbHBddL.js";import{u as $t,a as Et,M as Tt,i as Lt,B as Mt,C as Rt,P as At}from"./vendor-flow-YGpC9U9I.js";import{u as Dt}from"./useTabParam-ChbOedP1.js";import{h as Ot}from"./aiHandoff-vhtR29Fh.js";import{f as fe}from"./formatTestName-BKd2Uqhs.js";import{a8 as ce,b as _,cm as Ye,cn as Ft,co as Pt,cp as It,cq as Je,cr as Bt,cs as Ut,ct as _t,cu as qt,cv as Kt,cw as Ht,cx as Vt,cy as Gt,cz as Wt,cA as Qt,cB as Zt,cC as Xt,cD as Yt,cE as Jt,cF as es,cG as ts,s as ss,cH as as,cI as rs,cJ as ns,cK as ls}from"./index-DtBWNlVD.js";import{a3 as I,o as me,an as is,_ as H,bh as we,S as ne,a6 as Fe,b6 as Ae,ad as de,R as ct,$ as be,al as ue,cB as os,a_ as dt,d as cs,ac as ds,v as oe,X as xe,b9 as xs,ar as ms,aB as xt,ae as mt,bz as Be,y as us,cC as Pe,b as ps,a9 as ut,r as Ue,aK as ge,cn as et,bA as tt,cD as hs,N as _e,bB as pt,ak as Ce,a7 as bs}from"./vendor-icons-B0wLOBoh.js";import{A as ht}from"./AIStreamUI-BsxKziYG.js";import"./vendor-charts-DWFQlmCz.js";import"./vendor-query-BrzmPFT3.js";const pe={file:{label:"file",cls:"text-sky-400 bg-sky-500/10 border-sky-500/20"},provider:{label:"inline",cls:"text-violet-400 bg-violet-500/10 border-violet-500/20"},fixture:{label:"fixture",cls:"text-purple-400 bg-purple-500/10 border-purple-500/20"},hardcoded:{label:"hardcoded",cls:"text-amber-400 bg-amber-500/10 border-amber-500/20"},dynamic:{label:"dynamic",cls:"text-rose-400 bg-rose-500/10 border-rose-500/20"}},bt="••••••••",ae=t=>t==="file"||t==="fixture";function De(t,r){window.open(`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`,"_blank","noopener")}function ft(t,r){window.open(`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`,"_blank","noopener")}function Oe(t){const r=(t.split(/[/\\]/).pop()||t).replace(/\.[^.]+$/,"");return r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_.]+/g," ").replace(/\s+/g," ").trim().split(" ").map(n=>n&&n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||r}function le({icon:t,value:r,label:n,tone:l}){const i=l==="amber"&&r>0?"bg-amber-500/10 border-amber-500/20":l==="rose"&&r>0?"bg-rose-500/10 border-rose-500/20":"bg-surface-2/50 border-white/5";return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${i}`,children:[e.jsx("span",{className:"text-gray-500",children:t}),e.jsx("span",{className:"text-lg font-bold text-gray-100 tabular-nums",children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:n})]})}const ye="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 disabled:opacity-50";function st({kv:t,revealed:r,onToggle:n,rk:l,tests:i,usageOpen:m,onToggleUsage:b}){const p=t.sensitive&&!r.has(l),a=t.usedBy||[],c=m.has(l);return e.jsxs("div",{className:"border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-2.5",children:[e.jsx("span",{className:"w-44 flex-shrink-0 font-mono text-[13px] text-gray-400 break-words",children:t.key}),e.jsx("span",{className:`flex-1 font-mono text-[13px] break-words whitespace-pre-wrap ${p?"text-gray-500":"text-gray-200"}`,children:p?bt:t.value||e.jsx("span",{className:"text-gray-600 italic",children:"empty"})}),a.length>0&&e.jsxs("button",{onClick:()=>b(l),className:`flex-shrink-0 inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-md border transition-colors ${c?"border-cyan-600/60 text-cyan-700 bg-cyan-500/15 dark:border-cyan-500/40 dark:text-cyan-300 dark:bg-cyan-500/10":"border-cyan-600/50 text-cyan-700 hover:bg-cyan-500/10 dark:border-cyan-500/30 dark:text-cyan-400 dark:hover:text-cyan-300"}`,title:c?"Hide tests":"Show tests that use this field",children:[e.jsx(Be,{size:11})," ",a.length," test",a.length!==1?"s":"",e.jsx(us,{size:12,className:`transition-transform ${c?"rotate-180":""}`})]}),t.sensitive?e.jsx("button",{onClick:()=>n(l),className:"flex-shrink-0 text-gray-500 hover:text-amber-300 mt-0.5",title:p?"Reveal":"Hide",children:p?e.jsx(mt,{size:14}):e.jsx(de,{size:14})}):e.jsx("span",{className:"flex-shrink-0 text-[10px] text-gray-600 mt-1 w-9 text-right",children:"plain"})]}),c&&a.length>0&&e.jsx("div",{className:"px-3.5 pb-2.5 pl-[12.5rem] space-y-0.5",children:a.map(y=>{const h=i.find(u=>u.id===y);return h?e.jsxs("button",{onClick:()=>ft(h.file,h.name),className:"flex items-center gap-1.5 w-full text-left text-xs text-gray-400 hover:text-cyan-300 truncate",children:[e.jsx(we,{size:12,className:"flex-shrink-0 text-gray-600"}),e.jsx("span",{className:"truncate",title:h.name,children:fe(h.name)}),e.jsxs("span",{className:"text-gray-600 flex-shrink-0",children:["· ",h.file.split(/[/\\]/).pop(),":",h.line]})]},y):null})})]})}function at({columns:t,rows:r,truncated:n,totalRows:l,keyPrefix:i,revealed:m,onToggle:b,bare:p,tests:a}){return e.jsxs("div",{className:`${p?"":"bg-surface-1 border border-white/5 rounded-xl "}overflow-auto max-h-[60vh]`,children:[e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-2 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-10 px-2 py-2.5 text-[11px] text-gray-600 border-b border-white/5 text-right",children:"#"}),t.map((c,y)=>e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-semibold text-gray-400 border-b border-white/5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c.name,c.sensitive&&e.jsx("button",{onClick:()=>b(`${i}:${y}`),className:"text-amber-400/70 hover:text-amber-300",title:m.has(`${i}:${y}`)?"Hide column":"Reveal column",children:m.has(`${i}:${y}`)?e.jsx(de,{size:12}):e.jsx(xt,{size:12})}),c.usedBy&&c.usedBy.length>0&&e.jsxs("span",{className:"text-[10px] font-normal text-cyan-700 dark:text-cyan-400/80 normal-case",title:c.usedBy.map(h=>{var u;return(u=a.find($=>$.id===h))==null?void 0:u.name}).filter(Boolean).join(", "),children:["· ",c.usedBy.length," test",c.usedBy.length!==1?"s":""]})]})},y))]})}),e.jsx("tbody",{children:r.map((c,y)=>e.jsxs("tr",{className:"hover:bg-surface-2/40",children:[e.jsx("td",{className:"px-2 py-2 text-[11px] text-gray-600 border-b border-white/5 text-right tabular-nums",children:y+1}),t.map((h,u)=>{const $=h.sensitive&&!m.has(`${i}:${u}`),z=c[u]??"";return e.jsx("td",{title:$?void 0:z,className:`px-3 py-2 border-b border-white/5 font-mono text-xs truncate max-w-[280px] ${$?"text-gray-500":"text-gray-300"}`,children:$?bt:z},u)})]},y))})]}),n&&e.jsxs("div",{className:"px-3 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first ",r.length," of ",l," rows."]})]})}function fs({p:t,revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m}){const b={revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m};if(!t)return e.jsx("div",{className:"text-sm text-gray-600",children:"No preview available for this source."});if(t.shape==="none")return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-2 py-3",children:[e.jsx(dt,{size:15})," ",t.note||"Not previewable."]});if(t.shape==="raw"){const p=t.masked&&!r.has("raw");return e.jsxs(e.Fragment,{children:[(t.masked||r.has("raw"))&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 mb-2",children:[e.jsx(xt,{size:12,className:"text-amber-400/70"}),p?"Secret values in this file are hidden.":"Showing secret values.",e.jsx("button",{onClick:()=>n("raw"),className:"text-amber-400/80 hover:text-amber-300 inline-flex items-center gap-1",children:p?e.jsxs(e.Fragment,{children:[e.jsx(mt,{size:12})," Reveal"]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{size:12})," Hide"]})})]}),e.jsx("pre",{className:"text-[13px] font-mono text-gray-300 bg-surface-1 border border-white/5 rounded-xl p-4 overflow-auto max-h-[60vh] whitespace-pre-wrap break-words",children:t.raw})]})}return t.shape==="sections"?e.jsx("div",{className:"space-y-4",children:(t.sections||[]).map((p,a)=>{var h,u;const c=!!p.columns,y=c?p.totalRows??((h=p.rows)==null?void 0:h.length)??0:((u=p.pairs)==null?void 0:u.length)??0;return e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-2.5 bg-surface-1 border-b border-white/5 flex items-center gap-2",children:[c?e.jsx(we,{size:13,className:"text-sky-400"}):e.jsx(be,{size:13,className:"text-cyan-400"}),e.jsx("span",{className:"font-mono text-sm text-gray-200",children:p.name}),e.jsxs("span",{className:"text-[11px] text-gray-600",children:["· ",y," ",c?"row":"field",y!==1?"s":""]})]}),c?e.jsx(at,{columns:p.columns,rows:p.rows||[],truncated:p.truncated,totalRows:p.totalRows,keyPrefix:`sec${a}`,revealed:r,onToggle:n,tests:l,bare:!0}):(p.pairs||[]).map(($,z)=>e.jsx(st,{kv:$,rk:`sec:${a}:${z}`,...b},z))]},a)})}):t.shape==="keyvalue"?e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:(t.pairs||[]).map((p,a)=>e.jsx(st,{kv:p,rk:`kv:${a}`,...b},a))}):e.jsx(at,{columns:t.columns||[],rows:t.rows||[],truncated:t.truncated,totalRows:t.totalRows,keyPrefix:"col",revealed:r,onToggle:n,tests:l})}function gs(){var Ze;const t=zt(),[r,n]=ot(),l=r.get("source"),[i,m]=o.useState(null),[b,p]=o.useState(!0),[a,c]=o.useState(null),[y,h]=o.useState(!1),[u,$]=o.useState(""),[z,q]=o.useState("all"),[M,T]=o.useState("all"),[x,N]=o.useState(null),[O,w]=o.useState(!1),[E,W]=o.useState(new Set),{hasRole:Q}=ce(),{toast:ee}=_(),[f,j]=o.useState(null),S=o.useRef(null),C=s=>W(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),F=s=>{var D;if(E.has(s)||f||!((D=x==null?void 0:x.preview)!=null&&D.masked)){C(s);return}if(!Q("tester")){ee("info","Only testers and admins can reveal secret values.");return}const k=l;k&&Ye(k,!0).then(Re=>{S.current===k&&(j(Re.preview),C(s))}).catch(Re=>ee("error",String(Re)))},[P,Z]=o.useState(new Set),B=s=>Z(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),[d,L]=o.useState({included:[],ignored:[]}),[K,v]=o.useState(!1),[A,U]=o.useState(!1),[g,R]=o.useState([]),[V,te]=o.useState(!1),[se,ze]=o.useState(""),[Ke,$e]=o.useState(null),He=()=>Pt().then(L).catch(()=>{}),Ee=(s=!1)=>{c(null),Ft(s).then(m).catch(k=>c(String(k))).finally(()=>{p(!1),h(!1)})};o.useEffect(()=>{Ee(),He()},[]);const Te=()=>{Ee(!0),He()},Le=s=>{$e(null),Ut(s).then(()=>{ze(""),Te(),Ve()}).catch(k=>$e(String(k)))},Nt=s=>{(s.manual?Je(s.file,"included"):Bt(s.file)).then(Te).catch(()=>{})},vt=s=>Je(s,"ignored").then(Te).catch(()=>{}),Ve=()=>{te(!0),_t().then(s=>R(s.candidates)).catch(()=>R([])).finally(()=>te(!1))},wt=()=>{v(!0),ze(""),$e(null),Ve()},Me=Q("tester");o.useEffect(()=>{if(S.current=l,j(null),!l){N(null);return}w(!0),W(new Set),Z(new Set),Ye(l).then(s=>N({source:s.source,preview:s.preview,tests:s.tests})).catch(()=>N(null)).finally(()=>w(!1))},[l]);const kt=()=>{h(!0),It().then(()=>Ee(!1)).catch(s=>{c(String(s)),h(!1)})},Ct=s=>n(k=>{const D=new URLSearchParams(k);return D.set("source",s.id),D},{replace:!0}),St=()=>n(s=>{const k=new URLSearchParams(s);return k.delete("source"),k},{replace:!0}),Ge=s=>Ot(t,{prompt:s,mode:"web"}),We=o.useMemo(()=>{if(!i)return[];const s=u.trim().toLowerCase();return i.sources.filter(k=>!(z!=="all"&&k.kind!==z||M==="orphans"&&!k.orphan||M==="indirect"&&!k.indirect||M==="secrets"&&!k.isSecret||s&&!(k.label.toLowerCase().includes(s)||k.file.toLowerCase().includes(s)||(k.searchText||"").includes(s)))).sort((k,D)=>D.usedByTestCount-k.usedByTestCount)},[i,u,z,M]);if(b)return e.jsxs("div",{className:"flex items-center justify-center h-full text-gray-500 gap-2",children:[e.jsx(I,{size:18,className:"animate-spin"})," Scanning test data…"]});if(a)return e.jsxs("div",{className:"flex items-center justify-center h-full text-red-400 gap-2",children:[e.jsx(me,{size:18})," ",a]});if(!i)return null;if(l){const s=x==null?void 0:x.source;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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.jsxs("button",{onClick:St,className:ye,children:[e.jsx(is,{size:15})," Test Data"]}),s&&e.jsx("span",{className:`text-sm text-gray-200 truncate ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),s&&e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"ml-auto text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1.5 text-sm",children:[e.jsx(H,{size:14})," Open file"]})]}),e.jsx("div",{className:"flex-1 overflow-auto px-5 py-4",children:e.jsx("div",{className:"max-w-[1100px] mx-auto",children:O||!s?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-10 justify-center",children:[e.jsx(I,{size:16,className:"animate-spin"})," Reading data…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label}),s.format&&e.jsx("span",{className:"text-[11px] text-gray-500 uppercase",children:s.format}),((Ze=x==null?void 0:x.preview)==null?void 0:Ze.totalRows)!=null&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:[x.preview.totalRows," ",x.preview.shape==="table"?"rows":x.preview.shape==="sections"?"groups":"fields"]}),s.isDynamic&&e.jsx("span",{className:"text-[11px] text-rose-400",children:"non-deterministic"}),s.isSecret&&e.jsx("span",{className:"text-[11px] text-amber-400",children:"PII / secret"})]}),e.jsx("h1",{className:`text-lg text-gray-100 break-all ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1",children:[s.file,s.line?`:${s.line}`:""," ",e.jsx(H,{size:10})]})," ","· used by ",(x==null?void 0:x.tests.length)??s.usedByTestCount," test",((x==null?void 0:x.tests.length)??s.usedByTestCount)!==1?"s":""]})]}),ae(s.kind)?e.jsx(fs,{p:(f&&(f.shape!=="raw"||E.has("raw"))?f:x==null?void 0:x.preview)??null,revealed:E,onToggle:F,tests:(x==null?void 0:x.tests)??[],usageOpen:P,onToggleUsage:B}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 font-mono text-sm text-gray-300 break-all",children:s.label}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-300 mb-2",children:["Used by ",(x==null?void 0:x.tests.length)??0," test",((x==null?void 0:x.tests.length)??0)!==1?"s":""]}),((x==null?void 0:x.tests.length)??0)===0?e.jsx("div",{className:"text-sm text-gray-600",children:s.orphan?"No test references this — it may be dead data.":s.indirect?"Loaded via a helper / non-test file — not attributable to a specific test.":"No mapped tests."}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:x.tests.map(k=>e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-white/5 last:border-0 hover:bg-surface-2/40 group",children:[e.jsx(we,{size:14,className:"text-gray-500 flex-shrink-0"}),e.jsx("button",{onClick:()=>ft(k.file,k.name),title:"Open in Test Explorer (new tab)",className:"flex-1 text-left text-sm text-gray-300 hover:text-cyan-300 truncate",children:fe(k.name)}),e.jsxs("button",{onClick:()=>De(k.file,k.line),title:"Open file in Project Explorer (new tab)",className:"text-[11px] text-gray-600 hover:text-gray-300 truncate max-w-[240px] inline-flex items-center gap-1 flex-shrink-0",children:[k.file.split(/[/\\]/).pop(),":",k.line," ",e.jsx(H,{size:11,className:"opacity-0 group-hover:opacity-70"})]})]},k.id))})]}),(s.kind==="hardcoded"||s.kind==="dynamic")&&e.jsx("div",{className:"mt-5",children:e.jsxs("button",{onClick:()=>Ge(s.kind==="hardcoded"?`The value "${s.label}" is hardcoded as test data in my tests (${s.file}). Analyze its usages and suggest how to externalize it into a managed dataset or environment variable. Show me the plan first.`:`The tests use dynamic/random data via "${s.label}". Analyze which tests rely on it and whether it introduces non-determinism, and suggest a strategy (seeded data / fixtures). Plan only.`),className:"inline-flex items-center gap-1.5 px-3 py-2 text-sm rounded-xl border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10",children:[e.jsx(ne,{size:14})," ",s.kind==="hardcoded"?"Externalize with AI":"Analyze with AI"," ",e.jsx(H,{size:12})]})})]})})})]})}const Y=i.stats,Qe=s=>`px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${s?"bg-cyan-500/15 text-cyan-300 border-cyan-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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(Fe,{size:18,className:"text-gray-900 dark:text-gray-100 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Test data sources, test usage & duplicates"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[Y.filesScanned," files · ",Y.durationMs,"ms"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[Me&&e.jsxs("button",{onClick:wt,className:ye,title:"Add a test data file the scan missed",children:[e.jsx(Ae,{size:14})," Add file"]}),d.ignored.length>0&&e.jsxs("button",{onClick:()=>U(!0),className:ye,title:"Manage ignored files",children:[e.jsx(de,{size:14})," Ignored (",d.ignored.length,")"]}),e.jsxs("button",{onClick:kt,disabled:y,className:ye,children:[y?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rescan"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(le,{icon:e.jsx(be,{size:15}),value:Y.total,label:"data sources"}),e.jsx(le,{icon:e.jsx(Fe,{size:15}),value:Y.testsMapped,label:"tests mapped"}),e.jsx(le,{icon:e.jsx(ue,{size:15}),value:Y.duplicateClusters,label:"duplicates",tone:"amber"}),e.jsx(le,{icon:e.jsx(os,{size:15}),value:Y.dynamicCount,label:"dynamic / random"}),e.jsx(le,{icon:e.jsx(dt,{size:15}),value:Y.orphanCount,label:"orphan files"}),e.jsx(le,{icon:e.jsx(cs,{size:15}),value:Y.indirectCount??0,label:"used indirectly"}),e.jsx(le,{icon:e.jsx(ds,{size:15}),value:Y.hardcodedSecrets,label:"hardcoded secrets",tone:"rose"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:u,onChange:s=>$(s.target.value),placeholder:"Search name, path, or data contents (keys & values)…",className:"w-full pl-9 pr-9 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),u&&e.jsx("button",{onClick:()=>$(""),title:"Clear search",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:15})})]}),["all","file","fixture","provider","dynamic","hardcoded"].map(s=>e.jsx("button",{onClick:()=>{q(z===s?"all":s),T("all")},className:Qe(s==="all"?z==="all"&&M==="all":z===s),children:s==="all"?"All":pe[s].label},s)),["orphans","indirect","secrets"].map(s=>e.jsx("button",{onClick:()=>{T(M===s?"all":s),q("all")},className:Qe(M===s),children:s},s))]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[We.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(oe,{size:22})}),e.jsx("span",{className:"text-sm",children:"No data sources match."})]}):e.jsxs("table",{className:"w-full text-sm border-collapse bg-surface-1",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Source"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Kind"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Rows"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Used by"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Flags"}),e.jsx("th",{className:"w-12 px-2 pr-5 py-2.5 border-b border-white/5"})]})}),e.jsx("tbody",{children:We.map(s=>e.jsxs("tr",{onClick:()=>Ct(s),className:"hover:bg-surface-2/40 cursor-pointer group",children:[e.jsx("td",{className:"px-5 py-2.5 border-b border-white/5 max-w-[420px]",children:ae(s.kind)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-200 truncate",children:Oe(s.label)}),e.jsx("div",{className:"text-[11px] text-gray-500 font-mono truncate",title:s.label,children:s.label})]}):e.jsx("div",{className:"font-mono text-gray-200 truncate",title:s.label,children:s.label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right text-xs text-gray-500 tabular-nums",children:ae(s.kind)?`${s.rowCount??"–"} · ${s.format??""}`:"—"}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:s.usedByTestCount}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-[11px]",children:[s.manual&&e.jsx("span",{className:"text-cyan-400 mr-1",children:"added"}),s.orphan&&e.jsx("span",{className:"text-gray-500 mr-1",children:"orphan"}),s.indirect&&e.jsx("span",{className:"text-sky-400/80 mr-1",title:"Used via a helper / non-test file",children:"indirect"}),s.isDynamic&&e.jsx("span",{className:"text-rose-400 mr-1",children:"random"}),s.isSecret&&e.jsx("span",{className:"text-amber-400",children:"PII/secret"})]}),e.jsx("td",{className:"px-2 py-2.5 pr-5 border-b border-white/5 text-right",children:Me&&ae(s.kind)&&e.jsx("button",{onClick:k=>{k.stopPropagation(),Nt(s)},title:s.manual?"Remove added file":"Hide & ignore this file",className:"text-gray-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition-opacity",children:s.manual?e.jsx(xs,{size:14}):e.jsx(de,{size:14})})})]},s.id))})]}),i.duplicates.length>0&&e.jsxs("div",{className:"px-5 py-5",children:[e.jsxs("h2",{className:"flex items-center gap-2 mb-2 text-sm font-semibold text-gray-300",children:[e.jsx(ue,{size:15,className:"text-amber-400"})," Duplicate data (",i.duplicates.length,")"]}),e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[i.duplicates.slice(0,30).map(s=>e.jsxs("div",{className:"flex items-center px-4 py-2.5 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-gray-200 truncate pr-2",children:s.value}),e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded text-amber-400 bg-amber-500/10 border border-amber-500/20 mr-3",children:s.type}),e.jsxs("span",{className:"text-gray-400 text-xs mr-3 tabular-nums",children:["×",s.count]}),e.jsxs("button",{onClick:()=>Ge(`In my test project, the test data "${s.value}" is duplicated in ${s.count} places (${s.type}). Analyze where it's used and suggest how to consolidate it into a single shared dataset or constant. Plan only.`),className:"inline-flex items-center gap-1 text-[11px] text-cyan-400 hover:text-cyan-300",children:[e.jsx(ne,{size:12})," consolidate"]})]},s.fingerprint)),i.duplicates.length>30&&e.jsxs("div",{className:"px-4 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first 30 of ",i.duplicates.length," duplicate clusters."]})]})]})]}),K&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>v(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ae,{size:16})," Add test data file"]}),e.jsx("button",{onClick:()=>v(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Data-ish files the scan didn't capture:"}),V?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-4",children:[e.jsx(I,{size:14,className:"animate-spin"})," Finding files…"]}):g.length===0?e.jsx("div",{className:"text-sm text-gray-600 py-2 mb-2",children:"No uncaptured candidate files found."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[40vh] overflow-y-auto mb-4",children:g.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0 hover:bg-surface-2/40",children:[e.jsx(we,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s.file,children:s.file}),e.jsx("span",{className:"text-[10px] text-gray-600 uppercase",children:s.format}),e.jsxs("button",{onClick:()=>Le(s.file),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(Ae,{size:12})," add"]})]},s.file))}),e.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:"Or add by path (relative to project):"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:se,onChange:s=>ze(s.target.value),placeholder:"e.g. src/test/resources/data.csv",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-cyan-500/50",onKeyDown:s=>{s.key==="Enter"&&se.trim()&&Le(se.trim())}}),e.jsx("button",{onClick:()=>se.trim()&&Le(se.trim()),disabled:!se.trim(),className:"px-3 py-2 text-sm rounded-lg border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10 disabled:opacity-40",children:"Add"})]}),Ke&&e.jsx("p",{className:"text-xs text-rose-400 mt-2",children:Ke})]})]})}),document.body),A&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(de,{size:16})," Ignored files (",d.ignored.length,")"]}),e.jsx("button",{onClick:()=>U(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsx("div",{className:"p-4 overflow-y-auto",children:d.ignored.length===0?e.jsx("div",{className:"text-sm text-gray-600",children:"No ignored files."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden",children:d.ignored.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s,children:s}),Me&&e.jsxs("button",{onClick:()=>vt(s),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(ms,{size:12})," restore"]})]},s))})})]})}),document.body)]})}const Ie={page:"Page Object",helper:"Helper",support:"Support",step:"Step Def",fixture:"Fixture",test:"Test",source:"Source"};function J(t,r){const n=`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`;window.open(n,"_blank","noopener")}function Se(t,r){const n=`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`;window.open(n,"_blank","noopener")}const ys=new RegExp("\\b(?:async|await|function|return|const|let|var|if|else|elif|for|while|do|switch|case|break|continue|class|extends|implements|interface|type|enum|namespace|struct|new|delete|import|from|export|default|public|private|protected|internal|static|readonly|abstract|override|virtual|final|void|def|end|self|begin|rescue|ensure|module|require|lambda|yield|with|as|in|of|is|not|and|or|pass|raise|try|catch|except|finally|throw|throws|super|this|using|package|func|fn|val|when|then|true|false|null|nil|None|True|False|undefined|NaN|string|number|boolean|bool|int|float|double|char|str)\\b");function js(t,r){const n=r==="python"||r==="ruby",l=n?"#[^\\n]*":"\\/\\/[^\\n]*",i=n?"":"|\\/\\*[\\s\\S]*?\\*\\/",m=new RegExp(`(${l}${i})|(\`(?:\\\\.|[^\`\\\\])*\`|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*')|(\\b\\d[\\d_.]*(?:e[+-]?\\d+)?\\b)|(${ys.source})|([A-Za-z_$][\\w$]*)(?=\\s*\\()|(\\b[A-Z][A-Za-z0-9_]*\\b)`,"g"),b=[];let p=0,a,c=0;for(;(a=m.exec(t))!==null;){a.index>p&&b.push(t.slice(p,a.index));const y=a[1]?"cm-tok-comment":a[2]?"cm-tok-string":a[3]?"cm-tok-number":a[4]?"cm-tok-keyword":a[5]?"cm-tok-function":"cm-tok-type";b.push(e.jsx("span",{className:y,children:a[0]},c++)),p=a.index+a[0].length}return p<t.length&&b.push(t.slice(p)),b}function Ns({view:t,setView:r}){const n=(l,i,m)=>e.jsxs("button",{onClick:()=>r(l),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===l?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[m,i]});return e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[n("methods","Methods and Steps",e.jsx(Pe,{size:15})),n("data","Test Data",e.jsx(Fe,{size:15}))]})}function Js(){const[t,r]=Dt("view",["methods","data"],"methods");return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(Ns,{view:t,setView:r}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="methods"?e.jsx(vs,{}):e.jsx(gs,{})})]})}const je=500;function vs(){const{toast:t}=_(),[r,n]=o.useState(null),[l,i]=o.useState(!0),[m,b]=o.useState(!1),[p,a]=o.useState(""),[c,y]=o.useState("all"),[h,u]=o.useState(!1),[$,z]=o.useState("usage"),[q,M]=o.useState(null),[T,x]=o.useState("inventory"),[N,O]=o.useState(null),[w,E]=o.useState(!1),[W,Q]=o.useState(je);o.useEffect(()=>{Q(je)},[p,c,h,w,$]);const ee=(d=!1)=>{i(!0),Kt(d).then(L=>{n(L),Ht().then(O).catch(()=>O(null))}).catch(L=>t("error",`Failed to load code map: ${L}`)).finally(()=>i(!1))};o.useEffect(()=>{ee()},[]);const[f,j]=ot();o.useEffect(()=>{const d=f.get("symbol");if(!d)return;x("inventory"),M(d);const L=f.get("name");L&&a(L),j(K=>{const v=new URLSearchParams(K);return v.delete("symbol"),v.delete("name"),v},{replace:!0})},[]);const S=()=>{var A;const d=((r==null?void 0:r.symbols)||[]).filter(U=>U.unused);if(d.length===0){t("info","No unused methods to clean up.");return}const L=new Map;d.forEach(U=>{(L.get(U.file)||L.set(U.file,[]).get(U.file)).push(U)});const K=["# Code cleanup — unused methods (Testver Code Map)",""];for(const[U,g]of L){K.push(`## ${U}`);for(const R of g){const V=N!=null&&N.available&&N.executed[R.id]===!1?" — confirmed dead (not covered at runtime)":"";K.push(`- [ ] \`${R.className?R.className+".":""}${R.name}\` (line ${R.startLine})${V}`)}K.push("")}K.push("> Candidates only — verify before deleting (static analysis can miss reflection / dynamic dispatch).");const v=K.join(`
2
- `);(A=navigator.clipboard)==null||A.writeText(v).then(()=>t("success",`Copied cleanup checklist (${d.length} methods) to clipboard`),()=>t("error","Could not copy to clipboard"))},C=o.useMemo(()=>{const d=new Set;return((r==null?void 0:r.symbols)||[]).forEach(L=>d.add(L.role)),[...d]},[r]),F=o.useMemo(()=>((r==null?void 0:r.symbols)||[]).filter(d=>!d.isEntryPoint||d.role!=="test").length,[r]),P=o.useMemo(()=>{let d=((r==null?void 0:r.symbols)||[]).filter(v=>!v.isEntryPoint||v.role!=="test");const L=p.trim().toLowerCase();L&&(d=d.filter(v=>v.name.toLowerCase().includes(L)||v.file.toLowerCase().includes(L)||(v.className||"").toLowerCase().includes(L))),c!=="all"&&(d=d.filter(v=>v.role===c)),h&&(d=d.filter(v=>v.unused)),w&&(d=d.filter(v=>v.unused&&(N==null?void 0:N.executed[v.id])===!1));const K={usage:(v,A)=>A.usedByTestCount-v.usedByTestCount||v.name.localeCompare(A.name),callers:(v,A)=>A.callerCount-v.callerCount||v.name.localeCompare(A.name),name:(v,A)=>v.name.localeCompare(A.name),file:(v,A)=>v.file.localeCompare(A.file)||v.startLine-A.startLine};return[...d].sort(K[$])},[r,p,c,h,w,N,$]),Z=()=>{b(!0),Vt().then(()=>ee(!1)).catch(d=>t("error",String(d))).finally(()=>b(!1))},B=r==null?void 0:r.stats;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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(Pe,{size:18,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Methods & steps inventory, test usage and quality"}),e.jsx("div",{className:"flex items-center gap-1 p-0.5 rounded-xl bg-surface-2 border border-white/5",children:["inventory","quality","graph","steps"].filter(d=>d!=="steps"||(B==null?void 0:B.gherkin)).map(d=>e.jsx("button",{onClick:()=>x(d),className:`px-3 py-1.5 text-xs font-medium capitalize rounded-lg transition-colors ${T===d?"bg-brand-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200 hover:bg-white/5"}`,children:d},d))}),e.jsxs("button",{onClick:Z,disabled:m,className:"ml-auto 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 disabled:opacity-50",children:[m?e.jsx(I,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rebuild"]}),T==="inventory"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:S,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(ps,{size:14})," Copy cleanup task"]}),e.jsxs("button",{onClick:()=>qt().catch(d=>t("error",`Export failed: ${d}`)),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(ut,{size:14})," Export CSV"]})]})]}),B&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(Ne,{icon:e.jsx(Pe,{size:15}),label:"Methods",value:F}),e.jsx(Ne,{icon:e.jsx(me,{size:15}),label:"Unused",value:B.unused,tone:"amber"}),e.jsx(Ne,{icon:e.jsx(Ue,{size:15}),label:"Tests",value:B.tests}),e.jsx(Ne,{icon:e.jsx(ge,{size:15}),label:"Files",value:B.files}),(N==null?void 0:N.available)&&e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20",title:`Coverage from ${N.source}`,children:[e.jsx(et,{size:15,className:"text-emerald-400"}),e.jsx("span",{className:"text-[15px] font-bold text-emerald-300 tabular-nums",children:N.confirmedDead}),e.jsxs("span",{className:"text-xs text-emerald-400/70",children:["Confirmed dead · ",N.format]})]}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:["indexed in ",B.durationMs,"ms"]})]}),T==="inventory"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:d=>a(d.target.value),placeholder:"Search methods, files, classes…",className:"w-full pl-9 pr-3 py-1.5 rounded-xl 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.jsxs("select",{value:c,onChange:d=>y(d.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 roles"}),C.map(d=>e.jsx("option",{value:d,children:Ie[d]||d},d))]}),e.jsxs("select",{value:$,onChange:d=>z(d.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:"usage",children:"Sort: most used"}),e.jsx("option",{value:"callers",children:"Sort: most callers"}),e.jsx("option",{value:"name",children:"Sort: name"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>u(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${h?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),(N==null?void 0:N.available)&&e.jsxs("button",{onClick:()=>E(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${w?"bg-red-500/15 text-red-300 border-red-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,title:"Statically unused AND never executed at runtime",children:[e.jsx(et,{size:14})," Confirmed dead"]}),e.jsxs("span",{className:"text-xs text-gray-600",children:[P.length," shown"]})]}),T==="quality"?e.jsx($s,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="steps"?e.jsx(Ls,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="graph"?e.jsx(Us,{symbols:(r==null?void 0:r.symbols)||[],onOpenSymbol:d=>{x("inventory"),M(d)}}):e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-auto bg-surface-1",children:[l?e.jsxs("div",{className:"flex items-center gap-2 p-6 text-sm text-gray-500",children:[e.jsx(I,{size:16,className:"animate-spin"})," Indexing project…"]}):P.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-20 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",children:e.jsx(oe,{size:22})}),e.jsx("div",{className:"text-sm",children:"No methods match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Method"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Role"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Tests"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Callers"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",title:"Cyclomatic complexity",children:"Cx"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:P.slice(0,W).map(d=>e.jsxs("tr",{onClick:()=>M(d.id),className:`cursor-pointer transition-colors ${q===d.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsx("span",{className:"font-mono text-gray-200",children:d.name}),d.className&&e.jsxs("span",{className:"text-gray-500 text-xs",children:[" · ",d.className]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[260px]",title:d.file,children:[d.file,":",d.startLine]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-400 text-xs",children:Ie[d.role]||d.role}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:d.usedByTestCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:d.callerCount}),e.jsx("td",{className:`px-3 py-2.5 border-b border-white/5 text-right tabular-nums ${d.complexity>=10?"text-red-400":d.complexity>=6?"text-amber-400":"text-gray-500"}`,children:d.complexity}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:d.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):d.usedByTestCount>0?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20",children:"Indirect"})})]},d.id))})]}),!l&&P.length>W&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-4 text-xs text-gray-500",children:["Showing ",W.toLocaleString()," of ",P.length.toLocaleString()," methods",e.jsxs("button",{onClick:()=>Q(d=>d+je),className:"px-3 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 transition-colors",children:["Show ",Math.min(je,P.length-W).toLocaleString()," more"]})]})]}),q&&e.jsx(ws,{id:q,executed:N!=null&&N.available?N.executed[q]:void 0,onClose:()=>M(null)})]})]})}function Ne({icon:t,label:r,value:n,tone:l}){return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${l==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5"}`,children:[e.jsx("span",{className:l==="amber"?"text-amber-400":"text-brand-400",children:t}),e.jsx("span",{className:`text-[15px] font-bold tabular-nums ${l==="amber"?"text-amber-300":"text-gray-100"}`,children:n}),e.jsx("span",{className:"text-xs text-gray-500",children:r})]})}function ws({id:t,executed:r,onClose:n}){const{toast:l}=_(),[i,m]=o.useState(null),[b,p]=o.useState(!0);o.useEffect(()=>{p(!0),m(null),Xt(t).then(m).catch(c=>l("error",String(c))).finally(()=>p(!1))},[t]);const a=i==null?void 0:i.symbol;return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(be,{size:18,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:(a==null?void 0:a.name)||"…"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),b||!i?e.jsxs("div",{className:"p-4 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:14,className:"animate-spin"})," Loading…"]}):e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(a.file,a.startLine),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[a.file,":",a.startLine]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(ie,{children:Ie[a.role]||a.role}),e.jsx(ie,{children:a.language}),a.visibility&&e.jsx(ie,{children:a.visibility}),e.jsxs(ie,{children:[a.loc," LOC"]}),e.jsxs(ie,{children:["cx ",a.complexity]}),i.usage.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused candidate"}),r===!0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"ran at runtime"}),r===!1&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20",children:"not covered at runtime"})]}),e.jsx(Es,{id:t,unused:i.usage.unused}),i.usedByTests.length>0&&e.jsx(Ss,{tests:i.usedByTests}),i.usedByTests.length>0&&e.jsx(ve,{title:"Used by tests",icon:e.jsx(Ue,{size:14,className:"text-emerald-400"}),items:i.usedByTests,listClass:"space-y-2",getText:c=>`${c.name} ${c.file}`,placeholder:"Filter tests by name or file…",render:c=>e.jsx(zs,{t:c},c.id)}),i.calledBy.length>0&&e.jsx(ve,{title:"Called by methods",icon:e.jsx(be,{size:13,className:"text-brand-400"}),items:i.calledBy,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter methods by name or file…",render:c=>e.jsx(nt,{c},c.id)}),i.calls.length>0&&e.jsx(ve,{title:"Calls",icon:e.jsx(_e,{size:13,className:"text-brand-400"}),items:i.calls,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter calls by name or file…",render:c=>e.jsx(nt,{c},c.id)}),e.jsx(ke,{title:"Source",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:i.source||"(source unavailable)",lang:a.language})})]})]})}const ks=new Set(["playwright","jest","vitest","mocha","pytest","robot","puppeteer"]),Cs=3;function Ss({tests:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),m=o.useMemo(()=>{const c=new Map;for(const h of t)(c.get(h.framework)||c.set(h.framework,new Set).get(h.framework)).add(h.file);const y=[];for(const[h,u]of c)if(ks.has(h))y.push({files:[...u],framework:h});else for(const $ of u)y.push({files:[$],framework:h});return y},[t]);if(!n)return null;const b=m.reduce((c,y)=>c+y.files.length,0),p=m.length>Cs,a=async()=>{i(!0);try{for(const c of m)await ss(c);r("success",`Started ${m.length===1?"a run":`${m.length} runs`} for ${b} test file${b!==1?"s":""} — follow ${m.length===1?"it":"them"} in the Runner.`)}catch(c){r("error",String(c))}finally{i(!1)}};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:a,disabled:l||p,title:p?`${b} test files need ${m.length} separate runs — select the tests in Test Explorer to run them together`:"Run every test file that exercises this method",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium text-emerald-300 bg-emerald-500/10 border border-emerald-500/25 hover:bg-emerald-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:12,className:"animate-spin"}):e.jsx(bs,{size:12})," Run affected tests"]}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:[t.length," test",t.length!==1?"s":""," in ",b," file",b!==1?"s":"",p?" — too many separate runs; use Test Explorer":""]})]})}function rt({onClick:t,title:r,children:n,copied:l}){return e.jsx("button",{onClick:i=>{i.stopPropagation(),t()},title:r,className:`p-1.5 rounded-lg border transition-colors ${l?"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:n})}function zs({t}){const{toast:r}=_(),[n,l]=o.useState(!1),i=()=>{var m;return(m=navigator.clipboard)==null?void 0:m.writeText(t.name).then(()=>{l(!0),setTimeout(()=>l(!1),1500)},()=>r("error","Could not copy to clipboard"))};return e.jsx("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug",title:t.name,children:fe(t.name)}),e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open file in Project Explorer (new tab)",className:"group flex items-center gap-1.5 mt-1 text-xs text-gray-500 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:12,className:"shrink-0 text-gray-600 group-hover:text-brand-400"}),e.jsx("span",{className:"truncate",children:t.file}),e.jsxs("span",{className:"text-gray-600",children:[":",t.startLine]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(rt,{onClick:i,title:"Copy test name",copied:n,children:n?e.jsx(Ce,{size:13}):e.jsx(ue,{size:13})}),e.jsx(rt,{onClick:()=>Se(t.file,t.name),title:"Open in Test Explorer (new tab)",children:e.jsx(Be,{size:13})})]})]})})}function nt({c:t}){return e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open in Project Explorer (new tab)",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-[13px] text-gray-200 truncate",title:`${t.className?t.className+".":""}${t.name}`,children:[t.className&&e.jsxs("span",{className:"text-gray-500",children:[t.className,"."]}),t.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-gray-500 font-mono truncate max-w-[180px]",title:`${t.file}:${t.startLine}`,children:t.file}),e.jsx(H,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}function qe({code:t,lang:r}){const{toast:n}=_(),[l,i]=o.useState(!1),m=o.useMemo(()=>js(t,r),[t,r]),b=()=>{var p;(p=navigator.clipboard)==null||p.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1500)},()=>n("error","Could not copy to clipboard"))};return e.jsxs("div",{className:"cm-code rounded-xl border cm-code-surface overflow-hidden",children:[e.jsxs("div",{className:"cm-code-bar flex items-center justify-between px-3 py-1.5 border-b",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[10px] uppercase tracking-wide text-gray-500 font-medium",children:[e.jsxs("span",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400/70"})]}),r||"source"]}),e.jsx("button",{onClick:b,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"cm-code-pre text-[12.5px] leading-relaxed font-mono whitespace-pre overflow-auto p-3 max-h-80",children:m})]})}function ke({title:t,count:r,icon:n,children:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[n,e.jsx("span",{className:"text-xs font-semibold text-gray-300",children:t}),r!=null&&e.jsx("span",{className:"text-[10px] font-medium text-gray-500 bg-surface-2 border border-white/5 rounded-full px-1.5 py-0.5 tabular-nums",children:r})]}),l]})}function ve({title:t,icon:r,items:n,getText:l,render:i,placeholder:m,listClass:b="space-y-1.5"}){const[p,a]=o.useState(""),c=p.trim().toLowerCase(),y=c?n.filter(h=>l(h).toLowerCase().includes(c)):n;return e.jsxs(ke,{title:t,count:n.length,icon:r,children:[n.length>4&&e.jsxs("div",{className:"relative mb-2",children:[e.jsx(oe,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:h=>a(h.target.value),placeholder:m,className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"})]}),y.length===0?e.jsxs("div",{className:"text-xs text-gray-500 py-1",children:["No matches for “",p,"”."]}):e.jsx("div",{className:b,children:y.map(i)})]})}function ie({children:t}){return e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10",children:t})}function $s({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0);if(o.useEffect(()=>{m(!0),Gt().then(a=>l(a.quality)).catch(a=>r("error",String(a))).finally(()=>m(!1))},[]),i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:16,className:"animate-spin"})," Analyzing quality…"]});if(!n)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No quality data."});const b=({r:a})=>e.jsxs("button",{onClick:()=>t(a.id),title:"Open method details",className:"group inline-flex items-baseline gap-1 rounded-md px-2 py-1 -mx-2 text-left cursor-pointer hover:bg-brand-500/10 transition-colors",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2",children:[a.className?`${a.className}.`:"",a.name]}),e.jsxs("span",{className:"text-gray-600 text-xs font-mono",children:[" · ",a.file,":",a.startLine]})]}),p=a=>a==="A"?"text-emerald-400":a==="B"?"text-emerald-300":a==="C"?"text-amber-400":a==="D"?"text-orange-400":"text-red-400";return e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{label:"duplicate clusters",value:n.summary.duplicateClusters,tone:"amber"}),e.jsx(X,{label:"complex methods",value:n.summary.complexMethods,tone:"amber"}),e.jsx(X,{label:"orphan files",value:n.summary.orphanFiles,tone:"amber"}),e.jsx(X,{label:"orphan locators",value:n.summary.orphanLocators,tone:"amber"}),e.jsx(X,{label:"tests w/o assertions",value:n.summary.noAssertionTests,tone:"red"})]}),e.jsx(_s,{files:n.fileMaintainability}),e.jsx(G,{title:"Duplicate & near-duplicate methods",hint:"Refactor candidates. ‘identical’ = same body; ‘similar’ = same structure, renamed.",children:n.duplicates.length===0?e.jsx(re,{children:"No duplicates detected."}):n.duplicates.map((a,c)=>e.jsx(Ts,{c:a,RefEl:b},c))}),e.jsx(G,{title:"Most complex methods",hint:"High cyclomatic complexity / deep nesting / long bodies.",children:n.complexMethods.length===0?e.jsx(re,{children:"Nothing notably complex."}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:n.complexMethods.map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2",children:e.jsx(b,{r:a})}),e.jsxs("td",{className:"py-2 text-right text-sm text-amber-400 tabular-nums w-20",children:["cx ",a.complexity]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-24",children:["nest ",a.maxNesting]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-20",children:[a.loc," loc"]})]},a.id))})})}),e.jsx(G,{title:"Orphan files",hint:"Every automation method in the file is unused — whole-file dead-code candidates.",children:n.orphanFiles.length===0?e.jsx(re,{children:"No orphan files."}):n.orphanFiles.map(a=>e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-2 border-b border-white/5 hover:bg-brand-500/10 transition-colors",children:[e.jsx(ge,{size:14,className:"text-amber-400 shrink-0"}),e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2 truncate",children:a.file}),e.jsxs("span",{className:"text-gray-600 text-xs shrink-0",children:["· ",a.methods," unused method(s)"]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},a.file))}),e.jsx(G,{title:"Tests without assertions",hint:"Tests with no detected expect/assert — possible gaps.",children:n.noAssertionTests.length===0?e.jsx(re,{children:"All tests have assertions."}):n.noAssertionTests.map(a=>e.jsxs("button",{onClick:()=>Se(a.file,a.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left py-1.5 px-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors flex items-center gap-2",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2 truncate",title:a.name,children:fe(a.name)}),e.jsxs("span",{className:"block text-xs text-gray-600 font-mono truncate",children:[a.file,":",a.startLine]})]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},a.id))}),e.jsx(G,{title:"Orphan locators",hint:"Element/selector definitions referenced nowhere else (best-effort — verify before removing).",children:n.orphanLocators.length===0?e.jsx(re,{children:"No orphan locators detected."}):n.orphanLocators.map((a,c)=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors",children:[e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2",children:a.name}),e.jsxs("span",{className:"text-gray-600 text-xs",children:[" · ",a.file,":",a.line]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},c))}),e.jsx(G,{title:"File maintainability",hint:"Heuristic score (complexity, size, unused, duplication). Lowest first.",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-xs uppercase text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium py-2",children:"File"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Methods"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Avg cx"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Unused"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Score"})]})}),e.jsx("tbody",{children:n.fileMaintainability.slice(0,40).map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2 max-w-[320px]",children:e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1 max-w-full font-mono text-sm text-gray-300 hover:text-brand-300 transition-colors",children:[e.jsx("span",{className:"truncate group-hover:underline decoration-dotted underline-offset-2",children:a.file}),e.jsx(H,{size:11,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.methods}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.avgComplexity}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.unused}),e.jsx("td",{className:"py-1.5 text-right tabular-nums",children:e.jsxs("span",{className:p(a.grade),children:[a.score," · ",a.grade]})})]},a.file))})]})})]})}function X({label:t,value:r,tone:n}){const l=n==="red"?"bg-red-500/10 border-red-500/20":n==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5",i=n==="red"?"text-red-300":n==="amber"?"text-amber-300":"text-gray-100";return e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg border ${l}`,children:[e.jsx("span",{className:`text-sm font-bold tabular-nums ${i}`,children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:t})]})}function G({title:t,hint:r,children:n}){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-200",children:t}),r&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:r})]}),e.jsx("div",{className:"max-h-[340px] overflow-y-auto overflow-x-hidden pr-1",children:n})]})}function re({children:t}){return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-1.5",children:[e.jsx(Ue,{size:14,className:"text-emerald-400"})," ",t]})}function Es({id:t,unused:r}){const{toast:n}=_(),[l,i]=o.useState(null),[m,b]=o.useState(null),[p,a]=o.useState(!1);if(!ce().hasRole("tester"))return e.jsx(gt,{});const y=(u,$)=>{i(u),b(null),a(!1),$().then(z=>b({label:u,text:z&&z.trim()||"(no response from the AI model — check that an AI provider is configured in Settings)"})).catch(z=>n("error",String(z))).finally(()=>i(null))},h=()=>{var u;m&&((u=navigator.clipboard)==null||u.writeText(m.text).then(()=>{a(!0),setTimeout(()=>a(!1),1500)},()=>n("error","Could not copy to clipboard")))};return e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assists"]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(he,{onClick:()=>y("Explanation",()=>as(t).then(u=>u.explanation)),busy:l==="Explanation",children:"Explain"}),e.jsx(he,{onClick:()=>y("Doc comment",()=>rs(t).then(u=>u.doc)),busy:l==="Doc comment",children:"Document"}),r&&e.jsx(he,{onClick:()=>y("Safe to delete?",()=>ns(t).then(u=>`${u.verdict}${u.confidence!=null?` (${Math.round(u.confidence*100)}% confident)`:""}
3
- ${u.reasoning}`)),busy:l==="Safe to delete?",children:"Safe to delete?"}),r&&e.jsx(he,{onClick:()=>y("Suggested test",()=>ls(t).then(u=>u.code)),busy:l==="Suggested test",children:"Generate test"})]}),l&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(I,{size:12,className:"animate-spin"})," ",l,"…"]}),m&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:m.label}),e.jsx("button",{onClick:h,title:"Copy to clipboard",className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-400 hover:text-gray-100 hover:bg-white/10 transition-colors",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:m.text})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-2",children:"AI suggestions are read-only — nothing is changed in your project."})]})}function gt(){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(ne,{size:13,className:"text-gray-600"})," AI assists are available to testers and admins."]})}function he({onClick:t,busy:r,children:n}){return e.jsx("button",{onClick:t,disabled:r,className:"px-2.5 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:n})}function Ts({c:t,RefEl:r}){const{toast:n}=_(),l=ce().hasRole("tester"),[i,m]=o.useState(!1),[b,p]=o.useState(null),a=()=>{m(!0),Yt(t.members.map(c=>c.id)).then(c=>p(c.suggestion)).catch(c=>n("error",String(c))).finally(()=>m(!1))};return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-md border ${t.kind==="identical"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:t.kind}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.members.length," copies · ~",t.loc," lines each"]}),l&&e.jsxs("button",{onClick:a,disabled:i,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[i?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest consolidation"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(c=>e.jsx("div",{className:"text-sm",children:e.jsx(r,{r:c})},c.id))}),b&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:b})})]})}const lt={Given:"bg-sky-500/15 text-sky-500 border-sky-500/30",When:"bg-amber-500/15 text-amber-500 border-amber-500/40",Then:"bg-emerald-500/15 text-emerald-500 border-emerald-500/30",And:"bg-violet-500/15 text-violet-500 border-violet-500/30",But:"bg-violet-500/15 text-violet-500 border-violet-500/30",Step:"bg-gray-500/15 text-gray-500 border-gray-500/25"};function yt({kw:t}){return e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md border ${lt[t]||lt.And}`,children:t})}function Ls({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0),[b,p]=o.useState(""),[a,c]=o.useState("usage"),[y,h]=o.useState(!1),[u,$]=o.useState(!1),[z,q]=o.useState(null);o.useEffect(()=>{m(!0),Wt().then(l).catch(x=>r("error",String(x))).finally(()=>m(!1))},[]);const M=o.useMemo(()=>{let x=(n==null?void 0:n.stepDefs)||[];const N=b.trim().toLowerCase();N&&(x=x.filter(w=>w.pattern.toLowerCase().includes(N)||w.file.toLowerCase().includes(N)||w.keyword.toLowerCase().includes(N))),y&&(x=x.filter(w=>w.unused));const O={usage:(w,E)=>E.usageCount-w.usageCount||w.pattern.localeCompare(E.pattern),scenarios:(w,E)=>E.scenarioCount-w.scenarioCount||w.pattern.localeCompare(E.pattern),keyword:(w,E)=>w.keyword.localeCompare(E.keyword)||w.pattern.localeCompare(E.pattern),pattern:(w,E)=>w.pattern.localeCompare(E.pattern),file:(w,E)=>w.file.localeCompare(E.file)||w.line-E.line};return[...x].sort(O[a])},[n,b,y,a]);if(i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(I,{size:16,className:"animate-spin"})," Analyzing steps…"]});if(!n||!n.available)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No Gherkin scenarios detected in this project."});const T=n.totals;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(X,{label:"step defs",value:T.stepDefs}),e.jsx(X,{label:"used",value:T.usedDefs}),e.jsx(X,{label:"unused",value:T.unusedDefs,tone:"amber"}),e.jsx(X,{label:"undefined",value:T.undefinedSteps,tone:"red"}),e.jsx(X,{label:"ambiguous",value:T.ambiguousSteps,tone:"amber"}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:[T.features," features · ",T.scenarios," scenarios · ",T.steps," steps"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:b,onChange:x=>p(x.target.value),placeholder:"Search steps by pattern, keyword, or file…",disabled:u,className:"w-full pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors disabled:opacity-40"})]}),e.jsxs("select",{value:a,onChange:x=>c(x.target.value),disabled:u,className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer disabled:opacity-40",children:[e.jsx("option",{value:"usage",children:"Sort: most used"}),e.jsx("option",{value:"scenarios",children:"Sort: most scenarios"}),e.jsx("option",{value:"keyword",children:"Sort: keyword"}),e.jsx("option",{value:"pattern",children:"Sort: pattern"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>h(x=>!x),disabled:u,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors disabled:opacity-40 ${y?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),e.jsxs("button",{onClick:()=>{$(x=>!x),q(null)},title:u?"Close Quality — back to step list":"Show step quality (undefined, ambiguous, duplicates, tags)",className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${u?"bg-brand-600 text-white border-brand-500":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(tt,{size:14})," Quality",u&&e.jsx(xe,{size:14,className:"ml-0.5 opacity-90"})]}),e.jsxs("button",{onClick:()=>Qt().catch(x=>r("error",`Export failed: ${x}`)),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(ut,{size:14})," Export CSV"]}),e.jsx("span",{className:"text-xs text-gray-600",children:u?"quality view":`${M.length} shown`})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto bg-surface-1",children:u?e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsx(G,{title:"Undefined steps",hint:"Gherkin steps with no matching step definition — these fail at runtime ('step undefined').",children:n.undefinedSteps.length===0?e.jsx(re,{children:"Every Gherkin step has a definition."}):n.undefinedSteps.map((x,N)=>e.jsx(Ms,{u:x},N))}),e.jsx(G,{title:"Ambiguous steps",hint:"Gherkin steps matching more than one definition — Cucumber raises an 'ambiguous' error.",children:n.ambiguousSteps.length===0?e.jsx(re,{children:"No ambiguous steps."}):n.ambiguousSteps.map((x,N)=>e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"text-sm text-gray-200",children:[x.text," ",e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",x.occurrences,"×"]})]}),e.jsx("div",{className:"mt-1.5 space-y-1",children:x.defs.map(O=>e.jsxs("button",{onClick:()=>J(O.file,O.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[O.pattern," ",e.jsxs("span",{className:"text-gray-600",children:["· ",O.file,":",O.line]})]},O.id))})]},N))}),e.jsx(G,{title:"Duplicate step definitions",hint:"The same step pattern is defined more than once — consolidate to avoid ambiguity.",children:n.duplicateDefs.length===0?e.jsx(re,{children:"No duplicate definitions."}):n.duplicateDefs.map((x,N)=>e.jsx(Rs,{d:x},N))}),n.tags.length>0&&e.jsx(G,{title:"Tags",hint:"Scenario tags and how many scenarios carry each.",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.tags.map(x=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs bg-surface-2/60 border border-white/5 text-gray-300",children:[e.jsx(hs,{size:12,className:"text-brand-400"})," ",x.tag," ",e.jsx("span",{className:"text-gray-500 tabular-nums",children:x.scenarios})]},x.tag))})})]}):M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 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",children:e.jsx(tt,{size:22})}),e.jsx("div",{className:"text-sm",children:"No step definitions match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Step"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Scenarios"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Uses"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:M.map(x=>e.jsxs("tr",{onClick:()=>q(x),className:`cursor-pointer transition-colors ${(z==null?void 0:z.id)===x.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{kw:x.keyword}),e.jsx("span",{className:"font-mono text-gray-200",children:x.pattern})]}),x.reaches.length>0&&e.jsxs("div",{className:"text-[11px] text-gray-600 mt-0.5 truncate",children:["→ ",x.reaches.map(N=>N.name).join(", ")]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[220px]",title:`${x.file}:${x.line}`,children:[x.file,":",x.line]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:x.scenarioCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:x.usageCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:x.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"})})]},x.id))})]})}),!u&&z&&e.jsx(As,{step:z,onClose:()=>q(null),onOpenSymbol:t})]})]})}function Ms({u:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),b(null),Jt(t.text).then(a=>b(a.code&&a.code.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-red-500/15 bg-red-500/[0.04] p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:13,className:"text-red-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200",children:t.text}),e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",t.occurrences,"×"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest definition"]})]}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:t.scenarios.slice(0,6).map(a=>e.jsx("button",{onClick:()=>Se(a.file,a.name),title:"Open scenario in Test Explorer (new tab)",className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10 hover:text-brand-300 transition-colors",children:a.name},a.id))}),m&&e.jsx("div",{className:"mt-3",children:e.jsx(qe,{code:m,lang:"step definition"})})]})}function Rs({d:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),es(t.members.map(a=>a.id)).then(a=>b(a.suggestion)).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200",children:t.pattern}),e.jsxs("span",{className:"text-xs text-gray-500",children:[t.members.length," definitions"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(I,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Consolidate"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(a=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[a.file,":",a.line]},a.id))}),m&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:m})})]})}function As({step:t,onClose:r,onOpenSymbol:n}){const{toast:l}=_(),i=ce().hasRole("tester"),[m,b]=o.useState(!1),[p,a]=o.useState(null),[c,y]=o.useState(!1),h=()=>{b(!0),a(null),ts(t.id).then(u=>a(u.explanation&&u.explanation.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(u=>l("error",String(u))).finally(()=>b(!1))};return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(yt,{kw:t.keyword}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:t.pattern})]}),e.jsx("button",{onClick:r,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(t.file,t.line),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[t.file,":",t.line]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(ie,{children:[t.scenarioCount," scenario(s)"]}),e.jsxs(ie,{children:[t.usageCount," use(s)"]}),t.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused — no scenario uses this"})]}),i?e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assist"]}),e.jsx(he,{onClick:h,busy:m,children:"Explain this step"}),m&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(I,{size:12,className:"animate-spin"})," Explaining…"]}),p&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Explanation"}),e.jsx("button",{onClick:()=>{var u;return(u=navigator.clipboard)==null?void 0:u.writeText(p).then(()=>{y(!0),setTimeout(()=>y(!1),1500)})},className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:p})]})]}):e.jsx(gt,{}),t.scenarios.length>0&&e.jsx(ve,{title:"Used by scenarios",icon:e.jsx(Be,{size:13,className:"text-emerald-400"}),items:t.scenarios,listClass:"space-y-1.5",getText:u=>`${u.name} ${u.feature} ${(u.tags||[]).join(" ")}`,placeholder:"Filter scenarios…",render:u=>e.jsxs("button",{onClick:()=>Se(u.file,u.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug flex-1",children:u.name}),e.jsx(H,{size:12,className:"shrink-0 mt-0.5 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-1",children:[e.jsx("span",{className:"text-xs text-gray-500 truncate",children:u.feature||u.file}),(u.tags||[]).slice(0,4).map($=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-300 border border-brand-500/20",children:$},$))]})]},u.id)}),t.reaches.length>0&&e.jsx(ke,{title:"Reaches methods",count:t.reaches.length,icon:e.jsx(be,{size:13,className:"text-brand-400"}),children:e.jsx("div",{className:"space-y-1.5",children:t.reaches.map(u=>e.jsxs("button",{onClick:()=>n(u.id),title:"Open in Code Map · Inventory",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 truncate",children:[u.className&&e.jsxs("span",{className:"text-gray-500",children:[u.className,"."]}),u.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate max-w-[180px]",title:`${u.file}:${u.startLine}`,children:u.file}),e.jsx(_e,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]},u.id))})}),e.jsx(ke,{title:"Step definition",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:t.source||"(source unavailable)",lang:t.language})})]})]})}function Ds(){const[t,r]=o.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("light"));return o.useEffect(()=>{const n=document.documentElement,l=new MutationObserver(()=>r(n.classList.contains("light")));return l.observe(n,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),t}function Os(t,r){return(r?{focus:["#6d28d9","#7c3aed","#ffffff"],test:["#d1fae5","#34d399","#065f46"],caller:["#dbeafe","#60a5fa","#1e40af"],callee:["#f1f5f9","#cbd5e1","#334155"],unused:["#fef3c7","#f59e0b","#92400e"]}:{focus:["#6d28d9","#a78bfa","#ffffff"],test:["rgba(16,185,129,0.16)","rgba(16,185,129,0.55)","#6ee7b7"],caller:["rgba(59,130,246,0.16)","rgba(59,130,246,0.55)","#93c5fd"],callee:["rgba(148,163,184,0.14)","rgba(148,163,184,0.45)","#cbd5e1"],unused:["rgba(245,158,11,0.16)","rgba(245,158,11,0.55)","#fcd34d"]})[t]}function Fs(t,r){return(r?{focus:"#7c3aed",test:"#10b981",caller:"#3b82f6",callee:"#94a3b8",unused:"#f59e0b"}:{focus:"#a78bfa",test:"#34d399",caller:"#60a5fa",callee:"#94a3b8",unused:"#fbbf24"})[t]}const Ps=240,jt=4;function it(t,r){const[n,l,i]=Os(t,r);return{background:n,color:i,border:`1.5px solid ${l}`,borderRadius:10,width:Ps,padding:"8px 12px",fontSize:12,fontWeight:t==="focus"?600:500,lineHeight:"16px",textAlign:"center",whiteSpace:"normal",wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:jt,WebkitBoxOrient:"vertical",overflow:"hidden",transition:"opacity 0.15s ease",boxShadow:t==="focus"?"0 0 0 4px rgba(109,40,217,0.18)":"0 1px 2px rgba(0,0,0,0.12)"}}function Is(t){return Math.min(jt,Math.max(1,Math.ceil(t.length/30)))}const Bs=[{kind:"test",label:"Test"},{kind:"caller",label:"Caller"},{kind:"focus",label:"Focus"},{kind:"callee",label:"Callee"},{kind:"unused",label:"Unused"}];function Us({symbols:t,onOpenSymbol:r}){const{toast:n}=_(),l=Ds(),i=o.useMemo(()=>{var j;return((j=[...t.filter(S=>!S.isEntryPoint&&S.role!=="test")].sort((S,C)=>C.usedByTestCount+C.callerCount-(S.usedByTestCount+S.callerCount))[0])==null?void 0:j.id)||null},[t]),[m,b]=o.useState(null),[p,a]=o.useState(""),[c,y]=o.useState(!1),[h,u]=o.useState(null),[$,z,q]=$t([]),[M,T,x]=Et([]),[N,O]=o.useState(!1),[w,E]=o.useState(null),W=o.useRef(null);o.useEffect(()=>{!m&&i&&b(i)},[i,m]),o.useEffect(()=>{m&&(O(!0),Zt(m,2).then(f=>{const j=new Map,S=new Map;f.edges.forEach(g=>{(j.get(g.source)||j.set(g.source,[]).get(g.source)).push(g.target),(S.get(g.target)||S.set(g.target,[]).get(g.target)).push(g.source)});const C=new Map;C.set(f.focus,2),f.edges.forEach(g=>{var R;g.target===f.focus&&!C.has(g.source)&&C.set(g.source,((R=f.nodes.find(V=>V.id===g.source))==null?void 0:R.type)==="test"?0:1),g.source===f.focus&&!C.has(g.target)&&C.set(g.target,3)}),f.nodes.forEach(g=>{C.has(g.id)||C.set(g.id,g.type==="test"?0:4)});const F={};f.nodes.forEach(g=>{const R=C.get(g.id);(F[R]=F[R]||[]).push(g.id)});const P=new Map(f.nodes.map(g=>[g.id,g.label])),Z=new Map,B=22,d=16,L=18;Object.entries(F).forEach(([g,R])=>{let V=0;R.forEach(te=>{Z.set(te,{x:Number(g)*340,y:V});const se=Is(P.get(te)||"")*d+L;V+=se+B})});const K=g=>g.id===f.focus?"focus":g.type==="test"?"test":g.unused?"unused":(C.get(g.id)??4)<2?"caller":"callee",v={};f.nodes.forEach(g=>{v[g.id]=K(g)});const A=f.nodes.map(g=>({id:g.id,position:Z.get(g.id)||{x:0,y:0},data:{label:g.type==="test"?fe(g.label):g.label},sourcePosition:"right",targetPosition:"left",style:it(v[g.id],l)})),U=f.edges.map((g,R)=>{const V=v[g.source]??"callee",te=Fs(V,l);return{id:`e${R}`,source:g.source,target:g.target,type:"bezier",data:{srcKind:V},interactionWidth:0,style:{stroke:te,strokeWidth:1.5,strokeOpacity:.55},markerEnd:{type:Tt.ArrowClosed,color:te,width:16,height:16}}});u({nodes:A,edges:U,truncated:f.truncated,kinds:v})}).catch(f=>n("error",String(f))).finally(()=>O(!1)))},[m,l]);const Q=o.useMemo(()=>{const f=t.filter(C=>!C.isEntryPoint),j=p.trim().toLowerCase();return(j?f.filter(C=>C.name.toLowerCase().includes(j)||(C.className||"").toLowerCase().includes(j)).sort((C,F)=>C.name.localeCompare(F.name)):[...f].sort((C,F)=>F.usedByTestCount+F.callerCount-(C.usedByTestCount+C.callerCount))).slice(0,60)},[p,t]),ee=o.useMemo(()=>{const f=new Map;return h==null||h.edges.forEach(j=>{(f.get(j.source)||f.set(j.source,new Set).get(j.source)).add(j.target),(f.get(j.target)||f.set(j.target,new Set).get(j.target)).add(j.source)}),f},[h]);return o.useEffect(()=>{if(!h){z([]),T([]);return}E(null),z(h.nodes),T(h.edges)},[h]),o.useEffect(()=>{const f=w?ee.get(w):null;z(j=>j.map(S=>{var P;const F=!w||S.id===w||(f==null?void 0:f.has(S.id))?1:.18;return(((P=S.style)==null?void 0:P.opacity)??1)===F?S:{...S,style:{...S.style,opacity:F}}})),T(j=>j.map(S=>{var B,d;const C=!!w&&(S.source===w||S.target===w),P=!!w&&!C?.06:C?1:.55,Z=C?2.5:1.5;return!!S.animated===C&&(((B=S.style)==null?void 0:B.strokeOpacity)??.55)===P&&(((d=S.style)==null?void 0:d.strokeWidth)??1.5)===Z?S:{...S,animated:C,zIndex:C?1:0,style:{...S.style,strokeOpacity:P,strokeWidth:Z}}}))},[w,ee]),o.useEffect(()=>{if(!h)return;const f=setTimeout(()=>{var j;return(j=W.current)==null?void 0:j.fitView({padding:.25,duration:350})},80);return()=>clearTimeout(f)},[h]),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-white/5 bg-surface-1/50 flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Focus:"}),e.jsxs("div",{className:"relative",children:[e.jsx(oe,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:f=>a(f.target.value),onFocus:()=>y(!0),onBlur:()=>setTimeout(()=>y(!1),150),placeholder:"click to browse, or type to filter methods…",className:"w-80 pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),c&&Q.length>0&&e.jsxs("div",{className:"absolute z-20 mt-1 w-80 max-h-72 overflow-auto rounded-xl border border-white/10 bg-surface-1 shadow-xl py-1",children:[e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5 sticky top-0 bg-surface-1",children:p.trim()?`${Q.length} match${Q.length===1?"":"es"}`:"All methods · most connected first"}),Q.map(f=>e.jsxs("button",{onMouseDown:j=>j.preventDefault(),onClick:()=>{b(f.id),a(""),y(!1)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-white/5 transition-colors ${f.id===m?"bg-brand-500/10":""}`,children:[e.jsxs("span",{className:"font-mono text-gray-200",children:[f.className?`${f.className}.`:"",f.name]}),e.jsxs("span",{className:"text-gray-600",children:[" · ",f.file]})]},f.id))]})]}),e.jsxs("span",{className:"hidden lg:flex items-center gap-1.5 text-[11px] text-gray-500",children:[e.jsx("span",{className:"font-medium text-gray-400",children:"tests"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callers"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-brand-400",children:"focus"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callees"}),e.jsx("span",{className:"text-gray-600 ml-1",children:"· hover to trace · click to re-center · double-click to inspect"})]}),(h==null?void 0:h.truncated)&&e.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-amber-400",children:[e.jsx(me,{size:12})," graph truncated (large neighborhood)"]})]}),e.jsxs("div",{className:"flex-1 relative bg-surface-0",children:[N&&e.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center text-sm text-gray-500 bg-surface-0/60 backdrop-blur-sm",children:[e.jsx(I,{size:16,className:"animate-spin mr-2"})," Building graph…"]}),m?h&&e.jsxs(Lt,{nodes:$,edges:M,onNodesChange:q,onEdgesChange:x,onInit:f=>{W.current=f},fitView:!0,minZoom:.2,fitViewOptions:{padding:.25},nodesConnectable:!1,nodesDraggable:!0,onNodeClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&b(j.id)},onNodeDoubleClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&r(j.id)},onNodeMouseEnter:(f,j)=>E(j.id),onNodeMouseLeave:()=>E(null),proOptions:{hideAttribution:!0},children:[e.jsx(Mt,{color:l?"#cbd5e1":"#2c2d36",gap:22,size:1}),e.jsx(Rt,{showInteractive:!1,className:"cm-graph-controls"}),e.jsx(At,{position:"top-right",children:e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-xl border border-white/10 bg-surface-1/95 backdrop-blur px-3 py-2.5 shadow-lg",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide font-semibold text-gray-500 mb-0.5",children:"Legend"}),Bs.map(f=>{const j=it(f.kind,l);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded-md shrink-0",style:{background:j.background,border:j.border}}),e.jsx("span",{className:"text-[11px] text-gray-400",children:f.label})]},f.kind)})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 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",children:e.jsx(_e,{size:22})}),e.jsx("div",{className:"text-sm",children:"Search for a method above to view its call graph."})]})]})]})}function _s({files:t}){const r=o.useMemo(()=>{const l=new Map;for(const i of t){const m=i.file.replace(/\\/g,"/").split("/")[0]||"(root)",b=l.get(m)||{files:0,methods:0,unused:0,dup:0,cxSum:0,scoreSum:0};b.files+=1,b.methods+=i.methods,b.unused+=i.unused,b.dup+=i.duplicated,b.cxSum+=i.avgComplexity*i.methods,b.scoreSum+=i.score,l.set(m,b)}return[...l.entries()].map(([i,m])=>({name:i,files:m.files,methods:m.methods,unused:m.unused,dup:m.dup,avgCx:m.methods?Math.round(m.cxSum/m.methods*10)/10:0,score:m.files?Math.round(m.scoreSum/m.files):0})).sort((i,m)=>i.score-m.score)},[t]);if(r.length===0)return null;const n=l=>l>=80?"text-emerald-400":l>=70?"text-amber-400":l>=60?"text-orange-400":"text-red-400";return e.jsx(G,{title:"Module overview",hint:"Aggregated by top-level folder. Lowest health first.",children:e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-2",children:r.map(l=>e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 hover:bg-surface-2/60 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-mono text-base text-gray-200 truncate",title:l.name,children:[l.name,"/"]}),e.jsx("span",{className:`text-base font-semibold tabular-nums ${n(l.score)}`,children:l.score})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[l.files," files"]}),e.jsxs("span",{children:[l.methods," methods"]}),e.jsxs("span",{children:["avg cx ",l.avgCx]}),l.unused>0&&e.jsxs("span",{className:"text-amber-400",children:[l.unused," unused"]}),l.dup>0&&e.jsxs("span",{className:"text-amber-400",children:[l.dup," dup"]})]})]},l.name))})})}export{Js as CodeMapPage};
1
+ import{u as zt,e as ot,r as o,j as e,b as Xe}from"./vendor-react-CTbHBddL.js";import{u as $t,a as Et,M as Tt,i as Lt,B as Mt,C as Rt,P as At}from"./vendor-flow-YGpC9U9I.js";import{u as Dt}from"./useTabParam-ChbOedP1.js";import{h as Ot}from"./aiHandoff-vhtR29Fh.js";import{f as fe}from"./formatTestName-BKd2Uqhs.js";import{a8 as ce,b as _,cm as Ye,cn as Ft,co as It,cp as Pt,cq as Je,cr as Bt,cs as Ut,ct as _t,cu as qt,cv as Kt,cw as Ht,cx as Vt,cy as Gt,cz as Wt,cA as Qt,cB as Zt,cC as Xt,cD as Yt,cE as Jt,cF as es,cG as ts,s as ss,cH as as,cI as rs,cJ as ns,cK as ls}from"./index-BYVxKLrT.js";import{a0 as P,o as me,aj as is,_ as H,bg as we,S as ne,a1 as Fe,b4 as Ae,a9 as de,R as ct,$ as be,ah as ue,cB as os,aY as dt,d as cs,a8 as ds,v as oe,X as xe,b7 as xs,an as ms,az as xt,aa as mt,by as Be,y as us,cC as Ie,b as ps,a5 as ut,r as Ue,aI as ge,cm as et,bz as tt,cD as hs,N as _e,bA as pt,ag as Ce,a2 as bs}from"./vendor-icons-BKPiFyYV.js";import{A as ht}from"./AIStreamUI-C3D989_6.js";import"./vendor-charts-DWFQlmCz.js";import"./vendor-query-BrzmPFT3.js";const pe={file:{label:"file",cls:"text-sky-400 bg-sky-500/10 border-sky-500/20"},provider:{label:"inline",cls:"text-violet-400 bg-violet-500/10 border-violet-500/20"},fixture:{label:"fixture",cls:"text-purple-400 bg-purple-500/10 border-purple-500/20"},hardcoded:{label:"hardcoded",cls:"text-amber-400 bg-amber-500/10 border-amber-500/20"},dynamic:{label:"dynamic",cls:"text-rose-400 bg-rose-500/10 border-rose-500/20"}},bt="••••••••",ae=t=>t==="file"||t==="fixture";function De(t,r){window.open(`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`,"_blank","noopener")}function ft(t,r){window.open(`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`,"_blank","noopener")}function Oe(t){const r=(t.split(/[/\\]/).pop()||t).replace(/\.[^.]+$/,"");return r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_.]+/g," ").replace(/\s+/g," ").trim().split(" ").map(n=>n&&n.charAt(0).toUpperCase()+n.slice(1)).join(" ")||r}function le({icon:t,value:r,label:n,tone:l}){const i=l==="amber"&&r>0?"bg-amber-500/10 border-amber-500/20":l==="rose"&&r>0?"bg-rose-500/10 border-rose-500/20":"bg-surface-2/50 border-white/5";return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${i}`,children:[e.jsx("span",{className:"text-gray-500",children:t}),e.jsx("span",{className:"text-lg font-bold text-gray-100 tabular-nums",children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:n})]})}const ye="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 disabled:opacity-50";function st({kv:t,revealed:r,onToggle:n,rk:l,tests:i,usageOpen:m,onToggleUsage:b}){const p=t.sensitive&&!r.has(l),a=t.usedBy||[],c=m.has(l);return e.jsxs("div",{className:"border-b border-white/5 last:border-0",children:[e.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-2.5",children:[e.jsx("span",{className:"w-44 flex-shrink-0 font-mono text-[13px] text-gray-400 break-words",children:t.key}),e.jsx("span",{className:`flex-1 font-mono text-[13px] break-words whitespace-pre-wrap ${p?"text-gray-500":"text-gray-200"}`,children:p?bt:t.value||e.jsx("span",{className:"text-gray-600 italic",children:"empty"})}),a.length>0&&e.jsxs("button",{onClick:()=>b(l),className:`flex-shrink-0 inline-flex items-center gap-1 text-[11px] font-medium px-2 py-0.5 rounded-md border transition-colors ${c?"border-cyan-600/60 text-cyan-700 bg-cyan-500/15 dark:border-cyan-500/40 dark:text-cyan-300 dark:bg-cyan-500/10":"border-cyan-600/50 text-cyan-700 hover:bg-cyan-500/10 dark:border-cyan-500/30 dark:text-cyan-400 dark:hover:text-cyan-300"}`,title:c?"Hide tests":"Show tests that use this field",children:[e.jsx(Be,{size:11})," ",a.length," test",a.length!==1?"s":"",e.jsx(us,{size:12,className:`transition-transform ${c?"rotate-180":""}`})]}),t.sensitive?e.jsx("button",{onClick:()=>n(l),className:"flex-shrink-0 text-gray-500 hover:text-amber-300 mt-0.5",title:p?"Reveal":"Hide",children:p?e.jsx(mt,{size:14}):e.jsx(de,{size:14})}):e.jsx("span",{className:"flex-shrink-0 text-[10px] text-gray-600 mt-1 w-9 text-right",children:"plain"})]}),c&&a.length>0&&e.jsx("div",{className:"px-3.5 pb-2.5 pl-[12.5rem] space-y-0.5",children:a.map(y=>{const h=i.find(u=>u.id===y);return h?e.jsxs("button",{onClick:()=>ft(h.file,h.name),className:"flex items-center gap-1.5 w-full text-left text-xs text-gray-400 hover:text-cyan-300 truncate",children:[e.jsx(we,{size:12,className:"flex-shrink-0 text-gray-600"}),e.jsx("span",{className:"truncate",title:h.name,children:fe(h.name)}),e.jsxs("span",{className:"text-gray-600 flex-shrink-0",children:["· ",h.file.split(/[/\\]/).pop(),":",h.line]})]},y):null})})]})}function at({columns:t,rows:r,truncated:n,totalRows:l,keyPrefix:i,revealed:m,onToggle:b,bare:p,tests:a}){return e.jsxs("div",{className:`${p?"":"bg-surface-1 border border-white/5 rounded-xl "}overflow-auto max-h-[60vh]`,children:[e.jsxs("table",{className:"w-full text-sm border-collapse",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-2 z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-10 px-2 py-2.5 text-[11px] text-gray-600 border-b border-white/5 text-right",children:"#"}),t.map((c,y)=>e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-semibold text-gray-400 border-b border-white/5 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[c.name,c.sensitive&&e.jsx("button",{onClick:()=>b(`${i}:${y}`),className:"text-amber-400/70 hover:text-amber-300",title:m.has(`${i}:${y}`)?"Hide column":"Reveal column",children:m.has(`${i}:${y}`)?e.jsx(de,{size:12}):e.jsx(xt,{size:12})}),c.usedBy&&c.usedBy.length>0&&e.jsxs("span",{className:"text-[10px] font-normal text-cyan-700 dark:text-cyan-400/80 normal-case",title:c.usedBy.map(h=>{var u;return(u=a.find($=>$.id===h))==null?void 0:u.name}).filter(Boolean).join(", "),children:["· ",c.usedBy.length," test",c.usedBy.length!==1?"s":""]})]})},y))]})}),e.jsx("tbody",{children:r.map((c,y)=>e.jsxs("tr",{className:"hover:bg-surface-2/40",children:[e.jsx("td",{className:"px-2 py-2 text-[11px] text-gray-600 border-b border-white/5 text-right tabular-nums",children:y+1}),t.map((h,u)=>{const $=h.sensitive&&!m.has(`${i}:${u}`),z=c[u]??"";return e.jsx("td",{title:$?void 0:z,className:`px-3 py-2 border-b border-white/5 font-mono text-xs truncate max-w-[280px] ${$?"text-gray-500":"text-gray-300"}`,children:$?bt:z},u)})]},y))})]}),n&&e.jsxs("div",{className:"px-3 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first ",r.length," of ",l," rows."]})]})}function fs({p:t,revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m}){const b={revealed:r,onToggle:n,tests:l,usageOpen:i,onToggleUsage:m};if(!t)return e.jsx("div",{className:"text-sm text-gray-600",children:"No preview available for this source."});if(t.shape==="none")return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-2 py-3",children:[e.jsx(dt,{size:15})," ",t.note||"Not previewable."]});if(t.shape==="raw"){const p=t.masked&&!r.has("raw");return e.jsxs(e.Fragment,{children:[(t.masked||r.has("raw"))&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 mb-2",children:[e.jsx(xt,{size:12,className:"text-amber-400/70"}),p?"Secret values in this file are hidden.":"Showing secret values.",e.jsx("button",{onClick:()=>n("raw"),className:"text-amber-400/80 hover:text-amber-300 inline-flex items-center gap-1",children:p?e.jsxs(e.Fragment,{children:[e.jsx(mt,{size:12})," Reveal"]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{size:12})," Hide"]})})]}),e.jsx("pre",{className:"text-[13px] font-mono text-gray-300 bg-surface-1 border border-white/5 rounded-xl p-4 overflow-auto max-h-[60vh] whitespace-pre-wrap break-words",children:t.raw})]})}return t.shape==="sections"?e.jsx("div",{className:"space-y-4",children:(t.sections||[]).map((p,a)=>{var h,u;const c=!!p.columns,y=c?p.totalRows??((h=p.rows)==null?void 0:h.length)??0:((u=p.pairs)==null?void 0:u.length)??0;return e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-3.5 py-2.5 bg-surface-1 border-b border-white/5 flex items-center gap-2",children:[c?e.jsx(we,{size:13,className:"text-sky-400"}):e.jsx(be,{size:13,className:"text-cyan-400"}),e.jsx("span",{className:"font-mono text-sm text-gray-200",children:p.name}),e.jsxs("span",{className:"text-[11px] text-gray-600",children:["· ",y," ",c?"row":"field",y!==1?"s":""]})]}),c?e.jsx(at,{columns:p.columns,rows:p.rows||[],truncated:p.truncated,totalRows:p.totalRows,keyPrefix:`sec${a}`,revealed:r,onToggle:n,tests:l,bare:!0}):(p.pairs||[]).map(($,z)=>e.jsx(st,{kv:$,rk:`sec:${a}:${z}`,...b},z))]},a)})}):t.shape==="keyvalue"?e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:(t.pairs||[]).map((p,a)=>e.jsx(st,{kv:p,rk:`kv:${a}`,...b},a))}):e.jsx(at,{columns:t.columns||[],rows:t.rows||[],truncated:t.truncated,totalRows:t.totalRows,keyPrefix:"col",revealed:r,onToggle:n,tests:l})}function gs(){var Ze;const t=zt(),[r,n]=ot(),l=r.get("source"),[i,m]=o.useState(null),[b,p]=o.useState(!0),[a,c]=o.useState(null),[y,h]=o.useState(!1),[u,$]=o.useState(""),[z,q]=o.useState("all"),[M,T]=o.useState("all"),[x,N]=o.useState(null),[O,w]=o.useState(!1),[E,W]=o.useState(new Set),{hasRole:Q}=ce(),{toast:ee}=_(),[f,j]=o.useState(null),S=o.useRef(null),C=s=>W(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),F=s=>{var D;if(E.has(s)||f||!((D=x==null?void 0:x.preview)!=null&&D.masked)){C(s);return}if(!Q("tester")){ee("info","Only testers and admins can reveal secret values.");return}const k=l;k&&Ye(k,!0).then(Re=>{S.current===k&&(j(Re.preview),C(s))}).catch(Re=>ee("error",String(Re)))},[I,Z]=o.useState(new Set),B=s=>Z(k=>{const D=new Set(k);return D.has(s)?D.delete(s):D.add(s),D}),[d,L]=o.useState({included:[],ignored:[]}),[K,v]=o.useState(!1),[A,U]=o.useState(!1),[g,R]=o.useState([]),[V,te]=o.useState(!1),[se,ze]=o.useState(""),[Ke,$e]=o.useState(null),He=()=>It().then(L).catch(()=>{}),Ee=(s=!1)=>{c(null),Ft(s).then(m).catch(k=>c(String(k))).finally(()=>{p(!1),h(!1)})};o.useEffect(()=>{Ee(),He()},[]);const Te=()=>{Ee(!0),He()},Le=s=>{$e(null),Ut(s).then(()=>{ze(""),Te(),Ve()}).catch(k=>$e(String(k)))},Nt=s=>{(s.manual?Je(s.file,"included"):Bt(s.file)).then(Te).catch(()=>{})},vt=s=>Je(s,"ignored").then(Te).catch(()=>{}),Ve=()=>{te(!0),_t().then(s=>R(s.candidates)).catch(()=>R([])).finally(()=>te(!1))},wt=()=>{v(!0),ze(""),$e(null),Ve()},Me=Q("tester");o.useEffect(()=>{if(S.current=l,j(null),!l){N(null);return}w(!0),W(new Set),Z(new Set),Ye(l).then(s=>N({source:s.source,preview:s.preview,tests:s.tests})).catch(()=>N(null)).finally(()=>w(!1))},[l]);const kt=()=>{h(!0),Pt().then(()=>Ee(!1)).catch(s=>{c(String(s)),h(!1)})},Ct=s=>n(k=>{const D=new URLSearchParams(k);return D.set("source",s.id),D},{replace:!0}),St=()=>n(s=>{const k=new URLSearchParams(s);return k.delete("source"),k},{replace:!0}),Ge=s=>Ot(t,{prompt:s,mode:"web"}),We=o.useMemo(()=>{if(!i)return[];const s=u.trim().toLowerCase();return i.sources.filter(k=>!(z!=="all"&&k.kind!==z||M==="orphans"&&!k.orphan||M==="indirect"&&!k.indirect||M==="secrets"&&!k.isSecret||s&&!(k.label.toLowerCase().includes(s)||k.file.toLowerCase().includes(s)||(k.searchText||"").includes(s)))).sort((k,D)=>D.usedByTestCount-k.usedByTestCount)},[i,u,z,M]);if(b)return e.jsxs("div",{className:"flex items-center justify-center h-full text-gray-500 gap-2",children:[e.jsx(P,{size:18,className:"animate-spin"})," Scanning test data…"]});if(a)return e.jsxs("div",{className:"flex items-center justify-center h-full text-red-400 gap-2",children:[e.jsx(me,{size:18})," ",a]});if(!i)return null;if(l){const s=x==null?void 0:x.source;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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.jsxs("button",{onClick:St,className:ye,children:[e.jsx(is,{size:15})," Test Data"]}),s&&e.jsx("span",{className:`text-sm text-gray-200 truncate ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),s&&e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"ml-auto text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1.5 text-sm",children:[e.jsx(H,{size:14})," Open file"]})]}),e.jsx("div",{className:"flex-1 overflow-auto px-5 py-4",children:e.jsx("div",{className:"max-w-[1100px] mx-auto",children:O||!s?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-10 justify-center",children:[e.jsx(P,{size:16,className:"animate-spin"})," Reading data…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label}),s.format&&e.jsx("span",{className:"text-[11px] text-gray-500 uppercase",children:s.format}),((Ze=x==null?void 0:x.preview)==null?void 0:Ze.totalRows)!=null&&e.jsxs("span",{className:"text-[11px] text-gray-500",children:[x.preview.totalRows," ",x.preview.shape==="table"?"rows":x.preview.shape==="sections"?"groups":"fields"]}),s.isDynamic&&e.jsx("span",{className:"text-[11px] text-rose-400",children:"non-deterministic"}),s.isSecret&&e.jsx("span",{className:"text-[11px] text-amber-400",children:"PII / secret"})]}),e.jsx("h1",{className:`text-lg text-gray-100 break-all ${ae(s.kind)?"":"font-mono"}`,children:ae(s.kind)?Oe(s.label):s.label}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsxs("button",{onClick:()=>De(s.file,s.line),title:"Open in Project Explorer (new tab)",className:"text-gray-500 hover:text-cyan-300 inline-flex items-center gap-1",children:[s.file,s.line?`:${s.line}`:""," ",e.jsx(H,{size:10})]})," ","· used by ",(x==null?void 0:x.tests.length)??s.usedByTestCount," test",((x==null?void 0:x.tests.length)??s.usedByTestCount)!==1?"s":""]})]}),ae(s.kind)?e.jsx(fs,{p:(f&&(f.shape!=="raw"||E.has("raw"))?f:x==null?void 0:x.preview)??null,revealed:E,onToggle:F,tests:(x==null?void 0:x.tests)??[],usageOpen:I,onToggleUsage:B}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl p-4 font-mono text-sm text-gray-300 break-all",children:s.label}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("h2",{className:"text-sm font-semibold text-gray-300 mb-2",children:["Used by ",(x==null?void 0:x.tests.length)??0," test",((x==null?void 0:x.tests.length)??0)!==1?"s":""]}),((x==null?void 0:x.tests.length)??0)===0?e.jsx("div",{className:"text-sm text-gray-600",children:s.orphan?"No test references this — it may be dead data.":s.indirect?"Loaded via a helper / non-test file — not attributable to a specific test.":"No mapped tests."}):e.jsx("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:x.tests.map(k=>e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-white/5 last:border-0 hover:bg-surface-2/40 group",children:[e.jsx(we,{size:14,className:"text-gray-500 flex-shrink-0"}),e.jsx("button",{onClick:()=>ft(k.file,k.name),title:"Open in Test Explorer (new tab)",className:"flex-1 text-left text-sm text-gray-300 hover:text-cyan-300 truncate",children:fe(k.name)}),e.jsxs("button",{onClick:()=>De(k.file,k.line),title:"Open file in Project Explorer (new tab)",className:"text-[11px] text-gray-600 hover:text-gray-300 truncate max-w-[240px] inline-flex items-center gap-1 flex-shrink-0",children:[k.file.split(/[/\\]/).pop(),":",k.line," ",e.jsx(H,{size:11,className:"opacity-0 group-hover:opacity-70"})]})]},k.id))})]}),(s.kind==="hardcoded"||s.kind==="dynamic")&&e.jsx("div",{className:"mt-5",children:e.jsxs("button",{onClick:()=>Ge(s.kind==="hardcoded"?`The value "${s.label}" is hardcoded as test data in my tests (${s.file}). Analyze its usages and suggest how to externalize it into a managed dataset or environment variable. Show me the plan first.`:`The tests use dynamic/random data via "${s.label}". Analyze which tests rely on it and whether it introduces non-determinism, and suggest a strategy (seeded data / fixtures). Plan only.`),className:"inline-flex items-center gap-1.5 px-3 py-2 text-sm rounded-xl border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10",children:[e.jsx(ne,{size:14})," ",s.kind==="hardcoded"?"Externalize with AI":"Analyze with AI"," ",e.jsx(H,{size:12})]})})]})})})]})}const Y=i.stats,Qe=s=>`px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${s?"bg-cyan-500/15 text-cyan-300 border-cyan-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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(Fe,{size:18,className:"text-gray-900 dark:text-gray-100 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Test data sources, test usage & duplicates"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[Y.filesScanned," files · ",Y.durationMs,"ms"]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[Me&&e.jsxs("button",{onClick:wt,className:ye,title:"Add a test data file the scan missed",children:[e.jsx(Ae,{size:14})," Add file"]}),d.ignored.length>0&&e.jsxs("button",{onClick:()=>U(!0),className:ye,title:"Manage ignored files",children:[e.jsx(de,{size:14})," Ignored (",d.ignored.length,")"]}),e.jsxs("button",{onClick:kt,disabled:y,className:ye,children:[y?e.jsx(P,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rescan"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(le,{icon:e.jsx(be,{size:15}),value:Y.total,label:"data sources"}),e.jsx(le,{icon:e.jsx(Fe,{size:15}),value:Y.testsMapped,label:"tests mapped"}),e.jsx(le,{icon:e.jsx(ue,{size:15}),value:Y.duplicateClusters,label:"duplicates",tone:"amber"}),e.jsx(le,{icon:e.jsx(os,{size:15}),value:Y.dynamicCount,label:"dynamic / random"}),e.jsx(le,{icon:e.jsx(dt,{size:15}),value:Y.orphanCount,label:"orphan files"}),e.jsx(le,{icon:e.jsx(cs,{size:15}),value:Y.indirectCount??0,label:"used indirectly"}),e.jsx(le,{icon:e.jsx(ds,{size:15}),value:Y.hardcodedSecrets,label:"hardcoded secrets",tone:"rose"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[220px]",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:u,onChange:s=>$(s.target.value),placeholder:"Search name, path, or data contents (keys & values)…",className:"w-full pl-9 pr-9 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),u&&e.jsx("button",{onClick:()=>$(""),title:"Clear search",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:15})})]}),["all","file","fixture","provider","dynamic","hardcoded"].map(s=>e.jsx("button",{onClick:()=>{q(z===s?"all":s),T("all")},className:Qe(s==="all"?z==="all"&&M==="all":z===s),children:s==="all"?"All":pe[s].label},s)),["orphans","indirect","secrets"].map(s=>e.jsx("button",{onClick:()=>{T(M===s?"all":s),q("all")},className:Qe(M===s),children:s},s))]}),e.jsxs("div",{className:"flex-1 overflow-auto",children:[We.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-600 gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-surface-2 border border-white/5 flex items-center justify-center",children:e.jsx(oe,{size:22})}),e.jsx("span",{className:"text-sm",children:"No data sources match."})]}):e.jsxs("table",{className:"w-full text-sm border-collapse bg-surface-1",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Source"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Kind"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Rows"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Used by"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Flags"}),e.jsx("th",{className:"w-12 px-2 pr-5 py-2.5 border-b border-white/5"})]})}),e.jsx("tbody",{children:We.map(s=>e.jsxs("tr",{onClick:()=>Ct(s),className:"hover:bg-surface-2/40 cursor-pointer group",children:[e.jsx("td",{className:"px-5 py-2.5 border-b border-white/5 max-w-[420px]",children:ae(s.kind)?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-gray-200 truncate",children:Oe(s.label)}),e.jsx("div",{className:"text-[11px] text-gray-500 font-mono truncate",title:s.label,children:s.label})]}):e.jsx("div",{className:"font-mono text-gray-200 truncate",title:s.label,children:s.label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded border ${pe[s.kind].cls}`,children:pe[s.kind].label})}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right text-xs text-gray-500 tabular-nums",children:ae(s.kind)?`${s.rowCount??"–"} · ${s.format??""}`:"—"}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:s.usedByTestCount}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-[11px]",children:[s.manual&&e.jsx("span",{className:"text-cyan-400 mr-1",children:"added"}),s.orphan&&e.jsx("span",{className:"text-gray-500 mr-1",children:"orphan"}),s.indirect&&e.jsx("span",{className:"text-sky-400/80 mr-1",title:"Used via a helper / non-test file",children:"indirect"}),s.isDynamic&&e.jsx("span",{className:"text-rose-400 mr-1",children:"random"}),s.isSecret&&e.jsx("span",{className:"text-amber-400",children:"PII/secret"})]}),e.jsx("td",{className:"px-2 py-2.5 pr-5 border-b border-white/5 text-right",children:Me&&ae(s.kind)&&e.jsx("button",{onClick:k=>{k.stopPropagation(),Nt(s)},title:s.manual?"Remove added file":"Hide & ignore this file",className:"text-gray-500 hover:text-rose-400 opacity-0 group-hover:opacity-100 transition-opacity",children:s.manual?e.jsx(xs,{size:14}):e.jsx(de,{size:14})})})]},s.id))})]}),i.duplicates.length>0&&e.jsxs("div",{className:"px-5 py-5",children:[e.jsxs("h2",{className:"flex items-center gap-2 mb-2 text-sm font-semibold text-gray-300",children:[e.jsx(ue,{size:15,className:"text-amber-400"})," Duplicate data (",i.duplicates.length,")"]}),e.jsxs("div",{className:"bg-surface-1 border border-white/5 rounded-xl overflow-hidden",children:[i.duplicates.slice(0,30).map(s=>e.jsxs("div",{className:"flex items-center px-4 py-2.5 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-gray-200 truncate pr-2",children:s.value}),e.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded text-amber-400 bg-amber-500/10 border border-amber-500/20 mr-3",children:s.type}),e.jsxs("span",{className:"text-gray-400 text-xs mr-3 tabular-nums",children:["×",s.count]}),e.jsxs("button",{onClick:()=>Ge(`In my test project, the test data "${s.value}" is duplicated in ${s.count} places (${s.type}). Analyze where it's used and suggest how to consolidate it into a single shared dataset or constant. Plan only.`),className:"inline-flex items-center gap-1 text-[11px] text-cyan-400 hover:text-cyan-300",children:[e.jsx(ne,{size:12})," consolidate"]})]},s.fingerprint)),i.duplicates.length>30&&e.jsxs("div",{className:"px-4 py-2 text-[11px] text-gray-500 border-t border-white/5",children:["Showing first 30 of ",i.duplicates.length," duplicate clusters."]})]})]})]}),K&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>v(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Ae,{size:16})," Add test data file"]}),e.jsx("button",{onClick:()=>v(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Data-ish files the scan didn't capture:"}),V?e.jsxs("div",{className:"flex items-center gap-2 text-gray-500 text-sm py-4",children:[e.jsx(P,{size:14,className:"animate-spin"})," Finding files…"]}):g.length===0?e.jsx("div",{className:"text-sm text-gray-600 py-2 mb-2",children:"No uncaptured candidate files found."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[40vh] overflow-y-auto mb-4",children:g.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0 hover:bg-surface-2/40",children:[e.jsx(we,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s.file,children:s.file}),e.jsx("span",{className:"text-[10px] text-gray-600 uppercase",children:s.format}),e.jsxs("button",{onClick:()=>Le(s.file),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(Ae,{size:12})," add"]})]},s.file))}),e.jsx("p",{className:"text-xs text-gray-500 mb-1.5",children:"Or add by path (relative to project):"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:se,onChange:s=>ze(s.target.value),placeholder:"e.g. src/test/resources/data.csv",className:"flex-1 bg-surface-2 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-cyan-500/50",onKeyDown:s=>{s.key==="Enter"&&se.trim()&&Le(se.trim())}}),e.jsx("button",{onClick:()=>se.trim()&&Le(se.trim()),disabled:!se.trim(),className:"px-3 py-2 text-sm rounded-lg border border-cyan-500/30 text-cyan-300 hover:bg-cyan-500/10 disabled:opacity-40",children:"Add"})]}),Ke&&e.jsx("p",{className:"text-xs text-rose-400 mt-2",children:Ke})]})]})}),document.body),A&&Xe.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/70 z-50 flex items-center justify-center p-4",onClick:()=>U(!1),children:e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/10 max-w-lg w-full max-h-[80vh] flex flex-col",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-white/5",children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(de,{size:16})," Ignored files (",d.ignored.length,")"]}),e.jsx("button",{onClick:()=>U(!1),className:"text-gray-500 hover:text-gray-300",children:e.jsx(xe,{size:18})})]}),e.jsx("div",{className:"p-4 overflow-y-auto",children:d.ignored.length===0?e.jsx("div",{className:"text-sm text-gray-600",children:"No ignored files."}):e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden",children:d.ignored.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-white/5 last:border-0",children:[e.jsx("span",{className:"flex-1 font-mono text-xs text-gray-300 truncate",title:s,children:s}),Me&&e.jsxs("button",{onClick:()=>vt(s),className:"text-[11px] text-cyan-400 hover:text-cyan-300 inline-flex items-center gap-1",children:[e.jsx(ms,{size:12})," restore"]})]},s))})})]})}),document.body)]})}const Pe={page:"Page Object",helper:"Helper",support:"Support",step:"Step Def",fixture:"Fixture",test:"Test",source:"Source"};function J(t,r){const n=`/explorer?file=${encodeURIComponent(t)}${r?`&line=${r}`:""}`;window.open(n,"_blank","noopener")}function Se(t,r){const n=`/tests?file=${encodeURIComponent(t)}&test=${encodeURIComponent(r)}`;window.open(n,"_blank","noopener")}const ys=new RegExp("\\b(?:async|await|function|return|const|let|var|if|else|elif|for|while|do|switch|case|break|continue|class|extends|implements|interface|type|enum|namespace|struct|new|delete|import|from|export|default|public|private|protected|internal|static|readonly|abstract|override|virtual|final|void|def|end|self|begin|rescue|ensure|module|require|lambda|yield|with|as|in|of|is|not|and|or|pass|raise|try|catch|except|finally|throw|throws|super|this|using|package|func|fn|val|when|then|true|false|null|nil|None|True|False|undefined|NaN|string|number|boolean|bool|int|float|double|char|str)\\b");function js(t,r){const n=r==="python"||r==="ruby",l=n?"#[^\\n]*":"\\/\\/[^\\n]*",i=n?"":"|\\/\\*[\\s\\S]*?\\*\\/",m=new RegExp(`(${l}${i})|(\`(?:\\\\.|[^\`\\\\])*\`|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*')|(\\b\\d[\\d_.]*(?:e[+-]?\\d+)?\\b)|(${ys.source})|([A-Za-z_$][\\w$]*)(?=\\s*\\()|(\\b[A-Z][A-Za-z0-9_]*\\b)`,"g"),b=[];let p=0,a,c=0;for(;(a=m.exec(t))!==null;){a.index>p&&b.push(t.slice(p,a.index));const y=a[1]?"cm-tok-comment":a[2]?"cm-tok-string":a[3]?"cm-tok-number":a[4]?"cm-tok-keyword":a[5]?"cm-tok-function":"cm-tok-type";b.push(e.jsx("span",{className:y,children:a[0]},c++)),p=a.index+a[0].length}return p<t.length&&b.push(t.slice(p)),b}function Ns({view:t,setView:r}){const n=(l,i,m)=>e.jsxs("button",{onClick:()=>r(l),className:`flex items-center gap-1.5 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${t===l?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[m,i]});return e.jsxs("div",{className:"flex items-center gap-1 px-5 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[n("methods","Methods and Steps",e.jsx(Ie,{size:15})),n("data","Test Data",e.jsx(Fe,{size:15}))]})}function Js(){const[t,r]=Dt("view",["methods","data"],"methods");return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx(Ns,{view:t,setView:r}),e.jsx("div",{className:"flex-1 min-h-0",children:t==="methods"?e.jsx(vs,{}):e.jsx(gs,{})})]})}const je=500;function vs(){const{toast:t}=_(),[r,n]=o.useState(null),[l,i]=o.useState(!0),[m,b]=o.useState(!1),[p,a]=o.useState(""),[c,y]=o.useState("all"),[h,u]=o.useState(!1),[$,z]=o.useState("usage"),[q,M]=o.useState(null),[T,x]=o.useState("inventory"),[N,O]=o.useState(null),[w,E]=o.useState(!1),[W,Q]=o.useState(je);o.useEffect(()=>{Q(je)},[p,c,h,w,$]);const ee=(d=!1)=>{i(!0),Kt(d).then(L=>{n(L),Ht().then(O).catch(()=>O(null))}).catch(L=>t("error",`Failed to load code map: ${L}`)).finally(()=>i(!1))};o.useEffect(()=>{ee()},[]);const[f,j]=ot();o.useEffect(()=>{const d=f.get("symbol");if(!d)return;x("inventory"),M(d);const L=f.get("name");L&&a(L),j(K=>{const v=new URLSearchParams(K);return v.delete("symbol"),v.delete("name"),v},{replace:!0})},[]);const S=()=>{var A;const d=((r==null?void 0:r.symbols)||[]).filter(U=>U.unused);if(d.length===0){t("info","No unused methods to clean up.");return}const L=new Map;d.forEach(U=>{(L.get(U.file)||L.set(U.file,[]).get(U.file)).push(U)});const K=["# Code cleanup — unused methods (Testver Code Map)",""];for(const[U,g]of L){K.push(`## ${U}`);for(const R of g){const V=N!=null&&N.available&&N.executed[R.id]===!1?" — confirmed dead (not covered at runtime)":"";K.push(`- [ ] \`${R.className?R.className+".":""}${R.name}\` (line ${R.startLine})${V}`)}K.push("")}K.push("> Candidates only — verify before deleting (static analysis can miss reflection / dynamic dispatch).");const v=K.join(`
2
+ `);(A=navigator.clipboard)==null||A.writeText(v).then(()=>t("success",`Copied cleanup checklist (${d.length} methods) to clipboard`),()=>t("error","Could not copy to clipboard"))},C=o.useMemo(()=>{const d=new Set;return((r==null?void 0:r.symbols)||[]).forEach(L=>d.add(L.role)),[...d]},[r]),F=o.useMemo(()=>((r==null?void 0:r.symbols)||[]).filter(d=>!d.isEntryPoint||d.role!=="test").length,[r]),I=o.useMemo(()=>{let d=((r==null?void 0:r.symbols)||[]).filter(v=>!v.isEntryPoint||v.role!=="test");const L=p.trim().toLowerCase();L&&(d=d.filter(v=>v.name.toLowerCase().includes(L)||v.file.toLowerCase().includes(L)||(v.className||"").toLowerCase().includes(L))),c!=="all"&&(d=d.filter(v=>v.role===c)),h&&(d=d.filter(v=>v.unused)),w&&(d=d.filter(v=>v.unused&&(N==null?void 0:N.executed[v.id])===!1));const K={usage:(v,A)=>A.usedByTestCount-v.usedByTestCount||v.name.localeCompare(A.name),callers:(v,A)=>A.callerCount-v.callerCount||v.name.localeCompare(A.name),name:(v,A)=>v.name.localeCompare(A.name),file:(v,A)=>v.file.localeCompare(A.file)||v.startLine-A.startLine};return[...d].sort(K[$])},[r,p,c,h,w,N,$]),Z=()=>{b(!0),Vt().then(()=>ee(!1)).catch(d=>t("error",String(d))).finally(()=>b(!1))},B=r==null?void 0:r.stats;return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",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(Ie,{size:18,className:"text-brand-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-500 hidden md:inline flex-shrink-0",children:"Methods & steps inventory, test usage and quality"}),e.jsx("div",{className:"flex items-center gap-1 p-0.5 rounded-xl bg-surface-2 border border-white/5",children:["inventory","quality","graph","steps"].filter(d=>d!=="steps"||(B==null?void 0:B.gherkin)).map(d=>e.jsx("button",{onClick:()=>x(d),className:`px-3 py-1.5 text-xs font-medium capitalize rounded-lg transition-colors ${T===d?"bg-brand-600 text-white shadow-sm":"text-gray-400 hover:text-gray-200 hover:bg-white/5"}`,children:d},d))}),e.jsxs("button",{onClick:Z,disabled:m,className:"ml-auto 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 disabled:opacity-50",children:[m?e.jsx(P,{size:14,className:"animate-spin"}):e.jsx(ct,{size:14})," Rebuild"]}),T==="inventory"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:S,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(ps,{size:14})," Copy cleanup task"]}),e.jsxs("button",{onClick:()=>qt().catch(d=>t("error",`Export failed: ${d}`)),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(ut,{size:14})," Export CSV"]})]})]}),B&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(Ne,{icon:e.jsx(Ie,{size:15}),label:"Methods",value:F}),e.jsx(Ne,{icon:e.jsx(me,{size:15}),label:"Unused",value:B.unused,tone:"amber"}),e.jsx(Ne,{icon:e.jsx(Ue,{size:15}),label:"Tests",value:B.tests}),e.jsx(Ne,{icon:e.jsx(ge,{size:15}),label:"Files",value:B.files}),(N==null?void 0:N.available)&&e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20",title:`Coverage from ${N.source}`,children:[e.jsx(et,{size:15,className:"text-emerald-400"}),e.jsx("span",{className:"text-[15px] font-bold text-emerald-300 tabular-nums",children:N.confirmedDead}),e.jsxs("span",{className:"text-xs text-emerald-400/70",children:["Confirmed dead · ",N.format]})]}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:["indexed in ",B.durationMs,"ms"]})]}),T==="inventory"&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:d=>a(d.target.value),placeholder:"Search methods, files, classes…",className:"w-full pl-9 pr-3 py-1.5 rounded-xl 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.jsxs("select",{value:c,onChange:d=>y(d.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 roles"}),C.map(d=>e.jsx("option",{value:d,children:Pe[d]||d},d))]}),e.jsxs("select",{value:$,onChange:d=>z(d.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:"usage",children:"Sort: most used"}),e.jsx("option",{value:"callers",children:"Sort: most callers"}),e.jsx("option",{value:"name",children:"Sort: name"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>u(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${h?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),(N==null?void 0:N.available)&&e.jsxs("button",{onClick:()=>E(d=>!d),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${w?"bg-red-500/15 text-red-300 border-red-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,title:"Statically unused AND never executed at runtime",children:[e.jsx(et,{size:14})," Confirmed dead"]}),e.jsxs("span",{className:"text-xs text-gray-600",children:[I.length," shown"]})]}),T==="quality"?e.jsx($s,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="steps"?e.jsx(Ls,{onOpenSymbol:d=>{x("inventory"),M(d)}}):T==="graph"?e.jsx(Us,{symbols:(r==null?void 0:r.symbols)||[],onOpenSymbol:d=>{x("inventory"),M(d)}}):e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-auto bg-surface-1",children:[l?e.jsxs("div",{className:"flex items-center gap-2 p-6 text-sm text-gray-500",children:[e.jsx(P,{size:16,className:"animate-spin"})," Indexing project…"]}):I.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-20 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",children:e.jsx(oe,{size:22})}),e.jsx("div",{className:"text-sm",children:"No methods match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Method"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Role"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Tests"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Callers"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",title:"Cyclomatic complexity",children:"Cx"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:I.slice(0,W).map(d=>e.jsxs("tr",{onClick:()=>M(d.id),className:`cursor-pointer transition-colors ${q===d.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsx("span",{className:"font-mono text-gray-200",children:d.name}),d.className&&e.jsxs("span",{className:"text-gray-500 text-xs",children:[" · ",d.className]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[260px]",title:d.file,children:[d.file,":",d.startLine]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-400 text-xs",children:Pe[d.role]||d.role}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:d.usedByTestCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:d.callerCount}),e.jsx("td",{className:`px-3 py-2.5 border-b border-white/5 text-right tabular-nums ${d.complexity>=10?"text-red-400":d.complexity>=6?"text-amber-400":"text-gray-500"}`,children:d.complexity}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:d.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):d.usedByTestCount>0?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-gray-500/10 text-gray-400 border border-gray-500/20",children:"Indirect"})})]},d.id))})]}),!l&&I.length>W&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-4 text-xs text-gray-500",children:["Showing ",W.toLocaleString()," of ",I.length.toLocaleString()," methods",e.jsxs("button",{onClick:()=>Q(d=>d+je),className:"px-3 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 transition-colors",children:["Show ",Math.min(je,I.length-W).toLocaleString()," more"]})]})]}),q&&e.jsx(ws,{id:q,executed:N!=null&&N.available?N.executed[q]:void 0,onClose:()=>M(null)})]})]})}function Ne({icon:t,label:r,value:n,tone:l}){return e.jsxs("div",{className:`flex items-center gap-2 px-3.5 py-2 rounded-xl border ${l==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5"}`,children:[e.jsx("span",{className:l==="amber"?"text-amber-400":"text-brand-400",children:t}),e.jsx("span",{className:`text-[15px] font-bold tabular-nums ${l==="amber"?"text-amber-300":"text-gray-100"}`,children:n}),e.jsx("span",{className:"text-xs text-gray-500",children:r})]})}function ws({id:t,executed:r,onClose:n}){const{toast:l}=_(),[i,m]=o.useState(null),[b,p]=o.useState(!0);o.useEffect(()=>{p(!0),m(null),Xt(t).then(m).catch(c=>l("error",String(c))).finally(()=>p(!1))},[t]);const a=i==null?void 0:i.symbol;return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(be,{size:18,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:(a==null?void 0:a.name)||"…"})]}),e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),b||!i?e.jsxs("div",{className:"p-4 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(P,{size:14,className:"animate-spin"})," Loading…"]}):e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(a.file,a.startLine),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[a.file,":",a.startLine]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(ie,{children:Pe[a.role]||a.role}),e.jsx(ie,{children:a.language}),a.visibility&&e.jsx(ie,{children:a.visibility}),e.jsxs(ie,{children:[a.loc," LOC"]}),e.jsxs(ie,{children:["cx ",a.complexity]}),i.usage.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused candidate"}),r===!0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"ran at runtime"}),r===!1&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20",children:"not covered at runtime"})]}),e.jsx(Es,{id:t,unused:i.usage.unused}),i.usedByTests.length>0&&e.jsx(Ss,{tests:i.usedByTests}),i.usedByTests.length>0&&e.jsx(ve,{title:"Used by tests",icon:e.jsx(Ue,{size:14,className:"text-emerald-400"}),items:i.usedByTests,listClass:"space-y-2",getText:c=>`${c.name} ${c.file}`,placeholder:"Filter tests by name or file…",render:c=>e.jsx(zs,{t:c},c.id)}),i.calledBy.length>0&&e.jsx(ve,{title:"Called by methods",icon:e.jsx(be,{size:13,className:"text-brand-400"}),items:i.calledBy,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter methods by name or file…",render:c=>e.jsx(nt,{c},c.id)}),i.calls.length>0&&e.jsx(ve,{title:"Calls",icon:e.jsx(_e,{size:13,className:"text-brand-400"}),items:i.calls,getText:c=>`${c.className?c.className+".":""}${c.name} ${c.file}`,placeholder:"Filter calls by name or file…",render:c=>e.jsx(nt,{c},c.id)}),e.jsx(ke,{title:"Source",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:i.source||"(source unavailable)",lang:a.language})})]})]})}const ks=new Set(["playwright","jest","vitest","mocha","pytest","robot","puppeteer"]),Cs=3;function Ss({tests:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),m=o.useMemo(()=>{const c=new Map;for(const h of t)(c.get(h.framework)||c.set(h.framework,new Set).get(h.framework)).add(h.file);const y=[];for(const[h,u]of c)if(ks.has(h))y.push({files:[...u],framework:h});else for(const $ of u)y.push({files:[$],framework:h});return y},[t]);if(!n)return null;const b=m.reduce((c,y)=>c+y.files.length,0),p=m.length>Cs,a=async()=>{i(!0);try{for(const c of m)await ss(c);r("success",`Started ${m.length===1?"a run":`${m.length} runs`} for ${b} test file${b!==1?"s":""} — follow ${m.length===1?"it":"them"} in the Runner.`)}catch(c){r("error",String(c))}finally{i(!1)}};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:a,disabled:l||p,title:p?`${b} test files need ${m.length} separate runs — select the tests in Test Explorer to run them together`:"Run every test file that exercises this method",className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-medium text-emerald-300 bg-emerald-500/10 border border-emerald-500/25 hover:bg-emerald-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(P,{size:12,className:"animate-spin"}):e.jsx(bs,{size:12})," Run affected tests"]}),e.jsxs("span",{className:"text-[11px] text-gray-500",children:[t.length," test",t.length!==1?"s":""," in ",b," file",b!==1?"s":"",p?" — too many separate runs; use Test Explorer":""]})]})}function rt({onClick:t,title:r,children:n,copied:l}){return e.jsx("button",{onClick:i=>{i.stopPropagation(),t()},title:r,className:`p-1.5 rounded-lg border transition-colors ${l?"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:n})}function zs({t}){const{toast:r}=_(),[n,l]=o.useState(!1),i=()=>{var m;return(m=navigator.clipboard)==null?void 0:m.writeText(t.name).then(()=>{l(!0),setTimeout(()=>l(!1),1500)},()=>r("error","Could not copy to clipboard"))};return e.jsx("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug",title:t.name,children:fe(t.name)}),e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open file in Project Explorer (new tab)",className:"group flex items-center gap-1.5 mt-1 text-xs text-gray-500 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:12,className:"shrink-0 text-gray-600 group-hover:text-brand-400"}),e.jsx("span",{className:"truncate",children:t.file}),e.jsxs("span",{className:"text-gray-600",children:[":",t.startLine]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(rt,{onClick:i,title:"Copy test name",copied:n,children:n?e.jsx(Ce,{size:13}):e.jsx(ue,{size:13})}),e.jsx(rt,{onClick:()=>Se(t.file,t.name),title:"Open in Test Explorer (new tab)",children:e.jsx(Be,{size:13})})]})]})})}function nt({c:t}){return e.jsxs("button",{onClick:()=>J(t.file,t.startLine),title:"Open in Project Explorer (new tab)",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-[13px] text-gray-200 truncate",title:`${t.className?t.className+".":""}${t.name}`,children:[t.className&&e.jsxs("span",{className:"text-gray-500",children:[t.className,"."]}),t.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-gray-500 font-mono truncate max-w-[180px]",title:`${t.file}:${t.startLine}`,children:t.file}),e.jsx(H,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]})}function qe({code:t,lang:r}){const{toast:n}=_(),[l,i]=o.useState(!1),m=o.useMemo(()=>js(t,r),[t,r]),b=()=>{var p;(p=navigator.clipboard)==null||p.writeText(t).then(()=>{i(!0),setTimeout(()=>i(!1),1500)},()=>n("error","Could not copy to clipboard"))};return e.jsxs("div",{className:"cm-code rounded-xl border cm-code-surface overflow-hidden",children:[e.jsxs("div",{className:"cm-code-bar flex items-center justify-between px-3 py-1.5 border-b",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[10px] uppercase tracking-wide text-gray-500 font-medium",children:[e.jsxs("span",{className:"flex gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-red-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-400/70"}),e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-emerald-400/70"})]}),r||"source"]}),e.jsx("button",{onClick:b,className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"cm-code-pre text-[12.5px] leading-relaxed font-mono whitespace-pre overflow-auto p-3 max-h-80",children:m})]})}function ke({title:t,count:r,icon:n,children:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[n,e.jsx("span",{className:"text-xs font-semibold text-gray-300",children:t}),r!=null&&e.jsx("span",{className:"text-[10px] font-medium text-gray-500 bg-surface-2 border border-white/5 rounded-full px-1.5 py-0.5 tabular-nums",children:r})]}),l]})}function ve({title:t,icon:r,items:n,getText:l,render:i,placeholder:m,listClass:b="space-y-1.5"}){const[p,a]=o.useState(""),c=p.trim().toLowerCase(),y=c?n.filter(h=>l(h).toLowerCase().includes(c)):n;return e.jsxs(ke,{title:t,count:n.length,icon:r,children:[n.length>4&&e.jsxs("div",{className:"relative mb-2",children:[e.jsx(oe,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:h=>a(h.target.value),placeholder:m,className:"w-full pl-8 pr-3 py-1.5 rounded-lg text-xs bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"})]}),y.length===0?e.jsxs("div",{className:"text-xs text-gray-500 py-1",children:["No matches for “",p,"”."]}):e.jsx("div",{className:b,children:y.map(i)})]})}function ie({children:t}){return e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10",children:t})}function $s({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0);if(o.useEffect(()=>{m(!0),Gt().then(a=>l(a.quality)).catch(a=>r("error",String(a))).finally(()=>m(!1))},[]),i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(P,{size:16,className:"animate-spin"})," Analyzing quality…"]});if(!n)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No quality data."});const b=({r:a})=>e.jsxs("button",{onClick:()=>t(a.id),title:"Open method details",className:"group inline-flex items-baseline gap-1 rounded-md px-2 py-1 -mx-2 text-left cursor-pointer hover:bg-brand-500/10 transition-colors",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2",children:[a.className?`${a.className}.`:"",a.name]}),e.jsxs("span",{className:"text-gray-600 text-xs font-mono",children:[" · ",a.file,":",a.startLine]})]}),p=a=>a==="A"?"text-emerald-400":a==="B"?"text-emerald-300":a==="C"?"text-amber-400":a==="D"?"text-orange-400":"text-red-400";return e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(X,{label:"duplicate clusters",value:n.summary.duplicateClusters,tone:"amber"}),e.jsx(X,{label:"complex methods",value:n.summary.complexMethods,tone:"amber"}),e.jsx(X,{label:"orphan files",value:n.summary.orphanFiles,tone:"amber"}),e.jsx(X,{label:"orphan locators",value:n.summary.orphanLocators,tone:"amber"}),e.jsx(X,{label:"tests w/o assertions",value:n.summary.noAssertionTests,tone:"red"})]}),e.jsx(_s,{files:n.fileMaintainability}),e.jsx(G,{title:"Duplicate & near-duplicate methods",hint:"Refactor candidates. ‘identical’ = same body; ‘similar’ = same structure, renamed.",children:n.duplicates.length===0?e.jsx(re,{children:"No duplicates detected."}):n.duplicates.map((a,c)=>e.jsx(Ts,{c:a,RefEl:b},c))}),e.jsx(G,{title:"Most complex methods",hint:"High cyclomatic complexity / deep nesting / long bodies.",children:n.complexMethods.length===0?e.jsx(re,{children:"Nothing notably complex."}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:n.complexMethods.map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2",children:e.jsx(b,{r:a})}),e.jsxs("td",{className:"py-2 text-right text-sm text-amber-400 tabular-nums w-20",children:["cx ",a.complexity]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-24",children:["nest ",a.maxNesting]}),e.jsxs("td",{className:"py-2 text-right text-sm text-gray-500 tabular-nums w-20",children:[a.loc," loc"]})]},a.id))})})}),e.jsx(G,{title:"Orphan files",hint:"Every automation method in the file is unused — whole-file dead-code candidates.",children:n.orphanFiles.length===0?e.jsx(re,{children:"No orphan files."}):n.orphanFiles.map(a=>e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-2 border-b border-white/5 hover:bg-brand-500/10 transition-colors",children:[e.jsx(ge,{size:14,className:"text-amber-400 shrink-0"}),e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2 truncate",children:a.file}),e.jsxs("span",{className:"text-gray-600 text-xs shrink-0",children:["· ",a.methods," unused method(s)"]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},a.file))}),e.jsx(G,{title:"Tests without assertions",hint:"Tests with no detected expect/assert — possible gaps.",children:n.noAssertionTests.length===0?e.jsx(re,{children:"All tests have assertions."}):n.noAssertionTests.map(a=>e.jsxs("button",{onClick:()=>Se(a.file,a.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left py-1.5 px-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors flex items-center gap-2",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"block text-sm text-gray-200 group-hover:underline decoration-dotted underline-offset-2 truncate",title:a.name,children:fe(a.name)}),e.jsxs("span",{className:"block text-xs text-gray-600 font-mono truncate",children:[a.file,":",a.startLine]})]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},a.id))}),e.jsx(G,{title:"Orphan locators",hint:"Element/selector definitions referenced nowhere else (best-effort — verify before removing).",children:n.orphanLocators.length===0?e.jsx(re,{children:"No orphan locators detected."}):n.orphanLocators.map((a,c)=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"group w-full text-left text-sm py-1.5 px-1 flex items-center gap-1 border-b border-white/5 last:border-0 hover:bg-brand-500/10 transition-colors",children:[e.jsx("span",{className:"font-mono text-gray-300 group-hover:underline decoration-dotted underline-offset-2",children:a.name}),e.jsxs("span",{className:"text-gray-600 text-xs",children:[" · ",a.file,":",a.line]}),e.jsx(H,{size:12,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity ml-auto shrink-0"})]},c))}),e.jsx(G,{title:"File maintainability",hint:"Heuristic score (complexity, size, unused, duplication). Lowest first.",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-xs uppercase text-gray-500 border-b border-white/5",children:[e.jsx("th",{className:"text-left font-medium py-2",children:"File"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Methods"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Avg cx"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Unused"}),e.jsx("th",{className:"text-right font-medium py-2",children:"Score"})]})}),e.jsx("tbody",{children:n.fileMaintainability.slice(0,40).map(a=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-2 max-w-[320px]",children:e.jsxs("button",{onClick:()=>J(a.file),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1 max-w-full font-mono text-sm text-gray-300 hover:text-brand-300 transition-colors",children:[e.jsx("span",{className:"truncate group-hover:underline decoration-dotted underline-offset-2",children:a.file}),e.jsx(H,{size:11,className:"text-brand-400 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.methods}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.avgComplexity}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-gray-400",children:a.unused}),e.jsx("td",{className:"py-1.5 text-right tabular-nums",children:e.jsxs("span",{className:p(a.grade),children:[a.score," · ",a.grade]})})]},a.file))})]})})]})}function X({label:t,value:r,tone:n}){const l=n==="red"?"bg-red-500/10 border-red-500/20":n==="amber"?"bg-amber-500/10 border-amber-500/20":"bg-surface-2/50 border-white/5",i=n==="red"?"text-red-300":n==="amber"?"text-amber-300":"text-gray-100";return e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg border ${l}`,children:[e.jsx("span",{className:`text-sm font-bold tabular-nums ${i}`,children:r}),e.jsx("span",{className:"text-xs text-gray-500",children:t})]})}function G({title:t,hint:r,children:n}){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-base font-semibold text-gray-200",children:t}),r&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5",children:r})]}),e.jsx("div",{className:"max-h-[340px] overflow-y-auto overflow-x-hidden pr-1",children:n})]})}function re({children:t}){return e.jsxs("div",{className:"text-sm text-gray-500 flex items-center gap-1.5",children:[e.jsx(Ue,{size:14,className:"text-emerald-400"})," ",t]})}function Es({id:t,unused:r}){const{toast:n}=_(),[l,i]=o.useState(null),[m,b]=o.useState(null),[p,a]=o.useState(!1);if(!ce().hasRole("tester"))return e.jsx(gt,{});const y=(u,$)=>{i(u),b(null),a(!1),$().then(z=>b({label:u,text:z&&z.trim()||"(no response from the AI model — check that an AI provider is configured in Settings)"})).catch(z=>n("error",String(z))).finally(()=>i(null))},h=()=>{var u;m&&((u=navigator.clipboard)==null||u.writeText(m.text).then(()=>{a(!0),setTimeout(()=>a(!1),1500)},()=>n("error","Could not copy to clipboard")))};return e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assists"]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsx(he,{onClick:()=>y("Explanation",()=>as(t).then(u=>u.explanation)),busy:l==="Explanation",children:"Explain"}),e.jsx(he,{onClick:()=>y("Doc comment",()=>rs(t).then(u=>u.doc)),busy:l==="Doc comment",children:"Document"}),r&&e.jsx(he,{onClick:()=>y("Safe to delete?",()=>ns(t).then(u=>`${u.verdict}${u.confidence!=null?` (${Math.round(u.confidence*100)}% confident)`:""}
3
+ ${u.reasoning}`)),busy:l==="Safe to delete?",children:"Safe to delete?"}),r&&e.jsx(he,{onClick:()=>y("Suggested test",()=>ls(t).then(u=>u.code)),busy:l==="Suggested test",children:"Generate test"})]}),l&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(P,{size:12,className:"animate-spin"})," ",l,"…"]}),m&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:m.label}),e.jsx("button",{onClick:h,title:"Copy to clipboard",className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-400 hover:text-gray-100 hover:bg-white/10 transition-colors",children:p?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:m.text})]}),e.jsx("p",{className:"text-[10px] text-gray-600 mt-2",children:"AI suggestions are read-only — nothing is changed in your project."})]})}function gt(){return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 text-xs text-gray-500 flex items-center gap-1.5",children:[e.jsx(ne,{size:13,className:"text-gray-600"})," AI assists are available to testers and admins."]})}function he({onClick:t,busy:r,children:n}){return e.jsx("button",{onClick:t,disabled:r,className:"px-2.5 py-1 rounded-lg text-xs text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:n})}function Ts({c:t,RefEl:r}){const{toast:n}=_(),l=ce().hasRole("tester"),[i,m]=o.useState(!1),[b,p]=o.useState(null),a=()=>{m(!0),Yt(t.members.map(c=>c.id)).then(c=>p(c.suggestion)).catch(c=>n("error",String(c))).finally(()=>m(!1))};return e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-md border ${t.kind==="identical"?"bg-red-500/10 text-red-400 border-red-500/20":"bg-amber-500/10 text-amber-400 border-amber-500/20"}`,children:t.kind}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.members.length," copies · ~",t.loc," lines each"]}),l&&e.jsxs("button",{onClick:a,disabled:i,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[i?e.jsx(P,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest consolidation"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(c=>e.jsx("div",{className:"text-sm",children:e.jsx(r,{r:c})},c.id))}),b&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:b})})]})}const lt={Given:"bg-sky-500/15 text-sky-500 border-sky-500/30",When:"bg-amber-500/15 text-amber-500 border-amber-500/40",Then:"bg-emerald-500/15 text-emerald-500 border-emerald-500/30",And:"bg-violet-500/15 text-violet-500 border-violet-500/30",But:"bg-violet-500/15 text-violet-500 border-violet-500/30",Step:"bg-gray-500/15 text-gray-500 border-gray-500/25"};function yt({kw:t}){return e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded-md border ${lt[t]||lt.And}`,children:t})}function Ls({onOpenSymbol:t}){const{toast:r}=_(),[n,l]=o.useState(null),[i,m]=o.useState(!0),[b,p]=o.useState(""),[a,c]=o.useState("usage"),[y,h]=o.useState(!1),[u,$]=o.useState(!1),[z,q]=o.useState(null);o.useEffect(()=>{m(!0),Wt().then(l).catch(x=>r("error",String(x))).finally(()=>m(!1))},[]);const M=o.useMemo(()=>{let x=(n==null?void 0:n.stepDefs)||[];const N=b.trim().toLowerCase();N&&(x=x.filter(w=>w.pattern.toLowerCase().includes(N)||w.file.toLowerCase().includes(N)||w.keyword.toLowerCase().includes(N))),y&&(x=x.filter(w=>w.unused));const O={usage:(w,E)=>E.usageCount-w.usageCount||w.pattern.localeCompare(E.pattern),scenarios:(w,E)=>E.scenarioCount-w.scenarioCount||w.pattern.localeCompare(E.pattern),keyword:(w,E)=>w.keyword.localeCompare(E.keyword)||w.pattern.localeCompare(E.pattern),pattern:(w,E)=>w.pattern.localeCompare(E.pattern),file:(w,E)=>w.file.localeCompare(E.file)||w.line-E.line};return[...x].sort(O[a])},[n,b,y,a]);if(i)return e.jsxs("div",{className:"flex-1 p-6 text-sm text-gray-500 flex items-center gap-2",children:[e.jsx(P,{size:16,className:"animate-spin"})," Analyzing steps…"]});if(!n||!n.available)return e.jsx("div",{className:"flex-1 p-6 text-sm text-gray-500",children:"No Gherkin scenarios detected in this project."});const T=n.totals;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(X,{label:"step defs",value:T.stepDefs}),e.jsx(X,{label:"used",value:T.usedDefs}),e.jsx(X,{label:"unused",value:T.unusedDefs,tone:"amber"}),e.jsx(X,{label:"undefined",value:T.undefinedSteps,tone:"red"}),e.jsx(X,{label:"ambiguous",value:T.ambiguousSteps,tone:"amber"}),e.jsxs("span",{className:"ml-auto text-xs text-gray-500",children:[T.features," features · ",T.scenarios," scenarios · ",T.steps," steps"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-3 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(oe,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:b,onChange:x=>p(x.target.value),placeholder:"Search steps by pattern, keyword, or file…",disabled:u,className:"w-full pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors disabled:opacity-40"})]}),e.jsxs("select",{value:a,onChange:x=>c(x.target.value),disabled:u,className:"bg-surface-2 border border-white/10 rounded-xl px-3 py-1.5 text-sm text-gray-300 outline-none cursor-pointer disabled:opacity-40",children:[e.jsx("option",{value:"usage",children:"Sort: most used"}),e.jsx("option",{value:"scenarios",children:"Sort: most scenarios"}),e.jsx("option",{value:"keyword",children:"Sort: keyword"}),e.jsx("option",{value:"pattern",children:"Sort: pattern"}),e.jsx("option",{value:"file",children:"Sort: file"})]}),e.jsxs("button",{onClick:()=>h(x=>!x),disabled:u,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors disabled:opacity-40 ${y?"bg-amber-500/15 text-amber-300 border-amber-500/30":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(me,{size:14})," Unused only"]}),e.jsxs("button",{onClick:()=>{$(x=>!x),q(null)},title:u?"Close Quality — back to step list":"Show step quality (undefined, ambiguous, duplicates, tags)",className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-xl border transition-colors ${u?"bg-brand-600 text-white border-brand-500":"bg-surface-2 text-gray-400 border-white/5 hover:bg-surface-3 hover:text-gray-200"}`,children:[e.jsx(tt,{size:14})," Quality",u&&e.jsx(xe,{size:14,className:"ml-0.5 opacity-90"})]}),e.jsxs("button",{onClick:()=>Qt().catch(x=>r("error",`Export failed: ${x}`)),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(ut,{size:14})," Export CSV"]}),e.jsx("span",{className:"text-xs text-gray-600",children:u?"quality view":`${M.length} shown`})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto bg-surface-1",children:u?e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsx(G,{title:"Undefined steps",hint:"Gherkin steps with no matching step definition — these fail at runtime ('step undefined').",children:n.undefinedSteps.length===0?e.jsx(re,{children:"Every Gherkin step has a definition."}):n.undefinedSteps.map((x,N)=>e.jsx(Ms,{u:x},N))}),e.jsx(G,{title:"Ambiguous steps",hint:"Gherkin steps matching more than one definition — Cucumber raises an 'ambiguous' error.",children:n.ambiguousSteps.length===0?e.jsx(re,{children:"No ambiguous steps."}):n.ambiguousSteps.map((x,N)=>e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"text-sm text-gray-200",children:[x.text," ",e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",x.occurrences,"×"]})]}),e.jsx("div",{className:"mt-1.5 space-y-1",children:x.defs.map(O=>e.jsxs("button",{onClick:()=>J(O.file,O.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[O.pattern," ",e.jsxs("span",{className:"text-gray-600",children:["· ",O.file,":",O.line]})]},O.id))})]},N))}),e.jsx(G,{title:"Duplicate step definitions",hint:"The same step pattern is defined more than once — consolidate to avoid ambiguity.",children:n.duplicateDefs.length===0?e.jsx(re,{children:"No duplicate definitions."}):n.duplicateDefs.map((x,N)=>e.jsx(Rs,{d:x},N))}),n.tags.length>0&&e.jsx(G,{title:"Tags",hint:"Scenario tags and how many scenarios carry each.",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:n.tags.map(x=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs bg-surface-2/60 border border-white/5 text-gray-300",children:[e.jsx(hs,{size:12,className:"text-brand-400"})," ",x.tag," ",e.jsx("span",{className:"text-gray-500 tabular-nums",children:x.scenarios})]},x.tag))})})]}):M.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-16 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",children:e.jsx(tt,{size:22})}),e.jsx("div",{className:"text-sm",children:"No step definitions match your filters."})]}):e.jsxs("table",{className:"w-full text-sm border-separate border-spacing-0",children:[e.jsx("thead",{className:"sticky top-0 bg-surface-1 z-10",children:e.jsxs("tr",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:[e.jsx("th",{className:"text-left font-semibold px-5 py-2.5 border-b border-white/5",children:"Step"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"File"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Scenarios"}),e.jsx("th",{className:"text-right font-semibold px-3 py-2.5 border-b border-white/5",children:"Uses"}),e.jsx("th",{className:"text-left font-semibold px-3 py-2.5 border-b border-white/5",children:"Status"})]})}),e.jsx("tbody",{children:M.map(x=>e.jsxs("tr",{onClick:()=>q(x),className:`cursor-pointer transition-colors ${(z==null?void 0:z.id)===x.id?"bg-brand-500/10":"hover:bg-white/[0.03]"}`,children:[e.jsxs("td",{className:"px-5 py-2.5 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yt,{kw:x.keyword}),e.jsx("span",{className:"font-mono text-gray-200",children:x.pattern})]}),x.reaches.length>0&&e.jsxs("div",{className:"text-[11px] text-gray-600 mt-0.5 truncate",children:["→ ",x.reaches.map(N=>N.name).join(", ")]})]}),e.jsxs("td",{className:"px-3 py-2.5 border-b border-white/5 text-gray-500 text-xs font-mono truncate max-w-[220px]",title:`${x.file}:${x.line}`,children:[x.file,":",x.line]}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-300",children:x.scenarioCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5 text-right tabular-nums text-gray-500",children:x.usageCount}),e.jsx("td",{className:"px-3 py-2.5 border-b border-white/5",children:x.unused?e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused"}):e.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded-md bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:"Used"})})]},x.id))})]})}),!u&&z&&e.jsx(As,{step:z,onClose:()=>q(null),onOpenSymbol:t})]})]})}function Ms({u:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),b(null),Jt(t.text).then(a=>b(a.code&&a.code.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-red-500/15 bg-red-500/[0.04] p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:13,className:"text-red-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200",children:t.text}),e.jsxs("span",{className:"text-gray-600 text-xs",children:["· ",t.occurrences,"×"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(P,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Suggest definition"]})]}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:t.scenarios.slice(0,6).map(a=>e.jsx("button",{onClick:()=>Se(a.file,a.name),title:"Open scenario in Test Explorer (new tab)",className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-2 text-gray-400 border border-white/10 hover:text-brand-300 transition-colors",children:a.name},a.id))}),m&&e.jsx("div",{className:"mt-3",children:e.jsx(qe,{code:m,lang:"step definition"})})]})}function Rs({d:t}){const{toast:r}=_(),n=ce().hasRole("tester"),[l,i]=o.useState(!1),[m,b]=o.useState(null),p=()=>{i(!0),es(t.members.map(a=>a.id)).then(a=>b(a.suggestion)).catch(a=>r("error",String(a))).finally(()=>i(!1))};return e.jsxs("div",{className:"rounded-lg border border-white/5 bg-surface-2/40 p-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("span",{className:"font-mono text-sm text-gray-200",children:t.pattern}),e.jsxs("span",{className:"text-xs text-gray-500",children:[t.members.length," definitions"]}),n&&e.jsxs("button",{onClick:p,disabled:l,className:"ml-auto flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-brand-200 bg-brand-500/10 border border-brand-500/25 hover:bg-brand-500/20 disabled:opacity-50 transition-colors",children:[l?e.jsx(P,{size:11,className:"animate-spin"}):e.jsx(ne,{size:11})," Consolidate"]})]}),e.jsx("div",{className:"space-y-1",children:t.members.map(a=>e.jsxs("button",{onClick:()=>J(a.file,a.line),title:"Open in Project Explorer (new tab)",className:"block text-left text-xs font-mono text-gray-400 hover:text-brand-300 transition-colors",children:[a.file,":",a.line]},a.id))}),m&&e.jsx("div",{className:"mt-2 rounded-lg border border-white/5 bg-surface-2/40 p-3 max-h-96 overflow-auto text-sm text-gray-200",children:e.jsx(ht,{text:m})})]})}function As({step:t,onClose:r,onOpenSymbol:n}){const{toast:l}=_(),i=ce().hasRole("tester"),[m,b]=o.useState(!1),[p,a]=o.useState(null),[c,y]=o.useState(!1),h=()=>{b(!0),a(null),ts(t.id).then(u=>a(u.explanation&&u.explanation.trim()||"(no response — check that an AI provider is configured in Settings)")).catch(u=>l("error",String(u))).finally(()=>b(!1))};return e.jsxs("div",{className:"w-[540px] max-w-[48vw] shrink-0 border-l border-white/5 bg-surface-1 flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 bg-surface-1 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(yt,{kw:t.keyword}),e.jsx("span",{className:"font-mono text-sm font-semibold text-gray-100 truncate",children:t.pattern})]}),e.jsx("button",{onClick:r,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(xe,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[e.jsxs("button",{onClick:()=>J(t.file,t.line),title:"Open in Project Explorer (new tab)",className:"group flex items-center gap-1.5 text-[13px] text-brand-400 hover:text-brand-300 font-mono transition-colors",children:[e.jsx(ge,{size:13,className:"shrink-0 text-brand-400"}),e.jsxs("span",{className:"truncate underline decoration-dotted decoration-gray-400/50 underline-offset-2",children:[t.file,":",t.line]}),e.jsx(H,{size:12,className:"shrink-0 text-brand-400"})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.jsxs(ie,{children:[t.scenarioCount," scenario(s)"]}),e.jsxs(ie,{children:[t.usageCount," use(s)"]}),t.unused&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:"Unused — no scenario uses this"})]}),i?e.jsxs("div",{className:"rounded-xl border border-brand-500/20 bg-brand-500/[0.04] p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold text-brand-200 mb-2",children:[e.jsx(ne,{size:14,className:"text-brand-400"})," AI assist"]}),e.jsx(he,{onClick:h,busy:m,children:"Explain this step"}),m&&e.jsxs("div",{className:"text-xs text-gray-500 mt-2 flex items-center gap-1.5",children:[e.jsx(P,{size:12,className:"animate-spin"})," Explaining…"]}),p&&e.jsxs("div",{className:"mt-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Explanation"}),e.jsx("button",{onClick:()=>{var u;return(u=navigator.clipboard)==null?void 0:u.writeText(p).then(()=>{y(!0),setTimeout(()=>y(!1),1500)})},className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] text-gray-500 hover:bg-gray-500/20 transition-colors",children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{size:12,className:"text-emerald-400"})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:12})," Copy"]})})]}),e.jsx("pre",{className:"text-[11px] text-gray-200 whitespace-pre-wrap break-words bg-black/30 rounded-lg p-2 max-h-60 overflow-auto",children:p})]})]}):e.jsx(gt,{}),t.scenarios.length>0&&e.jsx(ve,{title:"Used by scenarios",icon:e.jsx(Be,{size:13,className:"text-emerald-400"}),items:t.scenarios,listClass:"space-y-1.5",getText:u=>`${u.name} ${u.feature} ${(u.tags||[]).join(" ")}`,placeholder:"Filter scenarios…",render:u=>e.jsxs("button",{onClick:()=>Se(u.file,u.name),title:"Open in Test Explorer (new tab)",className:"group w-full text-left rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2.5 hover:bg-surface-2/70 transition-colors",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"text-sm text-gray-200 leading-snug flex-1",children:u.name}),e.jsx(H,{size:12,className:"shrink-0 mt-0.5 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-1.5 mt-1",children:[e.jsx("span",{className:"text-xs text-gray-500 truncate",children:u.feature||u.file}),(u.tags||[]).slice(0,4).map($=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-300 border border-brand-500/20",children:$},$))]})]},u.id)}),t.reaches.length>0&&e.jsx(ke,{title:"Reaches methods",count:t.reaches.length,icon:e.jsx(be,{size:13,className:"text-brand-400"}),children:e.jsx("div",{className:"space-y-1.5",children:t.reaches.map(u=>e.jsxs("button",{onClick:()=>n(u.id),title:"Open in Code Map · Inventory",className:"group w-full flex items-center gap-2 rounded-lg border border-white/5 bg-surface-2/40 px-3 py-2 hover:bg-surface-2/70 transition-colors text-left",children:[e.jsxs("span",{className:"font-mono text-sm text-gray-200 truncate",children:[u.className&&e.jsxs("span",{className:"text-gray-500",children:[u.className,"."]}),u.name]}),e.jsxs("span",{className:"ml-auto flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate max-w-[180px]",title:`${u.file}:${u.startLine}`,children:u.file}),e.jsx(_e,{size:12,className:"shrink-0 text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity"})]})]},u.id))})}),e.jsx(ke,{title:"Step definition",icon:e.jsx(pt,{size:13,className:"text-brand-400"}),children:e.jsx(qe,{code:t.source||"(source unavailable)",lang:t.language})})]})]})}function Ds(){const[t,r]=o.useState(()=>typeof document<"u"&&document.documentElement.classList.contains("light"));return o.useEffect(()=>{const n=document.documentElement,l=new MutationObserver(()=>r(n.classList.contains("light")));return l.observe(n,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),t}function Os(t,r){return(r?{focus:["#6d28d9","#7c3aed","#ffffff"],test:["#d1fae5","#34d399","#065f46"],caller:["#dbeafe","#60a5fa","#1e40af"],callee:["#f1f5f9","#cbd5e1","#334155"],unused:["#fef3c7","#f59e0b","#92400e"]}:{focus:["#6d28d9","#a78bfa","#ffffff"],test:["rgba(16,185,129,0.16)","rgba(16,185,129,0.55)","#6ee7b7"],caller:["rgba(59,130,246,0.16)","rgba(59,130,246,0.55)","#93c5fd"],callee:["rgba(148,163,184,0.14)","rgba(148,163,184,0.45)","#cbd5e1"],unused:["rgba(245,158,11,0.16)","rgba(245,158,11,0.55)","#fcd34d"]})[t]}function Fs(t,r){return(r?{focus:"#7c3aed",test:"#10b981",caller:"#3b82f6",callee:"#94a3b8",unused:"#f59e0b"}:{focus:"#a78bfa",test:"#34d399",caller:"#60a5fa",callee:"#94a3b8",unused:"#fbbf24"})[t]}const Is=240,jt=4;function it(t,r){const[n,l,i]=Os(t,r);return{background:n,color:i,border:`1.5px solid ${l}`,borderRadius:10,width:Is,padding:"8px 12px",fontSize:12,fontWeight:t==="focus"?600:500,lineHeight:"16px",textAlign:"center",whiteSpace:"normal",wordBreak:"break-word",display:"-webkit-box",WebkitLineClamp:jt,WebkitBoxOrient:"vertical",overflow:"hidden",transition:"opacity 0.15s ease",boxShadow:t==="focus"?"0 0 0 4px rgba(109,40,217,0.18)":"0 1px 2px rgba(0,0,0,0.12)"}}function Ps(t){return Math.min(jt,Math.max(1,Math.ceil(t.length/30)))}const Bs=[{kind:"test",label:"Test"},{kind:"caller",label:"Caller"},{kind:"focus",label:"Focus"},{kind:"callee",label:"Callee"},{kind:"unused",label:"Unused"}];function Us({symbols:t,onOpenSymbol:r}){const{toast:n}=_(),l=Ds(),i=o.useMemo(()=>{var j;return((j=[...t.filter(S=>!S.isEntryPoint&&S.role!=="test")].sort((S,C)=>C.usedByTestCount+C.callerCount-(S.usedByTestCount+S.callerCount))[0])==null?void 0:j.id)||null},[t]),[m,b]=o.useState(null),[p,a]=o.useState(""),[c,y]=o.useState(!1),[h,u]=o.useState(null),[$,z,q]=$t([]),[M,T,x]=Et([]),[N,O]=o.useState(!1),[w,E]=o.useState(null),W=o.useRef(null);o.useEffect(()=>{!m&&i&&b(i)},[i,m]),o.useEffect(()=>{m&&(O(!0),Zt(m,2).then(f=>{const j=new Map,S=new Map;f.edges.forEach(g=>{(j.get(g.source)||j.set(g.source,[]).get(g.source)).push(g.target),(S.get(g.target)||S.set(g.target,[]).get(g.target)).push(g.source)});const C=new Map;C.set(f.focus,2),f.edges.forEach(g=>{var R;g.target===f.focus&&!C.has(g.source)&&C.set(g.source,((R=f.nodes.find(V=>V.id===g.source))==null?void 0:R.type)==="test"?0:1),g.source===f.focus&&!C.has(g.target)&&C.set(g.target,3)}),f.nodes.forEach(g=>{C.has(g.id)||C.set(g.id,g.type==="test"?0:4)});const F={};f.nodes.forEach(g=>{const R=C.get(g.id);(F[R]=F[R]||[]).push(g.id)});const I=new Map(f.nodes.map(g=>[g.id,g.label])),Z=new Map,B=22,d=16,L=18;Object.entries(F).forEach(([g,R])=>{let V=0;R.forEach(te=>{Z.set(te,{x:Number(g)*340,y:V});const se=Ps(I.get(te)||"")*d+L;V+=se+B})});const K=g=>g.id===f.focus?"focus":g.type==="test"?"test":g.unused?"unused":(C.get(g.id)??4)<2?"caller":"callee",v={};f.nodes.forEach(g=>{v[g.id]=K(g)});const A=f.nodes.map(g=>({id:g.id,position:Z.get(g.id)||{x:0,y:0},data:{label:g.type==="test"?fe(g.label):g.label},sourcePosition:"right",targetPosition:"left",style:it(v[g.id],l)})),U=f.edges.map((g,R)=>{const V=v[g.source]??"callee",te=Fs(V,l);return{id:`e${R}`,source:g.source,target:g.target,type:"bezier",data:{srcKind:V},interactionWidth:0,style:{stroke:te,strokeWidth:1.5,strokeOpacity:.55},markerEnd:{type:Tt.ArrowClosed,color:te,width:16,height:16}}});u({nodes:A,edges:U,truncated:f.truncated,kinds:v})}).catch(f=>n("error",String(f))).finally(()=>O(!1)))},[m,l]);const Q=o.useMemo(()=>{const f=t.filter(C=>!C.isEntryPoint),j=p.trim().toLowerCase();return(j?f.filter(C=>C.name.toLowerCase().includes(j)||(C.className||"").toLowerCase().includes(j)).sort((C,F)=>C.name.localeCompare(F.name)):[...f].sort((C,F)=>F.usedByTestCount+F.callerCount-(C.usedByTestCount+C.callerCount))).slice(0,60)},[p,t]),ee=o.useMemo(()=>{const f=new Map;return h==null||h.edges.forEach(j=>{(f.get(j.source)||f.set(j.source,new Set).get(j.source)).add(j.target),(f.get(j.target)||f.set(j.target,new Set).get(j.target)).add(j.source)}),f},[h]);return o.useEffect(()=>{if(!h){z([]),T([]);return}E(null),z(h.nodes),T(h.edges)},[h]),o.useEffect(()=>{const f=w?ee.get(w):null;z(j=>j.map(S=>{var I;const F=!w||S.id===w||(f==null?void 0:f.has(S.id))?1:.18;return(((I=S.style)==null?void 0:I.opacity)??1)===F?S:{...S,style:{...S.style,opacity:F}}})),T(j=>j.map(S=>{var B,d;const C=!!w&&(S.source===w||S.target===w),I=!!w&&!C?.06:C?1:.55,Z=C?2.5:1.5;return!!S.animated===C&&(((B=S.style)==null?void 0:B.strokeOpacity)??.55)===I&&(((d=S.style)==null?void 0:d.strokeWidth)??1.5)===Z?S:{...S,animated:C,zIndex:C?1:0,style:{...S.style,strokeOpacity:I,strokeWidth:Z}}}))},[w,ee]),o.useEffect(()=>{if(!h)return;const f=setTimeout(()=>{var j;return(j=W.current)==null?void 0:j.fitView({padding:.25,duration:350})},80);return()=>clearTimeout(f)},[h]),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-white/5 bg-surface-1/50 flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400",children:"Focus:"}),e.jsxs("div",{className:"relative",children:[e.jsx(oe,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{value:p,onChange:f=>a(f.target.value),onFocus:()=>y(!0),onBlur:()=>setTimeout(()=>y(!1),150),placeholder:"click to browse, or type to filter methods…",className:"w-80 pl-9 pr-3 py-1.5 rounded-xl text-sm bg-surface-2 border border-white/10 text-gray-200 outline-none placeholder-gray-600 focus:border-brand-500/50 transition-colors"}),c&&Q.length>0&&e.jsxs("div",{className:"absolute z-20 mt-1 w-80 max-h-72 overflow-auto rounded-xl border border-white/10 bg-surface-1 shadow-xl py-1",children:[e.jsx("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wide text-gray-500 border-b border-white/5 sticky top-0 bg-surface-1",children:p.trim()?`${Q.length} match${Q.length===1?"":"es"}`:"All methods · most connected first"}),Q.map(f=>e.jsxs("button",{onMouseDown:j=>j.preventDefault(),onClick:()=>{b(f.id),a(""),y(!1)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-white/5 transition-colors ${f.id===m?"bg-brand-500/10":""}`,children:[e.jsxs("span",{className:"font-mono text-gray-200",children:[f.className?`${f.className}.`:"",f.name]}),e.jsxs("span",{className:"text-gray-600",children:[" · ",f.file]})]},f.id))]})]}),e.jsxs("span",{className:"hidden lg:flex items-center gap-1.5 text-[11px] text-gray-500",children:[e.jsx("span",{className:"font-medium text-gray-400",children:"tests"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callers"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-brand-400",children:"focus"}),e.jsx("span",{className:"text-gray-600",children:"→"}),e.jsx("span",{className:"font-medium text-gray-400",children:"callees"}),e.jsx("span",{className:"text-gray-600 ml-1",children:"· hover to trace · click to re-center · double-click to inspect"})]}),(h==null?void 0:h.truncated)&&e.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-amber-400",children:[e.jsx(me,{size:12})," graph truncated (large neighborhood)"]})]}),e.jsxs("div",{className:"flex-1 relative bg-surface-0",children:[N&&e.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center text-sm text-gray-500 bg-surface-0/60 backdrop-blur-sm",children:[e.jsx(P,{size:16,className:"animate-spin mr-2"})," Building graph…"]}),m?h&&e.jsxs(Lt,{nodes:$,edges:M,onNodesChange:q,onEdgesChange:x,onInit:f=>{W.current=f},fitView:!0,minZoom:.2,fitViewOptions:{padding:.25},nodesConnectable:!1,nodesDraggable:!0,onNodeClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&b(j.id)},onNodeDoubleClick:(f,j)=>{(h==null?void 0:h.kinds[j.id])!=="test"&&r(j.id)},onNodeMouseEnter:(f,j)=>E(j.id),onNodeMouseLeave:()=>E(null),proOptions:{hideAttribution:!0},children:[e.jsx(Mt,{color:l?"#cbd5e1":"#2c2d36",gap:22,size:1}),e.jsx(Rt,{showInteractive:!1,className:"cm-graph-controls"}),e.jsx(At,{position:"top-right",children:e.jsxs("div",{className:"flex flex-col gap-1.5 rounded-xl border border-white/10 bg-surface-1/95 backdrop-blur px-3 py-2.5 shadow-lg",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide font-semibold text-gray-500 mb-0.5",children:"Legend"}),Bs.map(f=>{const j=it(f.kind,l);return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 rounded-md shrink-0",style:{background:j.background,border:j.border}}),e.jsx("span",{className:"text-[11px] text-gray-400",children:f.label})]},f.kind)})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 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",children:e.jsx(_e,{size:22})}),e.jsx("div",{className:"text-sm",children:"Search for a method above to view its call graph."})]})]})]})}function _s({files:t}){const r=o.useMemo(()=>{const l=new Map;for(const i of t){const m=i.file.replace(/\\/g,"/").split("/")[0]||"(root)",b=l.get(m)||{files:0,methods:0,unused:0,dup:0,cxSum:0,scoreSum:0};b.files+=1,b.methods+=i.methods,b.unused+=i.unused,b.dup+=i.duplicated,b.cxSum+=i.avgComplexity*i.methods,b.scoreSum+=i.score,l.set(m,b)}return[...l.entries()].map(([i,m])=>({name:i,files:m.files,methods:m.methods,unused:m.unused,dup:m.dup,avgCx:m.methods?Math.round(m.cxSum/m.methods*10)/10:0,score:m.files?Math.round(m.scoreSum/m.files):0})).sort((i,m)=>i.score-m.score)},[t]);if(r.length===0)return null;const n=l=>l>=80?"text-emerald-400":l>=70?"text-amber-400":l>=60?"text-orange-400":"text-red-400";return e.jsx(G,{title:"Module overview",hint:"Aggregated by top-level folder. Lowest health first.",children:e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-2",children:r.map(l=>e.jsxs("div",{className:"rounded-xl border border-white/5 bg-surface-2/40 p-3 hover:bg-surface-2/60 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-mono text-base text-gray-200 truncate",title:l.name,children:[l.name,"/"]}),e.jsx("span",{className:`text-base font-semibold tabular-nums ${n(l.score)}`,children:l.score})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[l.files," files"]}),e.jsxs("span",{children:[l.methods," methods"]}),e.jsxs("span",{children:["avg cx ",l.avgCx]}),l.unused>0&&e.jsxs("span",{className:"text-amber-400",children:[l.unused," unused"]}),l.dup>0&&e.jsxs("span",{className:"text-amber-400",children:[l.dup," dup"]})]})]},l.name))})})}export{Js as CodeMapPage};
@@ -1 +1 @@
1
- import{b as u,j as e}from"./vendor-react-CTbHBddL.js";import{o as h}from"./vendor-icons-B0wLOBoh.js";function v({open:a,title:i,description:n,confirmLabel:l="Delete",cancelLabel:o="Cancel",onConfirm:c,onCancel:r,variant:d="danger",icon:x,size:t="md",children:m,confirmDisabled:b=!1}){if(!a)return null;const g=t==="xl"?"w-[760px]":t==="lg"?"w-[640px]":"w-[480px]",s=d==="primary"?{iconBg:"bg-brand-500/15",iconColor:"text-brand-400",confirmBg:"bg-brand-600 hover:bg-brand-500"}:{iconBg:"bg-red-500/15",iconColor:"text-red-400",confirmBg:"bg-red-600 hover:bg-red-500"},f=x??h;return u.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:r}),e.jsxs("div",{className:`relative bg-surface-1 rounded-xl border border-white/10 p-6 ${g} max-w-[90vw] animate-fade-in`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-full ${s.iconBg} flex items-center justify-center flex-shrink-0`,children:e.jsx(f,{size:20,className:s.iconColor})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:i}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:n}),m]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:o}),e.jsx("button",{onClick:c,disabled:b,className:`px-4 py-2 text-sm rounded-lg ${s.confirmBg} text-white font-medium disabled:opacity-50 disabled:cursor-not-allowed`,children:l})]})]})]}),document.body)}export{v as C};
1
+ import{b as u,j as e}from"./vendor-react-CTbHBddL.js";import{o as h}from"./vendor-icons-BKPiFyYV.js";function v({open:a,title:i,description:n,confirmLabel:l="Delete",cancelLabel:o="Cancel",onConfirm:c,onCancel:r,variant:d="danger",icon:x,size:t="md",children:m,confirmDisabled:b=!1}){if(!a)return null;const g=t==="xl"?"w-[760px]":t==="lg"?"w-[640px]":"w-[480px]",s=d==="primary"?{iconBg:"bg-brand-500/15",iconColor:"text-brand-400",confirmBg:"bg-brand-600 hover:bg-brand-500"}:{iconBg:"bg-red-500/15",iconColor:"text-red-400",confirmBg:"bg-red-600 hover:bg-red-500"},f=x??h;return u.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:r}),e.jsxs("div",{className:`relative bg-surface-1 rounded-xl border border-white/10 p-6 ${g} max-w-[90vw] animate-fade-in`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:`w-10 h-10 rounded-full ${s.iconBg} flex items-center justify-center flex-shrink-0`,children:e.jsx(f,{size:20,className:s.iconColor})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:i}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:n}),m]})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:r,className:"px-4 py-2 text-sm rounded-lg bg-surface-2 hover:bg-surface-3 text-gray-300",children:o}),e.jsx("button",{onClick:c,disabled:b,className:`px-4 py-2 text-sm rounded-lg ${s.confirmBg} text-white font-medium disabled:opacity-50 disabled:cursor-not-allowed`,children:l})]})]})]}),document.body)}export{v as C};