@testver/testver 1.4.2 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/index.js +1174 -800
  2. package/package.json +1 -1
  3. package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
  4. package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
  5. package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
  6. package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
  7. package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
  8. package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
  9. package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
  10. package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
  11. package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
  12. package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
  13. package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
  14. package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
  15. package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
  16. package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
  17. package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
  18. package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
  19. package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
  20. package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
  21. package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
  22. package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
  23. package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
  24. package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
  25. package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
  26. package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
  27. package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
  28. package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
  29. package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
  30. package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
  31. package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
  32. package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
  33. package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
  34. package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
  35. package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
  36. package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
  37. package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
  38. package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
  39. package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
  40. package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
  41. package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
  42. package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
  43. package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
  44. package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
  45. package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
  46. package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
  47. package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
  48. package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
  49. package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
  50. package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
  51. package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
  52. package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
  53. package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
  54. package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
  55. package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
  56. package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
  57. package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
  58. package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
  59. package/src/ui/static/assets/index-aInN0yoR.css +1 -0
  60. package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
  61. package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
  62. package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
  63. package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
  64. package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
  65. package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
  66. package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
  67. package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
  68. package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
  69. package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
  70. package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
  71. package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
  72. package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
  73. package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
  74. package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
  75. package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
  76. package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
  77. package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
  78. package/src/ui/static/index.html +5 -5
  79. package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
  80. package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
  81. package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
  82. package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
  83. package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
  84. package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
  85. package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
  86. package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
  87. package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
  88. package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
  89. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as o,j as e,L as V,u as W,e as Ie}from"./vendor-react-CTbHBddL.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{s as Le}from"./visibleInterval-BKsLfJZ3.js";import{b as Y,a8 as X,ip as ze,bN as Pe,gK as De,gJ as Fe,iq as _e,gI as Oe,ir as Be,is as me,it as Me,iu as ue,iv as qe,iw as Ue,ix as Ke}from"./index-BYVxKLrT.js";import{C as pe}from"./ConfirmDialog-t7mpeeSN.js";import{t as L,i as J,S as ge,s as be,a as Qe}from"./reportMeta-AKcU_qwq.js";import{h as ye}from"./aiHandoff-vhtR29Fh.js";import{s as Ve}from"./KpiTile-inmeEsy3.js";import{a0 as z,g as Z,S as q,v as He,c7 as Ge,c8 as We,bp as ee,R as te,a3 as F,dl as ae,a5 as Ye,y as fe,cu as Xe,bo as Je,b7 as je,b4 as Ze,ag as ie,X as et,a2 as tt}from"./vendor-icons-BKPiFyYV.js";import"./vendor-query-BrzmPFT3.js";import"./CronBuilder-Nk-K-_8I.js";const oe="testver-reports-view",H={good:"text-emerald-700 dark:text-emerald-400",bad:"text-rose-700 dark:text-rose-400",warn:"text-amber-700 dark:text-amber-400",flat:"text-gray-600 dark:text-gray-400"},de={good:"#059669",bad:"#dc2626",warn:"#d97706",flat:"#94a3b8"},G="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 text-[13px] font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",se="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",Q="h-9 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-sm text-gray-900 dark:text-gray-100",M="flex flex-col gap-1 text-xs font-semibold text-gray-600 dark:text-gray-400";function ce({shared:t,reports:n,schedules:a,loading:l,reload:i,onNewReport:x,onBrowseTemplates:d}){var re;const c=Y(),g=X().hasRole("tester"),[N,C]=o.useState(""),[w,S]=o.useState("all"),[k,b]=o.useState("any"),[R,A]=o.useState("updated"),[y,v]=o.useState(()=>{try{return localStorage.getItem(oe)==="list"?"list":"grid"}catch{return"grid"}}),[m,f]=o.useState(null),[p,r]=o.useState(null),[h,$]=o.useState(null);o.useEffect(()=>{try{localStorage.setItem(oe,y)}catch{}},[y]);const _=o.useMemo(()=>{const s=new Map;for(const u of a)s.set(u.sourceReportId,[...s.get(u.sourceReportId)??[],u]);return s},[a]),Te=o.useMemo(()=>[...new Set(n.map(s=>s.templateId||""))].sort((s,u)=>L(s).localeCompare(L(u))),[n]),P=o.useMemo(()=>{const s=N.trim().toLowerCase(),u=n.filter(j=>{var T,ne;if(s&&!`${j.title} ${L(j.templateId)} ${((T=j.preview)==null?void 0:T.verdict)??""}`.toLowerCase().includes(s)||w!=="all"&&(j.templateId||"")!==w)return!1;if(k!=="any"){const Ee=J((ne=j.preview)==null?void 0:ne.generatedAt,j.templateId);if(k==="stale"!==Ee)return!1}return!0}),E=j=>{var T;return((T=j.preview)==null?void 0:T.generatedAt)||j.updatedAt||""};return u.sort((j,T)=>R==="name"?j.title.localeCompare(T.title):R==="data"?E(T).localeCompare(E(j)):(T.updatedAt||"").localeCompare(j.updatedAt||""))},[n,N,w,k,R]),O=t?[]:P.filter(s=>s.pinned),U=t?P:P.filter(s=>!s.pinned),Ae=!!N.trim()||w!=="all"||k!=="any",Ce=s=>g&&s.mine!==!1,B=async(s,u)=>{f(s);try{await u()}finally{f(null)}},D=s=>s instanceof Error?s.message:String(s),K={canChange:Ce,busy:m,schedulesOf:s=>_.get(s.id)??[],refresh:s=>B(`${s.id}:refresh`,async()=>{try{await Be(s.id),c.toast("success",`"${s.title}" refreshed with current data`),await i()}catch(u){c.toast("error",`Refresh failed: ${D(u)}`)}}),exportAs:(s,u)=>B(`${s.id}:${u}`,async()=>{try{await Oe(u,{reportId:s.id})}catch(E){c.toast("error",`Download failed: ${D(E)}`)}}),togglePin:s=>B(`${s.id}:pin`,async()=>{try{await _e(s.id,{pinned:!s.pinned}),await i()}catch(u){c.toast("error",`Pin failed: ${D(u)}`)}}),toggleShare:s=>B(`${s.id}:share`,async()=>{try{if(s.shareToken)await De(s.id),c.toast("success","Share link revoked");else{const{shareUrl:u}=await Fe(s.id),E=`${window.location.origin}${u}`;try{await navigator.clipboard.writeText(E)}catch{}c.toast("success",`Share link copied: ${E}`)}await i()}catch(u){c.toast("error",`Share failed: ${D(u)}`)}}),schedule:s=>$(s),remove:s=>r(s)},$e=async()=>{if(p)try{await ze(p.id),r(null),c.toast("success","Report deleted"),await i()}catch(s){c.toast("error",`Delete failed: ${D(s)}`)}};return l?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 py-10 justify-center",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading reports…"]}):n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.02] px-6 py-14 text-center",children:[e.jsx(Z,{size:30,className:"mx-auto mb-3 text-gray-400","aria-hidden":!0}),e.jsx("p",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t?"No shared reports yet":"No saved reports yet"}),e.jsx("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-lg mx-auto",children:t?"Reports anyone in this workspace shares with a public link appear here, for every role.":"Ask the AI Assistant for a report in Reporting mode, then save it with the bookmark button on the report — or start from a template."}),!t&&g&&e.jsxs("div",{className:"mt-5 flex justify-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:x,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-4 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(q,{size:15})," New report with AI"]}),e.jsx("button",{onClick:d,className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 px-4 text-sm font-medium text-gray-900 dark:text-gray-100",children:"Browse templates"})]})]}):e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"report-library",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3","data-testid":"report-toolbar",children:[e.jsxs("label",{className:`${M} flex-[1_1_260px]`,children:["Search",e.jsxs("span",{className:"flex h-9 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5",children:[e.jsx(He,{size:15,className:"text-gray-500","aria-hidden":!0}),e.jsx("input",{type:"search",value:N,onChange:s=>C(s.target.value),placeholder:"Search reports",className:"w-full bg-transparent text-sm font-normal text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-500"})]})]}),e.jsxs("label",{className:M,children:["Template",e.jsxs("select",{value:w,onChange:s=>S(s.target.value),className:Q,children:[e.jsx("option",{value:"all",children:"All templates"}),Te.map(s=>e.jsx("option",{value:s,children:L(s)},s||"custom"))]})]}),e.jsxs("label",{className:M,children:["Updated",e.jsxs("select",{value:k,onChange:s=>b(s.target.value),className:Q,children:[e.jsx("option",{value:"any",children:"Any time"}),e.jsx("option",{value:"fresh",children:"Up to date"}),e.jsx("option",{value:"stale",children:"Out of date"})]})]}),e.jsxs("label",{className:M,children:["Sort",e.jsxs("select",{value:R,onChange:s=>A(s.target.value),className:Q,children:[e.jsx("option",{value:"updated",children:"Recently changed"}),e.jsx("option",{value:"data",children:"Newest data"}),e.jsx("option",{value:"name",children:"Name"})]})]}),e.jsxs("div",{role:"group","aria-label":"View",className:"flex h-9 overflow-hidden rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04]",children:[e.jsx("button",{"aria-label":"Grid view","aria-pressed":y==="grid",onClick:()=>v("grid"),className:`flex w-9 items-center justify-center ${y==="grid"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(Ge,{size:15})}),e.jsx("button",{"aria-label":"List view","aria-pressed":y==="list",onClick:()=>v("list"),className:`flex w-9 items-center justify-center ${y==="list"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(We,{size:15})})]})]}),P.length===0&&e.jsxs("p",{className:"py-10 text-center text-sm text-gray-600 dark:text-gray-400",children:["No reports match",Ae?" these filters":"","."," ",e.jsx("button",{className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",onClick:()=>{C(""),S("all"),b("any")},children:"Clear filters"})]}),y==="list"?P.length>0&&e.jsx(st,{reports:[...O,...U],actions:K}):e.jsxs(e.Fragment,{children:[O.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":"Pinned reports",children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"Pinned"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))]",children:O.map(s=>e.jsx(he,{report:s,actions:K,large:!0},s.id))})]}),U.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":t?"Shared reports":"All reports",children:[O.length>0&&e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"All reports"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))]",children:U.map(s=>e.jsx(he,{report:s,actions:K},s.id))})]})]}),h&&e.jsx(ge,{reports:[h],editing:null,initialReportId:h.id,onClose:()=>$(null),onSaved:async()=>{$(null),await i()}}),e.jsx(pe,{open:!!p,title:"Delete report?",description:`"${p==null?void 0:p.title}" will be permanently deleted. Any active share link will stop working.`+(p&&(((re=_.get(p.id))==null?void 0:re.length)??0)>0?` ${_.get(p.id).length} scheduled email${_.get(p.id).length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:$e,onCancel:()=>r(null)})]})}function we({report:t}){var l,i;const n=((l=t.preview)==null?void 0:l.generatedAt)||t.updatedAt,a=J((i=t.preview)==null?void 0:i.generatedAt,t.templateId);return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${a?"font-medium text-amber-700 dark:text-amber-400":""}`,title:a?"Out of date — Refresh rebuilds it from current results":void 0,children:[e.jsx("span",{className:`h-[7px] w-[7px] rounded-full ${a?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":!0}),"Updated ",Qe(n),a?" · out of date":""]})}function xe({preview:t,height:n}){var x,d;const a=t!=null&&t.trend?Ve(t.trend,160,n,5):"";if(!a)return null;const l=(t==null?void 0:t.status)??((x=t==null?void 0:t.kpis[0])==null?void 0:x.status)??((d=t==null?void 0:t.kpis[0])==null?void 0:d.tone)??"good",i=de[l]??de.good;return e.jsxs("svg",{viewBox:`0 0 160 ${n}`,preserveAspectRatio:"none",className:"block w-full",style:{height:n},role:"img","aria-label":"Trend",children:[e.jsx("polygon",{points:`0,${n} ${a} 160,${n}`,fill:i,fillOpacity:.1}),e.jsx("polyline",{points:a,fill:"none",stroke:i,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})]})}function at({preview:t,size:n}){const a=(t==null?void 0:t.kpis)??[];return a.length===0?t!=null&&t.verdict?e.jsx("p",{className:"text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:t.verdict}):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Open the report to see it."}):e.jsx("div",{className:"grid grid-cols-3 gap-3",children:a.map((l,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-xs text-gray-600 dark:text-gray-400",title:l.title,children:l.title}),e.jsx("p",{className:`truncate font-bold tabular-nums text-gray-900 dark:text-gray-100 ${n==="lg"?"text-xl":"text-[17px]"} ${l.status?H[l.status]:""}`,title:l.value,children:l.value}),l.delta&&e.jsx("p",{className:`text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]},i))})}function he({report:t,actions:n,large:a=!1}){var c;const l=n.canChange(t),i=n.schedulesOf(t),x=J((c=t.preview)==null?void 0:c.generatedAt,t.templateId),d=n.busy===`${t.id}:refresh`;return e.jsxs("article",{className:"flex flex-col rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]","data-testid":"report-card",children:[e.jsxs("div",{className:`flex flex-col gap-2 ${a?"px-5 pt-5":"px-4 pt-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"rounded-md bg-gray-100 dark:bg-white/10 px-2 py-0.5 text-xs font-semibold text-gray-700 dark:text-gray-300",children:L(t.templateId)}),t.pinned&&e.jsx(ee,{size:15,className:"text-amber-600","aria-label":"Pinned"})]}),e.jsx("h3",{className:`font-bold text-gray-900 dark:text-gray-100 ${a?"text-lg":"text-base"}`,children:e.jsx(V,{to:`/reports/view/${t.id}`,className:"hover:underline",children:t.title})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-gray-600 dark:text-gray-400",children:[e.jsx(we,{report:t}),i.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{size:12,"aria-hidden":!0})," ",be(g)]},g.id))]})]}),e.jsxs("div",{className:`grid items-end gap-3 ${a?"grid-cols-[minmax(0,3fr)_minmax(0,1.2fr)] px-5 py-4":"grid-cols-1 px-4 pt-3.5 pb-1"}`,children:[e.jsx(at,{preview:t.preview,size:a?"lg":"md"}),a&&e.jsx(xe,{preview:t.preview,height:48})]}),!a&&e.jsx(xe,{preview:t.preview,height:40}),e.jsxs("div",{className:`mt-auto flex flex-wrap items-center gap-2 border-t border-gray-100 dark:border-white/[0.06] ${a?"px-5 py-3":"px-4 py-2.5"}`,children:[e.jsx(V,{to:`/reports/view/${t.id}`,className:`${G} ${a?"":"flex-1 justify-center"} !bg-brand-600 !text-white !border-brand-600 hover:!bg-brand-700`,children:"Open"}),l&&e.jsxs("button",{onClick:()=>n.refresh(t),disabled:d,className:`${G} ${x?"!border-amber-300 !bg-amber-50 !text-amber-800 dark:!bg-amber-500/15 dark:!text-amber-300 dark:!border-amber-400/30":""}`,title:"The AI rebuilds this report from current data (30 seconds to 2 minutes; uses AI credits)",children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14}),d?"Refreshing…":x?"Refresh now":"Refresh"]}),e.jsx(Ne,{report:t,actions:n,compact:!a}),l&&e.jsx(Se,{report:t,actions:n}),t.shareToken&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-300","data-testid":"report-shared-by",children:[e.jsx(ae,{size:11,"aria-hidden":!0}),t.mine===!1?`Shared${t.sharedByName?` by ${t.sharedByName}`:""}`:`Shared link · ${t.shareViews??0} view${t.shareViews===1?"":"s"}`]})]})]})}function st({reports:t,actions:n}){return e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full min-w-[900px] border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-white/[0.04] text-left text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400",children:[e.jsx("th",{className:"px-4 py-2.5",children:"Report"}),e.jsx("th",{className:"px-4 py-2.5",children:"Headline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Updated"}),e.jsx("th",{className:"px-4 py-2.5",children:"Schedule"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(a=>{var x;const l=(x=a.preview)==null?void 0:x.kpis[0],i=n.schedulesOf(a);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/[0.06] align-middle","data-testid":"report-row",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a.pinned&&e.jsx(ee,{size:13,className:"text-amber-600 flex-shrink-0","aria-label":"Pinned"}),e.jsx(V,{to:`/reports/view/${a.id}`,className:"font-semibold text-gray-900 dark:text-gray-100 hover:underline",children:a.title})]}),e.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-400",children:[L(a.templateId),a.shareToken?" · shared":""]})]}),e.jsx("td",{className:"px-4 py-3",children:l?e.jsxs("span",{className:"tabular-nums",children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[l.title," "]}),e.jsx("strong",{className:"text-gray-900 dark:text-gray-100",children:l.value}),l.delta&&e.jsx("span",{className:`ml-1.5 text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]}):e.jsx("span",{className:"text-gray-500",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400 whitespace-nowrap",children:e.jsx(we,{report:a})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400",children:i.length?i.map(be).join("; "):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-end gap-1.5",children:[n.canChange(a)&&e.jsx("button",{onClick:()=>n.refresh(a),disabled:n.busy===`${a.id}:refresh`,className:se,"aria-label":"Refresh data",title:"Refresh data",children:n.busy===`${a.id}:refresh`?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14})}),e.jsx(Ne,{report:a,actions:n,compact:!0}),n.canChange(a)&&e.jsx(Se,{report:a,actions:n})]})})]},a.id)})})]})})}function ke(){const[t,n]=o.useState(!1),a=o.useRef(null);return o.useEffect(()=>{if(!t)return;const l=x=>{a.current&&!a.current.contains(x.target)&&n(!1)},i=x=>{x.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[t]),{open:t,setOpen:n,ref:a}}const ve="absolute right-0 top-full mt-1 z-20 w-48 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",I="w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5";function Ne({report:t,actions:n,compact:a=!1}){const{open:l,setOpen:i,ref:x}=ke(),d=!!n.busy&&n.busy.startsWith(`${t.id}:`)&&/:(pdf|docx|xlsx)$/.test(n.busy),c=t.mine===!1&&t.shareToken?`/api/reports/share/${encodeURIComponent(t.shareToken)}/render.html`:Pe(`/api/reports/${encodeURIComponent(t.id)}/render.html`);return e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>i(g=>!g),className:a?se:G,"aria-label":"Download","aria-haspopup":"menu","aria-expanded":l,disabled:d,children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),!a&&e.jsxs(e.Fragment,{children:["Download ",e.jsx(fe,{size:13,"aria-hidden":!0})]})]}),l&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsx("a",{role:"menuitem",href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>i(!1),className:I,children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([g,N])=>e.jsx("button",{role:"menuitem",className:I,onClick:()=>{i(!1),n.exportAs(t,g)},children:N},g))]})]})}function Se({report:t,actions:n}){const{open:a,setOpen:l,ref:i}=ke(),x=W(),d=c=>()=>{l(!1),c()};return e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>l(c=>!c),className:se,"aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,children:e.jsx(Xe,{size:15})}),a&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>x(`/reports/view/${t.id}`)),children:[e.jsx(Z,{size:14})," Open"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.togglePin(t)),children:[t.pinned?e.jsx(Je,{size:14}):e.jsx(ee,{size:14})," ",t.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.toggleShare(t)),children:[e.jsx(ae,{size:14})," ",t.shareToken?"Revoke share link":"Copy a share link"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>n.schedule(t)),children:[e.jsx(F,{size:14})," Schedule email…"]}),e.jsxs("button",{role:"menuitem",className:`${I} !text-rose-700 dark:!text-rose-400`,onClick:d(()=>n.remove(t)),children:[e.jsx(je,{size:14})," Delete"]})]})]})}const rt=["my","shared","scheduled","templates"];function yt(){const t=W(),n=Y(),a=X().hasRole("tester"),[l,i]=Ie(),x=l.get("tab"),d=x&&rt.includes(x)?x:"my",c=m=>i(f=>{const p=new URLSearchParams(f);return m==="my"?p.delete("tab"):p.set("tab",m),p},{replace:!0}),[g,N]=o.useState([]),[C,w]=o.useState([]),[S,k]=o.useState([]),[b,R]=o.useState(!0),A=async()=>{try{const[m,f,p]=await Promise.all([me(),Me(),ue().catch(()=>({schedules:[],count:0}))]);N(m.reports),w(f.reports),k(p.schedules)}catch(m){n.toast("error",`Load failed: ${m instanceof Error?m.message:String(m)}`)}finally{R(!1)}};o.useEffect(()=>{A()},[d]);const y=()=>ye(t,{mode:"reporting"}),v=[{id:"my",label:"My reports",Icon:Z,count:b?null:g.length},{id:"shared",label:"Shared",Icon:ae,count:b?null:C.length},{id:"scheduled",label:"Scheduled",Icon:F,count:b?null:S.length},{id:"templates",label:"Templates",Icon:q,count:Re.length}];return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[26px] font-bold tracking-tight text-gray-900 dark:text-gray-100",children:"Reports"}),e.jsxs("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-3xl",children:["Dashboards built by the AI Assistant in Reporting mode. Refresh, share, schedule or download any of them."," ",e.jsx("strong",{className:"font-semibold text-gray-800 dark:text-gray-200",children:"Shared"})," lists every report with a public link in this workspace — anyone signed in can open it."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>c("scheduled"),className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08]",children:[e.jsx(F,{size:15})," Schedules"]}),a&&e.jsxs("button",{onClick:y,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(q,{size:15})," New report with AI"]})]})]}),e.jsx("div",{role:"tablist",className:"flex gap-6 overflow-x-auto border-b border-gray-200 dark:border-white/10","data-testid":"report-tabs",children:v.map(m=>{const f=d===m.id;return e.jsxs("button",{role:"tab","aria-selected":f,onClick:()=>c(m.id),className:`flex h-10 flex-shrink-0 items-center gap-2 whitespace-nowrap border-b-2 px-0.5 text-sm transition-colors ${f?"border-gray-900 dark:border-gray-100 font-semibold text-gray-900 dark:text-gray-100":"border-transparent font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(m.Icon,{size:15,"aria-hidden":!0,className:f?"":"opacity-80"}),m.label,m.count!=null&&e.jsx("span",{className:`min-w-[22px] rounded-full px-2 py-px text-center text-xs font-semibold tabular-nums ${f?"bg-brand-600 text-white dark:bg-white dark:text-gray-900":"bg-gray-200 text-gray-700 dark:bg-white/10 dark:text-gray-300"}`,children:m.count})]},m.id)})}),d==="my"&&e.jsx(ce,{shared:!1,reports:g,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="shared"&&e.jsx(ce,{shared:!0,reports:C,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="scheduled"&&e.jsx(nt,{}),d==="templates"&&e.jsx(lt,{})]})}function nt(){const t=Y(),n=X().hasRole("tester"),[a,l]=o.useState([]),[i,x]=o.useState([]),[d,c]=o.useState(!0),[g,N]=o.useState(!1),[C,w]=o.useState(null),[S,k]=o.useState(!1),[b,R]=o.useState(null),[A,y]=o.useState(null),v=async r=>{r!=null&&r.initial?c(!0):r!=null&&r.silent||N(!0);try{const[h,$]=await Promise.all([ue(),me()]);l(h.schedules),x($.reports)}catch(h){r!=null&&r.silent||t.toast("error",`Load failed: ${h instanceof Error?h.message:String(h)}`)}finally{c(!1),N(!1)}};o.useEffect(()=>{v({initial:!0})},[]),o.useEffect(()=>{if(!(S||b))return Le(()=>{v({silent:!0})},2e4)},[S,b]);const m=async r=>{try{await Ue(r.id,{enabled:!r.enabled}),await v()}catch(h){t.toast("error",`Update failed: ${h instanceof Error?h.message:String(h)}`)}},f=async r=>{y(r.id);try{const h=await qe(r.id);h.success?t.toast("success","Dispatch succeeded"):t.toast("error",`Dispatch failed: ${h.error||"unknown"}`),await v()}catch(h){t.toast("error",`Run failed: ${h instanceof Error?h.message:String(h)}`)}finally{y(null)}},p=async()=>{if(b)try{await Ke(b.id),t.toast("success","Schedule deleted"),R(null),await v()}catch(r){t.toast("error",`Delete failed: ${r instanceof Error?r.message:String(r)}`)}};return d?e.jsxs("div",{className:"py-10 text-center text-sm text-gray-500",children:[e.jsx(z,{size:14,className:"inline animate-spin mr-2"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.length," schedule",a.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(),disabled:g,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors disabled:opacity-60",title:"Refresh schedule list",children:[e.jsx(te,{size:12,className:g?"animate-spin":""}),g?"Refreshing…":"Refresh"]}),n&&e.jsxs("button",{onClick:()=>{w(null),k(!0)},disabled:i.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors disabled:opacity-50",title:i.length===0?"Save a report first in Reporting mode, then you can schedule it":"Create a new schedule",children:[e.jsx(Ze,{size:12})," New schedule"]})]})]}),a.length===0?e.jsxs("div",{className:"text-center py-14 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(F,{size:28,className:"mx-auto mb-3 opacity-40"}),"No schedules yet. Click ",e.jsx("strong",{children:"New schedule"})," to dispatch a saved report on a recurring basis."]}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-white/[0.04]",children:e.jsxs("tr",{className:"text-left text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Schedule"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Format"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Recipients"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last run"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Status"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-white/[0.02]",children:a.map(r=>{const h=i.find($=>$.id===r.sourceReportId);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/5 bg-white dark:bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:r.title})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[160px]",children:h?h.title:e.jsx("span",{className:"text-rose-500",children:"Missing"})}),e.jsxs("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300",title:r.cron,children:[r.cronHuman&&r.cronHuman!==r.cron?r.cronHuman:e.jsx("span",{className:"font-mono",children:r.cron}),r.enabled&&r.nextRun&&e.jsxs("div",{className:"text-[10px] text-gray-500",children:["next ",le(r.nextRun)]})]}),e.jsx("td",{className:"px-3 py-2 text-xs uppercase text-gray-600 dark:text-gray-400",children:r.format}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300 truncate max-w-[180px]",title:r.recipients.join(", "),children:r.recipients.length===1?r.recipients[0]:`${r.recipients.length} recipients`}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:r.lastRun?le(r.lastRun):"—"}),e.jsx("td",{className:"px-3 py-2 text-xs",children:r.enabled?r.lastStatus==="success"&&r.lastWarning?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",title:r.lastWarning,children:[e.jsx(ie,{size:10})," Sent · stale data"]}):r.lastStatus==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400",children:[e.jsx(ie,{size:10})," Success"]}):r.lastStatus==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-rose-600 dark:text-rose-400",title:r.lastError,children:[e.jsx(et,{size:10})," Error"]}):e.jsx("span",{className:"text-gray-500",children:"—"}):e.jsx("span",{className:"text-gray-500",children:"paused"})}),e.jsx("td",{className:"px-3 py-2",children:n&&e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>f(r),disabled:A===r.id,className:"p-1 rounded text-gray-500 hover:text-emerald-600 hover:bg-emerald-500/10 disabled:opacity-50",title:"Run now",children:A===r.id?e.jsx(z,{size:12,className:"animate-spin"}):e.jsx(tt,{size:12})}),e.jsx("button",{onClick:()=>m(r),className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/5",title:r.enabled?"Pause — stop sending until resumed":"Resume — send on schedule again",children:r.enabled?e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"PAUSE"}):e.jsx("span",{className:"text-[10px] font-semibold px-1 text-emerald-500",children:"RESUME"})}),e.jsx("button",{onClick:()=>{w(r),k(!0)},className:"p-1 rounded text-gray-500 hover:text-brand-500 hover:bg-brand-500/10",title:"Edit",children:e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"EDIT"})}),e.jsx("button",{onClick:()=>R(r),className:"p-1 rounded text-gray-500 hover:text-rose-500 hover:bg-rose-500/10",title:"Delete",children:e.jsx(je,{size:12})})]})})]},r.id)})})]})}),S&&e.jsx(ge,{reports:i,editing:C,onClose:()=>{k(!1),w(null)},onSaved:async()=>{k(!1),w(null),await v()}}),e.jsx(pe,{open:!!b,title:"Delete schedule?",description:`"${b==null?void 0:b.title}" will stop dispatching. This cannot be undone.`,confirmLabel:"Delete",onConfirm:p,onCancel:()=>R(null)})]})}const Re=[{id:"executive",label:"Executive Summary",description:"High-level KPIs + pass-rate trend + top failures — for managers.",prompt:`Build an EXECUTIVE QA dashboard for the current sprint using the \`generate_dashboard\` tool.
