@testver/testver 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/bin/testver.js +8 -1
  2. package/dist/index.js +1414 -793
  3. package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
  4. package/package.json +7 -6
  5. package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
  6. package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
  7. package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
  8. package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
  9. package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
  10. package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
  11. package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
  12. package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
  13. package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
  14. package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
  15. package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
  16. package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
  17. package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
  18. package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
  19. package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
  20. package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
  21. package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
  22. package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
  23. package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
  24. package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
  25. package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
  26. package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
  27. package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
  28. package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
  29. package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
  30. package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
  31. package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
  32. package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
  33. package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
  34. package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
  35. package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
  36. package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
  37. package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
  38. package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
  39. package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
  40. package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
  41. package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
  42. package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
  43. package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
  44. package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
  45. package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
  46. package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
  47. package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
  48. package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
  49. package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
  50. package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
  51. package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
  52. package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
  53. package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
  54. package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
  55. package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
  56. package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
  57. package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
  58. package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
  59. package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
  60. package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
  61. package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
  62. package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
  63. package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
  64. package/src/ui/static/assets/index-B0klHYbO.css +1 -0
  65. package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
  66. package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
  67. package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
  68. package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
  69. package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
  70. package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
  71. package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
  72. package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
  73. package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
  74. package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
  75. package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
  76. package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
  77. package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
  78. package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
  79. package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
  80. package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
  81. package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
  82. package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
  83. package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
  84. package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
  85. package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
  86. package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
  87. package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
  88. package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
  89. package/src/ui/static/assets/{index-xlbWNOlh.js → vendor-quill-W-RoQfb6.js} +1 -1
  90. package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
  91. package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
  92. package/src/ui/static/dark-logo.svg +1 -1
  93. package/src/ui/static/index.html +5 -2
  94. package/src/ui/static/logo.svg +1 -1
  95. package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
  96. package/src/ui/static/assets/index-8gWK1fNb.js +0 -2250
  97. package/src/ui/static/assets/index-DMd4ynKJ.css +0 -7
  98. package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
