@testver/testver 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/testver.js +1 -1
- package/dist/index.js +1943 -1190
- package/package.json +2 -1
- package/src/ui/static/assets/AIPanel-KQFq4c0Q.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-CAs8fXyS.js +40 -0
- package/src/ui/static/assets/AIStreamUI-p_sMTEDQ.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-Cg21-P1W.js → AITestGenPage-CHaHfmu4.js} +5 -5
- package/src/ui/static/assets/APITestingPage-BSGJY_hd.js +19 -0
- package/src/ui/static/assets/{AboutPage-yJLCr2_q.js → AboutPage-CDa24SCJ.js} +1 -1
- package/src/ui/static/assets/AdvancedPage-BqXP0FLg.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-gTPFsiLZ.js → AnalyticsPage-Lm8noJqC.js} +1 -1
- package/src/ui/static/assets/{AuditLogPage-DE45E_PV.js → AuditLogPage-BvldSIik.js} +1 -1
- package/src/ui/static/assets/ChangesSummary-Cu0_4Ucf.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-DgU6ZYBO.js → CodeMapPage-uEjuo3fk.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-DNU3qoAP.js → ConfirmDialog-DtotgVmI.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-BpTjgcdV.js → CoveragePage-jNkQJA1P.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-DsnX-vRr.js → CronBuilder-D2fERHt9.js} +1 -1
- package/src/ui/static/assets/Dashboard-BaIj_IdQ.js +1 -0
- package/src/ui/static/assets/{DefectsPage-BtMNbq6Z.js → DefectsPage-DH0njYFG.js} +3 -3
- package/src/ui/static/assets/{EmptyState-BH_aDO0P.js → EmptyState-utxlJ0fu.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Ce_MxnM1.js → ExportButton-ouKqn9CU.js} +1 -1
- package/src/ui/static/assets/{FileViewer-iYL0lxyY.js → FileViewer-mU3JloJ6.js} +5 -5
- package/src/ui/static/assets/{GitPage-CQqV8JBC.js → GitPage-TrX-RqNC.js} +5 -5
- package/src/ui/static/assets/{ImportExportPage-DXk7Koaq.js → ImportExportPage-CIhK_raX.js} +1 -1
- package/src/ui/static/assets/{JiraPushDialog-CqftoLh8.js → JiraPushDialog-DgEZS-0u.js} +1 -1
- package/src/ui/static/assets/KpiTile-BHLE3HVj.js +1 -0
- package/src/ui/static/assets/{LiveExecutionView-BD0wE8sz.js → LiveExecutionView-CaIf7Jux.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-DiSINwmh.js → MediaModal-DNM45Uz2.js} +1 -1
- package/src/ui/static/assets/{MobileRunPicker-BNs2lZFf.js → MobileRunPicker-DFKm6_nU.js} +1 -1
- package/src/ui/static/assets/{MobileRunTarget-D2Nqcj10.js → MobileRunTarget-DHDoDZ_F.js} +3 -3
- package/src/ui/static/assets/{ModuleExplorer-BmkoQrHb.js → ModuleExplorer-rni7JbsL.js} +1 -1
- package/src/ui/static/assets/{OutputPage-Dcsr7cmr.js → OutputPage-Cn2WCpJ6.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-D6zWcLtD.js +1 -0
- package/src/ui/static/assets/{ProfilePage-ByshrcwC.js → ProfilePage-BKNdkSnx.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-B9B___ij.js → ProjectExplorer-5e7J8t-o.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-DbPnaZ-v.js → RemoteFileStrip-C1S2aclP.js} +1 -1
- package/src/ui/static/assets/ReportCard-D4EElEe9.js +2 -0
- package/src/ui/static/assets/ReportFullView-2w2ysKRg.js +1 -0
- package/src/ui/static/assets/ReportsPage-9Fx-IEwV.js +48 -0
- package/src/ui/static/assets/ResultsPage-DPkfGh-K.js +115 -0
- package/src/ui/static/assets/RunState-CRuS_bC2.js +1 -0
- package/src/ui/static/assets/{RunTargets-C7Vqd4TU.js → RunTargets-CPKBrefj.js} +1 -1
- package/src/ui/static/assets/{ScriptMappingPage-BrANeHv0.js → ScriptMappingPage-C3K_uyf0.js} +1 -1
- package/src/ui/static/assets/{SearchableDevicePicker-CFJ_DUAA.js → SearchableDevicePicker-DubIldKj.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-BwOiebKG.js → SettingsPage-BuZrrlW2.js} +1 -1
- package/src/ui/static/assets/SharedReportView-ig5hECRk.js +1 -0
- package/src/ui/static/assets/{SourcesPage-C_QVQwiA.js → SourcesPage-BPkqRqkC.js} +1 -1
- package/src/ui/static/assets/TestExplorerPage-C_jl93GR.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-Ch4PthuU.js → TestManagementPage-DJiWpCne.js} +1 -1
- package/src/ui/static/assets/TestPlansPage-G1lvK1C0.js +5 -0
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-CUsMGEe3.js → TestverCreditsRing-CEBSy3w3.js} +1 -1
- package/src/ui/static/assets/{UncommittedDiffViewer-B5HSURk8.js → UncommittedDiffViewer-FKvUZcRi.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-BjY3ftxf.js → UserManagementPage-gDGhaHE4.js} +3 -3
- package/src/ui/static/assets/{WorkflowsPage-BUu-LjZ8.js → WorkflowsPage-BACdnU-1.js} +17 -17
- package/src/ui/static/assets/{hiddenLlmProviders-setxgY_B.js → hiddenLlmProviders-DzwaR-b9.js} +1 -1
- package/src/ui/static/assets/index-D6sQYc_0.js +47 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/index-aInN0yoR.css +1 -0
- package/src/ui/static/assets/reportMeta-3kxT7BIT.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DqhngqgG.js → useFeatureFlags-DrhvBp0C.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-TM1Rfj1s.js → useJiraConnector-Dwj69Rfh.js} +1 -1
- package/src/ui/static/assets/useOwnership-C1CmzcvJ.js +1 -0
- package/src/ui/static/assets/useSuites-V0AxZYex.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-HqvURJAc.js → useTestExplorer-CUqC18DV.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-CL7-zz0Q.js → useTestLifecycle-C2S_vaX2.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-ZTA1_VUm.js → useTestManagement-DW6AW2mt.js} +2 -2
- package/src/ui/static/assets/useTestResults-yjH1aUy-.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-B0wLOBoh.js → vendor-icons-D_Dmmj8d.js} +277 -282
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +5 -5
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +0 -40
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +0 -19
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +0 -3
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +0 -2
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +0 -1
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +0 -2
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +0 -1
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +0 -2
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +0 -1
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +0 -48
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +0 -115
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +0 -7
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +0 -5
- package/src/ui/static/assets/index-B0klHYbO.css +0 -1
- package/src/ui/static/assets/index-DtBWNlVD.js +0 -47
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +0 -1
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +0 -1
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,j as e}from"./vendor-react-CTbHBddL.js";import{a as E,u as P,c as N}from"./vendor-query-BrzmPFT3.js";import{e7 as W,fI as Y,fJ as G,eD as U,fK as J,fL as V,fM as X,fN as Z,fO as H,fP as ee,fQ as se,a8 as te,b as re,fR as ae,fS as ne,fT as ie,L as oe,fU as ce,B as $,fV as de,fW as le,fX as xe,dW as L,fY as ue}from"./index-DtBWNlVD.js";import{ag as me,a3 as C,J as F,o as he,R as ge,aq as pe,ba as R,b9 as K,X as D,ac as fe,q as be,ak as ye,b8 as je,a1 as we,u as B,cU as ve,ad as A,ae as T,aE as Ne,z as Ce,d9 as ke,cn as q,cf as Se,t as Pe,K as ze,M as Ae,x as Te}from"./vendor-icons-B0wLOBoh.js";const S=s=>s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never",M="w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500";function Fe({toast:s,describeBrowser:i}){const r=E(),{data:t,isLoading:u}=P({queryKey:["two-factor"],queryFn:W}),[o,n]=d.useState("idle"),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!0),[h,p]=d.useState(null),f=()=>{r.invalidateQueries({queryKey:["two-factor"]}),r.invalidateQueries({queryKey:["profile"]}),r.invalidateQueries({queryKey:["my-sessions"]}),r.invalidateQueries({queryKey:["my-activity"]})},b=()=>{n("idle"),l(""),y(""),p(null)},g=N({mutationFn:Y,onSuccess:()=>{s("success","This browser will ask for the code again"),f()},onError:a=>s("error",a.message)}),k=N({mutationFn:G,onSuccess:a=>{s("success",`${a.removed} browser${a.removed===1?"":"s"} will ask for the code again`),f()},onError:a=>s("error",a.message)});return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4","data-testid":"two-factor-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(me,{size:16}),"Two-factor authentication"]}),t&&e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border ${t.enabled?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-500 dark:text-gray-400 border-white/10"}`,children:t.enabled?"On":"Off"})]}),u||!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(C,{size:14,className:"animate-spin"})," Loading…"]}):t.enabled?e.jsxs("div",{className:"space-y-4",children:[!t.keyReadable&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-sm text-red-500 dark:text-red-300",children:[e.jsx(he,{size:14,className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"This server can no longer read your authenticator setup (its two-factor key is missing or was replaced). Sign in with a recovery code until you set it up again — turn it off below with a recovery code, then set it up once more."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Turned on"}),e.jsx("p",{className:"text-sm text-gray-200 mt-0.5",children:S(t.enabledAt)})]}),e.jsxs("div",{className:`p-3 rounded-lg border ${t.recoveryCodesLeft<=2?"bg-amber-500/10 border-amber-500/20":"bg-surface-2 border-white/5"}`,children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Recovery codes left"}),e.jsxs("p",{className:`text-sm mt-0.5 ${t.recoveryCodesLeft<=2?"text-amber-600 dark:text-amber-400 font-medium":"text-gray-200"}`,children:[t.recoveryCodesLeft," of 10",t.recoveryCodesLeft<=2?" — make new ones":""]})]})]}),h?e.jsx("div",{className:"max-w-lg",children:e.jsx(Z,{codes:h,onDone:()=>{b(),f()}})}):o==="codes"||o==="disable"?e.jsx(Re,{title:o==="codes"?"New recovery codes — your old ones stop working":"Turn off two-factor authentication",submitLabel:o==="codes"?"Make new codes":"Turn off",danger:o==="disable",onCancel:b,onSubmit:async(a,w)=>{o==="codes"?p((await H(a,w)).recoveryCodes):(await ee(a,w),s("success","Two-factor authentication is off"),b(),f())}}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("codes"),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-white/10 text-sm text-gray-300 hover:bg-white/5",children:[e.jsx(ge,{size:14})," New recovery codes"]}),e.jsxs("button",{type:"button",onClick:()=>n("disable"),disabled:t.required,title:t.required?"Your administrator requires two-factor authentication":void 0,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-red-500/20 text-sm text-red-500 dark:text-red-400 hover:bg-red-500/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pe,{size:14})," Turn off"]}),t.required&&e.jsx("span",{className:"self-center text-xs text-gray-500",children:"Required by your administrator"})]}),e.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-300",children:["Trusted browsers ",e.jsx("span",{className:"font-normal text-gray-500",children:"— skip the code at sign-in"})]}),t.trustedBrowsers.length>1&&e.jsx("button",{type:"button",onClick:()=>k.mutate(),disabled:k.isPending,className:"text-xs text-red-500 dark:text-red-400 hover:underline",children:"Remove all"})]}),t.trustedBrowsers.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:t.policy.allowTrustedBrowsers?`None. Tick “Trust this browser” when you enter a code to skip it on that browser for ${t.policy.trustedBrowserDays} days.`:"Your administrator has turned trusted browsers off — every sign-in asks for a code."}):t.trustedBrowsers.map(a=>{const{label:w,isMobile:_}=i(a.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[_?e.jsx(F,{size:16,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:16,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200",children:w}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a.ipAddress?`${a.ipAddress} · `:"","Trusted ",S(a.createdAt)," · until ",S(a.expiresAt),a.lastUsedAt?` · last used ${S(a.lastUsedAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>g.mutate(a.id),disabled:g.isPending,title:"Stop trusting this browser",className:"p-1.5 text-gray-500 hover:text-red-400",children:e.jsx(K,{size:14})})]},a.id)})]})]}):o==="idle"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed max-w-xl",children:["Sign-in asks for a 6-digit code from an authenticator app on your phone as well as your password, so a stolen password alone is not enough.",t.required&&e.jsx("span",{className:"block mt-1 text-amber-600 dark:text-amber-400",children:"Your administrator requires it for your account."})]}),e.jsxs("button",{type:"button",onClick:()=>n("password"),className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors",children:[e.jsx(F,{size:14})," Set up"]})]}):o==="password"?e.jsxs("form",{onSubmit:a=>{a.preventDefault(),c&&(y(c),n("setup"))},className:"space-y-3 max-w-md",children:[e.jsx("label",{htmlFor:"two-factor-setup-password",className:"block text-sm font-medium text-gray-400",children:"Confirm your password"}),e.jsx(U,{id:"two-factor-setup-password",value:c,onChange:a=>l(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:!c,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2.5 text-[15px] text-gray-400 hover:text-gray-200",children:"Cancel"})]})]}):e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsx(J,{start:()=>X(x).catch(a=>{throw s("error",a.message),b(),a}),confirm:async a=>{const w=await V(a,m);return w.sessionsRevoked&&s("info",`Signed out of ${w.sessionsRevoked} other session${w.sessionsRevoked===1?"":"s"}`),w.recoveryCodes},beforeCode:e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>j(a.target.checked),className:"accent-brand-500"}),"Sign out my other sessions when it is on"]}),onFinished:()=>{s("success","Two-factor authentication is on"),b(),f()}}),e.jsx("button",{type:"button",onClick:b,className:"text-xs text-gray-500 hover:text-gray-300",children:"Cancel"})]})]})}function Re({title:s,submitLabel:i,danger:r,onSubmit:t,onCancel:u}){const[o,n]=d.useState(""),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!1),[h,p]=d.useState(""),[f,b]=d.useState(!1),g=!!o&&(m?!!x.trim():c.length===6),k=async()=>{if(!(!g||f)){b(!0),p("");try{await t(o,m?{recoveryCode:x.trim()}:{code:c})}catch(a){p(a.message||"That did not work."),l("")}finally{b(!1)}}};return e.jsxs("form",{onSubmit:a=>{a.preventDefault(),k()},className:"space-y-3 max-w-md p-4 rounded-xl border border-white/10 bg-surface-2/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:s}),e.jsx("button",{type:"button",onClick:u,className:"p-1 text-gray-500 hover:text-gray-300",title:"Cancel",children:e.jsx(D,{size:14})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"two-factor-stepup-password",className:"block text-xs text-gray-400 mb-1",children:"Password"}),e.jsx(U,{id:"two-factor-stepup-password",value:o,onChange:a=>n(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs text-gray-400",children:m?"Recovery code":"Code from your authenticator app"}),e.jsxs("button",{type:"button",onClick:()=>j(a=>!a),className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300",children:[e.jsx(fe,{size:11})," ",m?"Use the app code":"Use a recovery code"]})]}),m?e.jsx("input",{value:x,onChange:a=>y(a.target.value),placeholder:"xxxxx-xxxxx",spellCheck:!1,className:`${M} font-mono`}):e.jsx(se,{value:c,onChange:l,autoFocus:!1})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:!g||f,className:`flex items-center gap-2 px-5 py-2.5 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50 ${r?"bg-red-600 hover:bg-red-500":"bg-brand-600 hover:bg-brand-500"}`,children:[f&&e.jsx(C,{size:14,className:"animate-spin"})," ",i]})]})}function I(s){if(!s)return{browser:"Unknown",os:"Unknown",isMobile:!1};let i="Unknown";s.includes("Edg")?i="Edge":s.includes("Chrome")?i="Chrome":s.includes("Firefox")?i="Firefox":s.includes("Safari")&&(i="Safari");let r="Unknown";s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("Android")?r="Android":(s.includes("iPhone")||s.includes("iPad"))&&(r="iOS");const t=/Mobile|Android|iPhone|iPad/i.test(s);return{browser:i,os:r,isMobile:t}}function z(s){return s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never"}function Q(s){const i=Date.now()-new Date(s).getTime(),r=Math.floor(i/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const t=Math.floor(r/60);if(t<24)return`${t}h ago`;const u=Math.floor(t/24);return u<30?`${u}d ago`:z(s)}const Me={superadmin:"yellow",admin:"brand",tester:"green",viewer:"gray"},O={admin:"bg-brand-500/20 text-brand-300 ring-brand-500/30",tester:"bg-emerald-500/20 text-emerald-300 ring-emerald-500/30",viewer:"bg-gray-500/20 text-gray-300 ring-gray-500/30"},Le={"auth.":"text-amber-400","user.":"text-brand-400","run.":"text-emerald-400","file.":"text-sky-400","git.":"text-orange-400","ai.":"text-purple-400","settings.":"text-gray-400","recorder.":"text-pink-400","cicd.":"text-teal-400"};function qe(s){for(const[i,r]of Object.entries(Le))if(s.startsWith(i))return r;return"text-gray-400"}function Oe(s){return s.replace(/[._]/g," ").replace(/\b\w/g,i=>i.toUpperCase()).replace(/\b2fa\b/gi,"2FA")}function We(){const{user:s,refreshStatus:i}=te(),{toast:r}=re(),t=E(),{data:u,isLoading:o}=P({queryKey:["profile"],queryFn:ae}),{data:n}=P({queryKey:["my-sessions"],queryFn:ne}),[c,l]=d.useState(0),{data:x,isFetching:y}=P({queryKey:["my-activity",c],queryFn:()=>ie(v,c*v),placeholderData:m=>m});return o?e.jsx(oe,{text:"Loading profile..."}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(be,{size:24,className:"text-brand-300"}),"Profile"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage your account settings and preferences"})]})}),e.jsx("div",{className:"max-w-3xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Ee,{profile:u,userRole:(s==null?void 0:s.role)||"viewer",onUpdate:async m=>{await ce({displayName:m}),t.invalidateQueries({queryKey:["profile"]}),i()},toast:r}),e.jsx(Ue,{toast:r}),e.jsx(Fe,{toast:r,describeBrowser:m=>{const{browser:j,os:h,isMobile:p}=I(m);return{label:`${j} on ${h}`,isMobile:p}}}),e.jsx($e,{sessions:(n==null?void 0:n.sessions)||[],queryClient:t,toast:r}),e.jsx(Ke,{entries:(x==null?void 0:x.entries)||[],total:(x==null?void 0:x.total)??0,page:c,loading:y,onPage:l}),e.jsx(De,{})]})})]})}function Ee({profile:s,userRole:i,onUpdate:r,toast:t}){const[u,o]=d.useState(!1),[n,c]=d.useState(s.displayName),[l,x]=d.useState(!1),y=async()=>{if(n.trim()){x(!0);try{await r(n.trim()),t("success","Display name updated"),o(!1)}catch(h){t("error",h.message||"Failed to update")}finally{x(!1)}}},m=(s.displayName||s.username).charAt(0).toUpperCase(),j=O[i]||O.viewer;return e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center text-2xl font-bold ring-2 shrink-0 ${j}`,children:m}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:n,onChange:h=>c(h.target.value),className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-lg font-semibold text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500",autoFocus:!0,onKeyDown:h=>{h.key==="Enter"&&y(),h.key==="Escape"&&o(!1)}}),e.jsx("button",{onClick:y,disabled:l,className:"p-1 text-emerald-400 hover:text-emerald-300",children:l?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16})}),e.jsx("button",{onClick:()=>{o(!1),c(s.displayName)},className:"p-1 text-gray-400 hover:text-gray-300",children:e.jsx(D,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 truncate",children:s.displayName}),e.jsx("button",{onClick:()=>{c(s.displayName),o(!0)},className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(je,{size:14})})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["@",s.username]}),e.jsx($,{label:s.role==="superadmin"?"super admin":s.role,color:Me[s.role]||"gray"})]}),e.jsx("div",{className:"mt-1 text-sm text-gray-400",children:s.email?s.email:e.jsx("span",{className:"text-gray-600",children:"No email on file — ask an administrator to add one (needed for password reset)"})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{size:12})," Joined ",z(s.createdAt)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12})," Last login ",z(s.lastLoginAt)]})]})]})]})})}function Ue({toast:s}){const[i,r]=d.useState(""),[t,u]=d.useState(""),[o,n]=d.useState(""),[c,l]=d.useState(!1),[x,y]=d.useState(!1),[m,j]=d.useState(!1),[h,p]=d.useState(""),f=N({mutationFn:()=>de(i,t),onSuccess:()=>{s("success","Password changed successfully"),r(""),u(""),n(""),p("")},onError:g=>{p(g.message||"Failed to change password")}}),b=g=>{if(g.preventDefault(),p(""),!i||!t||!o){p("All fields are required");return}if(t.length<6){p("New password must be at least 6 characters");return}if(t!==o){p("New passwords do not match");return}f.mutate()};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ve,{size:16}),"Change Password"]}),e.jsxs("form",{onSubmit:b,className:"space-y-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Current Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c?"text":"password",value:i,onChange:g=>r(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Enter current password"}),e.jsx("button",{type:"button",onClick:()=>l(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:c?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:x?"text":"password",value:t,onChange:g=>u(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"At least 6 characters"}),e.jsx("button",{type:"button",onClick:()=>y(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:x?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:m?"text":"password",value:o,onChange:g=>n(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Re-enter new password"}),e.jsx("button",{type:"button",onClick:()=>j(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:m?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:f.isPending,className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50",children:[f.isPending?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ne,{size:14}),"Update Password"]})]})]})}function $e({sessions:s,queryClient:i,toast:r}){const t=N({mutationFn:le,onSuccess:()=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success","Session revoked")},onError:n=>r("error",n.message)}),u=N({mutationFn:xe,onSuccess:n=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success",`${n.sessionsRevoked} session(s) revoked`)},onError:n=>r("error",n.message)}),o=s.filter(n=>!n.isCurrent);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(R,{size:16}),"Active Sessions",e.jsxs("span",{className:"text-xs text-gray-500 font-normal",children:["(",s.length,")"]})]}),o.length>0&&e.jsxs("button",{onClick:()=>u.mutate(),disabled:u.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 rounded transition-colors",children:[u.isPending?e.jsx(C,{size:12,className:"animate-spin"}):e.jsx(Ce,{size:12}),"Revoke All Others"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No active sessions"}):e.jsx("div",{className:"space-y-2",children:s.map(n=>{const{browser:c,os:l,isMobile:x}=I(n.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[x?e.jsx(F,{size:18,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:18,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-200 font-medium",children:[c," on ",l]}),n.isCurrent&&e.jsx($,{label:"Current",color:"green"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 mt-0.5",children:[n.ipAddress&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{size:10})," ",n.ipAddress]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:10})," ",Q(n.createdAt)]}),e.jsxs("span",{children:["Expires ",z(n.expiresAt)]})]})]}),!n.isCurrent&&e.jsx("button",{onClick:()=>t.mutate(n.id),disabled:t.isPending,className:"p-1.5 text-gray-500 hover:text-red-400 transition-colors",title:"Revoke session",children:e.jsx(K,{size:14})})]},n.id)})})]})}const v=20;function Ke({entries:s,total:i,page:r,loading:t,onPage:u}){const o=Math.max(1,Math.ceil(i/v)),n=i===0?0:r*v+1,c=Math.min(i,(r+1)*v);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(q,{size:16}),"Recent Activity",i>0&&e.jsxs("span",{className:"text-xs font-normal text-gray-500",children:["(",i,")"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No recent activity"}):e.jsx("div",{className:"space-y-1",children:s.map(l=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded hover:bg-surface-2 transition-colors",children:[e.jsx(q,{size:14,className:`shrink-0 ${qe(l.action)}`}),e.jsx("span",{className:"text-sm text-gray-300 flex-1 truncate",children:Oe(l.action)}),l.resourceId&&e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[200px]",children:l.resourceId}),e.jsx("span",{className:"text-xs text-gray-500 shrink-0",children:Q(l.timestamp)})]},l.id))}),i>v&&e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Showing ",n,"–",c," of ",i]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>u(r-1),disabled:r===0||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Se,{size:14})," Previous"]}),e.jsxs("span",{className:"text-xs text-gray-400 tabular-nums min-w-[84px] text-center",children:["Page ",r+1," of ",o]}),e.jsxs("button",{onClick:()=>u(r+1),disabled:r>=o-1||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:["Next ",e.jsx(Pe,{size:14})]})]})]})]})}function De(){const[s,i]=d.useState(L()),r=()=>{ue(),i(L())};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ze,{size:16}),"Preferences"]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200",children:"Theme"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Switch between dark and light mode"})]}),e.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border border-white/10 rounded text-sm text-gray-300 hover:text-gray-100 transition-colors",children:[s==="dark"?e.jsx(Ae,{size:14}):e.jsx(Te,{size:14}),s==="dark"?"Dark":"Light"]})]})]})}export{We as ProfilePage};
|
|
1
|
+
import{r as d,j as e}from"./vendor-react-DOVfxdUy.js";import{a as E,u as P,c as N}from"./vendor-query-DkZSMtfn.js";import{eh as Y,fN as W,fO as G,eK as U,fP as V,fQ as J,fR as X,fS as Z,fT as H,fU as ee,fV as se,ae as te,b as re,fW as ae,fX as ne,fY as ie,L as oe,fZ as ce,B as $,f_ as de,f$ as le,g0 as xe,bO as L,g1 as ue}from"./index-D6sQYc_0.js";import{ac as me,a0 as C,J as F,o as he,R as ge,am as pe,b9 as R,b7 as K,X as D,a8 as fe,q as be,ag as ye,b6 as je,a3 as we,u as B,cU as ve,a9 as A,aa as T,aC as Ne,z as Ce,d9 as ke,cm as O,ce as Se,t as Pe,K as ze,M as Ae,x as Te}from"./vendor-icons-D_Dmmj8d.js";const S=s=>s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never",M="w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500";function Fe({toast:s,describeBrowser:i}){const r=E(),{data:t,isLoading:u}=P({queryKey:["two-factor"],queryFn:Y}),[o,n]=d.useState("idle"),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!0),[h,p]=d.useState(null),f=()=>{r.invalidateQueries({queryKey:["two-factor"]}),r.invalidateQueries({queryKey:["profile"]}),r.invalidateQueries({queryKey:["my-sessions"]}),r.invalidateQueries({queryKey:["my-activity"]})},b=()=>{n("idle"),l(""),y(""),p(null)},g=N({mutationFn:W,onSuccess:()=>{s("success","This browser will ask for the code again"),f()},onError:a=>s("error",a.message)}),k=N({mutationFn:G,onSuccess:a=>{s("success",`${a.removed} browser${a.removed===1?"":"s"} will ask for the code again`),f()},onError:a=>s("error",a.message)});return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4","data-testid":"two-factor-section",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(me,{size:16}),"Two-factor authentication"]}),t&&e.jsx("span",{className:`text-xs font-medium px-2 py-0.5 rounded-full border ${t.enabled?"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20":"bg-gray-500/10 text-gray-500 dark:text-gray-400 border-white/10"}`,children:t.enabled?"On":"Off"})]}),u||!t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(C,{size:14,className:"animate-spin"})," Loading…"]}):t.enabled?e.jsxs("div",{className:"space-y-4",children:[!t.keyReadable&&e.jsxs("div",{className:"flex items-start gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20 text-sm text-red-500 dark:text-red-300",children:[e.jsx(he,{size:14,className:"mt-0.5 flex-shrink-0"}),e.jsx("span",{children:"This server can no longer read your authenticator setup (its two-factor key is missing or was replaced). Sign in with a recovery code until you set it up again — turn it off below with a recovery code, then set it up once more."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-surface-2 border border-white/5",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Turned on"}),e.jsx("p",{className:"text-sm text-gray-200 mt-0.5",children:S(t.enabledAt)})]}),e.jsxs("div",{className:`p-3 rounded-lg border ${t.recoveryCodesLeft<=2?"bg-amber-500/10 border-amber-500/20":"bg-surface-2 border-white/5"}`,children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Recovery codes left"}),e.jsxs("p",{className:`text-sm mt-0.5 ${t.recoveryCodesLeft<=2?"text-amber-600 dark:text-amber-400 font-medium":"text-gray-200"}`,children:[t.recoveryCodesLeft," of 10",t.recoveryCodesLeft<=2?" — make new ones":""]})]})]}),h?e.jsx("div",{className:"max-w-lg",children:e.jsx(Z,{codes:h,onDone:()=>{b(),f()}})}):o==="codes"||o==="disable"?e.jsx(Re,{title:o==="codes"?"New recovery codes — your old ones stop working":"Turn off two-factor authentication",submitLabel:o==="codes"?"Make new codes":"Turn off",danger:o==="disable",onCancel:b,onSubmit:async(a,w)=>{o==="codes"?p((await H(a,w)).recoveryCodes):(await ee(a,w),s("success","Two-factor authentication is off"),b(),f())}}):e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>n("codes"),className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-white/10 text-sm text-gray-300 hover:bg-white/5",children:[e.jsx(ge,{size:14})," New recovery codes"]}),e.jsxs("button",{type:"button",onClick:()=>n("disable"),disabled:t.required,title:t.required?"Your administrator requires two-factor authentication":void 0,className:"flex items-center gap-1.5 px-3.5 py-2 rounded-xl border border-red-500/20 text-sm text-red-500 dark:text-red-400 hover:bg-red-500/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(pe,{size:14})," Turn off"]}),t.required&&e.jsx("span",{className:"self-center text-xs text-gray-500",children:"Required by your administrator"})]}),e.jsxs("div",{className:"pt-2 border-t border-white/5 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-sm font-medium text-gray-300",children:["Trusted browsers ",e.jsx("span",{className:"font-normal text-gray-500",children:"— skip the code at sign-in"})]}),t.trustedBrowsers.length>1&&e.jsx("button",{type:"button",onClick:()=>k.mutate(),disabled:k.isPending,className:"text-xs text-red-500 dark:text-red-400 hover:underline",children:"Remove all"})]}),t.trustedBrowsers.length===0?e.jsx("p",{className:"text-xs text-gray-500",children:t.policy.allowTrustedBrowsers?`None. Tick “Trust this browser” when you enter a code to skip it on that browser for ${t.policy.trustedBrowserDays} days.`:"Your administrator has turned trusted browsers off — every sign-in asks for a code."}):t.trustedBrowsers.map(a=>{const{label:w,isMobile:_}=i(a.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[_?e.jsx(F,{size:16,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:16,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-200",children:w}),e.jsxs("p",{className:"text-xs text-gray-500",children:[a.ipAddress?`${a.ipAddress} · `:"","Trusted ",S(a.createdAt)," · until ",S(a.expiresAt),a.lastUsedAt?` · last used ${S(a.lastUsedAt)}`:""]})]}),e.jsx("button",{type:"button",onClick:()=>g.mutate(a.id),disabled:g.isPending,title:"Stop trusting this browser",className:"p-1.5 text-gray-500 hover:text-red-400",children:e.jsx(K,{size:14})})]},a.id)})]})]}):o==="idle"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-gray-400 leading-relaxed max-w-xl",children:["Sign-in asks for a 6-digit code from an authenticator app on your phone as well as your password, so a stolen password alone is not enough.",t.required&&e.jsx("span",{className:"block mt-1 text-amber-600 dark:text-amber-400",children:"Your administrator requires it for your account."})]}),e.jsxs("button",{type:"button",onClick:()=>n("password"),className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors",children:[e.jsx(F,{size:14})," Set up"]})]}):o==="password"?e.jsxs("form",{onSubmit:a=>{a.preventDefault(),c&&(y(c),n("setup"))},className:"space-y-3 max-w-md",children:[e.jsx("label",{htmlFor:"two-factor-setup-password",className:"block text-sm font-medium text-gray-400",children:"Confirm your password"}),e.jsx(U,{id:"two-factor-setup-password",value:c,onChange:a=>l(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",disabled:!c,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl disabled:opacity-50",children:"Continue"}),e.jsx("button",{type:"button",onClick:b,className:"px-4 py-2.5 text-[15px] text-gray-400 hover:text-gray-200",children:"Cancel"})]})]}):e.jsxs("div",{className:"max-w-lg space-y-3",children:[e.jsx(V,{start:()=>X(x).catch(a=>{throw s("error",a.message),b(),a}),confirm:async a=>{const w=await J(a,m);return w.sessionsRevoked&&s("info",`Signed out of ${w.sessionsRevoked} other session${w.sessionsRevoked===1?"":"s"}`),w.recoveryCodes},beforeCode:e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:m,onChange:a=>j(a.target.checked),className:"accent-brand-500"}),"Sign out my other sessions when it is on"]}),onFinished:()=>{s("success","Two-factor authentication is on"),b(),f()}}),e.jsx("button",{type:"button",onClick:b,className:"text-xs text-gray-500 hover:text-gray-300",children:"Cancel"})]})]})}function Re({title:s,submitLabel:i,danger:r,onSubmit:t,onCancel:u}){const[o,n]=d.useState(""),[c,l]=d.useState(""),[x,y]=d.useState(""),[m,j]=d.useState(!1),[h,p]=d.useState(""),[f,b]=d.useState(!1),g=!!o&&(m?!!x.trim():c.length===6),k=async()=>{if(!(!g||f)){b(!0),p("");try{await t(o,m?{recoveryCode:x.trim()}:{code:c})}catch(a){p(a.message||"That did not work."),l("")}finally{b(!1)}}};return e.jsxs("form",{onSubmit:a=>{a.preventDefault(),k()},className:"space-y-3 max-w-md p-4 rounded-xl border border-white/10 bg-surface-2/40",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm font-medium text-gray-200",children:s}),e.jsx("button",{type:"button",onClick:u,className:"p-1 text-gray-500 hover:text-gray-300",title:"Cancel",children:e.jsx(D,{size:14})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"two-factor-stepup-password",className:"block text-xs text-gray-400 mb-1",children:"Password"}),e.jsx(U,{id:"two-factor-stepup-password",value:o,onChange:a=>n(a.target.value),autoFocus:!0,autoComplete:"current-password",className:M})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-xs text-gray-400",children:m?"Recovery code":"Code from your authenticator app"}),e.jsxs("button",{type:"button",onClick:()=>j(a=>!a),className:"flex items-center gap-1 text-xs text-brand-400 hover:text-brand-300",children:[e.jsx(fe,{size:11})," ",m?"Use the app code":"Use a recovery code"]})]}),m?e.jsx("input",{value:x,onChange:a=>y(a.target.value),placeholder:"xxxxx-xxxxx",spellCheck:!1,className:`${M} font-mono`}):e.jsx(se,{value:c,onChange:l,autoFocus:!1})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:!g||f,className:`flex items-center gap-2 px-5 py-2.5 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50 ${r?"bg-red-600 hover:bg-red-500":"bg-brand-600 hover:bg-brand-500"}`,children:[f&&e.jsx(C,{size:14,className:"animate-spin"})," ",i]})]})}function Q(s){if(!s)return{browser:"Unknown",os:"Unknown",isMobile:!1};let i="Unknown";s.includes("Edg")?i="Edge":s.includes("Chrome")?i="Chrome":s.includes("Firefox")?i="Firefox":s.includes("Safari")&&(i="Safari");let r="Unknown";s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("Android")?r="Android":(s.includes("iPhone")||s.includes("iPad"))&&(r="iOS");const t=/Mobile|Android|iPhone|iPad/i.test(s);return{browser:i,os:r,isMobile:t}}function z(s){return s?new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Never"}function I(s){const i=Date.now()-new Date(s).getTime(),r=Math.floor(i/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const t=Math.floor(r/60);if(t<24)return`${t}h ago`;const u=Math.floor(t/24);return u<30?`${u}d ago`:z(s)}const Me={superadmin:"yellow",admin:"brand",tester:"green",viewer:"gray"},q={admin:"bg-brand-500/20 text-brand-300 ring-brand-500/30",tester:"bg-emerald-500/20 text-emerald-300 ring-emerald-500/30",viewer:"bg-gray-500/20 text-gray-300 ring-gray-500/30"},Le={"auth.":"text-amber-400","user.":"text-brand-400","run.":"text-emerald-400","file.":"text-sky-400","git.":"text-orange-400","ai.":"text-purple-400","settings.":"text-gray-400","recorder.":"text-pink-400","cicd.":"text-teal-400"};function Oe(s){for(const[i,r]of Object.entries(Le))if(s.startsWith(i))return r;return"text-gray-400"}function qe(s){return s.replace(/[._]/g," ").replace(/\b\w/g,i=>i.toUpperCase()).replace(/\b2fa\b/gi,"2FA")}function Ye(){const{user:s,refreshStatus:i}=te(),{toast:r}=re(),t=E(),{data:u,isLoading:o}=P({queryKey:["profile"],queryFn:ae}),{data:n}=P({queryKey:["my-sessions"],queryFn:ne}),[c,l]=d.useState(0),{data:x,isFetching:y}=P({queryKey:["my-activity",c],queryFn:()=>ie(v,c*v),placeholderData:m=>m});return o?e.jsx(oe,{text:"Loading profile..."}):e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"border-b border-white/5 bg-surface-1",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-6 py-6",children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(be,{size:24,className:"text-brand-300"}),"Profile"]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage your account settings and preferences"})]})}),e.jsx("div",{className:"max-w-3xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsx(Ee,{profile:u,userRole:(s==null?void 0:s.role)||"viewer",onUpdate:async m=>{await ce({displayName:m}),t.invalidateQueries({queryKey:["profile"]}),i()},toast:r}),e.jsx(Ue,{toast:r}),e.jsx(Fe,{toast:r,describeBrowser:m=>{const{browser:j,os:h,isMobile:p}=Q(m);return{label:`${j} on ${h}`,isMobile:p}}}),e.jsx($e,{sessions:(n==null?void 0:n.sessions)||[],queryClient:t,toast:r}),e.jsx(Ke,{entries:(x==null?void 0:x.entries)||[],total:(x==null?void 0:x.total)??0,page:c,loading:y,onPage:l}),e.jsx(De,{})]})})]})}function Ee({profile:s,userRole:i,onUpdate:r,toast:t}){const[u,o]=d.useState(!1),[n,c]=d.useState(s.displayName),[l,x]=d.useState(!1),y=async()=>{if(n.trim()){x(!0);try{await r(n.trim()),t("success","Display name updated"),o(!1)}catch(h){t("error",h.message||"Failed to update")}finally{x(!1)}}},m=(s.displayName||s.username).charAt(0).toUpperCase(),j=q[i]||q.viewer;return e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:`w-16 h-16 rounded-full flex items-center justify-center text-2xl font-bold ring-2 shrink-0 ${j}`,children:m}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:n,onChange:h=>c(h.target.value),className:"bg-surface-2 border border-white/10 rounded px-2 py-1 text-lg font-semibold text-gray-100 focus:outline-none focus:ring-1 focus:ring-brand-500",autoFocus:!0,onKeyDown:h=>{h.key==="Enter"&&y(),h.key==="Escape"&&o(!1)}}),e.jsx("button",{onClick:y,disabled:l,className:"p-1 text-emerald-400 hover:text-emerald-300",children:l?e.jsx(C,{size:16,className:"animate-spin"}):e.jsx(ye,{size:16})}),e.jsx("button",{onClick:()=>{o(!1),c(s.displayName)},className:"p-1 text-gray-400 hover:text-gray-300",children:e.jsx(D,{size:16})})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-100 truncate",children:s.displayName}),e.jsx("button",{onClick:()=>{c(s.displayName),o(!0)},className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(je,{size:14})})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["@",s.username]}),e.jsx($,{label:s.role==="superadmin"?"super admin":s.role,color:Me[s.role]||"gray"})]}),e.jsx("div",{className:"mt-1 text-sm text-gray-400",children:s.email?s.email:e.jsx("span",{className:"text-gray-600",children:"No email on file — ask an administrator to add one (needed for password reset)"})}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(we,{size:12})," Joined ",z(s.createdAt)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:12})," Last login ",z(s.lastLoginAt)]})]})]})]})})}function Ue({toast:s}){const[i,r]=d.useState(""),[t,u]=d.useState(""),[o,n]=d.useState(""),[c,l]=d.useState(!1),[x,y]=d.useState(!1),[m,j]=d.useState(!1),[h,p]=d.useState(""),f=N({mutationFn:()=>de(i,t),onSuccess:()=>{s("success","Password changed successfully"),r(""),u(""),n(""),p("")},onError:g=>{p(g.message||"Failed to change password")}}),b=g=>{if(g.preventDefault(),p(""),!i||!t||!o){p("All fields are required");return}if(t.length<6){p("New password must be at least 6 characters");return}if(t!==o){p("New passwords do not match");return}f.mutate()};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ve,{size:16}),"Change Password"]}),e.jsxs("form",{onSubmit:b,className:"space-y-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Current Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:c?"text":"password",value:i,onChange:g=>r(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Enter current password"}),e.jsx("button",{type:"button",onClick:()=>l(!c),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:c?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:x?"text":"password",value:t,onChange:g=>u(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"At least 6 characters"}),e.jsx("button",{type:"button",onClick:()=>y(!x),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:x?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:m?"text":"password",value:o,onChange:g=>n(g.target.value),className:"w-full bg-surface-2 border border-white/10 rounded-xl px-3.5 py-2.5 text-[15px] text-gray-100 pr-10 focus:outline-none focus:ring-1 focus:ring-brand-500",placeholder:"Re-enter new password"}),e.jsx("button",{type:"button",onClick:()=>j(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-300",children:m?e.jsx(A,{size:16}):e.jsx(T,{size:16})})]})]}),h&&e.jsx("p",{className:"text-xs text-red-400",children:h}),e.jsxs("button",{type:"submit",disabled:f.isPending,className:"flex items-center gap-2 px-5 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-[15px] font-medium rounded-xl transition-colors disabled:opacity-50",children:[f.isPending?e.jsx(C,{size:14,className:"animate-spin"}):e.jsx(Ne,{size:14}),"Update Password"]})]})]})}function $e({sessions:s,queryClient:i,toast:r}){const t=N({mutationFn:le,onSuccess:()=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success","Session revoked")},onError:n=>r("error",n.message)}),u=N({mutationFn:xe,onSuccess:n=>{i.invalidateQueries({queryKey:["my-sessions"]}),r("success",`${n.sessionsRevoked} session(s) revoked`)},onError:n=>r("error",n.message)}),o=s.filter(n=>!n.isCurrent);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(R,{size:16}),"Active Sessions",e.jsxs("span",{className:"text-xs text-gray-500 font-normal",children:["(",s.length,")"]})]}),o.length>0&&e.jsxs("button",{onClick:()=>u.mutate(),disabled:u.isPending,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-red-400 hover:text-red-300 bg-red-500/10 hover:bg-red-500/20 rounded transition-colors",children:[u.isPending?e.jsx(C,{size:12,className:"animate-spin"}):e.jsx(Ce,{size:12}),"Revoke All Others"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No active sessions"}):e.jsx("div",{className:"space-y-2",children:s.map(n=>{const{browser:c,os:l,isMobile:x}=Q(n.userAgent);return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-surface-2 rounded-lg border border-white/5",children:[x?e.jsx(F,{size:18,className:"text-gray-400 shrink-0"}):e.jsx(R,{size:18,className:"text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-200 font-medium",children:[c," on ",l]}),n.isCurrent&&e.jsx($,{label:"Current",color:"green"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 mt-0.5",children:[n.ipAddress&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ke,{size:10})," ",n.ipAddress]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{size:10})," ",I(n.createdAt)]}),e.jsxs("span",{children:["Expires ",z(n.expiresAt)]})]})]}),!n.isCurrent&&e.jsx("button",{onClick:()=>t.mutate(n.id),disabled:t.isPending,className:"p-1.5 text-gray-500 hover:text-red-400 transition-colors",title:"Revoke session",children:e.jsx(K,{size:14})})]},n.id)})})]})}const v=20;function Ke({entries:s,total:i,page:r,loading:t,onPage:u}){const o=Math.max(1,Math.ceil(i/v)),n=i===0?0:r*v+1,c=Math.min(i,(r+1)*v);return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(O,{size:16}),"Recent Activity",i>0&&e.jsxs("span",{className:"text-xs font-normal text-gray-500",children:["(",i,")"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-gray-500 py-4 text-center",children:"No recent activity"}):e.jsx("div",{className:"space-y-1",children:s.map(l=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 rounded hover:bg-surface-2 transition-colors",children:[e.jsx(O,{size:14,className:`shrink-0 ${Oe(l.action)}`}),e.jsx("span",{className:"text-sm text-gray-300 flex-1 truncate",children:qe(l.action)}),l.resourceId&&e.jsx("span",{className:"text-xs text-gray-500 truncate max-w-[200px]",children:l.resourceId}),e.jsx("span",{className:"text-xs text-gray-500 shrink-0",children:I(l.timestamp)})]},l.id))}),i>v&&e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-3 border-t border-white/5",children:[e.jsxs("span",{className:"text-xs text-gray-500",children:["Showing ",n,"–",c," of ",i]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>u(r-1),disabled:r===0||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(Se,{size:14})," Previous"]}),e.jsxs("span",{className:"text-xs text-gray-400 tabular-nums min-w-[84px] text-center",children:["Page ",r+1," of ",o]}),e.jsxs("button",{onClick:()=>u(r+1),disabled:r>=o-1||t,className:"flex items-center gap-1 h-8 px-3 rounded-lg border border-white/10 text-xs text-gray-300 hover:bg-white/5 disabled:opacity-40 disabled:cursor-not-allowed",children:["Next ",e.jsx(Pe,{size:14})]})]})]})]})}function De(){const[s,i]=d.useState(L()),r=()=>{ue(),i(L())};return e.jsxs("div",{className:"bg-surface-1 rounded-xl border border-white/5 p-5 space-y-4",children:[e.jsxs("h2",{className:"text-base font-semibold text-gray-200 flex items-center gap-2",children:[e.jsx(ze,{size:16}),"Preferences"]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200",children:"Theme"}),e.jsx("p",{className:"text-xs text-gray-500",children:"Switch between dark and light mode"})]}),e.jsxs("button",{onClick:r,className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border border-white/10 rounded text-sm text-gray-300 hover:text-gray-100 transition-colors",children:[s==="dark"?e.jsx(Ae,{size:14}):e.jsx(Te,{size:14}),s==="dark"?"Dark":"Light"]})]})]})}export{Ye as ProfilePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as I,r as t,
|
|
1
|
+
import{e as I,r as t,b as K,j as e}from"./vendor-react-DOVfxdUy.js";import{u as U}from"./vendor-query-DkZSMtfn.js";import{a as q,L as _}from"./index-D6sQYc_0.js";import{u as $,F as B,a as O}from"./FileViewer-mU3JloJ6.js";import{E as Q}from"./EmptyState-utxlJ0fu.js";import{F as V,ax as G,ay as J,v as Y,X as Z,i as ee}from"./vendor-icons-D_Dmmj8d.js";import"./RemoteFileStrip-C1S2aclP.js";import"./index-DLmlY2Ol.js";import"./useChartTheme-CTIe6M63.js";import"./sandboxStorage-BrzaG3ny.js";import"./simpleMarkdown-kWs-10D8.js";import"./formatDate-T65-Y6Mi.js";import"./UncommittedDiffViewer-FKvUZcRi.js";function F(o){const r=[];for(const s of o)s.type==="directory"&&(r.push(s.path),s.children&&r.push(...F(s.children)));return r}function L(o){let r=0;for(const s of o)s.type==="file"?r++:s.children&&(r+=L(s.children));return r}function te(o,r){const s=[];function u(d,h){for(const i of d){if(i.path===o)return s.push(...h),!0;if(i.type==="directory"&&i.children&&u(i.children,[...h,i.path]))return!0}return!1}return u(r,[]),s}function me(){const[o,r]=I(),{expanded:s,toggle:u,expandAll:d,collapseAll:h}=$("testver_explorer_expanded"),[i,j]=t.useState(null),[S,P]=t.useState(null),[m,w]=t.useState(""),[p,z]=t.useState(280),[C,b]=t.useState(!1),M=t.useRef(null),g=t.useRef(null),[R,N]=t.useState(null),{data:f,isLoading:D}=U({queryKey:["fileTree"],queryFn:q,staleTime:3e4}),l=t.useMemo(()=>f?f.children??[f]:[],[f]),T=t.useMemo(()=>L(l),[l]),A=t.useMemo(()=>F(l),[l]),v=K(),k=t.useRef(null),y=t.useRef(s);y.current=s,t.useEffect(()=>{if(!l.length||k.current===v.key)return;k.current=v.key;const n=o.get("file");if(!n)return;j(n);const a=Number.parseInt(o.get("line")??"",10);N(a>0?a:null);const c=te(n,l).filter(x=>!y.current.has(x));c.length>0&&d([...y.current,...c]),r({},{replace:!0})},[l,v.key,o,r,d]),t.useEffect(()=>{const n=a=>{if((a.ctrlKey||a.metaKey)&&a.key==="f"&&g.current){const c=document.activeElement;(!c||!c.closest(".monaco-editor"))&&(a.preventDefault(),g.current.focus())}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]);const W=t.useCallback(n=>{n.preventDefault(),b(!0);const a=n.clientX,c=p,x=X=>{const H=Math.max(200,Math.min(500,c+X.clientX-a));z(H)},E=()=>{b(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",E)},[p]);return D?e.jsx(_,{text:"Loading project tree..."}):l.length?e.jsx("div",{className:"h-full flex flex-col animate-fade-in",children:e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col border-r border-white/5 bg-surface-1 flex-shrink-0 overflow-hidden",style:{width:`${p}px`},children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-white/5 flex-shrink-0",children:[e.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-gray-500 mr-auto",children:["Explorer",e.jsxs("span",{className:"ml-1.5 font-normal text-gray-600",children:[T," files"]})]}),e.jsx("button",{onClick:()=>d(A),className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Expand all",children:e.jsx(G,{size:14})}),e.jsx("button",{onClick:h,className:"p-1 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300 transition-colors",title:"Collapse all",children:e.jsx(J,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-white/5 flex-shrink-0",children:[e.jsx(Y,{size:13,className:"text-gray-500 flex-shrink-0"}),e.jsx("input",{ref:g,type:"text",value:m,onChange:n=>w(n.target.value),placeholder:"Filter files...",className:"flex-1 bg-transparent border-none outline-none text-xs text-gray-300 placeholder-gray-600 min-w-0"}),m&&e.jsx("button",{onClick:()=>w(""),className:"p-0.5 rounded hover:bg-white/5 text-gray-500 hover:text-gray-300",children:e.jsx(Z,{size:12})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden py-1 scrollbar-thin",children:e.jsx(B,{nodes:l,expanded:s,selectedPath:S??i,onToggle:u,onSelect:j,filter:m||void 0})})]}),e.jsx("div",{ref:M,className:`w-1 cursor-col-resize hover:bg-brand-500/30 transition-colors flex-shrink-0 ${C?"bg-brand-500/40":""}`,onMouseDown:W}),e.jsx("div",{className:"flex-1 overflow-hidden",children:i?e.jsx(O,{filePath:i,onActiveFileChange:P,initialHighlightLine:R,onHighlightConsumed:()=>N(null)}):e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-gray-500",children:[e.jsx(ee,{size:40,strokeWidth:1,className:"text-gray-600"}),e.jsx("p",{className:"text-sm",children:"Select a file to view its contents"}),e.jsx("p",{className:"text-xs text-gray-600",children:"Browse the project tree on the left"})]})})})]})}):e.jsx(Q,{title:"No project files",description:"No files found in this project",icon:e.jsx(V,{size:28})})}export{me as ProjectExplorer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,u}from"./vendor-react-
|
|
1
|
+
import{j as e,u}from"./vendor-react-DOVfxdUy.js";import{aa as d,a9 as g,ax as f,ay as h,h as x,P as b}from"./index-D6sQYc_0.js";import{A as k,s as m,aa as y,br as j}from"./vendor-icons-D_Dmmj8d.js";function p(){const n=d(),{data:t}=g(n),s=(t==null?void 0:t.check)??null,i=new Map;if(s&&f(s)){for(const a of s.incoming)for(const r of a.files){const o=h(s,r.path);o&&!i.has(o)&&i.set(o,a)}for(const a of s.incomingFiles){const r=h(s,a);r&&!i.has(r)&&i.set(r,{sha:s.upstreamSha??"",shortSha:"",author:"",email:"",message:"",timestamp:"",files:[]})}}return{check:s,byPath:i}}const c=n=>n.replace(/\\/g,"/").replace(/^\.\//,"");function v({path:n,byPath:t,label:s}){return t.has(c(n))?e.jsx("span",{className:"text-[10px] font-semibold px-1 rounded bg-sky-500/15 text-sky-700 dark:text-sky-300 flex items-center flex-shrink-0",title:`Newer on ${s}`,children:e.jsx(k,{size:10})}):null}function P({filePath:n}){const t=u(),{check:s,byPath:i}=p(),a=i.get(c(n));if(!s||!a)return null;const r=x(s),o=s.projectPrefix+c(n),l=s.dirtyFiles.includes(o);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-sky-500/30 bg-sky-500/10 text-xs text-gray-700 dark:text-gray-300 flex-shrink-0",children:[e.jsx(m,{size:13,className:"text-sky-600 shrink-0"}),e.jsxs("span",{className:"flex-1 min-w-0",children:[a.author?e.jsxs(e.Fragment,{children:[a.author," changed this file on ",r," ",b(a.timestamp)," — “",a.message,"”."]}):e.jsxs(e.Fragment,{children:["This file has newer changes on ",r,"."]}),l&&" You also have uncommitted edits here."]}),e.jsxs("button",{onClick:()=>t("/git?incoming=1"),className:"px-2 py-1 text-xs rounded bg-surface-2 hover:bg-surface-3 text-gray-300 border border-white/5 flex items-center gap-1 shrink-0",children:[e.jsx(y,{size:12})," View change"]}),e.jsx("button",{onClick:()=>t("/git"),className:`px-2 py-1 text-xs rounded text-white flex items-center gap-1 shrink-0 ${l?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:l?e.jsxs(e.Fragment,{children:[e.jsx(j,{size:12})," Stash, pull & re-apply"]}):e.jsxs(e.Fragment,{children:[e.jsx(m,{size:12})," Pull"]})})]})}function R({filePath:n}){const{check:t,byPath:s}=p();return!t||!s.has(c(n))?null:e.jsxs("span",{className:"text-[9px] font-medium text-sky-700 dark:text-sky-300 bg-sky-500/15 px-1.5 py-0.5 rounded uppercase",children:["Newer on ",x(t)]})}export{v as I,R,P as a,p as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as p,j as e,u as Fe,L as Te}from"./vendor-react-DOVfxdUy.js";import{f as X}from"./formatDate-T65-Y6Mi.js";import{T as he,a as Re,K as Me}from"./KpiTile-BHLE3HVj.js";import{R as O,P as De,m as Be,n as ze,T as H,o as K,B as ge,h as G,X as Q,Y as Z,l as me,j as Ie,L as _e}from"./vendor-charts-By5uZ93z.js";import{y as V,S as Ue,v as Oe,cy as He,a0 as B,a5 as Ke,dk as z,am as Pe,dl as pe,L as We,dm as Ye,_ as qe,ag as Xe,dd as Ge}from"./vendor-icons-D_Dmmj8d.js";import{ae as Qe,bY as Ze,a6 as ue,gN as Je,gO as Ve,gP as et,gQ as tt}from"./index-D6sQYc_0.js";function be({active:t,payload:s,label:a,clickHint:n}){return!t||!s||s.length===0?null:e.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-gray-900 shadow-lg px-2.5 py-2 text-xs min-w-[120px]",children:[a!=null&&a!==""&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider font-semibold text-gray-500 dark:text-gray-400 mb-1.5",children:String(a)}),e.jsx("div",{className:"space-y-1",children:s.map((r,g)=>{var N;const l=r.value,x=String(r.name??r.dataKey??""),S=r.color||((N=r.payload)==null?void 0:N.fill)||"#3B82F6";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{"aria-hidden":!0,className:"inline-block w-2.5 h-2.5 rounded-sm flex-shrink-0",style:{background:S}}),x&&x!=="value"&&e.jsx("span",{className:"text-gray-600 dark:text-gray-300 flex-1 truncate",children:x}),e.jsx("span",{className:"tabular-nums font-semibold text-gray-900 dark:text-gray-100 ml-auto",children:typeof l=="number"?Number.isInteger(l)?l.toLocaleString():l.toFixed(2):String(l??"")})]},g)})}),n&&e.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-gray-100 dark:border-white/10 text-[11px] text-blue-700 dark:text-blue-300",children:n})]})}const ye={vibrant:["#8AB4F8","#F4A0A0","#7DD3AE","#F6C66E","#B3A1EE","#F2A5C7","#7CCFC6","#F7B489","#A2ACF2","#8BCFE6"],pastel:["#93C5FD","#FCA5A5","#6EE7B7","#FCD34D","#C4B5FD","#F9A8D4","#5EEAD4","#FDBA74","#A5B4FC","#67E8F9"]},rt={status:{passed:"#7DD3AE",failed:"#F4A0A0",skipped:"#F6C66E",blocked:"#F7B489",not_run:"#C3C9D2",in_progress:"#8AB4F8"},priority:{critical:"#F4A0A0",high:"#F7B489",medium:"#F6C66E",low:"#8AB4F8"},severity:{blocker:"#EE8F8F",critical:"#F4A0A0",major:"#F6C66E",minor:"#8AB4F8",trivial:"#C3C9D2"}};function fe(t,s,a){if(Array.isArray(a)&&a.length>=t.length&&a.every(g=>typeof g=="string"))return a;const n=ye.vibrant;if(s==="status"||s==="priority"||s==="severity"){const g=rt[s];return t.map((l,x)=>g[String(l).toLowerCase().replace(/\s+/g,"_")]||n[x%n.length])}const r=s==="pastel"?ye.pastel:n;return t.map((g,l)=>r[l%r.length])}const P=t=>s=>{const a=String(s??"");return a.length>t?`${a.slice(0,t-1)}…`:a},ke=t=>(Array.isArray(t)?t:[]).map(s=>typeof s=="number"&&Number.isFinite(s)?s:Number(s)||0);function at({cell:t,height:s=260,onPick:a,clickHint:n}){var v;const r=p.useMemo(()=>{var j;const i=(Array.isArray(t.labels)?t.labels:[]).map(w=>String(w??"")),h=(Array.isArray(t.datasets)?t.datasets:[]).filter(w=>w&&typeof w=="object").map((w,$)=>({label:String(w.label??`Series ${$+1}`),data:ke(w.data)})),y=t.chartType==="pie"||t.chartType==="doughnut",k=Array.isArray(t.data)&&t.data.length>0?ke(t.data):y?(j=h[0])==null?void 0:j.data:void 0;return{...t,labels:i,data:k,datasets:y?void 0:h.length>0?h:void 0}},[t]),g=p.useMemo(()=>fe(r.labels,r.colorScheme,r.colors),[r.labels,r.colorScheme,r.colors]),l=p.useMemo(()=>fe((r.datasets||[]).map(i=>i.label),r.colorScheme,r.colors),[r.datasets,r.colorScheme,r.colors]),x=r.datasets&&r.datasets.length>0?l:g,S=p.useMemo(()=>r.datasets&&r.datasets.length>0?r.labels.map((i,h)=>{const y={label:i};for(const k of r.datasets)y[k.label]=k.data[h]??0;return y}):r.labels.map((i,h)=>{var y;return{label:i,value:((y=r.data)==null?void 0:y[h])??0}}),[r.labels,r.data,r.datasets]),N=((v=r.datasets)==null?void 0:v.map(i=>i.label))??["value"],R=r.labels.reduce((i,h)=>Math.max(i,h.length),0),C={fill:"rgb(107 114 128)",fontSize:11},L="rgba(107,114,128,0.2)",A={stroke:"rgba(107,114,128,0.4)"},M={fill:"rgba(107,114,128,0.08)"},m=p.useMemo(()=>{var w;const i=(((w=r.datasets)==null?void 0:w.flatMap($=>$.data))??r.data??[]).filter($=>Number.isFinite($));if(i.length<2)return;const h=Math.min(...i),y=Math.max(...i),k=Math.max((y-h)*.15,Math.abs(y)*.01,1);return[h>=0?Math.max(0,Math.floor(h-k)):Math.floor(h-k),Math.ceil(y+k)]},[r.data,r.datasets]),o=a?i=>{const h=i==null?void 0:i.activeTooltipIndex;typeof h=="number"&&h>=0&&a(h)}:void 0,u=a?{cursor:"pointer"}:void 0,b=e.jsx(be,{clickHint:a?n:void 0}),f=i=>e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:String(i??"")}),d={fontSize:11,color:"rgb(107 114 128)",maxHeight:56,overflowY:"auto"};if(r.labels.length===0||!r.datasets&&!(r.data&&r.data.length>0))return e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 p-4 text-center",children:"No data to chart."});switch(r.chartType){case"line":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(Ie,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1,domain:m,allowDecimals:!0}),e.jsx(H,{content:b,cursor:A}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(_e,{type:"monotone",dataKey:i,stroke:x[h%x.length],strokeWidth:2,dot:{r:3,fill:x[h%x.length]},activeDot:{r:5}},i))]})});case"bar":case"stacked_bar":return e.jsx(O,{width:"100%",height:s,children:e.jsxs(ge,{data:S,margin:{top:8,right:16,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L}),e.jsx(Q,{dataKey:"label",tick:C,axisLine:!1,tickLine:!1,interval:0,angle:-28,textAnchor:"end",height:60,tickFormatter:P(16)}),e.jsx(Z,{tick:C,axisLine:!1,tickLine:!1}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[4,4,0,0],stackId:r.chartType==="stacked_bar"?"s1":void 0},i))]})});case"horizontal_bar":return e.jsx(O,{width:"100%",height:Math.max(s,r.labels.length*28+40),children:e.jsxs(ge,{data:S,layout:"vertical",margin:{top:8,right:24,bottom:8,left:0},onClick:o,style:u,children:[e.jsx(G,{strokeDasharray:"3 3",stroke:L,horizontal:!1}),e.jsx(Q,{type:"number",tick:C,axisLine:!1,tickLine:!1}),e.jsx(Z,{type:"category",dataKey:"label",tick:C,axisLine:!1,tickLine:!1,width:Math.min(180,Math.max(60,R*6.5)),tickFormatter:P(28)}),e.jsx(H,{content:b,cursor:M}),N.length>1&&e.jsx(K,{wrapperStyle:d,formatter:f}),N.map((i,h)=>e.jsx(me,{dataKey:i,fill:x[h%x.length],radius:[0,4,4,0]},i))]})});case"pie":case"doughnut":{const i=r.labels.map((k,j)=>{var w;return{name:k,value:((w=r.data)==null?void 0:w[j])??0}}),h=i.reduce((k,j)=>k+(Number(j.value)||0),0),y=(k,j)=>{var I;const w=Number((I=j==null?void 0:j.payload)==null?void 0:I.value)||0,$=h>0?Math.round(w/h*1e3)/10:0;return e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:`${P(28)(k)} · ${$}%`})};return e.jsx(O,{width:"100%",height:s,children:e.jsxs(De,{children:[e.jsx(Be,{data:i,dataKey:"value",nameKey:"name",innerRadius:r.chartType==="doughnut"?"55%":0,outerRadius:"85%",paddingAngle:2,children:i.map((k,j)=>e.jsx(ze,{fill:x[j%x.length],stroke:"transparent"},j))}),e.jsx(H,{content:e.jsx(be,{})}),e.jsx(K,{wrapperStyle:d,formatter:y})]})})}default:return e.jsxs("div",{className:"text-xs text-gray-500 p-4",children:["Unsupported chart type: ",r.chartType]})}}function st(){const t=p.useRef(null),[s,a]=p.useState(0);return p.useEffect(()=>{const n=t.current;if(!n||typeof ResizeObserver>"u")return;const r=new ResizeObserver(g=>{var l;return a(((l=g[0])==null?void 0:l.contentRect.width)??0)});return r.observe(n),a(n.getBoundingClientRect().width),()=>r.disconnect()},[]),[t,s]}function je({spec:t,links:s=!0}){const[a,n]=st(),r=n>0&&n<640,g=Array.isArray(t.cells)?t.cells:[],l=typeof t.method=="string"?t.method.trim():"";return e.jsxs("div",{ref:a,className:"flex flex-col gap-4",children:[t.summary&&e.jsx(nt,{summary:t.summary,narrow:r}),e.jsx("div",{className:"grid grid-cols-12 gap-4",children:g.map((x,S)=>e.jsx(it,{cell:x,narrow:r,links:s},S))}),l&&e.jsxs("details",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-3.5 group","data-testid":"report-method",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-semibold text-gray-800 dark:text-gray-200 list-none flex items-center gap-1.5",children:[e.jsx(V,{size:14,className:"transition-transform group-open:rotate-180","aria-hidden":!0}),"How this was calculated"]}),e.jsx("p",{className:"mt-2 text-sm leading-relaxed text-gray-700 dark:text-gray-300 whitespace-pre-line",children:l})]})]})}const we={good:{sym:"✓",cls:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"},warn:{sym:"~",cls:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300"},bad:{sym:"!",cls:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300"},info:{sym:"i",cls:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"}};function nt({summary:t,narrow:s}){const a=Array.isArray(t.findings)?t.findings:[],n=t.status&&he[t.status]?t.status:void 0;return e.jsxs("section",{className:`rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 grid gap-5 ${s||a.length===0?"grid-cols-1":"grid-cols-[minmax(220px,1fr)_minmax(0,2fr)]"}`,"aria-label":"Summary","data-testid":"report-summary",children:[e.jsxs("div",{className:"flex flex-col items-start gap-2",children:[n&&e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${Re[n]}`,children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-current opacity-80","aria-hidden":!0}),he[n]]}),t.verdict&&e.jsx("p",{className:"text-lg leading-snug font-bold text-gray-900 dark:text-gray-100",children:t.verdict}),e.jsxs("p",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx(Ue,{size:13,"aria-hidden":!0})," Summary written by the AI Assistant"]})]}),a.length>0&&e.jsx("ul",{className:"flex flex-col gap-2.5",children:a.map((r,g)=>{const l=we[r.tone]??we.info;return e.jsxs("li",{className:"flex items-start gap-2.5 text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:[e.jsx("span",{className:`mt-0.5 flex h-[18px] w-[18px] flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold ${l.cls}`,"aria-hidden":!0,children:l.sym}),e.jsxs("span",{children:[e.jsx("strong",{className:"font-semibold text-gray-900 dark:text-gray-100",children:r.title}),r.detail?` ${r.detail}`:""]})]},g)})})]})}function it({cell:t,narrow:s,links:a}){const n=t.type==="kpi"?3:t.type==="chart"?6:12,r=Math.max(1,Math.min(12,Math.round(Number(t.span)||n))),g=s?t.type==="kpi"?6:12:r,l={gridColumn:`span ${g} / span ${g}`};return t.type==="kpi"?e.jsx("div",{style:l,children:e.jsx(Me,{cell:t})}):t.type==="chart"?e.jsx("div",{style:l,children:e.jsx(ot,{cell:t,links:a})}):t.type==="table"?e.jsx("div",{style:l,children:e.jsx(ht,{cell:t,links:a})}):t.type==="markdown"?e.jsx("div",{style:l,children:e.jsx("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4","data-testid":"report-note",children:e.jsx(gt,{content:String(t.content??"")})})}):null}function ot({cell:t,links:s}){const a=Fe(),n=s&&Array.isArray(t.runIds)&&t.runIds.some(Boolean)?t.runIds:null,r=n?g=>{const l=n[g];l&&a(`/results?runId=${encodeURIComponent(l)}`)}:void 0;return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-chart",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),(t.hint||n)&&e.jsxs("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:[t.hint,t.hint&&n?" ":"",n?"Click a bar or point to open the run.":""]}),e.jsx("div",{className:"mt-3",children:e.jsx(at,{cell:t,onPick:r,clickHint:"Click to open this run in Results"})})]})}const lt=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected|never run|not run)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,dt={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",bad:"bg-rose-50 text-rose-700 dark:bg-rose-500/15 dark:text-rose-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300",neutral:"bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300"},ct={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn"},Ne=/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/,xt=/^[A-Za-z0-9._-]{1,120}$/,J=10;function ve(t){const s=t.trim();return Ne.test(s)?Number(s.replace(/[,%\s]|ms|s$/g,"")):null}function ht({cell:t,links:s=!0}){const a=(Array.isArray(t.headers)?t.headers:[]).map(m=>String(m??"")),n=p.useMemo(()=>(Array.isArray(t.rows)?t.rows:[]).map(m=>(Array.isArray(m)?m:[m]).map(o=>String(o??""))),[t.rows]),[r,g]=p.useState(null),[l,x]=p.useState(""),[S,N]=p.useState(!1),R=p.useMemo(()=>a.map((m,o)=>{const u=n.map(b=>(b[o]??"").trim()).filter(Boolean);return u.length>0&&u.every(b=>Ne.test(b))}),[a,n]),C=p.useMemo(()=>{const m=s&&t.columnLinks&&typeof t.columnLinks=="object"?t.columnLinks:{},o=a.findIndex(u=>m[u]==="file");return(u,b)=>{const f=m[a[b]??""],d=(u[b]??"").trim();if(!f||!d)return null;if(f==="run"){const v=d.split(/\s+/)[0]??"";return xt.test(v)?`/results?runId=${encodeURIComponent(v)}`:null}return f==="file"?`/tests?file=${encodeURIComponent(d)}`:f==="test"&&o>=0&&u[o]?`/tests?file=${encodeURIComponent(u[o].trim())}&test=${encodeURIComponent(d)}`:null}},[s,t.columnLinks,a]),L=p.useMemo(()=>{const m=l.trim().toLowerCase();let o=m?n.filter(u=>u.some(b=>b.toLowerCase().includes(m))):n;return r&&(o=[...o].sort((u,b)=>{const f=u[r.col]??"",d=b[r.col]??"",v=ve(f),i=ve(d);return(v!=null&&i!=null?v-i:f.localeCompare(d,void 0,{numeric:!0,sensitivity:"base"}))*r.dir})),o},[n,l,r]),A=S?L:L.slice(0,J),M=m=>g(o=>{const u=R[m]?-1:1;return!o||o.col!==m?{col:m,dir:u}:o.dir===u?{col:m,dir:u===1?-1:1}:null});return e.jsxs("div",{className:"rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] px-5 py-4 h-full","data-testid":"report-table",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:t.title}),t.hint&&e.jsx("p",{className:"mt-0.5 text-[13px] text-gray-500 dark:text-gray-400",children:t.hint})]}),n.length>J&&e.jsxs("label",{className:"flex h-8 items-center gap-2 rounded-lg border border-gray-300 dark:border-white/15 px-2.5 text-[13px] text-gray-500 dark:text-gray-400",children:[e.jsx(Oe,{size:13,"aria-hidden":!0}),e.jsx("span",{className:"sr-only",children:"Filter rows"}),e.jsx("input",{value:l,onChange:m=>{x(m.target.value),N(!1)},placeholder:"Filter rows",className:"w-36 bg-transparent text-[13px] text-gray-900 dark:text-gray-100 outline-none placeholder:text-gray-400"})]})]}),e.jsx("div",{className:"mt-3 overflow-x-auto rounded-lg border border-gray-200 dark:border-white/10",children:e.jsxs("table",{className:"w-full border-collapse text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-white/[0.04]",children:a.map((m,o)=>{const u=(r==null?void 0:r.col)===o;return e.jsx("th",{scope:"col","aria-sort":u?r.dir===1?"ascending":"descending":"none",className:`border-b border-gray-200 dark:border-white/10 px-3.5 py-2.5 text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-400 whitespace-nowrap ${R[o]?"text-right":"text-left"}`,children:e.jsxs("button",{type:"button",onClick:()=>M(o),className:"inline-flex items-center gap-1 uppercase hover:text-gray-900 dark:hover:text-gray-200",title:`Sort by ${m}`,children:[m,u&&(r.dir===1?e.jsx(He,{size:12,"aria-hidden":!0}):e.jsx(V,{size:12,"aria-hidden":!0}))]})},o)})})}),e.jsxs("tbody",{children:[A.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:a.length||1,className:"px-3.5 py-6 text-center text-[13px] text-gray-500 dark:text-gray-400",children:n.length===0?"No rows":"No rows match the filter"})}),A.map((m,o)=>e.jsx("tr",{className:"hover:bg-gray-50/70 dark:hover:bg-white/[0.03]",children:a.map((u,b)=>{const f=m[b]??"",d=lt.exec(f.trim()),v=C(m,b);let i=f;if(d){const h=ct[d[1].toLowerCase()]??"neutral";i=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`inline-block rounded-full px-2 py-0.5 text-xs font-semibold ${dt[h]}`,children:`${d[1]}${d[2]??""}`.trim()}),d[3]&&e.jsx("span",{className:"ml-1.5 text-gray-500 dark:text-gray-400",children:d[3].trim()})]})}else v&&(i=e.jsx(Te,{to:v,className:"font-medium text-blue-700 dark:text-blue-300 hover:underline",children:f}));return e.jsx("td",{title:f.length>60?f:void 0,className:`border-b border-gray-100 dark:border-white/[0.06] px-3.5 py-2.5 align-top text-gray-800 dark:text-gray-200 ${R[b]?"text-right tabular-nums whitespace-nowrap":""} ${b===0&&!v?"font-medium text-gray-900 dark:text-gray-100":""} max-w-[28rem] break-words`,children:i},b)})},o))]})]})}),L.length>J&&e.jsx("button",{type:"button",onClick:()=>N(m=>!m),className:"mt-2.5 text-[13px] font-medium text-blue-700 dark:text-blue-300 hover:underline",children:S?"Show fewer rows":`Show all ${L.length} rows`})]})}function gt({content:t}){const s=t.split(`
|
|
2
|
+
`),a=[];let n=[];const r=()=>{n.length!==0&&(a.push(e.jsx("ul",{className:"list-disc pl-5 text-sm text-gray-700 dark:text-gray-300 space-y-1.5 my-2 leading-relaxed",children:n.map((l,x)=>e.jsx("li",{dangerouslySetInnerHTML:{__html:g(l)}},x))},a.length)),n=[])},g=l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/\*\*(.+?)\*\*/g,'<strong class="font-semibold text-gray-900 dark:text-gray-100">$1</strong>').replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 rounded bg-gray-100 dark:bg-white/10 font-mono text-[12px]">$1</code>');for(const l of s){const x=l.trim();if(!x){r();continue}x.startsWith("## ")||x.startsWith("### ")?(r(),a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.replace(/^#+\s/,""))}},a.length))):x.startsWith("# ")?(r(),a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-gray-100 mt-2 mb-1.5",dangerouslySetInnerHTML:{__html:g(x.slice(2))}},a.length))):x.startsWith("- ")||x.startsWith("* ")?n.push(x.slice(2)):(r(),a.push(e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300 my-1.5 leading-relaxed",dangerouslySetInnerHTML:{__html:g(x)}},a.length)))}return r(),e.jsx(e.Fragment,{children:a})}const mt=[{days:void 0,label:"Never"},{days:7,label:"7 days"},{days:30,label:"30 days"},{days:90,label:"90 days"}];function jt({spec:t,urls:s,savedId:a,initialShareToken:n,initialShareExpiresAt:r,readonly:g=!1,variant:l="card",chips:x,metaLine:S,leadActions:N,trailActions:R,links:C}){const{hasRole:L}=Qe(),A=!g&&L("tester"),[M,m]=p.useState(!1),[o,u]=p.useState(a),[b,f]=p.useState(!1),[d,v]=p.useState(n),[i,h]=p.useState(r),[y,k]=p.useState(!1),[j,w]=p.useState("closed"),[$,I]=p.useState(void 0),[_,U]=p.useState(!1),[ee,te]=p.useState(null),[re,ae]=p.useState(null);p.useEffect(()=>{a&&u(a)},[a]),p.useEffect(()=>{n&&v(n)},[n]),p.useEffect(()=>{r&&h(r)},[r]);const F=c=>{ae(c),setTimeout(()=>ae(null),2600)},D=d?`/reports/share/${d}`:o?`/reports/view/${o}`:(s==null?void 0:s.html)||"",Se=async()=>{if(!D)return;const c=`${window.location.origin}${D}`;try{await navigator.clipboard.writeText(c),m(!0),setTimeout(()=>m(!1),1500)}catch{}},se=async()=>{const c=await tt({title:t.title,spec:t,outputFiles:s?{html:s.html,json:s.json}:void 0});return u(c.id),c.id},ne=async()=>{if(!(o||b)){f(!0);try{await se(),F("Saved to your reports")}catch(c){F(`Save failed: ${c instanceof Error?c.message:String(c)}`)}finally{f(!1)}}},Ce=async()=>{if(!y){k(!0);try{const c=o??await se(),{token:E,shareExpiresAt:Ee}=await Ve(c,$);v(E),h(Ee),w("link"),F("Share link created")}catch(c){F(`Share failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},Ae=async()=>{if(!(!d||!o)){k(!0);try{await et(o),v(void 0),h(void 0),w("closed"),F("Share link revoked")}catch(c){F(`Revoke failed: ${c instanceof Error?c.message:String(c)}`)}finally{k(!1)}}},W=d?`${window.location.origin}/reports/share/${d}`:"",Le=async()=>{if(W)try{await navigator.clipboard.writeText(W),F("Share URL copied")}catch{}},ie=g&&d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:o?Ze(`/api/reports/${encodeURIComponent(o)}/render.html`):d?`/api/reports/share/${encodeURIComponent(d)}/render.html`:s!=null&&s.html?ue(s.html):null,$e=async c=>{U(!1),te(c);try{await Je(c,g&&d?{shareToken:d}:o?{reportId:o}:{spec:t,title:t.title})}catch(E){F(`Download failed: ${E instanceof Error?E.message:String(E)}`)}finally{te(null)}},Y=p.useRef(null);p.useEffect(()=>{if(!_)return;const c=E=>{Y.current&&!Y.current.contains(E.target)&&U(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[_]);const oe="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",q="inline-flex h-8 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-2.5 text-[13px] font-medium text-gray-800 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60",le="inline-flex h-8 w-8 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-600 dark:text-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-white/[0.08] dark:hover:text-gray-100 transition-colors",T=l==="page",de=()=>w(c=>c==="closed"?d?"link":"create":"closed"),ce=e.jsxs("div",{className:"relative",ref:Y,children:[e.jsxs("button",{onClick:()=>U(c=>!c),disabled:!!ee,title:"Download","aria-haspopup":"menu","aria-expanded":_,className:T?"inline-flex h-9 items-center gap-1.5 rounded-lg bg-brand-600 px-3.5 text-sm font-medium text-white hover:bg-brand-700 transition-colors disabled:opacity-60":q,children:[ee?e.jsx(B,{size:T?15:14,className:"animate-spin"}):e.jsx(Ke,{size:T?15:14}),"Download",e.jsx(V,{size:T?14:13,"aria-hidden":!0})]}),_&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[ie&&e.jsx("a",{role:"menuitem",href:ie,download:`${t.title||t.id}.html`,onClick:()=>U(!1),className:"block px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:"HTML page"}),[["pdf","PDF"],["docx","Word (.docx)"],["xlsx","Excel (.xlsx)"]].map(([c,E])=>e.jsx("button",{role:"menuitem",onClick:()=>$e(c),className:"w-full text-left px-3 py-1.5 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:E},c))]})]}),xe=e.jsxs(e.Fragment,{children:[A&&j==="create"&&!d&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:"Anyone with the link can view this report."}),e.jsxs("label",{className:"flex items-center gap-1 text-gray-700 dark:text-gray-300 ml-auto",children:["Expires",e.jsx("select",{value:$??"",onChange:c=>I(c.target.value?Number(c.target.value):void 0),className:"px-1.5 py-0.5 rounded border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.05] text-[12px]",children:mt.map(c=>e.jsx("option",{value:c.days??"",children:c.label},c.label))})]}),e.jsx("button",{onClick:Ce,disabled:y,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Create link"})]}),A&&d&&j==="link"&&e.jsxs("div",{className:`${T?"rounded-xl border mb-4":"border-b"} px-5 py-2.5 border-gray-200 dark:border-white/10 bg-blue-50/60 dark:bg-blue-500/10 flex items-center gap-2 text-[13px] flex-wrap`,children:[e.jsx(z,{size:13,className:"text-blue-700 dark:text-blue-300 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 flex-shrink-0",children:"Public link:"}),e.jsx("code",{className:"flex-1 min-w-[12rem] truncate font-mono text-[12px] text-blue-800 dark:text-blue-200 bg-white dark:bg-white/[0.05] border border-blue-200 dark:border-blue-400/20 rounded px-2 py-1",children:W}),e.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-400",children:i?`Expires ${X(i)}`:"No expiry"}),e.jsx("button",{onClick:Le,className:"px-2.5 py-1 rounded-md text-[12px] font-semibold bg-brand-600 text-white hover:bg-brand-700 transition-colors",children:"Copy"}),e.jsxs("button",{onClick:Ae,disabled:y,title:"Revoke this share link",className:"px-2 py-1 rounded-md text-[12px] font-semibold text-rose-700 dark:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center gap-1",children:[e.jsx(Pe,{size:12})," Revoke"]})]}),re&&e.jsx("div",{role:"status",className:`${T?"rounded-lg mb-4 border border-gray-200 dark:border-white/10":"border-b border-gray-200 dark:border-white/10"} px-5 py-1.5 text-[12px] text-gray-700 dark:text-gray-300 bg-gray-50 dark:bg-white/[0.02]`,children:re})]});return T?e.jsxs("div",{children:[e.jsxs("header",{className:"flex flex-wrap items-start justify-between gap-4 mb-5","data-testid":"report-header",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[x&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x}),e.jsx("h1",{className:"text-[28px] leading-tight font-bold tracking-tight text-gray-900 dark:text-gray-100",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[S,t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2","data-testid":"report-actions",children:[N,A&&e.jsxs("button",{onClick:de,disabled:y,className:oe,"aria-expanded":j!=="closed",children:[y?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(z,{size:15}),d?"Shared":"Share"]}),A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:oe,children:[b?e.jsx(B,{size:15,className:"animate-spin"}):e.jsx(pe,{size:15})," Save"]}),ce,R]})]}),xe,e.jsx(je,{spec:t,links:C??!g})]}):e.jsxs("div",{className:"rounded-2xl border border-gray-200 dark:border-white/10 bg-gray-50 dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-200 dark:border-white/10 bg-white dark:bg-white/[0.03] flex flex-wrap items-start justify-between gap-x-4 gap-y-3","data-testid":"report-card-header",children:[e.jsxs("div",{className:"flex min-w-[16rem] flex-1 items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300","aria-hidden":!0,children:e.jsx(We,{size:18})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.jsx("h3",{className:"text-base font-semibold leading-snug text-gray-900 dark:text-gray-100",children:t.title}),o&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-emerald-50 px-1.5 py-0.5 text-[11px] font-semibold text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300",children:[e.jsx(Ye,{size:11,"aria-hidden":!0})," Saved"]}),d&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-blue-50 px-1.5 py-0.5 text-[11px] font-semibold text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",children:[e.jsx(z,{size:11,"aria-hidden":!0})," Shared"]})]}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-gray-600 dark:text-gray-400",children:[t.subtitle,`Data as of ${X(t.generatedAt)}`].filter(Boolean).join(" · ")})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[A&&!o&&e.jsxs("button",{onClick:ne,disabled:b,className:q,title:"Save to your reports",children:[b?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(pe,{size:14})," Save"]}),A&&e.jsxs("button",{onClick:de,disabled:y,"aria-expanded":j!=="closed",title:d?"Public link active — view or revoke":"Create a public share link",className:q,children:[y?e.jsx(B,{size:14,className:"animate-spin"}):e.jsx(z,{size:14}),d?"Shared":"Share"]}),ce,D&&e.jsx("a",{href:D.startsWith("/api/")?ue(D):D,target:"_blank",rel:"noopener noreferrer",title:d?"Open shareable full view (new tab)":o?"Open full view (new tab)":"Open HTML snapshot (new tab)","aria-label":"Open full view",className:le,children:e.jsx(qe,{size:14})}),D&&e.jsx("button",{onClick:Se,title:M?"Copied!":d?"Copy share link":o?"Copy link to full view":"Copy HTML snapshot link (signed-in users only)","aria-label":"Copy link",className:le,children:M?e.jsx(Xe,{size:14,className:"text-emerald-600"}):e.jsx(Ge,{size:14})})]})]}),xe,e.jsx("div",{className:"p-4",children:e.jsx(je,{spec:t,links:C??!g})})]})}export{jt as R};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as J,u as K,r as s,j as e,L as C}from"./vendor-react-DOVfxdUy.js";import{b as Q,ae as W,a5 as X,iv as Y,iz as Z,iu as _,iw as ee}from"./index-D6sQYc_0.js";import{C as te}from"./ConfirmDialog-DtotgVmI.js";import{R as re}from"./ReportCard-D4EElEe9.js";import{i as se,t as ae,a as ne,s as ie,S as oe}from"./reportMeta-3kxT7BIT.js";import{a0 as z,aj as E,a as le,a3 as A,bp as L,cu as de,bo as ce,b7 as me,S as ue,R as xe}from"./vendor-icons-D_Dmmj8d.js";import"./vendor-query-DkZSMtfn.js";import"./formatDate-T65-Y6Mi.js";import"./KpiTile-BHLE3HVj.js";import"./vendor-charts-By5uZ93z.js";import"./CronBuilder-D2fERHt9.js";const i="inline-flex items-center gap-1.5 rounded-md px-2 py-0.5 text-xs font-semibold",$="inline-flex h-9 items-center gap-1.5 rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] px-3.5 text-sm font-medium text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-white/[0.08] transition-colors disabled:opacity-60";function Se(){var N;const{id:c}=J(),D=K(),a=Q(),I=W().hasRole("tester"),[r,m]=s.useState(null),[o,k]=s.useState([]),[T,u]=s.useState(!0),[n,j]=s.useState(!1),[w,x]=s.useState(null),[P,v]=s.useState(!1),[F,p]=s.useState(!1),[l,d]=s.useState(!1),g=s.useRef(null),R=async t=>{try{const{schedules:y}=await Z();k(y.filter(H=>H.sourceReportId===t))}catch{k([])}},U=async()=>{if(!c){x("No report ID in URL"),u(!1);return}x(null);try{const t=await X(c);m(t),t.mine!==!1&&R(t.id)}catch(t){x(t instanceof Error?t.message:String(t))}finally{u(!1)}};s.useEffect(()=>{u(!0),U()},[c]),s.useEffect(()=>{if(!l)return;const t=y=>{g.current&&!g.current.contains(y.target)&&d(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[l]);const B=async()=>{if(r)try{await _(r.id),a.toast("success","Report deleted"),D("/reports")}catch(t){a.toast("error",`Delete failed: ${t instanceof Error?t.message:String(t)}`)}},M=async()=>{if(!(!r||n)){j(!0);try{const t=await ee(r.id);m(t),a.toast("success","Report refreshed with current data")}catch(t){a.toast("error",`Refresh failed: ${t instanceof Error?t.message:String(t)}`)}finally{j(!1)}}},O=async()=>{if(r){d(!1);try{const t=await Y(r.id,{pinned:!r.pinned});m({...r,pinned:t.pinned}),a.toast("success",t.pinned?"Pinned to the top of Reports":"Unpinned")}catch(t){a.toast("error",`Pin failed: ${t instanceof Error?t.message:String(t)}`)}}};if(T)return e.jsxs("div",{className:"p-6 flex items-center justify-center text-sm text-gray-600 dark:text-gray-400 gap-2",children:[e.jsx(z,{size:14,className:"animate-spin"})," Loading report…"]});if(w||!r)return e.jsxs("div",{className:"p-6 max-w-2xl mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(E,{size:15})," Reports"]}),e.jsxs("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/5 p-6 text-center",children:[e.jsx(le,{size:24,className:"text-rose-500 mx-auto mb-3"}),e.jsx("div",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 mb-1",children:"Could not load report"}),e.jsx("div",{className:"text-[13px] text-gray-600 dark:text-gray-400",children:w||"Report not found"})]})]});const h=r.mine!==!1,S=I&&h,b=(N=r.spec)==null?void 0:N.generatedAt,f=se(b,r.templateId),V=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:ae(r.templateId)}),b&&e.jsxs("span",{className:`${i} ${f?"bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300":"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300"}`,title:f?"The data is out of date — Refresh data rebuilds it from current results":void 0,children:["Updated ",ne(b),f?" · out of date":""]}),o.map(t=>e.jsxs("span",{className:`${i} bg-gray-100 text-gray-700 dark:bg-white/10 dark:text-gray-300`,children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",ie(t)]},t.id)),r.pinned&&e.jsxs("span",{className:`${i} bg-amber-50 text-amber-700 dark:bg-amber-500/15 dark:text-amber-300`,children:[e.jsx(L,{size:12,"aria-hidden":!0})," Pinned"]}),!h&&r.sharedByName&&e.jsxs("span",{className:`${i} bg-blue-50 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300`,"data-testid":"report-shared-by",children:["Shared by ",r.sharedByName]})]}),q=S?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:M,disabled:n,className:$,title:"The AI rebuilds this report from current data — same layout, new numbers. Takes 30 seconds to 2 minutes and uses AI credits.",children:[n?e.jsx(z,{size:15,className:"animate-spin"}):e.jsx(xe,{size:15}),n?"Refreshing…":"Refresh data"]}),e.jsxs("button",{onClick:()=>p(!0),className:$,title:"Email this report on a schedule",children:[e.jsx(A,{size:15})," Schedule"]})]}):null,G=S?e.jsxs("div",{className:"relative",ref:g,children:[e.jsx("button",{onClick:()=>d(t=>!t),className:"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-gray-300 dark:border-white/15 bg-white dark:bg-white/[0.04] text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-white/[0.08]","aria-label":"More actions","aria-haspopup":"menu","aria-expanded":l,children:e.jsx(de,{size:16})}),l&&e.jsxs("div",{role:"menu",className:"absolute right-0 top-full mt-1 z-20 w-44 rounded-lg border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-lg py-1 text-sm",children:[e.jsxs("button",{role:"menuitem",onClick:O,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-white/5",children:[r.pinned?e.jsx(ce,{size:14}):e.jsx(L,{size:14})," ",r.pinned?"Unpin":"Pin to top"]}),e.jsxs("button",{role:"menuitem",onClick:()=>{d(!1),v(!0)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-rose-700 dark:text-rose-400 hover:bg-rose-500/10",children:[e.jsx(me,{size:14})," Delete"]})]})]}):null;return e.jsxs("div",{className:"p-6 max-w-[1360px] mx-auto",children:[e.jsxs(C,{to:"/reports",className:"inline-flex items-center gap-1.5 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 mb-4",children:[e.jsx(E,{size:15})," Reports"]}),n&&e.jsxs("div",{role:"status",className:"mb-4 flex items-center gap-2 rounded-xl border border-blue-200 dark:border-blue-400/20 bg-blue-50/70 dark:bg-blue-500/10 px-4 py-2.5 text-[13px] text-blue-900 dark:text-blue-200",children:[e.jsx(ue,{size:14,"aria-hidden":!0})," The AI is rebuilding this report from current data — same layout, new numbers. This takes 30 seconds to 2 minutes."]}),e.jsx(re,{variant:"page",spec:r.spec,urls:r.outputFiles,savedId:r.id,initialShareToken:r.shareToken,initialShareExpiresAt:r.shareExpiresAt,readonly:!h,links:!0,chips:V,leadActions:q,trailActions:G}),F&&e.jsx(oe,{reports:[r],editing:null,initialReportId:r.id,onClose:()=>p(!1),onSaved:async()=>{p(!1),await R(r.id)}}),e.jsx(te,{open:P,title:"Delete report?",description:`"${r.title}" will be permanently deleted. Any active share link will stop working.`+(o.length>0?` ${o.length} scheduled email${o.length===1?"":"s"} for this report will also be removed.`:""),confirmLabel:"Delete",onConfirm:B,onCancel:()=>v(!1)})]})}export{Se as ReportFullView};
|