@testver/testver 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +3 -1
  2. package/bin/testver.js +1 -1
  3. package/dist/index.js +770 -391
  4. package/package.json +2 -1
  5. package/src/ui/static/assets/{AIPanel-D09Ni3a4.js → AIPanel-B_R-CbrF.js} +2 -2
  6. package/src/ui/static/assets/{AIRecordPanel-DZtUZnRe.js → AIRecordPanel-BRQWIU5h.js} +3 -3
  7. package/src/ui/static/assets/{AIStreamUI-BsxKziYG.js → AIStreamUI-C3D989_6.js} +3 -3
  8. package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-D3t2gPAA.js} +5 -5
  9. package/src/ui/static/assets/{APITestingPage-Cdc8EZz2.js → APITestingPage-Cmwkiiys.js} +1 -1
  10. package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CjEqKB-q.js} +1 -1
  11. package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +3 -0
  12. package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-64mYNK2v.js} +1 -1
  13. package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BQjOzQje.js} +1 -1
  14. package/src/ui/static/assets/{ChangesSummary-C-7oi_sx.js → ChangesSummary-CY_Vb27i.js} +2 -2
  15. package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-B1ezmnlE.js} +3 -3
  16. package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-t7mpeeSN.js} +1 -1
  17. package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-YMmCbiBk.js} +2 -2
  18. package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-Nk-K-_8I.js} +1 -1
  19. package/src/ui/static/assets/Dashboard-BDVxO2V4.js +1 -0
  20. package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-l8yGeCyR.js} +1 -1
  21. package/src/ui/static/assets/{DiffViewer-DPglzjPH.js → DiffViewer-BIU09a_i.js} +1 -1
  22. package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-D1T3JWUr.js} +1 -1
  23. package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-Dt5RhL-h.js} +1 -1
  24. package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-CrKgh_cB.js} +5 -5
  25. package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-_4nCEzkJ.js} +5 -5
  26. package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-BcR7IQi9.js} +1 -1
  27. package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-C2sP4_4h.js} +1 -1
  28. package/src/ui/static/assets/KpiTile-inmeEsy3.js +1 -0
  29. package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-D5BRe9jq.js} +1 -1
  30. package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-C5n6sHYi.js} +1 -1
  31. package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-0h-N2c6d.js} +1 -1
  32. package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-Bo_xekig.js} +1 -1
  33. package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-VGcmK167.js} +1 -1
  34. package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-B_1nPPxE.js} +1 -1
  35. package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +1 -0
  36. package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-y7tJNNFd.js} +1 -1
  37. package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-DbfGhRq0.js} +1 -1
  38. package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-WuRKtx_h.js} +1 -1
  39. package/src/ui/static/assets/ReportCard-G52Q6-2i.js +2 -0
  40. package/src/ui/static/assets/ReportFullView-Bt8UFP2J.js +1 -0
  41. package/src/ui/static/assets/ReportsPage-DMtDi73Q.js +48 -0
  42. package/src/ui/static/assets/ResultsPage-BI9jpK2N.js +115 -0
  43. package/src/ui/static/assets/RunState-ifC4zi6M.js +1 -0
  44. package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-C7vpCbck.js} +1 -1
  45. package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-7vHuvhQw.js} +1 -1
  46. package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-BYxYJNWl.js} +1 -1
  47. package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-DSISg7r7.js} +1 -1
  48. package/src/ui/static/assets/SharedReportView-BOqKGJmR.js +1 -0
  49. package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-CgqtYGBi.js} +1 -1
  50. package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +7 -0
  51. package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-wqYTKP7W.js} +2 -2
  52. package/src/ui/static/assets/TestPlansPage-DOKX9p6z.js +5 -0
  53. package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-DpMzl3h7.js} +1 -1
  54. package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-BxS0zi-p.js} +1 -1
  55. package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-B5d0uDU_.js} +2 -2
  56. package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-Bk0DFnFS.js} +17 -17
  57. package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-CdhhNa5G.js} +1 -1
  58. package/src/ui/static/assets/index-BYVxKLrT.js +47 -0
  59. package/src/ui/static/assets/index-C2KJt7SI.css +1 -0
  60. package/src/ui/static/assets/reportMeta-AKcU_qwq.js +1 -0
  61. package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DNkIctil.js} +1 -1
  62. package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-D5ysBBvz.js} +1 -1
  63. package/src/ui/static/assets/{useOwnership-eW6Egd7X.js → useOwnership-U0AfKBRo.js} +1 -1
  64. package/src/ui/static/assets/{useSuites-CvtMGakZ.js → useSuites-DyfN9HVv.js} +1 -1
  65. package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-DT8frjCK.js} +1 -1
  66. package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-OcwQaB1s.js} +1 -1
  67. package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-Xm4Bcx3u.js} +2 -2
  68. package/src/ui/static/assets/useTestResults-D5EwGIX9.js +1 -0
  69. package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-BKPiFyYV.js} +1 -1
  70. package/src/ui/static/index.html +3 -3
  71. package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
  72. package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
  73. package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
  74. package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
  75. package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
  76. package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
  77. package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
  78. package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
  79. package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
  80. package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
  81. package/src/ui/static/assets/index-B0klHYbO.css +0 -1
  82. package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
  83. package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
