apitestcenter 0.14.0 → 0.16.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/dist/THIRD-PARTY-NOTICES-UI.txt +1 -1
- package/dist/THIRD-PARTY-NOTICES.txt +1 -1
- package/dist/cli.mjs +506 -448
- package/dist/ui/404/index.html +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/__next.__PAGE__.txt +11 -11
- package/dist/ui/__next._full.txt +13 -13
- package/dist/ui/__next._tree.txt +2 -2
- package/dist/ui/_next/static/chunks/{2u2hx7jqhjo62.js → 0z965ndwtjbm_.js} +5 -5
- package/dist/ui/_next/static/chunks/11ttwsn_q1n9e.js +50 -0
- package/dist/ui/_next/static/chunks/1dblkl6d18f29.js +50 -0
- package/dist/ui/_next/static/chunks/1g6q7zaut7pts.js +50 -0
- package/dist/ui/_next/static/chunks/1mj3_49yxxkvu.js +3 -0
- package/dist/ui/_next/static/chunks/{40n7rab9memc2.js → 1t823xy7gguwx.js} +1 -1
- package/dist/ui/_next/static/chunks/2-fk7_1yukwm4.js +4 -0
- package/dist/ui/_next/static/chunks/22z3xj74zl8o3.js +1 -0
- package/dist/ui/_next/static/chunks/24xh2ng9tdid9.js +50 -0
- package/dist/ui/_next/static/chunks/2844deqm9c797.js +50 -0
- package/dist/ui/_next/static/chunks/2p2xxbfeii3so.css +3 -0
- package/dist/ui/_next/static/chunks/2t65s4y0z2a60.js +50 -0
- package/dist/ui/_next/static/chunks/37fbrlydrkdac.js +10 -0
- package/dist/ui/_next/static/chunks/3ddcv0i2wy657.js +2 -0
- package/dist/ui/_next/static/chunks/{3qrp203pdimxn.js → 3o926vjke_xbm.js} +84 -79
- package/dist/ui/_next/static/chunks/3oetlmylrxpce.js +123 -0
- package/dist/ui/_next/static/chunks/41xixugzzb47w.js +27 -0
- package/dist/ui/_next/static/chunks/{turbopack-2ryv3cb9r14p8.js → turbopack-2qka98q_-4ca1.js} +1 -1
- package/dist/ui/_not-found/__next._full.txt +12 -12
- package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +10 -10
- package/dist/ui/_not-found/__next._tree.txt +2 -2
- package/dist/ui/_not-found/index.html +1 -1
- package/dist/ui/_not-found/index.txt +12 -12
- package/dist/ui/compare/__next._full.txt +13 -13
- package/dist/ui/compare/__next._tree.txt +2 -2
- package/dist/ui/compare/__next.compare.__PAGE__.txt +11 -11
- package/dist/ui/compare/index.html +1 -1
- package/dist/ui/compare/index.txt +13 -13
- package/dist/ui/connections/__next._full.txt +21 -0
- package/dist/ui/connections/__next._tree.txt +4 -0
- package/dist/ui/connections/__next.connections.__PAGE__.txt +25 -0
- package/dist/ui/connections/index.html +2 -0
- package/dist/ui/connections/index.txt +21 -0
- package/dist/ui/history/__next._full.txt +14 -14
- package/dist/ui/history/__next._tree.txt +2 -2
- package/dist/ui/history/__next.history.__PAGE__.txt +12 -12
- package/dist/ui/history/index.html +1 -1
- package/dist/ui/history/index.txt +14 -14
- package/dist/ui/home/__next._full.txt +13 -13
- package/dist/ui/home/__next._tree.txt +2 -2
- package/dist/ui/home/__next.home.__PAGE__.txt +11 -11
- package/dist/ui/home/index.html +1 -1
- package/dist/ui/home/index.txt +13 -13
- package/dist/ui/index.html +1 -1
- package/dist/ui/index.txt +13 -13
- package/dist/ui/preview/__next._full.txt +14 -14
- package/dist/ui/preview/__next._tree.txt +2 -2
- package/dist/ui/preview/__next.preview.__PAGE__.txt +12 -12
- package/dist/ui/preview/index.html +1 -1
- package/dist/ui/preview/index.txt +14 -14
- package/dist/ui/suite/__next._full.txt +13 -13
- package/dist/ui/suite/__next._tree.txt +2 -2
- package/dist/ui/suite/__next.suite.__PAGE__.txt +11 -11
- package/dist/ui/suite/index.html +1 -1
- package/dist/ui/suite/index.txt +13 -13
- package/dist/ui/tests/__next._full.txt +12 -12
- package/dist/ui/tests/__next._tree.txt +2 -2
- package/dist/ui/tests/__next.tests.__PAGE__.txt +10 -10
- package/dist/ui/tests/index.html +1 -1
- package/dist/ui/tests/index.txt +12 -12
- package/package.json +1 -1
- package/dist/ui/_next/static/chunks/09i5zrliu0ihk.js +0 -2
- package/dist/ui/_next/static/chunks/0_0x8uij5q9uo.js +0 -1
- package/dist/ui/_next/static/chunks/0hcsfv99w40pd.js +0 -1
- package/dist/ui/_next/static/chunks/0hzm2s0wkhmzk.js +0 -9
- package/dist/ui/_next/static/chunks/0jepa0hc-rzkw.js +0 -27
- package/dist/ui/_next/static/chunks/13nvl7bxr0ra-.js +0 -1
- package/dist/ui/_next/static/chunks/1d3l7hra87g66.js +0 -1
- package/dist/ui/_next/static/chunks/2dn12byo9lp8w.js +0 -1
- package/dist/ui/_next/static/chunks/2nuly7x38k2--.js +0 -119
- package/dist/ui/_next/static/chunks/3een3k2hd15nf.css +0 -3
- package/dist/ui/_next/static/chunks/3hn-tmfmw2hkd.js +0 -59
- /package/dist/ui/_next/static/{xVTi1MWdof3rkYYR1nxdn → emu38N9csb28KU3jv4SH4}/_buildManifest.js +0 -0
- /package/dist/ui/_next/static/{xVTi1MWdof3rkYYR1nxdn → emu38N9csb28KU3jv4SH4}/_clientMiddlewareManifest.js +0 -0
- /package/dist/ui/_next/static/{xVTi1MWdof3rkYYR1nxdn → emu38N9csb28KU3jv4SH4}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,33622,e=>{"use strict";var t=e.i(14368);e.i(24856);var s=e.i(48191);function r(e){return!!e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.testName&&Array.isArray(e.buckets)&&"object"==typeof e.summary&&null!==e.summary}var n=e.i(45404),a=e.i(29724),o=e.i(88153),i=e.i(56396),l=e.i(59180),c=e.i(67938),d=e.i(30099),p=e.i(99181);e.s(["default",0,function(){let[e,m]=(0,p.useState)(null),[u,h]=(0,p.useState)(null),[f,x]=(0,p.useState)(null),[y,v]=(0,p.useState)(null),[b,g]=(0,p.useState)(!1),[k,w]=(0,p.useState)(!1),[_,S]=(0,p.useState)(null),[T,F]=(0,p.useState)(!1),N=(0,i.useToast)(),{refresh:j}=(0,l.useHistory)();async function C(){F(!0);try{await l.historyApi.import(_),await j(),w(!0),N("Saved to History","success")}catch(e){N(e instanceof Error?e.message:"Could not save to History","error")}finally{F(!1)}}let I=(0,p.useCallback)(async e=>{x(null),w(!1),m(null),h(null);let t=e.name.toLowerCase();if(t.endsWith(".html")||t.endsWith(".xlsx")||t.endsWith(".csv")||t.endsWith(".zip")){v(e.name),x("Preview needs the JSON export from the lab. HTML and Excel are for sharing, not for opening back here.");return}try{let t=await e.text(),n=JSON.parse(t),a=function(e){if(!e||"object"!=typeof e)throw Error("That file is not JSON we can open.");if("compare"===e.kind||Array.isArray(e.apis)&&e.apis.length>0){if(!(e&&"object"==typeof e&&"compare"===e.kind&&Array.isArray(e.apis)&&e.apis.length>=1&&e.apis.every(e=>e&&"object"==typeof e&&r(e.report))))throw Error("Not a valid APITestCenter compare export.");return{kind:"compare",doc:{...e,apis:e.apis.map(e=>({...e,report:(0,s.repairSummary)(e.report)}))}}}if(r(e.report))return{kind:"report",report:(0,s.repairSummary)(e.report)};if(r(e))return{kind:"report",report:(0,s.repairSummary)(e)};throw Error("Not an APITestCenter report. Export JSON from the lab (not HTML or Excel).")}(n);S(n),v(e.name),"compare"===a.kind?h(a.doc):m(a.report)}catch(t){v(e.name),x(t instanceof Error?t.message:"Could not read that file.")}},[]);function M(e){e.preventDefault(),g(!0)}function E(e){e.preventDefault(),g(!1);let t=e.dataTransfer.files[0];t&&I(t)}let A=b?"border-accent bg-accent-dim":"border-line bg-panel",$=u?.apis.map(e=>e.title)??[],{slo:R}=(0,o.useSlo)();return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col p-6 lg:p-8",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h1",{className:"text-xl font-medium text-ink",children:"Open a report"}),(0,t.jsx)("p",{className:"mt-1 max-w-xl text-sm text-mute",children:"Reopen a JSON report you exported earlier — a single run or a compare. Excel and HTML exports are for sharing and can't be reopened."})]}),e||u?(0,t.jsxs)("label",{onDragOver:M,onDragLeave:()=>g(!1),onDrop:E,className:`inline-flex cursor-pointer items-center gap-2 rounded-md border border-dashed px-3 py-2 text-xs ${A}`,children:[(0,t.jsx)(c.FileUp,{size:14,className:"text-accent"}),"Replace JSON",(0,t.jsx)("input",{type:"file",accept:"application/json,.json",className:"sr-only",onChange:e=>{let t=e.target.files?.[0];t&&I(t),e.target.value=""}})]}):null]}),f?(0,t.jsx)("p",{className:"mt-4 text-sm text-bad",children:f}):null,u?(0,t.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"text-xs text-mute",children:[y," · compare · ",u.mode]}),(0,t.jsx)("button",{type:"button",disabled:k||T,onClick:()=>void C(),className:"rounded-md border border-line px-3 py-1.5 text-xs text-ink hover:border-accent disabled:opacity-40",children:k?"Saved to History":"Keep in History"})]}),(0,t.jsx)(n.Dashboard,{scope:"compare",data:{reports:u.apis.map(e=>e.report),titles:$,slo:R,live:!1}}),(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Open"," ",(0,t.jsx)(d.default,{href:"/compare",className:"text-accent hover:underline",children:"Compare"})," ","to re-run these APIs live."]})]}):e?(0,t.jsxs)("div",{className:"mt-6 space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("p",{className:"text-xs text-mute",children:y}),(0,t.jsx)("button",{type:"button",disabled:k||T,onClick:()=>void C(),className:"rounded-md border border-line px-3 py-1.5 text-xs text-ink hover:border-accent disabled:opacity-40",children:k?"Saved to History":"Keep in History"})]}),k?(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Open it anytime on"," ",(0,t.jsx)(d.default,{href:"/history",className:"text-accent hover:underline",children:"History"}),"."]}):null,(0,t.jsx)("div",{className:"rounded-lg border border-line bg-panel p-4",children:(0,t.jsx)(a.ReportView,{report:e,source:"file"})})]}):(0,t.jsxs)("label",{onDragOver:M,onDragLeave:()=>g(!1),onDrop:E,className:`mt-6 flex min-h-0 flex-1 cursor-pointer flex-col items-center justify-center rounded-lg border border-dashed px-8 py-16 text-center ${A}`,children:[(0,t.jsx)(c.FileUp,{size:28,className:"text-accent"}),(0,t.jsx)("span",{className:"mt-4 text-base text-ink",children:"Drop a JSON report here, or click to choose"}),(0,t.jsx)("span",{className:"mt-2 max-w-md text-sm text-mute",children:"Single-run or compare JSON from Export. HTML, Excel, and zip are for sharing — they will not open here."}),(0,t.jsx)("span",{className:"mt-4 font-mono text-xs text-mute",children:"apitestcenter-*.json"}),(0,t.jsx)("input",{type:"file",accept:"application/json,.json",className:"sr-only",onChange:e=>{let t=e.target.files?.[0];t&&I(t),e.target.value=""}})]})]})}],33622)},37837,e=>{"use strict";var t=e.i(14368),s=e.i(99181),r=e.i(68820),n=e.i(14865);e.s(["Popover",0,function({anchor:e,open:a,onClose:o,children:i,label:l,width:c=280,role:d="dialog"}){let p=(0,s.useRef)(null),[m,u]=(0,s.useState)(null);return((0,s.useLayoutEffect)(()=>{if(!a)return;let t=()=>{if(!e.current)return;let t=(0,n.pageRect)(e.current),s=(0,n.pageViewport)(),r=p.current?.offsetHeight??320,a=s.height-t.bottom-8,o=t.top-8,i=a<Math.min(r,240)&&o>a,l=Math.min(Math.max(8,t.right-c),s.width-c-8);u({top:i?Math.max(8,t.top-Math.min(r,o)-4):t.bottom+4,left:l,maxHeight:Math.max(160,(i?o:a)-4)})};t();let s=window.requestAnimationFrame(t);return window.addEventListener("resize",t),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",t)}},[a,e,c]),(0,s.useEffect)(()=>{if(!a)return;let t=t=>{let s=t.target;p.current?.contains(s)||e.current?.contains(s)||o()},s=t=>{"Escape"===t.key&&(t.stopPropagation(),o(),e.current?.focus())},r=e=>{p.current?.contains(e.target)||o()},n=t=>{e.current?.contains(t.target)&&(t.stopPropagation(),t.preventDefault(),o())};return document.addEventListener("pointerdown",t,!0),document.addEventListener("click",n,!0),document.addEventListener("keydown",s,!0),document.addEventListener("scroll",r,!0),()=>{document.removeEventListener("pointerdown",t,!0),document.removeEventListener("click",n,!0),document.removeEventListener("keydown",s,!0),document.removeEventListener("scroll",r,!0)}},[a,o,e]),(0,s.useEffect)(()=>{a&&window.setTimeout(()=>p.current?.querySelector("[role=menuitem], input, select, button")?.focus(),0)},[a]),!a||"u"<typeof document)?null:(0,r.createPortal)((0,t.jsx)("div",{ref:p,role:d,"aria-label":l,style:{top:m?.top??-9999,left:m?.left??-9999,width:c,maxHeight:m?.maxHeight},className:"anim-pop fixed z-[70] overflow-auto rounded-lg border border-line bg-panel p-3 shadow-2xl",children:i}),document.body)}])},30617,e=>{"use strict";e.i(24856);var t=e.i(46306),s=e.i(36558),r=e.i(2385),n=e.i(17219);let a={base:0,header:1,desc:2,pass:3,warn:4,fail:5};function o(e){return String(e).replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("\n"," ")}function i(e,t,s){if("level"===e)return"pass"===t?a.pass:"warn"===t?a.warn:"fail"===t?a.fail:a.base;let r="number"==typeof t?t:Number(t);return"errors"===e?r>=s.errorFail?a.fail:r>=s.errorWarn?a.warn:a.pass:r>=s.p95FailMs?a.fail:r>=s.p95WarnMs?a.warn:a.pass}let l=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
|
3
|
+
<fonts count="3">
|
|
4
|
+
<font><sz val="11"/><name val="Calibri"/></font>
|
|
5
|
+
<font><b/><sz val="11"/><color rgb="FFFFFFFF"/><name val="Calibri"/></font>
|
|
6
|
+
<font><sz val="10"/><color rgb="FF5C6778"/><name val="Calibri"/></font>
|
|
7
|
+
</fonts>
|
|
8
|
+
<fills count="6">
|
|
9
|
+
<fill><patternFill patternType="none"/></fill>
|
|
10
|
+
<fill><patternFill patternType="gray125"/></fill>
|
|
11
|
+
<fill><patternFill patternType="solid"><fgColor rgb="FF0B8F7C"/></patternFill></fill>
|
|
12
|
+
<fill><patternFill patternType="solid"><fgColor rgb="FFDCFCE7"/></patternFill></fill>
|
|
13
|
+
<fill><patternFill patternType="solid"><fgColor rgb="FFFEF3C7"/></patternFill></fill>
|
|
14
|
+
<fill><patternFill patternType="solid"><fgColor rgb="FFFECACA"/></patternFill></fill>
|
|
15
|
+
</fills>
|
|
16
|
+
<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>
|
|
17
|
+
<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>
|
|
18
|
+
<cellXfs count="6">
|
|
19
|
+
<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
|
|
20
|
+
<xf numFmtId="0" fontId="1" fillId="2" borderId="0" xfId="0" applyFont="1" applyFill="1" applyAlignment="1"><alignment horizontal="center" vertical="center"/></xf>
|
|
21
|
+
<xf numFmtId="0" fontId="2" fillId="0" borderId="0" xfId="0" applyFont="1" applyAlignment="1"><alignment wrapText="1" vertical="center"/></xf>
|
|
22
|
+
<xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1"/>
|
|
23
|
+
<xf numFmtId="0" fontId="0" fillId="4" borderId="0" xfId="0" applyFill="1"/>
|
|
24
|
+
<xf numFmtId="0" fontId="0" fillId="5" borderId="0" xfId="0" applyFill="1"/>
|
|
25
|
+
</cellXfs>
|
|
26
|
+
</styleSheet>`;async function c(e,n,o){let l=(0,r.buildVerdict)(e,{slo:n}),c=(0,r.verdictBars)(n),p=(0,t.normalizeChartLayout)(o,(0,t.hasThresholdTiles)(e));return d([{name:"Overview",rows:[[{v:"Key",s:a.header},{v:"Value",s:a.header},{v:"What this means",s:a.header}],...(0,s.summaryExportRows)(e).map(e=>{let t=a.base;return"failed_rate"===e.key&&(t=i("errors",e.value,c)),"latency_p95_ms"===e.key&&(t=i("latency",e.value,c)),(e.key.startsWith("status_5")||"status_0"===e.key)&&(t=Number(e.value)>0?a.fail:a.pass),e.key.startsWith("status_4")&&Number(e.value)>0&&(t=a.warn),e.key.startsWith("threshold:")&&(t="pass"===e.value?a.pass:a.fail),[{v:e.key},{v:e.value,s:t},{v:e.description,s:a.desc}]})]},{name:"Result summary",rows:[[{v:"Field",s:a.header},{v:"Level",s:a.header},{v:"What this means",s:a.header}],[{v:"overall"},{v:l.overall,s:i("level",l.overall,c)},{v:l.headline,s:a.desc}],...l.aspects.map(e=>[{v:e.title},{v:e.level,s:i("level",e.level,c)},{v:e.summary,s:a.desc}]),[{v:"disclaimer"},{v:""},{v:l.disclaimer,s:a.desc}],...p.map((e,s)=>[{v:`chart_${s+1}`},{v:`${e.w}x${e.h}`},{v:t.CHART_TILE_TITLES[e.id],s:a.desc}])]},{name:"Second by second",rows:[s.SERIES_COLUMNS.map(e=>({v:e.header,s:a.header})),...e.buckets.map(e=>(0,s.seriesExportRow)(e).map((e,t)=>{let r=s.SERIES_COLUMNS[t]?.key,n=a.base;return"p95_ms"===r&&(n=i("latency",e,c)),"failed_rate"===r&&(n=i("errors",e,c)),"http_5xx"===r&&Number(e)>0&&(n=a.fail),"http_0"===r&&Number(e)>0&&(n=a.fail),"http_4xx"===r&&Number(e)>0&&(n=a.warn),"http_2xx"===r&&Number(e)>0&&(n=a.pass),{v:e,s:n}}))]}])}function d(e){let t={"[Content_Types].xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
27
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
28
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
29
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
30
|
+
<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
|
|
31
|
+
<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>
|
|
32
|
+
${e.map((e,t)=>` <Override PartName="/xl/worksheets/sheet${t+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("\n")}
|
|
33
|
+
</Types>`,"_rels/.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
34
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
35
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
|
|
36
|
+
</Relationships>`,"xl/workbook.xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
37
|
+
<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
38
|
+
<sheets>
|
|
39
|
+
${e.map((e,t)=>` <sheet name="${o(e.name.replace(/[:\\/?*[\]]/g," ").trim().slice(0,31)||"Sheet")}" sheetId="${t+1}" r:id="rId${t+1}"/>`).join("\n")}
|
|
40
|
+
</sheets>
|
|
41
|
+
</workbook>`,"xl/_rels/workbook.xml.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
42
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
43
|
+
${e.map((e,t)=>` <Relationship Id="rId${t+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${t+1}.xml"/>`).join("\n")}
|
|
44
|
+
<Relationship Id="rId${e.length+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
|
|
45
|
+
</Relationships>`,"xl/styles.xml":l};return e.forEach((e,s)=>{var r;let n,a,i;return t[`xl/worksheets/sheet${s+1}.xml`]=(r=e.rows,a=Array.from({length:n=r[0]?.length??0},(e,t)=>{let s=function(e,t,s=10,r=48){let n=s;for(let s of e){let e=s[t]?.v;void 0!==e&&(n=Math.max(n,String(e).length+2))}return Math.min(r,n)}(r,t,t===n-1&&n>=3?36:12,t===n-1&&n>=3?72:42);return`<col min="${t+1}" max="${t+1}" width="${s}" customWidth="1"/>`}).join(""),i=r.map((e,t)=>`<row r="${t+1}" ht="${0===t?22:18}" customHeight="1">${e.map((e,s)=>{var r;let n,a;return r=t+1,n=`${function(e){let t=e+1,s="";for(;t>0;)s=String.fromCharCode(65+(t-1)%26)+s,t=Math.floor((t-1)/26);return s}(s)}${r}`,a=void 0!==e.s?` s="${e.s}"`:"","number"==typeof e.v&&Number.isFinite(e.v)?`<c r="${n}"${a}><v>${e.v}</v></c>`:`<c r="${n}"${a} t="inlineStr"><is><t xml:space="preserve">${o(e.v)}</t></is></c>`}).join("")}</row>`).join(""),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
46
|
+
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
|
47
|
+
<sheetViews><sheetView workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>
|
|
48
|
+
<cols>${a}</cols>
|
|
49
|
+
<sheetData>${i}</sheetData>
|
|
50
|
+
</worksheet>`)}),new Blob([(0,n.zipStore)(t)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}e.s(["S",0,a,"exportRunXlsx",0,c,"xlsxBook",0,d])},17219,e=>{"use strict";let t=new Uint32Array(256).map((e,t)=>{let s=t;for(let e=0;e<8;e++)s=1&s?0xedb88320^s>>>1:s>>>1;return s>>>0});function s(e){let t=new Uint8Array(2);return new DataView(t.buffer).setUint16(0,e,!0),t}function r(e){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),t}function n(e){let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),s=0;for(let r of e)t.set(r,s),s+=r.length;return t}e.s(["zipStore",0,function(e){let a=new TextEncoder,o=[],i=[],l=0;for(let[c,d]of Object.entries(e)){let e=a.encode(c),p="string"==typeof d?a.encode(d):d,m=function(e){let s=0xffffffff;for(let r of e)s=t[(s^r)&255]^s>>>8;return(0xffffffff^s)>>>0}(p),u=n([r(0x4034b50),s(20),s(0),s(0),s(0),s(0),r(m),r(p.length),r(p.length),s(e.length),s(0),e,p]),h=n([r(0x2014b50),s(20),s(20),s(0),s(0),s(0),s(0),r(m),r(p.length),r(p.length),s(e.length),s(0),s(0),s(0),s(0),r(0),r(l),e]);o.push(u),i.push(h),l+=u.length}let c=n(i),d=n([r(0x6054b50),s(0),s(0),s(Object.keys(e).length),s(Object.keys(e).length),r(c.length),r(l),s(0)]),p=n([...o,c,d]);return new Blob([p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength)],{type:"application/zip"})}])},13643,e=>{"use strict";let t=(0,e.i(99522).default)("bell-off",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]]);e.s(["BellOff",0,t],13643)},95211,e=>{"use strict";let t=(0,e.i(99522).default)("columns-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);e.s(["Columns3",0,t],95211)},81538,e=>{"use strict";let t=(0,e.i(99522).default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);e.s(["MoreHorizontal",0,t],81538)},36558,e=>{"use strict";function t(e,s=2){if(!Number.isFinite(e))return 0;let r=10**s;return Math.round(e*r)/r}function s(e){return e>=100?Math.round(e):e>=10?t(e,1):t(e,2)}function r(e){return e>=10?Math.round(e):t(e,1)}function n(e,t=e=>e){return null==e?"":t(e)}e.s(["SERIES_COLUMNS",0,[{key:"elapsed_s",header:"Seconds into test",description:"Seconds from the start of the run."},{key:"ts",header:"Clock time",description:"Wall-clock time for this one-second sample."},{key:"vus",header:"Concurrent users",description:"Virtual users (VUs) active in this second."},{key:"rps",header:"Requests per second",description:"Completed requests in this second."},{key:"p50_ms",header:"Median latency (ms)",description:"Half of requests this second were faster than this."},{key:"p95_ms",header:"95th percentile (ms)",description:"95% of requests this second were faster than this."},{key:"p99_ms",header:"99th percentile (ms)",description:"The slow tail this second — 1 in 100 was slower."},{key:"failed_rate",header:"Error rate",description:"Share of requests that failed in this second (0–1)."},{key:"http_2xx",header:"Success (2xx)",description:"Successful HTTP responses this second."},{key:"http_4xx",header:"Client errors (4xx)",description:"Client / auth errors this second."},{key:"http_5xx",header:"Server errors (5xx)",description:"Server errors this second."},{key:"http_0",header:"Network failures",description:"No HTTP status (timeout / reset) this second."},{key:"bytes_in",header:"Bytes received",description:"Response bytes this second."},{key:"bytes_out",header:"Bytes sent",description:"Request bytes this second."},{key:"p90_ms",header:"90th percentile (ms)",description:"90% of requests this second were faster than this."},{key:"p999_ms",header:"99.9th percentile (ms)",description:"1 in 1,000 requests this second was slower than this."},{key:"max_ms",header:"Slowest (ms)",description:"Slowest request this second."},{key:"ttfb_ms",header:"Server time (ms)",description:"Average time to first byte this second — the server's own work."},{key:"connect_ms",header:"TCP connect (ms)",description:"Average TCP connect time this second (0 when connections are reused)."},{key:"tls_ms",header:"TLS handshake (ms)",description:"Average TLS handshake time this second."},{key:"checks_passed",header:"Checks passed",description:"Response checks that passed this second."},{key:"checks_failed",header:"Checks failed",description:"Response checks that failed this second."},{key:"dropped",header:"Dropped requests",description:"Rate mode: requests k6 could not start this second."}],"seriesExportRow",0,function(e){return[e.elapsedS,e.ts,t(e.vus,1),s(e.rps),r(e.p50Ms),r(e.p95Ms),r(e.p99Ms),t(e.failedRate,4),e.http2xx,e.http4xx,e.http5xx,e.http0,e.bytesIn,e.bytesOut,n(e.p90Ms,r),n(e.p999Ms,r),n(e.maxMs,r),n(e.ttfbMs,r),n(e.connectMs,r),n(e.tlsMs,r),n(e.checksPassed),n(e.checksFailed),n(e.dropped)]},"summaryExportRows",0,function(e){let{summary:n}=e,a=[{key:"run_id",value:e.id,description:"Id of this run in this browser tab."},{key:"test_name",value:e.testName,description:"Display name (method, path, time)."},{key:"status",value:e.status,description:"completed, failed, cancelled, or still running."},{key:"started_at",value:e.startedAt,description:"When the load test started (UTC)."},{key:"ended_at",value:e.endedAt,description:"When the load test finished (UTC)."},{key:"method",value:e.definition.method,description:"HTTP method that was repeated."},{key:"url",value:e.definition.url,description:"Target URL (secrets are not exported)."},{key:"auth_mode",value:e.definition.auth.mode,description:"Auth used: none, bearer, basic, or api_key. The secret is not exported."},{key:"executor",value:e.definition.load.executor,description:"Load pattern: constant-vus (steady) or ramping-vus (ramp / hold / down)."},{key:"requests",value:n.http.requests,description:"How many HTTP calls finished. Zero usually means the target never answered."},{key:"rps_avg",value:s(n.http.rps.avg),description:"Average requests per second completed by this generator."},{key:"rps_max",value:s(n.http.rps.max),description:"Peak requests per second in any one-second sample."},{key:"failed_count",value:n.http.failed.count,description:"Requests that failed (4xx, 5xx, timeout, or no status)."},{key:"failed_rate",value:t(n.http.failed.rate,4),description:"Failed / total. Default warning bar is 1% (0.01)."},{key:"latency_min_ms",value:r(n.latencyMs.min),description:"Fastest request (milliseconds)."},{key:"latency_mean_ms",value:r(n.latencyMs.mean),description:"Average response time. Slow outliers pull this up."},{key:"latency_p50_ms",value:r(n.latencyMs.median),description:"Median — half of requests were faster than this."},{key:"latency_p95_ms",value:r(n.latencyMs.p95),description:"95th percentile — 95% of requests were faster. Usual headline latency."},{key:"latency_p99_ms",value:r(n.latencyMs.p99),description:"99th percentile — the slow tail (1 in 100 was slower)."},{key:"latency_max_ms",value:r(n.latencyMs.max),description:"Slowest single request."},{key:"vus_max",value:n.vus.max,description:"Peak concurrent users (virtual users / VUs)."},{key:"vus_avg",value:t(n.vus.avg,1),description:"Average concurrent users over the run."},{key:"bytes_in",value:n.data.bytesIn,description:"Response bytes received by the generator."},{key:"bytes_out",value:n.data.bytesOut,description:"Request bytes sent by the generator."},{key:"phase_ttfb_avg_ms",value:r(n.phasesMs.ttfb.avg),description:"Time to first byte — waiting on the server after the connection is up."},{key:"phase_tls_avg_ms",value:r(n.phasesMs.tls.avg),description:"TLS handshake time. High values often mean a far or overloaded endpoint."}];for(let[e,t]of Object.entries(n.http.status)){let s="0"===e?"No HTTP status (timeout / network).":Number(e)>=500?"Server error.":Number(e)>=400?"Client / auth error.":"Success-class response.";a.push({key:`status_${e}`,value:t,description:`How many responses had status ${e}. ${s}`})}for(let e of n.thresholds)a.push({key:`threshold:${e.name}`,value:e.ok?"pass":"fail",description:"k6 threshold result for this run."});return a}])}]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63343,44794,54792,88871,36620,73436,12580,55680,e=>{"use strict";var t=e.i(14368);e.i(24856);var s=e.i(59100),n=e.i(30340),a=e.i(71189),r=e.i(87283),l=e.i(99181),i=e.i(22543),o=e.i(31753),c=e.i(28867);e.i(42674);var d=e.i(5305);function u({label:e,value:s,min:n,max:a,onChange:r,hint:l}){return(0,t.jsxs)("label",{className:"block",children:[(0,t.jsxs)("span",{className:"mb-1 flex items-center gap-1 text-xs text-mute",children:[e,l?(0,t.jsx)(i.Hint,{label:`About ${e}`,text:l}):null]}),(0,t.jsx)("input",{type:"number",min:n,max:a,value:s,onChange:e=>r(h(e.target.value,n,a)),className:"input font-mono"})]})}function p({stages:e,unit:s,rate:n,onChange:l}){let i=(t,s)=>l(e.map((e,n)=>n===t?{...e,...s}:e));return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("p",{className:"text-xs text-mute",children:"Each stage moves linearly to its target over its duration. Hold steady by repeating the same target."}),(0,t.jsxs)("div",{className:"overflow-hidden rounded-md border border-line",children:[(0,t.jsxs)("div",{className:"grid grid-cols-[2.5rem_minmax(0,1fr)_minmax(0,1fr)_2rem] bg-panel-2 text-xs text-mute",children:[(0,t.jsx)("span",{className:"px-2 py-1.5",children:"#"}),(0,t.jsx)("span",{className:"border-l border-line px-2 py-1.5",children:"Duration"}),(0,t.jsxs)("span",{className:"border-l border-line px-2 py-1.5",children:["Target (",s,")"]}),(0,t.jsx)("span",{})]}),e.map((s,a)=>{let o=(0,d.durationError)(s.duration,!1);return(0,t.jsxs)("div",{className:"grid grid-cols-[2.5rem_minmax(0,1fr)_minmax(0,1fr)_2rem] border-t border-line",children:[(0,t.jsx)("span",{className:"px-2 py-1.5 font-mono text-xs text-mute",children:a+1}),(0,t.jsx)("input",{"aria-label":`Stage ${a+1} duration`,"aria-invalid":!!o||void 0,title:o,value:s.duration,onChange:e=>i(a,{duration:e.target.value}),className:`min-w-0 border-l border-line bg-transparent px-2 py-1.5 font-mono text-[13px] outline-none focus:bg-panel-2 ${o?"text-bad":"text-ink"}`}),(0,t.jsx)("input",{"aria-label":`Stage ${a+1} target`,type:"number",min:0,max:n?1e5:500,value:s.target,onChange:e=>i(a,{target:h(e.target.value,0,n?1e5:500)}),className:"min-w-0 border-l border-line bg-transparent px-2 py-1.5 font-mono text-[13px] text-ink outline-none focus:bg-panel-2"}),(0,t.jsx)("button",{type:"button","aria-label":`Remove stage ${a+1}`,disabled:e.length<=1,onClick:()=>l(e.filter((e,t)=>t!==a)),className:"grid place-items-center text-mute hover:text-bad disabled:opacity-30",children:(0,t.jsx)(r.X,{size:13})})]},a)})]}),(0,t.jsxs)("button",{type:"button",disabled:e.length>=20,onClick:()=>l([...e,{duration:"30s",target:e[e.length-1]?.target??1}]),className:"inline-flex items-center gap-1 text-xs text-accent hover:underline disabled:opacity-40",children:[(0,t.jsx)(a.Plus,{size:12,"aria-hidden":!0})," Add stage"]})]})}function h(e,t,s){let n=Math.round(Number(e));return Number.isFinite(n)?Math.min(s,Math.max(t,n)):t}function m(e){let t="rate"===e.mode;if(e.stages&&e.stages.length){let t=[[0,0]],n=0;for(let a of e.stages)n+=(0,s.durationToMs)(a.duration),t.push([n,a.target]);return{points:t,totalMs:n,peak:Math.max(0,...e.stages.map(e=>e.target))}}let n=t?e.rps??20:e.vus,a=(0,s.durationToMs)(e.rampUp),r=(0,s.durationToMs)(e.duration),l=(0,s.durationToMs)(e.rampDown);return{points:[[0,a>0?0:n],[a,n],[a+r,n],[a+r+l,l>0?0:n]],totalMs:a+r+l,peak:n}}function x(e){let{totalMs:t,peak:s}=m(e),n="rate"===e.mode?"req/s":1===s?"VU":"VUs";return`${e.stages?.length?"peak ":""}${s.toLocaleString()} ${n} \xb7 ${f(t)}`}function f(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60);return s<60?t%60?`${s}m ${t%60}s`:`${s}m`:`${Math.floor(s/60)}h ${s%60}m`}function b({load:e}){let{points:s,totalMs:n,peak:a}=m(e),r=s.map(([e,t])=>`${e/Math.max(n,1)*300},${56-t/Math.max(a,1)*50}`).join(" "),l=`0,56 ${r} 300,56`;return(0,t.jsxs)("figure",{className:"rounded-md border border-line bg-panel-2 px-3 py-2",children:[(0,t.jsxs)("figcaption",{className:"mb-1 flex justify-between text-xs text-mute",children:[(0,t.jsx)("span",{children:"Planned load"}),(0,t.jsx)("span",{className:"font-mono text-ink",children:x(e)})]}),(0,t.jsxs)("svg",{viewBox:"0 0 300 56",preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":`Load profile: ${x(e)}`,children:[(0,t.jsx)("polygon",{points:l,fill:"var(--series-1)",fillOpacity:.15}),(0,t.jsx)("polyline",{points:r,fill:"none",stroke:"var(--series-1)",strokeWidth:2,vectorEffect:"non-scaling-stroke"})]}),(0,t.jsxs)("div",{className:"mt-1 flex justify-between font-mono text-[11px] text-mute",children:[(0,t.jsx)("span",{children:"0s"}),(0,t.jsx)("span",{children:"rate"===e.mode?"requests per second":"simulated users"}),(0,t.jsx)("span",{children:f(n)})]})]})}e.s(["LoadEditor",0,function({load:e,onChange:a}){var r;let h,[m,x]=(0,l.useState)(!1),f=t=>a({...e,...t,preset:"custom"}),g="rate"===e.mode,v=!!(e.stages&&e.stages.length);return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"mb-1 block text-xs text-mute",children:"Test type"}),(0,t.jsx)(c.Segmented,{label:"Test type",value:e.preset,onChange:t=>a((0,d.applyPreset)(e,t)),options:[...n.TEST_TYPES.map(e=>({value:e.id,label:e.label})),{value:"custom",label:"Custom"}]}),(0,t.jsx)("p",{className:"mt-2 text-xs text-mute",children:(r=e.preset,(h=n.TEST_TYPES.find(e=>e.id===r))?`${h.question} ${h.hint}`:"Your own numbers — change users, duration or stages below.")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{className:"mb-1 flex items-center gap-1 text-xs text-mute",children:["Drive load by",(0,t.jsx)(i.Hint,{label:"About users vs rate",text:"Simulated users (VUs): N clients each send, wait for the answer, and send again — a slow API gets fewer requests. Requests per second: k6 holds the rate whatever the API does — the honest way to test capacity."})]}),(0,t.jsx)(c.Segmented,{label:"Drive load by",value:e.mode??"users",onChange:e=>f({mode:e}),options:[{value:"users",label:"Simulated users"},{value:"rate",label:"Requests per second"}]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"mb-1 block text-xs text-mute",children:"Shape"}),(0,t.jsx)(c.Segmented,{label:"Load shape",value:v?"stages":"simple",onChange:function(t){if("simple"===t)return f({stages:null});let n=g?e.rps??20:e.vus,a=[];(0,s.durationToMs)(e.rampUp)>0&&a.push({duration:e.rampUp,target:n}),a.push({duration:e.duration,target:n}),(0,s.durationToMs)(e.rampDown)>0&&a.push({duration:e.rampDown,target:0}),f({stages:a})},options:[{value:"simple",label:"Ramp · hold · down"},{value:"stages",label:"Step by step"}]})]})]}),v?(0,t.jsx)(p,{stages:e.stages,unit:g?"req/s":"VUs",rate:g,onChange:e=>f({stages:e})}):(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[g?(0,t.jsx)(u,{label:"Requests / second",value:e.rps??20,min:1,max:1e5,onChange:e=>f({rps:e})}):(0,t.jsx)(u,{label:"Simulated users",hint:"Concurrent clients running from this computer. 50+ will load both the API and this machine.",value:e.vus,min:1,max:500,onChange:e=>f({vus:e})}),(0,t.jsx)(o.LabeledInput,{label:"Hold for",mono:!0,value:e.duration,error:(0,d.durationError)(e.duration,!1),onChange:e=>f({duration:e})}),(0,t.jsx)(o.LabeledInput,{label:"Ramp up",mono:!0,value:e.rampUp,error:(0,d.durationError)(e.rampUp),onChange:e=>f({rampUp:e})}),(0,t.jsx)(o.LabeledInput,{label:"Ramp down",mono:!0,value:e.rampDown,error:(0,d.durationError)(e.rampDown),onChange:e=>f({rampDown:e})})]}),g?(0,t.jsx)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:(0,t.jsx)(u,{label:"Max simulated users",hint:"k6 starts more VUs when responses slow down, up to this ceiling. If it runs out, requests are dropped and the report says how many.",value:e.maxVus??100,min:1,max:2e3,onChange:e=>f({maxVus:e})})}):null,(0,t.jsx)(b,{load:e}),(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>x(e=>!e),"aria-expanded":m,children:m?"Hide pacing options":"Pacing options"}),m?(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[g?(0,t.jsx)("p",{className:"text-xs text-mute sm:col-span-2",children:"Think time does not apply when holding a request rate — k6 paces the requests itself."}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{label:"Think time (ms)",value:e.thinkTimeMs,min:0,max:6e5,onChange:e=>f({thinkTimeMs:e})}),(0,t.jsx)(u,{label:"Random extra (ms)",value:e.thinkJitterMs,min:0,max:6e5,onChange:e=>f({thinkJitterMs:e})})]}),(0,t.jsx)(o.LabeledInput,{label:"Graceful stop",mono:!0,value:e.gracefulStop,error:(0,d.durationError)(e.gracefulStop),onChange:e=>f({gracefulStop:e}),hint:"Time in-flight requests get to finish."})]}):null]})},"profileSummary",0,x],63343);var g=e.i(1675),v=e.i(458),y=e.i(84575),j=e.i(80707),w=e.i(70746);let k=null,N=null,$=new Set;function C(){return N??=fetch("/engine/local-servers",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>(e&&(k=e.servers),k)).catch(()=>k).finally(()=>{N=null,$.forEach(e=>e())}),$.forEach(e=>e()),N}var S=e.i(6278);let T=/^\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/,q=/^(https?):\/\/(localhost|127\.0\.0\.1)(?::(\d{1,5}))?(?=[/?#]|$)/i,E="\0none",M="\0local-other",R="apitestcenter-local-ports",A={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad",HEAD:"text-mute",OPTIONS:"text-mute"};function D(){try{let e=JSON.parse(localStorage.getItem(R)??"[]");return(Array.isArray(e)?e.filter(e=>Number.isInteger(e)&&e>0&&e<65536):[]).slice(0,5)}catch{return[]}}function L(e){try{localStorage.setItem(R,JSON.stringify([e,...D().filter(t=>t!==e)].slice(0,5)))}catch{}}let H=(0,l.forwardRef)(function({draft:e,onChange:s,onImported:n,actions:a},i){let{vars:o,environments:c,activeEnv:u}=(0,S.useWorkspace)(),p=(0,w.useConnections)(),h=(0,l.useRef)(null);(0,l.useImperativeHandle)(i,()=>h.current);let[m,x]=(0,l.useState)([]),[f,b]=(0,l.useState)(null),[R,H]=(0,l.useState)(!1),z=(0,l.useRef)(null);(0,l.useEffect)(()=>x(D()),[]),(0,l.useEffect)(()=>{f&&z.current?.focus()},[f]);let P=e.url,F=T.exec(P)?.[1],O=Object.entries(o).filter(([e,t])=>/^https?:\/\//i.test(t.trim())&&("practiceApi"!==e||F===e)),U=p.filter(e=>!O.some(([t])=>t===e.variable)).map(e=>[e.variable,e.baseUrl,e.name]),I=[...O,...U.map(([e,t])=>[e,t])],B=(()=>{if(R)return null;let e=T.exec(P);if(e&&I.some(([t])=>t===e[1]))return{prefix:e[0],text:`{{${e[1]}}}`,value:e[1]};let t=q.exec(P);if(t){let e=t[1].toLowerCase(),s=t[3]??("https"===e?"443":"80");return{prefix:t[0],text:`${t[2]}${t[3]?`:${t[3]}`:""}`,value:`local:${e}:${s}`}}return null})(),V=P.startsWith("/"),W=V||""===P||null!=B,_=function(e){let[,t]=(0,l.useState)(0);(0,l.useEffect)(()=>{let e=()=>t(e=>e+1);return $.add(e),()=>void $.delete(e)},[]),(0,l.useEffect)(()=>{e&&null==k&&!N&&C()},[e]);let s=(0,l.useCallback)(()=>void C(),[]);return{servers:k??[],checked:null!=k,checking:null!=N,refresh:s}}(W),K=B?P.slice(B.prefix.length):P,J=e=>{let t=""===K||K.startsWith("/")||K.startsWith("?")?K:`/${K}`;return`${e}${t||(e.startsWith("{{")?"":"/")}`},X=t=>{let n=/^(https?:\/\/|\{\{)/i.test(t.trim())||""===K&&""!==t&&!/^[/?#]/.test(t);/^https?:\/\//i.test(t.trim())&&H(!0),s((0,d.withUrl)(e,B&&!n?`${B.prefix}${t}`:t))},G=(0,y.useVariableSuggest)(h,X),Z=_.servers,Q=[...Z.map(e=>({value:`local:${e.scheme}:${e.port}`,label:`localhost:${e.port}`,hint:[e.name,e.scheme,e.selfSigned?"self-signed":""].filter(Boolean).join(" · "),text:`localhost ${e.port} ${e.name??""}`,className:"font-mono",group:"local",inline:!0})),...m.filter(e=>!Z.some(t=>t.port===e)).map(e=>({value:`local:http:${e}`,label:`localhost:${e}`,hint:_.checked?"used before · not running now":"used before",text:`localhost ${e}`,className:"font-mono text-mute",group:"local",inline:!0}))];B?.value.startsWith("local:")&&!Q.some(e=>e.value===B.value)&&Q.unshift({value:B.value,label:B.text,hint:"in this request",text:B.text,className:"font-mono",group:"local",inline:!0});let Y=null!=B&&!B.value.startsWith("local:"),ee=[...U.length?[{id:"connections",label:"Connections",text:"connections",defaultOpen:!0}]:[],...O.length?[{id:"env",label:u?.name??"Variables",text:u?.name??"variables",defaultOpen:Y||null==B,action:c.length>1?{label:"switch",title:"Choose another environment",onClick:()=>setTimeout(()=>document.querySelector('button[role="combobox"][aria-label="Environment"]')?.click(),0)}:void 0}]:[],{id:"local",label:"Localhost",text:"localhost",hint:_.checking&&!_.checked?"checking…":`${Z.length||"none"} running${_.checking?" · checking…":""}`,defaultOpen:!I.length&&null==B,action:{label:(0,t.jsx)(v.RefreshCw,{size:12,"aria-hidden":!0,className:_.checking?"animate-spin":""}),title:"Check again for running servers",onClick:_.refresh,keepOpen:!0}}],et=B?"text-accent":V?"text-warn":"text-mute";return(0,t.jsxs)("div",{className:"flex flex-wrap items-stretch gap-2",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-[1_1_28rem] overflow-hidden rounded-lg border border-line bg-panel-2 focus-within:border-accent",children:[(0,t.jsx)(j.Select,{label:"Method",value:e.method,onChange:t=>s({...e,method:t}),options:d.METHODS.map(e=>({value:e,label:e,className:`font-mono font-medium ${A[e]}`})),minWidth:140,className:`shrink-0 border-r border-line px-3 font-mono text-sm font-medium outline-none focus-visible:bg-panel ${A[e.method]}`}),f?(0,t.jsxs)("form",{className:"flex shrink-0 items-center gap-1 border-r border-line px-2 font-mono text-xs",onSubmit:t=>{t.preventDefault(),(()=>{if(!f)return;let t=Number(f.port);!Number.isInteger(t)||t<1||t>65535||(L(t),x(D()),s((0,d.withUrl)(e,J(`${f.scheme}://localhost:${t}`))),b(null))})()},onKeyDown:e=>"Escape"===e.key&&b(null),children:[(0,t.jsx)("button",{type:"button",title:"Switch between http and https",onClick:()=>b({...f,scheme:"http"===f.scheme?"https":"http"}),className:"rounded px-1 text-accent hover:bg-panel",children:f.scheme}),(0,t.jsx)("span",{className:"text-mute",children:"://localhost:"}),(0,t.jsx)("input",{ref:z,value:f.port,onChange:e=>b({...f,port:e.target.value.replace(/\D/g,"").slice(0,5)}),inputMode:"numeric",placeholder:"8080","aria-label":"Port",className:"w-14 rounded border border-line bg-panel px-1.5 py-0.5 text-ink outline-none focus:border-accent"}),(0,t.jsx)("button",{type:"submit","aria-label":"Use this port",className:"rounded p-0.5 text-accent hover:bg-panel",children:(0,t.jsx)(g.Check,{size:14})}),(0,t.jsx)("button",{type:"button","aria-label":"Cancel",onClick:()=>b(null),className:"rounded p-0.5 text-mute hover:text-ink",children:(0,t.jsx)(r.X,{size:14})})]}):W?(0,t.jsx)(j.Select,{label:"Base URL",value:B?.value??E,onChange:t=>{if(t===M)return b({scheme:"http",port:""});if(t===E)return s((0,d.withUrl)(e,K));if(t.startsWith("local:")){let[,n,a]=t.split(":"),r=Number(a);return L(r),x(D()),s((0,d.withUrl)(e,J(`${n}://localhost:${r}`)))}s((0,d.withUrl)(e,J(`{{${t}}}`)))},onOpen:_.refresh,minWidth:320,buttonContent:B?.text??"Base URL",groups:ee,options:[...U.map(([e,t,s])=>({value:e,label:`{{${e}}}`,hint:`${s} \xb7 ${t}`,text:`${e} ${s}`,className:"font-mono text-accent",group:"connections"})),...O.map(([e,t])=>({value:e,label:`{{${e}}}`,hint:t,text:e,className:"font-mono text-accent",group:"env"})),...Q,{value:M,label:"Another port…",text:"another port",group:"local"},{value:E,label:"No base URL — type the whole address",text:"no"}],className:`shrink-0 border-r border-line px-2.5 font-mono text-xs outline-none focus-visible:bg-panel ${et}`}):null,(0,t.jsx)("label",{className:"sr-only",htmlFor:"request-url",children:"Request URL"}),(0,t.jsx)("input",{...G.handlers,ref:h,id:"request-url",value:K,spellCheck:!1,autoComplete:"off",onChange:e=>X(e.target.value),onKeyDown:e=>void G.onKeyDown(e),onBlur:()=>{H(!1),G.handlers.onBlur()},onPaste:t=>{let a=(0,d.withPaste)(e,t.clipboardData.getData("text"));a&&(t.preventDefault(),s(a.draft),a.note&&n?.(a.note))},placeholder:B?"/path — after the base URL":"Paste a URL or a curl command, or type a /path",className:"min-w-0 flex-1 bg-transparent px-3 py-2.5 font-mono text-sm text-ink outline-none placeholder:text-mute"})]}),G.popup,(0,t.jsx)("div",{className:"flex shrink-0 gap-2",children:a})]})});e.s(["RequestBar",0,H],44794);var z=e.i(99522);let P=(0,z.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);e.s(["ChevronUp",0,P],54792);let F=(0,z.default)("wrap-text",[["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["path",{d:"M3 18h7",key:"sq21v6"}],["path",{d:"M3 6h18",key:"d0wm0j"}]]);e.s(["WrapText",0,F],88871);let O="<hidden>";function U(e){let t=new Set(e.secretHeaders.map(e=>e.toLowerCase())),s=e.headers.map(([e,s])=>[e,t.has(e.toLowerCase())?function(e,t){if("authorization"===e.toLowerCase()||"proxy-authorization"===e.toLowerCase()){let e=/^(\w+)\s+/.exec(t);if(e)return`${e[1]} ${O}`}return O}(e,s):s]),n=e.url;if(e.secretQuery.length)try{let t=new URL(e.url);for(let s of e.secretQuery)t.searchParams.has(s)&&t.searchParams.set(s,O);n=t.toString().replace(/%3Chidden%3E/g,O)}catch{}return{...e,url:n,headers:s}}let I=[{id:"curl",label:"curl"},{id:"powershell",label:"PowerShell"},{id:"javascript",label:"JavaScript"},{id:"python",label:"Python"},{id:"csharp",label:"C#"},{id:"java",label:"Java"},{id:"go",label:"Go"},{id:"k6",label:"k6 load test"}],B=new Set(["host","content-length","connection","accept-encoding"]);function V(e){return e.headers.filter(([e,t])=>!B.has(e.toLowerCase())&&!("user-agent"===e.toLowerCase()&&t.startsWith("ApiTestCenter/")))}let W=e=>JSON.stringify(e),_=e=>`'${e.replace(/'/g,"'\\''")}'`,K=e=>`'${e.replace(/'/g,"''")}'`,J=e=>`@"${e.replace(/"/g,'""')}"`;var X=e.i(89932);let G=(0,z.default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Eye",0,G],36620);let Z=(0,z.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);e.s(["EyeOff",0,Z],73436);var Q=e.i(42967),Y=e.i(56396);let ee="apitestcenter-code-target";e.s(["ResponseCookiesView",0,function({cookies:e}){let[s,n]=(0,l.useState)(!1);return(0,t.jsxs)("div",{className:"space-y-2 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Set by this answer",e.length>1?" and the redirects on the way":"",". With the cookie jar on, they go with the next requests to the same site."]}),(0,t.jsxs)("button",{type:"button",onClick:()=>n(e=>!e),"aria-pressed":s,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[s?(0,t.jsx)(Z,{size:12,"aria-hidden":!0}):(0,t.jsx)(G,{size:12,"aria-hidden":!0}),s?"Hide values":"Show values"]})]}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsxs)("table",{className:"w-full text-left text-[13px]",children:[(0,t.jsx)("thead",{className:"bg-panel-2 text-xs text-mute",children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Name"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Value"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Domain · path"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Expires"}),(0,t.jsx)("th",{className:"px-3 py-1.5 font-normal",children:"Flags"})]})}),(0,t.jsx)("tbody",{children:e.map((e,n)=>{var a;return(0,t.jsxs)("tr",{className:"border-t border-line align-top",children:[(0,t.jsx)("td",{className:"px-3 py-1.5 font-mono text-ink",children:e.name}),(0,t.jsx)("td",{className:`max-w-[16rem] px-3 py-1.5 font-mono break-all ${s?"text-ink":"text-mute italic"}`,children:s?e.value||"(empty)":O}),(0,t.jsxs)("td",{className:"px-3 py-1.5 font-mono text-xs text-mute",children:[e.domain??"this host"," · ",e.path??"/"]}),(0,t.jsx)("td",{className:"px-3 py-1.5 text-xs text-mute",children:void 0!==e.maxAge?e.maxAge<=0?"deleted":`in ${(a=e.maxAge)<120?`${a} s`:a<7200?`${Math.round(a/60)} min`:a<172800?`${Math.round(a/3600)} h`:`${Math.round(a/86400)} days`}`:e.expires?new Date(e.expires).toLocaleString():"when the app closes"}),(0,t.jsx)("td",{className:"px-3 py-1.5 text-xs text-mute",children:[e.httpOnly?"HttpOnly":"",e.secure?"Secure":"",e.sameSite?`SameSite=${e.sameSite}`:""].filter(Boolean).join(" · ")||"—"})]},n)})})]})})]})},"SentRequestView",0,function({sent:e}){let s=(0,Y.useToast)(),[n,a]=(0,l.useState)(!1),[r,i]=(0,l.useState)("curl");(0,l.useEffect)(()=>i(function(){try{let e=localStorage.getItem(ee);if(I.some(t=>t.id===e))return e}catch{}return"curl"}()),[]);let o=(0,l.useMemo)(()=>n?e:U(e),[e,n]),c=(0,l.useMemo)(()=>(function(e,t){if(t.form||t.file)return function(e,t){let s=t.form,n=t.file,a=V(t).filter(([e])=>!(s&&"content-type"===e.toLowerCase())),r=t.method.toUpperCase(),l=(s??[]).filter(e=>void 0!==e.file),i=l.length+ +!!n===1,o=e=>`${e} ${i?"The file name stands for the file you chose: put its path there.":"File names stand for the files you chose: put their paths there."}`,c=e=>e.replace(/["\\\r\n]/g,"_"),d=[];switch(e){case"curl":for(let[e,s]of(d.push(`curl -X ${r} ${_(t.url)}`),a))d.push(` -H ${_(`${e}: ${s}`)}`);for(let e of s??[])d.push(void 0!==e.file?` -F ${_(`${e.name}=@${e.file}${e.contentType?`;type=${e.contentType}`:""}`)}`:` --form-string ${_(`${e.name}=${e.value??""}`)}`);return n&&d.push(` --data-binary ${_(`@${n.name}`)}`),t.insecure&&d.push(" -k"),`${o("#")}
|
|
2
|
+
${d.join(" \\\n")}`;case"powershell":{let e=a.filter(([e])=>"content-type"!==e.toLowerCase());if(d.push(o("#"),"# PowerShell 7 or later."),e.length){for(let[t,s]of(d.push("$headers = @{"),e))d.push(` ${K(t)} = ${K(s)}`);d.push("}")}let l=[`-Uri ${K(t.url)}`,`-Method ${r}`];if(e.length&&l.push("-Headers $headers"),s){for(let e of(d.push("$form = @{"),s))d.push(` ${K(e.name)} = ${void 0!==e.file?`Get-Item -Path ${K(e.file)}`:K(e.value??"")}`);d.push("}"),l.push("-Form $form")}return n&&l.push(`-InFile ${K(n.name)}`,`-ContentType ${K(n.contentType)}`),t.insecure&&l.push("-SkipCertificateCheck"),d.push(`$response = Invoke-WebRequest ${l.join(" ")}`,"$response.StatusCode","$response.Content"),d.join("\n")}case"javascript":if(d.push(o("//"),'import { openAsBlob } from "node:fs";',""),s)for(let e of(d.push("const form = new FormData();"),s))d.push(void 0!==e.file?`form.append(${W(e.name)}, await openAsBlob(${W(e.file)}${e.contentType?`, { type: ${W(e.contentType)} }`:""}), ${W(e.file)});`:`form.append(${W(e.name)}, ${W(e.value??"")});`);if(d.push(`const response = await fetch(${W(t.url)}, {`,` method: ${W(r)},`),a.length){for(let[e,t]of(d.push(" headers: {"),a))d.push(` ${W(e)}: ${W(t)},`);d.push(" },")}return d.push(s?" body: form,":` body: await openAsBlob(${W(n.name)}),`),d.push("});","console.log(response.status);","console.log(await response.text());"),d.join("\n");case"python":{if(d.push(o("#"),"import requests","",`url = ${W(t.url)}`),a.length){for(let[e,t]of(d.push("headers = {"),a))d.push(` ${W(e)}: ${W(t)},`);d.push("}")}let e=[W(r),"url"];if(a.length&&e.push("headers=headers"),s){let t=s.filter(e=>void 0===e.file);if(t.length){for(let e of(d.push("data = ["),t))d.push(` (${W(e.name)}, ${W(e.value??"")}),`);d.push("]"),e.push("data=data")}for(let e of(d.push("files = ["),l))d.push(` (${W(e.name)}, (${W(e.file)}, open(${W(e.file)}, "rb")${e.contentType?`, ${W(e.contentType)}`:""})),`);d.push("]"),e.push("files=files")}return n&&e.push(`data=open(${W(n.name)}, "rb")`),t.insecure&&e.push("verify=False"),d.push("",`response = requests.request(${e.join(", ")})`,"print(response.status_code)","print(response.text)"),d.join("\n")}case"csharp":{let e=a.filter(([e])=>"content-type"!==e.toLowerCase());for(let[s,n]of(d.push(o("//"),"using System.Net.Http.Headers;",""),d.push(t.insecure?"using var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator });":"using var client = new HttpClient();"),d.push(`var request = new HttpRequestMessage(new HttpMethod(${J(r)}), ${J(t.url)});`),e))d.push(`request.Headers.TryAddWithoutValidation(${J(s)}, ${J(n)});`);return s&&(d.push("var form = new MultipartFormDataContent();"),s.forEach((e,t)=>{void 0===e.file?d.push(`form.Add(new StringContent(${J(e.value??"")}), ${J(e.name)});`):(d.push(`var file${t} = new ByteArrayContent(File.ReadAllBytes(${J(e.file)}));`),e.contentType&&d.push(`file${t}.Headers.ContentType = MediaTypeHeaderValue.Parse(${J(e.contentType)});`),d.push(`form.Add(file${t}, ${J(e.name)}, ${J(e.file)});`))}),d.push("request.Content = form;")),n&&d.push(`request.Content = new ByteArrayContent(File.ReadAllBytes(${J(n.name)}));`,`request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(${J(n.contentType)});`),d.push("var response = await client.SendAsync(request);","Console.WriteLine((int)response.StatusCode);","Console.WriteLine(await response.Content.ReadAsStringAsync());"),d.join("\n")}case"java":if(d.push(o("//"),"import java.net.URI;","import java.net.http.HttpClient;","import java.net.http.HttpRequest;","import java.net.http.HttpResponse;","import java.nio.file.Files;","import java.nio.file.Path;"),s&&d.push("import java.util.ArrayList;"),d.push(""),s){for(let e of(d.push('String boundary = "----ApiTestCenter" + System.currentTimeMillis();',"var parts = new ArrayList<byte[]>();"),s)){let t=`form-data; name="${c(e.name)}"`;void 0===e.file?d.push(`parts.add(("--" + boundary + ${W(`\r
|
|
3
|
+
Content-Disposition: ${t}\r
|
|
4
|
+
\r
|
|
5
|
+
`)} + ${W(e.value??"")} + "\\r\\n").getBytes("UTF-8"));`):(d.push(`parts.add(("--" + boundary + ${W(`\r
|
|
6
|
+
Content-Disposition: ${t}; filename="${c(e.file)}"\r
|
|
7
|
+
Content-Type: ${e.contentType??"application/octet-stream"}\r
|
|
8
|
+
\r
|
|
9
|
+
`)}).getBytes("UTF-8"));`),d.push(`parts.add(Files.readAllBytes(Path.of(${W(e.file)})));`,'parts.add("\\r\\n".getBytes("UTF-8"));'))}d.push('parts.add(("--" + boundary + "--\\r\\n").getBytes("UTF-8"));',"")}for(let[e,s]of(t.insecure&&d.push("// The certificate check was skipped in the app; Java's HttpClient needs an SSLContext that trusts the test server."),d.push("HttpClient client = HttpClient.newHttpClient();","HttpRequest request = HttpRequest.newBuilder()",` .uri(URI.create(${W(t.url)}))`),a))d.push(` .header(${W(e)}, ${W(s)})`);return s&&d.push(' .header("Content-Type", "multipart/form-data; boundary=" + boundary)'),d.push(` .method(${W(r)}, ${s?"HttpRequest.BodyPublishers.ofByteArrays(parts)":`HttpRequest.BodyPublishers.ofFile(Path.of(${W(n.name)}))`})`," .build();"),d.push("HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());","System.out.println(response.statusCode());","System.out.println(response.body());"),d.join("\n");case"go":{let e=['"fmt"','"io"','"net/http"','"os"',...s?['"bytes"','"mime/multipart"','"net/textproto"']:[],...t.insecure?['"crypto/tls"']:[]].sort();if(d.push(o("//"),"package main","","import (",...e.map(e=>` ${e}`),")","","func main() {"),s){for(let e of(d.push(" var body bytes.Buffer"," w := multipart.NewWriter(&body)"),s)){if(void 0===e.file){d.push(` w.WriteField(${W(e.name)}, ${W(e.value??"")})`);continue}d.push(" {"," h := make(textproto.MIMEHeader)",` h.Set("Content-Disposition", ${W(`form-data; name="${c(e.name)}"; filename="${c(e.file)}"`)})`,` h.Set("Content-Type", ${W(e.contentType??"application/octet-stream")})`," part, _ := w.CreatePart(h)",` data, err := os.ReadFile(${W(e.file)})`," if err != nil {"," panic(err)"," }"," part.Write(data)"," }")}d.push(" w.Close()")}else d.push(` body, err := os.Open(${W(n.name)})`," if err != nil {"," panic(err)"," }"," defer body.Close()");for(let[e,n]of(d.push(` req, err := http.NewRequest(${W(r)}, ${W(t.url)}, ${s?"&body":"body"})`," if err != nil {"," panic(err)"," }"),a))d.push(` req.Header.Set(${W(e)}, ${W(n)})`);return s&&d.push(' req.Header.Set("Content-Type", w.FormDataContentType())'),d.push(t.insecure?" client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}":" client := http.DefaultClient"," res, err := client.Do(req)"," if err != nil {"," panic(err)"," }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(res.StatusCode)"," fmt.Println(string(data))","}"),d.join("\n")}case"k6":if(d.push(o("//"),'import http from "k6/http";','import { check, sleep } from "k6";',""),l.forEach((e,t)=>d.push(`const file${t} = open(${W(e.file)}, "b");`)),n&&d.push(`const body = open(${W(n.name)}, "b");`),d.push("",`export const options = { vus: 5, duration: "30s"${t.insecure?", insecureSkipTLSVerify: true":""} };`,""),d.push("export default function () {"),s){let e=0;for(let t of(d.push(" const body = {"),s))d.push(` ${W(t.name)}: ${void 0!==t.file?`http.file(file${e++}, ${W(t.file)}${t.contentType?`, ${W(t.contentType)}`:""})`:W(t.value??"")},`);d.push(" };")}if(d.push(` const res = http.request(${W(r)}, ${W(t.url)}, body, {`),a.length){for(let[e,t]of(d.push(" headers: {"),a))d.push(` ${W(e)}: ${W(t)},`);d.push(" },")}return d.push(" });",' check(res, { "status is 2xx": (r) => r.status >= 200 && r.status < 300 });'," sleep(1);","}"),d.join("\n")}}(e,t);let s=V(t),n=t.body,a=t.method.toUpperCase(),r=[];switch(e){case"curl":for(let[e,l]of(r.push(`curl${"GET"===a&&void 0===n?"":` -X ${a}`} ${_(t.url)}`),s))r.push(` -H ${_(`${e}: ${l}`)}`);return void 0!==n&&r.push(` --data-raw ${_(n)}`),t.insecure&&r.push(" -k"),r.join(" \\\n");case"powershell":{let e=s.find(([e])=>"content-type"===e.toLowerCase())?.[1],l=s.filter(([e])=>"content-type"!==e.toLowerCase());if(l.length){for(let[e,t]of(r.push("$headers = @{"),l))r.push(` ${K(e)} = ${K(t)}`);r.push("}")}let i=[`-Uri ${K(t.url)}`,`-Method ${a}`];return l.length&&i.push("-Headers $headers"),e&&i.push(`-ContentType ${K(e)}`),void 0!==n&&i.push(/^[\x20-\x7e\r\n\t]*$/.test(n)?`-Body ${K(n)}`:`-Body ([System.Text.Encoding]::UTF8.GetBytes(${K(n)}))`),t.insecure&&i.push("-SkipCertificateCheck"),r.push(`$response = Invoke-WebRequest ${i.join(" ")}`,"$response.StatusCode","$response.Content"),r.join("\n")}case"javascript":if(r.push(`const response = await fetch(${W(t.url)}, {`,` method: ${W(a)},`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${W(e)}: ${W(t)},`);r.push(" },")}return void 0!==n&&r.push(` body: ${W(n)},`),r.push("});","console.log(response.status);","console.log(await response.text());"),t.insecure&&r.unshift("// The certificate check was skipped in the app; in Node.js run with NODE_TLS_REJECT_UNAUTHORIZED=0 for a test server only."),r.join("\n");case"python":{if(r.push("import requests","",`url = ${W(t.url)}`),s.length){for(let[e,t]of(r.push("headers = {"),s))r.push(` ${W(e)}: ${W(t)},`);r.push("}")}void 0!==n&&r.push(`payload = ${W(n)}`);let e=[W(a),"url"];return s.length&&e.push("headers=headers"),void 0!==n&&e.push('data=payload.encode("utf-8")'),t.insecure&&e.push("verify=False"),r.push("",`response = requests.request(${e.join(", ")})`,"print(response.status_code)","print(response.text)"),r.join("\n")}case"csharp":{let e=s.find(([e])=>"content-type"===e.toLowerCase())?.[1],l=s.filter(([e])=>"content-type"!==e.toLowerCase());for(let[e,s]of(r.push("using System.Net.Http.Headers;",""),r.push(t.insecure?"using var client = new HttpClient(new HttpClientHandler { ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator });":"using var client = new HttpClient();"),r.push(`var request = new HttpRequestMessage(new HttpMethod(${J(a)}), ${J(t.url)});`),l))r.push(`request.Headers.TryAddWithoutValidation(${J(e)}, ${J(s)});`);return void 0!==n&&(r.push(`request.Content = new StringContent(${J(n)});`),e&&r.push(`request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(${J(e)});`)),r.push("var response = await client.SendAsync(request);","Console.WriteLine((int)response.StatusCode);","Console.WriteLine(await response.Content.ReadAsStringAsync());"),r.join("\n")}case"java":for(let[e,n]of(r.push("import java.net.URI;","import java.net.http.HttpClient;","import java.net.http.HttpRequest;","import java.net.http.HttpResponse;",""),t.insecure&&r.push("// The certificate check was skipped in the app; Java's HttpClient needs an SSLContext that trusts the test server."),r.push("HttpClient client = HttpClient.newHttpClient();","HttpRequest request = HttpRequest.newBuilder()",` .uri(URI.create(${W(t.url)}))`),s))r.push(` .header(${W(e)}, ${W(n)})`);return r.push(` .method(${W(a)}, ${void 0!==n?`HttpRequest.BodyPublishers.ofString(${W(n)})`:"HttpRequest.BodyPublishers.noBody()"})`," .build();"),r.push("HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());","System.out.println(response.statusCode());","System.out.println(response.body());"),r.join("\n");case"go":{let e=['"fmt"','"io"','"net/http"',...void 0!==n?['"strings"']:[],...t.insecure?['"crypto/tls"']:[]].sort();for(let[l,i]of(r.push("package main","","import (",...e.map(e=>` ${e}`),")","","func main() {"),r.push(` req, err := http.NewRequest(${W(a)}, ${W(t.url)}, ${void 0!==n?`strings.NewReader(${W(n)})`:"nil"})`),r.push(" if err != nil {"," panic(err)"," }"),s))r.push(` req.Header.Set(${W(l)}, ${W(i)})`);return r.push(t.insecure?" client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}":" client := http.DefaultClient"," res, err := client.Do(req)"," if err != nil {"," panic(err)"," }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(res.StatusCode)"," fmt.Println(string(data))","}"),r.join("\n")}case"k6":if(r.push('import http from "k6/http";','import { check, sleep } from "k6";',""),r.push(`export const options = { vus: 5, duration: "30s"${t.insecure?", insecureSkipTLSVerify: true":""} };`,""),r.push("export default function () {"),r.push(` const res = http.request(${W(a)}, ${W(t.url)}, ${void 0!==n?W(n):"null"}, {`),s.length){for(let[e,t]of(r.push(" headers: {"),s))r.push(` ${W(e)}: ${W(t)},`);r.push(" },")}return r.push(" });",' check(res, { "status is 2xx": (r) => r.status >= 200 && r.status < 300 });'," sleep(1);","}"),r.join("\n")}})(r,o),[r,o]),d=(0,l.useMemo)(()=>JSON.stringify(U(e))!==JSON.stringify(e),[e]),u=(e,t)=>{navigator.clipboard.writeText(e),s(`${t} copied`,"success")};return(0,t.jsxs)("div",{className:"space-y-4 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("p",{className:"min-w-0 flex-1 font-mono text-[13px] break-all text-ink",children:[(0,t.jsx)("span",{className:"mr-2 font-medium text-accent",children:o.method}),o.url]}),d?(0,t.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),"aria-pressed":n,className:"inline-flex shrink-0 items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[n?(0,t.jsx)(Z,{size:12,"aria-hidden":!0}):(0,t.jsx)(G,{size:12,"aria-hidden":!0}),n?"Hide secrets":"Show secrets"]}):null]}),e.authNote||e.redirects?.length?(0,t.jsxs)("div",{className:"space-y-1 text-xs text-mute",children:[e.authNote?(0,t.jsxs)("p",{className:"flex items-start gap-1.5",children:[(0,t.jsx)(Q.Info,{size:12,className:"mt-0.5 shrink-0","aria-hidden":!0}),e.authNote,"."]}):null,e.redirects?.length?(0,t.jsxs)("div",{children:["Then followed ",1===e.redirects.length?"a redirect":`${e.redirects.length} redirects`,":",(0,t.jsx)("ul",{className:"mt-0.5 space-y-0.5 font-mono",children:e.redirects.map((e,s)=>(0,t.jsxs)("li",{className:"break-all",children:["→ ",e]},s))})]}):null]}):null,(0,t.jsxs)("section",{"aria-label":"Headers sent",children:[(0,t.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Headers"}),(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>u(o.headers.map(([e,t])=>`${e}: ${t}`).join("\n"),"Headers"),children:[(0,t.jsx)(X.Copy,{size:12})," Copy"]})]}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsx)("table",{className:"w-full text-left text-[13px]",children:(0,t.jsx)("tbody",{children:o.headers.map(([e,s],n)=>(0,t.jsxs)("tr",{className:"border-t border-line first:border-t-0",children:[(0,t.jsx)("th",{scope:"row",className:"w-2/5 bg-panel-2 px-3 py-1.5 align-top font-mono font-normal text-mute",children:e}),(0,t.jsx)("td",{className:`px-3 py-1.5 font-mono break-all ${s.includes(O)?"text-mute italic":"text-ink"}`,children:s})]},n))})})})]}),(0,t.jsxs)("section",{"aria-label":"Body sent",children:[(0,t.jsx)("h3",{className:"mb-1.5 text-xs font-medium text-mute",children:"Body"}),void 0===e.body?(0,t.jsx)("p",{className:"text-xs text-mute",children:"No body."}):(0,t.jsxs)("pre",{className:"max-h-64 overflow-auto rounded-md border border-line bg-panel-2 p-3 font-mono text-[13px] leading-5 break-words whitespace-pre-wrap text-ink",children:[o.body,e.bodyTruncated?(0,t.jsxs)("span",{className:"text-warn",children:["\n","… the first 20 MB shown"]}):null]})]}),(0,t.jsxs)("section",{"aria-label":"Code",children:[(0,t.jsxs)("div",{className:"mb-1.5 flex flex-wrap items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-mute",children:"Code"}),(0,t.jsx)(j.Select,{label:"Language",value:r,onChange:e=>{i(e);try{localStorage.setItem(ee,e)}catch{}},options:I.map(e=>({value:e.id,label:e.label})),minWidth:180,className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink outline-none focus-visible:border-accent"}),(0,t.jsxs)("button",{type:"button",className:"ml-auto inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>u(c,"Code"),children:[(0,t.jsx)(X.Copy,{size:12})," Copy"]})]}),(0,t.jsx)("pre",{"aria-label":`${I.find(e=>e.id===r)?.label} code`,className:"max-h-96 overflow-auto rounded-md border border-line bg-panel-2 p-3 font-mono text-[12.5px] leading-5 whitespace-pre text-ink",children:c}),(0,t.jsxs)("p",{className:"mt-1.5 text-xs text-mute",children:[n||!d?"":`Secrets show as ${O} — choose Show secrets to put the real values in. `,"curl"===r&&e.body&&/[^\x00-\x7f]/.test(e.body)?"On Windows, curl.exe can garble non-English letters in the command line — use the PowerShell code there, or save the body to a file and send it with --data-binary @file. ":"",e.authNote&&/signed|challenge|three requests/.test(e.authNote)?"A signature or challenge answer is only good for this one request; sent again later, the server may refuse it.":e.authNote?.startsWith("OAuth 2.0")?"The token expires; the code works until it does.":""]})]})]})}],12580);let et=(0,z.default)("arrow-down-left",[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]);e.s(["ArrowDownLeft",0,et],55680)},60566,97716,68228,65638,46679,e=>{"use strict";var t=e.i(14368),s=e.i(95486),n=e.i(60961),a=e.i(54792),r=e.i(89932),l=e.i(75117),i=e.i(88293),o=e.i(88871),c=e.i(99181),d=e.i(28867),u=e.i(13318),p=e.i(56396),h=e.i(15060),m=e.i(12580),x=e.i(55680),f=e.i(20738),b=e.i(42967),g=e.i(50962),v=e.i(42709),y=e.i(10281);let j={async connect(e){let t=await fetch("/engine/realtime/ws",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),s=await t.json();if(!t.ok||!s.id)throw Error(s.error??`Could not connect (${t.status})`);return{id:s.id}},close:e=>fetch(`/engine/realtime/${e}/close`,{method:"POST"}).catch(()=>void 0)};function w({id:e,onClosed:s}){let n=(0,p.useToast)(),[a,l]=(0,c.useState)([]),[o,d]=(0,c.useState)(null),[u,h]=(0,c.useState)(!1),[m,k]=(0,c.useState)(""),[N,$]=(0,c.useState)(""),[C,S]=(0,c.useState)(!0),T=(0,c.useRef)(null),q=(0,c.useRef)(0),E=(0,c.useRef)(s);E.current=s,(0,c.useEffect)(()=>{l([]),d(null),h(!1),q.current=0;let t=!0,s=0,n=async()=>{try{let s=await fetch(`/engine/realtime/${e}?since=${q.current}`,{cache:"no-store"});if(404===s.status)return void h(!0);let n=await s.json();if(!t)return;if(q.current=n.next,n.events.length&&l(e=>[...e,...n.events].slice(-2e3)),d({kind:n.kind,url:n.url,status:n.status,dropped:n.dropped}),"closed"===n.status)return void E.current?.()}catch{}t&&(s=window.setTimeout(()=>void n(),350))};return n(),()=>{t=!1,window.clearTimeout(s)}},[e]),(0,c.useEffect)(()=>{C&&T.current?.lastElementChild?.scrollIntoView({block:"nearest"})},[a,C]);let M=(0,c.useMemo)(()=>N?a.filter(e=>e.text.toLowerCase().includes(N.toLowerCase())||(e.event??"").toLowerCase().includes(N.toLowerCase())):a,[a,N]),R=(0,c.useMemo)(()=>({in:a.filter(e=>"in"===e.dir).length,out:a.filter(e=>"out"===e.dir).length}),[a]),A=o?.status==="open",D=o?.kind==="ws",L=async()=>{if(!m.trim()||!A)return;let t=await fetch(`/engine/realtime/${e}/send`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:m})});t.ok||n((await t.json().catch(()=>({}))).error??"Could not send","error")};return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5",children:[(0,t.jsx)("span",{className:`rounded-md border px-2 py-0.5 font-mono text-sm ${u?"border-line text-mute":A?"border-ok/40 bg-ok/10 text-ok":o?.status==="connecting"?"border-accent/40 text-accent":"border-line text-mute"}`,children:u?"Gone":A?D?"Connected":"Receiving":o?.status==="connecting"?"Connecting…":"Closed"}),(0,t.jsxs)("span",{className:"text-xs text-mute",children:[D?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:R.in})," received · ",(0,t.jsx)("span",{className:"text-ink",children:R.out})," sent"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:R.in})," events"]}),o?.dropped?` \xb7 first ${o.dropped} no longer kept`:""]}),(0,t.jsxs)("label",{className:"ml-auto flex items-center gap-1 rounded-md border border-line bg-panel px-1.5",children:[(0,t.jsx)(i.Search,{size:12,className:"text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:N,onChange:e=>$(e.target.value),"aria-label":"Filter messages",placeholder:"Filter",className:"w-28 bg-transparent py-1 text-xs text-ink outline-none"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:[(0,t.jsx)("input",{type:"checkbox",checked:C,onChange:e=>S(e.target.checked),className:"accent-[var(--accent)]"}),"Follow"]}),A?(0,t.jsxs)("button",{type:"button",onClick:()=>void j.close(e),className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink",children:[(0,t.jsx)(y.Unplug,{size:12,"aria-hidden":!0})," ",D?"Disconnect":"Stop"]}):null]}),o?.url?(0,t.jsx)("p",{className:"font-mono text-xs break-all text-mute",children:o.url}):null,(0,t.jsxs)("ol",{ref:T,"aria-label":D?"Messages":"Events","aria-live":"polite",className:"min-h-[14rem] flex-1 space-y-1 overflow-auto rounded-md border border-line bg-panel-2 p-2",children:[0===M.length?(0,t.jsx)("li",{className:"p-2 text-xs text-mute",children:N?"Nothing matches the filter.":D?"No messages yet.":"No events yet."}):null,M.map((e,s)=>{let a;return(0,t.jsxs)("li",{className:`group flex gap-2 rounded px-1.5 py-1 text-[12.5px] ${"error"===e.dir?"bg-bad/10":"out"===e.dir?"bg-accent/5":""}`,children:[(0,t.jsx)("span",{className:"w-14 shrink-0 pt-0.5 text-right font-mono text-[11px] text-mute tabular",children:(a=e.at/1e3)<60?`${a.toFixed(2)} s`:`${Math.floor(a/60)}:${String(Math.floor(a%60)).padStart(2,"0")}`}),(0,t.jsx)("span",{className:"shrink-0 pt-0.5","aria-label":"in"===e.dir?"received":"out"===e.dir?"sent":e.dir,children:"in"===e.dir?(0,t.jsx)(x.ArrowDownLeft,{size:13,className:"text-ok"}):"out"===e.dir?(0,t.jsx)(f.ArrowUpRight,{size:13,className:"text-accent"}):"error"===e.dir?(0,t.jsx)(v.TriangleAlert,{size:13,className:"text-bad"}):(0,t.jsx)(b.Info,{size:13,className:"text-mute"})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[e.event||e.id?(0,t.jsxs)("span",{className:"mr-2 font-mono text-[11px] text-mute",children:[e.event?`event: ${e.event}`:"",e.id?` id: ${e.id}`:""]}):null,(0,t.jsx)("span",{className:`block font-mono break-words whitespace-pre-wrap ${"info"===e.dir?"text-mute":"error"===e.dir?"text-bad":"text-ink"}`,children:"in"===e.dir||"out"===e.dir?function(e){let t=e.trim();if(!(t.startsWith("{")||t.startsWith("[")))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}(e.text):e.text})]}),"in"===e.dir||"out"===e.dir?(0,t.jsx)("button",{type:"button","aria-label":"Copy message",onClick:()=>{navigator.clipboard.writeText(e.text),n("Message copied","success")},className:"shrink-0 self-start rounded p-0.5 text-mute opacity-0 group-hover:opacity-100 hover:text-ink focus:opacity-100",children:(0,t.jsx)(r.Copy,{size:12})}):null]},s)})]}),D?(0,t.jsxs)("form",{className:"flex items-end gap-2",onSubmit:e=>{e.preventDefault(),L()},children:[(0,t.jsxs)("label",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"sr-only",children:"Message to send"}),(0,t.jsx)("textarea",{value:m,onChange:e=>k(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),L())},rows:Math.min(8,Math.max(2,m.split("\n").length)),disabled:!A,placeholder:A?'{ "type": "subscribe", "channel": "orders" } — Ctrl+Enter sends':"Connect to send messages",spellCheck:!1,className:"w-full resize-y rounded-md border border-line bg-panel-2 px-3 py-2 font-mono text-[13px] text-ink outline-none focus:border-accent disabled:opacity-50"})]}),(0,t.jsxs)("button",{type:"submit",disabled:!A||!m.trim(),className:"btn btn-primary py-2",children:[(0,t.jsx)(g.Send,{size:14})," Send"]})]}):null]})}e.s(["LiveView",0,w,"realtimeApi",0,j],97716);var k=e.i(19656),N=e.i(61230);let $="apitestcenter-show-big-answers",C={200:"OK",201:"Created",202:"Accepted",204:"No Content",301:"Moved Permanently",302:"Found",304:"Not Modified",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",408:"Request Timeout",409:"Conflict",415:"Unsupported Media Type",422:"Unprocessable Content",429:"Too Many Requests",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function S(e){return e>=200&&e<300?"text-ok border-ok/40 bg-ok/10":e>=300&&e<400?"text-accent border-accent/40 bg-accent/10":e>=400&&e<500?"text-warn border-warn/40 bg-warn/10":"text-bad border-bad/40 bg-bad/10"}function T({logs:e}){return(0,t.jsx)("ol",{"aria-label":"Script console",className:"overflow-auto rounded-md border border-line bg-panel-2 p-2 font-mono text-[12.5px] leading-5",children:e.map((e,s)=>(0,t.jsxs)("li",{className:"flex gap-2 border-t border-line/50 px-1 py-0.5 first:border-t-0",children:[(0,t.jsx)("span",{className:"w-24 shrink-0 whitespace-nowrap text-mute",children:"pre"===e.phase?"pre-request":"tests"}),(0,t.jsx)("span",{className:"min-w-0 break-words whitespace-pre-wrap text-ink",children:e.text})]},s))})}function q({label:e,value:s}){return(0,t.jsxs)("span",{className:"text-xs text-mute",children:[e," ",(0,t.jsx)("span",{className:"font-mono text-sm text-ink",children:s})]})}function E({message:e,onWaitLonger:s}){let n,a,r,{title:l,tip:i}=(n=e.toLowerCase(),(a=/^No answer within (\S+)/.exec(e))?{title:`No answer in ${a[1]}`,tip:"The server is reachable but slow: it didn't answer within this request's timeout. Wait longer and send again, or change what new requests wait in Settings → Requests."}:n.includes("econnrefused")?{title:"Connection refused",tip:"Nothing is listening on that host and port. Is the server running, and is the port right?"}:n.includes("enotfound")||n.includes("eai_again")?{title:"Host not found",tip:"DNS could not resolve the host name. Check the spelling, or connect to the VPN for internal hosts."}:n.includes("timeout")||n.includes("etimedout")||n.includes("und_err_headers_timeout")?{title:"Timed out",tip:"The server did not answer in time. Raise Timeout under Settings, or check that the host is reachable."}:n.includes("certificate")||n.includes("self-signed")||n.includes("unable to verify")||n.includes("cert_")?{title:"TLS certificate rejected",tip:"The certificate is not trusted. For a lab certificate, turn on 'Skip TLS certificate check' under Settings."}:n.includes("econnreset")||n.includes("socket hang up")?{title:"Connection reset",tip:"The server closed the connection mid-request. Check the server logs, or a proxy or firewall in between."}:n.includes("engine")?{title:"Engine problem",tip:"The local engine did not answer. Make sure pnpm dev is running."}:{title:"Request failed",tip:"See the details below."}),o=/^No answer within (\S+)/.exec(e)?.[1],c=o&&s?(r=e=>{let t=/^(\d+)(ms|s|m)$/.exec(e.trim());return t?Number(t[1])*("ms"===t[2]?1:"s"===t[2]?1e3:6e4):0},["2m","5m","10m","30m"].filter(e=>r(e)>r(o)).slice(0,2)):[];return(0,t.jsxs)("div",{role:"alert",className:"mt-3 rounded-md border border-bad/40 bg-bad/10 px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-bad",children:l}),(0,t.jsx)("p",{className:"mt-1 text-sm text-ink",children:i}),c.length?(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:c.map((e,n)=>(0,t.jsxs)("button",{type:"button",className:`btn ${0===n?"btn-primary":"btn-secondary"} py-1 text-xs`,onClick:()=>s(e),children:["Wait up to ",e," and send again"]},e))}):null,(0,t.jsx)("p",{className:"mt-2 font-mono text-xs break-all text-mute",children:e})]})}function M({headers:e}){let s=(0,p.useToast)(),n=Object.entries(e).sort(([e],[t])=>e.localeCompare(t));return 0===n.length?(0,t.jsx)("p",{className:"text-sm text-mute",children:"No headers."}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 text-xs text-mute hover:text-ink",onClick:()=>{navigator.clipboard.writeText(n.map(([e,t])=>`${e}: ${t}`).join("\n")),s("Headers copied","success")},children:[(0,t.jsx)(r.Copy,{size:12})," Copy all"]})}),(0,t.jsx)("div",{className:"overflow-auto rounded-md border border-line",children:(0,t.jsx)("table",{className:"w-full text-left text-[13px]",children:(0,t.jsx)("tbody",{children:n.map(([e,s])=>(0,t.jsxs)("tr",{className:"border-t border-line first:border-t-0",children:[(0,t.jsx)("th",{scope:"row",className:"w-2/5 bg-panel-2 px-3 py-1.5 align-top font-mono font-normal text-mute",children:e}),(0,t.jsx)("td",{className:`px-3 py-1.5 font-mono break-all ${"[redacted]"===s?"text-mute italic":"text-ink"}`,children:s})]},e))})})}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Cookie and authorization headers are hidden here — see Cookies, and Request sent."})]})}function R({body:e,contentType:n,truncated:u,url:m,base64:x}){let f=(0,p.useToast)(),b=function(e,t){let s=t.toLowerCase();if(s.startsWith("image/"))return"image";if(s.includes("json"))return"json";if(s.includes("html"))return"html";if(s.includes("xml"))return"xml";let n=e.trim();if(n.startsWith("{")||n.startsWith("["))try{return JSON.parse(n),"json"}catch{}return/^<!doctype html|^<html/i.test(n)?"html":n.startsWith("<")?"xml":"text"}(e,n),g="image"===b&&x?`data:${n.split(";")[0]};base64,${x}`:null,v=u||e.length>=2e5,[y,j]=(0,c.useState)("pretty"),[w,N]=(0,c.useState)(!0),[C,S]=(0,c.useState)(""),[T,q]=(0,c.useState)(0),[E,M]=(0,c.useState)(!1),z=(0,c.useRef)(null),P=(0,c.useRef)(null),[F,O]=(0,c.useState)(!1);(0,c.useEffect)(()=>{try{O("1"===localStorage.getItem($))}catch{}},[e]),(0,c.useEffect)(()=>{j("image"===b?"preview":"pretty"),S(""),q(0)},[e,b]);let U=(0,c.useMemo)(()=>e?"raw"===y?e:function(e,t){if("json"!==t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}(e,b):"",[e,y,b]),I=(0,c.useMemo)(()=>(function(e,t){if(!t)return 0;let s=e.toLowerCase(),n=t.toLowerCase(),a=0;for(let e=s.indexOf(n);e>=0&&a<1e4;e=s.indexOf(n,e+n.length))a++;return a})(U,C),[U,C]);function B(e){0!==I&&q(t=>(t+e+I)%I)}(0,c.useEffect)(()=>{let e=P.current?.querySelector("mark.current");e?.scrollIntoView({block:"center"})},[T,C,y]);let V=g?[{value:"preview",label:"Preview"},{value:"raw",label:"Raw"}]:[{value:"pretty",label:"Pretty"},{value:"raw",label:"Raw"},..."html"===b?[{value:"preview",label:"Preview"}]:[]];return e?e.length>2097152&&!F?(0,t.jsxs)("div",{role:"region","aria-label":"A big answer",className:"flex flex-1 flex-col items-center justify-center gap-3 rounded-md border border-line bg-panel-2 px-6 py-10 text-center",children:[(0,t.jsxs)("p",{className:"text-sm text-ink",children:["This answer is ",(0,k.formatBytes)(e.length),u?" (cut at 20 MB)":"","."]}),(0,t.jsx)("p",{className:"max-w-sm text-xs text-mute",children:"Showing it can take the app a few seconds. Checks and Save values already used all of it."}),(0,t.jsxs)("div",{className:"flex flex-wrap justify-center gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-primary py-1.5 text-sm",onClick:()=>O(!0),children:"Show it"}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:()=>{j("raw"),O(!0)},children:"As plain text"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:()=>(0,h.downloadText)(L(m,b),e,H(b)),children:[(0,t.jsx)(l.Download,{size:14}),"Save to file"]})]}),(0,t.jsx)("button",{type:"button",className:"text-xs text-mute hover:text-ink",onClick:()=>{try{localStorage.setItem($,"1")}catch{}O(!0)},children:"Always show big answers"})]}):(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border border-line bg-panel-2",onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"f"===e.key.toLowerCase()&&(e.preventDefault(),M(!0),window.setTimeout(()=>z.current?.focus(),0))},children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-2 py-1.5",children:[(0,t.jsx)(d.Segmented,{label:"Body view",value:y,onChange:j,options:V}),(0,t.jsx)("span",{className:"rounded border border-line px-1.5 py-0.5 font-mono text-xs text-mute uppercase",children:b}),u?(0,t.jsx)("span",{className:"text-xs text-warn",children:"Over 20 MB: the first 20 MB shown"}):null,(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[E?(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-md border border-line bg-panel px-1.5",children:[(0,t.jsx)(i.Search,{size:12,className:"text-mute"}),(0,t.jsx)("input",{ref:z,value:C,"aria-label":"Find in body",placeholder:"Find",onChange:e=>{S(e.target.value),q(0)},onKeyDown:e=>{"Enter"===e.key&&B(e.shiftKey?-1:1),"Escape"===e.key&&(S(""),M(!1))},className:"w-28 bg-transparent py-1 text-xs text-ink outline-none"}),(0,t.jsx)("span",{className:"font-mono text-xs text-mute tabular",children:C?`${I?T+1:0}/${I}`:""}),(0,t.jsx)(A,{label:"Previous match",onClick:()=>B(-1),children:(0,t.jsx)(a.ChevronUp,{size:12})}),(0,t.jsx)(A,{label:"Next match",onClick:()=>B(1),children:(0,t.jsx)(s.ChevronDown,{size:12})})]}):(0,t.jsx)(A,{label:"Find in body (Ctrl+F)",onClick:()=>{M(!0),window.setTimeout(()=>z.current?.focus(),0)},children:(0,t.jsx)(i.Search,{size:14})}),(0,t.jsx)(A,{label:w?"Turn off line wrap":"Wrap long lines",pressed:w,onClick:()=>N(e=>!e),children:(0,t.jsx)(o.WrapText,{size:14})}),(0,t.jsx)(A,{label:"Copy body",onClick:()=>{navigator.clipboard.writeText(U),f("Body copied","success")},children:(0,t.jsx)(r.Copy,{size:14})}),(0,t.jsx)(A,{label:"Download body",onClick:()=>g&&x?(0,h.downloadBlob)(L(m,b,n),new Blob([Uint8Array.from(atob(x),e=>e.charCodeAt(0))],{type:n.split(";")[0]})):(0,h.downloadText)(L(m,b),U,H(b)),children:(0,t.jsx)(l.Download,{size:14})})]})]}),"preview"===y&&g?(0,t.jsx)("div",{className:"flex min-h-[12rem] flex-1 items-center justify-center overflow-auto p-3",children:(0,t.jsx)("img",{src:g,alt:"Response image",className:"max-h-[32rem] max-w-full object-contain"})}):"preview"===y?(0,t.jsx)("iframe",{title:"HTML preview",sandbox:"",srcDoc:e,className:"min-h-[24rem] w-full flex-1 bg-white"}):(0,t.jsx)("pre",{ref:P,tabIndex:0,"aria-label":"Response body",className:`min-h-[12rem] flex-1 overflow-auto p-3 font-mono text-[13px] leading-5 text-ink ${w?"break-words whitespace-pre-wrap":"whitespace-pre"}`,children:C?function(e,s,n){let a=[],r=e.toLowerCase(),l=s.toLowerCase(),i=0,o=0;for(let s=r.indexOf(l);s>=0&&o<1e4;s=r.indexOf(l,s+l.length))a.push(e.slice(i,s)),a.push((0,t.jsx)("mark",{className:`find-hit${o===n?" current":""}`,children:e.slice(s,s+l.length)},s)),i=s+l.length,o++;return a.push(e.slice(i)),a}(U,C,T):"pretty"!==y||"json"!==b||v?U:function(e){let s=[],n=0;for(let a of e.matchAll(D)){let r=a.index??0;s.push(e.slice(n,r)),a[1]?(s.push((0,t.jsx)("span",{className:a[2]?"tok-key":"tok-str",children:a[1]},r)),a[2]&&s.push(a[2])):a[3]?s.push((0,t.jsx)("span",{className:"tok-lit",children:a[3]},r)):s.push((0,t.jsx)("span",{className:"tok-num",children:a[4]},r)),n=r+a[0].length}return s.push(e.slice(n)),s}(U)})]}):(0,t.jsx)("p",{className:"text-sm text-mute",children:"Empty body."})}function A({label:e,onClick:s,children:n,pressed:a}){return(0,t.jsx)("button",{type:"button","aria-label":e,title:e,"aria-pressed":a,onClick:s,className:`rounded p-1 hover:bg-panel hover:text-ink ${a?"text-accent":"text-mute"}`,children:n})}let D=/("(?:\\u[a-fA-F0-9]{4}|\\[^u]|[^\\"])*")(\s*:)?|\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/g;function L(e,t,s=""){let n="response";try{n=new URL(e).pathname.split("/").filter(Boolean).pop()||"response"}catch{}let a="json"===t?"json":"html"===t?"html":"xml"===t?"xml":"image"===t?/svg/.test(s)?"svg":s.split("/")[1]?.split(/[;+]/)[0]?.replace("jpeg","jpg")||"img":"txt";return`${n.replace(/[^\w.-]+/g,"_")}.${a}`}function H(e){return"json"===e?"application/json":"html"===e?"text/html":"xml"===e?"application/xml":"text/plain"}function z({url:e}){let s=(0,p.useToast)(),[a,l]=(0,c.useState)(!1),i=(0,N.readableUrl)(e);return(0,t.jsxs)("div",{role:"group","aria-label":"The address that answered",className:"mt-2 flex items-start gap-1 font-mono text-xs text-mute",children:[(0,t.jsx)("button",{type:"button",onClick:()=>l(e=>!e),"aria-expanded":a,"aria-label":a?"Show the address on one line":"Show the whole address",className:"mt-px shrink-0 rounded text-mute hover:text-ink",children:(0,t.jsx)(n.ChevronRight,{size:13,"aria-hidden":!0,className:`transition-transform ${a?"rotate-90":""}`})}),(0,t.jsx)("span",{onClick:()=>l(!0),className:`min-w-0 flex-1 ${a?"break-all whitespace-pre-wrap":"cursor-pointer truncate"}`,children:i}),(0,t.jsx)("button",{type:"button",title:"Copy the URL","aria-label":"Copy the URL",onClick:()=>void navigator.clipboard.writeText(i).then(()=>s("Copied the URL","success"),()=>s("Could not copy","error")),className:"shrink-0 rounded p-0.5 text-mute hover:text-ink",children:(0,t.jsx)(r.Copy,{size:12,"aria-hidden":!0})})]})}e.s(["ResponseViewer",0,function({result:e,onSaveExample:s,extra:n,onWaitLonger:a}){var r;let l,[i,o]=(0,c.useState)("body"),d=e.logs??[],p=e.cookies??[],h=("console"!==i||d.length)&&("cookies"!==i||p.length)&&("request"!==i||e.sent)&&("checks"!==i||(e.checks??[]).length)?i:"body",x=e.checks??[],f=x.filter(e=>e.ok).length,b=Object.keys(e.headers).length,g=(l=Object.keys(r=e.headers).find(e=>"content-type"===e.toLowerCase()))?r[l]??"":"",v=(0,c.useMemo)(()=>new TextEncoder().encode(e.body).length,[e.body]),y=!e.status;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)("span",{className:`rounded-md border px-2 py-0.5 font-mono text-sm font-medium ${S(e.status)}`,children:y?"Error":`${e.status} ${C[e.status]??""}`.trim()}),(0,t.jsx)(q,{label:"Time",value:`${e.durationMs} ms`}),y?null:(0,t.jsx)(q,{label:"Size",value:`${(0,k.formatBytes)(v)}${e.truncated?"+":""}`}),g?(0,t.jsx)(q,{label:"Type",value:g.split(";")[0]??g}):null,x.length?(0,t.jsxs)("button",{type:"button",onClick:()=>o("checks"),className:`rounded-md border px-2 py-0.5 text-xs ${f===x.length?"border-ok/40 text-ok":"border-bad/40 text-bad"}`,children:[f===x.length?"✓":"✕"," ",f,"/",x.length," checks"]}):null,n?(0,t.jsx)("span",{className:s&&!y?"":"ml-auto",children:n}):null,s&&!y?(0,t.jsx)("button",{type:"button",onClick:s,title:"Use this answer as what the mock server answers for this request",className:"ml-auto rounded-md border border-line px-2 py-0.5 text-xs text-mute hover:border-accent hover:text-ink",children:"Save as example"}):null]}),(0,t.jsx)(z,{url:e.url}),e.setup||e.dataRow?(0,t.jsxs)("p",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-mute",children:[e.setup?(0,t.jsxs)("span",{className:e.setup.ok?"":"text-bad",children:["Ran first: ",(0,t.jsx)("span",{className:"text-ink",children:e.setup.label}),e.setup.status?` \xb7 ${e.setup.status} \xb7 ${e.setup.durationMs} ms`:"",e.setup.values.map(e=>(0,t.jsxs)("span",{className:`ml-2 font-mono ${e.found?"text-ok":"text-bad"}`,title:e.found?`From ${e.from}: ${e.preview}`:`Not found: ${e.from}`,children:[e.found?"✓":"✕"," ",`{{${e.name}}}`]},e.name))]}):null,e.dataRow?(0,t.jsxs)("span",{children:["Test data: row ",e.dataRow.row," of ",e.dataRow.of.toLocaleString()]}):null]}):null,e.error?(0,t.jsx)(E,{message:e.error,onWaitLonger:a}):null,y&&e.sent?(0,t.jsxs)("details",{className:"mt-3 text-sm",children:[(0,t.jsx)("summary",{className:"cursor-pointer text-xs text-mute hover:text-ink",children:"What was sent"}),(0,t.jsx)("div",{className:"mt-2",children:(0,t.jsx)(m.SentRequestView,{sent:e.sent})})]}):null,y?null:(0,t.jsxs)("div",{className:"mt-3 flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)(u.Tabs,{id:"response",label:"Response",value:h,onChange:o,items:[{id:"body",label:"Body"},{id:"headers",label:"Headers",badge:b||void 0},...p.length?[{id:"cookies",label:"Cookies",badge:p.length}]:[],...x.length?[{id:"checks",label:"Checks",badge:(0,t.jsxs)("span",{className:f===x.length?"text-ok":"text-bad",children:[f,"/",x.length]})}]:[],...e.sent?[{id:"request",label:"Request sent"}]:[],...d.length?[{id:"console",label:"Console",badge:d.length}]:[]]}),(0,t.jsx)("div",{...(0,u.tabPanelProps)("response",h),className:"flex min-h-0 flex-1 flex-col pt-3",children:"body"===h?e.streamId?(0,t.jsx)(w,{id:e.streamId}):(0,t.jsx)(R,{body:e.body,contentType:g,truncated:e.truncated,url:e.url,base64:e.bodyBase64}):"cookies"===h?(0,t.jsx)(m.ResponseCookiesView,{cookies:p}):"console"===h?(0,t.jsx)(T,{logs:d}):"request"===h&&e.sent?(0,t.jsx)(m.SentRequestView,{sent:e.sent}):"checks"===h?(0,t.jsx)("ul",{className:"space-y-1.5",children:x.map((e,s)=>(0,t.jsxs)("li",{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-sm ${e.ok?"border-ok/30 bg-ok/5":"border-bad/40 bg-bad/10"}`,children:[(0,t.jsx)("span",{className:e.ok?"text-ok":"text-bad","aria-hidden":!0,children:e.ok?"✓":"✕"}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsx)("span",{className:"block font-mono text-[13px] text-ink",children:e.name}),!e.ok&&e.detail?(0,t.jsx)("span",{className:"block text-xs text-mute",children:e.detail}):null]}),(0,t.jsx)("span",{className:`ml-auto shrink-0 text-xs ${e.ok?"text-ok":"text-bad"}`,children:e.ok?"pass":"fail"})]},s))}):(0,t.jsx)(M,{headers:e.headers})})]})]})},"statusTone",0,S],60566),e.i(24856);var P=e.i(99112),F=e.i(78451),O=e.i(1675),U=e.i(36620),I=e.i(73436),B=e.i(99522);let V=(0,B.default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),W=(0,B.default)("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);var _=e.i(71189),K=e.i(43514),J=e.i(96659),X=e.i(87283),G=e.i(39170),Z=e.i(17847),Q=e.i(37837),Y=e.i(80707);e.i(42674);var ee=e.i(5305),et=e.i(65238),es=e.i(48181),en=e.i(6278);let ea=()=>globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`;function er({onClose:e,startNew:s=!1}){let n=(0,p.useToast)(),a=(0,G.useConfirm)(),{environments:l,activeEnv:i,setActiveEnv:o,saveEnvironments:d,index:u}=(0,en.useWorkspace)(),[h,m]=(0,c.useState)(()=>structuredClone(l)),[x,f]=(0,c.useState)(i?.id??l[0]?.id??null),[b,g]=(0,c.useState)(!1),v=(0,c.useRef)(null),y=h.find(e=>e.id===x)??null,j=JSON.stringify(h)!==JSON.stringify(l);(0,c.useEffect)(()=>{let e=document.activeElement;return s&&k(),v.current?.querySelector("input,button")?.focus(),()=>e?.focus()},[]);let w=(e,t)=>m(s=>s.map(s=>s.id===e?{...s,...t}:s));function k(e){let t=e?{id:ea(),name:`${e.name} copy`,variables:structuredClone(e.variables)}:{id:ea(),name:h.length?`Environment ${h.length+1}`:"DEV",variables:[{key:"baseUrl",value:"",secret:!1}]};m(e=>[...e,t]),f(t.id)}async function N(){(!j||await a({title:"Discard changes to environments?",confirmLabel:"Discard",tone:"danger"}))&&e()}async function $(){g(!0);try{await d(h),i&&!h.some(e=>e.id===i.id)&&o(null),n("Environments saved","success"),e()}catch(e){n(e instanceof Error?e.message:"Could not save environments","error")}finally{g(!1)}}return(0,t.jsx)("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:e=>e.target===e.currentTarget&&void N(),children:(0,t.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Environments",onKeyDown:e=>"Escape"===e.key&&void N(),className:"flex max-h-[85vh] w-full max-w-4xl flex-col overflow-hidden rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:"Environments"}),(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Use ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"{{name}}"})," in the URL, params, headers, body, or auth. Saved to environments.json in your app-data folder."]})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>void N(),children:(0,t.jsx)(X.X,{size:16})})]}),(0,t.jsxs)("div",{className:"grid min-h-0 flex-1 md:grid-cols-[14rem_minmax(0,1fr)]",children:[(0,t.jsxs)("nav",{"aria-label":"Environment list",className:"space-y-1 overflow-auto border-line p-3 md:border-r",children:[h.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>f(e.id),"aria-current":e.id===x?"true":void 0,className:`block w-full truncate rounded-md px-2 py-1.5 text-left text-sm ${e.id===x?"bg-accent-dim text-ink":"text-mute hover:bg-panel-2 hover:text-ink"}`,children:[e.name,(0,t.jsx)("span",{className:"ml-1 text-xs text-mute",children:e.variables.length})]},e.id)),(0,t.jsxs)("button",{type:"button",onClick:()=>k(),className:"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline",children:[(0,t.jsx)(_.Plus,{size:12,"aria-hidden":!0})," New environment"]})]}),(0,t.jsxs)("section",{className:"min-h-0 space-y-4 overflow-auto p-4",children:[y?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("label",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"sr-only",children:"Environment name"}),(0,t.jsx)("input",{value:y.name,onChange:e=>w(y.id,{name:e.target.value}),className:"input text-base font-medium"})]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1.5 text-xs",onClick:()=>k(y),children:[(0,t.jsx)(r.Copy,{size:13})," Duplicate"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger py-1.5 text-xs",onClick:()=>{m(e=>e.filter(e=>e.id!==y.id)),f(h.find(e=>e.id!==y.id)?.id??null)},children:[(0,t.jsx)(J.Trash2,{size:13})," Delete"]})]}),(0,t.jsxs)("label",{className:"flex items-start gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",className:"mt-1 accent-[var(--accent)]",checked:!!y.production,onChange:e=>w(y.id,{production:e.target.checked||void 0})}),(0,t.jsxs)("span",{children:["This is production",(0,t.jsx)("span",{className:"block text-xs text-mute",children:"The top of the window turns red while it's in use, and the app asks before a request that changes data, or a performance test."})]})]}),(0,t.jsx)(ei,{vars:y.variables,onPatch:(e,t)=>y&&w(y.id,{variables:y.variables.map((s,n)=>n===e?{...s,...t}:s)}),onChange:e=>w(y.id,{variables:e})}),(0,t.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-mute",children:[(0,t.jsx)(W,{size:12,className:"mt-0.5 shrink-0","aria-hidden":!0}),u?.secretsPersistent?"Secret values are encrypted on this computer and never written to environments.json.":"Secret values are never written to disk. In this browser setup they are kept by the engine until it restarts; the desktop app encrypts them."]})]}):(0,t.jsxs)("div",{className:"py-12 text-center text-sm text-mute",children:["No environments yet. Create one for each place you test — DEV, UAT, PROD.",(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsxs)("button",{type:"button",className:"btn btn-primary text-sm",onClick:()=>k(),children:[(0,t.jsx)(_.Plus,{size:14})," New environment"]})})]}),(0,t.jsx)(el,{onCopied:e=>n(`Copied ${e}`,"success")})]})]}),(0,t.jsxs)("footer",{className:"flex justify-end gap-2 border-t border-line px-5 py-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary text-sm",onClick:()=>void N(),children:"Cancel"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary text-sm",disabled:!j||b,onClick:()=>void $(),children:"Save environments"})]})]})})}function el({onCopied:e}){return(0,t.jsxs)("details",{className:"rounded-md border border-line bg-panel-2/40 px-3 py-2 text-sm",children:[(0,t.jsxs)("summary",{className:"cursor-pointer text-xs font-medium text-ink",children:["Built-in values ",(0,t.jsx)("span",{className:"font-normal text-mute",children:"— made anew for every request, in performance tests too"})]}),(0,t.jsx)("ul",{className:"mt-2 space-y-1",children:P.BUILTIN_VALUES.map(s=>(0,t.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsxs)("button",{type:"button",title:"Copy",onClick:()=>void navigator.clipboard?.writeText(s.example).then(()=>e(s.example)),className:"inline-flex shrink-0 items-center gap-1 rounded border border-line px-1.5 py-0.5 font-mono text-accent hover:border-accent",children:[s.example,(0,t.jsx)(r.Copy,{size:11,"aria-hidden":!0})]}),(0,t.jsx)("span",{className:"text-mute",children:s.description})]},s.name))}),(0,t.jsxs)("p",{className:"mt-2 text-xs text-mute",children:["In a JSON body put them in quotes, like ",(0,t.jsx)("code",{className:"font-mono text-ink",children:'"id": "{{$uuid}}"'}),"."]})]})}function ei({vars:e,onPatch:s,onChange:n}){let[a,r]=(0,c.useState)(new Set),l=new Set(e.map(e=>e.key.trim()).filter((e,t,s)=>e&&s.indexOf(e)!==t));return(0,t.jsxs)("div",{className:"overflow-hidden rounded-md border border-line",children:[(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_5.5rem_2rem] bg-panel-2 text-xs text-mute",children:[(0,t.jsx)("span",{className:"px-2.5 py-1.5",children:"Variable"}),(0,t.jsx)("span",{className:"border-l border-line px-2.5 py-1.5",children:"Value"}),(0,t.jsx)("span",{className:"border-l border-line px-2.5 py-1.5",children:"Secret"}),(0,t.jsx)("span",{})]}),e.map((i,o)=>{let c=i.key&&!/^[A-Za-z_][\w.-]*$/.test(i.key)||l.has(i.key.trim());return(0,t.jsxs)("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)_5.5rem_2rem] border-t border-line",children:[(0,t.jsx)("input",{"aria-label":`Variable ${o+1} name`,"aria-invalid":c||void 0,title:c?"Letters, digits, _ . - ; must start with a letter or _ ; must be unique":void 0,value:i.key,onChange:e=>s(o,{key:e.target.value}),placeholder:"baseUrl",className:`min-w-0 bg-transparent px-2.5 py-1.5 font-mono text-[13px] outline-none focus:bg-panel-2 ${c?"text-bad":"text-ink"}`}),(0,t.jsxs)("span",{className:"relative flex min-w-0 border-l border-line",children:[(0,t.jsx)("input",{"aria-label":`Variable ${o+1} value`,type:i.secret&&!a.has(o)?"password":"text",autoComplete:"off",value:i.value,onChange:e=>s(o,{value:e.target.value}),className:"min-w-0 flex-1 bg-transparent px-2.5 py-1.5 font-mono text-[13px] text-ink outline-none focus:bg-panel-2"}),i.secret?(0,t.jsx)("button",{type:"button","aria-label":a.has(o)?"Hide value":"Show value",onClick:()=>r(e=>{let t=new Set(e);return t.has(o)?t.delete(o):t.add(o),t}),className:"px-2 text-mute hover:text-ink",children:a.has(o)?(0,t.jsx)(I.EyeOff,{size:13}):(0,t.jsx)(U.Eye,{size:13})}):null]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 border-l border-line px-2.5 text-xs text-mute",children:[(0,t.jsx)("input",{type:"checkbox",checked:i.secret,onChange:e=>s(o,{secret:e.target.checked}),className:"accent-[var(--accent)]"}),"secret"]}),(0,t.jsx)("button",{type:"button","aria-label":`Remove ${i.key||`variable ${o+1}`}`,onClick:()=>n(e.filter((e,t)=>t!==o)),className:"grid place-items-center text-mute hover:text-bad",children:(0,t.jsx)(X.X,{size:13})})]},o)}),(0,t.jsxs)("button",{type:"button",onClick:()=>n([...e,{key:"",value:"",secret:!1}]),className:"flex w-full items-center gap-1 border-t border-line px-2.5 py-1.5 text-xs text-accent hover:bg-panel-2",children:[(0,t.jsx)(_.Plus,{size:12,"aria-hidden":!0})," Add variable"]})]})}e.s(["EnvironmentBar",0,function({drafts:e,collections:n=[],compact:a=!1}){let{environments:r,activeEnv:l,setActiveEnv:i,vars:o,savedValues:d,clearSavedValues:u}=(0,en.useWorkspace)(),p=Object.keys(d),[h,m]=(0,c.useState)(!1),[x,f]=(0,c.useState)(!1),b=(0,c.useRef)(null),g=(0,c.useMemo)(()=>{let t=new Set;for(let s of e){let e=new Set((0,ee.draftRuntimeNames)(s)),n=[s.url,s.bodyText,s.token,s.username,s.password,s.apiValue,...s.params.map(e=>e.value),...s.headers.map(e=>e.value)].join(" ");(0,F.findVariables)(n).forEach(s=>!e.has(s)&&t.add(s))}return[...t]},[e]),y=(0,et.useFolderVarNames)(n),j=g.filter(e=>!(e in o)&&!y.has(e));if([...r.map(e=>({value:e.id,label:e.name,hint:`${e.variables.length} variable${1===e.variables.length?"":"s"}`}))],a){let e=es.ENV_COLOUR[(0,es.envKind)(l)];return(0,t.jsxs)("div",{className:"flex items-center gap-1 text-xs",children:[j.length?(0,t.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-warn",title:`${j.map(e=>`{{${e}}}`).join(", ")} not defined${l?` in ${l.name}`:" — pick an environment"}`,children:[(0,t.jsx)(v.TriangleAlert,{size:12,"aria-hidden":!0}),(0,t.jsx)("span",{className:"max-w-40 truncate",children:j.map(e=>`{{${e}}}`).join(", ")})]}):null,p.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-mute",title:p.map(e=>`{{${e}}} — saved from “${d[e].from}”`).join("\n"),children:[(0,t.jsxs)("span",{className:"font-mono text-accent",children:[p.length," saved"]}),(0,t.jsx)("button",{type:"button",onClick:u,"aria-label":"Clear the values saved from answers",className:"rounded p-0.5 hover:text-ink",children:(0,t.jsx)(X.X,{size:11,"aria-hidden":!0})})]}):null,(0,t.jsxs)("button",{ref:b,type:"button",role:"combobox","aria-label":"Environment","aria-haspopup":"listbox","aria-expanded":x,onClick:()=>f(e=>!e),className:"inline-flex max-w-52 items-center gap-1.5 rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink hover:border-mute",children:[(0,t.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:l?e??"var(--ok)":"var(--line)"},"aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:l?.name??"No environment"}),(0,t.jsx)(s.ChevronDown,{size:12,className:"shrink-0 text-mute","aria-hidden":!0})]}),(0,t.jsx)(Q.Popover,{anchor:b,open:x,onClose:()=>f(!1),label:"Environments",width:260,children:(0,t.jsxs)("div",{className:"-m-2",children:[(0,t.jsx)(Z.MenuLabel,{children:"Environment"}),(0,t.jsx)("ul",{role:"listbox","aria-label":"Environment",children:[{id:"",name:"No environment",count:-1,production:!1},...r.map(e=>({id:e.id,name:e.name,count:e.variables.length,production:e.production}))].map(e=>{let s=(l?.id??"")===e.id,n=e.id?es.ENV_COLOUR[(0,es.envKind)(e)]??"var(--ok)":"var(--line)";return(0,t.jsx)("li",{role:"option","aria-selected":s,children:(0,t.jsxs)("button",{type:"button",onClick:()=>{i(e.id||null),f(!1)},className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm text-ink hover:bg-panel-2",children:[(0,t.jsx)("span",{className:"flex w-4 justify-center","aria-hidden":!0,children:(0,t.jsx)("span",{className:"h-2 w-2 rounded-full",style:{background:n}})}),(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[e.name,(0,t.jsx)("span",{className:"block text-[11px] text-mute",children:e.count<0?"Only built-in variables":`${e.count} variable${1===e.count?"":"s"}`})]}),s?(0,t.jsx)(O.Check,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},e.id||"none")})}),(0,t.jsx)(Z.MenuSeparator,{}),(0,t.jsx)(Z.MenuItem,{icon:_.Plus,label:"New environment…",onSelect:()=>{f(!1),m("new")}}),(0,t.jsx)(Z.MenuItem,{icon:K.Settings2,label:"Manage environments…",onSelect:()=>{f(!1),m("manage")}})]})}),(0,t.jsx)("button",{type:"button",onClick:()=>m("manage"),"aria-label":"Manage environments",title:"Manage environments",className:"rounded p-1.5 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(V,{size:14,"aria-hidden":!0})}),h?(0,t.jsx)(er,{startNew:"new"===h,onClose:()=>m(!1)}):null]})}return(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-mute",children:["Environment",(0,t.jsx)(Y.Select,{label:"Environment",value:l?.id??"",onChange:e=>i(e||null),minWidth:200,options:[{value:"",label:"None",hint:"Only built-in variables"},...r.map(e=>({value:e.id,label:e.name,hint:`${e.variables.length} variable${1===e.variables.length?"":"s"}`}))],className:"rounded-md border border-line bg-panel-2 px-2 py-1 text-xs text-ink hover:border-mute focus-visible:border-accent focus-visible:outline-none"})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>m("manage"),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-mute hover:text-ink",children:[(0,t.jsx)(K.Settings2,{size:12,"aria-hidden":!0})," Manage"]}),g.length>0?j.length?(0,t.jsxs)("span",{className:"text-warn",role:"status",children:[j.map(e=>`{{${e}}}`).join(", ")," not defined",l?` in ${l.name}`:" — pick an environment"]}):(0,t.jsxs)("span",{className:"text-mute",children:["Uses ",g.map(e=>`{{${e}}}`).join(", ")]}):null,p.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-mute",title:p.map(e=>`{{${e}}} — saved from “${d[e].from}”`).join("\n"),children:["Saved from answers: ",(0,t.jsx)("span",{className:"font-mono text-accent",children:p.map(e=>`{{${e}}}`).join(", ")}),(0,t.jsx)("button",{type:"button",onClick:u,className:"text-mute underline-offset-2 hover:text-ink hover:underline",children:"Clear"})]}):null,h?(0,t.jsx)(er,{onClose:()=>m(!1)}):null]})},"VariableTable",0,ei],68228);var eo=e.i(80190);let ec=(0,B.default)("file-plus-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]);var ed=e.i(47677),eu=e.i(17819);let ep=(0,B.default)("folder-input",[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]),eh=(0,B.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var em=e.i(91694);let ex=(0,B.default)("import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);var ef=e.i(19286),eb=e.i(81538),eg=e.i(13163),ev=e.i(3792),ey=e.i(67290),ej=e.i(30099),ew=e.i(36994),ek=e.i(67217),eN=e.i(74749),e$=e.i(97942),eC=e.i(91549),eS=e.i(41997),eT=e.i(27813),eq=e.i(36e3),eE=e.i(55925),eM=e.i(22079),eR=e.i(23227);function eA({value:e,parents:s,onChange:n}){let a,r=(0,eR.useContracts)(),l=[...s].reverse().find(e=>e.settings.contract);return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-xs text-mute",children:"Each answer inside is checked against this OpenAPI description, on Send and in collection runs: is the operation in it, is the status documented, does the body match the documented schema. That's a contract test."}),(0,t.jsxs)("label",{className:"block space-y-1",children:[(0,t.jsx)("span",{className:"text-sm text-ink",children:"API description"}),(0,t.jsxs)("select",{className:"input",value:e??"",onChange:e=>n(e.target.value||void 0),children:[(0,t.jsx)("option",{value:"",children:l?`From ${l.path}: ${a=l.settings.contract,r?.find(e=>e.id===a)?.name??"a description that was removed"}`:"None"}),r?.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name,e.error?" (doesn't read)":` — ${e.operations} operations`]},e.id))]})]}),r&&!r.length?(0,t.jsx)("p",{className:"text-xs text-mute",children:"There are none in this project yet."}):null,(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>(0,eM.openContracts)(e??l?.settings.contract),children:r&&!r.length?"Add an API description…":"API descriptions — add one, and see which operations have a request"})]})}function eD({path:e,onClose:s}){let n=(0,p.useToast)(),{refresh:a}=(0,en.useWorkspace)(),[r,l]=(0,c.useState)(null),[i,o]=(0,c.useState)([]),[d,h]=(0,c.useState)([]),[m,x]=(0,c.useState)("auth"),[f,b]=(0,c.useState)(!1);async function g(){if(r&&!f){b(!0);try{await et.folderApi.save(e,{...r,headers:r.headers.filter(e=>e.key.trim()),variables:r.variables.filter(e=>e.key.trim())}),await a(),n(`Saved the settings of ${e}`,"success"),s()}catch(e){n(e instanceof Error?e.message:"Could not save","error")}finally{b(!1)}}}(0,c.useEffect)(()=>{let t=!0;return Promise.all([et.folderApi.get(e),et.folderApi.chain((0,F.parentFolder)(e))]).then(([e,s])=>{t&&(l(e.settings),o(e.secretsMissing??[]),h(s))}).catch(e=>{t&&(n(e instanceof Error?e.message:"Could not open the folder","error"),l((0,F.emptyFolderSettings)()))}),()=>{t=!1}},[e,n]);let v=[...d].reverse().find(e=>"inherit"!==e.settings.auth.authMode),y=r?{headers:r.headers.filter(e=>e.key.trim()&&!1!==e.enabled).length,variables:r.variables.length}:{headers:0,variables:0};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 grid place-items-center bg-black/50 p-4 backdrop-blur-sm",onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"folder-settings-title",onKeyDown:e=>"Escape"===e.key&&s(),className:"flex max-h-[85vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-start justify-between gap-3 border-b border-line px-5 py-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("h2",{id:"folder-settings-title",className:"truncate text-base font-medium text-ink",children:["Folder settings · ",e]}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Every request inside — and inside its subfolders — uses these. A request's own value wins."})]}),(0,t.jsx)("button",{type:"button","aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",onClick:s,children:(0,t.jsx)(X.X,{size:16})})]}),r?(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[(0,t.jsx)(u.Tabs,{id:"folder-settings",label:"Folder settings",value:m,onChange:x,items:[{id:"auth",label:"Auth"},{id:"headers",label:"Headers",badge:y.headers||void 0},{id:"variables",label:"Variables",badge:y.variables||void 0},{id:"scripts",label:"Scripts",badge:+!!r.preScript.trim()+ +!!r.postScript.trim()||void 0},{id:"contract",label:"API description",badge:r.contract?1:void 0}]}),(0,t.jsxs)("div",{...(0,u.tabPanelProps)("folder-settings",m),className:"pt-4",children:["auth"===m?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Requests set to ",(0,t.jsx)("span",{className:"text-ink",children:"Auth → From folder"})," (the default for new requests) use this — sign in once here instead of in every request."]}),(0,t.jsx)(eS.AuthFields,{value:r.auth,onChange:e=>l({...r,auth:{...r.auth,...e}}),inheritLabel:"From parent",defaults:Object.fromEntries([...d.flatMap(e=>e.settings.variables),...r.variables].map(e=>[e.key,e.value])),inheritNote:v&&"none"!==v.settings.auth.authMode?(0,t.jsxs)(t.Fragment,{children:["Passes on the ",(0,t.jsx)("span",{className:"text-ink",children:(0,eS.authModeLabel)(v.settings.auth.authMode)})," of"," ",(0,t.jsx)("span",{className:"text-ink",children:v.path}),"."]}):(0,t.jsx)(t.Fragment,{children:"No folder above sets auth, so this folder passes none down."}),secretNote:"Use {{token}} to take it from the environment, or type it — it's kept encrypted on this computer, never in the folder's file."}),i.some(e=>!e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["The saved ",i.filter(e=>!e.startsWith("var:")).join(", ")," isn't available on this computer — enter it again."]}):null]}):null,"headers"===m?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eq.KeyValueEditor,{rows:r.headers,onChange:e=>l({...r,headers:e}),keyPlaceholder:"Header",valuePlaceholder:"Value",noun:"header"}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"Sent with every request inside. An inner folder's or a request's header with the same name replaces it."})]}):null,"scripts"===m?(0,t.jsx)(eE.ScriptsPanel,{draft:r,onChange:l,forFolder:!0}):null,"contract"===m?(0,t.jsx)(eA,{value:r.contract,parents:d,onChange:e=>l({...r,contract:e})}):null,"variables"===m?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ei,{vars:r.variables,onPatch:(e,t)=>l({...r,variables:r.variables.map((s,n)=>n===e?{...s,...t}:s)}),onChange:e=>l({...r,variables:e})}),(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Defaults for ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"{{name}}"})," in the requests inside. The chosen environment wins when it has the same name — so a folder can say"," ",(0,t.jsx)("code",{className:"font-mono text-ink",children:"basePath = /v2"})," and the environment picks the server."]}),i.some(e=>e.startsWith("var:"))?(0,t.jsxs)("p",{className:"text-xs text-warn",children:["Secret values not available on this computer: ",i.filter(e=>e.startsWith("var:")).map(e=>e.slice(4)).join(", ")," — enter them again."]}):null]}):null]})]}):(0,t.jsx)("div",{className:"grid place-items-center p-10 text-mute",children:(0,t.jsx)(eT.Loader2,{className:"animate-spin",size:18,"aria-label":"Loading"})}),(0,t.jsxs)("footer",{className:"flex justify-end gap-2 border-t border-line px-5 py-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:s,disabled:f,children:"Cancel"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",onClick:()=>void g(),disabled:!r||f,children:[f?(0,t.jsx)(eT.Loader2,{size:14,className:"animate-spin"}):null,"Save folder settings"]})]})]})})}var eL=e.i(14168),eH=e.i(2603);let ez={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"},eP="atc:request-moved",eF="application/x-atc-requests";function eO({activeId:e,onOpen:a,allowDelete:l=!0,newFolder:o,onNewFolderDone:d}){let u=(0,p.useToast)(),h=(0,G.useConfirm)(),{index:m,refresh:x}=(0,en.useWorkspace)(),[f,b]=(0,c.useState)({});(0,c.useEffect)(()=>{fetch("/engine/responses",{cache:"no-store"}).then(e=>e.json()).then(e=>b(e.requests??{})).catch(()=>void 0)},[m]);let[g,v]=(0,c.useState)(""),[y,j]=(0,c.useState)(new Set),[w,N]=(0,c.useState)(null),[$,C]=(0,c.useState)(null),[S,T]=(0,c.useState)(null),[q,E]=(0,c.useState)(new Set),M=(0,c.useRef)(null),[R,A]=(0,c.useState)(null),[D,L]=(0,c.useState)(null),[H,z]=(0,c.useState)(null),P=m?.requests??[],O=m?.folders??[],U=g.trim().toLowerCase(),I=(0,c.useMemo)(()=>U?P.filter(e=>`${e.name} ${e.collection} ${e.url} ${e.method}`.toLowerCase().includes(U)):P,[P,U]),B=(0,c.useMemo)(()=>(function(e,t,s){let n={path:"",name:"",folders:[],requests:[],summary:null},a=new Map([["",n]]),r=e=>{let t=a.get(e);if(t)return t;let s={path:e,name:(0,F.folderName)(e),folders:[],requests:[],summary:null};return a.set(e,s),r((0,F.parentFolder)(e)).folders.push(s),s};if(s)for(let e of t)r(e.path);for(let t of e)r(t.collection).requests.push(t);for(let e of t){let t=a.get(e.path);t&&(t.summary=e)}let l=e=>{e.folders.sort((e,t)=>e.name.localeCompare(t.name)),e.folders.forEach(l)};return l(n),n})(I,O,!U),[I,O,U]);async function V(e){try{let t=await en.workspaceApi.get(e);a(t),t.secretsMissing?.length&&u(`Re-enter the ${t.secretsMissing.join(", ")} — secrets are kept only until the engine restarts in this setup`,"info")}catch(e){u(e instanceof Error?e.message:"Could not open the request","error")}}async function W(e,t){let s=0;try{for(let n of e){let e=await en.workspaceApi.get(n),a=t.name?.trim()||e.name,r=t.collection??e.collection;if(a===e.name&&r===e.collection)continue;let l=await en.workspaceApi.update(n,{name:a,collection:r,request:e.request});window.dispatchEvent(new CustomEvent(eP,{detail:{id:n,name:l.name,collection:l.collection}})),s++}await x(),void 0!==t.collection&&s&&u(`Moved ${s} request${1===s?"":"s"} to ${t.collection||"the top level"}`,"success")}catch(e){u(e instanceof Error?e.message:"Could not do that","error")}}async function _(e){for(let t of e)await en.workspaceApi.remove(t).catch(()=>void 0);E(new Set),await x(),u(`${e.length} request${1===e.length?"":"s"} moved to Trash — restore them from Trash in the sidebar`,"success")}(0,c.useEffect)(()=>{o&&N({kind:"new",parent:""})},[o]);let K=e=>l?{onDragOver:t=>{t.dataTransfer.types.includes(eF)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="move",z(e))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||z(t=>t===e?null:t)},onDrop:t=>{t.preventDefault(),t.stopPropagation(),z(null);try{let s=JSON.parse(t.dataTransfer.getData(eF));Array.isArray(s)&&s.length&&(E(new Set),W(s,{collection:e}))}catch{}}}:{};async function Z(e){try{let t=await en.workspaceApi.create({name:"New request",collection:e,request:(0,ee.defaultRequestDraft)()});j(t=>{let s=new Set(t);return s.delete(e),s}),await x(),await V(t.id),A(t.id)}catch(e){u(e instanceof Error?e.message:"Could not make the request","error")}}async function Q(e){try{let t=await en.workspaceApi.get(e.id);await en.workspaceApi.create({name:`${e.name} copy`.slice(0,200),collection:e.collection,request:t.request}),await x(),u(`Duplicated “${e.name}”`,"success")}catch(e){u(e instanceof Error?e.message:"Could not duplicate it","error")}}async function Y(e){try{await en.workspaceApi.remove(e.id),await x(),u(`“${e.name}” moved to Trash — restore it from Trash in the sidebar`,"success")}catch(e){u(e instanceof Error?e.message:"Could not delete it","error")}}async function es(e){if(N(null),d?.(),!w)return;let t=e.trim();if(t)try{if("new"===w.kind){let e=(0,F.folderPath)(w.parent?`${w.parent}/${t}`:t);await et.folderApi.save(e,(0,F.emptyFolderSettings)()),j(e=>{let t=new Set(e);return t.delete(w.parent),t})}else{let e=(0,F.folderPath)(t.includes("/")?t:(0,F.parentFolder)(w.path)?`${(0,F.parentFolder)(w.path)}/${t}`:t);e!==w.path&&await et.folderApi.move(w.path,e)}await x()}catch(e){u(e instanceof Error?e.message:"Could not do that","error")}}async function ea(e){if(await h({title:`Delete the folder “${e}”?`,body:"Its settings and empty subfolders are removed. A folder that still has requests can't be deleted — move or delete them first.",confirmLabel:"Delete folder",tone:"danger"}))try{await et.folderApi.remove(e),await x()}catch(e){u(e instanceof Error?e.message:"Could not delete the folder","error")}}let er=s=>(0,t.jsx)("ul",{children:s.map(s=>{let n=s.id===e,a=q.has(s.id);return R===s.id?(0,t.jsx)("li",{className:"py-0.5 pl-1",children:(0,t.jsx)("input",{autoFocus:!0,defaultValue:s.name,"aria-label":`New name for ${s.name}`,className:"input py-1 text-[13px]",onFocus:e=>e.target.select(),onKeyDown:e=>{"Enter"===e.key&&e.target.blur(),"Escape"===e.key&&A(null)},onBlur:e=>{A(null),W([s.id],{name:e.target.value})}})},s.id):(0,t.jsxs)("li",{draggable:l,onDragStart:e=>{let t=a?[...q]:[s.id];e.dataTransfer.setData(eF,JSON.stringify(t)),e.dataTransfer.effectAllowed="move"},onContextMenu:e=>{l&&(e.preventDefault(),T(`r:${s.id}`))},className:`group flex items-center rounded-md ${n?"bg-accent-dim shadow-[inset_2px_0_0_var(--accent)]":a?"bg-panel-2 ring-1 ring-accent/50 ring-inset":"hover:bg-panel-2"}`,children:[(0,t.jsxs)("button",{type:"button",onClick:e=>(function(e,t){if(l&&(e.ctrlKey||e.metaKey)){E(e=>{let s=new Set(e);return s.has(t.id)?s.delete(t.id):s.add(t.id),s}),M.current=t.id;return}if(l&&e.shiftKey&&M.current){let e=function e(t){return!y.has(t.path)||U||""===t.path?[...t.folders.flatMap(e),...t.requests.map(e=>e.id)]:[]}(B),[s,n]=[e.indexOf(M.current),e.indexOf(t.id)].sort((e,t)=>e-t);if(s>=0)return E(new Set(e.slice(s,n+1)))}E(new Set),M.current=t.id,V(t.id)})(e,s),onKeyDown:e=>{l&&("F2"===e.key?(e.preventDefault(),A(s.id)):"Delete"===e.key?(e.preventDefault(),a&&q.size>1?_([...q]):Y(s)):(e.ctrlKey||e.metaKey)&&"d"===e.key.toLowerCase()&&(e.preventDefault(),Q(s)))},"aria-current":n?"true":void 0,"aria-pressed":l&&q.size?a:void 0,title:f[s.id]?`${s.url}
|
|
10
|
+
Earlier answers kept: ${(0,k.formatBytes)(f[s.id])}`:s.url,className:"tree-row flex min-w-0 flex-1 items-center gap-2 py-1 pr-1 pl-2 text-left",children:[(0,t.jsx)("span",{className:`w-10 shrink-0 font-mono text-[10.5px] font-semibold tracking-wide ${ez[s.method]??"text-mute"}`,children:"DELETE"===s.method?"DEL":s.method}),(0,t.jsx)("span",{className:`min-w-0 truncate text-[13px] ${n?"text-ink":"text-ink/90"}`,children:s.name})]}),l?(0,t.jsx)(eB,{label:`Actions for ${s.name}`,open:S===`r:${s.id}`,onOpenChange:e=>T(e?`r:${s.id}`:null),items:[{icon:eo.ExternalLink,label:"Open",hint:"Enter",run:()=>void V(s.id)},{icon:eg.Pencil,label:"Rename",hint:"F2",run:()=>A(s.id)},{icon:r.Copy,label:"Duplicate",hint:"Ctrl+D",run:()=>void Q(s)},{icon:ep,label:"Move to…",run:()=>L([s.id])},"separator",{icon:em.History,label:"Version history",run:()=>(0,e$.openVersions)(s.id)},{icon:ed.FileOutput,label:"Export…",run:()=>(0,eC.openExport)({kind:"request",id:s.id,name:s.name,collection:s.collection})},"separator",{icon:J.Trash2,label:"Move to Trash",hint:"Del",run:()=>void Y(s),danger:!0}]}):null]},s.id)})}),el=e=>{var a;let r=y.has(e.path)&&!U,i=(a=e.summary)?[a.auth?(0,eS.authModeLabel)(a.auth):"",a.headers?`${a.headers} header${1===a.headers?"":"s"}`:"",a.variables?`${a.variables} variable${1===a.variables?"":"s"}`:""].filter(Boolean).join(" · "):"";return(0,t.jsxs)("div",{className:"mb-0.5",children:[w?.kind==="rename"&&w.path===e.path?(0,t.jsx)(eU,{initial:e.path,label:`New name for ${e.path}`,onDone:e=>void es(e),hint:"Use / to move it into another folder"}):(0,t.jsxs)("div",{...K(e.path),className:`group/folder flex items-center rounded-md ${H===e.path?"bg-accent-dim ring-1 ring-accent ring-inset":"hover:bg-panel-2"}`,onContextMenu:t=>{l&&(t.preventDefault(),T(`f:${e.path}`))},children:[(0,t.jsxs)("button",{type:"button","aria-expanded":!r,onClick:()=>{let t;return t=e.path,j(e=>{let s=new Set(e);return s.has(t)?s.delete(t):s.add(t),s})},title:i?`Passes down: ${i}`:e.path,className:"tree-row flex min-w-0 flex-1 items-center gap-1.5 py-1 pr-1 pl-1 text-left text-[13px] font-medium text-ink",children:[r?(0,t.jsx)(n.ChevronRight,{size:13,"aria-hidden":!0,className:"shrink-0 text-mute"}):(0,t.jsx)(s.ChevronDown,{size:13,"aria-hidden":!0,className:"shrink-0 text-mute"}),(0,t.jsx)(eu.Folder,{size:14,"aria-hidden":!0,className:"shrink-0 text-mute"}),(0,t.jsx)("span",{className:"truncate",children:e.name}),e.summary?.auth?(0,t.jsx)(ef.KeyRound,{size:11,className:"shrink-0 text-accent","aria-label":`signs in with ${(0,eS.authModeLabel)(e.summary.auth)}`}):null,(0,t.jsx)("span",{className:"ml-auto shrink-0 rounded-full bg-panel-2 px-1.5 text-[11px] font-normal text-mute group-hover/folder:bg-panel",children:function e(t){return t.requests.length+t.folders.reduce((t,s)=>t+e(s),0)}(e)})]}),l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ej.default,{href:(0,eL.suiteHref)(e.path),title:`Run all requests in ${e.path}`,"aria-label":`Run all requests in ${e.path}`,className:"ml-0.5 rounded p-1 text-mute opacity-0 group-hover/folder:opacity-100 hover:text-accent focus:opacity-100",children:(0,t.jsx)(ev.Play,{size:12})}),(0,t.jsx)(eV,{path:e.path,onNewRequest:()=>void Z(e.path),open:S===`f:${e.path}`,onOpenChange:t=>T(t?`f:${e.path}`:null),onSettings:()=>C(e.path),onNewInside:()=>N({kind:"new",parent:e.path}),onRename:()=>N({kind:"rename",path:e.path}),onDelete:()=>void ea(e.path)})]}):null]}),r?null:(0,t.jsxs)("div",{className:"ml-[0.9rem] border-l border-line pl-1",children:[w?.kind==="new"&&w.parent===e.path?(0,t.jsx)(eU,{initial:"",label:`New folder in ${e.path}`,onDone:e=>void es(e)}):null,e.folders.map(el),er(e.requests)]})]},e.path)};return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsxs)("label",{className:"relative mb-2 block",children:[(0,t.jsx)("span",{className:"sr-only",children:"Search saved requests"}),(0,t.jsx)(i.Search,{size:13,className:"pointer-events-none absolute top-1/2 left-2 -translate-y-1/2 text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:g,onChange:e=>v(e.target.value),placeholder:"Search requests",className:"input h-8 rounded-lg pl-7 text-xs"})]}),q.size?(0,t.jsxs)("div",{role:"toolbar","aria-label":"Selected requests",className:"mb-2 flex items-center gap-1 rounded-lg border border-accent/40 bg-accent-dim/40 px-2 py-1.5 text-xs",children:[(0,t.jsxs)("span",{className:"flex-1 text-ink",children:[q.size," selected"]}),(0,t.jsx)("button",{type:"button",title:"Move to…","aria-label":"Move the selected requests",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>L([...q]),children:(0,t.jsx)(ep,{size:14,"aria-hidden":!0})}),(0,t.jsx)("button",{type:"button",title:"Export…","aria-label":"Export the selected requests",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>(0,eC.openExport)({kind:"requests",ids:[...q]}),children:(0,t.jsx)(ed.FileOutput,{size:14,"aria-hidden":!0})}),(0,t.jsx)("button",{type:"button",title:"Move to Trash","aria-label":"Move the selected requests to Trash",className:"rounded p-1 text-mute hover:text-bad",onClick:()=>void _([...q]),children:(0,t.jsx)(J.Trash2,{size:14,"aria-hidden":!0})}),(0,t.jsx)("button",{type:"button",title:"Clear the selection","aria-label":"Clear the selection",className:"rounded p-1 text-mute hover:text-ink",onClick:()=>E(new Set),children:(0,t.jsx)(X.X,{size:14,"aria-hidden":!0})})]}):null,(0,t.jsxs)("div",{...K(""),className:`min-h-0 flex-1 overflow-auto rounded-md ${""===H?"bg-accent-dim/30 ring-1 ring-accent/60 ring-inset":""}`,children:[w?.kind==="new"&&""===w.parent?(0,t.jsx)(eU,{initial:"",label:"New folder",onDone:e=>void es(e),hint:"Use / for a folder inside another: Orders/Admin"}):null,0===P.length&&0===O.length?(0,t.jsxs)("div",{className:"space-y-2 px-1 py-4 text-xs text-mute",children:[(0,t.jsx)("p",{children:"No saved requests yet. Press Save (Ctrl+S) to keep the current one."}),(0,t.jsxs)("p",{children:["Coming from Postman or Swagger?"," ",(0,t.jsx)("button",{type:"button",onClick:()=>(0,ek.openImport)(),className:"text-accent hover:underline",children:"Import your requests"})]})]}):U&&0===I.length?(0,t.jsx)("p",{className:"px-1 py-4 text-xs text-mute",children:"Nothing matches."}):(0,t.jsxs)(t.Fragment,{children:[B.folders.map(el),er(B.requests)]})]}),$?(0,t.jsx)(eD,{path:$,onClose:()=>C(null)}):null,D?(0,t.jsx)(eI,{count:D.length,folders:[...new Set([...O.map(e=>e.path),...P.map(e=>e.collection)].filter(Boolean))].sort(),onPick:e=>{L(null),E(new Set),W(D,{collection:e})},onClose:()=>L(null)}):null]})}function eU({initial:e,label:s,onDone:n,hint:a}){let[r,l]=(0,c.useState)(e),i=(0,c.useRef)(null),o=(0,c.useRef)(!1);(0,c.useEffect)(()=>i.current?.select(),[]);let d=e=>{o.current||(o.current=!0,n(e))};return(0,t.jsxs)("div",{className:"px-1 py-1",children:[(0,t.jsx)("input",{ref:i,value:r,"aria-label":s,placeholder:"Folder name",onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&d(r),"Escape"===e.key&&d("")},onBlur:()=>d(r),className:"input py-1 text-xs"}),a?(0,t.jsx)("p",{className:"mt-0.5 text-[11px] text-mute",children:a}):null]})}function eI({count:e,folders:s,onPick:n,onClose:a}){let[r,l]=(0,c.useState)("");(0,c.useEffect)(()=>{let e=e=>"Escape"===e.key&&a();return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a]);let i=s.filter(e=>e.toLowerCase().includes(r.trim().toLowerCase()));return(0,t.jsx)("div",{className:"fixed inset-0 z-[66] flex items-center-safe justify-center bg-black/50 p-4 sm:p-16",role:"presentation",onMouseDown:e=>e.target===e.currentTarget&&a(),children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true","aria-labelledby":"move-title",className:"flex max-h-[70vh] w-full max-w-md flex-col rounded-xl border border-line bg-panel shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2 border-b border-line px-4 py-3",children:[(0,t.jsx)(ep,{size:15,className:"text-accent","aria-hidden":!0}),(0,t.jsxs)("h2",{id:"move-title",className:"flex-1 text-sm font-medium text-ink",children:["Move ",e," request",1===e?"":"s"," to…"]}),(0,t.jsx)("button",{type:"button",onClick:a,"aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",children:(0,t.jsx)(X.X,{size:15})})]}),(0,t.jsx)("div",{className:"border-b border-line p-3",children:(0,t.jsx)("input",{autoFocus:!0,value:r,onChange:e=>l(e.target.value),placeholder:"Find a folder","aria-label":"Find a folder",className:"input h-8 text-xs"})}),(0,t.jsxs)("ul",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[(0,t.jsx)("li",{children:(0,t.jsx)("button",{type:"button",onClick:()=>n(""),className:"w-full rounded-md px-3 py-2 text-left text-sm text-mute hover:bg-panel-2 hover:text-ink",children:"Top level — no folder"})}),i.map(e=>(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:()=>n(e),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-ink hover:bg-panel-2",children:[(0,t.jsx)(eu.Folder,{size:14,className:"shrink-0 text-mute","aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e})]})},e))]})]})})}function eB({label:e,open:s,onOpenChange:n,items:a}){let r=(0,c.useRef)(null);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{ref:r,type:"button","aria-label":e,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>n(!s),className:`mr-1 rounded p-1 text-mute hover:text-ink focus:opacity-100 ${s?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:(0,t.jsx)(eb.MoreHorizontal,{size:13})}),(0,t.jsx)(Q.Popover,{anchor:r,open:s,onClose:()=>n(!1),label:e,width:220,role:"menu",children:(0,t.jsx)("div",{className:"-m-2",children:a.map((e,s)=>"separator"===e?(0,t.jsx)(Z.MenuSeparator,{},s):(0,t.jsx)(Z.MenuItem,{icon:e.icon,label:e.label,hint:e.hint,danger:e.danger,onSelect:()=>{n(!1),e.run()}},e.label))})})]})}function eV({path:e,open:s,onOpenChange:n,onNewRequest:a,onSettings:r,onNewInside:l,onRename:i,onDelete:o}){let d=(0,c.useRef)(null),u=(0,ew.useRouter)(),p=e=>()=>{n(!1),e()};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{ref:d,type:"button","aria-label":`Actions for ${e}`,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>n(!s),className:`rounded p-1 text-mute hover:text-ink focus:opacity-100 ${s?"opacity-100":"opacity-0 group-hover/folder:opacity-100"}`,children:(0,t.jsx)(eb.MoreHorizontal,{size:13})}),(0,t.jsx)(Q.Popover,{anchor:d,open:s,onClose:()=>n(!1),label:`Actions for ${e}`,width:240,role:"menu",children:(0,t.jsxs)("div",{className:"-m-2",children:[(0,t.jsx)(Z.MenuItem,{icon:ec,label:"New request here",onSelect:p(a)}),(0,t.jsx)(Z.MenuItem,{icon:eh,label:"New folder inside",onSelect:p(l)}),(0,t.jsx)(Z.MenuSeparator,{}),(0,t.jsx)(Z.MenuItem,{icon:ev.Play,label:"Run this folder",onSelect:p(()=>u.push((0,eL.suiteHref)(e)))}),(0,t.jsx)(Z.MenuItem,{icon:ey.Server,label:"Mock server for this folder",onSelect:p(()=>(0,eN.openMock)(e))}),(0,t.jsx)(Z.MenuItem,{icon:K.Settings2,label:"Folder settings",onSelect:p(r)}),(0,t.jsx)(Z.MenuSeparator,{}),(0,t.jsx)(Z.MenuItem,{icon:eg.Pencil,label:"Rename or move",onSelect:p(i)}),(0,t.jsx)(Z.MenuItem,{icon:ed.FileOutput,label:"Export…",onSelect:p(()=>(0,eC.openExport)({kind:"folder",path:e}))}),(0,t.jsx)(Z.MenuSeparator,{}),(0,t.jsx)(Z.MenuItem,{icon:J.Trash2,label:"Delete folder",danger:!0,onSelect:p(o)})]})})]})}async function eW(e,t,s,n){let a,r,l=t.before;if(!l)return e;try{a=await en.workspaceApi.get(l.requestId)}catch{throw Error(`Run first: “${l.requestName}” is no longer saved — pick another request on the Run first tab`)}if(a.secretsMissing?.length)throw Error(`Run first: the saved ${a.secretsMissing.join(", ")} of “${a.name}” is not available — open it and enter it again`);try{let e=await (0,et.withFolders)({...(0,ee.requestFromUnknown)(a.request),before:null,testData:null},a.collection,s);r=(0,ee.resolveDraft)(e.draft,e.vars,n)}catch(e){throw Error(`Run first “${a.name}”: ${e instanceof Error?e.message:"invalid request"}`)}try{return{...e,setup:(0,ee.buildSetup)({...l,requestName:a.name},r)}}catch(e){throw Error(e instanceof Error&&e.message.startsWith("Run first")?e.message:`Run first “${a.name}”: ${e instanceof Error?e.message:"invalid request"}`)}}e.s(["REQUEST_MOVED_EVENT",0,eP,"RequestPicker",0,function({onOpen:e}){let[s,n]=(0,c.useState)(!1),a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(!s)return;let e=e=>!a.current?.contains(e.target)&&n(!1),t=e=>"Escape"===e.key&&n(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[s]),(0,t.jsxs)("div",{ref:a,className:"relative",children:[(0,t.jsxs)("button",{type:"button","aria-expanded":s,onClick:()=>n(e=>!e),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-xs text-mute hover:text-ink",children:[(0,t.jsx)(eu.Folder,{size:12,"aria-hidden":!0})," Load saved request"]}),s?(0,t.jsx)("div",{className:"absolute left-0 z-40 mt-1 flex h-80 w-80 flex-col rounded-md border border-line bg-panel p-2 shadow-xl",children:(0,t.jsx)(eO,{allowDelete:!1,onOpen:t=>{e(t),n(!1)}})}):null]})},"RequestsPanel",0,function({activeId:e,onOpen:s,onNew:n}){let[a,r]=(0,c.useState)(!1),l=(0,eH.useModKey)();return(0,t.jsxs)("aside",{"aria-label":"Saved requests",className:"flex min-h-0 flex-col border-line bg-panel/40 px-2.5 py-3 lg:border-r",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center justify-between pl-1",children:[(0,t.jsxs)("h2",{className:"text-[13px] font-semibold whitespace-nowrap text-ink",children:["Saved requests ",(0,t.jsxs)("span",{className:"text-[11px] font-normal text-mute",title:"Show or hide this panel",children:["(",l,"+B)"]})]}),(0,t.jsxs)("span",{className:"flex shrink-0 items-center",children:[(0,t.jsx)("button",{type:"button",onClick:n,title:"New request","aria-label":"New request",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(ec,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:()=>r(!0),title:"New folder","aria-label":"New folder",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(eh,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:()=>(0,ek.openImport)(),title:"Import requests — Postman, Insomnia, Bruno, OpenAPI, .http, Hurl, HAR","aria-label":"Import requests",className:"rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(ex,{size:14})})]})]}),(0,t.jsx)(eO,{activeId:e,onOpen:s,newFolder:a,onNewFolderDone:()=>r(!1)})]})},"SaveRequestForm",0,function({initial:e,onSave:s,onCancel:n}){let{index:a}=(0,en.useWorkspace)(),[r,l]=(0,c.useState)(e.name),[i,o]=(0,c.useState)(e.collection),d=(0,c.useRef)(null),u=[...new Set([...(a?.folders??[]).map(e=>e.path),...(a?.requests??[]).map(e=>e.collection)].filter(Boolean))].sort();return(0,c.useEffect)(()=>d.current?.select(),[]),(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r.trim()&&s(r.trim(),i.trim())},onKeyDown:e=>"Escape"===e.key&&n(),className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:["Collection",(0,t.jsx)("input",{value:i,onChange:e=>o(e.target.value),list:"atc-collections",placeholder:"none — or Orders/Admin",title:"A folder; use / for a folder inside another",className:"input w-48 py-1 text-xs","aria-label":"Collection"}),(0,t.jsx)("datalist",{id:"atc-collections",children:u.map(e=>(0,t.jsx)("option",{value:e},e))})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-mute",children:[(0,t.jsx)("span",{"aria-hidden":!0,children:"/"}),"Name",(0,t.jsx)("input",{ref:d,value:r,onChange:e=>l(e.target.value),className:"input w-52 py-1 text-xs","aria-label":"Request name"})]}),(0,t.jsx)("button",{type:"submit",className:"btn btn-primary py-1 text-xs",children:"Save request"}),(0,t.jsx)("button",{type:"button",className:"rounded p-1 text-mute hover:text-ink","aria-label":"Cancel",onClick:n,children:(0,t.jsx)(X.X,{size:14})})]})}],65638),e.s(["withRunFirst",0,eW],46679)},10281,e=>{"use strict";let t=(0,e.i(99522).default)("unplug",[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]]);e.s(["Unplug",0,t],10281)}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,6980,e=>{"use strict";var t=e.i(14368);e.i(24856);var s=e.i(90870),n=e.i(2385),a=e.i(36163),r=e.i(78451),l=e.i(90139),i=e.i(95486),o=e.i(1245),c=e.i(33577),d=e.i(89932),u=e.i(85905),m=e.i(47677),h=e.i(20621),p=e.i(91694),x=e.i(30197),f=e.i(27813),b=e.i(99522);let y=(0,b.default)("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]),g=(0,b.default)("minimize-2",[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]]);var v=e.i(3792),k=e.i(5769),w=e.i(71189);let j=(0,b.default)("rows-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]]);var N=e.i(95927),S=e.i(50962),E=e.i(66478);let C=(0,b.default)("square-x",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var q=e.i(10281),R=e.i(87283),$=e.i(99181),M=e.i(63343),O=e.i(44794),T=e.i(31753),P=e.i(29724),L=e.i(60566),A=e.i(39170),I=e.i(13318),U=e.i(68228),F=e.i(59100);let D=(0,b.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);var z=e.i(80707),_=e.i(56396);e.i(42674);var V=e.i(5305),J=e.i(6278);let K="\0new";function H(e,t){if(!t.has("baseUrl"))return"baseUrl";let s="api";try{s=new URL(e).hostname.split(".")[0].replace(/[^A-Za-z0-9]/g,"")||"api"}catch{}let n=`${s}Url`;for(let e=2;t.has(n);e++)n=`${s}Url${e}`;return n}function B({draft:e,sent:s,onChange:n}){let{environments:a,activeEnv:r,vars:l}=(0,J.useWorkspace)(),[i,o]=(0,$.useState)(!1),c=function(e){try{let t=new URL(e);if(!/^https?:$/.test(t.protocol)||["localhost","127.0.0.1"].includes(t.hostname))return[];let s=t.origin,n=t.pathname.split("/").filter(Boolean);return n.length>=2?[s,`${s}/${n[0]}`]:[s]}catch{return[]}}(e.url),d=new Set(Object.values(l).map(e=>e.trim().replace(/\/+$/,"")));return!s||!c.length||c.some(e=>d.has(e))?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{type:"button",onClick:()=>o(!0),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-accent hover:underline",title:"Keep this server address in an environment",children:[(0,t.jsx)(D,{size:13,"aria-hidden":!0})," Save ",c[0].replace(/^https?:\/\//,"")," as a base URL"]}),i?(0,t.jsx)(W,{draft:e,addresses:c,environments:a,activeEnvId:r?.id??null,onChange:n,onClose:()=>o(!1)}):null]})}function W({draft:e,addresses:s,environments:n,activeEnvId:a,onChange:r,onClose:l}){let i=(0,_.useToast)(),{index:o,saveEnvironments:c,setActiveEnv:d,refresh:u}=(0,J.useWorkspace)(),[m,h]=(0,$.useState)(s[0]),[p,x]=(0,$.useState)(a??n[0]?.id??K),[f,b]=(0,$.useState)(()=>{try{return new URL(s[0]).hostname.split(".").slice(0,2).join(" ")}catch{return"My API"}}),y=n.find(e=>e.id===p)??null,g=(0,$.useMemo)(()=>new Set((y?.variables??[]).map(e=>e.key)),[y]),[v,k]=(0,$.useState)(()=>H(s[0],g)),[w,j]=(0,$.useState)(!0),[N,S]=(0,$.useState)(!1),E=(0,$.useRef)(null);(0,$.useEffect)(()=>E.current?.focus(),[]),(0,$.useEffect)(()=>k(H(m,g)),[m,g]);let C=(o?.requests??[]).filter(t=>t.url.startsWith(m)&&t.url!==e.url),q=y?.variables.find(e=>e.key===v),M=F.VARIABLE_NAME.test(v)&&(p!==K||f.trim());async function O(){if(M&&!N){S(!0);try{let t=p===K?globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`:p,s=structuredClone(n),a=s.find(e=>e.id===t);a||(a={id:t,name:f.trim(),variables:[]},s.push(a)),a.variables=[...a.variables.filter(e=>e.key!==v),{key:v,value:m,secret:!1}],await c(s),d(t),r((0,V.withUrl)(e,`{{${v}}}${e.url.slice(m.length)}`));let o=0,h=0;if(w){for(let e of C){let t=await J.workspaceApi.get(e.id).catch(()=>null);if(!t||t.secretsMissing?.length){h++;continue}let s=(0,V.requestFromUnknown)(t.request);s.url.startsWith(m)&&(await J.workspaceApi.update(e.id,{name:t.name,collection:t.collection,request:(0,V.withUrl)(s,`{{${v}}}${s.url.slice(m.length)}`)}),o++)}await u()}i(`Saved {{${v}}} in ${a.name}.${o?` ${o} other saved request${1===o?"":"s"} now use it.`:""}${h?` ${h} left as they were (a saved secret isn't available).`:""} Save this request to keep the change.`,"success"),l()}catch(e){i(e instanceof Error?e.message:"Could not save the base URL","error")}finally{S(!1)}}}return(0,t.jsx)("div",{className:"fixed inset-0 z-[75] flex items-center-safe justify-center overflow-y-auto bg-black/50 p-4 sm:p-16",role:"presentation",onMouseDown:e=>e.target===e.currentTarget&&!N&&l(),children:(0,t.jsxs)("form",{role:"dialog","aria-modal":"true","aria-labelledby":"save-base-title",onSubmit:e=>{e.preventDefault(),O()},onKeyDown:e=>"Escape"===e.key&&!N&&l(),className:"w-full max-w-lg space-y-4 rounded-xl border border-line bg-panel p-5 shadow-2xl",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2",children:[(0,t.jsx)("h2",{id:"save-base-title",className:"text-base font-medium text-ink",children:"Save as a base URL"}),(0,t.jsx)("button",{type:"button",onClick:l,"aria-label":"Close",className:"ml-auto rounded p-1 text-mute hover:text-ink",children:(0,t.jsx)(R.X,{size:16})})]}),(0,t.jsx)("p",{className:"text-sm text-mute",children:"Keep the server address in an environment, so you type only the path — and switch servers (UAT, Prod) by switching environments."}),(0,t.jsxs)("fieldset",{className:"space-y-1.5",children:[(0,t.jsx)("legend",{className:"mb-1 text-xs text-mute",children:"Address"}),s.map(e=>(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"radio",name:"address",checked:m===e,onChange:()=>h(e)}),(0,t.jsx)("span",{className:"font-mono text-xs break-all",children:e})]},e))]}),(0,t.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Environment",(0,t.jsx)(z.Select,{label:"Environment",value:p,onChange:x,options:[...n.map(e=>({value:e.id,label:e.name,hint:`${e.variables.length} variables`})),{value:K,label:"New environment…"}],className:"rounded-md border border-line bg-panel-2 px-2 py-1.5 text-sm text-ink"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute",children:["Variable name",(0,t.jsx)("input",{ref:E,value:v,onChange:e=>k(e.target.value.replace(/[^\w.-]/g,"")),className:"input py-1.5 font-mono text-sm"})]}),p===K?(0,t.jsxs)("label",{className:"flex flex-col gap-1 text-xs text-mute sm:col-span-2",children:["New environment name",(0,t.jsx)("input",{value:f,onChange:e=>b(e.target.value),className:"input py-1.5 text-sm"})]}):null]}),q&&q.value!==m?(0,t.jsxs)("p",{className:"text-xs text-warn",children:[`{{${v}}}`," already exists in this environment (",q.value,") — it will be replaced."]}):null,(0,t.jsxs)("p",{className:"rounded-md bg-panel-2 px-3 py-2 font-mono text-xs text-ink break-all",children:[`{{${v}}}`,(0,t.jsx)("span",{className:"text-mute",children:e.url.slice(m.length)||"/"})]}),C.length?(0,t.jsxs)("label",{className:"flex items-start gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:w,onChange:e=>j(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Also switch ",C.length," other saved request",1===C.length?"":"s"," that use this address",(0,t.jsxs)("span",{className:"block text-xs text-mute",children:[C.slice(0,3).map(e=>e.name).join(", "),C.length>3?` and ${C.length-3} more`:""]})]})]}):null,(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:l,disabled:N,children:"Cancel"}),(0,t.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:!M||N,children:"Save base URL"})]})]})})}var Q=e.i(65638),X=e.i(37837),Y=e.i(17847);function G(e,t){let s=(0,$.useRef)(!0);(0,$.useEffect)(()=>{if(s.current){s.current=!1;return}let t=e.current;!t||function(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}()||"function"!=typeof t.animate||t.animate([{opacity:.35,transform:"translateY(3px)"},{opacity:1,transform:"none"}],{duration:180,easing:"cubic-bezier(0.2, 0, 0, 1)"})},[e,t])}var Z=e.i(97716);let ee=(e,t)=>"number"==typeof t?`${e}[${t}]`:/^[A-Za-z_$][\w$]*$/.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`;var et=e.i(96659),es=e.i(19656);function en({requestId:e,refreshKey:s,onOpen:n}){let a=(0,$.useRef)(null),[r,l]=(0,$.useState)(!1),[i,o]=(0,$.useState)([]),c=()=>void fetch(`/engine/responses/${e}`,{cache:"no-store"}).then(e=>e.ok?e.json():{answers:[]}).then(e=>o(e.answers)).catch(()=>void 0);return((0,$.useEffect)(c,[e,s]),i.length<2)?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{ref:a,type:"button",onClick:()=>l(e=>!e),"aria-expanded":r,title:"Earlier answers of this request — open one, or see what changed",className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-0.5 text-xs text-mute hover:border-accent hover:text-ink",children:[(0,t.jsx)(p.History,{size:12,"aria-hidden":!0})," Earlier · ",i.length-1]}),(0,t.jsx)(X.Popover,{anchor:a,open:r,onClose:()=>l(!1),label:"Earlier answers",width:340,children:(0,t.jsxs)("div",{className:"max-h-80 overflow-auto p-1",children:[(0,t.jsxs)("p",{className:"px-2 py-1.5 text-xs text-mute",children:["The last ",i.length," answers of this request, newest first · ",(0,es.formatBytes)(i.reduce((e,t)=>e+t.size,0))," kept"]}),(0,t.jsx)("ul",{children:i.map((s,a)=>{let r;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{type:"button",onClick:async()=>{let t=await fetch(`/engine/responses/${e}/${a}`,{cache:"no-store"});t.ok&&n(await t.json(),a),l(!1)},className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs hover:bg-panel-2",children:[(0,t.jsx)("span",{className:`rounded border px-1.5 font-mono ${(0,L.statusTone)(s.status)}`,children:s.status||"ERR"}),(0,t.jsx)("span",{className:"text-ink",children:0===a?"Latest":(r=new Date(s.at),new Date().toDateString()===r.toDateString()?r.toLocaleTimeString():r.toLocaleString())}),(0,t.jsxs)("span",{className:"ml-auto font-mono text-mute",children:[Math.round(s.durationMs)," ms"]}),(0,t.jsx)("span",{className:"w-16 text-right font-mono text-mute",children:(0,es.formatBytes)(s.size)}),s.checks?(0,t.jsxs)("span",{className:s.passed===s.checks?"text-ok":"text-bad",children:[s.passed,"/",s.checks]}):null]})},s.at)})}),(0,t.jsxs)("button",{type:"button",onClick:async()=>{await fetch(`/engine/responses/${e}`,{method:"DELETE"}),l(!1),c()},className:"mt-1 flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs text-mute hover:bg-panel-2 hover:text-bad",children:[(0,t.jsx)(et.Trash2,{size:12,"aria-hidden":!0})," Forget these answers"]})]})})]})}function ea(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}let er=e=>{let t="string"==typeof e?JSON.stringify(e):JSON.stringify(e)??"undefined";return t.length>80?`${t.slice(0,79)}…`:t};function el({earlier:e,latest:s}){let n=(0,$.useMemo)(()=>(function(e,t,s=200){let n,a;try{n=JSON.parse(e),a=JSON.parse(t)}catch{return null}let r=[],l=(e,t,n,a)=>{if(r.length>=s)return;let i=null!==t&&"object"==typeof t;if(null!==e&&"object"==typeof e&&i&&Array.isArray(e)===Array.isArray(t)&&a<40){if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.max(e.length,t.length)&&(i>=e.length?r.push({path:ee(n,i),kind:"added",after:t[i]}):i>=t.length?r.push({path:ee(n,i),kind:"removed",before:e[i]}):l(e[i],t[i],ee(n,i),a+1),!(r.length>=s));i++);return}for(let i of new Set([...Object.keys(e),...Object.keys(t)]))if(i in t?i in e?l(e[i],t[i],ee(n,i),a+1):r.push({path:ee(n,i),kind:"added",after:t[i]}):r.push({path:ee(n,i),kind:"removed",before:e[i]}),r.length>=s)break;return}JSON.stringify(e)!==JSON.stringify(t)&&r.push({path:n,kind:"changed",before:e,after:t})};return l(n,a,"$",0),r})(e.body,s.body),[e.body,s.body]),a=(0,$.useMemo)(()=>(function(e,t,s=3e3){let n=e.split("\n"),a=t.split("\n"),r=n.length>s||a.length>s;n=n.slice(0,s),a=a.slice(0,s);let l=0;for(;l<n.length&&l<a.length&&n[l]===a[l];)l++;let i=n.length,o=a.length;for(;i>l&&o>l&&n[i-1]===a[o-1];)i--,o--;let c=n.slice(l,i),d=a.slice(l,o),u=n.slice(0,l).map(e=>({kind:"same",text:e}));if(c.length*d.length>4e6)u.push(...c.map(e=>({kind:"removed",text:e})),...d.map(e=>({kind:"added",text:e})));else{let e=d.length+1,t=new Uint32Array((c.length+1)*e);for(let s=c.length-1;s>=0;s--)for(let n=d.length-1;n>=0;n--)t[s*e+n]=c[s]===d[n]?t[(s+1)*e+n+1]+1:Math.max(t[(s+1)*e+n],t[s*e+n+1]);let s=0,n=0;for(;s<c.length&&n<d.length;)c[s]===d[n]?(u.push({kind:"same",text:c[s]}),s++,n++):t[(s+1)*e+n]>=t[s*e+n+1]?u.push({kind:"removed",text:c[s++]}):u.push({kind:"added",text:d[n++]});for(;s<c.length;)u.push({kind:"removed",text:c[s++]});for(;n<d.length;)u.push({kind:"added",text:d[n++]})}return u.push(...n.slice(i).map(e=>({kind:"same",text:e}))),{lines:u,cut:r}})(ea(e.body),ea(s.body)),[e.body,s.body]),r=a.lines.filter(e=>"same"!==e.kind).length;return(0,t.jsxs)("div",{className:"space-y-3 overflow-auto",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-mute",children:[(0,t.jsxs)("span",{children:["Status ",(0,t.jsx)("span",{className:"font-mono text-ink",children:e.status})," → ",(0,t.jsx)("span",{className:"font-mono text-ink",children:s.status}),e.status===s.status?" (same)":""]}),(0,t.jsxs)("span",{children:["Time ",(0,t.jsxs)("span",{className:"font-mono text-ink",children:[Math.round(e.durationMs)," ms"]})," → ",(0,t.jsxs)("span",{className:"font-mono text-ink",children:[Math.round(s.durationMs)," ms"]})]}),(0,t.jsx)("span",{children:r?`${r} line${1===r?"":"s"} differ`:"The body is the same"})]}),e.masked?(0,t.jsx)("p",{className:"text-xs text-mute",children:"Values that look like secrets were hidden when the earlier answer was kept, so they show as changed."}):null,n&&n.length?(0,t.jsxs)("section",{"aria-label":"Changed fields",children:[(0,t.jsxs)("h3",{className:"mb-1 text-xs font-medium text-mute",children:[n.length," field",1===n.length?"":"s"," changed",n.length>=200?" (the first 200)":""]}),(0,t.jsx)("ul",{className:"max-h-56 space-y-0.5 overflow-auto rounded-md border border-line bg-panel-2 p-2 font-mono text-xs",children:n.map((e,s)=>(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"text-ink",children:e.path})," ","changed"===e.kind?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-bad line-through decoration-bad/60",children:er(e.before)})," → ",(0,t.jsx)("span",{className:"text-ok",children:er(e.after)})]}):"added"===e.kind?(0,t.jsxs)("span",{className:"text-ok",children:["added ",er(e.after)]}):(0,t.jsxs)("span",{className:"text-bad",children:["removed (was ",er(e.before),")"]})]},s))})]}):null,(0,t.jsxs)("section",{"aria-label":"Line by line",children:[(0,t.jsxs)("h3",{className:"mb-1 text-xs font-medium text-mute",children:["Line by line",a.cut?" (the first 3,000 lines)":""]}),(0,t.jsx)("pre",{className:"max-h-[28rem] overflow-auto rounded-md border border-line bg-panel-2 py-2 font-mono text-[12.5px] leading-5",children:a.lines.map((e,s)=>(0,t.jsxs)("div",{className:"added"===e.kind?"bg-ok/10 text-ok":"removed"===e.kind?"bg-bad/10 text-bad":"text-ink",children:[(0,t.jsx)("span",{className:"inline-block w-5 select-none text-center text-mute",children:"added"===e.kind?"+":"removed"===e.kind?"−":" "}),e.text]},s))})]})]})}var ei=e.i(21206),eo=e.i(20054);let ec="apitestcenter-lab-draft";var ed=e.i(59180),eu=e.i(88153),em=e.i(2603),eh=e.i(28950),ep=e.i(14865),ex=e.i(46679),ef=e.i(65238),eb=e.i(7149),ey=e.i(727),eg=e.i(45672),ev=e.i(69578),ek=e.i(17118),ew=e.i(40945),ej=e.i(27122);function eN({steps:e,startedAt:s,onCancel:n}){let[a,r]=(0,$.useState)(()=>Date.now()),[l]=(0,$.useState)(()=>new Map);for(let t of e)"start"!==t.state||l.has(t.id)||l.set(t.id,Date.now());(0,$.useEffect)(()=>{let e=window.setInterval(()=>r(Date.now()),100);return()=>window.clearInterval(e)},[]);let i=e=>e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`;return a-s<250?(0,t.jsx)("div",{className:"flex-1","aria-busy":"true"}):(0,t.jsxs)("div",{role:"status","aria-label":"Sending",className:"flex flex-1 flex-col items-center justify-center gap-5 py-10",children:[(0,t.jsxs)("ul",{className:"w-full max-w-md space-y-2",children:[e.map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-2.5 text-sm",children:["done"===e.state?(0,t.jsx)(ek.CheckCircle2,{size:16,className:"shrink-0 text-ok","aria-label":"done"}):"failed"===e.state?(0,t.jsx)(ej.XCircle,{size:16,className:"shrink-0 text-bad","aria-label":"failed"}):(0,t.jsx)(f.Loader2,{size:16,className:"shrink-0 animate-spin text-accent","aria-label":"running"}),(0,t.jsx)("span",{className:`min-w-0 flex-1 truncate ${"start"===e.state?"text-ink":"text-mute"}`,children:e.label}),(0,t.jsx)("span",{className:"shrink-0 font-mono text-xs text-mute",children:void 0!==e.ms?i(e.ms):i(a-(l.get(e.id)??a))})]},e.id)),e.every(e=>"start"!==e.state)?(0,t.jsxs)("li",{className:"flex items-center gap-2.5 text-sm text-mute",children:[(0,t.jsx)(ew.Circle,{size:16,className:"shrink-0","aria-hidden":!0}),(0,t.jsx)("span",{className:"flex-1",children:"Starting…"})]}):null]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:n,children:"Cancel"}),(0,t.jsxs)("span",{className:"font-mono text-xs text-mute",children:[i(a-s)," in all"]})]})]})}var eS=e.i(48181),eE=e.i(25120),eC=e.i(97942),eq=e.i(91549);let eR=(0,eE.projectKey)("apitestcenter-lab-saved"),e$="apitestcenter-requests-panel",eM="lab:answers",eO=(0,eE.projectKey)("apitestcenter-lab-tabs"),eT=()=>Math.random().toString(36).slice(2,10),eP=JSON.stringify((0,V.defaultRequestDraft)()),eL=()=>({key:eT(),draft:(0,V.defaultRequestDraft)(),saved:null,result:null,liveId:null,liveOpen:!1}),eA=e=>e.saved?.name??(e.draft.url.trim()?(0,V.autoRunName)(e.draft).replace(/ · \d.*$/,"").replace(/^[A-Z]+ /,""):"New request"),eI=e=>e.saved?JSON.stringify(e.draft)!==e.saved.snapshot:JSON.stringify(e.draft)!==eP,eU={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"},eF=(0,eE.projectKey)("apitestcenter-last-run");function eD(e){try{sessionStorage.setItem(eF,e)}catch{}}function ez(){return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-accent opacity-60"}),(0,t.jsx)("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-accent"})]}),"Load running"]})}function e_({title:e,lines:s,action:n}){return(0,t.jsxs)("div",{className:"flex flex-1 flex-col items-center justify-center rounded-lg border border-dashed border-line px-6 py-14 text-center",children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:e}),(0,t.jsx)("div",{className:"mt-2 max-w-md space-y-1.5 text-sm text-mute",children:s.map((e,s)=>(0,t.jsx)("p",{children:e},s))}),n?(0,t.jsx)("div",{className:"mt-5",children:n}):null]})}function eV({runs:e,current:s,disabled:a,onPick:r}){let{slo:l}=(0,eu.useSlo)(),[o,c]=(0,$.useState)(!1),d=(0,$.useRef)(null),u=(0,$.useMemo)(()=>e.slice(0,30),[e]);return(0,$.useEffect)(()=>{if(!o)return;let e=e=>{d.current?.contains(e.target)||c(!1)},t=e=>"Escape"===e.key&&c(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[o]),(0,t.jsxs)("div",{ref:d,className:"relative",children:[(0,t.jsxs)("button",{type:"button",disabled:a,"aria-haspopup":"listbox","aria-expanded":o,onClick:()=>c(e=>!e),className:"inline-flex items-center gap-1 rounded-md border border-line px-2 py-1 text-xs text-mute hover:text-ink disabled:opacity-40",children:["Recent runs",u.length?(0,t.jsx)("span",{className:"rounded bg-panel-2 px-1 font-mono text-[10px] text-ink",children:u.length}):null,(0,t.jsx)(i.ChevronDown,{size:12})]}),o?(0,t.jsx)("ul",{role:"listbox","aria-label":"Recent runs",className:"absolute right-0 z-30 mt-1 max-h-80 w-80 overflow-auto rounded-md border border-line bg-panel p-1 shadow-xl",children:u.map(e=>{let a=(0,n.buildVerdictFromInputs)(e.verdict,{slo:l}).overall,i=s?.id===e.id;return(0,t.jsx)("li",{role:"option","aria-selected":i,children:(0,t.jsxs)("button",{type:"button",onClick:()=>{r(e),c(!1)},className:`flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-xs ${i?"bg-accent-dim text-ink":"text-ink hover:bg-panel-2"}`,children:[(0,t.jsxs)("span",{className:"min-w-0 truncate",children:[e.baseline?(0,t.jsx)("span",{className:"mr-1 text-accent",title:"Baseline",children:"◆"}):null,e.name]}),(0,t.jsx)(eJ,{level:a})]})},e.id)})}):null]})}function eJ({level:e}){let s="pass"===e?"text-ok":"fail"===e?"text-bad":"text-warn";return(0,t.jsxs)("span",{className:`shrink-0 font-mono text-xs uppercase ${s}`,children:[(0,t.jsxs)("span",{"aria-hidden":!0,children:["pass"===e?"✓":"fail"===e?"✕":"!"," "]}),e]})}function eK(){let{slo:e,setSlo:s,ready:n}=(0,eu.useSlo)(),[a,r]=(0,$.useState)(!1),[l,i]=(0,$.useState)(500),[o,c]=(0,$.useState)(0),[d,u]=(0,$.useState)(1),[m,h]=(0,$.useState)(99),[p,x]=(0,$.useState)(!1),f=(0,$.useRef)(!1);function b(e){let t={on:a,p95:l,p99:o,errPct:d,checksPct:m,abort:p,...e};if(r(t.on),i(t.p95),c(t.p99),u(t.errPct),h(t.checksPct),x(t.abort),!t.on||!(t.p95>0)||t.errPct<0)return s(null);s({p95Ms:t.p95,errorRate:t.errPct/100,p99Ms:t.p99>0?t.p99:void 0,checksRate:Math.min(100,Math.max(0,t.checksPct))/100,abortOnFail:t.abort})}(0,$.useEffect)(()=>{n&&!f.current&&(f.current=!0,e&&(r(!0),i(e.p95Ms),c(e.p99Ms??0),u(Number((100*e.errorRate).toFixed(4))),h(null!=e.checksRate?Number((100*e.checksRate).toFixed(2)):99),x(!0===e.abortOnFail)))},[n,e]);let y=(e,s,n,a)=>(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("span",{className:"mb-1 block text-xs text-mute",children:e}),(0,t.jsx)("input",{type:"number",min:a.min,max:a.max,step:a.step,value:s,onChange:e=>b({[n]:Number(e.target.value)}),className:"input font-mono"}),a.hint?(0,t.jsx)("span",{className:"mt-1 block text-xs text-mute",children:a.hint}):null]});return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-sm text-mute",children:"Targets decide whether a performance test passes. They are sent to k6 as thresholds, drive the verdict and the report colours, and are remembered on this computer."}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:a,onChange:e=>b({on:e.target.checked}),className:"accent-[var(--accent)]"}),"Use my own performance targets"]}),a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[y("p95 must stay under (ms)",l,"p95",{min:1}),y("p99 must stay under (ms)",o,"p99",{min:0,hint:"0 = no p99 target"}),y("Error rate must stay under (%)",d,"errPct",{min:0,max:100,step:.1}),y("Checks must pass at least (%)",m,"checksPct",{min:0,max:100,step:.1,hint:"Only used when the request has checks"})]}),(0,t.jsxs)("label",{className:"flex items-start gap-2 rounded-md border border-line px-3 py-2.5 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:p,onChange:e=>b({abort:e.target.checked}),className:"mt-0.5 accent-[var(--accent)]"}),(0,t.jsxs)("span",{children:["Stop the test early if a target is clearly missed",(0,t.jsx)("span",{className:"block text-xs text-mute",children:"After a 10-second warm-up, k6 ends the run as soon as a target fails — saves time and stops hammering a struggling API."})]})]})]}):(0,t.jsx)("p",{className:"rounded-md bg-panel-2 px-3 py-2 text-sm text-mute",children:"Using built-in defaults: warn at p95 ≥ 500 ms or errors ≥ 1%, fail at p95 ≥ 2 s or errors ≥ 5%. No thresholds are sent to k6."})]})}function eH({dirty:e,isSaved:s,title:n,onSave:a,onSaveAs:r,onHistory:l,onExport:o}){let[c,d]=(0,$.useState)(!1),x=(0,$.useRef)(null);return(0,t.jsxs)("div",{className:"inline-flex",children:[(0,t.jsxs)("button",{type:"button",onClick:a,disabled:s&&!e,title:n,className:"btn btn-secondary rounded-r-none border-r-0",children:[(0,t.jsx)(N.Save,{size:16,"aria-hidden":!0}),"Save",e?(0,t.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-accent","aria-label":"unsaved changes"}):null]}),(0,t.jsx)("button",{ref:x,type:"button",onClick:()=>d(e=>!e),"aria-label":"More ways to save","aria-haspopup":"menu","aria-expanded":c,className:"btn btn-secondary rounded-l-none px-2",children:(0,t.jsx)(i.ChevronDown,{size:14,"aria-hidden":!0})}),(0,t.jsx)(X.Popover,{anchor:x,open:c,onClose:()=>d(!1),label:"More ways to save",width:220,role:"menu",children:(0,t.jsxs)("div",{className:"-m-2",children:[(0,t.jsx)(Y.MenuItem,{icon:s?u.CopyPlus:h.FolderOpen,label:s?"Save as a new request…":"Save to a folder…",onSelect:()=>{d(!1),r()}}),l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(Y.MenuSeparator,{}),(0,t.jsx)(Y.MenuItem,{icon:p.History,label:"Version history…",onSelect:()=>{d(!1),l()}})]}):null,o?(0,t.jsx)(Y.MenuItem,{icon:m.FileOutput,label:"Export…",onSelect:()=>{d(!1),o()}}):null]})})]})}e.s(["LabPage",0,function(){var e;let i=(0,_.useToast)(),m=(0,A.useConfirm)(),p=(0,eo.useEngineHealth)(),b=(0,em.useModKey)(),{slo:N}=(0,eu.useSlo)(),{vars:F,activeEnv:D,refresh:z,rememberValues:K}=(0,J.useWorkspace)(),[H,W]=(0,$.useState)(null),[X,ee]=(0,$.useState)(!1),[et,es]=(0,$.useState)(!0),ea=(0,$.useRef)(null),[er,ek]=(0,$.useState)(V.defaultRequestDraft),[ew,ej]=(0,$.useState)(V.defaultLoad),[eE,eJ]=(0,$.useState)(!1),[eB,eW]=(0,$.useState)(null),[eQ,eX]=(0,$.useState)(null),[eY,eG]=(0,$.useState)(!1),[eZ,e0]=(0,$.useState)(null),[e1,e2]=(0,$.useState)(!1),e5=(0,$.useRef)(null),e9=(0,$.useRef)(null);G(e5,H?.id),G(e9,eB);let[e6,e3]=(0,$.useState)(!1),[e7,e4]=(0,$.useState)([]),[e8,te]=(0,$.useState)(0),tt=(0,$.useRef)(null),[ts,tn]=(0,$.useState)(!1),[ta,tr]=(0,$.useState)(!1),[tl,ti]=(0,$.useState)(null),[to,tc]=(0,$.useState)(null),{index:td,refresh:tu}=(0,ed.useHistory)(),tm=td?.runs??[],[th,tp]=(0,$.useState)("response"),[tx,tf]=(0,$.useState)(!1),{layout:tb,setLayout:ty}=(0,ep.useViewPrefs)(),tg="below"===tb,[tv,tk]=(0,$.useState)([]),[tw,tj]=(0,$.useState)(""),tN=to?.status==="running"||to?.status==="queued",tS=(0,V.isReady)(er),tE=(0,V.loadProblem)(ew),tC=e6||ts;(0,$.useEffect)(()=>{let e=null;try{e=sessionStorage.getItem(eF)}catch{}e&&(0,ei.fetchRun)(e).then(async t=>{if(t)return tc(t);let s=await ed.historyApi.run(e).catch(()=>null);s&&tc({id:s.report.id,status:s.report.status,report:s.report})});let t=function(){try{let e=sessionStorage.getItem(ec);if(!e)return null;let t=JSON.parse(e);if(2===t.v)return{request:(0,V.requestFromUnknown)(t.request),load:(0,V.loadFromUnknown)(t.load)};return{request:(0,V.requestFromUnknown)(t),load:(0,V.loadFromUnknown)(t)}}catch{return null}}();t&&ej(t.load);let s=[],n="";try{let e=JSON.parse(localStorage.getItem(eO)??"null"),t=(0,eh.recall)(eM)??{};s=(e?.tabs??[]).map(e=>({key:e.key||eT(),draft:(0,V.requestFromUnknown)(e.draft),saved:e.saved??null,result:t[e.key]??null,liveId:null,liveOpen:!1})),n=e?.active??"",es("closed"!==localStorage.getItem(e$))}catch{}if(!s.length){let e=null;try{e=JSON.parse(sessionStorage.getItem(eR)??"null")}catch{}s=[{...eL(),draft:t?.request??(0,V.defaultRequestDraft)(),saved:e}]}let a=s.find(e=>e.key===n)??s[0];tk(s),tj(a.key),ek(a.draft),W(a.saved),eW(a.result),eJ(!0)},[]),(0,$.useEffect)(()=>{if(!eE)return;let e={};for(let t of tv){let s=t.key===tw?eB:t.result;s&&(e[t.key]=s)}(0,eh.remember)(eM,e)},[eE,tv,tw,eB]),(0,$.useEffect)(()=>{if(!eE)return;let e=window.setTimeout(()=>{try{sessionStorage.setItem(ec,JSON.stringify({v:2,request:er,load:ew}))}catch{}try{let e=tv.map(e=>e.key===tw?{key:e.key,draft:er,saved:H}:{key:e.key,draft:e.draft,saved:e.saved});localStorage.setItem(eO,JSON.stringify({tabs:e,active:tw}))}catch{}},250);return()=>window.clearTimeout(e)},[er,ew,eE,tv,tw,H]),(0,$.useEffect)(()=>{if(!to||!tN)return;let e=!1,t=window.setInterval(async()=>{let t=await (0,ei.fetchRun)(to.id);if(t&&!e&&(tc(t),(0,ei.isTerminalStatus)(t.status))){tu();let e="completed"===t.status?"finished":t.status;i(`Performance test ${e}`,"failed"===t.status?"error":"success");let s=(0,n.buildVerdict)(t.report,{slo:N});(0,ey.notifyFinished)({title:`Performance test ${e}`,body:`${t.report.testName}
|
|
2
|
+
${"completed"===t.status?s.headline:t.error??"See the report for details."}`,ok:"completed"===t.status&&"fail"!==s.overall})}},500);return()=>{e=!0,window.clearInterval(t)}},[to?.id,tN]);let tq=!!H&&JSON.stringify(er)!==H.snapshot;function tR(e){W(e);try{e?sessionStorage.setItem(eR,JSON.stringify(e)):sessionStorage.removeItem(eR)}catch{}}function t$(e){es(e);try{localStorage.setItem(e$,e?"open":"closed")}catch{}}async function tM(e){try{let t={name:e?.name??H.name,collection:e?.collection??H.collection,request:er},s=H&&!e?await J.workspaceApi.update(H.id,t):await J.workspaceApi.create(t);tR({id:s.id,name:s.name,collection:s.collection,snapshot:JSON.stringify(er)}),ee(!1),await z(),i(`Saved “${s.name}”${s.collection?` in ${s.collection}`:""}`,"success")}catch(e){i(e instanceof Error?e.message:"Could not save the request","error")}}let tO=()=>({key:tw,draft:er,saved:H,result:eB,liveId:eQ,liveOpen:eY});function tT(e){tj(e.key),ek(e.draft),tR(e.saved),eW(e.result),eX(e.liveId),eG(e.liveOpen),e0(null),e2(!1),tr(!1),ti(null),ee(!1),tp("response")}function tP(e){if(e===tw)return;let t=tv.find(t=>t.key===e);t&&(tk(e=>e.map(e=>e.key===tw?tO():e)),tT(t))}function tL(e,t){let s=!H&&!eB&&!eQ&&JSON.stringify(er)===eP,n={key:s?tw:eT(),draft:e,saved:t,result:null,liveId:null,liveOpen:!1};tk(e=>{if(s)return e.map(e=>e.key===tw?n:e);let t=e.map(e=>e.key===tw?tO():e),a=t.findIndex(e=>e.key===tw);return[...t.slice(0,a+1),n,...t.slice(a+1)]}),tT(n)}async function tA(e){let t=tv.map(e=>e.key===tw?tO():e),s=t.filter(t=>e.includes(t.key));if(!s.length)return;let n=s.filter(eI);if(n.length){let e=1===s.length;if(!await m({title:e?`Close “${eA(n[0])}” without saving?`:`Close ${s.length} tabs?`,body:e?"Its changes have not been saved.":1===n.length?`“${eA(n[0])}” has changes that are not saved.`:`${n.length} of them have changes that are not saved.`,confirmLabel:"Close",tone:"danger"}))return}for(let e of s)e.liveId&&Z.realtimeApi.close(e.liveId);let a=t.filter(t=>!e.includes(t.key));if(!e.includes(tw))return tk(a);let r=t.findIndex(e=>e.key===tw),l=t.slice(r+1).find(t=>!e.includes(t.key))??t.slice(0,r).reverse().find(t=>!e.includes(t.key))??eL();tk(a.length?a:[l]),tT(l)}let[tI,tU]=(0,$.useState)(null),[tF,tD]=(0,$.useState)(!1);async function tz(){try{let e=await J.workspaceApi.index(),t=t=>e.requests.find(e=>"Practice"===e.collection&&e.name===t),s=t("Sign in")?.id??(await J.workspaceApi.create({name:"Sign in",collection:"Practice",request:{...(0,V.withUrl)({...(0,V.defaultRequestDraft)(),method:"POST"},"{{practiceApi}}/login"),bodyMode:"json",bodyText:'{\n "username": "you",\n "password": "demo"\n}',checks:[{type:"status",expect:"200"}]}})).id,n=t("My orders"),a=n?await J.workspaceApi.get(n.id):await J.workspaceApi.create({name:"My orders",collection:"Practice",request:{...(0,V.withUrl)((0,V.defaultRequestDraft)(),"{{practiceApi}}/orders"),authMode:"bearer",token:"{{token}}",checks:[{type:"status",expect:"200"}],before:{requestId:s,requestName:"Sign in",extract:[{name:"token",from:"json",path:"data.token"}]}}});await z(),t$(!0),await t_(a),i("Added Practice → Sign in and My orders. Press Send: it signs in first, then uses the token.","success")}catch(e){i(e instanceof Error?e.message:"Could not add the practice requests","error")}}function t_(e){if(H?.id===e.id)return;let t=tv.find(t=>t.key!==tw&&t.saved?.id===e.id);if(t)return tP(t.key);let s=(0,V.requestFromUnknown)(e.request);tL(s,{id:e.id,name:e.name,collection:e.collection,snapshot:JSON.stringify(s)})}(0,$.useEffect)(()=>{let e=()=>tD(!(0,eg.welcomeHidden)());return e(),window.addEventListener(eg.WELCOME_EVENT,e),()=>window.removeEventListener(eg.WELCOME_EVENT,e)},[]);let tV=(0,$.useRef)(()=>{});tV.current=e=>{let t=(0,V.requestFromUnknown)(e.request),s={id:e.id,name:e.name,collection:e.collection,snapshot:JSON.stringify(t)};H?.id===e.id?(ek(t),tR(s)):tk(n=>n.map(n=>n.saved?.id===e.id?{...n,draft:t,saved:s}:n))},(0,$.useEffect)(()=>{let e=e=>tV.current(e.detail);return window.addEventListener(eC.REQUEST_REPLACED_EVENT,e),()=>window.removeEventListener(eC.REQUEST_REPLACED_EVENT,e)},[]),(0,$.useEffect)(()=>{let e=e=>{let t=e.detail;W(e=>e?.id===t.id?{...e,name:t.name,collection:t.collection}:e),tk(e=>e.map(e=>e.saved?.id===t.id?{...e,saved:{...e.saved,name:t.name,collection:t.collection}}:e))};return window.addEventListener(Q.REQUEST_MOVED_EVENT,e),()=>window.removeEventListener(Q.REQUEST_MOVED_EVENT,e)},[]);let tJ=(0,$.useRef)(t_);tJ.current=t_;let tK=(0,$.useRef)(tL);function tH(){tL((0,V.defaultRequestDraft)(),null),window.setTimeout(()=>ea.current?.focus(),0)}async function tB(){try{ti(null);let e=await (0,ef.withFolders)(er,H?.collection,F),t=(0,V.resolveDraft)(e.draft,e.vars,D?.name),s=/^wss?:\/\//i.test(t.url),n=s?(0,V.withUrl)(t,t.url.replace(/^ws/i,"http")):t,a=(0,V.buildPayload)(n,(0,V.toLoadConfig)(ew),(0,V.autoRunName)(n,H?.name),(0,V.targetsFromSlo)(N));return e.contract&&!s&&(a.contract=e.contract),s&&(a.request={...a.request,url:a.request.url.replace(/^http/i,"ws")}),await (0,ex.withRunFirst)(a,t,F,D?.name)}catch(e){return ti(e instanceof Error?e.message:"Request is not valid"),null}}async function tW(){try{let e={...er,method:"POST",bodyMode:"graphql",graphqlQuery:s.INTROSPECTION_QUERY,graphqlVariables:"",graphqlOperation:"IntrospectionQuery",graphqlErrorsFail:!1,checks:[],saveValues:[],testData:null},t=await (0,ef.withFolders)(e,H?.collection,F),n=(0,V.resolveDraft)(t.draft,t.vars,D?.name),{request:a,auth:r,options:l,setup:i}=await (0,ex.withRunFirst)((0,V.buildPayload)(n,(0,V.toLoadConfig)(ew),"schema"),n,F,D?.name),o=await fetch("/engine/graphql/introspect",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({request:a,auth:r,options:l,setup:i})}),c=await o.json();return o.ok?c:{status:0,body:"",error:c.error??`Engine error (${o.status})`}}catch(e){return{status:0,body:"",error:e instanceof Error?e.message:String(e)}}}tK.current=tL,(0,$.useEffect)(()=>{let e=()=>{let e=null;try{e=sessionStorage.getItem(ev.OPEN_REQUEST_KEY),sessionStorage.removeItem(ev.OPEN_REQUEST_KEY)}catch{}e&&J.workspaceApi.get(e).then(e=>tJ.current(e)).catch(()=>i("That saved request is gone","error"));let t=null;try{t=sessionStorage.getItem(ev.OPEN_DRAFT_KEY),sessionStorage.removeItem(ev.OPEN_DRAFT_KEY)}catch{}if(t)try{let e=JSON.parse(t);tK.current((0,V.withUrl)((0,V.requestFromUnknown)(e),e.url??""),null)}catch{}};return eE&&e(),window.addEventListener(ev.OPEN_REQUEST_EVENT,e),()=>window.removeEventListener(ev.OPEN_REQUEST_EVENT,e)},[eE]);let[tQ,tX]=(0,$.useState)(0);async function tY(){if(tC||!tS)return;let e=performance.now(),s=await tB(),n=Math.round(performance.now()-e);if(!s)return;if(/^wss?:\/\//i.test(s.request.url)){if(eQ&&eY)return void await Z.realtimeApi.close(eQ);e3(!0),tp("response");try{eQ&&Z.realtimeApi.close(eQ);let{id:e}=await Z.realtimeApi.connect({request:s.request,auth:s.auth,options:s.options});eW(null),eX(e),eG(!0)}catch(e){ti(e instanceof Error?e.message:"Could not connect")}finally{e3(!1)}return}if("production"===(0,eS.envKind)(D)&&!(0,eS.isReadOnlyMethod)(s.request.method)&&!await m({title:`Send ${s.request.method} to ${D.name}?`,body:(0,t.jsxs)(t.Fragment,{children:["This request can change real data on ",(0,ei.hostOf)(s.request.url),"."]}),confirmLabel:`Send to ${D.name}`,tone:"danger"}))return;e3(!0),tr(!1),tp("response");let a=new AbortController;tt.current=a,te(Date.now()),e4([{id:"prepare",label:"Prepared: folders, connection, variables",state:"done",ms:n}]);try{eX(null);let e=await (0,ei.sendRequest)(s,H?.id,{signal:a.signal,onStep:e=>e4(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e])});e0(null),e2(!1),eW(e);let t=(e.saved??[]).flatMap(e=>e.found&&void 0!==e.value?[{name:e.name,value:e.value}]:[]);K(t,H?.name??"the last Send")}finally{e3(!1),tt.current=null}}async function tG(e=!1){if(tC||tN||!tS||!p.k6Ready)return;if(tE)return void ti(tE);let s=await tB();if(s){if(tr(!1),!e){tn(!0);try{let e=await (0,ei.sendRequest)(s);if(eW(e),!(0,ei.isSuccess)(e)){tr(!0),tp("response");return}}finally{tn(!1)}}if("production"===(0,eS.envKind)(D)){if(!await m({title:`Performance test ${D.name}?`,body:(0,t.jsxs)(t.Fragment,{children:["A performance test sends many requests at once to ",(0,ei.hostOf)(s.request.url),". Real users of that system may notice."]}),confirmLabel:"Start performance test",tone:"danger"}))return}else if((0,ei.needsLoadConfirm)(ew.preset,s.load,s.request.url)&&!await m({title:`Start a ${(0,M.profileSummary)(ew)} performance test against ${(0,ei.hostOf)(s.request.url)}?`,body:(0,t.jsxs)(t.Fragment,{children:["This is a ",(0,t.jsx)("span",{className:"text-ink",children:ew.preset})," profile against a non-local host (",(0,M.profileSummary)(ew),"). Only load-test systems you own or are allowed to test.",(0,t.jsxs)("span",{className:"mt-2 block",children:["Each simulated user sends its next request as soon as the last one returns, so a few dozen users can mean thousands of requests per second. Public sites and APIs behind a CDN or firewall usually answer that with ",(0,t.jsx)("span",{className:"text-ink",children:"429"})," or"," ",(0,t.jsx)("span",{className:"text-ink",children:"403"})," and may block this computer for a while — test a staging server, or use Requests per second mode with a modest rate."]})]}),confirmLabel:"Start performance test",tone:"danger"}))return;try{let e=await (0,ei.startLoadRun)(s);eD(e.id),tc(e),tp("report")}catch(e){i(e instanceof Error?e.message:"Failed to start load","error")}}}async function tZ(){if(!to)return;let e=await (0,ei.stopLoadRun)(to.id);e?tc(e):i("Could not reach the engine to stop the run","error")}(0,$.useEffect)(()=>{tQ&&tY()},[tQ]),(0,em.useShortcuts)({send:()=>void tY(),run:()=>void tG(),focusUrl:()=>ea.current?.focus(),save:()=>H?void tM():ee(!0),toggleSaved:()=>t$(!et)});let t0=/^wss?:\/\//i.test((0,r.substitute)(er.url,F).text),t1=t0?"Performance tests of WebSockets aren't available yet — Connect to try it":p.k6Ready?tS?tE??void 0:"Enter a URL first":p.k6Label,t2=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{type:"button","data-tour":"send",onClick:()=>void tY(),disabled:tC||!tS,title:t0?eY?"Close the connection":`Open the WebSocket (${b}+Enter)`:`Send one request (${b}+Enter)`,className:t0&&eY?"btn btn-secondary":"btn btn-primary",children:[e6?(0,t.jsx)(f.Loader2,{size:16,className:"animate-spin"}):t0?eY?(0,t.jsx)(q.Unplug,{size:16}):(0,t.jsx)(k.Plug,{size:16}):(0,t.jsx)(S.Send,{size:16}),t0?eY?"Disconnect":"Connect":"Send"]}),tN?(0,t.jsxs)("button",{type:"button",onClick:()=>void tZ(),disabled:to?.stopping,className:"btn btn-danger",children:[to?.stopping?(0,t.jsx)(f.Loader2,{size:16,className:"animate-spin"}):(0,t.jsx)(E.Square,{size:16}),to?.stopping?"Stopping…":"Stop"]}):(0,t.jsxs)("button",{type:"button","data-tour":"run",onClick:()=>void tG(),disabled:tC||!!t1,title:t1??`Check the request, then run the load profile (${b}+Shift+Enter)`,className:"btn btn-secondary",children:[ts?(0,t.jsx)(f.Loader2,{size:16,className:"animate-spin"}):(0,t.jsx)(v.Play,{size:16}),ts?"Checking…":"Run performance test"]}),(0,t.jsx)(eH,{dirty:H?tq:JSON.stringify(er)!==eP,isSaved:!!H,onHistory:H?()=>(0,eC.openVersions)(H.id):void 0,onExport:H?()=>(0,eq.openExport)({kind:"request",id:H.id,name:H.name,collection:H.collection}):void 0,title:`Save request (${b}+S)`,onSave:()=>H?void tM():ee(!0),onSaveAs:()=>ee(!0)})]}),t5=tv.map(e=>e.key===tw?tO():e);return(0,t.jsx)(eb.VariableScope,{collection:H?.collection,url:er.url,children:(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[t5.length?(0,t.jsxs)("div",{className:"flex shrink-0 items-stretch border-b border-line bg-canvas",children:[(0,t.jsx)("button",{type:"button",onClick:()=>t$(!et),"aria-label":et?`Hide saved requests (${b}+B)`:`Show saved requests (${b}+B)`,"aria-pressed":et,title:et?`Hide saved requests (${b}+B)`:`Show saved requests (${b}+B)`,className:`hidden shrink-0 items-center border-r border-line px-3 hover:bg-panel/60 hover:text-ink lg:flex ${et?"text-ink":"text-mute"}`,children:(0,t.jsx)(h.FolderOpen,{size:15,"aria-hidden":!0})}),(0,t.jsx)("div",{role:"tablist","aria-label":"Open requests",className:"flex min-w-0 items-stretch overflow-x-auto",children:t5.map(e=>{let s=e.key===tw,n=eA(e);return(0,t.jsxs)("div",{onContextMenu:t=>{t.preventDefault();let s=Number(document.documentElement.style.zoom)||1;tU({key:e.key,x:t.clientX/s,y:t.clientY/s})},onMouseDown:t=>{1===t.button&&(t.preventDefault(),tA([e.key]))},className:`flex max-w-60 min-w-0 shrink-0 items-center border-r border-line ${s?"bg-panel shadow-[inset_0_2px_0_var(--accent)]":"hover:bg-panel/60"}`,children:[(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>tP(e.key),onKeyDown:t=>{if("ContextMenu"===t.key||t.shiftKey&&"F10"===t.key){t.preventDefault();let s=(0,ep.pageRect)(t.currentTarget);tU({key:e.key,x:s.left+8,y:s.bottom})}},title:e.saved?.collection?`${e.saved.collection} / ${n}`:n,className:"tab-btn flex min-w-0 items-center gap-2 py-2 pr-1 pl-3 text-sm",children:[(0,t.jsx)("span",{className:`font-mono text-[11px] font-semibold ${eU[e.draft.method]??"text-mute"}`,children:"DELETE"===e.draft.method?"DEL":e.draft.method}),(0,t.jsx)("span",{className:`truncate ${s?"text-ink":"text-mute"}`,children:n})]}),e.saved&&eI(e)?(0,t.jsx)("span",{title:"Not saved","aria-label":"not saved",className:"h-1.5 w-1.5 shrink-0 rounded-full bg-accent"}):null,(0,t.jsx)("button",{type:"button",onClick:()=>{tA([e.key])},"aria-label":`Close ${n}`,title:"Close (middle click)",className:"mx-1 shrink-0 rounded p-1 text-mute hover:bg-panel-2 hover:text-ink",children:(0,t.jsx)(R.X,{size:13,"aria-hidden":!0})})]},e.key)})}),tI?(()=>{let e=t5.map(e=>e.key),s=e.indexOf(tI.key),n=t5[s];if(!n)return null;let a=e=>()=>{tU(null),e()},r=t5.filter(e=>!eI(e)).map(e=>e.key);return(0,t.jsxs)(Y.ContextMenu,{at:tI,label:`Actions for ${eA(n)}`,onClose:()=>tU(null),children:[(0,t.jsx)(Y.MenuItem,{icon:R.X,label:"Close",hint:"Middle click",onSelect:a(()=>void tA([tI.key]))}),(0,t.jsx)(Y.MenuItem,{icon:C,label:"Close others",disabled:e.length<2,onSelect:a(()=>void tA(e.filter(e=>e!==tI.key)))}),(0,t.jsx)(Y.MenuItem,{icon:l.ArrowRightToLine,label:"Close to the right",disabled:s===e.length-1,onSelect:a(()=>void tA(e.slice(s+1)))}),(0,t.jsx)(Y.MenuItem,{icon:o.CircleCheck,label:"Close unchanged",disabled:!r.length,onSelect:a(()=>void tA(r))}),(0,t.jsx)(Y.MenuItem,{icon:x.ListX,label:"Close all",onSelect:a(()=>void tA(e))}),(0,t.jsx)(Y.MenuSeparator,{}),(0,t.jsx)(Y.MenuItem,{icon:u.CopyPlus,label:"Duplicate",onSelect:a(()=>(function(e){let t=e===tw?tO():tv.find(t=>t.key===e);if(!t)return;let s={key:eT(),draft:structuredClone(t.draft),saved:null,result:null,liveId:null,liveOpen:!1};tk(t=>{let n=t.map(e=>e.key===tw?tO():e),a=n.findIndex(t=>t.key===e);return[...n.slice(0,a+1),s,...n.slice(a+1)]}),tT(s)})(tI.key))}),(0,t.jsx)(Y.MenuItem,{icon:d.Copy,label:"Copy URL",disabled:!n.draft.url.trim(),onSelect:a(()=>void navigator.clipboard.writeText(n.draft.url).then(()=>i("Copied the URL","success"),()=>i("Could not copy","error")))})]})})():null,(0,t.jsx)("button",{type:"button",onClick:()=>tH(),"aria-label":"New request tab",title:"New request",className:"shrink-0 px-3 text-mute hover:bg-panel/60 hover:text-ink",children:(0,t.jsx)(w.Plus,{size:15,"aria-hidden":!0})}),(0,t.jsx)("div",{className:"ml-auto flex shrink-0 items-center px-2",children:(0,t.jsx)(U.EnvironmentBar,{compact:!0,drafts:[er],collections:[H?.collection]})})]}):null,(0,t.jsxs)("header",{className:"border-b border-line bg-panel px-4 py-3 lg:px-6",children:[(0,t.jsx)("h1",{className:"sr-only",children:"Test an API"}),(0,t.jsx)(O.RequestBar,{ref:ea,draft:er,onChange:e=>{ek(e),ti(null)},onImported:e=>i(e,"success"),actions:t2}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-mute empty:hidden",children:[(0,t.jsx)(B,{draft:er,sent:!!(eB&&eB.status>0),onChange:ek}),X?(0,t.jsx)(Q.SaveRequestForm,{initial:{name:H?.name??(0,V.autoRunName)(er).replace(/ · \d.*$/,""),collection:H?.collection??""},onSave:(e,t)=>void tM({name:e,collection:t}),onCancel:()=>ee(!1)}):null,tl?(0,t.jsx)("span",{className:"text-bad",role:"alert",children:tl}):null]})]}),(0,t.jsxs)("div",{className:`grid min-h-0 flex-1 overflow-y-auto transition-[grid-template-columns] duration-200 ease-out motion-reduce:transition-none lg:overflow-hidden ${tx?"":tg?`lg:grid-rows-[minmax(0,1fr)_minmax(0,1fr)] ${et?"lg:grid-cols-[15rem_minmax(0,1fr)] 2xl:grid-cols-[16rem_minmax(0,1fr)]":"lg:grid-cols-[0rem_minmax(0,1fr)]"}`:et?"lg:grid-cols-[15rem_minmax(0,1fr)_minmax(0,1fr)] 2xl:grid-cols-[16rem_minmax(0,5fr)_minmax(0,7fr)]":"lg:grid-cols-[0rem_minmax(0,1fr)_minmax(0,1fr)] 2xl:grid-cols-[0rem_minmax(0,5fr)_minmax(0,7fr)]"}`,children:[tx?null:(0,t.jsx)("div",{inert:!et,"aria-hidden":!et||void 0,className:`min-h-0 min-w-0 overflow-hidden transition-opacity duration-200 motion-reduce:transition-none ${tg?"lg:row-span-2":""} ${et?"opacity-100":"opacity-0 max-lg:hidden"}`,children:(0,t.jsx)("div",{className:"flex h-full w-[15rem] flex-col 2xl:w-[16rem] [&>aside]:flex-1",children:(0,t.jsx)(Q.RequestsPanel,{activeId:H?.id??null,onOpen:e=>void t_(e),onNew:()=>void tH()})})}),tx?null:(0,t.jsx)("section",{ref:e5,"aria-label":"Request",className:"min-w-0 px-4 py-4 lg:overflow-y-auto lg:px-6",children:(0,t.jsx)(T.RequestEditor,{id:"lab-request",draft:er,onChange:ek,checkResults:eB?.checks,lastBody:eB?.body,lastResult:eB??void 0,setupResult:eB?.setup,savedResults:eB?.saved,currentId:H?.id,collection:H?.collection,introspect:tW,extraTabs:[{id:"load",label:"Performance",badge:ew.stages?.length?"stages":"rate"===ew.mode?`${ew.rps}/s`:`${ew.vus} users \xb7 ${ew.duration}`,content:(0,t.jsx)(M.LoadEditor,{load:ew,onChange:ej})},{id:"targets",label:"Goals",content:(0,t.jsx)(eK,{})}]})}),(0,t.jsxs)("section",{ref:e9,"aria-label":"Results",className:`@container flex min-h-[32rem] min-w-0 flex-col border-line bg-panel/40 px-4 py-4 lg:min-h-0 lg:overflow-y-auto lg:px-6 ${tg&&!tx?"lg:border-t":"lg:border-l"}`,children:[(0,t.jsx)(I.Tabs,{id:"lab-results",label:"Results",value:th,onChange:tp,items:[{id:"response",label:"Response",badge:eB?eB.status||"ERR":void 0},{id:"report",label:tN?(0,t.jsx)(ez,{}):"Performance report"}],trailing:(0,t.jsxs)(t.Fragment,{children:["report"===th&&tm.length>0?(0,t.jsx)(eV,{runs:tm,current:to,disabled:tN,onPick:async e=>{try{let t=await ed.historyApi.run(e.id);eD(e.id),tc({id:t.report.id,status:t.report.status,report:t.report})}catch(e){i(e instanceof Error?e.message:"Could not open that run","error")}}}):null,tx?null:(0,t.jsx)("button",{type:"button",onClick:()=>ty(tg?"beside":"below"),"aria-label":tg?"Show the response beside the request":"Show the response below the request",title:tg?"Response beside the request":"Response below the request",className:"hidden rounded p-1.5 text-mute hover:bg-panel-2 hover:text-ink lg:block",children:tg?(0,t.jsx)(c.Columns2,{size:14}):(0,t.jsx)(j,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:()=>tf(e=>!e),"aria-label":tx?"Show the request editor":"Expand results to full width",title:tx?"Show the request editor":"Expand results",className:"hidden rounded p-1.5 text-mute hover:bg-panel-2 hover:text-ink lg:block",children:tx?(0,t.jsx)(g,{size:14}):(0,t.jsx)(y,{size:14})})]})}),(0,t.jsx)("div",{...(0,I.tabPanelProps)("lab-results",th),className:"flex min-h-0 flex-1 flex-col pt-4",children:"response"===th?(0,t.jsxs)(t.Fragment,{children:[ta&&eB?(0,t.jsxs)("div",{role:"alert",className:"mb-4 flex flex-wrap items-center gap-3 rounded-md border border-warn/40 bg-warn/10 px-3 py-2.5",children:[(0,t.jsxs)("p",{className:"min-w-0 flex-1 text-sm text-ink",children:[(0,t.jsx)("span",{className:"font-medium text-warn",children:"Performance test not started."})," The check returned"," ",eB.status||"an error",", not 2xx. Fix the request, or run anyway if this status is expected."]}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-xs",onClick:()=>void tG(!0),children:"Run anyway"})]}):null,e6&&e7.length?(0,t.jsx)(eN,{steps:e7,startedAt:e8,onCancel:()=>tt.current?.abort()}):eQ&&!eB?(0,t.jsx)(Z.LiveView,{id:eQ,onClosed:()=>eG(!1)}):eB&&eZ?(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 rounded-md border border-accent/40 bg-accent/10 px-3 py-2 text-xs",children:[(0,t.jsxs)("span",{className:"text-ink",children:[e1?"What changed since":"An earlier answer —"," ",new Date(eZ.answer.at).toLocaleString()]}),(0,t.jsxs)("span",{className:"ml-auto flex gap-2",children:[(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>e2(e=>!e),children:e1?"Show that answer":"Compare with the latest"}),(0,t.jsx)("button",{type:"button",className:"text-accent hover:underline",onClick:()=>e0(null),children:"Back to the latest"})]})]}),e1?(0,t.jsx)(el,{earlier:eZ.answer,latest:eB}):(0,t.jsx)(L.ResponseViewer,{result:{ok:(e=eZ.answer).status>=200&&e.status<400,status:e.status,statusText:String(e.status),headers:e.headers,body:e.body,truncated:e.truncated,durationMs:e.durationMs,url:e.url,...e.error?{error:e.error}:{},...e.checks?{checks:e.checks}:{}}})]}):eB?(0,t.jsx)(L.ResponseViewer,{result:eB,onWaitLonger:e=>{ek(t=>({...t,timeout:e})),tX(e=>e+1),i(`This request now waits up to ${e} — save it to keep that`,"success")},extra:H?.id?(0,t.jsx)(en,{requestId:H.id,refreshKey:eB,onOpen:(e,t)=>0===t?e0(null):(e0({answer:e,index:t}),e2(!1))}):null,onSaveExample:()=>{ek(e=>({...e,mock:(0,a.exampleFromResponse)(eB.status,eB.headers,eB.body)})),i(H?"Kept as the mock example — save the request to keep it":"Kept as the mock example — save the request to use it in the mock server","success")}}):tF?(0,t.jsx)(eg.WelcomeCard,{practiceReady:!!p.demoApi,onSimple:()=>void(tL({...(0,V.withUrl)((0,V.defaultRequestDraft)(),"{{practiceApi}}/products"),checks:[{type:"status",expect:"2xx"},{type:"json",path:"items[0].name",op:"exists",value:""}]},null),i("Practice request ready — press Send","success")),onSignIn:()=>void tz(),onHide:()=>(0,eg.setWelcomeHidden)(!0)}):(0,t.jsx)(e_,{title:"Send a request to see the response",lines:[(0,t.jsx)(t.Fragment,{children:"Paste a URL — or a whole curl command from your browser's DevTools — into the bar above."}),(0,t.jsxs)(t.Fragment,{children:["Press ",(0,t.jsx)("span",{className:"kbd",children:b}),"+",(0,t.jsx)("span",{className:"kbd",children:"Enter"})," to send it."]})]})]}):to?(0,t.jsxs)(t.Fragment,{children:[to.error?(0,t.jsx)("p",{role:"alert",className:"mb-3 rounded-md border border-bad/40 bg-bad/10 px-3 py-2 text-sm text-bad",children:to.error}):null,(0,t.jsx)(P.ReportView,{report:to.report,source:"session",live:tN,probe:eB})]}):(0,t.jsx)(e_,{title:"No performance test yet",lines:[(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:"Run performance test"})," sends one check request first, then runs"," ",(0,t.jsx)("span",{className:"font-mono text-ink",children:(0,M.profileSummary)(ew)})," with k6."]}),(0,t.jsx)(t.Fragment,{children:"Change users, duration, and ramps in the Performance tab. Set pass/fail goals in Goals."})],action:(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:tC||!!t1,title:t1,onClick:()=>void tG(),children:[(0,t.jsx)(v.Play,{size:16}),"Run performance test"]})})})]})]})]})})},"VerdictTag",0,eJ],6980)},90139,1245,33577,85905,e=>{"use strict";var t=e.i(99522);let s=(0,t.default)("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]);e.s(["ArrowRightToLine",0,s],90139);var n=e.i(95754);e.s(["CircleCheck",()=>n.default],1245);let a=(0,t.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);e.s(["Columns2",0,a],33577);let r=(0,t.default)("copy-plus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);e.s(["CopyPlus",0,r],85905)},30197,e=>{"use strict";let t=(0,e.i(99522).default)("list-x",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);e.s(["ListX",0,t],30197)}]);
|