@testver/testver 1.4.2 → 1.5.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/LICENSE +88 -69
- package/README.md +6 -2
- package/bin/testver.js +9 -1
- package/dist/index.js +52650 -35771
- package/package.json +179 -178
- package/src/ui/static/agents/antigravity.svg +76 -0
- package/src/ui/static/agents/codex.svg +3 -0
- package/src/ui/static/agents/gemini.svg +1 -0
- package/src/ui/static/agents/opencode.svg +4 -0
- package/src/ui/static/agents/vscode.svg +17 -0
- package/src/ui/static/assets/AIPanel-RWO8Cd9w.js +32 -0
- package/src/ui/static/assets/AIRecordPanel-DnreS585.js +40 -0
- package/src/ui/static/assets/AIStreamUI-C1gHJtlF.js +9 -0
- package/src/ui/static/assets/{AITestGenPage-D3t2gPAA.js → AITestGenPage-C8bWUelu.js} +5 -5
- package/src/ui/static/assets/APITestingPage-DwL67hqL.js +19 -0
- package/src/ui/static/assets/AboutPage-CynLB95E.js +1 -0
- package/src/ui/static/assets/AccessTokensTab-BdevOmpE.js +1 -0
- package/src/ui/static/assets/AdvancedPage-BeM7aB8b.js +3 -0
- package/src/ui/static/assets/{AnalyticsPage-64mYNK2v.js → AnalyticsPage-C5ddYfRk.js} +1 -1
- package/src/ui/static/assets/AuditLogPage-DYcUdJoj.js +1 -0
- package/src/ui/static/assets/ChangesSummary-BjNMwGIZ.js +3 -0
- package/src/ui/static/assets/{CodeMapPage-B1ezmnlE.js → CodeMapPage-BQOEtv-R.js} +3 -3
- package/src/ui/static/assets/{ConfirmDialog-t7mpeeSN.js → ConfirmDialog-D_N9188T.js} +1 -1
- package/src/ui/static/assets/{CoveragePage-YMmCbiBk.js → CoveragePage-8bDSphY1.js} +2 -2
- package/src/ui/static/assets/{CronBuilder-Nk-K-_8I.js → CronBuilder-C7_JADb7.js} +1 -1
- package/src/ui/static/assets/{Dashboard-BDVxO2V4.js → Dashboard-B22yRPyV.js} +1 -1
- package/src/ui/static/assets/{DefectsPage-l8yGeCyR.js → DefectsPage-Arv4Ac-b.js} +72 -72
- package/src/ui/static/assets/{EmptyState-D1T3JWUr.js → EmptyState-BShNSbLf.js} +1 -1
- package/src/ui/static/assets/{ExportButton-Dt5RhL-h.js → ExportButton-xrS_AnfS.js} +1 -1
- package/src/ui/static/assets/{FileViewer-CrKgh_cB.js → FileViewer-Bcr9T1jW.js} +18 -18
- package/src/ui/static/assets/{GitPage-_4nCEzkJ.js → GitPage-DXL2Sv40.js} +12 -12
- package/src/ui/static/assets/{ImportExportPage-BcR7IQi9.js → ImportExportPage-BcjzRd7T.js} +36 -36
- package/src/ui/static/assets/{JiraPushDialog-C2sP4_4h.js → JiraPushDialog-DNYU9Ce0.js} +1 -1
- package/src/ui/static/assets/{KpiTile-inmeEsy3.js → KpiTile-BKlWqjgN.js} +1 -1
- package/src/ui/static/assets/{LiveExecutionView-D5BRe9jq.js → LiveExecutionView-1LlyEDEe.js} +1 -1
- package/src/ui/static/assets/{ManagePage-B8iG6Q0B.js → ManagePage-SvRQ6L19.js} +1 -1
- package/src/ui/static/assets/{MediaModal-C5n6sHYi.js → MediaModal-Dyy_iHl9.js} +1 -1
- package/src/ui/static/assets/MobileRunPicker-Cf5rm469.js +1 -0
- package/src/ui/static/assets/MobileRunTarget-C4M4YJJh.js +6 -0
- package/src/ui/static/assets/{ModuleExplorer-VGcmK167.js → ModuleExplorer-BKVbxFZK.js} +1 -1
- package/src/ui/static/assets/{OutputPage-B_1nPPxE.js → OutputPage-Bi-28tJi.js} +1 -1
- package/src/ui/static/assets/PipelinesPanel-BtO3iSJ4.js +1 -0
- package/src/ui/static/assets/{ProfilePage-y7tJNNFd.js → ProfilePage-BgZ4VDC-.js} +1 -1
- package/src/ui/static/assets/{ProjectExplorer-DbfGhRq0.js → ProjectExplorer-BVGbmVP7.js} +1 -1
- package/src/ui/static/assets/{RemoteFileStrip-WuRKtx_h.js → RemoteFileStrip-dzPInzgb.js} +1 -1
- package/src/ui/static/assets/{ReportCard-G52Q6-2i.js → ReportCard-LOf1PXlb.js} +2 -2
- package/src/ui/static/assets/{ReportFullView-Bt8UFP2J.js → ReportFullView-Ce4OI8lf.js} +1 -1
- package/src/ui/static/assets/{ReportsPage-DMtDi73Q.js → ReportsPage-DFxCQ8cY.js} +48 -48
- package/src/ui/static/assets/{ResultsPage-BI9jpK2N.js → ResultsPage-DD-uj8gk.js} +115 -115
- package/src/ui/static/assets/{RunState-ifC4zi6M.js → RunState-DDwFB4tA.js} +1 -1
- package/src/ui/static/assets/{RunTargets-C7vpCbck.js → RunTargets-CkIpY3v3.js} +1 -1
- package/src/ui/static/assets/ScriptMappingPage-DQQoR6sR.js +1 -0
- package/src/ui/static/assets/{SearchableDevicePicker-BYxYJNWl.js → SearchableDevicePicker-CenIxD7b.js} +1 -1
- package/src/ui/static/assets/{SettingsPage-DSISg7r7.js → SettingsPage-DAV_0y0m.js} +83 -83
- package/src/ui/static/assets/{SharedReportView-BOqKGJmR.js → SharedReportView-CqSLFKT1.js} +1 -1
- package/src/ui/static/assets/{SourcesPage-CgqtYGBi.js → SourcesPage-BvqC9oKw.js} +14 -14
- package/src/ui/static/assets/TestExplorerPage-Bdnll77k.js +7 -0
- package/src/ui/static/assets/{TestManagementPage-wqYTKP7W.js → TestManagementPage-CCNE688A.js} +10 -10
- package/src/ui/static/assets/{TestPlansPage-DOKX9p6z.js → TestPlansPage-T6D25i6-.js} +5 -5
- package/src/ui/static/assets/{TestverCreditsDetail-cSW0SpNx.js → TestverCreditsDetail-BKpt4oLW.js} +1 -1
- package/src/ui/static/assets/{TestverCreditsRing-DpMzl3h7.js → TestverCreditsRing-CoDk5eAS.js} +1 -1
- package/src/ui/static/assets/TestverMcpPage-Dte0qSXp.js +34 -0
- package/src/ui/static/assets/{UncommittedDiffViewer-BxS0zi-p.js → UncommittedDiffViewer-BNroxCoo.js} +2 -2
- package/src/ui/static/assets/{UserManagementPage-B5d0uDU_.js → UserManagementPage-BU4MuDJZ.js} +10 -10
- package/src/ui/static/assets/{WorkflowsPage-Bk0DFnFS.js → WorkflowsPage-BP5k7AqE.js} +83 -83
- package/src/ui/static/assets/clipboard-BIEd7Ccc.js +1 -0
- package/src/ui/static/assets/{hiddenLlmProviders-CdhhNa5G.js → hiddenLlmProviders-BPORgy-e.js} +1 -1
- package/src/ui/static/assets/index-BlA8ntjb.js +47 -0
- package/src/ui/static/assets/index-Co4_SlGD.css +1 -0
- package/src/ui/static/assets/{index-DpQhqcHv.js → index-DLmlY2Ol.js} +1 -1
- package/src/ui/static/assets/{reportMeta-AKcU_qwq.js → reportMeta-B9ZRW6ts.js} +1 -1
- package/src/ui/static/assets/runSelected-BoPm1sz-.js +1 -0
- package/src/ui/static/assets/{useChartTheme-BFz2QcND.js → useChartTheme-CTIe6M63.js} +1 -1
- package/src/ui/static/assets/{useDebouncedValue-BsHptIvX.js → useDebouncedValue-C9odz7b2.js} +1 -1
- package/src/ui/static/assets/{useFeatureFlags-DNkIctil.js → useFeatureFlags-B4Otsv-N.js} +1 -1
- package/src/ui/static/assets/{useJiraConnector-D5ysBBvz.js → useJiraConnector--JZhbYrT.js} +1 -1
- package/src/ui/static/assets/{useOwnership-U0AfKBRo.js → useOwnership-BhPOiYzy.js} +1 -1
- package/src/ui/static/assets/useSuites-GN_K2mHc.js +1 -0
- package/src/ui/static/assets/{useTabParam-ChbOedP1.js → useTabParam-CyYAP90W.js} +1 -1
- package/src/ui/static/assets/{useTestExplorer-DT8frjCK.js → useTestExplorer-BGhkGHKy.js} +1 -1
- package/src/ui/static/assets/{useTestLifecycle-OcwQaB1s.js → useTestLifecycle-DX5ES6x8.js} +1 -1
- package/src/ui/static/assets/{useTestManagement-Xm4Bcx3u.js → useTestManagement-ommXjx0q.js} +2 -2
- package/src/ui/static/assets/useTestResults-DWjvm8gm.js +1 -0
- package/src/ui/static/assets/{vendor-charts-DWFQlmCz.js → vendor-charts-By5uZ93z.js} +1 -1
- package/src/ui/static/assets/{vendor-flow-YGpC9U9I.js → vendor-flow-B61ZV-pm.js} +1 -1
- package/src/ui/static/assets/{vendor-icons-BKPiFyYV.js → vendor-icons-Cm92aSc5.js} +1426 -1421
- package/src/ui/static/assets/vendor-query-DkZSMtfn.js +1 -0
- package/src/ui/static/assets/{vendor-quill-W-RoQfb6.js → vendor-quill-xJF2Jvjc.js} +1 -1
- package/src/ui/static/assets/{vendor-react-CTbHBddL.js → vendor-react-DOVfxdUy.js} +1 -1
- package/src/ui/static/index.html +479 -479
- package/src/ui/static/assets/AIPanel-B_R-CbrF.js +0 -32
- package/src/ui/static/assets/AIRecordPanel-BRQWIU5h.js +0 -40
- package/src/ui/static/assets/AIStreamUI-C3D989_6.js +0 -9
- package/src/ui/static/assets/APITestingPage-Cmwkiiys.js +0 -19
- package/src/ui/static/assets/AboutPage-CjEqKB-q.js +0 -1
- package/src/ui/static/assets/AdvancedPage-4kAcpE8Y.js +0 -3
- package/src/ui/static/assets/AuditLogPage-BQjOzQje.js +0 -1
- package/src/ui/static/assets/ChangesSummary-CY_Vb27i.js +0 -2
- package/src/ui/static/assets/DiffViewer-BIU09a_i.js +0 -2
- package/src/ui/static/assets/MobileRunPicker-0h-N2c6d.js +0 -1
- package/src/ui/static/assets/MobileRunTarget-Bo_xekig.js +0 -6
- package/src/ui/static/assets/PipelinesPanel-PmmPu8pj.js +0 -1
- package/src/ui/static/assets/ScriptMappingPage-7vHuvhQw.js +0 -1
- package/src/ui/static/assets/TestExplorerPage-gYLhCD4d.js +0 -7
- package/src/ui/static/assets/index-BYVxKLrT.js +0 -47
- package/src/ui/static/assets/index-C2KJt7SI.css +0 -1
- package/src/ui/static/assets/runSelected-WlgnZcSF.js +0 -1
- package/src/ui/static/assets/useSuites-DyfN9HVv.js +0 -1
- package/src/ui/static/assets/useTestResults-D5EwGIX9.js +0 -1
- package/src/ui/static/assets/vendor-query-BrzmPFT3.js +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as h,b as ee,j as e}from"./vendor-react-CTbHBddL.js";import{u as te}from"./vendor-query-BrzmPFT3.js";import{gp as re,a1 as H}from"./index-BYVxKLrT.js";import{af as se,X as ne,a0 as ae,_ as ie,aC as oe,ac as K,de as le,a as J,aa as de,bK as ce,F as xe,v as me,K as ue,g as pe}from"./vendor-icons-BKPiFyYV.js";function he({run:t,file:s,onClose:i}){const{data:n,isLoading:l,error:r}=te({queryKey:["explore-run-file",t,s],queryFn:()=>re(t,s),staleTime:3e4});h.useEffect(()=>{const a=c=>{c.key==="Escape"&&i()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[i]);const o=/\.(md|markdown)$/i.test(s);return ee.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-center justify-center p-4","data-testid":"run-file-viewer",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:i}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`Exploration ${t} — ${s}`,className:"relative w-full max-w-3xl max-h-[85vh] flex flex-col rounded-2xl border border-gray-200 dark:border-white/10 bg-white dark:bg-surface-1 shadow-2xl",children:[e.jsxs("div",{className:"flex items-start gap-3 px-5 pt-4 pb-3 border-b border-gray-200 dark:border-white/5",children:[e.jsx("span",{className:"mt-0.5 rounded-lg bg-emerald-500/10 p-2 text-emerald-600 dark:text-emerald-400",children:e.jsx(se,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-gray-100 break-all",children:s}),e.jsxs("p",{className:"text-[13px] text-gray-500 dark:text-gray-400 break-all",children:["Exploration run ",t," · read-only, credentials masked"]})]}),e.jsx("button",{type:"button",onClick:i,className:"p-1 rounded-md text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",title:"Close","aria-label":"Close",children:e.jsx(ne,{size:16})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 text-[13px]",children:[l&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[e.jsx(ae,{size:14,className:"animate-spin"})," Reading the file…"]}),r&&e.jsxs("p",{className:"text-red-600 dark:text-red-400",children:["This file could not be opened: ",r.message]}),n&&(o?e.jsx("div",{className:"text-gray-800 dark:text-gray-200",children:e.jsx(Y,{text:n.content})}):e.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-[12px] text-gray-800 dark:text-gray-200",children:n.content}))]})]})]}),document.body)}const A=/\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]/g,ge=/\[\[cite\\?\|[^\]]*\]\]/g;function fe(t){return t.replace(/\\(?=[|[\]])/g,"")}function Fe(t){return t.replace(ge,fe)}function W(t){const s=t.trim().toLowerCase();return s==="observed"||s==="reported"||s==="asserted"||s==="automated"||s==="stated"?s:"stated"}function _(t,s,i){return`${W(t)}|${s.trim()||i.trim()||"source"}`}function be(t){const s=new Map;for(const i of t.matchAll(A)){const n=i[1]||"",l=(i[2]||"").trim(),r=(i[3]||"").trim(),o=_(n,l,r);s.has(o)||s.set(o,{index:s.size+1,tier:W(n),ref:l||r||"source",detail:l?r:"",kind:(i[4]||"").trim()||void 0})}return[...s.values()]}function Oe(t){return t.replace(A,"").replace(/[ \t]+([.,;:!?])/g,"$1")}function C(t){return t.kind||X[t.tier]}function De(t){const s=be(t),i=new Map(s.map(r=>[_(r.tier,r.ref,""),r])),n=t.replace(A,(r,o,a,c)=>{const p=i.get(_(o,a.trim()||c.trim(),""));return p?` [${p.index}]`:""}).replace(/[ \t]+(\[\d+\])/g," $1");if(s.length===0)return n;const l=s.map(r=>`[${r.index}] ${C(r)} · ${r.ref}${r.detail?` — ${r.detail}`:""}`);return`${n}
|
|
2
|
-
|
|
3
|
-
Sources:
|
|
4
|
-
${l.join(`
|
|
5
|
-
`)}`}const M=h.createContext(null);function Be({citations:t,children:s}){const i=`src-${h.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,n=new Map(t.map(l=>[_(l.tier,l.ref,""),l]));return e.jsx(M.Provider,{value:{map:n,listId:i},children:s})}const Q={observed:"text-emerald-600 dark:text-emerald-400 border-emerald-500/30 bg-emerald-500/10",reported:"text-rose-600 dark:text-rose-400 border-rose-500/30 bg-rose-500/10",asserted:"text-blue-600 dark:text-blue-400 border-blue-500/30 bg-blue-500/10",automated:"text-violet-600 dark:text-violet-400 border-violet-500/30 bg-violet-500/10",stated:"text-amber-600 dark:text-amber-400 border-amber-500/30 bg-amber-500/10"},ye={observed:"Observed — the app was watched doing this",reported:"Reported — a tester logged this as a defect",asserted:"Asserted — a test case says so",automated:"Automated — a test in the repository checks this",stated:"Stated — written in a document"},X={observed:"Exploration",reported:"Defect",asserted:"Test case",automated:"Automated test",stated:"Document"},ke="relative -top-[3px] mx-[3px] inline-flex items-center justify-center min-w-[14px] h-[14px] px-[3px] rounded-[4px] border text-[9px] leading-none font-semibold tabular-nums align-baseline";function je(t,s){const i=document.getElementById(t);if(!i)return;i.open=!0;const n=document.getElementById(`${t}-${s}`);n==null||n.scrollIntoView({block:"nearest",behavior:"smooth"}),n==null||n.focus({preventScroll:!0})}function we({tier:t,refId:s,detail:i,kind:n}){const l=h.useContext(M),r=l==null?void 0:l.map.get(_(t,s,i)),o=W((r==null?void 0:r.tier)??t),a=(r==null?void 0:r.ref)??(s||i||"source"),c=r?String(r.index):a,p=(r==null?void 0:r.kind)||n||X[o],b=`${p} · ${a}
|
|
6
|
-
${ye[o]}${r!=null&&r.detail||i?`
|
|
7
|
-
${(r==null?void 0:r.detail)||i}`:""}`;return e.jsx("button",{type:"button",title:b,"aria-label":`Source ${c}: ${p} ${a}`,onClick:()=>{l&&r&&je(l.listId,r.index)},className:`${ke} cursor-pointer focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 ${Q[o]}`,children:c})}function ve(t){var l;const s=t.ref.split(" · ")[0].trim();if(!s)return null;const i=(r,o)=>({kind:"page",href:`${r}?${new URLSearchParams(o).toString()}`});if(t.kind==="Defect register")return{kind:"page",href:"/defects"};if(t.kind==="Defect"||t.tier==="reported")return i("/defects",{defectId:s});if(t.kind==="Test run")return i("/results",{runId:s});if(t.tier==="asserted")return i("/test-cases",{tcId:s});if(t.kind==="Automation library")return{kind:"page",href:"/tests"};if(t.tier==="automated"&&t.kind==="Method"){const r=/^(.+?) · (.+):(\d+)$/.exec(t.ref.trim());if(!r)return null;const o=r[1].lastIndexOf("."),a=o>0?r[1].slice(0,o):"-",c=o>0?r[1].slice(o+1):r[1];return i("/code-map",{symbol:`${r[2]}::${a}::${c}::${r[3]}`,name:c})}if(t.tier==="automated"){const r=t.ref.indexOf(" :: ");return r<0?null:i("/tests",{file:t.ref.slice(0,r),test:t.ref.slice(r+4)})}if(t.tier==="stated"&&/^SRC-/i.test(s)){const r=t.kind==="Jira ticket"?"jira":t.kind==="Requirement"?"requirement":t.kind==="Note"?"nlp":"document";return i("/sources",{tab:r,sourceId:s})}if(t.tier==="stated"&&/^REQ-/i.test(s))return i("/coverage",{tab:"requirements",reqId:s});const n=(l=/\brun ([\w.-]+)/.exec(t.detail))==null?void 0:l[1];return t.tier==="observed"&&n&&/\.(md|markdown|txt|json)$/i.test(s)?{kind:"run-file",run:n,file:s}:null}function Ne(t,s){const i=t.split(" ").map(n=>n==="Jira"?n:n.toLowerCase()).join(" ");return`${s} ${s===1?i:`${i}s`}`}function Ue({citations:t}){const s=h.useContext(M),[i,n]=h.useState(null);if(t.length===0)return null;const l=a=>{a.kind==="run-file"?n({run:a.run,file:a.file}):window.open(a.href,"_blank","noopener")},r=new Map;for(const a of t){const c=C(a);r.set(c,(r.get(c)??0)+1)}const o=[...r.entries()].map(([a,c])=>Ne(a,c)).join(" · ");return e.jsxs("details",{id:s==null?void 0:s.listId,className:"group mt-3.5 rounded-xl border border-black/[0.07] dark:border-white/[0.08] bg-black/[0.015] dark:bg-white/[0.02] overflow-hidden",children:[e.jsxs("summary",{className:"flex items-center gap-2 cursor-pointer select-none px-3.5 py-2.5 list-none [&::-webkit-details-marker]:hidden hover:bg-black/[0.02] dark:hover:bg-white/[0.02] transition-colors",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open:rotate-90 flex-shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),e.jsx("span",{className:"text-[12px] font-semibold text-gray-700 dark:text-gray-300",children:"Sources"}),e.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-500",children:o})]}),e.jsx("div",{className:"border-t border-black/[0.06] dark:border-white/[0.06]",children:t.map(a=>e.jsxs("div",{id:s?`${s.listId}-${a.index}`:void 0,tabIndex:-1,className:"flex items-start gap-2.5 px-3.5 py-2.5 border-b last:border-b-0 border-black/[0.04] dark:border-white/[0.04] focus:outline-none focus:bg-cyan-500/[0.06]",children:[e.jsx("span",{className:`mt-[1px] inline-flex items-center justify-center min-w-[16px] h-[16px] px-[3px] rounded-[4px] border text-[9.5px] leading-none font-semibold tabular-nums flex-shrink-0 ${Q[a.tier]}`,children:a.index}),e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"block text-[12px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-300",children:C(a)}),a.ref!==C(a)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-400 dark:text-gray-600",children:" · "}),e.jsx("span",{className:"font-mono text-[11.5px] text-gray-800 dark:text-gray-200 break-all",children:a.ref})]})]}),a.detail&&e.jsx("span",{className:"block mt-0.5 text-[11px] leading-relaxed text-gray-500 dark:text-gray-500 break-words",children:a.detail})]}),(()=>{const c=ve(a);return c?e.jsxs("button",{type:"button",onClick:()=>l(c),title:c.kind==="run-file"?"Read this file of the exploration run":`Open ${C(a).toLowerCase()} ${a.ref.split(" · ")[0]} in a new tab`,"aria-label":`Open ${C(a)} ${a.ref}`,"data-testid":"source-open",className:"flex-shrink-0 inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-cyan-700 dark:text-cyan-400 hover:bg-cyan-500/10 focus:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60",children:["Open ",e.jsx(ie,{size:11})]}):null})()]},`${a.tier}|${a.ref}`))}),i&&e.jsx(he,{run:i.run,file:i.file,onClose:()=>n(null)})]})}function He(t){if(!t)return null;const s=[...t.matchAll(/(?:#{1,4}\s*)?(?:\*\*)?Attempt\s+(\d+)\s*(?:of|\/)\s*(\d+)(?:\*\*)?/gi)];if(s.length===0)return null;const i=s[s.length-1],n=parseInt(i[1],10),l=parseInt(i[2],10),r=t.lastIndexOf(i[0]),o=t.slice(r);return/\*\*Test Result:?\*\*\s*:?\s*PASS/i.test(o)||/\ball\s+\d+\s+(tests?\s+)?passed/i.test(o)||/test(s)?\s+(run\s+)?pass(ed)?/i.test(o)?{current:n,total:l,status:"pass"}:/\*\*Test Result:?\*\*\s*:?\s*FAIL/i.test(o)||/test(s)?\s+(still\s+)?fail(ed|ing)?/i.test(o)||/\d+\s+fail(ed|ing|ure)/i.test(o)?{current:n,total:l,status:"fail"}:{current:n,total:l,status:"running"}}function $e(t){return t==="read_file"?e.jsx(de,{size:12,className:"text-sky-400"}):t==="write_file"||t==="edit_file"||t==="find_replace"?e.jsx(ce,{size:12,className:"text-amber-400"}):t==="run_command"||t==="run_tests"?e.jsx(J,{size:12,className:"text-emerald-400"}):t==="create_directory"||t==="list_directory"?e.jsx(xe,{size:12,className:"text-purple-400"}):t==="glob_search"||t==="grep"?e.jsx(me,{size:12,className:"text-indigo-400"}):t.startsWith("browser_")?e.jsx(ue,{size:12,className:"text-pink-400"}):e.jsx(pe,{size:12,className:"text-gray-400"})}function Ce(t){return t==="start"?"text-sky-400":t==="complete"?"text-emerald-400":t==="error"?"text-red-400":t==="denied"?"text-amber-400":"text-gray-400"}function V(t){return t==="start"?"Running":t==="complete"?"Done":t==="error"?"Failed":t==="denied"?"Denied":t}function Ee({events:t,label:s}){const i=h.useRef(null);if(h.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[t]),t.length===0)return null;const n=[],l=new Map;for(const r of t)if(r.phase==="start")l.set(r.toolName+"-"+r.id,r),n.push(r);else if(r.phase==="complete"){const o=r.toolName+"-"+r.id,a=l.get(o);if(a){const c=n.indexOf(a);c>=0&&(n[c]={...a,phase:"complete",result:r.result})}else n.push(r)}else n.push(r);return e.jsxs("div",{className:"mb-3 space-y-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx(J,{size:11,className:"text-gray-500"}),e.jsx("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wider",children:s||"Tool Activity"})]}),e.jsx("div",{ref:i,className:"max-h-[240px] overflow-y-auto rounded-lg bg-black/20 border border-white/5",children:n.map((r,o)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-white/[0.03] last:border-b-0 hover:bg-white/[0.02] transition-colors",children:[$e(r.toolName),e.jsxs("span",{className:"text-xs text-gray-300 font-mono truncate flex-1",children:[r.toolName,r.args&&e.jsx("span",{className:"text-gray-500 ml-1",children:r.args})]}),e.jsx("span",{className:`text-[10px] font-medium ${Ce(r.phase)}`,children:r.phase==="start"?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sky-400 animate-pulse"}),V(r.phase)]}):V(r.phase)})]},o))})]})}function Ke({permission:t,onRespond:s}){return e.jsxs("div",{className:"mb-3 rounded-xl border border-amber-500/30 bg-amber-500/5 p-4 animate-in fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(oe,{size:16,className:"text-amber-400"}),e.jsx("span",{className:"text-sm font-semibold text-amber-300",children:"Permission Required"})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"text-sm text-gray-300",children:["AI wants to execute: ",e.jsx("span",{className:"font-mono text-amber-300",children:t.toolName})]}),t.args&&e.jsx("p",{className:"text-xs text-gray-500 font-mono mt-1 truncate",children:t.args})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>s(t.permissionId,!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-emerald-500/20 text-emerald-300 text-sm font-medium hover:bg-emerald-500/30 transition-colors border border-emerald-500/20",children:[e.jsx(K,{size:14}),"Allow"]}),e.jsxs("button",{onClick:()=>s(t.permissionId,!0,!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-sky-500/20 text-sky-300 text-sm font-medium hover:bg-sky-500/30 transition-colors border border-sky-500/20",children:[e.jsx(K,{size:14}),"Always Allow"]}),e.jsxs("button",{onClick:()=>s(t.permissionId,!1),className:"flex items-center gap-1.5 px-4 py-2 rounded-lg bg-red-500/20 text-red-300 text-sm font-medium hover:bg-red-500/30 transition-colors border border-red-500/20",children:[e.jsx(le,{size:14}),"Deny"]})]})]})}const Y=h.memo(function({text:s}){var z,F,O,D,B,U;const i=[];let n=s;const l=/EMAIL_PREVIEW_START\n([\s\S]*?)EMAIL_PREVIEW_END/g;let r;for(;(r=l.exec(s))!==null;){const u=r[1]||"",d=u.match(/^To:\s*(.+)/m),y=u.match(/^CC:\s*(.+)/m),k=u.match(/^From:\s*(.+)/m),j=u.match(/^Subject:\s*(.+)/m),w=u.match(/---BODY---\n([\s\S]*?)---END_BODY---/);i.push({to:((z=d==null?void 0:d[1])==null?void 0:z.trim())||"",cc:(F=y==null?void 0:y[1])==null?void 0:F.trim(),from:((O=k==null?void 0:k[1])==null?void 0:O.trim())||"",subject:((D=j==null?void 0:j[1])==null?void 0:D.trim())||"",body:((B=w==null?void 0:w[1])==null?void 0:B.trim())||""}),n=n.replace(r[0],`__EMAIL_PREVIEW_${i.length-1}__`)}const o=n.split(`
|
|
8
|
-
`),a=[];let c=!1,p="",b=[],m=[],x=0;const N=(u=!1)=>{if(b.length>0){const d=b.join(`
|
|
9
|
-
`);a.push(e.jsxs("div",{className:"my-2",children:[p&&e.jsxs("div",{className:"text-[10px] text-gray-500 bg-black/30 px-3 py-1 rounded-t-lg border border-b-0 border-white/5 font-mono flex items-center gap-2",children:[e.jsx("span",{children:p}),u&&e.jsx("span",{className:"text-[9px] text-gray-600 italic",children:"(streaming...)"})]}),e.jsx("pre",{className:`bg-black/30 border border-white/5 ${p?"rounded-b-lg":"rounded-lg"} p-3 text-xs text-gray-300 font-mono overflow-x-auto whitespace-pre-wrap max-h-[500px] overflow-y-auto`,children:d})]},x++)),b=[],p=""}},I=u=>{const d=[];return u.replace(/\[\[cite\\?\|[^\]]*\]\]/g,k=>(d.push(k.replace(/\\(?=[|[\]])/g,"")),`\0${d.length-1}\0`)).replace(/\\\|/g,"").replace(/^\|/,"").replace(/\|$/,"").split("|").map(k=>k.trim().replace(/\u0001/g,"|").replace(/\u0000(\d+)\u0000/g,(j,w)=>d[Number(w)]??""))},Z=u=>/^\|[\s:]*-{2,}[\s:]*(\|[\s:]*-{2,}[\s:]*)*\|?$/.test(u.trim()),L=()=>{if(m.length===0)return;const u=m.map(I);let d=null,y=[];m.length>=2&&Z(m[1])?(d=u[0],y=u.slice(2)):y=u,a.push(e.jsx(_e,{headers:d,rows:y},x++)),m=[]};for(const u of o){if(u.trimStart().startsWith("```")){L(),c?(c=!1,N()):(c=!0,p=u.trimStart().slice(3).trim());continue}if(c){b.push(u);continue}const d=u.trim();if(d.startsWith("|")){m.push(d);continue}if(L(),!d){a.push(e.jsx("div",{className:"h-2"},x++));continue}const y=d.match(/^__EMAIL_PREVIEW_(\d+)__$/);if(y){const $=parseInt(y[1],10),g=i[$];g&&a.push(e.jsxs("div",{className:"my-3 rounded-xl border border-blue-500/20 bg-blue-50/60 dark:bg-blue-500/5 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 bg-blue-500/10 border-b border-blue-500/10",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-blue-500 dark:text-blue-400 shrink-0",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),e.jsx("span",{className:"text-sm font-semibold text-blue-700 dark:text-blue-300",children:"Email Preview"})]}),e.jsxs("div",{className:"px-4 py-3 space-y-1.5 border-b border-gray-200 dark:border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"To:"}),e.jsx("span",{className:"text-gray-800 dark:text-gray-200 font-medium",children:g.to})]}),g.cc&&e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"CC:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:g.cc})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"From:"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300",children:g.from})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-gray-500 w-16 shrink-0",children:"Subject:"}),e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:g.subject})]})]}),e.jsx("div",{className:"px-4 py-3 max-h-[300px] overflow-y-auto",children:e.jsx("div",{className:"text-xs text-gray-700 dark:text-gray-300 whitespace-pre-wrap leading-relaxed",children:g.body})}),e.jsx("div",{className:"px-4 py-2 bg-gray-50 dark:bg-white/[0.02] border-t border-gray-200 dark:border-white/5",children:e.jsx("span",{className:"text-[10px] text-gray-500 italic",children:"Confirm to send this email"})})]},x++));continue}const k=d.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/([^\s)\]"']+\.(?:png|svg|jpg|jpeg)))/);if(k){const $=H(k[1]),g=decodeURIComponent(k[2]||"").replace(/^\d+-/,"");a.push(e.jsxs("div",{className:"my-3 w-full max-w-[640px] rounded-xl border border-gray-200 dark:border-white/10 overflow-hidden bg-white dark:bg-black/20",children:[e.jsx("img",{src:$,alt:g,className:"w-full h-auto max-h-[500px] object-contain block",loading:"lazy"}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-gray-100 dark:border-white/5 bg-gray-50 dark:bg-white/[0.02]",children:[e.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-400 truncate",children:g}),e.jsxs("button",{onClick:()=>{fetch($).then(E=>E.blob()).then(E=>{const T=URL.createObjectURL(E),v=document.createElement("a");v.href=T,v.download=g,document.body.appendChild(v),v.click(),document.body.removeChild(v),URL.revokeObjectURL(T)}).catch(()=>window.open($,"_blank"))},className:"flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-white dark:bg-white/5 border border-gray-200 dark:border-white/10 hover:bg-gray-100 dark:hover:bg-white/10 transition-colors text-xs text-gray-700 dark:text-gray-300 cursor-pointer",children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]})]})]},x++));continue}const j=d.match(/\[([^\]]*)\]\(((?:https?:\/\/[^)\s/]+)?\/api\/documents\/download\/([^)]+))\)/),w=j?null:d.match(/((?:https?:\/\/[^\s/]+)?\/api\/documents\/download\/(\S+))/),S=j?{url:j[2],file:j[3]}:w?{url:w[1],file:w[2]}:null;if(S){const $=H(S.url||""),g=decodeURIComponent(S.file||"document").replace(/^\d+-/,""),E=((U=g.split(".").pop())==null?void 0:U.toLowerCase())||"",v={docx:{color:"text-blue-500",label:"Word Document"},doc:{color:"text-blue-500",label:"Word Document"},pdf:{color:"text-rose-500",label:"PDF Document"},xlsx:{color:"text-emerald-500",label:"Excel Spreadsheet"},xls:{color:"text-emerald-500",label:"Excel Spreadsheet"},csv:{color:"text-gray-500",label:"CSV File"}}[E]||{color:"text-gray-500",label:"Document"};a.push(e.jsxs("a",{href:$,download:g,className:"flex items-center gap-3 p-3 my-2 rounded-xl border border-gray-200 dark:border-white/10 bg-transparent hover:bg-gray-50 dark:hover:bg-white/[0.03] transition-colors cursor-pointer no-underline group",children:[e.jsx("div",{className:"w-11 h-11 rounded-lg flex items-center justify-center shrink-0",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:v.color,children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200 truncate",children:g}),e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:v.label})]}),e.jsxs("div",{className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-gray-200 dark:border-white/10 group-hover:bg-gray-100 dark:group-hover:bg-white/5 transition-colors shrink-0 ${v.color}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),e.jsx("span",{className:"text-xs font-medium",children:"Download"})]})]},x++));continue}if(/^[-*_]{3,}$/.test(d)){a.push(e.jsx("hr",{className:"border-white/5 my-3"},x++));continue}if(d.startsWith("#### ")){a.push(e.jsx("h5",{className:"text-[13px] font-semibold text-gray-200 mt-2.5 mb-1",children:f(d.slice(5))},x++));continue}if(d.startsWith("### ")){a.push(e.jsx("h4",{className:"text-sm font-semibold text-gray-200 mt-3 mb-1",children:f(d.slice(4))},x++));continue}if(d.startsWith("## ")){a.push(e.jsx("h3",{className:"text-base font-semibold text-gray-100 mt-4 mb-1",children:f(d.slice(3))},x++));continue}if(d.startsWith("# ")){a.push(e.jsx("h2",{className:"text-lg font-bold text-gray-100 mt-4 mb-1.5",children:f(d.slice(2))},x++));continue}const R=d.match(/^(\d+)\.\s+(.+)/);if(R){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsxs("span",{className:"text-gray-500 flex-shrink-0 w-4 text-right",children:[R[1],"."]}),e.jsx("span",{children:f(R[2])})]},x++));continue}if(d.startsWith("- ")||d.startsWith("* ")){a.push(e.jsxs("div",{className:"flex gap-2 text-sm text-gray-300 leading-relaxed ml-2",children:[e.jsx("span",{className:"text-gray-500 flex-shrink-0",children:"•"}),e.jsx("span",{children:f(d.slice(2))})]},x++));continue}if(d.startsWith("**")){a.push(e.jsx("p",{className:"text-sm text-gray-200 mt-2",children:f(d)},x++));continue}a.push(e.jsx("p",{className:"text-sm text-gray-300 leading-relaxed",children:f(d)},x++))}return c&&N(!0),L(),e.jsx("div",{className:"space-y-0.5",children:a})});function _e({headers:t,rows:s,alignNumbers:i=!1}){const n=t?t.findIndex(Te):-1,l=o=>o===n?" text-center w-px whitespace-nowrap":"",r=o=>i&&/^[-+]?[\d,]+(\.\d+)?\s*(%|ms|s)?$/.test(o.trim());return e.jsx("div",{className:"my-2.5 rounded-[10px] border border-gray-200 dark:border-[#2c2d36] overflow-hidden","data-testid":"ai-table",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse text-[13px] text-gray-700 dark:text-gray-300 tabular-nums",children:[t&&e.jsx("thead",{children:e.jsx("tr",{children:t.map((o,a)=>e.jsx("th",{className:`bg-[#f7f8fa] dark:bg-[#22232a] border-b border-gray-200 dark:border-[#2c2d36] px-3.5 py-[9px] text-left text-[11.5px] font-semibold uppercase tracking-[0.05em] text-gray-500 dark:text-gray-400 whitespace-nowrap${l(a)}`,children:f(o,!0)},a))})}),e.jsxs("tbody",{children:[s.map((o,a)=>e.jsx("tr",{className:"group/row",children:o.map((c,p)=>{var b;return e.jsx("td",{className:`px-3.5 py-2.5 align-middle border-b border-[#eef0f3] dark:border-[#25262d] group-last/row:border-b-0 group-hover/row:bg-[#f5f7fa] dark:group-hover/row:bg-[#23242b]${p===0?" font-medium text-gray-800 dark:text-gray-200":""}${(b=G(c))!=null&&b.rest?" min-w-[13rem]":Ie(c)}${l(p)}${r(c)?" text-right":""}`,children:Ae(c)},p)})},a)),s.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:Math.max(1,(t==null?void 0:t.length)??1),className:"px-3.5 py-6 text-center text-gray-400 dark:text-gray-500",children:"No rows"})})]})]})})})}const P=/\[\[cite\|[^\]]*\]\]/g;function Ie(t){const s=t.replace(P,"").replace(/[`*]/g,"").trim().length;return s<=18?" whitespace-nowrap":s>40?" min-w-[16rem]":""}const Le=/^(passed|pass|failed|fail|error|skipped|blocked|flaky|open|in progress|resolved|closed|fixed|rejected)(\s*\((?:error|fixed)\))?(?:\s*[—–-]\s+([\s\S]+))?$/i,Se={passed:"ok",pass:"ok",resolved:"ok",closed:"ok",fixed:"ok",failed:"bad",fail:"bad",error:"bad",blocked:"bad",open:"bad",skipped:"warn",flaky:"warn","in progress":"warn",rejected:"neutral"},Re={bad:"text-red-700 bg-red-50 dark:text-red-400 dark:bg-red-500/[0.12]",ok:"text-emerald-700 bg-emerald-50 dark:text-emerald-400 dark:bg-emerald-500/[0.12]",warn:"text-amber-700 bg-amber-50 dark:text-amber-400 dark:bg-amber-500/[0.12]",neutral:"text-gray-600 bg-gray-100 dark:text-gray-300 dark:bg-white/[0.08]"};function G(t){const s=Le.exec(t.replace(P,"").trim());return s?{label:`${s[1]}${s[2]??""}`.trim(),tone:Se[s[1].toLowerCase()]??"neutral",rest:(s[3]??"").trim()}:null}function Te(t){return/^sources?$/i.test((t??"").replace(/\*/g,"").trim())}function q(t){const s=t.split(/\s→\s/);return s.length===1?f(t,!0):s.map((i,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{className:"px-1 text-[#9ca3af] dark:text-gray-500",children:"→"}),f(i,!0)]},n))}function Ae(t){const s=G(t);if(!s)return q(t);const i=(t.match(P)??[]).join(" ");return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:`inline-flex items-center gap-[5px] rounded-full px-2 py-0.5 text-[11.5px] font-semibold whitespace-nowrap ${Re[s.tone]}`,children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current","aria-hidden":"true"}),s.label]}),i&&e.jsxs(e.Fragment,{children:[" ",f(i,!0)]}),s.rest&&e.jsx("span",{className:"mt-[3px] block text-[12px] text-gray-500 dark:text-gray-400",children:q(s.rest)})]})}function f(t,s=!1){const i=t.split(/(\*\*[^*]+\*\*|`[^`]+`|\[\[cite\|[^\]]*\]\]|\*[^\s*][^*\n]*[^\s*]\*|\*[^\s*]\*)/g);return i.length===1?t:e.jsx(e.Fragment,{children:i.map((n,l)=>{if(n.startsWith("[[cite|")){const r=/^\[\[cite\|([^|\]]*)\|([^|\]]*)\|([^|\]]*)(?:\|([^\]]*))?\]\]$/.exec(n);return r?e.jsx(we,{tier:r[1]||"",refId:(r[2]||"").trim(),detail:(r[3]||"").trim(),kind:(r[4]||"").trim()||void 0},l):null}return n.startsWith("**")&&n.endsWith("**")?e.jsx("strong",{className:"font-semibold text-gray-200",children:f(n.slice(2,-2),s)},l):n.startsWith("`[[cite|")&&n.endsWith("]]`")?e.jsx("span",{children:f(n.slice(1,-1),s)},l):n.startsWith("`")&&n.endsWith("`")?e.jsx("code",{className:s?"bg-gray-100 text-gray-700 dark:bg-white/[0.08] dark:text-gray-200 px-[5px] py-px rounded text-[0.86em] font-mono whitespace-nowrap":"bg-white/5 text-amber-300 px-1 py-0.5 rounded text-xs font-mono",children:n.slice(1,-1)},l):n.length>2&&n.startsWith("*")&&n.endsWith("*")?e.jsx("em",{className:"italic",children:f(n.slice(1,-1),s)},l):e.jsx("span",{children:n},l)})})}function Ve({state:t,panelRef:s,label:i,icon:n,emptyMessage:l}){const r=h.useRef(null),o=s??r,a=h.useRef(null),c=h.useRef(!0);h.useEffect(()=>{const m=o.current;if(!m)return;const x=()=>{const N=m.scrollHeight-m.scrollTop-m.clientHeight<32;c.current=N};return m.addEventListener("scroll",x,{passive:!0}),()=>m.removeEventListener("scroll",x)},[o]);const p=h.useRef(!0);h.useEffect(()=>{const m=()=>{const x=document.scrollingElement||document.documentElement;if(!x)return;const N=x.scrollHeight-x.scrollTop-x.clientHeight<120;p.current=N};return window.addEventListener("scroll",m,{passive:!0}),()=>window.removeEventListener("scroll",m)},[]),h.useEffect(()=>{const m=o.current,x=requestAnimationFrame(()=>{m&&c.current&&(m.scrollTop=m.scrollHeight),p.current&&a.current&&a.current.scrollIntoView({block:"end",behavior:"smooth"})});return()=>cancelAnimationFrame(x)},[t.content,t.toolEvents.length,t.status,o]);const b=(()=>{if(t.status!=="streaming"||t.content)return null;const m=t.toolEvents.filter(I=>I.phase==="start");if(m.length===0)return null;const x=m[m.length-1];return{read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",find_replace:"Editing file",run_command:"Running command",run_tests:"Running tests",glob_search:"Searching files",grep:"Searching code",create_directory:"Creating directory",list_directory:"Listing directory",browser_launch:"Launching browser",browser_navigate:"Navigating",browser_click:"Clicking element",browser_type:"Typing text",browser_inspect:"Inspecting page",browser_screenshot:"Taking screenshot",browser_get_text:"Reading page text"}[x.toolName]||`Running ${x.toolName}`})();return e.jsxs(e.Fragment,{children:[t.toolEvents.length>0&&e.jsx(Ee,{events:t.toolEvents,label:i==="AI Fix"?"Analysis Activity":"Implementation Activity"}),e.jsxs("div",{ref:o,className:"bg-surface-1 rounded-lg border border-white/5 p-4 max-h-[600px] overflow-y-auto",children:[t.status==="error"&&e.jsxs("div",{className:"text-sm text-red-400",children:[e.jsxs("p",{children:["Failed: ",t.error]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"If this mentions your AI provider or connection, check Settings → LLM and verify the provider is connected."})]}),t.content?e.jsx(Y,{text:t.content}):t.status==="streaming"?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-purple-400 border-t-transparent rounded-full animate-spin"}),e.jsxs("div",{children:[e.jsx("span",{children:t.statusMessage||b||l}),t.toolEvents.length>0&&!b&&e.jsxs("span",{className:"text-gray-600 ml-1",children:["(",t.toolEvents.length," tools executed)"]})]})]}):null,t.status==="streaming"&&t.content&&e.jsx("span",{className:"inline-block w-2 h-4 bg-purple-400 animate-pulse ml-0.5 align-text-bottom"})]}),e.jsx("div",{ref:a,"aria-hidden":"true"})]})}export{Y as A,Be as C,Ke as P,Ue as S,Ve as a,De as c,be as e,He as p,Oe as s,Fe as u};
|
|
@@ -1,19 +0,0 @@
|
|
|
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-BYVxKLrT.js";import{cY as $e,b4 as ye,ag as ze,X as ge,y as ce,t as me,F as Fe,cZ as Ye,b6 as Xe,b7 as xe,a2 as Me,bI as _t,ah as Pe,aL as Ze,bs as et,r as pe,ap as he,O as Kt,a0 as De,a6 as dt,al as xt,u as He,au as Jt,cW as Oe,ac as mt,a5 as Le,bm as Je,K as Ee,a9 as Qt,aa as Gt,I as Wt,cn as Se,l as Be,D as Yt,E as Xt,cz as tt,c_ as Zt}from"./vendor-icons-BKPiFyYV.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-C3D989_6.js";import{D as as}from"./DiffViewer-BIU09a_i.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};
|