@@ -0,0 +1 @@
1
+ import{u as F,r as d,j as t}from"./vendor-react-CTbHBddL.js";import{a as I}from"./formatDate-T65-Y6Mi.js";import{a as O,u as Q}from"./vendor-query-BrzmPFT3.js";import{b as _,e9 as L}from"./index-DtBWNlVD.js";async function W(s){try{const a=await L(!0);await s.cancelQueries({queryKey:["testver-status"]}),s.setQueryData(["testver-status"],a)}catch{}}function K(s){return Q({queryKey:["testver-status"],queryFn:()=>L(),refetchInterval:3e4,refetchOnWindowFocus:!0,staleTime:15e3,enabled:(s==null?void 0:s.enabled)??!0})}let x=!1;const M=.75,S=.9;function V({size:s=18,refreshSignal:a,align:U="right"}){var $;const E=F(),{toast:y}=_(),{data:e}=K(),f=d.useRef(!1),w=O(),N=d.useRef(!!a);d.useEffect(()=>{const l=N.current;if(N.current=!!a,l&&!a){const m=setTimeout(()=>void W(w),1500);return()=>clearTimeout(m)}},[a,w]);const n=(e==null?void 0:e.totalCredits)??0,P=(e==null?void 0:e.usedCredits)??0,c=(e==null?void 0:e.remainingCredits)??0,j=!!(e!=null&&e.reserveOnlyMode)&&!!(e!=null&&e.active),C=j||!!(e!=null&&e.usingReserve),i=(e==null?void 0:e.cycleAllowanceCredits)??n,T=Math.min((e==null?void 0:e.cycleUsedCredits)??P,i),h=Math.max(((e==null?void 0:e.reserveTankCredits)??0)>0?e.reserveTankCredits:(e==null?void 0:e.reserveBoughtCredits)??0,(e==null?void 0:e.reserveCredits)??0),p=C?h>0?Math.min(1,Math.max(0,h-((e==null?void 0:e.reserveCredits)??0))/h):0:i>0?Math.min(1,T/i):0,o=(e==null?void 0:e.status)==="paused",r=(e==null?void 0:e.connected)&&n>0&&c<=0&&!o,u=i+((e==null?void 0:e.reserveCredits)??0),v=u>0&&c/u<=1-S,R=u>0&&c/u>=1-M;if(d.useEffect(()=>{!(e!=null&&e.connected)||n<=0||(v&&!r&&!x&&!f.current?(x=!0,f.current=!0,y("error",`Testver credits running low — ${c.toLocaleString()} left. Top up from the credits ring.`)):R&&x&&(x=!1,f.current=!1))},[e==null?void 0:e.connected,v,R,r,c,n,y]),!(e!=null&&e.connected))return null;const D=r?"stroke-red-500":o?"stroke-amber-400":C?"stroke-emerald-400":p>=S?"stroke-red-400":p>=M?"stroke-amber-400":"stroke-sky-400",g=2.5,b=(s-g)/2,k=2*Math.PI*b,A=r?k:k*p,B=!o&&(r||v||!e.active);return t.jsxs("div",{className:"relative group flex-shrink-0 -mr-2 flex items-center gap-1.5",children:[r&&t.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-medium text-red-400 whitespace-nowrap",children:["Credits used up",e.billingUrl&&t.jsx("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sky-400 hover:text-sky-300 underline underline-offset-2",children:"Top up →"})]}),o&&t.jsx("span",{className:"text-[11px] font-medium text-amber-400 whitespace-nowrap",children:"Seat paused"}),t.jsx("button",{onClick:()=>E("/settings?tab=llm"),className:"flex items-center justify-center p-0.5 rounded-lg hover:bg-white/5 transition-colors","aria-label":"Testver credits",children:t.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,className:r?"animate-pulse":"",children:[t.jsx("circle",{cx:s/2,cy:s/2,r:b,fill:"none",strokeWidth:g,className:"stroke-gray-300 dark:stroke-white/15"}),t.jsx("circle",{cx:s/2,cy:s/2,r:b,fill:"none",strokeWidth:g,strokeLinecap:"round",strokeDasharray:`${A} ${k}`,transform:`rotate(-90 ${s/2} ${s/2})`,className:`${D} transition-all duration-500`})]})}),t.jsxs("div",{className:`absolute bottom-full ${U==="left"?"left-0":"right-0"} mb-1.5 hidden group-hover:block w-60 bg-surface-1 border border-white/10 rounded-xl shadow-xl z-50 p-3 text-left`,children:[n>0?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm font-medium text-gray-200",children:[j?"Plan credits ended with the term":`${Math.max(0,i-T).toLocaleString()} of ${i.toLocaleString()} plan credits left`,($=e.plan)!=null&&$.name?t.jsxs("span",{className:"text-gray-500",children:[" · ",e.plan.name]}):null]}),e.teamRole&&e.teamRole!=="owner"&&e.teamName&&t.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:["Allocated by ",e.teamName]}),((e.reserveBoughtCredits??0)>0||(e.reserveCredits??0)>0)&&t.jsxs("p",{className:"mt-1 text-xs text-emerald-400",children:[(()=>{const l=e.reserveCredits??0,m=e.reserveTankCredits??0,q=Math.max(m>0?m:e.reserveBoughtCredits??0,l);return`Reserve: ${l.toLocaleString()} of ${q.toLocaleString()} left`})(),e.usingReserve?" — in use now":e.active===!1&&n>0?" — banked until renewal":""]}),e.reserveOnlyMode&&e.active&&t.jsx("p",{className:"mt-1 text-xs font-medium text-amber-400",children:"Plan expired — running on your extra usage reserve."}),e.active===!1&&n>0&&!r&&!o&&t.jsxs("p",{className:"mt-1 text-xs font-medium text-amber-400",children:["Plan ",e.status==="suspended"?"suspended":"expired"," — AI requests are paused."]}),o&&t.jsxs("p",{className:"mt-1 text-xs font-medium text-amber-400",children:["Your seat in ",e.teamName||"your team"," is paused — the team owner gives it back."]}),e.nextPlan&&t.jsxs("p",{className:"mt-1 text-xs text-gray-400",children:["Renewed ✓ ",e.nextPlan.name," starts ",I(e.nextPlan.startsAt)]}),r&&t.jsx("p",{className:"mt-1 text-xs font-medium text-red-400",children:"Credits used up — AI requests are paused."})]}):t.jsx("p",{className:"text-sm text-gray-400",children:o?`Your seat in ${e.teamName||"your team"} is paused — the team owner gives it back.`:e.active===!1?"No active Testver plan.":"Loading credits…"}),B&&e.billingUrl&&t.jsx("a",{href:e.billingUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-block text-xs font-semibold text-sky-400 hover:text-sky-300 underline underline-offset-2",children:"Top up at testver.com →"})]})]})}export{V as T,W as b,K as u};
@@ -0,0 +1,2 @@
1
+ import{r as p,j as t}from"./vendor-react-CTbHBddL.js";import{az as T,r as _,f as B,y as F,t as I,b6 as R,cy as H,b9 as K,af as V,d4 as X,d5 as q,c1 as G}from"./vendor-icons-B0wLOBoh.js";const $=200,x=r=>`${r.staged?"s":"u"}:${r.path}`;function Y({files:r,showGroups:P=!0,defaultExpanded:g=!1,onStageFile:u,onUnstageFile:b,onStageAll:j,onUnstageAll:f,onDiscardFile:N,busy:c=!1}){const[E,w]=p.useState(()=>{if(g){const e={};return r.forEach(s=>{e[x(s)]=!0}),e}return{}}),[v,U]=p.useState(g),[D,A]=p.useState({});if(r.length===0)return null;const y=r.filter(e=>e.staged),C=r.filter(e=>!e.staged),W=()=>{const e=!v;U(e);const s={};r.forEach(n=>{s[x(n)]=e}),w(s)},L=e=>{w(s=>({...s,[e]:!s[e]}))},M=e=>{switch(e){case"added":case"untracked":return t.jsx(G,{size:13,className:"text-emerald-400"});case"deleted":return t.jsx(q,{size:13,className:"text-red-400"});case"renamed":return t.jsx(X,{size:13,className:"text-sky-400"});default:return t.jsx(V,{size:13,className:"text-amber-400"})}},k=(e,s)=>{const n=E[s]??!1,h=!e.staged&&u,m=e.staged&&b;return t.jsxs("div",{className:"rounded-lg border border-white/5 bg-black/20 overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 hover:bg-surface-2/50 transition-colors",children:[t.jsxs("button",{onClick:()=>L(s),"aria-expanded":n,className:"flex items-center gap-2 flex-1 text-left min-w-0",children:[t.jsx("span",{className:"text-gray-500 flex-shrink-0",children:n?t.jsx(F,{size:13}):t.jsx(I,{size:13})}),M(e.status),t.jsx("span",{className:"text-sm text-gray-200 font-mono truncate flex-1",children:e.path}),e.additions>0&&t.jsxs("span",{className:"text-xs text-emerald-500 flex-shrink-0 font-medium",children:["+",e.additions]}),e.deletions>0&&t.jsxs("span",{className:"text-xs text-red-500 flex-shrink-0 font-medium",children:["-",e.deletions]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full flex-shrink-0 font-medium ${e.status==="untracked"||e.status==="added"?"bg-emerald-500/10 text-emerald-500":e.status==="deleted"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-500"}`,children:e.status})]}),h&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),u(e.path)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-emerald-500 hover:bg-emerald-500/10 border border-emerald-500/20 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Stage ${e.path} — put its changes into the next commit`,"aria-label":`Stage ${e.path}`,children:[t.jsx(R,{size:12})," Stage"]}),m&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),b(e.path)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-gray-400 hover:bg-gray-500/10 border border-white/10 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Unstage ${e.path} — take it out of the next commit (your edits stay)`,"aria-label":`Unstage ${e.path}`,children:[t.jsx(H,{size:12})," Unstage"]}),N&&!e.staged&&t.jsxs("button",{onClick:a=>{a.stopPropagation(),N(e)},disabled:c,className:"flex items-center gap-1 px-2.5 py-1.5 rounded text-xs font-medium text-red-500 hover:bg-red-500/10 border border-red-500/20 flex-shrink-0 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:`Discard changes to ${e.path} — throw the edits away for good (can't be undone)`,"aria-label":`Discard changes to ${e.path}`,children:[t.jsx(K,{size:12})," Discard"]})]}),n&&e.patch&&(()=>{const a=e.patch.split(`
2
+ `),l=D[s]??!1,z=l?0:Math.max(0,a.length-$);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-white/5 max-h-[440px] overflow-auto",children:t.jsx("pre",{className:"text-sm font-mono leading-[1.6] whitespace-pre",children:(l?a:a.slice(0,$)).map((d,O)=>{let o="",i="text-gray-400";return d.startsWith("+++")||d.startsWith("---")?(i="text-gray-500 font-bold",o="bg-white/[0.02]"):d.startsWith("@@")?(i="text-sky-400/50",o="bg-sky-500/5"):d.startsWith("+")?(i="text-emerald-500",o="bg-emerald-500/10"):d.startsWith("-")&&(i="text-red-500",o="bg-red-500/10"),t.jsx("div",{className:`px-3 ${o} ${i}`,children:d||" "},O)})})}),z>0&&t.jsxs("button",{onClick:()=>A(d=>({...d,[s]:!0})),className:"w-full px-3 py-1.5 text-xs font-medium text-brand-400 hover:text-brand-300 hover:bg-brand-500/5 border-t border-white/5 transition-colors",children:["Show all ",a.length," lines (",z," more)"]}),e.truncated&&t.jsx("div",{className:"border-t border-white/5 px-3 py-1.5 text-xs text-amber-600 dark:text-amber-400",children:"This diff is too large to show in full — the rest is cut off. Open the file to see all of it."})]})})(),n&&!e.patch&&t.jsx("div",{className:"border-t border-white/5 px-3 py-2 text-xs text-gray-500",children:e.noPreview?"No preview — only the first 50 new files are previewed. Stage and commit work as usual.":"No diff content available."})]},s)},S=(e,s,n,h,m,a)=>e.length===0?null:t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h,t.jsxs("span",{className:`text-[11px] font-semibold uppercase flex-1 ${m}`,children:[n," (",e.length,")"]}),a&&t.jsx("button",{onClick:a.onClick,disabled:c,className:"text-[11px] text-gray-500 hover:text-gray-300 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:a.label})]}),t.jsx("div",{className:"space-y-1",children:e.map(l=>k(l,x(l)))})]});return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-[11px] font-semibold text-gray-400 uppercase",children:[r.length," changed file",r.length!==1?"s":""]}),t.jsxs("button",{onClick:W,className:"flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-300 transition-colors",children:[t.jsx(T,{size:11}),v?"Collapse All":"Expand All"]})]}),P?t.jsxs("div",{className:"space-y-4",children:[S(y,"s","Staged",t.jsx(_,{size:12,className:"text-emerald-400"}),"text-emerald-400",f&&y.length>0?{label:"Unstage All",onClick:f}:void 0),S(C,"u","Unstaged",t.jsx(B,{size:12,className:"text-amber-400"}),"text-amber-400",j&&C.length>0?{label:"Stage All",onClick:j}:void 0)]}):t.jsx("div",{className:"space-y-1",children:r.map(e=>k(e,x(e)))})]})}export{Y as U};
@@ -0,0 +1,10 @@
1
+ import{r as c,j as e,b as N}from"./vendor-react-CTbHBddL.js";import{a as W}from"./formatDate-T65-Y6Mi.js";import{a as Y,u as Z,c as m}from"./vendor-query-BrzmPFT3.js";import{a8 as ee,b as se,fy as te,fz as ae,fA as re,fB as le,fC as ie,fD as ne,fE as de,B as oe,eD as D}from"./index-DtBWNlVD.js";import{U as ce,b6 as xe,d6 as z,d7 as P,ag as M,o as q,b8 as me,ac as L,aq as $,z as ue,b9 as he,X as be}from"./vendor-icons-B0wLOBoh.js";const pe=[{value:"admin",label:"Admin",description:"Full access + user management (created by the super admin)"},{value:"tester",label:"Tester",description:"Run tests, edit files, use tools"},{value:"viewer",label:"Viewer",description:"Read-only dashboard access"}],ye=t=>t==="superadmin"?"super admin":t,ge=t=>t==="superadmin"?"yellow":t==="admin"?"brand":t==="tester"?"green":"gray";function ke(){const{user:t}=ee(),{toast:l}=se(),u=Y(),{data:v,isLoading:K}=Z({queryKey:["users"],queryFn:te}),[n,p]=c.useState(null),[r,w]=c.useState(null),[h,y]=c.useState(null),[b,g]=c.useState(null),[i,f]=c.useState(null),[a,d]=c.useState({username:"",displayName:"",email:"",password:"",role:"tester"}),[k,S]=c.useState(""),F=(v==null?void 0:v.users)??[],C=(t==null?void 0:t.role)==="superadmin",R=m({mutationFn:()=>ae(a),onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User created successfully"),o()},onError:s=>l("error",s.message)}),A=m({mutationFn:s=>re(s.id,s.updates),onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User updated"),o()},onError:s=>l("error",s.message)}),O=m({mutationFn:le,onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","User deleted")},onError:s=>l("error",s.message)}),E=m({mutationFn:()=>ie(r.id,k),onSuccess:()=>{l("success","Password reset successfully"),o()},onError:s=>l("error",s.message)}),T=m({mutationFn:ne,onSuccess:()=>{u.invalidateQueries({queryKey:["users"]}),l("success","Two-factor authentication reset"),g(null)},onError:s=>l("error",s.message)}),Q=m({mutationFn:de,onSuccess:s=>{u.invalidateQueries({queryKey:["users"]}),l("success",`Revoked ${s.sessionsRevoked} session(s)`)},onError:s=>l("error",s.message)});function B(){d({username:"",displayName:"",email:"",password:"",role:"tester"}),p("create")}function I(s){w(s),d({username:s.username,displayName:s.displayName,email:s.email||"",password:"",role:s.role}),p("edit")}function X(s){w(s),S(""),p("reset-password")}function o(){p(null),w(null)}function V(s){y(s)}function _(){h&&(O.mutate(h.id),y(null))}function G(s){f(s)}function H(){i&&(A.mutate({id:i.id,updates:{isActive:!i.isActive}}),f(null))}const x=s=>s.id===(t==null?void 0:t.id)?!0:!(s.role==="superadmin"||s.role==="admin"&&!C),j=s=>s.role==="superadmin",J=s=>!!s.twoFactorEnabled&&s.id!==(t==null?void 0:t.id)&&!j(s)&&x(s);return 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.jsx("div",{className:"max-w-[1400px] mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-100 flex items-center gap-3",children:[e.jsx(ce,{size:24,className:"text-brand-300"}),"User Management",e.jsxs("span",{className:"text-sm font-normal bg-brand-500/15 text-brand-300 px-2.5 py-0.5 rounded-full",children:[F.length," users"]})]}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Manage user accounts, roles, and access"})]}),e.jsxs("button",{onClick:B,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors",children:[e.jsx(xe,{size:16}),"Add User"]})]})})}),e.jsxs("div",{className:"max-w-[1400px] mx-auto px-6 py-8 space-y-6",children:[K?e.jsx("div",{className:"text-sm text-gray-500",children:"Loading users..."}):e.jsx("div",{className:"bg-surface-1 rounded-xl border border-white/5 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 text-sm text-gray-500",children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"User"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Email"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Role"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Status"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"2FA"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Last Login"}),e.jsx("th",{className:"text-left px-4 py-3 font-medium",children:"Sessions"}),e.jsx("th",{className:"text-right px-4 py-3 font-medium",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:F.map(s=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-500/20 flex items-center justify-center text-brand-300 text-sm font-semibold",children:s.displayName.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium",children:s.displayName}),e.jsxs("p",{className:"text-xs text-gray-500",children:["@",s.username]})]}),s.id===(t==null?void 0:t.id)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-brand-500/10 text-brand-400 rounded",children:"you"})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:"text-sm text-gray-400",children:s.email||e.jsx("span",{className:"text-gray-600 italic",children:"—"})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(oe,{label:ye(s.role),color:ge(s.role)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`flex items-center gap-1.5 text-xs ${s.isActive?"text-emerald-400":"text-gray-500"}`,children:[s.isActive?e.jsx(z,{size:14}):e.jsx(P,{size:14}),s.isActive?"Active":"Disabled"]})}),e.jsx("td",{className:"px-4 py-3","data-testid":`two-factor-${s.username}`,children:s.twoFactorEnabled?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-emerald-400 whitespace-nowrap",children:[e.jsx(M,{size:14})," On"]}):s.twoFactorRequired?e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-amber-400 whitespace-nowrap",title:"Required by the workspace — they set it up at their next sign-in",children:[e.jsx(q,{size:13,className:"flex-shrink-0"})," Not set up"]}):e.jsx("span",{className:"text-xs text-gray-500",children:"Off"})}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:s.lastLoginAt?W(s.lastLoginAt):"Never"}),e.jsx("td",{className:"px-4 py-3 text-xs text-gray-500",children:s.sessions}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{onClick:()=>I(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Edit user",disabled:!x(s),children:e.jsx(me,{size:14})}),e.jsx("button",{onClick:()=>X(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Reset password",disabled:!x(s),children:e.jsx(L,{size:14})}),e.jsx("button",{onClick:()=>g(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-amber-400 disabled:opacity-30",title:s.twoFactorEnabled?s.id===(t==null?void 0:t.id)?"Turn your own off from Profile":j(s)?"The super admin's two-factor authentication cannot be reset here":"Reset two-factor authentication":"Two-factor authentication is off",disabled:!J(s),children:e.jsx($,{size:14})}),e.jsx("button",{onClick:()=>Q.mutate(s.id),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-gray-200 disabled:opacity-30",title:"Revoke sessions",disabled:s.sessions===0||!x(s),children:e.jsx(ue,{size:14})}),e.jsx("button",{onClick:()=>G(s),className:`p-1.5 rounded hover:bg-surface-2 disabled:opacity-30 ${s.isActive?"text-gray-400 hover:text-amber-400":"text-gray-400 hover:text-emerald-400"}`,title:s.isActive?"Disable user":"Enable user",disabled:j(s)||!x(s),children:s.isActive?e.jsx(P,{size:14}):e.jsx(z,{size:14})}),e.jsx("button",{onClick:()=>V(s),className:"p-1.5 rounded hover:bg-surface-2 text-gray-400 hover:text-red-400 disabled:opacity-30",title:"Delete user",disabled:s.id===(t==null?void 0:t.id)||j(s)||!x(s),children:e.jsx(he,{size:14})})]})})]},s.id))})]})}),n&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60",onClick:o}),e.jsxs("div",{className:"relative bg-surface-1 rounded-xl border border-white/10 p-6 w-full max-w-md animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h3",{className:"text-xl font-bold text-gray-100",children:n==="create"?"Create User":n==="edit"?"Edit User":"Reset Password"}),e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-surface-2 text-gray-400",children:e.jsx(be,{size:18})})]}),(n==="create"||n==="edit")&&e.jsxs("form",{onSubmit:s=>{s.preventDefault(),n==="create"?R.mutate():r&&A.mutate({id:r.id,updates:{displayName:a.displayName,email:a.email,role:a.role}})},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Username ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:a.username,onChange:s=>d({...a,username:s.target.value}),disabled:n==="edit",className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
2
+ focus:outline-none focus:border-brand-500/50 disabled:opacity-50`,placeholder:"username"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Display Name ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"text",value:a.displayName,onChange:s=>d({...a,displayName:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
3
+ focus:outline-none focus:border-brand-500/50`,placeholder:"Display Name"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Email ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx("input",{type:"email",required:!0,value:a.email,onChange:s=>d({...a,email:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-lg text-sm text-gray-100\r
4
+ focus:outline-none focus:border-brand-500/50`,placeholder:"user@example.com"})]}),n==="create"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:["Password ",e.jsx("span",{className:"text-red-400",children:"*"})]}),e.jsx(D,{value:a.password,onChange:s=>d({...a,password:s.target.value}),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-lg text-sm text-gray-100\r
5
+ focus:outline-none focus:border-brand-500/50`,placeholder:"Min. 6 characters"})]}),n==="edit"&&(r==null?void 0:r.role)==="superadmin"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Role"}),e.jsx("p",{className:"text-xs text-gray-500 border border-white/5 rounded-lg p-2.5",children:"Super admin — the account created at setup. This role cannot be changed."})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"Role"}),e.jsx("div",{className:"space-y-2",children:pe.filter(s=>C||s.value!=="admin"||(r==null?void 0:r.role)==="admin").map(s=>{const U=!C&&(r==null?void 0:r.role)==="admin";return e.jsxs("label",{className:`flex items-center gap-3 p-2.5 rounded-lg border transition-colors
6
+ ${U?"cursor-not-allowed opacity-60":"cursor-pointer"}
7
+ ${a.role===s.value?"border-brand-500/50 bg-brand-500/5":"border-white/5 hover:border-white/10"}`,children:[e.jsx("input",{type:"radio",name:"role",value:s.value,checked:a.role===s.value,disabled:U,onChange:()=>d({...a,role:s.value}),className:"accent-brand-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-200",children:s.label}),e.jsx("p",{className:"text-xs text-gray-500",children:s.description})]})]},s.value)})})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-gray-200 rounded-lg hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:R.isPending||A.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\r
8
+ disabled:opacity-50 transition-colors`,children:[e.jsx(M,{size:14}),n==="create"?"Create":"Save"]})]})]}),n==="reset-password"&&r&&e.jsxs("form",{onSubmit:s=>{s.preventDefault(),E.mutate()},className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-gray-400",children:["Set a new password for ",e.jsx("span",{className:"text-gray-200 font-medium",children:r.username})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-400 mb-1",children:"New Password"}),e.jsx(D,{value:k,onChange:s=>S(s.target.value),className:`w-full px-3 py-2 bg-surface-2 border border-white/10 rounded-xl text-[15px] text-gray-100\r
9
+ focus:outline-none focus:border-brand-500/50`,placeholder:"Min. 6 characters",autoFocus:!0})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-sm text-gray-400 hover:text-gray-200 rounded-lg hover:bg-surface-2",children:"Cancel"}),e.jsxs("button",{type:"submit",disabled:E.isPending||k.length<6,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\r
10
+ disabled:opacity-50 transition-colors`,children:[e.jsx(L,{size:14}),"Reset Password"]})]})]})]})]}),document.body),i&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>f(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${i.isActive?"bg-amber-500/10":"bg-emerald-500/10"}`,children:i.isActive?e.jsx(P,{size:20,className:"text-amber-400"}):e.jsx(z,{size:20,className:"text-emerald-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:i.isActive?"Disable User":"Enable User"})]}),e.jsx("div",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-300",children:i.isActive?e.jsxs(e.Fragment,{children:["Are you sure you want to disable ",e.jsxs("strong",{className:"text-gray-100",children:['"',i.displayName,'"']}),"? They will not be able to log in and all active sessions will be revoked."]}):e.jsxs(e.Fragment,{children:["Are you sure you want to re-enable ",e.jsxs("strong",{className:"text-gray-100",children:['"',i.displayName,'"']}),"? They will be able to log in again."]})})}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>f(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:H,className:`px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors ${i.isActive?"bg-amber-600 hover:bg-amber-500":"bg-emerald-600 hover:bg-emerald-500"}`,children:i.isActive?"Disable User":"Enable User"})]})]})]}),document.body),b&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center","data-testid":"reset-two-factor-dialog",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>g(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/10 flex items-center justify-center shrink-0",children:e.jsx($,{size:20,className:"text-amber-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Reset two-factor authentication"})]}),e.jsxs("div",{className:"px-6 py-4 space-y-2",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["Turn off two-factor authentication for ",e.jsx("strong",{className:"text-gray-100",children:b.displayName})," (@",b.username,")?"]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Use this when they lost their phone and their recovery codes. Their authenticator entry, recovery codes and trusted browsers stop working.",b.twoFactorRequired?" The workspace requires two-factor authentication, so they set it up again at their next sign-in.":" They sign in with their password only until they turn it on again."," ","If email is set up, they are told by email."]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>g(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:()=>T.mutate(b.id),disabled:T.isPending,className:"px-4 py-2 text-sm font-medium text-white bg-amber-600 hover:bg-amber-500 rounded-lg transition-colors disabled:opacity-50",children:"Reset 2FA"})]})]})]}),document.body),h&&N.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>y(null)}),e.jsxs("div",{className:"relative z-10 bg-surface-1 rounded-xl border border-white/10 shadow-2xl w-full max-w-md mx-4",children:[e.jsxs("div",{className:"flex items-center gap-3 px-6 py-4 border-b border-white/5",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/10 flex items-center justify-center shrink-0",children:e.jsx(q,{size:20,className:"text-red-400"})}),e.jsx("h3",{className:"text-base font-semibold text-gray-100",children:"Delete User"})]}),e.jsxs("div",{className:"px-6 py-4",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["Are you sure you want to permanently delete ",e.jsxs("strong",{className:"text-gray-100",children:['"',h.displayName,'"']})," (@",h.username,")?"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"This action cannot be undone. The user will be permanently removed along with all their sessions."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 px-6 py-4 border-t border-white/5",children:[e.jsx("button",{onClick:()=>y(null),className:"px-4 py-2 text-sm text-gray-400 hover:text-gray-200 transition-colors rounded-lg",children:"Cancel"}),e.jsx("button",{onClick:_,className:"px-4 py-2 text-sm font-medium text-white bg-red-600 hover:bg-red-500 rounded-lg transition-colors",children:"Delete Permanently"})]})]})]}),document.body)]})]})}export{ke as UserManagementPage};