@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.
- package/dist-viewer/assets/Host-DsO9W5X8.js +41 -0
- package/dist-viewer/assets/{index-BBlFcQUE.js → index-D59fkVA9.js} +1 -1
- package/dist-viewer/assets/main-i06Egg5h.js +14 -0
- package/dist-viewer/assets/{mount-DfwluJy4.js → mount-CLHBtIzR.js} +2 -2
- package/dist-viewer/assets/panel-l1xvY4kI.css +1 -0
- package/dist-viewer/assets/registry-b_jzfqy0.js +2 -0
- package/dist-viewer/index.html +4 -4
- package/dist-viewer/specbook.js +1 -1
- package/package.json +4 -4
- package/src/app.tsx +2 -0
- package/src/panel/OperationDocs.tsx +1 -1
- package/src/panel/RequestPanel.tsx +12 -4
- package/src/styles/app.css +13 -0
- package/src/styles/panel.css +2 -4
- package/src/viewer/embed.ts +9 -2
- package/src/viewer/mount.ts +2 -0
- package/src/viewer/registry.ts +2 -0
- package/dist-viewer/assets/Host-Cq-4gDuM.js +0 -41
- package/dist-viewer/assets/main-CSkB-O_8.js +0 -14
- package/dist-viewer/assets/panel-hNOojwiM.css +0 -1
- package/dist-viewer/assets/registry-DIHX11uY.js +0 -2
- /package/dist-viewer/assets/{panel-9eYU7Gz6.js → panel-nV09I7Wr.js} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
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-9eYU7Gz6.js";import{i as u}from"./mount-DfwluJy4.js";import{i as d,l as f}from"./registry-DIHX11uY.js";import{A as p,C as m,D as h,E as g,M as _,N as v,O as y,S as b,T as x,_ as S,a as C,b as w,c as T,d as E,f as D,g as O,h as k,i as A,j,k as M,l as ee,m as te,n as ne,o as re,p as ie,r as N,s as P,u as F,v as I,w as ae,x as oe,y as L}from"./main-CSkB-O_8.js";var se={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=>se[e]??``;function R(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 le(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 ue(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 de(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?ue(le(R(e.expected),R(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 fe(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 pe(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 me(e){return typeof e!=`object`||!e?[]:_(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var he=/[^[\]]+|\[\]/g;function ge(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?ge(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?ge(o,i,n):o===void 0?n:[...[].concat(o),n],a}function _e(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=ge(t,n.match(he)??[n],a&&v(a)?a:r));return t}var ve=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,ye=e=>new RegExp(ve.source).test(e),be=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function xe(e){let t=[],n=0;for(let r of e.matchAll(ve))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?be(r[1]):`SESSION_${be(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var Se=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${Ce(e)}`);return t.length?`?${t.join(`&`)}`:``};function Ce(e){return xe(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function B(e){if(v(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var we=e=>e.name??e.file??`file`,Te=e=>`'${e.replace(/'/g,`'\\''`)}'`;function V(e){return ye(e)?`"${xe(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:Te(e)}function Ee(e){let t=e.encoding??`json`,n=[V(`${e.url}${Se(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 _(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}=@${we(n)}`)}`):s.push(`-F ${V(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${V(`@${B(o)?we(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 De=/^[A-Za-z_$][\w$]*$/;function H(e){return ye(e)?`\`${xe(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=>De.test(e)?e:H(e);function Oe(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}${Oe(e,n)},`).join(`
|
|
7
|
-
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${U(e)}: ${Oe(t,n)},`).join(`
|
|
8
|
-
`)}\n${t}}`}function ke(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(${Oe(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=_(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${Oe(Object.fromEntries(t),` `)})`:`new URLSearchParams(${Oe(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=we(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)?we(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}${Se(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 Ae(e,t){return e===`curl`?Ee(t):ke(t)}var je=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],W=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function Me(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 Ne(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
12
|
-
`).split(`
|
|
13
|
-
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${Me(W(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${Me(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}>${Me(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>${Me(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 Pe(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 Fe(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function Ie(e){return e?Me(W(e)):``}function Le(e,t=300){let n=Fe(e);if(!n)return``;let r=Pe(n);return r.length>t?W(`${r.slice(0,t-1).trimEnd()}…`):Ie(n)}var G=/^\s*\{\{[^}]+\}\}\s*$/,Re=e=>typeof e==`string`&&G.test(e);function ze(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Be=[`title`,`description`,`default`,`examples`,`deprecated`];function Ve(e,t){let n={...e};for(let e of Be)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=Ve(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=>!ze(e));if(e.length===1||e.length>1)return q(Ve(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(Ve(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 Be)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 He(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function Ue(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 We(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 Ge(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 Ke=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function qe(e,t,n){let r=K(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!ze(e));if(!i?.length)return q(r,n);let a=Ke(t);return q(Ve(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 Je(e,t,n,r={},i=``,a=0){if(!t||a>12||Re(e))return[];let o=qe(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=Ke(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(...Je(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Je(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(...Je(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 Ye=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Xe(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 Ze(e,t,n){let r=e;for(let e of t){if(!r)return;r=Ge(r,e,n)}return r}var Qe={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`},$e=e=>Qe[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),et=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,tt=new Set([`path`,`query`,`headers`,`data`]),nt=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function rt(e,t){return[e,...nt(t)].join(`.`)}function it(e){let t=nt(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&tt.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var at=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function ot(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?it(at(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 st=60;function ct(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function lt(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of We(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:ct(e,t),required:a.required,description:He(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(...lt(s,t,n+1,o))}return i}function ut({schema:e,defs:n,section:r=`data`,notes:i}){let a=lt(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,st).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:Le(e.description,220)}}),i?.get(rt(r,e.name))&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(rt(r,e.name))}}),e.enum&&t(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>t(`code`,{children:e}))]})]})]})),a.length>st&&t(`tr`,{children:t(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-st,` more fields in the spec`]})})]})]})}var dt={intro:``,notes:new Map,replace:!1,found:!1};function ft(e){let[t,r]=a(),[i,s]=a(!1),c=C.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?{...dt,loaded:i}:{...ot(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var pt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],mt=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function ht(e,t,n){return Promise.all([mt(C.operationDocs[e]?.().then(e=>e.default)),mt(C.schemas[e]?.().then(e=>e.default)),mt(C.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>mt(C.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 gt({variant:e,html:n}){return n?t(`section`,{class:`saved-note-doc`,children:[t(`h2`,{children:[`Saved request `,t(`code`,{children:e.name})]}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:n}})]}):null}function _t({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),ht(s,e,d?d.split(`
|
|
18
|
-
`):[]).then(e=>t&&u(e)),()=>{t=!1}},[s,e,d]);let f=ft(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:Ne(m.description)}}),f.intro&&t(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>t(gt,{variant:e,html:c?.saved[e.file]},e.file)),pt.map(([e,n])=>v(e)?t(`section`,{children:[t(`h2`,{children:[n,` parameters`]}),t(ut,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&t(`section`,{children:[t(`h2`,{children:`Request body`}),t(ut,{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 ${et(e)}`,children:e}),` `,$e(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 vt=c(``);function yt(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 bt=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}},xt=0,St=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Ct({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-${++xt}`,[]);return n(()=>()=>{vt.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(St)].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&&E.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:E.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(bt,{children:m})}),t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:vt.value})]})]})}function wt(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:Ze(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=Ze(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Ye(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&We(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:He(o),parent:c?He(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Tt(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function Et(e,t,n,r){let i=e&&t?.get(rt(n,r));return e&&i?{...e,note:i}:e}var Dt={},Ot=Symbol(),kt=Symbol(),At=e=>typeof e==`string`?jt[e]:e,jt={plain:Dt,plaintext:Dt,text:Dt,txt:Dt},Mt=(e,t)=>(t[kt]||Nt)(e,t),Nt=(e,t)=>{for(var n=[e],r,i=[],a=0;r=At(t[Ot]);)delete t[Ot],Object.assign(t,r);for(Bt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},Pt=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),Ft=`</span>`,It=``,Lt=``,Rt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=zt(n);return t},zt=e=>{if(e instanceof Vt){var{type:t,alias:n,content:r}=e,i=It,a=Lt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;Lt+=Ft,It+=o;var s=zt(r);return It=i,Lt=a,o+s+Ft}return typeof e==`string`?(e=Pt(e,/</g,`<`),Lt&&e.includes(`
|
|
19
|
-
`)?e.replace(/\n/g,Lt+`
|
|
20
|
-
`+It):e):Rt(e)},Bt=(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=At(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 Vt)){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 Vt)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 Vt(a,d?Mt(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof Vt?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&&(Bt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Vt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Ht=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Yt(),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=Mt(o=_.value,jt[r]||{}),O(`tokenize`,u,r,o);let e=Rt(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=qt(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`,()=>{Xt=null,c=!1,w()}),Y(_,`focus`,()=>{Xt=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),Kt(e)?.append(p),t&&x(t),A},Ut=`u`>typeof window?document:null,Wt=Ut?.createElement(`div`),Gt=(e,t)=>(Wt&&(Wt.innerHTML=e,t=Wt.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),Kt=e=>typeof e==`string`?Ut.querySelector(e):e,qt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
23
|
-
`,t)+1)&&t<=n;r++);return r},Jt={},Yt=Gt(`<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()},Xt;Ut&&Y(Ut,`selectionchange`,()=>Xt?.());var Zt=(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) + ${mn&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},Qt=(e,t)=>t?e.lastIndexOf(`
|
|
24
|
-
`,t-1)+1:0,$t=(e,t)=>(t=e.indexOf(`
|
|
25
|
-
`,t))+1?t:e.length,en=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),tn=(e,t,n,r)=>en(e.textarea,t,n,r),nn=(e,t)=>parseFloat(getComputedStyle(e)[t]),rn=(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}},an=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var on,sn=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),cn=(e,t)=>e.slice(Qt(e,t),t),ln=(e,t,n=t)=>[e.slice(t=Qt(e,t),n=$t(e,n)).split(`
|
|
26
|
-
`),t,n],un=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[qt(a,0,i)],s=Ut.createTreeWalker(o,5),c=s.lastChild(),l=$t(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}},dn=(e,t)=>un(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;on=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=mn&&!s[r??on[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,on[2]),l()})),hn||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),mn||hn?(c&&(o.selectionEnd--,t=t.slice(0,-1)),hn&&(t+=`
|
|
27
|
-
`),Ut.execCommand(t?`insertHTML`:`delete`,!1,Pt(t,/</g,`<`)),c&&o.selectionStart++):Ut.execCommand(t?`insertText`:`delete`,!1,t),on=0},fn=(e,t,n=t,r)=>{let i=e.textarea,a=en(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},pn=Ut?navigator.userAgent:``,Q=Ut?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,mn=/Chrome\//.test(pn),hn=!mn&&/AppleWebKit\//.test(pn),gn=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,_n=(e,t)=>e.lines[0].append(t),vn=Gt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),yn=Gt(`<span> `),bn=Gt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),xn=(e,t,n=!0)=>{let r=bn(),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||_n(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 Sn=(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(``,yn()),an(r[o],n.slice(a,a=t[o++])),an(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();an(r[s],n.slice(a))},Cn=0,wn=Gt(`<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>`),Tn=Gt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),En={},Dn=(e,t)=>{e.forEach(e=>En[e]=t)},On=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=wn(),O=vn(),[k,A]=xn(n,D),[j,M]=D.children,[ee,te,ne]=M.children,re=j.firstChild,ie=re.id=`pce-ac-`+Cn++,N=re.children,P=[],F=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},I=()=>{f=nn(N[0],`height`)},ae=e=>{let t=o[e+d],[n,r,i]=N[e].children,a=t[4],s=a.icon||`variable`;Sn(r,t[1],a.label),an(i.firstChild.firstChild,a.detail||``),P[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${P[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),N[e].setAttribute(`aria-posinset`,e+d)},oe=()=>{I();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,ce(),L()},L=()=>{let e=l;l=N[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`)},se=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,oe()},ce=()=>{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;)ae(e++);re.style.paddingTop=d*f+`px`},R=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
|
-
`+cn(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||_n(n,O),p=o,m=0,g=n.value.length,fe(),h=E(),ue()):n.extensions.cursor?.scrollIntoView()},ue=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},de=e=>{m+=e,fn(n,p[m],p[m+1]),ue()},z=()=>{O.remove(),p=null},fe=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),Sn(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=nn(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=dn(n,u=p<`f`?a:l),h=En[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=cn(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;)N[e].setAttribute(`aria-setsize`,s),ae(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,L(),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 F()}else F()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)re.append(Tn()),N[e].id=ie+`-`+e++;Y(j,`scroll`,()=>{I(),ce()||L()}),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)z();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]));fe()}_=!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])&&z()}a?(a=!1,_e()):(S!=e||C!=t)&&F(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!on&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&R(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!on||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&F()}),Y(T,`keydown`,e=>{let t=e.key,n=gn(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)?(se(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(R(c),F(),X(e)):t==`Escape`?(F(),X(e)):t.slice(0,4)==`Page`&&(I(),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`&&(z(),X(e)))},!0),Y(re,`mousedown`,e=>{e.target!=te&&(R([].indexOf.call(N,e.target.closest(`li`))+d),F()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&F()}),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},kn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return An(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]},An=(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]]},jn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Vn[e]||0;return t+`+`+r},Mn=e=>{if(!zn[48]){for(let e=48;e<91;e++)zn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)zn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=gn(e),r=zn[e.keyCode],i=Bn[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},Nn=new WeakMap,Pn=(e,t,n)=>{let r=new Set,i;try{for(let a of Mn(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)))}},Fn=e=>{let t=Nn.get(e);return t||(Nn.set(e,t={}),tn(e,`keydown`,n=>{Pn(n,t,e)})),t},In=(e,t,n,r)=>Ln(Fn(e),t,n,r),Ln=(e,t,n,r=2)=>{let i=(e[t==`any`?t:jn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},Rn=Q?4:2,zn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Bn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Vn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},Hn=!1,Un=e=>e.search(/\S|$/),Wn=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),Gn=(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+Un((f<0?n:t)[0]),m=i-u.length+Un(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,_))},Kn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=ln(e.value,n,r),[s,c]=Wn(e);return Gn(e,i,i.map(t?e=>e.slice(Un(e)?c-Un(e)%c:0):e=>e&&s.repeat(c-Un(e)%c)+e),a,o,n,r),$(e)},qn=(e,t)=>{let[n,r]=Wn(e);return Z(e,n.repeat(r-(t-Qt(e.value,t))%r)),$(e)},Jn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=$t(r,n[1]));let[i,a]=Wn(e),[o,s]=n,c=Jt[dn(e,o)]?.autoIndent,l=Math.floor(Un(cn(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)},Yn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?Qt(i,n)-1:n,o=t?r:i.indexOf(`
|
|
33
|
-
`,r)+1;if(a>-1&&o>0){let[s,c,l]=ln(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)},Xn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=ln(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)},Zn=(e,t)=>(e.container.scrollBy(0,nn(e.container,`lineHeight`)*(t?-1:1)),!0),Qn=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=ln(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=$t(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},$n=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:Qt(i,n),o=Jt[dn(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=ln(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(sn(t)+` ?$`);s+1&&RegExp(`^ ?`+sn(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=sn(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));Gn(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=Un(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(sn(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${sn(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},er={Tab(e){if(!Hn){let[t,n]=e.getSelection();return t==n?qn(e,t):Kn(e)}},"8+Tab":e=>!Hn&&Kn(e,!0),"1+ArrowDown":e=>Yn(e),"1+ArrowUp":e=>Yn(e,!0),"9+ArrowDown":e=>Xn(e),"9+ArrowUp":e=>Xn(e,!0),Enter:e=>Jn(e),"8+Enter":e=>Jn(e),"Mod+Enter":e=>Jn(e,!0),"Mod+]":e=>Kn(e),"Mod+[":e=>Kn(e,!0),"8+Mod+k":Qn,"Mod+/":e=>$n(e),"9+a":e=>$n(e,!0),[Q?`10+m`:`2+m`]:()=>(Hn=!Hn,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Zn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Zn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var tr=Q?5:1;tr+``,tr+``,tr+``,tr+``;var nr=(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&&!fn(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=cn(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=Jt[dn(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},In(r,`Backspace`,u),In(r,`8+Backspace`,u);for(let t in e)In(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>tn(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=ln(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))}}))},rr=(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}),tn(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`)&&!on&&(n!=` `||o==n))||(d[t][2]=on||u()),i=!0,o=n,s=f,a=l}),tn(e,`input`,()=>f(t+!c)),tn(e,`keydown`,e=>{if(!g.readOnly){let n=gn(e),r=e.keyCode,i=n==Rn&&r==90,a=n==Rn+8&&r==90||!Q&&n==Rn&&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},ir=Gt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),ar=()=>{let e,t=ir(),[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];an(n,cn(i,s)),an(a,i.slice(s,$t(i,s))+`
|
|
39
|
-
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Zt(e,i)},c=t=>{e=t,t.extensions.cursor=c,tn(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),rn(e,i)),c.scrollIntoView=s,c.element=i,c};Gt(`<div class=pce-cursor>`);var or=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,sr=/\b(?:false|true)\b/,cr=/\[]|\(\)|{}/,lr=/[([{][^)\]}]*$/,ur=([e,t],n)=>cr.test(n[e-1]+n[t]),dr={line:`//`,block:[`/*`,`*/`]},fr=(e=dr,t=lr)=>({comments:e,autoIndent:[([e],n)=>t.test(cn(n,e)),ur]});Jt.json=Jt.json5=Jt.jsonp=fr(),Jt.graphql=fr({line:`#`}),jt.webmanifest=jt.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:or,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:sr,null:{pattern:/\bnull\b/,alias:`keyword`}},jt.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:sr,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+/,[kt](e,t){for(var n=Nt(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 pr=new WeakMap;Dn([`json`],{sources:[(e,t)=>{let n=pr.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 mr({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=Ht(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)},nr(er),rr(),...l?[ar(),On({filter:kn})]:[]);return l&&pr.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 hr=/[\w$.+-]/;function gr(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&&hr.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&hr.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 _r=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),vr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function yr(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 br(e,t,n,r,i){if(!e)return;let a=gr(r,i);if(!a)return;let o=Ze(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=We(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=yr(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${vr(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:_r(Ue(He(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 xr=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Sr(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:fe(e.path),query:fe(e.query),headers:fe(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?me(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var Cr=e=>Object.keys(e).length?e:void 0;function wr(e,t){let n;if(xr(e,t))n=_e(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:Cr(pe(e.path)),query:Cr(pe(e.query)),headers:Cr(pe(e.headers)),data:n}}var Tr=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function Er(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 Dr({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:Ne(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 Or(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 kr(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 Ar({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 jr=`specbook:grid-cols`,Mr={key:26,val:34},Nr=10,Pr=c(Fr());function Fr(){try{let e=JSON.parse(L.local.getItem(jr)??`null`);if(e&&e.key>=Nr&&e.val>=Nr&&e.key+e.val<=90)return e}catch{}return Mr}function Ir(e){let t=e??Mr,n=Math.min(80,Math.max(Nr,t.key)),r=Math.min(100-n-Nr,Math.max(Nr,t.val));Pr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?L.local.setItem(jr,JSON.stringify(Pr.value)):L.local.removeItem(jr)}catch{}}function Lr(){return t(`colgroup`,{children:[t(`col`,{style:{width:`36px`}}),t(`col`,{style:{width:`${Pr.value.key}%`}}),t(`col`,{style:{width:`${Pr.value.val}%`}}),t(`col`,{}),t(`col`,{style:{width:`60px`}})]})}function Rr({which:e,table:n}){let r=t=>{let n=Pr.value;Ir(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(Pr.value[e]),"aria-valuemin":Nr,"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:()=>Ir(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var zr=1,Br=2;function Vr(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 Hr=({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 Ur({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)}:${Br}`,C(o)},O=(e,t)=>{let n=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(n.trim()))return;e.preventDefault();let a=Vr(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(Lr,{}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-check`}),t(`th`,{class:`g-key`,children:[`Key`,t(Rr,{which:`key`,table:()=>h.current})]}),t(`th`,{class:`g-val`,children:[`Value`,t(Rr,{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}:${zr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>w(n,{key:e.target.value}),onKeyDown:E(n,zr),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(Ar,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${n}:${Br}`,readOnly:p,placeholder:`value`,onKeyDown:E(n,Br),onChange:e=>w(n,{value:e,enabled:!0})}):t(`input`,{class:`cell`,"data-cell":`${n}:${Br}`,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,Br)})}),t(`td`,{class:`g-doc`,title:Pe(r?.description),children:r&&t(l,{children:[t(`span`,{class:`chip`,children:r.type}),` `,t(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:Le(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(Hr,{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(Hr,{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}:${zr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{g.current=`${r.length}:${zr}`,i([...r,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:E(k,zr),onPaste:e=>O(e,r.length)})}),t(`td`,{class:`g-val`}),t(`td`,{class:`g-doc`}),t(`td`,{class:`g-act`})]},k)]})]})]})}function Wr({draft:e,onChange:r,readOnly:i}){let[o,c]=a(()=>Or(e.body)),l=s(e.body);n(()=>{if(e.body===l.current)return;let t=Or(e.body);t&&c(t),l.current=e.body},[e.body]);let u=t=>{let n={...o,...t};c(n),l.current=kr(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(mr,{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(mr,{readOnly:i,label:`GraphQL variables`,language:`json`,value:o.variables,onChange:e=>u({variables:e})})]})}var Gr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function Kr({encoding:e,draft:n,onChange:r,schema:i,defs:s,files:c=[],notes:u,readOnly:d}){let[f,p]=a(0),m=o(()=>Xe(n.body),[n.body]),h=e===`json`||e===`form`,g=o(()=>{let e=m[f];return e&&h?Et(wt(i,s,e,[`data`]),u,`data`,Ye(e)):void 0},[m,f,i,s,h,u]),_=o(()=>h&&i?(e,t)=>br(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:me(JSON.parse(n.body||`{}`))})}catch{r({...n,formView:`grid`})}else r({...n,formView:`json`,body:JSON.stringify(_e(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(xr(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(Ur,{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=>Et(wt(i,s,Tt(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&Or(n.body)?t(Wr,{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(mr,{readOnly:d,label:`Request body`,language:Gr(e===`form`?`json`:e),value:n.body,onChange:e=>r({...n,body:e}),onLine:p,complete:_}),h&&t(Dr,{doc:g})]})}var qr=`specbook:code-lang`;function Jr(){try{let e=L.local.getItem(qr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Yr({service:e,profile:r,secured:i,make:s,sent:c}){let[l,u]=a(Jr),d=l===`sent`?`curl`:l,[f,p]=a(!1),[m,h]=a(),[g,_]=a();n(()=>{let t=!0;return N.config(k.value).then(async n=>{let i=n.services?.[e],a=t=>N.baseUrlOf(e,t,k.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,ee.value]);let v=o(()=>{try{return{text:Ae(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(qr,e)}catch{}};return t(`div`,{class:`code-sample`,children:[t(`div`,{class:`code-head`,children:[t(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[je.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 Xr({service:e,method:n,path:r,draft:a,encoding:o,vars:s,secured:c,sent:l}){let u=i((e,t)=>{let i=wr(a,o),c={path:i.path??{},query:i.query??{},headers:i.headers??{},data:i.data},l=c;try{l=f(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(Yr,{service:e,profile:c?`service`:void 0,secured:c,make:u,sent:l})}function Zr({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(Yr,{service:e.service,profile:e.profile,secured:!!e.profile,make:a,sent:r})}function Qr(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 $r(e){let t=typeof e==`string`?e:Qr(e);return t.length>28?`${t.slice(0,27)}…`:t}var ei=e=>typeof e==`string`?e:Qr(e,2);function ti(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 ni({body:e,docs:n}){let[r,i]=a(0),s=ei(e),c=!!n?.schema&&typeof e==`object`&&!!e,u=o(()=>c?Xe(s):[],[c,s]),d=o(()=>{let e=u[r];return e&&n?Et(wt(n.schema,n.defs,e,[`data`]),n.notes,`data`,Ye(e)):void 0},[u,r,n]);return t(l,{children:[t(mr,{label:`Body as sent`,value:s,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&t(Dr,{doc:d})]})}function ri({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,ti(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(ni,{body:e.body,docs:r})]})]})}function ii(e){let t=e.location;if(!t)return;let n=[...C.requests,...C.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 ai={expected:`−`,received:`+`,same:` `,skip:` `},oi={expected:`expected`,received:`received`,same:``,skip:``};function si({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:ai[e.kind]}),oi[e.kind]&&t(`span`,{class:`visually-hidden`,children:[oi[e.kind],`: `]}),t(`span`,{class:`diff-text`,children:e.text})]}))})}function ci({a:e}){let n=de(e),r=ii(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(si,{lines:n})]}),r&&t(`div`,{class:`check-where`,children:[`at `,r]})]})}function li({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(ci,{a:e})}))})}var ui=e=>Qr(e,2),di=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function fi({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?Je(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:ui(m.body),v=o(()=>Xe(_),[_]),y=o(()=>{let e=v[f];return e?wt(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 ${et(m.status)}`,children:[m.status,` `,$e(m.status)]}),t(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),t(`span`,{class:`rs-stat`,children:di(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,ti(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(w,{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(mr,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:p}),_!==``&&t(Dr,{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(li,{assertions:b})})]})]})]})}var pi=()=>{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 mi(e){let t=window.open(``,u,`popup,width=520,height=720`);if(!t)throw new ae(`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 g(),o=y(),s=pi(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new ae(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new ae(`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=x({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=M({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(j({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return p(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var hi=`specbook.oauth.clients.v1`,gi=`specbook.oauth.expiry.v1`,_i=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},vi=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},yi=e=>{try{return _i(L.local,hi)[e]}catch{return}},bi=(e,t)=>{try{vi(L.local,hi,{..._i(L.local,hi),[e]:t})}catch{}},xi=(e,t)=>`${e}\n${t}`,Si=(e,t,n)=>{try{let r=_i(L.session,gi);n===void 0?delete r[xi(e,t)]:r[xi(e,t)]=Date.now()+n*1e3,vi(L.session,gi,r)}catch{}},Ci=(e,t)=>{try{return _i(L.session,gi)[xi(e,t)]}catch{return}};function wi({service:e,profile:r,origin:i,secret:o,oauth:c,onSignedIn:l}){let u=h(c)?c.openIdConnectUrl:c.authorizationUrl,[d,f]=a(()=>c.clientId??yi(u)??``);n(()=>{f(c.clientId??yi(u)??``)},[u,c.clientId]);let[p,m]=a(void 0),[g,_]=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:k.value,profile:r}).then(t=>{e&&(m(t),_(h(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,k.value,S,ee.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`}),bi(u,e),mi({authorizationUrl:p.authorizationUrl,clientId:e,scopes:g,signal:t.signal,exchange:(e,t)=>N.oauthExchange({env:P.value,version:k.value,profile:r,fields:e,signal:t})}).then(e=>{I.set(i,o,e.accessToken),Si(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 (`,g.length,` of `,w.length,`)`]}),w.map(e=>t(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[t(`input`,{type:`checkbox`,checked:g.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: ${pi()}`:`Looking up the provider…`})]})}var Ti=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),Ei={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Di({services:e,enabled:r=!0,supplied:i}){let[o,s]=a([]),[c,u]=a({}),d=i??c,[,f]=a(0),[p,h]=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(k.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=S(s?m(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(O)].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,_,k.value,ee.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:()=>h(!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&&Ti(Ci(e.origin,n))!==void 0?` · expires in ${Ti(Ci(e.origin,n))} min`:``]}),t(`button`,{type:`button`,class:`link`,onClick:()=>{I.remove(e.origin,n),Si(e.origin,n,void 0),f(e=>e+1)},children:`Clear`})]}):t(l,{children:[i&&t(`span`,{class:`muted`,children:[`from `,Ei[i]??i]}),e.oauth&&t(wi,{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:()=>h(!1),children:`Hide`})]})}var Oi=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),ki=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ai(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[ki(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(ki(Oi(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 ji(e){let{seq:t}=e,[r,i]=a(),[s,c]=a(!1);n(()=>{let n=!0;i(void 0),c(!1);let r=C.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(()=>({...Ai(r??Ne(t.meta.description),l),loaded:s}),[r,l,t,s])}function Mi(e){let[t,r]=a();return n(()=>{let t=!0;return r(void 0),e&&C.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&r(e)),()=>{t=!1}},[e]),t}var Ni=(e,t)=>`specbook:draft:${e}:${t}`,Pi=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Fi(e){try{let t=L.local.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Ii=`specbook:saved-example`;function Li(e){try{let t=L.session.getItem(Ii),n=t?JSON.parse(t):void 0;return n?.key===e?(L.session.removeItem(Ii),n):void 0}catch{return}}function Ri({service:e,op:r,variants:i,initial:c,autoRun:u}){let f=`${e}/${r.id}`,p=s(null),m=s(!1),h=s(void 0),g=N.examplesOf(f),[_,v]=a(()=>Li(f)),[y,b]=a(()=>{if(c?.startsWith(`saved:`)&&i.some(e=>`saved:${e.file}`===c))return c;let e=g.find(e=>e.name===(_?.name??c));return e?`ex:${e.name}`:g[0]?`ex:${g[0].name}`:i[0]?`saved:${i[0].file}`:``}),x=y.startsWith(`saved:`)?i.find(e=>`saved:${e.file}`===y):void 0,S=Mi(x?.file),E=ft(f),[O,j]=a(),[M,F]=a(),[I,ae]=a(),[se,ce]=a({}),[R,le]=a(),[ue,de]=a(),[z,fe]=a(),[pe,me]=a(),[he,ge]=a(),[_e,ve]=a(),[ye,be]=a(!1),[xe,Se]=a(),[Ce,B]=a(),[we,Te]=a(``),[V,Ee]=a(),[De,H]=a();n(()=>{let t=!0;if(H(void 0),P.value===`mock`)Te(``);else return N.baseUrlOf(e,P.value,k.value).then(e=>t&&Te(e??``)).catch(e=>{t&&(Te(``),H(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[e,P.value,k.value,ee.value]),n(()=>{let e=!0;return Ee(void 0),N.knownVars(P.value,k.value).then(t=>e&&Ee(t)),()=>{e=!1}},[P.value]),n(()=>{let t=!0;return C.schemas[f]?.().then(e=>t&&le(e.default)),C.responseSchemas[f]?.().then(e=>t&&de(e.default)),C.definitions[e]?.().then(e=>t&&fe(e.default)),N.operationMeta(f,k.value).then(e=>{t&&j({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[f,e]);let U=O?.encoding??`json`,Oe=C.manifests[e]?.operations.find(e=>e.id===r.id)?.secured;n(()=>{if(!O)return;let e=!0;return ve(void 0),ge(void 0),(async()=>{let t=x?await N.savedExample(x.def,k.value):await N.loadExample(f,y.replace(/^ex:/,``),k.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};F(n),ae(!x&&Fi(Ni(f,y))||Sr(n,U))})().catch(t=>e&&ve(t instanceof Error?t.message:String(t))),()=>{e=!1}},[f,y,O,x]);let ke=o(()=>M?Sr(M,U):void 0,[M,U]),Ae=!!I&&!!ke&&JSON.stringify(Tr(I))!==JSON.stringify(Tr(ke)),je=e=>{if(ae(e),!x)try{let t=Ni(f,y);ke&&JSON.stringify(Tr(e))===JSON.stringify(Tr(ke))?L.local.removeItem(t):L.local.setItem(t,JSON.stringify(Tr(e)))}catch{}},W=o(()=>{let e=R?q(R,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=We(r,z).map(e=>({name:e.name,doc:Et(wt(R,z,[e.name],[n]),E.notes,n,e.name),repeat:q(e.schema,z).type===`array`})))}return t},[R,z,E.notes]),Me=o(()=>{if(!I)return[];try{let e=wr(I,U);return[...d([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(e=>e.split(`.`)[0]).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[I,U]),Ne=Object.keys(x?.def.input.init??{}),Pe=V?Me.filter(e=>!V.includes(e)&&!Ne.includes(e)):[],Fe=Pe.filter(e=>(se[e]??``)===``),Ie=async e=>{if(!I||h.current)return;ve(void 0),be(!0);let t=new AbortController;h.current=t;try{let n=x?x.def:await N.operationRequest(f,k.value,wr(I,U)),r=await N.run(n,{env:P.value,version:k.value,mockStatus:P.value===`mock`?e??pe:void 0,locale:ie.value,seed:te.value,vars:Object.fromEntries(Object.entries(se).filter(([,e])=>e!==``)),fileDir:M?.dir,signal:t.signal});ge(r),vt.value=yt(r)}catch(e){ve(e instanceof Error?e.message:String(e))}finally{h.current=void 0,be(!1),B(`response`)}};n(()=>{u&&I&&!m.current&&(m.current=!0,Ie())},[I]);let Le=async t=>{if(!I)return;let n=wr(I,U),i=Pi(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=`${C.project.requestsDir}/${e}/${r.id}/${i}.example.json`,s={key:f,path:o,name:i};try{L.session.setItem(Ii,JSON.stringify(s))}catch{}await re(o,`${JSON.stringify(a,null,2)}\n`),v(s),Se(void 0)},G=he?.steps.find(e=>e.response)??he?.steps[0],Re=_e?.match(/Missing variable "\{\{([^}.]+)/)?.[1],ze=!!I&&(I.path.length>0||I.query.length>0||W.path.length>0||W.query.length>0),Be=!!I&&(I.headers.length>0||W.headers.length>0),Ve=!!I&&U!==`none`&&(I.body!==``||I.fields.length>0||!!R?.properties?.data),K=Ce??(ze?`params`:Ve?`body`:Be?`headers`:`params`),J=e=>e.filter(e=>e.enabled).length,He=I?J(I.query):0,Ue=I?J(I.path):0,Ge=I?Er(r.path,I.path,I.query,we):r.path;return n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Ie())},t=p.current?.getRootNode()??window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)}),t(`div`,{class:`request-panel`,"data-op":f,ref:p,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:Ge,children:t(`code`,{children:Ge.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?t(`mark`,{children:e}):e)})}),(G?.response||_e||G?.error)&&t(`button`,{type:`button`,class:`result-chip ${G?.response?et(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>B(`response`),children:G?.response?`${G.response.status} ${$e(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),t(`button`,{type:`button`,class:`btn primary send`,title:ye?`Stop`:`Send (⌘/Ctrl + Enter)`,"aria-label":ye?`Stop`:`Send`,disabled:!ye&&!I,onClick:()=>ye?h.current?.abort():Ie(),children:t(ye?oe:w,{})})]}),De&&t(`p`,{class:`envmenu-warn`,role:`alert`,children:[De,`.`,` `,D.value.environmentSettings&&t(`button`,{type:`button`,class:`link`,onClick:()=>T.value=!0,children:`Open Environment settings`})]}),S&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this request`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:S}})]},x?.file),Pe.length>0&&t(`fieldset`,{class:`needs-vars ${Fe.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[t(`span`,{class:`muted`,children:Fe.length>0?`Needs a value for`:`Values for`}),Pe.map(e=>t(`label`,{class:`needs-var`,children:[t(`code`,{children:e}),t(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:se[e]??``,onInput:t=>ce({...se,[e]:t.target.value})})]}))]}),Oe&&t(Di,{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:y,onChange:e=>b(e.target.value),children:[g.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,` · saved request`]}))]})]}),t(ne,{})]}),Ae&&t(`span`,{class:`edited`,children:`Edited`}),t(`span`,{class:`spacer`}),Ae&&t(`button`,{type:`button`,class:`link`,onClick:()=>ke&&je(ke),children:`↺ Reset`}),!A&&!x&&Ae&&xe===void 0&&t(`button`,{type:`button`,class:`link`,onClick:()=>Se(``),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:pe===void 0?``:String(pe),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);me(n),Ie(n)},children:[t(`option`,{value:``,children:`Default`}),r.statuses.map(e=>t(`option`,{value:String(e),children:[e,` `,$e(e)]}))]})]})]}),_&&t(`p`,{class:`saved-note`,role:`status`,children:[t(`span`,{children:[`✓ Saved to `,t(`code`,{children:_.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:()=>v(void 0),children:`×`})]}),xe!==void 0&&t(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),xe.trim()&&Le(xe.trim()).catch(e=>ve(String(e)))},children:[t(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:xe,onInput:e=>Se(e.target.value)}),t(`button`,{type:`submit`,class:`btn`,children:`Save`}),t(`button`,{type:`button`,class:`link`,onClick:()=>Se(void 0),children:`Cancel`})]}),x&&t(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock hook apply, and it is read-only here.`}),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,He+Ue],[`headers`,`Headers`,I?J(I.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,Me.length]].filter(([e])=>e===`params`?ze:e===`headers`?Be:e===`body`?Ve:Me.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 ${et(G.response.status)}`,children:G.response.status}),!G?.response&&(_e||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(Ur,{title:`Query`,rows:I.query,documented:W.query,readOnly:!!x,onChange:e=>je({...I,query:e})}),(I.path.length>0||W.path.length>0)&&t(Ur,{title:`Path`,rows:I.path,documented:W.path,fixed:!0,readOnly:!!x,onChange:e=>je({...I,path:e})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:Be&&t(Ur,{title:`Headers`,rows:I.headers,documented:W.headers,readOnly:!!x,onChange:e=>je({...I,headers:e})})}),t(`div`,{class:`tab-pane`,hidden:K!==`body`,children:Ve&&t(Kr,{encoding:U,draft:I,onChange:je,schema:R,defs:z,files:O?.files,notes:E.notes,readOnly:!!x})}),t(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:Me.length>0&&t(Ur,{title:`Variables`,rows:Me.map(e=>({key:e,value:se[e]??``,enabled:!0})),fixed:!0,bad:Re,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(Xr,{service:e,method:r.method,path:r.path,draft:I,encoding:U,vars:se,secured:Oe,sent:G?.request?t(ri,{request:G.request,docs:{schema:R,defs:z,notes:E.notes}}):void 0})}),t(`div`,{class:`tab-pane`,hidden:K!==`response`,children:t(fi,{step:G,error:_e,schemas:ue,defs:z})})]})]})})}function zi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Bi(e,t),...n}}function Bi(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,zi(t)]))};case`array`:return{kind:`array`,item:zi(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 Vi(e){if(e.generate)try{return e.generate()}catch{}return Hi({...e,generate:void 0})}function Hi(e){if(e.generate)return Vi(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,Hi(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Ui={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Wi=e=>typeof e==`string`?e:Qr(e);function Gi({info:e}){let{seq:n}=e,{intro:r,notes:i}=ji(e),a=o(()=>Object.entries(n.meta.inputs??{}).map(([e,t])=>{let n=zi(t);return{name:e,spec:n,initial:Hi(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:Wi(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:()=>b({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:Ui[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 Ki=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function qi(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Ji({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(Ar,{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=>Ki(e.value,r));return t(Ar,{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=>Ki(e,n.value)),onChange:t=>i(t.target.checked?[...e,n.value]:e.filter(e=>!Ki(e,n.value)))}),n.label]}))})}case`object`:case`array`:return t(`input`,{class:`cell mono`,"aria-label":e,value:o??JSON.stringify(r??Hi(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 Yi(){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 Xi({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,Vi(n[e])]))}),children:[t(Yi,{}),` 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(Ji,{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]:Vi(a)}),children:t(Yi,{})})]})}),t(`td`,{class:`g-doc`,title:a.description,children:[t(`span`,{class:`chip`,children:qi(a)}),` `,a.description]})]},e)})})]})]})}function Zi({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&&(C.schemas[g]?.().then(t=>e&&f(t.default)),N.operationMeta(g,k.value).then(t=>e&&m(t?.encoding??`json`)),C.responseSchemas[g]?.().then(t=>e&&c(t.default)),C.definitions[h.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[g]);let _=e.response,v=h?`${h.url}${ti(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 ${et(_.status)}`,children:[_.status,` `,$e(_.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 ${et(_.status)}`,children:_.status})]}))}),t(`div`,{class:`rq-pane`,children:[t(`div`,{class:`tab-pane`,hidden:i!==`request`,children:h?t(Zr,{request:h,encoding:p,sent:t(ri,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}):t(ri,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}),t(`div`,{class:`tab-pane`,hidden:i!==`response`,children:t(fi,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var Qi=e=>e.replace(/ #\d+$/,``),$i={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``};function ea({info:e,preset:r,autoRun:i}){let{seq:c}=e,l=o(()=>Object.fromEntries(Object.entries(c.meta.inputs??{}).map(([e,t])=>[e,zi(t)])),[c]),u=ji(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,A]=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(k.value,ie.value,te.value).catch(()=>{}),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)])));n(()=>{let e=!0,t=e=>({...e,...r??{}});return p(t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)])))),j?ee().then(n=>{e&&(p(t(n)),i&&ce({inputs:t(n),headless:!0}))}):i&&ce({inputs:t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Hi(t)]))),headless:!0}),h(void 0),_({}),x(void 0),()=>{e=!1}},[e.file]);let re=c.nodes.map(e=>e.name),F=m?m.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):re.map(e=>({name:e})),I=F[w]?.step,ae=s(void 0),[oe,L]=a(!1),se=()=>{L(!0),ae.current?.abort(),b?.resolve(S)},ce=async(e={})=>{let t=new AbortController;ae.current=t,L(!1),y(!0),h(void 0),A(void 0),_({}),T(0),D(!1);try{let n=await N.run(c,{env:P.value,version:k.value,inputs:e.inputs??f,locale:ie.value,seed:te.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,Hi(t)]))),x({name:e,controls:r,resolve:e=>{x(void 0),n(e)}})})});h(n),vt.value=yt(n);let r=n.steps.filter(e=>e.kind!==`auth`).findIndex(e=>e.status===`fail`||e.status===`error`);r>=0&&T(r)}catch(e){A(e instanceof Error?e.message:String(e))}finally{ae.current=void 0,y(!1),x(void 0)}},R=m?.status;return t(`div`,{class:`sequence-panel ${E&&I?`sheet-open`:``}`,"data-seq":c.meta.id,children:[t(`div`,{class:`seq-left`,children:[t(Di,{services:d}),t(Xi,{title:`Inputs`,specs:l,values:f,onChange:p}),t(`div`,{class:`seq-run`,children:[t(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:()=>ce(),children:v?`Running…`:`▶ Run`}),v&&t(`button`,{type:`button`,class:`btn`,onClick:se,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 ce({inputs:e,headless:!0})},children:`Run with defaults`}),t(ne,{}),m&&t(`span`,{class:`badge ${R}`,children:[$i[R],` `,R===`pass`?`Passed`:oe?`Stopped`:R===`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:F.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:$i[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:Qr(n),children:[`→ `,e,` `,t(`b`,{children:$r(n)})]})),r?.error&&t(`div`,{class:`error-text`,children:r.error}),a.map(e=>t(ci,{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(Xi,{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&&I?`sheet-open`:``}`,children:[I&&t(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>D(!1),children:[t(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,I.name]}),!I&&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.`})]}),I&&t(Zi,{step:I,note:u.notes.get(Qi(I.name))})]})]})}function ta(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(Ct,{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(Gi,{info:e.info}):t(ea,{info:e.info,preset:e.preset,autoRun:e.autoRun})})]})}):t(Ct,{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(_t,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):t(Ri,{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{ta as Host};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Host-Cq-4gDuM.js","./panel-9eYU7Gz6.js","./panel-hNOojwiM.css","./mount-DfwluJy4.js","./registry-DIHX11uY.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-9eYU7Gz6.js";import{a as m,n as h}from"./mount-DfwluJy4.js";import{a as g,c as _,d as v,environmentStore as y,f as b,i as x,l as S,loadManifests as C,m as w,mode as T,n as E,o as D,p as ee,r as te,s as O,t as k,u as ne}from"./registry-DIHX11uY.js";var re=Object.prototype.hasOwnProperty;function ie(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=ie(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=ie(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(re.call(e,n)&&++r&&!re.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 ae,oe,se,ce,le=!0;typeof process<`u`&&({FORCE_COLOR:ae,NODE_DISABLE_COLORS:oe,NO_COLOR:se,TERM:ce}={},le=process.stdout&&process.stdout.isTTY);var j={enabled:!oe&&se==null&&ce!==`dumb`&&(ae!=null&&ae!==`0`||le),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 ue(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 de(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?ue(this.keys,t+``):t+``):t===void 0?de([e],[n]):j.enabled?ue([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(fe(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 fe(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 pe=new N;function me(e,t,n){return pe.diff(e,t,n)}var he=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ge=/\S/,_e=new N;_e.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!ge.test(e)&&!ge.test(t)},_e.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]&&he.test(t[n])&&he.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var ve=new N;ve.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 ye(e,t,n){return ve.diff(e,t,n)}var be=new N;be.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var xe=new N;xe.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Se(e){"@babel/helpers - typeof";return Se=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},Se(e)}var Ce=Object.prototype.toString,we=new N;we.useLongestToken=!0,we.tokenize=ve.tokenize,we.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(Te(e,null,null,i),i,` `)},we.equals=function(e,t){return N.prototype.equals.call(we,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Te(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(Ce.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Te(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),Se(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]=Te(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var Ee=new N;Ee.tokenize=function(e){return e.slice()},Ee.join=Ee.removeEmpty=function(e){return e};function De(e,t,n){return Ee.diff(e,t,n)}var P={"--":j.red,"··":j.grey,"++":j.green},Oe=j.dim().italic,ke=j.dim(`→`),Ae=j.dim(`·`),je=j.dim(`↵`),Me=(e,t)=>P[e](e+Pe(t))+`
|
|
4
|
-
`,Ne=(e,t)=>j.dim(`L`+String(e).padStart(t,`0`)+` `),Pe=e=>e.replace(/[ ]/g,Ae).replace(/\t/g,ke).replace(/(\r?\n)/g,je);function Fe(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(Oe(`Expected:`))+`
|
|
6
|
-
`:e.removed&&(s+=P[r]().underline(Oe(`Actual:`))+`
|
|
7
|
-
`);a<i.length;a++)o=i[a],o!=null&&(t&&(s+=Ne(t+a,n)),s+=Me(r,o||`
|
|
8
|
-
`));return s}function Ie(e,t){let n=De(e,t),r=0,i=0,a=0,o,s,c,l,u,d=Me(`··`,`[`);for(;r<n.length;r++)for(c=(o=n[r]).removed?`--`:o.added?`++`:`··`,o.added?d+=P[c]().underline(Oe(`Expected:`))+`
|
|
9
|
-
`:o.removed&&(d+=P[c]().underline(Oe(`Actual:`))+`
|
|
10
|
-
`),i=0;i<o.value.length;i++)for(l=o.value[i]&&typeof o.value[i]==`object`,s=He(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+=Me(c,u);return d+Me(`··`,`]`)}function Le(e,t,n=0){let r=0,i,a=``,o=ye(e,t),s=String(t.split(/\r?\n/g).length-n).length;for(;r<o.length;r++)a+=Fe(i=o[r],n,s),n&&!i.removed&&(n+=i.count);return a}function Re(e,t){let n=me(e,t),r=0,i=``,a,o=e.length,s=t.length,c=Pe(e),l=Pe(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+=ze(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 ze(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)+Oe(`(Expected)`))+`
|
|
11
|
-
`+P[`--`](`--`+e+` `.repeat(i+a-n)+Oe(`(Actual)`))+`
|
|
12
|
-
`}function Be(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]=Be(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]=Be(i,t[n]));for(n in e)s.hasOwnProperty(n)||(s[n]=e[n])}return s}function Ve(){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 He(e){return JSON.stringify(e,Ve(),2).replace(/"\[__NAN__\]"/g,`NaN`).replace(/"\[__VOID__\]"/g,`undefined`)}function Ue(e,t){if(Array.isArray(t)&&Array.isArray(e))return Ie(e,t);if(t instanceof RegExp)return Re(``+e,``+t);let n=e&&typeof e==`object`,r=t&&typeof t==`object`;return n&&r&&(e=Be(e,t)),r&&(t=He(t)),n&&(e=He(e)),t&&typeof t==`object`&&(e=He(Be(e,t)),t=He(t)),n=typeof e==`string`,r=typeof t==`string`,n&&/\r?\n/.test(e)?Le(e,``+t):r&&/\r?\n/.test(t)?Le(``+e,t):n&&r?Re(e,t):ze(e,t)}var We=w({Assertion:()=>Ge,equal:()=>Je,fixture:()=>tt,instance:()=>Ze,is:()=>qe,match:()=>Qe,not:()=>L,ok:()=>Ke,snapshot:()=>$e,throws:()=>nt,type:()=>Xe,unreachable:()=>Ye});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 Ge=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 Ge({actual:t,expects:n,operator:r,message:s,details:i&&i(t,n),generated:!o})}function Ke(e,t){I(!!e,!1,!0,`ok`,!1,`Expected value to be truthy`,t)}function qe(e,t,n){I(e===t,e,t,`is`,Ue,`Expected values to be strictly equal:`,n)}function Je(e,t,n){I(A(e,t),e,t,`equal`,Ue,`Expected values to be deeply equal:`,n)}function Ye(e){I(!1,!0,!1,`unreachable`,!1,`Expected not to be reached!`,e)}function Xe(e,t,n){let r=typeof e;I(r===t,r,t,`type`,!1,`Expected "${r}" to be "${t}"`,n)}function Ze(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 Qe(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 $e(e,t,n){e=F(e),t=F(t),I(e===t,e,t,`snapshot`,Le,`Expected value to match snapshot:`,n)}var et=(e,t)=>Le(e,t,1);function tt(e,t,n){e=F(e),t=F(t),I(e===t,e,t,`fixture`,et,`Expected value to match fixture:`,n)}function nt(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 Ge)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,qe.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 rt=/\u001b\[[0-9;]*m/g,it=e=>e.replace(rt,``),at=/(?:\(|at )?([^\s()]+):(\d+):(\d+)\)?\s*$/;function ot(e){if(!e)return;let t=e.split(`
|
|
14
|
-
`).slice(1).map(e=>({line:e,m:at.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 st(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:ot(Error().stack)})}catch(r){if(r?.name!==`Assertion`||(t.push({label:it(String(r.message??o??n)),operator:n,pass:!1,actual:r.actual,expected:r.expects,diff:r.details?it(String(r.details)):void 0,location:ot(Error().stack)}),e===`hard`))throw r}}},r=We,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 ct=e=>typeof e.opts.default==`function`;function lt(e){return typeof e==`function`?e():e}var ut=class extends Error{};function dt(e,t){let n=e.opts.value;return n?n(t):t}function ft(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function pt(e,t,n){switch(t.kind){case`select`:{let r=t.opts.options;if(r.length===0)throw new ut(`No options available for "${e}"`);let i=r.map(e=>dt(t,e));if(n!==void 0){if(!i.some(e=>ft(e,n)))throw new ut(`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=>ft(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,pt(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 ut(`"${e}" needs at least ${i} items`);if(a!==void 0&&r.length>a)throw new ut(`"${e}" allows at most ${a} items`);return r.map(n=>pt(e,t.opts.item,n))}case`boolean`:return n??lt(t.opts.default)??!1;case`number`:return n??lt(t.opts.default)??0;default:return n??lt(t.opts.default)??``}}function mt(e,t={}){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,pt(e,n,t[e])]))}function ht(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(dt(t,e)),value:dt(t,e)}));return[e,{kind:t.kind,options:r}]}return[e,{kind:t.kind,default:lt(t.opts.default),generated:ct(t)}]}))}var R=class extends Error{variable;constructor(e,t){super(e),this.variable=t,this.name=`AddressError`}},gt=[`authorizationUrl`,`tokenUrl`,`openIdConnectUrl`,`clientId`];function _t(e,t,n={},r={}){return{...e.vars,...e.environments?.[t]?.vars,...n,...r}}function vt(e,t,n){for(let t of x(e))if(D(t)||O(t))throw new R(`${n} cannot use {{${t}}}: only environment variables are available`);let r;try{r=ne(e,t)}catch(e){throw e instanceof te?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 yt(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)?vt(a,r,o):a.trim();return s?s.replace(/\/+$/,``):void 0}function bt(e,t,n=`sign-in`){let r={...e};for(let e of gt){let i=r[e];if(typeof i!=`string`||!/\{\{/.test(i))continue;let a=vt(i,t,`${n} ${e}`);a?r[e]=a:delete r[e]}return r}function xt(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 St(e){let t={},n=e=>{if(!(D(e)||O(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 x(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 gt){let i=r.oauth?.[e];if(typeof i==`string`)for(let r of x(i))n(r)?.profiles.push({profile:t,field:e})}return t}var Ct={comma:`,`,space:` `,pipe:`|`},wt=e=>typeof Blob<`u`&&e instanceof Blob;function Tt(e,t=`indices`,n=``,r=[]){if(typeof t==`string`||n||typeof e!=`object`||!e)Et(n,e,r,typeof t==`string`?t:`indices`);else for(let[n,i]of Object.entries(e))Et(n,i,r,t[n]??`indices`);return r}function Et(e,t,n,r){if(t!=null){if(Array.isArray(t)&&r in Ct&&t.every(e=>typeof e!=`object`||!e))n.push([e,t.map(String).join(Ct[r])]);else if(Array.isArray(t))t.forEach((t,i)=>{Et(r===`indices`||r in Ct?`${e}[${i}]`:r===`brackets`?`${e}[]`:e,t,n,r)});else if(typeof t==`object`)for(let[i,a]of Object.entries(t))Et(e?`${e}[${i}]`:i,a,n,r);else n.push([e,String(t)])}}function Dt(e,t=`indices`){return Tt(e,t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}function Ot(e){let t=new FormData,n=(e,n)=>{n!=null&&(wt(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 kt(e){return JSON.stringify(typeof e==`string`?{query:e}:e)}function At(e,t,n,r){switch(e){case`json`:return{body:JSON.stringify(t),contentType:`application/json`};case`graphql`:return{body:kt(t),contentType:`application/json`};case`form`:return{body:Dt(t,n),contentType:`application/x-www-form-urlencoded`};case`text`:return{body:String(t),contentType:`text/plain`};case`multipart`:return{body:Ot(t)};case`binary`:return{body:t,contentType:r||(wt(t)&&t.type?t.type:`application/octet-stream`)};default:return{body:t}}}function jt(e){if(wt(e)){let t=e;return{file:t.name??`file`,type:t.type,size:t.size}}return Array.isArray(e)?e.map(jt):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,jt(t)])):e}var z=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Mt=e=>[`string`,`number`,`boolean`].includes(typeof e);function Nt(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 Pt(e,t){if(z(e)&&z(t)){let n={...e};for(let[e,r]of Object.entries(t))e in n&&(n[e]=Pt(n[e],r));return n}if(Array.isArray(e)&&Array.isArray(t)){if(t.length===0)return e;if(t.every(Mt)&&e.every(Mt))return t;let n=e[0];return z(n)&&t.every(z)?t.map(e=>Pt(n,e)):e}return Mt(t)&&Mt(e)&&typeof t==typeof e?t:typeof e==`number`&&typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t))?Number(t):e}function Ft(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]=Nt(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=Nt(t,n.id));return n}var It=e=>Mt(e),Lt=new Set([`id`,`object`,`type`,`kind`,`created`,`updated`,`url`,`livemode`,`metadata`,`status`]);function Rt(e,t=[],n=[],r=0){if(r>6)return n;if(z(e))for(let[i,a]of Object.entries(e))Rt(a,[...t,i],n,r+1);else Array.isArray(e)?e.length&&Rt(e[0],[...t,0],n,r+1):It(e)&&n.push({path:t,value:e});return n}var zt=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n};function Bt(e,t,n=[],r=[],i=0){if(i>5)return r;if(z(e))for(let[a,o]of Object.entries(e))a===t&&It(o)?r.push([...n,a]):Bt(o,t,[...n,a],r,i+1);else Array.isArray(e)&&e.length&&Bt(e[0],t,[...n,0],r,i+1);return r}var Vt=(e,t)=>typeof e==typeof t||typeof t==`number`&&typeof e==`string`&&e.trim()!==``&&!Number.isNaN(Number(e));function Ht(e,t,n){let r=zt(e,t.slice(0,-1));typeof r==`object`&&r&&(r[t[t.length-1]]=n)}function Ut(e,t,n){let r=structuredClone(e),i=new Set(Rt(n).map(e=>e.path.join(`\0`)));for(let e of Rt(t)){if(zt(r,e.path)!==void 0)continue;let t=String(e.path[e.path.length-1]);if(Lt.has(t)||typeof e.path[e.path.length-1]==`number`)continue;let n=Bt(r,t).filter(e=>!i.has(e.join(`\0`)));if(n.length!==1)continue;let a=n[0],o=zt(r,a);Vt(e.value,o)&&(Ht(r,a,Nt(e.value,o)),i.add(a.join(`\0`)))}return r}var Wt=/^(limit|per_?page|page_?size|size|count|max|max_?results|take)$/i;function Gt(e){return Array.isArray(e)?e[0]:typeof e==`string`&&e.includes(`,`)?e.split(`,`)[0]?.trim():e}function Kt(e,t){let n=Object.entries(t).map(([e,t])=>[e,Gt(t)]).filter(([,e])=>It(e)&&e!==``);if(n.length===0)return e;let r=e=>{let t={...e};for(let[e,r]of n)e in t&&It(t[e])&&Vt(r,t[e])&&(t[e]=Nt(r,t[e]));return t},i=n.find(([e])=>Wt.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 qt(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=Pt(n,e),z(n)&&z(e)&&(n=Ut(n,e,e)))}return z(n)&&t.path&&(n=Ft(n,t.path)),t.query&&(n=Kt(n,t.query)),n}var Jt=e=>e>=200&&e<300,Yt=e=>e===void 0?e:JSON.parse(JSON.stringify(e));function Xt(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(Jt)??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 Zt(401,await e.loader.example(n.service,n.opId,401));let s={...i?.vars??{},...i?.pathParams??{},...i?.rawQuery??{}},c=async t=>{let r=Yt(await e.loader.example(n.service,n.opId,t));return Jt(t)&&(r=qt(r,{body:n.body,path:i?.pathParams,query:i?.rawQuery})),r===void 0?void 0:S(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),{...Zt(l.status,l.data),headers:{"content-type":`application/json`,...l.headers}}}}function Zt(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`}},Qt=e=>`openIdConnectUrl`in e;function $t(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 en=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},tn=e=>en(crypto.getRandomValues(new Uint8Array(e)));async function nn(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 en(new Uint8Array(t))}async function rn(){let e=tn(48);return{verifier:e,challenge:await nn(e)}}var an=()=>tn(24);function on(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 sn(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 cn(e){return{grant_type:`authorization_code`,code:e.code,redirect_uri:e.redirectUri,client_id:e.clientId,code_verifier:e.verifier}}function ln(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 un=123,dn=125,fn=e=>e===32||e===9||e===10||e===13,pn=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e===45,mn=[115,101,99,114,101,116,115,46];function hn(e,t){let n=t+2;for(;n<e.length&&fn(e[n]);)n++;for(let t of mn)if(e[n++]!==t)return;let r=n;for(;n<e.length&&pn(e[n]);)n++;if(n===r)return;let i=String.fromCharCode(...e.subarray(r,n));for(;n<e.length&&fn(e[n]);)n++;if(e[n]===dn&&e[n+1]===dn)return{start:t,end:n+2,name:i}}function gn(e){let t=[];for(let n=0;n<e.length-1;n++)if(e[n]===un&&e[n+1]===un){let r=hn(e,n);r&&(t.push(r),n=r.end-1)}return t}var _n=new TextEncoder;function vn(e){return[...new Set(gn(e).map(e=>e.name))]}function yn(e,t){let n=gn(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),_n.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 bn=new TextDecoder;function xn(e,t){return e.includes(`{{`)?bn.decode(yn(_n.encode(e),t)):e}var Sn=new TextDecoder(`utf-8`,{fatal:!0}),Cn=new TextEncoder;function wn(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function Tn(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 En(e){try{return{kind:`text`,text:Sn.decode(e)}}catch{return{kind:`b64`,b64:wn(e)}}}function Dn(e){return e.kind===`text`?Cn.encode(e.text):Tn(e.b64)}async function On(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:En(new Uint8Array(await e.arrayBuffer()))}:{}}}function kn(e){let t=e.status===204||e.status===205||e.status===304;return new Response(e.body&&!t?Dn(e.body):null,{status:e.status,headers:e.headers})}var An=class extends Error{names;constructor(e){super(`Missing secrets: ${e.join(`, `)}`),this.names=e,this.name=`MissingSecretsError`}},jn=3;function Mn(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 Nn(e,t){let n=[...new Set([...t].filter(e=>e.length>=jn).flatMap(Mn))].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 Pn(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 Fn(e,t){try{return new URL(e,t).toString()}catch{return e}}function In(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=At(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());try{let n=await r(Pn(e.baseUrl(t.service),t),{method:t.method,headers:i,body:a,signal:o.signal}),s=await n.text(),c={};n.headers.forEach((e,t)=>{c[t.toLowerCase()]=e});let l=s;if(s.length===0)l=void 0;else try{l=JSON.parse(s)}catch{l=s}return{status:n.status,headers:c,text:s,body:l}}catch(e){throw s?Error(`Timed out after ${t.timeoutMs}ms: no answer from the API.`):n?.aborted?Error(`Stopped before the API answered.`):e}finally{c&&clearTimeout(c)}}}var V=()=>Date.now(),Ln=class extends Error{};function Rn(){return`run_${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}var zn=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]));function Bn(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=typeof r==`function`?r():r;return t}async function Vn(e){return typeof e==`function`?(await e()).default:e}async function Hn(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=>Hn(e,t,n)));let[r,...i]=t;return _(e)&&r in e?{...e,[r]:await Hn(e[r],i,n)}:e}async function Un(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 Hn(o,e.split(`.`),a);return o}function Wn(e,t,n){let r=new Set,i=[];for(let a of e){if(D(a)||O(a))continue;let e=a.split(`.`)[0];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 Gn(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 An([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 Ln(`No session value "${a}" for profile "${n}"`);return t.mask.add(String(o)),String(o)}),i=e=>wt(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?Nn(t,e.mask):t)}var Kn=new Set([`GET`,`HEAD`,`OPTIONS`]);function qn(e,t){if(e.input.safe||Kn.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 Jn(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 Yn(e,t){return{status:e.status,ok:e.status>=200&&e.status<300,headers:zn(e.headers),data:e.body,text:e.text,durationMs:t}}async function Xn(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 Qn(e,await r.login(),`Login (${t})`,Zn,`auth`,!0);if(n.push(o),!s?.ok)throw new Ln(`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 Zn={inputs:{},captured:{},from:{}};async function Qn(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`,Bn(t.input.init)],[`input`,r.inputs],[`capture`,r.captured],[`override`,Bn(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 Ln(`Example "${t.input.example}" not found for ${t.op.id}`);let p=g(f?.body,await Vn(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=Wn(x([p,m,h,_]),o,r.from);let v=p===void 0?void 0:S(p,d),y=S(m,d)??{},b=S(h,d)??{},C=zn(S(_,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 Un(v,t.op.files??[],w,e.o.readFile,f?.dir));let T=a?void 0:Jn(e,t),E=T?e.o.auth?.[T]:void 0,D={};E&&T&&(C={...zn(S(E.apply.headers??{},d)),...C},Object.assign(D,S(E.apply.query??{},d)));let ee=t.op.path.replace(/\{([^}]+)\}/g,(e,t)=>{let n=y[t];if(n==null)throw new Ln(`Missing path parameter "${t}"`);return encodeURIComponent(String(n))}),te={};for(let[e,t]of Object.entries({...b,...D}))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:ee,query:te,headers:C,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:jt(O.body),profile:T},H(e,{type:`request`,name:n,request:c.request}),e.o.readOnly&&i!==`auth`&&!qn(t,O))throw new Ln(`Refusing ${O.method} ${t.op.path} in "${e.o.env}": this is a --safe run, which only reads.`);let k=async()=>{T&&await Xn(e,T,s);let{mock:t,...n}=O,r={...Gn(n,e,T),mock:t},i=e.o.now?.()??V();return Yn(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 Xn(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=st(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 $n(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 er(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 tr(e,t,n,r,i){let a=Nn({schemaVersion:1,runId:Rn(),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:er(r),startedAt:new Date(i).toISOString(),durationMs:(e.o.now?.()??V())-i,totals:$n(r),steps:r},e.mask);return H(e,{type:`done`,result:a}),a}function nr(e){return{o:e,sessions:new Map,inflight:new Map,mask:new Set(Object.values(e.secrets??{}))}}async function rr(e,t){let n=nr(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 Qn(n,e,i,Zn);return tr(n,`request`,{id:e.op.id,title:i,tags:e.input.tags},[...o,a],r)}async function ir(e,t){let n=nr(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=mt(e.meta.inputs??{},t.inputs)}catch(t){return i.push({name:`inputs`,kind:`input`,status:`error`,assertions:[],captured:{},error:t.message,durationMs:0}),tr(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 Qn(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 Qn(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=ht(e);H(n,{type:`input:required`,name:r.name,controls:a});let o=mt(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=st(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 ut;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 tr(n,`sequence`,e.meta,i,r)}var U=d({links:[],ready:!1});function ar(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 or(e){let t=ar(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 sr=e=>`--sb-accent:${e};--sb-accent-hover:color-mix(in srgb,${e} 82%,black);--sb-focus-ring:color-mix(in srgb,${e} 45%,white);`+(or(e)?`--sb-text-on-accent:${or(e)};`:``);function cr(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}{${sr(e.accent)}}`:``;return e.accentDark?`${a}@media (prefers-color-scheme: dark){${r}{${sr(e.accentDark)}}}${i}{${sr(e.accentDark)}}`:a}function lr(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?cr(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 ur;function dr(e){ur=e,typeof location<`u`&&(W.value=hr(location.hash))}var fr=e=>ur&&e.startsWith(`${ur}/`)?e.slice(ur.length+1):e,pr=e=>ur&&!e.includes(`/`)?`${ur}/${e}`:e,mr=e=>encodeURIComponent(e).replace(/%2F/gi,`/`);function hr(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:pr(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 gr(e){if(e.kind===`home`)return`#/`;if(e.kind===`browse`)return`#/browse`;let t=e.kind===`op`?`#/op/${mr(fr(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 _r=()=>typeof matchMedia==`function`&&matchMedia(`(max-width: 820px)`).matches,vr=e=>_r()?{kind:`browse`}:{kind:`home`},W=d(hr(typeof location>`u`?``:location.hash)),G=d(!1),yr=d(``),br=d(``);function K(e){location.hash=gr(e),W.value=e}function xr(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 Sr({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 Cr({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 wr({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 Tr({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 Er({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 Dr(){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 Or(e){try{let t=globalThis[e];if(t)return t}catch{}return Dr()}var kr={get local(){return Or(`localStorage`)},get session(){return Or(`sessionStorage`)}},Ar=`specbook.environments.v1`,jr={local:{},session:{}},Mr=e=>e===`local`?kr.local:kr.session;function Nr(e){try{let t=Mr(e).getItem(Ar);return t?JSON.parse(t):jr[e]}catch{return jr[e]}}function Pr(e,t){jr[e]=t;try{Mr(e).setItem(Ar,JSON.stringify(t))}catch{}}function Fr(e,t=`local`){return{all:()=>Nr(t)[e]??{},save(n,r){let i=Nr(t);Pr(t,{...i,[e]:{...i[e],[n]:r}})},remove(n){let r=Nr(t),{[n]:i,...a}=r[e]??{};Pr(t,{...r,[e]:a})}}}var Ir=`specbook`;function Lr(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!==`${Ir}:reply`||!t.reply)return;let r=t.reply;(i===void 0||r.id===i)&&(s(),n(t.reply))},o=()=>{s(),window.postMessage({channel:`${Ir}: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:`${Ir}:call`,call:e},`*`)})}}}async function Rr(e=250){let t=globalThis.__SPECBOOK_EXTENSION__;if(t)return t;if(typeof window>`u`)return;let n=Lr(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 zr=0;function Br(e,t){return In({baseUrl:t,fetch:async(t,n)=>{let r=new Request(t,n),i=`c${Date.now().toString(36)}${zr++}`,a=await e.send({v:1,type:`fetch`,id:i,req:await On(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 kn(a.res)}})}var Vr=`specbook.secrets.v1`,Hr={},Ur=()=>{try{let e=kr.session.getItem(Vr);return e?JSON.parse(e):Hr}catch{return Hr}},Wr=e=>{Hr=e;try{kr.session.setItem(Vr,JSON.stringify(e))}catch{}},Gr={get:(e,t)=>Ur()[e]?.[t],set(e,t,n){let r=Ur();Wr({...r,[e]:{...r[e],[t]:n}})},remove(e,t){let n=Ur(),{[t]:r,...i}=n[e]??{};Wr({...n,[e]:i})}},Kr=e=>{try{return e?new URL(e).origin:void 0}catch{return}},qr=/\{\{\s*secrets\.([\w$-]+)\s*\}\}/g;function Jr(e){return e.proxy?`proxy`:e.pageOrigin&&Kr(e.baseUrl)===e.pageOrigin?`direct`:e.extension?`extension`:`direct`}var Yr=e=>{let t=new Set,n=e=>{if(typeof e==`string`)for(let n of vn(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 Xr(e,t){return(n,r)=>{let i=Yr(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 An(s);let c=e=>typeof e==`string`?xn(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 Zr(e){return(t,n)=>{let r=Jr({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 Qr=`auth:`,$r=e=>`${Qr}${encodeURIComponent(e)}`,ei=`discovery:`,ti=e=>`${ei}${encodeURIComponent(e)}`,ni=/^[A-Za-z0-9_-]+$/,ri=/^[A-Za-z_][\w.-]*$/,ii=e=>typeof e==`string`?/\{\{/.test(e):typeof e==`object`&&!!e&&Object.values(e).some(ii),ai=e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``);function oi(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 xt({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 _t(await r(t),e,await u(e))}async function f(e,t,n){return yt(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||!ii(i)?i:bt(i,await d(t,n),e)}async function m(e,t){let n=_t(e,t,Object.values(e.services??{}).some(e=>ii(e.baseUrl))||Object.values(e.auth??{}).some(e=>ii(e.oauth))?await u(t):{});return{baseUrl(r){try{return yt(e,r,t,n)}catch{return}},oauth(t){let r=e.auth?.[t]?.oauth;try{return r?bt(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:ai(r),source:n??(e in l?`config`:`default`),fallback:n&&i!==void 0?ai(i):void 0,editable:h}}),_=_t(s,n,{...f,...p}),v=[];if(n!==`mock`)for(let e of Object.keys(s.services??{}))try{let t=yt(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:St(s),removable:!!d?.from}}let _=()=>e.mode===`dev`||!!t.environmentStore;async function y(n,i,a){if(!ni.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 x(n,r,i){if(!ri.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 S(e){t.environmentStore?.remove(e)}async function C(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 w(i,a,o,s={}){if(i===`mock`)return Xt({loader:n});let c=await r(o),l=Object.values(c.services??{}).some(e=>ii(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=yt(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 Fn(t,u)},m=e.mode!==`static`,h=await t.extension?.(),g=h?Br(h,x):void 0,_=t.secrets??Gr,v=In({baseUrl:p}),y=m?In({baseUrl:e=>`${a}/${i}/${e}`}):void 0;return Zr({direct:S(Xr(v,{store:_,originFor:b,unresolved:`fail`})),proxy:y?Xr(y,{store:_,originFor:b,unresolved:`keep`}):void 0,extension:g?Xr(g,{store:_,originFor:b,unresolved:`keep`}):void 0,baseOf:x,pageOrigin:f});function b(e){return Kr(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(Qr)||t.service.startsWith(ei))?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 T(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 D=new Map;async function te(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(!Qt(t))return{authorizationUrl:t.authorizationUrl,tokenUrl:t.tokenUrl,scopes:t.scopes??{}};let n=new URL(t.openIdConnectUrl),r=D.get(n.href);r||(r=(async()=>{let t=ti(e.profile),r=await(await w(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 $t(r.body)})(),D.set(n.href,r),r.catch(()=>D.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 te(e),n=new URL(t),r=$r(e.profile),i=await(await w(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 A(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 w(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 ae(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 v([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 ee(a,o.faker,n);return b(s,o.faker,{locale:n,seed:i}),!0}async function se(t,n){e.loadFaker&&await ae(t,n)&&await oe(n.version,n.locale,n.seed);let r=await A(n);return t.kind===`sequence`?ir(t,r):rr(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?E(c,i.mockHook):c}async function le(t,n){return(await e.operations[t]?.(n))?.[t.split(`/`)[1]]?.meta}async function j(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 ue(e,t){let n={};await Promise.all(e.map(async e=>{try{let r=si(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=si(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:y,deleteEnvironment:S,setVariable:x,baseUrlOf:f,oauthOf:p,addressesIn:m,managedSecrets:T,oauthEndpoints:te,oauthExchange:O,run:se,fakerReady:oe,operationRequest:ce,operationMeta:le,examplesOf:ne,knownVars:C,loadExample:re,savedExample:j,loadVariants:ue,loadSequences:de}}function si(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`]),ci=d({}),li=d({}),ui=d(void 0),X=d(void 0),di=d(0),fi=d(!1),pi=d(!1),mi=d({createEnvironment:!0,environmentSettings:!0}),Z=k,hi,gi=async()=>{if(hi&&Date.now()-hi.at<3e4)return hi.bridge;let e=await Rr();return hi={at:Date.now(),bridge:e},e},_i=y,vi=_i===null?void 0:Fr(_i?.scope??`${globalThis.location?.origin}${globalThis.location?.pathname}`,_i?.session?`session`:`local`),Q=oi(k,{extension:gi,environmentStore:vi}),yi=T===`static`;async function bi(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 xi(){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 Si=/(^|\.)specbook\.dev$/i;function Ci(e){return e.published&&e.badge!==!1&&!Si.test(e.host)}var wi=e=>`https://ui.specbook.dev/?ref=${encodeURIComponent(e)}`;function Ti(){let t=globalThis.location?.hostname??``;return Ci({host:t,published:yi,badge:U.value.badge})?e(`p`,{class:`powered-by`,children:e(`a`,{href:wi(t),target:`_blank`,rel:`noopener`,children:`Powered by Specbook`})}):null}var Ei=60,Di=`Default`;function Oi(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 ki({e:t}){return e(`button`,{type:`button`,class:`op-row ${Oi(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(Cr,{})})]}),e(`span`,{class:`op-path`,children:t.path})]})}function Ai(e,t){let n=br.value.trim(),r=t.length<=1,i=r?t[0]?.id??``:yr.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?xr(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?xr(e,n,500):e},[o,i,n]),shownFlows:a(()=>{let e=i&&!r?s.filter(e=>e.tags?.includes(i)):s;return n?xr(e,n,100):e},[s,i,n,r]),shownReqs:l}}function ji({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}=Ai(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()||Di;e.set(n,[...e.get(n)??[],t])}let t=e=>e===Di?0:1;return[...e.entries()].sort(([e],[n])=>t(e)-t(n)||e.localeCompare(n))},[h]),x=m.length>Ei&&!d,S=(e,t)=>l.get(e)??(!x||t.some(Oi)),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:()=>yr.value=``,children:`All`}),i.map(t=>e(`button`,{type:`button`,role:`tab`,"aria-selected":p===t.id,class:`pill ${p===t.id?`on`:``}`,onClick:()=>yr.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:br.value,onInput:e=>br.value=e.target.value,onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),s.current?.querySelector(`.op-row, .flow-row`)?.focus()),e.key===`Escape`&&(br.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 ${Oi(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 ${Oi(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(ki,{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:()=>br.value=``,children:`Clear the filter`})]})]})}function Mi({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(xi,{}),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(Ti,{})]})}var Ni=`\0new-environment`;function Pi(){let t=J.value,n=Y.value.includes(t)?Y.value:[t,...Y.value],r=ci.value[t],i=t===`mock`?`mock`:r===`production`||r!==`sandbox`&&/prod/i.test(t)?`prod`:`live`,a=mi.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===Ni?(e.target.value=J.value,pi.value=!0):J.value=t},children:[n.map(t=>e(`option`,{value:t,title:li.value[t],children:t})),a&&e(`option`,{value:Ni,children:`New environment…`})]})]})}async function Fi(){let e=q.value,[t,n,r]=await Promise.all([Q.environments(e),Q.environmentRisks(e),Q.environmentNotes(e)]);Y.value=t,ci.value=n,li.value=r,di.value+=1}var Ii={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`},Li={default:`default`,config:`config`,file:`file`,browser:`this browser`};async function Ri(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 zi(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 Bi(){let[t,i]=r(),[o,s]=r(),[c,l]=r({}),u=fi.value,d=e=>fi.value=e,[f,m]=r(`environment`),[h,g]=r({}),[_,v]=r({name:``,value:``}),[y,b]=r(),x=J.value,S=()=>yi?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,di.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||!yi&&!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 Ri(`/__specbook/secret`,{name:e,value:t,scope:f,env:f===`shared`?void 0:x}),g(t=>({...t,[e]:``}))}),D=(e,t)=>T(async()=>{await Q.setVariable(x,e,t===``?null:t),di.value+=1}),ee=()=>T(async()=>{Q.deleteEnvironment(x),J.value=`mock`,await Fi()}),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:yi?`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&&D(t.name,e)},onKeyDown:e=>e.key===`Enter`&&e.target.blur()}),e(`span`,{class:`src ${n?`set`:`inherited`}`,children:Li[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:()=>D(t.name,null),children:`×`})]}),zi(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&&D(_.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:ee,children:`Delete environment`})})]}),!yi&&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?Ii[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 Vi=`https://github.com/specbook-dev/specbook`;function Hi(){return globalThis.__SPECBOOK_VIEWER__?.source?e(`a`,{class:`btn gh-star`,href:Vi,target:`_blank`,rel:`noopener`,title:`Specbook's source is on GitHub`,children:[e(Tr,{}),e(`span`,{class:`gh-label`,children:`GitHub`})]}):null}var Ui=`specbook:list-width`,Wi=()=>Math.round(innerWidth*.55);function Gi(){try{let e=Number(localStorage.getItem(Ui));return e>=280?e:void 0}catch{return}}var $=d(Gi());function Ki(e){$.value=e===void 0?void 0:Math.round(Math.max(280,Math.min(Wi(),e)));try{$.value===void 0?localStorage.removeItem(Ui):localStorage.setItem(Ui,String($.value))}catch{}}function qi(){let t=e=>{e.preventDefault(),document.body.classList.add(`resizing`);let t=e=>Ki(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:()=>Ki(void 0),onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),Ki(n()-24)):e.key===`ArrowRight`&&(e.preventDefault(),Ki(n()+24))}})}var Ji=/^[A-Za-z0-9_-]+$/;function Yi(){return pi.value?e(Xi,{}):null}function Xi(){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`&&(pi.value=!1)};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]);let p=()=>pi.value=!1,m=Y.value.includes(t),h=t===``?void 0:Ji.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 Fi(),J.value=t,pi.value=!1,fi.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 Zi({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(()=>xr(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 Qi(){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(wr,{}),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 $i={auto:`Theme: follows your system. Click for light.`,light:`Theme: light. Click for dark.`,dark:`Theme: dark. Click to follow your system.`},ea=({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 ta(){let n=i.value;return e(`button`,{type:`button`,class:`icon theme-toggle`,title:$i[n],"aria-label":$i[n],"data-theme-mode":n,onClick:t,children:e(ea,{mode:n})})}var na=`\0new-environment`,ra=globalThis.__SPECBOOK_VIEWER__?.source?s:void 0;function ia(){r(()=>{let e=Object.keys(Z.manifests);dr(e.length===1?e[0]:void 0)})}var aa=d([]);function oa(){let[e,t]=r(),i=W.value.kind===`op`||W.value.kind===`seq`;return n(()=>{i&&!e&&h(()=>import(`./Host-Cq-4gDuM.js`).then(t),__vite__mapDeps([0,1,2,3,4]),import.meta.url)},[i,e]),i?e:void 0}function sa(){ia();let[t,i]=r({}),[o,s]=r(void 0),[l,u]=r(!1);n(()=>{let e=()=>{W.value=hr(location.hash)};return addEventListener(`hashchange`,e),Q.config(q.value).then(async e=>{aa.value=Object.keys(e.faker?.locales??{}),e.faker?.default&&(ui.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,lr(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}),Q.environmentRisks(q.value).then(e=>{ci.value=e}),Q.environmentNotes(q.value).then(e=>{li.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`?ca(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=oa(),x=()=>K(vr(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??ra)&&e(`img`,{class:`brand-logo`,src:U.value.logo??ra,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(Pi,{})}),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}})]}),aa.value.length>1&&e(`label`,{class:`row muted`,children:[`locale`,e(`select`,{value:ui.value??``,onChange:e=>ui.value=e.target.value||void 0,children:aa.value.map(t=>e(`option`,{value:t,children:t}))})]}),e(Bi,{}),e(`label`,{class:`row`,children:[`Environment`,e(`select`,{value:J.value,onChange:e=>{let t=e.target.value;t===na?(e.target.value=J.value,pi.value=!0):J.value=t},children:[Y.value.map(t=>e(`option`,{value:t,title:li.value[t],children:t})),Q.canCreateEnvironment()&&e(`option`,{value:na,children:`New environment…`})]})]}),e(Hi,{}),e(Qi,{}),e(ta,{})]})]}),e(`div`,{class:`layout`,"data-view":m.kind===`home`?`splash`:`list`,children:[e(`nav`,{class:`list-col`,"aria-label":`Operations and flows`,children:e(ji,{entries:p,services:S})}),e(qi,{}),e(`main`,{class:`stage`,children:(m.kind===`home`||m.kind===`browse`)&&e(Mi,{services:S,counts:{flows:p.filter(e=>e.kind===`seq`).length,requests:p.filter(e=>e.kind===`req`).length}})})]}),e(Zi,{entries:p}),e(Yi,{}),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 ca(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 la=w({});u(),(globalThis.__SPECBOOK_VIEWER__===void 0?m():Promise.resolve(!1)).then(async t=>{t||(await C(),f(e(sa,{}),document.getElementById(`app`)))});export{ln as A,Fn as C,Qt as D,rn as E,Tt as M,wt as N,an as O,K as S,on as T,Kr as _,Z as a,Sr as b,fi as c,Y as d,mi as f,qr as g,q as h,yi as i,cn as j,sn as k,di as l,X as m,Pi as n,bi as o,ui as p,Q as r,J as s,la as t,li as u,Gr as v,B as w,Er as x,kr as y};
|