@testver/testver 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1174 -800
- package/package.json +1 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-CHaHfmu4.js} +1 -1
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-CjEqKB-q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/{AdvancedPage-4kAcpE8Y.js → AdvancedPage-BqXP0FLg.js} +1 -1
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-BQjOzQje.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-jNkQJA1P.js} +1 -1
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-BaIj_IdQ.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-mU3JloJ6.js} +1 -1
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BHLE3HVj.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-0h-N2c6d.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-Bo_xekig.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/{PipelinesPanel-PmmPu8pj.js → PipelinesPanel-D6zWcLtD.js} +1 -1
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-D4EElEe9.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-2w2ysKRg.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-9Fx-IEwV.js} +2 -2
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DPkfGh-K.js} +1 -1
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-CRuS_bC2.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-7vHuvhQw.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-ig5hECRk.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/{TestExplorerPage-gYLhCD4d.js → TestExplorerPage-C_jl93GR.js} +3 -3
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-DJiWpCne.js} +2 -2
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-G1lvK1C0.js} +3 -3
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BACdnU-1.js} +1 -1
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-3kxT7BIT.js} +1 -1
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/{useTestResults-D5EwGIX9.js → useTestResults-yjH1aUy-.js} +1 -1
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/useOwnership-U0AfKBRo.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1 +1 @@
|
|
|
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{R as ot,Q as ct}from"./RunState-ifC4zi6M.js";import{a8 as dt,cL as xt,cM as mt,cN as ht,ck as ut,cO as pt,cP as Qe,cQ as gt,cR as bt,cS as yt,cT as ft,cU as Ze,cV as vt,cW as jt,cX as Nt,cY as wt,cZ as kt,c_ as Ct,c$ as St}from"./index-BYVxKLrT.js";import{C as Te}from"./ConfirmDialog-t7mpeeSN.js";import{u as It,T as De}from"./RunTargets-C7vpCbck.js";import{u as Tt,b as zt,a as Se}from"./useTabParam-ChbOedP1.js";import{G as Le,X as $e,a0 as Y,cm as He,as as Rt,b4 as Ye,o as Ae,aI as Ee,b6 as Et,b7 as Pt,a8 as Ge,aZ as $t,cE as ue,v as Fe,R as At,cF as Mt,_ as Je,b8 as Lt,cG as Ht,ag as Ie,ah as Oe}from"./vendor-icons-BKPiFyYV.js";const qt="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",Ft="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",Ot="/assets/jenkins-CWiA3Rta.svg",Bt="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",_t="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",Ut="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",Dt={"github-actions":qt,"gitlab-ci":Ft,jenkins:Ot,"azure-pipelines":Bt,bitbucket:_t,circleci:Ut},Gt={circleci:!0};function Kt({platform:s,size:i=16,className:n=""}){const a=Dt[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 ${Gt[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 V(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 Re({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(At,{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 ls(){var je,ie,Ne,we;const s=it(),{hasRole:i}=dt(),n=i("tester"),a=i("admin"),[o,w]=Tt("tab",["dashboard","pipelines","ci-runs","tokens","trace"],"dashboard"),x=zt(),N=K({queryKey:["ci-pipelines"],queryFn:xt}),g=K({queryKey:["ci-tokens"],queryFn:mt}),v=K({queryKey:["ci-runs"],queryFn:()=>ht(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:ut}),c=K({queryKey:["ci-analytics"],queryFn:pt,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:R}=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 Qe(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 E=Math.max(1,Math.ceil(L.length/z)),T=Math.min(se,E-1),re=L.slice(T*z,(T+1)*z),[ne,G]=l.useState(null),[W,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},Z=()=>{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 Ze({...t,enabled:!t.enabled}),Z()}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(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading the dashboard…"]}),o==="dashboard"&&c.isError&&e.jsx(Re,{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(Rt,{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`:""}, ${V(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:[V(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(Re,{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(Y,{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?R==null?void 0:R[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 gt(t.id),Z()}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 ",V(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(Ee,{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(Et,{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(Pt,{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(Vt,{pipelines:j,onCreated:t=>{le(t),Z()}}):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(Re,{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(Y,{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($t,{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(Yt,{}),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(Re,{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(Y,{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}),E>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 ",E]}),e.jsx("button",{onClick:()=>I(t=>Math.min(E-1,t+1)),disabled:T>=E-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(E-1),disabled:T>=E-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(Qt,{mapping:ne,suites:O,onClose:()=>G(null),onSaved:()=>{G(null),Z()}}),y&&e.jsx(Zt,{mapping:y,hasToken:F.length>0,onOpenTokens:()=>{J(null),w("tokens")},onClose:()=>J(null)}),ge&&e.jsx(Wt,{raw:ge.raw,token:ge.token,pipelines:j,onClose:()=>le(null)}),W&&e.jsx(Te,{open:!0,title:`Delete mapping "${W.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 bt(W.id),Z()}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 yt(Q.id),Z()}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 ft(X.id),Z()}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 ",V(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 ",V(s.createdAt),s.createdBy?` by ${s.createdBy}`:""," · last used ",V(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(Mt,{size:15})})]})}function Vt({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 kt({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(Y,{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:R=>N(A=>R.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,R])=>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"}),R]},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 Wt({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(Ee,{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 Qt({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)||""),[R,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?"••••••••":""),[E,T]=l.useState(((D=s.statusPush)==null?void 0:D.baseUrl)||""),[re,ne]=l.useState(s.enabled!==!1),[G,W]=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||"")!==E.trim()),de=z==="••••••••";l.useEffect(()=>{Q&&de&&ae("")},[Q,de]);const{data:X}=K({queryKey:["tm-plans"],queryFn:()=>vt(),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 Qe(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:()=>jt(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 Nt(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}=It(),ve=!!o.trim()&&!/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/.test(o.trim()),Z=!!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."}):Z?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":""} ${R===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":R===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:E,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;W(!0),y(null);try{await Ze({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:R,timeoutMinutes:k.trim()?Number(k):void 0,statusPush:M?{enabled:!0,provider:_,repo:se.trim(),token:z.trim(),baseUrl:E.trim()||void 0}:void 0,enabled:re}),a()}catch(C){y((C==null?void 0:C.message)||String(C)),W(!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(Y,{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 Zt({mapping:s,hasToken:i,onOpenTokens:n,onClose:a}){var W;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),[R,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),E=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 St({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(Ht,{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(Ee,{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(Kt,{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:E.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.",(W=s.statusPush)!=null&&W.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: "}),E.note]}),e.jsxs("button",{disabled:O||ae.length===0,onClick:async()=>{h(!0),B(!1),I(null);try{const m=await wt({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(Y,{size:14,className:"animate-spin"}):e.jsx(Ee,{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:R||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:[R?e.jsx(Y,{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"?"bg-sky-400 animate-pulse":a.lastState==="queued"?"border border-dashed border-gray-400 bg-transparent":"bg-gray-500"}`,title:`last: ${a.lastState} · ${V(a.lastAt)}`,"aria-label":`last run ${a.lastState}`})})]},a.key))})})]})}function Yt(){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 Ct(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(Y,{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:[V(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:[V(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:a.state==="running"?e.jsx(ot,{size:"sm"}):a.state==="queued"?e.jsx(ct,{size:"sm",position:a.queuePosition||void 0}):e.jsx("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full border capitalize ${Pe[a.state]}`,children:a.state})}),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:[V(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(Lt,{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{ls as PipelinesPage};
|
|
1
|
+
import{j as e,r as l}from"./vendor-react-DOVfxdUy.js";import{a as it,u as K}from"./vendor-query-DkZSMtfn.js";import{R as ot,Q as ct}from"./RunState-CRuS_bC2.js";import{ae as dt,cW as xt,cX as mt,cY as ht,cv as ut,cZ as pt,c_ as Ze,c$ as gt,d0 as bt,d1 as yt,d2 as ft,d3 as Qe,d4 as vt,d5 as jt,d6 as Nt,d7 as wt,d8 as kt,d9 as Ct,da as St}from"./index-D6sQYc_0.js";import{C as Te}from"./ConfirmDialog-DtotgVmI.js";import{u as It,T as Ge}from"./RunTargets-CPKBrefj.js";import{u as Tt,b as zt,a as Se}from"./useTabParam-CyYAP90W.js";import{G as Le,X as $e,a0 as Y,cm as He,as as Rt,b4 as Ye,o as Ae,aI as Ee,b6 as Et,b7 as Pt,a8 as Ue,aZ as $t,cE as ue,v as Fe,R as At,cF as Mt,_ as Je,b8 as Lt,cG as Ht,ag as Ie,ah as Oe}from"./vendor-icons-D_Dmmj8d.js";const qt="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",Ft="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",Ot="/assets/jenkins-CWiA3Rta.svg",Bt="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",_t="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",Dt="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",Gt={"github-actions":qt,"gitlab-ci":Ft,jenkins:Ot,"azure-pipelines":Bt,bitbucket:_t,circleci:Dt},Ut={circleci:!0};function Kt({platform:s,size:i=16,className:n=""}){const a=Gt[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 V(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 Re({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(At,{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 ls(){var je,ie,Ne,we;const s=it(),{hasRole:i}=dt(),n=i("tester"),a=i("admin"),[o,w]=Tt("tab",["dashboard","pipelines","ci-runs","tokens","trace"],"dashboard"),x=zt(),N=K({queryKey:["ci-pipelines"],queryFn:xt}),g=K({queryKey:["ci-tokens"],queryFn:mt}),v=K({queryKey:["ci-runs"],queryFn:()=>ht(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:ut}),c=K({queryKey:["ci-analytics"],queryFn:pt,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:R}=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 E=Math.max(1,Math.ceil(L.length/z)),T=Math.min(se,E-1),re=L.slice(T*z,(T+1)*z),[ne,U]=l.useState(null),[W,m]=l.useState(null),[y,J]=l.useState(null),[ge,le]=l.useState(null),[Z,de]=l.useState(null),[X,p]=l.useState(null),[be,ye]=l.useState(!1),[fe,D]=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},Q=()=>{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}),Q()}catch(u){D((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(Ue,{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:()=>D(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(Y,{size:16,className:"animate-spin inline mr-2"}),"Loading the dashboard…"]}),o==="dashboard"&&c.isError&&e.jsx(Re,{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(Rt,{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",G=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`:""}, ${V(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 ${G} 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:[V(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:()=>U({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(Re,{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(Y,{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?R==null?void 0:R[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(G=>`"${G}"`).join(", "),n&&e.jsx("button",{onClick:async()=>{try{await gt(t.id),Q()}catch(G){D((G==null?void 0:G.message)||String(G))}},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 ",V(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(Ee,{size:15})}),n&&e.jsx("button",{onClick:()=>U(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(Et,{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(Pt,{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(Ue,{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(Vt,{pipelines:j,onCreated:t=>{le(t),Q()}}):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(Re,{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(Y,{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($t,{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(Yt,{}),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(Re,{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(Y,{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}),E>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 ",E]}),e.jsx("button",{onClick:()=>I(t=>Math.min(E-1,t+1)),disabled:T>=E-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(E-1),disabled:T>=E-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(Zt,{mapping:ne,suites:O,onClose:()=>U(null),onSaved:()=>{U(null),Q()}}),y&&e.jsx(Qt,{mapping:y,hasToken:F.length>0,onOpenTokens:()=>{J(null),w("tokens")},onClose:()=>J(null)}),ge&&e.jsx(Wt,{raw:ge.raw,token:ge.token,pipelines:j,onClose:()=>le(null)}),W&&e.jsx(Te,{open:!0,title:`Delete mapping "${W.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 bt(W.id),Q()}catch(t){D((t==null?void 0:t.message)||String(t))}m(null)}}),Z&&e.jsx(Te,{open:!0,title:`Revoke token "${Z.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 yt(Z.id),Q()}catch(t){D((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 ft(X.id),Q()}catch(t){D((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 ",V(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 ",V(s.createdAt),s.createdBy?` by ${s.createdBy}`:""," · last used ",V(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(Mt,{size:15})})]})}function Vt({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 kt({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(Y,{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:R=>N(A=>R.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,R])=>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"}),R]},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 Wt({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(Ee,{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 Zt({mapping:s,suites:i,onClose:n,onSaved:a}){var Ne,we,t,u,f,xe,te,me,oe,G,ke,Ce,H,_e,De;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)||""),[R,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?"••••••••":""),[E,T]=l.useState(((G=s.statusPush)==null?void 0:G.baseUrl)||""),[re,ne]=l.useState(s.enabled!==!1),[U,W]=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,Z=!!le&&(le.provider!==_||(le.baseUrl||"")!==E.trim()),de=z==="••••••••";l.useEffect(()=>{Z&&de&&ae("")},[Z,de]);const{data:X}=K({queryKey:["tm-plans"],queryFn:()=>vt(),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:()=>jt(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 Nt(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],D=((p==null?void 0:p.cycles)||[]).filter(r=>(fe(r.id)??1)!==0).length,{browserOpts:Me,envOpts:ee}=It(),ve=!!o.trim()&&!/^[A-Za-z0-9][A-Za-z0-9 ._-]*$/.test(o.trim()),Q=!!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(Z?"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."}):Q?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&&D>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 (",D," of ",p.cycles.length," cycle",p.cycles.length!==1?"s":""," in this plan ",D===1?"has":"have"," automated scripts). Map scripts under Script Mapping to enable a cycle."]}),d&&(((De=p==null?void 0:p.cycles)==null?void 0:De.length)||0)>0&&D===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(Ge,{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(Ge,{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":""} ${R===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":R===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&&!Z?"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"}),Z&&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:E,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||U,onClick:async()=>{var r;W(!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:R,timeoutMinutes:k.trim()?Number(k):void 0,statusPush:M?{enabled:!0,provider:_,repo:se.trim(),token:z.trim(),baseUrl:E.trim()||void 0}:void 0,enabled:re}),a()}catch(C){y((C==null?void 0:C.message)||String(C)),W(!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:[U&&e.jsx(Y,{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 Qt({mapping:s,hasToken:i,onOpenTokens:n,onClose:a}){var W;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),[R,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),E=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.")},U=async m=>{if(d){A(!0),I(null);try{await St({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(Ht,{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(Ee,{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(Kt,{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:E.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.",(W=s.statusPush)!=null&&W.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: "}),E.note]}),e.jsxs("button",{disabled:O||ae.length===0,onClick:async()=>{h(!0),B(!1),I(null);try{const m=await wt({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(Y,{size:14,className:"animate-spin"}):e.jsx(Ee,{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:R||k,onClick:()=>$?L(!0):void U(!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:[R?e.jsx(Y,{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),U(!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"?"bg-sky-400 animate-pulse":a.lastState==="queued"?"border border-dashed border-gray-400 bg-transparent":"bg-gray-500"}`,title:`last: ${a.lastState} · ${V(a.lastAt)}`,"aria-label":`last run ${a.lastState}`})})]},a.key))})})]})}function Yt(){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 Ct(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(Y,{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:[V(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:[V(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:a.state==="running"?e.jsx(ot,{size:"sm"}):a.state==="queued"?e.jsx(ct,{size:"sm",position:a.queuePosition||void 0}):e.jsx("span",{className:`inline-flex items-center gap-1.5 text-xs px-2 py-0.5 rounded-full border capitalize ${Pe[a.state]}`,children:a.state})}),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:[V(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(Lt,{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{ls as PipelinesPage};
|