@specbook/ui 0.1.0 → 0.2.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/THIRD-PARTY-NOTICES.txt +581 -0
- package/dist-viewer/assets/Host-CSrM9wY1.js +37 -0
- package/dist-viewer/assets/index-ez9c20v3.js +1 -0
- package/dist-viewer/assets/main-38QGGpNT.js +14 -0
- package/dist-viewer/assets/mount-CGL2tOpN.js +2 -0
- package/dist-viewer/assets/{panel-Coi9H1nv.css → panel-C-vBZrep.css} +1 -1
- package/dist-viewer/assets/panel-C8Ve3LeS.js +1 -0
- package/dist-viewer/assets/registry-ChKCFBt1.js +2 -0
- package/dist-viewer/assets/{worker-Dw3Ps3hk.js → worker-ClGb0tE1.js} +1 -1
- package/dist-viewer/index.html +4 -4
- package/dist-viewer/specbook.js +1 -1
- package/package.json +5 -4
- package/src/app.tsx +7 -2
- package/src/components/EnvBadge.tsx +4 -2
- package/src/embed/panel.tsx +2 -1
- package/src/engine.ts +143 -1
- package/src/main.tsx +9 -1
- package/src/oauth-callback.ts +87 -0
- package/src/oauth.ts +194 -0
- package/src/panel/CodeSample.tsx +4 -3
- package/src/panel/OAuthSignIn.tsx +163 -0
- package/src/panel/Panel.tsx +8 -4
- package/src/panel/RequestPanel.tsx +2 -0
- package/src/panel/SecretsBar.tsx +35 -2
- package/src/store.ts +2 -0
- package/src/styles/panel.css +44 -2
- package/src/viewer/embed.ts +5 -0
- package/src/viewer/main.tsx +5 -1
- package/src/viewer/protocol.ts +3 -0
- package/src/viewer/registry-data.ts +4 -0
- package/src/viewer/registry.ts +11 -2
- package/src/viewer/worker.ts +12 -7
- package/dist-viewer/assets/Host-DdTTHeXU.js +0 -37
- package/dist-viewer/assets/index-DnYdlDXQ.js +0 -1
- package/dist-viewer/assets/main-uV4JzQPd.js +0 -14
- package/dist-viewer/assets/mount-B-qFOcWp.js +0 -2
- package/dist-viewer/assets/panel-CoQ6iQpX.js +0 -1
- package/dist-viewer/assets/registry-DI74Wtj8.js +0 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{c as e,r as t}from"./registry-ChKCFBt1.js";import{a as n,d as r,f as i,g as a,h as o,m as s,p as c,u as l,v as u}from"./panel-C8Ve3LeS.js";import{i as d}from"./mount-CGL2tOpN.js";import{C as f,D as p,E as m,O as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as ee,o as k,p as A,r as j,s as M,u as N,v as P,w as te,x as F,y as I}from"./main-38QGGpNT.js";var ne=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function L(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:ne(t),enabled:!0})))}function R(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 re(e){return typeof e!=`object`||!e?[]:I(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var ie=/[^[\]]+|\[\]/g;function ae(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?ae(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?ae(o,i,n):o===void 0?n:[...[].concat(o),n],a}function oe(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=ae(t,n.match(ie)??[n],a&&b(a)?a:r));return t}var se=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,ce=e=>new RegExp(se.source).test(e),le=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function ue(e){let t=[],n=0;for(let r of e.matchAll(se))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?le(r[1]):`SESSION_${le(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var de=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${fe(e)}`);return t.length?`?${t.join(`&`)}`:``};function fe(e){return ue(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function z(e){if(b(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var pe=e=>e.name??e.file??`file`,me=e=>`'${e.replace(/'/g,`'\\''`)}'`;function B(e){return ce(e)?`"${ue(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:me(e)}function he(e){let t=e.encoding??`json`,n=[B(`${e.url}${de(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 ${B(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of I(o,e.formArrays))s.push(`--data-urlencode ${B(`${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&&(z(n)?s.push(`-F ${B(`${e}=@${pe(n)}`)}`):s.push(`-F ${B(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${B(`@${z(o)?pe(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=z(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${B(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 ${B(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
|
|
2
|
+
`)}`}var ge=/^[A-Za-z_$][\w$]*$/;function V(e){return ce(e)?`\`${ue(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 H=e=>ge.test(e)?e:V(e);function _e(e,t){if(e==null)return`null`;if(typeof e==`string`)return V(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${_e(e,n)},`).join(`
|
|
3
|
+
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${H(e)}: ${_e(t,n)},`).join(`
|
|
4
|
+
`)}\n${t}}`}function ve(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(${_e(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=I(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${_e(Object.fromEntries(t),` `)})`:`new URLSearchParams(${_e(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(z(n)){l=!0;let t=pe(n);s.push(`form.append(${V(e)}, await openAsBlob(${V(t)}), ${V(t)})`)}else s.push(`form.append(${V(e)}, ${V(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${V(z(a)?pe(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=z(a)&&a.type?a.type:`application/octet-stream`)):(c=V(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${de(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${V(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${H(e)}: ${V(t)},`).join(`
|
|
5
|
+
`)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${V(u)})`:`const res = await fetch(${V(u)}, {\n${d.join(`
|
|
6
|
+
`)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
|
|
7
|
+
`)}function ye(e,t){return e===`curl`?he(t):ve(t)}var be=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],U=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function W(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 xe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
8
|
+
`).split(`
|
|
9
|
+
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${W(U(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${W(U(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>${U(r.join(`
|
|
10
|
+
`))}</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}>${W(U(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>${W(U(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 Se(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 Ce(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function we(e){return e?W(U(e)):``}function G(e,t=300){let n=Ce(e);if(!n)return``;let r=Se(n);return r.length>t?U(`${r.slice(0,t-1).trimEnd()}…`):we(n)}var Te=/^\s*\{\{[^}]+\}\}\s*$/,Ee=e=>typeof e==`string`&&Te.test(e);function De(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Oe=[`title`,`description`,`default`,`examples`,`deprecated`];function K(e,t){let n={...e};for(let e of Oe)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function ke(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=K(r,n)}return n}function q(e,t,n=0){let r=ke(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!De(e));if(e.length===1||e.length>1)return q(K(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(K(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 Oe)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 Ae(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function je(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 Me(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 Ne(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 Pe=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Fe(e,t,n){let r=ke(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!De(e));if(!i?.length)return q(r,n);let a=Pe(t);return q(K(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 Ie(e,t,n,r={},i=``,a=0){if(!t||a>12||Ee(e))return[];let o=Fe(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=Pe(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(...Ie(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ie(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(...Ie(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 Le=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Re(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===`
|
|
11
|
+
`)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]!==`
|
|
12
|
+
`;)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=Ne(r,e,n)}return r}var Be={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`},Ve=e=>Be[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),He=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,Ue=new Set([`path`,`query`,`headers`,`data`]),We=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function Ge(e,t){return[e,...We(t)].join(`.`)}function Ke(e){let t=We(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&Ue.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var qe=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function Je(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?Ke(qe(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 Ye=60;function Xe(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function Ze(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Me(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:Xe(e,t),required:a.required,description:Ae(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(...Ze(s,t,n+1,o))}return i}function Qe({schema:e,defs:t,section:r=`data`,notes:i}){let a=Ze(e,t);return a.length===0?null:n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`Field`}),n(`th`,{children:`Type`}),n(`th`,{children:`Description`})]})}),n(`tbody`,{children:[a.slice(0,Ye).map(e=>n(`tr`,{children:[n(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[n(`code`,{children:e.name.split(`.`).pop()}),e.required&&n(`span`,{class:`req`,title:`required`,children:`*`})]}),n(`td`,{children:n(`span`,{class:`chip`,children:e.type})}),n(`td`,{children:[n(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:G(e.description,220)}}),i?.get(Ge(r,e.name))&&n(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(Ge(r,e.name))}}),e.enum&&n(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>n(`code`,{children:e}))]})]})]})),a.length>Ye&&n(`tr`,{children:n(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-Ye,` more fields in the spec`]})})]})]})}var $e={intro:``,notes:new Map,replace:!1,found:!1};function et(e){let[t,n]=o(),[i,a]=o(!1),c=y.docs.find(t=>t.operation===e);return r(()=>{let e=!0;return n(void 0),a(!c),c?.load().then(t=>e&&n(t)).catch(()=>{}).finally(()=>e&&a(!0)),()=>{e=!1}},[e,c]),s(()=>!c||t===void 0?{...$e,loaded:i}:{...Je(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var tt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],nt=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function rt(e,t,n){return Promise.all([nt(y.operationDocs[e]?.().then(e=>e.default)),nt(y.schemas[e]?.().then(e=>e.default)),nt(y.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>nt(y.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 it({variant:e,html:t}){return t?n(`section`,{class:`saved-note-doc`,children:[n(`h2`,{children:[`Saved request `,n(`code`,{children:e.name})]}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]}):null}function at({service:e,op:t,variants:i=[],onTry:a}){let s=`${e}/${t.id}`,[c,l]=o(),d=i.map(e=>e.file).join(`
|
|
13
|
+
`);r(()=>{let t=!0;return l(void 0),rt(s,e,d?d.split(`
|
|
14
|
+
`):[]).then(e=>t&&l(e)),()=>{t=!1}},[s,e,d]);let f=et(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 n(`article`,{class:`doc`,"data-op":s,children:[n(`div`,{class:`doc-intro`,children:[n(`span`,{class:`method ${t.method}`,children:t.method}),` `,n(`code`,{children:t.path}),n(`span`,{class:`spacer`}),n(`button`,{type:`button`,class:`btn primary`,onClick:()=>a(),children:`Try it`})]}),p&&n(u,{children:[!(f.found&&f.replace)&&m?.description&&n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:xe(m.description)}}),f.intro&&n(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>n(it,{variant:e,html:c?.saved[e.file]},e.file)),tt.map(([e,t])=>v(e)?n(`section`,{children:[n(`h2`,{children:[t,` parameters`]}),n(Qe,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&n(`section`,{children:[n(`h2`,{children:`Request body`}),n(Qe,{schema:y,defs:g,section:`data`,notes:f.notes})]}),t.statuses.length>0&&n(`section`,{children:[n(`h2`,{children:`Responses`}),n(`ul`,{class:`statuses`,children:t.statuses.map(e=>n(`li`,{children:[n(`span`,{class:`state-badge ${He(e)}`,children:e}),` `,Ve(e)]}))})]}),(m?.examples.length??0)>1&&n(`section`,{children:[n(`h2`,{children:`Examples`}),n(`ul`,{class:`examples`,children:m?.examples.map(e=>n(`li`,{children:n(`button`,{type:`button`,class:`link`,onClick:()=>a(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var ot=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function st({title:e,subtitle:t,flush:a,modal:o=!0,onPrev:s,onNext:l,onClose:d,children:p}){let m=c(null);return r(()=>{let e=m.current?.getRootNode()?.activeElement;return o&&m.current?.focus(),()=>e?.focus?.()},[o]),r(()=>{let e=m.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=r+i*.2;(o>r+i*.4||o<r)&&(t.scrollTop+=o-s)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s);c&&r?.box!==c&&(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)}},[]),i(()=>{let e=e=>{if(e.key===`Escape`&&d(),e.key!==`Tab`||!o||!m.current)return;let t=[...m.current.querySelectorAll(ot)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=m.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===m.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[d,o]),n(u,{children:[o&&n(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:d}),n(`section`,{class:`panel ${o?``:`docked`}`,part:`panel`,"aria-label":e,"aria-modal":o?!0:void 0,role:o?`dialog`:`complementary`,tabIndex:-1,ref:m,children:[n(`header`,{class:`panel-head`,part:`header`,children:[n(`div`,{class:`panel-title`,children:[n(`h2`,{children:e}),t&&n(`div`,{class:`muted small`,children:t})]}),n(`span`,{class:`spacer`}),o&&f.value.length>1&&n(`label`,{class:`row`,children:[n(`span`,{class:`muted`,children:`Environment`}),n(`select`,{value:F.value,onChange:e=>F.value=e.target.value,children:f.value.map(e=>n(`option`,{value:e,title:g.value[e],children:e}))})]}),(s||l)&&n(`span`,{class:`stepper`,children:[n(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!s,onClick:s,children:`↑`}),n(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!l,onClick:l,children:`↓`})]}),n(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:d,children:`×`})]}),n(`div`,{class:`panel-body ${a?`flush`:``}`,children:p})]})]})}function ct(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:Le(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Me(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:Ae(o),parent:c?Ae(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function lt(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function ut(e,t,n,r){let i=e&&t?.get(Ge(n,r));return e&&i?{...e,note:i}:e}var dt={},ft=Symbol(),pt=Symbol(),mt=e=>typeof e==`string`?ht[e]:e,ht={plain:dt,plaintext:dt,text:dt,txt:dt},gt=(e,t)=>(t[pt]||_t)(e,t),_t=(e,t)=>{for(var n=[e],r,i=[],a=0;r=mt(t[ft]);)delete t[ft],Object.assign(t,r);for(wt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},vt=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),yt=`</span>`,bt=``,xt=``,St=e=>{for(var t=``,n,r=0;n=e[r++];)t+=Ct(n);return t},Ct=e=>{if(e instanceof Tt){var{type:t,alias:n,content:r}=e,i=bt,a=xt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;xt+=yt,bt+=o;var s=Ct(r);return bt=i,xt=a,o+s+yt}return typeof e==`string`?(e=vt(e,/</g,`<`),xt&&e.includes(`
|
|
15
|
+
`)?e.replace(/\n/g,xt+`
|
|
16
|
+
`+bt):e):St(e)},wt=(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=mt(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 Tt)){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 Tt)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 Tt(a,d?gt(S,d):S,S,m),O=h,ee=0,k;O=O[1],ee++<v;);T&&(!O||O[0]instanceof Tt?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&&(wt(e,t,h,g,k=[a,o,E]),E=k[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Tt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Et=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Nt(),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=gt(o=_.value,ht[r]||{}),O(`tokenize`,u,r,o);let e=St(u).split(`
|
|
17
|
+
`),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]+`
|
|
18
|
+
`;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),ee(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(k,v),e&&y.add(t)):(t(k,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(k,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,k)},ee=e=>{if(e||l){let e=T(),t=h[s=jt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},k={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`,()=>{Pt=null,c=!1,w()}),Y(_,`focus`,()=>{Pt=ee,c=!0,w()}),Y(_,`selectionchange`,e=>{ee(!e.isTrusted),X(e)}),At(e)?.append(p),t&&x(t),k},Dt=`u`>typeof window?document:null,Ot=Dt?.createElement(`div`),kt=(e,t)=>(Ot&&(Ot.innerHTML=e,t=Ot.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),At=e=>typeof e==`string`?Dt.querySelector(e):e,jt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
19
|
+
`,t)+1)&&t<=n;r++);return r},Mt={},Nt=kt(`<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>`),X=e=>{e.preventDefault(),e.stopImmediatePropagation()},Pt;Dt&&Y(Dt,`selectionchange`,()=>Pt?.());var Ft=(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) + ${Zt&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},It=(e,t)=>t?e.lastIndexOf(`
|
|
20
|
+
`,t-1)+1:0,Lt=(e,t)=>(t=e.indexOf(`
|
|
21
|
+
`,t))+1?t:e.length,Rt=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),zt=(e,t,n,r)=>Rt(e.textarea,t,n,r),Bt=(e,t)=>parseFloat(getComputedStyle(e)[t]),Vt=(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}},Ht=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var Ut,Wt=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),Gt=(e,t)=>e.slice(It(e,t),t),Kt=(e,t,n=t)=>[e.slice(t=It(e,t),n=Lt(e,n)).split(`
|
|
22
|
+
`),t,n],qt=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[jt(a,0,i)],s=Dt.createTreeWalker(o,5),c=s.lastChild(),l=Lt(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}},Jt=(e,t)=>qt(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;Ut=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=Zt&&!s[r??Ut[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,Ut[2]),l()})),Qt||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),Zt||Qt?(c&&(o.selectionEnd--,t=t.slice(0,-1)),Qt&&(t+=`
|
|
23
|
+
`),Dt.execCommand(t?`insertHTML`:`delete`,!1,vt(t,/</g,`<`)),c&&o.selectionStart++):Dt.execCommand(t?`insertText`:`delete`,!1,t),Ut=0},Yt=(e,t,n=t,r)=>{let i=e.textarea,a=Rt(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},Xt=Dt?navigator.userAgent:``,Q=Dt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,Zt=/Chrome\//.test(Xt),Qt=!Zt&&/AppleWebKit\//.test(Xt),$t=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,en=(e,t)=>e.lines[0].append(t),tn=kt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),nn=kt(`<span> `),rn=kt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),an=(e,t,n=!0)=>{let r=rn(),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||en(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 on=(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(``,nn()),Ht(r[o],n.slice(a,a=t[o++])),Ht(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();Ht(r[s],n.slice(a))},sn=0,cn=kt(`<div class="pce-ac-wrapper pce-ac-top"><div class=pce-ac-tooltip><ul role=listbox></ul></div><div class=pce-ac-docs tabindex=-1><button class=pce-ac-close tabindex=-1 title=Close></button><button class=pce-ac-toggle tabindex=-1 title="Read More"></button><div class=pce-ac-content>`),ln=kt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),un={},dn=(e,t)=>{e.forEach(e=>un[e]=t)},fn=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=cn(),O=tn(),[ee,k]=an(n,D),[A,j]=D.children,[M,N,P]=j.children,te=A.firstChild,F=te.id=`pce-ac-`+sn++,I=te.children,ne=[],L=()=>{i&&=(k(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&j.remove(),!1)},R=()=>{f=Bt(I[0],`height`)},re=e=>{let t=o[e+d],[n,r,i]=I[e].children,a=t[4],s=a.icon||`variable`;on(r,t[1],a.label),Ht(i.firstChild.firstChild,a.detail||``),ne[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${ne[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),I[e].setAttribute(`aria-posinset`,e+d)},ie=()=>{R();let e=A.scrollTop,t=f*c,n=f*(c+1)-A.clientHeight;A.scrollTop=e>t?t:e<n?n:e,se(),ae()},ae=()=>{let e=l;l=I[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),N.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(N),b=!b,he()):j.remove()):e&&T.removeAttribute(`aria-activedescendant`)},oe=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,ie()},se=()=>{let e=Math.min(Math.floor(A.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)re(e++);te.style.paddingTop=d*f+`px`},ce=e=>le(o[e][4],o[e][2],o[e][3]),le=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
|
|
24
|
+
`+Gt(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||en(n,O),p=o,m=0,g=n.value.length,z(),h=E(),ue()):n.extensions.cursor?.scrollIntoView()},ue=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},de=e=>{m+=e,Yt(n,p[m],p[m+1]),ue()},fe=()=>{O.remove(),p=null},z=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),on(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=Bt(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()}`},B=()=>{let e=o[c][4];e.renderDocs&&(j.parentNode||D.append(j),y!=e&&(y=e,P.textContent=``,P.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,F+`d`))},he=()=>{b?j.remove():B(),b=!b},ge=t.startQuery=t=>{let[a,l,p]=E(),m=Jt(n,u=p<`f`?a:l),h=un[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=Gt(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;)I[e].setAttribute(`aria-setsize`,s),re(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);j.style.maxWidth=A.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}te.style.paddingTop=``,te.style.height=f?f*s+`px`:1.4*s+`em`,A.scrollTop=0,ae(),i=!0,ee(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,F),T.setAttribute(`aria-haspopup`,`listbox`)}else L()}else L()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)te.append(ln()),I[e].id=F+`-`+e++;Y(A,`scroll`,()=>{R(),se()||ae()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)fe();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));z()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&fe()}a?(a=!1,ge()):(S!=e||C!=t)&&L(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!Ut&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&ce(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!Ut||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&L()}),Y(T,`keydown`,e=>{let t=e.key,n=$t(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?he():ge(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(oe(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(ce(c),L(),X(e)):t==`Escape`?(L(),X(e)):t.slice(0,4)==`Page`&&(R(),r=A.scrollTop,a=A.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),ie(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(de(-2),X(e)):(de(2),X(e)):!n&&t==`Escape`&&(fe(),X(e)))},!0),Y(te,`mousedown`,e=>{e.target!=N&&(ce([].indexOf.call(I,e.target.closest(`li`))+d),L()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&L()}),Y(w,`scroll`,()=>{i&&me()}),Y(M,`click`,he),Y(M,`mousedown`,X),Y(N,`click`,he),j.id=F+`d`,N.remove(),j.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},pn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return mn(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]},mn=(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]]},hn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Tn[e]||0;return t+`+`+r},gn=e=>{if(!Cn[48]){for(let e=48;e<91;e++)Cn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)Cn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=$t(e),r=Cn[e.keyCode],i=wn[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},_n=new WeakMap,vn=(e,t,n)=>{let r=new Set,i;try{for(let a of gn(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)))}},yn=e=>{let t=_n.get(e);return t||(_n.set(e,t={}),zt(e,`keydown`,n=>{vn(n,t,e)})),t},bn=(e,t,n,r)=>xn(yn(e),t,n,r),xn=(e,t,n,r=2)=>{let i=(e[t==`any`?t:hn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},Sn=Q?4:2,Cn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},wn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Tn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},En=!1,Dn=e=>e.search(/\S|$/),On=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),kn=(e,t,n,r,i,a,o)=>{let s=n.join(`
|
|
25
|
+
`);if(s==t.join(`
|
|
26
|
+
`))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+Dn((f<0?n:t)[0]),m=i-u.length+Dn(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,_))},An=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=Kt(e.value,n,r),[s,c]=On(e);return kn(e,i,i.map(t?e=>e.slice(Dn(e)?c-Dn(e)%c:0):e=>e&&s.repeat(c-Dn(e)%c)+e),a,o,n,r),$(e)},jn=(e,t)=>{let[n,r]=On(e);return Z(e,n.repeat(r-(t-It(e.value,t))%r)),$(e)},Mn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=Lt(r,n[1]));let[i,a]=On(e),[o,s]=n,c=Mt[Jt(e,o)]?.autoIndent,l=Math.floor(Dn(Gt(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
|
|
27
|
+
`+i.repeat(l+u)+(d?`
|
|
28
|
+
`+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Nn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?It(i,n)-1:n,o=t?r:i.indexOf(`
|
|
29
|
+
`,r)+1;if(a>-1&&o>0){let[s,c,l]=Kt(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
|
|
30
|
+
`),c,l,n+d,r+d)}return $(e)},Pn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=Kt(i,n,r),c=a.join(`
|
|
31
|
+
`),l=t?0:c.length+1;return Z(e,c+`
|
|
32
|
+
`+c,o,s,n+l,r+l),$(e)},Fn=(e,t)=>(e.container.scrollBy(0,Bt(e.container,`lineHeight`)*(t?-1:1)),!0),In=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=Kt(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=Lt(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},Ln=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:It(i,n),o=Mt[Jt(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=Kt(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(Wt(t)+` ?$`);s+1&&RegExp(`^ ?`+Wt(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=Wt(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));kn(e,l,l.map(!c&&l.every(e=>a.test(e))?e=>e.replace(o,``):e=>c||/\S/.test(e)?e.replace(/(?!\s)/,s+` `):e),u,d,n,r)}else if(c){let[t,i]=c,a=l[0],o=Dn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(Wt(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${Wt(i)}$`),``):l[f]+` `+i;let m=l.join(`
|
|
33
|
+
`),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},Rn={Tab(e){if(!En){let[t,n]=e.getSelection();return t==n?jn(e,t):An(e)}},"8+Tab":e=>!En&&An(e,!0),"1+ArrowDown":e=>Nn(e),"1+ArrowUp":e=>Nn(e,!0),"9+ArrowDown":e=>Pn(e),"9+ArrowUp":e=>Pn(e,!0),Enter:e=>Mn(e),"8+Enter":e=>Mn(e),"Mod+Enter":e=>Mn(e,!0),"Mod+]":e=>An(e),"Mod+[":e=>An(e,!0),"8+Mod+k":In,"Mod+/":e=>Ln(e),"9+a":e=>Ln(e,!0),[Q?`10+m`:`2+m`]:()=>(En=!En,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Fn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Fn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var zn=Q?5:1;zn+``,zn+``,zn+``,zn+``;var Bn=(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&&!Yt(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=Gt(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=Mt[Jt(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},bn(r,`Backspace`,u),bn(r,`8+Backspace`,u);for(let t in e)bn(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>zt(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=Kt(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
|
|
34
|
+
`,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},Vn=(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}),zt(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`)&&!Ut&&(n!=` `||o==n))||(d[t][2]=Ut||u()),i=!0,o=n,s=f,a=l}),zt(e,`input`,()=>f(t+!c)),zt(e,`keydown`,e=>{if(!g.readOnly){let n=$t(e),r=e.keyCode,i=n==Sn&&r==90,a=n==Sn+8&&r==90||!Q&&n==Sn&&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},Hn=kt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),Un=()=>{let e,t=Hn(),[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];Ht(n,Gt(i,s)),Ht(a,i.slice(s,Lt(i,s))+`
|
|
35
|
+
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Ft(e,i)},c=t=>{e=t,t.extensions.cursor=c,zt(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),Vt(e,i)),c.scrollIntoView=s,c.element=i,c};kt(`<div class=pce-cursor>`);var Wn=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,Gn=/\b(?:false|true)\b/,Kn=/\[]|\(\)|{}/,qn=/[([{][^)\]}]*$/,Jn=([e,t],n)=>Kn.test(n[e-1]+n[t]),Yn={line:`//`,block:[`/*`,`*/`]},Xn=(e=Yn,t=qn)=>({comments:e,autoIndent:[([e],n)=>t.test(Gt(n,e)),Jn]});Mt.json=Mt.json5=Mt.jsonp=Xn(),Mt.graphql=Xn({line:`#`}),ht.webmanifest=ht.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:Wn,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:Gn,null:{pattern:/\bnull\b/,alias:`keyword`}},ht.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:Gn,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+/,[pt](e,t){for(var n=_t(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 Zn=new WeakMap;dn([`json`],{sources:[(e,t)=>{let n=Zn.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 Qn({value:e,language:t=`json`,readOnly:i,label:a,onChange:o,onLine:s,complete:l}){let u=c(null),d=c(void 0),f=c({onChange:o,onLine:s});f.current={onChange:o,onLine:s};let p=c(l);return p.current=l,r(()=>{let n=Et(u.current,{value:e,language:t,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},Bn(Rn),Vn(),...l?[Un(),fn({filter:pn})]:[]);return l&&Zn.set(n,(e,t)=>p.current?.(e,t)),n.textarea.setAttribute(`aria-label`,a),d.current=n,()=>n.remove()},[]),r(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),r(()=>{d.current?.setOptions({readOnly:i,language:t})},[i,t]),n(`div`,{class:`body-editor`,part:`editor`,ref:u})}var $n=/[\w$.+-]/;function er(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]!==`
|
|
36
|
+
`;)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&&$n.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&$n.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 tr=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),nr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function rr(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 ir(e,t,n,r,i){if(!e)return;let a=er(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=Me(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=rr(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${nr(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:tr(je(Ae(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 ar=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function or(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:L(e.path),query:L(e.query),headers:L(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?re(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var sr=e=>Object.keys(e).length?e:void 0;function cr(e,t){let n;if(ar(e,t))n=oe(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:sr(R(e.path)),query:sr(R(e.query)),headers:sr(R(e.headers)),data:n}}var lr=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function ur(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:t}){return e?n(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[n(`div`,{class:`field-doc-head`,children:[n(`code`,{children:e.path}),n(`span`,{class:`chip`,children:e.type}),e.required&&n(`span`,{class:`chip req`,children:`required`}),e.deprecated&&n(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?n(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:xe(e.description)}}):e.note?null:n(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&n(u,{children:[` It is part of: `,e.parent]})]}),e.note&&n(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&n(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>n(`code`,{children:e})),e.enum.length>12&&n(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):n(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:t??`Put the cursor on a field to see what the API says about it.`})}function fr(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 pr(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 mr({value:e,options:t,onChange:i,label:a,placeholder:s,onKeyDown:l,cell:u}){let[d,f]=o(!1),[p,m]=o(-1),[h,g]=o(),_=c(null),v=()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-8,n=t<160&&e.top>t;g({left:`${e.left}px`,width:`${Math.max(e.width,160)}px`,maxHeight:`${Math.min(240,(n?e.top:t)-4)}px`,...n?{bottom:`${innerHeight-e.top+2}px`}:{top:`${e.bottom+2}px`}})};r(()=>{if(!d)return;v();let e=e=>{e.target instanceof Node&&_.current?.contains(e.target)||f(!1)};return addEventListener(`scroll`,e,!0),addEventListener(`resize`,e),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,e)}},[d]),r(()=>{if(!d)return;let e=e=>{e.composedPath().includes(_.current)||f(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[d]);let y=e=>{i(e),f(!1),m(-1)};return n(`div`,{class:`combo`,ref:_,children:[n(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:s,"aria-label":a,"aria-expanded":d,role:`combobox`,autocomplete:`off`,onFocus:()=>f(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{d&&e.key===`ArrowDown`?(e.preventDefault(),m((p+1)%t.length)):d&&e.key===`ArrowUp`?(e.preventDefault(),m((p-1+t.length)%t.length)):d&&e.key===`Enter`&&p>=0?(e.preventDefault(),y(t[p])):e.key===`Escape`&&d?(e.stopPropagation(),f(!1)):((e.key===`Enter`||e.key===`Tab`)&&f(!1),l?.(e))}}),n(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${a} options`,onClick:()=>f(!d),children:`▾`}),d&&n(`div`,{class:`combo-list`,role:`listbox`,style:h,children:t.map((t,r)=>n(`button`,{type:`button`,role:`option`,"aria-selected":t===e,class:`${t===e?`on`:``} ${r===p?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>y(t),children:t}))})]})}var hr=`specbook:grid-cols`,gr={key:26,val:34},_r=10,vr=l(yr());function yr(){try{let e=JSON.parse(localStorage.getItem(hr)??`null`);if(e&&e.key>=_r&&e.val>=_r&&e.key+e.val<=90)return e}catch{}return gr}function br(e){let t=e??gr,n=Math.min(80,Math.max(_r,t.key)),r=Math.min(100-n-_r,Math.max(_r,t.val));vr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?localStorage.setItem(hr,JSON.stringify(vr.value)):localStorage.removeItem(hr)}catch{}}function xr(){return n(`colgroup`,{children:[n(`col`,{style:{width:`36px`}}),n(`col`,{style:{width:`${vr.value.key}%`}}),n(`col`,{style:{width:`${vr.value.val}%`}}),n(`col`,{}),n(`col`,{style:{width:`60px`}})]})}function Sr({which:e,table:t}){let r=t=>{let n=vr.value;br(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return n(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(vr.value[e]),"aria-valuemin":_r,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let n=t()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/n*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>br(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var Cr=1,wr=2;function Tr(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 Er=({d:e})=>n(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:n(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Dr({title:e,rows:t,onChange:i,documented:a=[],docFor:o,fixed:s,bad:l,placeholder:d,bare:f}){let p=c(null),m=c(null),h=c(void 0),g=new Set(t.map(e=>e.key)),_=a.filter(e=>!g.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),v=[...t,..._],y=e=>a.find(t=>t.name===e),b=e=>y(e)?.doc??o?.(e);r(()=>{if(!h.current)return;let e=p.current?.querySelector(`[data-cell="${h.current}"]`);h.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let x=e=>!e.virtual||e.enabled||e.value!==``||e.file,S=e=>i(e.filter(x).map(({virtual:e,...t})=>t)),C=(e,t)=>S(v.map((n,r)=>r===e?{...n,...t}:n)),w=(e,t)=>p.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),T=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),w(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),w(e-1,t))},E=e=>{let t=v[e],n=b(t.key)?.enum??[],r=new Set(v.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=[...v];o.splice(e+1,0,a),h.current=`${o.filter(x).indexOf(a)}:${wr}`,S(o)},D=(e,n)=>{let r=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(r.trim()))return;e.preventDefault();let a=Tr(r).map(e=>({...e,enabled:!0})),o=[...t];o.splice(n,+(n<t.length&&!t[n]?.key),...a),i(o)},O=v.length;return n(`section`,{class:`grid`,"aria-label":e,ref:p,children:[!f&&n(`h3`,{children:e}),n(`table`,{ref:m,children:[n(xr,{}),n(`thead`,{children:n(`tr`,{children:[n(`th`,{class:`g-check`}),n(`th`,{class:`g-key`,children:[`Key`,n(Sr,{which:`key`,table:()=>m.current})]}),n(`th`,{class:`g-val`,children:[`Value`,n(Sr,{which:`val`,table:()=>m.current})]}),n(`th`,{class:`g-doc`,children:`Description`}),n(`th`,{class:`g-act`})]})}),n(`tbody`,{children:[v.map((e,t)=>{let r=b(e.key),i=y(e.key)?.file,a=s||e.virtual||y(e.key);return n(`tr`,{class:`${e.enabled?``:`off`} ${l===e.key?`bad`:``}`,children:[n(`td`,{class:`g-check`,children:n(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:s,onChange:e=>C(t,{enabled:e.target.checked})})}),n(`td`,{class:`g-key`,children:a?n(`span`,{class:`key`,children:[n(`code`,{children:e.key}),r?.required&&n(`span`,{class:`req`,title:`required`,children:`*`})]}):n(`input`,{class:`cell`,"data-cell":`${t}:${Cr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>C(t,{key:e.target.value}),onKeyDown:T(t,Cr),onPaste:e=>D(e,t)})}),n(`td`,{class:`g-val`,children:i?n(`label`,{class:`file-cell`,children:[n(`input`,{type:`file`,"aria-label":`File for ${e.key}`,onChange:e=>{let n=e.target.files?.[0];n&&C(t,{file:n,value:n.name,enabled:!0})}}),n(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?n(mr,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${t}:${wr}`,placeholder:`value`,onKeyDown:T(t,wr),onChange:e=>C(t,{value:e,enabled:!0})}):n(`input`,{class:`cell`,"data-cell":`${t}:${wr}`,value:e.value,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>C(t,{value:e.target.value,enabled:!0}),onKeyDown:T(t,wr)})}),n(`td`,{class:`g-doc`,title:Se(r?.description),children:r&&n(u,{children:[n(`span`,{class:`chip`,children:r.type}),` `,n(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:G(r.description)}})]})}),n(`td`,{class:`g-act`,children:[!s&&e.key&&n(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>E(t),children:n(Er,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!s&&!e.virtual&&n(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>S(v.filter((e,n)=>n!==t)),children:n(Er,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},t)}),!s&&n(`tr`,{class:`ghost`,children:[n(`td`,{class:`g-check`}),n(`td`,{class:`g-key`,children:n(`input`,{class:`cell`,"data-cell":`${O}:${Cr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{h.current=`${t.length}:${Cr}`,i([...t,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:T(O,Cr),onPaste:e=>D(e,t.length)})}),n(`td`,{class:`g-val`}),n(`td`,{class:`g-doc`}),n(`td`,{class:`g-act`})]},O)]})]})]})}function Or({draft:e,onChange:t}){let[i,a]=o(()=>fr(e.body)),s=c(e.body);r(()=>{if(e.body===s.current)return;let t=fr(e.body);t&&a(t),s.current=e.body},[e.body]);let l=n=>{let r={...i,...n};a(r),s.current=pr(r),t({...e,body:s.current})};return n(`section`,{class:`body`,"aria-label":`Body`,children:[n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Query`}),n(`span`,{class:`chip`,children:`graphql`})]}),n(Qn,{label:`GraphQL query`,language:`graphql`,value:i.query,onChange:e=>l({query:e})}),n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Variables`}),n(`span`,{class:`chip`,children:`json`})]}),n(Qn,{label:`GraphQL variables`,language:`json`,value:i.variables,onChange:e=>l({variables:e})})]})}var kr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function Ar({encoding:e,draft:t,onChange:r,schema:i,defs:a,files:c=[],notes:l}){let[d,f]=o(0),p=s(()=>Re(t.body),[t.body]),m=e===`json`||e===`form`,h=s(()=>{let e=p[d];return e&&m?ut(ct(i,a,e,[`data`]),l,`data`,Le(e)):void 0},[p,d,i,a,m,l]),g=s(()=>m&&i?(e,t)=>ir(i,a,[`data`],e,t):void 0,[i,a,m]),_=e=>{if(e!==(t.formView??`grid`)){if(e===`grid`)try{r({...t,formView:`grid`,fields:re(JSON.parse(t.body||`{}`))})}catch{r({...t,formView:`grid`})}else r({...t,formView:`json`,body:JSON.stringify(oe(t.fields.filter(e=>!e.file)),null,2)})}},v=e===`form`?n(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>n(`button`,{type:`button`,class:`seg-btn ${(t.formView??`grid`)===e?`on`:``}`,"aria-pressed":(t.formView??`grid`)===e,onClick:()=>_(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(ar(t,e)||e===`binary`){let o=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),s=e=>r({...t,fields:e}),d=(t.fields.length?t.fields.map(e=>e.key):[]).filter(o);return n(u,{children:[v&&n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Body`}),n(`span`,{class:`chip`,children:e}),n(`span`,{class:`spacer`}),v]}),n(Dr,{title:e===`binary`?`File`:`Body`,bare:!!v,rows:t.fields,onChange:s,documented:[...new Set(d)].map(e=>({name:e,file:!0})),docFor:e=>ut(ct(i,a,lt(e),[`data`]),l,`data`,e)})]})}return e===`graphql`&&fr(t.body)?n(Or,{draft:t,onChange:r}):n(`section`,{class:`body`,"aria-label":`Body`,children:[n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Body`}),n(`span`,{class:`chip`,children:e}),n(`span`,{class:`spacer`}),e!==`text`&&n(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...t,body:JSON.stringify(JSON.parse(t.body),null,2)})}catch{}},children:`Format`}),v]}),n(Qn,{label:`Request body`,language:kr(e===`form`?`json`:e),value:t.body,onChange:e=>r({...t,body:e}),onLine:f,complete:g}),m&&n(dr,{doc:h})]})}var jr=`specbook:code-lang`;function Mr(){try{let e=localStorage.getItem(jr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Nr({service:e,profile:t,secured:i,make:a,sent:c}){let[l,u]=o(Mr),d=l===`sent`?`curl`:l,[f,p]=o(!1),[h,g]=o(),[_,v]=o();r(()=>{let n=!0;return j.config(m.value).then(r=>{if(!n)return;let i=r.services?.[e],a=i?.baseUrl??{};g(a[F.value]??a.live??Object.values(a)[0]);let o=t===`service`?i?.auth:t;v(o?r.auth?.[o]?.apply:void 0)}),()=>{n=!1}},[e,t,F.value]);let y=s(()=>{try{return{text:ye(d,a(h??`https://api.example.com`,_))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[a,d,h,_]),b=e=>{if(u(e),e!==`sent`)try{localStorage.setItem(jr,e)}catch{}};return n(`div`,{class:`code-sample`,children:[n(`div`,{class:`code-head`,children:[n(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[be.map(e=>n(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>b(e.id),children:e.label})),c!==void 0&&n(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>b(`sent`),children:`Sent`})]}),n(`span`,{class:`spacer`}),l!==`sent`&&n(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(y.text)try{await navigator.clipboard.writeText(y.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!y.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:y.error?n(`p`,{class:`muted`,children:y.error}):n(`pre`,{class:`code-block`,part:`code`,children:n(`code`,{children:y.text})}),l!==`sent`&&i&&n(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Pr({service:t,method:r,path:i,draft:o,encoding:s,vars:c,secured:l,sent:u}){let d=a((t,n)=>{let a=cr(o,s),l={path:a.path??{},query:a.query??{},headers:a.headers??{},data:a.data},u=l;try{u=e(l,c)}catch{}let d=i.replace(/\{([^}]+)\}/g,(e,t)=>{let n=u.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:r,url:`${t.replace(/\/+$/,``)}${d}`,query:{...n?.query??{},...u.query},headers:{...n?.headers??{},...u.headers},body:u.data,encoding:s}},[o,s,c,r,i]);return n(Nr,{service:t,profile:l?`service`:void 0,secured:l,make:d,sent:u})}function Fr({request:e,encoding:t,sent:r}){let i=a((n,r)=>({method:e.method,url:`${n.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:t}),[e,t]);return n(Nr,{service:e.service,profile:e.profile,secured:!!e.profile,make:i,sent:r})}var Ir=e=>typeof e==`string`?e:JSON.stringify(e,null,2);function Lr(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 Rr({body:e,docs:t}){let[r,i]=o(0),a=Ir(e),c=!!t?.schema&&typeof e==`object`&&!!e,l=s(()=>c?Re(a):[],[c,a]),d=s(()=>{let e=l[r];return e&&t?ut(ct(t.schema,t.defs,e,[`data`]),t.notes,`data`,Le(e)):void 0},[l,r,t]);return n(u,{children:[n(Qn,{label:`Body as sent`,value:a,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&n(dr,{doc:d})]})}function zr({request:e,hideBar:t,docs:r}){if(!e)return n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`Nothing sent yet`}),n(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return n(`div`,{class:`sent-view`,children:[!t&&n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${e.method}`,children:e.method}),n(`div`,{class:`rq-url`,title:e.url,children:n(`code`,{children:[e.url,Lr(e.query)]})})]}),n(`h3`,{children:`Headers`}),i.length===0?n(`p`,{class:`muted`,children:`No headers.`}):n(`table`,{class:`headers`,children:n(`tbody`,{children:i.map(([e,t])=>n(`tr`,{children:[n(`th`,{children:e}),n(`td`,{children:t})]}))})}),e.body!==void 0&&n(u,{children:[n(`h3`,{children:`Body`}),n(Rr,{body:e.body,docs:r})]})]})}var Br=e=>JSON.stringify(e,null,2),Vr=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function Hr({step:e,error:t,schemas:r,defs:i,hideRequest:a}){let[c,l]=o(`body`),[d,f]=o(0),m=e?.response,h=m?r?.[String(m.status)]??r?.default:void 0,g=s(()=>m&&h?Ie(m.body,h,i,{reportExtra:!0}):[],[m,h,i]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:Br(m.body),v=s(()=>Re(_),[_]),y=s(()=>{let e=v[d];return e?ct(h,i,e):void 0},[v,d,h,i]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length,S=Object.entries(m?.headers??{}),C=!m&&!t&&!e?.error;return n(`section`,{class:`response`,"aria-label":`Response`,children:[n(`div`,{class:`rs-head`,children:[m&&n(u,{children:[n(`span`,{class:`state-badge ${He(m.status)}`,children:[m.status,` `,Ve(m.status)]}),n(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),n(`span`,{class:`rs-stat`,children:Vr(new Blob([_]).size)})]}),n(`span`,{class:`spacer`}),m&&n(`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&&!a&&n(`p`,{class:`sent`,children:[n(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,n(`code`,{children:[e.request.url,Lr(e.request.query)]})]}),t&&n(`p`,{class:`error-text`,children:t}),e?.error&&n(`p`,{class:`error-text`,children:e.error}),C&&n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`No response yet`}),n(`span`,{class:`muted`,children:[`Press`,` `,n(`kbd`,{class:`icon-key`,children:n(p,{size:12})}),` `,`or `,n(`kbd`,{children:`⌘`}),` `,n(`kbd`,{children:`↵`})]})]}),m&&n(u,{children:[n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,t,r])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":c===e,class:`rq-tab ${c===e?`on`:``}`,onClick:()=>l(e),children:[t,r>0&&n(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,children:r})]}))}),n(`div`,{class:`rs-pane`,children:[n(`div`,{hidden:c!==`body`,children:[_===``?n(`p`,{class:`muted`,children:`No content.`}):n(Qn,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:f}),_!==``&&n(dr,{doc:y}),g.length>0&&n(`details`,{class:`issues`,children:[n(`summary`,{children:`What differs`}),n(`ul`,{children:g.map(e=>n(`li`,{children:[n(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),n(`div`,{hidden:c!==`headers`,children:n(`table`,{class:`headers`,children:n(`tbody`,{children:[S.map(([e,t])=>n(`tr`,{children:[n(`th`,{children:e}),n(`td`,{children:t})]})),S.length===0&&n(`tr`,{children:n(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),n(`div`,{hidden:c!==`checks`,children:b.length===0?n(`p`,{class:`muted`,children:`This request has no checks.`}):n(`ul`,{class:`checks`,children:b.map(e=>n(`li`,{class:e.pass?`ok`:`bad`,children:[e.pass?`✓`:`✗`,` `,e.label]}))})})]})]})]})}var Ur=()=>{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 Wr(e){let t=window.open(``,d,`popup,width=520,height=720`);if(!t)throw new S(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(d),r;try{let{verifier:i,challenge:a}=await A(),o=T(),s=Ur(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new S(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new S(`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=C({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=w({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(P({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return v(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var Gr=`specbook.oauth.clients.v1`,Kr=`specbook.oauth.expiry.v1`,qr=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},Jr=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},Yr=e=>{try{return qr(localStorage,Gr)[e]}catch{return}},Xr=(e,t)=>{try{Jr(localStorage,Gr,{...qr(localStorage,Gr),[e]:t})}catch{}},Zr=(e,t)=>`${e}\n${t}`,Qr=(e,t,n)=>{try{let r=qr(sessionStorage,Kr);n===void 0?delete r[Zr(e,t)]:r[Zr(e,t)]=Date.now()+n*1e3,Jr(sessionStorage,Kr,r)}catch{}},$r=(e,t)=>{try{return qr(sessionStorage,Kr)[Zr(e,t)]}catch{return}};function ei({service:e,profile:t,origin:i,secret:a,oauth:s,onSignedIn:l}){let u=O(s)?s.openIdConnectUrl:s.authorizationUrl,[d,f]=o(()=>s.clientId??Yr(u)??``),[p,h]=o(void 0),[g,_]=o([]),[v,y]=o({kind:`idle`}),b=c(void 0),x=v.kind===`busy`,[S,C]=o(0);r(()=>{let e=!0;return h(void 0),y(e=>e.kind===`busy`?e:{kind:`idle`}),j.oauthEndpoints({env:F.value,version:m.value,profile:t}).then(t=>{e&&(h(t),_(O(s)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&y({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[t,F.value,m.value,S]);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 n=new AbortController;b.current=n,y({kind:`busy`}),Xr(u,e),Wr({authorizationUrl:p.authorizationUrl,clientId:e,scopes:g,signal:n.signal,exchange:(e,n)=>j.oauthExchange({env:F.value,version:m.value,profile:t,fields:e,signal:n})}).then(e=>{N.set(i,a,e.accessToken),Qr(i,a,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 n(`span`,{class:`needs-var oauth-signin`,children:[n(`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?n(`button`,{type:`button`,class:`link`,onClick:()=>b.current?.abort(),children:`Cancel`}):n(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&n(`details`,{children:[n(`summary`,{class:`muted small`,children:[`Scopes (`,g.length,` of `,w.length,`)`]}),w.map(e=>n(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[n(`input`,{type:`checkbox`,checked:g.includes(e),disabled:x,onChange:t=>_(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,n(`code`,{children:e})]}))]}),n(`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: ${Ur()}`:`Looking up the provider…`})]})}var ti=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),ni={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function ri({services:e,enabled:t=!0,supplied:i}){let[a,s]=o([]),[c,l]=o({}),d=i??c,[,f]=o(0),[p,h]=o(!1),g=t&&F.value!==`mock`,_=e?.join(`
|
|
37
|
+
`)??`*`;if(r(()=>{if(!g){s([]);return}let t=!0;return i||j.managedSecrets(F.value).then(e=>t&&l(e)),j.config(m.value).then(n=>{if(!t)return;let r=[];for(let[t,i]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let a=i.auth?n.auth?.[i.auth]:void 0,o=i.baseUrl?.[F.value],s=D(o?M(o,globalThis.location?.href):void 0);if(!a||!s)continue;let c=[...new Set([...JSON.stringify(a.apply).matchAll(x)].map(e=>e[1]))];c.length&&r.push({service:t,origin:s,title:a.title??i.auth??``,names:c,profile:i.auth,oauth:a.oauth})}s(r)}),()=>{t=!1}},[g,F.value,_,m.value]),!g||a.length===0)return null;let v=(e,t)=>N.get(e.origin,t)!==void 0||d[t]!==void 0,y=a.some(e=>e.names.some(t=>!v(e,t)));return!y&&!p?n(`div`,{class:`secrets-folded`,children:n(`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:[n(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,a.map(e=>e.title||e.service).join(` · `),` ✓`]})}):n(`fieldset`,{class:`needs-vars ${y?``:`ok`}`,"aria-label":`Credentials for this request`,children:[a.map(e=>n(u,{children:[n(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(t=>{let r=N.get(e.origin,t)!==void 0,i=d[t];return n(`span`,{class:`needs-var`,children:[n(`code`,{children:t}),r?n(u,{children:[n(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&ti($r(e.origin,t))!==void 0?` · expires in ${ti($r(e.origin,t))} min`:``]}),n(`button`,{type:`button`,class:`link`,onClick:()=>{N.remove(e.origin,t),Qr(e.origin,t,void 0),f(e=>e+1)},children:`Clear`})]}):n(u,{children:[i&&n(`span`,{class:`muted`,children:[`from `,ni[i]??i]}),e.oauth&&n(ei,{service:e.service,profile:e.profile,origin:e.origin,secret:t,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),n(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${t} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:n=>{let r=n.target.value;r!==``&&(N.set(e.origin,t,r),f(e=>e+1))}})]})]})})]})),n(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!y&&n(`button`,{type:`button`,class:`link`,onClick:()=>h(!1),children:`Hide`})]})}var ii=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),ai=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function oi(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[ai(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(ai(ii(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 si(e){let{seq:t}=e,[n,i]=o(),[a,c]=o(!1);r(()=>{let n=!0;i(void 0),c(!1);let r=y.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=s(()=>t.nodes.map(e=>e.name),[t]);return s(()=>({...oi(n??xe(t.meta.description),l),loaded:a}),[n,l,t,a])}function ci(e){let[t,n]=o();return r(()=>{let t=!0;return n(void 0),e&&y.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&n(e)),()=>{t=!1}},[e]),t}var li=(e,t)=>`specbook:draft:${e}:${t}`,ui=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function di(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var fi=`specbook:saved-example`;function pi(e){try{let t=sessionStorage.getItem(fi),n=t?JSON.parse(t):void 0;return n?.key===e?(sessionStorage.removeItem(fi),n):void 0}catch{return}}function mi({service:e,op:i,variants:a,initial:c}){let l=`${e}/${i.id}`,d=j.examplesOf(l),[f,h]=o(()=>pi(l)),[g,v]=o(()=>{let e=d.find(e=>e.name===(f?.name??c));return e?`ex:${e.name}`:d[0]?`ex:${d[0].name}`:a[0]?`saved:${a[0].file}`:``}),b=g.startsWith(`saved:`)?a.find(e=>`saved:${e.file}`===g):void 0,x=ci(b?.file),S=et(l),[C,w]=o(),[T,D]=o(),[O,A]=o(),[M,N]=o({}),[P,I]=o(),[ne,L]=o(),[R,re]=o(),[ie,ae]=o(),[oe,se]=o(),[ce,le]=o(),[ue,de]=o(!1),[fe,z]=o(),[pe,me]=o(),[B,he]=o(``),[ge,V]=o();r(()=>{j.config(m.value).then(t=>he(t.services?.[e]?.baseUrl?.[F.value]??``))},[e,F.value]),r(()=>{let e=!0;return V(void 0),j.knownVars(F.value,m.value).then(t=>e&&V(t)),()=>{e=!1}},[F.value]),r(()=>{let t=!0;return y.schemas[l]?.().then(e=>t&&I(e.default)),y.responseSchemas[l]?.().then(e=>t&&L(e.default)),y.definitions[e]?.().then(e=>t&&re(e.default)),j.operationMeta(l,m.value).then(e=>{t&&w({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[l,e]);let H=C?.encoding??`json`,_e=y.manifests[e]?.operations.find(e=>e.id===i.id)?.secured;r(()=>{if(!C)return;let e=!0;return le(void 0),se(void 0),(async()=>{let t=b?await j.savedExample(b.def,m.value):await j.loadExample(l,g.replace(/^ex:/,``),m.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};D(n),A(!b&&di(li(l,g))||or(n,H))})().catch(t=>e&&le(t instanceof Error?t.message:String(t))),()=>{e=!1}},[l,g,C,b]);let ve=s(()=>T?or(T,H):void 0,[T,H]),ye=!!O&&!!ve&&JSON.stringify(lr(O))!==JSON.stringify(lr(ve)),be=e=>{if(A(e),!b)try{let t=li(l,g);ve&&JSON.stringify(lr(e))===JSON.stringify(lr(ve))?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(lr(e)))}catch{}},U=s(()=>{let e=P?q(P,R):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Me(r,R).map(e=>({name:e.name,doc:ut(ct(P,R,[e.name],[n]),S.notes,n,e.name),repeat:q(e.schema,R).type===`array`})))}return t},[P,R,S.notes]),W=s(()=>{if(!O)return[];try{let e=cr(O,H);return[...t([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[]}},[O,H]),xe=ge?W.filter(e=>!ge.includes(e)):[],Se=xe.filter(e=>(M[e]??``)===``),Ce=async e=>{if(O){le(void 0),de(!0);try{let t=b?b.def:await j.operationRequest(l,m.value,cr(O,H));se(await j.run(t,{env:F.value,version:m.value,mockStatus:F.value===`mock`?e??ie:void 0,locale:te.value,seed:_.value,vars:Object.fromEntries(Object.entries(M).filter(([,e])=>e!==``)),fileDir:T?.dir}))}catch(e){le(e instanceof Error?e.message:String(e))}finally{de(!1),me(`response`)}}},we=async t=>{if(!O)return;let n=cr(O,H),r=ui(t),a={name:r,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=`${y.project.requestsDir}/${e}/${i.id}/${r}.example.json`,s={key:l,path:o,name:r};try{sessionStorage.setItem(fi,JSON.stringify(s))}catch{}await k(o,`${JSON.stringify(a,null,2)}\n`),h(s),z(void 0)},G=oe?.steps.find(e=>e.response)??oe?.steps[0],Te=ce?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Ee=!!O&&(O.path.length>0||O.query.length>0||U.path.length>0||U.query.length>0),De=!!O&&(O.headers.length>0||U.headers.length>0),Oe=!!O&&H!==`none`&&(O.body!==``||O.fields.length>0||!!P?.properties?.data),K=pe??(Ee?`params`:Oe?`body`:De?`headers`:`params`),ke=e=>e.filter(e=>e.enabled).length,J=O?ke(O.query):0,Ae=O?ke(O.path):0,je=O?ur(i.path,O.path,O.query,B):i.path;return r(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Ce())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)}),n(`div`,{class:`request-panel`,"data-op":l,children:n(`div`,{class:`rq`,children:[n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${i.method}`,children:i.method}),n(`div`,{class:`rq-url`,title:je,children:n(`code`,{children:je.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?n(`mark`,{children:e}):e)})}),(G?.response||ce||G?.error)&&n(`button`,{type:`button`,class:`result-chip ${G?.response?He(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>me(`response`),children:G?.response?`${G.response.status} ${Ve(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),n(`button`,{type:`button`,class:`btn primary send`,title:`Send (⌘/Ctrl + Enter)`,"aria-label":`Send`,disabled:ue||!O,onClick:()=>Ce(),children:ue?`…`:n(p,{})})]}),x&&n(`details`,{class:`step-about`,children:[n(`summary`,{children:`About this request`}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:x}})]},b?.file),xe.length>0&&n(`fieldset`,{class:`needs-vars ${Se.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[n(`span`,{class:`muted`,children:Se.length>0?`Needs a value for`:`Values for`}),xe.map(e=>n(`label`,{class:`needs-var`,children:[n(`code`,{children:e}),n(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:M[e]??``,onInput:t=>N({...M,[e]:t.target.value})})]}))]}),_e&&n(ri,{services:[e]}),n(`div`,{class:`rq-meta`,children:[n(`div`,{class:`rq-example`,children:[n(`label`,{class:`row`,children:[n(`span`,{class:`muted`,children:`Example`}),n(`select`,{value:g,onChange:e=>v(e.target.value),children:[d.map(e=>n(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),a.map(e=>n(`option`,{value:`saved:${e.file}`,children:[e.name,` · saved request`]}))]})]}),n(ee,{})]}),ye&&n(`span`,{class:`edited`,children:`Edited`}),n(`span`,{class:`spacer`}),ye&&n(`button`,{type:`button`,class:`link`,onClick:()=>ve&&be(ve),children:`↺ Reset`}),!E&&!b&&ye&&fe===void 0&&n(`button`,{type:`button`,class:`link`,onClick:()=>z(``),children:`Save as example…`}),F.value===`mock`&&i.statuses.length>0&&n(`label`,{class:`rq-status`,children:[n(`span`,{class:`muted`,children:`Respond with`}),n(`select`,{"aria-label":`Mock response`,value:ie===void 0?``:String(ie),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);ae(n),Ce(n)},children:[n(`option`,{value:``,children:`Default`}),i.statuses.map(e=>n(`option`,{value:String(e),children:[e,` `,Ve(e)]}))]})]})]}),f&&n(`p`,{class:`saved-note`,role:`status`,children:[n(`span`,{children:[`✓ Saved to `,n(`code`,{children:f.path}),`. It is a normal project file: commit it to share this example with your team.`]}),n(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>h(void 0),children:`×`})]}),fe!==void 0&&n(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),fe.trim()&&we(fe.trim()).catch(e=>le(String(e)))},children:[n(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:fe,onInput:e=>z(e.target.value)}),n(`button`,{type:`submit`,class:`btn`,children:`Save`}),n(`button`,{type:`button`,class:`link`,onClick:()=>z(void 0),children:`Cancel`})]}),b&&n(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock responses apply, and it is read-only here.`}),n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,J+Ae],[`headers`,`Headers`,O?ke(O.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,W.length]].filter(([e])=>e===`params`?Ee:e===`headers`?De:e===`body`?Oe:W.length>0).map(([e,t,r])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":K===e,class:`rq-tab ${K===e?`on`:``}`,onClick:()=>me(e),children:[t,r>0&&n(`span`,{class:`count`,children:r}),e===`body`&&n(`span`,{class:`chip`,children:H})]})),n(`span`,{class:`tab-gap`}),n(`button`,{type:`button`,role:`tab`,"aria-selected":K===`request`,class:`rq-tab ${K===`request`?`on`:``}`,onClick:()=>me(`request`),children:`Request`}),n(`button`,{type:`button`,role:`tab`,"aria-selected":K===`response`,class:`rq-tab ${K===`response`?`on`:``}`,onClick:()=>me(`response`),children:[`Response`,G?.response&&n(`span`,{class:`state-dot ${He(G.response.status)}`,children:G.response.status}),!G?.response&&(ce||G?.error)&&n(`span`,{class:`state-dot s5`,children:`!`})]})]}),n(`div`,{class:`rq-pane`,children:[O&&n(u,{children:[n(`div`,{class:`tab-pane`,hidden:K!==`params`,children:[(O.query.length>0||U.query.length>0)&&n(Dr,{title:`Query`,rows:O.query,documented:U.query,onChange:e=>be({...O,query:e})}),(O.path.length>0||U.path.length>0)&&n(Dr,{title:`Path`,rows:O.path,documented:U.path,fixed:!0,onChange:e=>be({...O,path:e})})]}),n(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:De&&n(Dr,{title:`Headers`,rows:O.headers,documented:U.headers,onChange:e=>be({...O,headers:e})})}),n(`div`,{class:`tab-pane`,hidden:K!==`body`,children:Oe&&n(Ar,{encoding:H,draft:O,onChange:be,schema:P,defs:R,files:C?.files,notes:S.notes})}),n(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:W.length>0&&n(Dr,{title:`Variables`,rows:W.map(e=>({key:e,value:M[e]??``,enabled:!0})),fixed:!0,bad:Te,placeholder:`from the request's init, config or earlier steps`,onChange:e=>N(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),n(`div`,{class:`tab-pane`,hidden:K!==`request`,children:O&&n(Pr,{service:e,method:i.method,path:i.path,draft:O,encoding:H,vars:M,secured:_e,sent:G?.request?n(zr,{request:G.request,docs:{schema:P,defs:R,notes:S.notes}}):void 0})}),n(`div`,{class:`tab-pane`,hidden:K!==`response`,children:n(Hr,{step:G,error:ce,schemas:ne,defs:R})})]})]})})}function hi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...gi(e,t),...n}}function gi(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,hi(t)]))};case`array`:return{kind:`array`,item:hi(t.item),default:t.default,min:t.min,max:t.max};default:return{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function _i(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,_i(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var vi={step:`request`,each:`for each item`,input:`you choose`,check:`check`},yi=e=>typeof e==`string`?e:JSON.stringify(e);function bi({info:e}){let{seq:t}=e,{intro:r,notes:i}=si(e),a=s(()=>Object.entries(t.meta.params??{}).map(([e,t])=>{let n=hi(t);return{name:e,spec:n,initial:_i(n)}}),[t]);return n(`article`,{class:`doc`,"data-seq":t.meta.id,children:[(t.meta.tags?.length??0)>0&&n(`p`,{class:`doc-tags`,children:t.meta.tags?.map(e=>n(`span`,{class:`chip`,children:e}))}),r&&n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&n(`section`,{children:[n(`h2`,{children:`Controls`}),n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`Name`}),n(`th`,{children:`Type`}),n(`th`,{children:`Default`}),n(`th`,{children:`Description`})]})}),n(`tbody`,{children:a.map(e=>n(`tr`,{children:[n(`td`,{children:n(`code`,{children:e.name})}),n(`td`,{children:n(`span`,{class:`chip`,children:e.spec.kind})}),n(`td`,{children:n(`code`,{children:yi(e.initial)})}),n(`td`,{children:e.spec.description})]}))})]})]}),n(`section`,{children:[n(`h2`,{children:`Steps`}),n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`#`}),n(`th`,{children:`Step`}),n(`th`,{children:`What it does`})]})}),n(`tbody`,{children:t.nodes.map((e,t)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return n(u,{children:[n(`tr`,{class:a?`has-note`:``,children:[n(`td`,{children:t+1}),n(`td`,{children:e.name}),n(`td`,{children:r?n(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>h({kind:`op`,key:`${r.service}/${r.id}`}),children:[n(`span`,{class:`method ${r.method}`,children:r.method}),` `,n(`code`,{children:r.path})]}):n(`span`,{class:`muted`,children:vi[e.kind]??e.kind})})]}),a&&n(`tr`,{class:`step-note-row`,children:[n(`td`,{}),n(`td`,{colSpan:2,children:n(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var xi=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Si(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Ci({name:e,spec:t,value:r,onChange:i}){let[a,s]=o();switch(t.kind){case`number`:return n(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:t.min,max:t.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return n(mr,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return n(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=t.options??[],o=a.find(e=>xi(e.value,r));return n(mr,{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 n(`div`,{class:`multi-cell`,children:(t.options??[]).map(t=>n(`label`,{children:[n(`input`,{type:`checkbox`,checked:e.some(e=>xi(e,t.value)),onChange:n=>i(n.target.checked?[...e,t.value]:e.filter(e=>!xi(e,t.value)))}),t.label]}))})}case`object`:case`array`:return n(`input`,{class:`cell mono`,"aria-label":e,value:a??JSON.stringify(r??_i(t)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return n(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function wi({title:e,specs:t,values:r,onChange:i}){let a=Object.keys(t);return a.length===0?null:n(`section`,{class:`grid controls-grid`,"aria-label":e,children:[n(`h3`,{children:e}),n(`table`,{children:[n(`colgroup`,{children:[n(`col`,{class:`c-key`}),n(`col`,{class:`c-val`}),n(`col`,{})]}),n(`thead`,{children:n(`tr`,{children:[n(`th`,{class:`g-key`,children:`Name`}),n(`th`,{class:`g-val`,children:`Value`}),n(`th`,{class:`g-doc`,children:`Description`})]})}),n(`tbody`,{children:a.map(e=>{let a=t[e];return n(`tr`,{children:[n(`td`,{class:`g-key`,children:n(`span`,{class:`key`,children:n(`code`,{children:a.label??e})})}),n(`td`,{class:`g-val`,children:n(Ci,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})})}),n(`td`,{class:`g-doc`,title:a.description,children:[n(`span`,{class:`chip`,children:Si(a)}),` `,a.description]})]},e)})})]})]})}function Ti({step:e,note:t}){let[i,a]=o(`response`),[s,c]=o(),[l,u]=o(),[d,f]=o(),[p,h]=o(`json`),g=e.request,_=g?.opId?`${g.service}/${g.opId}`:void 0;r(()=>{a(`response`)},[e.name]),r(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),_&&g&&(y.schemas[_]?.().then(t=>e&&f(t.default)),j.operationMeta(_,m.value).then(t=>e&&h(t?.encoding??`json`)),y.responseSchemas[_]?.().then(t=>e&&c(t.default)),y.definitions[g.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[_]);let v=e.response,b=g?`${g.url}${Lr(g.query)}`:``;return n(`div`,{class:`step-exchange`,children:[g&&n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${g.method}`,children:g.method}),n(`div`,{class:`rq-url`,title:b,children:n(`code`,{children:b})}),v&&n(`span`,{class:`result-chip ${He(v.status)}`,children:[v.status,` `,Ve(v.status),` · `,v.durationMs,` ms`]})]}),t&&n(`details`,{class:`step-about`,children:[n(`summary`,{children:`About this step`}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]},e.name),n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,t])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>a(e),children:[t,e===`response`&&v&&n(`span`,{class:`state-dot ${He(v.status)}`,children:v.status})]}))}),n(`div`,{class:`rq-pane`,children:[n(`div`,{class:`tab-pane`,hidden:i!==`request`,children:g?n(Fr,{request:g,encoding:p,sent:n(zr,{request:g,hideBar:!0,docs:{schema:d,defs:l}})}):n(zr,{request:g,hideBar:!0,docs:{schema:d,defs:l}})}),n(`div`,{class:`tab-pane`,hidden:i!==`response`,children:n(Hr,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var Ei=e=>e.replace(/ #\d+$/,``),Di={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``},Oi=e=>{let t=typeof e==`string`?e:JSON.stringify(e);return t.length>28?`${t.slice(0,27)}…`:t};function ki({info:e}){let{seq:t}=e,i=s(()=>Object.fromEntries(Object.entries(t.meta.params??{}).map(([e,t])=>[e,hi(t)])),[t]),a=si(e),c=s(()=>{let e=new Set;for(let n of t.nodes)if(n.kind===`step`&&typeof n.def!=`function`)e.add(n.def.op.service);else if(n.kind===`step`||n.kind===`each`)return;return[...e]},[t]),[l,u]=o({}),[d,f]=o(),[p,h]=o({}),[g,v]=o(!1),[y,b]=o(),[x,S]=o({}),[C,w]=o(0),[T,E]=o(!1),[D,O]=o();r(()=>{u(Object.fromEntries(Object.entries(i).map(([e,t])=>[e,_i(t)]))),f(void 0),h({}),b(void 0)},[e.file]);let k=t.nodes.map(e=>e.name),A=d?d.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):k.map(e=>({name:e})),M=A[C]?.step,N=async()=>{v(!0),f(void 0),O(void 0),h({}),w(0),E(!1);try{let e=await j.run(t,{env:F.value,version:m.value,params:l,locale:te.value,seed:_.value,onEvent:e=>{e.type===`step:start`&&h(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&h(t=>({...t,[e.name]:e.status}))},onInput:({name:e,controls:t})=>new Promise(n=>{let r=t;h(t=>({...t,[e]:`paused`})),S(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,_i(t)]))),b({name:e,controls:r,resolve:e=>{b(void 0),n(e)}})})});f(e)}catch(e){O(e instanceof Error?e.message:String(e))}finally{v(!1),b(void 0)}},P=d?.status;return n(`div`,{class:`sequence-panel ${T&&M?`sheet-open`:``}`,"data-seq":t.meta.id,children:[n(`div`,{class:`seq-left`,children:[n(ri,{services:c}),n(wi,{title:`Controls`,specs:i,values:l,onChange:u}),n(`div`,{class:`seq-run`,children:[n(`button`,{type:`button`,class:`btn primary`,disabled:g,onClick:N,children:g?`Running…`:`▶ Run`}),n(ee,{}),d&&n(`span`,{class:`badge ${P}`,children:[Di[P],` `,P===`pass`?`Passed`:P===`fail`?`Failed`:`Error`,` ·`,` `,d.totals.passed,`/`,d.totals.steps,` steps · `,d.durationMs,`ms`]})]}),D&&n(`p`,{class:`error-text`,children:D}),n(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:A.map((e,t)=>{let r=e.step,i=r?.status??p[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return n(`li`,{class:`jstep ${i} ${C===t?`picked`:``}`,children:[n(`div`,{class:`jmark`,children:Di[i]||t+1}),n(`div`,{class:`jbody`,children:[n(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let n=e.currentTarget;w(t),E(!0),requestAnimationFrame(()=>n.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[n(`span`,{class:`jname`,children:e.name}),r?.response&&n(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&n(`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=>n(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,n(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,t])=>n(`span`,{class:`cap make`,title:JSON.stringify(t),children:[`→ `,e,` `,n(`b`,{children:Oi(t)})]})),r?.error&&n(`div`,{class:`error-text`,children:r.error}),a.map(e=>n(`div`,{class:`error-text`,children:[`✗ `,e.label]})),i===`skipped`&&n(`div`,{class:`muted`,children:`Skipped: an earlier step did not pass.`}),y&&p[e.name]===`paused`&&n(`div`,{class:`pause`,children:[n(`strong`,{children:[`Your turn: `,y.name]}),n(wi,{title:`Choose`,specs:y.controls,values:x,onChange:S}),n(`button`,{type:`button`,class:`btn primary`,onClick:()=>y.resolve(x),children:`Continue ▶`})]})]})]})})})]}),n(`div`,{class:`seq-right ${T&&M?`sheet-open`:``}`,children:[M&&n(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>E(!1),children:[n(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,M.name]}),!M&&n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`Nothing run yet`}),n(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),M&&n(Ti,{step:M,note:a.notes.get(Ei(M.name))})]})]})}function Ai(e){let t=e.tab??`try`,r=n(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":t===r,class:`rq-tab ${t===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?n(st,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:n(`div`,{class:`panel-split`,children:[r,n(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:n(t===`docs`?bi:ki,{info:e.info})})]})}):n(st,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:n(`div`,{class:`panel-split`,children:[r,n(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:t===`docs`?n(at,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):n(mi,{service:e.service,op:e.op,variants:e.variants,initial:e.example},`${e.service}/${e.op.id}`)})]})})}export{Ai as Host};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as e,a as t,d as n,h as r,i,o as a,p as o,s,t as c,v as l}from"./panel-C8Ve3LeS.js";import{a as u,r as d,t as f}from"./mount-CGL2tOpN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:e,progress:n}){return t(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[t(`header`,{class:`header`,children:[t(`span`,{class:`sk-brand`,children:[t(`img`,{src:a,alt:``,width:`24`,height:`24`}),`Specbook`]}),t(`span`,{class:`sk-search`,"aria-hidden":`true`}),t(`span`,{class:`spacer`}),m.map(e=>t(`span`,{class:`sk-pill`,style:{width:`${e}px`},"aria-hidden":`true`})),t(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),t(`div`,{class:`layout`,"data-view":`splash`,children:[t(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[t(`span`,{class:`sk-filter`}),p.map(e=>t(`span`,{class:`sk-row`,style:{width:`${e}%`}}))]}),t(`main`,{class:`stage`,children:[t(`p`,{class:`sk-status`,children:n??`Opening…`}),t(`p`,{class:`sk-what`,title:e,children:e})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];s();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${i(e)}`;function M({initial:e}){let[i,a]=r(e),[s,u]=r(k.get(`spec`)??``),[p,m]=r(``),[g,_]=r(!1),b=o(void 0),x=async(e,t,n)=>{b.current??=new d,a({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>a({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?a({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;a({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=c(e.trim());if(t){if(!/^https?:\/\//i.test(t))return a({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};n(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):a({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?t(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):t(`main`,{class:`vw`,children:t(`div`,{class:`vw-card`,children:[t(`h1`,{children:`Specbook`}),t(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),t(`form`,{onSubmit:e=>{e.preventDefault(),S(s)},children:[t(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:s,onInput:e=>u(e.target.value),disabled:w}),t(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&t(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&t(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&t(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&t(N,{onApply:i.apply,title:i.open.title}),t(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,t(`label`,{class:`link`,children:[`choose one`,t(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),t(`details`,{children:[t(`summary`,{children:`Paste the document`}),t(`p`,{}),t(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),t(`p`,{}),t(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),t(`section`,{children:[t(`p`,{children:`Try one`}),t(`ul`,{children:D.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>S(e.url),children:e.label})}))})]}),v().length>0&&t(`section`,{children:[t(`p`,{children:`Recent`}),t(`ul`,{children:v().map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,title:e,onClick:()=>S(e),children:e})}))})]})]})})}function N({onApply:e,title:n}){let[i,a]=r(``);return t(`form`,{class:`vw-base`,onSubmit:t=>{t.preventDefault(),/^https?:\/\//i.test(i.trim())&&e(i.trim().replace(/\/$/,``))},children:[t(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),t(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${n}`,value:i,onInput:e=>a(e.target.value)}),t(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),t(`button`,{type:`button`,class:`link`,onClick:()=>e(void 0),children:`Continue with mock data`})]})}u().then(n=>{n||e(t(M,{initial:{kind:`idle`}}),O)});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Host-CSrM9wY1.js","./registry-ChKCFBt1.js","./mount-CGL2tOpN.js","./panel-C8Ve3LeS.js","./panel-C-vBZrep.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./registry-ChKCFBt1.js";import{_ as f,a as p,c as m,d as h,h as g,l as _,m as v,n as y,o as b,p as x,r as S,s as C,u as w,v as T}from"./panel-C8Ve3LeS.js";import{a as ee,n as te}from"./mount-CGL2tOpN.js";var E=w({links:[],ready:!1});function D(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 ne(e){let t=D(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 re=e=>`--sb-accent:${e};--sb-accent-hover:color-mix(in srgb,${e} 82%,black);--sb-focus-ring:color-mix(in srgb,${e} 45%,white);`+(ne(e)?`--sb-text-on-accent:${ne(e)};`:``);function ie(e){if(!e.accent&&!e.accentDark)return``;let t=e.accent?`:root{${re(e.accent)}}`:``;return e.accentDark?`${t}@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${re(e.accentDark)}}}:root[data-theme="dark"]{${re(e.accentDark)}}`:t}function ae(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?ie(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 O;function oe(e){O=e,typeof location<`u`&&(k.value=ue(location.hash))}var se=e=>O&&e.startsWith(`${O}/`)?e.slice(O.length+1):e,ce=e=>O&&!e.includes(`/`)?`${O}/${e}`:e,le=e=>encodeURIComponent(e).replace(/%2F/gi,`/`);function ue(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:ce(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 de(e){if(e.kind===`home`)return`#/`;if(e.kind===`browse`)return`#/browse`;let t=e.kind===`op`?`#/op/${le(se(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 fe=()=>typeof matchMedia==`function`&&matchMedia(`(max-width: 820px)`).matches,pe=e=>fe()?{kind:`browse`}:{kind:`home`},k=w(ue(typeof location>`u`?``:location.hash)),A=w(!1),me=w(``),he=w(``);function j(e){location.hash=de(e),k.value=e}function ge(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),i.push([a,t])}return i.sort((e,t)=>t[0]-e[0]).slice(0,n).map(([,e])=>e)}function _e({size:e=16}){return p(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[p(`path`,{d:`M3 3l19 9-19 9 3.5-9z`}),p(`path`,{d:`M6.5 12H14`})]})}function ve({size:e=12}){return p(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[p(`rect`,{x:`4`,y:`11`,width:`16`,height:`10`,rx:`2`}),p(`path`,{d:`M8 11V7a4 4 0 0 1 8 0v4`})]})}function ye({size:e=16}){return p(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,fill:`none`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,children:[p(`path`,{d:`M12 15V3`}),p(`path`,{d:`M7.5 7.5 12 3l4.5 4.5`}),p(`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 be({size:e=16}){return p(`svg`,{viewBox:`0 0 16 16`,width:e,height:e,fill:`currentColor`,"aria-hidden":`true`,children:p(`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`})})}var M=w(Date.now()),N=w(`mock`),P=w([`mock`]),xe=w({}),Se=w({}),Ce=w(void 0),F=w(void 0);function we(){if(!globalThis.__SPECBOOK_VIEWER__)return null;let e=P.value.some(e=>e!==`mock`);return p(`p`,{class:`muted overview-mode`,children:e?`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 Te=/(^|\.)specbook\.dev$/i;function Ee(e){return e.published&&e.badge!==!1&&!Te.test(e.host)}var De=e=>`https://ui.specbook.dev/?ref=${encodeURIComponent(e)}`,Oe=Object.prototype.hasOwnProperty;function ke(e,t,n){for(n of e.keys())if(I(n,t))return n}function I(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--&&I(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=ke(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=ke(t,i),!i)||!I(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(Oe.call(e,n)&&++r&&!Oe.call(t,n)||!(n in t)||!I(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var Ae,je,Me,Ne,Pe=!0;typeof process<`u`&&({FORCE_COLOR:Ae,NODE_DISABLE_COLORS:je,NO_COLOR:Me,TERM:Ne}={},Pe=process.stdout&&process.stdout.isTTY);var L={enabled:!je&&Me==null&&Ne!==`dumb`&&(Ae!=null&&Ae!==`0`||Pe),reset:R(0,0),bold:R(1,22),dim:R(2,22),italic:R(3,23),underline:R(4,24),inverse:R(7,27),hidden:R(8,28),strikethrough:R(9,29),black:R(30,39),red:R(31,39),green:R(32,39),yellow:R(33,39),blue:R(34,39),magenta:R(35,39),cyan:R(36,39),white:R(37,39),gray:R(90,39),grey:R(90,39),bgBlack:R(40,49),bgRed:R(41,49),bgGreen:R(42,49),bgYellow:R(43,49),bgBlue:R(44,49),bgMagenta:R(45,49),bgCyan:R(46,49),bgWhite:R(47,49)};function Fe(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 Ie(e,t){let n={has:e,keys:t};return n.reset=L.reset.bind(n),n.bold=L.bold.bind(n),n.dim=L.dim.bind(n),n.italic=L.italic.bind(n),n.underline=L.underline.bind(n),n.inverse=L.inverse.bind(n),n.hidden=L.hidden.bind(n),n.strikethrough=L.strikethrough.bind(n),n.black=L.black.bind(n),n.red=L.red.bind(n),n.green=L.green.bind(n),n.yellow=L.yellow.bind(n),n.blue=L.blue.bind(n),n.magenta=L.magenta.bind(n),n.cyan=L.cyan.bind(n),n.white=L.white.bind(n),n.gray=L.gray.bind(n),n.grey=L.grey.bind(n),n.bgBlack=L.bgBlack.bind(n),n.bgRed=L.bgRed.bind(n),n.bgGreen=L.bgGreen.bind(n),n.bgYellow=L.bgYellow.bind(n),n.bgBlue=L.bgBlue.bind(n),n.bgMagenta=L.bgMagenta.bind(n),n.bgCyan=L.bgCyan.bind(n),n.bgWhite=L.bgWhite.bind(n),n}function R(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:L.enabled?Fe(this.keys,t+``):t+``):t===void 0?Ie([e],[n]):L.enabled?Fe([n],t+``):t+``}}function z(){}z.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(Le(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 Le(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 Re=new z;function ze(e,t,n){return Re.diff(e,t,n)}var Be=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Ve=/\S/,He=new z;He.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!Ve.test(e)&&!Ve.test(t)},He.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]&&Be.test(t[n])&&Be.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var Ue=new z;Ue.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 We(e,t,n){return Ue.diff(e,t,n)}var Ge=new z;Ge.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ke=new z;Ke.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function qe(e){"@babel/helpers - typeof";return qe=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},qe(e)}var Je=Object.prototype.toString,B=new z;B.useLongestToken=!0,B.tokenize=Ue.tokenize,B.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(Ye(e,null,null,i),i,` `)},B.equals=function(e,t){return z.prototype.equals.call(B,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Ye(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(Je.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ye(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),qe(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]=Ye(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var Xe=new z;Xe.tokenize=function(e){return e.slice()},Xe.join=Xe.removeEmpty=function(e){return e};function Ze(e,t,n){return Xe.diff(e,t,n)}var V={"--":L.red,"··":L.grey,"++":L.green},H=L.dim().italic,Qe=L.dim(`→`),$e=L.dim(`·`),et=L.dim(`↵`),tt=(e,t)=>V[e](e+rt(t))+`
|
|
4
|
+
`,nt=(e,t)=>L.dim(`L`+String(e).padStart(t,`0`)+` `),rt=e=>e.replace(/[ ]/g,$e).replace(/\t/g,Qe).replace(/(\r?\n)/g,et);function it(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+=V[r]().underline(H(`Expected:`))+`
|
|
6
|
+
`:e.removed&&(s+=V[r]().underline(H(`Actual:`))+`
|
|
7
|
+
`);a<i.length;a++)o=i[a],o!=null&&(t&&(s+=nt(t+a,n)),s+=tt(r,o||`
|
|
8
|
+
`));return s}function at(e,t){let n=Ze(e,t),r=0,i=0,a=0,o,s,c,l,u,d=tt(`··`,`[`);for(;r<n.length;r++)for(c=(o=n[r]).removed?`--`:o.added?`++`:`··`,o.added?d+=V[c]().underline(H(`Expected:`))+`
|
|
9
|
+
`:o.removed&&(d+=V[c]().underline(H(`Actual:`))+`
|
|
10
|
+
`),i=0;i<o.value.length;i++)for(l=o.value[i]&&typeof o.value[i]==`object`,s=dt(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+=tt(c,u);return d+tt(`··`,`]`)}function ot(e,t,n=0){let r=0,i,a=``,o=We(e,t),s=String(t.split(/\r?\n/g).length-n).length;for(;r<o.length;r++)a+=it(i=o[r],n,s),n&&!i.removed&&(n+=i.count);return a}function st(e,t){let n=ze(e,t),r=0,i=``,a,o=e.length,s=t.length,c=rt(e),l=rt(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+=ct(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+L.red(a)}function ct(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)+L.dim(`[${o}]`),t+=` `.repeat(l)+L.dim(`[${s}]`),n+=c+o.length+2,r+=l+s.length+2,a=Math.max(n,r)}return V[`++`](`++`+t+` `.repeat(i+a-r)+H(`(Expected)`))+`
|
|
11
|
+
`+V[`--`](`--`+e+` `.repeat(i+a-n)+H(`(Actual)`))+`
|
|
12
|
+
`}function lt(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]=lt(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]=lt(i,t[n]));for(n in e)s.hasOwnProperty(n)||(s[n]=e[n])}return s}function ut(){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 dt(e){return JSON.stringify(e,ut(),2).replace(/"\[__NAN__\]"/g,`NaN`).replace(/"\[__VOID__\]"/g,`undefined`)}function ft(e,t){if(Array.isArray(t)&&Array.isArray(e))return at(e,t);if(t instanceof RegExp)return st(``+e,``+t);let n=e&&typeof e==`object`,r=t&&typeof t==`object`;return n&&r&&(e=lt(e,t)),r&&(t=dt(t)),n&&(e=dt(e)),t&&typeof t==`object`&&(e=dt(lt(e,t)),t=dt(t)),n=typeof e==`string`,r=typeof t==`string`,n&&/\r?\n/.test(e)?ot(e,``+t):r&&/\r?\n/.test(t)?ot(``+e,t):n&&r?st(e,t):ct(e,t)}var pt=r({Assertion:()=>mt,equal:()=>_t,fixture:()=>wt,instance:()=>bt,is:()=>gt,match:()=>xt,not:()=>G,ok:()=>ht,snapshot:()=>St,throws:()=>Tt,type:()=>yt,unreachable:()=>vt});function U(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 mt=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 W(e,t,n,r,i,a,o){if(e)return;let s=o||a;throw o instanceof Error?o:new mt({actual:t,expects:n,operator:r,message:s,details:i&&i(t,n),generated:!o})}function ht(e,t){W(!!e,!1,!0,`ok`,!1,`Expected value to be truthy`,t)}function gt(e,t,n){W(e===t,e,t,`is`,ft,`Expected values to be strictly equal:`,n)}function _t(e,t,n){W(I(e,t),e,t,`equal`,ft,`Expected values to be deeply equal:`,n)}function vt(e){W(!1,!0,!1,`unreachable`,!1,`Expected not to be reached!`,e)}function yt(e,t,n){let r=typeof e;W(r===t,r,t,`type`,!1,`Expected "${r}" to be "${t}"`,n)}function bt(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";W(e instanceof t,e,t,`instance`,!1,`Expected value to be an instance of ${r}`,n)}function xt(e,t,n){typeof t==`string`?W(e.includes(t),e,t,`match`,!1,`Expected value to include "${t}" substring`,n):W(t.test(e),e,t,`match`,!1,`Expected value to match \`${String(t)}\` pattern`,n)}function St(e,t,n){e=U(e),t=U(t),W(e===t,e,t,`snapshot`,ot,`Expected value to match snapshot:`,n)}var Ct=(e,t)=>ot(e,t,1);function wt(e,t,n){e=U(e),t=U(t),W(e===t,e,t,`fixture`,Ct,`Expected value to match fixture:`,n)}function Tt(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e(),W(!1,!1,!0,`throws`,!1,`Expected function to throw`,n)}catch(e){if(e instanceof mt)throw e;typeof t==`function`?W(t(e),!1,!0,`throws`,!1,`Expected function to throw matching exception`,n):t instanceof RegExp&&W(t.test(e.message),!1,!0,`throws`,!1,`Expected function to throw exception matching \`${String(t)}\` pattern`,n)}}function G(e,t){W(!e,!0,!1,`not`,!1,`Expected value to be falsey`,t)}G.ok=G,gt.not=function(e,t,n){W(e!==t,e,t,`is.not`,!1,`Expected values not to be strictly equal`,n)},G.equal=function(e,t,n){W(!I(e,t),e,t,`not.equal`,!1,`Expected values not to be deeply equal`,n)},G.type=function(e,t,n){let r=typeof e;W(r!==t,r,t,`not.type`,!1,`Expected "${r}" not to be "${t}"`,n)},G.instance=function(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";W(!(e instanceof t),e,t,`not.instance`,!1,`Expected value not to be an instance of ${r}`,n)},G.snapshot=function(e,t,n){e=U(e),t=U(t),W(e!==t,e,t,`not.snapshot`,!1,`Expected value not to match snapshot`,n)},G.fixture=function(e,t,n){e=U(e),t=U(t),W(e!==t,e,t,`not.fixture`,!1,`Expected value not to match fixture`,n)},G.match=function(e,t,n){typeof t==`string`?W(!e.includes(t),e,t,`not.match`,!1,`Expected value not to include "${t}" substring`,n):W(!t.test(e),e,t,`not.match`,!1,`Expected value not to match \`${String(t)}\` pattern`,n)},G.throws=function(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e()}catch(e){typeof t==`function`?W(!t(e),!0,!1,`not.throws`,!1,`Expected function not to throw matching exception`,n):t instanceof RegExp?W(!t.test(e.message),!0,!1,`not.throws`,!1,`Expected function not to throw exception matching \`${String(t)}\` pattern`,n):t||W(!1,!0,!1,`not.throws`,!1,`Expected function not to throw`,n)}};var Et=/\u001b\[[0-9;]*m/g,Dt=e=>e.replace(Et,``);function Ot(e){if(!e)return;let t=e.split(`
|
|
14
|
+
`).slice(1);for(let e of t){if(e.includes(`/core/src/assert`)||e.includes(`node_modules`))continue;let t=/(?:\(|at )?([^\s()]+):(\d+):(\d+)\)?\s*$/.exec(e);if(t)return{file:t[1],line:Number(t[2]),column:Number(t[3])}}}function kt(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:Dt(String(r.message??o??n)),operator:n,pass:!1,actual:r.actual,expected:r.expects,diff:r.details?Dt(String(r.details)):void 0,location:Ot(Error().stack)}),e===`hard`))throw r}}},r=pt,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 K=class extends Error{};function At(e,t){let n=e.opts.value;return n?n(t):t}function jt(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function Mt(e,t,n){switch(t.kind){case`select`:{let r=t.opts.options;if(r.length===0)throw new K(`No options available for "${e}"`);let i=r.map(e=>At(t,e));if(n!==void 0){if(!i.some(e=>jt(e,n)))throw new K(`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[0]:a}case`multiselect`:{let e=t.opts.options;if(n!==void 0)return n;let r=t.opts.default;return typeof r==`function`?r(e):r??[]}case`object`:{let e=t.opts.shape,r=n??{};return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Mt(e,t,r[e])]))}case`array`:{let r=n??t.opts.default??[],{min:i,max:a}=t.opts;if(i!==void 0&&r.length<i)throw new K(`"${e}" needs at least ${i} items`);if(a!==void 0&&r.length>a)throw new K(`"${e}" allows at most ${a} items`);return r.map(n=>Mt(e,t.opts.item,n))}case`boolean`:return n??t.opts.default??!1;case`number`:return n??t.opts.default??0;default:return n??t.opts.default??``}}function Nt(e,t={}){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Mt(e,n,t[e])]))}function Pt(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(At(t,e)),value:At(t,e)}));return[e,{kind:t.kind,options:r}]}return[e,{kind:t.kind,default:t.opts.default}]}))}var Ft={comma:`,`,space:` `,pipe:`|`},It=e=>typeof Blob<`u`&&e instanceof Blob;function Lt(e,t=`indices`,n=``,r=[]){if(typeof t==`string`||n||typeof e!=`object`||!e)Rt(n,e,r,typeof t==`string`?t:`indices`);else for(let[n,i]of Object.entries(e))Rt(n,i,r,t[n]??`indices`);return r}function Rt(e,t,n,r){if(t!=null){if(Array.isArray(t)&&r in Ft&&t.every(e=>typeof e!=`object`||!e))n.push([e,t.map(String).join(Ft[r])]);else if(Array.isArray(t))t.forEach((t,i)=>{Rt(r===`indices`||r in Ft?`${e}[${i}]`:r===`brackets`?`${e}[]`:e,t,n,r)});else if(typeof t==`object`)for(let[i,a]of Object.entries(t))Rt(e?`${e}[${i}]`:i,a,n,r);else n.push([e,String(t)])}}function zt(e,t=`indices`){return Lt(e,t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}function Bt(e){let t=new FormData,n=(e,n)=>{n!=null&&(It(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 Vt(e){return JSON.stringify(typeof e==`string`?{query:e}:e)}function Ht(e,t,n,r){switch(e){case`json`:return{body:JSON.stringify(t),contentType:`application/json`};case`graphql`:return{body:Vt(t),contentType:`application/json`};case`form`:return{body:zt(t,n),contentType:`application/x-www-form-urlencoded`};case`text`:return{body:String(t),contentType:`text/plain`};case`multipart`:return{body:Bt(t)};case`binary`:return{body:t,contentType:r||(It(t)&&t.type?t.type:`application/octet-stream`)};default:return{body:t}}}function Ut(e){if(It(e)){let t=e;return{file:t.name??`file`,type:t.type,size:t.size}}return Array.isArray(e)?e.map(Ut):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Ut(t)])):e}var q=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Wt=e=>[`string`,`number`,`boolean`].includes(typeof e);function Gt(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 Kt(e,t){if(q(e)&&q(t)){let n={...e};for(let[e,r]of Object.entries(t))e in n&&(n[e]=Kt(n[e],r));return n}if(Array.isArray(e)&&Array.isArray(t)){if(t.length===0)return e;if(t.every(Wt)&&e.every(Wt))return t;let n=e[0];return q(n)&&t.every(q)?t.map(e=>Kt(n,e)):e}return Wt(t)&&Wt(e)&&typeof t==typeof e?t:typeof e==`number`&&typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t))?Number(t):e}function qt(e,t){let n={...e},r=Object.entries(t).filter(([,e])=>e!==void 0&&e!==``);for(let[e,t]of r)e in n&&!q(n[e])&&!Array.isArray(n[e])?n[e]=Gt(t,n[e]):r.length===1&&`id`in n&&/^(id|.*[a-z]Id|.*_id)$/.test(e)&&!q(n.id)&&!Array.isArray(n.id)&&(n.id=Gt(t,n.id));return n}var Jt=e=>Wt(e),Yt=new Set([`id`,`object`,`type`,`kind`,`created`,`updated`,`url`,`livemode`,`metadata`,`status`]);function Xt(e,t=[],n=[],r=0){if(r>6)return n;if(q(e))for(let[i,a]of Object.entries(e))Xt(a,[...t,i],n,r+1);else Array.isArray(e)?e.length&&Xt(e[0],[...t,0],n,r+1):Jt(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 Qt(e,t,n=[],r=[],i=0){if(i>5)return r;if(q(e))for(let[a,o]of Object.entries(e))a===t&&Jt(o)?r.push([...n,a]):Qt(o,t,[...n,a],r,i+1);else Array.isArray(e)&&e.length&&Qt(e[0],t,[...n,0],r,i+1);return r}var $t=(e,t)=>typeof e==typeof t||typeof t==`number`&&typeof e==`string`&&e.trim()!==``&&!Number.isNaN(Number(e));function en(e,t,n){let r=Zt(e,t.slice(0,-1));typeof r==`object`&&r&&(r[t[t.length-1]]=n)}function tn(e,t,n){let r=structuredClone(e),i=new Set(Xt(n).map(e=>e.path.join(`\0`)));for(let e of Xt(t)){if(Zt(r,e.path)!==void 0)continue;let t=String(e.path[e.path.length-1]);if(Yt.has(t)||typeof e.path[e.path.length-1]==`number`)continue;let n=Qt(r,t).filter(e=>!i.has(e.join(`\0`)));if(n.length!==1)continue;let a=n[0],o=Zt(r,a);$t(e.value,o)&&(en(r,a,Gt(e.value,o)),i.add(a.join(`\0`)))}return r}var nn=/^(limit|per_?page|page_?size|size|count|max|max_?results|take)$/i;function rn(e){return Array.isArray(e)?e[0]:typeof e==`string`&&e.includes(`,`)?e.split(`,`)[0]?.trim():e}function an(e,t){let n=Object.entries(t).map(([e,t])=>[e,rn(t)]).filter(([,e])=>Jt(e)&&e!==``);if(n.length===0)return e;let r=e=>{let t={...e};for(let[e,r]of n)e in t&&Jt(t[e])&&$t(r,t[e])&&(t[e]=Gt(r,t[e]));return t},i=n.find(([e])=>nn.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(q))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(q(e)){let t={...e},n=Object.entries(t).filter(([,e])=>Array.isArray(e)&&e.length>0&&e.every(q));if(n.length===1)t[n[0]?.[0]]=o(n[0]?.[1]);else return r(t);return t}return e}function on(e,t){let n=e;if(t.body!==void 0){let e=q(n)&&Array.isArray(t.body)&&t.body.length>0&&t.body.every(q)?t.body[0]:t.body;(q(n)&&q(e)||Array.isArray(n)&&Array.isArray(e))&&(n=Kt(n,e),q(n)&&q(e)&&(n=tn(n,e,e)))}return q(n)&&t.path&&(n=qt(n,t.path)),t.query&&(n=an(n,t.query)),n}var sn=e=>typeof e==`object`&&!!e&&(`data`in e||`init`in e||`headers`in e||`delayMs`in e);function cn(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,typeof t==`function`?t():t]))}function ln(e){let n=e.sleep??(e=>new Promise(t=>setTimeout(t,e)));return async r=>{let a=r.mock,o=a?.config,s=await e.loader.statuses(r.service,r.opId),c=Object.keys(o?.responses??{}).map(Number),l=[...new Set([...s,...c])],u=o?.when?.({vars:a?.vars??{},body:r.body,query:a?.rawQuery,path:a?.pathParams}),d=r.mockStatus??u??o?.status??l.find(e=>e>=200&&e<300)??l[0]??200;if(a?.secured&&!r.headers.authorization&&!Object.keys(r.headers).some(e=>/api[-_]?key|token/i.test(e))&&r.mockStatus===void 0&&l.includes(401))return dn(401,await e.loader.example(r.service,r.opId,401));let f=o?.responses?.[d],p=0,m={},h={...a?.vars??{},...a?.pathParams??{},...a?.rawQuery??{}},g=await e.loader.example(r.service,r.opId,d);if(d>=200&&d<300&&o?.reflect!==!1&&(g=on(g,{body:r.body,path:a?.pathParams,query:a?.rawQuery})),f!==void 0){let e;sn(f)?(e=await un(f.data),h={...h,...cn(f.init)},m=f.headers?t(f.headers,h):{},p=f.delayMs??0):e=await un(f),e!==void 0&&(g=i(g,e))}return p&&await n(p),{...dn(d,g===void 0?void 0:t(g,h)),headers:{"content-type":`application/json`,...m}}}}async function un(e){return typeof e==`function`?(await e()).default:e}function dn(e,t){return{status:e,headers:{"content-type":`application/json`},text:t===void 0?``:JSON.stringify(t),body:t}}var J=class extends Error{constructor(e){super(e),this.name=`OAuthError`}},fn=e=>`openIdConnectUrl`in e;function pn(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 J(`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 mn=e=>{let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)},hn=e=>mn(crypto.getRandomValues(new Uint8Array(e)));async function gn(e){if(!globalThis.crypto?.subtle)throw new J(`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 mn(new Uint8Array(t))}async function _n(){let e=hn(48);return{verifier:e,challenge:await gn(e)}}var vn=()=>hn(24);function yn(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 bn(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 J(`Sign-in was refused: ${e?`${r} (${e})`:r}`)}if(n(`state`)!==t)throw new J(`Sign-in was rejected: the response did not match this request (state)`);let i=n(`code`);if(!i)throw new J(`Sign-in returned no authorization code`);return{code:i}}function xn(e){return{grant_type:`authorization_code`,code:e.code,redirect_uri:e.redirectUri,client_id:e.clientId,code_verifier:e.verifier}}function Sn(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 J(`The token endpoint refused the code: ${t.error}${e}`)}if(typeof t.access_token!=`string`||t.access_token===``)throw new J(`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 Cn=123,wn=125,Tn=e=>e===32||e===9||e===10||e===13,En=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e===45,Dn=[115,101,99,114,101,116,115,46];function On(e,t){let n=t+2;for(;n<e.length&&Tn(e[n]);)n++;for(let t of Dn)if(e[n++]!==t)return;let r=n;for(;n<e.length&&En(e[n]);)n++;if(n===r)return;let i=String.fromCharCode(...e.subarray(r,n));for(;n<e.length&&Tn(e[n]);)n++;if(e[n]===wn&&e[n+1]===wn)return{start:t,end:n+2,name:i}}function kn(e){let t=[];for(let n=0;n<e.length-1;n++)if(e[n]===Cn&&e[n+1]===Cn){let r=On(e,n);r&&(t.push(r),n=r.end-1)}return t}var An=new TextEncoder;function jn(e){return[...new Set(kn(e).map(e=>e.name))]}function Mn(e,t){let n=kn(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),An.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 Nn=new TextDecoder;function Pn(e,t){return e.includes(`{{`)?Nn.decode(Mn(An.encode(e),t)):e}var Fn=new TextDecoder(`utf-8`,{fatal:!0}),In=new TextEncoder;function Ln(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function Rn(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 zn(e){try{return{kind:`text`,text:Fn.decode(e)}}catch{return{kind:`b64`,b64:Ln(e)}}}function Bn(e){return e.kind===`text`?In.encode(e.text):Rn(e.b64)}async function Vn(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:zn(new Uint8Array(await e.arrayBuffer()))}:{}}}function Hn(e){let t=e.status===204||e.status===205||e.status===304;return new Response(e.body&&!t?Bn(e.body):null,{status:e.status,headers:e.headers})}var Un=class extends Error{names;constructor(e){super(`Missing secrets: ${e.join(`, `)}`),this.names=e,this.name=`MissingSecretsError`}};function Wn(e,t){let n=[...t].filter(e=>e.length>=4).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)}var Y=()=>Date.now(),Gn=class extends Error{};function Kn(){return`run_${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}var qn=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]));function Jn(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=typeof r==`function`?r():r;return t}async function Yn(e){return typeof e==`function`?(await e()).default:e}async function Xn(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=>Xn(e,t,n)));let[r,...i]=t;return l(e)&&r in e?{...e,[r]:await Xn(e[r],i,n)}:e}async function Zn(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 Xn(o,e.split(`.`),a);return o}function Qn(t,n,r){let i=new Set,a=[];for(let o of t){if(e(o)||s(o))continue;let t=o.split(`.`)[0];if(!i.has(t)){i.add(t);for(let e=n.length-1;e>=0;e--){let[i,o]=n[e];if(t in o){let s=i===`capture`?{key:t,source:i,step:r[t]}:{key:t,source:i};if(i===`capture`){let r=n.slice(0,e).reverse().find(([,e])=>t in e),[i,a]=[typeof r?.[1][t],typeof o[t]];r&&i!==a&&(s.shadows={source:r[0],type:i,replacedBy:a})}a.push(s);break}}}}return a}function $n(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 Un([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 Gn(`No session value "${a}" for profile "${n}"`);return t.mask.add(String(o)),String(o)}),i=e=>It(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 X(e,t){e.o.onEvent?.(t)}function er(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 tr(e,t){return{status:e.status,ok:e.status>=200&&e.status<300,headers:qn(e.headers),data:e.body,text:e.text,durationMs:t}}async function nr(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?.()??Y()))&&!r)return;let s=e.inflight.get(a);if(s)return s;let c=(async()=>{let r=i;X(e,{type:`auth:login`,profile:t});let{result:o,response:s}=await ir(e,await r.login(),`Login (${t})`,rr,`auth`,!0);if(n.push(o),!s?.ok)throw new Gn(`Login for profile "${t}" failed (${s?.status})`);let c=r.token(s),l=typeof c.expiresIn==`number`?(e.o.now?.()??Y())+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 rr={params:{},captured:{},from:{}};async function ir(e,n,r,a,o=`request`,s=!1){let l=e.o.now?.()??Y(),u=[],d={name:r,kind:o,status:`pass`,assertions:[],captured:{},durationMs:0},f=n.input.assertMode??e.seqAssertMode??e.o.assertMode??`soft`;X(e,{type:`step:start`,name:r});let p;try{let o=[[`config`,e.o.vars??{}],[`init`,Jn(n.input.init)],[`param`,a.params],[`capture`,a.captured],[`override`,Jn(n.varOverrides)],[`override`,e.o.overrides??{}]],l=Object.assign({},...o.map(e=>e[1])),m;if(n.input.example&&(m=await e.o.example?.(n.op,n.input.example),!m))throw new Gn(`Example "${n.input.example}" not found for ${n.op.id}`);let h=i(m?.body,await Yn(n.input.data));for(let e of n.dataPatches)h=i(h,e);let g=i(m?.path??{},n.input.path??{}),_=i(m?.query??{},n.input.query??{}),v={...m?.headers??{},...n.input.headers??{}};d.uses=Qn(c([h,g,_,v]),o,a.from);let y=h===void 0?void 0:t(h,l),b=t(g,l)??{},x=t(_,l)??{},S=qn(t(v,l)),C=n.input.encoding??n.op.encoding??(y===void 0?`none`:`json`);y!==void 0&&e.o.readFile&&(n.op.files?.length||C===`binary`)&&(y=await Zn(y,n.op.files??[],C,e.o.readFile,m?.dir));let w=s?void 0:er(e,n),T=w?e.o.auth?.[w]:void 0,ee={};T&&w&&(S={...qn(t(T.apply.headers??{},l)),...S},Object.assign(ee,t(T.apply.query??{},l)));let te=n.op.path.replace(/\{([^}]+)\}/g,(e,t)=>{let n=b[t];if(n==null)throw new Gn(`Missing path parameter "${t}"`);return encodeURIComponent(String(n))}),E={};for(let[e,t]of Object.entries({...x,...ee}))t!=null&&(E[e]=Array.isArray(t)?t.map(String):String(t));let D={service:n.op.service,opId:n.op.id,method:n.op.method,url:te,query:E,headers:S,body:y,encoding:C,mediaType:C===`binary`?n.op.mediaType:void 0,formArrays:n.op.formArrays,timeoutMs:n.input.timeoutMs,mockStatus:e.o.env===`mock`?n.input.mock?.status:void 0,mock:e.o.env===`mock`?{config:n.input.mock,vars:l,pathParams:b,rawQuery:x,secured:n.op.security}:void 0};d.request={opId:n.op.id,method:D.method,service:D.service,url:D.url,query:D.query,headers:D.headers,body:Ut(D.body),profile:w},X(e,{type:`request`,name:r,request:d.request});let ne=async()=>{w&&await nr(e,w,u);let{mock:t,...n}=D,r={...$n(n,e,w),mock:t},i=e.o.now?.()??Y();return tr(await e.o.transport(r,e.o.signal),(e.o.now?.()??Y())-i)};p=await ne(),p.status===401&&w&&T?.retryOn401!==!1&&T?.login&&(await nr(e,w,u,!0),p=await ne()),d.response={status:p.status,headers:p.headers,body:p.data,durationMs:p.durationMs},X(e,{type:`response`,name:r,status:p.status,durationMs:p.durationMs});for(let[e,t]of Object.entries(n.input.capture??{}))d.captured[e]=t(p,l);if(X(e,{type:`capture`,name:r,captured:d.captured}),n.input.assert){let t=kt(f);try{await n.input.assert(p,{assert:t.assert,vars:{...l,...d.captured},req:d.request})}catch(e){e?.name!==`Assertion`&&(d.status=`error`,d.error=`assert threw: ${e?.message??e}`)}d.assertions=t.results;for(let n of t.results)X(e,{type:n.pass?`assert:pass`:`assert:fail`,name:r,assertion:n})}d.status===`pass`&&d.assertions.some(e=>!e.pass)&&(d.status=`fail`)}catch(e){d.status=`error`,d.error=e instanceof Error?e.message:String(e)}return d.durationMs=(e.o.now?.()??Y())-l,X(e,{type:`step:end`,name:r,status:d.status}),{result:d,response:p,authResults:u}}function ar(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 or(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 sr(e,t,n,r,i){let a=Wn({schemaVersion:1,runId:Kn(),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:or(r),startedAt:new Date(i).toISOString(),durationMs:(e.o.now?.()??Y())-i,totals:ar(r),steps:r},e.mask);return X(e,{type:`done`,result:a}),a}function cr(e){return{o:e,sessions:new Map,inflight:new Map,mask:new Set}}async function lr(e,t){let n=cr(t),r=t.now?.()??Y();X(n,{type:`run:start`,id:e.op.id});let i=e.input.name??e.op.id,{result:a,authResults:o}=await ir(n,e,i,rr);return sr(n,`request`,{id:e.op.id,title:i},[...o,a],r)}async function ur(e,t){let n=cr(t);n.seqAuth=e.meta.auth,n.seqAssertMode=e.meta.assertMode;let r=t.now?.()??Y();X(n,{type:`run:start`,id:e.meta.id});let i=[],a={},o={},s=(e,t)=>{Object.assign(a,e);for(let n of Object.keys(e))o[n]=t},c;try{c=Nt(e.meta.params??{},t.params)}catch(t){return i.push({name:`params`,kind:`input`,status:`error`,assertions:[],captured:{},error:t.message,durationMs:0}),sr(n,`sequence`,e.meta,i,r)}let l=t.vars??{},u=()=>({params: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 ir(n,typeof r.def==`function`?r.def(u()):r.def,r.name,{params: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?.()??Y(),m={};for(let t=0;t<l.length;t++){let{result:i,authResults:s}=await ir(n,r.def(l[t],u(),t),`${r.name} #${t+1}`,{params: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?.()??Y())-p,s(m,r.name),i.push(f),f.status!==`pass`&&(d=!0)}else if(r.kind===`input`){let e=r.controls(u()),a=Pt(e);X(n,{type:`input:required`,name:r.name,controls:a});let o=Nt(e,t.onInput?await t.onInput({name:r.name,controls:a}):t.params??{});c={...c,...o},i.push({name:r.name,kind:`input`,status:`pass`,assertions:[],captured:o,durationMs:0})}else if(r.kind===`check`){let a=kt(e.meta.assertMode??t.assertMode??`soft`),o={name:r.name,kind:`check`,status:`pass`,assertions:[],captured:{},durationMs:0};X(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`),X(n,{type:`step:end`,name:r.name,status:o.status}),i.push(o),o.status!==`pass`&&(d=!0)}}catch(e){let t=e instanceof K;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 sr(n,`sequence`,e.meta,i,r)}function dr(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 fr(e){return async(t,n)=>{let r=e.fetch??fetch,i={...t.headers},a;if(t.body!==void 0&&t.method!==`GET`&&t.method!==`HEAD`){let e=Ht(t.encoding,t.body,t.formArrays,t.mediaType);a=e.body,e.contentType&&(i[`content-type`]??=e.contentType)}t.mockStatus!==void 0&&(i[`x-specbook-mock-status`]=String(t.mockStatus));let o=new AbortController,s=t.timeoutMs?setTimeout(()=>o.abort(),t.timeoutMs):void 0;n?.addEventListener(`abort`,()=>o.abort());try{let n=await r(dr(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}}finally{s&&clearTimeout(s)}}}var pr=`specbook`;function mr(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!==`${pr}:reply`||!t.reply)return;let r=t.reply;(i===void 0||r.id===i)&&(s(),n(t.reply))},o=()=>{s(),window.postMessage({channel:`${pr}: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:`${pr}:call`,call:e},`*`)})}}}async function hr(e=250){let t=globalThis.__SPECBOOK_EXTENSION__;if(t)return t;if(typeof window>`u`)return;let n=mr(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 gr=0;function _r(e,t){return fr({baseUrl:t,fetch:async(t,n)=>{let r=new Request(t,n),i=`c${Date.now().toString(36)}${gr++}`,a=await e.send({v:1,type:`fetch`,id:i,req:await Vn(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 Hn(a.res)}})}var vr=`specbook.secrets.v1`,yr={},br=()=>{try{let e=sessionStorage.getItem(vr);return e?JSON.parse(e):yr}catch{return yr}},xr=e=>{yr=e;try{sessionStorage.setItem(vr,JSON.stringify(e))}catch{}},Sr={get:(e,t)=>br()[e]?.[t],set(e,t,n){let r=br();xr({...r,[e]:{...r[e],[t]:n}})},remove(e,t){let n=br(),{[t]:r,...i}=n[e]??{};xr({...n,[e]:i})}},Cr=e=>{try{return e?new URL(e).origin:void 0}catch{return}},wr=/\{\{\s*secrets\.([\w$-]+)\s*\}\}/g;function Tr(e){return e.proxy?`proxy`:e.pageOrigin&&Cr(e.baseUrl)===e.pageOrigin?`direct`:e.extension?`extension`:`direct`}function Er(e,t){try{return new URL(e,t).toString()}catch{return e}}var Dr=e=>{let t=new Set,n=e=>{if(typeof e==`string`)for(let n of jn(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 Or(e,t){return(n,r)=>{let i=Dr(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 Un(s);let c=e=>typeof e==`string`?Pn(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 kr(e){return(t,n)=>{let r=Tr({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 Ar=`auth:`,jr=e=>`${Ar}${encodeURIComponent(e)}`,Mr=`discovery:`,Nr=e=>`${Mr}${encodeURIComponent(e)}`;function Pr(e,t={}){let r={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 o(t){return(await e.loadConfig(t)).default}async function s(e){let t=await o(e),n={};for(let[e,r]of Object.entries(t.environments??{})){let t=r?.risk;(t===`production`||t===`sandbox`)&&(n[e]=t)}return n}async function c(e){let t=await o(e),n={};for(let[e,r]of Object.entries(t.environments??{})){let t=r?.description;t&&(n[e]=t)}return n}async function l(t){let n=await o(t),r=new Set([`mock`]);for(let e of Object.values(n.services??{}))for(let t of Object.keys(e.baseUrl??{}))r.add(t);for(let t of Object.keys(e.environmentVars??{}))r.add(t);for(let e of Object.keys(n.environments??{}))r.add(e);return[...r]}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]??{}}async function f(e,t){let n=await o(t);return[...new Set([...Object.keys(n.vars??{}),...Object.keys(n.environments?.[e]?.vars??{}),...Object.keys(await u(e))])]}async function p(n,i,a,s={}){if(n===`mock`)return ln({loader:r});let c=await o(a),l=globalThis.location?.href,u=globalThis.location?.origin,d=e=>{if(s[e])return s[e];let t=c.services?.[e]?.baseUrl?.[n];if(!t)throw Error(`No base URL for ${e} in the "${n}" environment`);return Er(t,l)},f=e.mode!==`static`,p=await t.extension?.(),m=p?_r(p,y):void 0,h=t.secrets??Sr,g=fr({baseUrl:d}),_=f?fr({baseUrl:e=>`${i}/${n}/${e}`}):void 0;return kr({direct:b(Or(g,{store:h,originFor:v,unresolved:`fail`})),proxy:_?Or(_,{store:h,originFor:v,unresolved:`keep`}):void 0,extension:m?Or(m,{store:h,originFor:v,unresolved:`keep`}):void 0,baseOf:y,pageOrigin:u});function v(e){return Cr(y(e))}function y(e){try{return d(e)}catch{return``}}function b(e){return async(t,r)=>{try{return await e(t,r)}catch(e){throw e instanceof TypeError&&(t.service.startsWith(Ar)||t.service.startsWith(Mr))?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 "${n}". 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 m(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 h=new Map;async function g(e){if(e.env===`mock`)throw Error(`Sign in needs a live environment, not mock`);let t=(await o(e.version)).auth?.[e.profile]?.oauth;if(!t)throw Error(`"${e.profile}" has no sign-in configured`);if(!fn(t))return{authorizationUrl:t.authorizationUrl,tokenUrl:t.tokenUrl,scopes:t.scopes??{}};let n=new URL(t.openIdConnectUrl),r=h.get(n.href);r||(r=(async()=>{let t=Nr(e.profile),r=await(await p(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 pn(r.body)})(),h.set(n.href,r),r.catch(()=>h.delete(n.href)));let i=await r;return{...i,scopes:t.scopes&&Object.keys(t.scopes).length?t.scopes:i.scopes}}async function _(e){let{tokenUrl:t}=await g(e),n=new URL(t),r=jr(e.profile),i=await(await p(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 v=e=>e.replace(/^\.\//,``),y=t=>e.requestExamples[t]??[];async function b(e,t,n){let r=y(e).find(e=>e.name===t);if(r)return{...(await r.load(n)).default,source:r.source,dir:r.dir}}async function x(t,n){let r=await e.assets[`${n}/${v(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()],v(t).split(`/`).pop(),{type:i.headers.get(`content-type`)??void 0})}async function S(e){let t=await o(e.version),n=t.auth??{},r=Object.fromEntries(Object.entries(t.services??{}).filter(([,e])=>e.auth).map(([e,t])=>[e,t.auth]));return{env:e.env,vars:{...t.vars??{},...t.environments?.[e.env]?.vars??{},...await u(e.env)},overrides:e.vars,params:e.params,transport:await p(e.env,e.proxyBase??`/__specbook/proxy`,e.version),deferSecrets:!0,auth:n,serviceAuth:r,onEvent:e.onEvent,onInput:e.onInput,signal:e.signal,example:(t,n)=>b(`${t.service}/${t.id}`,n,e.version),readFile:(t,n)=>x(t,n??e.fileDir)}}async function C(e,t){if(e.kind===`sequence`)return!0;let{init:n,data:r,example:i,path:o,query:s,headers:c}=e.input;if(Object.values(n??{}).some(e=>typeof e==`function`)||typeof r==`function`)return!0;let l=i?await b(`${e.op.service}/${e.op.id}`,i,t.version):void 0;return a([l,r,e.dataPatches,o,s,c,t.vars])}async function w(t,r){if(e.loadFaker&&await C(t,r)){let[t,i]=await Promise.all([e.loadFaker(r.version),o(r.version)]),a=await n(t,i.faker,r.locale);d(a,i.faker,{locale:r.locale,seed:r.seed})}let i=await S(r);return t.kind===`sequence`?ur(t,i):lr(r.mockStatus!==void 0&&r.env===`mock`?t.with({mock:{status:r.mockStatus}}):t,i)}async function T(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));return o.request({...i?.input??{},...s})}async function ee(t,n){return(await e.operations[t]?.(n))?.[t.split(`/`)[1]]?.meta}async function te(e,t){let n=`${e.op.service}/${e.op.id}`,r=e.input.example?await b(n,e.input.example,t):void 0,a=e.input.data;typeof a==`function`&&(a=(await a()).default);let o=i(r?.body,a);for(let t of e.dataPatches)o=i(o,t);return{name:e.input.name??e.op.id,source:`project`,dir:r?.dir,path:i(r?.path??{},e.input.path??{}),query:i(r?.query??{},e.input.query??{}),headers:{...r?.headers??{},...e.input.headers??{}},body:o}}async function E(e,t){let n={};await Promise.all(e.map(async e=>{try{let r=Fr(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 D(e,t){let n=[];return await Promise.all(e.map(async e=>{try{let r=Fr(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:o,environments:l,environmentRisks:s,environmentNotes:c,managedSecrets:m,oauthEndpoints:g,oauthExchange:_,run:w,operationRequest:T,operationMeta:ee,examplesOf:y,knownVars:f,loadExample:b,savedExample:te,loadVariants:E,loadSequences:D}}function Fr(e){let t=e=>e&&(e.kind===`request`||e.kind===`sequence`);return t(e.default)?e.default:Object.values(e).find(t)}var Z=o,Ir,Q=Pr(o,{extension:async()=>{if(Ir&&Date.now()-Ir.at<3e4)return Ir.bridge;let e=await hr();return Ir={at:Date.now(),bridge:e},e}}),Lr=u===`static`;async function Rr(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`);M.value=Date.now()}function zr(){let e=globalThis.location?.hostname??``;return Ee({host:e,published:Lr,badge:E.value.badge})?p(`p`,{class:`powered-by`,children:p(`a`,{href:De(e),target:`_blank`,rel:`noopener`,children:`Powered by Specbook`})}):null}var Br=60,Vr=`Default`;function Hr(e){let t=k.value;return e.route.kind===`op`&&t.kind===`op`&&e.route.key===t.key||e.route.kind===`seq`&&t.kind===`seq`&&e.route.id===t.id}function Ur({e}){return p(`button`,{type:`button`,class:`op-row ${Hr(e)?`active`:``}`,onClick:()=>j(e.route),title:e.path?`${e.title}\n${e.path}`:e.title,children:[p(`span`,{class:`method ${e.method}`,children:e.method}),p(`span`,{class:`op-title`,children:[e.title,e.secured&&p(`span`,{class:`op-lock`,title:`Needs credentials`,children:p(ve,{})})]}),p(`span`,{class:`op-path`,children:e.path})]})}function Wr(e,t){let n=he.value.trim(),r=t.length<=1,i=r?t[0]?.id??``:me.value,a=v(()=>e.filter(e=>e.kind===`op`),[e]),o=v(()=>e.filter(e=>e.kind===`seq`),[e]);return{q:n,single:r,svc:i,shownOps:v(()=>{let e=i?a.filter(e=>e.service===i):a;return n?ge(e,n,500):e},[a,i,n]),shownFlows:v(()=>{let e=i&&!r?o.filter(e=>e.tags?.includes(i)):o;return n?ge(e,n,100):e},[o,i,n,r])}}function Gr({entries:e,services:t}){let n=x(null),r=x(null),[i,a]=g(new Map),{q:o,single:s,svc:c,shownOps:l,shownFlows:u}=Wr(e,t);h(()=>{let e=e=>{let t=e.target;e.key===`/`&&!/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)&&(e.preventDefault(),n.current?.focus())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]),h(()=>{let e=r.current;if(!e)return;let t=t=>{if(t.key!==`ArrowDown`&&t.key!==`ArrowUp`)return;let r=[...e.querySelectorAll(`.op-row, .flow-row`)],i=r.indexOf(document.activeElement);if(i<0)return;let a=t.key===`ArrowDown`?i+1:i-1;t.preventDefault(),a>=0&&a<r.length?r[a]?.focus():a<0&&n.current?.focus()};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[]);let d=v(()=>{let e=new Map;for(let t of l){let n=t.tag??`default`,r=c||s?n:`${t.service} · ${n}`;e.set(r,[...e.get(r)??[],t])}return[...e.entries()].sort(([e],[t])=>e.localeCompare(t))},[l,c,s]),f=v(()=>{let e=new Map;for(let t of u){let n=t.flowGroup?.trim()||Vr;e.set(n,[...e.get(n)??[],t])}let t=e=>e===Vr?0:1;return[...e.entries()].sort(([e],[n])=>t(e)-t(n)||e.localeCompare(n))},[u]),m=l.length>Br&&!o,_=(e,t)=>i.get(e)??(!m||t.some(Hr)),y=(e,t)=>{let n=new Map(i);n.set(e,!_(e,t)),a(n)};return p(`div`,{class:`catalog`,ref:r,children:[p(`div`,{class:`cat-top`,children:[!s&&p(`div`,{class:`pills`,role:`tablist`,"aria-label":`APIs`,children:[p(`button`,{type:`button`,role:`tab`,"aria-selected":c===``,class:`pill ${c===``?`on`:``}`,onClick:()=>me.value=``,children:`All`}),t.map(e=>p(`button`,{type:`button`,role:`tab`,"aria-selected":c===e.id,class:`pill ${c===e.id?`on`:``}`,onClick:()=>me.value=e.id,children:[e.id,` `,p(`span`,{class:`count`,children:e.ops})]}))]}),p(`div`,{class:`cat-filter-wrap`,children:[p(`input`,{ref:n,type:`text`,class:`cat-filter`,placeholder:c?`Filter ${c}`:`Filter operations and flows`,"aria-label":`Filter`,value:he.value,onInput:e=>he.value=e.target.value,onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),r.current?.querySelector(`.op-row, .flow-row`)?.focus()),e.key===`Escape`&&(he.value=``)}}),p(`kbd`,{class:`cat-hint`,title:`Focus the filter`,children:`/`})]})]}),f.length>0&&p(`section`,{class:`flows`,"aria-label":`Flows`,children:[p(`div`,{class:`flows-title`,children:[p(`span`,{class:`method flow`,children:`FLOW`}),p(`span`,{class:`muted small`,children:`Multi-step sequences you can run end to end`}),p(`span`,{class:`count`,children:u.length})]}),f.map(([e,t])=>{let n=`flows:${e}`,r=f.length===1,o=r||(i.get(n)??!0);return p(`div`,{class:`flow-group`,children:[!r&&p(`button`,{type:`button`,class:`group-head flow-head`,"aria-expanded":o,onClick:()=>{let e=new Map(i);e.set(n,!o),a(e)},children:[p(`span`,{class:`caret`,children:o?`▾`:`▸`}),` `,e,` `,p(`span`,{class:`count`,children:t.length})]}),o&&t.map(e=>p(`button`,{type:`button`,class:`op-row flow-row ${Hr(e)?`active`:``}`,onClick:()=>j(e.route),children:[p(`span`,{class:`flow-play`,"aria-hidden":`true`,children:`▶`}),p(`span`,{class:`op-title`,children:e.title})]}))]},n)})]}),d.map(([e,t])=>{let n=_(e,t);return p(`div`,{class:`op-group`,children:[p(`button`,{type:`button`,class:`group-head`,"aria-expanded":n,onClick:()=>y(e,t),children:[p(`span`,{class:`caret`,children:n?`▾`:`▸`}),` `,e,` `,p(`span`,{class:`count`,children:t.length})]}),n&&t.map(e=>p(Ur,{e}))]},e)}),d.length===0&&f.length===0&&p(`p`,{class:`muted cat-empty`,children:[o?`Nothing matches “${o}”.`:`No operations.`,` `,o&&p(`button`,{type:`button`,class:`link`,onClick:()=>he.value=``,children:`Clear the filter`})]})]})}function Kr({services:e}){let t=E.value;if(!t.ready)return p(`div`,{class:`overview`,"aria-busy":`true`});let n=e.reduce((e,t)=>e+t.ops,0),r=e.length===1?e[0]:void 0,i=t.title??t.name??(r?r.title??r.id:`${e.length} APIs · ${n.toLocaleString()} operations`),a=r?`${r.ops} ${r.ops===1?`operation`:`operations`}${r.version?` · v${r.version}`:``}`:t.name||t.title?`${e.length} APIs · ${n.toLocaleString()} operations`:void 0;return p(`div`,{class:`overview`,children:[t.logo&&p(`img`,{class:`overview-logo`,src:t.logo,alt:``,style:t.logoBackground?{background:t.logoBackground,padding:`10px 16px`,borderRadius:`10px`}:void 0}),t.title&&t.name&&p(`p`,{class:`overview-name`,children:t.name}),p(`h1`,{children:i}),t.tagline&&p(`p`,{class:`tagline`,children:t.tagline}),a&&p(`p`,{class:`muted`,children:a}),p(`p`,{class:`overview-hint`,children:`Choose an operation or flow on the left to read it and try it.`}),p(we,{}),p(`button`,{type:`button`,class:`btn primary overview-browse`,onClick:()=>j({kind:`browse`}),children:`Browse operations and flows`}),t.links.length>0&&p(`p`,{class:`overview-links`,children:t.links.map(e=>p(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,children:e.label}))}),p(`p`,{class:`muted overview-keys`,children:[p(`kbd`,{children:`⌘`}),` `,p(`kbd`,{children:`K`}),` jumps anywhere · `,p(`kbd`,{children:`/`}),` filters the list`]}),p(zr,{})]})}function qr(){let e=N.value,t=P.value.includes(e)?P.value:[e,...P.value],n=xe.value[e],r=e===`mock`?`mock`:n===`production`||n!==`sandbox`&&/prod/i.test(e)?`prod`:`live`,i=t.length>1;return p(`span`,{class:`env-badge ${r} ${i?`switch`:``}`,title:e===`mock`?`Environment: mock (no network)`:`Environment: ${e}. Requests go to the real API.`,children:[p(`span`,{class:`env-name`,children:e}),i&&p(`select`,{"aria-label":`Environment`,value:e,onChange:e=>N.value=e.target.value,children:t.map(e=>p(`option`,{value:e,title:Se.value[e],children:e}))})]})}var Jr={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};async function Yr(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 Xr(){let[e,t]=g(),[n,r]=g({}),[i,a]=g(!1),[o,s]=g(`environment`),[c,l]=g({}),[u,d]=g({name:``,value:``}),[f,m]=g(),_=N.value,y=()=>fetch(`/__specbook/environment?env=${encodeURIComponent(_)}`).then(e=>e.json()).then(t,()=>t(void 0));h(()=>{Lr||(y(),s(_===`mock`?`session`:`environment`),l({}))},[_]),h(()=>{Q.config(M.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;r(t)})},[]);let b=v(()=>_===`mock`?0:e?.secrets.filter(e=>!e.source).length??0,[e,_]);if(Lr||!e||!(e.secrets.length>0||Object.keys(e.vars).length>0||_!==`mock`))return null;let x=async e=>{m(void 0);try{await e(),await y()}catch(e){m(e instanceof Error?e.message:String(e))}},S=(e,t)=>x(async()=>{await Yr(`/__specbook/secret`,{name:e,value:t,scope:o,env:o===`shared`?void 0:_}),l(t=>({...t,[e]:``}))}),C=(e,t)=>x(()=>Yr(`/__specbook/var`,{env:_,name:e,value:t}));return p(`div`,{class:`envmenu`,children:[p(`button`,{type:`button`,class:`btn envmenu-btn`,"aria-expanded":i,title:`Variables and credentials for ${_}`,onClick:()=>a(!i),children:[p(`span`,{"aria-hidden":`true`,children:`⚙︎`}),` Environment settings`,b>0&&p(`span`,{class:`badge-missing`,children:b})]}),i&&p(`div`,{class:`envmenu-pop`,role:`dialog`,"aria-label":`Settings for ${_}`,children:[p(`header`,{class:`envmenu-head`,children:[p(`strong`,{children:_}),p(`span`,{class:`muted small`,children:_===`mock`?`mocks need no credentials`:`values apply to this environment`}),p(`span`,{class:`spacer`}),p(`button`,{type:`button`,class:`icon`,"aria-label":`Close`,onClick:()=>a(!1),children:`×`})]}),e.warnings.map(e=>p(`p`,{class:`envmenu-warn`,children:e})),f&&p(`p`,{class:`envmenu-warn`,children:f}),p(`section`,{children:[p(`h3`,{children:`Variables`}),p(`p`,{class:`muted small`,children:[`Shared with the team in `,p(`code`,{children:[`.specbook/environments/`,_,`.env`]}),`.`]}),Object.entries(e.vars).map(([e,t])=>p(`div`,{class:`envrow`,children:[p(`code`,{children:e}),p(`input`,{"aria-label":`Value of ${e}`,value:c[`var:${e}`]??t,onInput:t=>l({...c,[`var:${e}`]:t.target.value}),onBlur:()=>{let n=c[`var:${e}`];n!==void 0&&n!==t&&C(e,n)},onKeyDown:e=>e.key===`Enter`&&e.target.blur()}),p(`button`,{type:`button`,class:`icon`,"aria-label":`Remove ${e}`,onClick:()=>C(e,null),children:`×`})]})),p(`form`,{class:`envrow`,onSubmit:e=>{e.preventDefault(),u.name&&C(u.name,u.value).then(()=>d({name:``,value:``}))},children:[p(`input`,{placeholder:`name`,"aria-label":`New variable name`,value:u.name,onInput:e=>d({...u,name:e.target.value})}),p(`input`,{placeholder:`value`,"aria-label":`New variable value`,value:u.value,onInput:e=>d({...u,value:e.target.value})}),p(`button`,{type:`submit`,class:`btn`,disabled:!u.name,children:`Add`})]})]}),p(`section`,{children:[p(`h3`,{children:`Secrets`}),e.secrets.length===0?p(`p`,{class:`muted small`,children:[`None declared. Add `,p(`code`,{children:[`secrets: `,`{ NAME: {} }`]}),` to the config.`]}):p(T,{children:[p(`label`,{class:`envrow scope`,children:[p(`span`,{class:`muted small`,children:`Save to`}),p(`select`,{"aria-label":`Where to save secrets`,value:o,onChange:e=>s(e.target.value),children:[p(`option`,{value:`environment`,children:[_,`.secrets.env (remembered here)`]}),p(`option`,{value:`session`,children:`this session only`}),p(`option`,{value:`shared`,children:`all environments (secrets.local.env)`})]})]}),e.secrets.map(e=>p(`form`,{class:`secretrow`,onSubmit:t=>{t.preventDefault(),S(e.name,c[e.name]??``)},children:[p(`div`,{class:`secretrow-head`,children:[p(`span`,{children:n[e.name]??e.name}),p(`code`,{class:`muted small`,children:e.key}),p(`span`,{class:`src ${e.source?`set`:`missing`}`,children:e.source?Jr[e.source]:`missing`})]}),p(`div`,{class:`envrow`,children:[p(`input`,{type:`password`,autocomplete:`off`,"aria-label":`Value of ${e.name}`,placeholder:e.source?`•••••• (type to replace)`:`paste a value`,value:c[e.name]??``,onInput:t=>l({...c,[e.name]:t.target.value})}),p(`button`,{type:`submit`,class:`btn`,disabled:!c[e.name],children:`Save`}),e.source&&e.source!==`process`&&p(`button`,{type:`button`,class:`link`,onClick:()=>S(e.name,``),title:`Remove the value from the selected place`,children:`Clear`})]})]}))]})]})]})]})}var Zr=`https://github.com/specbook-dev/specbook`;function Qr(){return globalThis.__SPECBOOK_VIEWER__?.source?p(`a`,{class:`btn gh-star`,href:Zr,target:`_blank`,rel:`noopener`,title:`Specbook's source is on GitHub`,children:[p(be,{}),p(`span`,{class:`gh-label`,children:`GitHub`})]}):null}var $r=`specbook:list-width`,ei=()=>Math.round(innerWidth*.55);function ti(){try{let e=Number(localStorage.getItem($r));return e>=280?e:void 0}catch{return}}var $=w(ti());function ni(e){$.value=e===void 0?void 0:Math.round(Math.max(280,Math.min(ei(),e)));try{$.value===void 0?localStorage.removeItem($r):localStorage.setItem($r,String($.value))}catch{}}function ri(){let e=e=>{e.preventDefault(),document.body.classList.add(`resizing`);let t=e=>ni(e.clientX),n=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,t),removeEventListener(`pointerup`,n)};addEventListener(`pointermove`,t),addEventListener(`pointerup`,n)},t=()=>$.value??document.querySelector(`.list-col`)?.offsetWidth??360;return p(`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:e,onDblClick:()=>ni(void 0),onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),ni(t()-24)):e.key===`ArrowRight`&&(e.preventDefault(),ni(t()+24))}})}function ii({entries:e}){let[t,n]=g(``),[r,i]=g(0),a=x(null),o=A.value;h(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`?(e.preventDefault(),A.value=!A.value):e.key===`Escape`&&(A.value=!1)};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[]),h(()=>{o&&(n(``),i(0),setTimeout(()=>a.current?.focus(),0))},[o]);let s=v(()=>ge(e,t,30),[e,t]);if(!o)return null;let c=e=>{e&&(A.value=!1,j(e.route))};return p(`div`,{class:`palette-backdrop`,children:[p(`button`,{type:`button`,class:`palette-dismiss`,"aria-label":`Close`,onClick:()=>A.value=!1}),p(`div`,{class:`palette`,role:`dialog`,"aria-label":`Jump to`,children:[p(`input`,{ref:a,type:`text`,placeholder:`Jump to a sequence or operation…`,value:t,onInput:e=>{n(e.target.value),i(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),i(Math.min(s.length-1,r+1))):e.key===`ArrowUp`?(e.preventDefault(),i(Math.max(0,r-1))):e.key===`Enter`&&c(s[r])}}),p(`ul`,{children:[s.map((e,t)=>p(`li`,{children:p(`button`,{type:`button`,class:t===r?`sel`:``,onMouseEnter:()=>i(t),onClick:()=>c(e),children:[p(`span`,{class:`p-title`,children:e.title}),p(`span`,{class:`muted`,children:e.kind===`seq`?`Sequence`:e.group})]})})),s.length===0&&p(`li`,{class:`muted pad`,children:[`Nothing matches “`,t,`”`]})]})]})]})}function ai(){let e=globalThis.__SPECBOOK_VIEWER__,[t,n]=g(!1),[r,i]=g(!1);if(!e?.source)return null;k.value;let a=S(e.source),o=a.ok?y({origin:location.origin,pathname:location.pathname,hash:location.hash},a.spec,e.open.title):void 0;return p(`div`,{class:`share`,children:[p(`button`,{type:`button`,class:`btn`,"aria-expanded":t,"aria-haspopup":`true`,"aria-label":`Share`,onClick:()=>n(!t),children:[p(ye,{}),p(`span`,{class:`share-label`,children:`Share`})]}),t&&p(`div`,{class:`share-pop`,role:`menu`,children:o?p(T,{children:[p(`input`,{class:`share-link`,readOnly:!0,value:o.link,"aria-label":`Link to this view`,onFocus:e=>e.target.select()}),p(`div`,{class:`share-actions`,children:[p(`button`,{type:`button`,class:`btn primary`,onClick:async()=>{if(o)try{await navigator.clipboard.writeText(o.link),i(!0),setTimeout(()=>i(!1),1500)}catch{}},children:r?`Copied`:`Copy link`}),typeof navigator.share==`function`&&p(`button`,{type:`button`,class:`btn`,onClick:()=>void navigator.share({title:o.title,url:o.link}).catch(()=>{}),children:`Share…`})]}),p(`ul`,{class:`share-targets`,children:o.targets.map(e=>p(`li`,{children:p(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.label})}))})]}):p(`p`,{class:`muted`,children:a.ok?``:a.reason})})]})}var oi={auto:`Theme: follows your system. Click for light.`,light:`Theme: light. Click for dark.`,dark:`Theme: dark. Click to follow your system.`},si=({mode:e})=>p(`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:[e===`light`&&p(T,{children:[p(`circle`,{cx:`12`,cy:`12`,r:`4`}),p(`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`})]}),e===`dark`&&p(`path`,{d:`M20 14.5A8.5 8.5 0 0 1 9.5 4 8.5 8.5 0 1 0 20 14.5z`}),e===`auto`&&p(T,{children:[p(`circle`,{cx:`12`,cy:`12`,r:`8.5`}),p(`path`,{d:`M12 3.5v17a8.5 8.5 0 0 0 0-17z`,fill:`currentColor`,stroke:`none`})]})]});function ci(){let e=_.value;return p(`button`,{type:`button`,class:`icon theme-toggle`,title:oi[e],"aria-label":oi[e],"data-theme-mode":e,onClick:m,children:p(si,{mode:e})})}var li=globalThis.__SPECBOOK_VIEWER__?.source?b:void 0;{let e=Object.keys(Z.manifests);oe(e.length===1?e[0]:void 0)}var ui=w([]);function di(){let[e,t]=g(),n=k.value.kind===`op`||k.value.kind===`seq`;return h(()=>{n&&!e&&te(()=>import(`./Host-CSrM9wY1.js`).then(t),__vite__mapDeps([0,1,2,3,4]),import.meta.url)},[n,e]),n?e:void 0}function fi(){let[e,t]=g({}),[n,r]=g(void 0),[i,a]=g(!1);h(()=>{let e=()=>{k.value=ue(location.hash)};return addEventListener(`hashchange`,e),Q.config(M.value).then(async e=>{ui.value=Object.keys(e.faker?.locales??{}),e.faker?.default&&(Ce.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)};E.value=o,ae(t,o,r.length===1?r[0]?.title??`Specbook`:`Specbook`)}).catch(()=>{E.value={...E.value,ready:!0}}).finally(()=>{Q.loadVariants(Z.requests,M.value).then(t);let e=Z.sequences.filter(e=>Z.unresolvedSequences.includes(e.file));e.length&&Q.loadSequences(e,M.value).then(r)}),Q.environments(M.value).then(e=>{P.value=e}),Q.environmentRisks(M.value).then(e=>{xe.value=e}),Q.environmentNotes(M.value).then(e=>{Se.value=e}),()=>removeEventListener(`hashchange`,e)},[]);let o=x(k.value);h(()=>{o.current!==k.value&&(o.current=k.value,a(!1))},[k.value]),h(()=>{if(!i)return;let e=e=>e.key===`Escape`&&a(!1);return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[i]);let s=Object.keys(Z.manifests).length>1,c=v(()=>{let t=[],r=[...Object.values(Z.sequenceMeta),...(n??[]).map(e=>({...e.seq.meta}))];for(let e of r)t.push({kind:`seq`,route:{kind:`seq`,id:e.id},title:e.title,group:e.tags?.[0]??`sequence`,tags:e.tags,flowGroup:e.group,description:e.description,hay:`${e.description??``} ${(e.tags??[]).join(` `)}`});for(let n of Object.values(Z.manifests))for(let r of n.operations){let i=`${n.service}/${r.id}`,a=(e[i]??[]).map(e=>e.name).join(` `);t.push({kind:`op`,route:{kind:`op`,key:i},title:r.summary?.replace(/\.$/,``)||r.path,group:`${s?`${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 t},[n,e,s]),l=k.value,u=l.kind===`op`?pi(l.key):void 0,d=l.kind===`seq`?l.id:void 0,[f,m]=g();h(()=>{if(!d)return;let e=Z.sequenceMeta[d]?.file;if(e){let t=Z.sequences.filter(t=>t.file===e);Q.loadSequences(t,M.value).then(e=>m(e[0]))}else m(n?.find(e=>e.seq.meta.id===d))},[d,n,M.value]);let _=f?.seq.meta.id===d?f:void 0,y=di(),b=()=>j(pe(k.value)),S=v(()=>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=v(()=>{if(l.kind!==`op`&&l.kind!==`seq`)return{};let e=c.find(e=>e.route.kind===`op`&&l.kind===`op`&&e.route.key===l.key||e.route.kind===`seq`&&l.kind===`seq`&&e.route.id===l.id);if(!e)return{};let t=c.filter(t=>e.kind===`seq`?t.kind===`seq`:t.service===e.service&&t.tag===e.tag),n=t.indexOf(e),r=e=>e?()=>j({...e.route,play:``}):void 0;return{prev:r(t[n-1]),next:r(t[n+1])}},[c,l.kind===`op`?l.key:l.kind===`seq`?l.id:``]),w=e=>j(l.kind===`op`?{kind:`op`,key:l.key,play:e.example??l.play??``,tab:e.tab}:l.kind===`seq`?{kind:`seq`,id:l.id,play:``,tab:e.tab}:l);return p(`div`,{class:`app`,style:$.value?{"--sb-list-w":`${$.value}px`}:void 0,children:[p(`header`,{class:`header`,children:[p(`button`,{type:`button`,class:`brand`,onClick:()=>j({kind:`home`}),children:[(E.value.logo??li)&&p(`img`,{class:`brand-logo`,src:E.value.logo??li,alt:``,style:E.value.logoBackground?{background:E.value.logoBackground,padding:`3px 6px`,borderRadius:`4px`}:void 0}),p(`span`,{class:`brand-name`,children:E.value.name??`Specbook`})]}),p(`button`,{type:`button`,class:`palette-btn`,onClick:()=>A.value=!0,children:[p(`span`,{children:`Jump to an operation or flow…`}),p(`kbd`,{children:`⌘K`})]}),p(`span`,{class:`spacer`}),p(`span`,{class:`header-env`,children:p(qr,{})}),p(`button`,{type:`button`,class:`menu-btn icon`,"aria-label":`Settings`,"aria-expanded":i,onClick:()=>a(!i),children:`⋯`}),p(`div`,{class:`header-controls ${i?`open`:``}`,children:[Z.loadFaker&&p(`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:[p(`label`,{class:`row`,children:[`Synthetic data`,p(`select`,{"aria-label":`Synthetic data`,value:F.value===void 0?`random`:`fixed`,onChange:e=>{F.value=e.target.value===`fixed`?F.value??42:void 0},children:[p(`option`,{value:`random`,children:`New each run`}),p(`option`,{value:`fixed`,children:`Fixed`})]})]}),F.value!==void 0&&p(`input`,{type:`number`,class:`seed-input`,"aria-label":`Seed number`,title:`The same number gives the same data every run`,value:F.value,onInput:e=>{let t=e.target.valueAsNumber;F.value=Number.isFinite(t)?t:void 0}})]}),ui.value.length>1&&p(`label`,{class:`row muted`,children:[`locale`,p(`select`,{value:Ce.value??``,onChange:e=>Ce.value=e.target.value||void 0,children:ui.value.map(e=>p(`option`,{value:e,children:e}))})]}),p(Xr,{}),p(`label`,{class:`row`,children:[`Environment`,p(`select`,{value:N.value,onChange:e=>N.value=e.target.value,children:P.value.map(e=>p(`option`,{value:e,title:Se.value[e],children:e}))})]}),p(Qr,{}),p(ai,{}),p(ci,{})]})]}),p(`div`,{class:`layout`,"data-view":l.kind===`home`?`splash`:`list`,children:[p(`nav`,{class:`list-col`,"aria-label":`Operations and flows`,children:p(Gr,{entries:c,services:S})}),p(ri,{}),p(`main`,{class:`stage`,children:(l.kind===`home`||l.kind===`browse`)&&p(Kr,{services:S})})]}),p(ii,{entries:c}),y&&l.kind===`op`&&u&&p(y.Host,{kind:`op`,modal:!1,service:u.service,op:u.op,variants:e[l.key]??[],example:l.play??``,tab:l.tab,onNavigate:w,onPrev:C.prev,onNext:C.next,onClose:b}),y&&l.kind===`seq`&&_&&p(y.Host,{kind:`seq`,modal:!1,info:_,tab:l.tab,onNavigate:w,onPrev:C.prev,onNext:C.next,onClose:b})]})}function pi(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 mi=r({});C(),(globalThis.__SPECBOOK_VIEWER__===void 0?ee():Promise.resolve(!1)).then(e=>{e||f(p(fi,{}),document.getElementById(`app`))});export{P as C,_e as D,M as E,j as O,Se as S,F as T,Sn as _,Z as a,It as b,wr as c,J as d,yn as f,bn as g,vn as h,Lr as i,Cr as l,fn as m,qr as n,Rr as o,_n as p,Q as r,Er as s,mi as t,Sr as u,xn as v,Ce as w,N as x,Lt as y};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./main-38QGGpNT.js","./registry-ChKCFBt1.js","./panel-C8Ve3LeS.js","./panel-C-vBZrep.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e=`specbook-oauth`;function t(t={}){let n=t.stripWhenUnclaimed??!0,r=globalThis.location;if(!r||typeof BroadcastChannel>`u`&&!globalThis.opener)return Promise.resolve(!1);let i=new URLSearchParams(r.search),a=i.get(`state`);if(!a||!(i.has(`code`)||i.has(`error`)))return Promise.resolve(!1);let o={type:`callback`,state:a,...i.get(`code`)?{code:i.get(`code`)}:{},...i.get(`error`)?{error:i.get(`error`)}:{},...i.get(`error_description`)?{description:i.get(`error_description`)}:{}},s=()=>history.replaceState(null,``,r.pathname+r.hash);return n&&s(),new Promise(t=>{let n=typeof BroadcastChannel>`u`?null:new BroadcastChannel(e),i=!1,c=e=>{i||(i=!0,clearTimeout(f),n?.close(),removeEventListener(`message`,d),t(e))},l=()=>{i||(s(),c(!0),document.body.textContent=`Signed in. You can close this window.`,window.close())},u=e=>e?.type===`ack`&&e.state===a,d=e=>{e.origin===r.origin&&u(e.data)&&l()},f=setTimeout(()=>c(!1),1500);n&&(n.onmessage=e=>u(e.data)&&l()),addEventListener(`message`,d),n?.postMessage(o);try{window.opener?.postMessage(o,r.origin)}catch{}})}var n=new URL(`worker-ClGb0tE1.js`,import.meta.url).href;function r(){let e=new URL(n,import.meta.url);if(e.origin===location.origin)return new Worker(e,{type:`module`});let t=new Blob([`import ${JSON.stringify(e.href)}`],{type:`text/javascript`});return new Worker(URL.createObjectURL(t),{type:`module`})}var i=class{worker;next=1;pending=new Map;constructor(){this.worker=r(),this.worker.addEventListener(`message`,e=>{let t=e.data,n=this.pending.get(t.id);if(n){if(`progress`in t)return n.onProgress?.(t.progress);this.pending.delete(t.id),t.ok?n.resolve(t.result):n.reject(Object.assign(Error(t.error),{code:t.code}))}})}call(e,t){let n=this.next++;return{id:n,promise:new Promise((r,i)=>{this.pending.set(n,{resolve:r,reject:i,onProgress:t}),this.worker.postMessage({...e,id:n})})}}open(e,t){let{id:n,promise:r}=this.call({type:`open`,source:e},t);return{promise:r,cancel:()=>this.worker.postMessage({type:`cancel`,id:n})}}async bundle(e){let t=await this.call({type:`bundle`,opId:e}).promise;return JSON.parse(t)}async definitions(){return JSON.parse(await this.call({type:`definitions`}).promise)}},a=`modulepreload`,o=function(e,t){return new URL(e,t).href},s={},c=function(e){return e.pathname.endsWith(`.css`)},l=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},u=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),u=i?.nonce||i?.getAttribute(`nonce`);function d(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function f(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=d(t.map(t=>{t=o(t,n);let r=f(t),i=c(r);return l(s,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:a,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,u&&t.setAttribute(`nonce`,u),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};async function d(e){let{worker:t}=e,n={open:e.result,baseUrl:e.baseUrl,source:e.shareable===!1?void 0:e.source.kind===`url`?{kind:`url`,url:e.source.url}:{kind:`text`},bundle:e=>t.bundle(e),definitions:()=>t.definitions()};globalThis.__SPECBOOK_VIEWER__=n,e.setTitle!==!1&&(document.title=`${e.result.title} · Specbook`),await u(()=>import(`./main-38QGGpNT.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3]),import.meta.url),f()}function f(){navigator.connection?.saveData||(window.requestIdleCallback??(e=>setTimeout(e,1500)))(()=>{u(()=>import(`./registry-ChKCFBt1.js`).then(e=>e.n).then(e=>e.loadFaker()),[],import.meta.url).catch(()=>{})})}export{t as a,e as i,u as n,i as r,d as t};
|