@@ -1 +0,0 @@
1
- import{j as e,r as l}from"./vendor-react-CTbHBddL.js";import{a as it,u as K}from"./vendor-query-BrzmPFT3.js";import{a8 as ot,cL as ct,cM as dt,cN as xt,ck as mt,cO as ht,cP as Ze,cQ as ut,cR as pt,cS as gt,cT as bt,cU as Qe,cV as yt,cW as ft,cX as vt,cY as jt,cZ as Nt,c_ as wt,c$ as kt}from"./index-DtBWNlVD.js";import{C as Te}from"./ConfirmDialog-DNU3qoAP.js";import{u as Ct,T as De}from"./RunTargets-C7Vqd4TU.js";import{u as St,b as It,a as Se}from"./useTabParam-ChbOedP1.js";import{G as Le,X as $e,a3 as V,cn as He,av as Tt,b6 as Ye,o as Ae,aK as Re,b8 as zt,b9 as Et,ac as Ge,a$ as Rt,cE as ue,v as Fe,R as Pt,cF as $t,_ as Je,a5 as At,cG as Mt,ak as Ie,al as Oe}from"./vendor-icons-B0wLOBoh.js";const Lt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%232088ff'%20d='M26.666%200C11.97%200%200%2011.97%200%2026.666c0%2012.87%209.181%2023.651%2021.334%2026.13v37.87c0%2011.77%209.68%2021.334%2021.332%2021.334h.195c1.302%209.023%209.1%2016%2018.473%2016C71.612%20128%2080%20119.612%2080%20109.334s-8.388-18.668-18.666-18.668c-9.372%200-17.17%206.977-18.473%2016h-.195c-8.737%200-16-7.152-16-16V63.779a18.514%2018.514%200%200%200%2013.24%205.555h2.955c1.303%209.023%209.1%2016%2018.473%2016%209.372%200%2017.169-6.977%2018.47-16h11.057c1.303%209.023%209.1%2016%2018.473%2016%2010.278%200%2018.666-8.39%2018.666-18.668C128%2056.388%20119.612%2048%20109.334%2048c-9.373%200-17.171%206.977-18.473%2016H79.805c-1.301-9.023-9.098-16-18.471-16s-17.171%206.977-18.473%2016h-2.955c-6.433%200-11.793-4.589-12.988-10.672%2014.58-.136%2026.416-12.05%2026.416-26.662C53.334%2011.97%2041.362%200%2026.666%200zm0%205.334A21.292%2021.292%200%200%201%2048%2026.666%2021.294%2021.294%200%200%201%2026.666%2048%2021.292%2021.292%200%200%201%205.334%2026.666%2021.29%2021.29%200%200%201%2026.666%205.334zm-5.215%207.541C18.67%2012.889%2016%2015.123%2016%2018.166v17.043c0%204.043%204.709%206.663%208.145%204.533l13.634-8.455c3.257-2.02%203.274-7.002.032-9.045l-13.635-8.59a5.024%205.024%200%200%200-2.725-.777zm-.117%205.291%2013.635%208.588-13.635%208.455V18.166zm40%2035.168a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%2061.334%2080%2013.294%2013.294%200%200%201%2048%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm48%200a13.29%2013.29%200%200%201%2013.332%2013.332A13.293%2013.293%200%200%201%20109.334%2080%2013.294%2013.294%200%200%201%2096%2066.666a13.293%2013.293%200%200%201%2013.334-13.332zm-42.568%206.951a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zm48%200a2.667%202.667%200%200%200-1.887.78l-6.3%206.294-2.093-2.084a2.667%202.667%200%200%200-3.771.006%202.667%202.667%200%200%200%20.008%203.772l3.974%203.96a2.667%202.667%200%200%200%203.766-.001l8.185-8.174a2.667%202.667%200%200%200%20.002-3.772%202.667%202.667%200%200%200-1.884-.78zM61.334%2096a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2048%20109.334%2013.294%2013.294%200%200%201%2061.334%2096zM56%20105.334c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zm10.666%200c-2.193%200-4%201.807-4%204%200%202.195%201.808%204%204%204s4-1.805%204-4c0-2.193-1.807-4-4-4zM56%20108c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.334-.58-1.334-1.332%200-.75.585-1.334%201.334-1.334zm10.666%200c.75%200%201.334.585%201.334%201.334%200%20.753-.583%201.332-1.334%201.332-.75%200-1.332-.58-1.332-1.332%200-.75.583-1.334%201.332-1.334z'/%3e%3cpath%20fill='%2379b8ff'%20d='M109.334%2090.666c-9.383%200-17.188%206.993-18.477%2016.031a2.667%202.667%200%200%200-.265-.011l-2.7.09a2.667%202.667%200%200%200-2.578%202.751%202.667%202.667%200%200%200%202.752%202.578l2.7-.087a2.667%202.667%200%200%200%20.097-.006C92.17%20121.029%2099.965%20128%20109.334%20128c10.278%200%2018.666-8.388%2018.666-18.666s-8.388-18.668-18.666-18.668zm0%205.334a13.293%2013.293%200%200%201%2013.332%2013.334%2013.29%2013.29%200%200%201-13.332%2013.332A13.293%2013.293%200%200%201%2096%20109.334%2013.294%2013.294%200%200%201%20109.334%2096z'/%3e%3c/svg%3e",Ht="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%20xml:space='preserve'%3e%3cpath%20fill='%23E24329'%20d='m124.755%2051.382-.177-.452L107.47%206.282a4.459%204.459%200%200%200-1.761-2.121%204.581%204.581%200%200%200-5.236.281%204.578%204.578%200%200%200-1.518%202.304L87.404%2042.088H40.629L29.077%206.746a4.492%204.492%200%200%200-1.518-2.31%204.581%204.581%200%200%200-5.236-.281%204.502%204.502%200%200%200-1.761%202.121L3.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758%2026.218-19.634.065-.052c11.273-8.526%2015.562-23.472%2010.524-36.677z'/%3e%3cpath%20fill='%23FC6D26'%20d='m124.755%2051.382-.177-.452a57.79%2057.79%200%200%200-23.005%2010.341L64%2089.682c12.795%209.68%2023.934%2018.09%2023.934%2018.09l26.218-19.634.065-.052c11.291-8.527%2015.586-23.488%2010.538-36.704z'/%3e%3cpath%20fill='%23FCA326'%20d='m40.066%20107.771%2012.893%209.758%207.854%205.93a5.283%205.283%200%200%200%206.388%200l7.854-5.93%2012.893-9.758s-11.152-8.436-23.947-18.09a18379.202%2018379.202%200%200%200-23.935%2018.09z'/%3e%3cpath%20fill='%23FC6D26'%20d='M26.42%2061.271A57.73%2057.73%200%200%200%203.422%2050.904l-.17.452c-5.059%2013.219-.763%2028.192%2010.537%2036.716l.059.046.157.111%2026.061%2019.516L64%2089.655%2026.42%2061.271z'/%3e%3c/svg%3e",qt="/assets/jenkins-CWiA3Rta.svg",Ft="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%2032%2032'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3cmask%20id='a'%20x='1.455'%20y='1.455'%20width='29.091'%20height='29.091'%20maskUnits='userSpaceOnUse'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:%23fff'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:%23fff'/%3e%3c/mask%3e%3clinearGradient%20id='b'%20x1='0.069'%20y1='31.569'%20x2='1.069'%20y2='31.569'%20gradientTransform='matrix(0,%2029.091,%2029.091,%200,%20-902.364,%20-0.545)'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20offset='0'%20stop-color='%23ffffff'/%3e%3cstop%20offset='1'%20stop-color='%23ffffff'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3clinearGradient%20id='c'%20x1='0.069'%20y1='31.194'%20x2='1.069'%20y2='31.194'%20xlink:href='%23b'/%3e%3c/defs%3e%3ctitle%3efile_type_azurepipelines%3c/title%3e%3cg%20style='mask:url(%23a)'%3e%3cpath%20d='M1.455,23.273H3.636v5.091H8.727v2.182H1.455Z'%20style='fill:%2391b0f2'/%3e%3cpath%20d='M1.455,9.939v6.667L5.7,20.974,7.515,19.03l5.455,5.455L11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.939Z'%20style='fill:%230f46bd'/%3e%3cpath%20d='M6,18.249,17.212,1.455H30.545V14.788L13.751,26Z'%20style='fill:%23062aa9'/%3e%3cpath%20d='M6.7,18.952a1.212,1.212,0,0,1-.151-1.53l9.94-14.889a2.424,2.424,0,0,1,2.016-1.078H29.333a1.212,1.212,0,0,1,1.212,1.212V13.492a2.424,2.424,0,0,1-1.078,2.016l-14.889,9.94a1.212,1.212,0,0,1-1.53-.151Z'%20style='fill:%232560e0'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M7.5,22.707l9.255-9.255,1.792,1.792L9.293,24.5Z'%20style='fill:%23729af2'/%3e%3cpath%20d='M10.772,23.02,8.98,21.228l7.776-7.775,1.792,1.792Z'%20style='fill:%234c80f0'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%230a44c2'/%3e%3cpath%20d='M23.273,12.364a3.636,3.636,0,1,0-3.636-3.636A3.636,3.636,0,0,0,23.273,12.364Z'%20style='fill:%2391b0f2'/%3e%3cg%20style='opacity:0.20000000298023224'%3e%3cpath%20d='M5.7,20.974l1.464-1.565,1.819,1.819L7.5,22.707,9.293,24.5l1.479-1.479L12.6,24.852,11.151,26.3l4.242,4.242h6.667a1.212,1.212,0,0,0,1.212-1.212v-9.7l6.195-4.129a2.425,2.425,0,0,0,1.078-2.016V2.667a1.212,1.212,0,0,0-1.212-1.212H18.509a2.425,2.425,0,0,0-2.016,1.078L12.364,8.727h-9.7A1.212,1.212,0,0,0,1.455,9.94v6.666Z'%20style='fill:url(%23b)'/%3e%3cpath%20d='M3.636,23.273H1.455v7.273H8.727V28.364H3.636Z'%20style='fill:url(%23c)'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Ot="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cdefs%3e%3clinearGradient%20id='bitbucket-original-a'%20gradientUnits='userSpaceOnUse'%20x1='28.593'%20y1='14.226'%20x2='16.672'%20y2='23.532'%20gradientTransform='scale(4)'%3e%3cstop%20offset='.176'%20stop-color='%230052cc'/%3e%3cstop%20offset='1'%20stop-color='%232684ff'/%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M19.082%2020c-1.918%200-3.355%201.758-3.039%203.516l12.95%2079.289c.32%202.078%202.077%203.515%204.155%203.515h62.66c1.442%200%202.72-1.12%203.04-2.558l13.109-80.086c.316-1.918-1.121-3.516-3.039-3.516zM74.07%2077.227H54.09l-5.278-28.293h30.215zm0%200'%20fill='%232684ff'/%3e%3cpath%20d='M107.64%2048.934H78.868L74.07%2077.227H54.09l-23.5%2027.972s1.12.961%202.719.961h62.66c1.441%200%202.719-1.12%203.039-2.558zm0%200'%20fill='url(%23bitbucket-original-a)'/%3e%3c/svg%3e",Bt="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20128%20128'%3e%3cpath%20fill='%23343434'%20d='M47.809%2064c0-8.45%206.847-15.23%2015.23-15.23%208.387%200%2015.234%206.847%2015.234%2015.23S71.426%2079.23%2063.04%2079.23c-8.383%200-15.23-6.847-15.23-15.23zm15.23-64C33.152%200%208.13%2020.48%201.023%2048.129c-.062.191-.062.383-.062.64a3.07%203.07%200%20003.07%203.07h25.793c1.215%200%202.305-.702%202.75-1.792%205.313-11.52%2016.961-19.582%2030.465-19.582%2018.496%200%2033.535%2015.039%2033.535%2033.535%200%2018.496-15.039%2033.535-33.535%2033.535-13.504%200-25.152-8-30.465-19.582-.511-1.023-1.535-1.793-2.75-1.793H4.031a3.07%203.07%200%2000-3.07%203.07c0%20.196.062.387.062.641C8.063%20107.52%2033.153%20128%2063.04%20128c35.328%200%2064-28.672%2064-64s-28.672-64-64-64zm0%200'/%3e%3c/svg%3e",_t={"github-actions":Lt,"gitlab-ci":Ht,jenkins:qt,"azure-pipelines":Ft,bitbucket:Ot,circleci:Bt},Ut={circleci:!0};function Dt({platform:s,size:i=16,className:n=""}){const a=_t[s];return a?e.jsx("img",{src:a,alt:"","aria-hidden":"true",width:i,height:i,style:{width:i,height:i},className:`flex-shrink-0 object-contain ${Ut[s]?"dark:invert":""} ${n}`}):null}async function Xe(s){var i;try{if((i=navigator.clipboard)!=null&&i.writeText)return await navigator.clipboard.writeText(s),!0}catch{}try{const n=document.createElement("textarea");n.value=s,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();const a=document.execCommand("copy");return document.body.removeChild(n),a}catch{return!1}}const Pe={queued:"bg-amber-500/10 border-amber-500/30 text-amber-300",running:"bg-blue-500/10 border-blue-500/30 text-blue-300",passed:"bg-emerald-500/10 border-emerald-500/30 text-emerald-300",failed:"bg-red-500/10 border-red-500/30 text-red-300",cancelled:"bg-white/5 border-white/10 text-gray-400",error:"bg-red-500/10 border-red-500/30 text-red-300"},et={command:"Command",suite:"Suite",cycle:"Cycle"};function W(s){if(!s)return"—";const i=Date.now()-new Date(s).getTime(),n=Math.floor(i/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const a=Math.floor(n/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function tt(s){if(!s)return"";const i=new Date(s).getTime()-Date.now();if(i<=0)return"expired";const n=i/864e5;return n>=1?`expires in ${Math.round(n)}d`:`expires in ${Math.max(1,Math.floor(i/36e5))}h`}function pe(s){if(!s||s<=0)return"—";const i=Math.round(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60);return n<60?`${n}m ${i%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function st(s){return s>=90?"text-emerald-400":s>=70?"text-amber-400":"text-red-400"}function at(s){let i;try{i=new URL(s)}catch{return"Enter a full address, e.g. https://testver.example.com"}return/^https?:$/.test(i.protocol)?/^(localhost|127\.|0\.0\.0\.0|\[?::1\]?)/i.test(i.hostname)?"This is a local address — CI runners in the cloud cannot reach it. Use the address your CI runners reach this server at.":i.protocol==="http:"?"Plain http — the CI token travels unencrypted. Use https when CI reaches this server over the internet.":null:"Use an http(s) address"}function Be(s){const i=l.useRef(s);i.current=s,l.useEffect(()=>{const n=a=>{a.key==="Escape"&&i.current()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[])}function Ee({what:s,error:i,onRetry:n}){return e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["Could not load ",s,": ",(i==null?void 0:i.message)||String(i)]}),e.jsxs("button",{onClick:n,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg border border-red-500/30 hover:bg-red-500/10 text-xs font-medium",children:[e.jsx(Pt,{size:12})," Retry"]})]})}function rt({message:s,onDismiss:i}){return s?e.jsxs("div",{role:"alert",className:"mb-4 px-3 py-2.5 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-start gap-2",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0 mt-0.5"}),e.jsx("span",{className:"flex-1",children:s}),e.jsx("button",{onClick:i,"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}):null}function as(){var je,ie,Ne,we;const s=it(),{hasRole:i}=ot(),n=i("tester"),a=i("admin"),[o,w]=St("tab",["dashboard","pipelines","ci-runs","tokens","trace"],"dashboard"),x=It(),N=K({queryKey:["ci-pipelines"],queryFn:ct}),g=K({queryKey:["ci-tokens"],queryFn:dt}),v=K({queryKey:["ci-runs"],queryFn:()=>xt(200),refetchInterval:t=>{var u;return(((u=t.state.data)==null?void 0:u.runs)||[]).some(f=>f.state==="running"||f.state==="queued")?1e4:3e4}}),{data:b}=K({queryKey:["suites"],queryFn:mt}),c=K({queryKey:["ci-analytics"],queryFn:ht,refetchInterval:3e4}),d=c.data,j=((je=N.data)==null?void 0:je.pipelines)||[],P=((ie=g.data)==null?void 0:ie.tokens)||[],F=P.filter(t=>!t.revoked),$=P.filter(t=>t.revoked),S=((Ne=v.data)==null?void 0:Ne.runs)||[],O=(b==null?void 0:b.suites)||[],h=[...new Set(j.filter(t=>t.target.type==="cycle"&&t.target.cycleId).map(t=>t.target.cycleId))],{data:E}=K({queryKey:["ci-cycle-names",h.join(",")],enabled:h.length>0,queryFn:async()=>{const t=await Promise.all(h.map(async u=>{try{const f=await Ze(u);return[u,{name:f==null?void 0:f.name,planId:f==null?void 0:f.planId}]}catch{return[u,null]}}));return Object.fromEntries(t)}}),[A]=Se("state"),[k]=Se("pipeline"),[B]=Se("branch"),[M]=Se("env"),L=S.filter(t=>(!A||t.state===A)&&(!k||t.mappingName===k)&&(!B||(t.branch||"").toLowerCase().includes(B.toLowerCase()))&&(!M||(t.environment||"").toLowerCase()===M.toLowerCase())),_=!!(A||k||B||M),ce=()=>x({state:null,pipeline:null,branch:null,env:null}),[se,I]=l.useState(0),[z,ae]=l.useState(20);l.useEffect(()=>{I(0)},[A,k,B,M]);const R=Math.max(1,Math.ceil(L.length/z)),T=Math.min(se,R-1),re=L.slice(T*z,(T+1)*z),[ne,G]=l.useState(null),[Z,m]=l.useState(null),[y,J]=l.useState(null),[ge,le]=l.useState(null),[Q,de]=l.useState(null),[X,p]=l.useState(null),[be,ye]=l.useState(!1),[fe,U]=l.useState(null),[Me,ee]=l.useState(null),ve=t=>{var u;return(u=O.find(f=>f.id===t))==null?void 0:u.name},Y=()=>{s.invalidateQueries({queryKey:["ci-pipelines"]}),s.invalidateQueries({queryKey:["ci-tokens"]}),s.invalidateQueries({queryKey:["ci-runs"]}),s.invalidateQueries({queryKey:["ci-analytics"]})},ze=async t=>{try{await Qe({...t,enabled:!t.enabled}),Y()}catch(u){U((u==null?void 0:u.message)||String(u))}},q=[{id:"dashboard",label:"Dashboard",icon:e.jsx(He,{size:15})},{id:"pipelines",label:"Pipelines",icon:e.jsx(Le,{size:15})},{id:"tokens",label:"CI Tokens",icon:e.jsx(Ge,{size:15})},{id:"ci-runs",label:"CI Runs",icon:e.jsx(ue,{size:15})},{id:"trace",label:"Trace",icon:e.jsx(Fe,{size:15})}];return e.jsxs("div",{className:"h-full flex flex-col bg-surface-0 text-gray-200 animate-fade-in",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(Le,{size:24,className:"text-brand-300"}),"CI/CD Pipelines"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Your CI/CD pipelines trigger test runs that execute on this Testver server and gate the build on the verdict"})]})}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsx("div",{role:"tablist","aria-label":"CI/CD Pipelines sections",className:"max-w-[1400px] mx-auto w-full px-6 flex gap-1",children:q.map(t=>e.jsxs("button",{role:"tab","aria-selected":o===t.id,onClick:()=>w(t.id),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium border-b-2 transition-colors ${o===t.id?"border-brand-400 text-brand-300":"border-transparent text-gray-400 hover:text-gray-200 hover:border-white/10"}`,children:[t.icon,t.label]},t.id))})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto w-full px-6 py-6 space-y-8",children:[fe&&e.jsxs("div",{role:"alert",className:"px-4 py-3 rounded-xl bg-red-500/10 border border-red-500/30 text-sm text-red-300 flex items-center justify-between",children:[e.jsx("span",{children:fe}),e.jsx("button",{onClick:()=>U(null),"aria-label":"Dismiss error",className:"text-red-300 hover:text-red-200",children:e.jsx($e,{size:14})})]}),o==="pipelines"&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-brand-500/10 border border-brand-500/25 text-sm text-gray-300",children:[e.jsx("b",{className:"text-brand-300",children:"Delegated execution:"})," CI pipelines trigger runs that execute ",e.jsx("b",{children:"on this Testver server"}),", then gate the build on the verdict. Map a pipeline to a suite, cycle, or command, create a CI token, and wire your workflow — from CI or any terminal via"," ",e.jsx("code",{className:"text-brand-300",children:"testver trigger"}),"."]}),o==="dashboard"&&c.isLoading&&e.jsxs("div",{className:"py-12 text-center text-gray-500 text-sm",children:[e.jsx(V,{size:16,className:"animate-spin inline mr-2"}),"Loading the dashboard…"]}),o==="dashboard"&&c.isError&&e.jsx(Ee,{what:"the CI dashboard",error:c.error,onRetry:()=>c.refetch()}),o==="dashboard"&&d&&d.totals.runs===0&&e.jsxs("div",{className:"py-16 text-center rounded-xl border border-dashed border-white/10",children:[e.jsx(He,{size:32,className:"mx-auto text-gray-600 mb-3"}),e.jsx("p",{className:"text-base font-medium text-gray-300 mb-1",children:"No CI runs yet"}),e.jsx("p",{className:"text-sm text-gray-500 max-w-md mx-auto mb-4",children:"Create a pipeline mapping and a CI token, then trigger a run from your pipeline or any terminal. The dashboard lights up with pass rates, trends, and insights from the first run."}),e.jsx("button",{onClick:()=>w("pipelines"),className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:"Set up a Pipeline →"})]}),o==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(He,{size:17,className:"text-emerald-300"})," Overview"]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-3",children:[e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"CI Runs"}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:d.totals.runs})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",title:"Passed ÷ (passed + failed + errored). A run that errored — lost, timed out or ran no tests — counts against it; cancelled runs don't count.",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Pass Rate"}),e.jsxs("div",{className:`text-xl font-semibold mt-0.5 ${st(d.totals.passRate)}`,children:[d.totals.passRate,"%"]}),(d.totals.errored||0)>0&&e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5",children:[d.totals.errored," errored"]})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsxs("div",{className:"text-xs text-gray-500 uppercase tracking-wide flex items-center gap-1",children:[e.jsx(Tt,{size:11})," Avg Duration"]}),e.jsx("div",{className:"text-xl font-semibold text-gray-100 mt-0.5",children:pe(d.totals.avgDurationMs)})]}),e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide",children:"Active / Queued"}),e.jsx("div",{className:`text-xl font-semibold mt-0.5 ${d.totals.active>0?"text-blue-300":"text-gray-100"}`,children:d.totals.active})]})]}),d.trend.length>1&&e.jsxs("div",{className:"px-4 py-3 rounded-xl bg-surface-1 border border-white/5",children:[e.jsx("div",{className:"text-xs text-gray-500 uppercase tracking-wide mb-2",children:"Recent verdicts (oldest → newest)"}),e.jsx("div",{className:"flex items-end gap-1 h-14",role:"list","aria-label":"Recent CI verdicts",children:d.trend.map((t,u)=>{const f=d.trend.length,xe=Math.max(...d.trend.map(H=>H.durationMs||0),1),te=30+Math.round((t.durationMs||0)/xe*70),oe=t.state==="passed"?"bg-emerald-400/70":t.state==="error"?"bg-amber-400/80":"bg-red-400/80",D=u<f/4?"left-0":u>3*f/4?"right-0":"left-1/2 -translate-x-1/2",ke=`${t.mapping||"CI run"}: ${t.state}${t.summary?`, ${t.summary.passed} of ${t.summary.total} passed`:""}, ${W(t.at)}`,Ce=`block w-full rounded-sm transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-brand-400 ${oe}`;return e.jsxs("div",{role:"listitem",className:"relative flex-1 max-w-[14px] h-full flex items-end",onMouseEnter:()=>ee(u),onMouseLeave:()=>ee(H=>H===u?null:H),children:[t.runId?e.jsx("a",{href:`/results?runId=${encodeURIComponent(t.runId)}`,target:"_blank",rel:"noopener noreferrer","aria-label":`${ke} — open the report`,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}):e.jsx("span",{tabIndex:0,"aria-label":ke,onFocus:()=>ee(u),onBlur:()=>ee(H=>H===u?null:H),className:Ce,style:{height:`${te}%`}}),Me===u&&e.jsxs("div",{className:`absolute bottom-full mb-2 ${D} z-50 pointer-events-none w-64 rounded-xl bg-surface-1 border border-white/10 shadow-xl shadow-black/30 p-3.5 text-left`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2.5",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-100 truncate",children:t.mapping||"CI run"}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[t.state]||Pe.failed}`,children:t.state})]}),e.jsxs("div",{className:"space-y-1.5 text-xs",children:[t.branch&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Branch"}),e.jsx("span",{className:"text-gray-200 truncate",children:t.branch})]}),t.summary&&e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Result"}),e.jsxs("span",{className:"text-gray-200",children:[e.jsx("span",{className:"text-emerald-400",children:t.summary.passed})," / ",t.summary.total," passed",t.summary.failed>0&&e.jsxs("span",{className:"text-red-400",children:[" · ",t.summary.failed," failed"]})]})]}),t.error&&e.jsx("div",{className:"text-amber-300 line-clamp-2",children:t.error}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"Duration"}),e.jsx("span",{className:"text-gray-200",children:pe(t.durationMs)})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-gray-500",children:"When"}),e.jsxs("span",{className:"text-gray-200",children:[W(t.at)," · ",new Date(t.at).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]}),t.runId&&e.jsx("div",{className:"mt-2.5 pt-2 border-t border-white/10 text-xs text-brand-300",children:"Click the bar to open the full report →"})]})]},t.ciRunId)})})]})]}),o==="pipelines"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(Le,{size:17,className:"text-brand-300"})," Pipeline Mappings"]}),n&&e.jsxs("button",{onClick:()=>G({enabled:!0,target:{type:"suite"}}),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:[e.jsx(Ye,{size:14})," New Mapping"]})]}),N.isError?e.jsx(Ee,{what:"pipeline mappings",error:N.error,onRetry:()=>N.refetch()}):N.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(V,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):j.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No pipeline mappings yet — ",n?"create one to let CI (or the CLI) trigger runs on this server.":"a tester or admin can create one."]}):e.jsx("div",{className:"space-y-2",children:j.map(t=>{var te,me,oe;const u=t.target.type==="suite"?ve(t.target.suiteId):void 0,f=t.target.type==="cycle"&&t.target.cycleId?E==null?void 0:E[t.target.cycleId]:void 0,xe=t.target.type==="suite"&&O.length>0&&!u||t.target.type==="cycle"&&f===null;return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-xl bg-surface-1 border border-white/5 ${t.enabled?"":"opacity-60"}`,children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-brand-500/15 text-brand-300 border border-brand-500/25 flex-shrink-0",children:et[t.target.type]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-medium text-gray-200",children:t.name}),!t.enabled&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:"disabled"}),t.previousNames&&t.previousNames.length>0&&e.jsxs("span",{className:"text-xs text-gray-500",title:"CI files that still use an old name keep triggering this mapping",children:["also answers to ",t.previousNames.map(D=>`"${D}"`).join(", "),n&&e.jsx("button",{onClick:async()=>{try{await ut(t.id),Y()}catch(D){U((D==null?void 0:D.message)||String(D))}},className:"ml-1.5 text-brand-300 hover:text-brand-200 underline-offset-2 hover:underline",children:"Forget old names"})]})]}),e.jsxs("div",{className:"text-sm text-gray-400 truncate",children:[t.target.type==="command"&&e.jsx("code",{children:t.target.command}),t.target.type==="suite"&&e.jsxs(e.Fragment,{children:["→ ",u||e.jsx("code",{children:t.target.suiteId})]}),t.target.type==="cycle"&&e.jsxs(e.Fragment,{children:["→ ",f!=null&&f.name?`Cycle "${f.name}"`:e.jsxs(e.Fragment,{children:["Cycle ",e.jsx("code",{children:t.target.cycleId})]})]}),xe&&e.jsxs("span",{className:"ml-2 text-amber-400",children:[e.jsx(Ae,{size:12,className:"inline -mt-0.5"})," no longer exists — triggers will fail"]}),((te=t.overrides)==null?void 0:te.environment)&&e.jsxs("span",{className:"ml-2",children:["env: ",t.overrides.environment]}),((me=t.overrides)==null?void 0:me.browser)&&e.jsxs("span",{className:"ml-2",children:["browser: ",t.overrides.browser]}),((oe=t.statusPush)==null?void 0:oe.enabled)&&e.jsxs("span",{className:"ml-2 text-brand-400/80",children:["PR status → ",t.statusPush.provider]}),e.jsxs("span",{className:"ml-2",children:["· last triggered ",W(t.lastTriggeredAt)]})]})]}),n&&e.jsx("button",{onClick:()=>void ze(t),role:"switch","aria-checked":t.enabled,"aria-label":`${t.enabled?"Disable":"Enable"} ${t.name}`,title:t.enabled?"Enabled — click to disable":"Disabled — click to enable",className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${t.enabled?"bg-brand-500":"bg-surface-3 border border-white/10"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${t.enabled?"translate-x-4":""}`})}),n&&e.jsx("button",{onClick:()=>J(t),title:"Get pipeline config + CLI snippet","aria-label":`Wire ${t.name} into CI`,className:"p-2 rounded-lg text-gray-400 hover:text-brand-300 hover:bg-white/5 transition-colors",children:e.jsx(Re,{size:15})}),n&&e.jsx("button",{onClick:()=>G(t),title:"Edit","aria-label":`Edit ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:e.jsx(zt,{size:15})}),n&&e.jsx("button",{onClick:()=>m(t),title:"Delete","aria-label":`Delete ${t.name}`,className:"p-2 rounded-lg text-gray-400 hover:text-red-300 hover:bg-white/5 transition-colors",children:e.jsx(Et,{size:15})})]},t.id)})})]}),o==="tokens"&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Ge,{size:17,className:"text-amber-300"})," CI Tokens"]}),e.jsxs("p",{className:"text-sm text-gray-400 mb-3",children:["Machine tokens for the Gate API. Store one as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," in your CI platform's secrets. The value is shown ",e.jsx("b",{children:"once"})," at creation. A token triggers only the pipeline mappings it is scoped to — ad-hoc suites, cycles and commands need a token that allows them."]}),a?e.jsx(Gt,{pipelines:j,onCreated:t=>{le(t),Y()}}):e.jsx("p",{className:"text-sm text-gray-500 mb-3 px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:"Only admins can create or revoke CI tokens."}),g.isError?e.jsx(Ee,{what:"CI tokens",error:g.error,onRetry:()=>g.refetch()}):g.isLoading?e.jsxs("div",{className:"py-6 text-center text-gray-500 text-sm",children:[e.jsx(V,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):F.length===0?e.jsxs("div",{className:"py-8 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No active CI tokens.",a?" Create one above, then add it to your CI platform's secrets.":""]}):e.jsx("div",{className:"space-y-1.5",children:F.map(t=>e.jsx(Ke,{token:t,pipelines:j,onRevoke:a?()=>de({id:t.id,name:t.name}):void 0},t.id))}),$.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("button",{onClick:()=>ye(t=>!t),"aria-expanded":be,className:"text-sm text-gray-500 hover:text-gray-300",children:[be?"▾":"▸"," Revoked tokens (",$.length,")"]}),be&&e.jsx("div",{className:"space-y-1.5 mt-2",children:$.map(t=>e.jsx(Ke,{token:t,pipelines:j},t.id))})]})]}),o==="dashboard"&&d&&(d.perPipeline.length>0||d.perBranch.length>0)&&e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-3",children:[e.jsx(Rt,{size:17,className:"text-purple-300"})," Insights"]}),e.jsx("p",{className:"text-sm text-gray-500 -mt-2 mb-3",children:"Click a row to see its runs."}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[e.jsx(qe,{title:"By Pipeline",rows:d.perPipeline,onSelect:t=>x({tab:"ci-runs",pipeline:t,branch:null,env:null,state:null})}),e.jsx(qe,{title:"By Branch",rows:d.perBranch,onSelect:t=>x({tab:"ci-runs",branch:t,pipeline:null,env:null,state:null})}),e.jsx(qe,{title:"By Environment",rows:d.perEnvironment,onSelect:t=>x({tab:"ci-runs",env:t,pipeline:null,branch:null,state:null})})]})]}),o==="trace"&&e.jsx(Zt,{}),o==="dashboard"&&d&&d.totals.runs>0&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," Recent CI Runs",e.jsx("span",{className:"text-sm text-gray-500 font-normal",children:"(last 5)"})]}),e.jsx("button",{onClick:()=>w("ci-runs"),className:"text-sm text-brand-300 hover:text-brand-200 font-medium",children:"View all runs →"})]}),e.jsx(We,{runs:S.slice(0,5),onCancel:n?p:void 0})]}),o==="ci-runs"&&e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 flex-wrap gap-2",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2",children:[e.jsx(ue,{size:17,className:"text-blue-300"})," CI Runs",e.jsxs("span",{className:"text-sm text-gray-500 font-normal",children:[_?`${L.length} of ${S.length}`:`${S.length} total`,(((we=v.data)==null?void 0:we.total)||0)>S.length&&` (latest ${S.length} of ${v.data.total})`]})]}),S.length>0&&e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsxs("select",{value:A||"",onChange:t=>x({state:t.target.value||null}),"aria-label":"Filter by state",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All states"}),["running","queued","passed","failed","cancelled","error"].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:k||"",onChange:t=>x({pipeline:t.target.value||null}),"aria-label":"Filter by pipeline",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All pipelines"}),[...new Set(S.map(t=>t.mappingName).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsxs("select",{value:M||"",onChange:t=>x({env:t.target.value||null}),"aria-label":"Filter by environment",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none",children:[e.jsx("option",{value:"",children:"All environments"}),[...new Set(S.map(t=>t.environment).filter(Boolean))].map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx("input",{value:B||"",onChange:t=>x({branch:t.target.value||null}),placeholder:"Branch…","aria-label":"Filter by branch",className:"px-2.5 py-1.5 rounded-lg bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none w-32"}),_&&e.jsx("button",{onClick:ce,className:"text-sm text-gray-500 hover:text-gray-300 px-1.5",title:"Clear all filters",children:"✕ Clear"})]})]}),v.isError?e.jsx(Ee,{what:"CI runs",error:v.error,onRetry:()=>v.refetch()}):v.isLoading?e.jsxs("div",{className:"py-8 text-center text-gray-500 text-sm",children:[e.jsx(V,{size:16,className:"animate-spin inline mr-2"}),"Loading…"]}):S.length===0?e.jsxs("div",{className:"py-10 text-center rounded-xl border border-dashed border-white/10 text-sm text-gray-500",children:["No CI-triggered runs yet. Trigger one with ",e.jsx("code",{children:'testver trigger --mapping "…"'})," or from your pipeline."]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{runs:re,emptyNote:"No runs match the filters.",onCancel:n?p:void 0}),R>1&&e.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5 mt-2 rounded-xl border border-white/5 bg-surface-1 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx("span",{children:"Rows per page:"}),e.jsx("select",{value:z,onChange:t=>{ae(Number(t.target.value)),I(0)},"aria-label":"Rows per page",className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/40",children:[10,20,50,100].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsxs("span",{children:["Showing ",T*z+1,"–",Math.min((T+1)*z,L.length)," of ",L.length," run",L.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsx("button",{onClick:()=>I(0),disabled:T===0,title:"First page","aria-label":"First page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"«"}),e.jsx("button",{onClick:()=>I(t=>Math.max(0,t-1)),disabled:T===0,title:"Previous page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"‹ Prev"}),e.jsxs("span",{className:"px-2 text-gray-400",children:["Page ",e.jsx("span",{className:"text-gray-900 dark:text-gray-200 font-medium",children:T+1})," of ",R]}),e.jsx("button",{onClick:()=>I(t=>Math.min(R-1,t+1)),disabled:T>=R-1,title:"Next page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"Next ›"}),e.jsx("button",{onClick:()=>I(R-1),disabled:T>=R-1,title:"Last page","aria-label":"Last page",className:"px-2 py-1 rounded hover:bg-white/5 disabled:opacity-30 disabled:cursor-not-allowed text-gray-400",children:"»"})]})]})]})]})]})]})}),ne&&e.jsx(Vt,{mapping:ne,suites:O,onClose:()=>G(null),onSaved:()=>{G(null),Y()}}),y&&e.jsx(Wt,{mapping:y,hasToken:F.length>0,onOpenTokens:()=>{J(null),w("tokens")},onClose:()=>J(null)}),ge&&e.jsx(Kt,{raw:ge.raw,token:ge.token,pipelines:j,onClose:()=>le(null)}),Z&&e.jsx(Te,{open:!0,title:`Delete mapping "${Z.name}"?`,description:"CI jobs and scripts triggering this mapping name will start failing with 404. This does not affect past runs.",confirmLabel:"Delete",variant:"danger",onCancel:()=>m(null),onConfirm:async()=>{try{await pt(Z.id),Y()}catch(t){U((t==null?void 0:t.message)||String(t))}m(null)}}),Q&&e.jsx(Te,{open:!0,title:`Revoke token "${Q.name}"?`,description:"Every CI job or script using this token immediately loses access. This cannot be undone.",confirmLabel:"Revoke",variant:"danger",onCancel:()=>de(null),onConfirm:async()=>{try{await gt(Q.id),Y()}catch(t){U((t==null?void 0:t.message)||String(t))}de(null)}}),X&&e.jsx(Te,{open:!0,title:`Cancel this ${X.mappingName||"CI"} run?`,description:X.state==="queued"?'It leaves the queue and its CI job fails with "cancelled".':'The tests stop on the Testver server and the CI job fails with "cancelled".',confirmLabel:"Cancel run",variant:"danger",onCancel:()=>p(null),onConfirm:async()=>{try{await bt(X.id),Y()}catch(t){U((t==null?void 0:t.message)||String(t))}p(null)}})]})}function nt(s,i){const n=s==null?void 0:s.mappingIds,a=n?n.length===0?"no pipeline mappings":n.map(w=>{var x;return((x=i.find(N=>N.id===w))==null?void 0:x.name)||"a deleted mapping"}).join(", "):"all pipeline mappings",o=(s==null?void 0:s.adHoc)??"none";return o==="commands"?`${a} + ad-hoc suites, cycles and shell commands`:o==="suites"?`${a} + ad-hoc suites and cycles`:a}function Ke({token:s,pipelines:i,onRevoke:n}){var o;const a=!!s.expiresAt&&new Date(s.expiresAt).getTime()<=Date.now();return e.jsxs("div",{className:`flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm ${s.revoked||a?"opacity-70":""}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-gray-200",children:s.name}),e.jsxs("code",{className:"text-xs text-gray-500",children:[s.prefix,"…"]}),s.revoked&&e.jsxs("span",{className:"text-xs px-1.5 py-0.5 rounded bg-white/5 text-gray-500",children:["revoked ",W(s.revokedAt),s.revokedBy?` by ${s.revokedBy}`:""]}),!s.revoked&&s.expiresAt&&e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a?"bg-red-500/10 text-red-300":"bg-white/5 text-gray-400"}`,children:tt(s.expiresAt)}),(((o=s.scope)==null?void 0:o.adHoc)??"none")==="commands"&&!s.revoked&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-300",title:"Can run any shell command on this server",children:"runs commands"})]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-0.5 truncate",children:["Triggers ",nt(s.scope,i)]})]}),e.jsxs("span",{className:"text-sm text-gray-500 whitespace-nowrap",children:["created ",W(s.createdAt),s.createdBy?` by ${s.createdBy}`:""," · last used ",W(s.lastUsedAt)]}),n&&e.jsx("button",{onClick:n,title:"Revoke","aria-label":`Revoke ${s.name}`,className:"p-1.5 rounded-lg text-red-400 hover:text-red-600 dark:hover:text-red-500 hover:bg-red-500/10 transition-colors",children:e.jsx($t,{size:15})})]})}function Gt({pipelines:s,onCreated:i}){const[n,a]=l.useState(""),[o,w]=l.useState(!0),[x,N]=l.useState([]),[g,v]=l.useState("none"),[b,c]=l.useState("365"),[d,j]=l.useState(!1),[P,F]=l.useState(null),$=!!n.trim()&&!d&&(o||x.length>0||g!=="none"),S=async()=>{if($){j(!0),F(null);try{const h=await Nt({name:n.trim(),scope:{mappingIds:o?void 0:x,adHoc:g},expiresInDays:b?Number(b):void 0});a(""),N([]),w(!0),v("none"),i(h)}catch(h){F((h==null?void 0:h.message)||String(h))}finally{j(!1)}}};return e.jsxs("div",{className:"mb-4 p-4 rounded-xl bg-surface-1 border border-white/5 space-y-3",children:[e.jsxs("div",{className:"flex items-end gap-2 flex-wrap",children:[e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Name"}),e.jsx("input",{value:n,onChange:h=>a(h.target.value),maxLength:60,onKeyDown:h=>{h.key==="Enter"&&S()},placeholder:"e.g. github-pr-gate",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-64"})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Expires"}),e.jsxs("select",{value:b,onChange:h=>c(h.target.value),className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"30",children:"in 30 days"}),e.jsx("option",{value:"90",children:"in 90 days"}),e.jsx("option",{value:"365",children:"in 1 year"}),e.jsx("option",{value:"",children:"never"})]})]}),e.jsxs("button",{disabled:!$,onClick:()=>void S(),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[d?e.jsx(V,{size:14,className:"animate-spin"}):e.jsx(Ye,{size:14})," Create Token"]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs text-gray-500 mb-1",children:"May trigger"}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-sm text-gray-300",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:o,onChange:()=>w(!0),className:"accent-brand-500"}),"Every pipeline mapping"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-scope",checked:!o,onChange:()=>w(!1),className:"accent-brand-500"}),"Only these mappings:"]}),!o&&e.jsxs("div",{className:"ml-6 flex flex-wrap gap-x-4 gap-y-1",children:[s.length===0&&e.jsx("span",{className:"text-xs text-gray-500",children:"No mappings yet."}),s.map(h=>e.jsxs("label",{className:"flex items-center gap-1.5 text-sm",children:[e.jsx("input",{type:"checkbox",checked:x.includes(h.id),className:"accent-brand-500",onChange:E=>N(A=>E.target.checked?[...A,h.id]:A.filter(k=>k!==h.id))}),h.name]},h.id))]})]})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"text-xs text-gray-500 mb-1",children:["Ad-hoc targets (CLI ",e.jsx("code",{children:"--suite"})," / ",e.jsx("code",{children:"--cycle"})," / ",e.jsx("code",{children:"--command"}),")"]}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 text-sm text-gray-300",children:[["none","Not allowed"],["suites","Any suite or cycle"],["commands","Suites, cycles and shell commands"]].map(([h,E])=>e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"radio",name:"tok-adhoc",checked:g===h,onChange:()=>v(h),className:"accent-brand-500"}),E]},h))}),g==="commands"&&e.jsx("p",{className:"mt-1.5 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ Anyone holding this token can run any shell command on this Testver server. Prefer a pipeline mapping with a fixed command, and only allow this for a trusted, private pipeline."})]}),P&&e.jsx("p",{role:"alert",className:"text-sm text-red-300",children:P})]})}function Kt({raw:s,token:i,pipelines:n,onClose:a}){const[o,w]=l.useState(null),[x,N]=l.useState(!1),g=()=>{o==="ok"?a():N(!0)};Be(g);const v=window.location.origin,b=at(v);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"new-token-title",className:"w-full max-w-xl rounded-2xl bg-surface-1 border border-white/10 p-6",children:[e.jsxs("h3",{id:"new-token-title",className:"text-base font-semibold text-gray-100 mb-2",children:['CI token "',i.name,'" created']}),e.jsx("p",{className:"text-xs text-amber-300 mb-3",children:"Copy it now — this is the only time it will be shown."}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10",children:[e.jsx("code",{className:"text-xs text-gray-200 break-all flex-1 select-all",children:s}),e.jsx("button",{onClick:async()=>{w(await Xe(s)?"ok":"fail")},"aria-label":"Copy the token",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:o==="ok"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),o==="fail"&&e.jsx("p",{role:"alert",className:"text-xs text-red-300 mt-1.5",children:"Copying isn't available here — select the token above and copy it by hand."}),e.jsxs("div",{className:"mt-4 text-sm text-gray-400 space-y-1.5",children:[e.jsx("p",{className:"font-medium text-gray-300",children:"Next:"}),e.jsxs("ol",{className:"list-decimal ml-5 space-y-1",children:[e.jsxs("li",{children:["Add it to your CI platform's secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsxs("li",{children:["Open a pipeline mapping's ",e.jsx(Re,{size:12,className:"inline -mt-0.5"})," ",e.jsx("b",{children:"Wire into CI"})," to generate the pipeline file."]}),e.jsxs("li",{children:["CI reaches this server at ",b?e.jsxs("span",{className:"text-amber-300",children:["the address your CI runners can reach (this page's address, ",e.jsx("code",{children:v}),", is local)"]}):e.jsx("code",{children:v}),"."]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["It may trigger ",nt(i.scope,n),i.expiresAt?` · ${tt(i.expiresAt)}`:" · never expires","."]})]}),e.jsx("div",{className:"mt-4 text-right",children:e.jsx("button",{onClick:g,className:"px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white",children:"Done"})})]}),x&&e.jsx(Te,{open:!0,title:"Close without copying the token?",description:"It cannot be shown again — you would have to create a new token.",confirmLabel:"Close",variant:"danger",onCancel:()=>N(!1),onConfirm:a})]})}function Vt({mapping:s,suites:i,onClose:n,onSaved:a}){var Ne,we,t,u,f,xe,te,me,oe,D,ke,Ce,H,_e,Ue;Be(n);const[o,w]=l.useState(s.name||""),[x,N]=l.useState(((Ne=s.target)==null?void 0:Ne.type)||"suite"),[g,v]=l.useState(((we=s.target)==null?void 0:we.command)||""),[b,c]=l.useState(((t=s.target)==null?void 0:t.suiteId)||""),[d,j]=l.useState(""),[P,F]=l.useState(((u=s.target)==null?void 0:u.cycleId)||""),[$,S]=l.useState(((f=s.overrides)==null?void 0:f.environment)||""),[O,h]=l.useState(((xe=s.overrides)==null?void 0:xe.browser)||""),[E,A]=l.useState(s.autoHeal||"inherit"),[k,B]=l.useState(s.timeoutMinutes?String(s.timeoutMinutes):""),[M,L]=l.useState(!!((te=s.statusPush)!=null&&te.enabled)),[_,ce]=l.useState(((me=s.statusPush)==null?void 0:me.provider)||"github"),[se,I]=l.useState(((oe=s.statusPush)==null?void 0:oe.repo)||""),[z,ae]=l.useState(s.statusPush?"••••••••":""),[R,T]=l.useState(((D=s.statusPush)==null?void 0:D.baseUrl)||""),[re,ne]=l.useState(s.enabled!==!1),[G,Z]=l.useState(!1),[m,y]=l.useState(null),J={github:"owner/repo",gitlab:"group/project (or numeric id)","azure-devops":"org/project/repo",bitbucket:"workspace/repo"},ge={github:"PAT with repo:status (classic) or Commit statuses read/write (fine-grained)",gitlab:"Access token with api scope","azure-devops":"PAT with Code (Status) scope",bitbucket:"username:app_password with Repositories:Write (or a workspace access token)"},le=s.statusPush,Q=!!le&&(le.provider!==_||(le.baseUrl||"")!==R.trim()),de=z==="••••••••";l.useEffect(()=>{Q&&de&&ae("")},[Q,de]);const{data:X}=K({queryKey:["tm-plans"],queryFn:()=>yt(),enabled:x==="cycle"});K({queryKey:["ci-cycle-plan",(ke=s.target)==null?void 0:ke.cycleId],enabled:x==="cycle"&&!!((Ce=s.target)!=null&&Ce.cycleId)&&!d,queryFn:async()=>{const r=await Ze(s.target.cycleId).catch(()=>null);return r!=null&&r.planId&&j(r.planId),(r==null?void 0:r.planId)||null}});const{data:p}=K({queryKey:["tm-cycles",d],queryFn:()=>ft(d),enabled:x==="cycle"&&!!d}),be=((p==null?void 0:p.cycles)||[]).map(r=>r.id).join(","),{data:ye}=K({queryKey:["cycle-automation-counts",d,be],enabled:x==="cycle"&&!!d&&(((H=p==null?void 0:p.cycles)==null?void 0:H.length)||0)>0,queryFn:async()=>{const r=await Promise.all(p.cycles.map(async C=>{try{const he=await vt(C.id);return[C.id,(he.executions||[]).filter(lt=>lt.hasMappedScript).length]}catch{return[C.id,-1]}}));return Object.fromEntries(r)}}),fe=r=>ye==null?void 0:ye[r],U=((p==null?void 0:p.cycles)||[]).filter(r=>(fe(r.id)??1)!==0).length,{browserOpts:Me,envOpts:ee}=Ct(),ve=!!o.trim()&&!/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/.test(o.trim()),Y=!!s.id&&!!s.name&&o.trim()!==s.name,ze=k.trim()!==""&&!(Number.isInteger(Number(k))&&Number(k)>=1&&Number(k)<=1440),q=[];o.trim()?ve&&q.push("a valid name"):q.push("a name"),x==="command"&&!g.trim()&&q.push("the command"),x==="suite"&&!b&&q.push("a suite"),x==="cycle"&&!P&&q.push("a cycle"),ze&&q.push("a timeout between 1 and 1440 minutes"),M&&!se.trim()&&q.push("the repository for status push"),M&&!z.trim()&&q.push(Q?"the access token for the new git host":"the status push access token");const je=q.length===0,ie="w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-900 dark:text-gray-200 focus:outline-none focus:border-brand-500/50";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"mapping-modal-title",className:"w-full max-w-2xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"mapping-modal-title",className:"text-base font-semibold text-gray-100",children:[s.id?"Edit":"New"," Pipeline Mapping"]}),e.jsx("button",{onClick:n,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:m,onDismiss:()=>y(null)}),e.jsx("label",{htmlFor:"mapping-name",className:"block text-sm font-medium text-gray-300 mb-1",children:"Mapping name (the trigger key)"}),e.jsx("input",{id:"mapping-name",value:o,onChange:r=>w(r.target.value),placeholder:'e.g. "pr-gate-main"',maxLength:60,className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none mb-1 ${ve?"border-red-500/50 focus:border-red-500/70":"border-white/10 focus:border-brand-500/50"}`}),ve?e.jsx("p",{className:"text-xs text-red-400 mb-3",children:"This name can only contain letters, numbers, spaces, dots, dashes, and underscores — and must start with a letter or number. Special characters would break the generated CI config files."}):Y?e.jsxs("p",{className:"text-xs text-amber-300 mb-3",children:['CI files that use "',s.name,'" keep working — Testver remembers the old name. Update them to "',o.trim(),'" when you can, then forget the old name from the mapping list.']}):e.jsxs("p",{className:"text-xs text-gray-500 mb-3",children:["Your CI pipeline uses this exact name to trigger the run — e.g. ",e.jsxs("code",{children:['testver trigger --mapping "',o.trim()||"pr-gate-main",'"']}),". Allowed: letters, numbers, spaces, dots, dashes, underscores."]}),e.jsx("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:"Execution target"}),e.jsx("div",{className:"flex gap-1.5 mb-3",role:"group","aria-label":"Execution target",children:["suite","cycle","command"].map(r=>e.jsx("button",{onClick:()=>N(r),"aria-pressed":x===r,className:`px-3.5 py-1.5 rounded-lg text-sm font-medium transition-colors ${x===r?"bg-brand-600 text-white":"bg-surface-2 text-gray-400 hover:text-gray-200"}`,children:et[r]},r))}),x==="suite"&&e.jsxs("select",{value:b,onChange:r=>c(r.target.value),className:`${ie} mb-4`,"aria-label":"Suite",children:[e.jsx("option",{value:"",children:"Select a suite…"}),i.map(r=>{var C;return e.jsxs("option",{value:r.id,children:[r.name," (",((C=r.tests)==null?void 0:C.length)||0," tests)"]},r.id)}),b&&!i.some(r=>r.id===b)&&e.jsxs("option",{value:b,children:["(deleted suite ",b,")"]})]}),x==="cycle"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-4",children:[e.jsxs("select",{value:d,onChange:r=>{j(r.target.value),F("")},className:ie,"aria-label":"Test plan",children:[e.jsx("option",{value:"",children:"Select a plan…"}),((X==null?void 0:X.plans)||[]).map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),e.jsxs("select",{value:P,onChange:r=>F(r.target.value),className:ie,disabled:!d,"aria-label":"Test cycle",children:[e.jsx("option",{value:"",children:d?"Select a cycle…":"Pick a plan first"}),((p==null?void 0:p.cycles)||[]).map(r=>{const C=fe(r.id),he=C===0;return e.jsxs("option",{value:r.id,disabled:he,children:[r.name,C===void 0||C===-1?"":he?" — no automated scripts":` (${C} automated)`]},r.id)})]}),d&&(((_e=p==null?void 0:p.cycles)==null?void 0:_e.length)||0)>0&&U>0&&e.jsxs("p",{className:"col-span-2 text-xs text-gray-500",children:["CI triggers run a cycle's ",e.jsx("b",{className:"text-gray-400",children:"mapped automation scripts"})," — cycles without any are disabled here (",U," of ",p.cycles.length," cycle",p.cycles.length!==1?"s":""," in this plan ",U===1?"has":"have"," automated scripts). Map scripts under Script Mapping to enable a cycle."]}),d&&(((Ue=p==null?void 0:p.cycles)==null?void 0:Ue.length)||0)>0&&U===0&&e.jsx("p",{className:"col-span-2 text-xs px-3 py-2 rounded-lg bg-amber-500/10 border border-amber-500/25 text-amber-300",children:"⚠ None of this plan's cycles have mapped automation scripts — a CI trigger would fail. Pick a different plan or map automation scripts first (Script Mapping screen)."})]}),x==="command"&&e.jsx("textarea",{value:g,onChange:r=>v(r.target.value),rows:2,"aria-label":"Command",placeholder:"npx playwright test --grep @smoke",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5",children:["Overrides ",e.jsxs("span",{className:"text-gray-600",children:["(optional — ",x==="command"?"the browser / environment entries from Settings → Run Commands":`defaults come from the ${x}'s saved settings`,")"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Environment"}),e.jsx(De,{isEnv:!0,value:$,onChange:S,options:ee})]}),e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Browser"}),e.jsx(De,{isEnv:!1,value:O,onChange:h,options:Me})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs text-gray-500 mb-1",children:"Time limit (minutes)"}),e.jsx("input",{value:k,onChange:r=>B(r.target.value.replace(/[^0-9]/g,"")),inputMode:"numeric",placeholder:"240",className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 placeholder-gray-600 focus:outline-none ${ze?"border-red-500/50":"border-white/10 focus:border-brand-500/50"}`})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-sm text-gray-300 mb-1",children:"Auto-Heal on this pipeline"}),e.jsx("div",{className:"inline-flex rounded-lg border border-white/10 bg-surface-2 overflow-hidden",role:"group","aria-label":"Auto-Heal on this pipeline",children:[["inherit","Inherit"],["off","Off"],["heal","Heal only"],["heal-regate","Heal + re-gate"]].map(([r,C],he)=>e.jsx("button",{type:"button",onClick:()=>A(r),className:`px-3 py-1.5 text-xs font-medium transition-colors ${he>0?"border-l border-white/10":""} ${E===r?"bg-purple-500/15 text-purple-600 dark:text-purple-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,"aria-pressed":E===r,children:C},r))}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:[e.jsx("b",{children:"Heal only"})," keeps the build result and heals in the workspace's mode (Suggest when the workspace is Off). ",e.jsx("b",{children:"Heal + re-gate"})," always keeps verified fixes (Auto) and holds the gate until healing finishes, so a fully-healed run turns the build green, labeled as auto-healed."," ",e.jsx("b",{children:"Inherit"})," follows Settings → General."]})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:r=>L(r.target.checked),className:"accent-brand-500 mt-0.5"}),e.jsxs("span",{children:["Push commit statuses to the git host (PR decoration)",e.jsx("span",{className:"block text-xs text-gray-500",children:"Testver posts queued → running → success/failure statuses on the triggering commit, so PRs show the verdict — this is what enables the fire-and-forget CI job mode."})]})]}),M&&e.jsxs("div",{className:"ml-6 mb-3 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{value:_,onChange:r=>ce(r.target.value),className:ie,"aria-label":"Git host",children:[e.jsx("option",{value:"github",children:"GitHub"}),e.jsx("option",{value:"gitlab",children:"GitLab"}),e.jsx("option",{value:"azure-devops",children:"Azure DevOps"}),e.jsx("option",{value:"bitbucket",children:"Bitbucket"})]}),e.jsx("input",{value:se,onChange:r=>I(r.target.value),placeholder:J[_],"aria-label":"Repository",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none"})]}),e.jsx("input",{value:z,onChange:r=>ae(r.target.value),type:"password",autoComplete:"new-password","aria-label":"Access token",placeholder:le&&!Q?"Token saved — type to replace":"Access token",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"}),Q&&e.jsx("p",{className:"text-xs text-amber-300",children:"The git host changed — enter the access token for it. The saved token is not sent to a different host."}),e.jsxs("p",{className:"text-xs text-gray-600 -mt-1",children:[ge[_],". Stored encrypted on this server, never returned to the browser."]}),e.jsx("input",{value:R,onChange:r=>T(r.target.value),"aria-label":"Self-hosted base URL",placeholder:"Self-hosted base URL (optional — GHE / self-managed GitLab / Azure Server)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 placeholder-gray-600 focus:outline-none"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-300 mb-5",children:[e.jsx("input",{type:"checkbox",checked:re,onChange:r=>ne(r.target.checked),className:"accent-brand-500"}),"Enabled (triggers are rejected while disabled)"]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[!je&&e.jsxs("span",{className:"text-xs text-gray-500 mr-auto",children:["Still needed: ",q.join(", ")]}),e.jsx("button",{onClick:n,className:"px-4 py-2 rounded-xl text-sm text-gray-400 hover:text-gray-200",children:"Cancel"}),e.jsxs("button",{disabled:!je||G,onClick:async()=>{var r;Z(!0),y(null);try{await Qe({id:s.id,name:o.trim(),target:{type:x,command:x==="command"?g.trim():void 0,suiteId:x==="suite"?b:void 0,cycleId:x==="cycle"?P||((r=s.target)==null?void 0:r.cycleId):void 0},overrides:$||O?{environment:$||void 0,browser:O||void 0}:void 0,autoHeal:E,timeoutMinutes:k.trim()?Number(k):void 0,statusPush:M?{enabled:!0,provider:_,repo:se.trim(),token:z.trim(),baseUrl:R.trim()||void 0}:void 0,enabled:re}),a()}catch(C){y((C==null?void 0:C.message)||String(C)),Z(!1)}},className:"flex items-center gap-1.5 px-4 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50",children:[G&&e.jsx(V,{size:13,className:"animate-spin"}),s.id?"Save Changes":"Create Mapping"]})]})]})})}const Ve=[{id:"github-actions",label:"GitHub Actions",note:"Add TESTVER_CI_TOKEN as a repository secret (Settings → Secrets and variables → Actions). Pull requests report on their own commit."},{id:"gitlab-ci",label:"GitLab CI",note:"Add TESTVER_CI_TOKEN as a masked CI/CD variable. This file is the repo's .gitlab-ci.yml — saving replaces any existing pipeline. Merge requests are gated once (no duplicate branch pipeline)."},{id:"jenkins",label:"Jenkins",note:`Add a Secret Text credential with id "testver-ci-token", then set the job's Script Path to Jenkinsfile.testver-gate. The agent needs curl + jq.`,branchNote:"Jenkins decides which branches build in the job settings — the branch list is not used."},{id:"azure-pipelines",label:"Azure Pipelines",note:`Create a pipeline from azure-testver-gate.yml (Pipelines → New → Existing Azure Pipelines YAML file), then add TESTVER_CI_TOKEN as a secret variable ("Keep this value secret"). PR builds report on the PR's own commit.`},{id:"bitbucket",label:"Bitbucket",note:"Add TESTVER_CI_TOKEN as a SECURED repository variable (Repository settings → Repository variables). This is the repo's bitbucket-pipelines.yml — saving replaces any existing pipeline."},{id:"circleci",label:"CircleCI",note:"Add TESTVER_CI_TOKEN as a project environment variable (Project Settings → Environment Variables). This is the repo's .circleci/config.yml — saving replaces any existing config.",branchNote:'CircleCI filters by the pushed branch: listing branches means only those are gated — pull request branches too need "*" to be gated.'}];function Wt({mapping:s,hasToken:i,onOpenTokens:n,onClose:a}){var Z;Be(a);const[o,w]=l.useState(window.location.origin),[x,N]=l.useState("github-actions"),[g,v]=l.useState(!1),[b,c]=l.useState("main"),[d,j]=l.useState(null),[P,F]=l.useState(".github/workflows/testver-gate.yml"),[$,S]=l.useState(!1),[O,h]=l.useState(!1),[E,A]=l.useState(!1),[k,B]=l.useState(!1),[M,L]=l.useState(!1),[_,ce]=l.useState(null),[se,I]=l.useState(null),z=l.useMemo(()=>at(o),[o]),ae=b.split(",").map(m=>m.trim()).filter(Boolean),R=Ve.find(m=>m.id===x),T=()=>{j(null),B(!1),I(null)},re=`npx -y testver trigger --server ${o} --mapping "${s.name}"`,ne=async(m,y)=>{await Xe(y)?(ce(m),setTimeout(()=>ce(J=>J===m?null:J),1500)):I("Copying isn't available here — select the text and copy it by hand.")},G=async m=>{if(d){A(!0),I(null);try{await kt({filePath:P,content:d,overwrite:m}),B(!0)}catch(y){(y==null?void 0:y.status)===409?L(!0):I((y==null?void 0:y.message)||String(y))}finally{A(!1)}}};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:[e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"wire-modal-title",className:"w-full max-w-5xl rounded-2xl bg-surface-1 border border-white/10 p-6 max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h3",{id:"wire-modal-title",className:"text-base font-semibold text-gray-100",children:['Wire "',s.name,'" into CI']}),e.jsx("button",{onClick:a,"aria-label":"Close",className:"text-gray-500 hover:text-gray-300",children:e.jsx($e,{size:16})})]}),e.jsx(rt,{message:se,onDismiss:()=>I(null)}),!i&&e.jsxs("div",{className:"mb-4 px-3 py-2.5 rounded-xl bg-amber-500/10 border border-amber-500/25 text-sm text-amber-300 flex items-center gap-3",children:[e.jsx(Ae,{size:15,className:"flex-shrink-0"}),e.jsxs("span",{className:"flex-1",children:["There is no active CI token yet — the pipeline needs one in its secrets as ",e.jsx("code",{children:"TESTVER_CI_TOKEN"}),"."]}),e.jsx("button",{onClick:n,className:"px-2.5 py-1 rounded-lg border border-amber-500/30 hover:bg-amber-500/10 text-xs font-medium whitespace-nowrap",children:"Go to CI Tokens"})]}),e.jsxs("label",{htmlFor:"wire-server-url",className:"block text-sm font-medium text-gray-300 mb-1",children:["Testver server URL ",e.jsx("span",{className:"text-gray-600",children:"(must be reachable from CI runners)"})]}),e.jsx("input",{id:"wire-server-url",value:o,onChange:m=>{w(m.target.value.trim()),T()},className:`w-full px-3 py-2 rounded-xl bg-surface-2 border text-sm text-gray-200 focus:outline-none mb-1 ${z?"border-amber-500/40":"border-white/10 focus:border-brand-500/50"}`}),z?e.jsxs("p",{className:"text-xs text-amber-300 mb-4",children:["⚠ ",z]}):e.jsx("div",{className:"mb-4"}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1 flex items-center gap-1.5",children:[e.jsx(Mt,{size:13})," From any terminal / script (exit 0 passed · 1 failed · 2 no verdict)"]}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 mb-1",children:[e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap break-all flex-1 m-0",children:re}),e.jsx("button",{onClick:()=>void ne("cli",re),"aria-label":"Copy the CLI command",className:"p-1.5 rounded-lg text-gray-400 hover:text-gray-200",children:_==="cli"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("p",{className:"text-xs text-gray-600 mb-4",children:["Needs Node.js (npx fetches the ",e.jsx("code",{children:"testver"})," CLI). Auth: set ",e.jsx("code",{children:"TESTVER_CI_TOKEN"})," (or pass ",e.jsx("code",{children:"--token"}),")."," ","Add ",e.jsx("code",{children:"--sha <commit> --branch <name>"})," to record the commit on the run (Trace, PR status)."," ","Add ",e.jsx("code",{children:"--no-wait"})," to return right away and let the commit status carry the verdict."]}),e.jsxs("span",{className:"block text-sm font-medium text-gray-300 mb-1.5 flex items-center gap-1.5",children:[e.jsx(Re,{size:14})," Pipeline config",e.jsx("span",{className:"font-normal text-gray-500",children:"— the CI job triggers Testver and gates on the verdict; nothing is installed on the runner"})]}),e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Platform"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 mb-4",children:Ve.map(m=>{const y=x===m.id;return e.jsxs("button",{onClick:()=>{N(m.id),T()},"aria-pressed":y,className:`relative flex items-center gap-2.5 px-3 py-2.5 rounded-xl border text-sm font-medium transition-colors text-left ${y?"bg-brand-500/10 border-brand-500 text-gray-900 dark:text-gray-100":"bg-surface-1 border-white/10 text-gray-600 dark:text-gray-300 hover:border-white/25 hover:bg-surface-2"}`,children:[e.jsx(Dt,{platform:m.id,size:18}),e.jsx("span",{className:"truncate",children:m.label}),y&&e.jsx(Ie,{size:14,className:"ml-auto text-brand-500 flex-shrink-0"})]},m.id)})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Gate mode"}),e.jsx("div",{className:"inline-flex p-1 rounded-xl bg-surface-2 border border-white/10",children:[{id:!1,label:"Wait & gate",hint:"exit code"},{id:!0,label:"Fire-and-forget",hint:"status push-back"}].map(m=>{const y=g===m.id;return e.jsxs("button",{onClick:()=>{v(m.id),T()},"aria-pressed":y,className:`px-3.5 py-2 rounded-lg text-sm font-medium transition-colors ${y?"bg-brand-600 text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"}`,children:[m.label,e.jsxs("span",{className:`ml-1.5 text-xs ${y?"text-white/70":"text-gray-500"}`,children:["(",m.hint,")"]})]},String(m.id))})})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs font-medium text-gray-500 uppercase tracking-wide mb-1.5",children:"Branches"}),e.jsx("input",{value:b,onChange:m=>{c(m.target.value),T()},placeholder:"main, release/* ( * = every branch)",className:"w-full px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("span",{className:"block text-xs text-gray-500 mt-1",children:R.branchNote||"Pushes to these branches, and pull requests targeting them, run the gate. Comma-separated; * = every branch."})]})]}),g&&e.jsxs("p",{className:"text-xs mb-2 px-3 py-2 rounded-lg border bg-amber-500/10 border-amber-500/25 text-amber-300",children:["The job triggers and exits immediately — the PR verdict comes from the commit status Testver pushes.",(Z=s.statusPush)!=null&&Z.enabled?" Status push-back is configured on this mapping. ✓":' ⚠ Enable "Push commit statuses" on this mapping first, or the PR will never get a verdict.']}),e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[e.jsxs("p",{className:"flex-1 text-sm text-gray-500 dark:text-gray-400 leading-relaxed px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:"Setup: "}),R.note]}),e.jsxs("button",{disabled:O||ae.length===0,onClick:async()=>{h(!0),B(!1),I(null);try{const m=await jt({platform:x,options:{branches:ae,delegate:{mapping:s.name,serverUrl:o,noWait:g}}});j(m.content),F(m.filePath),S(!!m.exists)}catch(m){I((m==null?void 0:m.message)||String(m))}finally{h(!1)}},className:"flex items-center gap-1.5 px-4 py-2.5 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white disabled:opacity-50 flex-shrink-0 transition-colors",children:[O?e.jsx(V,{size:14,className:"animate-spin"}):e.jsx(Re,{size:14}),d?"Regenerate":"Generate Config"]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"px-3 py-2.5 rounded-xl bg-surface-2 border border-white/10 text-xs text-gray-300 overflow-auto max-h-80 whitespace-pre",children:d}),e.jsx("button",{onClick:()=>void ne("yaml",d),"aria-label":"Copy the pipeline config",className:"absolute top-2 right-2 p-1.5 rounded-lg bg-surface-1 text-gray-400 hover:text-gray-200",children:_==="yaml"?e.jsx(Ie,{size:14,className:"text-emerald-400"}):e.jsx(Oe,{size:14})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[e.jsxs("span",{className:"text-xs text-gray-600",children:["Saves to ",e.jsx("code",{children:P})," in this project — commit & push it (token setup: see the note above).",$&&e.jsx("span",{className:"text-amber-300",children:" That file already exists — saving replaces it."})]}),e.jsxs("button",{disabled:E||k,onClick:()=>$?L(!0):void G(!1),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-emerald-600 hover:bg-emerald-500 text-white disabled:opacity-60 flex-shrink-0",children:[E?e.jsx(V,{size:13,className:"animate-spin"}):k?e.jsx(Ie,{size:13}):null,k?"Saved to project":"Save to project"]})]})]})]}),M&&e.jsx(Te,{open:!0,title:`Replace ${P}?`,description:"This file already exists in the project. Saving replaces its whole content with the Testver gate — anything else in it is lost (git still has the previous version).",confirmLabel:"Replace file",variant:"danger",onCancel:()=>L(!1),onConfirm:()=>{L(!1),G(!0)}})]})}function qe({title:s,rows:i,onSelect:n}){return e.jsxs("div",{className:"rounded-xl bg-surface-1 border border-white/5 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2.5 text-xs font-semibold text-gray-400 uppercase tracking-wide border-b border-white/5",children:s}),i.length===0?e.jsx("div",{className:"px-4 py-5 text-center text-xs text-gray-600",children:"No data yet"}):e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:i.slice(0,6).map(a=>e.jsxs("tr",{onClick:n?()=>n(a.key):void 0,className:`border-t border-white/5 first:border-t-0 ${n?"cursor-pointer hover:bg-white/[0.04] transition-colors":""}`,children:[e.jsx("td",{className:"px-4 py-2 text-gray-200 truncate max-w-[120px]",title:a.key,children:n?e.jsx("button",{onClick:o=>{o.stopPropagation(),n(a.key)},"aria-label":`Show runs for ${a.key}`,className:"text-left truncate max-w-full hover:text-brand-300 focus:outline-none focus-visible:underline",children:a.key}):a.key}),e.jsxs("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:[a.runs," run",a.runs!==1?"s":""]}),e.jsxs("td",{className:`px-2 py-2 font-medium whitespace-nowrap ${st(a.passRate)}`,title:(a.errored||0)>0?`${a.errored} errored run(s) count against the pass rate`:void 0,children:[a.passRate,"%"]}),e.jsx("td",{className:"px-2 py-2 text-gray-500 whitespace-nowrap",children:pe(a.avgDurationMs)}),e.jsx("td",{className:"px-3 py-2 text-right",children:e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${a.lastState==="passed"?"bg-emerald-400":a.lastState==="failed"||a.lastState==="error"?"bg-red-400":a.lastState==="running"||a.lastState==="queued"?"bg-blue-400 animate-pulse":"bg-gray-500"}`,title:`last: ${a.lastState} · ${W(a.lastAt)}`,"aria-label":`last run ${a.lastState}`})})]},a.key))})})]})}function Zt(){const[s,i]=Se("q"),[n,a]=l.useState(s||""),[o,w]=l.useState(null),[x,N]=l.useState(!1),[g,v]=l.useState(null),b=async(c=n)=>{const d=c.trim();if(d.length<2){v("Enter at least 2 characters — a commit sha (6 or more) or a branch name");return}N(!0),v(null),d!==s&&i(d);try{w(await wt(d))}catch(j){v((j==null?void 0:j.message)||String(j)),w(null)}finally{N(!1)}};return l.useEffect(()=>{s&&!o&&b(s)},[]),e.jsxs("section",{children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-100 flex items-center gap-2 mb-1",children:[e.jsx(Fe,{size:17,className:"text-amber-300"})," Trace a Deploy"]}),e.jsx("p",{className:"text-sm text-gray-400 mb-3",children:"Paste a commit sha (6 or more characters) or a branch name from a deploy to see every run that gated it — the CI verdicts plus any manual verification runs on the same commit."}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("input",{value:n,onChange:c=>a(c.target.value),onKeyDown:c=>{c.key==="Enter"&&b()},placeholder:"e.g. 2f812c2 or release/2.4","aria-label":"Commit sha or branch",className:"px-3 py-2 rounded-xl bg-surface-2 border border-white/10 text-sm text-gray-200 font-mono placeholder-gray-600 focus:outline-none focus:border-brand-500/50 w-80"}),e.jsxs("button",{onClick:()=>void b(),disabled:x,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl text-sm font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:[x?e.jsx(V,{size:14,className:"animate-spin"}):e.jsx(Fe,{size:14})," Trace"]})]}),g&&e.jsx("div",{role:"alert",className:"px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/30 text-xs text-red-300 mb-3",children:g}),o&&e.jsxs("div",{className:"space-y-1.5",children:[o.ciRuns.length===0&&o.otherRuns.length===0&&e.jsxs("div",{className:"px-4 py-4 rounded-xl border border-dashed border-white/10 text-sm text-gray-500 text-center",children:["No runs found for ",e.jsx("code",{children:o.query}),".",o.hint?` ${o.hint}.`:""]}),o.ciRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm",children:[e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full border flex-shrink-0 ${Pe[c.state]}`,children:c.state}),e.jsx("span",{className:"text-gray-200 font-medium",children:c.mappingName}),c.buildNumber&&e.jsxs("span",{className:"text-gray-500 text-xs",children:["#",c.buildNumber]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.branch,c.sha?` · ${c.sha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),c.error&&e.jsx("span",{className:"text-xs text-red-300 truncate max-w-[280px]",title:c.error,children:c.error}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[W(c.createdAt)," · ",pe(c.durationMs)]}),c.buildUrl&&e.jsx("a",{href:c.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"CI build","aria-label":"Open the CI build",className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Je,{size:13})}),c.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.id)),o.otherRuns.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 rounded-xl bg-surface-1 border border-white/5 text-sm opacity-90",children:[e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full border bg-white/5 border-white/10 text-gray-400 flex-shrink-0",children:c.origin||"run"}),e.jsx("span",{className:"text-xs text-gray-400 flex-shrink-0",children:c.status}),e.jsx("span",{className:"text-gray-200",children:c.label||c.runId}),e.jsxs("span",{className:"text-sm text-gray-400",children:[c.gitBranch,c.gitCommitSha?` · ${c.gitCommitSha.slice(0,7)}`:""]}),c.summary&&e.jsxs("span",{className:"text-sm text-gray-300",children:[e.jsx("span",{className:"text-emerald-400",children:c.summary.passed}),"/",c.summary.total," passed"]}),e.jsxs("span",{className:"text-sm text-gray-500 ml-auto",children:[W(c.startTime)," · ",pe(c.duration)]}),e.jsx("a",{href:`/results?runId=${encodeURIComponent(c.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Testver report","aria-label":"Open the Testver report",className:"p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]},c.runId)),o.searched&&e.jsxs("p",{className:"text-xs text-gray-600 pt-1",children:["Searched the latest ",o.searched.ciRuns," CI runs and ",o.searched.otherRuns," other runs."]})]})]})}function We({runs:s,emptyNote:i,onCancel:n}){return e.jsx("div",{className:"rounded-xl border border-white/5 overflow-hidden bg-surface-1",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-xs text-gray-500 uppercase tracking-wide border-b border-white/5",children:[e.jsx("th",{className:"px-4 py-2.5",children:"State"}),e.jsx("th",{className:"px-4 py-2.5",children:"Pipeline"}),e.jsx("th",{className:"px-4 py-2.5",children:"Branch / Commit"}),e.jsx("th",{className:"px-4 py-2.5",children:"Result"}),e.jsx("th",{className:"px-4 py-2.5",children:"Duration"}),e.jsx("th",{className:"px-4 py-2.5",children:"Triggered"}),e.jsx("th",{className:"px-4 py-2.5 text-right",children:"Links"})]})}),e.jsxs("tbody",{children:[s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-4 py-6 text-center text-sm text-gray-500",children:i||"No runs."})}),s.map(a=>e.jsxs("tr",{className:"border-t border-white/5 align-top",children:[e.jsx("td",{className:"px-4 py-2.5",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full border ${Pe[a.state]}`,children:[(a.state==="running"||a.state==="queued")&&e.jsx(V,{size:10,className:"animate-spin"}),a.state,a.state==="queued"&&a.queuePosition?` #${a.queuePosition}`:""]})}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-200",children:[a.mappingName||"—",a.buildNumber&&e.jsxs("span",{className:"text-gray-500 ml-1.5",children:["#",a.buildNumber]})]}),e.jsxs("td",{className:"px-4 py-2.5 text-gray-300 text-sm",children:[a.branch||"—",a.sha&&e.jsx("code",{className:"ml-1.5 text-gray-500",children:a.sha.slice(0,7)})]}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-300 max-w-[320px]",children:[a.summary&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-emerald-400",children:a.summary.passed})," / ",a.summary.total," passed",a.summary.failed>0&&e.jsxs("span",{className:"text-red-400 ml-1",children:["(",a.summary.failed," failed)"]})]}),a.error&&e.jsx("span",{className:"block text-xs text-red-300 mt-0.5 line-clamp-2",title:a.error,children:a.error}),!a.summary&&!a.error&&"—",a.pushWarning&&e.jsxs("span",{className:"block text-xs text-amber-400/80 mt-0.5 line-clamp-2",title:a.pushWarning,children:["PR status not posted: ",a.pushWarning]}),a.autoHeal&&e.jsxs("span",{className:"block text-[11px] mt-0.5 space-x-2",children:[a.autoHeal.healed>0&&e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-300",title:"Locator repaired, verified by re-run, and kept — the summary above counts the original failure",children:["✦ ",a.autoHeal.healed," healed & verified"]}),a.autoHeal.suggested>0&&e.jsxs("span",{className:"text-purple-600 dark:text-purple-300",title:"A verified fix is waiting — open the run in Results and click Apply fix",children:[a.autoHeal.suggested," fix",a.autoHeal.suggested>1?"es":""," ready"]}),a.autoHeal.reverted>0&&e.jsxs("span",{className:"text-amber-600 dark:text-amber-300",title:"A repair was tried but failed verification — files were restored",children:[a.autoHeal.reverted," reverted"]})]})]}),e.jsx("td",{className:"px-4 py-2.5 text-sm text-gray-400",title:"Time on the Testver server (queue wait not included)",children:pe(a.durationMs)}),e.jsxs("td",{className:"px-4 py-2.5 text-sm text-gray-400",children:[W(a.createdAt)," by ",a.triggeredBy]}),e.jsxs("td",{className:"px-4 py-2.5 text-right whitespace-nowrap",children:[n&&(a.state==="queued"||a.state==="running")&&e.jsx("button",{onClick:()=>n(a),title:"Cancel this run","aria-label":`Cancel the ${a.mappingName||"CI"} run`,className:"inline-flex p-1.5 rounded-lg text-red-400 hover:text-red-500 hover:bg-red-500/10",children:e.jsx(At,{size:13})}),a.buildUrl&&e.jsx("a",{href:a.buildUrl,target:"_blank",rel:"noopener noreferrer",title:"Open CI build","aria-label":"Open the CI build",className:"inline-flex p-1.5 rounded-lg text-gray-500 hover:text-gray-200 hover:bg-white/5",children:e.jsx(Je,{size:13})}),a.runId&&e.jsx("a",{href:`/results?runId=${encodeURIComponent(a.runId)}`,target:"_blank",rel:"noopener noreferrer",title:"Open Testver report","aria-label":"Open the Testver report",className:"inline-flex p-1.5 rounded-lg text-brand-400 hover:text-brand-300 hover:bg-white/5",children:e.jsx(ue,{size:13})})]})]},a.id))]})]})})}export{as as PipelinesPage};
@@ -1,2 +0,0 @@
1
- import{j as e,r as h}from"./vendor-react-CTbHBddL.js";import{f as Q}from"./formatDate-T65-Y6Mi.js";import{cy as pe,dl as ue,dm as be,a3 as _,dn as ye,dp as fe,dq as I,_ as ke,a9 as je,y as ve,ak as we,dd as Ne,aq as Se}from"./vendor-icons-B0wLOBoh.js";import{R as A,P as Ce,m as Le,n as Ee,T as D,o as R,B as V,h as K,X as P,Y as H,l as Z,j as Fe,L as Ae}from"./vendor-charts-DWFQlmCz.js";import{b as De}from"./AIStreamUI-BsxKziYG.js";import{a8 as Re,bN as Be,a1 as ee,gI as Te,gJ as $e,gK as ze,gL as Me}from"./index-DtBWNlVD.js";function se(a){return a.toLocaleString(void 0,{maximumFractionDigits:1})}function _e(a,r){return`${a>0?"+":""}${se(a)}${r??""}`}function Ie({cell:a}){const{title:r,value:t,unit:o,delta:l,deltaGood:n,hint:d}=a,i=typeof l=="number"&&Number.isFinite(l),p=a.deltaDirection??(i?l>0?"up":l<0?"down":"flat":void 0),b=n??"up",x=p==="flat"||l===0,v=x?"text-gray-500 dark:text-gray-400":p==="up"&&b==="up"||p==="down"&&b==="down"?"text-emerald-600 dark:text-emerald-400":"text-rose-600 dark:text-rose-400",j=x?pe:p==="up"?ue:be;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4 h-full flex flex-col justify-between",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:r}),e.jsxs("div",{className:"mt-2 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100 tabular-nums",children:typeof t=="number"?se(t):t}),o&&e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:o})]}),i&&e.jsxs("div",{className:`mt-2 flex items-center gap-1 text-xs ${v}`,children:[e.jsx(j,{size:12}),e.jsx("span",{className:"tabular-nums font-medium",children:_e(l,o)}),d&&e.jsx("span",{className:"text-gray-500 dark:text-gray-400 ml-1",children:d})]}),!i&&d&&e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:d})]})}function B({active:a,payload:r,label:t}){return!a||!r||r.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[t!=null&&t!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(t)}),e.jsx("div",{className:"space-y-1",children:r.map((o,l)=>{var p;const n=o.value,d=String(o.name??o.dataKey??""),i=o.color||((p=o.payload)==null?void 0:p.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:i}}),d&&d!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:d}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof n=="number"?Number.isInteger(n)?n.toLocaleString():n.toFixed(2):String(n??"")})]},l)})})]})}const te={vibrant:["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#14B8A6","#F97316","#6366F1","#06B6D4"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},Ke={status:{passed:"#10B981",failed:"#EF4444",skipped:"#F59E0B",blocked:"#F97316",not_run:"#6B7280",in_progress:"#3B82F6"},priority:{critical:"#EF4444",high:"#F97316",medium:"#F59E0B",low:"#3B82F6"},severity:{blocker:"#DC2626",critical:"#EF4444",major:"#F59E0B",minor:"#3B82F6",trivial:"#6B7280"}};function ae(a,r,t){if(Array.isArray(t)&&t.length>=a.length&&t.every(n=>typeof n=="string"))return t;const o=te.vibrant;if(r==="status"||r==="priority"||r==="severity"){const n=Ke[r];return a.map((d,i)=>n[String(d).toLowerCase().replace(/\s+/g,"_")]||o[i%o.length])}const l=r==="pastel"?te.pastel:o;return a.map((n,d)=>l[d%l.length])}const T=a=>r=>{const t=String(r??"");return t.length>a?`${t.slice(0,a-1)}…`:t},re=a=>(Array.isArray(a)?a:[]).map(r=>typeof r=="number"&&Number.isFinite(r)?r:Number(r)||0);function Pe({cell:a,height:r=260}){var m;const t=h.useMemo(()=>{var N;const c=(Array.isArray(a.labels)?a.labels:[]).map(k=>String(k??"")),g=(Array.isArray(a.datasets)?a.datasets:[]).filter(k=>k&&typeof k=="object").map((k,L)=>({label:String(k.label??`Series ${L+1}`),data:re(k.data)})),u=a.chartType==="pie"||a.chartType==="doughnut",y=Array.isArray(a.data)&&a.data.length>0?re(a.data):u?(N=g[0])==null?void 0:N.data:void 0;return{...a,labels:c,data:y,datasets:u?void 0:g.length>0?g:void 0}},[a]),o=h.useMemo(()=>ae(t.labels,t.colorScheme,t.colors),[t.labels,t.colorScheme,t.colors]),l=h.useMemo(()=>ae((t.datasets||[]).map(c=>c.label),t.colorScheme,t.colors),[t.datasets,t.colorScheme,t.colors]),n=t.datasets&&t.datasets.length>0?l:o,d=h.useMemo(()=>t.datasets&&t.datasets.length>0?t.labels.map((c,g)=>{const u={label:c};for(const y of t.datasets)u[y.label]=y.data[g]??0;return u}):t.labels.map((c,g)=>{var u;return{label:c,value:((u=t.data)==null?void 0:u[g])??0}}),[t.labels,t.data,t.datasets]),i=((m=t.datasets)==null?void 0:m.map(c=>c.label))??["value"],p=t.labels.reduce((c,g)=>Math.max(c,g.length),0),b={fill:"rgb(107 114 128)",fontSize:11},x="rgba(107,114,128,0.2)",C={stroke:"rgba(107,114,128,0.4)"},v={fill:"rgba(107,114,128,0.08)"},j={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(t.labels.length===0||!t.datasets&&!(t.data&&t.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(t.chartType){case"line":return e.jsx(A,{width:"100%",height:r,children:e.jsxs(Fe,{data:d,margin:{top:8,right:16,bottom:8,left:0},children:[e.jsx(K,{strokeDasharray:"3 3",stroke:x}),e.jsx(P,{dataKey:"label",tick:b,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:T(16)}),e.jsx(H,{tick:b,axisLine:!1,tickLine:!1}),e.jsx(D,{content:e.jsx(B,{}),cursor:C}),i.length>1&&e.jsx(R,{wrapperStyle:j}),i.map((c,g)=>e.jsx(Ae,{type:"monotone",dataKey:c,stroke:n[g%n.length],strokeWidth:2,dot:{r:3,fill:n[g%n.length]},activeDot:{r:5}},c))]})});case"bar":case"stacked_bar":return e.jsx(A,{width:"100%",height:r,children:e.jsxs(V,{data:d,margin:{top:8,right:16,bottom:8,left:0},children:[e.jsx(K,{strokeDasharray:"3 3",stroke:x}),e.jsx(P,{dataKey:"label",tick:b,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:T(16)}),e.jsx(H,{tick:b,axisLine:!1,tickLine:!1}),e.jsx(D,{content:e.jsx(B,{}),cursor:v}),i.length>1&&e.jsx(R,{wrapperStyle:j}),i.map((c,g)=>e.jsx(Z,{dataKey:c,fill:n[g%n.length],radius:[4,4,0,0],stackId:t.chartType==="stacked_bar"?"s1":void 0},c))]})});case"horizontal_bar":return e.jsx(A,{width:"100%",height:Math.max(r,t.labels.length*28+40),children:e.jsxs(V,{data:d,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},children:[e.jsx(K,{strokeDasharray:"3 3",stroke:x,horizontal:!1}),e.jsx(P,{type:"number",tick:b,axisLine:!1,tickLine:!1}),e.jsx(H,{type:"category",dataKey:"label",tick:b,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,p*6.5)),tickFormatter:T(28)}),e.jsx(D,{content:e.jsx(B,{}),cursor:v}),i.length>1&&e.jsx(R,{wrapperStyle:j}),i.map((c,g)=>e.jsx(Z,{dataKey:c,fill:n[g%n.length],radius:[0,4,4,0]},c))]})});case"pie":case"doughnut":{const c=t.labels.map((g,u)=>{var y;return{name:g,value:((y=t.data)==null?void 0:y[u])??0}});return e.jsx(A,{width:"100%",height:r,children:e.jsxs(Ce,{children:[e.jsx(Le,{data:c,dataKey:"value",nameKey:"name",innerRadius:t.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:c.map((g,u)=>e.jsx(Ee,{fill:n[u%n.length],stroke:"transparent"},u))}),e.jsx(D,{content:e.jsx(B,{})}),e.jsx(R,{wrapperStyle:j,formatter:T(32)})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",t.chartType]})}}const He=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function Oe(){const a=h.useRef(null),[r,t]=h.useState(0);return h.useEffect(()=>{const o=a.current;if(!o||typeof ResizeObserver>"u")return;const l=new ResizeObserver(n=>{var d;return t(((d=n[0])==null?void 0:d.contentRect.width)??0)});return l.observe(o),t(o.getBoundingClientRect().width),()=>l.disconnect()},[]),[a,r]}function Ve({spec:a,urls:r,savedId:t,initialShareToken:o,initialShareExpiresAt:l,readonly:n=!1}){const{hasRole:d}=Re(),i=!n&&d("tester"),[p,b]=h.useState(!1),[x,C]=h.useState(t),[v,j]=h.useState(!1),[m,c]=h.useState(o),[g,u]=h.useState(l),[y,N]=h.useState(!1),[k,L]=h.useState("closed"),[O,ne]=h.useState(void 0),[$,E]=h.useState(!1),[W,U]=h.useState(null),[q,Y]=h.useState(null),[ie,G]=Oe();h.useEffect(()=>{t&&C(t)},[t]),h.useEffect(()=>{o&&c(o)},[o]),h.useEffect(()=>{l&&u(l)},[l]);const w=s=>{Y(s),setTimeout(()=>Y(null),2600)},S=m?`/reports/share/${m}`:x?`/reports/view/${x}`:(r==null?void 0:r.html)||"",oe=async()=>{if(!S)return;const s=`${window.location.origin}${S}`;try{await navigator.clipboard.writeText(s),b(!0),setTimeout(()=>b(!1),1500)}catch{}},X=async()=>{const s=await Me({title:a.title,spec:a,outputFiles:r?{html:r.html,json:r.json}:void 0});return C(s.id),s.id},le=async()=>{if(!(x||v)){j(!0);try{await X(),w("Saved to your reports")}catch(s){w(`Save failed: ${s instanceof Error?s.message:String(s)}`)}finally{j(!1)}}},de=async()=>{if(!y){N(!0);try{const s=x??await X(),{token:f,shareExpiresAt:me}=await $e(s,O);c(f),u(me),L("link"),w("Share link created")}catch(s){w(`Share failed: ${s instanceof Error?s.message:String(s)}`)}finally{N(!1)}}},ce=async()=>{if(!(!m||!x)){N(!0);try{await ze(x),c(void 0),u(void 0),L("closed"),w("Share link revoked")}catch(s){w(`Revoke failed: ${s instanceof Error?s.message:String(s)}`)}finally{N(!1)}}},z=m?`${window.location.origin}/reports/share/${m}`:"",xe=async()=>{if(z)try{await navigator.clipboard.writeText(z),w("Share URL copied")}catch{}},J=n&&m?`/api/reports/share/${encodeURIComponent(m)}/render.html`:x?Be(`/api/reports/${encodeURIComponent(x)}/render.html`):m?`/api/reports/share/${encodeURIComponent(m)}/render.html`:r!=null&&r.html?ee(r.html):null,he=async s=>{E(!1),U(s);try{await Te(s,n&&m?{shareToken:m}:x?{reportId:x}:{spec:a,title:a.title})}catch(f){w(`Download failed: ${f instanceof Error?f.message:String(f)}`)}finally{U(null)}},M=h.useRef(null);h.useEffect(()=>{if(!$)return;const s=f=>{M.current&&!M.current.contains(f.target)&&E(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[$]);const F="p-1.5 rounded-md text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5 transition-colors disabled:opacity-70",ge=G>0&&G<640;return e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-3 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex items-start gap-3",children:[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 truncate",children:a.title}),a.subtitle&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate mt-0.5",children:a.subtitle}),e.jsxs("div",{className:"text-[10px] text-gray-400 dark:text-gray-500 mt-0.5",children:["Generated ",Q(a.generatedAt)]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[i&&e.jsx("button",{onClick:le,disabled:!!x||v,title:x?"Saved to your reports":"Save to your reports",className:`p-1.5 rounded-md transition-colors ${x?"text-emerald-600 dark:text-emerald-400":"text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5"} disabled:opacity-70`,children:v?e.jsx(_,{size:14,className:"animate-spin"}):x?e.jsx(ye,{size:14}):e.jsx(fe,{size:14})}),i&&e.jsx("button",{onClick:()=>L(s=>s==="closed"?m?"link":"create":"closed"),disabled:y,title:m?"Public link active — view or revoke":"Create a public share link",className:m?"p-1.5 rounded-md text-brand-500 hover:text-brand-600 hover:bg-brand-500/10 transition-colors":F,children:y?e.jsx(_,{size:14,className:"animate-spin"}):e.jsx(I,{size:14})}),S&&e.jsx("a",{href:S.startsWith("/api/")?ee(S):S,target:"_blank",rel:"noopener noreferrer",title:m?"Open shareable full view (new tab)":x?"Open full view (new tab)":"Open HTML snapshot (new tab)",className:F,children:e.jsx(ke,{size:14})}),e.jsxs("div",{className:"relative",ref:M,children:[e.jsxs("button",{onClick:()=>E(s=>!s),disabled:!!W,title:"Download",className:`${F} flex items-center`,children:[W?e.jsx(_,{size:14,className:"animate-spin"}):e.jsx(je,{size:14}),e.jsx(ve,{size:10,className:"ml-0.5"})]}),$&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-20 w-40 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-xs",children:[J&&e.jsx("a",{href:J,download:`${a.title||a.id}.html`,onClick:()=>E(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([s,f])=>e.jsx("button",{onClick:()=>he(s),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:f},s))]})]}),S&&e.jsx("button",{onClick:oe,title:p?"Copied!":m?"Copy share link":x?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)",className:F,children:p?e.jsx(we,{size:14,className:"text-emerald-500"}):e.jsx(Ne,{size:14})})]})]}),i&&k==="create"&&!m&&e.jsxs("div",{className:"px-5 py-2.5 border-b border-gray-200 dark:border-white/10 bg-brand-500/5 flex items-center gap-2 text-xs flex-wrap",children:[e.jsx(I,{size:12,className:"text-brand-500 flex-shrink-0"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-600 dark:text-gray-400 ml-auto",children:["Expires",e.jsx("select",{value:O??"",onChange:s=>ne(s.target.value?Number(s.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.05] text-[11px]",children:He.map(s=>e.jsx("option",{value:s.days??"",children:s.label},s.label))})]}),e.jsx("button",{onClick:de,disabled:y,className:"px-2 py-1 rounded text-[11px] font-medium bg-brand-500/15 hover:bg-brand-500/25 text-brand-600 dark:text-brand-300 transition-colors",children:"Create link"})]}),i&&m&&k==="link"&&e.jsxs("div",{className:"px-5 py-2.5 border-b border-gray-200 dark:border-white/10 bg-brand-500/5 flex items-center gap-2 text-xs flex-wrap",children:[e.jsx(I,{size:12,className:"text-brand-500 flex-shrink-0"}),e.jsx("span",{className:"text-gray-600 dark:text-gray-400 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[11px] text-brand-600 dark:text-brand-300 bg-white dark:bg-white/[0.05] border border-brand-500/20 rounded px-2 py-1",children:z}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:g?`Expires ${Q(g)}`:"No expiry"}),e.jsx("button",{onClick:xe,className:"px-2 py-1 rounded text-[11px] font-medium bg-brand-500/15 hover:bg-brand-500/25 text-brand-600 dark:text-brand-300 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:ce,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded text-[11px] font-medium text-rose-600 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Se,{size:11})," Revoke"]})]}),q&&e.jsx("div",{className:"px-5 py-1.5 text-[11px] text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-white/[0.02] border-b border-gray-200 dark:border-white/10",children:q}),e.jsx("div",{ref:ie,className:"p-4 grid grid-cols-12 gap-3",children:a.cells.map((s,f)=>e.jsx(We,{cell:s,narrow:ge},f))})]})}function We({cell:a,narrow:r}){const t=a.type==="kpi"?3:a.type==="chart"?6:12,o=Math.max(1,Math.min(12,Math.round(Number(a.span)||t))),l=r?a.type==="kpi"?6:12:o,n={gridColumn:`span ${l} / span ${l}`};if(a.type==="kpi")return e.jsx("div",{style:n,children:e.jsx(Ie,{cell:a})});if(a.type==="chart")return e.jsx("div",{style:n,children:e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4 h-full",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mb-2",children:a.title}),e.jsx(Pe,{cell:a}),a.hint&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mt-2",children:a.hint})]})});if(a.type==="table"){const d=(Array.isArray(a.headers)?a.headers:[]).map(p=>String(p??"")),i=(Array.isArray(a.rows)?a.rows:[]).map(p=>(Array.isArray(p)?p:[p]).map(b=>String(b??"")));return e.jsx("div",{style:n,children:e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] overflow-hidden px-3 pt-2 pb-1",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 px-1",children:a.title}),e.jsx(De,{headers:d.length?d:null,rows:i,alignNumbers:!0}),a.hint&&e.jsx("div",{className:"px-1 pb-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:a.hint})]})})}return a.type==="markdown"?e.jsx("div",{style:n,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4",children:e.jsx(Ue,{content:String(a.content??"")})})}):null}function Ue({content:a}){const r=a.split(`
2
- `),t=[];let o=[];const l=()=>{o.length!==0&&(t.push(e.jsx("ul",{className:"list-disc list-inside text-xs text-gray-700 dark:text-gray-300 space-y-1 my-2",children:o.map((d,i)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:n(d)}},i))},t.length)),o=[])},n=d=>d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[11px]">$1</code>');for(const d of r){const i=d.trim();if(!i){l();continue}i.startsWith("## ")?(l(),t.push(e.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200 mt-3 mb-2",dangerouslySetInnerHTML:{__html:n(i.slice(3))}},t.length))):i.startsWith("# ")?(l(),t.push(e.jsx("h2",{className:"text-base font-bold text-gray-900 dark:text-gray-100 mt-3 mb-2",dangerouslySetInnerHTML:{__html:n(i.slice(2))}},t.length))):i.startsWith("- ")||i.startsWith("* ")?o.push(i.slice(2)):(l(),t.push(e.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:n(i)}},t.length)))}return l(),e.jsx(e.Fragment,{children:t})}export{Ve as R};
@@ -1 +0,0 @@
1
- import{o as S,u as C,r,j as e}from"./vendor-react-CTbHBddL.js";import{b as E,a8 as D,iy as T,a0 as z,it as A}from"./index-DtBWNlVD.js";import{C as L}from"./ConfirmDialog-DNU3qoAP.js";import{R as B}from"./ReportCard-BbNfk85h.js";import{a3 as v,an as j,l as I,R as $,S as F,b9 as P}from"./vendor-icons-B0wLOBoh.js";import"./vendor-query-BrzmPFT3.js";import"./formatDate-T65-Y6Mi.js";import"./vendor-charts-DWFQlmCz.js";import"./AIStreamUI-BsxKziYG.js";function Q(){const{id:l}=S(),d=C(),o=E(),R=D().hasRole("tester"),[t,u]=r.useState(null),[k,c]=r.useState(!0),[n,h]=r.useState(!1),[a,f]=r.useState(!1),[g,x]=r.useState(null),[N,m]=r.useState(!1),y=async s=>{if(!l){x("No report ID in URL"),c(!1);return}m(!1),s!=null&&s.initial?c(!0):h(!0),x(null);try{const i=await z(l);u(i)}catch(i){x(i instanceof Error?i.message:String(i))}finally{c(!1),h(!1)}};r.useEffect(()=>{y({initial:!0})},[l]);const w=async()=>{if(t)try{await A(t.id),o.toast("success","Report deleted"),d("/reports")}catch(s){o.toast("error",`Delete failed: ${s instanceof Error?s.message:String(s)}`)}};if(k)return e.jsxs("div",{className:"p-6 flex items-center justify-center text-sm text-gray-500 dark:text-gray-400 gap-2",children:[e.jsx(v,{size:14,className:"animate-spin"})," Loading report…"]});const p=(t==null?void 0:t.mine)!==!1,b=R&&p;return g||!t?e.jsxs("div",{className:"p-6 max-w-2xl mx-auto",children:[e.jsxs("button",{onClick:()=>d("/reports"),className:"flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 mb-4",children:[e.jsx(j,{size:12})," Back to Reports"]}),e.jsxs("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/5 p-6 text-center",children:[e.jsx(I,{size:24,className:"text-rose-500 mx-auto mb-3"}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Could not load report"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400",children:g||"Report not found"})]})]}):e.jsxs("div",{className:"p-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("button",{onClick:()=>d("/reports"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors",children:[e.jsx(j,{size:12})," Back to Reports"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>y(),disabled:n||a,className:"flex items-center gap-1 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:"Re-fetch the SAVED snapshot from the server. The chart values stay the same unless someone has edited the saved report.",children:[e.jsx($,{size:12,className:n?"animate-spin":""}),n?"Reloading…":"Reload"]}),b&&e.jsxs("button",{onClick:async()=>{if(!(!t||a)){f(!0);try{const s=await T(t.id);u(s),o.toast("success","Report regenerated with current data")}catch(s){o.toast("error",`Regenerate failed: ${s instanceof Error?s.message:String(s)}`)}finally{f(!1)}}},disabled:a||n,className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs text-brand-600 dark:text-brand-400 hover:bg-brand-500/10 transition-colors disabled:opacity-60",title:"Re-run the AI workflow that built this dashboard so the KPI/chart/table values reflect the CURRENT state of Testver. The saved report's id, share link, and pin state are preserved — only the spec values are refreshed. Takes ~30s to a couple of minutes.",children:[a?e.jsx(v,{size:12,className:"animate-spin"}):e.jsx(F,{size:12}),a?"Regenerating…":"Regenerate with current data"]}),b&&e.jsxs("button",{onClick:()=>m(!0),className:"flex items-center gap-1 px-2 py-1 rounded-md text-xs text-rose-600 dark:text-rose-400 hover:bg-rose-500/10 transition-colors",children:[e.jsx(P,{size:12})," Delete"]})]})]}),!p&&t.sharedByName&&e.jsxs("div",{className:"mb-2 text-xs text-gray-500 dark:text-gray-400","data-testid":"report-shared-by",children:["Shared by ",t.sharedByName]}),e.jsx(B,{spec:t.spec,urls:t.outputFiles,savedId:t.id,initialShareToken:t.shareToken,initialShareExpiresAt:t.shareExpiresAt,readonly:!p}),e.jsx(L,{open:N,title:"Delete report?",description:`"${t.title}" will be permanently deleted. Any active share link will stop working.`,confirmLabel:"Delete",onConfirm:w,onCancel:()=>m(!1)})]})}export{Q as ReportFullView};
@@ -1,48 +0,0 @@
1
- import{r as i,j as e,u as F}from"./vendor-react-CTbHBddL.js";import{a as E,f as I}from"./formatDate-T65-Y6Mi.js";import{s as G}from"./visibleInterval-BKsLfJZ3.js";import{b as L,a8 as _,ip as q,bN as W,iq as Y,ir as B,is as X,gK as J,gJ as Z,gI as ee,it as te,iu as ae,iv as M,iw as se,ix as re}from"./index-DtBWNlVD.js";import{C as O}from"./ConfirmDialog-DNU3qoAP.js";import{C as ne}from"./CronBuilder-DsnX-vRr.js";import{h as ie}from"./aiHandoff-vhtR29Fh.js";import{g as U,a1 as V,S as Q,dq as A,a3 as C,R as K,bq as P,bp as le,b9 as H,a9 as $,ae as oe,_ as de,b6 as ce,ak as z,X as xe,a7 as he,y as me,bD as pe}from"./vendor-icons-B0wLOBoh.js";import"./vendor-query-BrzmPFT3.js";function Ce(){const[o,r]=i.useState("my"),n=[{id:"my",label:"My Reports",Icon:U},{id:"scheduled",label:"Scheduled",Icon:V},{id:"templates",label:"Templates",Icon:Q},{id:"shared",label:"Shared",Icon:A}];return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Reports"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:["Dashboards generated through the ",e.jsx("em",{className:"italic text-gray-700 dark:text-gray-300",children:"AI Assistant in Reporting mode"})," live here."," ",e.jsx("em",{className:"italic text-gray-700 dark:text-gray-300",children:"My Reports"})," opens, pins, shares, or regenerates any saved dashboard with current data."," ",e.jsx("em",{className:"italic text-gray-700 dark:text-gray-300",children:"Scheduled"})," emails the latest version of a saved report on a recurring cadence."," ",e.jsx("em",{className:"italic text-gray-700 dark:text-gray-300",children:"Templates"})," kicks off a new report from a quick-start prompt, and"," ",e.jsx("em",{className:"italic text-gray-700 dark:text-gray-300",children:"Shared"})," lists every report shared in this workspace via a public link — anyone signed in can open and download them."]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-gray-200 dark:border-white/10 mb-5",children:n.map(h=>{const d=h.Icon,u=o===h.id;return e.jsxs("button",{onClick:()=>r(h.id),className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors -mb-px ${u?"border-brand-500 text-brand-600 dark:text-brand-400":"border-transparent text-gray-500 hover:text-gray-700 dark:hover:text-gray-300"}`,children:[e.jsx(d,{size:14}),h.label]},h.id)})}),o==="my"&&e.jsx(D,{shared:!1}),o==="shared"&&e.jsx(D,{shared:!0}),o==="scheduled"&&e.jsx(ue,{}),o==="templates"&&e.jsx(ye,{})]})}function D({shared:o}){const r=F(),n=L(),h=_().hasRole("tester"),[d,u]=i.useState(null),[S,w]=i.useState([]),[j,g]=i.useState(!0),[N,b]=i.useState(!1),[c,y]=i.useState(null),[x,m]=i.useState(0),f=async t=>{t!=null&&t.initial?g(!0):b(!0);try{const s=o?await Y():await B();w(s.reports)}catch(s){n.toast("error",`Load failed: ${s instanceof Error?s.message:String(s)}`)}finally{g(!1),b(!1)}};i.useEffect(()=>{f({initial:!0})},[]),i.useEffect(()=>{if(!c){m(0);return}(async()=>{try{const{schedules:t}=await q();m(t.filter(s=>s.sourceReportId===c.id).length)}catch{m(0)}})()},[c]);const v=o?S.filter(t=>!!t.shareToken):S,p=t=>h&&t.mine!==!1,T=async t=>{try{await X(t.id,{pinned:!t.pinned}),await f()}catch(s){n.toast("error",`Pin failed: ${s instanceof Error?s.message:String(s)}`)}},R=async()=>{if(c)try{await te(c.id),y(null),n.toast("success","Report deleted"),await f()}catch(t){n.toast("error",`Delete failed: ${t instanceof Error?t.message:String(t)}`)}},l=async(t,s)=>{u(`${t.id}:${s}`);try{await ee(s,{reportId:t.id})}catch(k){n.toast("error",`Download failed: ${k instanceof Error?k.message:String(k)}`)}finally{u(null)}},a=async t=>{try{if(t.shareToken)await J(t.id),n.toast("success","Share link revoked");else{const{shareUrl:s}=await Z(t.id),k=`${window.location.origin}${s}`;try{await navigator.clipboard.writeText(k)}catch{}n.toast("success",`Share link copied: ${k}`)}await f()}catch(s){n.toast("error",`Share failed: ${s instanceof Error?s.message:String(s)}`)}};return j?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400 py-10 justify-center",children:[e.jsx(C,{size:14,className:"animate-spin"})," Loading reports…"]}):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:[v.length," report",v.length===1?"":"s"]}),e.jsxs("button",{onClick:()=>f(),disabled:N,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",children:[e.jsx(K,{size:12,className:N?"animate-spin":""}),N?"Refreshing…":"Refresh"]})]}),v.length===0&&e.jsxs("div",{className:"text-center py-16 text-gray-500 dark:text-gray-400",children:[e.jsx(U,{size:32,className:"mx-auto mb-3 opacity-40"}),e.jsx("div",{className:"text-sm",children:o?"No shared reports yet.":"No saved reports yet."}),e.jsx("div",{className:"text-xs mt-2",children:o?h?"Reports shared by anyone in this workspace appear here. To share one of yours, click the Share icon on it in My Reports.":"Reports shared by anyone in this workspace appear here.":"Build a dashboard in Reporting mode and click the bookmark icon to save it here."})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:v.map(t=>e.jsxs("div",{className:"group rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] p-4 flex flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[t.pinned&&e.jsx(P,{size:12,className:"text-amber-500 mt-1 flex-shrink-0"}),e.jsx("div",{className:"font-semibold text-sm text-gray-900 dark:text-gray-100 truncate",children:t.title})]}),p(t)&&e.jsxs("div",{className:"flex gap-1 transition-opacity [@media(hover:hover)]:opacity-0 [@media(hover:hover)]:group-hover:opacity-100 focus-within:opacity-100",children:[e.jsx("button",{onClick:()=>T(t),className:"p-1 rounded text-gray-400 hover:text-amber-500 hover:bg-white/5",title:t.pinned?"Unpin":"Pin",children:t.pinned?e.jsx(le,{size:12}):e.jsx(P,{size:12})}),e.jsx("button",{onClick:()=>a(t),className:`p-1 rounded hover:bg-white/5 ${t.shareToken?"text-emerald-500 hover:text-emerald-600":"text-gray-400 hover:text-brand-500"}`,title:t.shareToken?"Revoke share link":"Create a public share link (copied to clipboard)",children:e.jsx(A,{size:12})}),e.jsx("button",{onClick:()=>y(t),className:"p-1 rounded text-gray-400 hover:text-rose-500 hover:bg-white/5",title:"Delete",children:e.jsx(H,{size:12})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-500 dark:text-gray-400 mb-3 flex-wrap",children:[t.templateId&&e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-600 dark:text-brand-400 font-medium",children:t.templateId}),t.shareToken&&t.mine!==!1&&e.jsxs("span",{className:"flex items-center gap-1",title:`Opened ${t.shareViews??0} time${t.shareViews===1?"":"s"}${t.shareLastViewedAt?`, last ${I(t.shareLastViewedAt)}`:""}`,children:[e.jsx(A,{size:10})," Shared · ",t.shareViews??0," view",t.shareViews===1?"":"s",t.shareExpiresAt&&e.jsxs(e.Fragment,{children:[" · expires ",E(t.shareExpiresAt)]})]}),t.shareToken&&t.mine===!1&&e.jsxs("span",{className:"flex items-center gap-1","data-testid":"report-shared-by",children:[e.jsx(A,{size:10})," Shared",t.sharedByName?` by ${t.sharedByName}`:"",t.shareExpiresAt&&e.jsxs(e.Fragment,{children:[" · expires ",E(t.shareExpiresAt)]})]}),e.jsx("span",{children:E(t.updatedAt)})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-3",children:[e.jsxs("a",{href:W(`/api/reports/${encodeURIComponent(t.id)}/render.html`),target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide bg-gray-100 dark:bg-white/[0.06] text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-white/[0.10] transition-colors",title:"Open the HTML report",children:[e.jsx($,{size:9})," html"]}),["pdf","docx","xlsx"].map(s=>e.jsxs("button",{onClick:k=>{k.stopPropagation(),l(t,s)},disabled:d===`${t.id}:${s}`,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide bg-gray-100 dark:bg-white/[0.06] text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-white/[0.10] transition-colors disabled:opacity-60",title:`Download ${s.toUpperCase()}`,children:[d===`${t.id}:${s}`?e.jsx(C,{size:9,className:"animate-spin"}):e.jsx($,{size:9})," ",s]},s))]}),e.jsxs("div",{className:"flex items-center gap-2 mt-auto",children:[e.jsxs("button",{onClick:()=>r(`/reports/view/${t.id}`),className:"flex-1 flex items-center justify-center gap-1 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:[e.jsx(oe,{size:12})," Open"]}),t.shareToken&&e.jsx("a",{href:`/reports/share/${t.shareToken}`,target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"flex items-center justify-center px-3 py-1.5 rounded-md text-xs font-medium bg-gray-100 dark:bg-white/5 hover:bg-gray-200 dark:hover:bg-white/10 text-gray-700 dark:text-gray-300 transition-colors",title:"Open public share link",children:e.jsx(de,{size:12})})]})]},t.id))}),e.jsx(O,{open:!!c,title:"Delete report?",description:`"${c==null?void 0:c.title}" will be permanently deleted. Any active share link will stop working.`+(x>0?` ${x} scheduled dispatch${x===1?"":"es"} pointing to this report will ALSO be removed.`:""),confirmLabel:"Delete",onConfirm:R,onCancel:()=>y(null)})]})}function ue(){const o=L(),r=_().hasRole("tester"),[n,h]=i.useState([]),[d,u]=i.useState([]),[S,w]=i.useState(!0),[j,g]=i.useState(!1),[N,b]=i.useState(null),[c,y]=i.useState(!1),[x,m]=i.useState(null),[f,v]=i.useState(null),p=async a=>{a!=null&&a.initial?w(!0):a!=null&&a.silent||g(!0);try{const[t,s]=await Promise.all([q(),B()]);h(t.schedules),u(s.reports)}catch(t){a!=null&&a.silent||o.toast("error",`Load failed: ${t instanceof Error?t.message:String(t)}`)}finally{w(!1),g(!1)}};i.useEffect(()=>{p({initial:!0})},[]),i.useEffect(()=>{if(!(c||x))return G(()=>{p({silent:!0})},2e4)},[c,x]);const T=async a=>{try{await M(a.id,{enabled:!a.enabled}),await p()}catch(t){o.toast("error",`Update failed: ${t instanceof Error?t.message:String(t)}`)}},R=async a=>{v(a.id);try{const t=await ae(a.id);t.success?o.toast("success","Dispatch succeeded"):o.toast("error",`Dispatch failed: ${t.error||"unknown"}`),await p()}catch(t){o.toast("error",`Run failed: ${t instanceof Error?t.message:String(t)}`)}finally{v(null)}},l=async()=>{if(x)try{await se(x.id),o.toast("success","Schedule deleted"),m(null),await p()}catch(a){o.toast("error",`Delete failed: ${a instanceof Error?a.message:String(a)}`)}};return S?e.jsxs("div",{className:"py-10 text-center text-sm text-gray-500",children:[e.jsx(C,{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:[n.length," schedule",n.length===1?"":"s"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>p(),disabled:j,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(K,{size:12,className:j?"animate-spin":""}),j?"Refreshing…":"Refresh"]}),r&&e.jsxs("button",{onClick:()=>{b(null),y(!0)},disabled:d.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:d.length===0?"Save a report first in Reporting mode, then you can schedule it":"Create a new schedule",children:[e.jsx(ce,{size:12})," New schedule"]})]})]}),n.length===0?e.jsxs("div",{className:"text-center py-14 text-sm text-gray-500 dark:text-gray-400",children:[e.jsx(V,{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:n.map(a=>{const t=d.find(s=>s.id===a.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:a.title})}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-600 dark:text-gray-400 truncate max-w-[160px]",children:t?t.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:a.cron,children:[a.cronHuman&&a.cronHuman!==a.cron?a.cronHuman:e.jsx("span",{className:"font-mono",children:a.cron}),a.enabled&&a.nextRun&&e.jsxs("div",{className:"text-[10px] text-gray-500",children:["next ",I(a.nextRun)]})]}),e.jsx("td",{className:"px-3 py-2 text-xs uppercase text-gray-600 dark:text-gray-400",children:a.format}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-700 dark:text-gray-300 truncate max-w-[180px]",title:a.recipients.join(", "),children:a.recipients.length===1?a.recipients[0]:`${a.recipients.length} recipients`}),e.jsx("td",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:a.lastRun?I(a.lastRun):"—"}),e.jsx("td",{className:"px-3 py-2 text-xs",children:a.enabled?a.lastStatus==="success"&&a.lastWarning?e.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400",title:a.lastWarning,children:[e.jsx(z,{size:10})," Sent · stale data"]}):a.lastStatus==="success"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400",children:[e.jsx(z,{size:10})," Success"]}):a.lastStatus==="error"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-rose-600 dark:text-rose-400",title:a.lastError,children:[e.jsx(xe,{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:r&&e.jsxs("div",{className:"flex items-center gap-1 justify-end",children:[e.jsx("button",{onClick:()=>R(a),disabled:f===a.id,className:"p-1 rounded text-gray-500 hover:text-emerald-600 hover:bg-emerald-500/10 disabled:opacity-50",title:"Run now",children:f===a.id?e.jsx(C,{size:12,className:"animate-spin"}):e.jsx(he,{size:12})}),e.jsx("button",{onClick:()=>T(a),className:"p-1 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-white/5",title:a.enabled?"Pause — stop sending until resumed":"Resume — send on schedule again",children:a.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:()=>{b(a),y(!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:()=>m(a),className:"p-1 rounded text-gray-500 hover:text-rose-500 hover:bg-rose-500/10",title:"Delete",children:e.jsx(H,{size:12})})]})})]},a.id)})})]})}),c&&e.jsx(ge,{reports:d,editing:N,onClose:()=>{y(!1),b(null)},onSaved:async()=>{y(!1),b(null),await p()}}),e.jsx(O,{open:!!x,title:"Delete schedule?",description:`"${x==null?void 0:x.title}" will stop dispatching. This cannot be undone.`,confirmLabel:"Delete",onConfirm:l,onCancel:()=>m(null)})]})}function ge({reports:o,editing:r,onClose:n,onSaved:h}){var R;const d=L(),[u,S]=i.useState((r==null?void 0:r.title)||""),[w,j]=i.useState(r?"":((R=o[0])==null?void 0:R.id)||""),[g,N]=i.useState((r==null?void 0:r.cron)||"0 9 * * *"),[b,c]=i.useState((r==null?void 0:r.format)||"pdf"),[y,x]=i.useState((r==null?void 0:r.recipients.join(", "))||""),[m,f]=i.useState((r==null?void 0:r.enabled)!==!1),[v,p]=i.useState(!1),T=async()=>{if(!u.trim()||!g.trim()||!r&&!w){d.toast("error",r?"Title and cron are required":"Title, source report, and cron are required");return}const l=y.split(",").map(s=>s.trim()).filter(Boolean);if(l.length===0){d.toast("error","At least one recipient email is required");return}const a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,t=l.find(s=>!a.test(s));if(t){d.toast("error",`Invalid recipient email: ${t}`);return}if(g.trim().split(/\s+/).length!==5){d.toast("error","Cron expression must have 5 fields (minute hour day-of-month month day-of-week)");return}p(!0);try{r?await M(r.id,{title:u,cron:g,format:b,recipients:l,enabled:m}):await re({title:u,sourceReportId:w,cron:g,format:b,recipients:l,enabled:m}),d.toast("success",r?"Schedule updated":"Schedule created"),await h()}catch(s){d.toast("error",`Save failed: ${s instanceof Error?s.message:String(s)}`)}finally{p(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:n,children:e.jsxs("div",{className:"bg-white dark:bg-surface-1 rounded-2xl border border-gray-200 dark:border-white/10 w-[640px] max-w-[95vw] max-h-[90vh] overflow-y-auto p-5",onClick:l=>l.stopPropagation(),children:[e.jsx("div",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:r?"Edit schedule":"New schedule"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Title"}),e.jsx("input",{value:u,onChange:l=>S(l.target.value),placeholder:"e.g., Weekly QA Summary",className:"w-full mt-1 px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 text-sm outline-none focus:border-brand-500/50"})]}),!r&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Source report"}),e.jsx("select",{value:w,onChange:l=>j(l.target.value),className:"w-full mt-1 px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 text-sm outline-none focus:border-brand-500/50",children:o.map(l=>e.jsx("option",{value:l.id,children:l.title},l.id))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Schedule"}),e.jsx("div",{className:"mt-1",children:e.jsx(ne,{value:g,onChange:N})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Format"}),e.jsxs("select",{value:b,onChange:l=>c(l.target.value),className:"w-full mt-1 px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 text-sm outline-none focus:border-brand-500/50",children:[e.jsx("option",{value:"pdf",children:"PDF"}),e.jsx("option",{value:"xlsx",children:"Excel (.xlsx)"}),e.jsx("option",{value:"docx",children:"Word (.docx)"}),e.jsx("option",{value:"html",children:"HTML"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Enabled"}),e.jsx("button",{onClick:()=>f(l=>!l),className:`w-full mt-1 px-3 py-2 rounded-md text-xs font-medium transition-colors ${m?"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400 border border-emerald-500/30":"bg-gray-100 dark:bg-white/5 text-gray-500"}`,children:m?"Enabled":"Paused"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold",children:"Recipients (comma-separated)"}),e.jsx("input",{value:y,onChange:l=>x(l.target.value),placeholder:"qa-lead@example.com, manager@example.com",className:"w-full mt-1 px-3 py-2 rounded-md bg-gray-50 dark:bg-white/[0.03] border border-gray-200 dark:border-white/10 text-sm outline-none focus:border-brand-500/50"}),e.jsxs("div",{className:"text-[10px] text-gray-500 mt-1 flex items-center gap-1",children:[e.jsx(pe,{size:9})," Requires an Email connector to be configured in Connectors."]}),e.jsx("div",{className:"text-[10px] text-gray-500 mt-1 leading-relaxed",children:"Each run refreshes the report with current data, saves it, and emails the result — the saved report (and its share link, if any) then shows those latest values. If the run fails you get an email."})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-5",children:[e.jsx("button",{onClick:n,className:"px-3 py-1.5 rounded-md text-xs font-medium text-gray-600 dark:text-gray-400 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:T,disabled:v,className:"flex items-center gap-1 px-3 py-1.5 rounded-md text-xs font-medium bg-brand-500 hover:bg-brand-600 text-white disabled:opacity-70 transition-colors",children:[v&&e.jsx(C,{size:11,className:"animate-spin"}),r?"Save changes":"Create schedule"]})]})]})})}const be=[{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
-
3
- Layout (4 rows on a 12-column grid):
4
- 1. Four KPI cards (span 3 each): Total Test Cases, Automation Coverage %, Latest Pass Rate %, Critical Failures (open).
5
- 2. A doughnut chart (span 6) "Automation Status" — Automated vs Manual.
6
- 3. A line chart (span 6) "Pass Rate Trend" over the last 7–10 runs.
7
- 4. A table (span 12) "Top 5 Failing Tests" with columns: Test Name, Failure Count, Last Failure, Category.
8
- 5. A markdown cell (span 12) with a 3–5 bullet executive summary covering sprint health, biggest risks, and recommended next steps.
9
-
10
- Pull real numbers from Testver — query test cases, run history, coverage stats, and failure analysis. Title: "Executive QA Summary — <Sprint Name or Date>". Save the result (save_report with templateId "executive") so it appears under My Reports.`},{id:"qa_daily",label:"QA Daily Report",description:"Last 24h status, new failures, flaky tests — for QA standups.",prompt:`Build a QA DAILY dashboard for the last 24 hours using the \`generate_dashboard\` tool.
11
-
12
- Layout:
13
- 1. Four KPI cards (span 3 each): Runs in Last 24h, Tests Executed, Pass Rate %, New Failures (since yesterday).
14
- 2. A stacked bar chart (span 6) "Pass / Fail / Skip per Run" for each run in the last 24h.
15
- 3. A doughnut chart (span 6) "Failure Categories" from the latest run (bug / environment / flaky / test-issue / timeout).
16
- 4. A table (span 12) "New Failures Today" with columns: Test Name, Error Signature, Run, First Seen.
17
- 5. A markdown cell (span 12) summarizing what changed since yesterday in 2–4 bullets — newly broken tests, fixed regressions, anything notable.
18
-
19
- Pull live data from Testver run history and failure analysis. Title: "QA Daily — <Today's Date>". Save the result (save_report with templateId "qa_daily").`},{id:"release",label:"Release Readiness",description:"Latest run vs baseline: regressions, new failures, duration delta.",prompt:`Build a RELEASE READINESS dashboard comparing the LATEST run to the configured BASELINE run using the \`generate_dashboard\` tool.
20
-
21
- Layout:
22
- 1. Four KPI cards (span 3 each): Total Tests in Latest Run, Pass Rate Δ vs Baseline (with up/down arrow), Duration Δ vs Baseline, Regressions Count.
23
- 2. A stacked bar chart (span 6) "Pass / Fail / Skip by Priority" for the latest run.
24
- 3. A horizontal bar chart (span 6) "Top 5 Regressions" — tests that passed in baseline but fail in latest, sorted by failure impact.
25
- 4. A table (span 12) "New Failures vs Baseline" with columns: Test Name, Baseline Result, Latest Result, Error Signature.
26
- 5. A markdown cell (span 12) with a Go / No-Go recommendation, 3–5 bullets summarizing release risk.
27
-
28
- Use Testver baseline + comparison endpoints. Title: "Release Readiness — Run <latest run id> vs Baseline". Save the result (save_report with templateId "release").`},{id:"trend_analysis",label:"Trend Analysis",description:"Pass rate / coverage / flaky / anomalies deep-dive across the last 20 runs.",prompt:`Build a TREND ANALYSIS dashboard covering the last 20 runs using the \`generate_dashboard\` tool.
29
-
30
- Layout:
31
- 1. Four KPI cards (span 3 each): Avg Pass Rate % (20 runs), Flaky Tests Count, Avg Run Duration, Coverage % (requirement coverage).
32
- 2. A line chart (span 6) "Pass Rate Trend — Last 20 Runs".
33
- 3. A line chart (span 6) "Duration Trend — Last 20 Runs" (avg seconds per run).
34
- 4. A horizontal bar chart (span 12) "Top 10 Flakiest Tests" — sorted by flip rate (pass↔fail toggles across the 20 runs).
35
- 5. A table (span 12) "Slowest 10 Tests" with columns: Test Name, Avg Duration, Max Duration, Runs Counted.
36
- 6. A markdown cell (span 12) calling out anomalies, regressions, and patterns — 4–6 bullets.
37
-
38
- Pull from run history, flaky-test detection, and slowest-tests stats. Title: "Trend Analysis — Last 20 Runs". Save the result (save_report with templateId "trend_analysis").`},{id:"automation_inventory",label:"Automation Inventory",description:"Every automation script — passing, failing, never run, skipped — by folder, framework and owner.",prompt:`Build an AUTOMATION INVENTORY dashboard of the project's automation scripts using the \`generate_dashboard\` tool. Take the numbers from \`test_library\` action "summary" — it covers every script, including the ones that have never run.
39
-
40
- Layout:
41
- 1. Four KPI cards (span 3 each): Total Scripts, Passing on Last Run %, Never Run, Not Linked to a Test Case.
42
- 2. A doughnut chart (span 6) "Scripts by Status" — passing / failing / never run / skipped in code.
43
- 3. A horizontal bar chart (span 6) "Scripts by Folder" — the folders with the most scripts.
44
- 4. A table (span 12) "Folders" with columns: Folder, Scripts, Failing, Never Run, Flaky.
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
- 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
-
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 ye(){const o=F(),r=n=>ie(o,{prompt:n,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:be.map(n=>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:n.label}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1 leading-relaxed",children:n.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:['"',n.prompt,'"']}),e.jsxs("button",{onClick:()=>r(n.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(me,{size:11,className:"-rotate-90"})]})]},n.id))})]})}export{Ce as ReportsPage};