@specbook/ui 0.1.0 → 0.3.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-Cq-4gDuM.js +41 -0
- package/dist-viewer/assets/index-BBlFcQUE.js +1 -0
- package/dist-viewer/assets/main-CSkB-O_8.js +14 -0
- package/dist-viewer/assets/mount-DfwluJy4.js +2 -0
- package/dist-viewer/assets/panel-9eYU7Gz6.js +1 -0
- package/dist-viewer/assets/panel-hNOojwiM.css +1 -0
- package/dist-viewer/assets/registry-DIHX11uY.js +2 -0
- package/dist-viewer/assets/worker-BmvGpsJS.js +181 -0
- package/dist-viewer/index.html +4 -4
- package/dist-viewer/specbook.js +1 -1
- package/package.json +7 -5
- package/src/app.tsx +71 -13
- package/src/branding.ts +12 -4
- package/src/components/Catalog.tsx +128 -51
- package/src/components/EnvBadge.tsx +24 -4
- package/src/components/EnvironmentMenu.tsx +237 -127
- package/src/components/Fields.tsx +18 -1
- package/src/components/NewEnvironmentDialog.tsx +118 -0
- package/src/components/Palette.tsx +7 -2
- package/src/custom-environments.ts +63 -0
- package/src/embed/panel.tsx +287 -44
- package/src/embed/styles.ts +2 -0
- package/src/embed/target.ts +82 -0
- package/src/embed/theme.ts +75 -0
- package/src/embed.ts +44 -15
- package/src/engine.ts +416 -32
- package/src/environment-list.ts +16 -0
- package/src/main.tsx +14 -1
- package/src/nav.ts +12 -1
- package/src/oauth-callback.ts +87 -0
- package/src/oauth.ts +195 -0
- package/src/panel/Body.tsx +27 -4
- package/src/panel/Checks.tsx +79 -0
- package/src/panel/CodeSample.tsx +16 -8
- package/src/panel/Combo.tsx +52 -13
- package/src/panel/ControlsGrid.tsx +54 -9
- package/src/panel/ErrorBoundary.tsx +36 -0
- package/src/panel/Host.tsx +14 -2
- package/src/panel/OAuthSignIn.tsx +167 -0
- package/src/panel/Panel.tsx +50 -13
- package/src/panel/ParamGrid.tsx +15 -8
- package/src/panel/RequestPanel.tsx +93 -36
- package/src/panel/RequestView.tsx +2 -1
- package/src/panel/ResponseView.tsx +25 -14
- package/src/panel/SecretsBar.tsx +43 -9
- package/src/panel/SequenceDocs.tsx +7 -6
- package/src/panel/SequencePanel.tsx +124 -32
- package/src/panel/announce.ts +17 -0
- package/src/panel/icons.tsx +9 -0
- package/src/panel/short.ts +24 -0
- package/src/routing.ts +0 -9
- package/src/runtime.ts +19 -1
- package/src/secrets.ts +4 -2
- package/src/storage.ts +58 -0
- package/src/store.ts +10 -0
- package/src/styles/app.css +69 -6
- package/src/styles/embed.css +116 -0
- package/src/styles/panel.css +277 -2
- package/src/viewer/embed.ts +5 -0
- package/src/viewer/main.tsx +5 -1
- package/src/viewer/manifests.ts +2 -0
- package/src/viewer/protocol.ts +9 -0
- package/src/viewer/registry-data.ts +4 -0
- package/src/viewer/registry.ts +48 -3
- package/src/viewer/worker.ts +20 -7
- package/src/virtual.d.ts +8 -0
- 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/panel-Coi9H1nv.css +0 -1
- package/dist-viewer/assets/registry-DI74Wtj8.js +0 -2
- package/dist-viewer/assets/worker-Dw3Ps3hk.js +0 -181
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{c as e,r as t}from"./registry-DI74Wtj8.js";import{_ as n,a as r,d as i,f as a,h as o,m as s,p as c,u as l}from"./panel-CoQ6iQpX.js";import{_ as u,a as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,u as T,v as E,y as D}from"./main-uV4JzQPd.js";var O=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function k(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:O(t),enabled:!0})))}function A(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 j(e){return typeof e!=`object`||!e?[]:p(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var M=/[^[\]]+|\[\]/g;function N(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?N(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?N(o,i,n):o===void 0?n:[...[].concat(o),n],a}function P(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=N(t,n.match(M)??[n],a&&m(a)?a:r));return t}var F=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,I=e=>new RegExp(F.source).test(e),L=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function R(e){let t=[],n=0;for(let r of e.matchAll(F))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?L(r[1]):`SESSION_${L(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var ee=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${te(e)}`);return t.length?`?${t.join(`&`)}`:``};function te(e){return R(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function z(e){if(m(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var ne=e=>e.name??e.file??`file`,re=e=>`'${e.replace(/'/g,`'\\''`)}'`;function B(e){return I(e)?`"${R(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:re(e)}function ie(e){let t=e.encoding??`json`,n=[B(`${e.url}${ee(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 p(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}=@${ne(n)}`)}`):s.push(`-F ${B(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${B(`@${z(o)?ne(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 ae=/^[A-Za-z_$][\w$]*$/;function V(e){return I(e)?`\`${R(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 oe=e=>ae.test(e)?e:V(e);function se(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}${se(e,n)},`).join(`
|
|
3
|
-
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${oe(e)}: ${se(t,n)},`).join(`
|
|
4
|
-
`)}\n${t}}`}function ce(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(${se(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=p(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${se(Object.fromEntries(t),` `)})`:`new URLSearchParams(${se(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=ne(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)?ne(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}${ee(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${V(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${oe(e)}: ${V(t)},`).join(`
|
|
5
|
-
`)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],m=d.length===0?`const res = await fetch(${V(u)})`:`const res = await fetch(${V(u)}, {\n${d.join(`
|
|
6
|
-
`)}\n})`;return[...f,...s,m,`console.log(res.status, await res.text())`].join(`
|
|
7
|
-
`)}function le(e,t){return e===`curl`?ie(t):ce(t)}var ue=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],de=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function H(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 fe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
8
|
-
`).split(`
|
|
9
|
-
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${H(de(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${H(de(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>${de(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}>${H(de(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>${H(de(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function pe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function me(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function he(e){return e?H(de(e)):``}function U(e,t=300){let n=me(e);if(!n)return``;let r=pe(n);return r.length>t?de(`${r.slice(0,t-1).trimEnd()}…`):he(n)}var ge=/^\s*\{\{[^}]+\}\}\s*$/,_e=e=>typeof e==`string`&&ge.test(e);function ve(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var ye=[`title`,`description`,`default`,`examples`,`deprecated`];function W(e,t){let n={...e};for(let e of ye)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function be(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=W(r,n)}return n}function G(e,t,n=0){let r=be(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!ve(e));if(e.length===1||e.length>1)return G(W(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return G(W(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=G(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of ye)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 K(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 xe(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function Se(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 Ce(e,t){let n=G(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function we(e,t,n){let r=G(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 q=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Te(e,t,n){let r=be(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!ve(e));if(!i?.length)return G(r,n);let a=q(t);return G(W(i.find(e=>{let t=K(G(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Ee(e,t,n,r={},i=``,a=0){if(!t||a>12||_e(e))return[];let o=Te(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&K(o)!==`null`&&K(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${K(o)}, got null`}),s;let u=K(o),d=q(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(...Ee(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ee(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(...Ee(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 De=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Oe(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 J(e,t,n){let r=e;for(let e of t){if(!r)return;r=we(r,e,n)}return r}var ke={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`},Ae=e=>ke[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),je=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,Me=new Set([`path`,`query`,`headers`,`data`]),Ne=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function Pe(e,t){return[e,...Ne(t)].join(`.`)}function Fe(e){let t=Ne(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&Me.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var Ie=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function Le(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?Fe(Ie(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 Re=60;function ze(e,t){let n=K(e);return n===`array`?`${K(G(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function Be(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Ce(e,t)){let e=G(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:ze(e,t),required:a.required,description:xe(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=K(e)===`array`?G(e.items,t):e;K(s)===`object`&&i.push(...Be(s,t,n+1,o))}return i}function Ve({schema:e,defs:t,section:n=`data`,notes:i}){let a=Be(e,t);return a.length===0?null:r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`Field`}),r(`th`,{children:`Type`}),r(`th`,{children:`Description`})]})}),r(`tbody`,{children:[a.slice(0,Re).map(e=>r(`tr`,{children:[r(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[r(`code`,{children:e.name.split(`.`).pop()}),e.required&&r(`span`,{class:`req`,title:`required`,children:`*`})]}),r(`td`,{children:r(`span`,{class:`chip`,children:e.type})}),r(`td`,{children:[r(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:U(e.description,220)}}),i?.get(Pe(n,e.name))&&r(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(Pe(n,e.name))}}),e.enum&&r(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>r(`code`,{children:e}))]})]})]})),a.length>Re&&r(`tr`,{children:r(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-Re,` more fields in the spec`]})})]})]})}var He={intro:``,notes:new Map,replace:!1,found:!1};function Ue(e){let[t,n]=s(),[r,a]=s(!1),o=d.docs.find(t=>t.operation===e);return i(()=>{let e=!0;return n(void 0),a(!o),o?.load().then(t=>e&&n(t)).catch(()=>{}).finally(()=>e&&a(!0)),()=>{e=!1}},[e,o]),c(()=>!o||t===void 0?{...He,loaded:r}:{...Le(t),replace:!!o.replace,found:!0,loaded:r},[t,o,r])}var We=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],Ge=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function Ke(e,t,n){return Promise.all([Ge(d.operationDocs[e]?.().then(e=>e.default)),Ge(d.schemas[e]?.().then(e=>e.default)),Ge(d.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>Ge(d.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 qe({variant:e,html:t}){return t?r(`section`,{class:`saved-note-doc`,children:[r(`h2`,{children:[`Saved request `,r(`code`,{children:e.name})]}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]}):null}function Je({service:e,op:t,variants:a=[],onTry:o}){let c=`${e}/${t.id}`,[l,u]=s(),d=a.map(e=>e.file).join(`
|
|
13
|
-
`);i(()=>{let t=!0;return u(void 0),Ke(c,e,d?d.split(`
|
|
14
|
-
`):[]).then(e=>t&&u(e)),()=>{t=!1}},[c,e,d]);let f=Ue(c),p=!!l&&f.loaded,{long:m,req:h,defs:g}=l??{saved:{}},_=h?G(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return r(`article`,{class:`doc`,"data-op":c,children:[r(`div`,{class:`doc-intro`,children:[r(`span`,{class:`method ${t.method}`,children:t.method}),` `,r(`code`,{children:t.path}),r(`span`,{class:`spacer`}),r(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&r(n,{children:[!(f.found&&f.replace)&&m?.description&&r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:fe(m.description)}}),f.intro&&r(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),a.map(e=>r(qe,{variant:e,html:l?.saved[e.file]},e.file)),We.map(([e,t])=>v(e)?r(`section`,{children:[r(`h2`,{children:[t,` parameters`]}),r(Ve,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&r(`section`,{children:[r(`h2`,{children:`Request body`}),r(Ve,{schema:y,defs:g,section:`data`,notes:f.notes})]}),t.statuses.length>0&&r(`section`,{children:[r(`h2`,{children:`Responses`}),r(`ul`,{class:`statuses`,children:t.statuses.map(e=>r(`li`,{children:[r(`span`,{class:`state-badge ${je(e)}`,children:e}),` `,Ae(e)]}))})]}),(m?.examples.length??0)>1&&r(`section`,{children:[r(`h2`,{children:`Examples`}),r(`ul`,{class:`examples`,children:m?.examples.map(e=>r(`li`,{children:r(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var Ye=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Xe({title:e,subtitle:t,flush:o,modal:s=!0,onPrev:c,onNext:l,onClose:u,children:d}){let f=a(null);return i(()=>{let e=f.current?.getRootNode()?.activeElement;return s&&f.current?.focus(),()=>e?.focus?.()},[s]),i(()=>{let e=f.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`&&u(),e.key!==`Tab`||!s||!f.current)return;let t=[...f.current.querySelectorAll(Ye)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=f.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===f.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[u,s]),r(n,{children:[s&&r(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:u}),r(`section`,{class:`panel ${s?``:`docked`}`,part:`panel`,"aria-label":e,"aria-modal":s?!0:void 0,role:s?`dialog`:`complementary`,tabIndex:-1,ref:f,children:[r(`header`,{class:`panel-head`,part:`header`,children:[r(`div`,{class:`panel-title`,children:[r(`h2`,{children:e}),t&&r(`div`,{class:`muted small`,children:t})]}),r(`span`,{class:`spacer`}),s&&y.value.length>1&&r(`label`,{class:`row`,children:[r(`span`,{class:`muted`,children:`Environment`}),r(`select`,{value:S.value,onChange:e=>S.value=e.target.value,children:y.value.map(e=>r(`option`,{value:e,children:e}))})]}),(c||l)&&r(`span`,{class:`stepper`,children:[r(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!c,onClick:c,children:`↑`}),r(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!l,onClick:l,children:`↓`})]}),r(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:u,children:`×`})]}),r(`div`,{class:`panel-body ${o?`flush`:``}`,children:d})]})]})}function Ze(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:J(e,i,t);if(!a)return;let o=G(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:K(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=J(e,i.slice(0,-1),t),l=K(o),u=l===`array`?K(G(o.items,t)):void 0;return{path:De(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Ce(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:xe(o),parent:c?xe(G(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Qe(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function $e(e,t,n,r){let i=e&&t?.get(Pe(n,r));return e&&i?{...e,note:i}:e}var et={},tt=Symbol(),nt=Symbol(),rt=e=>typeof e==`string`?it[e]:e,it={plain:et,plaintext:et,text:et,txt:et},at=(e,t)=>(t[nt]||ot)(e,t),ot=(e,t)=>{for(var n=[e],r,i=[],a=0;r=rt(t[tt]);)delete t[tt],Object.assign(t,r);for(pt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},st=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),ct=`</span>`,lt=``,ut=``,dt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=ft(n);return t},ft=e=>{if(e instanceof mt){var{type:t,alias:n,content:r}=e,i=lt,a=ut,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;ut+=ct,lt+=o;var s=ft(r);return lt=i,ut=a,o+s+ct}return typeof e==`string`?(e=st(e,/</g,`<`),ut&&e.includes(`
|
|
15
|
-
`)?e.replace(/\n/g,ut+`
|
|
16
|
-
`+lt):e):dt(e)},pt=(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=rt(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 mt)){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 mt)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 mt(a,d?at(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof mt?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&&(pt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function mt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var ht=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=St(),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=at(o=_.value,it[r]||{}),O(`tokenize`,u,r,o);let e=dt(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),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=bt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},A={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Ct=null,c=!1,w()}),Y(_,`focus`,()=>{Ct=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),yt(e)?.append(p),t&&x(t),A},gt=`u`>typeof window?document:null,_t=gt?.createElement(`div`),vt=(e,t)=>(_t&&(_t.innerHTML=e,t=_t.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),yt=e=>typeof e==`string`?gt.querySelector(e):e,bt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
19
|
-
`,t)+1)&&t<=n;r++);return r},xt={},St=vt(`<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()},Ct;gt&&Y(gt,`selectionchange`,()=>Ct?.());var wt=(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) + ${Bt&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},Tt=(e,t)=>t?e.lastIndexOf(`
|
|
20
|
-
`,t-1)+1:0,Et=(e,t)=>(t=e.indexOf(`
|
|
21
|
-
`,t))+1?t:e.length,Dt=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),Ot=(e,t,n,r)=>Dt(e.textarea,t,n,r),kt=(e,t)=>parseFloat(getComputedStyle(e)[t]),At=(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}},jt=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var Mt,Nt=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),Pt=(e,t)=>e.slice(Tt(e,t),t),Ft=(e,t,n=t)=>[e.slice(t=Tt(e,t),n=Et(e,n)).split(`
|
|
22
|
-
`),t,n],It=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[bt(a,0,i)],s=gt.createTreeWalker(o,5),c=s.lastChild(),l=Et(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}},Lt=(e,t)=>It(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;Mt=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=Bt&&!s[r??Mt[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,Mt[2]),l()})),Vt||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),Bt||Vt?(c&&(o.selectionEnd--,t=t.slice(0,-1)),Vt&&(t+=`
|
|
23
|
-
`),gt.execCommand(t?`insertHTML`:`delete`,!1,st(t,/</g,`<`)),c&&o.selectionStart++):gt.execCommand(t?`insertText`:`delete`,!1,t),Mt=0},Rt=(e,t,n=t,r)=>{let i=e.textarea,a=Dt(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},zt=gt?navigator.userAgent:``,Q=gt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,Bt=/Chrome\//.test(zt),Vt=!Bt&&/AppleWebKit\//.test(zt),Ht=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,Ut=(e,t)=>e.lines[0].append(t),Wt=vt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),Gt=vt(`<span> `),Kt=vt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),qt=(e,t,n=!0)=>{let r=Kt(),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||Ut(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 Jt=(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(``,Gt()),jt(r[o],n.slice(a,a=t[o++])),jt(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();jt(r[s],n.slice(a))},Yt=0,Xt=vt(`<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>`),Zt=vt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),Qt={},$t=(e,t)=>{e.forEach(e=>Qt[e]=t)},en=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=Xt(),O=Wt(),[k,A]=qt(n,D),[j,M]=D.children,[N,P,F]=M.children,I=j.firstChild,L=I.id=`pce-ac-`+Yt++,R=I.children,ee=[],te=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},z=()=>{f=kt(R[0],`height`)},ne=e=>{let t=o[e+d],[n,r,i]=R[e].children,a=t[4],s=a.icon||`variable`;Jt(r,t[1],a.label),jt(i.firstChild.firstChild,a.detail||``),ee[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${ee[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),R[e].setAttribute(`aria-posinset`,e+d)},re=()=>{z();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,ae(),B()},B=()=>{let e=l;l=R[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),P.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(P),b=!b,pe()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},ie=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,re()},ae=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)ne(e++);I.style.paddingTop=d*f+`px`},V=e=>oe(o[e][4],o[e][2],o[e][3]),oe=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
|
-
`+Pt(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||Ut(n,O),p=o,m=0,g=n.value.length,ue(),h=E(),se()):n.extensions.cursor?.scrollIntoView()},se=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},ce=e=>{m+=e,Rt(n,p[m],p[m+1]),se()},le=()=>{O.remove(),p=null},ue=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),Jt(O,e.flat(),n.value)},de=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=kt(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},H=()=>{D.className=`pce-ac-wrapper pce-ac-${de()}`},fe=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,F.textContent=``,F.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,L+`d`))},pe=()=>{b?M.remove():fe(),b=!b},me=t.startQuery=t=>{let[a,l,p]=E(),m=Lt(n,u=p<`f`?a:l),h=Qt[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=Pt(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;)R[e].setAttribute(`aria-setsize`,s),ne(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}I.style.paddingTop=``,I.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,B(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,H(),T.setAttribute(`aria-controls`,L),T.setAttribute(`aria-haspopup`,`listbox`)}else te()}else te()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)I.append(Zt()),R[e].id=L+`-`+e++;Y(j,`scroll`,()=>{z(),ae()||B()}),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)le();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]));ue()}_=!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])&&le()}a?(a=!1,me()):(S!=e||C!=t)&&te(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!Mt&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&V(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!Mt||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&te()}),Y(T,`keydown`,e=>{let t=e.key,n=Ht(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?pe():me(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(ie(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(V(c),te(),X(e)):t==`Escape`?(te(),X(e)):t.slice(0,4)==`Page`&&(z(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),re(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(ce(-2),X(e)):(ce(2),X(e)):!n&&t==`Escape`&&(le(),X(e)))},!0),Y(I,`mousedown`,e=>{e.target!=P&&(V([].indexOf.call(R,e.target.closest(`li`))+d),te()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&te()}),Y(w,`scroll`,()=>{i&&H()}),Y(N,`click`,pe),Y(N,`mousedown`,X),Y(P,`click`,pe),M.id=L+`d`,P.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},tn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return nn(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]},nn=(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]]},rn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||mn[e]||0;return t+`+`+r},an=e=>{if(!fn[48]){for(let e=48;e<91;e++)fn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)fn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=Ht(e),r=fn[e.keyCode],i=pn[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},on=new WeakMap,sn=(e,t,n)=>{let r=new Set,i;try{for(let a of an(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)))}},cn=e=>{let t=on.get(e);return t||(on.set(e,t={}),Ot(e,`keydown`,n=>{sn(n,t,e)})),t},ln=(e,t,n,r)=>un(cn(e),t,n,r),un=(e,t,n,r=2)=>{let i=(e[t==`any`?t:rn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},dn=Q?4:2,fn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},pn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},mn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},hn=!1,gn=e=>e.search(/\S|$/),_n=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),vn=(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+gn((f<0?n:t)[0]),m=i-u.length+gn(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,_))},yn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=Ft(e.value,n,r),[s,c]=_n(e);return vn(e,i,i.map(t?e=>e.slice(gn(e)?c-gn(e)%c:0):e=>e&&s.repeat(c-gn(e)%c)+e),a,o,n,r),$(e)},bn=(e,t)=>{let[n,r]=_n(e);return Z(e,n.repeat(r-(t-Tt(e.value,t))%r)),$(e)},xn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=Et(r,n[1]));let[i,a]=_n(e),[o,s]=n,c=xt[Lt(e,o)]?.autoIndent,l=Math.floor(gn(Pt(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)},Sn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?Tt(i,n)-1:n,o=t?r:i.indexOf(`
|
|
29
|
-
`,r)+1;if(a>-1&&o>0){let[s,c,l]=Ft(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)},Cn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=Ft(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)},wn=(e,t)=>(e.container.scrollBy(0,kt(e.container,`lineHeight`)*(t?-1:1)),!0),Tn=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=Ft(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=Et(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},En=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:Tt(i,n),o=xt[Lt(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=Ft(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(Nt(t)+` ?$`);s+1&&RegExp(`^ ?`+Nt(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=Nt(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));vn(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=gn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(Nt(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${Nt(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},Dn={Tab(e){if(!hn){let[t,n]=e.getSelection();return t==n?bn(e,t):yn(e)}},"8+Tab":e=>!hn&&yn(e,!0),"1+ArrowDown":e=>Sn(e),"1+ArrowUp":e=>Sn(e,!0),"9+ArrowDown":e=>Cn(e),"9+ArrowUp":e=>Cn(e,!0),Enter:e=>xn(e),"8+Enter":e=>xn(e),"Mod+Enter":e=>xn(e,!0),"Mod+]":e=>yn(e),"Mod+[":e=>yn(e,!0),"8+Mod+k":Tn,"Mod+/":e=>En(e),"9+a":e=>En(e,!0),[Q?`10+m`:`2+m`]:()=>(hn=!hn,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>wn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>wn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var On=Q?5:1;On+``,On+``,On+``,On+``;var kn=(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&&!Rt(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=Pt(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=xt[Lt(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},ln(r,`Backspace`,u),ln(r,`8+Backspace`,u);for(let t in e)ln(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>Ot(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=Ft(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))}}))},An=(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}),Ot(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`)&&!Mt&&(n!=` `||o==n))||(d[t][2]=Mt||u()),i=!0,o=n,s=f,a=l}),Ot(e,`input`,()=>f(t+!c)),Ot(e,`keydown`,e=>{if(!g.readOnly){let n=Ht(e),r=e.keyCode,i=n==dn&&r==90,a=n==dn+8&&r==90||!Q&&n==dn&&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},jn=vt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),Mn=()=>{let e,t=jn(),[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];jt(n,Pt(i,s)),jt(a,i.slice(s,Et(i,s))+`
|
|
35
|
-
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),wt(e,i)},c=t=>{e=t,t.extensions.cursor=c,Ot(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),At(e,i)),c.scrollIntoView=s,c.element=i,c};vt(`<div class=pce-cursor>`);var Nn=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,Pn=/\b(?:false|true)\b/,Fn=/\[]|\(\)|{}/,In=/[([{][^)\]}]*$/,Ln=([e,t],n)=>Fn.test(n[e-1]+n[t]),Rn={line:`//`,block:[`/*`,`*/`]},zn=(e=Rn,t=In)=>({comments:e,autoIndent:[([e],n)=>t.test(Pt(n,e)),Ln]});xt.json=xt.json5=xt.jsonp=zn(),xt.graphql=zn({line:`#`}),it.webmanifest=it.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:Nn,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:Pn,null:{pattern:/\bnull\b/,alias:`keyword`}},it.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:Pn,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+/,[nt](e,t){for(var n=ot(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 Bn=new WeakMap;$t([`json`],{sources:[(e,t)=>{let n=Bn.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 Vn({value:e,language:t=`json`,readOnly:n,label:o,onChange:s,onLine:c,complete:l}){let u=a(null),d=a(void 0),f=a({onChange:s,onLine:c});f.current={onChange:s,onLine:c};let p=a(l);return p.current=l,i(()=>{let r=ht(u.current,{value:e,language:t,readOnly:n,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},kn(Dn),An(),...l?[Mn(),en({filter:tn})]:[]);return l&&Bn.set(r,(e,t)=>p.current?.(e,t)),r.textarea.setAttribute(`aria-label`,o),d.current=r,()=>r.remove()},[]),i(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),i(()=>{d.current?.setOptions({readOnly:n,language:t})},[n,t]),r(`div`,{class:`body-editor`,part:`editor`,ref:u})}var Hn=/[\w$.+-]/;function Un(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&&Hn.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&Hn.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 Wn=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),Gn=(e,t)=>{let n=K(e);return n===`array`?`${K(G(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function Kn(e){let t=K(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 qn(e,t,n,r,i){if(!e)return;let a=Un(r,i);if(!a)return;let o=J(e,[...n,...a.path],t);if(!o)return;let s=G(o,t);if(a.mode===`key`){if(K(s)!==`object`&&!s.properties)return;let e=Ce(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=G(e.schema,t),r=Kn(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${Gn(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:Wn(Se(xe(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(K(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var Jn=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Yn(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:k(e.path),query:k(e.query),headers:k(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?j(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var Xn=e=>Object.keys(e).length?e:void 0;function Zn(e,t){let n;if(Jn(e,t))n=P(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:Xn(A(e.path)),query:Xn(A(e.query)),headers:Xn(A(e.headers)),data:n}}var Qn=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function $n(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 er({doc:e,hint:t}){return e?r(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[r(`div`,{class:`field-doc-head`,children:[r(`code`,{children:e.path}),r(`span`,{class:`chip`,children:e.type}),e.required&&r(`span`,{class:`chip req`,children:`required`}),e.deprecated&&r(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?r(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:fe(e.description)}}):e.note?null:r(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&r(n,{children:[` It is part of: `,e.parent]})]}),e.note&&r(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&r(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>r(`code`,{children:e})),e.enum.length>12&&r(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):r(`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 tr(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 nr(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 rr({value:e,options:t,onChange:n,label:o,placeholder:c,onKeyDown:l,cell:u}){let[d,f]=s(!1),[p,m]=s(-1),[h,g]=s(),_=a(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`}})};i(()=>{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]),i(()=>{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=>{n(e),f(!1),m(-1)};return r(`div`,{class:`combo`,ref:_,children:[r(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":d,role:`combobox`,autocomplete:`off`,onFocus:()=>f(!0),onInput:e=>n(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))}}),r(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,onClick:()=>f(!d),children:`▾`}),d&&r(`div`,{class:`combo-list`,role:`listbox`,style:h,children:t.map((t,n)=>r(`button`,{type:`button`,role:`option`,"aria-selected":t===e,class:`${t===e?`on`:``} ${n===p?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>y(t),children:t}))})]})}var ir=`specbook:grid-cols`,ar={key:26,val:34},or=10,sr=l(cr());function cr(){try{let e=JSON.parse(localStorage.getItem(ir)??`null`);if(e&&e.key>=or&&e.val>=or&&e.key+e.val<=90)return e}catch{}return ar}function lr(e){let t=e??ar,n=Math.min(80,Math.max(or,t.key)),r=Math.min(100-n-or,Math.max(or,t.val));sr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?localStorage.setItem(ir,JSON.stringify(sr.value)):localStorage.removeItem(ir)}catch{}}function ur(){return r(`colgroup`,{children:[r(`col`,{style:{width:`36px`}}),r(`col`,{style:{width:`${sr.value.key}%`}}),r(`col`,{style:{width:`${sr.value.val}%`}}),r(`col`,{}),r(`col`,{style:{width:`60px`}})]})}function dr({which:e,table:t}){let n=t=>{let n=sr.value;lr(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return r(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(sr.value[e]),"aria-valuemin":or,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let r=t()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{n((e.clientX-i)/r*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>lr(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),n(e.key===`ArrowLeft`?-2:2))}})}var fr=1,pr=2;function mr(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.search(/[=\t]|:\s/);return t<0?{key:e,value:``}:{key:e.slice(0,t).trim(),value:e.slice(t+1).trim()}})}var hr=({d:e})=>r(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:r(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function gr({title:e,rows:t,onChange:o,documented:s=[],docFor:c,fixed:l,bad:u,placeholder:d,bare:f}){let p=a(null),m=a(null),h=a(void 0),g=new Set(t.map(e=>e.key)),_=s.filter(e=>!g.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),v=[...t,..._],y=e=>s.find(t=>t.name===e),b=e=>y(e)?.doc??c?.(e);i(()=>{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=>o(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)}:${pr}`,S(o)},D=(e,n)=>{let r=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(r.trim()))return;e.preventDefault();let i=mr(r).map(e=>({...e,enabled:!0})),a=[...t];a.splice(n,+(n<t.length&&!t[n]?.key),...i),o(a)},O=v.length;return r(`section`,{class:`grid`,"aria-label":e,ref:p,children:[!f&&r(`h3`,{children:e}),r(`table`,{ref:m,children:[r(ur,{}),r(`thead`,{children:r(`tr`,{children:[r(`th`,{class:`g-check`}),r(`th`,{class:`g-key`,children:[`Key`,r(dr,{which:`key`,table:()=>m.current})]}),r(`th`,{class:`g-val`,children:[`Value`,r(dr,{which:`val`,table:()=>m.current})]}),r(`th`,{class:`g-doc`,children:`Description`}),r(`th`,{class:`g-act`})]})}),r(`tbody`,{children:[v.map((e,t)=>{let i=b(e.key),a=y(e.key)?.file,o=l||e.virtual||y(e.key);return r(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[r(`td`,{class:`g-check`,children:r(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:l,onChange:e=>C(t,{enabled:e.target.checked})})}),r(`td`,{class:`g-key`,children:o?r(`span`,{class:`key`,children:[r(`code`,{children:e.key}),i?.required&&r(`span`,{class:`req`,title:`required`,children:`*`})]}):r(`input`,{class:`cell`,"data-cell":`${t}:${fr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>C(t,{key:e.target.value}),onKeyDown:T(t,fr),onPaste:e=>D(e,t)})}),r(`td`,{class:`g-val`,children:a?r(`label`,{class:`file-cell`,children:[r(`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})}}),r(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):i?.enum?r(rr,{value:e.value,options:i.enum.map(String),label:e.key,cell:`${t}:${pr}`,placeholder:`value`,onKeyDown:T(t,pr),onChange:e=>C(t,{value:e,enabled:!0})}):r(`input`,{class:`cell`,"data-cell":`${t}:${pr}`,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,pr)})}),r(`td`,{class:`g-doc`,title:pe(i?.description),children:i&&r(n,{children:[r(`span`,{class:`chip`,children:i.type}),` `,r(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:U(i.description)}})]})}),r(`td`,{class:`g-act`,children:[!l&&e.key&&r(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>E(t),children:r(hr,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!l&&!e.virtual&&r(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>S(v.filter((e,n)=>n!==t)),children:r(hr,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},t)}),!l&&r(`tr`,{class:`ghost`,children:[r(`td`,{class:`g-check`}),r(`td`,{class:`g-key`,children:r(`input`,{class:`cell`,"data-cell":`${O}:${fr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{h.current=`${t.length}:${fr}`,o([...t,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:T(O,fr),onPaste:e=>D(e,t.length)})}),r(`td`,{class:`g-val`}),r(`td`,{class:`g-doc`}),r(`td`,{class:`g-act`})]},O)]})]})]})}function _r({draft:e,onChange:t}){let[n,o]=s(()=>tr(e.body)),c=a(e.body);i(()=>{if(e.body===c.current)return;let t=tr(e.body);t&&o(t),c.current=e.body},[e.body]);let l=r=>{let i={...n,...r};o(i),c.current=nr(i),t({...e,body:c.current})};return r(`section`,{class:`body`,"aria-label":`Body`,children:[r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Query`}),r(`span`,{class:`chip`,children:`graphql`})]}),r(Vn,{label:`GraphQL query`,language:`graphql`,value:n.query,onChange:e=>l({query:e})}),r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Variables`}),r(`span`,{class:`chip`,children:`json`})]}),r(Vn,{label:`GraphQL variables`,language:`json`,value:n.variables,onChange:e=>l({variables:e})})]})}var vr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function yr({encoding:e,draft:t,onChange:i,schema:a,defs:o,files:l=[],notes:u}){let[d,f]=s(0),p=c(()=>Oe(t.body),[t.body]),m=e===`json`||e===`form`,h=c(()=>{let e=p[d];return e&&m?$e(Ze(a,o,e,[`data`]),u,`data`,De(e)):void 0},[p,d,a,o,m,u]),g=c(()=>m&&a?(e,t)=>qn(a,o,[`data`],e,t):void 0,[a,o,m]),_=e=>{if(e!==(t.formView??`grid`)){if(e===`grid`)try{i({...t,formView:`grid`,fields:j(JSON.parse(t.body||`{}`))})}catch{i({...t,formView:`grid`})}else i({...t,formView:`json`,body:JSON.stringify(P(t.fields.filter(e=>!e.file)),null,2)})}},v=e===`form`?r(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>r(`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(Jn(t,e)||e===`binary`){let s=t=>e===`binary`||l.includes(t.replace(/\[\d+\]/g,``)),c=e=>i({...t,fields:e}),d=(t.fields.length?t.fields.map(e=>e.key):[]).filter(s);return r(n,{children:[v&&r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Body`}),r(`span`,{class:`chip`,children:e}),r(`span`,{class:`spacer`}),v]}),r(gr,{title:e===`binary`?`File`:`Body`,bare:!!v,rows:t.fields,onChange:c,documented:[...new Set(d)].map(e=>({name:e,file:!0})),docFor:e=>$e(Ze(a,o,Qe(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&tr(t.body)?r(_r,{draft:t,onChange:i}):r(`section`,{class:`body`,"aria-label":`Body`,children:[r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Body`}),r(`span`,{class:`chip`,children:e}),r(`span`,{class:`spacer`}),e!==`text`&&r(`button`,{type:`button`,class:`link`,onClick:()=>{try{i({...t,body:JSON.stringify(JSON.parse(t.body),null,2)})}catch{}},children:`Format`}),v]}),r(Vn,{label:`Request body`,language:vr(e===`form`?`json`:e),value:t.body,onChange:e=>i({...t,body:e}),onLine:f,complete:g}),m&&r(er,{doc:h})]})}var br=`specbook:code-lang`;function xr(){try{let e=localStorage.getItem(br);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Sr({service:e,profile:t,secured:n,make:a,sent:o}){let[l,d]=s(xr),f=l===`sent`?`curl`:l,[p,m]=s(!1),[h,g]=s(),[_,v]=s();i(()=>{let n=!0;return C.config(u.value).then(r=>{if(!n)return;let i=r.services?.[e],a=i?.baseUrl??{};g(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]);let y=c(()=>{try{return{text:le(f,a(h??`https://api.example.com`,_))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[a,f,h,_]),b=e=>{if(d(e),e!==`sent`)try{localStorage.setItem(br,e)}catch{}};return r(`div`,{class:`code-sample`,children:[r(`div`,{class:`code-head`,children:[r(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[ue.map(e=>r(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>b(e.id),children:e.label})),o!==void 0&&r(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>b(`sent`),children:`Sent`})]}),r(`span`,{class:`spacer`}),l!==`sent`&&r(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(y.text)try{await navigator.clipboard.writeText(y.text),m(!0),setTimeout(()=>m(!1),1500)}catch{}},disabled:!y.text,children:p?`Copied`:`Copy`})]}),l===`sent`?o:y.error?r(`p`,{class:`muted`,children:y.error}):r(`pre`,{class:`code-block`,part:`code`,children:r(`code`,{children:y.text})}),l!==`sent`&&n&&r(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Cr({service:t,method:n,path:i,draft:a,encoding:s,vars:c,secured:l,sent:u}){let d=o((t,r)=>{let o=Zn(a,s),l={path:o.path??{},query:o.query??{},headers:o.headers??{},data:o.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:n,url:`${t.replace(/\/+$/,``)}${d}`,query:{...r?.query??{},...u.query},headers:{...r?.headers??{},...u.headers},body:u.data,encoding:s}},[a,s,c,n,i]);return r(Sr,{service:t,profile:l?`service`:void 0,secured:l,make:d,sent:u})}function wr({request:e,encoding:t,sent:n}){let i=o((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 r(Sr,{service:e.service,profile:e.profile,secured:!!e.profile,make:i,sent:n})}var Tr=e=>typeof e==`string`?e:JSON.stringify(e,null,2);function Er(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 Dr({body:e,docs:t}){let[i,a]=s(0),o=Tr(e),l=!!t?.schema&&typeof e==`object`&&!!e,u=c(()=>l?Oe(o):[],[l,o]),d=c(()=>{let e=u[i];return e&&t?$e(Ze(t.schema,t.defs,e,[`data`]),t.notes,`data`,De(e)):void 0},[u,i,t]);return r(n,{children:[r(Vn,{label:`Body as sent`,value:o,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:a}),l&&r(er,{doc:d})]})}function Or({request:e,hideBar:t,docs:i}){if(!e)return r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`Nothing sent yet`}),r(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let a=Object.entries(e.headers);return r(`div`,{class:`sent-view`,children:[!t&&r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${e.method}`,children:e.method}),r(`div`,{class:`rq-url`,title:e.url,children:r(`code`,{children:[e.url,Er(e.query)]})})]}),r(`h3`,{children:`Headers`}),a.length===0?r(`p`,{class:`muted`,children:`No headers.`}):r(`table`,{class:`headers`,children:r(`tbody`,{children:a.map(([e,t])=>r(`tr`,{children:[r(`th`,{children:e}),r(`td`,{children:t})]}))})}),e.body!==void 0&&r(n,{children:[r(`h3`,{children:`Body`}),r(Dr,{body:e.body,docs:i})]})]})}var kr=e=>JSON.stringify(e,null,2),Ar=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function jr({step:e,error:t,schemas:i,defs:a,hideRequest:o}){let[l,u]=s(`body`),[d,f]=s(0),p=e?.response,m=p?i?.[String(p.status)]??i?.default:void 0,h=c(()=>p&&m?Ee(p.body,m,a,{reportExtra:!0}):[],[p,m,a]),g=p===void 0||p.body===void 0||p.body===``?``:typeof p.body==`string`?p.body:kr(p.body),_=c(()=>Oe(g),[g]),v=c(()=>{let e=_[d];return e?Ze(m,a,e):void 0},[_,d,m,a]),y=e?.assertions??[],b=y.filter(e=>!e.pass).length,x=Object.entries(p?.headers??{}),S=!p&&!t&&!e?.error;return r(`section`,{class:`response`,"aria-label":`Response`,children:[r(`div`,{class:`rs-head`,children:[p&&r(n,{children:[r(`span`,{class:`state-badge ${je(p.status)}`,children:[p.status,` `,Ae(p.status)]}),r(`span`,{class:`rs-stat`,children:[p.durationMs,` ms`]}),r(`span`,{class:`rs-stat`,children:Ar(new Blob([g]).size)})]}),r(`span`,{class:`spacer`}),p&&r(`span`,{class:`conf ${m?h.length?`warn`:`ok`:`none`}`,children:m?h.length?`⚠ ${h.length} difference${h.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!o&&r(`p`,{class:`sent`,children:[r(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,r(`code`,{children:[e.request.url,Er(e.request.query)]})]}),t&&r(`p`,{class:`error-text`,children:t}),e?.error&&r(`p`,{class:`error-text`,children:e.error}),S&&r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`No response yet`}),r(`span`,{class:`muted`,children:[`Press`,` `,r(`kbd`,{class:`icon-key`,children:r(E,{size:12})}),` `,`or `,r(`kbd`,{children:`⌘`}),` `,r(`kbd`,{children:`↵`})]})]}),p&&r(n,{children:[r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,x.length],[`checks`,`Checks`,y.length]].map(([e,t,n])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":l===e,class:`rq-tab ${l===e?`on`:``}`,onClick:()=>u(e),children:[t,n>0&&r(`span`,{class:`count ${e===`checks`&&b?`bad`:``}`,children:n})]}))}),r(`div`,{class:`rs-pane`,children:[r(`div`,{hidden:l!==`body`,children:[g===``?r(`p`,{class:`muted`,children:`No content.`}):r(Vn,{label:`Response body`,value:g,readOnly:!0,language:typeof p.body==`string`?`text`:`json`,onLine:f}),g!==``&&r(er,{doc:v}),h.length>0&&r(`details`,{class:`issues`,children:[r(`summary`,{children:`What differs`}),r(`ul`,{children:h.map(e=>r(`li`,{children:[r(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),r(`div`,{hidden:l!==`headers`,children:r(`table`,{class:`headers`,children:r(`tbody`,{children:[x.map(([e,t])=>r(`tr`,{children:[r(`th`,{children:e}),r(`td`,{children:t})]})),x.length===0&&r(`tr`,{children:r(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),r(`div`,{hidden:l!==`checks`,children:y.length===0?r(`p`,{class:`muted`,children:`This request has no checks.`}):r(`ul`,{class:`checks`,children:y.map(e=>r(`li`,{class:e.pass?`ok`:`bad`,children:[e.pass?`✓`:`✗`,` `,e.label]}))})})]})]})]})}var Mr={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Nr({services:e,enabled:t=!0,supplied:a}){let[o,c]=s([]),[l,d]=s({}),p=a??l,[,m]=s(0),[h,g]=s(!1),_=t&&S.value!==`mock`,y=e?.join(`
|
|
37
|
-
`)??`*`;if(i(()=>{if(!_){c([]);return}let t=!0;return a||C.managedSecrets(S.value).then(e=>t&&d(e)),C.config(u.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?.[S.value],s=v(o?w(o,globalThis.location?.href):void 0);if(!a||!s)continue;let c=[...new Set([...JSON.stringify(a.apply).matchAll(f)].map(e=>e[1]))];c.length&&r.push({service:t,origin:s,title:a.title??i.auth??``,names:c})}c(r)}),()=>{t=!1}},[_,S.value,y,u.value]),!_||o.length===0)return null;let b=(e,t)=>T.get(e.origin,t)!==void 0||p[t]!==void 0,x=o.some(e=>e.names.some(t=>!b(e,t)));return!x&&!h?r(`div`,{class:`secrets-folded`,children:r(`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:()=>g(!0),children:[r(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):r(`fieldset`,{class:`needs-vars ${x?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>r(n,{children:[r(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(t=>{let i=T.get(e.origin,t)!==void 0,a=p[t];return r(`span`,{class:`needs-var`,children:[r(`code`,{children:t}),i?r(n,{children:[r(`span`,{class:`muted`,children:`✓ set`}),r(`button`,{type:`button`,class:`link`,onClick:()=>{T.remove(e.origin,t),m(e=>e+1)},children:`Clear`})]}):r(n,{children:[a&&r(`span`,{class:`muted`,children:[`from `,Mr[a]??a]}),r(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${t} for ${e.service}`,placeholder:a?`use another value`:`paste value`,onChange:n=>{let r=n.target.value;r!==``&&(T.set(e.origin,t,r),m(e=>e+1))}})]})]})})]})),r(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!x&&r(`button`,{type:`button`,class:`link`,onClick:()=>g(!1),children:`Hide`})]})}var Pr=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Fr=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ir(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[Fr(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(Fr(Pr(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 Lr(e){let{seq:t}=e,[n,r]=s(),[a,o]=s(!1);i(()=>{let n=!0;r(void 0),o(!1);let i=d.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!i)o(!0);else return i.load().then(e=>n&&r(e)).finally(()=>n&&o(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=c(()=>t.nodes.map(e=>e.name),[t]);return c(()=>({...Ir(n??fe(t.meta.description),l),loaded:a}),[n,l,t,a])}function Rr(e){let[t,n]=s();return i(()=>{let t=!0;return n(void 0),e&&d.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&n(e)),()=>{t=!1}},[e]),t}var zr=(e,t)=>`specbook:draft:${e}:${t}`,Br=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Vr(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Hr=`specbook:saved-example`;function Ur(e){try{let t=sessionStorage.getItem(Hr),n=t?JSON.parse(t):void 0;return n?.key===e?(sessionStorage.removeItem(Hr),n):void 0}catch{return}}function Wr({service:e,op:a,variants:o,initial:l}){let f=`${e}/${a.id}`,p=C.examplesOf(f),[m,v]=s(()=>Ur(f)),[y,w]=s(()=>{let e=p.find(e=>e.name===(m?.name??l));return e?`ex:${e.name}`:p[0]?`ex:${p[0].name}`:o[0]?`saved:${o[0].file}`:``}),T=y.startsWith(`saved:`)?o.find(e=>`saved:${e.file}`===y):void 0,D=Rr(T?.file),O=Ue(f),[k,A]=s(),[j,M]=s(),[N,P]=s(),[F,I]=s({}),[L,R]=s(),[ee,te]=s(),[z,ne]=s(),[re,B]=s(),[ie,ae]=s(),[V,oe]=s(),[se,ce]=s(!1),[le,ue]=s(),[de,H]=s(),[fe,pe]=s(``),[me,he]=s();i(()=>{C.config(u.value).then(t=>pe(t.services?.[e]?.baseUrl?.[S.value]??``))},[e,S.value]),i(()=>{let e=!0;return he(void 0),C.knownVars(S.value,u.value).then(t=>e&&he(t)),()=>{e=!1}},[S.value]),i(()=>{let t=!0;return d.schemas[f]?.().then(e=>t&&R(e.default)),d.responseSchemas[f]?.().then(e=>t&&te(e.default)),d.definitions[e]?.().then(e=>t&&ne(e.default)),C.operationMeta(f,u.value).then(e=>{t&&A({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[f,e]);let U=k?.encoding??`json`,ge=d.manifests[e]?.operations.find(e=>e.id===a.id)?.secured;i(()=>{if(!k)return;let e=!0;return oe(void 0),ae(void 0),(async()=>{let t=T?await C.savedExample(T.def,u.value):await C.loadExample(f,y.replace(/^ex:/,``),u.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};M(n),P(!T&&Vr(zr(f,y))||Yn(n,U))})().catch(t=>e&&oe(t instanceof Error?t.message:String(t))),()=>{e=!1}},[f,y,k,T]);let _e=c(()=>j?Yn(j,U):void 0,[j,U]),ve=!!N&&!!_e&&JSON.stringify(Qn(N))!==JSON.stringify(Qn(_e)),ye=e=>{if(P(e),!T)try{let t=zr(f,y);_e&&JSON.stringify(Qn(e))===JSON.stringify(Qn(_e))?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(Qn(e)))}catch{}},W=c(()=>{let e=L?G(L,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Ce(r,z).map(e=>({name:e.name,doc:$e(Ze(L,z,[e.name],[n]),O.notes,n,e.name),repeat:G(e.schema,z).type===`array`})))}return t},[L,z,O.notes]),be=c(()=>{if(!N)return[];try{let e=Zn(N,U);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[]}},[N,U]),K=me?be.filter(e=>!me.includes(e)):[],xe=K.filter(e=>(F[e]??``)===``),Se=async e=>{if(N){oe(void 0),ce(!0);try{let t=T?T.def:await C.operationRequest(f,u.value,Zn(N,U));ae(await C.run(t,{env:S.value,version:u.value,mockStatus:S.value===`mock`?e??re:void 0,locale:g.value,seed:h.value,vars:Object.fromEntries(Object.entries(F).filter(([,e])=>e!==``)),fileDir:j?.dir}))}catch(e){oe(e instanceof Error?e.message:String(e))}finally{ce(!1)}}},we=async t=>{if(!N)return;let n=Zn(N,U),r=Br(t),i={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=`${d.project.requestsDir}/${e}/${a.id}/${r}.example.json`,s={key:f,path:o,name:r};try{sessionStorage.setItem(Hr,JSON.stringify(s))}catch{}await x(o,`${JSON.stringify(i,null,2)}\n`),v(s),ue(void 0)},q=ie?.steps.find(e=>e.response)??ie?.steps[0],Te=V?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Ee=!!N&&(N.path.length>0||N.query.length>0||W.path.length>0||W.query.length>0),De=!!N&&(N.headers.length>0||W.headers.length>0),Oe=!!N&&U!==`none`&&(N.body!==``||N.fields.length>0||!!L?.properties?.data),J=de??(Ee?`params`:Oe?`body`:De?`headers`:`params`),ke=e=>e.filter(e=>e.enabled).length,Me=N?ke(N.query):0,Ne=N?ke(N.path):0,Pe=N?$n(a.path,N.path,N.query,fe):a.path;return i(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Se())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)}),r(`div`,{class:`request-panel`,"data-op":f,children:r(`div`,{class:`rq`,children:[r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${a.method}`,children:a.method}),r(`div`,{class:`rq-url`,title:Pe,children:r(`code`,{children:Pe.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?r(`mark`,{children:e}):e)})}),(q?.response||V||q?.error)&&r(`button`,{type:`button`,class:`result-chip ${q?.response?je(q.response.status):`s5`}`,title:`Open the response`,onClick:()=>H(`response`),children:q?.response?`${q.response.status} ${Ae(q.response.status)} · ${q.response.durationMs} ms`:`Failed`}),r(`button`,{type:`button`,class:`btn primary send`,title:`Send (⌘/Ctrl + Enter)`,"aria-label":`Send`,disabled:se||!N,onClick:()=>Se(),children:se?`…`:r(E,{})})]}),D&&r(`details`,{class:`step-about`,children:[r(`summary`,{children:`About this request`}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:D}})]},T?.file),K.length>0&&r(`fieldset`,{class:`needs-vars ${xe.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[r(`span`,{class:`muted`,children:xe.length>0?`Needs a value for`:`Values for`}),K.map(e=>r(`label`,{class:`needs-var`,children:[r(`code`,{children:e}),r(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:F[e]??``,onInput:t=>I({...F,[e]:t.target.value})})]}))]}),ge&&r(Nr,{services:[e]}),r(`div`,{class:`rq-meta`,children:[r(`div`,{class:`rq-example`,children:[r(`label`,{class:`row`,children:[r(`span`,{class:`muted`,children:`Example`}),r(`select`,{value:y,onChange:e=>w(e.target.value),children:[p.map(e=>r(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),o.map(e=>r(`option`,{value:`saved:${e.file}`,children:[e.name,` · saved request`]}))]})]}),r(b,{})]}),ve&&r(`span`,{class:`edited`,children:`Edited`}),r(`span`,{class:`spacer`}),ve&&r(`button`,{type:`button`,class:`link`,onClick:()=>_e&&ye(_e),children:`↺ Reset`}),!_&&!T&&ve&&le===void 0&&r(`button`,{type:`button`,class:`link`,onClick:()=>ue(``),children:`Save as example…`}),S.value===`mock`&&a.statuses.length>0&&r(`label`,{class:`rq-status`,children:[r(`span`,{class:`muted`,children:`Respond with`}),r(`select`,{"aria-label":`Mock response`,value:re===void 0?``:String(re),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);B(n),Se(n)},children:[r(`option`,{value:``,children:`Default`}),a.statuses.map(e=>r(`option`,{value:String(e),children:[e,` `,Ae(e)]}))]})]})]}),m&&r(`p`,{class:`saved-note`,role:`status`,children:[r(`span`,{children:[`✓ Saved to `,r(`code`,{children:m.path}),`. It is a normal project file: commit it to share this example with your team.`]}),r(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>v(void 0),children:`×`})]}),le!==void 0&&r(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),le.trim()&&we(le.trim()).catch(e=>oe(String(e)))},children:[r(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:le,onInput:e=>ue(e.target.value)}),r(`button`,{type:`submit`,class:`btn`,children:`Save`}),r(`button`,{type:`button`,class:`link`,onClick:()=>ue(void 0),children:`Cancel`})]}),T&&r(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock responses apply, and it is read-only here.`}),r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,Me+Ne],[`headers`,`Headers`,N?ke(N.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,be.length]].filter(([e])=>e===`params`?Ee:e===`headers`?De:e===`body`?Oe:be.length>0).map(([e,t,n])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":J===e,class:`rq-tab ${J===e?`on`:``}`,onClick:()=>H(e),children:[t,n>0&&r(`span`,{class:`count`,children:n}),e===`body`&&r(`span`,{class:`chip`,children:U})]})),r(`span`,{class:`tab-gap`}),r(`button`,{type:`button`,role:`tab`,"aria-selected":J===`request`,class:`rq-tab ${J===`request`?`on`:``}`,onClick:()=>H(`request`),children:`Request`}),r(`button`,{type:`button`,role:`tab`,"aria-selected":J===`response`,class:`rq-tab ${J===`response`?`on`:``}`,onClick:()=>H(`response`),children:[`Response`,q?.response&&r(`span`,{class:`state-dot ${je(q.response.status)}`,children:q.response.status}),!q?.response&&(V||q?.error)&&r(`span`,{class:`state-dot s5`,children:`!`})]})]}),r(`div`,{class:`rq-pane`,children:[N&&r(n,{children:[r(`div`,{class:`tab-pane`,hidden:J!==`params`,children:[(N.query.length>0||W.query.length>0)&&r(gr,{title:`Query`,rows:N.query,documented:W.query,onChange:e=>ye({...N,query:e})}),(N.path.length>0||W.path.length>0)&&r(gr,{title:`Path`,rows:N.path,documented:W.path,fixed:!0,onChange:e=>ye({...N,path:e})})]}),r(`div`,{class:`tab-pane`,hidden:J!==`headers`,children:De&&r(gr,{title:`Headers`,rows:N.headers,documented:W.headers,onChange:e=>ye({...N,headers:e})})}),r(`div`,{class:`tab-pane`,hidden:J!==`body`,children:Oe&&r(yr,{encoding:U,draft:N,onChange:ye,schema:L,defs:z,files:k?.files,notes:O.notes})}),r(`div`,{class:`tab-pane`,hidden:J!==`vars`,children:be.length>0&&r(gr,{title:`Variables`,rows:be.map(e=>({key:e,value:F[e]??``,enabled:!0})),fixed:!0,bad:Te,placeholder:`from the request's init, config or earlier steps`,onChange:e=>I(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),r(`div`,{class:`tab-pane`,hidden:J!==`request`,children:N&&r(Cr,{service:e,method:a.method,path:a.path,draft:N,encoding:U,vars:F,secured:ge,sent:q?.request?r(Or,{request:q.request,docs:{schema:L,defs:z,notes:O.notes}}):void 0})}),r(`div`,{class:`tab-pane`,hidden:J!==`response`,children:r(jr,{step:q,error:V,schemas:ee,defs:z})})]})]})})}function Gr(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Kr(e,t),...n}}function Kr(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,Gr(t)]))};case`array`:return{kind:`array`,item:Gr(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 qr(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,qr(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Jr={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Yr=e=>typeof e==`string`?e:JSON.stringify(e);function Xr({info:e}){let{seq:t}=e,{intro:i,notes:a}=Lr(e),o=c(()=>Object.entries(t.meta.params??{}).map(([e,t])=>{let n=Gr(t);return{name:e,spec:n,initial:qr(n)}}),[t]);return r(`article`,{class:`doc`,"data-seq":t.meta.id,children:[(t.meta.tags?.length??0)>0&&r(`p`,{class:`doc-tags`,children:t.meta.tags?.map(e=>r(`span`,{class:`chip`,children:e}))}),i&&r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:i}}),o.length>0&&r(`section`,{children:[r(`h2`,{children:`Controls`}),r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`Name`}),r(`th`,{children:`Type`}),r(`th`,{children:`Default`}),r(`th`,{children:`Description`})]})}),r(`tbody`,{children:o.map(e=>r(`tr`,{children:[r(`td`,{children:r(`code`,{children:e.name})}),r(`td`,{children:r(`span`,{class:`chip`,children:e.spec.kind})}),r(`td`,{children:r(`code`,{children:Yr(e.initial)})}),r(`td`,{children:e.spec.description})]}))})]})]}),r(`section`,{children:[r(`h2`,{children:`Steps`}),r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`#`}),r(`th`,{children:`Step`}),r(`th`,{children:`What it does`})]})}),r(`tbody`,{children:t.nodes.map((e,t)=>{let i=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,o=a.get(e.name);return r(n,{children:[r(`tr`,{class:o?`has-note`:``,children:[r(`td`,{children:t+1}),r(`td`,{children:e.name}),r(`td`,{children:i?r(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>D({kind:`op`,key:`${i.service}/${i.id}`}),children:[r(`span`,{class:`method ${i.method}`,children:i.method}),` `,r(`code`,{children:i.path})]}):r(`span`,{class:`muted`,children:Jr[e.kind]??e.kind})})]}),o&&r(`tr`,{class:`step-note-row`,children:[r(`td`,{}),r(`td`,{colSpan:2,children:r(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:o}})})]})]})})})]})]})]})}var Zr=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Qr(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function $r({name:e,spec:t,value:n,onChange:i}){let[a,o]=s();switch(t.kind){case`number`:return r(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(n??``),min:t.min,max:t.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return r(rr,{label:e,value:String(!!n),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return r(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(n??``),onInput:e=>i(e.target.value)});case`select`:{let a=t.options??[],o=a.find(e=>Zr(e.value,n));return r(rr,{label:e,value:o?.label??String(n??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=n??[];return r(`div`,{class:`multi-cell`,children:(t.options??[]).map(t=>r(`label`,{children:[r(`input`,{type:`checkbox`,checked:e.some(e=>Zr(e,t.value)),onChange:n=>i(n.target.checked?[...e,t.value]:e.filter(e=>!Zr(e,t.value)))}),t.label]}))})}case`object`:case`array`:return r(`input`,{class:`cell mono`,"aria-label":e,value:a??JSON.stringify(n??qr(t)),onInput:e=>{let t=e.target.value;o(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>o(void 0)});default:return r(`input`,{class:`cell`,"aria-label":e,value:String(n??``),onInput:e=>i(e.target.value)})}}function ei({title:e,specs:t,values:n,onChange:i}){let a=Object.keys(t);return a.length===0?null:r(`section`,{class:`grid controls-grid`,"aria-label":e,children:[r(`h3`,{children:e}),r(`table`,{children:[r(`colgroup`,{children:[r(`col`,{class:`c-key`}),r(`col`,{class:`c-val`}),r(`col`,{})]}),r(`thead`,{children:r(`tr`,{children:[r(`th`,{class:`g-key`,children:`Name`}),r(`th`,{class:`g-val`,children:`Value`}),r(`th`,{class:`g-doc`,children:`Description`})]})}),r(`tbody`,{children:a.map(e=>{let a=t[e];return r(`tr`,{children:[r(`td`,{class:`g-key`,children:r(`span`,{class:`key`,children:r(`code`,{children:a.label??e})})}),r(`td`,{class:`g-val`,children:r($r,{name:e,spec:a,value:n[e],onChange:t=>i({...n,[e]:t})})}),r(`td`,{class:`g-doc`,title:a.description,children:[r(`span`,{class:`chip`,children:Qr(a)}),` `,a.description]})]},e)})})]})]})}function ti({step:e,note:t}){let[n,a]=s(`response`),[o,c]=s(),[l,f]=s(),[p,m]=s(),[h,g]=s(`json`),_=e.request,v=_?.opId?`${_.service}/${_.opId}`:void 0;i(()=>{a(`response`)},[e.name]),i(()=>{let e=!0;return c(void 0),f(void 0),m(void 0),v&&_&&(d.schemas[v]?.().then(t=>e&&m(t.default)),C.operationMeta(v,u.value).then(t=>e&&g(t?.encoding??`json`)),d.responseSchemas[v]?.().then(t=>e&&c(t.default)),d.definitions[_.service]?.().then(t=>e&&f(t.default))),()=>{e=!1}},[v]);let y=e.response,b=_?`${_.url}${Er(_.query)}`:``;return r(`div`,{class:`step-exchange`,children:[_&&r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${_.method}`,children:_.method}),r(`div`,{class:`rq-url`,title:b,children:r(`code`,{children:b})}),y&&r(`span`,{class:`result-chip ${je(y.status)}`,children:[y.status,` `,Ae(y.status),` · `,y.durationMs,` ms`]})]}),t&&r(`details`,{class:`step-about`,children:[r(`summary`,{children:`About this step`}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]},e.name),r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,t])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,class:`rq-tab ${n===e?`on`:``}`,onClick:()=>a(e),children:[t,e===`response`&&y&&r(`span`,{class:`state-dot ${je(y.status)}`,children:y.status})]}))}),r(`div`,{class:`rq-pane`,children:[r(`div`,{class:`tab-pane`,hidden:n!==`request`,children:_?r(wr,{request:_,encoding:h,sent:r(Or,{request:_,hideBar:!0,docs:{schema:p,defs:l}})}):r(Or,{request:_,hideBar:!0,docs:{schema:p,defs:l}})}),r(`div`,{class:`tab-pane`,hidden:n!==`response`,children:r(jr,{step:e,schemas:o,defs:l,hideRequest:!0})})]})]})}var ni=e=>e.replace(/ #\d+$/,``),ri={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``},ii=e=>{let t=typeof e==`string`?e:JSON.stringify(e);return t.length>28?`${t.slice(0,27)}…`:t};function ai({info:e}){let{seq:t}=e,n=c(()=>Object.fromEntries(Object.entries(t.meta.params??{}).map(([e,t])=>[e,Gr(t)])),[t]),a=Lr(e),o=c(()=>{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,d]=s({}),[f,p]=s(),[m,_]=s({}),[v,y]=s(!1),[x,w]=s(),[T,E]=s({}),[D,O]=s(0),[k,A]=s(!1),[j,M]=s();i(()=>{d(Object.fromEntries(Object.entries(n).map(([e,t])=>[e,qr(t)]))),p(void 0),_({}),w(void 0)},[e.file]);let N=t.nodes.map(e=>e.name),P=f?f.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):N.map(e=>({name:e})),F=P[D]?.step,I=async()=>{y(!0),p(void 0),M(void 0),_({}),O(0),A(!1);try{let e=await C.run(t,{env:S.value,version:u.value,params:l,locale:g.value,seed:h.value,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),E(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,qr(t)]))),w({name:e,controls:r,resolve:e=>{w(void 0),n(e)}})})});p(e)}catch(e){M(e instanceof Error?e.message:String(e))}finally{y(!1),w(void 0)}},L=f?.status;return r(`div`,{class:`sequence-panel ${k&&F?`sheet-open`:``}`,"data-seq":t.meta.id,children:[r(`div`,{class:`seq-left`,children:[r(Nr,{services:o}),r(ei,{title:`Controls`,specs:n,values:l,onChange:d}),r(`div`,{class:`seq-run`,children:[r(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:I,children:v?`Running…`:`▶ Run`}),r(b,{}),f&&r(`span`,{class:`badge ${L}`,children:[ri[L],` `,L===`pass`?`Passed`:L===`fail`?`Failed`:`Error`,` ·`,` `,f.totals.passed,`/`,f.totals.steps,` steps · `,f.durationMs,`ms`]})]}),j&&r(`p`,{class:`error-text`,children:j}),r(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:P.map((e,t)=>{let n=e.step,i=n?.status??m[e.name]??`pending`,a=n?.assertions.filter(e=>!e.pass)??[];return r(`li`,{class:`jstep ${i} ${D===t?`picked`:``}`,children:[r(`div`,{class:`jmark`,children:ri[i]||t+1}),r(`div`,{class:`jbody`,children:[r(`button`,{type:`button`,class:`jhead`,disabled:!n,onClick:e=>{let n=e.currentTarget;O(t),A(!0),requestAnimationFrame(()=>n.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[r(`span`,{class:`jname`,children:e.name}),n?.response&&r(`span`,{class:`muted`,children:[n.response.status,` · `,n.durationMs,`ms`]}),n&&n.assertions.length>0&&r(`span`,{class:a.length?`error-text`:`muted`,children:[n.assertions.length-a.length,`/`,n.assertions.length,` checks`]})]}),n?.uses?.filter(e=>e.source===`capture`).map(e=>r(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,r(`em`,{children:[`from `,e.step]})]})),n&&Object.entries(n.captured).map(([e,t])=>r(`span`,{class:`cap make`,title:JSON.stringify(t),children:[`→ `,e,` `,r(`b`,{children:ii(t)})]})),n?.error&&r(`div`,{class:`error-text`,children:n.error}),a.map(e=>r(`div`,{class:`error-text`,children:[`✗ `,e.label]})),i===`skipped`&&r(`div`,{class:`muted`,children:`Skipped: an earlier step did not pass.`}),x&&m[e.name]===`paused`&&r(`div`,{class:`pause`,children:[r(`strong`,{children:[`Your turn: `,x.name]}),r(ei,{title:`Choose`,specs:x.controls,values:T,onChange:E}),r(`button`,{type:`button`,class:`btn primary`,onClick:()=>x.resolve(T),children:`Continue ▶`})]})]})]})})})]}),r(`div`,{class:`seq-right ${k&&F?`sheet-open`:``}`,children:[F&&r(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>A(!1),children:[r(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,F.name]}),!F&&r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`Nothing run yet`}),r(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),F&&r(ti,{step:F,note:a.notes.get(ni(F.name))})]})]})}function oi(e){let t=e.tab??`try`,n=r(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([n,i])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,class:`rq-tab ${t===n?`on`:``}`,onClick:()=>e.onNavigate({tab:n}),children:i}))});return e.kind===`seq`?r(Xe,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:r(`div`,{class:`panel-split`,children:[n,r(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:r(t===`docs`?Xr:ai,{info:e.info})})]})}):r(Xe,{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:r(`div`,{class:`panel-split`,children:[n,r(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:t===`docs`?r(Je,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):r(Wr,{service:e.service,op:e.op,variants:e.variants,initial:e.example},`${e.service}/${e.op.id}`)})]})})}export{oi as Host};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,d as n,f as r,g as i,i as a,m as o,o as s,s as c,t as l}from"./panel-CoQ6iQpX.js";import{r as u,t as d}from"./mount-B-qFOcWp.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 f=[78,92,64,84,70,88,60,80,72,90,66,76],p=[93,118,81,72,46,46,32];function m({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:s,alt:``,width:`24`,height:`24`}),`Specbook`]}),t(`span`,{class:`sk-search`,"aria-hidden":`true`}),t(`span`,{class:`spacer`}),p.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`}),f.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 h=`specbook:recent-specs`,g=10;function _(){try{let e=JSON.parse(localStorage.getItem(h)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,g):[]}catch{return[]}}function v(e){try{localStorage.setItem(h,JSON.stringify([e,..._().filter(t=>t!==e)].slice(0,g)))}catch{}}var y=`specbook-viewer`,b=`uploads`,x=5;function S(){return new Promise((e,t)=>{let n=indexedDB.open(y,1);n.onupgradeneeded=()=>n.result.createObjectStore(b,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var C=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function w(e,t){try{let n=await S(),r=Math.random().toString(36).slice(2,10),i=n.transaction(b,`readwrite`).objectStore(b);await C(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await C(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(x))i.delete(e.id);return r}catch{return}}async function T(e){try{let t=await C((await S()).transaction(b).objectStore(b).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var E=[{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`}];c();var D=document.getElementById(`app`),O=new URLSearchParams(location.search),k=O.has(`spec`)||O.has(`upload`),A=e=>`${location.origin}${location.pathname}?spec=${a(e)}`;function j({initial:i}){let[a,s]=o(i),[c,f]=o(O.get(`spec`)??``),[p,h]=o(``),[g,y]=o(!1),b=r(void 0),x=async(e,t,n)=>{b.current??=new u,s({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>s({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&v(n),await d({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?s({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;s({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=l(e.trim());if(t){if(!/^https?:\/\//i.test(t))return s({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,A(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await w(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};n(()=>{let e=O.get(`spec`),t=O.get(`upload`);e?S(e):t&&T(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):s({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let D=a.kind===`loading`;return k&&(a.kind===`idle`||a.kind===`loading`)?t(m,{what:O.get(`spec`)??`your uploaded document`,progress:a.kind===`loading`?a.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(c)},children:[t(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:c,onInput:e=>f(e.target.value),disabled:D}),t(`button`,{type:`submit`,class:`btn primary`,disabled:D,children:`Open`})]}),a.kind===`loading`&&t(`p`,{class:`vw-progress`,role:`status`,children:a.progress??`Opening…`}),a.kind===`error`&&t(`div`,{class:`vw-error`,role:`alert`,children:[a.message,a.code===`cors`&&t(e,{children:` Paste the document below or drop the file instead; it works the same.`})]}),a.kind===`base`&&t(M,{onApply:a.apply,title:a.open.title}),t(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),y(!0)},onDragLeave:()=>y(!1),onDrop:async e=>{e.preventDefault(),y(!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=>h(e.target.value)}),t(`p`,{}),t(`button`,{type:`button`,class:`btn primary`,disabled:D||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),t(`section`,{children:[t(`p`,{children:`Try one`}),t(`ul`,{children:E.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>S(e.url),children:e.label})}))})]}),_().length>0&&t(`section`,{children:[t(`p`,{children:`Recent`}),t(`ul`,{children:_().map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,title:e,onClick:()=>S(e),children:e})}))})]})]})})}function M({onApply:e,title:n}){let[r,i]=o(``);return t(`form`,{class:`vw-base`,onSubmit:t=>{t.preventDefault(),/^https?:\/\//i.test(r.trim())&&e(r.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:r,onInput:e=>i(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`})]})}i(t(j,{initial:{kind:`idle`}}),D);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Host-DdTTHeXU.js","./registry-DI74Wtj8.js","./mount-B-qFOcWp.js","./panel-CoQ6iQpX.js","./panel-Coi9H1nv.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-DI74Wtj8.js";import{_ as f,a as p,c as m,d as h,f as g,g as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,u as T}from"./panel-CoQ6iQpX.js";import{n as ee}from"./mount-B-qFOcWp.js";var E=T({links:[],ready:!1});function te(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 D(e){let t=te(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 ne=e=>`--sb-accent:${e};--sb-accent-hover:color-mix(in srgb,${e} 82%,black);--sb-focus-ring:color-mix(in srgb,${e} 45%,white);`+(D(e)?`--sb-text-on-accent:${D(e)};`:``);function re(e){if(!e.accent&&!e.accentDark)return``;let t=e.accent?`:root{${ne(e.accent)}}`:``;return e.accentDark?`${t}@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${ne(e.accentDark)}}}:root[data-theme="dark"]{${ne(e.accentDark)}}`:t}function ie(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?re(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 ae(e){O=e,typeof location<`u`&&(k.value=le(location.hash))}var oe=e=>O&&e.startsWith(`${O}/`)?e.slice(O.length+1):e,se=e=>O&&!e.includes(`/`)?`${O}/${e}`:e,ce=e=>encodeURIComponent(e).replace(/%2F/gi,`/`);function le(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:se(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 ue(e){if(e.kind===`home`)return`#/`;if(e.kind===`browse`)return`#/browse`;let t=e.kind===`op`?`#/op/${ce(oe(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 de=()=>typeof matchMedia==`function`&&matchMedia(`(max-width: 820px)`).matches,fe=e=>de()?{kind:`browse`}:{kind:`home`},k=T(le(typeof location>`u`?``:location.hash)),A=T(!1),pe=T(``),j=T(``);function M(e){location.hash=ue(e),k.value=e}function me(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 he({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 ge({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 _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:`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 ve({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 N=T(Date.now()),P=T(`mock`),F=T([`mock`]),ye=T({}),be=T(void 0),I=T(void 0);function xe(){if(!globalThis.__SPECBOOK_VIEWER__)return null;let e=F.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 Se=/(^|\.)specbook\.dev$/i;function Ce(e){return e.published&&e.badge!==!1&&!Se.test(e.host)}var we=e=>`https://ui.specbook.dev/?ref=${encodeURIComponent(e)}`,Te=Object.prototype.hasOwnProperty;function Ee(e,t,n){for(n of e.keys())if(L(n,t))return n}function L(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--&&L(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=Ee(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=Ee(t,i),!i)||!L(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(Te.call(e,n)&&++r&&!Te.call(t,n)||!(n in t)||!L(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var De,Oe,ke,Ae,je=!0;typeof process<`u`&&({FORCE_COLOR:De,NODE_DISABLE_COLORS:Oe,NO_COLOR:ke,TERM:Ae}={},je=process.stdout&&process.stdout.isTTY);var R={enabled:!Oe&&ke==null&&Ae!==`dumb`&&(De!=null&&De!==`0`||je),reset:z(0,0),bold:z(1,22),dim:z(2,22),italic:z(3,23),underline:z(4,24),inverse:z(7,27),hidden:z(8,28),strikethrough:z(9,29),black:z(30,39),red:z(31,39),green:z(32,39),yellow:z(33,39),blue:z(34,39),magenta:z(35,39),cyan:z(36,39),white:z(37,39),gray:z(90,39),grey:z(90,39),bgBlack:z(40,49),bgRed:z(41,49),bgGreen:z(42,49),bgYellow:z(43,49),bgBlue:z(44,49),bgMagenta:z(45,49),bgCyan:z(46,49),bgWhite:z(47,49)};function Me(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 Ne(e,t){let n={has:e,keys:t};return n.reset=R.reset.bind(n),n.bold=R.bold.bind(n),n.dim=R.dim.bind(n),n.italic=R.italic.bind(n),n.underline=R.underline.bind(n),n.inverse=R.inverse.bind(n),n.hidden=R.hidden.bind(n),n.strikethrough=R.strikethrough.bind(n),n.black=R.black.bind(n),n.red=R.red.bind(n),n.green=R.green.bind(n),n.yellow=R.yellow.bind(n),n.blue=R.blue.bind(n),n.magenta=R.magenta.bind(n),n.cyan=R.cyan.bind(n),n.white=R.white.bind(n),n.gray=R.gray.bind(n),n.grey=R.grey.bind(n),n.bgBlack=R.bgBlack.bind(n),n.bgRed=R.bgRed.bind(n),n.bgGreen=R.bgGreen.bind(n),n.bgYellow=R.bgYellow.bind(n),n.bgBlue=R.bgBlue.bind(n),n.bgMagenta=R.bgMagenta.bind(n),n.bgCyan=R.bgCyan.bind(n),n.bgWhite=R.bgWhite.bind(n),n}function z(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:R.enabled?Me(this.keys,t+``):t+``):t===void 0?Ne([e],[n]):R.enabled?Me([n],t+``):t+``}}function B(){}B.prototype={diff:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.callback;typeof n==`function`&&(r=n,n={}),this.options=n;var i=this;function a(e){return r?(setTimeout(function(){r(void 0,e)},0),!0):e}e=this.castInput(e),t=this.castInput(t),e=this.removeEmpty(this.tokenize(e)),t=this.removeEmpty(this.tokenize(t));var o=t.length,s=e.length,c=1,l=o+s;n.maxEditLength&&(l=Math.min(l,n.maxEditLength));var u=n.timeout??1/0,d=Date.now()+u,f=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(f[0],t,e,0);if(f[0].oldPos+1>=s&&p+1>=o)return a([{value:this.join(t),count:t.length}]);var m=-1/0,h=1/0;function g(){for(var n=Math.max(m,-c);n<=Math.min(h,c);n+=2){var r=void 0,l=f[n-1],u=f[n+1];l&&(f[n-1]=void 0);var d=!1;if(u){var g=u.oldPos-n;d=u&&0<=g&&g<o}var _=l&&l.oldPos+1<s;if(!d&&!_)f[n]=void 0;else{if(r=!_||d&&l.oldPos+1<u.oldPos?i.addToPath(u,!0,void 0,0):i.addToPath(l,void 0,!0,1),p=i.extractCommon(r,t,e,n),r.oldPos+1>=s&&p+1>=o)return a(Pe(i,r.lastComponent,t,e,i.useLongestToken));f[n]=r,r.oldPos+1>=s&&(h=Math.min(h,n-1)),p+1>=o&&(m=Math.max(m,n+1))}}c++}if(r)(function e(){setTimeout(function(){if(c>l||Date.now()>d)return r();g()||e()},0)})();else for(;c<=l&&Date.now()<=d;){var _=g();if(_)return _}},addToPath:function(e,t,n,r){var i=e.lastComponent;return i&&i.added===t&&i.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:i.count+1,added:t,removed:n,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:i}}},extractCommon:function(e,t,n,r){for(var i=t.length,a=n.length,o=e.oldPos,s=o-r,c=0;s+1<i&&o+1<a&&this.equals(t[s+1],n[o+1]);)s++,o++,c++;return c&&(e.lastComponent={count:c,previousComponent:e.lastComponent}),e.oldPos=o,s},equals:function(e,t){return this.options.comparator?this.options.comparator(e,t):e===t||this.options.ignoreCase&&e.toLowerCase()===t.toLowerCase()},removeEmpty:function(e){for(var t=[],n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t},castInput:function(e){return e},tokenize:function(e){return e.split(``)},join:function(e){return e.join(``)}};function Pe(e,t,n,r,i){for(var a=[],o;t;)a.push(t),o=t.previousComponent,delete t.previousComponent,t=o;a.reverse();for(var s=0,c=a.length,l=0,u=0;s<c;s++){var d=a[s];if(!d.removed){if(!d.added&&i){var f=n.slice(l,l+d.count);f=f.map(function(e,t){var n=r[u+t];return n.length>e.length?n:e}),d.value=e.join(f)}else d.value=e.join(n.slice(l,l+d.count));l+=d.count,d.added||(u+=d.count)}else if(d.value=e.join(r.slice(u,u+d.count)),u+=d.count,s&&a[s-1].added){var p=a[s-1];a[s-1]=a[s],a[s]=p}}var m=a[c-1];return c>1&&typeof m.value==`string`&&(m.added||m.removed)&&e.equals(``,m.value)&&(a[c-2].value+=m.value,a.pop()),a}var Fe=new B;function Ie(e,t,n){return Fe.diff(e,t,n)}var Le=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Re=/\S/,ze=new B;ze.equals=function(e,t){return this.options.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e===t||this.options.ignoreWhitespace&&!Re.test(e)&&!Re.test(t)},ze.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]&&Le.test(t[n])&&Le.test(t[n+2])&&(t[n]+=t[n+2],t.splice(n+1,2),n--);return t};var Be=new B;Be.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 Ve(e,t,n){return Be.diff(e,t,n)}var He=new B;He.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var Ue=new B;Ue.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function We(e){"@babel/helpers - typeof";return We=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},We(e)}var Ge=Object.prototype.toString,V=new B;V.useLongestToken=!0,V.tokenize=Be.tokenize,V.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(Ke(e,null,null,i),i,` `)},V.equals=function(e,t){return B.prototype.equals.call(V,e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`))};function Ke(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(Ge.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=Ke(e[a],t,n,r,i);return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),We(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]=Ke(e[c],t,n,r,c);t.pop(),n.pop()}else o=e;return o}var qe=new B;qe.tokenize=function(e){return e.slice()},qe.join=qe.removeEmpty=function(e){return e};function Je(e,t,n){return qe.diff(e,t,n)}var H={"--":R.red,"··":R.grey,"++":R.green},U=R.dim().italic,Ye=R.dim(`→`),Xe=R.dim(`·`),Ze=R.dim(`↵`),Qe=(e,t)=>H[e](e+et(t))+`
|
|
4
|
-
`,$e=(e,t)=>R.dim(`L`+String(e).padStart(t,`0`)+` `),et=e=>e.replace(/[ ]/g,Xe).replace(/\t/g,Ye).replace(/(\r?\n)/g,Ze);function tt(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+=H[r]().underline(U(`Expected:`))+`
|
|
6
|
-
`:e.removed&&(s+=H[r]().underline(U(`Actual:`))+`
|
|
7
|
-
`);a<i.length;a++)o=i[a],o!=null&&(t&&(s+=$e(t+a,n)),s+=Qe(r,o||`
|
|
8
|
-
`));return s}function nt(e,t){let n=Je(e,t),r=0,i=0,a=0,o,s,c,l,u,d=Qe(`··`,`[`);for(;r<n.length;r++)for(c=(o=n[r]).removed?`--`:o.added?`++`:`··`,o.added?d+=H[c]().underline(U(`Expected:`))+`
|
|
9
|
-
`:o.removed&&(d+=H[c]().underline(U(`Actual:`))+`
|
|
10
|
-
`),i=0;i<o.value.length;i++)for(l=o.value[i]&&typeof o.value[i]==`object`,s=W(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+=Qe(c,u);return d+Qe(`··`,`]`)}function rt(e,t,n=0){let r=0,i,a=``,o=Ve(e,t),s=String(t.split(/\r?\n/g).length-n).length;for(;r<o.length;r++)a+=tt(i=o[r],n,s),n&&!i.removed&&(n+=i.count);return a}function it(e,t){let n=Ie(e,t),r=0,i=``,a,o=e.length,s=t.length,c=et(e),l=et(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+=at(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+R.red(a)}function at(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)+R.dim(`[${o}]`),t+=` `.repeat(l)+R.dim(`[${s}]`),n+=c+o.length+2,r+=l+s.length+2,a=Math.max(n,r)}return H[`++`](`++`+t+` `.repeat(i+a-r)+U(`(Expected)`))+`
|
|
11
|
-
`+H[`--`](`--`+e+` `.repeat(i+a-n)+U(`(Actual)`))+`
|
|
12
|
-
`}function ot(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]=ot(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]=ot(i,t[n]));for(n in e)s.hasOwnProperty(n)||(s[n]=e[n])}return s}function st(){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 W(e){return JSON.stringify(e,st(),2).replace(/"\[__NAN__\]"/g,`NaN`).replace(/"\[__VOID__\]"/g,`undefined`)}function ct(e,t){if(Array.isArray(t)&&Array.isArray(e))return nt(e,t);if(t instanceof RegExp)return it(``+e,``+t);let n=e&&typeof e==`object`,r=t&&typeof t==`object`;return n&&r&&(e=ot(e,t)),r&&(t=W(t)),n&&(e=W(e)),t&&typeof t==`object`&&(e=W(ot(e,t)),t=W(t)),n=typeof e==`string`,r=typeof t==`string`,n&&/\r?\n/.test(e)?rt(e,``+t):r&&/\r?\n/.test(t)?rt(``+e,t):n&&r?it(e,t):at(e,t)}var lt=r({Assertion:()=>ut,equal:()=>pt,fixture:()=>bt,instance:()=>gt,is:()=>ft,match:()=>_t,not:()=>q,ok:()=>dt,snapshot:()=>vt,throws:()=>xt,type:()=>ht,unreachable:()=>mt});function G(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 ut=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 K(e,t,n,r,i,a,o){if(e)return;let s=o||a;throw o instanceof Error?o:new ut({actual:t,expects:n,operator:r,message:s,details:i&&i(t,n),generated:!o})}function dt(e,t){K(!!e,!1,!0,`ok`,!1,`Expected value to be truthy`,t)}function ft(e,t,n){K(e===t,e,t,`is`,ct,`Expected values to be strictly equal:`,n)}function pt(e,t,n){K(L(e,t),e,t,`equal`,ct,`Expected values to be deeply equal:`,n)}function mt(e){K(!1,!0,!1,`unreachable`,!1,`Expected not to be reached!`,e)}function ht(e,t,n){let r=typeof e;K(r===t,r,t,`type`,!1,`Expected "${r}" to be "${t}"`,n)}function gt(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";K(e instanceof t,e,t,`instance`,!1,`Expected value to be an instance of ${r}`,n)}function _t(e,t,n){typeof t==`string`?K(e.includes(t),e,t,`match`,!1,`Expected value to include "${t}" substring`,n):K(t.test(e),e,t,`match`,!1,`Expected value to match \`${String(t)}\` pattern`,n)}function vt(e,t,n){e=G(e),t=G(t),K(e===t,e,t,`snapshot`,rt,`Expected value to match snapshot:`,n)}var yt=(e,t)=>rt(e,t,1);function bt(e,t,n){e=G(e),t=G(t),K(e===t,e,t,`fixture`,yt,`Expected value to match fixture:`,n)}function xt(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e(),K(!1,!1,!0,`throws`,!1,`Expected function to throw`,n)}catch(e){if(e instanceof ut)throw e;typeof t==`function`?K(t(e),!1,!0,`throws`,!1,`Expected function to throw matching exception`,n):t instanceof RegExp&&K(t.test(e.message),!1,!0,`throws`,!1,`Expected function to throw exception matching \`${String(t)}\` pattern`,n)}}function q(e,t){K(!e,!0,!1,`not`,!1,`Expected value to be falsey`,t)}q.ok=q,ft.not=function(e,t,n){K(e!==t,e,t,`is.not`,!1,`Expected values not to be strictly equal`,n)},q.equal=function(e,t,n){K(!L(e,t),e,t,`not.equal`,!1,`Expected values not to be deeply equal`,n)},q.type=function(e,t,n){let r=typeof e;K(r!==t,r,t,`not.type`,!1,`Expected "${r}" not to be "${t}"`,n)},q.instance=function(e,t,n){let r="`"+(t.name||t.constructor.name)+"`";K(!(e instanceof t),e,t,`not.instance`,!1,`Expected value not to be an instance of ${r}`,n)},q.snapshot=function(e,t,n){e=G(e),t=G(t),K(e!==t,e,t,`not.snapshot`,!1,`Expected value not to match snapshot`,n)},q.fixture=function(e,t,n){e=G(e),t=G(t),K(e!==t,e,t,`not.fixture`,!1,`Expected value not to match fixture`,n)},q.match=function(e,t,n){typeof t==`string`?K(!e.includes(t),e,t,`not.match`,!1,`Expected value not to include "${t}" substring`,n):K(!t.test(e),e,t,`not.match`,!1,`Expected value not to match \`${String(t)}\` pattern`,n)},q.throws=function(e,t,n){!n&&typeof t==`string`&&(n=t,t=null);try{e()}catch(e){typeof t==`function`?K(!t(e),!0,!1,`not.throws`,!1,`Expected function not to throw matching exception`,n):t instanceof RegExp?K(!t.test(e.message),!0,!1,`not.throws`,!1,`Expected function not to throw exception matching \`${String(t)}\` pattern`,n):t||K(!1,!0,!1,`not.throws`,!1,`Expected function not to throw`,n)}};var St=/\u001b\[[0-9;]*m/g,Ct=e=>e.replace(St,``);function wt(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 Tt(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:wt(Error().stack)})}catch(r){if(r?.name!==`Assertion`||(t.push({label:Ct(String(r.message??o??n)),operator:n,pass:!1,actual:r.actual,expected:r.expects,diff:r.details?Ct(String(r.details)):void 0,location:wt(Error().stack)}),e===`hard`))throw r}}},r=lt,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 Et=class extends Error{};function Dt(e,t){let n=e.opts.value;return n?n(t):t}function Ot(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function kt(e,t,n){switch(t.kind){case`select`:{let r=t.opts.options;if(r.length===0)throw new Et(`No options available for "${e}"`);let i=r.map(e=>Dt(t,e));if(n!==void 0){if(!i.some(e=>Ot(e,n)))throw new Et(`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,kt(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 Et(`"${e}" needs at least ${i} items`);if(a!==void 0&&r.length>a)throw new Et(`"${e}" allows at most ${a} items`);return r.map(n=>kt(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 At(e,t={}){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,kt(e,n,t[e])]))}function jt(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(t.kind===`select`||t.kind===`multiselect`){let n=t.opts.label,r=t.opts.options.map(e=>({label:n?n(e):String(Dt(t,e)),value:Dt(t,e)}));return[e,{kind:t.kind,options:r}]}return[e,{kind:t.kind,default:t.opts.default}]}))}var Mt={comma:`,`,space:` `,pipe:`|`},Nt=e=>typeof Blob<`u`&&e instanceof Blob;function Pt(e,t=`indices`,n=``,r=[]){if(typeof t==`string`||n||typeof e!=`object`||!e)Ft(n,e,r,typeof t==`string`?t:`indices`);else for(let[n,i]of Object.entries(e))Ft(n,i,r,t[n]??`indices`);return r}function Ft(e,t,n,r){if(t!=null){if(Array.isArray(t)&&r in Mt&&t.every(e=>typeof e!=`object`||!e))n.push([e,t.map(String).join(Mt[r])]);else if(Array.isArray(t))t.forEach((t,i)=>{Ft(r===`indices`||r in Mt?`${e}[${i}]`:r===`brackets`?`${e}[]`:e,t,n,r)});else if(typeof t==`object`)for(let[i,a]of Object.entries(t))Ft(e?`${e}[${i}]`:i,a,n,r);else n.push([e,String(t)])}}function It(e,t=`indices`){return Pt(e,t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}function Lt(e){let t=new FormData,n=(e,n)=>{n!=null&&(Nt(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 Rt(e){return JSON.stringify(typeof e==`string`?{query:e}:e)}function zt(e,t,n,r){switch(e){case`json`:return{body:JSON.stringify(t),contentType:`application/json`};case`graphql`:return{body:Rt(t),contentType:`application/json`};case`form`:return{body:It(t,n),contentType:`application/x-www-form-urlencoded`};case`text`:return{body:String(t),contentType:`text/plain`};case`multipart`:return{body:Lt(t)};case`binary`:return{body:t,contentType:r||(Nt(t)&&t.type?t.type:`application/octet-stream`)};default:return{body:t}}}function Bt(e){if(Nt(e)){let t=e;return{file:t.name??`file`,type:t.type,size:t.size}}return Array.isArray(e)?e.map(Bt):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Bt(t)])):e}var J=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Vt=e=>[`string`,`number`,`boolean`].includes(typeof e);function Ht(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 Ut(e,t){if(J(e)&&J(t)){let n={...e};for(let[e,r]of Object.entries(t))e in n&&(n[e]=Ut(n[e],r));return n}if(Array.isArray(e)&&Array.isArray(t)){if(t.length===0)return e;if(t.every(Vt)&&e.every(Vt))return t;let n=e[0];return J(n)&&t.every(J)?t.map(e=>Ut(n,e)):e}return Vt(t)&&Vt(e)&&typeof t==typeof e?t:typeof e==`number`&&typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t))?Number(t):e}function Wt(e,t){let n={...e},r=Object.entries(t).filter(([,e])=>e!==void 0&&e!==``);for(let[e,t]of r)e in n&&!J(n[e])&&!Array.isArray(n[e])?n[e]=Ht(t,n[e]):r.length===1&&`id`in n&&/^(id|.*[a-z]Id|.*_id)$/.test(e)&&!J(n.id)&&!Array.isArray(n.id)&&(n.id=Ht(t,n.id));return n}var Gt=e=>Vt(e),Kt=new Set([`id`,`object`,`type`,`kind`,`created`,`updated`,`url`,`livemode`,`metadata`,`status`]);function qt(e,t=[],n=[],r=0){if(r>6)return n;if(J(e))for(let[i,a]of Object.entries(e))qt(a,[...t,i],n,r+1);else Array.isArray(e)?e.length&&qt(e[0],[...t,0],n,r+1):Gt(e)&&n.push({path:t,value:e});return n}var Jt=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n)return;n=n[e]}return n};function Yt(e,t,n=[],r=[],i=0){if(i>5)return r;if(J(e))for(let[a,o]of Object.entries(e))a===t&&Gt(o)?r.push([...n,a]):Yt(o,t,[...n,a],r,i+1);else Array.isArray(e)&&e.length&&Yt(e[0],t,[...n,0],r,i+1);return r}var Xt=(e,t)=>typeof e==typeof t||typeof t==`number`&&typeof e==`string`&&e.trim()!==``&&!Number.isNaN(Number(e));function Zt(e,t,n){let r=Jt(e,t.slice(0,-1));typeof r==`object`&&r&&(r[t[t.length-1]]=n)}function Qt(e,t,n){let r=structuredClone(e),i=new Set(qt(n).map(e=>e.path.join(`\0`)));for(let e of qt(t)){if(Jt(r,e.path)!==void 0)continue;let t=String(e.path[e.path.length-1]);if(Kt.has(t)||typeof e.path[e.path.length-1]==`number`)continue;let n=Yt(r,t).filter(e=>!i.has(e.join(`\0`)));if(n.length!==1)continue;let a=n[0],o=Jt(r,a);Xt(e.value,o)&&(Zt(r,a,Ht(e.value,o)),i.add(a.join(`\0`)))}return r}var $t=/^(limit|per_?page|page_?size|size|count|max|max_?results|take)$/i;function en(e){return Array.isArray(e)?e[0]:typeof e==`string`&&e.includes(`,`)?e.split(`,`)[0]?.trim():e}function tn(e,t){let n=Object.entries(t).map(([e,t])=>[e,en(t)]).filter(([,e])=>Gt(e)&&e!==``);if(n.length===0)return e;let r=e=>{let t={...e};for(let[e,r]of n)e in t&&Gt(t[e])&&Xt(r,t[e])&&(t[e]=Ht(r,t[e]));return t},i=n.find(([e])=>$t.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(J))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(J(e)){let t={...e},n=Object.entries(t).filter(([,e])=>Array.isArray(e)&&e.length>0&&e.every(J));if(n.length===1)t[n[0]?.[0]]=o(n[0]?.[1]);else return r(t);return t}return e}function nn(e,t){let n=e;if(t.body!==void 0){let e=J(n)&&Array.isArray(t.body)&&t.body.length>0&&t.body.every(J)?t.body[0]:t.body;(J(n)&&J(e)||Array.isArray(n)&&Array.isArray(e))&&(n=Ut(n,e),J(n)&&J(e)&&(n=Qt(n,e,e)))}return J(n)&&t.path&&(n=Wt(n,t.path)),t.query&&(n=tn(n,t.query)),n}var rn=e=>typeof e==`object`&&!!e&&(`data`in e||`init`in e||`headers`in e||`delayMs`in e);function an(e){return Object.fromEntries(Object.entries(e??{}).map(([e,t])=>[e,typeof t==`function`?t():t]))}function on(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 cn(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=nn(g,{body:r.body,path:a?.pathParams,query:a?.rawQuery})),f!==void 0){let e;rn(f)?(e=await sn(f.data),h={...h,...an(f.init)},m=f.headers?t(f.headers,h):{},p=f.delayMs??0):e=await sn(f),e!==void 0&&(g=i(g,e))}return p&&await n(p),{...cn(d,g===void 0?void 0:t(g,h)),headers:{"content-type":`application/json`,...m}}}}async function sn(e){return typeof e==`function`?(await e()).default:e}function cn(e,t){return{status:e,headers:{"content-type":`application/json`},text:t===void 0?``:JSON.stringify(t),body:t}}var ln=123,un=125,dn=e=>e===32||e===9||e===10||e===13,fn=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95||e===36||e===45,pn=[115,101,99,114,101,116,115,46];function mn(e,t){let n=t+2;for(;n<e.length&&dn(e[n]);)n++;for(let t of pn)if(e[n++]!==t)return;let r=n;for(;n<e.length&&fn(e[n]);)n++;if(n===r)return;let i=String.fromCharCode(...e.subarray(r,n));for(;n<e.length&&dn(e[n]);)n++;if(e[n]===un&&e[n+1]===un)return{start:t,end:n+2,name:i}}function hn(e){let t=[];for(let n=0;n<e.length-1;n++)if(e[n]===ln&&e[n+1]===ln){let r=mn(e,n);r&&(t.push(r),n=r.end-1)}return t}var gn=new TextEncoder;function _n(e){return[...new Set(hn(e).map(e=>e.name))]}function vn(e,t){let n=hn(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),gn.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 yn=new TextDecoder;function bn(e,t){return e.includes(`{{`)?yn.decode(vn(gn.encode(e),t)):e}var xn=new TextDecoder(`utf-8`,{fatal:!0}),Sn=new TextEncoder;function Cn(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function wn(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 Tn(e){try{return{kind:`text`,text:xn.decode(e)}}catch{return{kind:`b64`,b64:Cn(e)}}}function En(e){return e.kind===`text`?Sn.encode(e.text):wn(e.b64)}async function Dn(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:Tn(new Uint8Array(await e.arrayBuffer()))}:{}}}function On(e){let t=e.status===204||e.status===205||e.status===304;return new Response(e.body&&!t?En(e.body):null,{status:e.status,headers:e.headers})}var kn=class extends Error{names;constructor(e){super(`Missing secrets: ${e.join(`, `)}`),this.names=e,this.name=`MissingSecretsError`}};function An(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(),jn=class extends Error{};function Mn(){return`run_${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`}var Nn=(e={})=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e.toLowerCase(),t]));function Pn(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]=typeof r==`function`?r():r;return t}async function Fn(e){return typeof e==`function`?(await e()).default:e}async function In(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=>In(e,t,n)));let[r,...i]=t;return l(e)&&r in e?{...e,[r]:await In(e[r],i,n)}:e}async function Ln(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 In(o,e.split(`.`),a);return o}function Rn(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 zn(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 kn([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 jn(`No session value "${a}" for profile "${n}"`);return t.mask.add(String(o)),String(o)}),i=e=>Nt(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 Bn(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 Vn(e,t){return{status:e.status,ok:e.status>=200&&e.status<300,headers:Nn(e.headers),data:e.body,text:e.text,durationMs:t}}async function Hn(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 Wn(e,await r.login(),`Login (${t})`,Un,`auth`,!0);if(n.push(o),!s?.ok)throw new jn(`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 Un={params:{},captured:{},from:{}};async function Wn(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`,Pn(n.input.init)],[`param`,a.params],[`capture`,a.captured],[`override`,Pn(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 jn(`Example "${n.input.example}" not found for ${n.op.id}`);let h=i(m?.body,await Fn(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=Rn(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=Nn(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 Ln(y,n.op.files??[],C,e.o.readFile,m?.dir));let w=s?void 0:Bn(e,n),T=w?e.o.auth?.[w]:void 0,ee={};T&&w&&(S={...Nn(t(T.apply.headers??{},l)),...S},Object.assign(ee,t(T.apply.query??{},l)));let E=n.op.path.replace(/\{([^}]+)\}/g,(e,t)=>{let n=b[t];if(n==null)throw new jn(`Missing path parameter "${t}"`);return encodeURIComponent(String(n))}),te={};for(let[e,t]of Object.entries({...x,...ee}))t!=null&&(te[e]=Array.isArray(t)?t.map(String):String(t));let D={service:n.op.service,opId:n.op.id,method:n.op.method,url:E,query:te,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:Bt(D.body),profile:w},X(e,{type:`request`,name:r,request:d.request});let ne=async()=>{w&&await Hn(e,w,u);let{mock:t,...n}=D,r={...zn(n,e,w),mock:t},i=e.o.now?.()??Y();return Vn(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 Hn(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=Tt(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 Gn(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 Kn(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 qn(e,t,n,r,i){let a=An({schemaVersion:1,runId:Mn(),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:Kn(r),startedAt:new Date(i).toISOString(),durationMs:(e.o.now?.()??Y())-i,totals:Gn(r),steps:r},e.mask);return X(e,{type:`done`,result:a}),a}function Jn(e){return{o:e,sessions:new Map,inflight:new Map,mask:new Set}}async function Yn(e,t){let n=Jn(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 Wn(n,e,i,Un);return qn(n,`request`,{id:e.op.id,title:i},[...o,a],r)}async function Xn(e,t){let n=Jn(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=At(e.meta.params??{},t.params)}catch(t){return i.push({name:`params`,kind:`input`,status:`error`,assertions:[],captured:{},error:t.message,durationMs:0}),qn(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 Wn(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 Wn(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=jt(e);X(n,{type:`input:required`,name:r.name,controls:a});let o=At(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=Tt(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 Et;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 qn(n,`sequence`,e.meta,i,r)}function Zn(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 Qn(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=zt(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(Zn(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 $n=`specbook`;function er(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!==`${$n}:reply`||!t.reply)return;let r=t.reply;(i===void 0||r.id===i)&&(s(),n(t.reply))},o=()=>{s(),window.postMessage({channel:`${$n}: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:`${$n}:call`,call:e},`*`)})}}}async function tr(e=250){let t=globalThis.__SPECBOOK_EXTENSION__;if(t)return t;if(typeof window>`u`)return;let n=er(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 nr=0;function rr(e,t){return Qn({baseUrl:t,fetch:async(t,n)=>{let r=new Request(t,n),i=`c${Date.now().toString(36)}${nr++}`,a=await e.send({v:1,type:`fetch`,id:i,req:await Dn(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 On(a.res)}})}var ir=`specbook.secrets.v1`,ar={},or=()=>{try{let e=sessionStorage.getItem(ir);return e?JSON.parse(e):ar}catch{return ar}},sr=e=>{ar=e;try{sessionStorage.setItem(ir,JSON.stringify(e))}catch{}},cr={get:(e,t)=>or()[e]?.[t],set(e,t,n){let r=or();sr({...r,[e]:{...r[e],[t]:n}})},remove(e,t){let n=or(),{[t]:r,...i}=n[e]??{};sr({...n,[e]:i})}},lr=e=>{try{return e?new URL(e).origin:void 0}catch{return}},ur=/\{\{\s*secrets\.([\w$-]+)\s*\}\}/g;function dr(e){return e.proxy?`proxy`:e.pageOrigin&&lr(e.baseUrl)===e.pageOrigin?`direct`:e.extension?`extension`:`direct`}function fr(e,t){try{return new URL(e,t).toString()}catch{return e}}var pr=e=>{let t=new Set,n=e=>{if(typeof e==`string`)for(let n of _n(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 mr(e,t){return(n,r)=>{let i=pr(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 kn(s);let c=e=>typeof e==`string`?bn(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 hr(e){return(t,n)=>{let r=dr({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)}}function gr(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(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 l(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 u(e,t){let n=await o(t);return[...new Set([...Object.keys(n.vars??{}),...Object.keys(n.environments?.[e]?.vars??{}),...Object.keys(await l(e))])]}async function f(n,i,a){if(n===`mock`)return on({loader:r});let s=await o(a),c=globalThis.location?.href,l=globalThis.location?.origin,u=e=>{let t=s.services?.[e]?.baseUrl?.[n];if(!t)throw Error(`No base URL for ${e} in the "${n}" environment`);return fr(t,c)},d=e.mode!==`static`,f=await t.extension?.(),p=f?rr(f,v):void 0,m=t.secrets??cr,h=Qn({baseUrl:u}),g=d?Qn({baseUrl:e=>`${i}/${n}/${e}`}):void 0;return hr({direct:y(mr(h,{store:m,originFor:_,unresolved:`fail`})),proxy:g?mr(g,{store:m,originFor:_,unresolved:`keep`}):void 0,extension:p?mr(p,{store:m,originFor:_,unresolved:`keep`}):void 0,baseOf:v,pageOrigin:l});function _(e){return lr(v(e))}function v(e){try{return u(e)}catch{return``}}function y(e){return async(t,r)=>{try{return await e(t,r)}catch(e){throw 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 p(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 m=e=>e.replace(/^\.\//,``),h=t=>e.requestExamples[t]??[];async function g(e,t,n){let r=h(e).find(e=>e.name===t);if(r)return{...(await r.load(n)).default,source:r.source,dir:r.dir}}async function _(t,n){let r=await e.assets[`${n}/${m(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()],m(t).split(`/`).pop(),{type:i.headers.get(`content-type`)??void 0})}async function v(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 l(e.env)},overrides:e.vars,params:e.params,transport:await f(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)=>g(`${t.service}/${t.id}`,n,e.version),readFile:(t,n)=>_(t,n??e.fileDir)}}async function y(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 g(`${e.op.service}/${e.op.id}`,i,t.version):void 0;return a([l,r,e.dataPatches,o,s,c,t.vars])}async function b(t,r){if(e.loadFaker&&await y(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 v(r);return t.kind===`sequence`?Xn(t,i):Yn(r.mockStatus!==void 0&&r.env===`mock`?t.with({mock:{status:r.mockStatus}}):t,i)}async function x(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 S(t,n){return(await e.operations[t]?.(n))?.[t.split(`/`)[1]]?.meta}async function C(e,t){let n=`${e.op.service}/${e.op.id}`,r=e.input.example?await g(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 w(e,t){let n={};await Promise.all(e.map(async e=>{try{let r=_r(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 T(e,t){let n=[];return await Promise.all(e.map(async e=>{try{let r=_r(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:c,environmentRisks:s,managedSecrets:p,run:b,operationRequest:x,operationMeta:S,examplesOf:h,knownVars:u,loadExample:g,savedExample:C,loadVariants:w,loadSequences:T}}function _r(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,vr,Q=gr(o,{extension:async()=>{if(vr&&Date.now()-vr.at<3e4)return vr.bridge;let e=await tr();return vr={at:Date.now(),bridge:e},e}}),yr=u===`static`;async function br(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`);N.value=Date.now()}function xr(){let e=globalThis.location?.hostname??``;return Ce({host:e,published:yr,badge:E.value.badge})?p(`p`,{class:`powered-by`,children:p(`a`,{href:we(e),target:`_blank`,rel:`noopener`,children:`Powered by Specbook`})}):null}var Sr=60,Cr=`Default`;function wr(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 Tr({e}){return p(`button`,{type:`button`,class:`op-row ${wr(e)?`active`:``}`,onClick:()=>M(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(ge,{})})]}),p(`span`,{class:`op-path`,children:e.path})]})}function Er(e,t){let n=j.value.trim(),r=t.length<=1,i=r?t[0]?.id??``:pe.value,a=S(()=>e.filter(e=>e.kind===`op`),[e]),o=S(()=>e.filter(e=>e.kind===`seq`),[e]);return{q:n,single:r,svc:i,shownOps:S(()=>{let e=i?a.filter(e=>e.service===i):a;return n?me(e,n,500):e},[a,i,n]),shownFlows:S(()=>{let e=i&&!r?o.filter(e=>e.tags?.includes(i)):o;return n?me(e,n,100):e},[o,i,n,r])}}function Dr({entries:e,services:t}){let n=g(null),r=g(null),[i,a]=y(new Map),{q:o,single:s,svc:c,shownOps:l,shownFlows:u}=Er(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=S(()=>{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=S(()=>{let e=new Map;for(let t of u){let n=t.flowGroup?.trim()||Cr;e.set(n,[...e.get(n)??[],t])}let t=e=>e===Cr?0:1;return[...e.entries()].sort(([e],[n])=>t(e)-t(n)||e.localeCompare(n))},[u]),m=l.length>Sr&&!o,_=(e,t)=>i.get(e)??(!m||t.some(wr)),v=(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:()=>pe.value=``,children:`All`}),t.map(e=>p(`button`,{type:`button`,role:`tab`,"aria-selected":c===e.id,class:`pill ${c===e.id?`on`:``}`,onClick:()=>pe.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:j.value,onInput:e=>j.value=e.target.value,onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),r.current?.querySelector(`.op-row, .flow-row`)?.focus()),e.key===`Escape`&&(j.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 ${wr(e)?`active`:``}`,onClick:()=>M(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:()=>v(e,t),children:[p(`span`,{class:`caret`,children:n?`▾`:`▸`}),` `,e,` `,p(`span`,{class:`count`,children:t.length})]}),n&&t.map(e=>p(Tr,{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:()=>j.value=``,children:`Clear the filter`})]})]})}function Or({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(xe,{}),p(`button`,{type:`button`,class:`btn primary overview-browse`,onClick:()=>M({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(xr,{})]})}function kr(){let e=P.value,t=F.value.includes(e)?F.value:[e,...F.value],n=ye.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=>P.value=e.target.value,children:t.map(e=>p(`option`,{value:e,children:e}))})]})}var Ar={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};async function jr(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 Mr(){let[e,t]=y(),[n,r]=y({}),[i,a]=y(!1),[o,s]=y(`environment`),[c,l]=y({}),[u,d]=y({name:``,value:``}),[m,g]=y(),_=P.value,v=()=>fetch(`/__specbook/environment?env=${encodeURIComponent(_)}`).then(e=>e.json()).then(t,()=>t(void 0));h(()=>{yr||(v(),s(_===`mock`?`session`:`environment`),l({}))},[_]),h(()=>{Q.config(N.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=S(()=>_===`mock`?0:e?.secrets.filter(e=>!e.source).length??0,[e,_]);if(yr||!e||!(e.secrets.length>0||Object.keys(e.vars).length>0||_!==`mock`))return null;let x=async e=>{g(void 0);try{await e(),await v()}catch(e){g(e instanceof Error?e.message:String(e))}},C=(e,t)=>x(async()=>{await jr(`/__specbook/secret`,{name:e,value:t,scope:o,env:o===`shared`?void 0:_}),l(t=>({...t,[e]:``}))}),w=(e,t)=>x(()=>jr(`/__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})),m&&p(`p`,{class:`envmenu-warn`,children:m}),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&&w(e,n)},onKeyDown:e=>e.key===`Enter`&&e.target.blur()}),p(`button`,{type:`button`,class:`icon`,"aria-label":`Remove ${e}`,onClick:()=>w(e,null),children:`×`})]})),p(`form`,{class:`envrow`,onSubmit:e=>{e.preventDefault(),u.name&&w(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(f,{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(),C(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?Ar[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:()=>C(e.name,``),title:`Remove the value from the selected place`,children:`Clear`})]})]}))]})]})]})]})}var Nr=`https://github.com/specbook-dev/specbook`;function Pr(){return globalThis.__SPECBOOK_VIEWER__?.source?p(`a`,{class:`btn gh-star`,href:Nr,target:`_blank`,rel:`noopener`,title:`Specbook's source is on GitHub`,children:[p(ve,{}),p(`span`,{class:`gh-label`,children:`GitHub`})]}):null}var Fr=`specbook:list-width`,Ir=()=>Math.round(innerWidth*.55);function Lr(){try{let e=Number(localStorage.getItem(Fr));return e>=280?e:void 0}catch{return}}var $=T(Lr());function Rr(e){$.value=e===void 0?void 0:Math.round(Math.max(280,Math.min(Ir(),e)));try{$.value===void 0?localStorage.removeItem(Fr):localStorage.setItem(Fr,String($.value))}catch{}}function zr(){let e=e=>{e.preventDefault(),document.body.classList.add(`resizing`);let t=e=>Rr(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:()=>Rr(void 0),onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),Rr(t()-24)):e.key===`ArrowRight`&&(e.preventDefault(),Rr(t()+24))}})}function Br({entries:e}){let[t,n]=y(``),[r,i]=y(0),a=g(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=S(()=>me(e,t,30),[e,t]);if(!o)return null;let c=e=>{e&&(A.value=!1,M(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 Vr(){let e=globalThis.__SPECBOOK_VIEWER__,[t,n]=y(!1),[r,i]=y(!1);if(!e?.source)return null;k.value;let a=C(e.source),o=a.ok?b({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(_e,{}),p(`span`,{class:`share-label`,children:`Share`})]}),t&&p(`div`,{class:`share-pop`,role:`menu`,children:o?p(f,{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 Hr={auto:`Theme: follows your system. Click for light.`,light:`Theme: light. Click for dark.`,dark:`Theme: dark. Click to follow your system.`},Ur=({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(f,{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(f,{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 Wr(){let e=v.value;return p(`button`,{type:`button`,class:`icon theme-toggle`,title:Hr[e],"aria-label":Hr[e],"data-theme-mode":e,onClick:m,children:p(Ur,{mode:e})})}var Gr=globalThis.__SPECBOOK_VIEWER__?.source?x:void 0;{let e=Object.keys(Z.manifests);ae(e.length===1?e[0]:void 0)}var Kr=T([]);function qr(){let[e,t]=y(),n=k.value.kind===`op`||k.value.kind===`seq`;return h(()=>{n&&!e&&ee(()=>import(`./Host-DdTTHeXU.js`).then(t),__vite__mapDeps([0,1,2,3,4]),import.meta.url)},[n,e]),n?e:void 0}function Jr(){let[e,t]=y({}),[n,r]=y(void 0),[i,a]=y(!1);h(()=>{let e=()=>{k.value=le(location.hash)};return addEventListener(`hashchange`,e),Q.config(N.value).then(async e=>{Kr.value=Object.keys(e.faker?.locales??{}),e.faker?.default&&(be.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,ie(t,o,r.length===1?r[0]?.title??`Specbook`:`Specbook`)}).catch(()=>{E.value={...E.value,ready:!0}}).finally(()=>{Q.loadVariants(Z.requests,N.value).then(t);let e=Z.sequences.filter(e=>Z.unresolvedSequences.includes(e.file));e.length&&Q.loadSequences(e,N.value).then(r)}),Q.environments(N.value).then(e=>{F.value=e}),Q.environmentRisks(N.value).then(e=>{ye.value=e}),()=>removeEventListener(`hashchange`,e)},[]);let o=g(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=S(()=>{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`?Yr(l.key):void 0,d=l.kind===`seq`?l.id:void 0,[f,m]=y();h(()=>{if(!d)return;let e=Z.sequenceMeta[d]?.file;if(e){let t=Z.sequences.filter(t=>t.file===e);Q.loadSequences(t,N.value).then(e=>m(e[0]))}else m(n?.find(e=>e.seq.meta.id===d))},[d,n,N.value]);let _=f?.seq.meta.id===d?f:void 0,v=qr(),b=()=>M(fe(k.value)),x=S(()=>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=S(()=>{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?()=>M({...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=>M(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:()=>M({kind:`home`}),children:[(E.value.logo??Gr)&&p(`img`,{class:`brand-logo`,src:E.value.logo??Gr,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(kr,{})}),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:I.value===void 0?`random`:`fixed`,onChange:e=>{I.value=e.target.value===`fixed`?I.value??42:void 0},children:[p(`option`,{value:`random`,children:`New each run`}),p(`option`,{value:`fixed`,children:`Fixed`})]})]}),I.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:I.value,onInput:e=>{let t=e.target.valueAsNumber;I.value=Number.isFinite(t)?t:void 0}})]}),Kr.value.length>1&&p(`label`,{class:`row muted`,children:[`locale`,p(`select`,{value:be.value??``,onChange:e=>be.value=e.target.value||void 0,children:Kr.value.map(e=>p(`option`,{value:e,children:e}))})]}),p(Mr,{}),p(`label`,{class:`row`,children:[`Environment`,p(`select`,{value:P.value,onChange:e=>P.value=e.target.value,children:F.value.map(e=>p(`option`,{value:e,children:e}))})]}),p(Pr,{}),p(Vr,{}),p(Wr,{})]})]}),p(`div`,{class:`layout`,"data-view":l.kind===`home`?`splash`:`list`,children:[p(`nav`,{class:`list-col`,"aria-label":`Operations and flows`,children:p(Dr,{entries:c,services:x})}),p(zr,{}),p(`main`,{class:`stage`,children:(l.kind===`home`||l.kind===`browse`)&&p(Or,{services:x})})]}),p(Br,{entries:c}),v&&l.kind===`op`&&u&&p(v.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}),v&&l.kind===`seq`&&_&&p(v.Host,{kind:`seq`,modal:!1,info:_,tab:l.tab,onNavigate:w,onPrev:C.prev,onNext:C.next,onClose:b})]})}function Yr(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 Xr=r({});w(),_(p(Jr,{}),document.getElementById(`app`));export{N as _,Z as a,ur as c,Pt as d,Nt as f,I as g,be as h,yr as i,lr as l,F as m,kr as n,br as o,P as p,Q as r,fr as s,Xr as t,cr as u,he as v,M as y};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./main-uV4JzQPd.js","./registry-DI74Wtj8.js","./panel-CoQ6iQpX.js","./panel-Coi9H1nv.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var e=new URL(`worker-Dw3Ps3hk.js`,import.meta.url).href;function t(){let t=new URL(e,import.meta.url);if(t.origin===location.origin)return new Worker(t,{type:`module`});let n=new Blob([`import ${JSON.stringify(t.href)}`],{type:`text/javascript`});return new Worker(URL.createObjectURL(n),{type:`module`})}var n=class{worker;next=1;pending=new Map;constructor(){this.worker=t(),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)}},r=`modulepreload`,i=function(e,t){return new URL(e,t).href},a={},o=function(e){return e.pathname.endsWith(`.css`)},s=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},c=function(e,t,n){let c=Promise.resolve();if(t&&t.length>0){let e,l=document.querySelector(`meta[property=csp-nonce]`),u=l?.nonce||l?.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)}c=d(t.map(t=>{t=i(t,n);let c=f(t),l=o(c);return s(a,c.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((l?e.styles:e.all).has(c.href))return;let t=document.createElement(`link`);if(t.rel=l?`stylesheet`:r,l||(t.as=`script`),t.crossOrigin=``,t.href=c.href,u&&t.setAttribute(`nonce`,u),document.head.appendChild(t),l)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${c}`)))})})}).filter(e=>e!==void 0))}function l(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return c.then(t=>{for(let e of t||[])e.status===`rejected`&&l(e.reason);return e().catch(l)})};async function l(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 c(()=>import(`./main-uV4JzQPd.js`).then(e=>e.t),__vite__mapDeps([0,1,2,3]),import.meta.url),u()}function u(){navigator.connection?.saveData||(window.requestIdleCallback??(e=>setTimeout(e,1500)))(()=>{c(()=>import(`./registry-DI74Wtj8.js`).then(e=>e.n).then(e=>e.loadFaker()),[],import.meta.url).catch(()=>{})})}export{c as n,n as r,l as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e,t,n,r,i,a,o,s,c,l,u,d={},f=[],p=/^m(i|n|o|s|text|space)$/,m=Array.isArray,h=f.slice,g=Object.assign;function _(e){e&&e.parentNode&&e.remove()}function v(n,r,i,a,o){var s={type:n,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o||++t,__i:-1,__u:0};return!o&&e.vnode&&e.vnode(s),s}function y(e){return e.children}function b(e,t){this.props=e,this.context=t,this.__g=0}function x(e,t){if(t==null)return e.__?x(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])&&n.__e)return n.__e;return typeof e.type!=`function`||e.props.__P?null:x(e)}function S(e){if((e=e.__)&&e.__c&&!e.props.__P)return e.__e=null,e.__k.some(function(t){return t&&(e.__e=t.__e)}),S(e)}function C(t){(8&t.__g||!(t.__g|=8)||!r.push(t)||a++)&&i==e.debounceRendering||((i=e.debounceRendering)||queueMicrotask)(w)}function w(){var t,n,i,s,c,l,u,d,f;try{for(n=1;r.length;)r.length>n&&r.sort(o),t=r.shift(),n=r.length,8&t.__g&&(s=void 0,c=void 0,l=(c=(i=t).__v).__e,u=[],d=[],(f=i.__P)&&((s=g({constructor:void 0},c)).__v=c.__v+1,e.vnode&&e.vnode(s),j(f,s,c,i.__n,f.namespaceURI,32&c.__u?[l]:null,u,l||x(c),32&c.__u,d),s.__v=c.__v,s.__.__k[s.__i]=s,ne(u,s,d),c.__=c.__e=null,s.__e!=l&&S(s)))}finally{r.length=a=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var p,m,h,g,_,v,y=r.__k||f,b=t.length;for(c=T(n,t,y,c,b),p=0;p<b;p++)(h=n.__k[p])!=null&&(m=~h.__i&&y[h.__i]||d,h.__i=p,v=j(e,h,m,i,a,o,s,c,l,u),g=h.__e,(m.ref!=h.ref||8&m.__u)&&(m.ref&&M(m.ref,null,h,m),h.ref&&u.push(h.ref,h.__c||g,h)),_||=g,4&h.__u?(c=E(h,c,e,!m.__v),m.__e&&(m.__e=null)):typeof h.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),h.__u&=-7);return n.__e=_,c}function T(e,t,n,r,i){var a,o,s,c,l,u,d,f,p,h,g=n.length,_=g,b=0,S=!1,C=e.__k=Array(i);for(a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o!=`object`||o.constructor==String?o=C[a]=v(null,o):m(o)?o=C[a]=v(y,{children:o}):o.constructor===void 0&&o.__b?o=C[a]=v(o.type,o.props,o.key,o.ref,o.__v):C[a]=o,c=a+b,o.__=e,o.__b=e.__b+1,s=null,~(l=o.__i=D(o,n,c,_))&&(_--,(s=n[l])&&(s.__u|=2)),s&&s.__v?(o.__u|=2,l==c-1?b--:l==c+1?b++:l!=c&&(l>c?b--:b++,S=!0)):(~l||(i>g?b--:i<g&&b++),typeof o.type!=`function`&&(o.__u|=4))):C[a]=null;if(S){for(u=[],d=[],a=0;a<i;a++)if((o=C[a])&&2&o.__u){for(f=0,p=u.length;f<p;)u[h=f+p>>1]<o.__i?f=h+1:p=h;u[f]=o.__i,d[a]=f+1}for(b=u.length;a--;)d[a]&&(d[a]==b?b--:C[a].__u|=4)}if(_)for(a=0;a<g;a++)!(s=n[a])||2&s.__u||(s.__e==r&&(r=x(s)),ie(s,s));return r}function E(e,t,n,r){var i,a,o;if(typeof e.type==`function`){if(e.props.__P)return t;if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&(i[a].__=e,t=E(i[a],t,n,!1));return t}for(t&&!t.parentNode&&(t=x(e))&&!t.parentNode&&(t=null),o=t;o&&o.nodeType==8;)o=o.nextSibling;for(e.__e!=o&&(!r&&n.moveBefore&&e.__e.parentNode?n.moveBefore(e.__e,t):n.insertBefore(e.__e,t||null)),t=e.__e;(t&&=t.nextSibling)&&t.nodeType==8;);return t}function D(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function O(e,t,n){n??=``,t[0]==`-`?e.setProperty(t,n):e[t]=n}function k(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||O(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||O(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)(e.__e||={})[t]=n,n&&r||(o=u[t]||(u[t]=A(t)),(e.__a||={})[t]=l,a=t!=(t=t.replace(c,`$1`)),(t=t.slice(2))[0]<`a`&&(t=t.toLowerCase()),n?e.addEventListener(t,o,a):e.removeEventListener(t,o,a));else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function A(t){return function(n){if(this.__e){var r=this.__e[t];if(n[s]==null)n[s]=l++;else if(n[s]<this.__a[t])return;return r(e.event?e.event(n):n)}}}function j(t,n,r,i,a,o,s,c,l,u){var d,p,h,v,S,C,w,T,E,D,O,k,A,j,ne,M,N,P,F,I,L=n.type;if(n.constructor!==void 0)return null;if(128&r.__u&&(l=32&r.__u,d=r.__c.__z)){if(n.__u|=l,p=o=[],d.nodeType==8)for(h=1,v=d.nextSibling;v;v=v.nextSibling){if(v.nodeType==8){if(v.data.startsWith(`$s`))h++;else if(v.data.startsWith(`/$s`)&&!--h)break}o.push(v)}else o.push(d);c=o[0]}(d=e.__b)&&d(n);n:if(typeof L==`function`){S=s.length;try{if(D=n.props,O=(d=L.prototype)&&d.render,k=(d=L.contextType)&&i[d.__c],A=d?k?k.props.value:d.__:i,r.__c?2&(C=n.__c=r.__c).__g&&(C.__g|=1):(O?n.__c=C=new L(D,A):(n.__c=C=new b(D,A),C.constructor=L,C.render=ae),k&&k.sub(C),C.state||(C.state={}),C.__n=i,C.__g|=8,C.__h=[],C.__k=[]),O&&(C.__s||(C.__s=C.state),L.getDerivedStateFromProps&&(C.__s==C.state&&(C.__s=g({},C.__s)),g(C.__s,L.getDerivedStateFromProps(D,C.__s)))),w=C.props,T=C.state,C.__v=n,r.__c){if(O&&!L.getDerivedStateFromProps&&D!==w&&C.componentWillReceiveProps&&C.componentWillReceiveProps(D,A),n.__v==r.__v&&!(8&C.__g)||!(4&C.__g)&&C.shouldComponentUpdate&&!1===C.shouldComponentUpdate(D,C.__s,A)){n.__v!=r.__v&&(C.props=D,C.state=C.__s,C.__g&=-9),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),f.push.apply(C.__h,C.__k),C.__k=[],C.__h.length&&s.push(C),c=x(r);break n}C.componentWillUpdate&&C.componentWillUpdate(D,C.__s,A),O&&C.componentDidUpdate&&C.__h.push(function(){C.componentDidUpdate(w,T,E)})}else O&&!L.getDerivedStateFromProps&&C.componentWillMount&&C.componentWillMount(),O&&C.componentDidMount&&C.__h.push(C.componentDidMount);if(C.context=A,C.props=D,C.__P=t,C.__g&=-5,j=e.__r,ne=0,O)C.state=C.__s,C.__g&=-9,j&&j(n),d=C.render(C.props,C.state,C.context),f.push.apply(C.__h,C.__k),C.__k=[];else do C.__g&=-9,j&&j(n),d=C.render(C.props,C.state,C.context),C.state=C.__s;while(8&C.__g&&++ne<25);C.state=C.__s,C.getChildContext&&(i=g({},i,C.getChildContext())),O&&r.__c&&C.getSnapshotBeforeUpdate&&(E=C.getSnapshotBeforeUpdate(w,T)),M=d&&d.type===y&&d.key==null?d.props.children:d,D.__P&&(d=c,a=(t=D.__P).namespaceURI,l=o=null,r.props&&r.props.__P!=t&&(r.__k.some(function(e){e&&ie(e,e)}),r.__k=null),c=r.__k?x(r,0):null),c=ee(t,m(M)?M:[M],n,r,i,a,o,s,c,l,u),D.__P&&(n.__e=null,c=d),n.__u&=-161,128&r.__u&&(C.__z=null),p&&p.some(_),C.__h.length&&s.push(C),1&C.__g&&(C.__g&=-4)}catch(t){if(s.length=S,n.__v=null,l||o){if(t.then){if(N=0,n.__u|=l?160:128,o){for(~(F=o.indexOf(c||void 0))||(F=o.length);(I=o[F-1])&&I.nodeType==8;)F--;for(;F<o.length;F++)if(I=o[F]){if(o[F]=null,I.nodeType==8){if(I.data.startsWith(`$s`))N++||(P=I);else if(N&&I.data.startsWith(`/$s`)&&!--N){c=I;break}}else if(!N)break}}if(!P){for(;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;P=c}n.__c.__z||(n.__c.__z=P),n.__e=c}else o&&o.some(_)}else n.__e=r.__e;n.__k||=r.__k||[],t.then||te(n),e.__e(t,n,r)}}else c=n.__e=re(r.__e,n,r,i,a,o,s,l,u,t);return(d=e.diffed)&&d(n),128&n.__u?void 0:c}function te(e){e&&(e.__c&&(e.__c.__g|=4),e.__k&&e.__k.some(te))}function ne(t,n,r){for(var i=0;i<r.length;)M(r[i++],r[i++],r[i++]);e.__c&&e.__c(n,t),t.some(function(n){try{t=n.__h,n.__h=[],t.some(function(e){e.call(n)})}catch(t){e.__e(t,n.__v)}})}function re(t,n,r,i,a,o,s,c,l,u){var f,g,v,y,b,S,C,w,T,E=r.props||d,D=n.props,O=n.type;if(O==`svg`?a=`http://www.w3.org/2000/svg`:O==`math`?a=`http://www.w3.org/1998/Math/MathML`:a||=`http://www.w3.org/1999/xhtml`,o){for(f=0;f<o.length;f++)if((b=o[f])&&(O?b.localName==O:b.nodeType==3)){t=b,o[f]=null;break}}if(!t){if(w=u.ownerDocument||document,!O)return w.createTextNode(D);t=w.createElementNS(a,O,D.is&&D),c&&=(e.__m&&e.__m(n,o),!1),o=null}if(O){if(u=O==`template`?t.content:t,o=O==`textarea`&&D.defaultValue!=null?null:o&&h.call(u.childNodes),!c&&o)for(E={},f=0;f<t.attributes.length;f++)E[(b=t.attributes[f]).name]=b.value;for(f in E)b=E[f],f==`dangerouslySetInnerHTML`?v=b:f==`children`||f in D||f==`value`&&`defaultValue`in D||f==`checked`&&`defaultChecked`in D||k(t,f,null,b,a);for(f in T=1&r.__u,D)b=D[f],f==`children`?y=b:f==`dangerouslySetInnerHTML`?g=b:f==`value`?S=b:f==`checked`?C=b:c&&typeof b!=`function`||!(E[f]!==b||T&&b!=null)||k(t,f,b,E[f],a);g?(c||v&&(g.__html==v.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),n.__k=[]):(v&&(t.textContent=``),(O==`foreignObject`||a==`http://www.w3.org/1998/Math/MathML`&&p.test(O))&&(a=`http://www.w3.org/1999/xhtml`),ee(u,m(y)?y:[y],n,r,i,a,o,s,o?o[0]:r.__k&&x(r,0),c,l),o&&o.some(_)),c&&O!=`textarea`||(f=`value`,O==`progress`&&S==null?t.removeAttribute(f):S==null||S===t[f]&&(O!=`progress`||S)||k(t,f,S,E[f],a),f=`checked`,C!=null&&C!=t[f]&&k(t,f,C,E[f],a))}else E===D||c&&t.data==D||(t.data=D);return t}function M(t,n,r,i){try{typeof t==`function`?n?n.__x=t(n)||1:(i&&=i.__c||i.__e)&&(n=i.__x)&&(i.__x=null,typeof n==`function`?n():t(null)):t.current=n}catch(t){e.__e(t,r)}}function ie(t,n,r){var i,a;if(e.unmount&&e.unmount(t),!(i=t.ref)||i.current&&i.current!=t.__e||M(i,null,n,t),i=t.__c){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(t){e.__e(t,n)}i.__P=i.__n=null}if(i=t.__k)for(a=0;a<i.length;a++)i[a]&&ie(i[a],n,typeof t.type!=`function`||r&&!t.props.__P);(i=t.__e)&&(r||_(i),i.__e&&(i.__e=null)),t.__e=t.__c=t.__=null}function ae(e,t,n){return this.constructor(e,n)}function N(t,n){var r,i,a,o;e.__&&e.__(t,n),n.nodeType==9&&(n=n.documentElement),i=(r=t&&32&t.__u)?null:n.__k,n.__k=v(y,{children:[t]}),a=[],o=[],j(n,n.__k,i||d,d,n.namespaceURI,i?null:n.firstChild?h.call(n.childNodes):null,a,i?i.__e:n.firstChild,r,o),ne(a,n.__k,o),n.__k.props.children=null}e={__e:function(e,t,n,r){for(var i,o,s;t=t.__;)if((i=t.__c)&&!(1&i.__g)){i.__g|=4;try{if((o=i.constructor)&&o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(e)),s=8&i.__g),i.componentDidCatch&&(i.componentDidCatch(e,r||{}),s=8&i.__g),s)return void(i.__g|=2)}catch(t){e=t,s=0}}throw a=0,e}},t=0,n=function(e){return e!=null&&e.constructor===void 0},b.prototype.setState=function(e,t){var n=this.__s;n&&n!=this.state||(n=this.__s=g({},this.state)),typeof e==`function`&&(e=e(g({},n),this.props)),e&&(g(n,e),this.__v&&(t&&this.__k.push(t),C(this)))},b.prototype.forceUpdate=function(e){this.__v&&(this.__g|=4,e&&this.__h.push(e),C(this))},b.prototype.render=y,r=[],a=0,o=function(e,t){return e.__v.__b-t.__v.__b},s=Symbol(),c=/(PointerCapture)$|Capture$/i,l=0,u={};var P,F,I,L,oe=Object.is,R=0,se=[],ce=[],z=e,le=z.__b,ue=z.__r,de=z.diffed,fe=z.__c,pe=z.unmount,me=z.__;function he(e,t){z.__h&&z.__h(F,e,R||t),R=0;var n=F.__H||(F.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function ge(e){return R=1,_e(De,e)}function _e(e,t,n){var r=he(P++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):De(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);oe(t,n)||(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=F,!F.__f)){F.__f=!0;var i=F.shouldComponentUpdate;F.shouldComponentUpdate=function(e,t,n){var r=this.__H;if(!r)return!0;var a=!1,o=this.props!=e;if(r.__.some(function(e){e.__N&&(a=!0,oe(e.__[0],e.__N[0])||(o=!0))}),i){var s=i.call(this,e,t,n);return a?s||o:s}return!a||o}}return r.__}function ve(e,t){var n=he(P++,3);!z.__s&&Ee(n.__H,t)&&(n.__P=!0,n.__=e,n.u=t,F.__H.__h.push(n))}function ye(e){return R=5,B(function(){return{current:e}},[])}function B(e,t){var n=he(P++,7);return Ee(n.__H,t)&&(n.__=e(),n.__H=t),n.__}function be(e,t){return R=8,B(function(){return e},t)}function xe(){var e;do{for(;e=ce.shift();)try{V(e)}catch(t){z.__e(t,{__:(e=e.__P)&&e.__v})}for(;e=se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(V),t.__h.some(Te),t.__h=[]}catch(n){t.__h=[],z.__e(n,e.__v)}}}while(ce.length)}z.__b=function(e){F=null,le&&le(e)},z.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),me&&me(e,t)},z.__r=function(e){ue&&ue(e),P=0;var t=(F=e.__c).__H;t&&(I==F?F.__h=[]:(t.__h.some(V),t.__h.some(Te),P=0),t.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})),I=F},z.diffed=function(e){de&&de(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&we(se.push(t)),t.__H.__.some(function(e){e.u&&(e.__H=e.u)})),I=F=null},z.__c=function(e,t){t.some(function(e){try{e.__h.some(V),e.__h=e.__h.filter(function(e){return!e.__||Te(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],z.__e(n,e.__v)}}),fe&&fe(e,t)},z.unmount=function(e){pe&&pe(e);var t,n,r=e.__c;r&&r.__H&&(r.__H.__.some(function(r){try{if(r.__P&&r.__c){if(n===void 0){for(n=e.__;n&&(!n.__c||!n.__c.__P);)n=n.__;n&&=n.__c}r.__P=n,we(ce.push(r))}else V(r)}catch(e){t=e}}),r.__H=void 0,t&&z.__e(t,r.__v))};var Se=typeof requestAnimationFrame==`function`;function Ce(e){var t,n=function(){clearTimeout(r),Se&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Se&&(t=requestAnimationFrame(n))}function we(e){e!=1&&L==z.requestAnimationFrame||((L=z.requestAnimationFrame)||Ce)(xe)}function V(e){var t=F,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),F=t}function Te(e){var t=F;e.__c=e.__(),F=t}function Ee(e,t){return!e||e.length!=t.length||t.some(function(t,n){return!oe(t,e[n])})}function De(e,t){return typeof t==`function`?t(e):t}var Oe=Symbol.for(`preact-signals`);function H(){if(q>1)q--;else{var e,t=!1;for((function(){var e=Ne;for(Ne=void 0;e!==void 0;){var t=e.S;if(t.v===e.v)for(var n=t.t;n!==void 0;n=n.x)n.i===e.i&&(n.i=t.i);e=e.o}})();K!==void 0;){var n=K;for(K=void 0,Ae++;n!==void 0;){var r=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&Le(n))try{n.c()}catch(n){t||=(e=n,!0)}n=r}}if(Ae=0,q--,t)throw e}}function ke(e){if(q>0)return e();Me=++je,q++;try{return e()}finally{H()}}var U,W=void 0;function G(e){var t=W,n=U;W=void 0,U=void 0;try{return e()}finally{W=t,U=n}}var K=void 0,q=0,Ae=0,je=0,Me=0,Ne=void 0,Pe=0;function Fe(e){if(W!==void 0){var t=e.n;if(t===void 0||t.t!==W)return t={i:0,S:e,p:W.s,n:void 0,t:W,e:void 0,x:void 0,r:t},W.s!==void 0&&(W.s.n=t),W.s=t,e.n=t,32&W.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=W.s,t.n=void 0,W.s.n=t,W.s=t),t}}function J(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t?.watched,this.Z=t?.unwatched,this.name=t?.name}J.prototype.brand=Oe,J.prototype.h=function(){return!0},J.prototype.S=function(e){var t=this,n=this.t;n!==e&&e.e===void 0&&(e.x=n,this.t=e,n===void 0?G(function(){var e;(e=t.W)==null||e.call(t)}):n.e=e)},J.prototype.U=function(e){var t=this;if(this.t!==void 0){var n=e.e,r=e.x;n!==void 0&&(n.x=r,e.e=void 0),r!==void 0&&(r.e=n,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&G(function(){var e;(e=t.Z)==null||e.call(t)}))}},J.prototype.subscribe=function(e){var t=this;return Z(function(){var n=t.value;G(function(){return e(n)})},{name:`sub`})},J.prototype.valueOf=function(){return this.value},J.prototype.toString=function(){return this.value+``},J.prototype.toJSON=function(){return this.value},J.prototype.peek=function(){var e=this;return G(function(){return e.value})},Object.defineProperty(J.prototype,"value",{get:function(){var e=Fe(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ae>100)throw Error(`Cycle detected`);(function(e){q!==0&&Ae===0&&e.l!==Me&&(e.l=Me,Ne={S:e,v:e.v,i:e.i,o:Ne})})(this),this.v=e,this.i++,Pe++,q++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{H()}}}});function Ie(e,t){return new J(e,t)}function Le(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Re(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function ze(e){for(var t=e.s,n=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=n}function Y(e,t){J.call(this,void 0,t),this.x=e,this.s=void 0,this.g=Pe-1,this.f=4}Y.prototype=new J,Y.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Pe))return!0;if(this.g=Pe,this.f|=1,this.i>0&&!Le(this))return this.f&=-2,!0;var e=W;try{Re(this),W=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return W=e,ze(this),this.f&=-2,!0},Y.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}J.prototype.S.call(this,e)},Y.prototype.U=function(e){if(this.t!==void 0&&(J.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Y.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Y.prototype,"value",{get:function(){if(1&this.f)throw Error(`Cycle detected`);var e=Fe(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Be(e,t){return new Y(e,t)}function Ve(e){var t=e.m;if(e.m=void 0,typeof t==`function`){q++;var n=W;W=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,He(e),t}finally{W=n,H()}}}function He(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Ve(e)}function Ue(e){if(W!==this)throw Error(`Out-of-order effect`);ze(this),W=e,this.f&=-2,8&this.f&&He(this),H()}function X(e,t){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t?.name,U&&U.push(this)}X.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t==`function`&&(this.m=t)}finally{e()}},X.prototype.S=function(){if(1&this.f)throw Error(`Cycle detected`);this.f|=1,this.f&=-9,Ve(this),Re(this),q++;var e=W;return W=this,Ue.bind(this,e)},X.prototype.N=function(){2&this.f||(this.f|=2,this.u=K,K=this)},X.prototype.d=function(){this.f|=8,1&this.f||He(this)},X.prototype.dispose=function(){this.d()};function Z(e,t){var n=new X(e,t);try{n.c()}catch(e){throw n.d(),e}var r=n.d.bind(n);return r[Symbol.dispose]=r,r}var We,Ge,Ke=typeof window<`u`&&!!window.__PREACT_SIGNALS_DEVTOOLS__,qe=[];Z(function(){We=this.N})();function Q(t,n){e[t]=n.bind(null,e[t]||function(){})}function $(e){if(Ge){var t=Ge;Ge=void 0,t()}Ge=e&&e.S()}function Je(e){var t=this,r=e.data,i=Xe(r);i.name=`ReactiveDom`,i.value=r;var a=B(function(){for(var e=t,r=t.__v;r=r.__;)if(r.__c){r.__c.__$f|=4;break}var a=Be(function(){var e=i.value.value;return e===0?0:!0===e?``:e||``}),o=Be(function(){return!Array.isArray(a.value)&&!n(a.value)}),s=Z(function(){if(this.N=$e,o.value){var t=a.value;e.__v&&e.__v.__e&&e.__v.__e.nodeType===3&&(e.__v.__e.data=t)}}),c=t.__$u.d;return t.__$u.d=function(){s(),c.call(this)},[o,a]},[]),o=a[0],s=a[1];return o.value?s.peek():s.value}Je.displayName=`ReactiveTextNode`,Object.defineProperties(J.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Je},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}}),Q(`__b`,function(e,t){if($(),typeof t.type==`string`){var n,r=t.props;for(var i in r)if(i!==`children`){var a=r[i];a instanceof J&&(n||(t.__np=n={}),n[i]=a,r[i]=a.peek())}}e(t)}),Q(`__r`,function(e,t){if(e(t),t.type!==y){$();var n,r=t.__c;r&&(r.__$f&=-2,(n=r.__$u)===void 0&&(r.__$u=n=function(e,t){var n;return Z(function(){n=this},{name:t}),n.c=e,n}(function(e){return function(){var t;Ke&&((t=this.y)==null||t.call(this)),e.__$f|=1,e.setState({})}}(r),typeof t.type==`function`?t.type.displayName||t.type.name:``))),$(n)}}),Q(`__e`,function(e,t,n,r){$(),e(t,n,r)}),Q(`diffed`,function(e,t){$();var n;if(typeof t.type==`string`&&(n=t.__e)){var r=t.__np,i=t.props,a=n.U;if(a)for(var o in a){var s=a[o];s===void 0||r&&o in r||(s.d(),a[o]=void 0)}if(r)for(var c in a||(a={},n.U=a),r){var l=a[c],u=r[c];l===void 0?(l=Ye(n,c,u,i),a[c]=l):l.o(u,i)}}e(t)});function Ye(e,t,n,r){var i=t in e&&e.ownerSVGElement===void 0,a=Ie(n);return{o:function(e,t){a.value=e,r=t},d:Z(function(){this.N=$e;var n=a.value.value;r[t]!==n&&(r[t]=n,i?e[t]=n:n!=null&&(!1!==n||t[4]===`-`)?e.setAttribute(t,n):e.removeAttribute(t))})}}Q(`unmount`,function(e,t){if(typeof t.type==`string`){var n=t.__e;if(n){var r=n.U;if(r)for(var i in n.U=void 0,r){var a=r[i];a&&a.d()}}var o=t.__np;if(o){var s=t.props;for(var c in o)s[c]=o[c]}t.__np=void 0}else{var l=t.__c;if(l){l.__$f|=8;var u=l.__$u;u&&(l.__$u=void 0,u.d())}}e(t)}),Q(`__h`,function(e,t,n,r){r<3&&(t.__$f|=2),e(t,n,r)}),b.prototype.shouldComponentUpdate=function(e,t){if(this.__R)return!0;var n=this.__$u,r=n&&n.s!==void 0;for(var i in t)return!0;if(this.__f||typeof this.u==`boolean`&&!0===this.u){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var o in e)if(o!==`__source`&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function Xe(e,t){return B(function(){return Ie(e,t)},[])}var Ze=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Qe(){ke(function(){for(var e;e=qe.shift();)We.call(e)})}function $e(){qe.push(this)===1&&(e.requestAnimationFrame||Ze)(Qe)}var et=`specbook:theme`;function tt(){try{let e=localStorage.getItem(et);return e===`light`||e===`dark`?e:`auto`}catch{return`auto`}}var nt=Ie(tt());function rt(e=nt.value){typeof document<`u`&&(e===`auto`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}var it={auto:`light`,light:`dark`,dark:`auto`};function at(){let e=it[nt.value];nt.value=e;try{e===`auto`?localStorage.removeItem(et):localStorage.setItem(et,e)}catch{}rt(e)}var ot=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2064%2064'%20role='img'%20aria-label='Specbook'%3e%3cdefs%3e%3clinearGradient%20id='g'%20x1='0'%20y1='0'%20x2='1'%20y2='1'%3e%3cstop%20offset='0'%20stop-color='%238b5cf6'/%3e%3cstop%20offset='1'%20stop-color='%235b21b6'/%3e%3c/linearGradient%3e%3c/defs%3e%3crect%20width='64'%20height='64'%20rx='15'%20fill='url(%23g)'/%3e%3cpath%20d='M32%2019.5c-4.5-3-10-3.6-15.5-2.4v28.4c5.500-1.200%2011-.6%2015.500%202.400%204.500-3%2010-3.600%2015.500-2.400V17.100c-5.500-1.200-11-.6-15.500%202.400z'%20fill='%23fff'%20fill-opacity='.95'/%3e%3cpath%20d='M32%2019.500v28.400'%20stroke='%236d28d9'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M38%2027.500v9.500l7.500-4.750z'%20fill='%236d28d9'/%3e%3cpath%20d='M26.500%2028.500l-4%203.750%204%203.750'%20fill='none'%20stroke='%236d28d9'%20stroke-width='2.200'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e`,st=0;Array.isArray;function ct(t,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l&&typeof t!=`function`)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:t,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--st,__i:-1,__u:0};return(a||o)&&(u.__source=a,u.__self=o),e.vnode&&e.vnode(u),u}var lt=/^(token|access_token|id_token|refresh_token|key|api[-_]?key|apikey|secret|client_secret|password|passwd|pwd|auth|authorization|signature|sig|jwt|session|sid|code|x-amz-.*|x-goog-.*)$/i,ut=/\.(local|internal|lan|home|corp|intranet|localhost)$/i;function dt(e){let t=e.replace(/^\[|\]$/g,``).toLowerCase();if(t===`localhost`||ut.test(t))return!0;let n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n){let[e,t]=[Number(n[1]),Number(n[2])];return e===0||e===10||e===127||e===169&&t===254||e===172&&t>=16&&t<=31||e===192&&t===168||e===100&&t>=64&&t<=127}return t===`::1`||/^f[cd]/.test(t)||/^fe[89ab]/.test(t)}var ft=e=>encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%2F/gi,`/`);function pt(e){let t;try{t=new URL(e)}catch{return e}if(t.protocol!==`https:`||!/^(www\.)?github\.com$/i.test(t.hostname))return e;let n=/^\/([^/]+)\/([^/]+)\/(?:blob|raw)\/(.+)$/.exec(t.pathname);return n?`https://raw.githubusercontent.com/${n[1]}/${n[2]}/${n[3]}`:e}function mt(e){if(!e||e.kind===`text`)return{ok:!1,reason:`This document was pasted or opened from a file, so there is no address to link to. Put the file somewhere public (a GitHub raw link or a Gist works) and open that address to get a link.`};let t;try{t=new URL(e.url)}catch{return{ok:!1,reason:`The document address is not a valid link.`}}if(t.protocol!==`https:`&&t.protocol!==`http:`)return{ok:!1,reason:`Only http and https addresses can be linked.`};if(dt(t.hostname))return{ok:!1,reason:`That address is only reachable from your own machine or network, so a link would not work for anyone else.`};if(t.username||t.password)return{ok:!1,reason:`The address contains a login, which a link would publish.`};for(let e of t.searchParams.keys())if(lt.test(e))return{ok:!1,reason:`The address has a "${e}" parameter that looks like a credential, which a link would publish.`};return{ok:!0,spec:t.toString()}}function ht(e,t,n){let r=`${e.origin}${e.pathname}?spec=${ft(t)}${e.hash}`,i=`Exploring ${n} in Specbook`,a=e=>new URLSearchParams(e).toString();return{link:r,title:i,targets:[{id:`x`,label:`X`,href:`https://twitter.com/intent/tweet?${a({text:i,url:r})}`},{id:`reddit`,label:`Reddit`,href:`https://www.reddit.com/submit?${a({url:r,title:i})}`},{id:`hn`,label:`Hacker News`,href:`https://news.ycombinator.com/submitlink?${a({u:r,t:i})}`},{id:`linkedin`,label:`LinkedIn`,href:`https://www.linkedin.com/sharing/share-offsite/?${a({url:r})}`}]}}export{y as _,ct as a,at as c,ve as d,ye as f,N as g,be as h,ft as i,nt as l,ge as m,ht as n,ot as o,B as p,mt as r,rt as s,pt as t,Ie as u};
|