@testver/testver 1.3.2 → 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.
- package/bin/testver.js +8 -1
- package/dist/index.js +1309 -781
- package/dist/py-agent/__pycache__/testver_appium.cpython-313.pyc +0 -0
- package/package.json +7 -6
- package/src/ui/static/assets/AIPanel-D09Ni3a4.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DZtUZnRe.js +40 -0
- package/src/ui/static/assets/AIStreamUI-BsxKziYG.js +9 -0
- package/src/ui/static/assets/AITestGenPage-Cg21-P1W.js +5 -0
- package/src/ui/static/assets/APITestingPage-Cdc8EZz2.js +19 -0
- package/src/ui/static/assets/AboutPage-yJLCr2_q.js +1 -0
- package/src/ui/static/assets/AdvancedPage-DB-6sJ6s.js +3 -0
- package/src/ui/static/assets/AnalyticsPage-gTPFsiLZ.js +1 -0
- package/src/ui/static/assets/AuditLogPage-DE45E_PV.js +1 -0
- package/src/ui/static/assets/ChangesSummary-C-7oi_sx.js +2 -0
- package/src/ui/static/assets/CodeMapPage-DgU6ZYBO.js +3 -0
- package/src/ui/static/assets/ConfirmDialog-DNU3qoAP.js +1 -0
- package/src/ui/static/assets/CoveragePage-BpTjgcdV.js +2 -0
- package/src/ui/static/assets/CronBuilder-DsnX-vRr.js +1 -0
- package/src/ui/static/assets/Dashboard-DRWbVyTb.js +1 -0
- package/src/ui/static/assets/DefectsPage-BtMNbq6Z.js +72 -0
- package/src/ui/static/assets/DiffViewer-DPglzjPH.js +2 -0
- package/src/ui/static/assets/EmptyState-BH_aDO0P.js +1 -0
- package/src/ui/static/assets/ExportButton-Ce_MxnM1.js +1 -0
- package/src/ui/static/assets/FileViewer-iYL0lxyY.js +18 -0
- package/src/ui/static/assets/GitPage-CQqV8JBC.js +12 -0
- package/src/ui/static/assets/ImportExportPage-DXk7Koaq.js +36 -0
- package/src/ui/static/assets/JiraPushDialog-CqftoLh8.js +1 -0
- package/src/ui/static/assets/LiveExecutionView-BD0wE8sz.js +1 -0
- package/src/ui/static/assets/ManagePage-B8iG6Q0B.js +1 -0
- package/src/ui/static/assets/MediaModal-DiSINwmh.js +1 -0
- package/src/ui/static/assets/MobileRunPicker-BNs2lZFf.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-D2Nqcj10.js +6 -0
- package/src/ui/static/assets/ModuleExplorer-BmkoQrHb.js +1 -0
- package/src/ui/static/assets/OutputPage-Dcsr7cmr.js +1 -0
- package/src/ui/static/assets/PipelinesPanel-CMMXCSda.js +1 -0
- package/src/ui/static/assets/ProfilePage-ByshrcwC.js +1 -0
- package/src/ui/static/assets/ProjectExplorer-B9B___ij.js +1 -0
- package/src/ui/static/assets/RemoteFileStrip-DbPnaZ-v.js +1 -0
- package/src/ui/static/assets/ReportCard-BbNfk85h.js +2 -0
- package/src/ui/static/assets/ReportFullView-Cg1rggho.js +1 -0
- package/src/ui/static/assets/ReportsPage-CFv3OAhe.js +48 -0
- package/src/ui/static/assets/ResultsPage-B4LwZH-R.js +115 -0
- package/src/ui/static/assets/RunTargets-C7Vqd4TU.js +1 -0
- package/src/ui/static/assets/ScriptMappingPage-BrANeHv0.js +1 -0
- package/src/ui/static/assets/SearchableDevicePicker-CFJ_DUAA.js +1 -0
- package/src/ui/static/assets/SettingsPage-BwOiebKG.js +83 -0
- package/src/ui/static/assets/SharedReportView-BAbW1WOs.js +1 -0
- package/src/ui/static/assets/SourcesPage-C_QVQwiA.js +14 -0
- package/src/ui/static/assets/TestExplorerPage-BRRWtwde.js +7 -0
- package/src/ui/static/assets/TestManagementPage-Ch4PthuU.js +10 -0
- package/src/ui/static/assets/TestPlansPage-Bno2vpGd.js +5 -0
- package/src/ui/static/assets/TestverCreditsDetail-cSW0SpNx.js +1 -0
- package/src/ui/static/assets/TestverCreditsRing-CUsMGEe3.js +1 -0
- package/src/ui/static/assets/UncommittedDiffViewer-B5HSURk8.js +2 -0
- package/src/ui/static/assets/UserManagementPage-BjY3ftxf.js +10 -0
- package/src/ui/static/assets/WorkflowsPage-BUu-LjZ8.js +83 -0
- package/src/ui/static/assets/aiHandoff-vhtR29Fh.js +1 -0
- package/src/ui/static/assets/ansiToHtml-DYRzYQV1.js +1 -0
- package/src/ui/static/assets/dark-logo-DCPcGDyT.svg +1 -0
- package/src/ui/static/assets/excel-BrxuVus5.js +1 -0
- package/src/ui/static/assets/formatDate-T65-Y6Mi.js +1 -0
- package/src/ui/static/assets/formatTestName-BKd2Uqhs.js +1 -0
- package/src/ui/static/assets/hiddenLlmProviders-setxgY_B.js +1 -0
- package/src/ui/static/assets/index-B0klHYbO.css +1 -0
- package/src/ui/static/assets/index-DpQhqcHv.js +11 -0
- package/src/ui/static/assets/index-DtBWNlVD.js +47 -0
- package/src/ui/static/assets/logo-C7ltqfpq.svg +1 -0
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +1 -0
- package/src/ui/static/assets/sandboxStorage-BrzaG3ny.js +1 -0
- package/src/ui/static/assets/simpleMarkdown-kWs-10D8.js +5 -0
- package/src/ui/static/assets/useChartTheme-BFz2QcND.js +1 -0
- package/src/ui/static/assets/useDebouncedValue-BsHptIvX.js +1 -0
- package/src/ui/static/assets/useFeatureFlags-DqhngqgG.js +1 -0
- package/src/ui/static/assets/useJiraConnector-TM1Rfj1s.js +1 -0
- package/src/ui/static/assets/useOwnership-eW6Egd7X.js +1 -0
- package/src/ui/static/assets/useSuites-CvtMGakZ.js +1 -0
- package/src/ui/static/assets/useTabParam-ChbOedP1.js +1 -0
- package/src/ui/static/assets/useTestExplorer-HqvURJAc.js +1 -0
- package/src/ui/static/assets/useTestLifecycle-CL7-zz0Q.js +1 -0
- package/src/ui/static/assets/useTestManagement-ZTA1_VUm.js +2 -0
- package/src/ui/static/assets/useTestResults-Bm-JyMhB.js +1 -0
- package/src/ui/static/assets/vendor-charts-DWFQlmCz.js +73 -0
- package/src/ui/static/assets/vendor-excel-BFHGVHVC.js +24 -0
- package/src/ui/static/assets/vendor-flow-BnuhLJ6X.css +1 -0
- package/src/ui/static/assets/vendor-flow-YGpC9U9I.js +23 -0
- package/src/ui/static/assets/vendor-icons-B0wLOBoh.js +1421 -0
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +1 -0
- package/src/ui/static/assets/vendor-quill-CTpA5PSA.css +7 -0
- package/src/ui/static/assets/{index-Dy7b6SNH.js → vendor-quill-W-RoQfb6.js} +1 -1
- package/src/ui/static/assets/vendor-react-CTbHBddL.js +61 -0
- package/src/ui/static/assets/visibleInterval-BKsLfJZ3.js +1 -0
- package/src/ui/static/dark-logo.svg +1 -1
- package/src/ui/static/index.html +5 -2
- package/src/ui/static/logo.svg +1 -1
- package/src/ui/static/assets/dark-logo-BddlJH8z.svg +0 -1
- package/src/ui/static/assets/index-Bt4_s1e0.css +0 -7
- package/src/ui/static/assets/index-C9pBWd6z.js +0 -2250
- package/src/ui/static/assets/logo-DwQCjTm_.svg +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import{r as c,j as e,n as jt}from"./vendor-react-CTbHBddL.js";import{u as Ke,a as de,c as je}from"./vendor-query-BrzmPFT3.js";import{eo as Nt,ep as vt,eq as ct,er as wt,es as kt,et as Ct,eu as St,ev as zt,ew as Et,ex as $t,ey as Pt,ez as Rt,b as Ve,eA as Dt,eB as At,eC as qt,eD as We,eE as It,eF as Tt,eG as Ot,eH as Ft,eI as Lt,eJ as Vt,eK as Ht,eL as Ut,eM as Mt,eN as Bt}from"./index-DtBWNlVD.js";import{cY as $e,b6 as ye,ak as ze,X as ge,y as ce,t as me,F as Fe,cZ as Ye,b8 as Xe,b9 as xe,a7 as Me,bJ as _t,al as Pe,aN as Ze,bt as et,r as pe,a2 as he,O as Kt,a3 as De,aa as dt,ap as xt,u as He,aw as Jt,cW as Oe,ag as mt,a9 as Le,bn as Je,K as Ee,ad as Qt,ae as Gt,I as Wt,co as Se,l as Be,D as Yt,E as Xt,cz as tt,c_ as Zt}from"./vendor-icons-B0wLOBoh.js";import{u as ut}from"./useTabParam-ChbOedP1.js";import{F as Qe}from"./index-DpQhqcHv.js";import{u as Ge}from"./useChartTheme-BFz2QcND.js";import{f as pt}from"./formatDate-T65-Y6Mi.js";import{p as es,P as ts,a as ss}from"./AIStreamUI-BsxKziYG.js";import{D as as}from"./DiffViewer-DPglzjPH.js";function rs(){return Ke({queryKey:["api-collections"],queryFn:Nt})}function ns(t){return Ke({queryKey:["api-collection",t],queryFn:()=>vt(t),enabled:!!t,placeholderData:a=>a})}function ls(){const t=de();return je({mutationFn:a=>kt(a),onSuccess:()=>{t.invalidateQueries({queryKey:["api-collections"]})}})}function is(){const t=de();return je({mutationFn:({id:a,data:s})=>St(a,s),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:["api-collections"]}),t.invalidateQueries({queryKey:["api-collection",s.id]})}})}function os(){const t=de();return je({mutationFn:a=>Ct(a),onSuccess:()=>{t.invalidateQueries({queryKey:["api-collections"]})}})}function cs(){const t=de();return je({mutationFn:({collectionId:a,request:s,folderId:l})=>ct(a,s,l),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:["api-collection",s.collectionId]})}})}function ds(){const t=de();return je({mutationFn:({collectionId:a,requestId:s})=>$t(a,s),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:["api-collection",s.collectionId]})}})}function xs(){const t=de();return je({mutationFn:({collectionId:a,name:s})=>zt(a,s),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:["api-collection",s.collectionId]})}})}function ms(){const t=de();return je({mutationFn:({collectionId:a,folderId:s})=>Et(a,s),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:["api-collection",s.collectionId]})}})}function us(){const t=de();return je({mutationFn:({request:a,variables:s,collectionId:l,environmentId:m})=>wt(a,s,l,m),onSuccess:()=>{t.invalidateQueries({queryKey:["api-history"]})}})}function ps(t=50){return Ke({queryKey:["api-history",t],queryFn:()=>Pt(t)})}function hs(){const t=de();return je({mutationFn:Rt,onSuccess:()=>{t.invalidateQueries({queryKey:["api-history"]})}})}const gs={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400",HEAD:"text-purple-400",OPTIONS:"text-gray-400"};function fs({collections:t,selectedCollection:a,selectedRequestId:s,onSelectCollection:l,onSelectRequest:m,onImport:x,onRunChain:n}){const[h,o]=c.useState(new Set),[u,p]=c.useState(new Set),[i,k]=c.useState(!1),[y,v]=c.useState(""),[C,M]=c.useState(null),[H,R]=c.useState(""),[N,q]=c.useState(null),[J,Q]=c.useState(""),[r,z]=c.useState(null),[j,U]=c.useState(""),[L,X]=c.useState(null),{toast:I}=Ve(),ie=ls(),te=os(),oe=is(),O=xs(),Ne=ms(),ae=ds(),g=(f,V,Y)=>{X({type:f,name:V,action:Y})},T=()=>{if(!L)return;L.action();const f=L.type==="collection"?"Collection":L.type==="folder"?"Folder":"Request";I("success",`${f} "${L.name}" deleted`),X(null)},[E,D]=c.useState(null),[P,B]=c.useState(null),G=c.useRef(!1),fe=de(),se=async(f,V,Y)=>{const b={...f,id:`req-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:`${f.name} (Copy)`};try{await ct(V,b,Y),fe.invalidateQueries({queryKey:["api-collection",V]}),I("success",`Duplicated "${f.name}"`)}catch{I("error","Failed to duplicate request")}},ve=c.useRef(null),ke=f=>{ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{fe.refetchQueries({queryKey:["api-collection",f]})},500)},d=(f,V)=>{G.current=!0;const Y=E,b=a;if(D(null),B(null),!Y||!b)return;const be=b.id,Ce=(Y.folderId||null)===f;Ce&&!V||(async()=>{var w;try{if(Ce&&V){const le=(f?((w=b.folders.find(ue=>ue.id===f))==null?void 0:w.requests)||[]:b.requests).map(ue=>ue.id).filter(ue=>ue!==Y.req.id),we=V==="__end__"?le.length:le.indexOf(V);le.splice(we>=0?we:le.length,0,Y.req.id),await At(be,f,le),I("success",`Reordered "${Y.req.name}"`)}else await qt(be,Y.req.id,f),I("success",`Moved "${Y.req.name}" to ${f?"folder":"root"}`);ke(be)}catch{I("error","Failed to move request"),ke(be)}})()},$=f=>{const V=new Set(h);V.has(f)?V.delete(f):V.add(f),o(V),l(f)},S=f=>{const V=new Set(u);V.has(f)?V.delete(f):V.add(f),p(V)},K=()=>{y.trim()&&ie.mutate({name:y.trim()},{onSuccess:()=>{k(!1),v(""),I("success","Collection created")},onError:f=>I("error",String(f))})},F=f=>{H.trim()&&O.mutate({collectionId:f,name:H.trim()},{onSuccess:()=>{M(null),R(""),I("success","Folder created")},onError:V=>I("error",String(V))})},Z=(f,V)=>{q(f),Q(V)},W=f=>{if(!J.trim()){q(null);return}oe.mutate({id:f,data:{name:J.trim()}},{onSuccess:()=>{q(null),I("success","Collection renamed")},onError:V=>{I("error",String(V))}})},re=(f,V)=>{z(f),U(V)},ne=async(f,V)=>{if(!j.trim()){z(null);return}try{await Dt(f,V,{name:j.trim()}),z(null),I("success","Folder renamed"),l(f)}catch(Y){I("error",String(Y))}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5 flex-shrink-0",children:[e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500 tracking-wider",children:"Collections"}),e.jsxs("div",{className:"flex gap-1",children:[x&&e.jsx("button",{onClick:x,className:"p-1 text-gray-500 hover:text-gray-300",title:"Import",children:e.jsx($e,{size:13})}),e.jsx("button",{onClick:()=>k(!0),className:"p-1 text-gray-500 hover:text-gray-300",title:"New Collection",children:e.jsx(ye,{size:13})})]})]}),i&&e.jsx("div",{className:"px-3 py-2 border-b border-white/5",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:y,onChange:f=>v(f.target.value),onKeyDown:f=>{f.key==="Enter"&&K(),f.key==="Escape"&&(k(!1),v(""))},placeholder:"Collection name",className:"flex-1 px-2 py-1.5 text-sm bg-surface-2 border border-brand-500/30 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none"}),e.jsx("button",{onClick:K,disabled:!y.trim(),className:"p-1.5 rounded-lg text-emerald-500 hover:bg-emerald-500/25 transition-colors disabled:opacity-30",title:"Create",children:e.jsx(ze,{size:14})}),e.jsx("button",{onClick:()=>{k(!1),v("")},className:"p-1.5 rounded-lg text-red-500 hover:bg-red-500/25 transition-colors",title:"Cancel",children:e.jsx(ge,{size:14})})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[t.length===0&&!i&&e.jsxs("div",{className:"px-3 py-6 text-center",children:[e.jsx("p",{className:"text-sm text-gray-600",children:"No collections yet"}),e.jsx("button",{onClick:()=>k(!0),className:"text-sm text-brand-400 hover:text-brand-300 mt-1",children:"Create one"})]}),t.map(f=>{const V=h.has(f.id),Y=(a==null?void 0:a.id)===f.id;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 cursor-pointer hover:bg-white/5 group ${Y?"bg-brand-500/10":""}`,onClick:()=>$(f.id),children:[V?e.jsx(ce,{size:14,className:"text-gray-500 flex-shrink-0"}):e.jsx(me,{size:14,className:"text-gray-500 flex-shrink-0"}),V?e.jsx(Fe,{size:13,className:"text-brand-400 flex-shrink-0"}):e.jsx(Ye,{size:13,className:"text-gray-400 flex-shrink-0"}),N===f.id?e.jsx("input",{autoFocus:!0,value:J,onChange:b=>Q(b.target.value),onKeyDown:b=>{b.key==="Enter"&&W(f.id),b.key==="Escape"&&q(null)},onBlur:()=>W(f.id),onClick:b=>b.stopPropagation(),className:"flex-1 px-1.5 py-0 text-sm bg-surface-2 border border-brand-500/30 rounded text-gray-200 focus:outline-none min-w-0"}):e.jsx("span",{className:"text-sm text-gray-300 truncate flex-1",onDoubleClick:b=>{b.stopPropagation(),Z(f.id,f.name)},children:f.name}),e.jsx("span",{className:"text-sm text-gray-600 flex-shrink-0",children:f.requestCount}),e.jsx("button",{onClick:b=>{b.stopPropagation(),Z(f.id,f.name)},className:"p-0.5 text-gray-600 hover:text-brand-300 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",title:"Rename",children:e.jsx(Xe,{size:13})}),e.jsx("button",{onClick:b=>{b.stopPropagation(),g("collection",f.name,()=>te.mutate(f.id))},className:"p-0.5 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:13})})]}),V&&Y&&a&&e.jsxs("div",{className:"ml-3",children:[a.folders.map(b=>{const be=u.has(b.id);return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1 cursor-pointer hover:bg-white/5 group transition-colors ${(P==null?void 0:P.type)==="folder"&&P.id===b.id?"bg-brand-500/15 border-l-2 border-l-brand-400":""}`,onClick:()=>S(b.id),onDragOver:A=>{A.preventDefault(),A.stopPropagation(),B({type:"folder",id:b.id})},onDragLeave:()=>B(null),onDrop:A=>{A.preventDefault(),A.stopPropagation(),d(b.id)},children:[be?e.jsx(ce,{size:13,className:"text-gray-600"}):e.jsx(me,{size:13,className:"text-gray-600"}),e.jsx(Ye,{size:14,className:"text-amber-500/60"}),r===b.id?e.jsx("input",{autoFocus:!0,value:j,onChange:A=>U(A.target.value),onKeyDown:A=>{A.key==="Enter"&&ne(f.id,b.id),A.key==="Escape"&&z(null)},onBlur:()=>ne(f.id,b.id),onClick:A=>A.stopPropagation(),className:"flex-1 px-1.5 py-0 text-sm bg-surface-2 border border-brand-500/30 rounded text-gray-200 focus:outline-none min-w-0"}):e.jsx("span",{className:"text-sm text-gray-400 truncate flex-1",onDoubleClick:A=>{A.stopPropagation(),re(b.id,b.name)},children:b.name}),n&&e.jsx("button",{onClick:A=>{A.stopPropagation(),b.requests.length>0&&n(b)},disabled:b.requests.length===0,className:`p-0.5 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0 ${b.requests.length>0?"text-gray-600 hover:text-emerald-400":"text-gray-700 cursor-not-allowed"}`,title:b.requests.length>0?"Run as chain":"Add requests to run as chain",children:e.jsx(Me,{size:13})}),e.jsx("button",{onClick:A=>{A.stopPropagation(),re(b.id,b.name)},className:"p-0.5 text-gray-600 hover:text-brand-300 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",title:"Rename",children:e.jsx(Xe,{size:13})}),e.jsx("button",{onClick:A=>{A.stopPropagation(),g("folder",b.name,()=>Ne.mutate({collectionId:f.id,folderId:b.id}))},className:"p-0.5 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:13})})]}),be&&e.jsxs(e.Fragment,{children:[b.requests.map(A=>e.jsx(st,{request:A,selected:s===A.id,onSelect:()=>m(A,b.id),onDelete:()=>g("request",A.name,()=>ae.mutate({collectionId:f.id,requestId:A.id})),onDuplicate:()=>se(A,f.id,b.id),onDragStart:()=>{G.current=!1,D({req:A,collectionId:f.id,folderId:b.id})},onDragEnd:()=>{G.current||(D(null),B(null)),G.current=!1},onDragOverItem:()=>B({type:"between",id:b.id,beforeId:A.id}),isDropTarget:(P==null?void 0:P.type)==="between"&&P.id===b.id&&P.beforeId===A.id,onDropItem:()=>d(b.id,A.id),indent:2},A.id)),E&&e.jsx("div",{className:`h-4 mx-2 ${(P==null?void 0:P.type)==="between"&&P.id===b.id&&P.beforeId==="__end__"?"border-t-2 border-brand-500":""}`,onDragOver:A=>{A.preventDefault(),B({type:"between",id:b.id,beforeId:"__end__"})},onDragLeave:()=>B(null),onDrop:A=>{A.preventDefault(),d(b.id,"__end__")}}),e.jsx("div",{style:{paddingLeft:"36px",paddingRight:"12px"},className:"py-0.5",children:e.jsx("button",{onClick:A=>{A.stopPropagation();const Ce={id:`req-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:"New Request",method:"GET",url:"",headers:[],queryParams:[],body:{type:"none"},auth:{type:"none"},validations:[],followRedirects:!0,sortOrder:b.requests.length};m(Ce,b.id)},className:"text-sm text-gray-600 hover:text-gray-400",children:"+ Request"})})]})]},b.id)}),E&&E.folderId&&e.jsx("div",{className:`mx-2 my-1 py-2 rounded-lg border-2 border-dashed text-center text-sm transition-colors ${(P==null?void 0:P.type)==="root"?"border-brand-500/50 bg-brand-500/10 text-brand-400":"border-white/10 text-gray-600"}`,onDragOver:b=>{b.preventDefault(),b.stopPropagation(),B({type:"root",id:"root"})},onDragLeave:()=>B(null),onDrop:b=>{b.preventDefault(),b.stopPropagation(),d(null)},children:"Drop here for root level"}),a.requests.map(b=>e.jsx(st,{request:b,selected:s===b.id,onSelect:()=>m(b),onDelete:()=>g("request",b.name,()=>ae.mutate({collectionId:f.id,requestId:b.id})),onDuplicate:()=>se(b,f.id),onDragStart:()=>{G.current=!1,D({req:b,collectionId:f.id})},onDragEnd:()=>{G.current||(D(null),B(null)),G.current=!1},onDragOverItem:()=>B({type:"between",id:"__root__",beforeId:b.id}),isDropTarget:(P==null?void 0:P.type)==="between"&&P.id==="__root__"&&P.beforeId===b.id,onDropItem:()=>d(null,b.id),indent:1},b.id)),C===f.id?e.jsx("div",{className:"px-5 py-1",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{autoFocus:!0,value:H,onChange:b=>R(b.target.value),onKeyDown:b=>{b.key==="Enter"&&F(f.id),b.key==="Escape"&&(M(null),R(""))},placeholder:"Folder name",className:"flex-1 px-2 py-1.5 text-sm bg-surface-2 border border-brand-500/30 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none"}),e.jsx("button",{onClick:()=>F(f.id),disabled:!H.trim(),className:"p-1.5 rounded-lg text-emerald-500 hover:bg-emerald-500/25 transition-colors disabled:opacity-30",title:"Create",children:e.jsx(ze,{size:14})}),e.jsx("button",{onClick:()=>{M(null),R("")},className:"p-1.5 rounded-lg text-red-500 hover:bg-red-500/25 transition-colors",title:"Cancel",children:e.jsx(ge,{size:14})})]})}):e.jsxs("div",{className:"flex gap-2 px-5 py-1",children:[e.jsx("button",{onClick:()=>M(f.id),className:"text-sm text-gray-600 hover:text-gray-400",children:"+ Folder"}),e.jsx("button",{onClick:()=>{const b={id:`req-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:"New Request",method:"GET",url:"",headers:[],queryParams:[],body:{type:"none"},auth:{type:"none"},validations:[],followRedirects:!0,sortOrder:0};m(b)},className:"text-sm text-gray-600 hover:text-gray-400",children:"+ Request"})]})]})]},f.id)})]}),L&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>X(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-md p-6",onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(xe,{size:20,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-semibold text-gray-200",children:["Delete ",L.type==="collection"?"Collection":L.type==="folder"?"Folder":"Request"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"This action cannot be undone"})]})]}),e.jsxs("p",{className:"text-sm text-gray-400 mb-2",children:["Are you sure you want to delete this ",L.type,"?"]}),e.jsx("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-surface-2 border border-white/5 mb-2",children:e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:L.name})}),L.type==="collection"&&e.jsx("p",{className:"text-sm text-orange-400/80 mb-4",children:"All folders, requests, and environments in this collection will be permanently deleted."}),L.type==="folder"&&e.jsx("p",{className:"text-sm text-orange-400/80 mb-4",children:"All requests inside this folder will be permanently deleted."}),L.type==="request"&&e.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"This request and its validations will be permanently deleted."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>X(null),className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:T,className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-500 transition-colors",children:"Delete"})]})]})})]})}function st({request:t,selected:a,onSelect:s,onDelete:l,onDuplicate:m,onDragStart:x,onDragEnd:n,onDragOverItem:h,onDropItem:o,isDropTarget:u,indent:p}){return e.jsxs("div",{children:[u&&e.jsx("div",{className:"h-0.5 bg-brand-500 mx-2 rounded-full",style:{marginLeft:`${p*12+12}px`}}),e.jsxs("div",{className:`flex items-center gap-1 py-1 cursor-pointer hover:bg-white/5 group ${a?"bg-brand-500/10":""}`,style:{paddingLeft:`${p*12+12}px`,paddingRight:"8px"},onClick:s,draggable:!0,onDragStart:i=>{i.dataTransfer.effectAllowed="move",i.dataTransfer.setData("text/plain",t.id),x()},onDragEnd:n,onDragOver:i=>{i.preventDefault(),h()},onDrop:i=>{i.preventDefault(),i.stopPropagation(),o()},children:[e.jsx(_t,{size:12,className:"text-gray-700 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0 cursor-grab"}),e.jsx("span",{className:`text-sm font-bold w-8 flex-shrink-0 ${gs[t.method]}`,children:t.method.slice(0,3)}),e.jsx("span",{className:"text-sm text-gray-400 truncate flex-1",children:t.name||t.url||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),m()},className:"p-0.5 text-gray-600 hover:text-cyan-400 transition-colors",title:"Duplicate request",children:e.jsx(Pe,{size:12})}),e.jsx("button",{onClick:i=>{i.stopPropagation(),l()},className:"p-0.5 text-gray-600 hover:text-red-400 transition-colors",title:"Delete request",children:e.jsx(xe,{size:13})})]})]})]})}function at({pairs:t,onChange:a,keyPlaceholder:s="Key",valuePlaceholder:l="Value",showDescription:m=!1}){const x=(o,u,p)=>{const i=[...t];i[o]={...i[o],[u]:p},a(i)},n=()=>{a([...t,{key:"",value:"",enabled:!0}])},h=o=>{a(t.filter((u,p)=>p!==o))};return e.jsxs("div",{className:"space-y-1",children:[t.map((o,u)=>e.jsxs("div",{className:"flex items-center gap-1.5 group",children:[e.jsx("input",{type:"checkbox",checked:o.enabled,onChange:p=>x(u,"enabled",p.target.checked),className:"w-3.5 h-3.5 rounded border-gray-600 bg-surface-2 accent-brand-500 flex-shrink-0"}),e.jsx("input",{type:"text",value:o.key,onChange:p=>x(u,"key",p.target.value),placeholder:s,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("input",{type:"text",value:o.value,onChange:p=>x(u,"value",p.target.value),placeholder:l,className:"flex-1 min-w-0 px-2 py-1 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),m&&e.jsx("input",{type:"text",value:o.description||"",onChange:p=>x(u,"description",p.target.value),placeholder:"Description",className:"w-32 px-2 py-1 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("button",{onClick:()=>h(u),className:"p-1 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:14})})]},u)),e.jsxs("button",{onClick:n,className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-300 transition-colors pt-1",children:[e.jsx(ye,{size:13})," Add"]})]})}const bs=[{value:"none",label:"None"},{value:"json",label:"JSON"},{value:"text",label:"Text"},{value:"form-data",label:"Form Data"},{value:"graphql",label:"GraphQL"}];function ys({body:t,onChange:a}){const{monacoTheme:s}=Ge();return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-1",children:bs.map(l=>e.jsx("button",{onClick:()=>a({...t,type:l.value}),className:`px-2.5 py-1 text-sm rounded transition-colors ${t.type===l.value?"bg-brand-500/20 text-brand-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:l.label},l.value))}),t.type==="none"&&e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No body content"}),t.type==="json"&&e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden",style:{height:"240px"},children:e.jsx(Qe,{value:t.raw||"",onChange:l=>a({...t,raw:l||""}),language:"json",theme:s,options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8},lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},tabSize:2,renderLineHighlight:"line",automaticLayout:!0}})}),t.type==="text"&&e.jsx("textarea",{value:t.raw||"",onChange:l=>a({...t,raw:l.target.value}),placeholder:"Plain text body...",className:"w-full h-48 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/5 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-y",spellCheck:!1}),t.type==="form-data"&&e.jsx(js,{pairs:t.formData||[],onChange:l=>a({...t,formData:l})}),t.type==="graphql"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Query"}),e.jsx("textarea",{value:t.raw||"",onChange:l=>a({...t,raw:l.target.value}),placeholder:`query {
|
|
2
|
+
users {
|
|
3
|
+
id
|
|
4
|
+
name
|
|
5
|
+
}
|
|
6
|
+
}`,className:"w-full h-36 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/5 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-y",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Variables"}),e.jsx("textarea",{value:t.graphqlVariables||"",onChange:l=>a({...t,graphqlVariables:l.target.value}),placeholder:`{
|
|
7
|
+
"id": 1
|
|
8
|
+
}`,className:"w-full h-20 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/5 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-y",spellCheck:!1})]})]})]})}function js({pairs:t,onChange:a}){const s=c.useRef({}),l=(u,p)=>{const i=[...t];i[u]={...i[u],...p},a(i)},m=u=>{a(t.filter((p,i)=>i!==u))},x=()=>{a([...t,{key:"",value:"",enabled:!0,fieldType:"text"}])},n=()=>{a([...t,{key:"",value:"",enabled:!0,fieldType:"file"}])},h=(u,p)=>{const i=new FileReader;i.onload=()=>{const k=i.result.split(",")[1]||"";l(u,{value:k,fileName:p.name,fileSize:p.size})},i.readAsDataURL(p)},o=u=>u<1024?`${u} B`:u<1024*1024?`${(u/1024).toFixed(1)} KB`:`${(u/(1024*1024)).toFixed(1)} MB`;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 px-1 mb-1",children:[e.jsx("span",{className:"w-6"}),e.jsx("span",{className:"w-14 text-center",children:"Type"}),e.jsx("span",{className:"flex-1",children:"Key"}),e.jsx("span",{className:"flex-1",children:"Value"}),e.jsx("span",{className:"w-8"})]}),t.map((u,p)=>e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsx("input",{type:"checkbox",checked:u.enabled,onChange:i=>l(p,{enabled:i.target.checked}),className:"w-4 h-4 accent-brand-500 flex-shrink-0"}),e.jsxs("button",{onClick:()=>l(p,{fieldType:u.fieldType==="file"?"text":"file",value:"",fileName:void 0,fileSize:void 0}),className:`w-14 flex items-center justify-center gap-1 px-1.5 py-1.5 rounded-lg text-sm font-medium transition-colors flex-shrink-0 ${u.fieldType==="file"?"bg-purple-500/15 text-purple-400":"bg-surface-2 text-gray-500 hover:text-gray-300"}`,title:u.fieldType==="file"?"Switch to text":"Switch to file",children:[u.fieldType==="file"?e.jsx(Ze,{size:12}):e.jsx(et,{size:12}),u.fieldType==="file"?"File":"Text"]}),e.jsx("input",{value:u.key,onChange:i=>l(p,{key:i.target.value}),placeholder:"Field name",className:"flex-1 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/10 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),u.fieldType==="file"?e.jsxs("div",{className:"flex-1 flex items-center gap-1.5",children:[e.jsx("input",{ref:i=>{s.current[p]=i},type:"file",className:"hidden",onChange:i=>{var y;const k=(y=i.target.files)==null?void 0:y[0];k&&h(p,k),i.target.value=""}}),u.fileName?e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-2 bg-purple-500/10 border border-purple-500/20 rounded-lg",children:[e.jsx(Ze,{size:13,className:"text-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-200 truncate",children:u.fileName}),e.jsx("span",{className:"text-sm text-gray-500",children:u.fileSize?o(u.fileSize):""}),e.jsx("button",{onClick:()=>l(p,{value:"",fileName:void 0,fileSize:void 0}),className:"p-0.5 text-gray-500 hover:text-red-400 transition-colors ml-auto flex-shrink-0",children:e.jsx(ge,{size:12})})]}):e.jsxs("button",{onClick:()=>{var i;return(i=s.current[p])==null?void 0:i.click()},className:"flex-1 flex items-center justify-center gap-2 px-3 py-2 bg-surface-2 border border-dashed border-white/10 rounded-lg text-sm text-gray-500 hover:text-purple-400 hover:border-purple-500/30 transition-colors",children:[e.jsx($e,{size:14})," Choose File"]})]}):e.jsx("input",{value:u.value,onChange:i=>l(p,{value:i.target.value}),placeholder:"Field value",className:"flex-1 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/10 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("button",{onClick:()=>m(p),className:"p-1.5 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:14})})]},p)),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs("button",{onClick:x,className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-300 transition-colors",children:[e.jsx(ye,{size:13})," ",e.jsx(et,{size:12})," Text Field"]}),e.jsx("span",{className:"text-gray-700",children:"|"}),e.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 text-sm text-purple-400 hover:text-purple-300 transition-colors",children:[e.jsx(ye,{size:13})," ",e.jsx($e,{size:12})," File Field"]})]})]})}const Ns=[{value:"none",label:"None"},{value:"bearer",label:"Bearer Token"},{value:"basic",label:"Basic Auth"},{value:"api-key",label:"API Key"},{value:"oauth2-client-credentials",label:"OAuth2 (client credentials)"}],Re="w-full px-2.5 py-1.5 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50";function vs({auth:t,onChange:a}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-1",children:Ns.map(s=>e.jsx("button",{onClick:()=>a({...t,type:s.value}),className:`px-2.5 py-1 text-sm rounded transition-colors ${t.type===s.value?"bg-brand-500/20 text-brand-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:s.label},s.value))}),t.type==="none"&&e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No authentication"}),t.type==="bearer"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Token"}),e.jsx("input",{type:"text",value:t.bearerToken||"",onChange:s=>a({...t,bearerToken:s.target.value}),placeholder:"Enter bearer token or {{variable}}",className:"w-full px-2.5 py-1.5 text-sm font-mono bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]}),t.type==="basic"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Username"}),e.jsx("input",{type:"text",value:t.basicUsername||"",onChange:s=>a({...t,basicUsername:s.target.value}),placeholder:"Username",className:"w-full px-2.5 py-1.5 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Password"}),e.jsx(We,{value:t.basicPassword||"",onChange:s=>a({...t,basicPassword:s.target.value}),placeholder:"Password",className:"w-full px-2.5 py-1.5 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]})]}),t.type==="api-key"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Key Name"}),e.jsx("input",{type:"text",value:t.apiKeyName||"",onChange:s=>a({...t,apiKeyName:s.target.value}),placeholder:"e.g. X-API-Key",className:"w-full px-2.5 py-1.5 text-sm bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Key Value"}),e.jsx("input",{type:"text",value:t.apiKeyValue||"",onChange:s=>a({...t,apiKeyValue:s.target.value}),placeholder:"API key value or {{variable}}",className:"w-full px-2.5 py-1.5 text-sm font-mono bg-surface-2 border border-white/5 rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Add to"}),e.jsx("div",{className:"flex gap-2",children:["header","query"].map(s=>e.jsx("button",{onClick:()=>a({...t,apiKeyIn:s}),className:`px-2.5 py-1 text-sm rounded transition-colors ${(t.apiKeyIn||"header")===s?"bg-brand-500/20 text-brand-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:s==="header"?"Header":"Query Param"},s))})]})]}),t.type==="oauth2-client-credentials"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-gray-500",children:["Service-to-service auth: the token is requested from the token URL, cached until it expires, and sent as a Bearer token. Use ",e.jsx("code",{children:"{{variables}}"})," for the secret so it lives in an environment."]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Token URL"}),e.jsx("input",{type:"text",value:t.oauth2TokenUrl||"",onChange:s=>a({...t,oauth2TokenUrl:s.target.value}),placeholder:"https://auth.example.com/oauth/token",className:`${Re} font-mono`})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Client ID"}),e.jsx("input",{type:"text",value:t.oauth2ClientId||"",onChange:s=>a({...t,oauth2ClientId:s.target.value}),placeholder:"orders-service or {{clientId}}",className:Re})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Client Secret"}),e.jsx(We,{value:t.oauth2ClientSecret||"",onChange:s=>a({...t,oauth2ClientSecret:s.target.value}),placeholder:"{{clientSecret}}",className:Re})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Scope"}),e.jsx("input",{type:"text",value:t.oauth2Scope||"",onChange:s=>a({...t,oauth2Scope:s.target.value}),placeholder:"optional",className:Re})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Audience"}),e.jsx("input",{type:"text",value:t.oauth2Audience||"",onChange:s=>a({...t,oauth2Audience:s.target.value}),placeholder:"optional",className:Re})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Send credentials"}),e.jsx("div",{className:"flex gap-2",children:["body","basic"].map(s=>e.jsx("button",{onClick:()=>a({...t,oauth2ClientAuth:s}),className:`px-2.5 py-1 text-sm rounded transition-colors ${(t.oauth2ClientAuth||"body")===s?"bg-brand-500/20 text-brand-300":"text-gray-500 hover:text-gray-300 hover:bg-white/5"}`,children:s==="body"?"In the request body":"As Basic auth header"},s))})]})]})]})}const ws=[{value:"status",label:"Status Code"},{value:"header",label:"Header"},{value:"body-contains",label:"Body Contains"},{value:"body-json-path",label:"JSON Path"},{value:"response-time",label:"Response Time"},{value:"schema",label:"JSON Schema"}],ks=[{value:"equals",label:"="},{value:"not-equals",label:"!="},{value:"contains",label:"contains"},{value:"not-contains",label:"!contains"},{value:"greater-than",label:">"},{value:"less-than",label:"<"},{value:"exists",label:"exists"},{value:"matches-regex",label:"regex"}];function Cs({rules:t,onChange:a,results:s,onQuickAdd:l}){const m=()=>{a([...t,{id:`vr-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"status",operator:"equals",expected:"200",enabled:!0}])},x=(o,u)=>{const p=[...t];p[o]={...p[o],...u},a(p)},n=o=>{a(t.filter((u,p)=>p!==o))},h=o=>s==null?void 0:s.find(u=>u.ruleId===o);return e.jsxs("div",{className:"space-y-2",children:[t.length===0&&e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No validations configured"}),t.map((o,u)=>{const p=h(o.id);return e.jsxs("div",{className:"flex items-center gap-1.5 group",children:[e.jsx("input",{type:"checkbox",checked:o.enabled,onChange:i=>x(u,{enabled:i.target.checked}),className:"w-3.5 h-3.5 rounded border-gray-600 bg-surface-2 accent-brand-500 flex-shrink-0"}),e.jsx("select",{value:o.type,onChange:i=>x(u,{type:i.target.value}),className:"px-1.5 py-1 text-sm bg-surface-2 border border-white/5 rounded text-gray-300 focus:outline-none focus:border-brand-500/50",children:ws.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),(o.type==="header"||o.type==="body-json-path")&&e.jsx("input",{type:"text",value:o.target||"",onChange:i=>x(u,{target:i.target.value}),placeholder:o.type==="header"?"Header name":"$.path",className:"w-24 px-1.5 py-1 text-sm font-mono bg-surface-2 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),o.type!=="schema"&&e.jsx("select",{value:o.operator,onChange:i=>x(u,{operator:i.target.value}),className:"px-1.5 py-1 text-sm bg-surface-2 border border-white/5 rounded text-gray-300 focus:outline-none focus:border-brand-500/50",children:ks.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),o.type==="schema"?e.jsx("textarea",{value:o.expected,onChange:i=>x(u,{expected:i.target.value}),placeholder:'{"type":"object","properties":{...}}',rows:3,className:"flex-1 min-w-0 px-1.5 py-1 text-sm font-mono bg-surface-2 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-y"}):e.jsx("input",{type:"text",value:o.expected,onChange:i=>x(u,{expected:i.target.value}),placeholder:"Expected",className:"flex-1 min-w-0 px-1.5 py-1 text-sm font-mono bg-surface-2 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),p&&(p.passed?e.jsx(pe,{size:14,className:"text-emerald-400 flex-shrink-0"}):e.jsx("span",{title:p.message,className:"flex-shrink-0",children:e.jsx(he,{size:14,className:"text-red-400"})})),e.jsx("button",{onClick:()=>n(u),className:"p-1 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:14})})]},o.id)}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("button",{onClick:m,className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-300 transition-colors",children:[e.jsx(ye,{size:13})," Add Validation"]}),l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-sm text-brand-400 hover:text-brand-300 transition-colors",children:[e.jsx(ye,{size:13})," Quick Add from Response"]})]})]})}function Ss({preRequestScript:t="",postResponseScript:a="",onChangePreRequest:s,onChangePostResponse:l}){const[m,x]=c.useState(!!t),[n,h]=c.useState(!!a),[o,u]=c.useState(!1),[p,i]=c.useState(""),[k,y]=c.useState(""),v=()=>{if(!p.trim()||!k.trim())return;const C=`set("${p.trim()}", jsonpath(response.body, "${k.trim()}"))`,M=a?`${a}
|
|
9
|
+
${C}`:C;l(M),i(""),y(""),h(!0)};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-3 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx("span",{className:"text-sm font-semibold text-gray-500 uppercase tracking-wider",children:"Quick Extract Variable"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:p,onChange:C=>i(C.target.value),placeholder:"Variable name",className:"w-28 px-2 py-1 text-sm bg-surface-1 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("span",{className:"text-sm text-gray-600",children:"="}),e.jsx("input",{value:k,onChange:C=>y(C.target.value),onKeyDown:C=>{C.key==="Enter"&&v()},placeholder:"$.data.token",className:"flex-1 px-2 py-1 text-sm font-mono bg-surface-1 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsxs("button",{onClick:v,disabled:!p.trim()||!k.trim(),className:"flex items-center gap-1 px-2.5 py-1 rounded bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:[e.jsx(ye,{size:13})," Add"]})]}),e.jsx("p",{className:"text-sm text-gray-600 mt-1.5",children:"Tip: Use the Extract Variable feature in the Response panel to auto-fill the JSONPath"})]}),e.jsxs("div",{className:"rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("button",{onClick:()=>x(!m),className:"w-full flex items-center gap-2 px-3 py-2 bg-surface-2 hover:bg-surface-3 transition-colors text-left",children:[m?e.jsx(ce,{size:14,className:"text-gray-500"}):e.jsx(me,{size:14,className:"text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Pre-Request Script"}),t&&e.jsx("span",{className:"text-sm px-1.5 py-0.5 rounded bg-brand-500/15 text-brand-300 ml-auto",children:"active"})]}),m&&e.jsx("textarea",{value:t,onChange:C=>s(C.target.value),placeholder:`// Runs before the request is sent
|
|
10
|
+
// Example: setHeader('Authorization', 'Bearer ' + get('token'))`,className:"w-full h-32 px-3 py-2 text-sm font-mono bg-surface-1 text-gray-300 placeholder-gray-600 border-t border-white/5 resize-y focus:outline-none"})]}),e.jsxs("div",{className:"rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("button",{onClick:()=>h(!n),className:"w-full flex items-center gap-2 px-3 py-2 bg-surface-2 hover:bg-surface-3 transition-colors text-left",children:[n?e.jsx(ce,{size:14,className:"text-gray-500"}):e.jsx(me,{size:14,className:"text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-300",children:"Post-Response Script"}),a&&e.jsx("span",{className:"text-sm px-1.5 py-0.5 rounded bg-brand-500/15 text-brand-300 ml-auto",children:"active"})]}),n&&e.jsx("textarea",{value:a,onChange:C=>l(C.target.value),placeholder:`// Runs after the response is received
|
|
11
|
+
// Example: set('userId', jsonpath(response.body, '$.data.id'))`,className:"w-full h-32 px-3 py-2 text-sm font-mono bg-surface-1 text-gray-300 placeholder-gray-600 border-t border-white/5 resize-y focus:outline-none"})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>u(!o),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-300 transition-colors",children:[e.jsx(Kt,{size:13})," Script DSL Reference"]}),o&&e.jsxs("div",{className:"mt-2 p-3 bg-surface-2 rounded-lg border border-white/5 space-y-2",children:[e.jsxs("div",{children:[e.jsx("code",{className:"text-sm text-brand-300",children:"get(key)"}),e.jsx("span",{className:"text-sm text-gray-500 ml-2",children:"Read a chain variable"})]}),e.jsxs("div",{children:[e.jsx("code",{className:"text-sm text-brand-300",children:"set(key, value)"}),e.jsx("span",{className:"text-sm text-gray-500 ml-2",children:"Store a chain variable for subsequent requests"})]}),e.jsxs("div",{children:[e.jsx("code",{className:"text-sm text-brand-300",children:"jsonpath(body, path)"}),e.jsx("span",{className:"text-sm text-gray-500 ml-2",children:"Extract value from JSON body using path like $.data.id"})]}),e.jsxs("div",{children:[e.jsx("code",{className:"text-sm text-brand-300",children:"setHeader(name, value)"}),e.jsx("span",{className:"text-sm text-gray-500 ml-2",children:"Set/override a header for the current request (pre-request only)"})]}),e.jsx("hr",{className:"border-white/5"}),e.jsx("p",{className:"text-sm text-gray-600",children:"Example: Extract a token from login response and use it in the next request:"}),e.jsx("code",{className:"block text-sm text-gray-400 font-mono bg-surface-1 p-2 rounded",children:`// Post-Response Script (on login request):
|
|
12
|
+
set("token", jsonpath(response.body, "$.access_token"))
|
|
13
|
+
|
|
14
|
+
// Pre-Request Script (on next request):
|
|
15
|
+
setHeader("Authorization", "Bearer " + get("token"))`})]})]})]})}function zs(t,a){if(!t||!t.includes("{{"))return null;const s=t.replace(/\{\{(\w+)\}\}/g,(l,m)=>a[m]??`{{${m}}}`);return s!==t?s:null}const Es=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],$s={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400",HEAD:"text-purple-400",OPTIONS:"text-gray-400"};function Ps({request:t,onChange:a,onSend:s,onSave:l,onQuickValidate:m,sending:x,validationResults:n,variables:h}){const[o,u]=ut("reqtab",["params","headers","body","auth","validations","scripts"],"params"),p=c.useMemo(()=>!h||Object.keys(h).length===0?null:zs(t.url,h),[t.url,h]),i=(y,v)=>{a({...t,[y]:v})},k=[{id:"params",label:"Params",count:t.queryParams.filter(y=>y.enabled&&y.key).length},{id:"headers",label:"Headers",count:t.headers.filter(y=>y.enabled&&y.key).length},{id:"body",label:"Body"},{id:"auth",label:"Auth"},{id:"validations",label:"Validations",count:t.validations.length},{id:"scripts",label:"Scripts",count:t.preRequestScript||t.postResponseScript?1:0}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-3 pt-2 pb-1 border-b border-white/5 flex-shrink-0",children:e.jsx("input",{type:"text",value:t.name,onChange:y=>i("name",y.target.value),onBlur:()=>l==null?void 0:l(),placeholder:"Request name",className:"w-full px-1 py-0.5 text-sm font-medium bg-transparent border-none text-gray-200 placeholder-gray-600 focus:outline-none hover:bg-surface-2 focus:bg-surface-2 rounded transition-colors"})}),e.jsxs("div",{className:"flex gap-1.5 px-3 py-2 border-b border-white/5 flex-shrink-0",children:[e.jsx("select",{value:t.method,onChange:y=>i("method",y.target.value),className:`px-2 py-1.5 text-sm font-bold bg-surface-2 border border-white/5 rounded-lg focus:outline-none focus:border-brand-500/50 ${$s[t.method]}`,children:Es.map(y=>e.jsx("option",{value:y,children:y},y))}),e.jsx("input",{type:"text",value:t.url,onChange:y=>i("url",y.target.value),onKeyDown:y=>{y.key==="Enter"&&!x&&s()},placeholder:"https://api.example.com/endpoint or {{baseUrl}}/path",className:"flex-1 px-3 py-1.5 text-sm font-mono bg-surface-2 border border-white/5 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsxs("button",{onClick:s,disabled:x||!t.url,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[x?e.jsx(De,{size:13,className:"animate-spin"}):e.jsx(dt,{size:13}),"Send"]})]}),p&&e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-1 border-b border-white/5 bg-surface-1/50 flex-shrink-0",children:[e.jsx(xt,{size:13,className:"text-emerald-500/60 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-gray-500 truncate",title:p,children:p})]}),e.jsx("div",{className:"flex gap-0.5 px-3 py-1 border-b border-white/5 flex-shrink-0",children:k.map(y=>e.jsxs("button",{onClick:()=>u(y.id),className:`px-2.5 py-1 text-sm rounded transition-colors ${o===y.id?"bg-brand-500/15 text-brand-300":"text-gray-500 hover:text-gray-300"}`,children:[y.label,y.count!==void 0&&y.count>0&&e.jsx("span",{className:"ml-1 text-sm px-1 py-0.5 rounded-full bg-surface-2 text-gray-400",children:y.count})]},y.id))}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[o==="params"&&e.jsx(at,{pairs:t.queryParams,onChange:y=>i("queryParams",y),keyPlaceholder:"Parameter",valuePlaceholder:"Value"}),o==="headers"&&e.jsx(at,{pairs:t.headers,onChange:y=>i("headers",y),keyPlaceholder:"Header name",valuePlaceholder:"Header value"}),o==="body"&&e.jsx(ys,{body:t.body,onChange:y=>i("body",y)}),o==="auth"&&e.jsx(vs,{auth:t.auth,onChange:y=>i("auth",y)}),o==="validations"&&e.jsx(Cs,{rules:t.validations,onChange:y=>i("validations",y),results:n,onQuickAdd:m}),o==="scripts"&&e.jsx(Ss,{preRequestScript:t.preRequestScript||"",postResponseScript:t.postResponseScript||"",onChangePreRequest:y=>i("preRequestScript",y),onChangePostResponse:y=>i("postResponseScript",y)})]})]})}function Rs(t,a){return typeof a=="number"?`${t}[${a}]`:/[.\s\-\[\]]/.test(a)?`${t}["${a}"]`:t?`${t}.${a}`:`$.${a}`}function ht(t){return t===null?{text:"null",color:"text-gray-500"}:t===void 0?{text:"undefined",color:"text-gray-500"}:typeof t=="boolean"?{text:String(t),color:"text-blue-400"}:typeof t=="number"?{text:String(t),color:"text-amber-400"}:typeof t=="string"?{text:t.length>60?`"${t.slice(0,57)}..."`:`"${t}"`,color:"text-emerald-400"}:Array.isArray(t)?{text:`Array(${t.length})`,color:"text-purple-400"}:typeof t=="object"?{text:`Object{${Object.keys(t).length}}`,color:"text-purple-400"}:{text:String(t),color:"text-gray-400"}}function Ds(t){return t==null||typeof t!="object"}function gt(t){return t==null?"exists":typeof t=="boolean"||typeof t=="number"?"equals":typeof t=="string"?t.length>50?"contains":"equals":"exists"}const rt=50;function _e({data:t,onSelectPath:a,rootPath:s="$"}){let l=t;if(typeof t=="string")try{l=JSON.parse(t)}catch{}if(l==null||typeof l!="object"){const m=ht(l);return e.jsx("button",{onClick:()=>a(s,l),className:`text-sm font-mono ${m.color} hover:bg-white/10 px-1 rounded cursor-pointer transition-colors`,children:m.text})}return e.jsx("div",{className:"text-sm font-mono",children:e.jsx(ft,{value:l,path:s,onSelectPath:a,depth:0,isRoot:!0})})}function ft({value:t,path:a,onSelectPath:s,depth:l,isRoot:m,keyName:x}){const[n,h]=c.useState(l===0),[o,u]=c.useState(rt);if(Ds(t)){const H=ht(t);return e.jsxs("div",{className:"flex items-center gap-1 py-0.5 group",style:{paddingLeft:l*16},children:[x!==void 0&&e.jsx("span",{className:"text-gray-400",children:typeof x=="number"?`${x}:`:`"${x}":`}),e.jsx("button",{onClick:()=>s(a,t),className:`${H.color} hover:bg-brand-500/20 px-1 rounded cursor-pointer transition-colors border border-transparent hover:border-brand-500/30`,title:`Click to select: ${a}`,children:H.text}),e.jsx("span",{className:"text-gray-700 opacity-0 group-hover:opacity-100 text-sm transition-opacity ml-1",children:a})]})}const p=Array.isArray(t),i=p?t.map((H,R)=>[R,H]):Object.entries(t),k=i.length,y=i.slice(0,o),v=k>o,C=p?"[":"{",M=p?"]":"}";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 py-0.5 cursor-pointer hover:bg-white/5 rounded",style:{paddingLeft:l*16},onClick:()=>h(!n),children:[n?e.jsx(ce,{size:13,className:"text-gray-600 flex-shrink-0"}):e.jsx(me,{size:13,className:"text-gray-600 flex-shrink-0"}),x!==void 0&&e.jsx("span",{className:"text-gray-400",children:typeof x=="number"?`${x}:`:`"${x}":`}),e.jsxs("span",{className:"text-gray-500",children:[C,!n&&e.jsxs("span",{className:"text-gray-600",children:[" ",k," ",p?"items":"keys"," ",M]})]})]}),n&&e.jsxs(e.Fragment,{children:[y.map(([H,R])=>{const N=Rs(a,H);return e.jsx(ft,{value:R,path:N,onSelectPath:s,depth:l+1,keyName:H},String(H))}),v&&e.jsx("div",{style:{paddingLeft:(l+1)*16},className:"py-1",children:e.jsxs("button",{onClick:H=>{H.stopPropagation(),u(R=>R+rt)},className:"text-sm text-brand-400 hover:text-brand-300 hover:bg-brand-500/10 px-2 py-0.5 rounded transition-colors",children:["Show more (",k-o," remaining)"]})}),e.jsx("div",{style:{paddingLeft:l*16},className:"text-gray-500 py-0.5",children:M})]})]})}function As(t){return t>=200&&t<300?"bg-emerald-500/15 text-emerald-400":t>=300&&t<400?"bg-blue-500/15 text-blue-400":t>=400&&t<500?"bg-amber-500/15 text-amber-400":t>=500?"bg-red-500/15 text-red-400":"bg-gray-500/15 text-gray-400"}function nt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function qs(t){try{const a=JSON.parse(t);return{formatted:JSON.stringify(a,null,2),language:"json"}}catch{return t.trim().startsWith("<")?{formatted:t,language:"html"}:{formatted:t,language:"text"}}}function Is({response:t,loading:a,onAddValidation:s,onExtractVariable:l,variables:m={},request:x,extractedVars:n={}}){const[h,o]=ut("restab",["body","headers","validations","variables","timing"],"body"),[u,p]=c.useState("none"),[i,k]=c.useState(""),[y,v]=c.useState(""),{monacoTheme:C}=Ge();if(a)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-gray-500",children:"Sending request..."})]})});if(!t)return e.jsx("div",{className:"flex items-center justify-center h-full text-gray-600 text-sm",children:"Send a request to see the response"});const{formatted:M,language:H}=qs(t.body),R=H==="json",N=t.validationResults||[],q=N.filter(r=>r.passed).length,J=Object.keys(m).length,Q=[{id:"body",label:"Body"},{id:"headers",label:`Headers (${Object.keys(t.headers).length})`},{id:"validations",label:"Validations",badge:N.length>0?`${q}/${N.length}`:void 0},{id:"variables",label:"Variables",badge:J>0?String(J):void 0},{id:"timing",label:"Timing"}];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-white/5 flex-shrink-0",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-sm font-bold ${As(t.status)}`,children:[t.status," ",t.statusText]}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-gray-500",children:[e.jsx(He,{size:13})," ",t.duration,"ms"]}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-gray-500",children:[e.jsx(Jt,{size:13})," ",nt(t.size)]}),t.status>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[l&&R&&e.jsxs("button",{onClick:()=>p(u==="extract"?"none":"extract"),className:`flex items-center gap-1 px-2 py-1 rounded-lg text-sm transition-colors ${u==="extract"?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400 hover:bg-amber-500/20"}`,children:[e.jsx(Oe,{size:13})," Extract"]}),s&&R&&e.jsxs("button",{onClick:()=>p(u==="validate"?"none":"validate"),className:`flex items-center gap-1 px-2 py-1 rounded-lg text-sm transition-colors ${u==="validate"?"bg-brand-500/20 text-brand-300":"bg-brand-500/10 text-brand-400 hover:bg-brand-500/20"}`,children:[e.jsx(mt,{size:13})," Validate"]})]})]}),e.jsx("div",{className:"flex gap-0.5 px-3 py-1 border-b border-white/5 flex-shrink-0",children:Q.map(r=>e.jsxs("button",{onClick:()=>o(r.id),className:`px-2.5 py-1 text-sm rounded transition-colors ${h===r.id?"bg-brand-500/15 text-brand-300":"text-gray-500 hover:text-gray-300"}`,children:[r.label,r.badge&&e.jsxs("span",{className:"ml-1 text-sm opacity-70",children:["(",r.badge,")"]})]},r.id))}),e.jsxs("div",{className:`flex-1 overflow-auto p-3 ${h==="body"?"flex flex-col":""}`,children:[h==="body"&&e.jsx(e.Fragment,{children:u==="validate"&&R&&s?e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 px-2 py-1.5 bg-brand-500/10 border border-brand-500/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-brand-300",children:"Click any value below to create a validation rule for it"})}),e.jsx(_e,{data:t.body,onSelectPath:(r,z)=>{const j=gt(z);s({id:`vr-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"body-json-path",target:r,operator:j,expected:z!=null&&typeof z!="object"?String(z):"",enabled:!0})}})]}):u==="extract"&&R&&l?e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 px-2 py-1.5 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:e.jsx("p",{className:"text-sm text-amber-300",children:"Click any value below to extract it as a variable"})}),e.jsx(_e,{data:t.body,onSelectPath:(r,z)=>{v(r);const U=r.replace(/\$/g,"").replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean).slice(-2).join("_").replace(/[^a-zA-Z0-9_]/g,"");k(U||"myVar")}}),y&&e.jsxs("div",{className:"mt-3 flex items-center gap-2 p-2 bg-surface-2 rounded-lg border border-white/5",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"Save as:"}),e.jsx("input",{value:i,onChange:r=>k(r.target.value),className:"w-28 px-2 py-1 text-sm font-mono bg-surface-1 border border-white/5 rounded text-gray-300 focus:outline-none",placeholder:"Variable name"}),e.jsx("span",{className:"text-sm text-gray-600",children:"="}),e.jsx("code",{className:"text-sm text-brand-300 font-mono flex-1 truncate",children:y}),e.jsx("button",{onClick:()=>{i.trim()&&y&&(l(i.trim(),y),v(""),k(""))},disabled:!i.trim(),className:"px-2.5 py-1 rounded bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 disabled:opacity-40 transition-colors",children:"Add"})]})]}):e.jsxs("div",{className:"flex flex-col h-full relative group/body",children:[e.jsxs("div",{className:"absolute top-2 right-4 z-10 flex items-center gap-1 opacity-0 group-hover/body:opacity-100 transition-opacity",children:[e.jsx(Ts,{text:M}),R&&e.jsxs("button",{onClick:()=>{const r=new Blob([M],{type:"application/json"}),z=URL.createObjectURL(r),j=document.createElement("a");j.href=z,j.download=`response-${Date.now()}.json`,document.body.appendChild(j),j.click(),document.body.removeChild(j),URL.revokeObjectURL(z)},className:"flex items-center gap-1 px-2.5 py-1 rounded-lg text-sm text-gray-500 hover:text-cyan-400 bg-surface-1/90 hover:bg-cyan-500/10 backdrop-blur-sm border border-white/10 transition-colors",title:"Download as JSON",children:[e.jsx(Le,{size:13})," Download"]})]}),e.jsx("div",{className:"flex-1 min-h-[200px]",children:e.jsx(Qe,{value:M,language:H,theme:C,options:{readOnly:!0,minimap:{enabled:!1},fontSize:14,lineHeight:22,scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:8,bottom:8},scrollbar:{verticalScrollbarSize:8,horizontalScrollbarSize:8},lineNumbers:"on",folding:!0,bracketPairColorization:{enabled:!0},renderLineHighlight:"none",automaticLayout:!0}})})]})}),h==="headers"&&e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:Object.entries(t.headers).map(([r,z])=>e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:"py-1.5 pr-3 text-gray-400 font-medium whitespace-nowrap align-top",children:r}),e.jsx("td",{className:"py-1.5 text-gray-300 font-mono break-all",children:z})]},r))})}),h==="validations"&&e.jsx("div",{className:"space-y-2",children:N.length===0?e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No validations configured. Use the Validate button to add rules."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-surface-2 border border-white/5 mb-3",children:[e.jsxs("span",{className:"text-sm text-gray-400",children:["Total: ",N.length]}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-emerald-400",children:[e.jsx(pe,{size:13})," ",q," passed"]}),N.length-q>0&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-400",children:[e.jsx(he,{size:13})," ",N.length-q," failed"]})]}),N.map((r,z)=>{var U;const j=(U=x==null?void 0:x.validations)==null?void 0:U.find(L=>L.id===r.ruleId);return e.jsxs("div",{className:`rounded-xl border px-4 py-3 ${r.passed?"bg-emerald-500/5 border-emerald-500/10":"bg-red-500/5 border-red-500/10"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r.passed?e.jsx(pe,{size:15,className:"text-emerald-400 flex-shrink-0"}):e.jsx(he,{size:15,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`text-sm font-semibold ${r.passed?"text-emerald-400":"text-red-400"}`,children:r.passed?"Passed":"Failed"}),j&&e.jsxs("span",{className:"text-sm text-gray-500",children:["— ",j.type,j.target?` (${j.target})`:""]})]}),j&&e.jsxs("div",{className:"mt-2 ml-6 space-y-1 text-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-500 w-16 flex-shrink-0",children:"Type:"}),e.jsx("span",{className:"text-gray-300 font-mono",children:j.type})]}),j.target&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-500 w-16 flex-shrink-0",children:"Target:"}),e.jsx("span",{className:"text-gray-300 font-mono break-all",children:j.target})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-500 w-16 flex-shrink-0",children:"Rule:"}),e.jsxs("span",{className:"text-gray-300 font-mono",children:[j.operator," ",j.expected]})]}),r.actual!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-500 w-16 flex-shrink-0",children:"Actual:"}),e.jsx("span",{className:`font-mono break-all ${r.passed?"text-emerald-300":"text-red-300"}`,children:r.actual})]}),r.message&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-500 w-16 flex-shrink-0",children:"Info:"}),e.jsx("span",{className:"text-gray-400",children:r.message})]})]}),!j&&r.message&&e.jsx("p",{className:"text-sm text-gray-500 mt-1 ml-6",children:r.message})]},r.ruleId||z)})]})}),h==="variables"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-2 flex items-center gap-1.5",children:[e.jsx(Oe,{size:14,className:"text-brand-400"})," Predefined Variables"]}),Object.keys(m).length===0?e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No environment variables set. Select an environment to see variables."}):e.jsx("div",{className:"space-y-1",children:Object.entries(m).map(([r,z])=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2 border border-white/5 text-sm",children:[e.jsx("span",{className:"text-brand-300 font-mono font-medium",children:`{{${r}}}`}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 font-mono truncate flex-1",children:z}),e.jsx(lt,{text:`{{${r}}}`,title:"Copy reference"})]},r))})]}),Object.keys(n).length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-gray-300 mb-2 flex items-center gap-1.5",children:[e.jsx(Oe,{size:14,className:"text-cyan-400"})," Extracted Variables"]}),e.jsx("div",{className:"space-y-1",children:Object.entries(n).map(([r,z])=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-cyan-500/5 border border-cyan-500/10 text-sm",children:[e.jsx("span",{className:"text-cyan-300 font-mono font-medium",children:`{{${r}}}`}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 font-mono truncate flex-1",children:z}),e.jsx(lt,{text:`{{${r}}}`,title:"Copy reference"})]},r))})]}),e.jsx("div",{className:"px-3 py-2 rounded-lg bg-brand-500/5 border border-brand-500/10",children:e.jsxs("p",{className:"text-sm text-gray-500",children:["Use ",e.jsx("code",{className:"px-1 py-0.5 bg-surface-2 rounded text-cyan-400 font-mono text-sm",children:"{{variableName}}"})," in URLs, headers, body, and auth fields. Variables are resolved at send time."]})})]}),h==="timing"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-surface-1 border border-white/5 rounded-lg",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Total Duration"}),e.jsxs("span",{className:"text-sm font-bold text-gray-200",children:[t.duration,"ms"]})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-surface-1 border border-white/5 rounded-lg",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Response Size"}),e.jsx("span",{className:"text-sm font-medium text-gray-200",children:nt(t.size)})]}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-surface-1 border border-white/5 rounded-lg",children:[e.jsx("span",{className:"text-sm text-gray-400",children:"Timestamp"}),e.jsx("span",{className:"text-sm text-gray-300",children:pt(t.timestamp)})]})]})]})]})}function lt({text:t,title:a="Copy"}){const[s,l]=c.useState(!1),m=()=>{try{navigator.clipboard.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{const x=document.createElement("textarea");x.value=t,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x),l(!0),setTimeout(()=>l(!1),1500)})}catch{const x=document.createElement("textarea");x.value=t,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.select(),document.execCommand("copy"),document.body.removeChild(x),l(!0),setTimeout(()=>l(!1),1500)}};return e.jsx("button",{onClick:m,className:`flex-shrink-0 p-1 rounded transition-colors ${s?"text-emerald-400":"text-gray-600 hover:text-cyan-400"}`,title:s?"Copied!":a,children:s?e.jsx(Je,{size:13}):e.jsx(Pe,{size:13})})}function Ts({text:t}){const[a,s]=c.useState(!1);return e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t).catch(()=>{}),s(!0),setTimeout(()=>s(!1),1500)},className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-sm backdrop-blur-sm border border-white/10 transition-colors ${a?"text-emerald-400 bg-emerald-500/20":"text-gray-500 hover:text-cyan-400 bg-surface-1/90 hover:bg-cyan-500/10"}`,title:a?"Copied!":"Copy response",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Je,{size:13})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:13})," Copy"]})})}function Os({environments:t,activeEnvId:a,onSelectEnv:s,onSave:l,onDelete:m,onClose:x}){const[n,h]=c.useState(t.find(r=>r.id===a)||null),[o,u]=c.useState(""),[p,i]=c.useState(null),[k,y]=c.useState(null),v=c.useRef(!1);c.useEffect(()=>{if(!n||v.current)return;const r=t.find(z=>z.id===n.id);r&&h(r)},[t]);const C=r=>{v.current=!0,h(r)},M=()=>{if(!o.trim())return;const r={id:`env-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:o.trim(),variables:[]};l(r),h(r),u("")},H=()=>{if(!n)return;const r={id:`env-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:`${n.name} (copy)`,variables:n.variables.map(z=>({...z}))};l(r),h(r)},R=(r,z,j)=>{if(!n)return;const U=[...n.variables];U[r]={...U[r],[z]:j},C({...n,variables:U})},N=()=>{n&&C({...n,variables:[...n.variables,{key:"",value:"",enabled:!0,secret:!1}]})},q=r=>{n&&C({...n,variables:n.variables.filter((z,j)=>j!==r)})},J=()=>{n&&(v.current=!1,l(n))},Q=r=>{navigator.clipboard.writeText(`{{${r}}}`).catch(()=>{}),i(r),setTimeout(()=>i(null),1500)};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:x,children:[e.jsxs("div",{className:"w-[860px] max-h-[85vh] bg-surface-1 rounded-2xl border border-white/10 shadow-2xl flex flex-col",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-white/5 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(Ee,{size:20,className:"text-emerald-400"}),e.jsx("h2",{className:"text-lg font-semibold text-gray-200",children:"Manage Environments"})]}),e.jsx("button",{onClick:x,className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:e.jsx(ge,{size:18})})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden min-h-0",children:[e.jsxs("div",{className:"w-56 border-r border-white/5 flex flex-col bg-black/10",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto py-2",children:[t.length===0&&e.jsx("div",{className:"text-center py-6 text-sm text-gray-600",children:"No environments yet"}),t.map(r=>e.jsxs("div",{className:`flex items-center gap-2.5 px-4 py-2.5 cursor-pointer transition-colors group ${(n==null?void 0:n.id)===r.id?"bg-brand-500/10 border-r-2 border-r-brand-400":"hover:bg-white/[0.03] border-r-2 border-r-transparent"}`,onClick:()=>{v.current=!1,h(r)},children:[e.jsx("input",{type:"radio",name:"activeEnv",checked:a===r.id,onChange:()=>s(a===r.id?null:r.id),onClick:z=>z.stopPropagation(),className:"w-3.5 h-3.5 accent-emerald-500 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:`text-sm truncate block ${(n==null?void 0:n.id)===r.id?"text-gray-200 font-medium":"text-gray-400"}`,children:r.name}),e.jsxs("span",{className:"text-xs text-gray-600",children:[r.variables.length," vars"]})]}),a===r.id&&e.jsx(pe,{size:14,className:"text-emerald-400 flex-shrink-0"}),e.jsx("button",{onClick:z=>{z.stopPropagation(),y({id:r.id,name:r.name})},className:"p-1 text-gray-600 hover:text-red-400 opacity-0 group-hover:opacity-100 transition-all flex-shrink-0",children:e.jsx(xe,{size:13})})]},r.id))]}),e.jsx("div",{className:"px-3 py-3 mb-2 border-t border-white/5 flex-shrink-0",children:e.jsx("input",{value:o,onChange:r=>u(r.target.value),onKeyDown:r=>{r.key==="Enter"&&M()},placeholder:"New environment... (Enter to create)",className:"w-full px-2.5 py-2 text-sm bg-surface-2 border border-white/10 rounded-lg text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 flex-shrink-0",children:[e.jsx("input",{value:n.name,onChange:r=>C({...n,name:r.target.value}),className:"text-base font-semibold bg-surface-2 border border-white/10 rounded-lg px-3 py-1.5 text-gray-200 focus:outline-none focus:border-brand-500/50 flex-1 max-w-[300px]"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:H,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-lg bg-surface-2 text-gray-400 hover:text-gray-200 hover:bg-surface-3 border border-white/5 transition-colors",title:"Duplicate environment",children:[e.jsx(Pe,{size:13})," Duplicate"]}),e.jsxs("button",{onClick:J,className:"flex items-center gap-1.5 px-4 py-1.5 text-sm font-medium rounded-lg bg-brand-600 text-white hover:bg-brand-500 transition-colors",children:[e.jsx(ze,{size:14})," Save"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-gray-600 uppercase tracking-wider font-medium",children:[e.jsx("span",{className:"w-6"}),e.jsx("span",{className:"flex-1",children:"Variable Name"}),e.jsx("span",{className:"flex-1",children:"Value"}),e.jsx("span",{className:"w-24"})]}),e.jsx("div",{className:"space-y-1.5",children:n.variables.map((r,z)=>e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:j=>R(z,"enabled",j.target.checked),className:"w-4 h-4 accent-emerald-500 rounded flex-shrink-0"}),e.jsx("input",{value:r.key,onChange:j=>R(z,"key",j.target.value),placeholder:"variable_name",className:"flex-1 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/10 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsx("input",{type:r.secret?"password":"text",value:r.value,onChange:j=>R(z,"value",j.target.value),placeholder:"value",className:"flex-1 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/10 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"}),e.jsxs("div",{className:"flex items-center gap-0.5 w-24 justify-end flex-shrink-0",children:[e.jsx("button",{onClick:()=>R(z,"secret",!r.secret),className:"p-1.5 rounded-lg text-gray-600 hover:text-gray-300 hover:bg-white/5 transition-colors",title:r.secret?"Show value":"Hide value",children:r.secret?e.jsx(Qt,{size:14}):e.jsx(Gt,{size:14})}),r.key&&e.jsx("button",{onClick:()=>Q(r.key),className:`p-1.5 rounded-lg transition-colors ${p===r.key?"text-emerald-400 bg-emerald-500/10":"text-gray-600 hover:text-brand-400 hover:bg-white/5 opacity-0 group-hover:opacity-100"}`,title:p===r.key?"Copied!":`Copy {{${r.key}}}`,children:p===r.key?e.jsx(ze,{size:14}):e.jsx(Pe,{size:14})}),e.jsx("button",{onClick:()=>q(z),className:"p-1.5 rounded-lg text-gray-600 hover:text-red-400 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition-all",children:e.jsx(xe,{size:14})})]})]},z))}),e.jsxs("button",{onClick:N,className:"flex items-center gap-1.5 text-sm text-brand-400 hover:text-brand-300 mt-3 px-1",children:[e.jsx(ye,{size:14})," Add Variable"]}),n.variables.filter(r=>r.key&&r.enabled).length>0&&e.jsxs("div",{className:"pt-4 mt-4 border-t border-white/5",children:[e.jsx("p",{className:"text-xs text-gray-500 uppercase tracking-wider font-medium mb-2",children:"Available Variables"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:n.variables.filter(r=>r.key&&r.enabled).map(r=>e.jsx("button",{onClick:()=>Q(r.key),className:`px-2 py-1 rounded-lg text-sm font-mono transition-colors ${p===r.key?"bg-emerald-500/20 text-emerald-400":"bg-surface-2 text-gray-400 hover:text-gray-200 hover:bg-surface-3 border border-white/5"}`,title:`Click to copy {{${r.key}}}`,children:p===r.key?"Copied!":`{{${r.key}}}`},r.key))})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Ee,{size:28,className:"text-gray-700 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Select or create an environment"})]})}),e.jsx("div",{className:"px-5 py-3 border-t border-white/5 bg-surface-2/20 flex-shrink-0",children:e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(Wt,{size:15,className:"text-brand-400 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"text-sm text-gray-500 leading-relaxed",children:["Use ",e.jsx("code",{className:"px-1.5 py-0.5 bg-surface-2 rounded text-cyan-400 font-mono text-sm",children:"{{variableName}}"})," in URLs, headers, body, and auth fields. Example: ",e.jsx("code",{className:"px-1.5 py-0.5 bg-surface-2 rounded text-cyan-400 font-mono text-sm",children:"{{baseUrl}}/api/users"})]})]})})]})]})]}),k&&e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:()=>y(null),children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-2xl shadow-xl w-full max-w-md p-6",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-red-500/10 flex items-center justify-center flex-shrink-0",children:e.jsx(xe,{size:20,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-gray-200",children:"Delete Environment"}),e.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:"This action cannot be undone"})]})]}),e.jsx("p",{className:"text-sm text-gray-400 mb-2",children:"Are you sure you want to delete this environment?"}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 rounded-lg bg-surface-2 border border-white/5 mb-2",children:[e.jsx(Ee,{size:14,className:"text-emerald-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-gray-200 truncate",children:k.name})]}),e.jsx("p",{className:"text-sm text-orange-400/80 mb-5",children:"All variables in this environment will be permanently deleted."}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{onClick:()=>y(null),className:"px-4 py-2 rounded-lg text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:"Cancel"}),e.jsx("button",{onClick:()=>{m(k.id),(n==null?void 0:n.id)===k.id&&h(null),y(null)},className:"px-4 py-2 rounded-lg text-sm font-medium text-white bg-red-600 hover:bg-red-500 transition-colors",children:"Delete"})]})]})})]})}const Fs={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400",HEAD:"text-purple-400",OPTIONS:"text-gray-400"};function Ls(t){return t>=200&&t<300?"text-emerald-400":t>=300&&t<400?"text-blue-400":t>=400&&t<500?"text-amber-400":t>=500?"text-red-400":"text-gray-500"}function Vs({onSelectRequest:t,onClose:a}){const{data:s}=ps(),l=hs(),m=(s==null?void 0:s.history)||[];return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{size:13,className:"text-gray-500"}),e.jsx("span",{className:"text-sm font-semibold uppercase text-gray-500 tracking-wider",children:"History"})]}),e.jsxs("div",{className:"flex gap-1",children:[m.length>0&&e.jsx("button",{onClick:()=>l.mutate(),className:"p-1 text-gray-600 hover:text-red-400",title:"Clear history",children:e.jsx(xe,{size:14})}),e.jsx("button",{onClick:a,className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(ge,{size:14})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-600",children:"No history yet"}):m.map(x=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 hover:bg-white/5 cursor-pointer border-b border-white/[0.03]",onClick:()=>t(x.request),children:[e.jsx("span",{className:`text-sm font-bold w-8 flex-shrink-0 ${Fs[x.request.method]}`,children:x.request.method.slice(0,3)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-gray-300 truncate font-mono",children:x.request.url}),e.jsx("p",{className:"text-sm text-gray-600",children:pt(x.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:`text-sm font-medium ${Ls(x.response.status)}`,children:x.response.status}),e.jsxs("span",{className:"text-sm text-gray-600",children:[x.response.duration,"ms"]})]})]},x.id))})]})}const Hs={GET:"bg-emerald-500/15 text-emerald-400",POST:"bg-blue-500/15 text-blue-400",PUT:"bg-amber-500/15 text-amber-400",PATCH:"bg-brand-500/15 text-brand-400",DELETE:"bg-red-500/15 text-red-400",HEAD:"bg-purple-500/15 text-purple-400",OPTIONS:"bg-gray-500/15 text-gray-400"};function Us({collection:t,currentRequest:a,lastResponse:s,subscribe:l,send:m,onClose:x}){const[n,h]=c.useState("selection"),[o,u]=c.useState(new Set),[p,i]=c.useState(new Set),[k,y]=c.useState(""),[v,C]=c.useState({requestId:null,content:"",status:"idle",toolEvents:[],pendingPermission:null}),[M,H]=c.useState([]),R=c.useRef(null),{toast:N}=Ve();c.useEffect(()=>{a&&u(new Set([a.id]))},[]),c.useEffect(()=>{const g=new Set(t.folders.map(T=>T.id));i(g)},[t]);const q=c.useCallback(g=>{const T=g.requestId;if(T){if(g.type==="ai-fix-file-diff"){H(E=>{const D=E.findIndex(B=>B.filePath===g.filePath),P={filePath:g.filePath,diffType:g.diffType,diff:g.diff,linesAdded:g.linesAdded,linesRemoved:g.linesRemoved,timestamp:Date.now()};if(D>=0){const B=[...E];return B[D]=P,B}return[...E,P]});return}C(E=>{if(!E.requestId||E.requestId!==T)return E;if(g.type==="ai-fix-stream")return{...E,content:E.content+g.content,status:"streaming"};if(g.type==="ai-fix-status")return{...E,statusMessage:g.message};if(g.type==="ai-fix-tool"){const D=g.phase,P=g.toolName,B=g.args;if(D==="complete"||D==="error"||D==="denied"){const fe=E.toolEvents.map(se=>se.toolName===P&&se.phase==="start"?{...se,phase:D,result:g.result,error:g.error}:se);return{...E,toolEvents:fe}}const G={id:`${Date.now()}-${E.toolEvents.length}`,phase:"start",toolName:P,args:B,timestamp:Date.now()};return{...E,toolEvents:[...E.toolEvents,G]}}return g.type==="ai-fix-permission"?{...E,pendingPermission:{permissionId:g.permissionId,toolName:g.toolName,args:g.args}}:g.type==="ai-fix-done"?{...E,status:"done",statusMessage:void 0,pendingPermission:null}:g.type==="ai-fix-error"?{...E,status:"error",error:g.message,pendingPermission:null}:E})}},[]);c.useEffect(()=>l(q),[l,q]),c.useEffect(()=>{R.current&&(R.current.scrollTop=R.current.scrollHeight)},[v.content,v.toolEvents]);const J=g=>{u(T=>{const E=new Set(T);return E.has(g)?E.delete(g):E.add(g),E})},Q=g=>{const T=g.map(D=>D.id),E=T.every(D=>o.has(D));u(D=>{const P=new Set(D);for(const B of T)E?P.delete(B):P.add(B);return P})},r=g=>{i(T=>{const E=new Set(T);return E.has(g)?E.delete(g):E.add(g),E})},z=()=>u(new Set(Ms(t))),j=()=>u(new Set),U=o.size,L=async()=>{const g=Bs(t,o);if(g.length===0)return;const T=`api-gen-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;h("streaming"),C({requestId:T,content:"",status:"streaming",toolEvents:[],pendingPermission:null}),H([]);const E=[];if(s&&a&&o.has(a.id))for(const D of g)D.id===a.id&&E.push(s);try{await It({requestId:T,apiRequests:g,responses:E.length>0?E:void 0,testName:k||void 0})}catch(D){C(P=>({...P,status:"error",error:String(D)})),N("error",`Failed to start generation: ${D}`)}},X=(g,T,E)=>{m({type:"ai-fix-permission-response",permissionId:g,granted:T,remember:E||!1}),C(D=>({...D,pendingPermission:null}))},I=()=>{h("selection"),C({requestId:null,content:"",status:"idle",toolEvents:[],pendingPermission:null}),H([])},ie=v.status==="streaming",te=v.status==="done",oe=v.status==="error",O=es(v.content),ae=(()=>{if(!te||!v.content)return null;const g=v.content.search(/###\s*Final\s*Result/i);if(g>=0){const T=v.content.slice(g);if(/\*\*Status:\*\*\s*PASS/i.test(T))return"pass";if(/\*\*Status:\*\*\s*FAIL/i.test(T))return"fail";if(/pass(ed)?/i.test(T)&&!/fail/i.test(T))return"pass";if(/fail/i.test(T))return"fail"}return(O==null?void 0:O.status)==="pass"?"pass":null})();return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"w-[800px] max-h-[90vh] bg-surface-1 rounded-xl border border-white/10 flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{size:16,className:"text-purple-400"}),e.jsx("h2",{className:"text-sm font-bold text-gray-200",children:"Generate API Test"}),n==="streaming"&&ie&&!O&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-purple-400 ml-2",children:[e.jsx(De,{size:13,className:"animate-spin"}),v.statusMessage||(v.toolEvents.length>0?`Working... (${v.toolEvents.filter(g=>g.phase==="complete"||g.phase==="error").length}/${v.toolEvents.filter(g=>g.phase==="start").length} tools)`:"Scanning project...")]}),n==="streaming"&&ie&&O&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-emerald-400 ml-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),"Attempt ",O.current," of ",O.total,O.status==="pass"?" — passed!":O.status==="fail"?" — retrying...":" — running..."]}),n==="streaming"&&te&&ae==="pass"&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-emerald-400 ml-2",children:[e.jsx(pe,{size:14})," Test Created & Passed"]}),n==="streaming"&&te&&ae==="fail"&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-400 ml-2",children:[e.jsx(he,{size:14})," Needs Manual Fix"]}),n==="streaming"&&te&&ae===null&&e.jsx("span",{className:"text-sm text-gray-400 ml-2",children:"Complete"}),n==="streaming"&&oe&&e.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-400 ml-2",children:[e.jsx(Be,{size:14})," Error"]})]}),e.jsx("button",{onClick:x,className:"text-gray-500 hover:text-gray-300 p-1",children:e.jsx(ge,{size:16})})]}),n==="selection"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 overflow-auto p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-gray-400",children:"Select endpoints and scenarios to include in the test:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:z,className:"text-sm text-brand-400 hover:text-brand-300",children:"Select All"}),e.jsx("span",{className:"text-gray-700",children:"|"}),e.jsx("button",{onClick:j,className:"text-sm text-gray-500 hover:text-gray-300",children:"Select None"})]})]}),e.jsxs("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[40vh] overflow-y-auto",children:[t.requests.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-white/5",children:[e.jsx("span",{className:"text-sm text-gray-400 font-medium",children:"Root Requests"}),e.jsxs("span",{className:"text-sm text-gray-600 ml-auto",children:[t.requests.filter(g=>o.has(g.id)).length,"/",t.requests.length]})]}),t.requests.map(g=>e.jsx(it,{request:g,selected:o.has(g.id),onToggle:()=>J(g.id)},g.id))]}),t.folders.map(g=>{const T=g.name.startsWith("[AI]"),E=p.has(g.id),D=g.requests.filter(G=>o.has(G.id)).length,P=g.requests.length>0&&D===g.requests.length,B=D>0&&!P;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 border-b border-white/5 ${T?"bg-purple-500/5":"bg-surface-2"}`,children:[e.jsx("button",{onClick:()=>r(g.id),className:"text-gray-500 hover:text-gray-300 p-0.5",children:E?e.jsx(ce,{size:13}):e.jsx(me,{size:13})}),e.jsx("input",{type:"checkbox",checked:P,ref:G=>{G&&(G.indeterminate=B)},onChange:()=>Q(g.requests),className:"w-3.5 h-3.5 rounded border-gray-600 bg-surface-2 accent-brand-500"}),T?e.jsx(Se,{size:13,className:"text-purple-400"}):e.jsx(Fe,{size:13,className:"text-amber-500/60"}),e.jsx("span",{className:`text-sm font-medium ${T?"text-purple-300":"text-gray-300"}`,children:g.name}),T&&e.jsx("span",{className:"text-sm px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-400 uppercase tracking-wider font-bold",children:"AI"}),e.jsxs("span",{className:"text-sm text-gray-600 ml-auto",children:[D,"/",g.requests.length]})]}),E&&g.requests.map(G=>e.jsx(it,{request:G,selected:o.has(G.id),onToggle:()=>J(G.id)},G.id))]},g.id)}),t.requests.length===0&&t.folders.length===0&&e.jsx("div",{className:"py-8 text-center text-sm text-gray-600",children:"No endpoints in this collection"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm uppercase text-gray-500 font-medium mb-1 block",children:"Test name (optional)"}),e.jsx("input",{type:"text",value:k,onChange:g=>y(g.target.value),placeholder:"e.g., Pet Store API CRUD tests",className:"w-full px-3 py-1.5 text-sm bg-surface-2 border border-white/5 rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50"})]}),e.jsx("p",{className:"text-sm text-gray-500",children:"AI will scan your project, discover your test framework, generate framework-native API test code, run it, and self-heal if tests fail. Permission will be requested before creating or editing files."})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-white/5 flex-shrink-0",children:[e.jsxs("span",{className:"text-sm text-gray-500",children:[U," endpoint",U!==1?"s":""," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:x,className:"px-4 py-1.5 rounded-lg text-sm text-gray-400 hover:text-gray-200 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:L,disabled:U===0,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-purple-500 text-white text-sm font-medium hover:bg-purple-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Se,{size:13})," Generate Test"]})]})]})]}),n==="streaming"&&e.jsxs("div",{ref:R,className:"flex-1 overflow-y-auto p-5 space-y-3",children:[O&&e.jsxs("div",{className:"mb-1",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 font-medium uppercase tracking-wider",children:"Test Verification Progress"}),e.jsx("span",{className:"text-sm text-gray-600",children:O.status==="pass"?"✓ Passed":O.status==="fail"&&te?"✗ All attempts exhausted":`Attempt ${O.current} of ${O.total}`})]}),e.jsx("div",{className:"flex gap-1",children:Array.from({length:O.total},(g,T)=>{const E=T+1;let D="bg-gray-700";return E<O.current&&(D="bg-red-500/50"),E===O.current&&O.status==="running"&&(D="bg-amber-500 animate-pulse"),E===O.current&&O.status==="pass"&&(D="bg-emerald-500"),E===O.current&&O.status==="fail"&&ie&&(D="bg-red-500 animate-pulse"),E===O.current&&O.status==="fail"&&te&&(D="bg-red-500"),e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-0.5",children:[e.jsx("div",{className:`h-2 w-full rounded-full ${D} transition-colors`}),e.jsx("span",{className:"text-sm text-gray-600",children:E})]},T)})})]}),v.pendingPermission&&e.jsx(ts,{permission:v.pendingPermission,onRespond:X}),e.jsx(ss,{state:v,panelRef:R,label:"API Test Generation",icon:e.jsx(Se,{size:14}),emptyMessage:"Scanning project structure and analyzing existing tests..."}),M.length>0&&e.jsx(as,{diffs:M}),te&&ae==="pass"&&e.jsxs("div",{className:"mt-3 rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-emerald-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx(pe,{size:22,className:"text-emerald-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-emerald-300",children:"API Test Created & Verified!"}),e.jsxs("p",{className:"text-sm text-gray-400 mt-0.5",children:[O&&O.current>1?`The AI created the test and self-healed in ${O.current} attempts.`:"The new API test was created and passed on the first run."," ",'Check the "Final Result" section above for details.']})]})]}),te&&ae==="fail"&&e.jsxs("div",{className:"mt-3 rounded-lg border border-red-500/30 bg-red-500/5 p-4 flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center flex-shrink-0",children:e.jsx(he,{size:22,className:"text-red-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-red-300",children:"Test Created — Needs Manual Fix"}),e.jsx("p",{className:"text-sm text-gray-400 mt-0.5",children:"The AI created the test files but couldn't get them to pass after all attempts. Check the output above for details on what was tried."})]})]}),oe&&e.jsxs("div",{className:"mt-3 rounded-lg border border-red-500/30 bg-red-500/5 p-3 flex items-center gap-2",children:[e.jsx(Be,{size:14,className:"text-red-400 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-red-300",children:v.error||"An error occurred during generation."})]}),(te||oe)&&e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:I,className:"px-3 py-1.5 rounded-lg bg-surface-2 text-gray-400 text-sm hover:bg-surface-3 hover:text-gray-300 transition-colors",children:"Back to Selection"}),e.jsx("button",{onClick:x,className:"px-4 py-1.5 rounded-lg bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 transition-colors",children:"Close"})]})]})]})})}function it({request:t,selected:a,onToggle:s}){return e.jsxs("label",{className:"flex items-center gap-2 px-4 py-1.5 hover:bg-white/5 cursor-pointer border-b border-white/[2%]",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:s,className:"w-3.5 h-3.5 rounded border-gray-600 bg-surface-2 accent-brand-500"}),e.jsx("span",{className:`text-sm font-bold px-1.5 py-0.5 rounded ${Hs[t.method]||"bg-gray-500/15 text-gray-400"}`,children:t.method}),e.jsx("span",{className:"text-sm text-gray-400 font-mono truncate flex-1",children:t.url||"(no URL)"}),t.name&&t.name!==t.url&&e.jsx("span",{className:"text-sm text-gray-600 truncate max-w-[180px]",children:t.name})]})}function Ms(t){const a=t.requests.map(s=>s.id);for(const s of t.folders)for(const l of s.requests)a.push(l.id);return a}function Bs(t,a){const s=[];for(const l of t.requests)a.has(l.id)&&s.push(l);for(const l of t.folders)for(const m of l.requests)a.has(m.id)&&s.push(m);return s}function qe(t){if(typeof t.passed=="boolean")return t.passed;const a=t.response.status;return a>=200&&a<300&&!(t.response.validationResults??[]).some(s=>!s.passed)}const Ue={GET:"text-emerald-400",POST:"text-blue-400",PUT:"text-amber-400",PATCH:"text-brand-400",DELETE:"text-red-400",HEAD:"text-purple-400",OPTIONS:"text-gray-400"};function _s(t){return t>=200&&t<300?"text-emerald-400 bg-emerald-400/10":t>=300&&t<400?"text-blue-400 bg-blue-400/10":t>=400&&t<500?"text-amber-400 bg-amber-400/10":t>=500?"text-red-400 bg-red-400/10":"text-gray-400 bg-gray-400/10"}function Ks({folder:t,variables:a={},onClose:s}){const{monacoTheme:l}=Ge(),[m,x]=c.useState(!1),[n,h]=c.useState([]),[o,u]=c.useState(null),[p,i]=c.useState(!1),[k,y]=c.useState({}),v=t.requests,C=async()=>{if(v.length!==0){x(!0),h([]),u(null),y({});try{const N=await Tt(v,a),q=N.steps||(N.responses||[]).map((Q,r)=>({index:r,request:v[r],response:Q,extractedVars:{}}));h(q);const J={...a};for(const Q of q)Object.assign(J,Q.extractedVars);y(J)}catch(N){h([{index:0,request:v[0],response:{requestId:v[0].id,status:0,statusText:"Error",headers:{},body:String(N),duration:0,size:0,timestamp:new Date().toISOString()},extractedVars:{},error:String(N)}])}finally{x(!1)}}},M=n.filter(qe).length,H=n.filter(N=>!qe(N)&&!N.skipped).length,R=n.reduce((N,q)=>N+q.response.duration,0);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-[700px] max-h-[85vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{size:16,className:"text-brand-400"}),e.jsx("h2",{className:"text-sm font-bold text-gray-100",children:"Chain Runner"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.name," (",v.length," request",v.length!==1?"s":"",")"]})]}),e.jsx("button",{onClick:s,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors",children:e.jsx(ge,{size:16})})]}),e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-white/5",children:[e.jsx("button",{onClick:C,disabled:m||v.length===0,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:m?e.jsxs(e.Fragment,{children:[e.jsx(De,{size:14,className:"animate-spin"})," Running..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{size:14})," Run Chain"]})}),n.length>0&&e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(pe,{size:14,className:"text-emerald-400"}),M," passed"]}),H>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{size:14,className:"text-red-400"}),H," failed"]}),e.jsx("span",{className:"text-gray-600",children:"|"}),e.jsxs("span",{children:[R,"ms total"]})]}),e.jsx("div",{className:"ml-auto",children:e.jsxs("button",{onClick:()=>i(!p),className:`flex items-center gap-1 px-2 py-1 rounded text-sm transition-colors ${p?"bg-brand-500/15 text-brand-300":"bg-surface-2 text-gray-500 hover:text-gray-300"}`,children:[e.jsx(Oe,{size:13})," Variables"]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-1.5",children:[n.length===0&&!m&&e.jsx("div",{className:"space-y-1",children:v.map((N,q)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-surface-2 border border-white/5",children:[e.jsxs("span",{className:"text-sm text-gray-600 w-5 text-right",children:[q+1,"."]}),e.jsx("span",{className:`text-sm font-bold w-12 ${Ue[N.method]||"text-gray-400"}`,children:N.method}),e.jsx("span",{className:"text-sm text-gray-300 truncate flex-1",children:N.name||N.url}),q<v.length-1&&e.jsx(xt,{size:13,className:"text-gray-600 flex-shrink-0"})]},N.id))}),m&&n.length<v.length&&e.jsx("div",{className:"space-y-1",children:v.map((N,q)=>{const J=n[q],Q=q===n.length,r=q>n.length;return e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg border ${J?"bg-surface-2 border-white/5":Q?"bg-brand-500/5 border-brand-500/20":"bg-surface-2 border-white/5 opacity-50"}`,children:[e.jsxs("span",{className:"text-sm text-gray-600 w-5 text-right",children:[q+1,"."]}),J?qe(J)?e.jsx(pe,{size:13,className:"text-emerald-400 flex-shrink-0"}):e.jsx(he,{size:13,className:"text-red-400 flex-shrink-0"}):Q?e.jsx(De,{size:13,className:"text-brand-400 animate-spin flex-shrink-0"}):e.jsx("div",{className:"w-3.5 h-3.5 rounded-full border border-gray-600 flex-shrink-0"}),e.jsx("span",{className:`text-sm font-bold w-12 ${Ue[N.method]||"text-gray-400"}`,children:N.method}),e.jsx("span",{className:`text-sm truncate flex-1 ${r?"text-gray-600":"text-gray-300"}`,children:N.name||N.url}),J&&e.jsxs("span",{className:"text-sm text-gray-500",children:[J.response.duration,"ms"]})]},N.id)})}),!m&&n.length>0&&e.jsx("div",{className:"space-y-1",children:n.map(N=>e.jsxs("div",{className:"rounded-lg border border-white/5 overflow-hidden",children:[e.jsxs("button",{onClick:()=>u(o===N.index?null:N.index),className:"w-full flex items-center gap-2 px-3 py-2 bg-surface-2 hover:bg-surface-3 transition-colors text-left",children:[o===N.index?e.jsx(ce,{size:14,className:"text-gray-500 flex-shrink-0"}):e.jsx(me,{size:14,className:"text-gray-500 flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-gray-600 w-5 text-right",children:[N.index+1,"."]}),qe(N)?e.jsx(pe,{size:13,className:"text-emerald-400 flex-shrink-0"}):e.jsx(he,{size:13,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`text-sm font-bold w-12 ${Ue[N.request.method]||"text-gray-400"}`,children:N.request.method}),e.jsx("span",{className:"text-sm text-gray-300 truncate flex-1",children:N.request.name||N.request.url}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-sm font-mono ${_s(N.response.status)}`,children:N.response.status||"ERR"}),e.jsxs("span",{className:"text-sm text-gray-500 w-14 text-right",children:[N.response.duration,"ms"]})]}),o===N.index&&e.jsx(Js,{step:N,monacoTheme:l,variables:k})]},N.index))})]}),p&&e.jsxs("div",{className:"border-t border-white/5 px-5 py-3 max-h-40 overflow-y-auto",children:[e.jsx("h3",{className:"text-sm text-gray-500 uppercase tracking-wider mb-2",children:"Runtime Variables"}),Object.keys(k).length===0&&Object.keys(a).length===0?e.jsx("p",{className:"text-sm text-gray-600 italic",children:"No variables set"}):e.jsx("div",{className:"space-y-0.5",children:Object.entries({...a,...k}).map(([N,q])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-brand-300 font-mono w-32 truncate",children:`{{${N}}}`}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 font-mono truncate flex-1",children:q}),k[N]&&!a[N]&&e.jsx("span",{className:"text-sm px-1 py-0.5 rounded bg-amber-500/15 text-amber-400",children:"extracted"})]},N))})]})]})})}function ot({text:t}){const[a,s]=c.useState(!1);return e.jsx("button",{onClick:()=>{navigator.clipboard.writeText(t).catch(()=>{}),s(!0),setTimeout(()=>s(!1),1500)},className:`flex items-center gap-1 px-2 py-0.5 rounded text-sm transition-colors ${a?"text-emerald-400 bg-emerald-500/10":"text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10"}`,title:a?"Copied!":"Copy",children:a?e.jsxs(e.Fragment,{children:[e.jsx(Je,{size:12})," Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{size:12})," Copy"]})})}function Js({step:t,monacoTheme:a,variables:s}){var Q,r,z;const[l,m]=c.useState(!1),[x,n]=c.useState(!1),h=t.request,o=t.response,u=o.status>=200&&o.status<400,p=h.url.replace(/\{\{(\w+)\}\}/g,(j,U)=>s[U]??`{{${U}}}`),i=p!==h.url,k=((Q=h.body)==null?void 0:Q.type)!=="none"&&((r=h.body)==null?void 0:r.raw),y=k?(()=>{try{return JSON.stringify(JSON.parse(h.body.raw),null,2)}catch{return h.body.raw}})():"",v=k&&(()=>{try{return JSON.parse(h.body.raw),!0}catch{return!1}})(),C=Qs(o.body),M=(()=>{try{return JSON.parse(o.body),!0}catch{return!1}})(),H=C.split(`
|
|
16
|
+
`).length,R=Math.min(Math.max(H*18,50),220),N={GET:"text-emerald-400 bg-emerald-500/15",POST:"text-blue-400 bg-blue-500/15",PUT:"text-amber-400 bg-amber-500/15",PATCH:"text-brand-400 bg-brand-500/15",DELETE:"text-red-400 bg-red-500/15"},q=(j,U)=>{const L=new Blob([j],{type:"application/json"}),X=URL.createObjectURL(L),I=document.createElement("a");I.href=X,I.download=U,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(X)},J=h.validations||[];return e.jsxs("div",{className:"border-t border-white/5 bg-surface-1",children:[t.error&&e.jsx("div",{className:"mx-4 mt-3 px-3 py-2 rounded-lg bg-red-500/10 border border-red-500/20 text-sm text-red-300",children:t.error}),e.jsxs("div",{className:"px-4 py-3 border-b border-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ee,{size:13,className:"text-gray-500"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded text-sm font-bold ${N[h.method]||"text-gray-400 bg-gray-500/15"}`,children:h.method}),e.jsx("span",{className:"text-sm font-mono text-gray-300 break-all",children:h.url})]}),h.name&&e.jsx("div",{className:"text-sm text-gray-500 ml-5",children:h.name}),i&&e.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-5",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"Resolved:"}),e.jsx("span",{className:"text-sm font-mono break-all",style:{color:"#d39034cc"},children:p})]})]}),((z=h.headers)==null?void 0:z.filter(j=>j.enabled).length)>0&&e.jsxs("div",{className:"border-b border-white/[0.03]",children:[e.jsxs("button",{onClick:()=>n(!x),className:"w-full flex items-center gap-1.5 px-4 py-2 text-sm text-gray-500 hover:text-gray-300 hover:bg-white/[0.02] transition-colors",children:[x?e.jsx(ce,{size:12}):e.jsx(me,{size:12}),e.jsx("span",{className:"font-medium",children:"Request Headers"}),e.jsxs("span",{className:"text-gray-600",children:["(",h.headers.filter(j=>j.enabled).length,")"]})]}),x&&e.jsx("div",{className:"px-4 pb-2 space-y-0.5",children:h.headers.filter(j=>j.enabled).map((j,U)=>e.jsxs("div",{className:"flex gap-2 text-sm font-mono",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 font-medium flex-shrink-0",children:[j.key,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:j.value})]},U))})]}),k&&e.jsxs("div",{className:"border-b border-white/[0.03]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 font-medium",children:"Request Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ot,{text:y}),v&&e.jsxs("button",{onClick:()=>q(y,`step-${t.index+1}-request-${Date.now()}.json`),className:"flex items-center gap-1 px-2 py-0.5 rounded text-sm text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",title:"Download as JSON",children:[e.jsx(Le,{size:12})," Download"]})]})]}),e.jsx("pre",{className:"px-4 pb-2 text-sm font-mono text-orange-700 dark:text-orange-300/70 whitespace-pre-wrap break-words max-h-[150px] overflow-auto",children:y})]}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-white/[0.03]",children:[e.jsx("span",{className:"text-sm text-gray-500 font-medium",children:"Response"}),e.jsxs("span",{className:`px-2 py-0.5 rounded-lg text-sm font-bold ${u?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400"}`,children:[o.status," ",o.statusText]}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto text-sm text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(He,{size:12})," ",o.duration,"ms"]}),e.jsx("span",{children:o.size>0?o.size<1024?`${o.size}B`:`${(o.size/1024).toFixed(1)}KB`:""})]})]}),Object.keys(o.headers).length>0&&e.jsxs("div",{className:"border-b border-white/[0.03]",children:[e.jsxs("button",{onClick:()=>m(!l),className:"w-full flex items-center gap-1.5 px-4 py-2 text-sm text-gray-500 hover:text-gray-300 hover:bg-white/[0.02] transition-colors",children:[l?e.jsx(ce,{size:12}):e.jsx(me,{size:12}),e.jsx("span",{className:"font-medium",children:"Response Headers"}),e.jsxs("span",{className:"text-gray-600",children:["(",Object.keys(o.headers).length,")"]})]}),l&&e.jsx("div",{className:"px-4 pb-2 space-y-0.5",children:Object.entries(o.headers).map(([j,U])=>e.jsxs("div",{className:"flex gap-2 text-sm font-mono",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400 font-medium flex-shrink-0",children:[j,":"]}),e.jsx("span",{className:"text-gray-400 break-all",children:String(U)})]},j))})]}),o.validationResults&&o.validationResults.length>0&&e.jsxs("div",{className:"px-4 py-2 border-b border-white/[0.03]",children:[e.jsx("span",{className:"text-sm text-gray-500 font-medium",children:"Validations"}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:o.validationResults.map((j,U)=>{const L=J.find(X=>X.id===j.ruleId);return e.jsxs("div",{className:"rounded-lg border border-white/[0.03] px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[j.passed?e.jsx(pe,{size:14,className:"text-emerald-400 flex-shrink-0"}):e.jsx(he,{size:14,className:"text-red-400 flex-shrink-0"}),e.jsx("span",{className:`font-medium ${j.passed?"text-emerald-400":"text-red-400"}`,children:j.passed?"Passed":"Failed"}),L&&e.jsxs("span",{className:"text-gray-500 ml-1",children:["— ",L.type,L.target?` (${L.target})`:""]})]}),L&&e.jsxs("div",{className:"mt-1 ml-5 space-y-0.5 text-sm",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-600 w-16 flex-shrink-0",children:"Rule:"}),e.jsxs("span",{className:"text-gray-400 font-mono",children:[L.type," ",L.target||""," ",L.operator," ",L.expected]})]}),j.actual!==void 0&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-600 w-16 flex-shrink-0",children:"Actual:"}),e.jsx("span",{className:`font-mono ${j.passed?"text-gray-300":"text-red-300"}`,children:j.actual})]}),j.message&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"text-gray-600 w-16 flex-shrink-0",children:"Message:"}),e.jsx("span",{className:"text-gray-400",children:j.message})]})]})]},U)})})]}),Object.keys(t.extractedVars).length>0&&e.jsxs("div",{className:"px-4 py-2 bg-cyan-500/5 border-b border-white/[0.03]",children:[e.jsx("span",{className:"text-sm text-cyan-400 font-medium",children:"Extracted Variables"}),e.jsx("div",{className:"mt-1 space-y-0.5",children:Object.entries(t.extractedVars).map(([j,U])=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-brand-300 font-mono",children:`{{${j}}}`}),e.jsx("span",{className:"text-gray-600",children:"="}),e.jsx("span",{className:"text-gray-300 font-mono truncate",children:U})]},j))})]}),o.body&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5",children:[e.jsx("span",{className:"text-sm text-gray-500 font-medium",children:"Response Body"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ot,{text:C}),M&&e.jsxs("button",{onClick:()=>q(C,`step-${t.index+1}-response-${Date.now()}.json`),className:"flex items-center gap-1 px-2 py-0.5 rounded text-sm text-gray-600 hover:text-cyan-400 hover:bg-cyan-500/10 transition-colors",title:"Download as JSON",children:[e.jsx(Le,{size:12})," Download"]})]})]}),M?e.jsx("div",{style:{height:`${R}px`},children:e.jsx(Qe,{value:C,language:"json",theme:a,options:{readOnly:!0,minimap:{enabled:!1},fontSize:13,lineHeight:18,scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:4,bottom:4},scrollbar:{verticalScrollbarSize:5,horizontalScrollbarSize:5},lineNumbers:"off",folding:!0,bracketPairColorization:{enabled:!0},renderLineHighlight:"none",automaticLayout:!0}})}):e.jsx("pre",{className:"px-4 pb-3 text-sm text-gray-400 font-mono bg-surface-2 rounded mx-4 mb-3 p-2 max-h-[200px] overflow-auto whitespace-pre-wrap break-all",children:C})]})]})}function Qs(t){try{const a=JSON.parse(t),s=JSON.stringify(a,null,2);return s.length>2e3?s.slice(0,2e3)+`
|
|
17
|
+
... (truncated)`:s}catch{return t.length>2e3?t.slice(0,2e3)+`
|
|
18
|
+
... (truncated)`:t}}function Gs({responseBody:t,onAddValidation:a,onClose:s}){const[l,m]=c.useState(null),[x,n]=c.useState(null),[h,o]=c.useState("equals"),[u,p]=c.useState("");let i;try{i=JSON.parse(t)}catch{i=null}const k=(v,C)=>{m(v),n(C);const M=gt(C);o(M),p(C!=null&&typeof C!="object"?String(C):"")},y=()=>{if(!l)return;const v={id:`vr-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:"body-json-path",target:l,operator:h,expected:u,enabled:!0};a(v),m(null),n(null),p("")};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-[600px] max-h-[80vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mt,{size:16,className:"text-brand-400"}),e.jsx("h3",{className:"text-sm font-bold text-gray-100",children:"Quick Validate"}),e.jsx("span",{className:"text-sm text-gray-500",children:"Click any value to create a validation"})]}),e.jsx("button",{onClick:s,className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(ge,{size:16})})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:i?e.jsx(_e,{data:i,onSelectPath:k}):e.jsx("p",{className:"text-sm text-gray-500 italic",children:"Response body is not valid JSON"})}),l&&e.jsxs("div",{className:"border-t border-white/5 px-4 py-3 bg-surface-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500 uppercase tracking-wider w-16",children:"Path"}),e.jsx("code",{className:"text-sm text-brand-300 font-mono bg-surface-1 px-2 py-0.5 rounded flex-1 truncate",children:l})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-500 uppercase tracking-wider w-16",children:"Assert"}),e.jsxs("select",{value:h,onChange:v=>o(v.target.value),className:"px-2 py-1 text-sm bg-surface-1 border border-white/5 rounded text-gray-300 focus:outline-none",children:[e.jsx("option",{value:"equals",children:"equals (=)"}),e.jsx("option",{value:"not-equals",children:"not equals (!=)"}),e.jsx("option",{value:"contains",children:"contains"}),e.jsx("option",{value:"not-contains",children:"not contains"}),e.jsx("option",{value:"greater-than",children:"greater than (>)"}),e.jsx("option",{value:"less-than",children:"less than (<)"}),e.jsx("option",{value:"exists",children:"exists"}),e.jsx("option",{value:"matches-regex",children:"regex match"})]}),h!=="exists"&&e.jsx("input",{value:u,onChange:v=>p(v.target.value),placeholder:"Expected value",className:"flex-1 px-2 py-1 text-sm font-mono bg-surface-1 border border-white/5 rounded text-gray-300 placeholder-gray-600 focus:outline-none"}),e.jsxs("button",{onClick:y,className:"flex items-center gap-1 px-3 py-1 rounded-lg bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 transition-colors",children:[e.jsx(ye,{size:14})," Add"]})]})]})]})})}function Ws(t){const a=t.match(/<SCENARIOS_JSON>([\s\S]+)<\/SCENARIOS_JSON>/i);if(a){const x=Ie(a[1].trim());if(x!=null&&x.scenarios)return x}const s=t.match(/```(?:json)?\s*\n?([\s\S]*?)```/g);if(s){const x=[...s].sort((n,h)=>h.length-n.length);for(const n of x){const h=n.replace(/```(?:json)?\s*\n?/,"").replace(/\n?```$/,"").trim(),o=Ie(h);if(o!=null&&o.scenarios)return o}}const l=Ys(t);if(l){const x=Ie(l);if(x!=null&&x.scenarios)return x}const m=Ie(t.trim());return m!=null&&m.scenarios?m:null}function Ie(t){try{return JSON.parse(t)}catch{try{const a=t.replace(/,\s*([\]}])/g,"$1");return JSON.parse(a)}catch{return null}}}function Ys(t){let a=-1,s=0;for(let l=0;l<t.length;l++)if(t[l]==="{"){let m=0,x=!1,n=!1;for(let h=l;h<t.length;h++){const o=t[h];if(n){n=!1;continue}if(o==="\\"&&x){n=!0;continue}if(o==='"'&&!n){x=!x;continue}if(!x){if(o==="{")m++;else if(o==="}"&&(m--,m===0)){const u=h-l+1;u>s&&(a=l,s=u);break}}}}return s>50?t.slice(a,a+s):null}const Te={GET:"bg-emerald-500/15 text-emerald-400",POST:"bg-blue-500/15 text-blue-400",PUT:"bg-amber-500/15 text-amber-400",PATCH:"bg-brand-500/15 text-brand-400",DELETE:"bg-red-500/15 text-red-400",HEAD:"bg-purple-500/15 text-purple-400",OPTIONS:"bg-gray-500/15 text-gray-400"};function Xs({onClose:t,existingCollections:a=[]}){const[s,l]=c.useState("upload"),[m,x]=c.useState(""),[n,h]=c.useState(""),[o,u]=c.useState(""),[p,i]=c.useState([]),[k,y]=c.useState(null),[v,C]=c.useState(!1),[M,H]=c.useState(""),[R,N]=c.useState([]),[q,J]=c.useState([]),[Q,r]=c.useState(""),[z,j]=c.useState(""),[U,L]=c.useState(!1),[X,I]=c.useState(""),[ie,te]=c.useState(new Set),oe=c.useRef(null),{toast:O}=Ve(),Ne=de(),ae=d=>{try{const $=JSON.parse(d);return $.openapi?"openapi":$.swagger?"swagger":$.info&&$.item?"postman":$.id&&$.requests?"native":"unknown"}catch{return/^\s*openapi\s*:/m.test(d)?"openapi":/^\s*swagger\s*:/m.test(d)?"swagger":"unknown"}},g=async d=>{var F;const $=(F=d.target.files)==null?void 0:F[0];if(!$)return;const S=await $.text();x(S);const K=ae(S);h(K),await T(S,K)},T=async(d,$)=>{const S=d||m;if(!S.trim()){I("Please provide spec content");return}const K=$||n||ae(S);h(K),L(!0),I("");try{const F=await Ot(S,K!=="unknown"?K:void 0);h(F.format),u(F.specName),r(F.specName),y(F.collection),j(F.collection.baseUrl||""),i(F.endpoints.map(Z=>({...Z,selected:!0}))),l("endpoints")}catch(F){I(`Failed to parse: ${F}`)}finally{L(!1)}},E=p.filter(d=>d.selected).length,D=d=>{i($=>$.map((S,K)=>K===d?{...S,selected:!S.selected}:S))},P=d=>{i($=>$.map(S=>({...S,selected:d})))},B=async()=>{l("ai-generating"),H("Analyzing API endpoints...");try{const d=p.filter(re=>re.selected),$=`import-ai-${Date.now()}`,S=await Lt({requestId:$,endpoints:d,selectedEndpoints:d,specSummary:o,existingCollections:a,baseUrl:z});H("AI is generating scenarios...");const K=window.location.protocol==="https:"?"wss:":"ws:",F=localStorage.getItem("testver_token")||"",Z=new WebSocket(`${K}//${window.location.host}/ws?token=${encodeURIComponent(F)}`);let W="";Z.onmessage=re=>{try{const ne=JSON.parse(re.data);if(ne.requestId!==$)return;if(ne.type==="ai-fix-stream"&&(W+=ne.content||"",H(`AI is generating scenarios... (${W.length} chars)`)),ne.type==="ai-fix-done"){Z.close();const f=Ws(W);f?(N(f.scenarios||[]),J(f.insights||[])):W.length>0?(console.warn("[ImportDialog] AI response could not be parsed. fullText length:",W.length),console.warn("[ImportDialog] First 500 chars:",W.slice(0,500)),console.warn("[ImportDialog] Last 500 chars:",W.slice(-500)),I("AI generated a response but could not parse scenarios JSON. Proceeding with original endpoints.")):(console.warn("[ImportDialog] AI returned empty response (fullText is empty)"),I("AI returned an empty response. Proceeding with original endpoints.")),l("preview")}ne.type==="ai-fix-error"&&(Z.close(),I(`AI generation failed: ${ne.message||ne.error||"Unknown error"}`),l("preview"))}catch{}},Z.onerror=()=>{I("WebSocket connection failed. Proceeding with original endpoints."),l("preview")},setTimeout(()=>{Z.readyState===WebSocket.OPEN&&(Z.close(),s==="ai-generating"&&(I("AI generation timed out. Proceeding with original endpoints."),l("preview")))},12e4)}catch(d){I(`AI generation failed: ${d}`),l("preview")}},G=()=>{v&&E>0?B():l("preview")},fe=()=>{if(!k)throw new Error("No parsed collection");const d={...k};d.name=Q||o||"Imported API",d.baseUrl=z;const $=new Set(p.filter(S=>S.selected).map(S=>`${S.method}:${S.path}`));if(d.requests=d.requests.filter(S=>$.has(`${S.method}:${S.url}`)||$.has(`${S.method}:${S.url.replace("{{baseUrl}}","")}`)),d.folders=d.folders.map(S=>({...S,requests:S.requests.filter(K=>$.has(`${K.method}:${K.url}`)||$.has(`${K.method}:${K.url.replace("{{baseUrl}}","")}`))})).filter(S=>S.requests.length>0),R.length>0)for(const S of R){const K={id:`fld-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:`[AI] ${S.name}`,requests:S.requests.map((F,Z)=>{let W=F.body||{type:"none"};W&&typeof W=="object"&&"content"in W&&!W.raw&&(W={...W,raw:W.content},delete W.content);let re=F.url||"";return re&&!re.startsWith("{{")&&!re.startsWith("http")&&(re=`{{baseUrl}}${re.startsWith("/")?"":"/"}${re}`),{...F,id:F.id||`req-${Date.now()}-${Math.random().toString(36).slice(2,6)}-${Z}`,name:F.name||`Step ${Z+1}`,url:re,headers:F.headers||[],queryParams:F.queryParams||[],body:W,auth:F.auth||{type:"none"},validations:(F.validations||[]).map((ne,f)=>({...ne,id:ne.id||`vr-${Date.now()}-${f}`,enabled:ne.enabled!==!1})),preRequestScript:F.preRequestScript||void 0,postResponseScript:F.postResponseScript||void 0,followRedirects:F.followRedirects!==!1,sortOrder:Z}}),sortOrder:d.folders.length};d.folders.push(K)}return z&&(d.environments=[{id:`env-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:"Dev",variables:[{key:"baseUrl",value:z,enabled:!0,secret:!1}]}]),d},se=async()=>{L(!0);try{const d=fe();if(await Ft(d),d.environments.length>0)try{localStorage.setItem(`testver-active-env-${d.id}`,d.environments[0].id)}catch{}Ne.invalidateQueries({queryKey:["api-collections"]}),O("success",`Collection "${d.name}" imported with ${d.folders.length} folders`),t()}catch(d){I(`Import failed: ${d}`)}finally{L(!1)}},ve=d=>{te($=>{const S=new Set($);return S.has(d)?S.delete(d):S.add(d),S})},ke=p.reduce((d,$,S)=>{var F;const K=$.folder||((F=$.tags)==null?void 0:F[0])||"Ungrouped";return d.has(K)||d.set(K,[]),d.get(K).push({...$,originalIndex:S}),d},new Map);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-surface-1 border border-white/10 rounded-xl w-[750px] max-h-[85vh] flex flex-col animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{size:16,className:"text-brand-400"}),e.jsx("h2",{className:"text-sm font-bold text-gray-100",children:"Import API Collection"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 text-sm text-gray-500",children:["upload","endpoints","preview","confirm"].map((d,$)=>e.jsxs("span",{className:"flex items-center gap-1",children:[$>0&&e.jsx(me,{size:13,className:"text-gray-700"}),e.jsx("span",{className:s===d?"text-brand-400 font-bold":["upload","endpoints","ai-generating","preview","confirm"].indexOf(s)>["upload","endpoints","preview","confirm"].indexOf(d)?"text-emerald-400":"",children:d==="upload"?"Upload":d==="endpoints"?"Select":d==="preview"?"Preview":"Import"})]},d))}),e.jsx("button",{onClick:t,className:"p-1 text-gray-500 hover:text-gray-300",children:e.jsx(ge,{size:16})})]})]}),X&&e.jsxs("div",{className:"px-5 py-2 bg-red-500/10 border-b border-red-500/20 flex items-center gap-2",children:[e.jsx(Be,{size:14,className:"text-red-400 flex-shrink-0"}),e.jsx("p",{className:"text-sm text-red-300 flex-1",children:X}),e.jsx("button",{onClick:()=>I(""),className:"text-red-400 hover:text-red-300",children:e.jsx(ge,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-5",children:[s==="upload"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"Upload a file (.json, .yaml)"}),e.jsx("input",{ref:oe,type:"file",accept:".json,.yaml,.yml",onChange:g,className:"hidden"}),e.jsxs("button",{onClick:()=>{var d;return(d=oe.current)==null?void 0:d.click()},className:"w-full py-8 border-2 border-dashed border-white/10 rounded-xl hover:border-brand-500/30 transition-colors flex flex-col items-center gap-2",children:[e.jsx($e,{size:24,className:"text-gray-600"}),e.jsx("span",{className:"text-sm text-gray-500",children:"Click to upload or drag & drop"}),e.jsx("span",{className:"text-sm text-gray-600",children:"Supports: OpenAPI 3.x and Swagger 2.x (JSON or YAML), Postman Collection v2.1"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 border-t border-white/5"}),e.jsx("span",{className:"text-sm text-gray-600 uppercase",children:"or paste JSON"}),e.jsx("div",{className:"flex-1 border-t border-white/5"})]}),e.jsx("textarea",{value:m,onChange:d=>{x(d.target.value),h(ae(d.target.value))},placeholder:'{"openapi": "3.0.0", ...} or {"info": {"name": "..."}, "item": [...]}',className:"w-full h-40 px-3 py-2 text-sm font-mono bg-surface-2 border border-white/5 rounded-lg text-gray-300 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 resize-y"}),n&&n!=="unknown"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{size:14,className:"text-emerald-400"}),e.jsxs("span",{className:"text-sm text-emerald-400",children:["Detected: ",n==="openapi"?"OpenAPI 3.x":n==="swagger"?"Swagger 2.x":n==="postman"?"Postman Collection":"Native Format"]})]})]}),s==="endpoints"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-bold text-gray-200",children:o}),e.jsxs("p",{className:"text-sm text-gray-500 mt-0.5",children:[E," of ",p.length," endpoints selected"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>P(!0),className:"text-sm text-brand-400 hover:text-brand-300",children:"Select All"}),e.jsx("span",{className:"text-gray-700",children:"|"}),e.jsx("button",{onClick:()=>P(!1),className:"text-sm text-gray-500 hover:text-gray-300",children:"Deselect All"})]})]}),e.jsx("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[40vh] overflow-y-auto",children:Array.from(ke.entries()).map(([d,$])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-white/5 cursor-pointer",onClick:()=>ve(d),children:[ie.has(d)||!ie.size?e.jsx(ce,{size:13,className:"text-gray-500"}):e.jsx(me,{size:13,className:"text-gray-500"}),e.jsx(Fe,{size:13,className:"text-amber-500/60"}),e.jsx("span",{className:"text-sm text-gray-400 font-medium",children:d}),e.jsxs("span",{className:"text-sm text-gray-600 ml-auto",children:[$.filter(S=>S.selected).length,"/",$.length]})]}),(ie.has(d)||!ie.size)&&$.map(S=>e.jsxs("label",{className:"flex items-center gap-2 px-4 py-1.5 hover:bg-white/5 cursor-pointer border-b border-white/[2%]",children:[e.jsx("input",{type:"checkbox",checked:S.selected,onChange:()=>D(S.originalIndex),className:"w-3.5 h-3.5 rounded border-gray-600 bg-surface-2 accent-brand-500"}),e.jsx("span",{className:`text-sm font-bold px-1.5 py-0.5 rounded ${Te[S.method]||"bg-gray-500/15 text-gray-400"}`,children:S.method}),e.jsx("span",{className:"text-sm text-gray-300 font-mono flex-1 truncate",children:S.path}),(S.summary||S.name)&&e.jsx("span",{className:"text-sm text-gray-600 truncate max-w-[200px]",children:S.summary||S.name})]},S.originalIndex))]},d))}),e.jsx("div",{className:"flex items-center gap-3 p-3 bg-purple-500/5 border border-purple-500/15 rounded-lg",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer flex-1",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:d=>C(d.target.checked),className:"w-4 h-4 rounded border-gray-600 bg-surface-2 accent-purple-500"}),e.jsx(Se,{size:14,className:"text-purple-400"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-purple-300 font-medium",children:"AI Generate Scenarios"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Let AI analyze endpoints and create meaningful test flows"})]})]})})]}),s==="ai-generating"&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-4",children:[e.jsx("div",{className:"w-12 h-12 border-2 border-purple-500 border-t-transparent rounded-full animate-spin"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-gray-200 font-medium",children:"Generating Scenarios"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:M})]})]}),s==="preview"&&e.jsxs("div",{className:"space-y-4",children:[q.length>0&&e.jsxs("div",{className:"p-3 bg-purple-500/5 border border-purple-500/15 rounded-lg",children:[e.jsx("h4",{className:"text-sm text-purple-400 uppercase tracking-wider mb-1.5",children:"AI Insights"}),e.jsx("ul",{className:"space-y-0.5",children:q.map((d,$)=>e.jsxs("li",{className:"text-sm text-gray-400 flex items-start gap-1.5",children:[e.jsx("span",{className:"text-purple-400 mt-0.5",children:"*"}),d]},$))})]}),e.jsxs("div",{className:"border border-white/5 rounded-lg overflow-hidden max-h-[45vh] overflow-y-auto",children:[k==null?void 0:k.folders.filter(d=>d.requests.length>0).map(d=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-white/5",children:[e.jsx(Fe,{size:13,className:"text-amber-500/60"}),e.jsx("span",{className:"text-sm text-gray-300 font-medium",children:d.name}),e.jsxs("span",{className:"text-sm text-gray-600 ml-auto",children:[d.requests.length," requests"]})]}),d.requests.map($=>e.jsxs("div",{className:"flex items-center gap-2 px-6 py-1 border-b border-white/[2%]",children:[e.jsx("span",{className:`text-sm font-bold px-1 py-0.5 rounded ${Te[$.method]||"bg-gray-500/15 text-gray-400"}`,children:$.method}),e.jsx("span",{className:"text-sm text-gray-400 truncate",children:$.name||$.url})]},$.id))]},d.id)),R.map((d,$)=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-purple-500/5 border-b border-purple-500/10",children:[e.jsx(Se,{size:13,className:"text-purple-400"}),e.jsxs("span",{className:"text-sm text-purple-300 font-medium",children:["[AI] ",d.name]}),e.jsxs("span",{className:"text-sm text-gray-600 ml-auto",children:[d.requests.length," steps"]})]}),e.jsx("p",{className:"px-6 py-1 text-sm text-gray-600 border-b border-white/[2%]",children:d.description}),d.requests.map((S,K)=>e.jsxs("div",{className:"flex items-center gap-2 px-6 py-1 border-b border-white/[2%]",children:[e.jsxs("span",{className:"text-sm text-gray-600 w-4 text-right",children:[K+1,"."]}),e.jsx("span",{className:`text-sm font-bold px-1 py-0.5 rounded ${Te[S.method]||"bg-gray-500/15 text-gray-400"}`,children:S.method}),e.jsx("span",{className:"text-sm text-gray-400 truncate",children:S.name||S.url})]},K))]},$)),(k==null?void 0:k.requests)&&k.requests.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-surface-2 border-b border-white/5",children:[e.jsx("span",{className:"text-sm text-gray-400 font-medium",children:"Root Requests"}),e.jsx("span",{className:"text-sm text-gray-600 ml-auto",children:k.requests.length})]}),k.requests.map(d=>e.jsxs("div",{className:"flex items-center gap-2 px-6 py-1 border-b border-white/[2%]",children:[e.jsx("span",{className:`text-sm font-bold px-1 py-0.5 rounded ${Te[d.method]||"bg-gray-500/15 text-gray-400"}`,children:d.method}),e.jsx("span",{className:"text-sm text-gray-400 truncate",children:d.name||d.url})]},d.id))]})]})]}),s==="confirm"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-500 uppercase tracking-wider",children:"Collection Name"}),e.jsx("input",{value:Q,onChange:d=>r(d.target.value),className:"w-full mt-1 px-3 py-2 text-sm bg-surface-2 border border-white/5 rounded-lg text-gray-200 focus:outline-none focus:border-brand-500/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-gray-500 uppercase tracking-wider",children:"Base URL"}),e.jsx("input",{value:z,onChange:d=>j(d.target.value),placeholder:"https://api.example.com",className:`w-full mt-1 px-3 py-2 text-sm font-mono bg-surface-2 border rounded-lg text-gray-200 placeholder-gray-600 focus:outline-none focus:border-brand-500/50 ${z&&!z.startsWith("http")?"border-amber-500/40":"border-white/5"}`}),z&&!z.startsWith("http")&&e.jsxs("p",{className:"text-sm text-amber-400 mt-1",children:["Base URL appears to be a relative path. Add the full hostname (e.g., https://petstore.swagger.io",z,")"]})]}),e.jsxs("div",{className:"p-3 bg-surface-2 rounded-lg border border-white/5 space-y-1",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-500",children:"Endpoints"}),e.jsx("span",{className:"text-gray-300",children:E})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-500",children:"Folders"}),e.jsx("span",{className:"text-gray-300",children:k?k.folders.length+R.length:0})]}),R.length>0&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-500",children:"AI Scenarios"}),e.jsx("span",{className:"text-purple-300",children:R.length})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-white/5",children:[e.jsx("button",{onClick:()=>{s==="upload"?t():s==="endpoints"?l("upload"):s==="preview"?l("endpoints"):s==="confirm"&&l("preview")},className:"px-4 py-1.5 rounded-lg text-sm text-gray-400 hover:text-gray-200 transition-colors",children:s==="upload"?"Cancel":"Back"}),e.jsxs("button",{onClick:()=>{s==="upload"?T():s==="endpoints"?G():s==="preview"?l("confirm"):s==="confirm"&&se()},disabled:U||s==="upload"&&!m.trim()||s==="endpoints"&&E===0,className:"flex items-center gap-1.5 px-4 py-1.5 rounded-lg bg-brand-500 text-white text-sm font-medium hover:bg-brand-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[U&&e.jsx(De,{size:14,className:"animate-spin"}),s==="upload"?"Parse":s==="endpoints"?v?"Generate & Preview":"Preview":s==="preview"?"Continue":"Import Collection"]})]})]})})}function Zs(t){if(!t)return null;try{return localStorage.getItem(`testver-active-env-${t}`)}catch{return null}}function ea(t,a){if(t)try{a?localStorage.setItem(`testver-active-env-${t}`,a):localStorage.removeItem(`testver-active-env-${t}`)}catch{}}function ta(){return{id:`req-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:"New Request",method:"GET",url:"",headers:[],queryParams:[],body:{type:"none"},auth:{type:"none"},validations:[],followRedirects:!0,sortOrder:0}}function ua(){var Ce;const{subscribe:t,send:a}=jt(),{data:s}=rs(),l=(s==null?void 0:s.collections)||[],[m,x]=c.useState(null),{data:n}=ns(m),[h,o]=c.useState(ta),[u,p]=c.useState(null),[i,k]=c.useState(null),[y,v]=c.useState({}),[C,M]=c.useState(null),[H,R]=c.useState(!1),[N,q]=c.useState(!1),[J,Q]=c.useState(!1),[r,z]=c.useState(null),[j,U]=c.useState(null),[L,X]=c.useState(!1),[I,ie]=c.useState(!1),te=c.useRef(null),[oe,O]=c.useState(!1),Ne=c.useRef(null),[ae,g]=c.useState(280),[T,E]=c.useState(50),[D,P]=c.useState(!1),[B,G]=c.useState(!1),fe=c.useRef(null),{toast:se}=Ve(),ve=de(),ke=cs(),d=us();c.useEffect(()=>{if(!m){M(null);return}const w=Zs(m);w&&(n!=null&&n.environments.some(_=>_.id===w))?M(w):M(null)},[m,n==null?void 0:n.environments]);const $=c.useCallback(w=>{M(w),ea(m,w)},[m]);c.useEffect(()=>{const w=_=>{Ne.current&&!Ne.current.contains(_.target)&&O(!1)};return oe&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[oe]),c.useEffect(()=>{const w=_=>{te.current&&!te.current.contains(_.target)&&ie(!1)};return I&&document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[I]);const S=c.useCallback(w=>{w.preventDefault(),P(!0);const _=w.clientX,ee=ae,le=ue=>{const Ae=Math.max(180,Math.min(450,ee+ue.clientX-_));g(Ae)},we=()=>{P(!1),document.removeEventListener("mousemove",le),document.removeEventListener("mouseup",we)};document.addEventListener("mousemove",le),document.addEventListener("mouseup",we)},[ae]),K=c.useCallback(w=>{var Ae;w.preventDefault();const _=w.clientY,ee=T,le=((Ae=fe.current)==null?void 0:Ae.offsetHeight)||600,we=bt=>{const yt=(bt.clientY-_)/le*100;E(Math.max(20,Math.min(80,ee+yt)))},ue=()=>{document.removeEventListener("mousemove",we),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",we),document.addEventListener("mouseup",ue)},[T]),F=c.useMemo(()=>{if(!n)return{};const w={};if(n.baseUrl&&(w.baseUrl=n.baseUrl),C){const _=n.environments.find(ee=>ee.id===C);if(_)for(const ee of _.variables)ee.enabled&&ee.key&&(w[ee.key]=ee.value)}return w},[n,C]),Z=c.useCallback(()=>F,[F]),W=(w,_)=>{o(w),p(w.id),U(_||null),k(null)},re=()=>{m&&ke.mutate({collectionId:m,request:h,folderId:j||void 0})},ne=async()=>{if(!h.url){se("error","Please enter a URL");return}const w=Z();d.mutate({request:h,variables:w,collectionId:m||void 0,environmentId:C||void 0},{onSuccess:_=>{const{extractedVars:ee,...le}=_;k(le),v(ee||{}),m&&ke.mutate({collectionId:m,request:h,folderId:j||void 0})},onError:_=>{se("error",`Request failed: ${_}`)}})},[f,V]=c.useState(!1),Y=w=>{o(_=>({..._,validations:[..._.validations,w]})),se("success","Validation added")},b=(w,_)=>{const ee=`set("${w}", jsonpath(response.body, "${_}"))`;o(le=>({...le,postResponseScript:le.postResponseScript?`${le.postResponseScript}
|
|
19
|
+
${ee}`:ee})),se("success",`Variable "${w}" extraction added to post-response script`)},be=async w=>{if(m)try{(n==null?void 0:n.environments.some(ee=>ee.id===w.id))?await Mt(m,w.id,w):await Bt(m,w),ve.invalidateQueries({queryKey:["api-collection",m]}),se("success","Environment saved")}catch(_){se("error",String(_))}},A=async w=>{if(m)try{await Ut(m,w),C===w&&$(null),ve.invalidateQueries({queryKey:["api-collection",m]})}catch(_){se("error",String(_))}};return e.jsxs("div",{className:"h-full flex flex-col animate-fade-in",children:[e.jsx("div",{className:"px-6 py-4 border-b border-white/5 bg-surface-1 flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>G(!B),className:"p-1.5 rounded-lg text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",title:B?"Show sidebar":"Hide sidebar",children:B?e.jsx(Yt,{size:18}):e.jsx(Xt,{size:18})}),e.jsx(dt,{size:22,className:"text-brand-400"}),e.jsx("h1",{className:"text-2xl font-bold text-gray-100",children:"API Testing"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>X(!0),className:"flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-sm bg-blue-500/15 text-blue-300 hover:bg-blue-500/25 transition-colors",children:[e.jsx($e,{size:14})," Import"]}),e.jsxs("div",{className:"relative",ref:te,children:[e.jsxs("button",{onClick:()=>ie(!I),className:"flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-sm bg-cyan-500/15 text-cyan-300 hover:bg-cyan-500/25 transition-colors",children:[e.jsx(tt,{size:14})," Export ",e.jsx(ce,{size:12,className:`transition-transform ${I?"rotate-180":""}`})]}),I&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 bg-surface-1 border border-white/10 rounded-lg z-50 py-1",style:{animation:"slideInRight 0.15s ease-out"},children:[m&&n&&e.jsxs("button",{onClick:async()=>{ie(!1);try{await Vt(m,n.name)}catch{}},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors text-left",children:[e.jsx(Le,{size:14,className:"text-cyan-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Export Collection"}),e.jsx("div",{className:"text-sm text-gray-500",children:n.name})]})]}),e.jsxs("button",{onClick:async()=>{ie(!1);try{await Ht()}catch{}},className:"w-full flex items-center gap-2.5 px-3 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors text-left",children:[e.jsx(tt,{size:14,className:"text-brand-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Export All Collections"}),e.jsx("div",{className:"text-sm text-gray-500",children:"Backup everything"})]})]})]})]}),m&&n&&e.jsxs("div",{className:"relative",ref:Ne,children:[e.jsxs("button",{onClick:()=>O(w=>!w),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-sm transition-colors ${C?"bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/25":"bg-surface-2 text-gray-400 hover:bg-surface-3 hover:text-gray-300"}`,children:[e.jsx(Ee,{size:14}),C?((Ce=n.environments.find(w=>w.id===C))==null?void 0:Ce.name)||"Environment":"No Environment",e.jsx(ce,{size:13,className:`transition-transform ${oe?"rotate-180":""}`})]}),oe&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-64 bg-surface-1 border border-white/10 rounded-lg z-50 py-1 animate-fade-in",children:[e.jsxs("button",{onClick:()=>{$(null),O(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm hover:bg-white/5 transition-colors ${C?"text-gray-500":"text-gray-200"}`,children:[e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:!C&&e.jsx(ze,{size:13,className:"text-emerald-400"})}),e.jsx(he,{size:13,className:"text-gray-600"}),"No Environment"]}),n.environments.length>0&&e.jsx("div",{className:"border-t border-white/5 my-1"}),n.environments.map(w=>e.jsxs("button",{onClick:()=>{$(w.id),O(!1)},className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm hover:bg-white/5 transition-colors ${C===w.id?"text-emerald-400":"text-gray-300"}`,children:[e.jsx("span",{className:"w-3.5 flex items-center justify-center",children:C===w.id&&e.jsx(ze,{size:13,className:"text-emerald-400"})}),e.jsx(Ee,{size:13,className:C===w.id?"text-emerald-400":"text-gray-600"}),e.jsx("span",{className:"truncate",children:w.name}),e.jsxs("span",{className:"ml-auto text-sm text-gray-600",children:[w.variables.filter(_=>_.enabled).length," vars"]})]},w.id)),e.jsx("div",{className:"border-t border-white/5 mt-1 pt-1",children:e.jsxs("button",{onClick:()=>{R(!0),O(!1)},className:"w-full flex items-center gap-2 px-3 py-1.5 text-sm text-gray-400 hover:text-gray-200 hover:bg-white/5 transition-colors",children:[e.jsx("span",{className:"w-3.5"}),e.jsx(Zt,{size:13}),"Manage Environments..."]})})]})]}),e.jsxs("button",{onClick:()=>Q(!0),disabled:!m,className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-sm transition-colors ${m?"bg-purple-500/15 text-purple-300 hover:bg-purple-500/25":"bg-surface-2 text-gray-600 cursor-not-allowed"}`,children:[e.jsx(Se,{size:14})," Generate Test"]}),e.jsxs("button",{onClick:()=>q(!N),className:`flex items-center gap-1.5 px-3.5 py-1.5 rounded-xl text-sm transition-colors ${N?"bg-brand-500/15 text-brand-300":"bg-surface-2 text-gray-400 hover:bg-surface-3 hover:text-gray-300"}`,children:[e.jsx(He,{size:14})," History"]})]})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden relative",children:[e.jsx("div",{className:`flex-shrink-0 overflow-hidden bg-surface-1 border-r border-white/5 transition-all duration-200 ${B?"w-0":""}`,style:B?{width:0}:{width:`${ae}px`},children:e.jsx(fs,{collections:l,selectedCollection:n||null,selectedRequestId:u,onSelectCollection:x,onSelectRequest:W,onImport:()=>X(!0),onRunChain:w=>z(w)})}),!B&&e.jsx("div",{className:`w-1 cursor-col-resize hover:bg-brand-500/30 transition-colors flex-shrink-0 ${D?"bg-brand-500/40":""}`,onMouseDown:S}),e.jsxs("div",{ref:fe,className:"flex-1 flex flex-col overflow-hidden bg-white dark:bg-surface-0",children:[e.jsx("div",{className:"overflow-hidden flex flex-col",style:{height:`${T}%`},children:e.jsx(Ps,{request:h,onChange:o,onSend:ne,onSave:re,onQuickValidate:i?()=>V(!0):void 0,sending:d.isPending,validationResults:i==null?void 0:i.validationResults,variables:F})}),e.jsx("div",{className:"h-1.5 cursor-row-resize hover:bg-brand-500/30 bg-white/[0.02] transition-colors flex-shrink-0 flex items-center justify-center group",onMouseDown:K,children:e.jsx("div",{className:"w-10 h-0.5 rounded-full bg-white/10 group-hover:bg-brand-500/50 transition-colors"})}),e.jsx("div",{className:"overflow-hidden flex flex-col",style:{height:`${100-T}%`},children:e.jsx(Is,{response:i,loading:d.isPending,onAddValidation:Y,onExtractVariable:b,variables:F,request:h,extractedVars:y})})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute inset-0 bg-[rgba(0,0,0,0.3)] z-40",onClick:()=>q(!1)}),e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-[400px] bg-surface-1 border-l border-white/10 z-50 shadow-2xl",style:{animation:"slideInRight 0.2s ease-out"},children:e.jsx(Vs,{onSelectRequest:w=>{W(w),q(!1)},onClose:()=>q(!1)})})]})]}),H&&n&&e.jsx(Os,{environments:n.environments,activeEnvId:C,onSelectEnv:$,onSave:be,onDelete:A,onClose:()=>R(!1)}),J&&n&&e.jsx(Us,{collection:n,currentRequest:h,lastResponse:i,subscribe:t,send:a,onClose:()=>Q(!1)}),r&&e.jsx(Ks,{folder:r,variables:Z(),onClose:()=>z(null)}),f&&i&&e.jsx(Gs,{responseBody:i.body,onAddValidation:w=>{Y(w)},onClose:()=>V(!1)}),L&&e.jsx(Xs,{onClose:()=>X(!1),existingCollections:l.map(w=>({name:w.name,requestCount:w.requestCount}))})]})}export{ua as APITestingPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as k,j as e,L as je,d as ke,u as we}from"./vendor-react-CTbHBddL.js";import{a as Ne,u as Ce}from"./vendor-query-BrzmPFT3.js";import{dQ as ge,iz as Te,b as ze,iA as Ae,dH as Se,iB as Ie,iC as Be,iD as Le,iE as $e,eh as Me}from"./index-DtBWNlVD.js";import{u as Pe,b as se}from"./TestverCreditsRing-CUsMGEe3.js";import{t as De,T as Ee}from"./TestverCreditsDetail-cSW0SpNx.js";import{C as Re}from"./ConfirmDialog-DNU3qoAP.js";import{a3 as T,o as re,Z as ue,cR as H,r as _e,R as Ge,z as Fe,S as W,$ as pe,ba as qe,bD as Oe,ag as ye,ap as Ye,_ as z,P as He,j as We,I as Ue,dl as ae,K as ne,Q as ie,dr as Qe,V as oe,J as Ke,bE as Ze,bQ as Je,b as Ve,bA as le,G as Xe,C as ce,c as de,ab as et,ds as tt,dt as xe,e as st,cs as rt,O as at,du as nt,g as it,bx as ot,Y as lt,dv as ct}from"./vendor-icons-B0wLOBoh.js";import"./formatDate-T65-Y6Mi.js";function dt(t){if(!t)return"";const a=Math.max(0,Math.round((Date.now()-Date.parse(t))/6e4));return a<1?"just now":a<60?`${a} min ago`:`${Math.floor(a/60)} h ago`}function me(t){return t?new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}):""}function o({tone:t,children:a}){const r={ok:"bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400",off:"bg-gray-100 text-gray-600 dark:bg-white/5 dark:text-gray-400",sys:"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",team:"bg-violet-50 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300",info:"bg-sky-50 text-sky-700 dark:bg-sky-500/10 dark:text-sky-300",warn:"bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300"}[t];return e.jsx("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-semibold whitespace-nowrap ${r}`,children:a})}function P({on:t,disabled:a,busy:r,onChange:i,label:n}){return e.jsxs("button",{type:"button",role:"switch","aria-checked":t,"aria-label":n,disabled:a||r,onClick:()=>i(!t),className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${t?"bg-sky-500":"bg-gray-300 dark:bg-zinc-600"} ${a?"opacity-40 cursor-not-allowed":""}`,children:[e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?"translate-x-[18px]":"translate-x-0.5"}`}),r&&e.jsx(T,{size:10,className:"absolute -right-4 animate-spin text-gray-500 dark:text-gray-400"})]})}function D({tone:t,children:a}){const r={sky:"border-sky-200 bg-sky-50 text-sky-600 dark:border-sky-400/30 dark:bg-sky-500/10 dark:text-sky-300",violet:"border-violet-200 bg-violet-50 text-violet-600 dark:border-violet-400/30 dark:bg-violet-500/10 dark:text-violet-300",emerald:"border-emerald-200 bg-emerald-50 text-emerald-600 dark:border-emerald-400/30 dark:bg-emerald-500/10 dark:text-emerald-300"}[t];return e.jsx("span",{className:`inline-flex h-10 w-10 items-center justify-center rounded-xl border ${r}`,children:a})}function E({children:t,dashed:a,dim:r,footer:i}){return e.jsxs("div",{className:`flex flex-col rounded-2xl border ${a?"border-dashed":""} border-black/[0.06] dark:border-white/5 bg-surface-1 p-6 ${r?"opacity-60":""}`,children:[t,i&&e.jsx("div",{className:"mt-auto flex justify-end pt-4 text-sm",children:i})]})}const he="text-sky-600 dark:text-sky-300 hover:text-sky-700 dark:hover:text-sky-200 font-medium inline-flex items-center gap-1 whitespace-nowrap";function B({to:t,href:a,children:r}){return t?e.jsxs(je,{to:t,className:he,children:[r," ",e.jsx(Ye,{size:12})]}):e.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:he,children:[r," ",e.jsx(z,{size:12})]})}const L=({k:t,v:a,tone:r})=>e.jsxs("div",{className:"flex justify-between gap-3 text-sm",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:t}),e.jsx("span",{className:r??"text-gray-800 dark:text-gray-200",children:a})]});function xt(t){const[a,r]=k.useState("idle"),[i,n]=k.useState(null),l=k.useRef(null);return k.useEffect(()=>()=>{l.current&&window.clearInterval(l.current)},[]),{state:a,error:i,start:async()=>{n(null),r("waiting");const f=window.open("about:blank","_blank");try{const m=await Be();if(!f){n("Your browser blocked the popup — allow popups for this site and retry."),r("error");return}f.location.href=m.approveUrl;const p=Math.max(1500,Number(m.pollIntervalMs)||2500),j=Date.now()+5*6e4;l.current=window.setInterval(async()=>{if(Date.now()>j){l.current&&window.clearInterval(l.current),r("error"),n("The connection request expired — click Connect to try again.");return}try{const w=await Le(m.code);w.status==="connected"?(l.current&&window.clearInterval(l.current),r("idle"),t()):(w.status==="denied"||w.status==="expired"||w.status==="invalid")&&(l.current&&window.clearInterval(l.current),r("error"),n(w.status==="denied"?"The request was denied on testver.com.":"The connection request expired — click Connect to try again."))}catch{}},p)}catch(m){f==null||f.close(),r("error"),n(m instanceof Error?m.message:"Could not start the connection")}},cancel:()=>{l.current&&window.clearInterval(l.current),r("idle")}}}function mt(){var Z,J,V,X,ee,te;const{data:t,isLoading:a,refetch:r,isFetching:i}=ge(),n=Te(),l=Ne(),v=!!(t!=null&&t.connected),{data:h,isError:f}=Pe({enabled:v});k.useEffect(()=>{v&&se(l)},[v,l]);const{toast:m}=ze(),[p,j]=k.useState(null),[w,R]=k.useState(!1),[S,$]=k.useState(null),I=xt(()=>{n(),r(),m("success","Connected to Testver — services are being set up.")}),U=async(x,M)=>{j(x),$(null);try{const F=(await Ae(x,M)).result;x==="grid"&&M&&F&&!F.connected&&$(F),n(),await r()}catch(G){m("error",G instanceof Error?G.message:"Could not update the service")}finally{j(null)}},Q=async()=>{j("takeover");try{await Se({takeover:!0}),$(null),n(),await r(),m("success","Testver Grid is now connected on this device.")}catch(x){m("error",x instanceof Error?x.message:"Take-over failed")}finally{j(null)}},be=async()=>{j("disconnect");try{await Ie(),n(),await r(),m("success","Disconnected from Testver.")}catch(x){m("error",x instanceof Error?x.message:"Disconnect failed")}finally{j(null)}};if(a||!t)return e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-16 text-sm text-gray-500 dark:text-gray-400 flex items-center gap-2",children:[e.jsx(T,{size:14,className:"animate-spin"})," Loading your Testver connections…"]});const{services:s,isSystem:u,memberOnly:c}=t,ve=!u&&(s.grid.providedBy==="system"||s.mail.providedBy==="system"),y=t.own.account,d=t.own.subject,fe=s.ai.entitled&&s.ai.credits?{connected:!0,active:s.ai.active,plan:s.ai.plan??null,paidThrough:s.ai.paidThrough,totalCredits:s.ai.credits.total,usedCredits:s.ai.credits.used,remainingCredits:s.ai.credits.remaining,cycleUsedCredits:s.ai.credits.cycleUsed,cycleAllowanceCredits:s.ai.credits.cycleAllowance}:null,N=h!=null&&h.connected&&(h.totalCredits??0)>0?h:f||h&&!h.connected?fe:null,K=t.connected&&!h&&!f,_=t.connected&&!K&&!N&&((h==null?void 0:h.active)===!1||!s.ai.entitled),b=N?De(N):null;return e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-10 space-y-5",children:[!t.connected&&e.jsxs("div",{className:"rounded-2xl border border-sky-200 dark:border-sky-500/20 bg-sky-50 dark:bg-sky-500/5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{className:"max-w-2xl",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:u?"Connect this Testver to your account":"Connect your Testver account"}),e.jsxs("p",{className:"mt-2 text-base text-gray-500 dark:text-gray-400 leading-relaxed",children:["One click on testver.com. Everything your plan includes and every add-on you hold switches on automatically — AI credits, Testver mail and Grid browsers — and you can turn any of them off here later. Your custom SMTP or vendor grids keep working as they are.",u&&" This becomes the system connection: schedules, CI gates and healing use it too."]}),t.own.invalid&&e.jsxs("p",{className:"mt-2 text-sm text-amber-300 flex items-center gap-1.5",children:[e.jsx(re,{size:14})," Your previous connection was rejected — connect again."]})]}),I.state==="waiting"?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300",children:[e.jsx(T,{size:16,className:"animate-spin text-sky-400"}),"Approve in the tab we opened… waiting.",e.jsx("button",{onClick:I.cancel,className:"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:text-gray-300 underline underline-offset-2",children:"Cancel"})]}):e.jsxs("button",{onClick:()=>void I.start(),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-semibold text-white bg-gradient-to-r from-sky-500 to-indigo-500 hover:from-sky-400 hover:to-indigo-400 transition-colors",children:[e.jsx(ue,{size:15})," Connect to Testver"]})]}),I.error&&e.jsx("p",{className:"mt-3 text-xs text-red-400",children:I.error}),e.jsx("ol",{className:"mt-5 grid gap-3 sm:grid-cols-3 text-[13px] text-gray-700 dark:text-gray-300",children:["A testver.com tab opens — sign in if you are not already.","Approve the connection for this installation.","Come back here — the services below light up on their own."].map((x,M)=>e.jsxs("li",{className:"flex items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-sky-500/15 text-[11px] font-bold text-sky-300",children:M+1}),e.jsx("span",{children:x})]},x))})]}),ve&&e.jsxs("div",{className:"flex items-start gap-2.5 rounded-xl border border-amber-200 dark:border-amber-500/25 bg-amber-50 dark:bg-amber-500/[0.07] px-4 py-3 text-sm text-amber-800 dark:text-amber-200",children:[e.jsx(H,{size:15,className:"mt-0.5 shrink-0"}),e.jsxs("span",{children:["This is a shared Testver server. The super admin's ",e.jsx("span",{className:"font-semibold",children:"system connection"})," provides"," ",[s.grid.providedBy==="system"&&"Testver Grid",s.mail.providedBy==="system"&&"Testver Mail"].filter(Boolean).join(" and ")," to everyone here — you cannot change ",s.grid.providedBy==="system"&&s.mail.providedBy==="system"?"them":"it",". Your AI credits come from your own account."]})]}),t.connected&&y&&d&&e.jsxs("div",{className:"rounded-2xl border border-sky-200 dark:border-sky-500/20 bg-sky-50 dark:bg-sky-500/5 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("span",{className:"inline-flex h-10 w-10 items-center justify-center rounded-full bg-gradient-to-br from-sky-500 to-indigo-500 text-sm font-bold text-white",children:(y.name??y.email??"?").split(/\s+/).map(x=>x[0]).join("").slice(0,2).toUpperCase()}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:["Connected as ",y.name??y.email]}),e.jsxs(o,{tone:"ok",children:[e.jsx(_e,{size:11})," ",u?"System connection":"Your account"]}),d.type==="team"&&e.jsxs(o,{tone:"team",children:[d.name??"Team"," · ",d.role]})]}),e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5",children:[y.email,y.plan?` · ${y.plan.name} plan${y.paidThrough?`, paid through ${me(y.paidThrough)}`:""}`:" · no plan",d.type==="team"&&((Z=d.owner)!=null&&Z.email)&&d.role!=="owner"?` · owner: ${d.owner.name??d.owner.email}`:"",d.type==="user"?" · individual":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>{r(),se(l)},disabled:i,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-gray-800 dark:text-gray-200 bg-surface-2 border border-black/10 dark:border-white/10 hover:bg-surface-3 disabled:opacity-50",children:[e.jsx(Ge,{size:12,className:i?"animate-spin":""})," Check all services"]}),e.jsxs("button",{onClick:()=>R(!0),disabled:p!==null,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-red-300 bg-red-500/10 border border-red-500/20 hover:bg-red-500/20 disabled:opacity-50",children:[p==="disconnect"?e.jsx(T,{size:12,className:"animate-spin"}):e.jsx(Fe,{size:12})," Disconnect"]})]})]}),e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:c?"As a team member you get the team's AI credits here. Grid, Cloud and Mail are set up once for the whole team by the owner or the platform manager, on their own Testver installation.":u?"Everything your plan includes is connected below. Switch a service off here at any time; automation (schedules, CI gates, healing) uses this connection too.":"Everything your plan includes is connected below for your own account. Switch a service off here at any time."})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs(E,{dim:!t.connected,footer:t.connected&&N?e.jsx(B,{to:"/settings?tab=llm",children:"AI settings"}):_?e.jsx(B,{href:"https://testver.com/pricing",children:"See plans"}):null,children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(D,{tone:"sky",children:e.jsx(W,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:"Testver AI"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:t.connected?(d==null?void 0:d.type)==="team"?"Team credits · your share":"Your account · frontier models, managed":"Frontier models, managed — no API keys"})]})]}),t.connected?b!=null&&b.suspended?e.jsx(o,{tone:"warn",children:"Suspended"}):b!=null&&b.seatPaused?e.jsx(o,{tone:"warn",children:"Seat paused"}):b!=null&&b.planExpired?e.jsx(o,{tone:"warn",children:"Plan expired"}):N||s.ai.entitled&&!_?e.jsx(o,{tone:"ok",children:"Active"}):e.jsx(o,{tone:"off",children:"No plan"}):e.jsx(o,{tone:"off",children:"Connects automatically"})]}),K&&e.jsxs("p",{className:"mt-3.5 text-sm text-gray-500 dark:text-gray-400 flex items-center gap-2",children:[e.jsx(T,{size:13,className:"animate-spin"})," Loading credits…"]}),t.connected&&N&&e.jsx(Ee,{data:N,formatDay:me,className:"mt-3.5"}),_&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"No Testver plan on this account."}),!t.connected&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"Your plan's credits power every AI feature the moment you connect."})]}),e.jsxs(E,{dim:!t.connected,dashed:c,footer:t.connected&&!c&&(s.grid.on||s.grid.providedBy)&&e.jsx(B,{to:"/settings?tab=connectors",children:"Grid settings"}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(D,{tone:"violet",children:e.jsx(pe,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:"Testver Grid"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:s.grid.entitled||s.grid.providedBy?`Cloud browsers · ${s.grid.limit} at once${(d==null?void 0:d.type)==="team"||s.grid.providedBy==="system"?", one pool":""}`:"Chromium, Firefox and WebKit in the cloud"})]})]}),t.connected?c?e.jsx(o,{tone:"team",children:"Managed by your team owner"}):s.grid.providedBy==="system"&&!u?e.jsx(P,{on:!0,disabled:!0,label:"Testver Grid (system)",onChange:()=>{}}):s.grid.entitled?e.jsx(P,{on:s.grid.on,busy:p==="grid",disabled:!s.grid.manageable,label:"Testver Grid",onChange:x=>void U("grid",x)}):e.jsx(o,{tone:"off",children:"Not in your plan"}):e.jsx(o,{tone:"off",children:"Add-on"})]}),t.connected&&s.grid.providedBy==="system"&&!u&&e.jsx("div",{className:"mt-3",children:e.jsx(o,{tone:"sys",children:"Provided by the system connection"})}),t.connected&&(s.grid.on||s.grid.providedBy)&&!c&&e.jsxs("div",{className:"mt-3.5 space-y-1.5",children:[e.jsx(L,{k:"Connection",v:s.grid.thisDevice?`This device · ${t.installation.deviceName}`:s.grid.connection?`${s.grid.connection.deviceName??"another device"} · ${dt(s.grid.connection.lastSeenAt)}`:"Not connected yet",tone:s.grid.thisDevice?"text-emerald-400":s.grid.connection?"text-amber-300":"text-gray-700 dark:text-gray-300"}),s.grid.providedBy==="system"&&!u&&e.jsx(L,{k:"Managed by",v:`super admin${(V=(J=t.system)==null?void 0:J.account)!=null&&V.email?` · ${t.system.account.email}`:""}`})]}),t.connected&&c&&e.jsxs("div",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:[s.grid.connection?e.jsxs("span",{className:"flex items-center gap-1.5 text-gray-700 dark:text-gray-300",children:[e.jsx(qe,{size:12})," ",((X=d==null?void 0:d.owner)==null?void 0:X.name)??"The owner"," holds the team's connection on ",s.grid.connection.deviceName??"their device","."]}):null,e.jsx("span",{className:"block mt-1",children:"Only the owner or the platform manager can connect or move it. Runs started from that installation use the team pool."})]}),S&&e.jsxs("div",{className:"mt-3 rounded-xl border border-amber-200 dark:border-amber-500/25 bg-amber-50 dark:bg-amber-500/[0.07] px-3 py-2.5 text-sm text-amber-800 dark:text-amber-200 space-y-2",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(re,{size:13,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:S.message})]}),S.code==="GRID_IN_USE"&&((ee=S.holder)==null?void 0:ee.canTakeOver)!==!1&&e.jsxs("div",{className:"flex gap-2 pl-5",children:[e.jsx("button",{onClick:()=>void Q(),disabled:p!==null,className:"px-2.5 py-1 rounded-md bg-amber-600 hover:bg-amber-500 text-white text-[11px] font-medium disabled:opacity-50",children:p==="takeover"?e.jsx(T,{size:11,className:"animate-spin"}):"Take over on this device"}),e.jsx("button",{onClick:()=>$(null),className:"px-2.5 py-1 rounded-md text-[11px] text-amber-200 hover:bg-amber-500/20",children:"Not now"})]})]}),t.connected&&!S&&s.grid.on&&s.grid.manageable&&s.grid.connection&&!s.grid.thisDevice&&!c&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>void Q(),disabled:p!==null,className:"px-2.5 py-1 rounded-md bg-amber-600 hover:bg-amber-500 text-white text-[11px] font-medium disabled:opacity-50",children:p==="takeover"?e.jsx(T,{size:11,className:"animate-spin"}):"Take over on this device"}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"allowed once that device has been idle for a few minutes"})]}),t.connected&&!s.grid.entitled&&!s.grid.providedBy&&!c&&s.grid.reason&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:s.grid.reason.message}),!t.connected&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"A prepaid add-on to a paid plan: buy parallel browsers on testver.com. Connects here unless another installation already holds your connection — then you choose whether to take it over."}),t.connected&&!c&&(s.grid.on||s.grid.providedBy)&&e.jsx("p",{className:"mt-4 text-sm text-gray-500 dark:text-gray-400",children:"Only one installation holds the connection at a time."})]}),e.jsxs(E,{dim:!t.connected,dashed:c,footer:t.connected&&!c&&(s.mail.on||s.mail.providedBy)&&e.jsx(B,{to:"/settings?tab=connectors",children:"Manage connectors"}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(D,{tone:"emerald",children:e.jsx(Oe,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:"Testver Mail"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Reports & notifications through Testver's mail server · no SMTP setup"})]})]}),t.connected?c?e.jsx(o,{tone:"team",children:"Managed by your team owner"}):s.mail.providedBy==="system"&&!u?e.jsx(P,{on:!0,disabled:!0,label:"Testver Mail (system)",onChange:()=>{}}):s.mail.entitled?e.jsx(P,{on:s.mail.on,busy:p==="mail",disabled:!s.mail.manageable,label:"Testver Mail",onChange:x=>void U("mail",x)}):e.jsx(o,{tone:"off",children:"Not in your plan"}):e.jsx(o,{tone:"off",children:"Connects automatically"})]}),t.connected&&s.mail.providedBy==="system"&&!u&&e.jsx("div",{className:"mt-3",children:e.jsx(o,{tone:"sys",children:"Provided by the system connection"})}),t.connected&&(s.mail.on||s.mail.providedBy)&&!c&&e.jsxs("div",{className:"mt-3.5 space-y-1.5",children:[e.jsx(L,{k:"Sends as",v:e.jsx("span",{className:"font-mono text-[12px]",children:s.mail.from??s.mail.fromAddress})}),e.jsx(L,{k:"Replies go to",v:e.jsx("span",{className:"font-mono text-[12px]",children:s.mail.replyTo??"—"})})]}),t.connected&&c&&e.jsxs("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:["Enabled on the team's Testver installation and sends as ",e.jsx("span",{className:"font-mono",children:s.mail.fromAddress??"tool@testver.com"}),". Your own SMTP connectors keep working here."]}),t.connected&&!s.mail.entitled&&!s.mail.providedBy&&!c&&s.mail.reason&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:s.mail.reason.message}),!t.connected&&e.jsx("p",{className:"mt-3 text-sm text-gray-500 dark:text-gray-400",children:"Included with paid plans. Becomes the default sender; no SMTP host, port or password to enter."}),t.connected&&!c&&(s.mail.on||s.mail.providedBy)&&e.jsx("div",{className:"mt-4 text-sm",children:s.mail.connectorConnected?e.jsxs(o,{tone:"info",children:[e.jsx(ye,{size:11})," Default sender for notifications & reports"]}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Connector is off"})})]}),e.jsxs(E,{dim:!t.connected,dashed:c,footer:e.jsx(B,{href:((te=s.cloud.workspace)==null?void 0:te.url)??(s.cloud.entitled?"https://testver.com/dashboard/cloud":"https://testver.com/pricing"),children:s.cloud.workspace?"Open workspace":s.cloud.entitled?"Manage on testver.com":"See plans"}),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(D,{tone:"sky",children:e.jsx(H,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:"Testver Cloud"}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Your always-on Testver · managed on testver.com"})]})]}),t.connected?c?e.jsx(o,{tone:"team",children:"Managed by your team owner"}):s.cloud.workspace?e.jsx(o,{tone:s.cloud.workspace.status==="active"?"ok":"warn",children:s.cloud.workspace.status==="active"?"Healthy":s.cloud.workspace.status}):s.cloud.entitled?e.jsx(o,{tone:"info",children:"Not created yet"}):e.jsx(o,{tone:"off",children:"Not in your plan"}):e.jsx(o,{tone:"off",children:"Shown after connecting"})]}),t.connected&&s.cloud.workspace&&e.jsx("div",{className:"mt-3.5 space-y-1.5",children:e.jsx(L,{k:"Workspace",v:e.jsxs("span",{className:"font-mono text-[12px]",children:[s.cloud.workspace.subdomain,".cloud.testver.com"]})})}),e.jsx("p",{className:"mt-4 text-sm text-gray-500 dark:text-gray-400",children:t.connected?c?"Sign in there with the workspace login.":s.cloud.workspace?"Restart, repository and backups live in your dashboard.":s.cloud.entitled?"Create it from your dashboard in about a minute.":"Testver Cloud is a prepaid add-on to a paid plan — add it from Billing → Add-ons on testver.com.":"A prepaid add-on to your plan, bought on testver.com. This page shows your workspace's health and links to the dashboard."})]})]}),e.jsx(Re,{open:w,title:"Disconnect from Testver?",description:u?"AI requests, Testver Grid and Testver mail will stop for everyone on this server until you reconnect. The connection is revoked on testver.com too.":"AI requests on your account will stop here until you reconnect, and your connection is revoked on testver.com.",confirmLabel:"Disconnect",onConfirm:()=>{R(!1),be()},onCancel:()=>R(!1)})]})}function ht({size:t=18}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 1200 1227",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M714.163 519.284 1160.89 0h-105.86L667.137 450.887 357.328 0H0l468.492 681.821L0 1226.37h105.866l409.625-476.152 327.181 476.152H1200L714.137 519.284h.026Zm-145.087 168.62-47.469-67.894L144.011 79.694h162.683l304.797 435.991 47.468 67.894 396.2 566.721h-162.68L569.076 687.929v-.025Z"})})}function gt(){const{data:t}=Ce({queryKey:["server-health-version"],queryFn:$e,staleTime:3e5,retry:1}),a=t!=null&&t.version&&t.version!=="0.0.0"?t.version:null;return e.jsxs("div",{className:"bg-surface-0 text-gray-200 animate-fade-in",children:[e.jsxs("div",{className:"relative overflow-hidden border-b border-white/5",children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -top-40 -right-40 w-[28rem] h-[28rem] rounded-full bg-blue-500/15 blur-3xl"}),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -bottom-40 -left-40 w-[28rem] h-[28rem] rounded-full bg-cyan-500/10 blur-3xl"}),e.jsxs("div",{className:"relative max-w-[1100px] mx-auto px-6 py-20 text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-3 mb-8",children:[e.jsx(Me,{className:"w-14 h-14 object-contain drop-shadow-[0_8px_20px_rgba(99,102,241,0.30)]"}),e.jsx("span",{className:"text-3xl font-bold bg-gradient-to-r from-blue-500 via-purple-500 to-emerald-500 bg-clip-text text-transparent",children:"Testver"})]}),a&&e.jsxs("div",{className:"-mt-3 mb-8 flex flex-wrap items-center justify-center gap-x-3 gap-y-2 text-sm",children:[e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-surface-2 px-3.5 py-1.5 ring-1 ring-white/10",title:"The Testver version installed on this server",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Version"}),e.jsxs("span",{className:"font-mono font-semibold text-gray-900 dark:text-gray-100","data-testid":"about-version",children:["v",a]})]}),e.jsxs("a",{href:"https://docs.testver.com/release-notes",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 font-medium text-blue-600 dark:text-blue-400 hover:underline",children:["What's new",e.jsx(ae,{size:14})]})]}),e.jsx("h1",{className:"text-4xl sm:text-5xl font-bold text-gray-100 leading-tight max-w-3xl mx-auto",children:"AI-powered test management & automation, in one workspace."}),e.jsx("p",{className:"mt-5 text-lg text-gray-500 dark:text-gray-400 max-w-2xl mx-auto leading-relaxed",children:"Plan, automate, execute, and report — across web, mobile, and API — without switching between half a dozen tools."}),e.jsxs("div",{className:"mt-9 flex flex-wrap items-center justify-center gap-3",children:[e.jsxs("a",{href:"https://testver.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-brand-500 hover:bg-brand-700 text-white text-sm font-semibold transition-colors shadow-lg shadow-brand-500/20",children:[e.jsx(ne,{size:16}),"Visit testver.com",e.jsx(z,{size:14,className:"opacity-80"})]}),e.jsxs("a",{href:"https://docs.testver.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-700 dark:text-gray-200 text-sm font-medium transition-colors ring-1 ring-white/10",children:[e.jsx(ie,{size:16}),"Documentation",e.jsx(z,{size:14,className:"opacity-60"})]}),e.jsxs("a",{href:"https://docs.testver.com/video-tutorials",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-700 dark:text-gray-200 text-sm font-medium transition-colors ring-1 ring-white/10",children:[e.jsx(Qe,{size:16}),"Video tutorials",e.jsx(z,{size:14,className:"opacity-60"})]}),e.jsxs("a",{href:"https://support.testver.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-surface-2 hover:bg-surface-3 text-gray-700 dark:text-gray-200 text-sm font-medium transition-colors ring-1 ring-white/10",children:[e.jsx(oe,{size:16}),"Support",e.jsx(z,{size:14,className:"opacity-60"})]})]})]})]}),e.jsx("div",{className:"border-b border-white/5 bg-surface-1/40",children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-14",children:[e.jsxs("div",{className:"text-center mb-9",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"One engine. Three surfaces."}),e.jsx("p",{className:"text-base text-gray-500 dark:text-gray-400 mt-2.5 max-w-2xl mx-auto leading-relaxed",children:"The same suites, runs, reporting, and AI work whether you're testing a browser, a device, or an endpoint."})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(q,{icon:e.jsx(ne,{size:22}),title:"Web Automation",desc:"Playwright, Selenium, Cypress, and more — run locally or on a cloud grid, with screenshots, video, and traces captured per test.",tint:"sky"}),e.jsx(q,{icon:e.jsx(Ke,{size:22}),title:"Mobile Automation",desc:"Appium on real devices and emulators, with live device mirroring while the test runs and native-locator recording.",tint:"emerald"}),e.jsx(q,{icon:e.jsx(Ze,{size:22}),title:"API Automation",desc:"A full REST/GraphQL workspace — collections, environments, auth profiles, schema validation, and chained requests.",tint:"violet"})]})]})}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-16",children:[e.jsxs("div",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"What's inside"}),e.jsx("p",{className:"text-base text-gray-500 dark:text-gray-400 mt-2.5 max-w-2xl mx-auto leading-relaxed",children:"The pillars covering the full QA lifecycle — from authoring a case to gating a production deploy."})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[e.jsx(g,{icon:e.jsx(W,{size:20}),title:"AI Assistant",desc:"Conversational AI that writes, refactors, and explains tests — and can drive a real browser to investigate a failure.",tint:"purple"}),e.jsx(g,{icon:e.jsx(Je,{size:20}),title:"AI Record",desc:"Click through your app once, on web or a device; Testver generates a clean, locator-stable test script.",tint:"cyan"}),e.jsx(g,{icon:e.jsx(ue,{size:20}),title:"AI Test Gen",desc:"Turn requirements, documents, JIRA tickets, or OpenAPI specs into traceable test cases in seconds.",tint:"amber"}),e.jsx(g,{icon:e.jsx(Ve,{size:20}),title:"Test Cases, Plans & Cycles",desc:"A first-class test management system — cases, plans, execution cycles, and a built-in defect tracker.",tint:"emerald"}),e.jsx(g,{icon:e.jsx(le,{size:20}),title:"Test Suites",desc:"Group any tests into a reusable suite in Test Explorer, then run them together with your own browser matrix, concurrency, and retries.",tint:"sky"}),e.jsx(g,{icon:e.jsx(Xe,{size:20}),title:"CI/CD Pipelines",desc:"GitHub Actions, GitLab, Jenkins, Azure, Bitbucket, and CircleCI trigger runs that execute here — and gate the build on the verdict.",tint:"indigo"}),e.jsx(g,{icon:e.jsx(ce,{size:20}),title:"Runs, Reports & AI Fix",desc:"Live execution, per-run artifacts, baselines and comparisons, AI failure analysis, and self-healing that repairs and re-runs a broken test.",tint:"rose"}),e.jsx(g,{icon:e.jsx(de,{size:20}),title:"Coverage & Traceability",desc:"See exactly which requirements are covered, by which cases, executed by which scripts, with which results.",tint:"blue"}),e.jsx(g,{icon:e.jsx(et,{size:20}),title:"Connectors",desc:"JIRA, Slack, MS Teams, Email, BrowserStack, LambdaTest, Sauce Labs — wired into the toolchain you already use.",tint:"teal"}),e.jsx(g,{icon:e.jsx(tt,{size:20}),title:"Agent Skills",desc:"Teach the AI your team's conventions with reusable skills — the assistant applies them whenever it writes or fixes your tests.",tint:"fuchsia"}),e.jsx(g,{icon:e.jsx(pe,{size:20}),title:"Testver Grid",desc:"Testver's own cloud browsers — Chromium, Firefox and WebKit on machines that are not yours, with no vendor account, no keys and no test-code changes. A prepaid add-on to a paid plan; connect once on Testver → Connections.",tint:"violet"}),e.jsx(g,{icon:e.jsx(H,{size:20}),title:"Testver Cloud",desc:"Your own always-on Testver at your-team.cloud.testver.com — built, patched, backed up and repaired for you, so schedules fire and the whole team shares one workspace without anyone's laptop.",tint:"sky"})]})]}),e.jsx("div",{className:"border-y border-white/5 bg-surface-1/40",children:e.jsx("div",{className:"max-w-[1100px] mx-auto px-6 py-14",children:e.jsx("div",{className:"rounded-2xl border border-violet-500/20 bg-gradient-to-br from-violet-500/[0.08] via-transparent to-cyan-500/[0.06] p-8 sm:p-10",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center gap-8",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-2.5 py-1 rounded-full bg-violet-500/12 ring-1 ring-violet-500/30 text-violet-700 dark:text-violet-300 text-xs font-semibold mb-4",children:[e.jsx(xe,{size:13}),"Testver AI Credits"]}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"AI that works out of the box — no API keys to manage."}),e.jsxs("p",{className:"mt-3 text-base text-gray-500 dark:text-gray-400 leading-relaxed max-w-2xl",children:["Connect your Testver account and every AI feature is ready immediately. Usage draws from a shared pool of ",e.jsx("strong",{className:"text-gray-700 dark:text-gray-200",children:"credits"})," on your plan — visible live in the header ring, so you always know what's left before a long run starts."]}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(C,{icon:e.jsx(W,{size:15}),title:"Zero setup",desc:"No provider accounts, no keys, no billing plumbing."}),e.jsx(C,{icon:e.jsx(ce,{size:15}),title:"Transparent usage",desc:"A live ring shows credits used and remaining at a glance."}),e.jsx(C,{icon:e.jsx(ye,{size:15}),title:"Managed by Testver",desc:"Models are chosen, tuned and kept current by Testver — nothing to pick, upgrade or maintain."})]})]}),e.jsxs("a",{href:"https://testver.com/pricing",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-brand-500 hover:bg-brand-700 text-white text-sm font-semibold transition-colors shadow-lg shadow-brand-500/20 flex-shrink-0 self-start lg:self-center",children:[e.jsx(xe,{size:16}),"View plans",e.jsx(z,{size:14,className:"opacity-80"})]})]})})})}),e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-16",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs uppercase tracking-widest text-gray-500 mb-3",children:[e.jsx(oe,{size:14,className:"text-emerald-500 dark:text-emerald-400"}),"Feedback & report issues"]}),e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-gray-100",children:"Found a bug or have an idea? Tell us on the Support portal."}),e.jsxs("p",{className:"mt-3 text-base text-gray-500 dark:text-gray-400 leading-relaxed max-w-3xl",children:["Sign in to ",e.jsx("span",{className:"text-gray-700 dark:text-gray-300 font-medium",children:"support.testver.com"})," with the same Testver account you use here and open a ticket. Every report gets a tracked ticket with its own history, so you can follow progress, add details and get a reply from the team in one place — no email threads to chase."]}),e.jsxs("div",{className:"mt-8 grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(O,{icon:e.jsx(st,{size:18}),tint:"rose",title:"Report an issue",desc:"Something failed, crashed or behaved unexpectedly — in the tool, the Grid, Cloud runs or Testver Mail."}),e.jsx(O,{icon:e.jsx(rt,{size:18}),tint:"amber",title:"Suggest a feature",desc:"A framework, integration or workflow you wish Testver supported. Ideas with a clear use case go to the top of the list."}),e.jsx(O,{icon:e.jsx(at,{size:18}),tint:"sky",title:"Ask a question",desc:"Not sure how something is meant to work? Ask — and check the docs first, most setup questions are answered there."})]}),e.jsxs("div",{className:"mt-6 rounded-2xl bg-surface-1 ring-1 ring-white/10 p-6 sm:p-7",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center gap-6",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:"What to include in a bug report"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"The more of this you attach, the faster we can reproduce and fix it."}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-3",children:[e.jsx(C,{icon:e.jsx(le,{size:15}),title:"Steps to reproduce",desc:"What you did, what you expected and what actually happened."}),e.jsx(C,{icon:e.jsx(de,{size:15}),title:"Framework and target",desc:"Playwright, Cypress, Appium… and whether it ran locally, on the Grid or in the cloud."}),e.jsx(C,{icon:e.jsx(nt,{size:15}),title:"Screenshots or a recording",desc:"A picture of the error or a short screen recording of the failure."}),e.jsx(C,{icon:e.jsx(it,{size:15}),title:"Logs and version",desc:"The run log or error text, and which Testver version and operating system you are on."})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row lg:flex-col gap-3 flex-shrink-0",children:[e.jsxs("a",{href:"https://support.testver.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-brand-500 hover:bg-brand-700 text-white text-sm font-semibold transition-colors shadow-lg shadow-brand-500/20",children:[e.jsx(ot,{size:16}),"Open the Support portal",e.jsx(z,{size:14,className:"opacity-80"})]}),e.jsxs("a",{href:"https://docs.testver.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 px-5 py-3 rounded-xl bg-surface-2 hover:bg-surface-3 ring-1 ring-white/10 text-gray-800 dark:text-gray-200 text-sm font-semibold transition-colors",children:[e.jsx(ie,{size:16}),"Check the docs first",e.jsx(ae,{size:14,className:"opacity-70"})]})]})]}),e.jsx("p",{className:"mt-5 text-xs text-gray-500 dark:text-gray-500",children:"One account for Testver, the dashboard and the Support portal — if you can sign in here, you can sign in there. Please don't paste passwords, API keys or tokens into a ticket; mask them before attaching logs."})]})]}),e.jsx("div",{children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 py-12",children:[e.jsxs("div",{className:"flex flex-col items-center gap-5",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-800 dark:text-gray-200",children:"Follow us"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1.5",children:"News, releases, and behind-the-scenes from the Testver team."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Y,{href:"https://www.youtube.com/@TestverAI",label:"YouTube",icon:e.jsx(lt,{size:18}),hoverIcon:"hover:text-[#FF0000]",hoverBg:"hover:bg-[#FF0000]/10",hoverRing:"hover:ring-[#FF0000]/40"}),e.jsx(Y,{href:"https://www.linkedin.com/company/testver-ai",label:"LinkedIn",icon:e.jsx(ct,{size:18}),hoverIcon:"hover:text-[#0A66C2]",hoverBg:"hover:bg-[#0A66C2]/10",hoverRing:"hover:ring-[#0A66C2]/40"}),e.jsx(Y,{href:"https://x.com/testverai",label:"X",icon:e.jsx(ht,{size:16}),hoverIcon:"hover:text-gray-900 dark:hover:text-white",hoverBg:"hover:bg-gray-900/10 dark:hover:bg-white/10",hoverRing:"hover:ring-gray-900/30 dark:hover:ring-white/40"})]})]}),e.jsx("div",{className:"mt-10 text-center text-xs text-gray-500",children:"© Testver. All rights reserved."})]})})]})}const A={blue:{iconBg:"bg-blue-500/15",iconColor:"text-blue-600 dark:text-blue-400",ring:"ring-blue-500/20"},purple:{iconBg:"bg-purple-500/15",iconColor:"text-purple-600 dark:text-purple-400",ring:"ring-purple-500/20"},cyan:{iconBg:"bg-cyan-500/15",iconColor:"text-cyan-600 dark:text-cyan-400",ring:"ring-cyan-500/20"},emerald:{iconBg:"bg-emerald-500/15",iconColor:"text-emerald-600 dark:text-emerald-400",ring:"ring-emerald-500/20"},amber:{iconBg:"bg-amber-500/15",iconColor:"text-amber-600 dark:text-amber-400",ring:"ring-amber-500/20"},violet:{iconBg:"bg-violet-500/15",iconColor:"text-violet-600 dark:text-violet-400",ring:"ring-violet-500/20"},rose:{iconBg:"bg-rose-500/15",iconColor:"text-rose-600 dark:text-rose-400",ring:"ring-rose-500/20"},sky:{iconBg:"bg-sky-500/15",iconColor:"text-sky-600 dark:text-sky-400",ring:"ring-sky-500/20"},indigo:{iconBg:"bg-indigo-500/15",iconColor:"text-indigo-600 dark:text-indigo-400",ring:"ring-indigo-500/20"},teal:{iconBg:"bg-teal-500/15",iconColor:"text-teal-600 dark:text-teal-400",ring:"ring-teal-500/20"},fuchsia:{iconBg:"bg-fuchsia-500/15",iconColor:"text-fuchsia-600 dark:text-fuchsia-400",ring:"ring-fuchsia-500/20"}};function q({icon:t,title:a,desc:r,tint:i}){const n=A[i]??A.brand;return e.jsxs("div",{className:"group bg-surface-1 rounded-2xl border border-white/5 p-6 hover:border-white/15 transition-colors",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl ${n.iconBg} ${n.iconColor} ring-1 ${n.ring} flex items-center justify-center mb-4`,children:t}),e.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:a}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2 leading-relaxed",children:r})]})}function g({icon:t,title:a,desc:r,tint:i}){const n=A[i]??A.brand;return e.jsxs("div",{className:"group bg-surface-1 rounded-2xl border border-white/5 p-6 hover:border-white/15 hover:bg-white/[0.02] transition-colors w-full sm:w-[calc(50%-0.5rem)] lg:w-[calc(33.333%-0.667rem)]",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl ${n.iconBg} ${n.iconColor} ring-1 ${n.ring} flex items-center justify-center mb-4`,children:t}),e.jsx("h3",{className:"text-[15px] font-semibold text-gray-900 dark:text-gray-100",children:a}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-2 leading-relaxed",children:r})]})}function O({icon:t,title:a,desc:r,tint:i}){const n=A[i]??A.blue;return e.jsxs("div",{className:"rounded-2xl bg-surface-1 ring-1 ring-white/10 p-5",children:[e.jsx("span",{className:`w-10 h-10 rounded-xl flex items-center justify-center ring-1 ${n.iconBg} ${n.iconColor} ${n.ring}`,children:t}),e.jsx("div",{className:"mt-3 text-sm font-semibold text-gray-800 dark:text-gray-200",children:a}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400 leading-relaxed",children:r})]})}function C({icon:t,title:a,desc:r}){return e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("span",{className:"mt-0.5 w-7 h-7 rounded-lg bg-surface-2 ring-1 ring-white/10 text-violet-600 dark:text-violet-300 flex items-center justify-center flex-shrink-0",children:t}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:a}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-0.5 leading-relaxed",children:r})]})]})}function Y({icon:t,label:a,href:r,hoverIcon:i,hoverBg:n,hoverRing:l}){return e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer","aria-label":a,title:a,className:["w-10 h-10 rounded-full bg-surface-1 ring-1 ring-white/10 text-gray-500 dark:text-gray-400","flex items-center justify-center transition-colors",i??"hover:text-brand-300",n??"hover:bg-white/5",l??"hover:ring-white/20"].join(" "),children:t})}function wt(){const t=ke(),a=we(),r=/\/about\/?$/.test(t.pathname)?"about":"connections",{data:i}=ge(),n=v=>{a(v==="about"?"/testver/about":"/testver",{replace:!0})},l=v=>`inline-flex items-center gap-2 px-3.5 py-3 text-sm font-medium border-b-2 transition-colors ${v?"text-gray-900 dark:text-gray-100 border-sky-400":"text-gray-500 dark:text-gray-400 border-transparent hover:text-gray-800 dark:hover:text-gray-200"}`;return e.jsxs("div",{className:"min-h-screen bg-surface-0 text-gray-200",children:[e.jsx("div",{className:"sticky top-0 z-10 bg-surface-1 border-b border-black/5 dark:border-white/5",children:e.jsxs("div",{className:"max-w-[1100px] mx-auto px-6 flex items-center gap-1",children:[e.jsxs("button",{type:"button",onClick:()=>n("connections"),className:l(r==="connections"),children:[i!=null&&i.connected?e.jsx(He,{size:15,className:"text-emerald-500"}):e.jsx(We,{size:15}),"Connections",(i==null?void 0:i.connected)&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400 shadow-[0_0_0_3px_rgba(52,211,153,0.15)]"})]}),e.jsxs("button",{type:"button",onClick:()=>n("about"),className:l(r==="about"),children:[e.jsx(Ue,{size:15}),"About"]})]})}),r==="about"?e.jsx(gt,{}):e.jsx(mt,{})]})}export{wt as AboutPage};
|