apitestcenter 0.18.3 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE.txt +1 -1
  2. package/README.md +1 -1
  3. package/dist/THIRD-PARTY-NOTICES-UI.txt +40 -10
  4. package/dist/THIRD-PARTY-NOTICES.txt +3 -3
  5. package/dist/cli.mjs +796 -548
  6. package/dist/ui/404/index.html +1 -1
  7. package/dist/ui/404.html +1 -1
  8. package/dist/ui/__next.__PAGE__.txt +17 -17
  9. package/dist/ui/__next._full.txt +18 -18
  10. package/dist/ui/__next._tree.txt +2 -2
  11. package/dist/ui/_next/static/chunks/06kdixojb32u6.js +27 -0
  12. package/dist/ui/_next/static/chunks/0a2q6cpe_c4k-.js +3 -0
  13. package/dist/ui/_next/static/chunks/0faedhifzwobh.js +31 -0
  14. package/dist/ui/_next/static/chunks/{0q8iq_7i4ohjr.js → 0glo5t3rr5ux5.js} +2 -2
  15. package/dist/ui/_next/static/chunks/0jq6xbzrkaewp.js +2 -0
  16. package/dist/ui/_next/static/chunks/1-9ymrwk2b425.js +1 -0
  17. package/dist/ui/_next/static/chunks/13ez75q2t6tkt.js +51 -0
  18. package/dist/ui/_next/static/chunks/1r8qtltx9mmfv.js +2 -0
  19. package/dist/ui/_next/static/chunks/{12whdxhkvkd-y.js → 1s068j2ev364j.js} +1 -1
  20. package/dist/ui/_next/static/chunks/1v2mgl5t1qg1g.js +50 -0
  21. package/dist/ui/_next/static/chunks/1y7u7u9moxxxk.js +1 -0
  22. package/dist/ui/_next/static/chunks/{3wtqdtu331_vc.js → 2-ccpn24ve6pz.js} +3 -3
  23. package/dist/ui/_next/static/chunks/2db3njpc0xw6w.js +1 -0
  24. package/dist/ui/_next/static/chunks/2gs5hczs3bpq_.css +3 -0
  25. package/dist/ui/_next/static/chunks/2pqt6mieje__r.js +123 -0
  26. package/dist/ui/_next/static/chunks/33purk5k-9o6l.js +1 -0
  27. package/dist/ui/_next/static/chunks/3ooomvul846zs.js +3 -0
  28. package/dist/ui/_next/static/chunks/3ps_0myey2cxz.js +22 -0
  29. package/dist/ui/_next/static/chunks/3rptf3gr286c3.js +1056 -0
  30. package/dist/ui/_next/static/chunks/3yvd9c8pue6u7.js +50 -0
  31. package/dist/ui/_next/static/chunks/45bkmnyf6ozrx.js +50 -0
  32. package/dist/ui/_not-found/__next._full.txt +13 -13
  33. package/dist/ui/_not-found/__next._not-found.__PAGE__.txt +12 -12
  34. package/dist/ui/_not-found/__next._tree.txt +2 -2
  35. package/dist/ui/_not-found/index.html +1 -1
  36. package/dist/ui/_not-found/index.txt +13 -13
  37. package/dist/ui/compare/__next._full.txt +18 -18
  38. package/dist/ui/compare/__next._tree.txt +2 -2
  39. package/dist/ui/compare/__next.compare.__PAGE__.txt +17 -17
  40. package/dist/ui/compare/index.html +1 -1
  41. package/dist/ui/compare/index.txt +18 -18
  42. package/dist/ui/connections/__next._full.txt +16 -16
  43. package/dist/ui/connections/__next._tree.txt +2 -2
  44. package/dist/ui/connections/__next.connections.__PAGE__.txt +15 -15
  45. package/dist/ui/connections/index.html +2 -2
  46. package/dist/ui/connections/index.txt +16 -16
  47. package/dist/ui/history/__next._full.txt +29 -28
  48. package/dist/ui/history/__next._tree.txt +2 -2
  49. package/dist/ui/history/__next.history.__PAGE__.txt +30 -29
  50. package/dist/ui/history/index.html +1 -1
  51. package/dist/ui/history/index.txt +29 -28
  52. package/dist/ui/home/__next._full.txt +18 -18
  53. package/dist/ui/home/__next._tree.txt +2 -2
  54. package/dist/ui/home/__next.home.__PAGE__.txt +17 -17
  55. package/dist/ui/home/index.html +1 -1
  56. package/dist/ui/home/index.txt +18 -18
  57. package/dist/ui/index.html +1 -1
  58. package/dist/ui/index.txt +18 -18
  59. package/dist/ui/preview/__next._full.txt +17 -17
  60. package/dist/ui/preview/__next._tree.txt +2 -2
  61. package/dist/ui/preview/__next.preview.__PAGE__.txt +16 -16
  62. package/dist/ui/preview/index.html +1 -1
  63. package/dist/ui/preview/index.txt +17 -17
  64. package/dist/ui/suite/__next._full.txt +15 -15
  65. package/dist/ui/suite/__next._tree.txt +2 -2
  66. package/dist/ui/suite/__next.suite.__PAGE__.txt +14 -14
  67. package/dist/ui/suite/index.html +1 -1
  68. package/dist/ui/suite/index.txt +15 -15
  69. package/dist/ui/tests/__next._full.txt +13 -13
  70. package/dist/ui/tests/__next._tree.txt +2 -2
  71. package/dist/ui/tests/__next.tests.__PAGE__.txt +12 -12
  72. package/dist/ui/tests/index.html +1 -1
  73. package/dist/ui/tests/index.txt +13 -13
  74. package/package.json +2 -2
  75. package/dist/ui/_next/static/chunks/0-zga2d528cxt.js +0 -50
  76. package/dist/ui/_next/static/chunks/03ligbvtk7nsc.js +0 -123
  77. package/dist/ui/_next/static/chunks/03y58w9gmwqc-.js +0 -50
  78. package/dist/ui/_next/static/chunks/08rlo-0gnct9m.js +0 -50
  79. package/dist/ui/_next/static/chunks/0bgmfb8f3pd8e.js +0 -1
  80. package/dist/ui/_next/static/chunks/0g9k0swrer6i5.js +0 -1
  81. package/dist/ui/_next/static/chunks/1-t79a3q7gmjn.js +0 -31
  82. package/dist/ui/_next/static/chunks/14dtemzsvcfmn.js +0 -50
  83. package/dist/ui/_next/static/chunks/1snbdq1z951ks.js +0 -906
  84. package/dist/ui/_next/static/chunks/20j4wusnbtqa2.js +0 -4
  85. package/dist/ui/_next/static/chunks/243c1-49gb3pr.js +0 -1
  86. package/dist/ui/_next/static/chunks/2sjog4to0fmbb.css +0 -3
  87. package/dist/ui/_next/static/chunks/2sr5dm3__ghgo.js +0 -27
  88. package/dist/ui/_next/static/chunks/2su0ql-zu4q0_.js +0 -3
  89. package/dist/ui/_next/static/chunks/3-rdixjnndtyk.js +0 -51
  90. package/dist/ui/_next/static/chunks/32_tmz8ibsdo3.js +0 -22
  91. package/dist/ui/_next/static/chunks/3eti_s9gpiis0.js +0 -2
  92. package/dist/ui/_next/static/chunks/3wzu1zkfqdmn6.js +0 -2
  93. /package/dist/ui/_next/static/{lomhkNrlljr9WxdUu6_Mc → XNta4K_1tCu7sU6jlccSS}/_buildManifest.js +0 -0
  94. /package/dist/ui/_next/static/{lomhkNrlljr9WxdUu6_Mc → XNta4K_1tCu7sU6jlccSS}/_clientMiddlewareManifest.js +0 -0
  95. /package/dist/ui/_next/static/{lomhkNrlljr9WxdUu6_Mc → XNta4K_1tCu7sU6jlccSS}/_ssgManifest.js +0 -0
