@specbook/ui 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,41 @@
1
+ import{_ as e,a as t,d as n,f as r,g as i,h as a,m as o,p as s,u as c,y as l}from"./panel-nV09I7Wr.js";import{i as u}from"./mount-CLHBtIzR.js";import{d,i as f,l as p}from"./registry-b_jzfqy0.js";import{A as m,C as h,D as g,E as _,M as v,N as y,O as b,S as x,T as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as ee,l as te,m as ne,n as re,o as ie,p as ae,r as N,s as P,u as F,v as I,w as oe,x as se,y as L}from"./main-i06Egg5h.js";var R={200:`OK`,201:`Created`,202:`Accepted`,204:`No Content`,301:`Moved Permanently`,302:`Found`,304:`Not Modified`,400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,422:`Unprocessable Entity`,429:`Too Many Requests`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`},ce=e=>R[e]??``;function le(e){if(typeof e==`string`)return e.includes(`
2
+ `)?e.split(`
3
+ `):[JSON.stringify(e)];if(e===void 0)return[`undefined`];try{return(JSON.stringify(e,null,2)??String(e)).split(`
4
+ `)}catch{return[String(e)]}}function ue(e,t){let n=[];if(e.length*t.length>25e4){for(let t of e)n.push({kind:`expected`,text:t});for(let e of t)n.push({kind:`received`,text:e});return n}let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=0,s=0;for(;o<r&&s<i;)e[o]===t[s]?(n.push({kind:`same`,text:e[o]}),o++,s++):a[o+1][s]>=a[o][s+1]?n.push({kind:`expected`,text:e[o++]}):n.push({kind:`received`,text:t[s++]});for(;o<r;)n.push({kind:`expected`,text:e[o++]});for(;s<i;)n.push({kind:`received`,text:t[s++]});return n}function de(e,t){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.kind!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=0,a=()=>{i>0&&r.push({kind:`skip`,text:`… ${i} unchanged line${i>1?`s`:``}`}),i=0};return e.forEach((e,t)=>{n[t]?(a(),r.push(e)):i++}),a(),r}function fe(e,t=3){if(e.operator===`status`){let t=typeof e.actual==`number`?`${e.actual} ${ce(e.actual)}`.trim():String(e.actual);return[{kind:`expected`,text:`status ${e.expected}`},{kind:`received`,text:`status ${t}`}]}return`expected`in e||`actual`in e?de(ue(le(e.expected),le(e.actual)),t):e.diff?e.diff.split(`
5
+ `).map(e=>({kind:`same`,text:e})):[]}var z=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function pe(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:z(t),enabled:!0})))}function me(e){let t={};for(let{key:n,value:r,enabled:i}of e){if(!i||n===``)continue;let e=t[n];t[n]=e===void 0?r:[...Array.isArray(e)?e:[e],r]}return t}function he(e){return typeof e!=`object`||!e?[]:v(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var ge=/[^[\]]+|\[\]/g;function _e(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?_e(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?_e(o,i,n):o===void 0?n:[...[].concat(o),n],a}function ve(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=_e(t,n.match(ge)??[n],a&&y(a)?a:r));return t}var ye=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,be=e=>new RegExp(ye.source).test(e),xe=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function Se(e){let t=[],n=0;for(let r of e.matchAll(ye))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?xe(r[1]):`SESSION_${xe(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var Ce=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${we(e)}`);return t.length?`?${t.join(`&`)}`:``};function we(e){return Se(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function B(e){if(y(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var Te=e=>e.name??e.file??`file`,Ee=e=>`'${e.replace(/'/g,`'\\''`)}'`;function V(e){return be(e)?`"${Se(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:Ee(e)}function De(e){let t=e.encoding??`json`,n=[V(`${e.url}${Ce(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${V(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of v(o,e.formArrays))s.push(`--data-urlencode ${V(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(B(n)?s.push(`-F ${V(`${e}=@${Te(n)}`)}`):s.push(`-F ${V(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${V(`@${B(o)?Te(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=B(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${V(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${V(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
6
+ `)}`}var Oe=/^[A-Za-z_$][\w$]*$/;function H(e){return be(e)?`\`${Se(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var U=e=>Oe.test(e)?e:H(e);function ke(e,t){if(e==null)return`null`;if(typeof e==`string`)return H(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${ke(e,n)},`).join(`
7
+ `)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${U(e)}: ${ke(t,n)},`).join(`
8
+ `)}\n${t}}`}function Ae(e){let t=e.encoding??`json`,n=e.method.toUpperCase(),r={...e.headers??{}},i=e=>Object.keys(r).some(t=>t.toLowerCase()===e),a=e.body,o=a!==void 0&&a!==``&&t!==`none`,s=[],c,l=!1;if(o){if(t===`json`||t===`graphql`)c=`JSON.stringify(${ke(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=v(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${ke(Object.fromEntries(t),` `)})`:`new URLSearchParams(${ke(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(B(n)){l=!0;let t=Te(n);s.push(`form.append(${H(e)}, await openAsBlob(${H(t)}), ${H(t)})`)}else s.push(`form.append(${H(e)}, ${H(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${H(B(a)?Te(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=B(a)&&a.type?a.type:`application/octet-stream`)):(c=H(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${Ce(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${H(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${U(e)}: ${H(t)},`).join(`
9
+ `)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${H(u)})`:`const res = await fetch(${H(u)}, {\n${d.join(`
10
+ `)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
11
+ `)}function je(e,t){return e===`curl`?De(t):Ae(t)}var Me=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],W=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`);function Ne(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function Pe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
12
+ `).split(`
13
+ `),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${Ne(W(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${Ne(W(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${W(r.join(`
14
+ `))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${Ne(W(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${Ne(W(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function Fe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function Ie(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function Le(e){return e?Ne(W(e)):``}function Re(e,t=300){let n=Ie(e);if(!n)return``;let r=Fe(n);return r.length>t?W(`${r.slice(0,t-1).trimEnd()}…`):Le(n)}var G=/^\s*\{\{[^}]+\}\}\s*$/,ze=e=>typeof e==`string`&&G.test(e);function Be(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Ve=[`title`,`description`,`default`,`examples`,`deprecated`];function He(e,t){let n={...e};for(let e of Ve)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function K(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=He(r,n)}return n}function q(e,t,n=0){let r=K(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!Be(e));if(e.length===1||e.length>1)return q(He(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(He(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=q(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of Ve)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function J(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function Ue(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function We(e,t=120){if(!e)return;let n=e.split(/\n+/)[0],r=(n.match(/^.*?[.!?](\s|$)/)?.[0]?.trim()??n).replace(/\s+/g,` `);return r.length>t?`${r.slice(0,t-1)}…`:r}function Ge(e,t){let n=q(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function Ke(e,t,n){let r=q(e,n);if(typeof t==`number`)return r.items;if(r.properties?.[t])return r.properties[t];if(r.additionalProperties&&typeof r.additionalProperties==`object`)return r.additionalProperties}var qe=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Je(e,t,n){let r=K(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!Be(e));if(!i?.length)return q(r,n);let a=qe(t);return q(He(i.find(e=>{let t=J(q(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Ye(e,t,n,r={},i=``,a=0){if(!t||a>12||ze(e))return[];let o=Je(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&J(o)!==`null`&&J(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${J(o)}, got null`}),s;let u=J(o),d=qe(e);switch(u){case`object`:{if(d!==`object`)return[{path:c,kind:`type`,message:`expected object, got ${d}`}];let t=e,l=o.properties??{};for(let e of o.required??[])e in t||s.push({path:i?`${i}.${e}`:e,kind:`required`,message:`required field is missing`});for(let[e,c]of Object.entries(t)){let t=i?`${i}.${e}`:e;l[e]?s.push(...Ye(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ye(c,o.additionalProperties,n,r,t,a+1)):r.reportExtra&&o.additionalProperties!==!0&&Object.keys(l).length>0&&s.push({path:t,kind:`extra`,message:`not in the spec`})}return s}case`array`:return d===`array`?(e.forEach((e,t)=>{s.push(...Ye(e,o.items,n,r,`${i}[${t}]`,a+1))}),s):[{path:c,kind:`type`,message:`expected array, got ${d}`}];case`string`:return d===`string`?(o.enum&&!o.enum.includes(e)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s):[{path:c,kind:`type`,message:`expected string, got ${d}`}];case`integer`:case`number`:{if(d!==`number`)return[{path:c,kind:`type`,message:`expected ${u}, got ${d}`}];let t=e;return u===`integer`&&!Number.isInteger(t)&&s.push({path:c,kind:`type`,message:`expected an integer`}),o.minimum!==void 0&&t<o.minimum&&s.push({path:c,kind:`range`,message:`must be ≥ ${o.minimum}`}),o.maximum!==void 0&&t>o.maximum&&s.push({path:c,kind:`range`,message:`must be ≤ ${o.maximum}`}),o.enum&&!o.enum.includes(t)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s}case`boolean`:return d===`boolean`?[]:[{path:c,kind:`type`,message:`expected boolean, got ${d}`}];default:return[]}}var Xe=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Ze(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
15
+ `)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
16
+ `;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function Qe(e,t,n){let r=e;for(let e of t){if(!r)return;r=Ke(r,e,n)}return r}var $e={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,301:`Moved`,304:`Not modified`,400:`Bad request`,401:`Unauthorized`,402:`Payment required`,403:`Forbidden`,404:`Not found`,405:`Invalid input`,409:`Conflict`,410:`Gone`,412:`Precondition failed`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`},et=e=>$e[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),tt=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,nt=new Set([`path`,`query`,`headers`,`data`]),rt=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function it(e,t){return[e,...rt(t)].join(`.`)}function at(e){let t=rt(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&nt.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var ot=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`);function st(e){let t=new Map;if(!e)return{intro:e,notes:t};let n=[];for(let r of e.split(/(?=<h[1-6][ >])/)){let e=/^<h([1-6])[^>]*>\s*<code>([^<]+)<\/code>\s*<\/h\1>/.exec(r),i=e?at(ot(e[2])):void 0;if(e&&i){let n=t.get(i),a=r.slice(e[0].length);t.set(i,n?n+a:a)}else n.push(r)}return{intro:n.join(``),notes:t}}var ct=60;function lt(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function ut(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Ge(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:lt(e,t),required:a.required,description:Ue(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=J(e)===`array`?q(e.items,t):e;J(s)===`object`&&i.push(...ut(s,t,n+1,o))}return i}function dt({schema:e,defs:n,section:r=`data`,notes:i}){let a=ut(e,n);return a.length===0?null:t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Field`}),t(`th`,{children:`Type`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:[a.slice(0,ct).map(e=>t(`tr`,{children:[t(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[t(`code`,{children:e.name.split(`.`).pop()}),e.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}),t(`td`,{children:t(`span`,{class:`chip`,children:e.type})}),t(`td`,{children:[t(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:Re(e.description,220)}}),i?.get(it(r,e.name))&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(it(r,e.name))}}),e.enum&&t(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>t(`code`,{children:e}))]})]})]})),a.length>ct&&t(`tr`,{children:t(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-ct,` more fields in the spec`]})})]})]})}var ft={intro:``,notes:new Map,replace:!1,found:!1};function pt(e){let[t,r]=a(),[i,s]=a(!1),c=w.docs.find(t=>t.operation===e);return n(()=>{let e=!0;return r(void 0),s(!c),c?.load().then(t=>e&&r(t)).catch(()=>{}).finally(()=>e&&s(!0)),()=>{e=!1}},[e,c]),o(()=>!c||t===void 0?{...ft,loaded:i}:{...st(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var mt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],ht=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function gt(e,t,n){return Promise.all([ht(w.operationDocs[e]?.().then(e=>e.default)),ht(w.schemas[e]?.().then(e=>e.default)),ht(w.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>ht(w.docs.find(t=>t.requestFile===e)?.load())))]).then(([e,t,r,i])=>({long:e,req:t,defs:r,saved:Object.fromEntries(n.flatMap((e,t)=>i[t]?[[e,i[t]]]:[]))}))}function _t({variant:e,html:n}){return n?t(`section`,{class:`saved-note-doc`,children:[t(`h2`,{children:[`Request `,t(`code`,{children:e.name})]}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:n}})]}):null}function vt({service:e,op:r,variants:i=[],onTry:o}){let s=`${e}/${r.id}`,[c,u]=a(),d=i.map(e=>e.file).join(`
17
+ `);n(()=>{let t=!0;return u(void 0),gt(s,e,d?d.split(`
18
+ `):[]).then(e=>t&&u(e)),()=>{t=!1}},[s,e,d]);let f=pt(s),p=!!c&&f.loaded,{long:m,req:h,defs:g}=c??{saved:{}},_=h?q(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return t(`article`,{class:`doc`,"data-op":s,children:[t(`div`,{class:`doc-intro`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path}),t(`span`,{class:`spacer`}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&t(l,{children:[!(f.found&&f.replace)&&m?.description&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:Pe(m.description)}}),f.intro&&t(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>t(_t,{variant:e,html:c?.saved[e.file]},e.file)),mt.map(([e,n])=>v(e)?t(`section`,{children:[t(`h2`,{children:[n,` parameters`]}),t(dt,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&t(`section`,{children:[t(`h2`,{children:`Request body`}),t(dt,{schema:y,defs:g,section:`data`,notes:f.notes})]}),r.statuses.length>0&&t(`section`,{children:[t(`h2`,{children:`Responses`}),t(`ul`,{class:`statuses`,children:r.statuses.map(e=>t(`li`,{children:[t(`span`,{class:`state-badge ${tt(e)}`,children:e}),` `,et(e)]}))})]}),(m?.examples.length??0)>1&&t(`section`,{children:[t(`h2`,{children:`Examples`}),t(`ul`,{class:`examples`,children:m?.examples.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var yt=c(``);function bt(e){if(e.kind===`request`){let t=e.steps.find(e=>e.response)??e.steps[0];if(!t?.response)return e.status===`error`?`The request could not be sent.`:`Done.`;let n=t.assertions.filter(e=>!e.pass).length;return`${t.response.status}, ${e.durationMs} milliseconds${n?`, ${n} check${n===1?``:`s`} failed`:``}.`}return`Flow ${e.status===`pass`?`passed`:e.status===`fail`?`failed`:`could not run`}, ${e.totals.passed} of ${e.totals.steps} steps passed.`}var xt=class extends e{state={};componentDidCatch(e){console.error(`specbook: a panel could not be drawn`,e),this.setState({error:e instanceof Error?e:Error(String(e))})}render(){let{error:e}=this.state;return e?t(`div`,{class:`panel-error`,role:`alert`,children:[t(`p`,{children:[t(`strong`,{children:`This could not be shown.`}),` The run finished, but what it returned could not be drawn.`]}),t(`pre`,{children:e.message}),t(`button`,{type:`button`,class:`btn`,onClick:()=>this.setState({error:void 0}),children:`Try drawing it again`})]}):this.props.children}},St=0,Ct=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function wt({title:e,subtitle:i,flush:a,modal:c=!0,variant:u=`side`,onPrev:d,onNext:f,onClose:p,children:m}){let h=s(null),g=o(()=>`sb-panel-title-${++St}`,[]);return n(()=>()=>{yt.value=``},[]),n(()=>{let e=h.current?.getRootNode()?.activeElement;return c&&h.current?.focus(),()=>e?.focus?.()},[c]),n(()=>{let e=h.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=e.getAttribute(`role`)===`combobox`,c=r+i*(s?.3:.2);(o>r+i*(s?.55:.4)||o<r)&&(t.scrollTop+=o-c)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s),l=typeof visualViewport>`u`?void 0:visualViewport,u=s.getBoundingClientRect().top>(l?.offsetTop??0)+(l?.height??innerHeight)*.55;c&&r?.box!==c&&(s.getAttribute(`role`)!==`combobox`||u)&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),r(()=>{let e=e=>{if(e.key===`Escape`&&p(),e.key!==`Tab`||!c||!h.current)return;let t=[...h.current.querySelectorAll(Ct)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=h.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===h.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))},t=c&&h.current?h.current:window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)},[p,c]),t(l,{children:[c&&t(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:p}),t(`section`,{class:`panel ${c?``:`docked`} ${u===`popover`?`popover`:``}`,part:`panel`,"aria-labelledby":g,"aria-modal":c?!0:void 0,role:c?`dialog`:`complementary`,tabIndex:-1,ref:h,children:[t(`header`,{class:`panel-head`,part:`header`,children:[t(`div`,{class:`panel-title`,children:[t(`h2`,{id:g,children:e}),i&&t(`div`,{class:`muted small`,children:i})]}),t(`span`,{class:`spacer`}),c&&D.value.length>1&&t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Environment`}),t(`select`,{value:P.value,onChange:e=>P.value=e.target.value,children:D.value.map(e=>t(`option`,{value:e,title:F.value[e],children:e}))})]}),(d||f)&&t(`span`,{class:`stepper`,children:[t(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!d,onClick:d,children:`↑`}),t(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!f,onClick:f,children:`↓`})]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:p,children:`×`})]}),t(`div`,{class:`panel-body ${a?`flush`:``}`,children:t(xt,{children:m})}),t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:yt.value})]})]})}function Tt(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:Qe(e,i,t);if(!a)return;let o=q(a,t);if(n.length===0){let e=typeof o.description==`string`?o.description.trim():``;return e?{path:typeof o.title==`string`&&o.title.trim()?o.title.trim():`body`,type:J(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=Qe(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Xe(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Ge(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:Ue(o),parent:c?Ue(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Et(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function Dt(e,t,n,r){let i=e&&t?.get(it(n,r));return e&&i?{...e,note:i}:e}var Ot={},kt=Symbol(),At=Symbol(),jt=e=>typeof e==`string`?Mt[e]:e,Mt={plain:Ot,plaintext:Ot,text:Ot,txt:Ot},Nt=(e,t)=>(t[At]||Pt)(e,t),Pt=(e,t)=>{for(var n=[e],r,i=[],a=0;r=jt(t[kt]);)delete t[kt],Object.assign(t,r);for(Vt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},Ft=(e,t,n)=>e.replace(/&/g,`&amp;`).replace(t,n),It=`</span>`,Lt=``,Rt=``,zt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=Bt(n);return t},Bt=e=>{if(e instanceof Ht){var{type:t,alias:n,content:r}=e,i=Lt,a=Rt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;Rt+=It,Lt+=o;var s=Bt(r);return Lt=i,Rt=a,o+s+It}return typeof e==`string`?(e=Ft(e,/</g,`&lt;`),Rt&&e.includes(`
19
+ `)?e.replace(/\n/g,Rt+`
20
+ `+Lt):e):zt(e)},Vt=(e,t,n,r,i)=>{for(var a in t)if(t[a])for(var o=0,s=t[a],c,l=Array.isArray(s)?s:[s];c=l[o];o++){if(i&&i[0]==a&&i[1]==o)return;for(var u=c.pattern||c,d=jt(c.inside),f=c.lookbehind,p=u.global,m=c.alias,h=n,g=r;h&&(!i||g<i[2]);g+=h[0].length,h=h[1]){var _=h[0],v=0,y;if(!(_ instanceof Ht)){if(u.lastIndex=p?g:0,y=u.exec(p?e:_),!y&&p)break;if(y&&y[0]){var b=f&&y[1]?y[1].length:0,x=y.index+b,S=y[0].slice(b),C=x+S.length,w,s;if(p){for(;s=g+h[0].length,x>=s;h=h[1],g=s);if(h[0]instanceof Ht)continue;for(w=h,s=g;(s+=w[0].length)<C;w=w[1],v++);_=e.slice(g,s),x-=g,C-=g}for(var T=_.slice(C),E=g+_.length,D=new Ht(a,d?Nt(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof Ht?O=[T,O]:O[0]=T+O[0]),g+=x,h[0]=x?_.slice(0,x):D,x?h=h[1]=[D,O]:h[1]=O,v&&(Vt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Ht(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Ut=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Xt(),m=p.firstChild,h=m.children,g=h[0],_=g.firstChild,v={language:`text`,value:o},y=new Set(n),b={},x=e=>{Object.assign(v,e);let t=o!=(o=e.value??o),n=r!=(r=v.language);d=!!v.readOnly,p.style.tabSize=v.tabSize||2,_.inputMode=d?`none`:``,_.setAttribute(`aria-readonly`,d),w(),C(),t&&(c||_.remove(),_.value=o,_.selectionEnd=0,c||g.prepend(_)),(t||n)&&S()},S=()=>{u=Nt(o=_.value,Mt[r]||{}),O(`tokenize`,u,r,o);let e=zt(u).split(`
21
+ `),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
22
+ `;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=Jt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},A={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Zt=null,c=!1,w()}),Y(_,`focus`,()=>{Zt=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),qt(e)?.append(p),t&&x(t),A},Wt=`u`>typeof window?document:null,Gt=Wt?.createElement(`div`),Kt=(e,t)=>(Gt&&(Gt.innerHTML=e,t=Gt.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),qt=e=>typeof e==`string`?Wt.querySelector(e):e,Jt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
23
+ `,t)+1)&&t<=n;r++);return r},Yt={},Xt=Kt(`<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>`),X=e=>{e.preventDefault(),e.stopImmediatePropagation()},Zt;Wt&&Y(Wt,`selectionchange`,()=>Zt?.());var Qt=(e,t,n=0)=>{let r=e.container.style;r.setProperty(`--_sp`,`var(--pce-scroll-padding, 2ch)`),r.scrollPaddingBlock=`calc(var(--_sp) + ${n}px) calc(var(--_sp) + ${hn&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},$t=(e,t)=>t?e.lastIndexOf(`
24
+ `,t-1)+1:0,en=(e,t)=>(t=e.indexOf(`
25
+ `,t))+1?t:e.length,tn=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),nn=(e,t,n,r)=>tn(e.textarea,t,n,r),rn=(e,t)=>parseFloat(getComputedStyle(e)[t]),an=(e,t)=>{let n=t.getBoundingClientRect(),r=e.lines[0].getBoundingClientRect();return{top:n.y-r.y,bottom:r.bottom-n.bottom,left:n.x-r.x,right:r.right-n.right,height:n.height}},on=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var sn,cn=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),ln=(e,t)=>e.slice($t(e,t),t),un=(e,t,n=t)=>[e.slice(t=$t(e,t),n=en(e,n)).split(`
26
+ `),t,n],dn=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[Jt(a,0,i)],s=Wt.createTreeWalker(o,5),c=s.lastChild(),l=en(a,i)+1-i-c.length;for(;-l<=r&&(c=s.previousNode());)if(!c.lastChild&&(l-=c.length||0,l<=n)){for(;c!=o;c=c.parentNode)if(c.matches?.(t))return c}},fn=(e,t)=>dn(e,`[class*=language-]`,0,0,t)?.className.match(/language-(\S*)/)[1]||e.options.language,Z=(e,t,n,r,i,a)=>{if(e.options.readOnly)return;sn=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=hn&&!s[r??sn[1]]&&/\n$/.test(t)&&/^$|\n$/.test(s),l;e.focused||o.focus(),n!=null&&o.setSelectionRange(n,r),i!=null&&(l=e.on(`update`,()=>{o.setSelectionRange(i,a??i,sn[2]),l()})),gn||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),hn||gn?(c&&(o.selectionEnd--,t=t.slice(0,-1)),gn&&(t+=`
27
+ `),Wt.execCommand(t?`insertHTML`:`delete`,!1,Ft(t,/</g,`&lt;`)),c&&o.selectionStart++):Wt.execCommand(t?`insertText`:`delete`,!1,t),sn=0},pn=(e,t,n=t,r)=>{let i=e.textarea,a=tn(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},mn=Wt?navigator.userAgent:``,Q=Wt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,hn=/Chrome\//.test(mn),gn=!hn&&/AppleWebKit\//.test(mn),_n=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,vn=(e,t)=>e.lines[0].append(t),yn=Kt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),bn=Kt(`<span> `),xn=Kt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),Sn=(e,t,n=!0)=>{let r=xn(),i=r.style,a=r.firstChild;return r.append(t),(n?t:a).style.flexShrink=0,[t=>{let n=e.extensions.cursor?.getPosition();if(n){r.parentNode||vn(e,r),a.style.width=(e.options.rtl?n.right:n.left)+`px`;let o=n.top,s=n.bottom,c=!t==o>s&&(t?o:s)<r.clientHeight?!t:t,l=n.height+(c?s:o)+`px`;i.bottom=c?l:`auto`,i.top=c?`auto`:l}},()=>r.remove()]};window.ResizeObserver;var Cn=(e,t,n)=>{let r=e.childNodes,i=r.length-1,a=0,o=0,s=t.length;for(;o<s;)o>=i&&r[o].before(``,bn()),on(r[o],n.slice(a,a=t[o++])),on(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();on(r[s],n.slice(a))},wn=0,Tn=Kt(`<div class="pce-ac-wrapper pce-ac-top"><div class=pce-ac-tooltip><ul role=listbox></ul></div><div class=pce-ac-docs tabindex=-1><button class=pce-ac-close tabindex=-1 title=Close></button><button class=pce-ac-toggle tabindex=-1 title="Read More"></button><div class=pce-ac-content>`),En=Kt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),Dn={},On=(e,t)=>{e.forEach(e=>Dn[e]=t)},kn=e=>{let t=(n,r)=>{let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=n.container,T=n.textarea,E=n.getSelection,D=Tn(),O=yn(),[k,A]=Sn(n,D),[j,M]=D.children,[ee,te,ne]=M.children,re=j.firstChild,ie=re.id=`pce-ac-`+wn++,ae=re.children,N=[],P=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},F=()=>{f=rn(ae[0],`height`)},I=e=>{let t=o[e+d],[n,r,i]=ae[e].children,a=t[4],s=a.icon||`variable`;Cn(r,t[1],a.label),on(i.firstChild.firstChild,a.detail||``),N[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${N[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),ae[e].setAttribute(`aria-posinset`,e+d)},oe=()=>{F();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,R(),se()},se=()=>{let e=l;l=ae[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),te.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(te),b=!b,ge()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},L=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,oe()},R=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)I(e++);re.style.paddingTop=d*f+`px`},ce=e=>le(o[e][4],o[e][2],o[e][3]),le=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
28
+ `+ln(n.value,u).match(/\s*/)[0],i=r.insertSpaces==0?` `:` `.repeat(r.tabSize||2),a=o.slice();s=s.replace(/\n| /g,(n,r)=>{let s=n==` `?i:e,l=s.length-1,u=0;for(;u<c;)a[u]>r+t&&(o[u]+=l),u++;return s})}else s=a;c%2&&(o[c]=o[c-1]),Z(n,s,t,i,o[0],o[1]),c>2?(p||vn(n,O),p=o,m=0,g=n.value.length,z(),h=E(),ue()):n.extensions.cursor?.scrollIntoView()},ue=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},de=e=>{m+=e,pn(n,p[m],p[m+1]),ue()},fe=()=>{O.remove(),p=null},z=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),Cn(O,e.flat(),n.value)},pe=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=rn(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},me=()=>{D.className=`pce-ac-wrapper pce-ac-${pe()}`},he=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,ne.textContent=``,ne.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,ie+`d`))},ge=()=>{b?M.remove():he(),b=!b},_e=t.startQuery=t=>{let[a,l,p]=E(),m=fn(n,u=p<`f`?a:l),h=Dn[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=ln(r,u),p=r.slice(0,u),_=e.filter;if(x={before:p,lineBefore:a,language:m,explicit:!!t,pos:u},Object.assign(x,h.context?.(x,n)),o=[],h.sources.forEach(e=>{let t=e(x,n),r=t?.from;t?.options.forEach(e=>{let n=_(p.slice(e.from??r),e.label);n&&(n[0]+=e.boost||0,n.push(r,t.to??l,e),o.push(n))})}),o[0]){o.sort((e,t)=>t[0]-e[0]||e[4].label.localeCompare(t[4].label)),s=o.length,c=d=0;for(let e=0,t=s<13?s:13;e<t;)ae[e].setAttribute(`aria-setsize`,s),I(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}re.style.paddingTop=``,re.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,se(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,ie),T.setAttribute(`aria-haspopup`,`listbox`)}else P()}else P()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)re.append(En()),ae[e].id=ie+`-`+e++;Y(j,`scroll`,()=>{F(),R()||se()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)fe();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));z()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&fe()}a?(a=!1,_e()):(S!=e||C!=t)&&P(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!sn&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&ce(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!sn||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&P()}),Y(T,`keydown`,e=>{let t=e.key,n=_n(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?ge():_e(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(L(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(ce(c),P(),X(e)):t==`Escape`?(P(),X(e)):t.slice(0,4)==`Page`&&(F(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),oe(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(de(-2),X(e)):(de(2),X(e)):!n&&t==`Escape`&&(fe(),X(e)))},!0),Y(re,`mousedown`,e=>{e.target!=te&&(ce([].indexOf.call(ae,e.target.closest(`li`))+d),P()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&P()}),Y(w,`scroll`,()=>{i&&me()}),Y(ee,`click`,ge),Y(ee,`mousedown`,X),Y(te,`click`,ge),M.id=ie+`d`,te.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},An=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return jn(e,t);let i=e.toLowerCase(),a=t.toLowerCase(),o=[],s=a.indexOf(i),c=0,l=0,u=0,d=0;for(;l<r;){let n=s>-1?l+s:a.indexOf(i[l],u),r=n>u;if(n<0)return;r&&(c-=800),(r||!d)&&(o[d]=n,d+=2),o[d-1]=u=n+1,e[l++]!=t[n]&&(c-=100)}return[r<n?c-100:c,o]},jn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;let i=t.slice(0,r),a=i==e?0:e.toLowerCase()==i.toLowerCase()?-200:null;if(a!=null)return[e?r<n?a-100:a:0,[0,r]]},Mn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Hn[e]||0;return t+`+`+r},Nn=e=>{if(!Bn[48]){for(let e=48;e<91;e++)Bn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)Bn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=_n(e),r=Bn[e.keyCode],i=Vn[e.keyCode],a=n>7,o=(Q&&n==12||t==`Dead`||t==`Unidentified`)&&(a&&i||r)||t.toLowerCase(),s=/\w\w| /.test(o.slice(0,2)),c=n&7,l=new Set([`${s||/\p{L}/u.test(o)?n:c}+${o}`]);return s||(c&&!(Q&&c==1)&&r?(l.add(n+`+`+r),a&&i&&l.add(c+`+`+i)):a&&l.add(n+`+`+o)),l},Pn=new WeakMap,Fn=(e,t,n)=>{let r=new Set,i;try{for(let a of Nn(e)){i||=a;for(let i of t[a]||[])for(let t of i||[])if(!r.has(t)){if(t(n,e,a))return X(e),!0;r.add(t)}}}finally{t.any?.forEach(t=>t?.forEach(t=>t(n,e,i)))}},In=e=>{let t=Pn.get(e);return t||(Pn.set(e,t={}),nn(e,`keydown`,n=>{Fn(n,t,e)})),t},Ln=(e,t,n,r)=>Rn(In(e),t,n,r),Rn=(e,t,n,r=2)=>{let i=(e[t==`any`?t:Mn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},zn=Q?4:2,Bn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Vn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Hn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},Un=!1,Wn=e=>e.search(/\S|$/),Gn=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),Kn=(e,t,n,r,i,a,o)=>{let s=n.join(`
29
+ `);if(s==t.join(`
30
+ `))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+Wn((f<0?n:t)[0]),m=i-u.length+Wn(d>0?l:u),h=r-i+s.length+d,g=p>a?a:Math.max(p,a+f),_=o+r-i+s.length;Z(e,s,r,i,g,o<m?_+d:Math.max(m+h,_))},qn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=un(e.value,n,r),[s,c]=Gn(e);return Kn(e,i,i.map(t?e=>e.slice(Wn(e)?c-Wn(e)%c:0):e=>e&&s.repeat(c-Wn(e)%c)+e),a,o,n,r),$(e)},Jn=(e,t)=>{let[n,r]=Gn(e);return Z(e,n.repeat(r-(t-$t(e.value,t))%r)),$(e)},Yn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=en(r,n[1]));let[i,a]=Gn(e),[o,s]=n,c=Yt[fn(e,o)]?.autoIndent,l=Math.floor(Wn(ln(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
31
+ `+i.repeat(l+u)+(d?`
32
+ `+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Xn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?$t(i,n)-1:n,o=t?r:i.indexOf(`
33
+ `,r)+1;if(a>-1&&o>0){let[s,c,l]=un(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
34
+ `),c,l,n+d,r+d)}return $(e)},Zn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=un(i,n,r),c=a.join(`
35
+ `),l=t?0:c.length+1;return Z(e,c+`
36
+ `+c,o,s,n+l,r+l),$(e)},Qn=(e,t)=>(e.container.scrollBy(0,rn(e.container,`lineHeight`)*(t?-1:1)),!0),$n=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=un(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=en(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},er=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:$t(i,n),o=Yt[fn(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=un(i,n,r),f=l.length-1;if(t){if(c){let[t,a]=c,o=i.slice(n,r),s=i.slice(0,n).search(cn(t)+` ?$`);s+1&&RegExp(`^ ?`+cn(a)).test(i.slice(r))?Z(e,o,s,r+(i[r]==` `)+a.length,s,s+r-n):Z(e,`${t} ${o} ${a}`,n,r,n+t.length+1,r+t.length+1)}}else if(s){let t=cn(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));Kn(e,l,l.map(!c&&l.every(e=>a.test(e))?e=>e.replace(o,``):e=>c||/\S/.test(e)?e.replace(/(?!\s)/,s+` `):e),u,d,n,r)}else if(c){let[t,i]=c,a=l[0],o=Wn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(cn(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${cn(i)}$`),``):l[f]+` `+i;let m=l.join(`
37
+ `),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},tr={Tab(e){if(!Un){let[t,n]=e.getSelection();return t==n?Jn(e,t):qn(e)}},"8+Tab":e=>!Un&&qn(e,!0),"1+ArrowDown":e=>Xn(e),"1+ArrowUp":e=>Xn(e,!0),"9+ArrowDown":e=>Zn(e),"9+ArrowUp":e=>Zn(e,!0),Enter:e=>Yn(e),"8+Enter":e=>Yn(e),"Mod+Enter":e=>Yn(e,!0),"Mod+]":e=>qn(e),"Mod+[":e=>qn(e,!0),"8+Mod+k":$n,"Mod+/":e=>er(e),"9+a":e=>er(e,!0),[Q?`10+m`:`2+m`]:()=>(Un=!Un,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Qn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Qn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var nr=Q?5:1;nr+``,nr+``,nr+``,nr+``;var rr=(e,t=[`""`,`''`,"``",`()`,`[]`,`{}`],n=/([^$\w'"`]["'`]|.[[({])[.,:;\])}>\s]|.[[({]`/s)=>(r,i)=>{let a,o=r.inputCommandMap,s=navigator.clipboard,c=([e,t],[i,a],o,s)=>(e<t||!s&&n.test((o[t-1]||` `)+i+(o[t]||` `)))&&!Z(r,i+o.slice(e,t)+a,null,null,e+1,t+1),l=([e,t],n,i)=>e==t&&i[t]==n&&!pn(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=ln(a,e),s=i.tabSize||2,c=t.includes(a.slice(e-1,e+1)),l=/[^ ]/.test(o)?0:(o.length-1)%s+1;if((c||l>1)&&e==n)return Z(r,``,e-(c?1:l),e+c),$(r)}};o[`<`]=(e,t,n)=>c(t,`<>`,n,!0),t.forEach(([e,t])=>{let n=e==t;o[e]=(i,a,o)=>(n&&l(a,t,o)||c(a,e+t,o))&&$(r),n||(o[t]=(e,n,i)=>l(n,t,i)&&$(r))}),o[`>`]=(e,t,n)=>{let i=Yt[fn(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},Ln(r,`Backspace`,u),Ln(r,`8+Backspace`,u);for(let t in e)Ln(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>nn(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=un(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
38
+ `,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},ir=(e=999)=>{let t=0,n,r,i=!1,a,o,s,c,l,u,d=[],f=r=>{r>=e&&(r--,d.shift()),d.splice(t=r,e,[n.value,u(),u()])},p=e=>{d[e]&&(l.value=d[e][0],l.setSelectionRange(...d[e][e<t?2:1]),n.update(),n.extensions.cursor?.scrollIntoView(),t=e,r=!1)},m=(e,g)=>{e.extensions.history=m,n=e,u=e.getSelection,l||f(0),l=e.textarea,e.on(`selectionChange`,()=>{r=i,i=!1}),nn(e,`beforeinput`,e=>{let n=e.data,l=e.inputType,f=e.timeStamp;/history/.test(l)?(p(t+(l[7]==`U`?-1:1)),X(e)):(c=r&&(a==l||f-s<99&&l.slice(-4)==`Drop`)&&!sn&&(n!=` `||o==n))||(d[t][2]=sn||u()),i=!0,o=n,s=f,a=l}),nn(e,`input`,()=>f(t+!c)),nn(e,`keydown`,e=>{if(!g.readOnly){let n=_n(e),r=e.keyCode,i=n==zn&&r==90,a=n==zn+8&&r==90||!Q&&n==zn&&r==89;i?(p(t-1),X(e)):a&&(p(t+1),X(e))}}),e.addExtensions({update(){e.value!=l.value&&h()}})},h=m.clear=()=>{f(0),r=!1};return m.has=e=>t+e in d,m.go=e=>p(t+e),m},ar=Kt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),or=()=>{let e,t=ar(),[n,r]=t.childNodes,[i,a]=r.childNodes,o=()=>{let r=e.getSelection(),i=e.value,o=e.lines[e.activeLine],s=r[r[2]<`f`?0:1];on(n,ln(i,s)),on(a,i.slice(s,en(i,s))+`
39
+ `),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Qt(e,i)},c=t=>{e=t,t.extensions.cursor=c,nn(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),an(e,i)),c.scrollIntoView=s,c.element=i,c};Kt(`<div class=pce-cursor>`);var sr=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,cr=/\b(?:false|true)\b/,lr=/\[]|\(\)|{}/,ur=/[([{][^)\]}]*$/,dr=([e,t],n)=>lr.test(n[e-1]+n[t]),fr={line:`//`,block:[`/*`,`*/`]},pr=(e=fr,t=ur)=>({comments:e,autoIndent:[([e],n)=>t.test(ln(n,e)),dr]});Yt.json=Yt.json5=Yt.jsonp=pr(),Yt.graphql=pr({line:`#`}),Mt.webmanifest=Mt.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:sr,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:cr,null:{pattern:/\bnull\b/,alias:`keyword`}},Mt.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|"(?!""))*"""|"(?:\\.|[^\\\n"])*")(?=\s*[a-z_])/gi,alias:`string`,inside:{"language-markdown":{pattern:/("(?!")|""")[^]+(?=\1)/,lookbehind:!0,inside:`md`}}},string:/"""[^]*?"""|"(?:\\.|[^\\\n"])*"/g,number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:cr,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:`function`},"attr-name":/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\\n"])*")*\))?:)/gi,"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:`class-name`},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-mutation":{pattern:/(\bmutation\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-query":{pattern:/(\bquery\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[&|!=]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[()[\]{},:!=]/,property:/\w+/,[At](e,t){for(var n=Pt(e,t),r=n.filter(({type:e})=>e&&e!=`comment`&&e!=`scalar`),i=r.length,a=0,o=e=>{for(var t=0;t<e.length;t++)if(a+t==i||r[a+t].type!=e[t])return!0},s=(e,t)=>{for(var n=1,o=a;o<i;o++){var s=r[o],c=s.content;if(s.type==`punctuation`){if(e==c)n++;else if(t==c&&!--n)return o}}};a<i;){var c=r[a++];if(c.type==`keyword`&&c.content==`mutation`){var l=[];if(!o([`definition-mutation`,`punctuation`])&&r[a+1].content==`(`){a+=2;var u=s(`(`,`)`);if(!u)continue;for(;a<u;a++){var d=r[a];d.type==`variable`&&(d.alias=`variable-input`,l.push(d.content))}a=u+1}if(!o([`punctuation`,`property-query`])&&r[a].content==`{`&&(r[++a].alias=`property-mutation`,l[0])){var f=s(`{`,`}`);if(f)for(var p=a;p<f;p++){var m=r[p];m.type==`variable`&&l.indexOf(m.content)>=0&&(m.alias=`variable-input`)}}}}return n}};var mr=new WeakMap;On([`json`],{sources:[(e,t)=>{let n=mr.get(t)?.(t.value,e.pos);return n?{from:n.from,to:n.to,options:n.options.map(e=>({...e,renderDocs:e.doc?()=>[e.doc]:void 0}))}:null}]});function hr({value:e,language:r=`json`,readOnly:i,label:a,onChange:o,onLine:c,complete:l}){let u=s(null),d=s(void 0),f=s({onChange:o,onLine:c});f.current={onChange:o,onLine:c};let p=s(l);return p.current=l,n(()=>{let t=Ut(u.current,{value:e,language:r,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},rr(tr),ir(),...l?[or(),kn({filter:An})]:[]);return l&&mr.set(t,(e,t)=>p.current?.(e,t)),t.textarea.setAttribute(`aria-label`,a),d.current=t,()=>t.remove()},[]),n(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),n(()=>{d.current?.setOptions({readOnly:i,language:r})},[i,r]),t(`div`,{class:`body-editor`,part:`editor`,ref:u})}var gr=/[\w$.+-]/;function _r(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
40
+ `;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&gr.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&gr.test(e[o]??``);)o++;let s=r();return c({mode:s?.t===`o`&&s.expectKey?`key`:`value`,from:a,to:o,inString:!1,prefix:e.slice(a,t),hasColon:!1});function c(e){if(n.length===0)return;let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=r===n.length-1;if(i.t===`o`){if(a&&e.mode===`key`)break;if(i.key===void 0)return;t.push(i.key)}else t.push(i.index)}let i=r();return{...e,path:t,existing:i?.t===`o`?i.keys:new Set}}}var vr=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),yr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function br(e){let t=J(e);return t===`object`?{text:`{}`,stop:1}:t===`array`?{text:`[]`,stop:1}:t===`boolean`?{text:`false`,stop:5}:t===`number`||t===`integer`?{text:`0`,stop:1}:{text:`""`,stop:1}}function xr(e,t,n,r,i){if(!e)return;let a=_r(r,i);if(!a)return;let o=Qe(e,[...n,...a.path],t);if(!o)return;let s=q(o,t);if(a.mode===`key`){if(J(s)!==`object`&&!s.properties)return;let e=Ge(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=q(e.schema,t),r=br(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${yr(n,t)}${e.required?` · required`:``}`,icon:n.deprecated?`text`:`property`,insert:s,tabStops:a.hasColon?void 0:[o.length+r.stop],boost:e.required?10:0,from:a.inString?a.from+1:void 0,doc:vr(We(Ue(n),400))}});return{from:a.from,to:a.to,options:n}}let c=[],l=(e,t)=>{let n=JSON.stringify(e);c.push({label:typeof e==`string`?e:n,insert:n,icon:`enum`,detail:t,from:a.inString?a.from+1:void 0})};if(Array.isArray(s.enum))for(let e of s.enum)l(e);else if(J(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var Sr=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Cr(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:pe(e.path),query:pe(e.query),headers:pe(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?he(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var wr=e=>Object.keys(e).length?e:void 0;function Tr(e,t){let n;if(Sr(e,t))n=ve(e.fields);else if(t===`binary`){let t=e.fields.find(e=>e.enabled);n=t?.file??t?.value}else if(e.body.trim()!==``){if(t===`text`)n=e.body;else try{n=JSON.parse(e.body)}catch(e){throw Error(`Invalid JSON: ${e.message}`)}}return{path:wr(me(e.path)),query:wr(me(e.query)),headers:wr(me(e.headers)),data:n}}var Er=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function Dr(e,t,n,r=``){let i=e=>e.includes(`{{`)?e:encodeURIComponent(e),a=e.replace(/\{([^}]+)\}/g,(e,n)=>{let r=t.find(e=>e.key===n&&e.enabled&&e.value!==``);return r?i(r.value):e}),o=n.filter(e=>e.enabled&&e.key!==``).map(e=>`${i(e.key)}=${i(e.value)}`).join(`&`);return`${r.replace(/\/+$/,``)}${a}${o?`?${o}`:``}`}function Or({doc:e,hint:n}){return e?t(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[t(`div`,{class:`field-doc-head`,children:[t(`code`,{children:e.path}),t(`span`,{class:`chip`,children:e.type}),e.required&&t(`span`,{class:`chip req`,children:`required`}),e.deprecated&&t(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?t(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:Pe(e.description)}}):e.note?null:t(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&t(l,{children:[` It is part of: `,e.parent]})]}),e.note&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&t(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>t(`code`,{children:e})),e.enum.length>12&&t(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):t(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:n??`Put the cursor on a field to see what the API says about it.`})}function kr(e){try{let{query:t,variables:n,...r}=JSON.parse(e);return typeof t==`string`?{query:t,variables:n===void 0?``:JSON.stringify(n,null,2),rest:r}:void 0}catch{return}}function Ar(e){let t;try{t=e.variables.trim()?JSON.parse(e.variables):void 0}catch{t=e.variables}return JSON.stringify({query:e.query,variables:t,...e.rest},null,2)}function jr({value:e,options:r,onChange:i,label:o,placeholder:c,onKeyDown:l,cell:u,readOnly:d}){let[f,p]=a(!1),[m,h]=a(-1),[g,_]=a(),v=s(null),y=()=>{let e=v.current,t=e?.getBoundingClientRect();if(!e||!t)return;let n=document.createElement(`div`);n.style.cssText=`position:fixed;inset:0;visibility:hidden;pointer-events:none`,e.append(n);let r=n.getBoundingClientRect();n.remove();let i=innerHeight-t.bottom-8,a=i<160&&t.top>i;_({left:`${t.left-r.left}px`,width:`${Math.max(t.width,160)}px`,maxHeight:`${Math.min(240,(a?t.top:i)-4)}px`,...a?{bottom:`${r.bottom-t.top+2}px`}:{top:`${t.bottom+2-r.top}px`}})};n(()=>{if(!f){_(void 0);return}y();let e=e=>{if(e.target instanceof Node&&v.current?.contains(e.target))return;let t=v.current?.getBoundingClientRect();!t||t.bottom<0||t.top>innerHeight?p(!1):y()},t=()=>p(!1);return addEventListener(`scroll`,e,!0),addEventListener(`resize`,t),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,t)}},[f]),n(()=>{if(!f)return;let e=e=>{e.composedPath().includes(v.current)||p(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[f]);let b=e=>{i(e),p(!1),h(-1)};return t(`div`,{class:`combo`,ref:v,children:[t(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":f,role:`combobox`,autocomplete:`off`,readOnly:d,onFocus:()=>!d&&p(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{f&&e.key===`ArrowDown`?(e.preventDefault(),h((m+1)%r.length)):f&&e.key===`ArrowUp`?(e.preventDefault(),h((m-1+r.length)%r.length)):f&&e.key===`Enter`&&m>=0?(e.preventDefault(),b(r[m])):e.key===`Escape`&&f?(e.stopPropagation(),p(!1)):((e.key===`Enter`||e.key===`Tab`)&&p(!1),l?.(e))}}),t(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,disabled:d,onClick:()=>p(!f),children:`▾`}),f&&t(`div`,{class:`combo-list`,role:`listbox`,style:g??{top:`0px`,left:`0px`,visibility:`hidden`},children:r.map((n,r)=>t(`button`,{type:`button`,role:`option`,"aria-selected":n===e,class:`${n===e?`on`:``} ${r===m?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(n),children:n}))})]})}var Mr=`specbook:grid-cols`,Nr={key:26,val:34},Pr=10,Fr=c(Ir());function Ir(){try{let e=JSON.parse(L.local.getItem(Mr)??`null`);if(e&&e.key>=Pr&&e.val>=Pr&&e.key+e.val<=90)return e}catch{}return Nr}function Lr(e){let t=e??Nr,n=Math.min(80,Math.max(Pr,t.key)),r=Math.min(100-n-Pr,Math.max(Pr,t.val));Fr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?L.local.setItem(Mr,JSON.stringify(Fr.value)):L.local.removeItem(Mr)}catch{}}function Rr(){return t(`colgroup`,{children:[t(`col`,{style:{width:`36px`}}),t(`col`,{style:{width:`${Fr.value.key}%`}}),t(`col`,{style:{width:`${Fr.value.val}%`}}),t(`col`,{}),t(`col`,{style:{width:`60px`}})]})}function zr({which:e,table:n}){let r=t=>{let n=Fr.value;Lr(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return t(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(Fr.value[e]),"aria-valuemin":Pr,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let t=n()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/t*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>Lr(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var Br=1,Vr=2;function Hr(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.search(/[=\t]|:\s/);return t<0?{key:e,value:``}:{key:e.slice(0,t).trim(),value:e.slice(t+1).trim()}})}var Ur=({d:e})=>t(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Wr({title:e,rows:r,onChange:i,documented:a=[],docFor:o,fixed:c,bad:u,placeholder:d,bare:f,readOnly:p}){let m=s(null),h=s(null),g=s(void 0),_=new Set(r.map(e=>e.key)),v=a.filter(e=>!_.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),y=[...r,...v],b=e=>a.find(t=>t.name===e),x=e=>b(e)?.doc??o?.(e);n(()=>{if(!g.current)return;let e=m.current?.querySelector(`[data-cell="${g.current}"]`);g.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let S=e=>!e.virtual||e.enabled||e.value!==``||e.file,C=e=>i(e.filter(S).map(({virtual:e,...t})=>t)),w=(e,t)=>C(y.map((n,r)=>r===e?{...n,...t}:n)),T=(e,t)=>m.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),E=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),T(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),T(e-1,t))},D=e=>{let t=y[e],n=x(t.key)?.enum??[],r=new Set(y.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...y];o.splice(e+1,0,a),g.current=`${o.filter(S).indexOf(a)}:${Vr}`,C(o)},O=(e,t)=>{let n=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(n.trim()))return;e.preventDefault();let a=Hr(n).map(e=>({...e,enabled:!0})),o=[...r];o.splice(t,+(t<r.length&&!r[t]?.key),...a),i(o)},k=y.length;return t(`section`,{class:`grid`,"aria-label":e,ref:m,children:[!f&&t(`h3`,{children:e}),t(`table`,{ref:h,children:[t(Rr,{}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-check`}),t(`th`,{class:`g-key`,children:[`Key`,t(zr,{which:`key`,table:()=>h.current})]}),t(`th`,{class:`g-val`,children:[`Value`,t(zr,{which:`val`,table:()=>h.current})]}),t(`th`,{class:`g-doc`,children:`Description`}),t(`th`,{class:`g-act`})]})}),t(`tbody`,{children:[y.map((e,n)=>{let r=x(e.key),i=b(e.key)?.file,a=c||p||e.virtual||b(e.key);return t(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[t(`td`,{class:`g-check`,children:t(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:c||p,onChange:e=>w(n,{enabled:e.target.checked})})}),t(`td`,{class:`g-key`,children:a?t(`span`,{class:`key`,children:[t(`code`,{children:e.key}),r?.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}):t(`input`,{class:`cell`,"data-cell":`${n}:${Br}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>w(n,{key:e.target.value}),onKeyDown:E(n,Br),onPaste:e=>O(e,n)})}),t(`td`,{class:`g-val`,children:i?t(`label`,{class:`file-cell`,children:[t(`input`,{type:`file`,disabled:p,"aria-label":`File for ${e.key}`,onChange:e=>{let t=e.target.files?.[0];t&&w(n,{file:t,value:t.name,enabled:!0})}}),t(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?t(jr,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${n}:${Vr}`,readOnly:p,placeholder:`value`,onKeyDown:E(n,Vr),onChange:e=>w(n,{value:e,enabled:!0})}):t(`input`,{class:`cell`,"data-cell":`${n}:${Vr}`,value:e.value,readOnly:p,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>w(n,{value:e.target.value,enabled:!0}),onKeyDown:E(n,Vr)})}),t(`td`,{class:`g-doc`,title:Fe(r?.description),children:r&&t(l,{children:[t(`span`,{class:`chip`,children:r.type}),` `,t(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:Re(r.description)}})]})}),t(`td`,{class:`g-act`,children:[!c&&!p&&e.key&&t(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>D(n),children:t(Ur,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!c&&!p&&!e.virtual&&t(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>C(y.filter((e,t)=>t!==n)),children:t(Ur,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},n)}),!c&&!p&&t(`tr`,{class:`ghost`,children:[t(`td`,{class:`g-check`}),t(`td`,{class:`g-key`,children:t(`input`,{class:`cell`,"data-cell":`${k}:${Br}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{g.current=`${r.length}:${Br}`,i([...r,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:E(k,Br),onPaste:e=>O(e,r.length)})}),t(`td`,{class:`g-val`}),t(`td`,{class:`g-doc`}),t(`td`,{class:`g-act`})]},k)]})]})]})}function Gr({draft:e,onChange:r,readOnly:i}){let[o,c]=a(()=>kr(e.body)),l=s(e.body);n(()=>{if(e.body===l.current)return;let t=kr(e.body);t&&c(t),l.current=e.body},[e.body]);let u=t=>{let n={...o,...t};c(n),l.current=Ar(n),r({...e,body:l.current})};return t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Query`}),t(`span`,{class:`chip`,children:`graphql`})]}),t(hr,{readOnly:i,label:`GraphQL query`,language:`graphql`,value:o.query,onChange:e=>u({query:e})}),t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Variables`}),t(`span`,{class:`chip`,children:`json`})]}),t(hr,{readOnly:i,label:`GraphQL variables`,language:`json`,value:o.variables,onChange:e=>u({variables:e})})]})}var Kr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function qr({encoding:e,draft:n,onChange:r,schema:i,defs:s,files:c=[],notes:u,readOnly:d}){let[f,p]=a(0),m=o(()=>Ze(n.body),[n.body]),h=e===`json`||e===`form`,g=o(()=>{let e=m[f];return e&&h?Dt(Tt(i,s,e,[`data`]),u,`data`,Xe(e)):void 0},[m,f,i,s,h,u]),_=o(()=>h&&i?(e,t)=>xr(i,s,[`data`],e,t):void 0,[i,s,h]),v=e=>{if(e!==(n.formView??`grid`)){if(e===`grid`)try{r({...n,formView:`grid`,fields:he(JSON.parse(n.body||`{}`))})}catch{r({...n,formView:`grid`})}else r({...n,formView:`json`,body:JSON.stringify(ve(n.fields.filter(e=>!e.file)),null,2)})}},y=e===`form`?t(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>t(`button`,{type:`button`,class:`seg-btn ${(n.formView??`grid`)===e?`on`:``}`,"aria-pressed":(n.formView??`grid`)===e,onClick:()=>v(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(Sr(n,e)||e===`binary`){let a=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),o=e=>r({...n,fields:e}),f=(n.fields.length?n.fields.map(e=>e.key):[]).filter(a);return t(l,{children:[y&&t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),y]}),t(Wr,{title:e===`binary`?`File`:`Body`,bare:!!y,rows:n.fields,readOnly:d,onChange:o,documented:[...new Set(f)].map(e=>({name:e,file:!0})),docFor:e=>Dt(Tt(i,s,Et(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&kr(n.body)?t(Gr,{draft:n,onChange:r,readOnly:d}):t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),e!==`text`&&!d&&t(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...n,body:JSON.stringify(JSON.parse(n.body),null,2)})}catch{}},children:`Format`}),y]}),t(hr,{readOnly:d,label:`Request body`,language:Kr(e===`form`?`json`:e),value:n.body,onChange:e=>r({...n,body:e}),onLine:p,complete:_}),h&&t(Or,{doc:g})]})}var Jr=`specbook:code-lang`;function Yr(){try{let e=L.local.getItem(Jr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Xr({service:e,profile:r,secured:i,make:s,sent:c}){let[l,u]=a(Yr),d=l===`sent`?`curl`:l,[f,p]=a(!1),[m,h]=a(),[g,_]=a();n(()=>{let t=!0;return N.config(A.value).then(async n=>{let i=n.services?.[e],a=t=>N.baseUrlOf(e,t,A.value).catch(()=>void 0),o=P.value===`mock`?void 0:await a(P.value);if(o??=await a(`live`),!o&&i&&typeof i.baseUrl==`object`&&(o=Object.values(i.baseUrl)[0]),!t)return;h(o);let s=r===`service`?i?.auth:r;_(s?n.auth?.[s]?.apply:void 0)}),()=>{t=!1}},[e,r,P.value,te.value]);let v=o(()=>{try{return{text:je(d,s(m??`https://api.example.com`,g))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[s,d,m,g]),y=e=>{if(u(e),e!==`sent`)try{L.local.setItem(Jr,e)}catch{}};return t(`div`,{class:`code-sample`,children:[t(`div`,{class:`code-head`,children:[t(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[Me.map(e=>t(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>y(e.id),children:e.label})),c!==void 0&&t(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>y(`sent`),children:`Sent`})]}),t(`span`,{class:`spacer`}),l!==`sent`&&t(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(v.text)try{await navigator.clipboard.writeText(v.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!v.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:v.error?t(`p`,{class:`muted`,children:v.error}):t(`pre`,{class:`code-block`,part:`code`,children:t(`code`,{children:v.text})}),l!==`sent`&&i&&t(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Zr({service:e,method:n,path:r,draft:a,encoding:o,vars:s,secured:c,sent:l}){let u=i((e,t)=>{let i=Tr(a,o),c={path:i.path??{},query:i.query??{},headers:i.headers??{},data:i.data},l=c;try{l=p(c,s)}catch{}let u=r.replace(/\{([^}]+)\}/g,(e,t)=>{let n=l.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:n,url:`${e.replace(/\/+$/,``)}${u}`,query:{...t?.query??{},...l.query},headers:{...t?.headers??{},...l.headers},body:l.data,encoding:o}},[a,o,s,n,r]);return t(Xr,{service:e,profile:c?`service`:void 0,secured:c,make:u,sent:l})}function Qr({request:e,encoding:n,sent:r}){let a=i((t,r)=>({method:e.method,url:`${t.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:n}),[e,n]);return t(Xr,{service:e.service,profile:e.profile,secured:!!e.profile,make:a,sent:r})}function $r(e,t){try{let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return Object.prototype.toString.call(e)}}function ei(e){let t=typeof e==`string`?e:$r(e);return t.length>28?`${t.slice(0,27)}…`:t}var ti=e=>typeof e==`string`?e:$r(e,2);function ni(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r])t.append(n,e);let n=t.toString();return n?`?${n}`:``}function ri({body:e,docs:n}){let[r,i]=a(0),s=ti(e),c=!!n?.schema&&typeof e==`object`&&!!e,u=o(()=>c?Ze(s):[],[c,s]),d=o(()=>{let e=u[r];return e&&n?Dt(Tt(n.schema,n.defs,e,[`data`]),n.notes,`data`,Xe(e)):void 0},[u,r,n]);return t(l,{children:[t(hr,{label:`Body as sent`,value:s,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&t(Or,{doc:d})]})}function ii({request:e,hideBar:n,docs:r}){if(!e)return t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing sent yet`}),t(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return t(`div`,{class:`sent-view`,children:[!n&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${e.method}`,children:e.method}),t(`div`,{class:`rq-url`,title:e.url,children:t(`code`,{children:[e.url,ni(e.query)]})})]}),t(`h3`,{children:`Headers`}),i.length===0?t(`p`,{class:`muted`,children:`No headers.`}):t(`table`,{class:`headers`,children:t(`tbody`,{children:i.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]}))})}),e.body!==void 0&&t(l,{children:[t(`h3`,{children:`Body`}),t(ri,{body:e.body,docs:r})]})]})}function ai(e){let t=e.location;if(!t)return;let n=[...w.requests,...w.sequences].map(e=>e.file).filter(e=>t.file.includes(e)).sort((e,t)=>t.length-e.length)[0];return n?`${n}:${t.line}`:void 0}var oi={expected:`−`,received:`+`,same:` `,skip:` `},si={expected:`expected`,received:`received`,same:``,skip:``};function ci({lines:e}){return t(`section`,{class:`diff`,tabIndex:0,"aria-label":`Expected and received values`,children:e.map(e=>t(`div`,{class:`diff-line diff-${e.kind}`,children:[t(`span`,{class:`diff-gutter`,"aria-hidden":`true`,children:oi[e.kind]}),si[e.kind]&&t(`span`,{class:`visually-hidden`,children:[si[e.kind],`: `]}),t(`span`,{class:`diff-text`,children:e.text})]}))})}function li({a:e}){let n=fe(e),r=ai(e);return t(`fieldset`,{class:`check-fail`,children:[t(`legend`,{class:`visually-hidden`,children:[`Failed check: `,e.label]}),t(`div`,{class:`check-head`,children:[t(`span`,{class:`check-mark`,"aria-hidden":`true`,children:`✗`}),t(`strong`,{children:e.label}),t(`span`,{class:`chip`,children:e.operator})]}),n.length>0&&t(l,{children:[t(`div`,{class:`diff-legend`,"aria-hidden":`true`,children:[t(`span`,{class:`diff-key diff-expected`,children:`− Expected`}),t(`span`,{class:`diff-key diff-received`,children:`+ Received`})]}),t(ci,{lines:n})]}),r&&t(`div`,{class:`check-where`,children:[`at `,r]})]})}function ui({assertions:e}){return t(`ul`,{class:`checks`,children:e.map(e=>e.pass?t(`li`,{class:`ok`,children:[t(`span`,{class:`tick`,children:`✓`}),` `,e.label]}):t(`li`,{class:`bad`,children:t(li,{a:e})}))})}var di=e=>$r(e,2),fi=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function pi({step:e,error:r,schemas:i,defs:s,hideRequest:c}){let[u,d]=a(`body`),[f,p]=a(0),m=e?.response,h=m?i?.[String(m.status)]??i?.default:void 0,g=o(()=>{try{return m&&h?Ye(m.body,h,s,{reportExtra:!0}):[]}catch{return[]}},[m,h,s]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:di(m.body),v=o(()=>Ze(_),[_]),y=o(()=>{let e=v[f];return e?Tt(h,s,e):void 0},[v,f,h,s]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length;n(()=>{e&&x>0&&d(`checks`)},[e]);let S=Object.entries(m?.headers??{}),C=!m&&!r&&!e?.error;return t(`section`,{class:`response`,"aria-label":`Response`,children:[t(`div`,{class:`rs-head`,children:[m&&t(l,{children:[t(`span`,{class:`state-badge ${tt(m.status)}`,children:[m.status,` `,et(m.status)]}),t(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),t(`span`,{class:`rs-stat`,children:fi(new Blob([_]).size)})]}),t(`span`,{class:`spacer`}),m&&t(`span`,{class:`conf ${h?g.length?`warn`:`ok`:`none`}`,children:h?g.length?`⚠ ${g.length} difference${g.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!c&&t(`p`,{class:`sent`,children:[t(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,t(`code`,{children:[e.request.url,ni(e.request.query)]})]}),r&&t(`p`,{class:`error-text`,children:r}),e?.error&&t(`p`,{class:`error-text`,children:e.error}),C&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`No response yet`}),t(`span`,{class:`muted`,children:[`Press`,` `,t(`kbd`,{class:`icon-key`,children:t(T,{size:12})}),` `,`or `,t(`kbd`,{children:`⌘`}),` `,t(`kbd`,{children:`↵`})]})]}),m&&t(l,{children:[t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":u===e,class:`rq-tab ${u===e?`on`:``}`,onClick:()=>d(e),children:[n,r>0&&t(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,title:e===`checks`&&x?`${x} of ${r} checks failed`:void 0,children:e===`checks`&&x?x:r})]}))}),t(`div`,{class:`rs-pane`,children:[t(`div`,{hidden:u!==`body`,children:[_===``?t(`p`,{class:`muted`,children:`No content.`}):t(hr,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:p}),_!==``&&t(Or,{doc:y}),g.length>0&&t(`details`,{class:`issues`,children:[t(`summary`,{children:`What differs`}),t(`ul`,{children:g.map(e=>t(`li`,{children:[t(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),t(`div`,{hidden:u!==`headers`,children:t(`table`,{class:`headers`,children:t(`tbody`,{children:[S.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]})),S.length===0&&t(`tr`,{children:t(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),t(`div`,{hidden:u!==`checks`,children:b.length===0?t(`p`,{class:`muted`,children:`This request has no checks.`}):t(ui,{assertions:b})})]})]})]})}var mi=()=>{let e=document.querySelector(`meta[name="specbook-oauth-callback"]`)?.content.trim();if(e)try{return new URL(e,location.origin).href}catch{}return`${location.origin}${location.pathname}`};async function hi(e){let t=window.open(``,u,`popup,width=520,height=720`);if(!t)throw new oe(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(u),r;try{let{verifier:i,challenge:a}=await _(),o=b(),s=mi(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new oe(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new oe(`Sign-in was cancelled.`))});let c=(e,n)=>{e?.type===`callback`&&e.state===o&&(s(),n({type:`ack`,state:o}),t(e))};n.onmessage=e=>c(e.data,e=>n.postMessage(e)),r=e=>{e.origin===location.origin&&c(e.data,t=>e.source?.postMessage(t,location.origin))},addEventListener(`message`,r)});t.location.href=S({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=ee({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(M({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return m(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var gi=`specbook.oauth.clients.v1`,_i=`specbook.oauth.expiry.v1`,vi=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},yi=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},bi=e=>{try{return vi(L.local,gi)[e]}catch{return}},xi=(e,t)=>{try{yi(L.local,gi,{...vi(L.local,gi),[e]:t})}catch{}},Si=(e,t)=>`${e}\n${t}`,Ci=(e,t,n)=>{try{let r=vi(L.session,_i);n===void 0?delete r[Si(e,t)]:r[Si(e,t)]=Date.now()+n*1e3,yi(L.session,_i,r)}catch{}},wi=(e,t)=>{try{return vi(L.session,_i)[Si(e,t)]}catch{return}};function Ti({service:e,profile:r,origin:i,secret:o,oauth:c,onSignedIn:l}){let u=g(c)?c.openIdConnectUrl:c.authorizationUrl,[d,f]=a(()=>c.clientId??bi(u)??``);n(()=>{f(c.clientId??bi(u)??``)},[u,c.clientId]);let[p,m]=a(void 0),[h,_]=a([]),[v,y]=a({kind:`idle`}),b=s(void 0),x=v.kind===`busy`,[S,C]=a(0);n(()=>{let e=!0;return m(void 0),y(e=>e.kind===`busy`?e:{kind:`idle`}),N.oauthEndpoints({env:P.value,version:A.value,profile:r}).then(t=>{e&&(m(t),_(g(c)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&y({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[r,P.value,A.value,S,te.value]);let w=Object.keys(p?.scopes??{}),T=()=>{if(!p)return C(e=>e+1);let e=d.trim();if(!e)return y({kind:`error`,message:`Enter the client id registered for this page.`});let t=new AbortController;b.current=t,y({kind:`busy`}),xi(u,e),hi({authorizationUrl:p.authorizationUrl,clientId:e,scopes:h,signal:t.signal,exchange:(e,t)=>N.oauthExchange({env:P.value,version:A.value,profile:r,fields:e,signal:t})}).then(e=>{I.set(i,o,e.accessToken),Ci(i,o,e.expiresIn),y({kind:`idle`}),l()}).catch(e=>y({kind:`error`,message:e instanceof Error?e.message:String(e)}))},E=!p&&v.kind===`error`,D=!x&&v.kind!==`error`&&!!p;return t(`span`,{class:`needs-var oauth-signin`,children:[t(`input`,{type:`text`,autocomplete:`off`,"aria-label":`Client id for ${e}`,placeholder:`client id`,value:d,disabled:x,onInput:e=>f(e.target.value)}),x?t(`button`,{type:`button`,class:`link`,onClick:()=>b.current?.abort(),children:`Cancel`}):t(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&t(`details`,{children:[t(`summary`,{class:`muted small`,children:[`Scopes (`,h.length,` of `,w.length,`)`]}),w.map(e=>t(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[t(`input`,{type:`checkbox`,checked:h.includes(e),disabled:x,onChange:t=>_(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,t(`code`,{children:e})]}))]}),t(`span`,{class:`muted small oauth-status ${D?`oauth-hint`:``}`,role:`status`,"aria-live":`polite`,children:x?`Waiting for the sign-in window…`:v.kind===`error`?v.message:p?`Register this redirect URI with the provider: ${mi()}`:`Looking up the provider…`})]})}var Ei=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),Di={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Oi({services:e,enabled:r=!0,supplied:i}){let[o,s]=a([]),[c,u]=a({}),d=i??c,[,f]=a(0),[p,m]=a(!1),g=r&&P.value!==`mock`,_=e?.join(`
41
+ `)??`*`;if(n(()=>{if(!g){s([]);return}let t=!0;return i||N.managedSecrets(P.value).then(e=>t&&u(e)),N.config(A.value).then(async n=>{let r=[],i=await N.addressesIn(n,P.value);for(let[t,a]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let o=a.auth?n.auth?.[a.auth]:void 0,s=i.baseUrl(t),c=C(s?h(s,globalThis.location?.href):void 0);if(!o||!c)continue;let l=a.auth?i.oauth(a.auth):void 0,u=[...new Set([...JSON.stringify(o.apply).matchAll(k)].map(e=>e[1]))];u.length&&r.push({service:t,origin:c,title:o.title??a.auth??``,names:u,profile:a.auth,oauth:l})}t&&s(r)}),()=>{t=!1}},[g,P.value,_,A.value,te.value]),!g||o.length===0)return null;let v=(e,t)=>I.get(e.origin,t)!==void 0||d[t]!==void 0,y=o.some(e=>e.names.some(t=>!v(e,t)));return!y&&!p?t(`div`,{class:`secrets-folded`,children:t(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>m(!0),children:[t(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):t(`fieldset`,{class:`needs-vars ${y?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>t(l,{children:[t(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(n=>{let r=I.get(e.origin,n)!==void 0,i=d[n];return t(`span`,{class:`needs-var`,children:[t(`code`,{children:n}),r?t(l,{children:[t(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&Ei(wi(e.origin,n))!==void 0?` · expires in ${Ei(wi(e.origin,n))} min`:``]}),t(`button`,{type:`button`,class:`link`,onClick:()=>{I.remove(e.origin,n),Ci(e.origin,n,void 0),f(e=>e+1)},children:`Clear`})]}):t(l,{children:[i&&t(`span`,{class:`muted`,children:[`from `,Di[i]??i]}),e.oauth&&t(Ti,{service:e.service,profile:e.profile,origin:e.origin,secret:n,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),t(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${n} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:t=>{let r=t.target.value;r!==``&&(I.set(e.origin,n,r),f(e=>e+1))}})]})]})})]})),t(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!y&&t(`button`,{type:`button`,class:`link`,onClick:()=>m(!1),children:`Hide`})]})}var ki=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`),Ai=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function ji(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[Ai(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(Ai(ki(e[1]))):void 0;e&&a!==void 0?n.has(a)||n.set(a,t.slice(e[0].length)):i.push(t)}return{intro:i.join(``),notes:n}}function Mi(e){let{seq:t}=e,[r,i]=a(),[s,c]=a(!1);n(()=>{let n=!0;i(void 0),c(!1);let r=w.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!r)c(!0);else return r.load().then(e=>n&&i(e)).finally(()=>n&&c(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=o(()=>t.nodes.map(e=>e.name),[t]);return o(()=>({...ji(r??Pe(t.meta.description),l),loaded:s}),[r,l,t,s])}function Ni(e){let[t,r]=a();return n(()=>{let t=!0;return r(void 0),e&&w.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&r(e)),()=>{t=!1}},[e]),t}var Pi=(e,t)=>`specbook:draft:${e}:${t}`,Fi=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Ii(e){try{let t=L.local.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Li=`specbook:saved-example`;function Ri(e){try{let t=L.session.getItem(Li),n=t?JSON.parse(t):void 0;return n?.key===e?(L.session.removeItem(Li),n):void 0}catch{return}}function zi({service:e,op:r,variants:i,initial:c,autoRun:u}){let p=`${e}/${r.id}`,m=s(null),h=s(!1),g=s(void 0),_=N.examplesOf(p),[v,y]=a(()=>Ri(p)),[b,x]=a(()=>{if(c?.startsWith(`saved:`)&&i.some(e=>`saved:${e.file}`===c))return c;let e=_.find(e=>e.name===(v?.name??c));return e?`ex:${e.name}`:_[0]?`ex:${_[0].name}`:i[0]?`saved:${i[0].file}`:``}),S=b.startsWith(`saved:`)?i.find(e=>`saved:${e.file}`===b):void 0,C=Ni(S?.file),D=pt(p),[k,M]=a(),[ee,F]=a(),[I,oe]=a(),[R,ce]=a({}),[le,ue]=a(),[de,fe]=a(),[z,pe]=a(),[me,he]=a(),[ge,_e]=a(),[ve,ye]=a(),[be,xe]=a(!1),[Se,Ce]=a(),[we,B]=a(),[Te,Ee]=a(``),[V,De]=a(),[Oe,H]=a();n(()=>{let t=!0;if(H(void 0),P.value===`mock`)Ee(``);else return N.baseUrlOf(e,P.value,A.value).then(e=>t&&Ee(e??``)).catch(e=>{t&&(Ee(``),H(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[e,P.value,A.value,te.value]),n(()=>{let e=!0;return De(void 0),N.knownVars(P.value,A.value).then(t=>e&&De(t)),()=>{e=!1}},[P.value]),n(()=>{let t=!0;return w.schemas[p]?.().then(e=>t&&ue(e.default)),w.responseSchemas[p]?.().then(e=>t&&fe(e.default)),w.definitions[e]?.().then(e=>t&&pe(e.default)),N.operationMeta(p,A.value).then(e=>{t&&M({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[p,e]);let U=k?.encoding??`json`,ke=w.manifests[e]?.operations.find(e=>e.id===r.id)?.secured;n(()=>{if(!k)return;let e=!0;return ye(void 0),_e(void 0),(async()=>{let t=S?await N.savedExample(S.def,A.value):await N.loadExample(p,b.replace(/^ex:/,``),A.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};F(n),oe(!S&&Ii(Pi(p,b))||Cr(n,U))})().catch(t=>e&&ye(t instanceof Error?t.message:String(t))),()=>{e=!1}},[p,b,k,S]);let Ae=o(()=>ee?Cr(ee,U):void 0,[ee,U]),je=!!I&&!!Ae&&JSON.stringify(Er(I))!==JSON.stringify(Er(Ae)),Me=e=>{if(oe(e),!S)try{let t=Pi(p,b);Ae&&JSON.stringify(Er(e))===JSON.stringify(Er(Ae))?L.local.removeItem(t):L.local.setItem(t,JSON.stringify(Er(e)))}catch{}},W=o(()=>{let e=le?q(le,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Ge(r,z).map(e=>({name:e.name,doc:Dt(Tt(le,z,[e.name],[n]),D.notes,n,e.name),repeat:q(e.schema,z).type===`array`})))}return t},[le,z,D.notes]),Ne=o(()=>{if(!I)return[];try{let e=Tr(I,U);return[...f([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(d).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[I,U]),Pe=Object.keys(S?.def.input.init??{}),Fe=V?Ne.filter(e=>!V.includes(e)&&!Pe.includes(e)):[],Ie=Fe.filter(e=>(R[e]??``)===``),Le=async e=>{if(!I||g.current)return;ye(void 0),xe(!0);let t=new AbortController;g.current=t;try{let n=S?S.def:await N.operationRequest(p,A.value,Tr(I,U)),r=await N.run(n,{env:P.value,version:A.value,mockStatus:P.value===`mock`?e??me:void 0,locale:ae.value,seed:ne.value,vars:Object.fromEntries(Object.entries(R).filter(([,e])=>e!==``)),fileDir:ee?.dir,signal:t.signal});_e(r),yt.value=bt(r)}catch(e){ye(e instanceof Error?e.message:String(e))}finally{g.current=void 0,xe(!1),B(`response`)}};n(()=>{u&&I&&!h.current&&(h.current=!0,Le())},[I]);let Re=async t=>{if(!I)return;let n=Tr(I,U),i=Fi(t),a={name:i,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${w.project.requestsDir}/${e}/${r.id}/${i}.example.json`,s={key:p,path:o,name:i};try{L.session.setItem(Li,JSON.stringify(s))}catch{}await ie(o,`${JSON.stringify(a,null,2)}\n`),y(s),Ce(void 0)},G=ge?.steps.find(e=>e.response)??ge?.steps[0],ze=ve?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Be=!!I&&(I.path.length>0||I.query.length>0||W.path.length>0||W.query.length>0),Ve=!!I&&(I.headers.length>0||W.headers.length>0),He=!!I&&U!==`none`&&(I.body!==``||I.fields.length>0||!!le?.properties?.data),K=we??(Be?`params`:He?`body`:Ve?`headers`:`params`),J=e=>e.filter(e=>e.enabled).length,Ue=I?J(I.query):0,We=I?J(I.path):0,Ke=I?Dr(r.path,I.path,I.query,Te):r.path;return n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Le())},t=m.current?.getRootNode()??window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)}),t(`div`,{class:`request-panel`,"data-op":p,ref:m,children:t(`div`,{class:`rq`,children:[t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),t(`div`,{class:`rq-url`,title:Ke,children:t(`code`,{children:Ke.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?t(`mark`,{children:e}):e)})}),(G?.response||ve||G?.error)&&t(`button`,{type:`button`,class:`result-chip ${G?.response?tt(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>B(`response`),children:G?.response?`${G.response.status} ${et(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),t(`button`,{type:`button`,class:`btn primary send`,title:be?`Stop`:`Send (⌘/Ctrl + Enter)`,"aria-label":be?`Stop`:`Send`,disabled:!be&&!I,onClick:()=>be?g.current?.abort():Le(),children:t(be?se:T,{})})]}),Oe&&t(`p`,{class:`envmenu-warn`,role:`alert`,children:[Oe,`.`,` `,O.value.environmentSettings&&t(`button`,{type:`button`,class:`link`,onClick:()=>E.value=!0,children:`Open Environment settings`})]}),C&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this request`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:C}})]},S?.file),Fe.length>0&&t(`fieldset`,{class:`needs-vars ${Ie.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[t(`span`,{class:`muted`,children:Ie.length>0?`Needs a value for`:`Values for`}),Fe.map(e=>t(`label`,{class:`needs-var`,children:[t(`code`,{children:e}),t(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:R[e]??``,onInput:t=>ce({...R,[e]:t.target.value})})]}))]}),ke&&t(Oi,{services:[e]}),t(`div`,{class:`rq-meta`,children:[t(`div`,{class:`rq-example`,children:[t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Example`}),t(`select`,{value:b,onChange:e=>x(e.target.value),children:[_.map(e=>t(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),i.map(e=>t(`option`,{value:`saved:${e.file}`,children:[e.name,` · request`]}))]})]}),t(re,{})]}),je&&t(`span`,{class:`edited`,children:`Edited`}),t(`span`,{class:`spacer`}),je&&t(`button`,{type:`button`,class:`link`,onClick:()=>Ae&&Me(Ae),children:`↺ Reset`}),!j&&!S&&je&&Se===void 0&&t(`button`,{type:`button`,class:`link`,onClick:()=>Ce(``),children:`Save as example…`}),P.value===`mock`&&r.statuses.length>0&&t(`label`,{class:`rq-status`,children:[t(`span`,{class:`muted`,children:`Respond with`}),t(`select`,{"aria-label":`Mock response`,value:me===void 0?``:String(me),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);he(n),Le(n)},children:[t(`option`,{value:``,children:`Default`}),r.statuses.map(e=>t(`option`,{value:String(e),children:[e,` `,et(e)]}))]})]})]}),v&&t(`p`,{class:`saved-note`,role:`status`,children:[t(`span`,{children:[`✓ Saved to `,t(`code`,{children:v.path}),`. It is a normal project file: commit it to share this example with your team.`]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>y(void 0),children:`×`})]}),Se!==void 0&&t(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),Se.trim()&&Re(Se.trim()).catch(e=>ye(String(e)))},children:[t(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:Se,onInput:e=>Ce(e.target.value)}),t(`button`,{type:`submit`,class:`btn`,children:`Save`}),t(`button`,{type:`button`,class:`link`,onClick:()=>Ce(void 0),children:`Cancel`})]}),S&&t(`p`,{class:`muted lock`,children:[`A request from your project: it runs with its own values and checks. Edit its file to change it.`,P.value===`mock`&&S.def.mockHook?` Its mock hook shapes the answer.`:``]}),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,Ue+We],[`headers`,`Headers`,I?J(I.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,Ne.length]].filter(([e])=>e===`params`?Be:e===`headers`?Ve:e===`body`?He:Ne.length>0).map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":K===e,class:`rq-tab ${K===e?`on`:``}`,onClick:()=>B(e),children:[n,r>0&&t(`span`,{class:`count`,children:r}),e===`body`&&t(`span`,{class:`chip`,children:U})]})),t(`span`,{class:`tab-gap`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`request`,class:`rq-tab ${K===`request`?`on`:``}`,onClick:()=>B(`request`),children:`Request`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`response`,class:`rq-tab ${K===`response`?`on`:``}`,onClick:()=>B(`response`),children:[`Response`,G?.response&&t(`span`,{class:`state-dot ${tt(G.response.status)}`,children:G.response.status}),!G?.response&&(ve||G?.error)&&t(`span`,{class:`state-dot s5`,children:`!`})]})]}),t(`div`,{class:`rq-pane`,children:[I&&t(l,{children:[t(`div`,{class:`tab-pane`,hidden:K!==`params`,children:[(I.query.length>0||W.query.length>0)&&t(Wr,{title:`Query`,rows:I.query,documented:W.query,readOnly:!!S,onChange:e=>Me({...I,query:e})}),(I.path.length>0||W.path.length>0)&&t(Wr,{title:`Path`,rows:I.path,documented:W.path,fixed:!0,readOnly:!!S,onChange:e=>Me({...I,path:e})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:Ve&&t(Wr,{title:`Headers`,rows:I.headers,documented:W.headers,readOnly:!!S,onChange:e=>Me({...I,headers:e})})}),t(`div`,{class:`tab-pane`,hidden:K!==`body`,children:He&&t(qr,{encoding:U,draft:I,onChange:Me,schema:le,defs:z,files:k?.files,notes:D.notes,readOnly:!!S})}),t(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:Ne.length>0&&t(Wr,{title:`Variables`,rows:Ne.map(e=>({key:e,value:R[e]??``,enabled:!0})),fixed:!0,bad:ze,placeholder:`from the request's init, config or earlier steps`,onChange:e=>ce(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`request`,children:I&&t(Zr,{service:e,method:r.method,path:r.path,draft:I,encoding:U,vars:R,secured:ke,sent:G?.request?t(ii,{request:G.request,docs:{schema:le,defs:z,notes:D.notes}}):void 0})}),t(`div`,{class:`tab-pane`,hidden:K!==`response`,children:t(pi,{step:G,error:ve,schemas:de,defs:z})})]})]})})}function Bi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Vi(e,t),...n}}function Vi(e,t){switch(e.kind){case`select`:case`multiselect`:{let n=e=>typeof t.value==`function`?t.value(e):e,r=e=>typeof t.label==`function`?t.label(e):String(n(e));return{kind:e.kind,options:t.options.map(e=>({label:r(e),value:n(e)}))}}case`object`:return{kind:`object`,shape:Object.fromEntries(Object.entries(t.shape).map(([e,t])=>[e,Bi(t)]))};case`array`:return{kind:`array`,item:Bi(t.item),default:t.default,min:t.min,max:t.max};default:return typeof t.default==`function`?{kind:e.kind,generate:t.default,min:t.min,max:t.max}:{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function Hi(e){if(e.generate)try{return e.generate()}catch{}return Ui({...e,generate:void 0})}function Ui(e){if(e.generate)return Hi(e);switch(e.kind){case`select`:return e.options?.[0]?.value;case`multiselect`:return[];case`object`:return Object.fromEntries(Object.entries(e.shape??{}).map(([e,t])=>[e,Ui(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Wi={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Gi=e=>typeof e==`string`?e:$r(e);function Ki({info:e}){let{seq:n}=e,{intro:r,notes:i}=Mi(e),a=o(()=>Object.entries(n.meta.inputs??{}).map(([e,t])=>{let n=Bi(t);return{name:e,spec:n,initial:Ui(n)}}),[n]);return t(`article`,{class:`doc`,"data-seq":n.meta.id,children:[(n.meta.tags?.length??0)>0&&t(`p`,{class:`doc-tags`,children:n.meta.tags?.map(e=>t(`span`,{class:`chip`,children:e}))}),r&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&t(`section`,{children:[t(`h2`,{children:`Controls`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Name`}),t(`th`,{children:`Type`}),t(`th`,{children:`Default`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:a.map(e=>t(`tr`,{children:[t(`td`,{children:t(`code`,{children:e.name})}),t(`td`,{children:t(`span`,{class:`chip`,children:e.spec.kind})}),t(`td`,{children:t(`code`,{children:Gi(e.initial)})}),t(`td`,{children:e.spec.description})]}))})]})]}),t(`section`,{children:[t(`h2`,{children:`Steps`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`#`}),t(`th`,{children:`Step`}),t(`th`,{children:`What it does`})]})}),t(`tbody`,{children:n.nodes.map((e,n)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return t(l,{children:[t(`tr`,{class:a?`has-note`:``,children:[t(`td`,{children:n+1}),t(`td`,{children:e.name}),t(`td`,{children:r?t(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>x({kind:`op`,key:`${r.service}/${r.id}`}),children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path})]}):t(`span`,{class:`muted`,children:Wi[e.kind]??e.kind})})]}),a&&t(`tr`,{class:`step-note-row`,children:[t(`td`,{}),t(`td`,{colSpan:2,children:t(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var qi=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Ji(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Yi({name:e,spec:n,value:r,onChange:i}){let[o,s]=a();switch(n.kind){case`number`:return t(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:n.min,max:n.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return t(jr,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return t(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=n.options??[],o=a.find(e=>qi(e.value,r));return t(jr,{label:e,value:o?.label??String(r??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=r??[];return t(`div`,{class:`multi-cell`,children:(n.options??[]).map(n=>t(`label`,{children:[t(`input`,{type:`checkbox`,checked:e.some(e=>qi(e,n.value)),onChange:t=>i(t.target.checked?[...e,n.value]:e.filter(e=>!qi(e,n.value)))}),n.label]}))})}case`object`:case`array`:return t(`input`,{class:`cell mono`,"aria-label":e,value:o??JSON.stringify(r??Ui(n)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return t(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function Xi(){return t(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:[t(`rect`,{x:`1.5`,y:`1.5`,width:`13`,height:`13`,rx:`3`,fill:`none`,stroke:`currentColor`}),t(`circle`,{cx:`5.2`,cy:`5.2`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`10.8`,cy:`10.8`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`8`,cy:`8`,r:`1.1`,fill:`currentColor`})]})}function Zi({title:e,specs:n,values:r,onChange:i}){let a=Object.keys(n);if(a.length===0)return null;let o=a.filter(e=>n[e]?.generate);return t(`section`,{class:`grid controls-grid`,"aria-label":e,children:[t(`h3`,{class:`controls-head`,children:[t(`span`,{children:e}),o.length>1&&t(`button`,{type:`button`,class:`btn small gen-all`,title:`Make a new value for every generated input`,onClick:()=>i({...r,...Object.fromEntries(o.map(e=>[e,Hi(n[e])]))}),children:[t(Xi,{}),` Generate all`]})]}),t(`table`,{children:[t(`colgroup`,{children:[t(`col`,{class:`c-key`}),t(`col`,{class:`c-val`}),t(`col`,{})]}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-key`,children:`Name`}),t(`th`,{class:`g-val`,children:`Value`}),t(`th`,{class:`g-doc`,children:`Description`})]})}),t(`tbody`,{children:a.map(e=>{let a=n[e];return t(`tr`,{children:[t(`td`,{class:`g-key`,children:t(`span`,{class:`key`,children:t(`code`,{children:a.label??e})})}),t(`td`,{class:`g-val`,children:t(`div`,{class:a.generate?`cell-gen`:void 0,children:[t(Yi,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})}),a.generate&&t(`button`,{type:`button`,class:`gen`,"aria-label":`Generate ${a.label??e}`,title:`Make another value`,onClick:()=>i({...r,[e]:Hi(a)}),children:t(Xi,{})})]})}),t(`td`,{class:`g-doc`,title:a.description,children:[t(`span`,{class:`chip`,children:Ji(a)}),` `,a.description]})]},e)})})]})]})}function Qi({step:e,note:r}){let[i,o]=a(`response`),[s,c]=a(),[l,u]=a(),[d,f]=a(),[p,m]=a(`json`),h=e.request,g=h?.opId?`${h.service}/${h.opId}`:void 0;n(()=>{o(`response`)},[e.name]),n(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),g&&h&&(w.schemas[g]?.().then(t=>e&&f(t.default)),N.operationMeta(g,A.value).then(t=>e&&m(t?.encoding??`json`)),w.responseSchemas[g]?.().then(t=>e&&c(t.default)),w.definitions[h.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[g]);let _=e.response,v=h?`${h.url}${ni(h.query)}`:``;return t(`div`,{class:`step-exchange`,children:[h&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${h.method}`,children:h.method}),t(`div`,{class:`rq-url`,title:v,children:t(`code`,{children:v})}),_&&t(`span`,{class:`result-chip ${tt(_.status)}`,children:[_.status,` `,et(_.status),` · `,_.durationMs,` ms`]})]}),r&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this step`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}})]},e.name),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,n])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>o(e),children:[n,e===`response`&&_&&t(`span`,{class:`state-dot ${tt(_.status)}`,children:_.status})]}))}),t(`div`,{class:`rq-pane`,children:[t(`div`,{class:`tab-pane`,hidden:i!==`request`,children:h?t(Qr,{request:h,encoding:p,sent:t(ii,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}):t(ii,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}),t(`div`,{class:`tab-pane`,hidden:i!==`response`,children:t(pi,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var $i=e=>e.replace(/ #\d+$/,``),ea={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``};function ta({info:e,preset:r,autoRun:i}){let{seq:c}=e,l=o(()=>Object.fromEntries(Object.entries(c.meta.inputs??{}).map(([e,t])=>[e,Bi(t)])),[c]),u=Mi(e),d=o(()=>{let e=new Set;for(let t of c.nodes)if(t.kind===`step`&&typeof t.def!=`function`)e.add(t.def.op.service);else if(t.kind===`step`||t.kind===`each`)return;return[...e]},[c]),[f,p]=a({}),[m,h]=a(),[g,_]=a({}),[v,y]=a(!1),[b,x]=a(),[S,C]=a({}),[w,T]=a(0),[E,D]=a(!1),[O,k]=a(),j=Object.values(l).some(e=>e.generate),M=Object.keys(l).length>0||c.nodes.some(e=>e.kind===`input`),ee=async()=>(j&&await N.fakerReady(A.value,ae.value,ne.value).catch(()=>{}),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)])));n(()=>{let e=!0,t=e=>({...e,...r??{}});return p(t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)])))),j?ee().then(n=>{e&&(p(t(n)),i&&R({inputs:t(n),headless:!0}))}):i&&R({inputs:t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)]))),headless:!0}),h(void 0),_({}),x(void 0),()=>{e=!1}},[e.file]);let te=c.nodes.map(e=>e.name),ie=m?m.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):te.map(e=>({name:e})),F=ie[w]?.step,I=s(void 0),[oe,se]=a(!1),L=()=>{se(!0),I.current?.abort(),b?.resolve(S)},R=async(e={})=>{let t=new AbortController;I.current=t,se(!1),y(!0),h(void 0),k(void 0),_({}),T(0),D(!1);try{let n=await N.run(c,{env:P.value,version:A.value,inputs:e.inputs??f,locale:ae.value,seed:ne.value,signal:t.signal,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:e.headless?void 0:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),C(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Ui(t)]))),x({name:e,controls:r,resolve:e=>{x(void 0),n(e)}})})});h(n),yt.value=bt(n);let r=n.steps.filter(e=>e.kind!==`auth`).findIndex(e=>e.status===`fail`||e.status===`error`);r>=0&&T(r)}catch(e){k(e instanceof Error?e.message:String(e))}finally{I.current=void 0,y(!1),x(void 0)}},ce=m?.status;return t(`div`,{class:`sequence-panel ${E&&F?`sheet-open`:``}`,"data-seq":c.meta.id,children:[t(`div`,{class:`seq-left`,children:[t(Oi,{services:d}),t(Zi,{title:`Inputs`,specs:l,values:f,onChange:p}),t(`div`,{class:`seq-run`,children:[t(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:()=>R(),children:v?`Running…`:`▶ Run`}),v&&t(`button`,{type:`button`,class:`btn`,onClick:L,children:`Stop`}),M&&t(`button`,{type:`button`,class:`btn`,disabled:v,title:`Skip every question and use each input's default, as specbook test does`,onClick:async()=>{let e=await ee();p(e),await R({inputs:e,headless:!0})},children:`Run with defaults`}),t(re,{}),m&&t(`span`,{class:`badge ${ce}`,children:[ea[ce],` `,ce===`pass`?`Passed`:oe?`Stopped`:ce===`fail`?`Failed`:`Error`,` `,`· `,m.totals.passed,`/`,m.totals.steps,` steps · `,m.durationMs,`ms`]})]}),O&&t(`p`,{class:`error-text`,children:O}),t(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:ie.map((e,n)=>{let r=e.step,i=r?.status??g[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return t(`li`,{class:`jstep ${i} ${w===n?`picked`:``}`,children:[t(`div`,{class:`jmark`,children:ea[i]||n+1}),t(`div`,{class:`jbody`,children:[t(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let t=e.currentTarget;T(n),D(!0),requestAnimationFrame(()=>t.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[t(`span`,{class:`jname`,children:e.name}),r?.response&&t(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&t(`span`,{class:a.length?`error-text`:`muted`,children:[r.assertions.length-a.length,`/`,r.assertions.length,` checks`]})]}),r?.uses?.filter(e=>e.source===`capture`).map(e=>t(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,t(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,n])=>t(`span`,{class:`cap make`,title:$r(n),children:[`→ `,e,` `,t(`b`,{children:ei(n)})]})),r?.error&&t(`div`,{class:`error-text`,children:r.error}),a.map(e=>t(li,{a:e})),i===`skipped`&&t(`div`,{class:`muted`,children:oe?`Skipped: you stopped the run.`:`Skipped: an earlier step did not pass.`}),b&&g[e.name]===`paused`&&t(`div`,{class:`pause`,children:[t(`strong`,{children:[`Your turn: `,b.name]}),t(Zi,{title:`Choose`,specs:b.controls,values:S,onChange:C}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>b.resolve(S),children:`Continue ▶`})]})]})]})})})]}),t(`div`,{class:`seq-right ${E&&F?`sheet-open`:``}`,children:[F&&t(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>D(!1),children:[t(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,F.name]}),!F&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing run yet`}),t(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),F&&t(Qi,{step:F,note:u.notes.get($i(F.name))})]})]})}function na(e){let n=e.tab??`try`,r=t(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,class:`rq-tab ${n===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?t(wt,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(Ki,{info:e.info}):t(ta,{info:e.info,preset:e.preset,autoRun:e.autoRun})})]})}):t(wt,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(vt,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):t(zi,{service:e.service,op:e.op,variants:e.variants,initial:e.example,autoRun:e.autoRun},`${e.service}/${e.op.id}${e.example.startsWith(`saved:`)?`@${e.example}`:``}`)})]})})}export{na as Host};
@@ -1 +1 @@
1
- import{a as e,d as t,h as n,i as r,o as i,p as a,s as o,t as s,v as c,y as l}from"./panel-9eYU7Gz6.js";import{a as u,r as d,t as f}from"./mount-DfwluJy4.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:t,progress:n}){return e(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[e(`header`,{class:`header`,children:[e(`span`,{class:`sk-brand`,children:[e(`img`,{src:i,alt:``,width:`24`,height:`24`}),`Specbook`]}),e(`span`,{class:`sk-search`,"aria-hidden":`true`}),e(`span`,{class:`spacer`}),m.map(t=>e(`span`,{class:`sk-pill`,style:{width:`${t}px`},"aria-hidden":`true`})),e(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),e(`div`,{class:`layout`,"data-view":`splash`,children:[e(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[e(`span`,{class:`sk-filter`}),p.map(t=>e(`span`,{class:`sk-row`,style:{width:`${t}%`}}))]}),e(`main`,{class:`stage`,children:[e(`p`,{class:`sk-status`,children:n??`Opening…`}),e(`p`,{class:`sk-what`,title:t,children:t})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];o();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${r(e)}`;function M({initial:r}){let[i,o]=n(r),[c,u]=n(k.get(`spec`)??``),[p,m]=n(``),[g,_]=n(!1),b=a(void 0),x=async(e,t,n)=>{b.current??=new d,o({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>o({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?o({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;o({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=s(e.trim());if(t){if(!/^https?:\/\//i.test(t))return o({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};t(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):o({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?e(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):e(`main`,{class:`vw`,children:e(`div`,{class:`vw-card`,children:[e(`h1`,{children:`Specbook`}),e(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),e(`form`,{onSubmit:e=>{e.preventDefault(),S(c)},children:[e(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:c,onInput:e=>u(e.target.value),disabled:w}),e(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&e(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&e(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&e(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&e(N,{onApply:i.apply,title:i.open.title}),e(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,e(`label`,{class:`link`,children:[`choose one`,e(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),e(`details`,{children:[e(`summary`,{children:`Paste the document`}),e(`p`,{}),e(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),e(`p`,{}),e(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),e(`section`,{children:[e(`p`,{children:`Try one`}),e(`ul`,{children:D.map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,onClick:()=>S(t.url),children:t.label})}))})]}),v().length>0&&e(`section`,{children:[e(`p`,{children:`Recent`}),e(`ul`,{children:v().map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,title:t,onClick:()=>S(t),children:t})}))})]})]})})}function N({onApply:t,title:r}){let[i,a]=n(``);return e(`form`,{class:`vw-base`,onSubmit:e=>{e.preventDefault(),/^https?:\/\//i.test(i.trim())&&t(i.trim().replace(/\/$/,``))},children:[e(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),e(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${r}`,value:i,onInput:e=>a(e.target.value)}),e(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),e(`button`,{type:`button`,class:`link`,onClick:()=>t(void 0),children:`Continue with mock data`})]})}u().then(t=>{t||c(e(M,{initial:{kind:`idle`}}),O)});
1
+ import{a as e,d as t,h as n,i as r,o as i,p as a,s as o,t as s,v as c,y as l}from"./panel-nV09I7Wr.js";import{a as u,r as d,t as f}from"./mount-CLHBtIzR.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:t,progress:n}){return e(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[e(`header`,{class:`header`,children:[e(`span`,{class:`sk-brand`,children:[e(`img`,{src:i,alt:``,width:`24`,height:`24`}),`Specbook`]}),e(`span`,{class:`sk-search`,"aria-hidden":`true`}),e(`span`,{class:`spacer`}),m.map(t=>e(`span`,{class:`sk-pill`,style:{width:`${t}px`},"aria-hidden":`true`})),e(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),e(`div`,{class:`layout`,"data-view":`splash`,children:[e(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[e(`span`,{class:`sk-filter`}),p.map(t=>e(`span`,{class:`sk-row`,style:{width:`${t}%`}}))]}),e(`main`,{class:`stage`,children:[e(`p`,{class:`sk-status`,children:n??`Opening…`}),e(`p`,{class:`sk-what`,title:t,children:t})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];o();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${r(e)}`;function M({initial:r}){let[i,o]=n(r),[c,u]=n(k.get(`spec`)??``),[p,m]=n(``),[g,_]=n(!1),b=a(void 0),x=async(e,t,n)=>{b.current??=new d,o({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>o({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?o({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;o({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=s(e.trim());if(t){if(!/^https?:\/\//i.test(t))return o({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};t(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):o({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?e(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):e(`main`,{class:`vw`,children:e(`div`,{class:`vw-card`,children:[e(`h1`,{children:`Specbook`}),e(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),e(`form`,{onSubmit:e=>{e.preventDefault(),S(c)},children:[e(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:c,onInput:e=>u(e.target.value),disabled:w}),e(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&e(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&e(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&e(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&e(N,{onApply:i.apply,title:i.open.title}),e(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,e(`label`,{class:`link`,children:[`choose one`,e(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),e(`details`,{children:[e(`summary`,{children:`Paste the document`}),e(`p`,{}),e(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),e(`p`,{}),e(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),e(`section`,{children:[e(`p`,{children:`Try one`}),e(`ul`,{children:D.map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,onClick:()=>S(t.url),children:t.label})}))})]}),v().length>0&&e(`section`,{children:[e(`p`,{children:`Recent`}),e(`ul`,{children:v().map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,title:t,onClick:()=>S(t),children:t})}))})]})]})})}function N({onApply:t,title:r}){let[i,a]=n(``);return e(`form`,{class:`vw-base`,onSubmit:e=>{e.preventDefault(),/^https?:\/\//i.test(i.trim())&&t(i.trim().replace(/\/$/,``))},children:[e(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),e(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${r}`,value:i,onInput:e=>a(e.target.value)}),e(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),e(`button`,{type:`button`,class:`link`,onClick:()=>t(void 0),children:`Continue with mock data`})]})}u().then(t=>{t||c(e(M,{initial:{kind:`idle`}}),O)});
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Host-DsO9W5X8.js","./panel-nV09I7Wr.js","./panel-l1xvY4kI.css","./mount-CLHBtIzR.js","./registry-b_jzfqy0.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,c as t,d as n,h as r,l as i,m as a,n as o,o as s,p as c,r as l,s as u,u as d,v as f,y as p}from"./panel-nV09I7Wr.js";import{a as m,n as h}from"./mount-CLHBtIzR.js";import{a as g,c as _,d as v,environmentStore as y,f as b,h as x,i as S,l as C,loadManifests as w,m as T,mode as E,n as ee,o as D,p as te,r as O,s as k,t as ne,u as re}from"./registry-b_jzfqy0.js";var ie=Object.prototype.hasOwnProperty;function ae(e,t,n){for(n of e.keys())if(A(n,t))return n}function A(e,t){var n,r,i;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&A(e[r],t[r]););return r===-1}if(n===Set){if(e.size!==t.size)return!1;for(r of e)if(i=r,i&&typeof i==`object`&&(i=ae(t,i),!i)||!t.has(i))return!1;return!0}if(n===Map){if(e.size!==t.size)return!1;for(r of e)if(i=r[0],i&&typeof i==`object`&&(i=ae(t,i),!i)||!A(r[1],t.get(i)))return!1;return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((r=e.byteLength)===t.byteLength)for(;r--&&e.getInt8(r)===t.getInt8(r););return r===-1}if(ArrayBuffer.isView(e)){if((r=e.byteLength)===t.byteLength)for(;r--&&e[r]===t[r];);return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(ie.call(e,n)&&++r&&!ie.call(t,n)||!(n in t)||!A(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var oe,se,ce,le,ue=!0;typeof process<`u`&&({FORCE_COLOR:oe,NODE_DISABLE_COLORS:se,NO_COLOR:ce,TERM:le}={},ue=process.stdout&&process.stdout.isTTY);var j={enabled:!se&&ce==null&&le!==`dumb`&&(oe!=null&&oe!==`0`||ue),reset:M(0,0),bold:M(1,22),dim:M(2,22),italic:M(3,23),underline:M(4,24),inverse:M(7,27),hidden:M(8,28),strikethrough:M(9,29),black:M(30,39),red:M(31,39),green:M(32,39),yellow:M(33,39),blue:M(34,39),magenta:M(35,39),cyan:M(36,39),white:M(37,39),gray:M(90,39),grey:M(90,39),bgBlack:M(40,49),bgRed:M(41,49),bgGreen:M(42,49),bgYellow:M(43,49),bgBlue:M(44,49),bgMagenta:M(45,49),bgCyan:M(46,49),bgWhite:M(47,49)};function de(e,t){let n=0,r,i=``,a=``;for(;n<e.length;n++)r=e[n],i+=r.open,a+=r.close,~t.indexOf(r.close)&&(t=t.replace(r.rgx,r.close+r.open));return i+t+a}function fe(e,t){let n={has:e,keys:t};return n.reset=j.reset.bind(n),n.bold=j.bold.bind(n),n.dim=j.dim.bind(n),n.italic=j.italic.bind(n),n.underline=j.underline.bind(n),n.inverse=j.inverse.bind(n),n.hidden=j.hidden.bind(n),n.strikethrough=j.strikethrough.bind(n),n.black=j.black.bind(n),n.red=j.red.bind(n),n.green=j.green.bind(n),n.yellow=j.yellow.bind(n),n.blue=j.blue.bind(n),n.magenta=j.magenta.bind(n),n.cyan=j.cyan.bind(n),n.white=j.white.bind(n),n.gray=j.gray.bind(n),n.grey=j.grey.bind(n),n.bgBlack=j.bgBlack.bind(n),n.bgRed=j.bgRed.bind(n),n.bgGreen=j.bgGreen.bind(n),n.bgYellow=j.bgYellow.bind(n),n.bgBlue=j.bgBlue.bind(n),n.bgMagenta=j.bgMagenta.bind(n),n.bgCyan=j.bgCyan.bind(n),n.bgWhite=j.bgWhite.bind(n),n}function M(e,t){let n={open:`\x1b[${e}m`,close:`\x1b[${t}m`,rgx:RegExp(`\\x1b\\[${t}m`,`g`)};return function(t){return this!==void 0&&this.has!==void 0?(~this.has.indexOf(e)||(this.has.push(e),this.keys.push(n)),t===void 0?this:j.enabled?de(this.keys,t+``):t+``):t===void 0?fe([e],[n]):j.enabled?de([n],t+``):t+``}}function N(){}N.prototype={diff:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.callback;typeof n==`function`&&(r=n,n={}),this.options=n;var i=this;function a(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var o=t.length,s=e.length,c=1,l=o+s;n.maxEditLength&&(l=Math.min(l,n.maxEditLength));var u=n.timeout??1/0,d=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],t,e,0);if(f[0].oldPos+1>=s&&p+1>=o)return a([{value:this.join(t),count:t.length}]);var m=-1/0,h=1/0;function g(){for(var n=Math.max(m,-c);n<=Math.min(h,c);n+=2){var r=void 0,l=f[n-1],u=f[n+1];l&&(f[n-1]=void 0);var d=!1;if(u){var g=u.oldPos-n;d=u&&0<=g&&g<o}var _=l&&l.oldPos+1<s;if(!d&&!_)f[n]=void 0;else{if(r=!_||d&&l.oldPos+1<u.oldPos?i.addToPath(u,!0,void 0,0):i.addToPath(l,void 0,!0,1),p=i.extractCommon(r,t,e,n),r.oldPos+1>=s&&p+1>=o)return a(pe(i,r.lastComponent,t,e,i.useLongestToken));f[n]=r,r.oldPos+1>=s&&(h=Math.min(h,n-1)),p+1>=o&&(m=Math.max(m,n+1))}}c++}if(r)(function e(){setTimeout(function(){if(c>l||Date.now()>d)return r();g()||e()},0)})();else for(;c<=l&&Date.now()<=d;){var _=g();if(_)return _}},addToPath:function(e,t,n,r){var i=e.lastComponent;return i&&i.added===t&&i.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:i.count+1,added:t,removed:n,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:i}}},extractCommon:function(e,t,n,r){for(var i=t.length,a=n.length,o=e.oldPos,s=o-r,c=0;s+1<i&&o+1<a&&this.equals(t[s+1],n[o+1]);)s++,o++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=o,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split(``)},join:function(e){return e.join(``)}};function pe(e,t,n,r,i){for(var a=[],o;t;)a.push(t),o=t.previousComponent,delete t.previousComponent,t=o;a.reverse();for(var s=0,c=a.length,l=0,u=0;s<c;s++){var d=a[s];if(!d.removed){if(!d.added&&i){var f=n.slice(l,l+d.count);f=f.map(function(e,t){var n=r[u+t];return n.length>e.length?n:e}),d.value=e.join(f)}else d.value=e.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}else if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,s&&a[s-1].added){var p=a[s-1];a[s-1]=a[s],a[s]=p}}var m=a[c-1];return c>1&&typeof m.value==`string`&&(m.added||m.removed)&&e.equals(``,m.value)&&(a[c-2].value+=m.value,a.pop()),a}var me=new N;function he(e,t,n){return me.diff(e,t,n)}var ge=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,_e=/\S/,ve=new N;ve.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!_e.test(e)&&!_e.test(t)},ve.tokenize=function(e){for(var t=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),n=0;n<t.length-1;n++)!t[n+1]&&t[n+2]&&ge.test(t[n])&&ge.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var ye=new N;ye.tokenize=function(e){this.options.stripTrailingCr&&(e=e.replace(/\r\n/g,`
3
+ `));var t=[],n=e.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(var r=0;r<n.length;r++){var i=n[r];r%2&&!this.options.newlineIsToken?t[t.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),t.push(i))}return t};function be(e,t,n){return ye.diff(e,t,n)}var xe=new N;xe.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var Se=new N;Se.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Ce(e){"@babel/helpers - typeof";return Ce=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Ce(e)}var we=Object.prototype.toString,Te=new N;Te.useLongestToken=!0,Te.tokenize=ye.tokenize,Te.castInput=function(e){var t=this.options,n=t.undefinedReplacement,r=t.stringifyReplacer,i=r===void 0?function(e,t){return t===void 0?n:t}:r;return typeof e==`string`?e:JSON.stringify(Ee(e,null,null,i),i,` `)},Te.equals=function(e,t){return N.prototype.equals.call(Te,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Ee(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i,e));for(var a=0;a<t.length;a+=1)if(t[a]===e)return n[a];var o;if(we.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ee(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),Ce(e)===`object`&&e!==null){t.push(e),o={},n.push(o);var s=[],c;for(c in e)e.hasOwnProperty(c)&&s.push(c);for(s.sort(),a=0;a<s.length;a+=1)c=s[a],o[c]=Ee(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var De=new N;De.tokenize=function(e){return e.slice()},De.join=De.removeEmpty=function(e){return e};function Oe(e,t,n){return De.diff(e,t,n)}var P={"--":j.red,"··":j.grey,"++":j.green},ke=j.dim().italic,Ae=j.dim(`→`),je=j.dim(`·`),Me=j.dim(`↵`),Ne=(e,t)=>P[e](e+Fe(t))+`
4
+ `,Pe=(e,t)=>j.dim(`L`+String(e).padStart(t,`0`)+` `),Fe=e=>e.replace(/[ ]/g,je).replace(/\t/g,Ae).replace(/(\r?\n)/g,Me);function Ie(e,t,n){let r=e.removed?`--`:e.added?`++`:`··`,i=e.value.replace(/\r?\n$/,``).split(`
5
+ `),a=0,o,s=``;for(e.added?s+=P[r]().underline(ke(`Expected:`))+`
6
+ `:e.removed&&(s+=P[r]().underline(ke(`Actual:`))+`
7
+ `);a<i.length;a++)o=i[a],o!=null&&(t&&(s+=Pe(t+a,n)),s+=Ne(r,o||`
8
+ `));return s}function Le(e,t){let n=Oe(e,t),r=0,i=0,a=0,o,s,c,l,u,d=Ne(`··`,`[`);for(;r<n.length;r++)for(c=(o=n[r]).removed?`--`:o.added?`++`:`··`,o.added?d+=P[c]().underline(ke(`Expected:`))+`
9
+ `:o.removed&&(d+=P[c]().underline(ke(`Actual:`))+`
10
+ `),i=0;i<o.value.length;i++)for(l=o.value[i]&&typeof o.value[i]==`object`,s=Ue(o.value[i]).split(/\r?\n/g),a=0;a<s.length;)u=` `+s[a++]+(l?``:`,`),l&&a===s.length&&i+1<o.value.length&&(u+=`,`),d+=Ne(c,u);return d+Ne(`··`,`]`)}function Re(e,t,n=0){let r=0,i,a=``,o=be(e,t),s=String(t.split(/\r?\n/g).length-n).length;for(;r<o.length;r++)a+=Ie(i=o[r],n,s),n&&!i.removed&&(n+=i.count);return a}function ze(e,t){let n=he(e,t),r=0,i=``,a,o=e.length,s=t.length,c=Fe(e),l=Fe(t);if(a=n[r],o!==s&&a.removed&&n[r+1]){let i=a.count-n[r+1].count;i==0||(i>0?(t=` `.repeat(i)+t,l=` `.repeat(i)+l,s+=i):i<0&&(e=` `.repeat(-i)+e,c=` `.repeat(-i)+c,o+=-i))}if(i+=Be(c,l,o,s),o===s)for(a=` `;r<o;r++)a+=e[r]===t[r]?` `:`^`;else for(a=` `;r<n.length;r++)a+=(n[r].added||n[r].removed?`^`:` `).repeat(Math.max(n[r].count,0)),r+1<n.length&&(n[r].added&&n[r+1].removed||n[r].removed&&n[r+1].added)&&(n[r+1].count-=n[r].count);return i+j.red(a)}function Be(e,t,n=String(e).length,r=String(t).length){let i=4,a=Math.max(n,r),o=typeof e,s=typeof t;if(o!==s){i=2;let c=i+a-n,l=i+a-r;e+=` `.repeat(c)+j.dim(`[${o}]`),t+=` `.repeat(l)+j.dim(`[${s}]`),n+=c+o.length+2,r+=l+s.length+2,a=Math.max(n,r)}return P[`++`](`++`+t+` `.repeat(i+a-r)+ke(`(Expected)`))+`
11
+ `+P[`--`](`--`+e+` `.repeat(i+a-n)+ke(`(Actual)`))+`
12
+ `}function Ve(e,t){var n,r=0,i,a=Array.isArray(e),o=[],s=a?Array(e.length):{};if(a)for(r=0;r<s.length;r++)i=e[r],!i||typeof i!=`object`?s[r]=i:s[r]=Ve(i,t[r]);else{for(n in t)o.push(n);for(;r<o.length;r++)Object.prototype.hasOwnProperty.call(e,n=o[r])&&(!(i=e[n])||typeof i!=`object`?s[n]=i:s[n]=Ve(i,t[n]));for(n in e)s.hasOwnProperty(n)||(s[n]=e[n])}return s}function He(){var e=new Set;return function(t,n){return n===void 0?`[__VOID__]`:typeof n==`number`&&n!==n?`[__NAN__]`:typeof n==`bigint`?n.toString():!n||typeof n!=`object`?n:e.has(n)?`[Circular]`:(e.add(n),n)}}function Ue(e){return JSON.stringify(e,He(),2).replace(/"\[__NAN__\]"/g,`NaN`).replace(/"\[__VOID__\]"/g,`undefined`)}function We(e,t){if(Array.isArray(t)&&Array.isArray(e))return Le(e,t);if(t instanceof RegExp)return ze(``+e,``+t);let n=e&&typeof e==`object`,r=t&&typeof t==`object`;return n&&r&&(e=Ve(e,t)),r&&(t=Ue(t)),n&&(e=Ue(e)),t&&typeof t==`object`&&(e=Ue(Ve(e,t)),t=Ue(t)),n=typeof e==`string`,r=typeof t==`string`,n&&/\r?\n/.test(e)?Re(e,``+t):r&&/\r?\n/.test(t)?Re(``+e,t):n&&r?ze(e,t):Be(e,t)}var Ge=x({Assertion:()=>Ke,equal:()=>Ye,fixture:()=>nt,instance:()=>Qe,is:()=>Je,match:()=>$e,not:()=>L,ok:()=>qe,snapshot:()=>et,throws:()=>rt,type:()=>Ze,unreachable:()=>Xe});function F(e){e=e.replace(/\r?\n/g,`
13
+ `);let t=e.match(/^[ \t]*(?=\S)/gm),n=0,r=1/0,i=(t||[]).length;for(;n<i;n++)r=Math.min(r,t[n].length);return i&&r?e.replace(RegExp(`^[ \\t]{${r}}`,`gm`),``):e}var Ke=class extends Error{constructor(e={}){super(e.message),this.name=`Assertion`,this.code=`ERR_ASSERTION`,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.details=e.details||!1,this.generated=!!e.generated,this.operator=e.operator,this.expects=e.expects,this.actual=e.actual}};function I(e,t,n,r,i,a,o){if(e)return;let s=o||a;throw o instanceof Error?o:new Ke({actual:t,expects:n,operator:r,message:s,details:i&&i(t,n),generated:!o})}function qe(e,t){I(!!e,!1,!0,`ok`,!1,`Expected value to be truthy`,t)}function Je(e,t,n){I(e===t,e,t,`is`,We,`Expected values to be strictly equal:`,n)}function Ye(e,t,n){I(A(e,t),e,t,`equal`,We,`Expected values to be deeply equal:`,n)}function Xe(e){I(!1,!0,!1,`unreachable`,!1,`Expected not to be reached!`,e)}function Ze(e,t,n){let r=typeof e;I(r===t,r,t,`type`,!1,`Expected "${r}" to be "${t}"`,n)}function Qe(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";I(e instanceof t,e,t,`instance`,!1,`Expected value to be an instance of ${r}`,n)}function $e(e,t,n){typeof t==`string`?I(e.includes(t),e,t,`match`,!1,`Expected value to include "${t}" substring`,n):I(t.test(e),e,t,`match`,!1,`Expected value to match \`${String(t)}\` pattern`,n)}function et(e,t,n){e=F(e),t=F(t),I(e===t,e,t,`snapshot`,Re,`Expected value to match snapshot:`,n)}var tt=(e,t)=>Re(e,t,1);function nt(e,t,n){e=F(e),t=F(t),I(e===t,e,t,`fixture`,tt,`Expected value to match fixture:`,n)}function rt(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e(),I(!1,!1,!0,`throws`,!1,`Expected function to throw`,n)}catch(e){if(e instanceof Ke)throw e;typeof t==`function`?I(t(e),!1,!0,`throws`,!1,`Expected function to throw matching exception`,n):t instanceof RegExp&&I(t.test(e.message),!1,!0,`throws`,!1,`Expected function to throw exception matching \`${String(t)}\` pattern`,n)}}function L(e,t){I(!e,!0,!1,`not`,!1,`Expected value to be falsey`,t)}L.ok=L,Je.not=function(e,t,n){I(e!==t,e,t,`is.not`,!1,`Expected values not to be strictly equal`,n)},L.equal=function(e,t,n){I(!A(e,t),e,t,`not.equal`,!1,`Expected values not to be deeply equal`,n)},L.type=function(e,t,n){let r=typeof e;I(r!==t,r,t,`not.type`,!1,`Expected "${r}" not to be "${t}"`,n)},L.instance=function(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";I(!(e instanceof t),e,t,`not.instance`,!1,`Expected value not to be an instance of ${r}`,n)},L.snapshot=function(e,t,n){e=F(e),t=F(t),I(e!==t,e,t,`not.snapshot`,!1,`Expected value not to match snapshot`,n)},L.fixture=function(e,t,n){e=F(e),t=F(t),I(e!==t,e,t,`not.fixture`,!1,`Expected value not to match fixture`,n)},L.match=function(e,t,n){typeof t==`string`?I(!e.includes(t),e,t,`not.match`,!1,`Expected value not to include "${t}" substring`,n):I(!t.test(e),e,t,`not.match`,!1,`Expected value not to match \`${String(t)}\` pattern`,n)},L.throws=function(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e()}catch(e){typeof t==`function`?I(!t(e),!0,!1,`not.throws`,!1,`Expected function not to throw matching exception`,n):t instanceof RegExp?I(!t.test(e.message),!0,!1,`not.throws`,!1,`Expected function not to throw exception matching \`${String(t)}\` pattern`,n):t||I(!1,!0,!1,`not.throws`,!1,`Expected function not to throw`,n)}};var it=/\u001b\[[0-9;]*m/g,at=e=>e.replace(it,``),ot=/(?:\(|at )?([^\s()]+):(\d+):(\d+)\)?\s*$/;function st(e){if(!e)return;let t=e.split(`
14
+ `).slice(1).map(e=>({line:e,m:ot.exec(e)})),n=t[0]?.m?.[1];for(let{line:e,m:r}of t)if(!(!r||e.includes(`/core/src/assert`)||e.includes(`node_modules`))&&r[1]!==n)return{file:r[1],line:Number(r[2]),column:Number(r[3])}}function ct(e=`soft`){let t=[],n=(n,r)=>{let i=r.length-1;return(...a)=>{let o=typeof a[i]==`string`?a[i]:void 0;try{r(...a),t.push({label:o??n,operator:n,pass:!0,location:st(Error().stack)})}catch(r){if(r?.name!==`Assertion`||(t.push({label:at(String(r.message??o??n)),operator:n,pass:!1,actual:r.actual,expected:r.expects,diff:r.details?at(String(r.details)):void 0,location:st(Error().stack)}),e===`hard`))throw r}}},r=Ge,i={};for(let e of[`ok`,`is`,`equal`,`type`,`instance`,`match`,`throws`,`unreachable`,`snapshot`,`fixture`])typeof r[e]==`function`&&(i[e]=n(e,r[e]));let a=n(`not`,r.not);for(let e of Object.keys(r.not??{}))typeof r.not[e]==`function`&&(a[e]=n(`not.${e}`,r.not[e]));return i.not=a,{assert:i,results:t}}var lt=e=>typeof e.opts.default==`function`;function ut(e){return typeof e==`function`?e():e}var dt=class extends Error{};function ft(e,t){let n=e.opts.value;return n?n(t):t}function pt(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function mt(e,t,n){switch(t.kind){case`select`:{let r=t.opts.options;if(r.length===0)throw new dt(`No options available for "${e}"`);let i=r.map(e=>ft(t,e));if(n!==void 0){if(!i.some(e=>pt(e,n)))throw new dt(`Value for "${e}" is not one of the available options`);return n}let a=t.opts.default;return typeof a==`number`&&Number.isInteger(a)&&a>=0&&a<i.length&&typeof i[0]!=`number`?i[a]:typeof a==`function`?a(r):a!==void 0&&i.some(e=>pt(e,a))?a:i[0]}case`multiselect`:{let e=t.opts.options;if(n!==void 0)return n;let r=t.opts.default;return typeof r==`function`?r(e):r??[]}case`object`:{let e=t.opts.shape,r=n??{};return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,mt(e,t,r[e])]))}case`array`:{let r=n??t.opts.default??[],{min:i,max:a}=t.opts;if(i!==void 0&&r.length<i)throw new dt(`"${e}" needs at least ${i} items`);if(a!==void 0&&r.length>a)throw new dt(`"${e}" allows at most ${a} items`);return r.map(n=>mt(e,t.opts.item,n))}case`boolean`:return n??ut(t.opts.default)??!1;case`number`:return n??ut(t.opts.default)??0;default:return n??ut(t.opts.default)??``}}function ht(e,t={}){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,mt(e,n,t[e])]))}function gt(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t.kind===`select`||t.kind===`multiselect`){let n=t.opts.label,r=t.opts.options.map(e=>({label:n?n(e):String(ft(t,e)),value:ft(t,e)}));return[e,{kind:t.kind,options:r}]}return[e,{kind:t.kind,default:ut(t.opts.default),generated:lt(t)}]}))}var R=class extends Error{variable;constructor(e,t){super(e),this.variable=t,this.name=`AddressError`}},_t=[`authorizationUrl`,`tokenUrl`,`openIdConnectUrl`,`clientId`];function vt(e,t,n={},r={}){return{...e.vars,...e.environments?.[t]?.vars,...n,...r}}function yt(e,t,n){for(let t of S(e))if(D(t)||k(t))throw new R(`${n} cannot use {{${t}}}: only environment variables are available`);let r;try{r=re(e,t)}catch(e){throw e instanceof O?new R(`${n}: set ${e.variable}`,e.variable):e}if(typeof r==`object`&&r)throw new R(`${n} is not a text value`);let i=r==null?``:String(r).trim();if(/\{\{/.test(i))throw new R(`${n} still contains a placeholder: ${i}`);return i}function bt(e,t,n,r){let i=e.services[t]?.baseUrl,a=typeof i==`string`?i:i?.[n];if(!a)return;let o=`No base URL for ${t} in ${n}`,s=/\{\{/.test(a)?yt(a,r,o):a.trim();return s?s.replace(/\/+$/,``):void 0}function xt(e,t,n=`sign-in`){let r={...e};for(let e of _t){let i=r[e];if(typeof i!=`string`||!/\{\{/.test(i))continue;let a=yt(i,t,`${n} ${e}`);a?r[e]=a:delete r[e]}return r}function St(e,t=[],n=[]){let r=new Set([`mock`]),i=Object.values(e.services??{});i.some(e=>typeof e.baseUrl==`string`)&&r.add(`live`);for(let e of i)if(e.baseUrl&&typeof e.baseUrl==`object`)for(let t of Object.keys(e.baseUrl))r.add(t);for(let t of Object.keys(e.environments??{}))r.add(t);for(let e of t)r.add(e);for(let e of n)r.add(e);return[...r]}function Ct(e){let t={},n=e=>{if(!(D(e)||k(e)))return t[e]??={services:[],profiles:[]},t[e]};for(let[t,r]of Object.entries(e.services??{})){let e=typeof r.baseUrl==`string`?[r.baseUrl]:Object.values(r.baseUrl??{});for(let r of e)for(let e of S(r)){let r=n(e);r&&!r.services.includes(t)&&r.services.push(t)}}for(let[t,r]of Object.entries(e.auth??{}))for(let e of _t){let i=r.oauth?.[e];if(typeof i==`string`)for(let r of S(i))n(r)?.profiles.push({profile:t,field:e})}return t}var wt={comma:`,`,space:` `,pipe:`|`},Tt=e=>typeof Blob<`u`&&e instanceof Blob;function Et(e,t=`indices`,n=``,r=[]){if(typeof t==`string`||n||typeof e!=`object`||!e)Dt(n,e,r,typeof t==`string`?t:`indices`);else for(let[n,i]of Object.entries(e))Dt(n,i,r,t[n]??`indices`);return r}function Dt(e,t,n,r){if(t!=null){if(Array.isArray(t)&&r in wt&&t.every(e=>typeof e!=`object`||!e))n.push([e,t.map(String).join(wt[r])]);else if(Array.isArray(t))t.forEach((t,i)=>{Dt(r===`indices`||r in wt?`${e}[${i}]`:r===`brackets`?`${e}[]`:e,t,n,r)});else if(typeof t==`object`)for(let[i,a]of Object.entries(t))Dt(e?`${e}[${i}]`:i,a,n,r);else n.push([e,String(t)])}}function Ot(e,t=`indices`){return Et(e,t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}function kt(e){let t=new FormData,n=(e,n)=>{n!=null&&(Tt(n)?t.append(e,n,n.name??`file`):typeof n==`object`?t.append(e,new Blob([JSON.stringify(n)],{type:`application/json`})):t.append(e,String(n)))};for(let[t,r]of Object.entries(e??{}))if(Array.isArray(r))for(let e of r)n(t,e);else n(t,r);return t}function At(e){return JSON.stringify(typeof e==`string`?{query:e}:e)}function jt(e,t,n,r){switch(e){case`json`:return{body:JSON.stringify(t),contentType:`application/json`};case`graphql`:return{body:At(t),contentType:`application/json`};case`form`:return{body:Ot(t,n),contentType:`application/x-www-form-urlencoded`};case`text`:return{body:String(t),contentType:`text/plain`};case`multipart`:return{body:kt(t)};case`binary`:return{body:t,contentType:r||(Tt(t)&&t.type?t.type:`application/octet-stream`)};default:return{body:t}}}function Mt(e){if(Tt(e)){let t=e;return{file:t.name??`file`,type:t.type,size:t.size}}return Array.isArray(e)?e.map(Mt):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Mt(t)])):e}var z=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Nt=e=>[`string`,`number`,`boolean`].includes(typeof e);function Pt(e,t){return typeof t==`number`&&typeof e==`string`&&e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):typeof t==`string`&&typeof e==`number`?String(e):e}function Ft(e,t){if(z(e)&&z(t)){let n={...e};for(let[e,r]of Object.entries(t))e in n&&(n[e]=Ft(n[e],r));return n}if(Array.isArray(e)&&Array.isArray(t)){if(t.length===0)return e;if(t.every(Nt)&&e.every(Nt))return t;let n=e[0];return z(n)&&t.every(z)?t.map(e=>Ft(n,e)):e}return Nt(t)&&Nt(e)&&typeof t==typeof e?t:typeof e==`number`&&typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t))?Number(t):e}function It(e,t){let n={...e},r=Object.entries(t).filter(([,e])=>e!==void 0&&e!==``);for(let[e,t]of r)e in n&&!z(n[e])&&!Array.isArray(n[e])?n[e]=Pt(t,n[e]):r.length===1&&`id`in n&&/^(id|.*[a-z]Id|.*_id)$/.test(e)&&!z(n.id)&&!Array.isArray(n.id)&&(n.id=Pt(t,n.id));return n}var Lt=e=>Nt(e),Rt=new Set([`id`,`object`,`type`,`kind`,`created`,`updated`,`url`,`livemode`,`metadata`,`status`]);function zt(e,t=[],n=[],r=0){if(r>6)return n;if(z(e))for(let[i,a]of Object.entries(e))zt(a,[...t,i],n,r+1);else Array.isArray(e)?e.length&&zt(e[0],[...t,0],n,r+1):Lt(e)&&n.push({path:t,value:e});return n}var Bt=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n};function Vt(e,t,n=[],r=[],i=0){if(i>5)return r;if(z(e))for(let[a,o]of Object.entries(e))a===t&&Lt(o)?r.push([...n,a]):Vt(o,t,[...n,a],r,i+1);else Array.isArray(e)&&e.length&&Vt(e[0],t,[...n,0],r,i+1);return r}var Ht=(e,t)=>typeof e==typeof t||typeof t==`number`&&typeof e==`string`&&e.trim()!==``&&!Number.isNaN(Number(e));function Ut(e,t,n){let r=Bt(e,t.slice(0,-1));typeof r==`object`&&r&&(r[t[t.length-1]]=n)}function Wt(e,t,n){let r=structuredClone(e),i=new Set(zt(n).map(e=>e.path.join(`\0`)));for(let e of zt(t)){if(Bt(r,e.path)!==void 0)continue;let t=String(e.path[e.path.length-1]);if(Rt.has(t)||typeof e.path[e.path.length-1]==`number`)continue;let n=Vt(r,t).filter(e=>!i.has(e.join(`\0`)));if(n.length!==1)continue;let a=n[0],o=Bt(r,a);Ht(e.value,o)&&(Ut(r,a,Pt(e.value,o)),i.add(a.join(`\0`)))}return r}var Gt=/^(limit|per_?page|page_?size|size|count|max|max_?results|take)$/i;function Kt(e){return Array.isArray(e)?e[0]:typeof e==`string`&&e.includes(`,`)?e.split(`,`)[0]?.trim():e}function qt(e,t){let n=Object.entries(t).map(([e,t])=>[e,Kt(t)]).filter(([,e])=>Lt(e)&&e!==``);if(n.length===0)return e;let r=e=>{let t={...e};for(let[e,r]of n)e in t&&Lt(t[e])&&Ht(r,t[e])&&(t[e]=Pt(r,t[e]));return t},i=n.find(([e])=>Gt.test(e))?.[1],a=i!==void 0&&Number.isFinite(Number(i))?Math.min(Math.max(Math.trunc(Number(i)),1),10):void 0,o=e=>{if(!e.every(z))return e;let t=e.map(e=>r(e));if(a===void 0||t.length===0||t.length>=a)return t.slice(0,a??t.length);let n=t[0];return Array.from({length:a},(e,r)=>r<t.length?t[r]:{...n,...typeof n.id==`number`?{id:n.id+r}:{}})};if(Array.isArray(e))return o(e);if(z(e)){let t={...e},n=Object.entries(t).filter(([,e])=>Array.isArray(e)&&e.length>0&&e.every(z));if(n.length===1)t[n[0]?.[0]]=o(n[0]?.[1]);else return r(t);return t}return e}function Jt(e,t){let n=e;if(t.body!==void 0){let e=z(n)&&Array.isArray(t.body)&&t.body.length>0&&t.body.every(z)?t.body[0]:t.body;(z(n)&&z(e)||Array.isArray(n)&&Array.isArray(e))&&(n=Ft(n,e),z(n)&&z(e)&&(n=Wt(n,e,e)))}return z(n)&&t.path&&(n=It(n,t.path)),t.query&&(n=qt(n,t.query)),n}var Yt=e=>e>=200&&e<300,Xt=e=>e===void 0?e:JSON.parse(JSON.stringify(e));function Zt(e){let t=e.sleep??((e,t)=>new Promise((n,r)=>{if(t?.aborted)return r(Error(`Stopped before the API answered.`));let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Stopped before the API answered.`))},{once:!0})}));return async(n,r)=>{let i=n.mock,a=await e.loader.statuses(n.service,n.opId),o=n.mockStatus??a.find(Yt)??a[0]??200;if(i?.secured&&!n.headers.authorization&&!Object.keys(n.headers).some(e=>/api[-_]?key|token/i.test(e))&&n.mockStatus===void 0&&a.includes(401))return Qt(401,await e.loader.example(n.service,n.opId,401));let s={...i?.vars??{},...i?.pathParams??{},...i?.rawQuery??{}},c=async t=>{let r=Xt(await e.loader.example(n.service,n.opId,t));return Yt(t)&&(r=Jt(r,{body:n.body,path:i?.pathParams,query:i?.rawQuery})),r===void 0?void 0:C(r,s)},l={status:o,data:await c(o),headers:{},delayMs:0,respond:(e,t)=>{u={status:e,data:t}}},u;if(i?.hook&&await i.hook({vars:i.vars??{},body:n.body,query:i.rawQuery,path:i.pathParams,headers:n.headers},l),u){let e=await c(u.status);l.status=u.status,l.data=u.data===void 0?e:g(e,u.data)}return l.delayMs&&await t(l.delayMs,r),{...Qt(l.status,l.data),headers:{"content-type":`application/json`,...l.headers}}}}function Qt(e,t){return{status:e,headers:{"content-type":`application/json`},text:t===void 0?``:JSON.stringify(t),body:t}}var B=class extends Error{constructor(e){super(e),this.name=`OAuthError`}},$t=e=>`openIdConnectUrl`in e;function en(e){let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`&&/^https?:\/\//i.test(e)?e:void 0,r=n(t.authorization_endpoint),i=n(t.token_endpoint);if(!r||!i)throw new B(`The provider’s discovery document has no authorization or token endpoint`);let a=[`openid`,...(Array.isArray(t.scopes_supported)?t.scopes_supported.filter(e=>typeof e==`string`):[]).filter(e=>e!==`openid`)];return{authorizationUrl:r,tokenUrl:i,scopes:Object.fromEntries(a.map(e=>[e,``]))}}var tn=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},nn=e=>tn(crypto.getRandomValues(new Uint8Array(e)));async function rn(e){if(!globalThis.crypto?.subtle)throw new B(`Sign-in needs a secure page (https, or localhost). Open the viewer over https, or paste an access token.`);let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return tn(new Uint8Array(t))}async function an(){let e=nn(48);return{verifier:e,challenge:await rn(e)}}var on=()=>nn(24);function sn(e){let t=new URL(e.authorizationUrl);return t.searchParams.set(`response_type`,`code`),t.searchParams.set(`client_id`,e.clientId),t.searchParams.set(`redirect_uri`,e.redirectUri),e.scopes?.length&&t.searchParams.set(`scope`,e.scopes.join(` `)),t.searchParams.set(`state`,e.state),t.searchParams.set(`code_challenge`,e.challenge),t.searchParams.set(`code_challenge_method`,`S256`),t.toString()}function cn(e,t){let n=t=>(e instanceof URLSearchParams?e.get(t):e[t])??void 0,r=n(`error`);if(r){let e=n(`error_description`);throw new B(`Sign-in was refused: ${e?`${r} (${e})`:r}`)}if(n(`state`)!==t)throw new B(`Sign-in was rejected: the response did not match this request (state)`);let i=n(`code`);if(!i)throw new B(`Sign-in returned no authorization code`);return{code:i}}function ln(e){return{grant_type:`authorization_code`,code:e.code,redirect_uri:e.redirectUri,client_id:e.clientId,code_verifier:e.verifier}}function un(e){let t=e&&typeof e==`object`?e:{};if(typeof t.error==`string`){let e=typeof t.error_description==`string`?` (${t.error_description})`:``;throw new B(`The token endpoint refused the code: ${t.error}${e}`)}if(typeof t.access_token!=`string`||t.access_token===``)throw new B(`The token endpoint returned no access token`);return{accessToken:t.access_token,...typeof t.expires_in==`number`?{expiresIn:t.expires_in}:{},...typeof t.scope==`string`?{scope:t.scope}:{}}}var dn=123,fn=125,pn=e=>e===32||e===9||e===10||e===13,mn=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e===45,hn=[115,101,99,114,101,116,115,46];function gn(e,t){let n=t+2;for(;n<e.length&&pn(e[n]);)n++;for(let t of hn)if(e[n++]!==t)return;let r=n;for(;n<e.length&&mn(e[n]);)n++;if(n===r)return;let i=String.fromCharCode(...e.subarray(r,n));for(;n<e.length&&pn(e[n]);)n++;if(e[n]===fn&&e[n+1]===fn)return{start:t,end:n+2,name:i}}function _n(e){let t=[];for(let n=0;n<e.length-1;n++)if(e[n]===dn&&e[n+1]===dn){let r=gn(e,n);r&&(t.push(r),n=r.end-1)}return t}var vn=new TextEncoder;function yn(e){return[...new Set(_n(e).map(e=>e.name))]}function bn(e,t){let n=_n(e).filter(e=>t.has(e.name));if(n.length===0)return e;let r=[],i=0;for(let a of n)r.push(e.subarray(i,a.start),vn.encode(t.get(a.name))),i=a.end;r.push(e.subarray(i));let a=new Uint8Array(r.reduce((e,t)=>e+t.length,0)),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}var xn=new TextDecoder;function Sn(e,t){return e.includes(`{{`)?xn.decode(bn(vn.encode(e),t)):e}var Cn=new TextDecoder(`utf-8`,{fatal:!0}),wn=new TextEncoder;function Tn(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function En(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Dn(e){try{return{kind:`text`,text:Cn.decode(e)}}catch{return{kind:`b64`,b64:Tn(e)}}}function On(e){return e.kind===`text`?wn.encode(e.text):En(e.b64)}async function kn(e){let t={};e.headers.forEach((e,n)=>{t[n]=e});let n=e.method!==`GET`&&e.method!==`HEAD`&&e.body!==null;return{method:e.method,url:e.url,headers:t,...n?{body:Dn(new Uint8Array(await e.arrayBuffer()))}:{}}}function An(e){let t=e.status===204||e.status===205||e.status===304;return new Response(e.body&&!t?On(e.body):null,{status:e.status,headers:e.headers})}var jn=class extends Error{names;constructor(e){super(`Missing secrets: ${e.join(`, `)}`),this.names=e,this.name=`MissingSecretsError`}},Mn=3;function Nn(e){let t=new Set([e]),n=e=>{try{t.add(e())}catch{}};return n(()=>encodeURIComponent(e)),n(()=>encodeURI(e)),n(()=>JSON.stringify(e).slice(1,-1)),n(()=>btoa(String.fromCharCode(...new TextEncoder().encode(e)))),[...t]}function Pn(e,t){let n=[...new Set([...t].filter(e=>e.length>=Mn).flatMap(Nn))].sort((e,t)=>t.length-e.length);if(n.length===0)return e;let r=e=>n.reduce((e,t)=>e.split(t).join(`***`),e),i=e=>typeof e==`string`?r(e):Array.isArray(e)?e.map(i):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[r(e),i(t)])):e;return i(e)}function Fn(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t.query))for(let t of Array.isArray(r)?r:[r])n.append(e,t);let r=n.toString();return`${e.replace(/\/+$/,``)}${t.url}${r?`?${r}`:``}`}function In(e,t){try{return new URL(e,t).toString()}catch{return e}}var Ln={ECONNREFUSED:`connection refused`,ENOTFOUND:`host not found`,EAI_AGAIN:`host not found`,ECONNRESET:`connection reset`,ETIMEDOUT:`connection timed out`,UND_ERR_CONNECT_TIMEOUT:`connection timed out`,EHOSTUNREACH:`host unreachable`,ENETUNREACH:`network unreachable`};function Rn(e,t){let n=e?.cause;if(!(e instanceof TypeError)||!n)return e;let r=n.code??n.errors?.find(e=>e.code)?.code,i=r&&/^CERT_|^ERR_TLS|SELF_SIGNED|UNABLE_TO_VERIFY/.test(r)?`certificate problem`:``,a=typeof n.message==`string`&&n.message.length<=120?n.message:``,o=r&&Ln[r]||i||a;if(!o)return e;let s=t;try{s=new URL(t).host}catch{}return Error(`Could not reach ${s}: ${o}.`,{cause:e})}function zn(e){return async(t,n)=>{if(n?.aborted)throw Error(`Stopped before the API answered.`);let r=e.fetch??fetch,i={...t.headers},a;if(t.body!==void 0&&t.method!==`GET`&&t.method!==`HEAD`){let e=jt(t.encoding,t.body,t.formArrays,t.mediaType);a=e.body,e.contentType&&(i[`content-type`]??=e.contentType)}let o=new AbortController,s=!1,c=t.timeoutMs?setTimeout(()=>{s=!0,o.abort()},t.timeoutMs):void 0;n?.addEventListener(`abort`,()=>o.abort());let l=Fn(e.baseUrl(t.service),t);try{let e=await r(l,{method:t.method,headers:i,body:a,signal:o.signal}),n=await e.text(),s={};e.headers.forEach((e,t)=>{s[t.toLowerCase()]=e});let c=n;if(n.length===0)c=void 0;else try{c=JSON.parse(n)}catch{c=n}return{status:e.status,headers:s,text:n,body:c}}catch(e){throw s?Error(`Timed out after ${t.timeoutMs}ms: no answer from the API.`):n?.aborted?Error(`Stopped before the API answered.`):Rn(e,l)}finally{c&&clearTimeout(c)}}}var V=()=>Date.now(),Bn=class extends Error{};function Vn(){return`run_${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}var Hn=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]));function Un(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=typeof r==`function`?r():r;return t}async function Wn(e){return typeof e==`function`?(await e()).default:e}async function Gn(e,t,n){if(t.length===0)return Array.isArray(e)?Promise.all(e.map(e=>typeof e==`string`?n(e):e)):typeof e==`string`?n(e):e;if(Array.isArray(e))return Promise.all(e.map(e=>Gn(e,t,n)));let[r,...i]=t;return _(e)&&r in e?{...e,[r]:await Gn(e[r],i,n)}:e}async function Kn(e,t,n,r,i){let a=e=>r(e,i);if(n===`binary`)return typeof e==`string`?a(e):e;let o=e;for(let e of t)o=await Gn(o,e.split(`.`),a);return o}function qn(e,t,n){let r=new Set,i=[];for(let a of e){if(D(a)||k(a))continue;let e=v(a);if(!r.has(e)){r.add(e);for(let r=t.length-1;r>=0;r--){let[a,o]=t[r];if(e in o){let s=a===`capture`?{key:e,source:a,step:n[e]}:{key:e,source:a};if(a===`capture`){let n=t.slice(0,r).reverse().find(([,t])=>e in t),[i,a]=[typeof n?.[1][e],typeof o[e]];n&&i!==a&&(s.shadows={source:n[0],type:i,replacedBy:a})}i.push(s);break}}}}return i}function Jn(e,t,n){let r=e=>e.replace(/\{\{\s*((?:secrets|session)\.[\w$-]+)\s*\}\}/g,(e,r)=>{let[i,a]=r.split(`.`);if(i===`secrets`){let n=t.o.secrets?.[a];if(n===void 0&&(t.o.env===`mock`||t.o.deferSecrets))return e;if(n===void 0)throw new jn([a]);return t.mask.add(n),n}let o=(n?t.sessions.get(`${t.o.env}:${n}`)?.session:void 0)?.[a];if(o===void 0)throw new Bn(`No session value "${a}" for profile "${n}"`);return t.mask.add(String(o)),String(o)}),i=e=>Tt(e)?e:typeof e==`string`?r(e):Array.isArray(e)?e.map(i):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,i(t)])):e;return i(e)}function H(e,t){e.o.onEvent?.(e.mask.size?Pn(t,e.mask):t)}var Yn=new Set([`GET`,`HEAD`,`OPTIONS`]);function Xn(e,t){if(e.input.safe||Yn.has(t.method))return!0;if(t.encoding===`graphql`){let e=t.body;return typeof e?.query==`string`&&!/(^|[\s}])mutation\b/.test(e.query)}return!1}function Zn(e,t){if(t.op.security===!1)return;let n=t.input.auth===void 0?e.seqAuth:t.input.auth;if(n===!1)return;let r=n??e.o.serviceAuth?.[t.op.service];return r&&e.o.auth?.[r]?r:void 0}function Qn(e,t){return{status:e.status,ok:e.status>=200&&e.status<300,headers:Hn(e.headers),data:e.body,text:e.text,durationMs:t}}async function $n(e,t,n,r=!1){let i=e.o.auth?.[t];if(!i.login||!i.token)return;let a=`${e.o.env}:${t}`,o=e.sessions.get(a);if(o&&(o.expiresAt===void 0||o.expiresAt>(e.o.now?.()??V()))&&!r)return;let s=e.inflight.get(a);if(s)return s;let c=(async()=>{let r=i;H(e,{type:`auth:login`,profile:t});let{result:o,response:s}=await tr(e,await r.login(),`Login (${t})`,er,`auth`,!0);if(n.push(o),!s?.ok)throw new Bn(`Login for profile "${t}" failed (${s?.status})`);let c=r.token(s),l=typeof c.expiresIn==`number`?(e.o.now?.()??V())+c.expiresIn*1e3:void 0;e.sessions.set(a,{session:c,expiresAt:l});for(let t of Object.values(c))typeof t==`string`&&e.mask.add(t)})().finally(()=>e.inflight.delete(a));return e.inflight.set(a,c),c}var er={inputs:{},captured:{},from:{}};async function tr(e,t,n,r,i=`request`,a=!1){let o=e.o.now?.()??V(),s=[],c={name:n,kind:i,status:`pass`,assertions:[],captured:{},durationMs:0},l=t.input.assertMode??e.seqAssertMode??e.o.assertMode??`soft`;H(e,{type:`step:start`,name:n});let u;try{let o=[[`config`,e.o.vars??{}],[`init`,Un(t.input.init)],[`input`,r.inputs],[`capture`,r.captured],[`override`,Un(t.varOverrides)],[`override`,e.o.overrides??{}]],d=Object.assign({},...o.map(e=>e[1])),f;if(t.input.example&&(f=await e.o.example?.(t.op,t.input.example),!f))throw new Bn(`Example "${t.input.example}" not found for ${t.op.id}`);let p=g(f?.body,await Wn(t.input.data));for(let e of t.dataPatches)p=g(p,e);let m=g(f?.path??{},t.input.path??{}),h=g(f?.query??{},t.input.query??{}),_={...f?.headers??{},...t.input.headers??{}};c.uses=qn(S([p,m,h,_]),o,r.from);let v=p===void 0?void 0:C(p,d),y=C(m,d)??{},b=C(h,d)??{},x=Hn(C(_,d)),w=t.input.encoding??t.op.encoding??(v===void 0?`none`:`json`);v!==void 0&&e.o.readFile&&(t.op.files?.length||w===`binary`)&&(v=await Kn(v,t.op.files??[],w,e.o.readFile,f?.dir));let T=a?void 0:Zn(e,t),E=T?e.o.auth?.[T]:void 0,ee={};E&&T&&(x={...Hn(C(E.apply.headers??{},d)),...x},Object.assign(ee,C(E.apply.query??{},d)));let D=t.op.path.replace(/\{([^}]+)\}/g,(e,t)=>{let n=y[t];if(n==null)throw new Bn(`Missing path parameter "${t}"`);return encodeURIComponent(String(n))}),te={};for(let[e,t]of Object.entries({...b,...ee}))t!=null&&(te[e]=Array.isArray(t)?t.map(String):String(t));let O={service:t.op.service,opId:t.op.id,method:t.op.method,url:D,query:te,headers:x,body:v,encoding:w,mediaType:w===`binary`?t.op.mediaType:void 0,formArrays:t.op.formArrays,timeoutMs:t.input.timeoutMs??e.o.timeoutMs??3e4,mockStatus:e.o.env===`mock`?e.o.mockStatus:void 0,mock:e.o.env===`mock`?{hook:t.mockHook,vars:d,pathParams:y,rawQuery:b,secured:t.op.security}:void 0};if(c.request={opId:t.op.id,method:O.method,service:O.service,url:O.url,query:O.query,headers:O.headers,body:Mt(O.body),profile:T},H(e,{type:`request`,name:n,request:c.request}),e.o.readOnly&&i!==`auth`&&!Xn(t,O))throw new Bn(`Refusing ${O.method} ${t.op.path} in "${e.o.env}": this is a --safe run, which only reads.`);let k=async()=>{T&&await $n(e,T,s);let{mock:t,...n}=O,r={...Jn(n,e,T),mock:t},i=e.o.now?.()??V();return Qn(await e.o.transport(r,e.o.signal),(e.o.now?.()??V())-i)};u=await k(),u.status===401&&T&&E?.retryOn401!==!1&&E?.login&&(await $n(e,T,s,!0),u=await k()),c.response={status:u.status,headers:u.headers,body:u.data,durationMs:u.durationMs},H(e,{type:`response`,name:n,status:u.status,durationMs:u.durationMs});for(let[e,n]of Object.entries(t.input.capture??{}))c.captured[e]=n(u,d);if(H(e,{type:`capture`,name:n,captured:c.captured}),t.input.assert){let r=ct(l);try{await t.input.assert(u,{assert:r.assert,vars:{...d,...c.captured},req:c.request})}catch(e){e?.name!==`Assertion`&&(c.status=`error`,c.error=`assert threw: ${e?.message??e}`)}c.assertions=r.results;for(let t of r.results)H(e,{type:t.pass?`assert:pass`:`assert:fail`,name:n,assertion:t})}else if(e.o.implicitStatusCheck&&i===`request`){let t=u.status>=200&&u.status<300,r={label:`status is 2xx`,operator:`status`,pass:t,actual:u.status,expected:`2xx`};c.assertions=[r],H(e,{type:t?`assert:pass`:`assert:fail`,name:n,assertion:r})}c.status===`pass`&&c.assertions.some(e=>!e.pass)&&(c.status=`fail`)}catch(e){c.status=`error`,c.error=e instanceof Error?e.message:String(e)}return c.durationMs=(e.o.now?.()??V())-o,H(e,{type:`step:end`,name:n,status:c.status}),{result:c,response:u,authResults:s}}function nr(e){let t={steps:0,passed:0,failed:0,skipped:0,assertions:{passed:0,failed:0}},n=e=>{if(e.children?.length)e.children.forEach(n);else{t.steps++,e.status===`pass`?t.passed++:e.status===`skipped`?t.skipped++:t.failed++;for(let n of e.assertions)n.pass?t.assertions.passed++:t.assertions.failed++}};return e.forEach(n),t}function rr(e){let t=[],n=e=>{t.push(e),e.children?.forEach(n)};return e.forEach(n),t.some(e=>e.status===`error`)?`error`:t.some(e=>e.status===`fail`)?`fail`:`pass`}function ir(e,t,n,r,i){let a=Pn({schemaVersion:1,runId:Vn(),kind:t,id:n.id,title:n.title,env:e.o.env,locale:e.o.locale,seed:e.o.seed,usedDrafts:e.o.usedDrafts??!1,tags:n.tags??[],status:rr(r),startedAt:new Date(i).toISOString(),durationMs:(e.o.now?.()??V())-i,totals:nr(r),steps:r},e.mask);return H(e,{type:`done`,result:a}),a}function ar(e){return{o:e,sessions:new Map,inflight:new Map,mask:new Set(Object.values(e.secrets??{}))}}async function or(e,t){let n=ar(t),r=t.now?.()??V();H(n,{type:`run:start`,id:e.op.id,title:e.input.name??e.op.id,kind:`request`,tags:e.input.tags});let i=e.input.name??e.op.id,{result:a,authResults:o}=await tr(n,e,i,er);return ir(n,`request`,{id:e.op.id,title:i,tags:e.input.tags},[...o,a],r)}async function sr(e,t){let n=ar(t);n.seqAuth=e.meta.auth,n.seqAssertMode=e.meta.assertMode;let r=t.now?.()??V();H(n,{type:`run:start`,id:e.meta.id,title:e.meta.title,kind:`sequence`,tags:e.meta.tags});let i=[],a={},o={},s=(e,t)=>{Object.assign(a,e);for(let n of Object.keys(e))o[n]=t},c;try{c=ht(e.meta.inputs??{},t.inputs)}catch(t){return i.push({name:`inputs`,kind:`input`,status:`error`,assertions:[],captured:{},error:t.message,durationMs:0}),ir(n,`sequence`,e.meta,i,r)}let l=t.vars??{},u=()=>({inputs:c,captured:a,vars:{...l,...t.overrides??{}},env:t.env}),d=!1,f=(e,t)=>i.push({name:e,kind:t,status:`skipped`,assertions:[],captured:{},durationMs:0});for(let r of e.nodes)if(d&&!e.meta.continueOnFailure)f(r.name,r.kind===`step`?`request`:r.kind);else if(t.signal?.aborted)f(r.name,r.kind===`step`?`request`:r.kind),d=!0;else try{if(r.kind===`step`){let{result:e,authResults:t}=await tr(n,typeof r.def==`function`?r.def(u()):r.def,r.name,{inputs:c,captured:a,from:o});i.push(...t,e),s(e.captured,r.name),e.status!==`pass`&&(d=!0)}else if(r.kind===`each`){let l=r.items(u()),f={name:r.name,kind:`each`,status:`pass`,assertions:[],captured:{},durationMs:0,children:[]},p=t.now?.()??V(),m={};for(let t=0;t<l.length;t++){let{result:i,authResults:s}=await tr(n,r.def(l[t],u(),t),`${r.name} #${t+1}`,{inputs:c,captured:a,from:o});f.children?.push(...s,i);for(let[e,t]of Object.entries(i.captured))m[e]??=[],m[e]?.push(t);if(i.status!==`pass`&&(f.status=i.status,!e.meta.continueOnFailure))break}f.captured=m,f.durationMs=(t.now?.()??V())-p,s(m,r.name),i.push(f),f.status!==`pass`&&(d=!0)}else if(r.kind===`input`){let e=r.controls(u()),a=gt(e);H(n,{type:`input:required`,name:r.name,controls:a});let o=ht(e,t.onInput?await t.onInput({name:r.name,controls:a}):t.inputs??{});c={...c,...o},i.push({name:r.name,kind:`input`,status:`pass`,assertions:[],captured:o,durationMs:0})}else if(r.kind===`check`){let a=ct(e.meta.assertMode??t.assertMode??`soft`),o={name:r.name,kind:`check`,status:`pass`,assertions:[],captured:{},durationMs:0};H(n,{type:`step:start`,name:r.name});try{await r.fn(u(),{assert:a.assert})}catch(e){e?.name!==`Assertion`&&(o.status=`error`,o.error=e?.message??String(e))}o.assertions=a.results,o.status===`pass`&&a.results.some(e=>!e.pass)&&(o.status=`fail`),H(n,{type:`step:end`,name:r.name,status:o.status}),i.push(o),o.status!==`pass`&&(d=!0)}}catch(e){let t=e instanceof dt;i.push({name:r.name,kind:r.kind===`step`?`request`:r.kind,status:`error`,assertions:[],captured:{},error:t?e.message:e?.message??String(e),durationMs:0}),d=!0}return ir(n,`sequence`,e.meta,i,r)}var U=d({links:[],ready:!1});function cr(e){let t=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return;let n=t[1].length===3?[...t[1]].map(e=>e+e).join(``):t[1];return[0,2,4].map(e=>Number.parseInt(n.slice(e,e+2),16))}function lr(e){let t=cr(e);if(!t)return;let n=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}),r=.2126*n[0]+.7152*n[1]+.0722*n[2],i=1.05/(r+.05);return(r+.05)/.056>i?`#0b1020`:`#ffffff`}var ur=e=>`--sb-accent:${e};--sb-accent-hover:color-mix(in srgb,${e} 82%,black);--sb-focus-ring:color-mix(in srgb,${e} 45%,white);`+(lr(e)?`--sb-text-on-accent:${lr(e)};`:``);function dr(e,t=`root`){if(!e.accent&&!e.accentDark)return``;let n=t===`host`?`:host`:`:root`,r=t===`host`?`:host(:not([data-theme="light"]))`:`:root:not([data-theme="light"])`,i=t===`host`?`:host([data-theme="dark"])`:`:root[data-theme="dark"]`,a=e.accent?`${n}{${ur(e.accent)}}`:``;return e.accentDark?`${a}@media (prefers-color-scheme: dark){${r}{${ur(e.accentDark)}}}${i}{${ur(e.accentDark)}}`:a}function fr(e,t,n){if(typeof document>`u`)return;let r=document.getElementById(`specbook-brand`);r||(r=document.createElement(`style`),r.id=`specbook-brand`,document.head.append(r)),r.textContent=e?dr(e):``;let i=t.name??n;if(document.title=t.title?`${i} · ${t.title}`:i,t.favicon||t.logo){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.append(e)),e.href=t.favicon??t.logo}}var pr;function mr(e){pr=e,typeof location<`u`&&(W.value=vr(location.hash))}var hr=e=>pr&&e.startsWith(`${pr}/`)?e.slice(pr.length+1):e,gr=e=>pr&&!e.includes(`/`)?`${pr}/${e}`:e,_r=e=>encodeURIComponent(e).replace(/%2F/gi,`/`);function vr(e){let[t=``,n=``]=e.split(`?`),r=new URLSearchParams(n),i=r.get(`play`)??void 0,a=r.get(`tab`),o=a===`docs`||a===`try`?a:void 0,s=/^#\/op\/(.+)$/.exec(t);if(s)return{kind:`op`,key:gr(decodeURIComponent(s[1])),play:i,tab:o};let c=/^#\/seq\/(.+)$/.exec(t);return c?{kind:`seq`,id:decodeURIComponent(c[1]),play:i,tab:o}:t===`#/browse`?{kind:`browse`}:{kind:`home`}}function yr(e){if(e.kind===`home`)return`#/`;if(e.kind===`browse`)return`#/browse`;let t=e.kind===`op`?`#/op/${_r(hr(e.key))}`:`#/seq/${encodeURIComponent(e.id)}`,n=new URLSearchParams;e.play!==void 0&&n.set(`play`,e.play),e.tab&&n.set(`tab`,e.tab);let r=n.toString();return r?`${t}?${r}`:t}var br=()=>typeof matchMedia==`function`&&matchMedia(`(max-width: 820px)`).matches,xr=e=>br()?{kind:`browse`}:{kind:`home`},W=d(vr(typeof location>`u`?``:location.hash)),G=d(!1),Sr=d(``),Cr=d(``);function K(e){location.hash=yr(e),W.value=e}function wr(e,t,n=40){let r=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return e.slice(0,n);let i=[];for(let t of e){let e=t.title.toLowerCase(),n=`${e} ${t.group.toLowerCase()} ${t.hay.toLowerCase()}`;if(!r.every(e=>n.includes(e)))continue;let a=0;for(let t of r)a+=e.startsWith(t)?3:e.includes(t)?2:1;t.kind===`seq`&&(a+=.5),t.kind===`req`&&(a+=.4),i.push([a,t])}return i.sort((e,t)=>t[0]-e[0]).slice(0,n).map(([,e])=>e)}function Tr({size:t=16}){return e(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[e(`path`,{d:`M3 3l19 9-19 9 3.5-9z`}),e(`path`,{d:`M6.5 12H14`})]})}function Er({size:t=12}){return e(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[e(`rect`,{x:`4`,y:`11`,width:`16`,height:`10`,rx:`2`}),e(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]})}function Dr({size:t=16}){return e(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[e(`path`,{d:`M12 15V3`}),e(`path`,{d:`M7.5 7.5 12 3l4.5 4.5`}),e(`path`,{d:`M5 11H4.5A1.5 1.5 0 0 0 3 12.5v7A1.5 1.5 0 0 0 4.5 21h15a1.5 1.5 0 0 0 1.5-1.5v-7a1.5 1.5 0 0 0-1.5-1.5H19`})]})}function Or({size:t=16}){return e(`svg`,{viewBox:`0 0 16 16`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,children:e(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 4 0c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z`})})}function kr({size:t=16}){return e(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,children:e(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`2`})})}function Ar(){let e=new Map;return{getItem:t=>e.get(t)??null,setItem:(t,n)=>void e.set(t,String(n)),removeItem:t=>void e.delete(t)}}function jr(e){try{let t=globalThis[e];if(t)return t}catch{}return Ar()}var Mr={get local(){return jr(`localStorage`)},get session(){return jr(`sessionStorage`)}},Nr=`specbook.environments.v1`,Pr={local:{},session:{}},Fr=e=>e===`local`?Mr.local:Mr.session;function Ir(e){try{let t=Fr(e).getItem(Nr);return t?JSON.parse(t):Pr[e]}catch{return Pr[e]}}function Lr(e,t){Pr[e]=t;try{Fr(e).setItem(Nr,JSON.stringify(t))}catch{}}function Rr(e,t=`local`){return{all:()=>Ir(t)[e]??{},save(n,r){let i=Ir(t);Lr(t,{...i,[e]:{...i[e],[n]:r}})},remove(n){let r=Ir(t),{[n]:i,...a}=r[e]??{};Lr(t,{...r,[e]:a})}}}var zr=`specbook`;function Br(e){return{version:e,send(e,t){return new Promise((n,r)=>{let i=e.id,a=e=>{let t=e.data;if(e.source!==window||t?.channel!==`${zr}:reply`||!t.reply)return;let r=t.reply;(i===void 0||r.id===i)&&(s(),n(t.reply))},o=()=>{s(),window.postMessage({channel:`${zr}:call`,call:{v:1,type:`abort`,id:i}},`*`),r(new DOMException(`aborted`,`AbortError`))},s=()=>{window.removeEventListener(`message`,a),t?.removeEventListener(`abort`,o)};window.addEventListener(`message`,a),t?.addEventListener(`abort`,o),window.postMessage({channel:`${zr}:call`,call:e},`*`)})}}}async function Vr(e=250){let t=globalThis.__SPECBOOK_EXTENSION__;if(t)return t;if(typeof window>`u`)return;let n=Br(1),r=new Promise(t=>setTimeout(()=>t(void 0),e)),i=await Promise.race([n.send({v:1,type:`ping`}).catch(()=>void 0),r]);return i?.type===`pong`?{...n,version:i.version}:void 0}var Hr=0;function Ur(e,t){return zn({baseUrl:t,fetch:async(t,n)=>{let r=new Request(t,n),i=`c${Date.now().toString(36)}${Hr++}`,a=await e.send({v:1,type:`fetch`,id:i,req:await kn(r)},n?.signal??void 0);if(a.type===`error`)throw Error(a.message);if(a.type!==`response`)throw Error(`unexpected reply from the extension`);return An(a.res)}})}var Wr=`specbook.secrets.v1`,Gr={},Kr=()=>{try{let e=Mr.session.getItem(Wr);return e?JSON.parse(e):Gr}catch{return Gr}},qr=e=>{Gr=e;try{Mr.session.setItem(Wr,JSON.stringify(e))}catch{}},Jr={get:(e,t)=>Kr()[e]?.[t],set(e,t,n){let r=Kr();qr({...r,[e]:{...r[e],[t]:n}})},remove(e,t){let n=Kr(),{[t]:r,...i}=n[e]??{};qr({...n,[e]:i})}},Yr=e=>{try{return e?new URL(e).origin:void 0}catch{return}},Xr=/\{\{\s*secrets\.([\w$-]+)\s*\}\}/g;function Zr(e){return e.proxy?`proxy`:e.pageOrigin&&Yr(e.baseUrl)===e.pageOrigin?`direct`:e.extension?`extension`:`direct`}var Qr=e=>{let t=new Set,n=e=>{if(typeof e==`string`)for(let n of yn(new TextEncoder().encode(e)))t.add(n);else Array.isArray(e)?e.forEach(n):e&&typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).forEach(n)};return n(e.headers),n(e.query),n(e.body),[...t]};function $r(e,t){return(n,r)=>{let i=Qr(n);if(i.length===0)return e(n,r);let a=t.originFor(n.service),o=new Map,s=[];for(let e of i){let n=a?t.store.get(a,e):void 0;n===void 0?s.push(e):o.set(e,n)}if(s.length&&t.unresolved===`fail`)throw new jn(s);let c=e=>typeof e==`string`?Sn(e,o):Array.isArray(e)?e.map(c):e&&typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,c(t)])):e;return e({...n,headers:c(n.headers),query:c(n.query),body:c(n.body)},r)}}function ei(e){return(t,n)=>{let r=Zr({proxy:!!e.proxy,extension:!!e.extension,baseUrl:e.baseOf(t.service),pageOrigin:e.pageOrigin});return((r===`proxy`?e.proxy:r===`extension`?e.extension:e.direct)??e.direct)(t,n)}}var ti=`auth:`,ni=e=>`${ti}${encodeURIComponent(e)}`,ri=`discovery:`,ii=e=>`${ri}${encodeURIComponent(e)}`,ai=/^[A-Za-z0-9_-]+$/,oi=/^[A-Za-z_][\w.-]*$/,si=e=>typeof e==`string`?/\{\{/.test(e):typeof e==`object`&&!!e&&Object.values(e).some(si),ci=e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``);function li(e,t={}){let n={statuses:(t,n)=>e.manifests[t]?.operations.find(e=>e.id===n)?.statuses??[],async example(t,n,r){let i=async r=>(await e.examples[`${t}/${n}.${r}`]?.(0))?.default;return await i(r)??await i(`default`)}};async function r(t){return(await e.loadConfig(t)).default}let i=()=>e.mode!==`dev`,a=()=>i()?t.environmentStore?.all()??{}:{},o=new Set;async function s(e){let t=await r(e),n={};for(let[e,r]of Object.entries(t.environments??{})){let t=r?.risk;(t===`production`||t===`sandbox`)&&(n[e]=t)}for(let[e,t]of Object.entries(a()))t.from&&n[t.from]&&!n[e]&&(n[e]=n[t.from]);return n}async function c(e){let t=await r(e),n={};for(let[e,r]of Object.entries(t.environments??{})){let t=r?.description;t&&(n[e]=t)}for(let[e,t]of Object.entries(a()))t.from&&(n[e]=`copy of ${t.from}, kept in this browser`);return n}async function l(t){let n=await r(t);return St({services:n.services??{},environments:n.environments},[...Object.keys(e.environmentVars??{}),...o],Object.keys(a()))}async function u(t){if(e.mode===`dev`)try{let e=await fetch(`/__specbook/environment?env=${encodeURIComponent(t)}`);if(e.ok)return(await e.json()).vars}catch{}return{...e.environmentVars?.[t],...a()[t]?.vars}}async function d(e,t){return vt(await r(t),e,await u(e))}async function f(e,t,n){return bt(await r(n),e,t,await d(t,n))}async function p(e,t,n){let i=(await r(n)).auth?.[e]?.oauth;return!i||!si(i)?i:xt(i,await d(t,n),e)}async function m(e,t){let n=vt(e,t,Object.values(e.services??{}).some(e=>si(e.baseUrl))||Object.values(e.auth??{}).some(e=>si(e.oauth))?await u(t):{});return{baseUrl(r){try{return bt(e,r,t,n)}catch{return}},oauth(t){let r=e.auth?.[t]?.oauth;try{return r?xt(r,n,t):void 0}catch{return}}}}async function h(n,o){let s=await r(o),c=s.vars??{},l=s.environments?.[n]?.vars??{},d=a()[n],f=i()?e.environmentVars?.[n]??{}:await u(n),p=d?.vars??{},m=[...new Set([...Object.keys(c),...Object.keys(l),...Object.keys(f),...Object.keys(p)])],h=e.mode===`dev`||!!t.environmentStore,g=m.map(e=>{let t=e in l?l[e]:c[e],n=e in p?`browser`:e in f?`file`:void 0,r=e in p?p[e]:e in f?f[e]:t,i=e in p&&e in f?f[e]:t;return{name:e,value:ci(r),source:n??(e in l?`config`:`default`),fallback:n&&i!==void 0?ci(i):void 0,editable:h}}),_=vt(s,n,{...f,...p}),v=[];if(n!==`mock`)for(let e of Object.keys(s.services??{}))try{let t=bt(s,e,n,_);v.push({service:e,...t?{url:t}:{}})}catch(t){if(!(t instanceof R))throw t;v.push({service:e,error:t.message})}return{rows:g,addresses:v,uses:Ct(s),removable:!!d?.from}}let _=()=>e.mode===`dev`||!!t.environmentStore;async function v(n,i,a){if(!ai.test(n))throw Error(`Use letters, digits, "-" and "_" in an environment name`);if(n===`mock`||(await l(a)).includes(n))throw Error(`"${n}" already exists`);if(e.mode===`dev`){let e=await fetch(`/__specbook/environment`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n,from:i})});if(!e.ok)throw Error((await e.json()).error??`could not create`);o.add(n);return}if(!t.environmentStore)throw Error(`This page has nowhere to keep a new environment`);let s={...(await r(a)).environments?.[i]?.vars??{},...await u(i)};t.environmentStore.save(n,{from:i,vars:Object.fromEntries(Object.entries(s).filter(([,e])=>e!==null&&typeof e!=`object`).map(([e,t])=>[e,String(t)]))})}async function y(n,r,i){if(!oi.test(r))throw Error(`"${r}" is not a variable name`);if(e.mode===`dev`){let e=await fetch(`/__specbook/var`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({env:n,name:r,value:i})});if(!e.ok)throw Error((await e.json()).error??`save failed`);return}let a=t.environmentStore;if(!a)throw Error(`This page has nowhere to keep a variable`);let o=a.all()[n]??{vars:{}},s={...o.vars};i===null?delete s[r]:s[r]=i,!o.from&&Object.keys(s).length===0?a.remove(n):a.save(n,{...o,vars:s})}function x(e){t.environmentStore?.remove(e)}async function S(e,t){let n=await r(t);return[...new Set([...Object.keys(n.vars??{}),...Object.keys(n.environments?.[e]?.vars??{}),...Object.keys(await u(e))])]}async function C(i,a,o,s={}){if(i===`mock`)return Zt({loader:n});let c=await r(o),l=Object.values(c.services??{}).some(e=>si(e.baseUrl))?await d(i,o):{},u=globalThis.location?.href,f=globalThis.location?.origin,p=e=>{if(s[e])return s[e];let t;try{t=bt(c,e,i,l)}catch(e){throw e instanceof R?Error(e.message):e}if(!t)throw Error(`No base URL for ${e} in ${i}`);return In(t,u)},m=e.mode!==`static`,h=await t.extension?.(),g=h?Ur(h,x):void 0,_=t.secrets??Jr,v=zn({baseUrl:p}),y=m?zn({baseUrl:e=>`${a}/${i}/${e}`}):void 0;return ei({direct:S($r(v,{store:_,originFor:b,unresolved:`fail`})),proxy:y?$r(y,{store:_,originFor:b,unresolved:`keep`}):void 0,extension:g?$r(g,{store:_,originFor:b,unresolved:`keep`}):void 0,baseOf:x,pageOrigin:f});function b(e){return Yr(x(e))}function x(e){try{return p(e)}catch{return``}}function S(e){return async(t,n)=>{try{return await e(t,n)}catch(e){throw e instanceof TypeError&&(t.service.startsWith(ti)||t.service.startsWith(ri))?Error(`The browser could not reach the sign-in provider (${s[t.service]??`unknown`}). It probably does not allow calls from this page (CORS). Embedding the viewer on the API's origin does not help when the sign-in server is on another host; the browser extension can make the call. You can still paste an access token.`):e instanceof TypeError?Error(`The browser could not reach ${t.service} in "${i}". The API probably does not allow calls from this page (CORS). It works when the viewer runs on the API's own origin: embed it in the API's docs route ("Embed the viewer" in the README). Mock data keeps working.`):e}}}}async function w(t){if(e.mode!==`dev`||t===`mock`)return{};try{let e=await fetch(`/__specbook/environment?env=${encodeURIComponent(t)}`);if(!e.ok)return{};let n=await e.json();return Object.fromEntries((n.secrets??[]).filter(e=>e.source).map(e=>[e.name,e.source]))}catch{return{}}}let E=new Map;async function D(e){if(e.env===`mock`)throw Error(`Sign in needs a live environment, not mock`);let t;try{t=await p(e.profile,e.env,e.version)}catch(e){throw e instanceof R?Error(e.message):e}if(!t)throw Error(`"${e.profile}" has no sign-in configured`);if(!$t(t))return{authorizationUrl:t.authorizationUrl,tokenUrl:t.tokenUrl,scopes:t.scopes??{}};let n=new URL(t.openIdConnectUrl),r=E.get(n.href);r||(r=(async()=>{let t=ii(e.profile),r=await(await C(e.env,e.proxyBase??`/__specbook/proxy`,e.version,{[t]:n.origin}))({service:t,opId:`oidc-discovery`,method:`GET`,url:n.pathname,query:Object.fromEntries(n.searchParams),headers:{accept:`application/json`},encoding:`none`},e.signal);if(r.status>=400)throw Error(`The provider's discovery document answered ${r.status}`);return en(r.body)})(),E.set(n.href,r),r.catch(()=>E.delete(n.href)));let i=await r;return{...i,scopes:t.scopes&&Object.keys(t.scopes).length?t.scopes:i.scopes}}async function O(e){let{tokenUrl:t}=await D(e),n=new URL(t),r=ni(e.profile),i=await(await C(e.env,e.proxyBase??`/__specbook/proxy`,e.version,{[r]:n.origin}))({service:r,opId:`oauth-token`,method:`POST`,url:n.pathname,query:Object.fromEntries(n.searchParams),headers:{accept:`application/json`},body:e.fields,encoding:`form`},e.signal),a=i.body;if(i.status>=400&&typeof a?.error!=`string`)throw Error(`The token endpoint answered ${i.status}`);return i.body}let k=e=>e.replace(/^\.\//,``),ne=t=>e.requestExamples[t]??[];async function re(e,t,n){let r=ne(e).find(e=>e.name===t);if(r)return{...(await r.load(n)).default,source:r.source,dir:r.dir}}async function ie(t,n){let r=await e.assets[`${n}/${k(t)}`]?.();if(!r)throw Error(`File "${t}" not found next to the example`);let i=await fetch(r);if(!i.ok)throw Error(`Could not read "${t}" (${i.status})`);return new File([await i.blob()],k(t).split(`/`).pop(),{type:i.headers.get(`content-type`)??void 0})}async function ae(e){let t=await r(e.version),n=t.auth??{},i=Object.fromEntries(Object.entries(t.services??{}).filter(([,e])=>e.auth).map(([e,t])=>[e,t.auth]));return{env:e.env,vars:await d(e.env,e.version),overrides:e.vars,inputs:e.inputs,transport:await C(e.env,e.proxyBase??`/__specbook/proxy`,e.version),deferSecrets:!0,auth:n,serviceAuth:i,onEvent:e.onEvent,onInput:e.onInput,signal:e.signal,timeoutMs:t.timeoutMs,example:(t,n)=>re(`${t.service}/${t.id}`,n,e.version),readFile:(t,n)=>ie(t,n??e.fileDir)}}async function A(e,t){if(e.kind===`sequence`)return!0;let{init:n,data:r,example:i,path:a,query:o,headers:s}=e.input;if(Object.values(n??{}).some(e=>typeof e==`function`)||typeof r==`function`)return!0;let c=i?await re(`${e.op.service}/${e.op.id}`,i,t.version):void 0;return b([c,r,e.dataPatches,a,o,s,t.vars])}async function oe(t,n,i){if(!e.loadFaker)return!1;let[a,o]=await Promise.all([e.loadFaker(t),r(t)]),s=await T(a,o.faker,n);return te(s,o.faker,{locale:n,seed:i}),!0}async function se(t,n){e.loadFaker&&await A(t,n)&&await oe(n.version,n.locale,n.seed);let r=await ae(n);return t.kind===`sequence`?sr(t,r):or(t,n.env===`mock`?{...r,mockStatus:n.mockStatus}:r)}async function ce(t,n,r,i){let a=e.operations[t];if(!a)throw Error(`Unknown operation ${t}`);let o=(await a(n))[t.split(`/`)[1]];if(!o)throw Error(`Operation module for ${t} has no export`);let s=Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0)),c=o.request({...i?.input??{},...s});return i?.mockHook?ee(c,i.mockHook):c}async function le(t,n){return(await e.operations[t]?.(n))?.[t.split(`/`)[1]]?.meta}async function ue(e,t){let n=`${e.op.service}/${e.op.id}`,r=e.input.example?await re(n,e.input.example,t):void 0,i=e.input.data;typeof i==`function`&&(i=(await i()).default);let a=g(r?.body,i);for(let t of e.dataPatches)a=g(a,t);return{name:e.input.name??e.op.id,source:`project`,dir:r?.dir,path:g(r?.path??{},e.input.path??{}),query:g(r?.query??{},e.input.query??{}),headers:{...r?.headers??{},...e.input.headers??{}},body:a}}async function j(e,t){let n={};await Promise.all(e.map(async e=>{try{let r=ui(await e.load(t));if(r?.kind!==`request`)return;let i=`${r.op.service}/${r.op.id}`,a=r.input.name??e.file.replace(/^.*\//,``).replace(/\.req\.ts$/,``);n[i]??=[],n[i]?.push({file:e.file,name:a,def:r})}catch{}}));for(let e of Object.values(n))e.sort((e,t)=>e.name.localeCompare(t.name));return n}async function de(e,t){let n=[];return await Promise.all(e.map(async e=>{try{let r=ui(await e.load(t));r?.kind===`sequence`&&n.push({file:e.file,seq:r})}catch{}})),n.sort((e,t)=>e.seq.meta.title.localeCompare(t.seq.meta.title))}return{config:r,environments:l,environmentRisks:s,environmentNotes:c,environmentVars:u,environmentView:h,canCreateEnvironment:_,createEnvironment:v,deleteEnvironment:x,setVariable:y,baseUrlOf:f,oauthOf:p,addressesIn:m,managedSecrets:w,oauthEndpoints:D,oauthExchange:O,run:se,fakerReady:oe,operationRequest:ce,operationMeta:le,examplesOf:ne,knownVars:S,loadExample:re,savedExample:ue,loadVariants:j,loadSequences:de}}function ui(e){let t=e=>e&&(e.kind===`request`||e.kind===`sequence`);return t(e.default)?e.default:Object.values(e).find(t)}var q=d(Date.now()),J=d(`mock`),Y=d([`mock`]),di=d({}),fi=d({}),pi=d(void 0),X=d(void 0),mi=d(0),hi=d(!1),gi=d(!1),_i=d({createEnvironment:!0,environmentSettings:!0}),Z=ne,vi,yi=async()=>{if(vi&&Date.now()-vi.at<3e4)return vi.bridge;let e=await Vr();return vi={at:Date.now(),bridge:e},e},bi=y,xi=bi===null?void 0:Rr(bi?.scope??`${globalThis.location?.origin}${globalThis.location?.pathname}`,bi?.session?`session`:`local`),Q=li(ne,{extension:yi,environmentStore:xi}),Si=E===`static`;async function Ci(e,t){let n=await fetch(`/__specbook/save`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:t})});if(!n.ok)throw Error((await n.json()).error??`save failed`);q.value=Date.now()}function wi(){if(!globalThis.__SPECBOOK_VIEWER__)return null;let t=Y.value.some(e=>e!==`mock`);return e(`p`,{class:`muted overview-mode`,children:t?`Requests start on mock data. Switch Environment to live to call the real API.`:`Requests run on generated mock data: this document does not say where the API lives.`})}var Ti=/(^|\.)specbook\.dev$/i;function Ei(e){return e.published&&e.badge!==!1&&!Ti.test(e.host)}var Di=e=>`https://ui.specbook.dev/?ref=${encodeURIComponent(e)}`;function Oi(){let t=globalThis.location?.hostname??``;return Ei({host:t,published:Si,badge:U.value.badge})?e(`p`,{class:`powered-by`,children:e(`a`,{href:Di(t),target:`_blank`,rel:`noopener`,children:`Powered by Specbook`})}):null}var ki=60,Ai=`Default`;function ji(e){let t=W.value;if(e.route.kind===`op`&&t.kind===`op`&&e.route.key===t.key){let n=(t.play??``).startsWith(`saved:`);return e.kind===`req`?t.play===e.route.play:!n}return e.route.kind===`seq`&&t.kind===`seq`&&e.route.id===t.id}function Mi({e:t}){return e(`button`,{type:`button`,class:`op-row ${ji(t)?`active`:``}`,onClick:()=>K(t.route),title:t.path?`${t.title}\n${t.path}`:t.title,children:[e(`span`,{class:`method ${t.method}`,children:t.method}),e(`span`,{class:`op-title`,children:[t.title,t.secured&&e(`span`,{class:`op-lock`,title:`Needs credentials`,children:e(Er,{})})]}),e(`span`,{class:`op-path`,children:t.path})]})}function Ni(e,t){let n=Cr.value.trim(),r=t.length<=1,i=r?t[0]?.id??``:Sr.value,o=a(()=>e.filter(e=>e.kind===`op`),[e]),s=a(()=>e.filter(e=>e.kind===`seq`),[e]),c=a(()=>e.filter(e=>e.kind===`req`),[e]),l=a(()=>{let e=i?c.filter(e=>e.service===i):c;return n?wr(e,n,200):e},[c,i,n]);return{q:n,single:r,svc:i,shownOps:a(()=>{let e=i?o.filter(e=>e.service===i):o;return n?wr(e,n,500):e},[o,i,n]),shownFlows:a(()=>{let e=i&&!r?s.filter(e=>e.tags?.includes(i)):s;return n?wr(e,n,100):e},[s,i,n,r]),shownReqs:l}}function Pi({entries:t,services:i}){let o=c(null),s=c(null),[l,u]=r(new Map),{q:d,single:f,svc:p,shownOps:m,shownFlows:h,shownReqs:g}=Ni(t,i),_=e=>l.get(`section:${e}`)??!0,v=e=>{let t=new Map(l);t.set(`section:${e}`,!_(e)),u(t)};n(()=>{let e=e=>{let t=e.target;e.key===`/`&&!/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)&&(e.preventDefault(),o.current?.focus())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]),n(()=>{let e=s.current;if(!e)return;let t=t=>{if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;let n=[...e.querySelectorAll(`.op-row, .flow-row`)],r=n.indexOf(document.activeElement);if(r<0)return;let i=t.key===`ArrowDown`?r+1:r-1;t.preventDefault(),i>=0&&i<n.length?n[i]?.focus():i<0&&o.current?.focus()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let y=a(()=>{let e=new Map;for(let t of m){let n=t.tag??`default`,r=p||f?n:`${t.service} · ${n}`;e.set(r,[...e.get(r)??[],t])}return[...e.entries()].sort(([e],[t])=>e.localeCompare(t))},[m,p,f]),b=a(()=>{let e=new Map;for(let t of h){let n=t.flowGroup?.trim()||Ai;e.set(n,[...e.get(n)??[],t])}let t=e=>e===Ai?0:1;return[...e.entries()].sort(([e],[n])=>t(e)-t(n)||e.localeCompare(n))},[h]),x=m.length>ki&&!d,S=(e,t)=>l.get(e)??(!x||t.some(ji)),C=(e,t)=>{let n=new Map(l);n.set(e,!S(e,t)),u(n)};return e(`div`,{class:`catalog`,ref:s,children:[e(`div`,{class:`cat-top`,children:[!f&&e(`div`,{class:`pills`,role:`tablist`,"aria-label":`APIs`,children:[e(`button`,{type:`button`,role:`tab`,"aria-selected":p===``,class:`pill ${p===``?`on`:``}`,onClick:()=>Sr.value=``,children:`All`}),i.map(t=>e(`button`,{type:`button`,role:`tab`,"aria-selected":p===t.id,class:`pill ${p===t.id?`on`:``}`,onClick:()=>Sr.value=t.id,children:[t.id,` `,e(`span`,{class:`count`,children:t.ops})]}))]}),e(`div`,{class:`cat-filter-wrap`,children:[e(`input`,{ref:o,type:`text`,class:`cat-filter`,placeholder:p?`Filter ${p}`:`Filter operations and flows`,"aria-label":`Filter`,value:Cr.value,onInput:e=>Cr.value=e.target.value,onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),s.current?.querySelector(`.op-row, .flow-row`)?.focus()),e.key===`Escape`&&(Cr.value=``)}}),e(`kbd`,{class:`cat-hint`,title:`Focus the filter`,children:`/`})]})]}),b.length>0&&e(`section`,{class:`flows`,"aria-label":`Flows`,children:[e(`button`,{type:`button`,class:`flows-title`,"aria-expanded":_(`flows`),onClick:()=>v(`flows`),children:[e(`span`,{class:`caret`,children:_(`flows`)?`▾`:`▸`}),e(`span`,{class:`method flow`,children:`FLOW`}),e(`span`,{class:`muted small`,children:`Multi-step flows you can run end to end`}),e(`span`,{class:`count`,children:h.length})]}),_(`flows`)&&b.map(([t,n])=>{let r=`flows:${t}`,i=b.length===1,a=i||(l.get(r)??!0);return e(`div`,{class:`flow-group`,children:[!i&&e(`button`,{type:`button`,class:`group-head flow-head`,"aria-expanded":a,onClick:()=>{let e=new Map(l);e.set(r,!a),u(e)},children:[e(`span`,{class:`caret`,children:a?`▾`:`▸`}),` `,t,` `,e(`span`,{class:`count`,children:n.length})]}),a&&n.map(t=>e(`button`,{type:`button`,class:`op-row flow-row ${ji(t)?`active`:``}`,onClick:()=>K(t.route),children:[e(`span`,{class:`flow-play`,"aria-hidden":`true`,children:`▶`}),e(`span`,{class:`op-title`,children:t.title})]}))]},r)})]}),g.length>0&&e(`section`,{class:`flows requests`,"aria-label":`Requests`,children:[e(`button`,{type:`button`,class:`flows-title`,"aria-expanded":_(`requests`),onClick:()=>v(`requests`),children:[e(`span`,{class:`caret`,children:_(`requests`)?`▾`:`▸`}),e(`span`,{class:`method req`,children:`REQ`}),e(`span`,{class:`muted small`,children:`Requests you can run and check`}),e(`span`,{class:`count`,children:g.length})]}),_(`requests`)&&g.map(t=>e(`button`,{type:`button`,class:`op-row req-row ${ji(t)?`active`:``}`,onClick:()=>K(t.route),title:`${t.method} ${t.path}`,children:[e(`span`,{class:`method ${t.method}`,children:t.method}),e(`span`,{class:`op-title`,children:[t.title,(t.tags??[]).map(t=>e(`span`,{class:`chip req-tag`,children:t}))]}),e(`span`,{class:`op-path`,children:t.path})]}))]}),y.map(([t,n])=>{let r=S(t,n);return e(`div`,{class:`op-group`,children:[e(`button`,{type:`button`,class:`group-head`,"aria-expanded":r,onClick:()=>C(t,n),children:[e(`span`,{class:`caret`,children:r?`▾`:`▸`}),` `,t,` `,e(`span`,{class:`count`,children:n.length})]}),r&&n.map(t=>e(Mi,{e:t}))]},t)}),y.length===0&&b.length===0&&g.length===0&&e(`p`,{class:`muted cat-empty`,children:[d?`Nothing matches “${d}”.`:`No operations.`,` `,d&&e(`button`,{type:`button`,class:`link`,onClick:()=>Cr.value=``,children:`Clear the filter`})]})]})}function Fi({services:t,counts:n}){let r=U.value;if(!r.ready)return e(`div`,{class:`overview`,"aria-busy":`true`});let i=t.reduce((e,t)=>e+t.ops,0),a=t.length===1?t[0]:void 0,o=r.title??r.name??(a?a.title??a.id:`${t.length} APIs · ${i.toLocaleString()} operations`),s=a?`${a.ops} ${a.ops===1?`operation`:`operations`}${a.version?` · v${a.version}`:``}`:r.name||r.title?`${t.length} APIs · ${i.toLocaleString()} operations`:void 0;return e(`div`,{class:`overview`,children:[r.logo&&e(`img`,{class:`overview-logo`,src:r.logo,alt:``,style:r.logoBackground?{background:r.logoBackground,padding:`10px 16px`,borderRadius:`10px`}:void 0}),r.title&&r.name&&e(`p`,{class:`overview-name`,children:r.name}),e(`h1`,{children:o}),r.tagline&&e(`p`,{class:`tagline`,children:r.tagline}),s&&e(`p`,{class:`muted`,children:s}),e(`p`,{class:`overview-hint`,children:`Choose an operation or flow on the left to read it and try it.`}),e(wi,{}),e(`button`,{type:`button`,class:`btn primary overview-browse`,onClick:()=>K({kind:`browse`}),children:`Browse operations and flows`}),r.links.length>0&&e(`p`,{class:`overview-links`,children:r.links.map(t=>e(`a`,{href:t.href,target:`_blank`,rel:`noreferrer`,children:t.label}))}),e(`p`,{class:`muted overview-keys`,children:[e(`kbd`,{children:`⌘`}),` `,e(`kbd`,{children:`K`}),` jumps anywhere · `,e(`kbd`,{children:`/`}),` filters the list`]}),e(Oi,{})]})}var Ii=`\0new-environment`;function Li(){let t=J.value,n=Y.value.includes(t)?Y.value:[t,...Y.value],r=di.value[t],i=t===`mock`?`mock`:r===`production`||r!==`sandbox`&&/prod/i.test(t)?`prod`:`live`,a=_i.value.createEnvironment&&Q.canCreateEnvironment(),o=n.length>1||a;return e(`span`,{class:`env-badge ${i} ${o?`switch`:``}`,title:t===`mock`?`Environment: mock (no network)`:`Environment: ${t}. Requests go to the real API.`,children:[e(`span`,{class:`env-name`,children:t}),o&&e(`select`,{"aria-label":`Environment`,value:t,onChange:e=>{let t=e.target.value;t===Ii?(e.target.value=J.value,gi.value=!0):J.value=t},children:[n.map(t=>e(`option`,{value:t,title:fi.value[t],children:t})),a&&e(`option`,{value:Ii,children:`New environment…`})]})]})}async function Ri(){let e=q.value,[t,n,r]=await Promise.all([Q.environments(e),Q.environmentRisks(e),Q.environmentNotes(e)]);Y.value=t,di.value=n,fi.value=r,mi.value+=1}var zi={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`},Bi={default:`default`,config:`config`,file:`file`,browser:`this browser`};async function Vi(e,t){let n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error((await n.json()).error??`save failed`)}function Hi(e,t){let n=t.uses[e.name];if(!n)return[];let r=[];for(let e of n.services){let n=t.addresses.find(t=>t.service===e);r.push(n?.url?`${e} calls go to ${n.url}`:`${e} calls use this address`)}for(let e of n.profiles)r.push(`${e.profile} sign-in reads this (${e.field})`);return r}function Ui(){let[t,i]=r(),[o,s]=r(),[c,l]=r({}),u=hi.value,d=e=>hi.value=e,[f,m]=r(`environment`),[h,g]=r({}),[_,v]=r({name:``,value:``}),[y,b]=r(),x=J.value,S=()=>Si?Promise.resolve():fetch(`/__specbook/environment?env=${encodeURIComponent(x)}`).then(e=>e.json()).then(i,()=>i(void 0));n(()=>{S(),m(x===`mock`?`session`:`environment`),g({})},[x]),n(()=>{let e=!0;return Q.environmentView(x,q.value).then(t=>e&&s(t)),()=>{e=!1}},[x,q.value,mi.value]),n(()=>{Q.config(q.value).then(e=>{let t={};for(let[n,r]of Object.entries(e.auth??{}))for(let e of JSON.stringify(r.apply).matchAll(/secrets\.([\w$-]+)/g))t[e[1]]=r.title??n;l(t)})},[]);let C=a(()=>x===`mock`?0:t?.secrets.filter(e=>!e.source).length??0,[t,x]);if(!o||!Si&&!t)return null;let w=t?.secrets??[];if(!(w.length>0||o.rows.length>0||x!==`mock`))return null;let T=async e=>{b(void 0);try{await e(),await S()}catch(e){b(e instanceof Error?e.message:String(e))}},E=(e,t)=>T(async()=>{await Vi(`/__specbook/secret`,{name:e,value:t,scope:f,env:f===`shared`?void 0:x}),g(t=>({...t,[e]:``}))}),ee=(e,t)=>T(async()=>{await Q.setVariable(x,e,t===``?null:t),mi.value+=1}),D=()=>T(async()=>{Q.deleteEnvironment(x),J.value=`mock`,await Ri()}),te=[...t?.warnings??[],...x===`mock`?[]:o.addresses.filter(e=>e.error).map(e=>e.error)],O=[...o.rows].sort((e,t)=>Number(!!o.uses[t.name])-Number(!!o.uses[e.name])||e.name.localeCompare(t.name));return e(`div`,{class:`envmenu`,children:[e(`button`,{type:`button`,class:`btn envmenu-btn`,"aria-expanded":u,title:`Variables and credentials for ${x}`,"aria-label":C>0?`Environment settings, ${C} missing`:`Environment settings`,onClick:()=>d(!u),children:[e(`span`,{"aria-hidden":`true`,children:`⚙︎`}),` `,e(`span`,{class:`envmenu-label`,children:`Environment settings`}),C>0&&e(`span`,{class:`badge-missing`,children:C})]}),u&&e(`div`,{class:`envmenu-pop`,role:`dialog`,"aria-label":`Settings for ${x}`,children:[e(`header`,{class:`envmenu-head`,children:[e(`strong`,{children:x}),e(`span`,{class:`muted small`,children:x===`mock`?`mocks need no credentials`:`values apply to this environment`}),e(`span`,{class:`spacer`}),e(`button`,{type:`button`,class:`icon`,"aria-label":`Close`,onClick:()=>d(!1),children:`×`})]}),te.map(t=>e(`p`,{class:`envmenu-warn`,children:t})),y&&e(`p`,{class:`envmenu-warn`,children:y}),e(`section`,{children:[e(`h3`,{children:`Variables`}),e(`p`,{class:`muted small`,children:Si?`Kept in this browser; the defaults come from the spec or site.`:e(p,{children:[`Shared with the team in `,e(`code`,{children:[`.specbook/environments/`,x,`.env`]}),`. Defaults come from specbook.config.ts.`]})}),O.map(t=>{let n=t.source===`file`||t.source===`browser`,r=`var:${t.name}`;return e(`div`,{children:[e(`div`,{class:`envrow`,children:[e(`code`,{children:t.name}),e(`input`,{"aria-label":`Value of ${t.name}`,value:h[r]??t.value,disabled:!t.editable,onInput:e=>g({...h,[r]:e.target.value}),onBlur:()=>{let e=h[r];e!==void 0&&e!==t.value&&ee(t.name,e)},onKeyDown:e=>e.key===`Enter`&&e.target.blur()}),e(`span`,{class:`src ${n?`set`:`inherited`}`,children:Bi[t.source]}),n&&t.editable&&e(`button`,{type:`button`,class:`icon`,"aria-label":t.fallback===void 0?`Remove ${t.name}`:`Reset ${t.name}`,title:t.fallback===void 0?`Remove this variable`:`Back to ${t.fallback}`,onClick:()=>ee(t.name,null),children:`×`})]}),Hi(t,o).map(t=>e(`p`,{class:`muted small envuse`,children:t}))]},t.name)}),x!==`mock`&&o.addresses.filter(e=>e.url&&!Object.values(o.uses).some(t=>t.services.includes(e.service))).map(t=>e(`p`,{class:`muted small envuse`,children:[t.service,` calls go to `,t.url]})),x!==`mock`&&e(`form`,{class:`envrow`,onSubmit:e=>{e.preventDefault(),_.name&&ee(_.name,_.value).then(()=>v({name:``,value:``}))},children:[e(`input`,{placeholder:`name`,"aria-label":`New variable name`,value:_.name,onInput:e=>v({..._,name:e.target.value})}),e(`input`,{placeholder:`value`,"aria-label":`New variable value`,value:_.value,onInput:e=>v({..._,value:e.target.value})}),e(`button`,{type:`submit`,class:`btn`,disabled:!_.name,children:`Add`})]}),o.removable&&e(`p`,{children:e(`button`,{type:`button`,class:`link`,onClick:D,children:`Delete environment`})})]}),!Si&&e(`section`,{children:[e(`h3`,{children:`Secrets`}),w.length===0?e(`p`,{class:`muted small`,children:[`None declared. Add `,e(`code`,{children:[`secrets: `,`{ NAME: {} }`]}),` to the config.`]}):e(p,{children:[e(`label`,{class:`envrow scope`,children:[e(`span`,{class:`muted small`,children:`Save to`}),e(`select`,{"aria-label":`Where to save secrets`,value:f,onChange:e=>m(e.target.value),children:[e(`option`,{value:`environment`,children:[x,`.secrets.env (remembered here)`]}),e(`option`,{value:`session`,children:`this session only`}),e(`option`,{value:`shared`,children:`all environments (secrets.local.env)`})]})]}),w.map(t=>e(`form`,{class:`secretrow`,onSubmit:e=>{e.preventDefault(),E(t.name,h[t.name]??``)},children:[e(`div`,{class:`secretrow-head`,children:[e(`span`,{children:c[t.name]??t.name}),e(`code`,{class:`muted small`,children:t.key}),e(`span`,{class:`src ${t.source?`set`:`missing`}`,children:t.source?zi[t.source]:`missing`})]}),e(`div`,{class:`envrow`,children:[e(`input`,{type:`password`,autocomplete:`off`,"aria-label":`Value of ${t.name}`,placeholder:t.source?`•••••• (type to replace)`:`paste a value`,value:h[t.name]??``,onInput:e=>g({...h,[t.name]:e.target.value})}),e(`button`,{type:`submit`,class:`btn`,disabled:!h[t.name],children:`Save`}),t.source&&t.source!==`process`&&e(`button`,{type:`button`,class:`link`,onClick:()=>E(t.name,``),title:`Remove the value from the selected place`,children:`Clear`})]})]}))]})]})]})]})}var Wi=`https://github.com/specbook-dev/specbook`;function Gi(){return globalThis.__SPECBOOK_VIEWER__?.source?e(`a`,{class:`btn gh-star`,href:Wi,target:`_blank`,rel:`noopener`,title:`Specbook's source is on GitHub`,children:[e(Or,{}),e(`span`,{class:`gh-label`,children:`GitHub`})]}):null}var Ki=`specbook:list-width`,qi=()=>Math.round(innerWidth*.55);function Ji(){try{let e=Number(localStorage.getItem(Ki));return e>=280?e:void 0}catch{return}}var $=d(Ji());function Yi(e){$.value=e===void 0?void 0:Math.round(Math.max(280,Math.min(qi(),e)));try{$.value===void 0?localStorage.removeItem(Ki):localStorage.setItem(Ki,String($.value))}catch{}}function Xi(){let t=e=>{e.preventDefault(),document.body.classList.add(`resizing`);let t=e=>Yi(e.clientX),n=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,t),removeEventListener(`pointerup`,n)};addEventListener(`pointermove`,t),addEventListener(`pointerup`,n)},n=()=>$.value??document.querySelector(`.list-col`)?.offsetWidth??360;return e(`div`,{class:`list-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the list`,"aria-valuenow":$.value,"aria-valuemin":280,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:t,onDblClick:()=>Yi(void 0),onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),Yi(n()-24)):e.key===`ArrowRight`&&(e.preventDefault(),Yi(n()+24))}})}var Zi=/^[A-Za-z0-9_-]+$/;function Qi(){return gi.value?e($i,{}):null}function $i(){let[t,i]=r(``),[a,o]=r(()=>J.value===`mock`?Y.value.find(e=>e!==`mock`)??`mock`:J.value),[s,l]=r(),[u,d]=r(!1),f=c(null);n(()=>{f.current?.focus();let e=e=>{e.key===`Escape`&&(gi.value=!1)};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]);let p=()=>gi.value=!1,m=Y.value.includes(t),h=t===``?void 0:Zi.test(t)?t===`mock`||m?`"${t}" already exists`:void 0:`Use letters, digits, "-" and "_"`,g=async()=>{d(!0),l(void 0);try{await Q.createEnvironment(t,a,q.value),await Ri(),J.value=t,gi.value=!1,hi.value=!0}catch(e){l(e instanceof Error?e.message:String(e))}finally{d(!1)}};return e(`div`,{class:`palette-backdrop newenv-backdrop`,children:[e(`button`,{type:`button`,class:`palette-dismiss`,"aria-label":`Close`,onClick:p}),e(`div`,{class:`palette newenv`,role:`dialog`,"aria-label":`New environment`,children:e(`form`,{onSubmit:e=>{e.preventDefault(),t&&!h&&!u&&g()},children:[e(`h2`,{children:`New environment`}),e(`label`,{children:[e(`span`,{class:`muted small`,children:`Name`}),e(`input`,{ref:f,type:`text`,"aria-label":`Environment name`,placeholder:`staging`,value:t,onInput:e=>i(e.target.value.trim())})]}),e(`label`,{children:[e(`span`,{class:`muted small`,children:`Duplicate of`}),e(`select`,{"aria-label":`Duplicate of`,value:a,onChange:e=>o(e.target.value),children:Y.value.filter(e=>e!==`mock`).map(t=>e(`option`,{value:t,children:t}))})]}),e(`p`,{class:`muted small`,children:[`It starts with `,a,`'s variables. Change its address in Variables; secrets are asked for again.`]}),(h||s)&&e(`p`,{class:`envmenu-warn`,children:h??s}),e(`div`,{class:`envrow`,children:[e(`span`,{class:`spacer`}),e(`button`,{type:`button`,class:`btn`,onClick:p,children:`Cancel`}),e(`button`,{type:`submit`,class:`btn primary`,disabled:!t||!!h||u,children:`Create`})]})]})})]})}function ea({entries:t}){let[i,o]=r(``),[s,l]=r(0),u=c(null),d=G.value;n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),G.value=!G.value):e.key===`Escape`&&(G.value=!1)};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]),n(()=>{d&&(o(``),l(0),setTimeout(()=>u.current?.focus(),0))},[d]);let f=a(()=>wr(t,i,30),[t,i]);if(!d)return null;let p=e=>{e&&(G.value=!1,K(e.route))};return e(`div`,{class:`palette-backdrop`,children:[e(`button`,{type:`button`,class:`palette-dismiss`,"aria-label":`Close`,onClick:()=>G.value=!1}),e(`div`,{class:`palette`,role:`dialog`,"aria-label":`Jump to`,children:[e(`input`,{ref:u,type:`text`,placeholder:`Jump to a sequence, request or operation…`,value:i,onInput:e=>{o(e.target.value),l(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),l(Math.min(f.length-1,s+1))):e.key===`ArrowUp`?(e.preventDefault(),l(Math.max(0,s-1))):e.key===`Enter`&&p(f[s])}}),e(`ul`,{children:[f.map((t,n)=>e(`li`,{children:e(`button`,{type:`button`,class:n===s?`sel`:``,onMouseEnter:()=>l(n),onClick:()=>p(t),children:[e(`span`,{class:`p-title`,children:t.title}),e(`span`,{class:`muted`,children:t.kind===`seq`?`Sequence`:t.kind===`req`?`Request`:t.group})]})})),f.length===0&&e(`li`,{class:`muted pad`,children:[`Nothing matches “`,i,`”`]})]})]})]})}function ta(){let t=globalThis.__SPECBOOK_VIEWER__,[n,i]=r(!1),[a,s]=r(!1);if(!t?.source)return null;W.value;let c=l(t.source),u=c.ok?o({origin:location.origin,pathname:location.pathname,hash:location.hash},c.spec,t.open.title):void 0;return e(`div`,{class:`share`,children:[e(`button`,{type:`button`,class:`btn`,"aria-expanded":n,"aria-haspopup":`true`,"aria-label":`Share`,onClick:()=>i(!n),children:[e(Dr,{}),e(`span`,{class:`share-label`,children:`Share`})]}),n&&e(`div`,{class:`share-pop`,role:`menu`,children:u?e(p,{children:[e(`input`,{class:`share-link`,readOnly:!0,value:u.link,"aria-label":`Link to this view`,onFocus:e=>e.target.select()}),e(`div`,{class:`share-actions`,children:[e(`button`,{type:`button`,class:`btn primary`,onClick:async()=>{if(u)try{await navigator.clipboard.writeText(u.link),s(!0),setTimeout(()=>s(!1),1500)}catch{}},children:a?`Copied`:`Copy link`}),typeof navigator.share==`function`&&e(`button`,{type:`button`,class:`btn`,onClick:()=>void navigator.share({title:u.title,url:u.link}).catch(()=>{}),children:`Share…`})]}),e(`ul`,{class:`share-targets`,children:u.targets.map(t=>e(`li`,{children:e(`a`,{href:t.href,target:`_blank`,rel:`noopener noreferrer`,children:t.label})}))})]}):e(`p`,{class:`muted`,children:c.ok?``:c.reason})})]})}var na={auto:`Theme: follows your system. Click for light.`,light:`Theme: light. Click for dark.`,dark:`Theme: dark. Click to follow your system.`},ra=({mode:t})=>e(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[t===`light`&&e(p,{children:[e(`circle`,{cx:`12`,cy:`12`,r:`4`}),e(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}),t===`dark`&&e(`path`,{d:`M20 14.5A8.5 8.5 0 0 1 9.5 4 8.5 8.5 0 1 0 20 14.5z`}),t===`auto`&&e(p,{children:[e(`circle`,{cx:`12`,cy:`12`,r:`8.5`}),e(`path`,{d:`M12 3.5v17a8.5 8.5 0 0 0 0-17z`,fill:`currentColor`,stroke:`none`})]})]});function ia(){let n=i.value;return e(`button`,{type:`button`,class:`icon theme-toggle`,title:na[n],"aria-label":na[n],"data-theme-mode":n,onClick:t,children:e(ra,{mode:n})})}var aa=`\0new-environment`,oa=globalThis.__SPECBOOK_VIEWER__?.source?s:void 0;function sa(){r(()=>{let e=Object.keys(Z.manifests);mr(e.length===1?e[0]:void 0)})}var ca=d([]);function la(){let[e,t]=r(),i=W.value.kind===`op`||W.value.kind===`seq`;return n(()=>{i&&!e&&h(()=>import(`./Host-DsO9W5X8.js`).then(t),__vite__mapDeps([0,1,2,3,4]),import.meta.url)},[i,e]),i?e:void 0}function ua(){sa();let[t,i]=r({}),[o,s]=r(void 0),[l,u]=r(!1);n(()=>{let e=()=>{W.value=vr(location.hash)};return addEventListener(`hashchange`,e),Q.config(q.value).then(async e=>{ca.value=Object.keys(e.faker?.locales??{}),e.faker?.default&&(pi.value=e.faker.default);let t=e.branding,n=Z.brandingAssets,r=Object.values(Z.manifests),i=r.length===1?r[0]?.logo:void 0,a=t?.logo??await n.logo?.().catch(()=>void 0),o={ready:!0,name:t?.name,title:t?.title,tagline:t?.tagline,links:t?.links??[],badge:t?.badge,logo:a??i?.url,logoBackground:a?void 0:i?.backgroundColor,favicon:t?.favicon??await n.favicon?.().catch(()=>void 0)};U.value=o,fr(t,o,r.length===1?r[0]?.title??`Specbook`:`Specbook`)}).catch(()=>{U.value={...U.value,ready:!0}}).finally(()=>{Q.loadVariants(Z.requests,q.value).then(i);let e=Z.sequences.filter(e=>Z.unresolvedSequences.includes(e.file));e.length&&Q.loadSequences(e,q.value).then(s)}),Q.environments(q.value).then(e=>{Y.value=e;let t=globalThis.__SPECBOOK_VIEWER__?.defaultEnv;t&&e.includes(t)&&(J.value=t)}),Q.environmentRisks(q.value).then(e=>{di.value=e}),Q.environmentNotes(q.value).then(e=>{fi.value=e}),()=>removeEventListener(`hashchange`,e)},[]);let d=c(W.value);n(()=>{d.current!==W.value&&(d.current=W.value,u(!1))},[W.value]),n(()=>{if(!l)return;let e=e=>e.key===`Escape`&&u(!1);return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[l]);let f=Object.keys(Z.manifests).length>1,p=a(()=>{let e=[],n=[...Object.values(Z.sequenceMeta),...(o??[]).map(e=>({...e.seq.meta}))];for(let t of n)e.push({kind:`seq`,route:{kind:`seq`,id:t.id},title:t.title,group:t.tags?.[0]??`sequence`,tags:t.tags,flowGroup:t.group,description:t.description,hay:`${t.description??``} ${(t.tags??[]).join(` `)}`});for(let n of Object.values(Z.manifests))for(let r of n.operations){let i=`${n.service}/${r.id}`;for(let a of t[i]??[])e.push({kind:`req`,route:{kind:`op`,key:i,play:`saved:${a.file}`},title:a.name,group:`request`,service:n.service,tag:r.tags[0]??`default`,method:r.method,path:r.path,tags:a.def.input.tags,hay:`${r.id} ${r.method} ${r.path} ${(a.def.input.tags??[]).join(` `)} ${a.file}`});let a=(t[i]??[]).map(e=>e.name).join(` `);e.push({kind:`op`,route:{kind:`op`,key:i},title:r.summary?.replace(/\.$/,``)||r.path,group:`${f?`${n.service} · `:``}${r.tags[0]??`default`}`,service:n.service,tag:r.tags[0]??`default`,method:r.method,path:r.path,secured:r.secured,hay:`${r.id} ${r.method} ${r.path} ${r.tags.join(` `)} ${a}`})}return e},[o,t,f]),m=W.value,h=m.kind===`op`?da(m.key):void 0,g=m.kind===`seq`?m.id:void 0,[_,v]=r();n(()=>{if(!g)return;let e=Z.sequenceMeta[g]?.file;if(e){let t=Z.sequences.filter(t=>t.file===e);Q.loadSequences(t,q.value).then(e=>v(e[0]))}else v(o?.find(e=>e.seq.meta.id===g))},[g,o,q.value]);let y=_?.seq.meta.id===g?_:void 0,b=la(),x=()=>K(xr(W.value)),S=a(()=>Object.values(Z.manifests).map(e=>({id:e.service,title:e.title,version:e.version,ops:e.operations.length})).sort((e,t)=>e.id.localeCompare(t.id)),[]),C=a(()=>{if(m.kind!==`op`&&m.kind!==`seq`)return{};let e=p.find(e=>e.kind===`op`&&m.kind===`op`&&e.route.kind===`op`&&e.route.key===m.key||e.kind===`seq`&&m.kind===`seq`&&e.route.kind===`seq`&&e.route.id===m.id);if(!e)return{};let t=p.filter(t=>e.kind===`seq`?t.kind===`seq`:t.kind===`op`&&t.service===e.service&&t.tag===e.tag),n=t.indexOf(e),r=e=>e?()=>K({...e.route,play:``}):void 0;return{prev:r(t[n-1]),next:r(t[n+1])}},[p,m.kind===`op`?m.key:m.kind===`seq`?m.id:``]),w=e=>K(m.kind===`op`?{kind:`op`,key:m.key,play:e.example??m.play??``,tab:e.tab}:m.kind===`seq`?{kind:`seq`,id:m.id,play:``,tab:e.tab}:m);return e(`div`,{class:`app`,style:$.value?{"--sb-list-w":`${$.value}px`}:void 0,children:[e(`header`,{class:`header`,children:[e(`button`,{type:`button`,class:`brand`,onClick:()=>K({kind:`home`}),children:[(U.value.logo??oa)&&e(`img`,{class:`brand-logo`,src:U.value.logo??oa,alt:``,style:U.value.logoBackground?{background:U.value.logoBackground,padding:`3px 6px`,borderRadius:`4px`}:void 0}),e(`span`,{class:`brand-name`,children:U.value.name??`Specbook`})]}),e(`button`,{type:`button`,class:`palette-btn`,onClick:()=>G.value=!0,children:[e(`span`,{children:`Jump to an operation or flow…`}),e(`kbd`,{children:`⌘K`})]}),e(`span`,{class:`spacer`}),e(`span`,{class:`header-env`,children:e(Li,{})}),e(`button`,{type:`button`,class:`menu-btn icon`,"aria-label":`Settings`,"aria-expanded":l,onClick:()=>u(!l),children:`⋯`}),e(`div`,{class:`header-controls ${l?`open`:``}`,children:[Z.loadFaker&&e(`span`,{class:`row muted`,title:`Generated values such as {{faker.person.fullName}}: new on every run, or fixed so the same number always gives the same data`,children:[e(`label`,{class:`row`,children:[`Synthetic data`,e(`select`,{"aria-label":`Synthetic data`,value:X.value===void 0?`random`:`fixed`,onChange:e=>{X.value=e.target.value===`fixed`?X.value??42:void 0},children:[e(`option`,{value:`random`,children:`New each run`}),e(`option`,{value:`fixed`,children:`Fixed`})]})]}),X.value!==void 0&&e(`input`,{type:`number`,class:`seed-input`,"aria-label":`Seed number`,title:`The same number gives the same data every run`,value:X.value,onInput:e=>{let t=e.target.valueAsNumber;X.value=Number.isFinite(t)?t:void 0}})]}),ca.value.length>1&&e(`label`,{class:`row muted`,children:[`locale`,e(`select`,{value:pi.value??``,onChange:e=>pi.value=e.target.value||void 0,children:ca.value.map(t=>e(`option`,{value:t,children:t}))})]}),e(Ui,{}),e(`label`,{class:`row`,children:[`Environment`,e(`select`,{value:J.value,onChange:e=>{let t=e.target.value;t===aa?(e.target.value=J.value,gi.value=!0):J.value=t},children:[Y.value.map(t=>e(`option`,{value:t,title:fi.value[t],children:t})),Q.canCreateEnvironment()&&e(`option`,{value:aa,children:`New environment…`})]})]}),e(Gi,{}),e(ta,{}),e(ia,{})]})]}),e(`div`,{class:`layout`,"data-view":m.kind===`home`?`splash`:`list`,children:[e(`nav`,{class:`list-col`,"aria-label":`Operations and flows`,children:e(Pi,{entries:p,services:S})}),e(Xi,{}),e(`main`,{class:`stage`,children:(m.kind===`home`||m.kind===`browse`)&&e(Fi,{services:S,counts:{flows:p.filter(e=>e.kind===`seq`).length,requests:p.filter(e=>e.kind===`req`).length}})})]}),e(ea,{entries:p}),e(Qi,{}),b&&m.kind===`op`&&h&&e(b.Host,{kind:`op`,modal:!1,service:h.service,op:h.op,variants:t[m.key]??[],example:m.play??``,tab:m.tab,onNavigate:w,onPrev:C.prev,onNext:C.next,onClose:x}),b&&m.kind===`seq`&&y&&e(b.Host,{kind:`seq`,modal:!1,info:y,tab:m.tab,onNavigate:w,onPrev:C.prev,onNext:C.next,onClose:x})]})}function da(e){let[t,n]=e.split(`/`),r=Z.manifests[t]?.operations.find(e=>e.id===n);return r?{service:t,op:r}:void 0}var fa=x({});u(),(globalThis.__SPECBOOK_VIEWER__===void 0?m():Promise.resolve(!1)).then(async t=>{t||(await w(),f(e(ua,{}),document.getElementById(`app`)))});export{un as A,In as C,$t as D,an as E,Et as M,Tt as N,on as O,K as S,sn as T,Yr as _,Z as a,Tr as b,hi as c,Y as d,_i as f,Xr as g,q as h,Si as i,ln as j,cn as k,mi as l,X as m,Li as n,Ci as o,pi as p,Q as r,J as s,fa as t,fi as u,Jr as v,B as w,kr as x,Mr as y};