1
+ import{r as o,j as e,L as V,u as W,e as Ie}from"./vendor-react-DOVfxdUy.js";import{f as le}from"./formatDate-T65-Y6Mi.js";import{s as Le}from"./visibleInterval-BKsLfJZ3.js";import{b as Y,ae as X,iu as ze,bY as Pe,gP as De,gO as Fe,iv as _e,gN as Oe,iw as Be,ix as me,iy as Me,iz as ue,iA as Ue,iB as qe,iC as Ke}from"./index-D6sQYc_0.js";import{C as pe}from"./ConfirmDialog-DtotgVmI.js";import{t as L,i as J,S as ge,s as be,a as Qe}from"./reportMeta-3kxT7BIT.js";import{h as ye}from"./aiHandoff-vhtR29Fh.js";import{s as Ve}from"./KpiTile-BHLE3HVj.js";import{a0 as z,i as Z,S as U,v as He,c7 as Ge,c8 as We,bp as ee,R as te,a3 as F,dk as ae,a5 as Ye,y as fe,cu as Xe,bo as Je,b7 as je,b4 as Ze,ag as ie,X as et,a2 as tt}from"./vendor-icons-D_Dmmj8d.js";import"./vendor-query-DkZSMtfn.js";import"./CronBuilder-D2fERHt9.js";const oe="testver-reports-view",H={good:"text-emerald-700 dark:text-emerald-400",bad:"text-rose-700 dark:text-rose-400",warn:"text-amber-700 dark:text-amber-400",flat:"text-gray-600 dark:text-gray-400"},de={good:"#059669",bad:"#dc2626",warn:"#d97706",flat:"#94a3b8"},G="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3 text-[13px] font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",se="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",Q="h-9 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-sm text-gray-900 dark:text-gray-100",M="flex flex-col gap-1 text-xs font-semibold text-gray-600 dark:text-gray-400";function ce({shared:t,reports:n,schedules:a,loading:l,reload:i,onNewReport:x,onBrowseTemplates:d}){var re;const c=Y(),g=X().hasRole("tester"),[N,C]=o.useState(""),[w,S]=o.useState("all"),[k,b]=o.useState("any"),[R,A]=o.useState("updated"),[y,v]=o.useState(()=>{try{return localStorage.getItem(oe)==="list"?"list":"grid"}catch{return"grid"}}),[m,f]=o.useState(null),[p,r]=o.useState(null),[h,$]=o.useState(null);o.useEffect(()=>{try{localStorage.setItem(oe,y)}catch{}},[y]);const _=o.useMemo(()=>{const s=new Map;for(const u of a)s.set(u.sourceReportId,[...s.get(u.sourceReportId)??[],u]);return s},[a]),Te=o.useMemo(()=>[...new Set(n.map(s=>s.templateId||""))].sort((s,u)=>L(s).localeCompare(L(u))),[n]),P=o.useMemo(()=>{const s=N.trim().toLowerCase(),u=n.filter(j=>{var T,ne;if(s&&!`${j.title} ${L(j.templateId)} ${((T=j.preview)==null?void 0:T.verdict)??""}`.toLowerCase().includes(s)||w!=="all"&&(j.templateId||"")!==w)return!1;if(k!=="any"){const Ee=J((ne=j.preview)==null?void 0:ne.generatedAt,j.templateId);if(k==="stale"!==Ee)return!1}return!0}),E=j=>{var T;return((T=j.preview)==null?void 0:T.generatedAt)||j.updatedAt||""};return u.sort((j,T)=>R==="name"?j.title.localeCompare(T.title):R==="data"?E(T).localeCompare(E(j)):(T.updatedAt||"").localeCompare(j.updatedAt||""))},[n,N,w,k,R]),O=t?[]:P.filter(s=>s.pinned),q=t?P:P.filter(s=>!s.pinned),Ae=!!N.trim()||w!=="all"||k!=="any",Ce=s=>g&&s.mine!==!1,B=async(s,u)=>{f(s);try{await u()}finally{f(null)}},D=s=>s instanceof Error?s.message:String(s),K={canChange:Ce,busy:m,schedulesOf:s=>_.get(s.id)??[],refresh:s=>B(`${s.id}:refresh`,async()=>{try{await Be(s.id),c.toast("success",`"${s.title}" refreshed with current data`),await i()}catch(u){c.toast("error",`Refresh failed: ${D(u)}`)}}),exportAs:(s,u)=>B(`${s.id}:${u}`,async()=>{try{await Oe(u,{reportId:s.id})}catch(E){c.toast("error",`Download failed: ${D(E)}`)}}),togglePin:s=>B(`${s.id}:pin`,async()=>{try{await _e(s.id,{pinned:!s.pinned}),await i()}catch(u){c.toast("error",`Pin failed: ${D(u)}`)}}),toggleShare:s=>B(`${s.id}:share`,async()=>{try{if(s.shareToken)await De(s.id),c.toast("success","Share link revoked");else{const{shareUrl:u}=await Fe(s.id),E=`${window.location.origin}${u}`;try{await navigator.clipboard.writeText(E)}catch{}c.toast("success",`Share link copied: ${E}`)}await i()}catch(u){c.toast("error",`Share failed: ${D(u)}`)}}),schedule:s=>$(s),remove:s=>r(s)},$e=async()=>{if(p)try{await ze(p.id),r(null),c.toast("success","Report deleted"),await i()}catch(s){c.toast("error",`Delete failed: ${D(s)}`)}};return l?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600 dark:text-gray-400 py-10 justify-center",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading reports…"]}):n.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.02] px-6 py-14 text-center",children:[e.jsx(Z,{size:30,className:"mx-auto mb-3 text-gray-400","aria-hidden":!0}),e.jsx("p",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t?"No shared reports yet":"No saved reports yet"}),e.jsx("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-lg mx-auto",children:t?"Reports anyone in this workspace shares with a public link appear here, for every role.":"Ask the AI Assistant for a report in Reporting mode, then save it with the bookmark button on the report — or start from a template."}),!t&&g&&e.jsxs("div",{className:"mt-5 flex justify-center gap-2 flex-wrap",children:[e.jsxs("button",{onClick:x,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-4 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]}),e.jsx("button",{onClick:d,className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 px-4 text-sm font-medium text-gray-900 dark:text-gray-100",children:"Browse templates"})]})]}):e.jsxs("div",{className:"flex flex-col gap-5","data-testid":"report-library",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3","data-testid":"report-toolbar",children:[e.jsxs("label",{className:`${M} flex-[1_1_260px]`,children:["Search",e.jsxs("span",{className:"flex h-9 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5",children:[e.jsx(He,{size:15,className:"text-gray-500","aria-hidden":!0}),e.jsx("input",{type:"search",value:N,onChange:s=>C(s.target.value),placeholder:"Search reports",className:"w-full bg-transparent text-sm font-normal text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-500"})]})]}),e.jsxs("label",{className:M,children:["Template",e.jsxs("select",{value:w,onChange:s=>S(s.target.value),className:Q,children:[e.jsx("option",{value:"all",children:"All templates"}),Te.map(s=>e.jsx("option",{value:s,children:L(s)},s||"custom"))]})]}),e.jsxs("label",{className:M,children:["Updated",e.jsxs("select",{value:k,onChange:s=>b(s.target.value),className:Q,children:[e.jsx("option",{value:"any",children:"Any time"}),e.jsx("option",{value:"fresh",children:"Up to date"}),e.jsx("option",{value:"stale",children:"Out of date"})]})]}),e.jsxs("label",{className:M,children:["Sort",e.jsxs("select",{value:R,onChange:s=>A(s.target.value),className:Q,children:[e.jsx("option",{value:"updated",children:"Recently changed"}),e.jsx("option",{value:"data",children:"Newest data"}),e.jsx("option",{value:"name",children:"Name"})]})]}),e.jsxs("div",{role:"group","aria-label":"View",className:"flex h-9 overflow-hidden rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04]",children:[e.jsx("button",{"aria-label":"Grid view","aria-pressed":y==="grid",onClick:()=>v("grid"),className:`flex w-9 items-center justify-center ${y==="grid"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(Ge,{size:15})}),e.jsx("button",{"aria-label":"List view","aria-pressed":y==="list",onClick:()=>v("list"),className:`flex w-9 items-center justify-center ${y==="list"?"bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-gray-100":"text-gray-500"}`,children:e.jsx(We,{size:15})})]})]}),P.length===0&&e.jsxs("p",{className:"py-10 text-center text-sm text-gray-600 dark:text-gray-400",children:["No reports match",Ae?" these filters":"","."," ",e.jsx("button",{className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",onClick:()=>{C(""),S("all"),b("any")},children:"Clear filters"})]}),y==="list"?P.length>0&&e.jsx(st,{reports:[...O,...q],actions:K}):e.jsxs(e.Fragment,{children:[O.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":"Pinned reports",children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"Pinned"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,420px),1fr))]",children:O.map(s=>e.jsx(he,{report:s,actions:K,large:!0},s.id))})]}),q.length>0&&e.jsxs("section",{className:"flex flex-col gap-3","aria-label":t?"Shared reports":"All reports",children:[O.length>0&&e.jsx("h2",{className:"text-xs font-bold uppercase tracking-wider text-gray-600 dark:text-gray-400",children:"All reports"}),e.jsx("div",{className:"grid gap-4 grid-cols-[repeat(auto-fill,minmax(min(100%,300px),1fr))]",children:q.map(s=>e.jsx(he,{report:s,actions:K},s.id))})]})]}),h&&e.jsx(ge,{reports:[h],editing:null,initialReportId:h.id,onClose:()=>$(null),onSaved:async()=>{$(null),await i()}}),e.jsx(pe,{open:!!p,title:"Delete report?",description:`"${p==null?void 0:p.title}" will be permanently deleted. Any active share link will stop working.`+(p&&(((re=_.get(p.id))==null?void 0:re.length)??0)>0?` ${_.get(p.id).length} scheduled email${_.get(p.id).length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:$e,onCancel:()=>r(null)})]})}function we({report:t}){var l,i;const n=((l=t.preview)==null?void 0:l.generatedAt)||t.updatedAt,a=J((i=t.preview)==null?void 0:i.generatedAt,t.templateId);return e.jsxs("span",{className:`inline-flex items-center gap-1.5 ${a?"font-medium text-amber-700 dark:text-amber-400":""}`,title:a?"Out of date — Refresh rebuilds it from current results":void 0,children:[e.jsx("span",{className:`h-[7px] w-[7px] rounded-full ${a?"bg-amber-500":"bg-emerald-500"}`,"aria-hidden":!0}),"Updated ",Qe(n),a?" · out of date":""]})}function xe({preview:t,height:n}){var x,d;const a=t!=null&&t.trend?Ve(t.trend,160,n,5):"";if(!a)return null;const l=(t==null?void 0:t.status)??((x=t==null?void 0:t.kpis[0])==null?void 0:x.status)??((d=t==null?void 0:t.kpis[0])==null?void 0:d.tone)??"good",i=de[l]??de.good;return e.jsxs("svg",{viewBox:`0 0 160 ${n}`,preserveAspectRatio:"none",className:"block w-full",style:{height:n},role:"img","aria-label":"Trend",children:[e.jsx("polygon",{points:`0,${n} ${a} 160,${n}`,fill:i,fillOpacity:.1}),e.jsx("polyline",{points:a,fill:"none",stroke:i,strokeWidth:2,vectorEffect:"non-scaling-stroke",strokeLinejoin:"round"})]})}function at({preview:t,size:n}){const a=(t==null?void 0:t.kpis)??[];return a.length===0?t!=null&&t.verdict?e.jsx("p",{className:"text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:t.verdict}):e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Open the report to see it."}):e.jsx("div",{className:"grid grid-cols-3 gap-3",children:a.map((l,i)=>e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-xs text-gray-600 dark:text-gray-400",title:l.title,children:l.title}),e.jsx("p",{className:`truncate font-bold tabular-nums text-gray-900 dark:text-gray-100 ${n==="lg"?"text-xl":"text-[17px]"} ${l.status?H[l.status]:""}`,title:l.value,children:l.value}),l.delta&&e.jsx("p",{className:`text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]},i))})}function he({report:t,actions:n,large:a=!1}){var c;const l=n.canChange(t),i=n.schedulesOf(t),x=J((c=t.preview)==null?void 0:c.generatedAt,t.templateId),d=n.busy===`${t.id}:refresh`;return e.jsxs("article",{className:"flex flex-col rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]","data-testid":"report-card",children:[e.jsxs("div",{className:`flex flex-col gap-2 ${a?"px-5 pt-5":"px-4 pt-4"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"rounded-md bg-gray-100 dark:bg-white/10 px-2 py-0.5 text-xs font-semibold text-gray-700 dark:text-gray-300",children:L(t.templateId)}),t.pinned&&e.jsx(ee,{size:15,className:"text-amber-600","aria-label":"Pinned"})]}),e.jsx("h3",{className:`font-bold text-gray-900 dark:text-gray-100 ${a?"text-lg":"text-base"}`,children:e.jsx(V,{to:`/reports/view/${t.id}`,className:"hover:underline",children:t.title})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-gray-600 dark:text-gray-400",children:[e.jsx(we,{report:t}),i.map(g=>e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{size:12,"aria-hidden":!0})," ",be(g)]},g.id))]})]}),e.jsxs("div",{className:`grid items-end gap-3 ${a?"grid-cols-[minmax(0,3fr)_minmax(0,1.2fr)] px-5 py-4":"grid-cols-1 px-4 pt-3.5 pb-1"}`,children:[e.jsx(at,{preview:t.preview,size:a?"lg":"md"}),a&&e.jsx(xe,{preview:t.preview,height:48})]}),!a&&e.jsx(xe,{preview:t.preview,height:40}),e.jsxs("div",{className:`mt-auto flex flex-wrap items-center gap-2 border-t border-gray-100 dark:border-white/[0.06] ${a?"px-5 py-3":"px-4 py-2.5"}`,children:[e.jsx(V,{to:`/reports/view/${t.id}`,className:`${G} ${a?"":"flex-1 justify-center"} !bg-brand-600 !text-white !border-brand-600 hover:!bg-brand-700`,children:"Open"}),l&&e.jsxs("button",{onClick:()=>n.refresh(t),disabled:d,className:`${G} ${x?"!border-amber-300 !bg-amber-50 !text-amber-800 dark:!bg-amber-500/15 dark:!text-amber-300 dark:!border-amber-400/30":""}`,title:"The AI rebuilds this report from current data (30 seconds to 2 minutes; uses AI credits)",children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14}),d?"Refreshing…":x?"Refresh now":"Refresh"]}),e.jsx(Ne,{report:t,actions:n,compact:!a}),l&&e.jsx(Se,{report:t,actions:n}),t.shareToken&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 rounded-md bg-emerald-50 dark:bg-emerald-500/15 px-2 py-0.5 text-xs font-semibold text-emerald-700 dark:text-emerald-300","data-testid":"report-shared-by",children:[e.jsx(ae,{size:11,"aria-hidden":!0}),t.mine===!1?`Shared${t.sharedByName?` by ${t.sharedByName}`:""}`:`Shared link · ${t.shareViews??0} view${t.shareViews===1?"":"s"}`]})]})]})}function st({reports:t,actions:n}){return e.jsx("div",{className:"overflow-x-auto rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full min-w-[900px] border-collapse text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-gray-50 dark:bg-white/[0.04] text-left text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400",children:[e.jsx("th",{className:"px-4 py-2.5",children:"Report"}),e.jsx("th",{className:"px-4 py-2.5",children:"Headline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Updated"}),e.jsx("th",{className:"px-4 py-2.5",children:"Schedule"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Actions"})]})}),e.jsx("tbody",{children:t.map(a=>{var x;const l=(x=a.preview)==null?void 0:x.kpis[0],i=n.schedulesOf(a);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/[0.06] align-middle","data-testid":"report-row",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a.pinned&&e.jsx(ee,{size:13,className:"text-amber-600 flex-shrink-0","aria-label":"Pinned"}),e.jsx(V,{to:`/reports/view/${a.id}`,className:"font-semibold text-gray-900 dark:text-gray-100 hover:underline",children:a.title})]}),e.jsxs("div",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-400",children:[L(a.templateId),a.shareToken?" · shared":""]})]}),e.jsx("td",{className:"px-4 py-3",children:l?e.jsxs("span",{className:"tabular-nums",children:[e.jsxs("span",{className:"text-gray-600 dark:text-gray-400",children:[l.title," "]}),e.jsx("strong",{className:"text-gray-900 dark:text-gray-100",children:l.value}),l.delta&&e.jsx("span",{className:`ml-1.5 text-xs font-semibold ${H[l.tone]??""}`,children:l.delta})]}):e.jsx("span",{className:"text-gray-500",children:"—"})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400 whitespace-nowrap",children:e.jsx(we,{report:a})}),e.jsx("td",{className:"px-4 py-3 text-[13px] text-gray-600 dark:text-gray-400",children:i.length?i.map(be).join("; "):"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-end gap-1.5",children:[n.canChange(a)&&e.jsx("button",{onClick:()=>n.refresh(a),disabled:n.busy===`${a.id}:refresh`,className:se,"aria-label":"Refresh data",title:"Refresh data",children:n.busy===`${a.id}:refresh`?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(te,{size:14})}),e.jsx(Ne,{report:a,actions:n,compact:!0}),n.canChange(a)&&e.jsx(Se,{report:a,actions:n})]})})]},a.id)})})]})})}function ke(){const[t,n]=o.useState(!1),a=o.useRef(null);return o.useEffect(()=>{if(!t)return;const l=x=>{a.current&&!a.current.contains(x.target)&&n(!1)},i=x=>{x.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[t]),{open:t,setOpen:n,ref:a}}const ve="absolute right-0 top-full mt-1 z-20 w-48 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",I="w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5";function Ne({report:t,actions:n,compact:a=!1}){const{open:l,setOpen:i,ref:x}=ke(),d=!!n.busy&&n.busy.startsWith(`${t.id}:`)&&/:(pdf|docx|xlsx)$/.test(n.busy),c=t.mine===!1&&t.shareToken?`/api/reports/share/${encodeURIComponent(t.shareToken)}/render.html`:Pe(`/api/reports/${encodeURIComponent(t.id)}/render.html`);return e.jsxs("div",{className:"relative",ref:x,children:[e.jsxs("button",{onClick:()=>i(g=>!g),className:a?se:G,"aria-label":"Download","aria-haspopup":"menu","aria-expanded":l,disabled:d,children:[d?e.jsx(z,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14}),!a&&e.jsxs(e.Fragment,{children:["Download ",e.jsx(fe,{size:13,"aria-hidden":!0})]})]}),l&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsx("a",{role:"menuitem",href:c,target:"_blank",rel:"noopener noreferrer",onClick:()=>i(!1),className:I,children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([g,N])=>e.jsx("button",{role:"menuitem",className:I,onClick:()=>{i(!1),n.exportAs(t,g)},children:N},g))]})]})}function Se({report:t,actions:n}){const{open:a,setOpen:l,ref:i}=ke(),x=W(),d=c=>()=>{l(!1),c()};return e.jsxs("div",{className:"relative",ref:i,children:[e.jsx("button",{onClick:()=>l(c=>!c),className:se,"aria-label":"More actions","aria-haspopup":"menu","aria-expanded":a,children:e.jsx(Xe,{size:15})}),a&&e.jsxs("div",{role:"menu",className:ve,children:[e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>x(`/reports/view/${t.id}`)),children:[e.jsx(Z,{size:14})," Open"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.togglePin(t)),children:[t.pinned?e.jsx(Je,{size:14}):e.jsx(ee,{size:14})," ",t.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>void n.toggleShare(t)),children:[e.jsx(ae,{size:14})," ",t.shareToken?"Revoke share link":"Copy a share link"]}),e.jsxs("button",{role:"menuitem",className:I,onClick:d(()=>n.schedule(t)),children:[e.jsx(F,{size:14})," Schedule email…"]}),e.jsxs("button",{role:"menuitem",className:`${I} !text-rose-700 dark:!text-rose-400`,onClick:d(()=>n.remove(t)),children:[e.jsx(je,{size:14})," Delete"]})]})]})}const rt=["my","shared","scheduled","templates"];function yt(){const t=W(),n=Y(),a=X().hasRole("tester"),[l,i]=Ie(),x=l.get("tab"),d=x&&rt.includes(x)?x:"my",c=m=>i(f=>{const p=new URLSearchParams(f);return m==="my"?p.delete("tab"):p.set("tab",m),p},{replace:!0}),[g,N]=o.useState([]),[C,w]=o.useState([]),[S,k]=o.useState([]),[b,R]=o.useState(!0),A=async()=>{try{const[m,f,p]=await Promise.all([me(),Me(),ue().catch(()=>({schedules:[],count:0}))]);N(m.reports),w(f.reports),k(p.schedules)}catch(m){n.toast("error",`Load failed: ${m instanceof Error?m.message:String(m)}`)}finally{R(!1)}};o.useEffect(()=>{A()},[d]);const y=()=>ye(t,{mode:"reporting"}),v=[{id:"my",label:"My reports",Icon:Z,count:b?null:g.length},{id:"shared",label:"Shared",Icon:ae,count:b?null:C.length},{id:"scheduled",label:"Scheduled",Icon:F,count:b?null:S.length},{id:"templates",label:"Templates",Icon:U,count:Re.length}];return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-[26px] font-bold tracking-tight text-gray-900 dark:text-gray-100",children:"Reports"}),e.jsxs("p",{className:"mt-1.5 text-sm text-gray-600 dark:text-gray-400 max-w-3xl",children:["Dashboards built by the AI Assistant in Reporting mode. Refresh, share, schedule or download any of them."," ",e.jsx("strong",{className:"font-semibold text-gray-800 dark:text-gray-200",children:"Shared"})," lists every report with a public link in this workspace — anyone signed in can open it."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>c("scheduled"),className:"inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08]",children:[e.jsx(F,{size:15})," Schedules"]}),a&&e.jsxs("button",{onClick:y,className:"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700",children:[e.jsx(U,{size:15})," New report with AI"]})]})]}),e.jsx("div",{role:"tablist",className:"flex gap-6 overflow-x-auto border-b border-gray-200 dark:border-white/10","data-testid":"report-tabs",children:v.map(m=>{const f=d===m.id;return e.jsxs("button",{role:"tab","aria-selected":f,onClick:()=>c(m.id),className:`flex h-10 flex-shrink-0 items-center gap-2 whitespace-nowrap border-b-2 px-0.5 text-sm transition-colors ${f?"border-gray-900 dark:border-gray-100 font-semibold text-gray-900 dark:text-gray-100":"border-transparent font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[e.jsx(m.Icon,{size:15,"aria-hidden":!0,className:f?"":"opacity-80"}),m.label,m.count!=null&&e.jsx("span",{className:`min-w-[22px] rounded-full px-2 py-px text-center text-xs font-semibold tabular-nums ${f?"bg-brand-600 text-white dark:bg-white dark:text-gray-900":"bg-gray-200 text-gray-700 dark:bg-white/10 dark:text-gray-300"}`,children:m.count})]},m.id)})}),d==="my"&&e.jsx(ce,{shared:!1,reports:g,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="shared"&&e.jsx(ce,{shared:!0,reports:C,schedules:S,loading:b,reload:A,onNewReport:y,onBrowseTemplates:()=>c("templates")}),d==="scheduled"&&e.jsx(nt,{}),d==="templates"&&e.jsx(lt,{})]})}function nt(){const t=Y(),n=X().hasRole("tester"),[a,l]=o.useState([]),[i,x]=o.useState([]),[d,c]=o.useState(!0),[g,N]=o.useState(!1),[C,w]=o.useState(null),[S,k]=o.useState(!1),[b,R]=o.useState(null),[A,y]=o.useState(null),v=async r=>{r!=null&&r.initial?c(!0):r!=null&&r.silent||N(!0);try{const[h,$]=await Promise.all([ue(),me()]);l(h.schedules),x($.reports)}catch(h){r!=null&&r.silent||t.toast("error",`Load failed: ${h instanceof Error?h.message:String(h)}`)}finally{c(!1),N(!1)}};o.useEffect(()=>{v({initial:!0})},[]),o.useEffect(()=>{if(!(S||b))return Le(()=>{v({silent:!0})},2e4)},[S,b]);const m=async r=>{try{await qe(r.id,{enabled:!r.enabled}),await v()}catch(h){t.toast("error",`Update failed: ${h instanceof Error?h.message:String(h)}`)}},f=async r=>{y(r.id);try{const h=await Ue(r.id);h.success?t.toast("success","Dispatch succeeded"):t.toast("error",`Dispatch failed: ${h.error||"unknown"}`),await v()}catch(h){t.toast("error",`Run failed: ${h instanceof Error?h.message:String(h)}`)}finally{y(null)}},p=async()=>{if(b)try{await Ke(b.id),t.toast("success","Schedule deleted"),R(null),await v()}catch(r){t.toast("error",`Delete failed: ${r instanceof Error?r.message:String(r)}`)}};return d?e.jsxs("div",{className:"py-10 text-center text-sm text-gray-500",children:[e.jsx(z,{size:14,className:"inline animate-spin mr-2"})," Loading…"]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.length," schedule",a.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(),disabled:g,className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-xs text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors disabled:opacity-60",title:"Refresh schedule list",children:[e.jsx(te,{size:12,className:g?"animate-spin":""}),g?"Refreshing…":"Refresh"]}),n&&e.jsxs("button",{onClick:()=>{w(null),k(!0)},disabled:i.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors disabled:opacity-50",title:i.length===0?"Save a report first in Reporting mode, then you can schedule it":"Create a new schedule",children:[e.jsx(Ze,{size:12})," New schedule"]})]})]}),a.length===0?e.jsxs("div",{className:"text-center py-14 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(F,{size:28,className:"mx-auto mb-3 opacity-40"}),"No schedules yet. Click ",e.jsx("strong",{children:"New schedule"})," to dispatch a saved report on a recurring basis."]}):e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-white/[0.03]",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-white/[0.04]",children:e.jsxs("tr",{className:"text-left text-[10px] text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Title"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Source"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Schedule"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Format"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Recipients"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Last run"}),e.jsx("th",{className:"px-3 py-2 font-semibold",children:"Status"}),e.jsx("th",{className:"px-3 py-2"})]})}),e.jsx("tbody",{className:"bg-white dark:bg-white/[0.02]",children:a.map(r=>{const h=i.find($=>$.id===r.sourceReportId);return e.jsxs("tr",{className:"border-t border-gray-100 dark:border-white/5 bg-white dark:bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.04] transition-colors",children:[e.jsx("td",{className:"px-3 py-2",children:e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100",children:r.title})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[160px]",children:h?h.title:e.jsx("span",{className:"text-rose-500",children:"Missing"})}),e.jsxs("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300",title:r.cron,children:[r.cronHuman&&r.cronHuman!==r.cron?r.cronHuman:e.jsx("span",{className:"font-mono",children:r.cron}),r.enabled&&r.nextRun&&e.jsxs("div",{className:"text-[10px] text-gray-500",children:["next ",le(r.nextRun)]})]}),e.jsx("td",{className:"px-3 py-2 text-xs uppercase text-gray-600 dark:text-gray-400",children:r.format}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300 truncate max-w-[180px]",title:r.recipients.join(", "),children:r.recipients.length===1?r.recipients[0]:`${r.recipients.length} recipients`}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:r.lastRun?le(r.lastRun):"—"}),e.jsx("td",{className:"px-3 py-2 text-xs",children:r.enabled?r.lastStatus==="success"&&r.lastWarning?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",title:r.lastWarning,children:[e.jsx(ie,{size:10})," Sent · stale data"]}):r.lastStatus==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400",children:[e.jsx(ie,{size:10})," Success"]}):r.lastStatus==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-rose-600 dark:text-rose-400",title:r.lastError,children:[e.jsx(et,{size:10})," Error"]}):e.jsx("span",{className:"text-gray-500",children:"—"}):e.jsx("span",{className:"text-gray-500",children:"paused"})}),e.jsx("td",{className:"px-3 py-2",children:n&&e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>f(r),disabled:A===r.id,className:"p-1 rounded text-gray-500 hover:text-emerald-600 hover:bg-emerald-500/10 disabled:opacity-50",title:"Run now",children:A===r.id?e.jsx(z,{size:12,className:"animate-spin"}):e.jsx(tt,{size:12})}),e.jsx("button",{onClick:()=>m(r),className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/5",title:r.enabled?"Pause — stop sending until resumed":"Resume — send on schedule again",children:r.enabled?e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"PAUSE"}):e.jsx("span",{className:"text-[10px] font-semibold px-1 text-emerald-500",children:"RESUME"})}),e.jsx("button",{onClick:()=>{w(r),k(!0)},className:"p-1 rounded text-gray-500 hover:text-brand-500 hover:bg-brand-500/10",title:"Edit",children:e.jsx("span",{className:"text-[10px] font-semibold px-1",children:"EDIT"})}),e.jsx("button",{onClick:()=>R(r),className:"p-1 rounded text-gray-500 hover:text-rose-500 hover:bg-rose-500/10",title:"Delete",children:e.jsx(je,{size:12})})]})})]},r.id)})})]})}),S&&e.jsx(ge,{reports:i,editing:C,onClose:()=>{k(!1),w(null)},onSaved:async()=>{k(!1),w(null),await v()}}),e.jsx(pe,{open:!!b,title:"Delete schedule?",description:`"${b==null?void 0:b.title}" will stop dispatching. This cannot be undone.`,confirmLabel:"Delete",onConfirm:p,onCancel:()=>R(null)})]})}const Re=[{id:"executive",label:"Executive Summary",description:"High-level KPIs + pass-rate trend + top failures — for managers.",prompt:`Build an EXECUTIVE QA dashboard for the current sprint using the \`generate_dashboard\` tool.
2
2
 
3
3
  Layout (4 rows on a 12-column grid):
4
4
  1. Four KPI cards (span 3 each): Total Test Cases, Automation Coverage %, Latest Pass Rate %, Critical Failures (open).
@@ -45,4 +45,4 @@ Layout:
45
45
  5. A bar chart (span 6) "Scripts by Framework", and a table (span 6) "Scripts by Owner" (Owner, Scripts, Failing) when owners are known — otherwise a bar chart "Scripts by Tag".
46
46
  6. A markdown cell (span 12) with 3–5 bullets: the biggest gaps (never-run and unlinked scripts), the folders with the most failures, and recommended next steps.
47
47
 
48
- Title: "Automation Inventory — <Today's Date>". Save the result (save_report with templateId "automation_inventory").`},{id:"manual_vs_automated",label:"Manual vs Automated",description:"Quick breakdown of test cases by automation status.",prompt:'Generate a dashboard showing the breakdown of manual and automated test cases — totals, automation coverage percentage, and a list of currently-manual tests that could be prioritized for automation. Save the result (save_report with templateId "manual_vs_automated").'},{id:"coverage_by_requirement",label:"Coverage by Requirement",description:"Requirement coverage with orphan tests and uncovered requirements.",prompt:'Generate a dashboard showing requirement coverage — how many requirements have linked test cases, how many are uncovered, and which test cases are orphaned (no requirement linked). Save the result (save_report with templateId "coverage_by_requirement").'}];function lt(){const t=W(),n=a=>ye(t,{prompt:a,mode:"reporting"});return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Click a template to open the AI Assistant in Reporting mode with the prompt pre-filled. You can edit the prompt before submitting."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Re.map(a=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(q,{size:14,className:"text-brand-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:a.description})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] border border-gray-100 dark:border-white/5 rounded-md p-2 font-mono mb-3 italic",children:['"',a.prompt,'"']}),e.jsxs("button",{onClick:()=>n(a.prompt),className:"w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors",children:["Run template ",e.jsx(fe,{size:11,className:"-rotate-90"})]})]},a.id))})]})}export{yt as ReportsPage};
48
+ Title: "Automation Inventory — <Today's Date>". Save the result (save_report with templateId "automation_inventory").`},{id:"manual_vs_automated",label:"Manual vs Automated",description:"Quick breakdown of test cases by automation status.",prompt:'Generate a dashboard showing the breakdown of manual and automated test cases — totals, automation coverage percentage, and a list of currently-manual tests that could be prioritized for automation. Save the result (save_report with templateId "manual_vs_automated").'},{id:"coverage_by_requirement",label:"Coverage by Requirement",description:"Requirement coverage with orphan tests and uncovered requirements.",prompt:'Generate a dashboard showing requirement coverage — how many requirements have linked test cases, how many are uncovered, and which test cases are orphaned (no requirement linked). Save the result (save_report with templateId "coverage_by_requirement").'}];function lt(){const t=W(),n=a=>ye(t,{prompt:a,mode:"reporting"});return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-3",children:"Click a template to open the AI Assistant in Reporting mode with the prompt pre-filled. You can edit the prompt before submitting."}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:Re.map(a=>e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4",children:[e.jsxs("div",{className:"flex items-start gap-2 mb-2",children:[e.jsx(U,{size:14,className:"text-brand-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:a.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:a.description})]})]}),e.jsxs("div",{className:"text-[11px] text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] border border-gray-100 dark:border-white/5 rounded-md p-2 font-mono mb-3 italic",children:['"',a.prompt,'"']}),e.jsxs("button",{onClick:()=>n(a.prompt),className:"w-full flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500/10 hover:bg-brand-500/20 text-brand-600 dark:text-brand-400 transition-colors",children:["Run template ",e.jsx(fe,{size:11,className:"-rotate-90"})]})]},a.id))})]})}export{yt as ReportsPage};
@@ -1,4 +1,4 @@
1
- import{u as is,r as m,j as e,b as ar,e as Gr,n as Wr}from"./vendor-react-CTbHBddL.js";import{f as lt,a as ls}from"./formatDate-T65-Y6Mi.js";import{b as nr,bR as os,bY as Kr,bZ as ir,b_ as lr,b$ as Yr,j as $t,a8 as cs,c0 as or,c1 as cr,c2 as Qr,e as Xr,c3 as Zr,c4 as dr,c5 as qt,bN as xr,c6 as ur,c7 as Jr,c8 as ea,c9 as ta,ca as sa,cb as Is,cc as Rs,k as ra,v as aa}from"./index-BYVxKLrT.js";import{p as Gt,s as Wt}from"./ansiToHtml-DYRzYQV1.js";import{e as ds,f as na,g as ia,h as la,i as oa,d as ca,j as da}from"./useTestResults-D5EwGIX9.js";import{a as Fs,c as xa,b as ua,u as pa}from"./useTabParam-ChbOedP1.js";import{C as pr}from"./ConfirmDialog-t7mpeeSN.js";import{u as We,a as Lt,c as mr}from"./vendor-query-BrzmPFT3.js";import{h as St}from"./aiHandoff-vhtR29Fh.js";import{a0 as je,S as ce,cm as ma,cn as Es,co as ha,v as xs,R as hr,h as ga,t as De,ag as Se,bJ as fa,_ as ve,r as qe,ap as we,b1 as Ge,J as at,cc as ba,m as gr,A as fr,l as ya,k as zt,b8 as ja,an as us,f as va,av as wa,ch as Kt,X as dt,aW as Na,aX as ka,cp as Ca,aE as ps,aU as $a,o as Oe,aV as Sa,a2 as nt,aw as xt,u as Je,cq as za,K as Aa,a5 as Pt,c as ms,q as br,T as Ta,at as rt,g as gt,ah as Ze,y as Be,a as ot,aZ as Yt,e as At,O as yr,c1 as Ia,b2 as Qt,bg as Ra,b3 as Fa,cr as Ea,bx as jr,C as Tt,b5 as hs,G as Xt,bz as Zt,b as Ma,a3 as gs,c7 as La,c8 as Pa,cs as Ha,ct as vr,cu as Ba,cd as Jt,cv as wr,cw as Oa,cx as Ua,cy as Ms,bO as _a,aj as Da,cz as Va,cA as qa}from"./vendor-icons-BKPiFyYV.js";import{B as fs,a as Xe}from"./RunTargets-C7vpCbck.js";import{t as Ga,f as ze}from"./formatTestName-BKd2Uqhs.js";import{b as Wa}from"./useSuites-DyfN9HVv.js";import{L as es}from"./LiveExecutionView-D5BRe9jq.js";import{R as Ve,a as Nr,b as It,L as kr,Q as Ka}from"./RunState-ifC4zi6M.js";import{d as Ya}from"./useTestExplorer-DT8frjCK.js";import{u as bs}from"./useOwnership-U0AfKBRo.js";import{M as Cr}from"./MediaModal-C5n6sHYi.js";import{w as Qa,o as Ht}from"./excel-BrxuVus5.js";import{E as Xa}from"./EmptyState-D1T3JWUr.js";const ts={bug:"Application Bug",environment:"Environment Issue",flaky:"Flaky Test","test-issue":"Test Code Issue",timeout:"Timeout",unknown:"Needs Investigation"},$r={"locator-not-found":"locator not found","strict-mode-violation":"strict mode violation","element-interaction":"element not interactable"},ht={"test-code":"test code",application:"application",environment:"environment",unclear:"unclear"};function Sr(t){return t==="bug"?"application":t==="test-issue"?"test-code":t==="environment"?"environment":"unclear"}function ss(t){var i;const s=(i=t.assessment)==null?void 0:i.layer;if(!s||s==="unclear")return!1;const r=Sr(t.category);return r!=="unclear"&&r!==s}function wt(t){var s;return((s=t.later)==null?void 0:s.status)!=="passed"}function ct(t,s=!1){const r=(t||"").toLowerCase();return s||r.includes("appium")?"mobile":r.includes("rest")||r.includes("supertest")||r.includes("karate")||r==="api"?"api":"web"}function zr(t,s){var f;const r=(t||"").toLowerCase(),i=[...new Set(s.map(g=>g.file).filter(g=>!!g))],x=s.map(g=>Nt(g.name)).filter(Boolean),l=x.map(Za).join("|"),u=i.join(" ");if(r.includes("playwright")){const g=x.map(N=>[...N].map(y=>'"$`\\%!'.includes(y)?".":".*+?^{}()|[]".includes(y)?`\\${y}`:y).join("")).join("|");return`npx playwright test${i.map(N=>` "${N}"`).join("")}${g?` -g "${g}"`:""}`}if(r.includes("cypress"))return`npx cypress run${i.length?` --spec "${i.join(",")}"`:""}`;const a=(f=/webdriverio|wdio|pytest|unittest|testng|junit|maven|gradle|selenium|nunit|xunit|mstest|dotnet|rspec|behave|cucumber|robot|appium/.exec(r))==null?void 0:f[0];if(a){const g=s.filter(y=>Nt(y.name));return g.length>0?g.map(y=>`run_tests test_name "${Nt(y.name).replace(/"/g,'\\"')}"${y.file?` test_file "${y.file}"`:""}`).join("; then "):`run_tests framework "${a==="wdio"?"webdriverio":a}"${i.length?` files "${u}"`:""}`}return r.includes("jest")||r.includes("vitest")?`npx ${r.includes("vitest")?"vitest run":"jest"} ${u}${l?` -t "${l}"`:""}`.trim():r.includes("mocha")?`npx mocha ${u}${l?` --grep "${l}"`:""}`.trim():`run only: ${x.join("; ")||i.join(", ")||"the affected tests"} (scoped by file and name, never the whole suite)`}function Nt(t){const s=t.split(/\s+[›>]\s+/);return(s[s.length-1]||t).trim()}function Za(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/"/g,'\\"')}function Ar(t){var i;if(!t)return[];const s=(i=t.files)!=null&&i.length?` in ${t.files.join(", ")}`:"",r=t.from&&t.to?`${t.from} → ${t.to}${s}`:"";switch(t.state){case"suggested":return[`Auto-Heal has a VERIFIED fix waiting: ${r}. If it is right, apply it from Results › Auto-Heal instead of writing a new edit; only change something else if that fix is wrong.`];case"healed":return[`Auto-Heal already changed ${r} and verified it — check whether the test passes now before editing anything.`];case"reverted":return[`Auto-Heal already tried ${r} and it failed verification${t.revertReason?` (${t.revertReason})`:""}. Do not repeat that exact change.`];case"undone":return[`The user undid Auto-Heal's change ${r}. Do not re-apply it.`];default:return t.skipReason?[`Auto-Heal did not heal this automatically: ${t.skipReason}`]:[]}}function Tr(t){const{group:s,kind:r}=t,i=ts[s.category]||s.category,x=s.signal?` — ${$r[s.signal]||s.signal}`:"",l=t.tests.filter(wt),u=t.tests.length-l.length,a=l.length?l:t.tests,f=t.runLabel?`run #${t.runId} (${t.runLabel})`:`run #${t.runId}`,g=[];g.push(r==="investigate"?`Investigate the failing tests from ${f} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}). The rule-based classifier and the AI read this failure differently — start by deciding which is right, then fix or report accordingly.`:`Fix the failing tests from ${f} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}).`),g.push(""),g.push(`Classification: ${i}${x}.`),s.assessment&&(g.push(`AI assessment: ${ht[s.assessment.layer]}, ${s.assessment.confidence} confidence${s.assessment.pointer?` — ${s.assessment.pointer}`:""}.`),g.push(`AI summary: ${s.assessment.summary}`)),g.push(`Root cause (rule-based): ${s.rootCause}`);const N=Ar(t.autoHeal);N.length&&g.push(...N),g.push("");const y=l.length&&u>0?`Still failing (${l.length} of ${t.tests.length} — the other ${u} passed in a later run):`:l.length?`Failing tests (${l.length}):`:`Affected tests (${t.tests.length} — all passed in a later run; confirm the fix is real, do not redo it):`;g.push(y);for(const T of a)g.push(` - ${T.file?`${T.file} › `:""}${Nt(T.name)}`);if(g.push(""),t.errorMessage){g.push("Error:");for(const T of t.errorMessage.trim().split(`
1
+ import{u as is,r as m,j as e,d as ar,e as Gr,n as Wr}from"./vendor-react-DOVfxdUy.js";import{f as lt,a as ls}from"./formatDate-T65-Y6Mi.js";import{b as nr,c0 as os,c7 as Kr,c8 as ir,c9 as lr,ca as Yr,j as $t,ae as cs,cb as or,cc as cr,cd as Qr,e as Xr,ce as Zr,cf as dr,cg as qt,bY as xr,ch as ur,ci as Jr,cj as ea,ck as ta,cl as sa,cm as Is,cn as Rs,k as ra,v as aa}from"./index-D6sQYc_0.js";import{p as Gt,s as Wt}from"./ansiToHtml-DYRzYQV1.js";import{e as ds,f as na,g as ia,h as la,i as oa,d as ca,j as da}from"./useTestResults-yjH1aUy-.js";import{a as Fs,c as xa,b as ua,u as pa}from"./useTabParam-CyYAP90W.js";import{C as pr}from"./ConfirmDialog-DtotgVmI.js";import{u as We,a as Lt,c as mr}from"./vendor-query-DkZSMtfn.js";import{h as St}from"./aiHandoff-vhtR29Fh.js";import{a0 as je,S as ce,cm as ma,cn as Es,co as ha,v as xs,R as hr,j as ga,t as De,ag as Se,bJ as fa,_ as ve,r as qe,ap as we,b1 as Ge,J as at,cc as ba,m as gr,A as fr,a as ya,C as zt,b8 as ja,an as us,h as va,av as wa,ch as Kt,X as dt,aW as Na,aX as ka,cp as Ca,aE as ps,aU as $a,o as Oe,aV as Sa,a2 as nt,aw as xt,u as Je,cq as za,K as Aa,a5 as Pt,e as ms,q as br,T as Ta,at as rt,i as gt,ah as Ze,y as Be,c as ot,aZ as Yt,g as At,O as yr,c1 as Ia,b2 as Qt,bg as Ra,b3 as Fa,cr as Ea,bx as jr,b as Tt,b5 as hs,G as Xt,bz as Zt,d as Ma,a3 as gs,c7 as La,c8 as Pa,cs as Ha,ct as vr,cu as Ba,cd as Jt,cv as wr,cw as Oa,cx as Ua,cy as Ms,bO as _a,aj as Da,cz as Va,cA as qa}from"./vendor-icons-D_Dmmj8d.js";import{B as fs,a as Xe}from"./RunTargets-CPKBrefj.js";import{t as Ga,f as ze}from"./formatTestName-BKd2Uqhs.js";import{b as Wa}from"./useSuites-V0AxZYex.js";import{L as es}from"./LiveExecutionView-CaIf7Jux.js";import{R as Ve,a as Nr,b as It,L as kr,Q as Ka}from"./RunState-CRuS_bC2.js";import{d as Ya}from"./useTestExplorer-CUqC18DV.js";import{u as bs}from"./useOwnership-C1CmzcvJ.js";import{M as Cr}from"./MediaModal-DNM45Uz2.js";import{w as Qa,o as Ht}from"./excel-BrxuVus5.js";import{E as Xa}from"./EmptyState-utxlJ0fu.js";const ts={bug:"Application Bug",environment:"Environment Issue",flaky:"Flaky Test","test-issue":"Test Code Issue",timeout:"Timeout",unknown:"Needs Investigation"},$r={"locator-not-found":"locator not found","strict-mode-violation":"strict mode violation","element-interaction":"element not interactable"},ht={"test-code":"test code",application:"application",environment:"environment",unclear:"unclear"};function Sr(t){return t==="bug"?"application":t==="test-issue"?"test-code":t==="environment"?"environment":"unclear"}function ss(t){var i;const s=(i=t.assessment)==null?void 0:i.layer;if(!s||s==="unclear")return!1;const r=Sr(t.category);return r!=="unclear"&&r!==s}function wt(t){var s;return((s=t.later)==null?void 0:s.status)!=="passed"}function ct(t,s=!1){const r=(t||"").toLowerCase();return s||r.includes("appium")?"mobile":r.includes("rest")||r.includes("supertest")||r.includes("karate")||r==="api"?"api":"web"}function zr(t,s){var f;const r=(t||"").toLowerCase(),i=[...new Set(s.map(g=>g.file).filter(g=>!!g))],x=s.map(g=>Nt(g.name)).filter(Boolean),l=x.map(Za).join("|"),u=i.join(" ");if(r.includes("playwright")){const g=x.map(N=>[...N].map(y=>'"$`\\%!'.includes(y)?".":".*+?^{}()|[]".includes(y)?`\\${y}`:y).join("")).join("|");return`npx playwright test${i.map(N=>` "${N}"`).join("")}${g?` -g "${g}"`:""}`}if(r.includes("cypress"))return`npx cypress run${i.length?` --spec "${i.join(",")}"`:""}`;const a=(f=/webdriverio|wdio|pytest|unittest|testng|junit|maven|gradle|selenium|nunit|xunit|mstest|dotnet|rspec|behave|cucumber|robot|appium/.exec(r))==null?void 0:f[0];if(a){const g=s.filter(y=>Nt(y.name));return g.length>0?g.map(y=>`run_tests test_name "${Nt(y.name).replace(/"/g,'\\"')}"${y.file?` test_file "${y.file}"`:""}`).join("; then "):`run_tests framework "${a==="wdio"?"webdriverio":a}"${i.length?` files "${u}"`:""}`}return r.includes("jest")||r.includes("vitest")?`npx ${r.includes("vitest")?"vitest run":"jest"} ${u}${l?` -t "${l}"`:""}`.trim():r.includes("mocha")?`npx mocha ${u}${l?` --grep "${l}"`:""}`.trim():`run only: ${x.join("; ")||i.join(", ")||"the affected tests"} (scoped by file and name, never the whole suite)`}function Nt(t){const s=t.split(/\s+[›>]\s+/);return(s[s.length-1]||t).trim()}function Za(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/"/g,'\\"')}function Ar(t){var i;if(!t)return[];const s=(i=t.files)!=null&&i.length?` in ${t.files.join(", ")}`:"",r=t.from&&t.to?`${t.from} → ${t.to}${s}`:"";switch(t.state){case"suggested":return[`Auto-Heal has a VERIFIED fix waiting: ${r}. If it is right, apply it from Results › Auto-Heal instead of writing a new edit; only change something else if that fix is wrong.`];case"healed":return[`Auto-Heal already changed ${r} and verified it — check whether the test passes now before editing anything.`];case"reverted":return[`Auto-Heal already tried ${r} and it failed verification${t.revertReason?` (${t.revertReason})`:""}. Do not repeat that exact change.`];case"undone":return[`The user undid Auto-Heal's change ${r}. Do not re-apply it.`];default:return t.skipReason?[`Auto-Heal did not heal this automatically: ${t.skipReason}`]:[]}}function Tr(t){const{group:s,kind:r}=t,i=ts[s.category]||s.category,x=s.signal?` — ${$r[s.signal]||s.signal}`:"",l=t.tests.filter(wt),u=t.tests.length-l.length,a=l.length?l:t.tests,f=t.runLabel?`run #${t.runId} (${t.runLabel})`:`run #${t.runId}`,g=[];g.push(r==="investigate"?`Investigate the failing tests from ${f} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}). The rule-based classifier and the AI read this failure differently — start by deciding which is right, then fix or report accordingly.`:`Fix the failing tests from ${f} (Failure Analysis, group ${t.groupIndex+1} of ${t.groupCount}).`),g.push(""),g.push(`Classification: ${i}${x}.`),s.assessment&&(g.push(`AI assessment: ${ht[s.assessment.layer]}, ${s.assessment.confidence} confidence${s.assessment.pointer?` — ${s.assessment.pointer}`:""}.`),g.push(`AI summary: ${s.assessment.summary}`)),g.push(`Root cause (rule-based): ${s.rootCause}`);const N=Ar(t.autoHeal);N.length&&g.push(...N),g.push("");const y=l.length&&u>0?`Still failing (${l.length} of ${t.tests.length} — the other ${u} passed in a later run):`:l.length?`Failing tests (${l.length}):`:`Affected tests (${t.tests.length} — all passed in a later run; confirm the fix is real, do not redo it):`;g.push(y);for(const T of a)g.push(` - ${T.file?`${T.file} › `:""}${Nt(T.name)}`);if(g.push(""),t.errorMessage){g.push("Error:");for(const T of t.errorMessage.trim().split(`
2
2
  `).slice(0,25))g.push(` ${T.trim()}`);g.push("")}if(t.stackTrace){g.push("Stack:");for(const T of t.stackTrace.trim().split(`
3
3
  `).slice(0,12))g.push(` ${T.trim()}`);g.push("")}return g.push(`Verify with: ${zr(t.framework,a)}`),g.push("Run only these tests, never the whole suite. After the fix passes, say which files changed and why."),g.join(`
4
4
  `)}function Ir(t){const s=[];return s.push(`Fix the failing test ${t.testFile?`${t.testFile} › `:""}${t.testName} from run #${t.runId}. Its locator no longer matches the page.`),s.push(""),s.push(...Ar({state:t.state,from:t.from,to:t.to,files:t.files,revertReason:t.revertReason})),s.push(""),s.push("Find the element the test means on the current page, repair the locator where it is defined (the page object if it lives there), and change nothing else."),s.push(`Verify with: ${zr(t.framework,[{name:t.testName,file:t.testFile}])}`),s.push("Run only this test, never the whole suite."),s.join(`
@@ -1 +1 @@
1
- import{j as s}from"./vendor-react-CTbHBddL.js";import{r as f,ap as g,b1 as j,u as m,a0 as b,aq as y}from"./vendor-icons-BKPiFyYV.js";const d={xs:"text-[10px] px-1.5 py-[1px] gap-1",sm:"text-[11px] px-2 py-0.5 gap-1.5",md:"text-xs px-2.5 py-1 gap-1.5"},N={xs:9,sm:10,md:12};function o({size:n="sm"}){const e=n==="md"?"h-2 w-2":"h-1.5 w-1.5";return s.jsxs("span",{className:`relative flex ${e} flex-shrink-0`,"aria-hidden":"true",children:[s.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75 motion-safe:animate-ping"}),s.jsx("span",{className:`relative inline-flex ${e} rounded-full bg-sky-500`})]})}function k({label:n="Running",detail:e,size:a="sm",title:t,className:l=""}){return s.jsxs("span",{"data-run-state":"running",title:t,className:`inline-flex items-center rounded-full border border-sky-500/30 bg-sky-500/10 text-sky-300 font-medium whitespace-nowrap flex-shrink-0 ${d[a]} ${l}`,children:[s.jsx(o,{size:a}),n,e!=null&&e!==""&&s.jsxs("span",{className:"opacity-70 font-normal tabular-nums",children:["· ",e]})]})}function v({label:n="Queued",position:e,size:a="sm",title:t,className:l=""}){return s.jsxs("span",{"data-run-state":"queued",title:t??(e?`Waiting — number ${e} in line`:"Waiting its turn"),className:`inline-flex items-center rounded-full border border-dashed border-gray-500/50 bg-gray-500/5 text-gray-400 font-medium whitespace-nowrap flex-shrink-0 ${d[a]} ${l}`,children:[s.jsx(m,{size:N[a],className:"flex-shrink-0"}),n,e?s.jsxs("span",{className:"tabular-nums opacity-80",children:["#",e]}):null]})}function C({state:n,size:e=16}){return n==="running"?s.jsx(b,{size:e,className:"text-sky-400 animate-spin flex-shrink-0","aria-label":"Running"}):s.jsx(y,{size:e,className:"text-gray-500 flex-shrink-0","aria-label":"Queued"})}function L({passed:n,failed:e,skipped:a=0,running:t=0,total:l,className:x="w-full",height:u="h-1.5"}){const i=l&&l>0?l:0,r=h=>i?Math.max(0,Math.min(100,h/i*100)):0,c=n+e+a,p=r(t);return s.jsx("span",{className:`${x} ${u} rounded-full bg-surface-3 overflow-hidden flex flex-shrink-0`,role:"progressbar","aria-valuemin":0,"aria-valuemax":i||void 0,"aria-valuenow":c,title:`${n} passed · ${e} failed${a?` · ${a} skipped`:""}${t?` · ${t} running`:""}${i?` · ${Math.max(0,i-c-t)} queued`:""}`,children:i?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"h-full bg-emerald-400 transition-[width] duration-500",style:{width:`${r(n)}%`}}),s.jsx("span",{className:"h-full bg-red-400 transition-[width] duration-500",style:{width:`${r(e)}%`}}),a>0&&s.jsx("span",{className:"h-full bg-gray-400/70 transition-[width] duration-500",style:{width:`${r(a)}%`}}),t>0&&s.jsx("span",{className:"h-full bg-sky-400 tv-stripes transition-[width] duration-500",style:{width:`${Math.max(p,3)}%`}})]}):s.jsx("span",{className:"h-full w-full bg-sky-400/80 tv-stripes"})})}function R({passed:n,failed:e,skipped:a=0,running:t=0,queued:l,size:x="sm",className:u=""}){const i=x==="xs"?"text-[11px]":"text-xs",r=x==="xs"?11:12;return s.jsxs("span",{className:`inline-flex items-center gap-x-2.5 gap-y-1 flex-wrap ${i} ${u}`,children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-400 tabular-nums",children:[s.jsx(f,{size:r})," ",n," passed"]}),e>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-red-400 tabular-nums",children:[s.jsx(g,{size:r})," ",e," failed"]}),a>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 tabular-nums",children:[s.jsx(j,{size:r})," ",a," skipped"]}),t>0&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sky-300 tabular-nums",children:[s.jsx(o,{size:"xs"})," ",t," running"]}),l!=null&&l>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 tabular-nums",children:[s.jsx(m,{size:r})," ",l," queued"]})]})}export{L,v as Q,k as R,R as a,C as b};
1
+ import{j as s}from"./vendor-react-DOVfxdUy.js";import{r as f,ap as g,b1 as j,u as m,a0 as b,aq as y}from"./vendor-icons-D_Dmmj8d.js";const d={xs:"text-[10px] px-1.5 py-[1px] gap-1",sm:"text-[11px] px-2 py-0.5 gap-1.5",md:"text-xs px-2.5 py-1 gap-1.5"},N={xs:9,sm:10,md:12};function o({size:n="sm"}){const e=n==="md"?"h-2 w-2":"h-1.5 w-1.5";return s.jsxs("span",{className:`relative flex ${e} flex-shrink-0`,"aria-hidden":"true",children:[s.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75 motion-safe:animate-ping"}),s.jsx("span",{className:`relative inline-flex ${e} rounded-full bg-sky-500`})]})}function k({label:n="Running",detail:e,size:a="sm",title:t,className:l=""}){return s.jsxs("span",{"data-run-state":"running",title:t,className:`inline-flex items-center rounded-full border border-sky-500/30 bg-sky-500/10 text-sky-300 font-medium whitespace-nowrap flex-shrink-0 ${d[a]} ${l}`,children:[s.jsx(o,{size:a}),n,e!=null&&e!==""&&s.jsxs("span",{className:"opacity-70 font-normal tabular-nums",children:["· ",e]})]})}function v({label:n="Queued",position:e,size:a="sm",title:t,className:l=""}){return s.jsxs("span",{"data-run-state":"queued",title:t??(e?`Waiting — number ${e} in line`:"Waiting its turn"),className:`inline-flex items-center rounded-full border border-dashed border-gray-500/50 bg-gray-500/5 text-gray-400 font-medium whitespace-nowrap flex-shrink-0 ${d[a]} ${l}`,children:[s.jsx(m,{size:N[a],className:"flex-shrink-0"}),n,e?s.jsxs("span",{className:"tabular-nums opacity-80",children:["#",e]}):null]})}function C({state:n,size:e=16}){return n==="running"?s.jsx(b,{size:e,className:"text-sky-400 animate-spin flex-shrink-0","aria-label":"Running"}):s.jsx(y,{size:e,className:"text-gray-500 flex-shrink-0","aria-label":"Queued"})}function L({passed:n,failed:e,skipped:a=0,running:t=0,total:l,className:x="w-full",height:u="h-1.5"}){const i=l&&l>0?l:0,r=h=>i?Math.max(0,Math.min(100,h/i*100)):0,c=n+e+a,p=r(t);return s.jsx("span",{className:`${x} ${u} rounded-full bg-surface-3 overflow-hidden flex flex-shrink-0`,role:"progressbar","aria-valuemin":0,"aria-valuemax":i||void 0,"aria-valuenow":c,title:`${n} passed · ${e} failed${a?` · ${a} skipped`:""}${t?` · ${t} running`:""}${i?` · ${Math.max(0,i-c-t)} queued`:""}`,children:i?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"h-full bg-emerald-400 transition-[width] duration-500",style:{width:`${r(n)}%`}}),s.jsx("span",{className:"h-full bg-red-400 transition-[width] duration-500",style:{width:`${r(e)}%`}}),a>0&&s.jsx("span",{className:"h-full bg-gray-400/70 transition-[width] duration-500",style:{width:`${r(a)}%`}}),t>0&&s.jsx("span",{className:"h-full bg-sky-400 tv-stripes transition-[width] duration-500",style:{width:`${Math.max(p,3)}%`}})]}):s.jsx("span",{className:"h-full w-full bg-sky-400/80 tv-stripes"})})}function R({passed:n,failed:e,skipped:a=0,running:t=0,queued:l,size:x="sm",className:u=""}){const i=x==="xs"?"text-[11px]":"text-xs",r=x==="xs"?11:12;return s.jsxs("span",{className:`inline-flex items-center gap-x-2.5 gap-y-1 flex-wrap ${i} ${u}`,children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-400 tabular-nums",children:[s.jsx(f,{size:r})," ",n," passed"]}),e>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-red-400 tabular-nums",children:[s.jsx(g,{size:r})," ",e," failed"]}),a>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 tabular-nums",children:[s.jsx(j,{size:r})," ",a," skipped"]}),t>0&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sky-300 tabular-nums",children:[s.jsx(o,{size:"xs"})," ",t," running"]}),l!=null&&l>0&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 tabular-nums",children:[s.jsx(m,{size:r})," ",l," queued"]})]})}export{L,v as Q,k as R,R as a,C as b};
@@ -1 +1 @@
1
- import{j as e,r as y}from"./vendor-react-CTbHBddL.js";import{u as z}from"./vendor-query-BrzmPFT3.js";import{K as u,cE as w,aB as v,c as x,bA as k,by as j,y as b}from"./vendor-icons-BKPiFyYV.js";import{v as C}from"./index-BYVxKLrT.js";const G="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2027600%2027600'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3clinearGradient%20id='A'%20gradientUnits='userSpaceOnUse'/%3e%3clinearGradient%20id='B'%20x1='6870'%20x2='24704'%20y1='18705'%20y2='18705'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%230c59a4'/%3e%3cstop%20offset='1'%20stop-color='%23114a8b'/%3e%3c/linearGradient%3e%3clinearGradient%20id='C'%20x1='16272'%20x2='5133'%20y1='10968'%20y2='23102'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%231b9de2'/%3e%3cstop%20offset='.16'%20stop-color='%231595df'/%3e%3cstop%20offset='.67'%20stop-color='%230680d7'/%3e%3cstop%20offset='1'%20stop-color='%230078d4'/%3e%3c/linearGradient%3e%3cradialGradient%20id='D'%20cx='16720'%20cy='18747'%20r='9538'%20xlink:href='%23A'%3e%3cstop%20offset='.72'%20stop-opacity='0'/%3e%3cstop%20offset='.95'%20stop-opacity='.53'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='E'%20cx='7130'%20cy='19866'%20r='14324'%20gradientTransform='matrix(.14843%20-.98892%20.79688%20.1196%20-8759%2025542)'%20xlink:href='%23A'%3e%3cstop%20offset='.76'%20stop-opacity='0'/%3e%3cstop%20offset='.95'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='F'%20cx='2523'%20cy='4680'%20r='20243'%20gradientTransform='matrix(-.03715%20.99931%20-2.12836%20-.07913%2013579%203530)'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%2335c1f1'/%3e%3cstop%20offset='.11'%20stop-color='%2334c1ed'/%3e%3cstop%20offset='.23'%20stop-color='%232fc2df'/%3e%3cstop%20offset='.31'%20stop-color='%232bc3d2'/%3e%3cstop%20offset='.67'%20stop-color='%2336c752'/%3e%3c/radialGradient%3e%3cradialGradient%20id='G'%20cx='24247'%20cy='7758'%20r='9734'%20gradientTransform='matrix(.28109%20.95968%20-.78353%20.22949%2024510%20-16292)'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%2366eb6e'/%3e%3cstop%20offset='1'%20stop-color='%2366eb6e'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cpath%20id='H'%20d='M24105%2020053a9345%209345%200%2001-1053%20472%2010202%2010202%200%2001-3590%20646c-4732%200-8855-3255-8855-7432%200-1175%20680-2193%201643-2729-4280%20180-5380%204640-5380%207253%200%207387%206810%208137%208276%208137%20791%200%201984-230%202704-456l130-44a12834%2012834%200%20006660-5282c220-350-168-757-535-565z'/%3e%3cpath%20id='I'%20d='M11571%2025141a7913%207913%200%2001-2273-2137%208145%208145%200%2001-1514-4740%208093%208093%200%20013093-6395%208082%208082%200%20011373-859c312-148%20846-414%201554-404a3236%203236%200%20012569%201297%203184%203184%200%2001636%201866c0-21%202446-7960-8005-7960-4390%200-8004%204166-8004%207820%200%202319%20538%204170%201212%205604a12833%2012833%200%20007684%206757%2012795%2012795%200%20003908%20610c1414%200%202774-233%204045-656a7575%207575%200%2001-6278-803z'/%3e%3cpath%20id='J'%20d='M16231%2015886c-80%20105-330%20250-330%20566%200%20260%20170%20512%20472%20723%201438%201003%204149%20868%204156%20868a5954%205954%200%20003027-839%206147%206147%200%20001133-850%206180%206180%200%20001910-4437c26-2242-796-3732-1133-4392-2120-4141-6694-6525-11668-6525-7011%200-12703%205635-12798%2012620%2047-3654%203679-6605%207996-6605%20350%200%202346%2034%204200%201007%201634%20858%202490%201894%203086%202921%20618%201067%20728%202415%20728%202952s-271%201333-780%201990z'/%3e%3cuse%20fill='url(%23B)'%20xlink:href='%23H'/%3e%3cuse%20fill='url(%23D)'%20opacity='.35'%20xlink:href='%23H'/%3e%3cuse%20fill='url(%23C)'%20xlink:href='%23I'/%3e%3cuse%20fill='url(%23E)'%20opacity='.4'%20xlink:href='%23I'/%3e%3cuse%20fill='url(%23F)'%20xlink:href='%23J'/%3e%3cuse%20fill='url(%23G)'%20xlink:href='%23J'/%3e%3c/svg%3e",M="/assets/firefox-FC5QDl5e.svg",A="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3clinearGradient%20id='a'%20x1='295.835'%20x2='295.835'%20y1='274.049'%20y2='272.933'%20gradientTransform='matrix(112%200%200%20-112%20-33069.5%2030695)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2319D7FF'/%3e%3cstop%20offset='1'%20stop-color='%231E64F0'/%3e%3c/linearGradient%3e%3ccircle%20cx='64'%20cy='64'%20r='62.5'%20fill='url(%23a)'/%3e%3cpath%20d='M63.5%207.6v9.2h1V7.6Zm-3.902.26-.996.08.4%205%20.996-.08zm8.804%200-.4%205%20.996.08.4-5zm-13.709.554-.986.172%201.6%209.101.986-.173zm18.614%200-1.6%209.1.986.174%201.6-9.102zM49.883%209.47l-.965.261%201.299%204.801.965-.261Zm28.234%200-1.299%204.8.965.262%201.299-4.8zm-32.846%201.363-.943.336%203.102%208.7.941-.337zm37.458%200-3.1%208.7.941.335%203.102-8.699zm4.62%201.852-2.2%204.601.902.43%202.201-4.6zm-46.695.007-.908.416%202.1%204.6.908-.414zm-4.32%202.26-.867.498%204.6%208%20.867-.498zm55.332%200-4.6%208%20.868.498%204.6-8zm-59.559%202.56-.816.577%202.9%204.101.817-.578zm63.786%200-2.9%204.1.816.578%202.9-4.101zm-67.61%202.968-.765.644%205.9%207%20.764-.644zm71.434%200-5.899%207%20.764.644%205.9-7zm-75.168%203.263-.697.717%203.6%203.5.696-.717zm-3.33%203.574-.639.768%207.1%205.9.64-.77zm85.562%200-7.101%205.899.64.77%207.1-5.901zM18.184%2031.19l-.569.823%204.201%202.9.569-.824zm91.632%200-4.2%202.899.568.824%204.2-2.9zM15.55%2035.367l-.498.867%208%204.6.498-.867zm96.902%200-8%204.6.498.867%208-4.6zm-99.14%204.28-.422.906%204.5%202.1.422-.907zm101.378%200-4.5%202.1.422.905%204.5-2.1zM11.375%2044.13l-.35.937%208.6%203.202.35-.938zm105.25%200-8.6%203.201.35.938%208.6-3.202zM9.828%2048.816l-.256.967%204.9%201.301.257-.967zm108.344%200-4.9%201.301.255.967%204.9-1.3zM8.688%2053.607l-.174.985%209.1%201.601.173-.986zm110.624%200-9.1%201.6.175.986%209.1-1.601zM8.05%2058.402l-.098.996%205%20.5.098-.996zm111.902%200-5%20.5.098.996%205-.5zM7.801%2063.4v1H17v-1zM111%2063.4v1h9.2v-1zm-98.049%204.403-5%20.5.098.994%205-.5zm102.098%200-.098.994%205%20.5.098-.994zm-97.436%203.705-9.1%201.6.175.984%209.1-1.6zm92.774%200-.174.984%209.1%201.6.173-.985zm-95.914%205.11-4.9%201.298.255.967%204.9-1.299zm99.054%200-.256.966%204.9%201.299.257-.967zm-93.902%202.814-8.6%203.199.35.937%208.6-3.199zm88.75%200-.35.937%208.6%203.2.35-.938zm-90.986%205.615-4.5%202.1.422.906%204.5-2.1zm93.222%200-.422.906%204.5%202.1.422-.907zm-87.56%201.92-8%204.6.498.867%208-4.6zm81.898%200-.498.867%208%204.6.498-.868zm-83.133%205.822-4.2%202.9.568.823%204.2-2.9zm84.368%200-.569.822%204.201%202.9.569-.822zm-78.504.926-7.1%205.9.639.77%207.101-5.9zm72.64%200-.64.77%207.101%205.9.639-.77zm-66.902%205.863-5.9%207%20.765.645%205.899-7zm61.164%200-.764.645%205.899%207%20.765-.645zm5.967.164-.697.717%203.6%203.5.696-.717zm-60.48%204.606-4.6%207.9.863.504%204.6-7.9zm47.863%200-.864.504%204.6%207.9.863-.504zm-53.74%201.164-2.901%204.1.816.577%202.9-4.101zm59.617%200-.817.576%202.9%204.101.817-.578zm-46.38%202.32-3.1%208.7.942.335%203.1-8.699zm33.141%200-.941.336%203.1%208.7.943-.337zm-25.263%202.182-1.6%209.1.986.173%201.6-9.1zm17.386%200-.986.174%201.6%209.1.986-.175zm-30.742.066-2.201%204.5.898.44%202.202-4.5zm44.098%200-.899.44%202.202%204.5.898-.44Zm-22.549.82v9.2h1v-9.2zm-13.283%202.272-1.301%204.9.967.256%201.3-4.9zm27.566%200-.967.256%201.301%204.9.967-.256zm-18.781%201.687-.4%205%20.996.08.4-5zm9.996%200-.996.08.4%205%20.996-.08z'%20style='-inkscape-stroke:none'%20color='%23000'%20fill='%23fff'/%3e%3cpath%20fill='%23f00'%20d='m106.7%2021-48%2037.7%205.2%205.2z'/%3e%3cpath%20fill='%23D01414'%20d='m63.9%2063.9%206%206L106.7%2021z'/%3e%3cpath%20fill='%23fff'%20d='m58.7%2058.7-37.7%2048%2042.9-42.8z'/%3e%3cpath%20fill='%23ACACAC'%20d='m21%20106.7%2048.9-36.8-6-6z'/%3e%3c/svg%3e";function N({browser:t,size:r=14,showLabel:s=!1}){if(!t)return null;const l=t.toLowerCase();return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"inline-flex",children:F(l,r)}),s&&e.jsx("span",{className:"text-[11px] text-gray-400",children:t})]})}function F(t,r){return t.includes("chromium")?e.jsx(D,{size:r}):t.includes("chrome")?e.jsx(B,{size:r}):t.includes("firefox")?e.jsx("img",{src:M,width:r,height:r,alt:"Firefox",style:{display:"block"}}):t.includes("safari")||t.includes("webkit")?e.jsx("img",{src:A,width:r,height:r,alt:"Safari",style:{display:"block"}}):t.includes("edge")?e.jsx("img",{src:G,width:r,height:r,alt:"Microsoft Edge",style:{display:"block"}}):e.jsx(u,{size:r,className:"text-gray-500"})}function B({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#EA4335",d:"M24 24 4.95 13A22 22 0 0 1 43.05 13Z"}),e.jsx("path",{fill:"#FBBC05",d:"M24 24 43.05 13A22 22 0 0 1 24 46Z"}),e.jsx("path",{fill:"#34A853",d:"M24 24 24 46A22 22 0 0 1 4.95 13Z"}),e.jsx("circle",{cx:"24",cy:"24",r:"10",fill:"#fff"}),e.jsx("circle",{cx:"24",cy:"24",r:"7.5",fill:"#4285F4"})]})}function D({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#5C9CE6",d:"M24 24 4.95 13A22 22 0 0 1 43.05 13Z"}),e.jsx("path",{fill:"#8AB4E8",d:"M24 24 43.05 13A22 22 0 0 1 24 46Z"}),e.jsx("path",{fill:"#4E8FD4",d:"M24 24 24 46A22 22 0 0 1 4.95 13Z"}),e.jsx("circle",{cx:"24",cy:"24",r:"10",fill:"#fff"}),e.jsx("circle",{cx:"24",cy:"24",r:"7.5",fill:"#5F6368"})]})}function E({name:t,size:r=15}){const s=(t||"").toLowerCase();return s.includes("prod")&&!s.includes("pre")?e.jsx(w,{size:r,className:"text-emerald-400"}):s.includes("pre")?e.jsx(v,{size:r,className:"text-amber-400"}):s.includes("stag")?e.jsx(x,{size:r,className:"text-cyan-400"}):s.includes("dev")?e.jsx(k,{size:r,className:"text-blue-400"}):s.includes("qa")||s.includes("test")?e.jsx(j,{size:r,className:"text-purple-400"}):e.jsx(x,{size:r,className:"text-gray-500"})}function p({name:t,isEnv:r,size:s=15}){return r?e.jsx(E,{name:t,size:s}):t?e.jsx(N,{browser:t,size:s}):e.jsx(u,{size:s,className:"text-gray-500"})}function R(){var r,s,l,c,n,o,a,f;const{data:t}=z({queryKey:["run-commands-config"],queryFn:C,staleTime:3e4});return{browserOpts:((s=(r=t==null?void 0:t.configured)==null?void 0:r.browsers)==null?void 0:s.options)||[],envOpts:((c=(l=t==null?void 0:t.configured)==null?void 0:l.environments)==null?void 0:c.options)||[],browserDefault:((o=(n=t==null?void 0:t.configured)==null?void 0:n.browsers)==null?void 0:o.default)||"",envDefault:((f=(a=t==null?void 0:t.configured)==null?void 0:a.environments)==null?void 0:f.default)||""}}function $({isEnv:t,value:r,onChange:s,options:l,size:c="md",variant:n="field"}){const[o,a]=y.useState(!1),f=c==="sm"?"px-2.5 py-1.5 text-xs":"px-3 py-2 text-sm",m=c==="sm"?14:15,d=n==="inline",g=d?`w-full flex items-center gap-1.5 rounded-md px-2 py-1.5 ${c==="sm"?"text-xs":"text-sm"} text-left group transition-colors ${o?"bg-surface-2":"hover:bg-surface-2"}`:`w-full flex items-center gap-2 bg-white dark:bg-white/[0.04] border border-gray-200 dark:border-white/10 rounded-lg ${f} text-left outline-none hover:border-gray-300 dark:hover:border-white/20 focus:border-brand-500/50`,h=d?`text-gray-400 dark:text-gray-500 flex-shrink-0 transition-all ${o?"opacity-100 rotate-180":"opacity-0 group-hover:opacity-100"}`:`text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform ${o?"rotate-180":""}`;return e.jsxs("div",{className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>a(i=>!i),className:g,children:[r?e.jsx(p,{name:r,isEnv:t,size:m}):null,e.jsx("span",{className:`flex-1 truncate ${r?"text-gray-800 dark:text-gray-200":"text-gray-400 dark:text-gray-500"}`,children:r||"Default"}),e.jsx(b,{size:13,className:h})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 w-full min-w-[180px] rounded-lg bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-xl shadow-black/20 dark:shadow-black/40 p-1 max-h-60 overflow-auto",children:[e.jsx("button",{type:"button",onClick:()=>{s(""),a(!1)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:"Default"}),l.map(i=>e.jsxs("button",{type:"button",onClick:()=>{s(i.name),a(!1)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:[e.jsx(p,{name:i.name,isEnv:t,size:m}),e.jsx("span",{className:"flex-1 text-left truncate",children:i.name})]},i.name))]})]})]})}export{N as B,$ as T,p as a,R as u};
1
+ import{j as e,r as y}from"./vendor-react-DOVfxdUy.js";import{u as z}from"./vendor-query-DkZSMtfn.js";import{K as u,cE as w,aB as v,e as x,bA as k,by as j,y as b}from"./vendor-icons-D_Dmmj8d.js";import{v as C}from"./index-D6sQYc_0.js";const G="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3c!--%20Uploaded%20to:%20SVG%20Repo,%20www.svgrepo.com,%20Generator:%20SVG%20Repo%20Mixer%20Tools%20--%3e%3csvg%20width='800px'%20height='800px'%20viewBox='0%200%2027600%2027600'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3clinearGradient%20id='A'%20gradientUnits='userSpaceOnUse'/%3e%3clinearGradient%20id='B'%20x1='6870'%20x2='24704'%20y1='18705'%20y2='18705'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%230c59a4'/%3e%3cstop%20offset='1'%20stop-color='%23114a8b'/%3e%3c/linearGradient%3e%3clinearGradient%20id='C'%20x1='16272'%20x2='5133'%20y1='10968'%20y2='23102'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%231b9de2'/%3e%3cstop%20offset='.16'%20stop-color='%231595df'/%3e%3cstop%20offset='.67'%20stop-color='%230680d7'/%3e%3cstop%20offset='1'%20stop-color='%230078d4'/%3e%3c/linearGradient%3e%3cradialGradient%20id='D'%20cx='16720'%20cy='18747'%20r='9538'%20xlink:href='%23A'%3e%3cstop%20offset='.72'%20stop-opacity='0'/%3e%3cstop%20offset='.95'%20stop-opacity='.53'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='E'%20cx='7130'%20cy='19866'%20r='14324'%20gradientTransform='matrix(.14843%20-.98892%20.79688%20.1196%20-8759%2025542)'%20xlink:href='%23A'%3e%3cstop%20offset='.76'%20stop-opacity='0'/%3e%3cstop%20offset='.95'%20stop-opacity='.5'/%3e%3cstop%20offset='1'/%3e%3c/radialGradient%3e%3cradialGradient%20id='F'%20cx='2523'%20cy='4680'%20r='20243'%20gradientTransform='matrix(-.03715%20.99931%20-2.12836%20-.07913%2013579%203530)'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%2335c1f1'/%3e%3cstop%20offset='.11'%20stop-color='%2334c1ed'/%3e%3cstop%20offset='.23'%20stop-color='%232fc2df'/%3e%3cstop%20offset='.31'%20stop-color='%232bc3d2'/%3e%3cstop%20offset='.67'%20stop-color='%2336c752'/%3e%3c/radialGradient%3e%3cradialGradient%20id='G'%20cx='24247'%20cy='7758'%20r='9734'%20gradientTransform='matrix(.28109%20.95968%20-.78353%20.22949%2024510%20-16292)'%20xlink:href='%23A'%3e%3cstop%20offset='0'%20stop-color='%2366eb6e'/%3e%3cstop%20offset='1'%20stop-color='%2366eb6e'%20stop-opacity='0'/%3e%3c/radialGradient%3e%3cpath%20id='H'%20d='M24105%2020053a9345%209345%200%2001-1053%20472%2010202%2010202%200%2001-3590%20646c-4732%200-8855-3255-8855-7432%200-1175%20680-2193%201643-2729-4280%20180-5380%204640-5380%207253%200%207387%206810%208137%208276%208137%20791%200%201984-230%202704-456l130-44a12834%2012834%200%20006660-5282c220-350-168-757-535-565z'/%3e%3cpath%20id='I'%20d='M11571%2025141a7913%207913%200%2001-2273-2137%208145%208145%200%2001-1514-4740%208093%208093%200%20013093-6395%208082%208082%200%20011373-859c312-148%20846-414%201554-404a3236%203236%200%20012569%201297%203184%203184%200%2001636%201866c0-21%202446-7960-8005-7960-4390%200-8004%204166-8004%207820%200%202319%20538%204170%201212%205604a12833%2012833%200%20007684%206757%2012795%2012795%200%20003908%20610c1414%200%202774-233%204045-656a7575%207575%200%2001-6278-803z'/%3e%3cpath%20id='J'%20d='M16231%2015886c-80%20105-330%20250-330%20566%200%20260%20170%20512%20472%20723%201438%201003%204149%20868%204156%20868a5954%205954%200%20003027-839%206147%206147%200%20001133-850%206180%206180%200%20001910-4437c26-2242-796-3732-1133-4392-2120-4141-6694-6525-11668-6525-7011%200-12703%205635-12798%2012620%2047-3654%203679-6605%207996-6605%20350%200%202346%2034%204200%201007%201634%20858%202490%201894%203086%202921%20618%201067%20728%202415%20728%202952s-271%201333-780%201990z'/%3e%3cuse%20fill='url(%23B)'%20xlink:href='%23H'/%3e%3cuse%20fill='url(%23D)'%20opacity='.35'%20xlink:href='%23H'/%3e%3cuse%20fill='url(%23C)'%20xlink:href='%23I'/%3e%3cuse%20fill='url(%23E)'%20opacity='.4'%20xlink:href='%23I'/%3e%3cuse%20fill='url(%23F)'%20xlink:href='%23J'/%3e%3cuse%20fill='url(%23G)'%20xlink:href='%23J'/%3e%3c/svg%3e",M="/assets/firefox-FC5QDl5e.svg",A="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3clinearGradient%20id='a'%20x1='295.835'%20x2='295.835'%20y1='274.049'%20y2='272.933'%20gradientTransform='matrix(112%200%200%20-112%20-33069.5%2030695)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%2319D7FF'/%3e%3cstop%20offset='1'%20stop-color='%231E64F0'/%3e%3c/linearGradient%3e%3ccircle%20cx='64'%20cy='64'%20r='62.5'%20fill='url(%23a)'/%3e%3cpath%20d='M63.5%207.6v9.2h1V7.6Zm-3.902.26-.996.08.4%205%20.996-.08zm8.804%200-.4%205%20.996.08.4-5zm-13.709.554-.986.172%201.6%209.101.986-.173zm18.614%200-1.6%209.1.986.174%201.6-9.102zM49.883%209.47l-.965.261%201.299%204.801.965-.261Zm28.234%200-1.299%204.8.965.262%201.299-4.8zm-32.846%201.363-.943.336%203.102%208.7.941-.337zm37.458%200-3.1%208.7.941.335%203.102-8.699zm4.62%201.852-2.2%204.601.902.43%202.201-4.6zm-46.695.007-.908.416%202.1%204.6.908-.414zm-4.32%202.26-.867.498%204.6%208%20.867-.498zm55.332%200-4.6%208%20.868.498%204.6-8zm-59.559%202.56-.816.577%202.9%204.101.817-.578zm63.786%200-2.9%204.1.816.578%202.9-4.101zm-67.61%202.968-.765.644%205.9%207%20.764-.644zm71.434%200-5.899%207%20.764.644%205.9-7zm-75.168%203.263-.697.717%203.6%203.5.696-.717zm-3.33%203.574-.639.768%207.1%205.9.64-.77zm85.562%200-7.101%205.899.64.77%207.1-5.901zM18.184%2031.19l-.569.823%204.201%202.9.569-.824zm91.632%200-4.2%202.899.568.824%204.2-2.9zM15.55%2035.367l-.498.867%208%204.6.498-.867zm96.902%200-8%204.6.498.867%208-4.6zm-99.14%204.28-.422.906%204.5%202.1.422-.907zm101.378%200-4.5%202.1.422.905%204.5-2.1zM11.375%2044.13l-.35.937%208.6%203.202.35-.938zm105.25%200-8.6%203.201.35.938%208.6-3.202zM9.828%2048.816l-.256.967%204.9%201.301.257-.967zm108.344%200-4.9%201.301.255.967%204.9-1.3zM8.688%2053.607l-.174.985%209.1%201.601.173-.986zm110.624%200-9.1%201.6.175.986%209.1-1.601zM8.05%2058.402l-.098.996%205%20.5.098-.996zm111.902%200-5%20.5.098.996%205-.5zM7.801%2063.4v1H17v-1zM111%2063.4v1h9.2v-1zm-98.049%204.403-5%20.5.098.994%205-.5zm102.098%200-.098.994%205%20.5.098-.994zm-97.436%203.705-9.1%201.6.175.984%209.1-1.6zm92.774%200-.174.984%209.1%201.6.173-.985zm-95.914%205.11-4.9%201.298.255.967%204.9-1.299zm99.054%200-.256.966%204.9%201.299.257-.967zm-93.902%202.814-8.6%203.199.35.937%208.6-3.199zm88.75%200-.35.937%208.6%203.2.35-.938zm-90.986%205.615-4.5%202.1.422.906%204.5-2.1zm93.222%200-.422.906%204.5%202.1.422-.907zm-87.56%201.92-8%204.6.498.867%208-4.6zm81.898%200-.498.867%208%204.6.498-.868zm-83.133%205.822-4.2%202.9.568.823%204.2-2.9zm84.368%200-.569.822%204.201%202.9.569-.822zm-78.504.926-7.1%205.9.639.77%207.101-5.9zm72.64%200-.64.77%207.101%205.9.639-.77zm-66.902%205.863-5.9%207%20.765.645%205.899-7zm61.164%200-.764.645%205.899%207%20.765-.645zm5.967.164-.697.717%203.6%203.5.696-.717zm-60.48%204.606-4.6%207.9.863.504%204.6-7.9zm47.863%200-.864.504%204.6%207.9.863-.504zm-53.74%201.164-2.901%204.1.816.577%202.9-4.101zm59.617%200-.817.576%202.9%204.101.817-.578zm-46.38%202.32-3.1%208.7.942.335%203.1-8.699zm33.141%200-.941.336%203.1%208.7.943-.337zm-25.263%202.182-1.6%209.1.986.173%201.6-9.1zm17.386%200-.986.174%201.6%209.1.986-.175zm-30.742.066-2.201%204.5.898.44%202.202-4.5zm44.098%200-.899.44%202.202%204.5.898-.44Zm-22.549.82v9.2h1v-9.2zm-13.283%202.272-1.301%204.9.967.256%201.3-4.9zm27.566%200-.967.256%201.301%204.9.967-.256zm-18.781%201.687-.4%205%20.996.08.4-5zm9.996%200-.996.08.4%205%20.996-.08z'%20style='-inkscape-stroke:none'%20color='%23000'%20fill='%23fff'/%3e%3cpath%20fill='%23f00'%20d='m106.7%2021-48%2037.7%205.2%205.2z'/%3e%3cpath%20fill='%23D01414'%20d='m63.9%2063.9%206%206L106.7%2021z'/%3e%3cpath%20fill='%23fff'%20d='m58.7%2058.7-37.7%2048%2042.9-42.8z'/%3e%3cpath%20fill='%23ACACAC'%20d='m21%20106.7%2048.9-36.8-6-6z'/%3e%3c/svg%3e";function N({browser:t,size:r=14,showLabel:s=!1}){if(!t)return null;const l=t.toLowerCase();return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-shrink-0",children:[e.jsx("span",{className:"inline-flex",children:F(l,r)}),s&&e.jsx("span",{className:"text-[11px] text-gray-400",children:t})]})}function F(t,r){return t.includes("chromium")?e.jsx(D,{size:r}):t.includes("chrome")?e.jsx(B,{size:r}):t.includes("firefox")?e.jsx("img",{src:M,width:r,height:r,alt:"Firefox",style:{display:"block"}}):t.includes("safari")||t.includes("webkit")?e.jsx("img",{src:A,width:r,height:r,alt:"Safari",style:{display:"block"}}):t.includes("edge")?e.jsx("img",{src:G,width:r,height:r,alt:"Microsoft Edge",style:{display:"block"}}):e.jsx(u,{size:r,className:"text-gray-500"})}function B({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#EA4335",d:"M24 24 4.95 13A22 22 0 0 1 43.05 13Z"}),e.jsx("path",{fill:"#FBBC05",d:"M24 24 43.05 13A22 22 0 0 1 24 46Z"}),e.jsx("path",{fill:"#34A853",d:"M24 24 24 46A22 22 0 0 1 4.95 13Z"}),e.jsx("circle",{cx:"24",cy:"24",r:"10",fill:"#fff"}),e.jsx("circle",{cx:"24",cy:"24",r:"7.5",fill:"#4285F4"})]})}function D({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{fill:"#5C9CE6",d:"M24 24 4.95 13A22 22 0 0 1 43.05 13Z"}),e.jsx("path",{fill:"#8AB4E8",d:"M24 24 43.05 13A22 22 0 0 1 24 46Z"}),e.jsx("path",{fill:"#4E8FD4",d:"M24 24 24 46A22 22 0 0 1 4.95 13Z"}),e.jsx("circle",{cx:"24",cy:"24",r:"10",fill:"#fff"}),e.jsx("circle",{cx:"24",cy:"24",r:"7.5",fill:"#5F6368"})]})}function E({name:t,size:r=15}){const s=(t||"").toLowerCase();return s.includes("prod")&&!s.includes("pre")?e.jsx(w,{size:r,className:"text-emerald-400"}):s.includes("pre")?e.jsx(v,{size:r,className:"text-amber-400"}):s.includes("stag")?e.jsx(x,{size:r,className:"text-cyan-400"}):s.includes("dev")?e.jsx(k,{size:r,className:"text-blue-400"}):s.includes("qa")||s.includes("test")?e.jsx(j,{size:r,className:"text-purple-400"}):e.jsx(x,{size:r,className:"text-gray-500"})}function p({name:t,isEnv:r,size:s=15}){return r?e.jsx(E,{name:t,size:s}):t?e.jsx(N,{browser:t,size:s}):e.jsx(u,{size:s,className:"text-gray-500"})}function R(){var r,s,l,c,n,o,a,f;const{data:t}=z({queryKey:["run-commands-config"],queryFn:C,staleTime:3e4});return{browserOpts:((s=(r=t==null?void 0:t.configured)==null?void 0:r.browsers)==null?void 0:s.options)||[],envOpts:((c=(l=t==null?void 0:t.configured)==null?void 0:l.environments)==null?void 0:c.options)||[],browserDefault:((o=(n=t==null?void 0:t.configured)==null?void 0:n.browsers)==null?void 0:o.default)||"",envDefault:((f=(a=t==null?void 0:t.configured)==null?void 0:a.environments)==null?void 0:f.default)||""}}function $({isEnv:t,value:r,onChange:s,options:l,size:c="md",variant:n="field"}){const[o,a]=y.useState(!1),f=c==="sm"?"px-2.5 py-1.5 text-xs":"px-3 py-2 text-sm",m=c==="sm"?14:15,d=n==="inline",g=d?`w-full flex items-center gap-1.5 rounded-md px-2 py-1.5 ${c==="sm"?"text-xs":"text-sm"} text-left group transition-colors ${o?"bg-surface-2":"hover:bg-surface-2"}`:`w-full flex items-center gap-2 bg-white dark:bg-white/[0.04] border border-gray-200 dark:border-white/10 rounded-lg ${f} text-left outline-none hover:border-gray-300 dark:hover:border-white/20 focus:border-brand-500/50`,h=d?`text-gray-400 dark:text-gray-500 flex-shrink-0 transition-all ${o?"opacity-100 rotate-180":"opacity-0 group-hover:opacity-100"}`:`text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform ${o?"rotate-180":""}`;return e.jsxs("div",{className:"relative w-full",children:[e.jsxs("button",{type:"button",onClick:()=>a(i=>!i),className:g,children:[r?e.jsx(p,{name:r,isEnv:t,size:m}):null,e.jsx("span",{className:`flex-1 truncate ${r?"text-gray-800 dark:text-gray-200":"text-gray-400 dark:text-gray-500"}`,children:r||"Default"}),e.jsx(b,{size:13,className:h})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>a(!1)}),e.jsxs("div",{className:"absolute left-0 top-full mt-1 z-50 w-full min-w-[180px] rounded-lg bg-white dark:bg-surface-1 border border-gray-200 dark:border-white/10 shadow-xl shadow-black/20 dark:shadow-black/40 p-1 max-h-60 overflow-auto",children:[e.jsx("button",{type:"button",onClick:()=>{s(""),a(!1)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:"Default"}),l.map(i=>e.jsxs("button",{type:"button",onClick:()=>{s(i.name),a(!1)},className:"w-full flex items-center gap-2 px-2 py-1.5 rounded-md text-sm text-gray-700 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors",children:[e.jsx(p,{name:i.name,isEnv:t,size:m}),e.jsx("span",{className:"flex-1 text-left truncate",children:i.name})]},i.name))]})]})]})}export{N as B,$ as T,p as a,R as u};
@@ -1 +1 @@
1
- import{r as z,j as e}from"./vendor-react-CTbHBddL.js";import{u as Ue}from"./useTabParam-ChbOedP1.js";import{b as Ae,D as Pe}from"./index-BYVxKLrT.js";import{C as Ee}from"./ConfirmDialog-t7mpeeSN.js";import{aa as Fe,ab as Ie,ac as Be,F as Oe,ad as He,ae as qe,af as Ve,ag as Ge}from"./useTestManagement-Xm4Bcx3u.js";import{u as Ye}from"./vendor-query-BrzmPFT3.js";import{f as D}from"./formatTestName-BKd2Uqhs.js";import{cv as q,C as De,d as I,a0 as F,T as Z,cf as J,aC as Je,cm as Ke,r as H,o as me,ap as pe,I as Qe,al as Xe,aI as he,Z as Ze,R as ge,v as ue,X as be,bO as We,y as fe,ag as X,_ as es,dk as oe,t as ss,aJ as ts,b1 as as}from"./vendor-icons-BKPiFyYV.js";const rs={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},ns={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"},xe={playwright:"bg-green-500/20 text-green-300",jest:"bg-red-500/20 text-red-300",cypress:"bg-teal-500/20 text-teal-300",mocha:"bg-amber-500/20 text-amber-300",vitest:"bg-yellow-500/20 text-yellow-300",cucumber:"bg-emerald-500/20 text-emerald-300",pytest:"bg-blue-500/20 text-blue-300",junit:"bg-orange-500/20 text-orange-300",testng:"bg-violet-500/20 text-violet-300",nunit:"bg-purple-500/20 text-purple-300",xunit:"bg-indigo-500/20 text-indigo-300",mstest:"bg-sky-500/20 text-sky-300",rspec:"bg-rose-500/20 text-rose-300",robot:"bg-cyan-500/20 text-cyan-300",unknown:"bg-gray-500/20 text-gray-300"},Y={synced:"bg-emerald-500",script_updated:"bg-amber-500",script_missing:"bg-red-500",case_updated:"bg-blue-500"};function is(t){if(!t)return"Never";const i=Date.now()-t,o=Math.floor(i/6e4);if(o<1)return"Just now";if(o<60)return`${o}m ago`;const j=Math.floor(o/60);return j<24?`${j}h ago`:`${Math.floor(j/24)}d ago`}function ye(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function je(t,i=40){if(t.length<=i)return t;const o=t.split("/");return o.length<=2?"..."+t.slice(-i):o[0]+"/.../"+o.slice(-2).join("/")}const ee=t=>{var i;return((i=t==null?void 0:t.mapping)==null?void 0:i.syncStatus)||(t==null?void 0:t.syncStatus)||"synced"};function ls({status:t}){const i={synced:{icon:H,label:"Synced",color:"text-emerald-400 bg-emerald-500/15"},script_updated:{icon:me,label:"Script Updated",color:"text-amber-400 bg-amber-500/15"},script_missing:{icon:pe,label:"Script Missing",color:"text-red-400 bg-red-500/15"},case_updated:{icon:q,label:"Case Updated",color:"text-blue-400 bg-blue-500/15"},not_mapped:{icon:as,label:"Not Mapped",color:"text-gray-400 bg-gray-500/15"}},o=i[t]||i.not_mapped,j=o.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${o.color}`,children:[e.jsx(j,{size:12}),o.label]})}function se({priority:t}){const i=rs[t]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:ye(t)})}function cs({type:t}){const i=ns[t]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:ye(t)})}function W({framework:t}){const i=xe[t]||xe.unknown;return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:t})}function js(){var le;const[t,i]=Ue("tab",["dashboard","mapped","map"],"dashboard"),[o,j]=z.useState(""),[b,S]=z.useState(""),[u,C]=z.useState(""),[M,R]=z.useState(null),[T,N]=z.useState(new Set),[E,$]=z.useState(new Set),{toast:A}=Ae(),[m,n]=z.useState(null),{data:w,isLoading:v}=Fe(),{data:p,isLoading:c}=Ie(),{data:g,isLoading:s}=Be(),{data:r}=Oe(),{data:l,isLoading:f}=Ye({queryKey:["test-explorer"],queryFn:Pe}),y=He(),h=qe(),_=Ve(),L=Ge(),k=w||{},P=Array.isArray(p)?p:(p==null?void 0:p.testCases)||(p==null?void 0:p.mappings)||[],B=Array.isArray(g)?g:(g==null?void 0:g.testCases)||[],V=k.totalTestCases??((le=r==null?void 0:r.testCases)==null?void 0:le.length)??(r==null?void 0:r.length)??0,K=k.syncedCount??0,te=k.scriptUpdatedCount??0,ae=k.scriptMissingCount??0,re=k.caseUpdatedCount??0,G=k.mappedCount??P.length??0,Ne=k.unmappedCount??Math.max(0,V-G),ne=k.totalMappings??K+te+ae+re,ve=k.syncHealthPercentage??(ne>0?Math.round(K/ne*100):0),we=k.mappingPercentage??(V>0?Math.round(G/V*100):0),Q=z.useMemo(()=>{let a=[...P];if(o){const d=o.toLowerCase();a=a.filter(x=>{var O,ce,de;return(x.title||((O=x.testCase)==null?void 0:O.title)||"").toLowerCase().includes(d)||(x.scriptPath||((ce=x.mapping)==null?void 0:ce.scriptPath)||"").toLowerCase().includes(d)||(x.testName||((de=x.mapping)==null?void 0:de.testName)||"").toLowerCase().includes(d)})}return u&&(a=a.filter(d=>ee(d)===u)),a},[P,o,u]),ke=z.useMemo(()=>{if(!b)return B;const a=b.toLowerCase();return B.filter(d=>(d.title||"").toLowerCase().includes(a)||(d.id||"").toLowerCase().includes(a))},[B,b]);function U(a){A("success",a)}function Se(a){$(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Ce(a){N(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Me(){T.size===Q.length?N(new Set):N(new Set(Q.map(a=>a.testCaseId||a.id)))}function ie(a){a.length>0&&n(a)}async function Te(a){n(null);try{await h.mutateAsync(a),N(new Set),U(`Unlinked ${a.length} mapping(s)`)}catch(d){A("error",d.message||"Failed to unlink")}}async function $e(a){const d=a.testCaseId||a.id;try{await L.mutateAsync({testCaseId:d,syncStatus:"synced"}),U("Marked as synced")}catch(x){U(`Error: ${x.message||"Failed to sync"}`)}}async function Le(a,d,x){try{await y.mutateAsync([{testCaseId:a,scriptPath:d.file,testName:x.name,suite:x.suite||d.name,framework:x.framework||d.framework}]),R(null),U(`Mapped successfully to "${x.name}"`)}catch(O){U(`Error: ${O.message||"Failed to map"}`)}}async function ze(){try{await _.mutateAsync(),U("Sync check completed")}catch(a){U(`Error: ${a.message||"Sync check failed"}`)}}async function _e(){const a=Array.from(T);try{for(const d of a)await L.mutateAsync({testCaseId:d,syncStatus:"synced"});N(new Set),U(`Marked ${a.length} as synced`)}catch(d){U(`Error: ${d.message||"Failed to mark synced"}`)}}const Re=[{id:"dashboard",label:"Dashboard",icon:De},{id:"mapped",label:"Mapped Test Cases",icon:I},{id:"map",label:"Map Test Cases",icon:q}];return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[m&&e.jsx(Ee,{open:!0,title:"Remove mapping?",description:`Remove the script mapping for ${m.length} test case${m.length===1?"":"s"}? This unlinks the script — it doesn't delete the test case or the script.`,confirmLabel:"Remove",onConfirm:()=>Te(m),onCancel:()=>n(null)}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(q,{size:24,className:"text-brand-300"}),"Script Mapping & Sync"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Link test cases to automation scripts and monitor sync health"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:Re.map(a=>{const d=a.icon,x=t===a.id;return e.jsxs("button",{onClick:()=>i(a.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${x?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[e.jsx(d,{size:14}),a.label]},a.id)})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[t==="dashboard"&&e.jsx(ds,{totalTestCases:V,totalMapped:G,totalUnmapped:Ne,mappingPercentage:we,syncHealth:ve,syncedCount:K,scriptUpdatedCount:te,scriptMissingCount:ae,caseUpdatedCount:re,isLoading:v,onCheckSync:ze,checkSyncPending:_.isPending,onGoToMap:()=>i("mapped"),onGoToUnmapped:()=>i("map"),mappedItems:P}),t==="mapped"&&e.jsx(os,{items:Q,isLoading:c,searchMapped:o,setSearchMapped:j,syncStatusFilter:u,setSyncStatusFilter:C,selectedMappedIds:T,toggleMappedSelection:Ce,selectAllMapped:Me,totalMapped:G,onUnlink:a=>ie([a.testCaseId||a.id]),onResync:$e,onBulkUnlink:()=>ie(Array.from(T)),onBulkMarkSynced:_e,onViewScript:(a,d)=>{const x=a.replace(/\\/g,"/"),O=`/tests?file=${encodeURIComponent(x)}&test=${encodeURIComponent(d)}`;window.open(O,"_blank","noopener")}}),t==="map"&&e.jsx(xs,{unmapped:ke,unmappedLoading:s,searchUnmapped:b,setSearchUnmapped:S,selectedTestCaseId:M,setSelectedTestCaseId:R,explorerData:l,explorerLoading:f,expandedSuites:E,toggleSuiteExpand:Se,onMap:Le,mappingPending:y.isPending,mappedScripts:P})]})]})}function ds({totalTestCases:t,totalMapped:i,totalUnmapped:o,mappingPercentage:j,syncHealth:b,syncedCount:S,scriptUpdatedCount:u,scriptMissingCount:C,caseUpdatedCount:M,isLoading:R,onCheckSync:T,checkSyncPending:N,onGoToMap:E,onGoToUnmapped:$,mappedItems:A}){const[m,n]=z.useState(null),w=j??(t>0?Math.round(i/t*100):0),v=S+u+C+M,p={synced:[],script_updated:[],script_missing:[],case_updated:[]};for(const c of A){const g=ee(c);p[g]&&p[g].push(c)}return R?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(F,{className:"w-6 h-6 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400",children:"Loading dashboard..."})]}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(Z,{className:"w-5 h-5 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:t}),e.jsx("div",{className:"text-xs text-gray-400",children:"Total Test Cases"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx(I,{className:"w-5 h-5 text-emerald-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[i,e.jsxs("span",{className:"text-sm font-normal text-emerald-400 ml-1.5",children:[w,"%"]})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Mapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/15 flex items-center justify-center",children:e.jsx(J,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:o}),e.jsx("div",{className:"text-xs text-gray-400",children:"Unmapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-cyan-500/15 flex items-center justify-center",children:e.jsx(Je,{className:"w-5 h-5 text-cyan-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[b,e.jsx("span",{className:"text-sm font-normal text-cyan-400 ml-0.5",children:"%"})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Sync Health"})]})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-4 flex items-center gap-2",children:[e.jsx(Ke,{className:"w-4 h-4 text-brand-400"}),"Sync Status Breakdown"]}),v>0?e.jsxs("div",{className:"w-full h-3 rounded-full bg-surface-2 overflow-hidden flex mb-4",children:[S>0&&e.jsx("div",{className:`${Y.synced} h-full transition-all`,style:{width:`${S/v*100}%`},title:`Synced: ${S}`}),u>0&&e.jsx("div",{className:`${Y.script_updated} h-full transition-all`,style:{width:`${u/v*100}%`},title:`Script Updated: ${u}`}),C>0&&e.jsx("div",{className:`${Y.script_missing} h-full transition-all`,style:{width:`${C/v*100}%`},title:`Script Missing: ${C}`}),M>0&&e.jsx("div",{className:`${Y.case_updated} h-full transition-all`,style:{width:`${M/v*100}%`},title:`Case Updated: ${M}`})]}):e.jsx("div",{className:"w-full h-3 rounded-full bg-surface-2 mb-4"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{key:"synced",label:"Synced",count:S,icon:H,color:"text-emerald-400",desc:"Test case and script file are in sync. No action needed."},{key:"script_updated",label:"Script Updated",count:u,icon:me,color:"text-amber-400",desc:"The automation script file was modified on disk after mapping. Review the test case to ensure it still matches the script."},{key:"script_missing",label:"Script Missing",count:C,icon:pe,color:"text-red-400",desc:"The mapped script file was deleted or moved. Re-map the test case to a valid script file."},{key:"case_updated",label:"Case Updated",count:M,icon:q,color:"text-blue-400",desc:"The test case was edited after mapping. The automation script may need to be updated to reflect the changes."}].map(c=>{const g=c.icon,s=m===c.key;return e.jsx("div",{className:"relative group/card",children:e.jsxs("button",{onClick:()=>n(s?null:c.key),className:`w-full bg-surface-2 rounded-lg border p-3 flex items-center gap-2 text-left transition-colors ${s?"border-brand-500/40 ring-1 ring-brand-500/20":"border-white/5 hover:border-white/10"}`,children:[e.jsx(g,{size:16,className:`${c.color} shrink-0`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-100",children:c.count}),e.jsx("div",{className:"text-xs text-gray-400",children:c.label})]}),e.jsxs("span",{className:"relative group/info shrink-0",children:[e.jsx(Qe,{size:12,className:"text-gray-600 hover:text-gray-300 transition-colors cursor-help"}),e.jsxs("span",{className:"absolute z-20 bottom-full right-0 mb-2 w-56 px-3 py-2.5 rounded-lg bg-gray-900 border border-white/10 shadow-xl text-[11px] text-gray-300 leading-relaxed opacity-0 invisible group-hover/info:opacity-100 group-hover/info:visible transition-all pointer-events-none",children:[e.jsxs("span",{className:"font-medium text-gray-100 mb-1 flex items-center gap-1.5",children:[e.jsx(g,{size:11,className:c.color})," ",c.label]}),c.desc,e.jsx("span",{className:"absolute top-full right-4 -mt-px w-2 h-2 bg-gray-900 border-r border-b border-white/10 rotate-45"})]})]})]})},c.key)})}),m&&p[m]&&e.jsxs("div",{className:"mt-4 bg-surface-2 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-white/5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:m==="synced"?"Synced Mappings":m==="script_updated"?"Scripts Changed on Disk":m==="script_missing"?"Missing Script Files":"Test Cases Updated After Mapping"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[p[m].length," item",p[m].length!==1?"s":""]})]}),p[m].length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-gray-500",children:"No items in this category"}):e.jsx("div",{className:"divide-y divide-white/5 max-h-[300px] overflow-y-auto",children:p[m].map((c,g)=>{const s=c,r=c.mapping||{},l=r.scriptPath||c.scriptPath||"",f=r.testName||c.testName||"",y=s.title||s.name||"Untitled",h=r.lastSynced||r.last_synced;return e.jsx("div",{className:"px-4 py-3 hover:bg-white/[0.02] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Z,{size:12,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200 font-medium truncate",children:y}),s.priority&&e.jsx(se,{priority:s.priority})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-5",children:[e.jsx(Xe,{size:10,className:"text-gray-600 shrink-0"}),e.jsx(he,{size:11,className:"text-gray-500 shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-gray-400 truncate",children:l||"No script path"}),f&&e.jsx("span",{className:"text-[10px] text-gray-500 bg-surface-1 px-1.5 py-0.5 rounded shrink-0",title:f,children:D(f)})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[m==="case_updated"&&e.jsx("span",{className:"text-[10px] text-blue-400",children:"Test case was modified after last sync"}),m==="script_updated"&&e.jsx("span",{className:"text-[10px] text-amber-400",children:"Script file changed on disk"}),m==="script_missing"&&e.jsxs("span",{className:"text-[10px] text-red-400",children:["File not found: ",l.split("/").pop()]}),h&&e.jsxs("div",{className:"text-[10px] text-gray-500 mt-0.5",children:["Last synced: ",new Date(h).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]})},c.id||g)})})]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-3 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-400"}),"Quick Actions"]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("button",{onClick:T,disabled:N,className:"inline-flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:16,className:"animate-spin"}):e.jsx(ge,{size:16}),"Check Sync Status"]}),e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(I,{size:16}),"View Mapped Test Cases"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(J,{size:16}),"View Unmapped Test Cases"]})]})]})]})}function os({items:t,isLoading:i,searchMapped:o,setSearchMapped:j,syncStatusFilter:b,setSyncStatusFilter:S,selectedMappedIds:u,toggleMappedSelection:C,selectAllMapped:M,totalMapped:R,onUnlink:T,onResync:N,onBulkUnlink:E,onBulkMarkSynced:$,onViewScript:A}){const m=t.length>0&&u.size===t.length;return e.jsxs("div",{className:"space-y-4 max-w-full",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("span",{className:"text-sm font-medium text-gray-200",children:[R," mapped test case",R!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:n=>j(n.target.value),placeholder:"Search mapped cases...",className:"bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 w-56"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(We,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{value:b,onChange:n=>S(n.target.value),className:"appearance-none bg-surface-2 border border-white/10 rounded-lg pl-8 pr-8 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50 cursor-pointer",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"synced",children:"Synced"}),e.jsx("option",{value:"script_updated",children:"Script Updated"}),e.jsx("option",{value:"script_missing",children:"Script Missing"}),e.jsx("option",{value:"case_updated",children:"Case Updated"})]}),e.jsx(fe,{size:14,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"})]})]})]}),u.size>0&&e.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg px-4 py-2.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-brand-300 font-medium",children:[u.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-1.5 bg-red-500/15 hover:bg-red-500/25 text-red-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(J,{size:12}),"Unlink Selected"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-1.5 bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(X,{size:12}),"Mark Synced"]})]})]}),i?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading mapped cases..."})]}):t.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(I,{className:"w-8 h-8 text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-400",children:o||b?"No mapped test cases match your filters.":'No mapped test cases yet. Go to "Map Test Cases" to create mappings.'})]}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-gray-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-3 text-left w-10",children:e.jsx("button",{onClick:M,className:"w-4 h-4 rounded border border-white/20 flex items-center justify-center hover:border-brand-400 transition-colors",children:m&&e.jsx(X,{size:10,className:"text-brand-400"})})}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Case"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Priority"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Script Path"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Name"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Framework"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Sync Status"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Last Synced"}),e.jsx("th",{className:"px-3 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:t.map(n=>{var y,h,_,L,k,P;const w=n.testCaseId||n.id,v=u.has(w),p=n.title||((y=n.testCase)==null?void 0:y.title)||"Untitled",c=n.priority||((h=n.testCase)==null?void 0:h.priority)||"medium",g=n.scriptPath||((_=n.mapping)==null?void 0:_.scriptPath)||"",s=n.testName||((L=n.mapping)==null?void 0:L.testName)||"",r=n.framework||((k=n.mapping)==null?void 0:k.framework)||"",l=ee(n),f=n.lastSynced||((P=n.mapping)==null?void 0:P.lastSynced)||null;return e.jsxs("tr",{className:`hover:bg-surface-2/50 transition-colors ${v?"bg-brand-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-3",children:e.jsx("button",{onClick:()=>C(w),className:`w-4 h-4 rounded border flex items-center justify-center transition-colors ${v?"bg-brand-600 border-brand-500":"border-white/20 hover:border-brand-400"}`,children:v&&e.jsx(X,{size:10,className:"text-white"})})}),e.jsx("td",{className:"px-3 py-3 align-top",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0 mt-0.5",children:w}),e.jsx("span",{className:"text-gray-200 font-medium break-words",children:p})]})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(se,{priority:c})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs font-mono cursor-help",title:g,children:je(g)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs",title:s,children:D(s)})}),e.jsx("td",{className:"px-3 py-3",children:r&&e.jsx(W,{framework:r})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(ls,{status:l})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-400 text-xs",children:is(f)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>N(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-blue-400 transition-colors",title:"Re-sync",children:e.jsx(ge,{size:14})}),e.jsx("button",{onClick:()=>T(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-red-400 transition-colors",title:"Unlink",children:e.jsx(J,{size:14})}),g&&e.jsx("button",{onClick:()=>{var B;return A(g,((B=n.mapping)==null?void 0:B.testName)||n.testName||"")},className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-brand-400 transition-colors",title:"View Script (new tab)",children:e.jsx(es,{size:14})})]})})]},w)})})]})})})]})}function xs({unmapped:t,unmappedLoading:i,searchUnmapped:o,setSearchUnmapped:j,selectedTestCaseId:b,setSelectedTestCaseId:S,explorerData:u,explorerLoading:C,expandedSuites:M,toggleSuiteExpand:R,onMap:T,mappingPending:N,mappedScripts:E}){const[$,A]=z.useState(!1),m=new Set,n=new Set,w=new Map;E.forEach(s=>{var f,y;const r=((f=s.mapping)==null?void 0:f.scriptPath)||s.scriptPath||"",l=((y=s.mapping)==null?void 0:y.testName)||s.testName||"";r&&(m.add(`${r}::${l}`.toLowerCase()),n.add(r.toLowerCase()),w.has(r.toLowerCase())||w.set(r.toLowerCase(),new Set),w.get(r.toLowerCase()).add(l.toLowerCase()))});const v=(u==null?void 0:u.suites)||[],p=(s,r)=>{if(m.has(`${s}::${r}`.toLowerCase()))return!0;const l=w.get(s.toLowerCase());if(!l)return!1;const f=v.find(h=>{var _;return((_=h.file)==null?void 0:_.toLowerCase())===s.toLowerCase()}),y=new Set(((f==null?void 0:f.tests)||[]).map(h=>(h.name||"").toLowerCase()));for(const h of l)if(h&&!y.has(h))return!0;return!1},c=v.map(s=>{const r=(s.tests||[]).filter(l=>$||!p(s.file,l.name));return{...s,tests:r,testCount:r.length}}).filter(s=>s.tests.length>0),g=v.reduce((s,r)=>s+(r.tests||[]).filter(l=>p(r.file,l.name)).length,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx(q,{className:"w-4 h-4 text-brand-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Map Test Cases to Scripts"}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:'Select a test case on the left, then click "Map" on a script on the right to create the mapping.'})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border ${t.length>0?"bg-amber-500/10 text-amber-300 border-amber-500/20":"bg-emerald-500/10 text-emerald-300 border-emerald-500/20"}`,children:t.length>0?`${t.length} unmapped`:"All mapped ✓"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",style:{minHeight:"60vh"},children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Unmapped Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:t.length})]})}),e.jsx("div",{className:"px-4 py-2 border-b border-white/5 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:s=>j(s.target.value),placeholder:"Search test cases...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading..."})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(H,{className:"w-8 h-8 text-emerald-400 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:o?"No unmapped test cases match your search.":"All test cases are mapped!"})]}):e.jsx("div",{className:"divide-y divide-white/5",children:t.map(s=>{const r=s.id||s.testCaseId,l=b===r;return e.jsx("button",{onClick:()=>S(l?null:r),className:`w-full text-left px-4 py-3 transition-colors ${l?"bg-brand-500/10 border-l-2 border-l-brand-500":"hover:bg-surface-2/50 border-l-2 border-l-transparent"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0",children:r}),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",title:s.title||"Untitled",children:s.title||"Untitled"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(se,{priority:s.priority||"medium"}),s.type&&e.jsx(cs,{type:s.type})]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 mt-0.5 shrink-0 transition-colors ${l?"border-brand-500 bg-brand-500":"border-white/20"}`,children:l&&e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white"})})})]})},r)})})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4 text-brand-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Available Scripts"}),c.length>0&&e.jsxs("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:[c.reduce((s,r)=>{var l;return s+(((l=r.tests)==null?void 0:l.length)||0)},0)," available"]})]}),g>0&&e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Show mapped"}),e.jsx("button",{role:"switch","aria-checked":$,onClick:()=>A(!$),className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${$?"bg-brand-500":"bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full bg-white transition-transform ${$?"translate-x-3.5":"translate-x-0.5"}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:C?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading scripts..."})]}):c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-gray-500 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:"No test scripts discovered yet."}),e.jsx("p",{className:"text-xs text-gray-500 text-center mt-1",children:"Run your test framework first so Testver can discover test suites, or use the Test Explorer to scan."})]}):e.jsx("div",{className:"divide-y divide-white/5",children:c.map((s,r)=>{const l=s.file||`suite-${r}`,f=M.has(l),y=s.tests||[];return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R(l),className:"w-full text-left px-4 py-3 hover:bg-surface-2/50 transition-colors flex items-center gap-2",children:[f?e.jsx(fe,{size:14,className:"text-gray-400 shrink-0"}):e.jsx(ss,{size:14,className:"text-gray-400 shrink-0"}),e.jsx(oe,{size:14,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200 truncate",title:s.name||s.file,children:s.name?D(s.name):s.file}),e.jsx("div",{className:"text-xs text-gray-500 font-mono truncate mt-0.5",children:s.file})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(W,{framework:s.framework||"unknown"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[s.testCount||y.length," test",(s.testCount||y.length)!==1?"s":""]})]})]}),f&&y.length>0&&e.jsx("div",{className:"bg-surface-0/50",children:y.map((h,_)=>{const L=p(s.file,h.name);return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 pl-10 border-t border-white/5 transition-colors ${L?"bg-emerald-500/[0.03] opacity-60":"hover:bg-surface-2/30"}`,children:[e.jsx(ts,{size:12,className:L?"text-emerald-500 shrink-0":"text-gray-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm truncate ${L?"text-gray-400":"text-gray-300"}`,title:h.name,children:D(h.name)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(W,{framework:h.framework||s.framework||"unknown"}),e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate",children:je(s.file,30)})]})]}),L&&!b?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20 shrink-0",children:[e.jsx(H,{size:10})," Mapped"]}):L&&b?e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20",children:[e.jsx(H,{size:9})," Mapped"]}),e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1 bg-amber-600 hover:bg-amber-500 text-white rounded-lg px-2.5 py-1 text-[10px] font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:10,className:"animate-spin"}):e.jsx(I,{size:10}),"Map Also"]})]}):b?e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition-colors shrink-0 disabled:opacity-50",children:[N?e.jsx(F,{size:12,className:"animate-spin"}):e.jsx(I,{size:12}),"Map"]}):e.jsx("span",{className:"text-xs text-gray-500 italic shrink-0",children:"Select a test case first"})]},`${l}-${_}`)})})]},l)})})})]})]})]})}export{js as ScriptMappingPage};
1
+ import{r as z,j as e}from"./vendor-react-DOVfxdUy.js";import{u as Ue}from"./useTabParam-CyYAP90W.js";import{b as Ae,D as Pe}from"./index-D6sQYc_0.js";import{C as Ee}from"./ConfirmDialog-DtotgVmI.js";import{aa as Fe,ab as Ie,ac as Be,F as Oe,ad as He,ae as qe,af as Ve,ag as Ge}from"./useTestManagement-DW6AW2mt.js";import{u as Ye}from"./vendor-query-DkZSMtfn.js";import{f as D}from"./formatTestName-BKd2Uqhs.js";import{cv as q,b as De,f as I,a0 as F,T as Z,cf as J,aC as Je,cm as Ke,r as H,o as me,ap as pe,I as Qe,al as Xe,aI as he,Z as Ze,R as ge,v as ue,X as be,bO as We,y as fe,ag as X,_ as es,dj as oe,t as ss,aJ as ts,b1 as as}from"./vendor-icons-D_Dmmj8d.js";const rs={critical:"bg-red-500/20 text-red-300",high:"bg-orange-500/20 text-orange-300",medium:"bg-amber-500/20 text-amber-300",low:"bg-emerald-500/20 text-emerald-300"},ns={functional:"bg-sky-500/20 text-sky-300",regression:"bg-violet-500/20 text-violet-300",smoke:"bg-amber-500/20 text-amber-300",integration:"bg-teal-500/20 text-teal-300",e2e:"bg-indigo-500/20 text-indigo-300",api:"bg-cyan-500/20 text-cyan-300",performance:"bg-rose-500/20 text-rose-300",security:"bg-red-500/20 text-red-300"},xe={playwright:"bg-green-500/20 text-green-300",jest:"bg-red-500/20 text-red-300",cypress:"bg-teal-500/20 text-teal-300",mocha:"bg-amber-500/20 text-amber-300",vitest:"bg-yellow-500/20 text-yellow-300",cucumber:"bg-emerald-500/20 text-emerald-300",pytest:"bg-blue-500/20 text-blue-300",junit:"bg-orange-500/20 text-orange-300",testng:"bg-violet-500/20 text-violet-300",nunit:"bg-purple-500/20 text-purple-300",xunit:"bg-indigo-500/20 text-indigo-300",mstest:"bg-sky-500/20 text-sky-300",rspec:"bg-rose-500/20 text-rose-300",robot:"bg-cyan-500/20 text-cyan-300",unknown:"bg-gray-500/20 text-gray-300"},Y={synced:"bg-emerald-500",script_updated:"bg-amber-500",script_missing:"bg-red-500",case_updated:"bg-blue-500"};function is(t){if(!t)return"Never";const i=Date.now()-t,o=Math.floor(i/6e4);if(o<1)return"Just now";if(o<60)return`${o}m ago`;const j=Math.floor(o/60);return j<24?`${j}h ago`:`${Math.floor(j/24)}d ago`}function ye(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function je(t,i=40){if(t.length<=i)return t;const o=t.split("/");return o.length<=2?"..."+t.slice(-i):o[0]+"/.../"+o.slice(-2).join("/")}const ee=t=>{var i;return((i=t==null?void 0:t.mapping)==null?void 0:i.syncStatus)||(t==null?void 0:t.syncStatus)||"synced"};function ls({status:t}){const i={synced:{icon:H,label:"Synced",color:"text-emerald-400 bg-emerald-500/15"},script_updated:{icon:me,label:"Script Updated",color:"text-amber-400 bg-amber-500/15"},script_missing:{icon:pe,label:"Script Missing",color:"text-red-400 bg-red-500/15"},case_updated:{icon:q,label:"Case Updated",color:"text-blue-400 bg-blue-500/15"},not_mapped:{icon:as,label:"Not Mapped",color:"text-gray-400 bg-gray-500/15"}},o=i[t]||i.not_mapped,j=o.icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${o.color}`,children:[e.jsx(j,{size:12}),o.label]})}function se({priority:t}){const i=rs[t]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:ye(t)})}function cs({type:t}){const i=ns[t]||"bg-gray-500/20 text-gray-300";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:ye(t)})}function W({framework:t}){const i=xe[t]||xe.unknown;return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${i}`,children:t})}function js(){var le;const[t,i]=Ue("tab",["dashboard","mapped","map"],"dashboard"),[o,j]=z.useState(""),[b,S]=z.useState(""),[u,C]=z.useState(""),[M,R]=z.useState(null),[T,N]=z.useState(new Set),[E,$]=z.useState(new Set),{toast:A}=Ae(),[m,n]=z.useState(null),{data:w,isLoading:v}=Fe(),{data:p,isLoading:c}=Ie(),{data:g,isLoading:s}=Be(),{data:r}=Oe(),{data:l,isLoading:f}=Ye({queryKey:["test-explorer"],queryFn:Pe}),y=He(),h=qe(),_=Ve(),L=Ge(),k=w||{},P=Array.isArray(p)?p:(p==null?void 0:p.testCases)||(p==null?void 0:p.mappings)||[],B=Array.isArray(g)?g:(g==null?void 0:g.testCases)||[],V=k.totalTestCases??((le=r==null?void 0:r.testCases)==null?void 0:le.length)??(r==null?void 0:r.length)??0,K=k.syncedCount??0,te=k.scriptUpdatedCount??0,ae=k.scriptMissingCount??0,re=k.caseUpdatedCount??0,G=k.mappedCount??P.length??0,Ne=k.unmappedCount??Math.max(0,V-G),ne=k.totalMappings??K+te+ae+re,ve=k.syncHealthPercentage??(ne>0?Math.round(K/ne*100):0),we=k.mappingPercentage??(V>0?Math.round(G/V*100):0),Q=z.useMemo(()=>{let a=[...P];if(o){const d=o.toLowerCase();a=a.filter(x=>{var O,ce,de;return(x.title||((O=x.testCase)==null?void 0:O.title)||"").toLowerCase().includes(d)||(x.scriptPath||((ce=x.mapping)==null?void 0:ce.scriptPath)||"").toLowerCase().includes(d)||(x.testName||((de=x.mapping)==null?void 0:de.testName)||"").toLowerCase().includes(d)})}return u&&(a=a.filter(d=>ee(d)===u)),a},[P,o,u]),ke=z.useMemo(()=>{if(!b)return B;const a=b.toLowerCase();return B.filter(d=>(d.title||"").toLowerCase().includes(a)||(d.id||"").toLowerCase().includes(a))},[B,b]);function U(a){A("success",a)}function Se(a){$(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Ce(a){N(d=>{const x=new Set(d);return x.has(a)?x.delete(a):x.add(a),x})}function Me(){T.size===Q.length?N(new Set):N(new Set(Q.map(a=>a.testCaseId||a.id)))}function ie(a){a.length>0&&n(a)}async function Te(a){n(null);try{await h.mutateAsync(a),N(new Set),U(`Unlinked ${a.length} mapping(s)`)}catch(d){A("error",d.message||"Failed to unlink")}}async function $e(a){const d=a.testCaseId||a.id;try{await L.mutateAsync({testCaseId:d,syncStatus:"synced"}),U("Marked as synced")}catch(x){U(`Error: ${x.message||"Failed to sync"}`)}}async function Le(a,d,x){try{await y.mutateAsync([{testCaseId:a,scriptPath:d.file,testName:x.name,suite:x.suite||d.name,framework:x.framework||d.framework}]),R(null),U(`Mapped successfully to "${x.name}"`)}catch(O){U(`Error: ${O.message||"Failed to map"}`)}}async function ze(){try{await _.mutateAsync(),U("Sync check completed")}catch(a){U(`Error: ${a.message||"Sync check failed"}`)}}async function _e(){const a=Array.from(T);try{for(const d of a)await L.mutateAsync({testCaseId:d,syncStatus:"synced"});N(new Set),U(`Marked ${a.length} as synced`)}catch(d){U(`Error: ${d.message||"Failed to mark synced"}`)}}const Re=[{id:"dashboard",label:"Dashboard",icon:De},{id:"mapped",label:"Mapped Test Cases",icon:I},{id:"map",label:"Map Test Cases",icon:q}];return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[m&&e.jsx(Ee,{open:!0,title:"Remove mapping?",description:`Remove the script mapping for ${m.length} test case${m.length===1?"":"s"}? This unlinks the script — it doesn't delete the test case or the script.`,confirmLabel:"Remove",onConfirm:()=>Te(m),onCancel:()=>n(null)}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(q,{size:24,className:"text-brand-300"}),"Script Mapping & Sync"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Link test cases to automation scripts and monitor sync health"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{className:"max-w-[1400px] mx-auto px-6 flex gap-1",children:Re.map(a=>{const d=a.icon,x=t===a.id;return e.jsxs("button",{onClick:()=>i(a.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${x?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[e.jsx(d,{size:14}),a.label]},a.id)})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8",children:[t==="dashboard"&&e.jsx(ds,{totalTestCases:V,totalMapped:G,totalUnmapped:Ne,mappingPercentage:we,syncHealth:ve,syncedCount:K,scriptUpdatedCount:te,scriptMissingCount:ae,caseUpdatedCount:re,isLoading:v,onCheckSync:ze,checkSyncPending:_.isPending,onGoToMap:()=>i("mapped"),onGoToUnmapped:()=>i("map"),mappedItems:P}),t==="mapped"&&e.jsx(os,{items:Q,isLoading:c,searchMapped:o,setSearchMapped:j,syncStatusFilter:u,setSyncStatusFilter:C,selectedMappedIds:T,toggleMappedSelection:Ce,selectAllMapped:Me,totalMapped:G,onUnlink:a=>ie([a.testCaseId||a.id]),onResync:$e,onBulkUnlink:()=>ie(Array.from(T)),onBulkMarkSynced:_e,onViewScript:(a,d)=>{const x=a.replace(/\\/g,"/"),O=`/tests?file=${encodeURIComponent(x)}&test=${encodeURIComponent(d)}`;window.open(O,"_blank","noopener")}}),t==="map"&&e.jsx(xs,{unmapped:ke,unmappedLoading:s,searchUnmapped:b,setSearchUnmapped:S,selectedTestCaseId:M,setSelectedTestCaseId:R,explorerData:l,explorerLoading:f,expandedSuites:E,toggleSuiteExpand:Se,onMap:Le,mappingPending:y.isPending,mappedScripts:P})]})]})}function ds({totalTestCases:t,totalMapped:i,totalUnmapped:o,mappingPercentage:j,syncHealth:b,syncedCount:S,scriptUpdatedCount:u,scriptMissingCount:C,caseUpdatedCount:M,isLoading:R,onCheckSync:T,checkSyncPending:N,onGoToMap:E,onGoToUnmapped:$,mappedItems:A}){const[m,n]=z.useState(null),w=j??(t>0?Math.round(i/t*100):0),v=S+u+C+M,p={synced:[],script_updated:[],script_missing:[],case_updated:[]};for(const c of A){const g=ee(c);p[g]&&p[g].push(c)}return R?e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx(F,{className:"w-6 h-6 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400",children:"Loading dashboard..."})]}):e.jsxs("div",{className:"space-y-6 max-w-6xl",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/15 flex items-center justify-center",children:e.jsx(Z,{className:"w-5 h-5 text-blue-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:t}),e.jsx("div",{className:"text-xs text-gray-400",children:"Total Test Cases"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-emerald-500/15 flex items-center justify-center",children:e.jsx(I,{className:"w-5 h-5 text-emerald-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[i,e.jsxs("span",{className:"text-sm font-normal text-emerald-400 ml-1.5",children:[w,"%"]})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Mapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-amber-500/15 flex items-center justify-center",children:e.jsx(J,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-gray-100",children:o}),e.jsx("div",{className:"text-xs text-gray-400",children:"Unmapped"})]})]})}),e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-cyan-500/15 flex items-center justify-center",children:e.jsx(Je,{className:"w-5 h-5 text-cyan-400"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-2xl font-bold text-gray-100",children:[b,e.jsx("span",{className:"text-sm font-normal text-cyan-400 ml-0.5",children:"%"})]}),e.jsx("div",{className:"text-xs text-gray-400",children:"Sync Health"})]})]})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-4 flex items-center gap-2",children:[e.jsx(Ke,{className:"w-4 h-4 text-brand-400"}),"Sync Status Breakdown"]}),v>0?e.jsxs("div",{className:"w-full h-3 rounded-full bg-surface-2 overflow-hidden flex mb-4",children:[S>0&&e.jsx("div",{className:`${Y.synced} h-full transition-all`,style:{width:`${S/v*100}%`},title:`Synced: ${S}`}),u>0&&e.jsx("div",{className:`${Y.script_updated} h-full transition-all`,style:{width:`${u/v*100}%`},title:`Script Updated: ${u}`}),C>0&&e.jsx("div",{className:`${Y.script_missing} h-full transition-all`,style:{width:`${C/v*100}%`},title:`Script Missing: ${C}`}),M>0&&e.jsx("div",{className:`${Y.case_updated} h-full transition-all`,style:{width:`${M/v*100}%`},title:`Case Updated: ${M}`})]}):e.jsx("div",{className:"w-full h-3 rounded-full bg-surface-2 mb-4"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{key:"synced",label:"Synced",count:S,icon:H,color:"text-emerald-400",desc:"Test case and script file are in sync. No action needed."},{key:"script_updated",label:"Script Updated",count:u,icon:me,color:"text-amber-400",desc:"The automation script file was modified on disk after mapping. Review the test case to ensure it still matches the script."},{key:"script_missing",label:"Script Missing",count:C,icon:pe,color:"text-red-400",desc:"The mapped script file was deleted or moved. Re-map the test case to a valid script file."},{key:"case_updated",label:"Case Updated",count:M,icon:q,color:"text-blue-400",desc:"The test case was edited after mapping. The automation script may need to be updated to reflect the changes."}].map(c=>{const g=c.icon,s=m===c.key;return e.jsx("div",{className:"relative group/card",children:e.jsxs("button",{onClick:()=>n(s?null:c.key),className:`w-full bg-surface-2 rounded-lg border p-3 flex items-center gap-2 text-left transition-colors ${s?"border-brand-500/40 ring-1 ring-brand-500/20":"border-white/5 hover:border-white/10"}`,children:[e.jsx(g,{size:16,className:`${c.color} shrink-0`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-lg font-semibold text-gray-100",children:c.count}),e.jsx("div",{className:"text-xs text-gray-400",children:c.label})]}),e.jsxs("span",{className:"relative group/info shrink-0",children:[e.jsx(Qe,{size:12,className:"text-gray-600 hover:text-gray-300 transition-colors cursor-help"}),e.jsxs("span",{className:"absolute z-20 bottom-full right-0 mb-2 w-56 px-3 py-2.5 rounded-lg bg-gray-900 border border-white/10 shadow-xl text-[11px] text-gray-300 leading-relaxed opacity-0 invisible group-hover/info:opacity-100 group-hover/info:visible transition-all pointer-events-none",children:[e.jsxs("span",{className:"font-medium text-gray-100 mb-1 flex items-center gap-1.5",children:[e.jsx(g,{size:11,className:c.color})," ",c.label]}),c.desc,e.jsx("span",{className:"absolute top-full right-4 -mt-px w-2 h-2 bg-gray-900 border-r border-b border-white/10 rotate-45"})]})]})]})},c.key)})}),m&&p[m]&&e.jsxs("div",{className:"mt-4 bg-surface-2 rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-white/5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider",children:m==="synced"?"Synced Mappings":m==="script_updated"?"Scripts Changed on Disk":m==="script_missing"?"Missing Script Files":"Test Cases Updated After Mapping"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[p[m].length," item",p[m].length!==1?"s":""]})]}),p[m].length===0?e.jsx("div",{className:"px-4 py-6 text-center text-sm text-gray-500",children:"No items in this category"}):e.jsx("div",{className:"divide-y divide-white/5 max-h-[300px] overflow-y-auto",children:p[m].map((c,g)=>{const s=c,r=c.mapping||{},l=r.scriptPath||c.scriptPath||"",f=r.testName||c.testName||"",y=s.title||s.name||"Untitled",h=r.lastSynced||r.last_synced;return e.jsx("div",{className:"px-4 py-3 hover:bg-white/[0.02] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Z,{size:12,className:"text-brand-400 shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200 font-medium truncate",children:y}),s.priority&&e.jsx(se,{priority:s.priority})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-5",children:[e.jsx(Xe,{size:10,className:"text-gray-600 shrink-0"}),e.jsx(he,{size:11,className:"text-gray-500 shrink-0"}),e.jsx("span",{className:"text-xs font-mono text-gray-400 truncate",children:l||"No script path"}),f&&e.jsx("span",{className:"text-[10px] text-gray-500 bg-surface-1 px-1.5 py-0.5 rounded shrink-0",title:f,children:D(f)})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[m==="case_updated"&&e.jsx("span",{className:"text-[10px] text-blue-400",children:"Test case was modified after last sync"}),m==="script_updated"&&e.jsx("span",{className:"text-[10px] text-amber-400",children:"Script file changed on disk"}),m==="script_missing"&&e.jsxs("span",{className:"text-[10px] text-red-400",children:["File not found: ",l.split("/").pop()]}),h&&e.jsxs("div",{className:"text-[10px] text-gray-500 mt-0.5",children:["Last synced: ",new Date(h).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]})},c.id||g)})})]})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-200 mb-3 flex items-center gap-2",children:[e.jsx(Ze,{className:"w-4 h-4 text-brand-400"}),"Quick Actions"]}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("button",{onClick:T,disabled:N,className:"inline-flex items-center gap-2 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:16,className:"animate-spin"}):e.jsx(ge,{size:16}),"Check Sync Status"]}),e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(I,{size:16}),"View Mapped Test Cases"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-2 bg-surface-2 hover:bg-surface-1 text-gray-300 rounded-lg px-4 py-2 text-sm font-medium transition-colors border border-white/5",children:[e.jsx(J,{size:16}),"View Unmapped Test Cases"]})]})]})]})}function os({items:t,isLoading:i,searchMapped:o,setSearchMapped:j,syncStatusFilter:b,setSyncStatusFilter:S,selectedMappedIds:u,toggleMappedSelection:C,selectAllMapped:M,totalMapped:R,onUnlink:T,onResync:N,onBulkUnlink:E,onBulkMarkSynced:$,onViewScript:A}){const m=t.length>0&&u.size===t.length;return e.jsxs("div",{className:"space-y-4 max-w-full",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4 text-emerald-400"}),e.jsxs("span",{className:"text-sm font-medium text-gray-200",children:[R," mapped test case",R!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:n=>j(n.target.value),placeholder:"Search mapped cases...",className:"bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50 w-56"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(We,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"}),e.jsxs("select",{value:b,onChange:n=>S(n.target.value),className:"appearance-none bg-surface-2 border border-white/10 rounded-lg pl-8 pr-8 py-1.5 text-sm text-gray-200 focus:outline-none focus:border-brand-500/50 cursor-pointer",children:[e.jsx("option",{value:"",children:"All Statuses"}),e.jsx("option",{value:"synced",children:"Synced"}),e.jsx("option",{value:"script_updated",children:"Script Updated"}),e.jsx("option",{value:"script_missing",children:"Script Missing"}),e.jsx("option",{value:"case_updated",children:"Case Updated"})]}),e.jsx(fe,{size:14,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none"})]})]})]}),u.size>0&&e.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/20 rounded-lg px-4 py-2.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-brand-300 font-medium",children:[u.size," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:E,className:"inline-flex items-center gap-1.5 bg-red-500/15 hover:bg-red-500/25 text-red-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(J,{size:12}),"Unlink Selected"]}),e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-1.5 bg-emerald-500/15 hover:bg-emerald-500/25 text-emerald-300 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors",children:[e.jsx(X,{size:12}),"Mark Synced"]})]})]}),i?e.jsxs("div",{className:"flex items-center justify-center py-16",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading mapped cases..."})]}):t.length===0?e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-12 text-center",children:[e.jsx(I,{className:"w-8 h-8 text-gray-500 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-400",children:o||b?"No mapped test cases match your filters.":'No mapped test cases yet. Go to "Map Test Cases" to create mappings.'})]}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-gray-400 text-xs uppercase tracking-wider",children:[e.jsx("th",{className:"px-3 py-3 text-left w-10",children:e.jsx("button",{onClick:M,className:"w-4 h-4 rounded border border-white/20 flex items-center justify-center hover:border-brand-400 transition-colors",children:m&&e.jsx(X,{size:10,className:"text-brand-400"})})}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Case"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Priority"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Script Path"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Test Name"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Framework"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Sync Status"}),e.jsx("th",{className:"px-3 py-3 text-left",children:"Last Synced"}),e.jsx("th",{className:"px-3 py-3 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:t.map(n=>{var y,h,_,L,k,P;const w=n.testCaseId||n.id,v=u.has(w),p=n.title||((y=n.testCase)==null?void 0:y.title)||"Untitled",c=n.priority||((h=n.testCase)==null?void 0:h.priority)||"medium",g=n.scriptPath||((_=n.mapping)==null?void 0:_.scriptPath)||"",s=n.testName||((L=n.mapping)==null?void 0:L.testName)||"",r=n.framework||((k=n.mapping)==null?void 0:k.framework)||"",l=ee(n),f=n.lastSynced||((P=n.mapping)==null?void 0:P.lastSynced)||null;return e.jsxs("tr",{className:`hover:bg-surface-2/50 transition-colors ${v?"bg-brand-500/5":""}`,children:[e.jsx("td",{className:"px-3 py-3",children:e.jsx("button",{onClick:()=>C(w),className:`w-4 h-4 rounded border flex items-center justify-center transition-colors ${v?"bg-brand-600 border-brand-500":"border-white/20 hover:border-brand-400"}`,children:v&&e.jsx(X,{size:10,className:"text-white"})})}),e.jsx("td",{className:"px-3 py-3 align-top",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0 mt-0.5",children:w}),e.jsx("span",{className:"text-gray-200 font-medium break-words",children:p})]})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(se,{priority:c})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs font-mono cursor-help",title:g,children:je(g)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-300 text-xs",title:s,children:D(s)})}),e.jsx("td",{className:"px-3 py-3",children:r&&e.jsx(W,{framework:r})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(ls,{status:l})}),e.jsx("td",{className:"px-3 py-3",children:e.jsx("span",{className:"text-gray-400 text-xs",children:is(f)})}),e.jsx("td",{className:"px-3 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>N(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-blue-400 transition-colors",title:"Re-sync",children:e.jsx(ge,{size:14})}),e.jsx("button",{onClick:()=>T(n),className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-red-400 transition-colors",title:"Unlink",children:e.jsx(J,{size:14})}),g&&e.jsx("button",{onClick:()=>{var B;return A(g,((B=n.mapping)==null?void 0:B.testName)||n.testName||"")},className:"p-1.5 rounded-md hover:bg-surface-2 text-gray-400 hover:text-brand-400 transition-colors",title:"View Script (new tab)",children:e.jsx(es,{size:14})})]})})]},w)})})]})})})]})}function xs({unmapped:t,unmappedLoading:i,searchUnmapped:o,setSearchUnmapped:j,selectedTestCaseId:b,setSelectedTestCaseId:S,explorerData:u,explorerLoading:C,expandedSuites:M,toggleSuiteExpand:R,onMap:T,mappingPending:N,mappedScripts:E}){const[$,A]=z.useState(!1),m=new Set,n=new Set,w=new Map;E.forEach(s=>{var f,y;const r=((f=s.mapping)==null?void 0:f.scriptPath)||s.scriptPath||"",l=((y=s.mapping)==null?void 0:y.testName)||s.testName||"";r&&(m.add(`${r}::${l}`.toLowerCase()),n.add(r.toLowerCase()),w.has(r.toLowerCase())||w.set(r.toLowerCase(),new Set),w.get(r.toLowerCase()).add(l.toLowerCase()))});const v=(u==null?void 0:u.suites)||[],p=(s,r)=>{if(m.has(`${s}::${r}`.toLowerCase()))return!0;const l=w.get(s.toLowerCase());if(!l)return!1;const f=v.find(h=>{var _;return((_=h.file)==null?void 0:_.toLowerCase())===s.toLowerCase()}),y=new Set(((f==null?void 0:f.tests)||[]).map(h=>(h.name||"").toLowerCase()));for(const h of l)if(h&&!y.has(h))return!0;return!1},c=v.map(s=>{const r=(s.tests||[]).filter(l=>$||!p(s.file,l.name));return{...s,tests:r,testCount:r.length}}).filter(s=>s.tests.length>0),g=v.reduce((s,r)=>s+(r.tests||[]).filter(l=>p(r.file,l.name)).length,0);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx(q,{className:"w-4 h-4 text-brand-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-200",children:"Map Test Cases to Scripts"}),e.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:'Select a test case on the left, then click "Map" on a script on the right to create the mapping.'})]}),e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full border ${t.length>0?"bg-amber-500/10 text-amber-300 border-amber-500/20":"bg-emerald-500/10 text-emerald-300 border-emerald-500/20"}`,children:t.length>0?`${t.length} unmapped`:"All mapped ✓"})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",style:{minHeight:"60vh"},children:[e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Unmapped Test Cases"}),e.jsx("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:t.length})]})}),e.jsx("div",{className:"px-4 py-2 border-b border-white/5 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(ue,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",value:o,onChange:s=>j(s.target.value),placeholder:"Search test cases...",className:"w-full bg-surface-2 border border-white/10 rounded-lg pl-8 pr-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:border-brand-500/50"}),o&&e.jsx("button",{onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-200",children:e.jsx(be,{size:12})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading..."})]}):t.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(H,{className:"w-8 h-8 text-emerald-400 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:o?"No unmapped test cases match your search.":"All test cases are mapped!"})]}):e.jsx("div",{className:"divide-y divide-white/5",children:t.map(s=>{const r=s.id||s.testCaseId,l=b===r;return e.jsx("button",{onClick:()=>S(l?null:r),className:`w-full text-left px-4 py-3 transition-colors ${l?"bg-brand-500/10 border-l-2 border-l-brand-500":"hover:bg-surface-2/50 border-l-2 border-l-transparent"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs font-mono text-brand-300 shrink-0",children:r}),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",title:s.title||"Untitled",children:s.title||"Untitled"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsx(se,{priority:s.priority||"medium"}),s.type&&e.jsx(cs,{type:s.type})]})]}),e.jsx("div",{className:`w-4 h-4 rounded-full border-2 mt-0.5 shrink-0 transition-colors ${l?"border-brand-500 bg-brand-500":"border-white/20"}`,children:l&&e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-white"})})})]})},r)})})})]}),e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-white/5 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-4 h-4 text-brand-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:"Available Scripts"}),c.length>0&&e.jsxs("span",{className:"text-xs text-gray-500 bg-surface-2 px-2 py-0.5 rounded-full",children:[c.reduce((s,r)=>{var l;return s+(((l=r.tests)==null?void 0:l.length)||0)},0)," available"]})]}),g>0&&e.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:"Show mapped"}),e.jsx("button",{role:"switch","aria-checked":$,onClick:()=>A(!$),className:`relative inline-flex h-4 w-7 items-center rounded-full transition-colors ${$?"bg-brand-500":"bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full bg-white transition-transform ${$?"translate-x-3.5":"translate-x-0.5"}`})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:C?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(F,{className:"w-5 h-5 text-brand-400 animate-spin"}),e.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"Loading scripts..."})]}):c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4",children:[e.jsx(oe,{className:"w-8 h-8 text-gray-500 mb-2"}),e.jsx("p",{className:"text-sm text-gray-400 text-center",children:"No test scripts discovered yet."}),e.jsx("p",{className:"text-xs text-gray-500 text-center mt-1",children:"Run your test framework first so Testver can discover test suites, or use the Test Explorer to scan."})]}):e.jsx("div",{className:"divide-y divide-white/5",children:c.map((s,r)=>{const l=s.file||`suite-${r}`,f=M.has(l),y=s.tests||[];return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>R(l),className:"w-full text-left px-4 py-3 hover:bg-surface-2/50 transition-colors flex items-center gap-2",children:[f?e.jsx(fe,{size:14,className:"text-gray-400 shrink-0"}):e.jsx(ss,{size:14,className:"text-gray-400 shrink-0"}),e.jsx(oe,{size:14,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-200 truncate",title:s.name||s.file,children:s.name?D(s.name):s.file}),e.jsx("div",{className:"text-xs text-gray-500 font-mono truncate mt-0.5",children:s.file})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(W,{framework:s.framework||"unknown"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[s.testCount||y.length," test",(s.testCount||y.length)!==1?"s":""]})]})]}),f&&y.length>0&&e.jsx("div",{className:"bg-surface-0/50",children:y.map((h,_)=>{const L=p(s.file,h.name);return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 pl-10 border-t border-white/5 transition-colors ${L?"bg-emerald-500/[0.03] opacity-60":"hover:bg-surface-2/30"}`,children:[e.jsx(ts,{size:12,className:L?"text-emerald-500 shrink-0":"text-gray-500 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-sm truncate ${L?"text-gray-400":"text-gray-300"}`,title:h.name,children:D(h.name)}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(W,{framework:h.framework||s.framework||"unknown"}),e.jsx("span",{className:"text-xs text-gray-500 font-mono truncate",children:je(s.file,30)})]})]}),L&&!b?e.jsxs("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20 shrink-0",children:[e.jsx(H,{size:10})," Mapped"]}):L&&b?e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-emerald-500/15 text-emerald-400 border border-emerald-500/20",children:[e.jsx(H,{size:9})," Mapped"]}),e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1 bg-amber-600 hover:bg-amber-500 text-white rounded-lg px-2.5 py-1 text-[10px] font-medium transition-colors disabled:opacity-50",children:[N?e.jsx(F,{size:10,className:"animate-spin"}):e.jsx(I,{size:10}),"Map Also"]})]}):b?e.jsxs("button",{onClick:()=>T(b,s,h),disabled:N,className:"inline-flex items-center gap-1.5 bg-brand-600 hover:bg-brand-500 text-white rounded-lg px-3 py-1.5 text-xs font-medium transition-colors shrink-0 disabled:opacity-50",children:[N?e.jsx(F,{size:12,className:"animate-spin"}):e.jsx(I,{size:12}),"Map"]}):e.jsx("span",{className:"text-xs text-gray-500 italic shrink-0",children:"Select a test case first"})]},`${l}-${_}`)})})]},l)})})})]})]})]})}export{js as ScriptMappingPage};