@@ -0,0 +1,51 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,49186,e=>{"use strict";var t=e.i(51487),s=e.i(32610),a=e.i(62766);e.i(24856);var n=e.i(56003);let r={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};r.node;let l=(0,n.f)(r);var i=e.i(30932),o=e.i(97424),d=e.i(80714),c=e.i(92368),p=e.i(2810),m=e.i(37841);let u={name:"send-horizontal",size:24,node:[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],aliases:["send-horizonal"]};u.node;let x=(0,n.f)(u);var h=e.i(47298),f=e.i(62620),b=e.i(2552),g=e.i(53798),y=e.i(77306),v=e.i(60617),w=e.i(88491),j=e.i(87953),k=e.i(92747),N=e.i(36558),I=e.i(17219);function $(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("\n","&#10;")}let C=`<?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>`;function S(){let e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-");return`compare-${e}.xlsx`}async function A(e,t,s){let a=e.map(e=>e.report),n=e.map(e=>e.title),r=a.length>=2?(0,v.l)(a):[],l=(0,v.g)(a),i=(0,w.y)(e,s),o=[[{v:"Metric",s:1},...n.map(e=>({v:e,s:1})),{v:"Best",s:1}],...r.map(e=>[{v:e.label},...e.values.map((t,s)=>{var a;return{v:"ms"===(a=e.unit)?`${Math.round(t)} ms`:"rps"===a?`${t.toFixed(1)} rps`:"pct"===a?`${(100*t).toFixed(2)}%`:String(Math.round(t)),s:3*(e.winner===s)}}),{v:(0,w.z)(e,n)}]),[{v:"Run mode"},{v:t},...n.slice(1).map(()=>({v:""})),{v:""}]],d=[{v:"Seconds into test",s:1}];n.forEach(e=>{d.push({v:`${e} — 95th pct (ms)`,s:1}),d.push({v:`${e} — req/s`,s:1}),d.push({v:`${e} — error rate`,s:1}),d.push({v:`${e} — VUs`,s:1})});let c=[{name:"Side by side",rows:o},{name:"Over time",rows:[d,...l.map(e=>{let t=[{v:e.elapsedS}];return e.p95.forEach((s,a)=>{t.push({v:s??""}),t.push({v:e.rps[a]??""}),t.push({v:e.failedRate[a]??""}),t.push({v:e.vus[a]??""})}),t})]},{name:"Result summary",rows:[[{v:"API",s:1},{v:"Result",s:1},{v:"What this means",s:1}],...i.map(e=>{var t;return[{v:e.title},{v:e.overall,s:"pass"===(t=e.overall)?3:"warn"===t?4:5*("fail"===t)},{v:e.headline,s:2}]})]},...e.map((e,t)=>{var s;return{name:(s=e.title,(s.replace(/[\\/?*[\]:]/g,"").slice(0,24)||`API ${t+1}`).slice(0,31)),rows:[[{v:"Key",s:1},{v:"Value",s:1},{v:"What this means",s:1}],...(0,N.E)(e.report).map(e=>[{v:e.key},{v:e.value},{v:e.description,s:2}])]}})].map((e,t)=>{var s;let a,n,r;return{id:t+1,relId:`rId${t+1}`,name:e.name,xml:(s=e.rows,n=Array.from({length:a=s[0]?.length??0},(e,t)=>{let n=function(e,t,s=10,a=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(a,n)}(s,t,0===t?14:12,t===a-1&&a>=3?72:42);return`<col min="${t+1}" max="${t+1}" width="${n}" customWidth="1"/>`}).join(""),r=s.map((e,t)=>`<row r="${t+1}" ht="${0===t?22:18}" customHeight="1">${e.map((e,s)=>{var a;let n,r;return a=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)}${a}`,r=void 0!==e.s?` s="${e.s}"`:"","number"==typeof e.v&&Number.isFinite(e.v)?`<c r="${n}"${r}><v>${e.v}</v></c>`:`<c r="${n}"${r} t="inlineStr"><is><t xml:space="preserve">${$(e.v)}</t></is></c>`}).join("")}</row>`).join(""),`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
27
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
28
+ <sheetViews><sheetView workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>
29
+ <cols>${n}</cols>
30
+ <sheetData>${r}</sheetData>
31
+ </worksheet>`)}}),p=c.map(e=>`<Override PartName="/xl/worksheets/sheet${e.id}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("\n "),m=c.map(e=>`<sheet name="${$(e.name)}" sheetId="${e.id}" r:id="${e.relId}"/>`).join("\n "),u=c.map(e=>`<Relationship Id="${e.relId}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${e.id}.xml"/>`).join("\n "),x={"[Content_Types].xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
33
+ <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
34
+ <Default Extension="xml" ContentType="application/xml"/>
35
+ <Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>
36
+ <Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>
37
+ ${p}
38
+ </Types>`,"_rels/.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
39
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
40
+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>
41
+ </Relationships>`,"xl/workbook.xml":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
42
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
43
+ <sheets>
44
+ ${m}
45
+ </sheets>
46
+ </workbook>`,"xl/_rels/workbook.xml.rels":`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
47
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
48
+ ${u}
49
+ <Relationship Id="rId${c.length+1}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
50
+ </Relationships>`,"xl/styles.xml":C};for(let e of c)x[`xl/worksheets/sheet${e.id}.xml`]=e.xml;return new Blob([(0,I.f)(x)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}async function P(e,t,s){let a=S().replace(/\.xlsx$/,""),n={[`${a}.xlsx`]:new Uint8Array(await (await A(e,t,s)).arrayBuffer()),[`${a}.json`]:(0,w.E)(e,t)};for(let t of e){if(!t.probe)continue;let e=t.title.replace(/[^\w.-]+/g,"-").slice(0,40)||t.id.slice(0,8);n[`${e}-probe.json`]=(0,w.m)(t.probe)}return{base:a,blob:(0,I.f)(n)}}var F=e.i(15060),E=e.i(88153);function R({apis:e,mode:s,probes:a}){var n,r,l;let o,d,c,p,m,{slo:u}=(0,E.G)(),x=S(),h=x.replace(/\.xlsx$/,""),f=Object.entries(a).filter(e=>!!e[1]),[b,g]=(0,y.useState)(!1),[N,$]=(0,y.useState)(null),[C,z]=(0,y.useState)(null);if(0===e.length)return null;let O=(n=e,r=s,l=u,o=n.map(e=>e.title),d=`Compare: ${o.join(" vs ")}`.slice(0,120),c=n.length>=2?(0,v.l)(n.map(e=>e.report)):[],p=[`APITestCenter compare (${r})`,"",...n.map(e=>`- ${e.title}: ${e.report.testName} [${e.report.status}]`),"",...c.map(e=>{let t=e.values.map((t,s)=>{var a,n;return`${o[s]}=${a=t,"ms"===(n=e.unit)?`${Math.round(a)}ms`:"rps"===n?`${a.toFixed(1)}/s`:"pct"===n?`${(100*a).toFixed(2)}%`:String(Math.round(a))}`}).join(", "),s=null==e.winner?"tie":o[e.winner]??"tie";return`${e.label}: ${t} (best: ${s})`})],l&&p.push("",`Performance targets: p95 ${l.p95Ms} ms, errors ${(100*l.errorRate).toFixed(1)}%`),p.push("","Attach the Excel or Zip export from APITestCenter."),{subject:d,body:m=p.join("\n"),mailto:`mailto:?subject=${encodeURIComponent(d)}&body=${encodeURIComponent(m)}`,gmail:`https://mail.google.com/mail/?view=cm&fs=1&tf=1&su=${encodeURIComponent(d)}&body=${encodeURIComponent(m)}`,outlook:`https://outlook.office.com/mail/deeplink/compose?subject=${encodeURIComponent(d)}&body=${encodeURIComponent(m)}`});async function D(){z(null),g(!1);try{let{base:t,blob:a}=await P(e,s,u),n={files:[new File([a],`${t}-export.zip`,{type:"application/zip"})],title:O.subject,text:O.body};if(navigator.canShare?.({files:n.files}))return void await navigator.share(n);$("mailto")}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;$("mailto"),z(e instanceof Error?e.message:"Share failed")}}return(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"mr-1 flex items-center gap-1.5 text-xs text-mute",children:[(0,t.jsx)(j.f,{size:14}),"Export"]}),(0,t.jsx)("button",{type:"button",disabled:e.length<2,className:"rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink hover:border-accent hover:text-accent disabled:opacity-40",onClick:()=>void A(e,s,u).then(e=>(0,F.h)(x,e)),children:"Excel"}),(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink hover:border-accent hover:text-accent",onClick:()=>(0,F.N)(`${h}.json`,(0,w.E)(e,s),"application/json"),children:"JSON"}),(0,t.jsx)("button",{type:"button",disabled:0===f.length,className:"rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink hover:border-accent hover:text-accent disabled:opacity-40",onClick:()=>{let t={};for(let[s,a]of f){let n=e.find(e=>e.id===s),r=(n?.title??s).replace(/[^\w.-]+/g,"-").slice(0,40);t[`${r}-probe.json`]=(0,w.m)(a)}(0,F.h)(`${h}-probes.zip`,(0,I.f)(t))},children:"Response JSONs"}),(0,t.jsxs)("button",{type:"button",className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink hover:border-accent hover:text-accent",onClick:()=>void P(e,s,u).then(({base:e,blob:t})=>(0,F.h)(`${e}-export.zip`,t)),children:[(0,t.jsx)(j.f,{size:12}),"Zip"]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>g(e=>!e),className:"inline-flex items-center gap-1 rounded-md border border-line bg-panel-2 px-2.5 py-1 text-xs text-ink hover:border-accent hover:text-accent",children:[(0,t.jsx)(k.f,{size:12}),"Share",(0,t.jsx)(i.f,{size:12})]}),b?(0,t.jsxs)("div",{className:"absolute right-0 z-20 mt-1 w-56 rounded-md border border-line bg-panel p-1 shadow-lg",children:[(0,t.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-ink hover:bg-panel-2",onClick:()=>{g(!1),$("gmail")},children:"Gmail"}),(0,t.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-ink hover:bg-panel-2",onClick:()=>{g(!1),$("outlook")},children:"Outlook on the web"}),(0,t.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-ink hover:bg-panel-2",onClick:()=>{g(!1),$("mailto")},children:"Default mail app"}),(0,t.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs text-ink hover:bg-panel-2",onClick:()=>void D(),children:"System share"})]}):null]})]}),C?(0,t.jsx)("p",{className:"max-w-md text-xs text-mute",children:C}):null,N?(0,t.jsx)(T,{apis:e,mode:s,target:N,links:O,onClose:()=>$(null)}):null]})}function T({apis:e,mode:s,target:a,links:n,onClose:r}){let{slo:l}=(0,E.G)(),i={gmail:"Gmail",outlook:"Outlook on the web",mailto:"default mail app"},o="gmail"===a?n.gmail:"outlook"===a?n.outlook:n.mailto;return(0,t.jsx)("div",{className:"fixed inset-0 z-50 grid place-items-center bg-canvas/70 p-4",role:"presentation",onClick:r,children:(0,t.jsxs)("div",{role:"dialog","aria-modal":"true",className:"w-full max-w-md rounded-lg border border-line bg-panel p-4 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("h2",{className:"text-sm font-medium text-ink",children:["Share via ",i[a]]}),(0,t.jsx)("p",{className:"mt-2 text-xs leading-5 text-mute",children:"Download the compare package, then attach it in the compose window. Browsers cannot attach files for you."}),(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-panel-2 px-2.5 py-1.5 text-xs text-ink",onClick:()=>void A(e,s,l).then(e=>(0,F.h)(S(),e)),children:"Download Excel"}),(0,t.jsx)("button",{type:"button",className:"rounded-md border border-line bg-panel-2 px-2.5 py-1.5 text-xs text-ink",onClick:()=>void P(e,s,l).then(({base:e,blob:t})=>(0,F.h)(`${e}-export.zip`,t)),children:"Download Zip"}),(0,t.jsxs)("a",{href:o,target:"_blank",rel:"noreferrer",className:"rounded-md bg-accent px-2.5 py-1.5 text-xs font-medium text-canvas",onClick:r,children:["Open ",i[a]]}),(0,t.jsx)("button",{type:"button",className:"rounded-md px-2.5 py-1.5 text-xs text-mute",onClick:r,children:"Close"})]})]})})}var z=e.i(55658),O=e.i(23986),D=e.i(45404),M=e.i(29724),U=e.i(88231);function q({items:e,liveTabs:s,running:a,source:n,mode:r,slo:l,title:i,actions:d,status:c,exportBar:p}){let[m,u]=(0,y.useState)("all"),x=(0,y.useRef)(null),h=e.map((e,t)=>(0,v.u)(t,e.title)),f=a||!e.some(e=>e.tabId===m)?"all":m,b=e.filter(e=>!s.has(e.tabId)),g=!a&&b.length>=2?(0,z.d)(b.map(e=>e.report),b.map(t=>h[e.indexOf(t)])):null;return(0,t.jsxs)("div",{ref:x,className:"min-h-0 flex-1 overflow-y-auto",children:[(0,t.jsxs)("header",{className:"sticky top-0 z-10 border-b border-line bg-canvas/95 px-4 pt-3 backdrop-blur lg:px-6",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)("h2",{className:"text-base font-medium text-ink",children:i}),(0,t.jsx)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:d})]}),(0,t.jsx)("div",{role:"tablist","aria-label":"Comparison or one run",className:"-mb-px mt-3 flex gap-1 overflow-x-auto",children:[{id:"all",label:"Comparison",color:null},...e.map((e,t)=>({id:e.tabId,label:h[t],color:(0,U.f)(t)}))].map(e=>{let n=f===e.id,r=s.has(e.id);return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":n,disabled:a&&"all"!==e.id,title:a&&"all"!==e.id?"Each run's own report opens when the compare has finished":e.label,onClick:()=>{u(e.id),x.current?.scrollTo({top:0})},className:`flex max-w-[18rem] shrink-0 items-center gap-2 rounded-t-md border border-b-0 px-3 py-2 text-sm disabled:opacity-50 ${n?"border-line bg-panel font-medium text-ink":"border-transparent text-mute hover:bg-panel-2 hover:text-ink"}`,children:[e.color?(0,t.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:e.color},"aria-hidden":!0}):null,(0,t.jsx)("span",{className:"truncate",children:e.label}),r?(0,t.jsx)(o.f,{size:12,className:"shrink-0 animate-spin text-accent","aria-label":"running"}):null]},e.id)})})]}),(0,t.jsx)("div",{className:"space-y-4 px-4 py-4 lg:px-6",children:"all"===f?(0,t.jsxs)(t.Fragment,{children:[c,p,g?.unfair?(0,t.jsxs)("p",{role:"note",className:"flex items-start gap-2 rounded-md border border-warn/40 bg-warn/10 px-3 py-2 text-sm text-ink",children:[(0,t.jsx)(O.f,{size:16,className:"mt-0.5 shrink-0 text-warn","aria-hidden":!0}),(0,t.jsxs)("span",{children:[g.unfair," Compare runs with the same load and length to say which API is faster."]})]}):null,(0,t.jsxs)("p",{className:"text-xs text-mute",children:["saved"===n?`Saved runs: ${e.map((e,t)=>{let s;return`${h[t]} ${Number.isNaN((s=new Date(e.report.startedAt)).getTime())?"":s.toLocaleString(void 0,{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"})}`}).join(" · ")}.`:"parallel"===r?"Ran at the same time — the runs shared this computer's CPU and network, so treat the numbers as directional.":"Ran one after another with the same load.",g&&!g.unfair&&g.caveats.length?` Note: ${g.caveats.join("; ")}.`:""]}),e.length>=2?(0,t.jsx)(D.f,{scope:"compare",data:{reports:e.map(e=>e.report),titles:e.map((e,t)=>h[t]+(s.has(e.tabId)?" · live":"")),slo:l,live:a}}):(0,t.jsx)("p",{className:"rounded-lg border border-dashed border-line px-6 py-14 text-center text-sm text-mute",children:a?"The overlay appears when the first API is under way…":"The overlay needs at least two finished runs."})]}):(0,t.jsx)(M.f,{report:e.find(e=>e.tabId===f).report,source:"engine"})})]})}var B=e.i(2385),L=e.i(19656);function J(e){let t=Math.max(0,Math.ceil(e/1e3)),s=Math.floor(t/60),a=t%60;return s>0?`${s}:${String(a).padStart(2,"0")}`:`${a}s`}function V(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let s=Math.floor(t/60),a=t%60;return a?`${s}m ${a}s`:`${s}m`}function G({mode:e,phase:s,liveRuns:a,startedAt:n,endedAt:r}){let[l,i]=(0,y.useState)(()=>Date.now()),o="running"===s||"probing"===s||"between"===s;return((0,y.useEffect)(()=>{if(!o)return;let e=setInterval(()=>i(Date.now()),250);return()=>clearInterval(e)},[o]),"idle"===s)?null:"probing"===s?(0,t.jsxs)("div",{className:"rounded-md border border-accent/30 bg-accent-dim px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs tracking-wide text-accent uppercase",children:"Checking APIs"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs text-mute",children:"Probing each API before load. This can take a few seconds."})]}):"between"===s?(0,t.jsxs)("div",{className:"rounded-md border border-accent/30 bg-accent-dim px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs tracking-wide text-accent uppercase",children:"Preparing next API"}),(0,t.jsx)("p",{className:"mt-0.5 text-xs text-mute",children:"Processing the last run and starting the next one. Sequence compares take a moment between APIs."}),n?(0,t.jsxs)("p",{className:"mt-1 font-mono text-sm text-ink",children:["Elapsed ",V(l-Date.parse(n))]}):null]}):"done"===s&&n&&r?(0,t.jsxs)("div",{className:"rounded-md border border-line bg-panel-2 px-3 py-2",children:[(0,t.jsx)("div",{className:"text-xs tracking-wide text-mute uppercase",children:"Overall time taken"}),(0,t.jsx)("p",{className:"mt-0.5 font-mono text-lg text-ink",children:(0,L.M)(n,r)}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs text-mute",children:["Wall clock for the whole compare (",e,"), including probes and gaps between runs."]})]}):"running"!==s||0===a.length?null:(0,t.jsxs)("div",{className:"space-y-2",children:[a.map(e=>{let s=(0,B.X)(e.report),a=Math.max(0,l-Date.parse(e.report.startedAt)),n=Math.max(0,s-a),r="running"===e.status&&0===n;return(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-accent/30 bg-accent-dim px-3 py-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"text-xs tracking-wide text-accent uppercase",children:["queued"===e.status?"Starting":r?"Finishing":"Load running"," · ",e.title]}),(0,t.jsx)("p",{className:"mt-0.5 text-xs text-mute",children:r?"Clock hit zero. k6 is letting in-flight requests finish.":`${J(a)} elapsed`})]}),(0,t.jsx)("div",{className:"font-mono text-2xl tabular text-ink",children:"queued"===e.status?"…":r?"—":J(n)})]},e.report.id)}),n?(0,t.jsxs)("p",{className:"text-xs text-mute",children:["Compare elapsed ",V(l-Date.parse(n))]}):null]})}var X=e.i(22543),K=e.i(63343),_=e.i(44794),H=e.i(31753),W=e.i(60566),Z=e.i(39170),Q=e.i(28867),Y=e.i(56396);e.i(42674);var ee=e.i(5305);let et="apitestcenter-compare-draft";function es(){return globalThis.crypto?.randomUUID?.()??`tab-${Date.now()}-${Math.random().toString(16).slice(2)}`}function ea(e){return{...(0,ee.t)(),id:es(),title:e}}function en(){let e=ea("API 1");return{tabs:[e,ea("API 2")],activeId:e.id,load:{...ee.J}}}function er(e,t){let s=e&&"object"==typeof e?e:{},a="string"==typeof s.title&&s.title.trim()||"string"==typeof s.label&&s.label.trim()||t;return{...(0,ee.i)(e),id:"string"==typeof s.id&&s.id?s.id:es(),title:a,collection:"string"==typeof s.collection&&s.collection?s.collection:void 0}}var el=e.i(21206),ei=e.i(20054),eo=e.i(68228),ed=e.i(65638),ec=e.i(6278),ep=e.i(46679),em=e.i(65238),eu=e.i(727),ex=e.i(59180),eh=e.i(2603);let ef=new Set(["title"]);function eb({tabs:e,activeId:s,probes:a,liveByTab:n,reports:r,running:l,onSelect:i,onRename:d,onClose:c,onAdd:m}){let[u,x]=(0,y.useState)(null);return(0,t.jsxs)("div",{className:"flex items-end gap-1 overflow-x-auto border-b border-line bg-canvas px-2 pt-2",role:"tablist","aria-label":"APIs to compare",children:[e.map((p,m)=>{let h=p.id===s,b=a[p.id],g=!!n[p.id],y=r.some(e=>e.tabId===p.id);return(0,t.jsxs)("div",{className:`group flex max-w-[15rem] shrink-0 items-center gap-1.5 rounded-t-md border border-b-0 pr-1 pl-2.5 text-sm ${h?"-mb-px border-line bg-panel text-ink":"border-transparent text-mute hover:bg-panel-2 hover:text-ink"}`,children:[(0,t.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full",style:{background:(0,U.f)(m)},"aria-hidden":!0}),u===p.id?(0,t.jsx)("input",{autoFocus:!0,defaultValue:p.title,"aria-label":"API name",onBlur:e=>{d(p.id,e.target.value.trim()||`API ${m+1}`),x(null)},onKeyDown:e=>{"Enter"===e.key&&e.target.blur(),"Escape"===e.key&&x(null)},className:"w-32 bg-transparent py-2 outline-none"}):(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":h,title:"Double-click to rename",onClick:()=>i(p.id),onDoubleClick:()=>x(p.id),className:"flex min-w-0 items-center gap-1.5 py-2",children:[(0,t.jsx)("span",{className:"truncate",children:p.title||"Untitled"}),g?(0,t.jsx)(o.f,{size:12,className:"shrink-0 animate-spin text-accent","aria-label":"running"}):b?(0,t.jsx)("span",{className:`shrink-0 font-mono text-xs ${(0,el.A)(b)?"text-ok":"text-bad"}`,children:b.status||"ERR"}):y?(0,t.jsx)("span",{className:"shrink-0 text-xs text-ok",children:"done"}):null]}),e.length>2?(0,t.jsx)("button",{type:"button","aria-label":`Close ${p.title}`,disabled:l,onClick:()=>c(p.id),className:"rounded p-0.5 text-mute opacity-0 group-hover:opacity-100 hover:bg-panel-2 hover:text-bad focus:opacity-100 disabled:opacity-0",children:(0,t.jsx)(f.X,{size:12})}):null]},p.id)}),(0,t.jsxs)("button",{type:"button",onClick:m,disabled:e.length>=6||l,title:e.length>=6?"Up to 6 APIs":"Add an API",className:"mb-1 ml-1 inline-flex shrink-0 items-center gap-1 rounded-md px-2 py-1.5 text-xs text-mute hover:bg-panel-2 hover:text-ink disabled:opacity-40",children:[(0,t.jsx)(p.f,{size:14}),"Add API"]})]})}function eg({contract:e,blocked:s,skipped:a,busy:n,onProceed:r}){if(!e)return null;if("pass"===e.level)return(0,t.jsx)("p",{className:"rounded-md border border-ok/40 bg-ok/10 px-3 py-2 text-sm text-ok",children:"✓ Every API returned the same response structure."});let l=e.issues.filter(e=>!/Need at least two/.test(e.message));return(0,t.jsxs)("div",{role:s?"alert":void 0,className:"rounded-md border border-warn/40 bg-warn/10 px-3 py-2.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-warn",children:s?"Compare not started — responses differ.":a?"Structures differ (allowed for this compare).":"Responses differ."}),l.length?(0,t.jsx)("ul",{className:"mt-1 list-disc space-y-0.5 pl-5 text-sm text-ink",children:l.map((e,s)=>(0,t.jsx)("li",{children:e.message},s))}):null,s?(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-xs",disabled:n,onClick:r,children:"Compare anyway"})}):null]})}function ey({entries:e,disabled:s,onPick:a}){let[n,r]=(0,y.useState)(!1),l=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!n)return;let e=e=>!l.current?.contains(e.target)&&r(!1),t=e=>"Escape"===e.key&&r(!1);return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[n]),(0,t.jsxs)("div",{ref:l,className:"relative",children:[(0,t.jsxs)("button",{type:"button",disabled:s,"aria-haspopup":"listbox","aria-expanded":n,onClick:()=>r(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:["Past compares",(0,t.jsx)(i.f,{size:12})]}),n?(0,t.jsx)("ul",{role:"listbox","aria-label":"Past compares",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:e.map(e=>(0,t.jsx)("li",{role:"option","aria-selected":!1,children:(0,t.jsxs)("button",{type:"button",onClick:()=>{a(e),r(!1)},className:"flex w-full items-center justify-between gap-2 rounded px-2 py-1.5 text-left text-xs text-ink hover:bg-panel-2",children:[(0,t.jsx)("span",{className:"min-w-0 truncate",children:e.name}),(0,t.jsxs)("span",{className:"shrink-0 text-mute",children:[e.titles.length," APIs"]})]})},e.id))}):null]})}function ev({children:e}){return(0,t.jsx)("div",{className:"flex flex-1 flex-col items-center justify-center rounded-lg border border-dashed border-line px-6 py-14 text-center text-sm text-mute",children:(0,t.jsx)("div",{className:"max-w-md",children:e})})}function ew(e,t){return function(e){let t=[];if(e.length<2)return{level:"fail",issues:[{level:"fail",message:"Need at least two APIs to compare"}]};for(let a of e){var s;a.probe.ok&&(s=a.probe.status)>=200&&s<300||t.push({level:"fail",message:`${a.label}: probe was ${a.probe.status||"ERR"}, not 2xx`}),a.probe.truncated&&t.push({level:"fail",message:`${a.label}: body was truncated, so the structure cannot be proven`})}let a=e.map(e=>({...e,structure:function(e){var t;let s,a=function(e,t){if(!e.trim())return"empty";if(t.toLowerCase().includes("json"))return"json";try{return JSON.parse(e),"json"}catch{return"text"}}(e.body,(s=Object.keys(t=e.headers).find(e=>"content-type"===e.toLowerCase()))?t[s]:"");if("empty"===a)return"empty";if("text"===a)return`text:${e.body}`;try{return`json:${JSON.stringify(function e(t){if(null===t)return"null";if(Array.isArray(t))return{type:"array",item:t.length>0?e(t[0]):"unknown"};if("object"==typeof t){let s={};for(let a of Object.keys(t).sort())s[a]=e(t[a]);return{type:"object",fields:s}}return typeof t}(JSON.parse(e.body)))}`}catch{return null}}(e.probe)}));if(a.some(e=>null==e.structure))t.push({level:"fail",message:"Could not parse one or more JSON bodies"});else{let e=a[0];if(e)for(let s of a.slice(1))s.structure!==e.structure&&t.push({level:"fail",message:`${s.label} response structure does not match ${e.label}`})}return{level:t.some(e=>"fail"===e.level)?"fail":t.some(e=>"warn"===e.level)?"warn":"pass",issues:t}}(e.map(e=>t[e.id]?{label:e.title||e.id,probe:t[e.id]}:null).filter(e=>!!e))}e.s(["ComparePage",0,function(){let e=(0,a.K)("compare",{min:320}),n=(0,g.useSearchParams)(),r=(0,g.useRouter)(),i=(0,Y.d)(),p=(0,Z.L)(),u=(0,ei.J)(),v=(0,eh.P)(),{slo:w}=(0,E.G)(),{vars:j,activeEnv:k}=(0,ec.U)(),N=(0,y.useRef)(null),[I,$]=(0,y.useState)(en),[C,S]=(0,y.useState)(!1),[A,P]=(0,y.useState)(!1),[F,T]=(0,y.useState)(null),[z,O]=(0,y.useState)({}),[D,M]=(0,y.useState)(null),[U,B]=(0,y.useState)(!1),[L,J]=(0,y.useState)("sequence"),[V,es]=(0,y.useState)(!1),[ej,ek]=(0,y.useState)(!1),[eN,eI]=(0,y.useState)(!1),[e$,eC]=(0,y.useState)(!1),[eS,eA]=(0,y.useState)({}),[eP,eF]=(0,y.useState)([]),[eE,eR]=(0,y.useState)(!1),[eT,ez]=(0,y.useState)(!1),{index:eO,refresh:eD}=(0,ex.K)(),eM=eO?.compares??[],[eU,eq]=(0,y.useState)("idle"),[eB,eL]=(0,y.useState)(null),[eJ,eV]=(0,y.useState)(null),[eG,eX]=(0,y.useState)("response"),eK=(0,y.useRef)(!1),e_=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{let e=function(){try{let e=sessionStorage.getItem(et);if(!e)return null;let t=JSON.parse(e),s=[];if(Array.isArray(t.tabs)&&t.tabs.length>0)s=t.tabs.map((e,t)=>er(e,`API ${t+1}`)).slice(0,6);else{if(!t.a||!t.b)return null;s=[er(t.a,"API 1"),er(t.b,"API 2")]}let a="string"==typeof t.activeId&&s.some(e=>e.id===t.activeId)?t.activeId:s[0].id,n=(0,ee.W)(t.load??t);return{tabs:s,activeId:a,load:n}}catch{return null}}();e&&$(e);let t=n.get("compare"),s=(n.get("ids")??[n.get("a"),n.get("b")].filter(Boolean).join(",")).split(",").map(e=>e.trim()).filter(Boolean);t?ex.c.compare(t).then(tn).catch(()=>i("That compare is no longer in History","error")):s.length>=2&&Promise.all(s.map(e=>ex.c.run(e).catch(()=>null))).then(e=>{let t=e.filter(e=>!!e);if(t.length<2)return i("Need at least two of those runs to overlay","error");eF(t.map((e,t)=>({tabId:e.report.id,title:e.meta?.name||e.report.testName||`API ${t+1}`,report:e.report}))),eR(!0),ez(!0),eq("done"),eX("results")}),S(!0)},[n]),(0,y.useEffect)(()=>{if(!C)return;let e=window.setTimeout(()=>(function(e){try{sessionStorage.setItem(et,JSON.stringify(e))}catch{}})(I),250);return()=>window.clearTimeout(e)},[I,C]);let eH=I.tabs.find(e=>e.id===I.activeId)??I.tabs[0],eW=I.tabs.filter(ee.k),eZ=eW.length>=2,eQ=(0,ee.w)(I.load),eY=(0,y.useMemo)(()=>{let e=new Map(eP.map(e=>[e.tabId,e]));for(let[t,s]of Object.entries(eS)){if(e.has(t))continue;let a=I.tabs.find(e=>e.id===t);e.set(t,{tabId:t,title:a?.title??t,report:s.report})}let t=I.tabs.filter(t=>e.has(t.id)).map(t=>e.get(t.id));return t.length===e.size?t:[...e.values()]},[eP,eS,I.tabs]),e0=eP.map(e=>({id:e.tabId,title:e.title,report:e.report,probe:z[e.tabId]??null})),e1=Object.entries(eS).map(([e,t])=>({title:I.tabs.find(t=>t.id===e)?.title||e,status:t.status,report:t.report}));function e2(e,t){let s=I.tabs.find(t=>t.id===e);s&&Object.keys(t).some(e=>!ef.has(e)&&t[e]!==s[e])&&z[e]&&(O(({[e]:t,...s})=>s),M(null),B(!1)),$(s=>({...s,tabs:s.tabs.map(s=>s.id===e?t:s)}))}async function e6(e){try{let t=await (0,em.c)(e,e.collection,j),s=(0,ee.x)(t.draft,t.vars,k?.name),a=(0,ee.M)(s,(0,ee.S)(I.load),(0,ee.m)(s,e.title),(0,ee.n)(w));return await (0,ep.f)(a,s,j,k?.name)}catch(t){throw Error(`${e.title||"API"}: ${t instanceof Error?t.message:"invalid request"}`)}}async function e5(){let e;if(!A&&!eN&&(0,ee.k)(eH)){try{e=await e6(eH)}catch(e){T(e instanceof Error?e.message:"Invalid request");return}P(!0),T(null),eX("response");try{let t=await (0,el.V)(e),s={...z,[eH.id]:t};O(s),M(ew(eW,s))}finally{P(!1)}}}async function e4(e,t){let s=Object.fromEntries(await Promise.all(e.map(async e=>[e.id,await (0,el.V)(t.get(e.id))])));return O(e=>({...e,...s})),s}async function e3(){let e;if(!A&&!eN&&eZ){try{e=new Map(await Promise.all(eW.map(async e=>[e.id,await e6(e)])))}catch(e){T(e instanceof Error?e.message:"Invalid request");return}P(!0),T(null),B(!1);try{let t=await e4(eW,e),s=ew(eW,t);M(s),eX("response"),i("pass"===s.level?"Every API answered with the same structure":"Checked — see the structure result","pass"===s.level?"success":"info")}finally{P(!1)}}}async function e8(e,t){let s=0;for(;;){let a=await (0,el.c)(t);if(a){if(s=0,eA(t=>({...t,[e.id]:a})),(0,el.P)(a.status))return e_.current.delete(t),eK.current||eF(t=>[...t.filter(t=>t.tabId!==e.id),{tabId:e.id,title:e.title,report:a.report}]),eA(({[e.id]:t,...s})=>s),eK.current?null:a.report}else if(++s>=20)throw Error(`Lost contact with the engine while ${e.title} was running`);await new Promise(e=>window.setTimeout(e,500))}}async function e7(e,t){let s=await (0,el.Q)(t);return e_.current.add(s.id),eA(t=>({...t,[e.id]:s})),s}async function e9(e,t){let s=[];for(let a=0;a<e.length&&!eK.current;a++){let n=e[a];eq(a>0?"between":"running"),$(e=>({...e,activeId:n.id}));let r=await e7(n,t.get(n.id));eq("running");let l=await e8(n,r.id);if(!l)break;s.push({tabId:n.id,title:n.title,report:l})}return s}async function te(e,t){eq("running");let s=await Promise.allSettled(e.map(e=>e7(e,t.get(e.id)))),a=s.find(e=>"rejected"===e.status);if(a)throw await ts(),a.reason instanceof Error?a.reason:Error("Failed to start load");return(await Promise.all(e.map(async(e,t)=>{let a=s[t].value,n=await e8(e,a.id);return n?{tabId:e.id,title:e.title,report:n}:null}))).filter(e=>!!e)}async function tt(e){let s;if(A||eN||!eZ||!u.k6Ready)return;if(eQ)return void T(eQ);try{s=new Map(await Promise.all(eW.map(async e=>[e.id,await e6(e)])))}catch(e){T(e instanceof Error?e.message:"Invalid request");return}let a=eW.filter(e=>(0,el.n)(I.load.preset,s.get(e.id).load,s.get(e.id).request.url));if(a.length>0&&!await p({title:`Start a ${(0,K.A)(I.load)} performance test against ${1===a.length?(0,el.q)(s.get(a[0].id).request.url):`${a.length} hosts`}?`,body:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("ul",{className:"mb-2 list-disc pl-5 font-mono text-xs text-ink",children:a.map(e=>(0,t.jsx)("li",{children:(0,el.q)(s.get(e.id).request.url)},e.id))}),"parallel"===L?"All APIs run at the same time":"APIs run one after another"," with"," ",(0,K.A)(I.load)," each. 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 compare",tone:"danger"}))return;let n=e||V;eK.current=!1,e_.current.clear(),T(null),P(!0),eI(!0),eR(!1),ez(!1),eF([]),eA({}),ek(!1),eL(new Date().toISOString()),eV(null),eq("probing"),eX("results");try{let e=await e4(eW,s),t=eW.filter(t=>!(0,el.A)(e[t.id]));if(t.length){T(`Every API needs a 2xx check before load. Not 2xx: ${t.map(t=>`${t.title} (${e[t.id]?.status||"error"})`).join(", ")}`),$(e=>({...e,activeId:t[0].id})),eX("response"),eq("idle");return}let a=ew(eW,e);if(M(a),"fail"===a.level&&!n){B(!0),eX("response"),eq("idle");return}B(!1),"fail"===a.level&&ek(!0);let r="parallel"===L?await te(eW,s):await e9(eW,s);if(eV(new Date().toISOString()),r.length>=2&&!eK.current){try{await ex.c.saveCompare({mode:L,ignoreStructure:n,apis:r.map(t=>({id:t.tabId,title:t.title,report:t.report,probe:e[t.tabId]??null}))}),i("Compare finished and saved to History","success"),(0,eu.G)({title:"Compare finished",body:`${r.map(e=>e.title).join(" vs ")}
51
+ Saved to History.`,ok:!0})}catch(e){i(`Compare finished, but saving it failed: ${e instanceof Error?e.message:"unknown error"}`,"error")}eD()}else eK.current&&i("Compare stopped","info");eq(eK.current?"idle":"done")}catch(e){T(e instanceof Error?e.message:"Compare failed"),eq("idle")}finally{e_.current.size>0&&await ts(),P(!1),eI(!1),eC(!1),eA({})}}async function ts(){await Promise.all([...e_.current].map(e=>(0,el.Z)(e)))}async function ta(){eK.current=!0,eC(!0),await ts()}function tn(e){eF(e.apis.map(e=>({tabId:e.id,title:e.title,report:e.report})));let t={};for(let s of e.apis)s.probe&&(t[s.id]=s.probe);O(t),J(e.mode),es(!!e.meta?.ignoreStructure),ek(!!e.meta?.ignoreStructure),eR(!0),ez(!1),B(!1),M(null),eq("done");let s=e.apis.map(e=>Date.parse(e.report.startedAt)).filter(Number.isFinite),a=e.apis.map(e=>Date.parse(e.report.endedAt)).filter(Number.isFinite);eL(s.length?new Date(Math.min(...s)).toISOString():e.exportedAt),eV(a.length?new Date(Math.max(...a)).toISOString():e.exportedAt),eX("results")}async function tr(e){try{tn(await ex.c.compare(e.id))}catch(e){i(e instanceof Error?e.message:"Could not open that compare","error")}}(0,eh.B)({send:()=>void e5(),run:()=>void tt(!1),focusUrl:()=>N.current?.focus()});let tl=z[eH.id],ti=u.k6Ready?eZ?eQ??void 0:"Give at least two APIs a URL":u.k6Label,to=eM.length>0?(0,t.jsx)(ey,{entries:eM,disabled:eN,onPick:e=>void tr(e)}):null;if("results"===eG){let e=eY.length||eW.length;return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("h1",{className:"sr-only",children:"Compare APIs"}),(0,t.jsx)(q,{items:eY,liveTabs:new Set(Object.keys(eS)),running:eN,source:eT?"saved":"compare",mode:L,slo:w,title:eT?`Comparing ${e} saved runs`:eE?`Saved compare \xb7 ${e} APIs`:eN?`Comparing ${e} APIs…`:`Compare results \xb7 ${e} APIs`,actions:eN?(0,t.jsxs)("button",{type:"button",className:"btn btn-danger",disabled:e$,onClick:()=>void ta(),children:[e$?(0,t.jsx)(o.f,{size:16,className:"animate-spin"}):(0,t.jsx)(h.f,{size:16}),e$?"Stopping…":"Stop"]}):(0,t.jsxs)(t.Fragment,{children:[to,eE?(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",onClick:()=>{eF([]),O({}),eR(!1),ez(!1),eq("idle"),eX("response"),r.replace("/compare")},title:"Close these results and set up a new compare",children:[(0,t.jsx)(f.X,{size:16}),"Close"]}):(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",onClick:()=>eX("response"),title:"Back to the APIs and the shared load",children:[(0,t.jsx)(d.f,{size:16}),"Edit setup"]})]}),status:eT?null:(0,t.jsx)(G,{mode:L,phase:eU,liveRuns:e1,startedAt:eB,endedAt:eJ}),exportBar:e0.length>0&&!eN?(0,t.jsx)(R,{apis:e0,mode:L,probes:z}):null})]})}return(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)("h1",{className:"sr-only",children:"Compare APIs"}),(0,t.jsx)(eb,{tabs:I.tabs,activeId:eH.id,probes:z,liveByTab:eS,reports:eP,running:eN,onSelect:e=>$(t=>({...t,activeId:e})),onRename:(e,t)=>e2(e,{...I.tabs.find(t=>t.id===e),title:t}),onClose:function(e){I.tabs.length<=2||eN||($(t=>{let s=t.tabs.findIndex(t=>t.id===e),a=t.tabs.filter(t=>t.id!==e),n=t.activeId===e?a[Math.max(0,s-1)]?.id??a[0].id:t.activeId;return{...t,tabs:a,activeId:n}}),O(({[e]:t,...s})=>s),eF(t=>t.filter(t=>t.tabId!==e)))},onAdd:function(){if(I.tabs.length>=6)return;let e=ea(`API ${I.tabs.length+1}`);$(t=>({...t,tabs:[...t.tabs,e],activeId:e.id})),window.setTimeout(()=>N.current?.focus(),0)}}),(0,t.jsxs)("header",{className:"border-b border-line bg-panel px-4 py-3 lg:px-6",children:[(0,t.jsx)(_.f,{ref:N,draft:eH,onChange:e=>e2(eH.id,{...eH,...e}),onImported:e=>i(e,"success"),actions:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("button",{type:"button",className:"btn btn-primary",disabled:A||eN||!(0,ee.k)(eH),title:`Send this API once (${v}+Enter)`,onClick:()=>void e5(),children:[A&&!eN?(0,t.jsx)(o.f,{size:16,className:"animate-spin"}):(0,t.jsx)(m.f,{size:16}),"Send"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",disabled:A||eN||!eZ,title:"Send every API once and compare response structure",onClick:()=>void e3(),children:[(0,t.jsx)(x,{size:16}),"Send all"]}),eN?(0,t.jsxs)("button",{type:"button",className:"btn btn-danger",disabled:e$,onClick:()=>void ta(),children:[e$?(0,t.jsx)(o.f,{size:16,className:"animate-spin"}):(0,t.jsx)(h.f,{size:16}),e$?"Stopping…":"Stop"]}):(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary",disabled:A||!!ti,title:ti??`Check every API, then run the shared load on each (${v}+Shift+Enter)`,onClick:()=>void tt(!1),children:[(0,t.jsx)(c.f,{size:16}),"Compare load"]})]})}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2",children:[(0,t.jsx)(eo.f,{drafts:I.tabs,collections:I.tabs.map(e=>e.collection)}),(0,t.jsx)(ed.M,{onOpen:e=>{e2(eH.id,{...eH,...(0,ee.i)(e.request),id:eH.id,title:e.name,collection:e.collection||void 0}),i(`Loaded “${e.name}” into this tab`,"success")}}),F?(0,t.jsx)("p",{role:"alert",className:"text-xs text-bad",children:F}):null]})]}),(0,t.jsxs)("div",{ref:e.gridRef,style:e.gridStyle,className:"relative grid min-h-0 flex-1 overflow-y-auto lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] lg:overflow-hidden 2xl:grid-cols-[minmax(0,5fr)_minmax(0,7fr)]",children:[(0,t.jsx)(s.f,{label:"Compare panes width",...e.splitter}),(0,t.jsxs)("section",{"aria-label":"Request",className:"min-w-0 space-y-6 px-4 py-4 lg:overflow-y-auto lg:px-6",children:[(0,t.jsx)(H.p,{id:"compare-request",draft:eH,collection:eH.collection,onChange:e=>e2(eH.id,{...eH,...e}),checkResults:z[eH.id]?.checks,lastBody:z[eH.id]?.body,setupResult:z[eH.id]?.setup}),(0,t.jsxs)("section",{className:"space-y-4 rounded-lg border border-line bg-panel p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h2",{className:"flex items-center gap-1.5 text-sm font-medium text-ink",children:["Compare setup",(0,t.jsx)(X.f,{text:"These settings apply to every API, so their timelines line up in the overlay."})]}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs text-mute",children:["Applies to all ",I.tabs.length," APIs."]})]}),(0,t.jsx)(K.B,{load:I.load,onChange:e=>$(t=>({...t,load:e}))}),(0,t.jsxs)("div",{className:"space-y-2 border-t border-line pt-4",children:[(0,t.jsx)("span",{className:"block text-xs text-mute",children:"Run mode"}),(0,t.jsx)(Q.f,{label:"Run mode",value:L,onChange:J,options:[{value:"sequence",label:"One after another"},{value:"parallel",label:"All at once"}]}),(0,t.jsx)("p",{className:"text-xs text-mute",children:"sequence"===L?"Fairest comparison: each API gets this computer's full CPU and network.":"Faster, but the runs share CPU and network, so treat the numbers as directional."}),(0,t.jsxs)("label",{className:"flex items-start gap-2 pt-1 text-sm text-ink",children:[(0,t.jsx)("input",{type:"checkbox",checked:V,onChange:e=>es(e.target.checked),className:"mt-1 accent-[var(--accent)]"}),(0,t.jsxs)("span",{children:["Allow different response structures",(0,t.jsx)("span",{className:"block text-xs text-mute",children:"By default every API must return the same JSON shape, so you compare like with like. Each still needs a 2xx."})]})]})]})]})]}),(0,t.jsxs)("section",{"aria-label":"Response",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:border-l lg:px-6",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line pb-2",children:[(0,t.jsxs)("h2",{className:"text-sm font-medium text-ink",children:["Response · ",eH.title||"API",tl?(0,t.jsx)("span",{className:`ml-2 font-mono text-xs ${(0,el.A)(tl)?"text-ok":"text-bad"}`,children:tl.status||"ERR"}):null]}),(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[to,eY.length>=2?(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1 text-xs",onClick:()=>eX("results"),children:["View results",(0,t.jsx)(l,{size:14})]}):null]})]}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col space-y-4 pt-4",children:[(0,t.jsx)(eg,{contract:D,blocked:U,skipped:ej,busy:A||eN,onProceed:()=>void tt(!0)}),tl?(0,t.jsx)(W.p,{result:tl}):(0,t.jsxs)(ev,{children:[(0,t.jsxs)("p",{children:["Give each tab a URL, choose the shared load, then press ",(0,t.jsx)("span",{className:"text-ink",children:"Compare load"}),". Each API is checked first; the results open full width, with a tab for each API."]}),(0,t.jsxs)("p",{className:"mt-2",children:[(0,t.jsx)("span",{className:"text-ink",children:"Send"})," checks this API once; ",(0,t.jsx)("span",{className:"text-ink",children:"Send all"})," checks every API and confirms they return the same structure. To compare finished runs, use ",(0,t.jsx)("span",{className:"text-ink",children:"Add to compare"})," on a report, or tick runs on"," ",(0,t.jsx)(b.default,{href:"/history",className:"text-accent hover:underline",children:"History"}),"."]})]})]})]})]})]})}],49186)}]);
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63343,44794,90972,45480,87078,35559,12580,90446,e=>{var t=e.i(51487);e.i(24856);var s=e.i(59100),n=e.i(30340),a=e.i(2810),r=e.i(62620),l=e.i(77306),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.f,{label:`About ${e}`,text:l}):null]}),(0,t.jsx)("input",{type:"number",min:n,max:a,value:s,onChange:e=>r(x(e.target.value,n,a)),className:"input font-mono"})]})}function m({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.R)(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:x(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.f,{size:12,"aria-hidden":!0})," Add stage"]})]})}function x(e,t,s){let n=Math.round(Number(e));return Number.isFinite(n)?Math.min(s,Math.max(t,n)):t}function h(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.L)(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.L)(e.rampUp),r=(0,s.L)(e.duration),l=(0,s.L)(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 p(e){let{totalMs:t,peak:s}=h(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}=h(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:p(e)})]}),(0,t.jsxs)("svg",{viewBox:"0 0 300 56",preserveAspectRatio:"none",className:"h-14 w-full",role:"img","aria-label":`Load profile: ${p(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(["B",0,function({load:e,onChange:a}){var r;let x,[h,p]=(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.f,{label:"Test type",value:e.preset,onChange:t=>a((0,d.V)(e,t)),options:[...n.R.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,(x=n.R.find(e=>e.id===r))?`${x.question} ${x.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.f,{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.f,{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.f,{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.L)(e.rampUp)>0&&a.push({duration:e.rampUp,target:n}),a.push({duration:e.duration,target:n}),(0,s.L)(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)(m,{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.S,{label:"Hold for",mono:!0,value:e.duration,error:(0,d.R)(e.duration,!1),onChange:e=>f({duration:e})}),(0,t.jsx)(o.S,{label:"Ramp up",mono:!0,value:e.rampUp,error:(0,d.R)(e.rampUp),onChange:e=>f({rampUp:e})}),(0,t.jsx)(o.S,{label:"Ramp down",mono:!0,value:e.rampDown,error:(0,d.R)(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:()=>p(e=>!e),"aria-expanded":h,children:h?"Hide pacing options":"Pacing options"}),h?(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.S,{label:"Graceful stop",mono:!0,value:e.gracefulStop,error:(0,d.R)(e.gracefulStop),onChange:e=>f({gracefulStop:e}),hint:"Time in-flight requests get to finish."})]}):null]})},"A",0,p],63343);var g=e.i(59780),v=e.i(83500),j=e.i(84575),y=e.i(80707),N=e.i(70746);let w=null,k=null,C=new Set;function $(){return k??=fetch("/engine/local-servers",{cache:"no-store"}).then(e=>e.ok?e.json():null).then(e=>(e&&(w=e.servers),w)).catch(()=>w).finally(()=>{k=null,C.forEach(e=>e())}),C.forEach(e=>e()),k}var S=e.i(6278);let q=/^\{\{\s*([A-Za-z_][\w.-]*)\s*\}\}/,E=/^(https?):\/\/(localhost|127\.0\.0\.1)(?::(\d{1,5}))?(?=[/?#]|$)/i,z="\0none",M="\0local-other",T="apitestcenter-local-ports",R={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(T)??"[]");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(T,JSON.stringify([e,...D().filter(t=>t!==e)].slice(0,5)))}catch{}}let O=(0,l.forwardRef)(function({draft:e,onChange:s,onImported:n,actions:a},i){let{vars:o,environments:c,activeEnv:u}=(0,S.U)(),m=(0,N.k)(),x=(0,l.useRef)(null);(0,l.useImperativeHandle)(i,()=>x.current);let[h,p]=(0,l.useState)([]),[f,b]=(0,l.useState)(null),[T,O]=(0,l.useState)(!1),A=(0,l.useRef)(null);(0,l.useEffect)(()=>p(D()),[]),(0,l.useEffect)(()=>{f&&A.current?.focus()},[f]);let P=e.url,U=q.exec(P)?.[1],F=Object.entries(o).filter(([e,t])=>/^https?:\/\//i.test(t.trim())&&("practiceApi"!==e||U===e)),I=m.filter(e=>!F.some(([t])=>t===e.variable)).map(e=>[e.variable,e.baseUrl,e.name]),B=[...F,...I.map(([e,t])=>[e,t])],W=(()=>{if(T)return null;let e=q.exec(P);if(e&&B.some(([t])=>t===e[1]))return{prefix:e[0],text:`{{${e[1]}}}`,value:e[1]};let t=E.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})(),_=P.startsWith("/"),H=_||""===P||null!=W,V=function(e){let[,t]=(0,l.useState)(0);(0,l.useEffect)(()=>{let e=()=>t(e=>e+1);return C.add(e),()=>void C.delete(e)},[]),(0,l.useEffect)(()=>{e&&null==w&&!k&&$()},[e]);let s=(0,l.useCallback)(()=>void $(),[]);return{servers:w??[],checked:null!=w,checking:null!=k,refresh:s}}(H),K=W?P.slice(W.prefix.length):P,X=e=>{let t=""===K||K.startsWith("/")||K.startsWith("?")?K:`/${K}`;return`${e}${t||(e.startsWith("{{")?"":"/")}`},J=t=>{let n=/^(https?:\/\/|\{\{)/i.test(t.trim())||""===K&&""!==t&&!/^[/?#]/.test(t);/^https?:\/\//i.test(t.trim())&&O(!0),s((0,d.e)(e,W&&!n?`${W.prefix}${t}`:t))},Z=(0,j.m)(x,J),G=V.servers,Y=[...G.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})),...h.filter(e=>!G.some(t=>t.port===e)).map(e=>({value:`local:http:${e}`,label:`localhost:${e}`,hint:V.checked?"used before · not running now":"used before",text:`localhost ${e}`,className:"font-mono text-mute",group:"local",inline:!0}))];W?.value.startsWith("local:")&&!Y.some(e=>e.value===W.value)&&Y.unshift({value:W.value,label:W.text,hint:"in this request",text:W.text,className:"font-mono",group:"local",inline:!0});let Q=null!=W&&!W.value.startsWith("local:"),ee=[...I.length?[{id:"connections",label:"Connections",text:"connections",defaultOpen:!0}]:[],...F.length?[{id:"env",label:u?.name??"Variables",text:u?.name??"variables",defaultOpen:Q||null==W,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:V.checking&&!V.checked?"checking…":`${G.length||"none"} running${V.checking?" · checking…":""}`,defaultOpen:!B.length&&null==W,action:{label:(0,t.jsx)(v.f,{size:12,"aria-hidden":!0,className:V.checking?"animate-spin":""}),title:"Check again for running servers",onClick:V.refresh,keepOpen:!0}}],et=W?"text-accent":_?"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)(y.f,{label:"Method",value:e.method,onChange:t=>s({...e,method:t}),options:d.C.map(e=>({value:e,label:e,className:`font-mono font-medium ${R[e]}`})),minWidth:140,className:`shrink-0 border-r border-line px-3 font-mono text-sm font-medium outline-none focus-visible:bg-panel ${R[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),p(D()),s((0,d.e)(e,X(`${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:A,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.f,{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})})]}):H?(0,t.jsx)(y.f,{label:"Base URL",value:W?.value??z,onChange:t=>{if(t===M)return b({scheme:"http",port:""});if(t===z)return s((0,d.e)(e,K));if(t.startsWith("local:")){let[,n,a]=t.split(":"),r=Number(a);return L(r),p(D()),s((0,d.e)(e,X(`${n}://localhost:${r}`)))}s((0,d.e)(e,X(`{{${t}}}`)))},onOpen:V.refresh,minWidth:320,buttonContent:W?.text??"Base URL",groups:ee,options:[...I.map(([e,t,s])=>({value:e,label:`{{${e}}}`,hint:`${s} \xb7 ${t}`,text:`${e} ${s}`,className:"font-mono text-accent",group:"connections"})),...F.map(([e,t])=>({value:e,label:`{{${e}}}`,hint:t,text:e,className:"font-mono text-accent",group:"env"})),...Y,{value:M,label:"Another port…",text:"another port",group:"local"},{value:z,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",{...Z.handlers,ref:x,id:"request-url",value:K,spellCheck:!1,autoComplete:"off",onChange:e=>J(e.target.value),onKeyDown:e=>void Z.onKeyDown(e),onBlur:()=>{O(!1),Z.handlers.onBlur()},onPaste:t=>{let a=(0,d.X)(e,t.clipboardData.getData("text"));a&&(t.preventDefault(),s(a.draft),a.note&&n?.(a.note))},placeholder:W?"/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"})]}),Z.popup,(0,t.jsx)("div",{className:"flex shrink-0 gap-2",children:a})]})});e.s(["f",0,O],44794);var A=e.i(56003);let P={name:"chevron-up",size:24,node:[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]};P.node;let U=(0,A.f)(P);e.s(["f",0,U],90972);let F={name:"text-wrap",size:24,node:[["path",{d:"m16 16-3 3 3 3",key:"117b85"}],["path",{d:"M3 12h14.5a1 1 0 0 1 0 7H13",key:"18xa6z"}],["path",{d:"M3 19h6",key:"1ygdsz"}],["path",{d:"M3 5h18",key:"1u36vt"}]],aliases:["wrap-text"]};F.node;let I=(0,A.f)(F);e.s(["f",0,I],45480);var B=e.i(75606),W=e.i(55919);let _={name:"eye",size:24,node:[["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"}]]};_.node;let H=(0,A.f)(_);e.s(["f",0,H],87078);let V={name:"eye-off",size:24,node:[["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"}]]};V.node;let K=(0,A.f)(V);e.s(["f",0,K],35559);var X=e.i(39024),J=e.i(56396);let Z="apitestcenter-code-target";e.s(["B",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)(K,{size:12,"aria-hidden":!0}):(0,t.jsx)(H,{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)":B.Z}),(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)})})]})})]})},"x",0,function({sent:e}){let s=(0,J.d)(),[n,a]=(0,l.useState)(!1),[r,i]=(0,l.useState)("curl");(0,l.useEffect)(()=>i(function(){try{let e=localStorage.getItem(Z);if(B.X.some(t=>t.id===e))return e}catch{}return"curl"}()),[]);let o=(0,l.useMemo)(()=>n?e:(0,B.A)(e),[e,n]),c=(0,l.useMemo)(()=>(0,B.T)(r,o),[r,o]),d=(0,l.useMemo)(()=>JSON.stringify((0,B.A)(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)(K,{size:12,"aria-hidden":!0}):(0,t.jsx)(H,{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)(X.f,{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)(W.f,{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(B.Z)?"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)(y.f,{label:"Language",value:r,onChange:e=>{i(e);try{localStorage.setItem(Z,e)}catch{}},options:B.X.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)(W.f,{size:12})," Copy"]})]}),(0,t.jsx)("pre",{"aria-label":`${B.X.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 ${B.Z} — 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 G={name:"arrow-down-left",size:24,node:[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]]};G.node;let Y=(0,A.f)(G);e.s(["f",0,Y],90446)},60566,97716,16788,68228,65638,46679,e=>{var t=e.i(51487),s=e.i(30932),n=e.i(78e3),a=e.i(90972),r=e.i(55919),l=e.i(87953),i=e.i(86766),o=e.i(45480),c=e.i(77306),d=e.i(28867),u=e.i(13318),m=e.i(56396),x=e.i(15060),h=e.i(12580),p=e.i(90446),f=e.i(51721),b=e.i(39024),g=e.i(37841),v=e.i(28232),j=e.i(92001);let y={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 N({id:e,onClosed:s}){let n=(0,m.d)(),[a,l]=(0,c.useState)([]),[o,d]=(0,c.useState)(null),[u,x]=(0,c.useState)(!1),[h,w]=(0,c.useState)(""),[k,C]=(0,c.useState)(""),[$,S]=(0,c.useState)(!0),q=(0,c.useRef)(null),E=(0,c.useRef)(0),z=(0,c.useRef)(s);z.current=s,(0,c.useEffect)(()=>{l([]),d(null),x(!1),E.current=0;let t=!0,s=0,n=async()=>{try{let s=await fetch(`/engine/realtime/${e}?since=${E.current}`,{cache:"no-store"});if(404===s.status)return void x(!0);let n=await s.json();if(!t)return;if(E.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 z.current?.()}catch{}t&&(s=window.setTimeout(()=>void n(),350))};return n(),()=>{t=!1,window.clearTimeout(s)}},[e]),(0,c.useEffect)(()=>{$&&q.current?.lastElementChild?.scrollIntoView({block:"nearest"})},[a,$]);let M=(0,c.useMemo)(()=>k?a.filter(e=>e.text.toLowerCase().includes(k.toLowerCase())||(e.event??"").toLowerCase().includes(k.toLowerCase())):a,[a,k]),T=(0,c.useMemo)(()=>({in:a.filter(e=>"in"===e.dir).length,out:a.filter(e=>"out"===e.dir).length}),[a]),R=o?.status==="open",D=o?.kind==="ws",L=async()=>{if(!h.trim()||!R)return;let t=await fetch(`/engine/realtime/${e}/send`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:h})});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":R?"border-ok/40 bg-ok/10 text-ok":o?.status==="connecting"?"border-accent/40 text-accent":"border-line text-mute"}`,children:u?"Gone":R?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:T.in})," received · ",(0,t.jsx)("span",{className:"text-ink",children:T.out})," sent"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"text-ink",children:T.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.f,{size:12,className:"text-mute","aria-hidden":!0}),(0,t.jsx)("input",{value:k,onChange:e=>C(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:$,onChange:e=>S(e.target.checked),className:"accent-[var(--accent)]"}),"Follow"]}),R?(0,t.jsxs)("button",{type:"button",onClick:()=>void y.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)(j.f,{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:q,"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:k?"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)(p.f,{size:13,className:"text-ok"}):"out"===e.dir?(0,t.jsx)(f.f,{size:13,className:"text-accent"}):"error"===e.dir?(0,t.jsx)(v.f,{size:13,className:"text-bad"}):(0,t.jsx)(b.f,{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.f,{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:h,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),L())},rows:Math.min(8,Math.max(2,h.split("\n").length)),disabled:!R,placeholder:R?'{ "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:!R||!h.trim(),className:"btn btn-primary py-2",children:[(0,t.jsx)(g.f,{size:14})," Send"]})]}):null]})}e.s(["d",0,N,"D",0,y],97716);var w=e.i(19656),k=e.i(61230);let C="apitestcenter-show-big-answers",$={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 q({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 E({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 z({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,m.d)(),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.f,{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 T({body:e,contentType:n,truncated:u,url:h,base64:p}){let f=(0,m.d)(),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&&p?`data:${n.split(";")[0]};base64,${p}`:null,v=u||e.length>=2e5,[j,y]=(0,c.useState)("pretty"),[N,k]=(0,c.useState)(!0),[$,S]=(0,c.useState)(""),[q,E]=(0,c.useState)(0),[z,M]=(0,c.useState)(!1),A=(0,c.useRef)(null),P=(0,c.useRef)(null),[U,F]=(0,c.useState)(!1);(0,c.useEffect)(()=>{try{F("1"===localStorage.getItem(C))}catch{}},[e]),(0,c.useEffect)(()=>{y("image"===b?"preview":"pretty"),S(""),E(0)},[e,b]);let I=(0,c.useMemo)(()=>e?"raw"===j?e:function(e,t){if("json"!==t)return e;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}(e,b):"",[e,j,b]),B=(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})(I,$),[I,$]);function W(e){0!==B&&E(t=>(t+e+B)%B)}(0,c.useEffect)(()=>{let e=P.current?.querySelector("mark.current");e?.scrollIntoView({block:"center"})},[q,$,j]);let _=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&&!U?(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,w.L)(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:()=>F(!0),children:"Show it"}),(0,t.jsx)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:()=>{y("raw"),F(!0)},children:"As plain text"}),(0,t.jsxs)("button",{type:"button",className:"btn btn-secondary py-1.5 text-sm",onClick:()=>(0,x.N)(L(h,b),e,O(b)),children:[(0,t.jsx)(l.f,{size:14}),"Save to file"]})]}),(0,t.jsx)("button",{type:"button",className:"text-xs text-mute hover:text-ink",onClick:()=>{try{localStorage.setItem(C,"1")}catch{}F(!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(()=>A.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.f,{label:"Body view",value:j,onChange:y,options:_}),(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:[z?(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.f,{size:12,className:"text-mute"}),(0,t.jsx)("input",{ref:A,value:$,"aria-label":"Find in body",placeholder:"Find",onChange:e=>{S(e.target.value),E(0)},onKeyDown:e=>{"Enter"===e.key&&W(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:$?`${B?q+1:0}/${B}`:""}),(0,t.jsx)(R,{label:"Previous match",onClick:()=>W(-1),children:(0,t.jsx)(a.f,{size:12})}),(0,t.jsx)(R,{label:"Next match",onClick:()=>W(1),children:(0,t.jsx)(s.f,{size:12})})]}):(0,t.jsx)(R,{label:"Find in body (Ctrl+F)",onClick:()=>{M(!0),window.setTimeout(()=>A.current?.focus(),0)},children:(0,t.jsx)(i.f,{size:14})}),(0,t.jsx)(R,{label:N?"Turn off line wrap":"Wrap long lines",pressed:N,onClick:()=>k(e=>!e),children:(0,t.jsx)(o.f,{size:14})}),(0,t.jsx)(R,{label:"Copy body",onClick:()=>{navigator.clipboard.writeText(I),f("Body copied","success")},children:(0,t.jsx)(r.f,{size:14})}),(0,t.jsx)(R,{label:"Download body",onClick:()=>g&&p?(0,x.h)(L(h,b,n),new Blob([Uint8Array.from(atob(p),e=>e.charCodeAt(0))],{type:n.split(";")[0]})):(0,x.N)(L(h,b),I,O(b)),children:(0,t.jsx)(l.f,{size:14})})]})]}),"preview"===j&&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"===j?(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 ${N?"break-words whitespace-pre-wrap":"whitespace-pre"}`,children:$?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}(I,$,q):"pretty"!==j||"json"!==b||v?I: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}(I)})]}):(0,t.jsx)("p",{className:"text-sm text-mute",children:"Empty body."})}function R({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 O(e){return"json"===e?"application/json":"html"===e?"text/html":"xml"===e?"application/xml":"text/plain"}function A({url:e}){let s=(0,m.d)(),[a,l]=(0,c.useState)(!1),i=(0,k.f)(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.f,{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.f,{size:12,"aria-hidden":!0})})]})}e.s(["p",0,function({result:e,onSaveExample:s,extra:n,onWaitLonger:a}){var r;let l,[i,o]=(0,c.useState)("body"),d=e.logs??[],m=e.cookies??[],x=("console"!==i||d.length)&&("cookies"!==i||m.length)&&("request"!==i||e.sent)&&("checks"!==i||(e.checks??[]).length)?i:"body",p=e.checks??[],f=p.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]),j=!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:j?"Error":`${e.status} ${$[e.status]??""}`.trim()}),(0,t.jsx)(E,{label:"Time",value:`${e.durationMs} ms`}),j?null:(0,t.jsx)(E,{label:"Size",value:`${(0,w.L)(v)}${e.truncated?"+":""}`}),g?(0,t.jsx)(E,{label:"Type",value:g.split(";")[0]??g}):null,p.length?(0,t.jsxs)("button",{type:"button",onClick:()=>o("checks"),className:`rounded-md border px-2 py-0.5 text-xs ${f===p.length?"border-ok/40 text-ok":"border-bad/40 text-bad"}`,children:[f===p.length?"✓":"✕"," ",f,"/",p.length," checks"]}):null,n?(0,t.jsx)("span",{className:s&&!j?"":"ml-auto",children:n}):null,s&&!j?(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)(A,{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)(z,{message:e.error,onWaitLonger:a}):null,j&&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)(h.x,{sent:e.sent})})]}):null,j?null:(0,t.jsxs)("div",{className:"mt-3 flex min-h-0 flex-1 flex-col",children:[(0,t.jsx)(u.i,{id:"response",label:"Response",value:x,onChange:o,items:[{id:"body",label:"Body"},{id:"headers",label:"Headers",badge:b||void 0},...m.length?[{id:"cookies",label:"Cookies",badge:m.length}]:[],...p.length?[{id:"checks",label:"Checks",badge:(0,t.jsxs)("span",{className:f===p.length?"text-ok":"text-bad",children:[f,"/",p.length]})}]:[],...e.sent?[{id:"request",label:"Request sent"}]:[],...d.length?[{id:"console",label:"Console",badge:d.length}]:[]]}),(0,t.jsx)("div",{...(0,u.q)("response",x),className:"flex min-h-0 flex-1 flex-col pt-3",children:"body"===x?e.streamId?(0,t.jsx)(N,{id:e.streamId}):(0,t.jsx)(T,{body:e.body,contentType:g,truncated:e.truncated,url:e.url,base64:e.bodyBase64}):"cookies"===x?(0,t.jsx)(h.B,{cookies:m}):"console"===x?(0,t.jsx)(q,{logs:d}):"request"===x&&e.sent?(0,t.jsx)(h.x,{sent:e.sent}):"checks"===x?(0,t.jsx)("ul",{className:"space-y-1.5",children:p.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})})]})]})},"Z",0,S],60566),e.i(24856);var P=e.i(99112),U=e.i(78451),F=e.i(59780),I=e.i(87078),B=e.i(35559),W=e.i(56003);let _={name:"layers",size:24,node:[["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"}]],aliases:["layers-3"]};_.node;let H=(0,W.f)(_),V={name:"lock",size:24,node:[["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"}]]};V.node;let K=(0,W.f)(V);e.s(["f",0,K],16788);var X=e.i(2810),J=e.i(54812),Z=e.i(1326),G=e.i(62620),Y=e.i(39170),Q=e.i(17847),ee=e.i(37837),et=e.i(80707);e.i(42674);var es=e.i(5305),en=e.i(65238),ea=e.i(48181),er=e.i(6278);let el=()=>globalThis.crypto?.randomUUID?.()??`env-${Date.now().toString(36)}`;function ei({onClose:e,startNew:s=!1}){let n=(0,m.d)(),a=(0,Y.L)(),{environments:l,activeEnv:i,setActiveEnv:o,saveEnvironments:d,index:u}=(0,er.U)(),[x,h]=(0,c.useState)(()=>structuredClone(l)),[p,f]=(0,c.useState)(i?.id??l[0]?.id??null),[b,g]=(0,c.useState)(!1),v=(0,c.useRef)(null),j=x.find(e=>e.id===p)??null,y=JSON.stringify(x)!==JSON.stringify(l);(0,c.useEffect)(()=>{let e=document.activeElement;return s&&w(),v.current?.querySelector("input,button")?.focus(),()=>e?.focus()},[]);let N=(e,t)=>h(s=>s.map(s=>s.id===e?{...s,...t}:s));function w(e){let t=e?{id:el(),name:`${e.name} copy`,variables:structuredClone(e.variables)}:{id:el(),name:x.length?`Environment ${x.length+1}`:"DEV",variables:[{key:"baseUrl",value:"",secret:!1}]};h(e=>[...e,t]),f(t.id)}async function k(){(!y||await a({title:"Discard changes to environments?",confirmLabel:"Discard",tone:"danger"}))&&e()}async function C(){g(!0);try{await d(x),i&&!x.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 k(),children:(0,t.jsxs)("div",{ref:v,role:"dialog","aria-modal":"true","aria-label":"Environments",onKeyDown:e=>"Escape"===e.key&&void k(),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 k(),children:(0,t.jsx)(G.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:[x.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>f(e.id),"aria-current":e.id===p?"true":void 0,className:`block w-full truncate rounded-md px-2 py-1.5 text-left text-sm ${e.id===p?"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:()=>w(),className:"mt-2 inline-flex items-center gap-1 text-xs text-accent hover:underline",children:[(0,t.jsx)(X.f,{size:12,"aria-hidden":!0})," New environment"]})]}),(0,t.jsxs)("section",{className:"min-h-0 space-y-4 overflow-auto p-4",children:[j?(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:j.name,onChange:e=>N(j.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:()=>w(j),children:[(0,t.jsx)(r.f,{size:13})," Duplicate"]}),(0,t.jsxs)("button",{type:"button",className:"btn btn-danger py-1.5 text-xs",onClick:()=>{h(e=>e.filter(e=>e.id!==j.id)),f(x.find(e=>e.id!==j.id)?.id??null)},children:[(0,t.jsx)(Z.f,{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:!!j.production,onChange:e=>N(j.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)(ec,{vars:j.variables,onPatch:(e,t)=>j&&N(j.id,{variables:j.variables.map((s,n)=>n===e?{...s,...t}:s)}),onChange:e=>N(j.id,{variables:e})}),(0,t.jsxs)("p",{className:"flex items-start gap-1.5 text-xs text-mute",children:[(0,t.jsx)(K,{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:()=>w(),children:[(0,t.jsx)(X.f,{size:14})," New environment"]})})]}),(0,t.jsx)(eo,{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 k(),children:"Cancel"}),(0,t.jsx)("button",{type:"button",className:"btn btn-primary text-sm",disabled:!y||b,onClick:()=>void C(),children:"Save environments"})]})]})})}function eo({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.Z.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.f,{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 ec({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)(B.f,{size:13}):(0,t.jsx)(I.f,{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)(G.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)(X.f,{size:12,"aria-hidden":!0})," Add variable"]})]})}e.s(["f",0,function({drafts:e,collections:n=[],compact:a=!1}){let{environments:r,activeEnv:l,setActiveEnv:i,vars:o,savedValues:d,clearSavedValues:u}=(0,er.U)(),m=Object.keys(d),[x,h]=(0,c.useState)(!1),[p,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,es.h)(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,U.n)(n).forEach(s=>!e.has(s)&&t.add(s))}return[...t]},[e]),j=(0,en.K)(n),y=g.filter(e=>!(e in o)&&!j.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=ea.q[(0,ea.v)(l)];return(0,t.jsxs)("div",{className:"flex items-center gap-1 text-xs",children:[y.length?(0,t.jsxs)("span",{role:"status",className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-warn",title:`${y.map(e=>`{{${e}}}`).join(", ")} not defined${l?` in ${l.name}`:" — pick an environment"}`,children:[(0,t.jsx)(v.f,{size:12,"aria-hidden":!0}),(0,t.jsx)("span",{className:"max-w-40 truncate",children:y.map(e=>`{{${e}}}`).join(", ")})]}):null,m.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-mute",title:m.map(e=>`{{${e}}} — saved from “${d[e].from}”`).join("\n"),children:[(0,t.jsxs)("span",{className:"font-mono text-accent",children:[m.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)(G.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":p,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.f,{size:12,className:"shrink-0 text-mute","aria-hidden":!0})]}),(0,t.jsx)(ee.f,{anchor:b,open:p,onClose:()=>f(!1),label:"Environments",width:260,children:(0,t.jsxs)("div",{className:"-m-2",children:[(0,t.jsx)(Q.U,{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?ea.q[(0,ea.v)(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)(F.f,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},e.id||"none")})}),(0,t.jsx)(Q.Z,{}),(0,t.jsx)(Q.d,{icon:X.f,label:"New environment…",onSelect:()=>{f(!1),h("new")}}),(0,t.jsx)(Q.d,{icon:J.f,label:"Manage environments…",onSelect:()=>{f(!1),h("manage")}})]})}),(0,t.jsx)("button",{type:"button",onClick:()=>h("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)(H,{size:14,"aria-hidden":!0})}),x?(0,t.jsx)(ei,{startNew:"new"===x,onClose:()=>h(!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)(et.f,{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:()=>h("manage"),className:"inline-flex items-center gap-1 rounded-md px-1.5 py-1 text-mute hover:text-ink",children:[(0,t.jsx)(J.f,{size:12,"aria-hidden":!0})," Manage"]}),g.length>0?y.length?(0,t.jsxs)("span",{className:"text-warn",role:"status",children:[y.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,m.length?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-mute",title:m.map(e=>`{{${e}}} — saved from “${d[e].from}”`).join("\n"),children:["Saved from answers: ",(0,t.jsx)("span",{className:"font-mono text-accent",children:m.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,x?(0,t.jsx)(ei,{onClose:()=>h(!1)}):null]})},"L",0,ec],68228);var ed=e.i(49257);let eu={name:"file-plus-corner",size:24,node:[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],aliases:["file-plus-2"]};eu.node;let em=(0,W.f)(eu);var ex=e.i(62338),eh=e.i(87891);let ep={name:"folder-input",size:24,node:[["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"}]]};ep.node;let ef=(0,W.f)(ep);var eb=e.i(97471),eg=e.i(59904);let ev={name:"import",size:24,node:[["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"}]]};ev.node;let ej=(0,W.f)(ev);var ey=e.i(77497),eN=e.i(61318),ew=e.i(80714),ek=e.i(92368),eC=e.i(67531),e$=e.i(2552),eS=e.i(53798),eq=e.i(67217),eE=e.i(15556),ez=e.i(74749),eM=e.i(97942),eT=e.i(91549),eR=e.i(41997),eD=e.i(97424),eL=e.i(36e3),eO=e.i(55925),eA=e.i(1359),eP=e.i(22079),eU=e.i(69159),eF=e.i(23227),eI=e.i(24448);function eB({value:e,parents:s,folder:n,onChange:a}){let r,l=(0,eF.l)(),i=[...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=>a(e.target.value||void 0),children:[(0,t.jsx)("option",{value:"",children:i?`From ${i.path}: ${r=i.settings.contract,l?.find(e=>e.id===r)?.name??"a description that was removed"}`:"None"}),l?.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name,e.error?" (doesn't read)":` — ${e.operations} operations`]},e.id))]})]}),l&&!l.length?(0,t.jsx)("p",{className:"text-xs text-mute",children:"There are none in this project yet."}):null,e??i?.settings.contract?(0,t.jsx)(eU._,{id:e??i?.settings.contract,folder:n}):null,(0,t.jsx)("button",{type:"button",className:"text-xs text-accent hover:underline",onClick:()=>(0,eP.A)(e??i?.settings.contract),children:l&&!l.length?"Add an API description…":"API descriptions — add one, and see which operations have a request"})]})}function eW({path:e,onClose:s}){let n=(0,m.d)(),{refresh:a}=(0,er.U)(),[r,l]=(0,c.useState)(null),[i,o]=(0,c.useState)([]),[d,x]=(0,c.useState)([]),[h,p]=(0,c.useState)("auth"),[f,b]=(0,c.useState)(!1);async function g(){if(r&&!f){b(!0);try{await en.X.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([en.X.get(e),en.X.chain((0,U.L)(e))]).then(([e,s])=>{t&&(l(e.settings),o(e.secretsMissing??[]),x(s))}).catch(e=>{t&&(n(e instanceof Error?e.message:"Could not open the folder","error"),l((0,U.I)()))}),()=>{t=!1}},[e,n]);let v=[...d].reverse().find(e=>"inherit"!==e.settings.auth.authMode),j=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.jsxs)("span",{className:"flex shrink-0 items-center gap-1",children:[(0,t.jsx)(eI.U,{topic:"sending-requests#folders-sign-in-once"}),(0,t.jsx)("button",{type:"button","aria-label":"Close",className:"rounded p-1 text-mute hover:text-ink",onClick:s,children:(0,t.jsx)(G.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.i,{id:"folder-settings",label:"Folder settings",value:h,onChange:p,items:[{id:"auth",label:"Auth"},{id:"headers",label:"Headers",badge:j.headers||void 0},{id:"variables",label:"Variables",badge:j.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},{id:"docs",label:"Docs",badge:r.description?.trim()?"✓":void 0}]}),(0,t.jsxs)("div",{...(0,u.q)("folder-settings",h),className:"pt-4",children:["auth"===h?(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)(eR.d,{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,eR.S)(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"===h?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(eL.f,{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"===h?(0,t.jsx)(eO.f,{draft:r,onChange:l,forFolder:!0}):null,"docs"===h?(0,t.jsx)(eA.f,{value:r.description??"",onChange:e=>l({...r,description:e}),forFolder:!0}):null,"contract"===h?(0,t.jsx)(eB,{value:r.contract,parents:d,folder:e,onChange:e=>l({...r,contract:e})}):null,"variables"===h?(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(ec,{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)(eD.f,{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)(eD.f,{size:14,className:"animate-spin"}):null,"Save folder settings"]})]})]})})}var e_=e.i(14168),eH=e.i(2603);let eV={GET:"text-ok",POST:"text-warn",PUT:"text-accent",PATCH:"text-accent",DELETE:"text-bad"},eK="atc:request-moved",eX="application/x-atc-requests";function eJ({activeId:e,onOpen:a,allowDelete:l=!0,newFolder:o,onNewFolderDone:d}){let u=(0,m.d)(),x=(0,Y.L)(),{index:h,refresh:p}=(0,er.U)(),[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)},[h]);let[g,v]=(0,c.useState)(""),[j,y]=(0,c.useState)(new Set),[N,k]=(0,c.useState)(null),[C,$]=(0,c.useState)(null),[S,q]=(0,c.useState)(null),[E,z]=(0,c.useState)(new Set),M=(0,c.useRef)(null),[T,R]=(0,c.useState)(null),[D,L]=(0,c.useState)(null),[O,A]=(0,c.useState)(null),P=h?.requests??[],F=h?.folders??[],I=g.trim().toLowerCase(),B=(0,c.useMemo)(()=>I?P.filter(e=>`${e.name} ${e.collection} ${e.url} ${e.method}`.toLowerCase().includes(I)):P,[P,I]),W=(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,U.g)(e),folders:[],requests:[],summary:null};return a.set(e,s),r((0,U.L)(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})(B,F,!I),[B,F,I]);async function _(e){try{let t=await er.v.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 H(e,t){let s=0;try{for(let n of e){let e=await er.v.get(n),a=t.name?.trim()||e.name,r=t.collection??e.collection;if(a===e.name&&r===e.collection)continue;let l=await er.v.update(n,{name:a,collection:r,request:e.request});window.dispatchEvent(new CustomEvent(eK,{detail:{id:n,name:l.name,collection:l.collection}})),s++}await p(),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 V(e){for(let t of e)await er.v.remove(t).catch(()=>void 0);z(new Set),await p(),u(`${e.length} request${1===e.length?"":"s"} moved to Trash — restore them from Trash in the sidebar`,"success")}(0,c.useEffect)(()=>{o&&k({kind:"new",parent:""})},[o]);let K=e=>l?{onDragOver:t=>{t.dataTransfer.types.includes(eX)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="move",A(e))},onDragLeave:t=>{t.currentTarget.contains(t.relatedTarget)||A(t=>t===e?null:t)},onDrop:t=>{t.preventDefault(),t.stopPropagation(),A(null);try{let s=JSON.parse(t.dataTransfer.getData(eX));Array.isArray(s)&&s.length&&(z(new Set),H(s,{collection:e}))}catch{}}}:{};async function X(e){try{let t=await er.v.create({name:"New request",collection:e,request:(0,es.t)()});y(t=>{let s=new Set(t);return s.delete(e),s}),await p(),await _(t.id),R(t.id)}catch(e){u(e instanceof Error?e.message:"Could not make the request","error")}}async function J(e){try{let t=await er.v.get(e.id);await er.v.create({name:`${e.name} copy`.slice(0,200),collection:e.collection,request:t.request}),await p(),u(`Duplicated “${e.name}”`,"success")}catch(e){u(e instanceof Error?e.message:"Could not duplicate it","error")}}async function Q(e){try{await er.v.remove(e.id),await p(),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 ee(e){if(k(null),d?.(),!N)return;let t=e.trim();if(t)try{if("new"===N.kind){let e=(0,U.y)(N.parent?`${N.parent}/${t}`:t);await en.X.save(e,(0,U.I)()),y(e=>{let t=new Set(e);return t.delete(N.parent),t})}else{let e=(0,U.y)(t.includes("/")?t:(0,U.L)(N.path)?`${(0,U.L)(N.path)}/${t}`:t);e!==N.path&&await en.X.move(N.path,e)}await p()}catch(e){u(e instanceof Error?e.message:"Could not do that","error")}}async function et(e){if(await x({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 en.X.remove(e),await p()}catch(e){u(e instanceof Error?e.message:"Could not delete the folder","error")}}let ea=s=>(0,t.jsx)("ul",{children:s.map(s=>{let n=s.id===e,a=E.has(s.id);return T===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&&R(null)},onBlur:e=>{R(null),H([s.id],{name:e.target.value})}})},s.id):(0,t.jsxs)("li",{draggable:l,onDragStart:e=>{let t=a?[...E]:[s.id];e.dataTransfer.setData(eX,JSON.stringify(t)),e.dataTransfer.effectAllowed="move"},onContextMenu:e=>{l&&(e.preventDefault(),q(`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)){z(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!j.has(t.path)||I||""===t.path?[...t.folders.flatMap(e),...t.requests.map(e=>e.id)]:[]}(W),[s,n]=[e.indexOf(M.current),e.indexOf(t.id)].sort((e,t)=>e-t);if(s>=0)return z(new Set(e.slice(s,n+1)))}z(new Set),M.current=t.id,_(t.id)})(e,s),onKeyDown:e=>{l&&("F2"===e.key?(e.preventDefault(),R(s.id)):"Delete"===e.key?(e.preventDefault(),a&&E.size>1?V([...E]):Q(s)):(e.ctrlKey||e.metaKey)&&"d"===e.key.toLowerCase()&&(e.preventDefault(),J(s)))},"aria-current":n?"true":void 0,"aria-pressed":l&&E.size?a:void 0,title:f[s.id]?`${s.url}
2
+ Earlier answers kept: ${(0,w.L)(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 ${eV[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)(eY,{label:`Actions for ${s.name}`,open:S===`r:${s.id}`,onOpenChange:e=>q(e?`r:${s.id}`:null),items:[{icon:ed.f,label:"Open",hint:"Enter",run:()=>void _(s.id)},{icon:ew.f,label:"Rename",hint:"F2",run:()=>R(s.id)},{icon:r.f,label:"Duplicate",hint:"Ctrl+D",run:()=>void J(s)},{icon:ef,label:"Move to…",run:()=>L([s.id])},"separator",{icon:eg.f,label:"Version history",run:()=>(0,eM.g)(s.id)},{icon:ex.f,label:"Export…",run:()=>(0,eT.q)({kind:"request",id:s.id,name:s.name,collection:s.collection})},"separator",{icon:Z.f,label:"Move to Trash",hint:"Del",run:()=>void Q(s),danger:!0}]}):null]},s.id)})}),el=e=>{var a;let r=j.has(e.path)&&!I,i=(a=e.summary)?[a.auth?(0,eR.S)(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:[N?.kind==="rename"&&N.path===e.path?(0,t.jsx)(eZ,{initial:e.path,label:`New name for ${e.path}`,onDone:e=>void ee(e),hint:"Use / to move it into another folder"}):(0,t.jsxs)("div",{...K(e.path),className:`group/folder flex items-center rounded-md ${O===e.path?"bg-accent-dim ring-1 ring-accent ring-inset":"hover:bg-panel-2"}`,onContextMenu:t=>{l&&(t.preventDefault(),q(`f:${e.path}`))},children:[(0,t.jsxs)("button",{type:"button","aria-expanded":!r,onClick:()=>{let t;return t=e.path,y(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.f,{size:13,"aria-hidden":!0,className:"shrink-0 text-mute"}):(0,t.jsx)(s.f,{size:13,"aria-hidden":!0,className:"shrink-0 text-mute"}),(0,t.jsx)(eh.f,{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)(ey.f,{size:11,className:"shrink-0 text-accent","aria-label":`signs in with ${(0,eR.S)(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)(e$.default,{href:(0,e_.W)(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)(ek.f,{size:12})}),(0,t.jsx)(eQ,{path:e.path,onNewRequest:()=>void X(e.path),open:S===`f:${e.path}`,onOpenChange:t=>q(t?`f:${e.path}`:null),onSettings:()=>$(e.path),onNewInside:()=>k({kind:"new",parent:e.path}),onRename:()=>k({kind:"rename",path:e.path}),onDelete:()=>void et(e.path)})]}):null]}),r?null:(0,t.jsxs)("div",{className:"ml-[0.9rem] border-l border-line pl-1",children:[N?.kind==="new"&&N.parent===e.path?(0,t.jsx)(eZ,{initial:"",label:`New folder in ${e.path}`,onDone:e=>void ee(e)}):null,e.folders.map(el),ea(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.f,{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"})]}),E.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:[E.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([...E]),children:(0,t.jsx)(ef,{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,eT.q)({kind:"requests",ids:[...E]}),children:(0,t.jsx)(ex.f,{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 V([...E]),children:(0,t.jsx)(Z.f,{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:()=>z(new Set),children:(0,t.jsx)(G.X,{size:14,"aria-hidden":!0})})]}):null,(0,t.jsxs)("div",{...K(""),className:`min-h-0 flex-1 overflow-auto rounded-md ${""===O?"bg-accent-dim/30 ring-1 ring-accent/60 ring-inset":""}`,children:[N?.kind==="new"&&""===N.parent?(0,t.jsx)(eZ,{initial:"",label:"New folder",onDone:e=>void ee(e),hint:"Use / for a folder inside another: Orders/Admin"}):null,0===P.length&&0===F.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,eq.F)(),className:"text-accent hover:underline",children:"Import your requests"})]}),(0,t.jsxs)("p",{children:["Or"," ",(0,t.jsx)("button",{type:"button",onClick:()=>(0,eE.W)(),className:"text-accent hover:underline",children:"start from a template"})," ","— ready-made requests that run straight away."]})]}):I&&0===B.length?(0,t.jsx)("p",{className:"px-1 py-4 text-xs text-mute",children:"Nothing matches."}):(0,t.jsxs)(t.Fragment,{children:[W.folders.map(el),ea(W.requests)]})]}),C?(0,t.jsx)(eW,{path:C,onClose:()=>$(null)}):null,D?(0,t.jsx)(eG,{count:D.length,folders:[...new Set([...F.map(e=>e.path),...P.map(e=>e.collection)].filter(Boolean))].sort(),onPick:e=>{L(null),z(new Set),H(D,{collection:e})},onClose:()=>L(null)}):null]})}function eZ({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 eG({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)(ef,{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)(G.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)(eh.f,{size:14,className:"shrink-0 text-mute","aria-hidden":!0}),(0,t.jsx)("span",{className:"truncate",children:e})]})},e))]})]})})}function eY({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)(eN.f,{size:13})}),(0,t.jsx)(ee.f,{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)(Q.Z,{},s):(0,t.jsx)(Q.d,{icon:e.icon,label:e.label,hint:e.hint,danger:e.danger,onSelect:()=>{n(!1),e.run()}},e.label))})})]})}function eQ({path:e,open:s,onOpenChange:n,onNewRequest:a,onSettings:r,onNewInside:l,onRename:i,onDelete:o}){let d=(0,c.useRef)(null),u=(0,eS.useRouter)(),m=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)(eN.f,{size:13})}),(0,t.jsx)(ee.f,{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)(Q.d,{icon:em,label:"New request here",onSelect:m(a)}),(0,t.jsx)(Q.d,{icon:eb.f,label:"New folder inside",onSelect:m(l)}),(0,t.jsx)(Q.Z,{}),(0,t.jsx)(Q.d,{icon:ek.f,label:"Run this folder",onSelect:m(()=>u.push((0,e_.W)(e)))}),(0,t.jsx)(Q.d,{icon:eC.f,label:"Mock server for this folder",onSelect:m(()=>(0,ez.o)(e))}),(0,t.jsx)(Q.d,{icon:J.f,label:"Folder settings",onSelect:m(r)}),(0,t.jsx)(Q.Z,{}),(0,t.jsx)(Q.d,{icon:ew.f,label:"Rename or move",onSelect:m(i)}),(0,t.jsx)(Q.d,{icon:ex.f,label:"Export…",onSelect:m(()=>(0,eT.q)({kind:"folder",path:e}))}),(0,t.jsx)(Q.Z,{}),(0,t.jsx)(Q.d,{icon:Z.f,label:"Delete folder",danger:!0,onSelect:m(o)})]})})]})}async function e0(e,t,s,n){let a,r,l=t.before;if(!l)return e;try{a=await er.v.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,en.c)({...(0,es.i)(a.request),before:null,testData:null},a.collection,s);r=(0,es.x)(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,es.d)({...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(["C",0,eK,"M",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)(eh.f,{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)(eJ,{allowDelete:!1,onOpen:t=>{e(t),n(!1)}})}):null]})},"N",0,function({activeId:e,onOpen:s,onNew:n}){let[a,r]=(0,c.useState)(!1),l=(0,eH.P)();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)(em,{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)(eb.f,{size:14})}),(0,t.jsx)("button",{type:"button",onClick:()=>(0,eq.F)(),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)(ej,{size:14})})]})]}),(0,t.jsx)(eJ,{activeId:e,onOpen:s,newFolder:a,onNewFolderDone:()=>r(!1)})]})},"Z",0,function({initial:e,onSave:s,onCancel:n}){let{index:a}=(0,er.U)(),[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)(G.X,{size:14})})]})}],65638),e.s(["f",0,e0],46679)},92001,e=>{var t=e.i(56003);let s={name:"unplug",size:24,node:[["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"}]]};s.node;let n=(0,t.f)(s);e.s(["f",0,n],92001)}])})();