@specbook/ui 0.4.0 → 0.5.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.
@@ -3,72 +3,6 @@ Third-party notices
3
3
  The Specbook viewer contains the software listed below, under the licences shown.
4
4
  Specbook itself is MIT licensed (see the LICENSE file of the repository).
5
5
 
6
- ------------------------------------------------------------------------------
7
- @faker-js/faker 9.3.0
8
- Licence: MIT
9
-
10
- Faker - Copyright (c) 2022-2024
11
-
12
- This software consists of voluntary contributions made by many individuals.
13
- For exact contribution history, see the revision history
14
- available at https://github.com/faker-js/faker
15
-
16
- Permission is hereby granted, free of charge, to any person obtaining
17
- a copy of this software and associated documentation files (the
18
- "Software"), to deal in the Software without restriction, including
19
- without limitation the rights to use, copy, modify, merge, publish,
20
- distribute, sublicense, and/or sell copies of the Software, and to
21
- permit persons to whom the Software is furnished to do so, subject to
22
- the following conditions:
23
-
24
- The above copyright notice and this permission notice shall be
25
- included in all copies or substantial portions of the Software.
26
-
27
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
-
35
- ===
36
-
37
- From: https://github.com/faker-js/faker/commit/a9f98046c7d5eeaabe12fc587024c06d683800b8
38
- To: https://github.com/faker-js/faker/commit/29234378807c4141588861f69421bf20b5ac635e
39
-
40
- Based on faker.js, copyright Marak Squires and contributor, what follows below is the original license.
41
-
42
- ===
43
-
44
- faker.js - Copyright (c) 2020
45
- Marak Squires
46
- http://github.com/marak/faker.js/
47
-
48
- faker.js was inspired by and has used data definitions from:
49
-
50
- * https://github.com/stympy/faker/ - Copyright (c) 2007-2010 Benjamin Curtis
51
- * http://search.cpan.org/~jasonk/Data-Faker-0.07/ - Copyright 2004-2005 by Jason Kohles
52
-
53
- Permission is hereby granted, free of charge, to any person obtaining
54
- a copy of this software and associated documentation files (the
55
- "Software"), to deal in the Software without restriction, including
56
- without limitation the rights to use, copy, modify, merge, publish,
57
- distribute, sublicense, and/or sell copies of the Software, and to
58
- permit persons to whom the Software is furnished to do so, subject to
59
- the following conditions:
60
-
61
- The above copyright notice and this permission notice shall be
62
- included in all copies or substantial portions of the Software.
63
-
64
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
65
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
66
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
67
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
68
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
69
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
70
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71
-
72
6
  ------------------------------------------------------------------------------
73
7
  @preact/signals 2.11.3
74
8
  Licence: MIT
@@ -0,0 +1,41 @@
1
+ import{_ as e,a as t,d as n,f as r,g as i,h as a,m as o,p as s,u as c,y as l}from"./panel-nV09I7Wr.js";import{i as u}from"./mount-D3holu10.js";import{A as d,C as f,D as p,E as m,F as h,I as g,L as _,M as v,N as y,O as b,P as x,S,T as C,_ as w,a as T,b as E,c as D,d as O,f as k,g as A,h as j,i as M,j as N,k as ee,l as te,m as ne,n as re,o as ie,p as ae,r as P,s as F,u as I,v as oe,w as L,x as se,y as ce}from"./main-CAlriyIm.js";var R={200:`OK`,201:`Created`,202:`Accepted`,204:`No Content`,301:`Moved Permanently`,302:`Found`,304:`Not Modified`,400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,422:`Unprocessable Entity`,429:`Too Many Requests`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`},le=e=>R[e]??``;function z(e){if(typeof e==`string`)return e.includes(`
2
+ `)?e.split(`
3
+ `):[JSON.stringify(e)];if(e===void 0)return[`undefined`];try{return(JSON.stringify(e,null,2)??String(e)).split(`
4
+ `)}catch{return[String(e)]}}function ue(e,t){let n=[];if(e.length*t.length>25e4){for(let t of e)n.push({kind:`expected`,text:t});for(let e of t)n.push({kind:`received`,text:e});return n}let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=0,s=0;for(;o<r&&s<i;)e[o]===t[s]?(n.push({kind:`same`,text:e[o]}),o++,s++):a[o+1][s]>=a[o][s+1]?n.push({kind:`expected`,text:e[o++]}):n.push({kind:`received`,text:t[s++]});for(;o<r;)n.push({kind:`expected`,text:e[o++]});for(;s<i;)n.push({kind:`received`,text:t[s++]});return n}function de(e,t){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.kind!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=0,a=()=>{i>0&&r.push({kind:`skip`,text:`… ${i} unchanged line${i>1?`s`:``}`}),i=0};return e.forEach((e,t)=>{n[t]?(a(),r.push(e)):i++}),a(),r}function fe(e,t=3){if(e.operator===`status`){let t=typeof e.actual==`number`?`${e.actual} ${le(e.actual)}`.trim():String(e.actual);return[{kind:`expected`,text:`status ${e.expected}`},{kind:`received`,text:`status ${t}`}]}return`expected`in e||`actual`in e?de(ue(z(e.expected),z(e.actual)),t):e.diff?e.diff.split(`
5
+ `).map(e=>({kind:`same`,text:e})):[]}var pe=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function me(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:pe(t),enabled:!0})))}function he(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 ge(e){return typeof e!=`object`||!e?[]:y(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var _e=/[^[\]]+|\[\]/g;function ve(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?ve(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?ve(o,i,n):o===void 0?n:[...[].concat(o),n],a}function ye(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=ve(t,n.match(_e)??[n],a&&x(a)?a:r));return t}var be=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,xe=e=>new RegExp(be.source).test(e),Se=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function Ce(e){let t=[],n=0;for(let r of e.matchAll(be))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?Se(r[1]):`SESSION_${Se(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var we=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 Ce(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function B(e){if(x(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var Ee=e=>e.name??e.file??`file`,De=e=>`'${e.replace(/'/g,`'\\''`)}'`;function V(e){return xe(e)?`"${Ce(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:De(e)}function Oe(e){let t=e.encoding??`json`,n=[V(`${e.url}${we(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${V(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of y(o,e.formArrays))s.push(`--data-urlencode ${V(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(B(n)?s.push(`-F ${V(`${e}=@${Ee(n)}`)}`):s.push(`-F ${V(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${V(`@${B(o)?Ee(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=B(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${V(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${V(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
6
+ `)}`}var ke=/^[A-Za-z_$][\w$]*$/;function H(e){return xe(e)?`\`${Ce(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var U=e=>ke.test(e)?e:H(e);function Ae(e,t){if(e==null)return`null`;if(typeof e==`string`)return H(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${Ae(e,n)},`).join(`
7
+ `)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${U(e)}: ${Ae(t,n)},`).join(`
8
+ `)}\n${t}}`}function je(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(${Ae(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=y(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${Ae(Object.fromEntries(t),` `)})`:`new URLSearchParams(${Ae(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(B(n)){l=!0;let t=Ee(n);s.push(`form.append(${H(e)}, await openAsBlob(${H(t)}), ${H(t)})`)}else s.push(`form.append(${H(e)}, ${H(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${H(B(a)?Ee(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=B(a)&&a.type?a.type:`application/octet-stream`)):(c=H(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${we(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${H(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${U(e)}: ${H(t)},`).join(`
9
+ `)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${H(u)})`:`const res = await fetch(${H(u)}, {\n${d.join(`
10
+ `)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
11
+ `)}function Me(e,t){return e===`curl`?Oe(t):je(t)}var Ne=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],W=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`);function G(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function Pe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
12
+ `).split(`
13
+ `),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${G(W(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${G(W(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${W(r.join(`
14
+ `))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${G(W(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${G(W(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function Fe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function Ie(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function Le(e){return e?G(W(e)):``}function Re(e,t=300){let n=Ie(e);if(!n)return``;let r=Fe(n);return r.length>t?W(`${r.slice(0,t-1).trimEnd()}…`):Le(n)}var ze=/^\s*\{\{[^}]+\}\}\s*$/,K=e=>typeof e==`string`&&ze.test(e);function Be(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Ve=[`title`,`description`,`default`,`examples`,`deprecated`];function He(e,t){let n={...e};for(let e of Ve)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function Ue(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=He(r,n)}return n}function q(e,t,n=0){let r=Ue(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!Be(e));if(e.length===1||e.length>1)return q(He(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(He(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=q(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of Ve)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function J(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function We(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function Ge(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 Ke(e,t){let n=q(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function qe(e,t,n){let r=q(e,n);if(typeof t==`number`)return r.items;if(r.properties?.[t])return r.properties[t];if(r.additionalProperties&&typeof r.additionalProperties==`object`)return r.additionalProperties}var Je=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Ye(e,t,n){let r=Ue(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!Be(e));if(!i?.length)return q(r,n);let a=Je(t);return q(He(i.find(e=>{let t=J(q(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Xe(e,t,n,r={},i=``,a=0){if(!t||a>12||K(e))return[];let o=Ye(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&J(o)!==`null`&&J(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${J(o)}, got null`}),s;let u=J(o),d=Je(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(...Xe(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Xe(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(...Xe(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 Ze=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Qe(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
15
+ `)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
16
+ `;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function $e(e,t,n){let r=e;for(let e of t){if(!r)return;r=qe(r,e,n)}return r}var et={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`},tt=e=>et[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),nt=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,rt=new Set([`path`,`query`,`headers`,`data`]),it=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function at(e,t){return[e,...it(t)].join(`.`)}function ot(e){let t=it(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&rt.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var st=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`);function ct(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?ot(st(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 lt=60;function ut(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function dt(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Ke(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:ut(e,t),required:a.required,description:We(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=J(e)===`array`?q(e.items,t):e;J(s)===`object`&&i.push(...dt(s,t,n+1,o))}return i}function ft({schema:e,defs:n,section:r=`data`,notes:i}){let a=dt(e,n);return a.length===0?null:t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Field`}),t(`th`,{children:`Type`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:[a.slice(0,lt).map(e=>t(`tr`,{children:[t(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[t(`code`,{children:e.name.split(`.`).pop()}),e.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}),t(`td`,{children:t(`span`,{class:`chip`,children:e.type})}),t(`td`,{children:[t(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:Re(e.description,220)}}),i?.get(at(r,e.name))&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(at(r,e.name))}}),e.enum&&t(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>t(`code`,{children:e}))]})]})]})),a.length>lt&&t(`tr`,{children:t(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-lt,` more fields in the spec`]})})]})]})}var pt={intro:``,notes:new Map,replace:!1,found:!1};function mt(e){let[t,r]=a(),[i,s]=a(!1),c=T.docs.find(t=>t.operation===e);return n(()=>{let e=!0;return r(void 0),s(!c),c?.load().then(t=>e&&r(t)).catch(()=>{}).finally(()=>e&&s(!0)),()=>{e=!1}},[e,c]),o(()=>!c||t===void 0?{...pt,loaded:i}:{...ct(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var ht=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],gt=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function _t(e,t,n){return Promise.all([gt(T.operationDocs[e]?.().then(e=>e.default)),gt(T.schemas[e]?.().then(e=>e.default)),gt(T.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>gt(T.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 vt({variant:e,html:n}){return n?t(`section`,{class:`saved-note-doc`,children:[t(`h2`,{children:[`Request `,t(`code`,{children:e.name})]}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:n}})]}):null}function yt({service:e,op:r,variants:i=[],onTry:o}){let s=`${e}/${r.id}`,[c,u]=a(),d=i.map(e=>e.file).join(`
17
+ `);n(()=>{let t=!0;return u(void 0),_t(s,e,d?d.split(`
18
+ `):[]).then(e=>t&&u(e)),()=>{t=!1}},[s,e,d]);let f=mt(s),p=!!c&&f.loaded,{long:m,req:h,defs:g}=c??{saved:{}},_=h?q(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return t(`article`,{class:`doc`,"data-op":s,children:[t(`div`,{class:`doc-intro`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path}),t(`span`,{class:`spacer`}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&t(l,{children:[!(f.found&&f.replace)&&m?.description&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:Pe(m.description)}}),f.intro&&t(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>t(vt,{variant:e,html:c?.saved[e.file]},e.file)),ht.map(([e,n])=>v(e)?t(`section`,{children:[t(`h2`,{children:[n,` parameters`]}),t(ft,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&t(`section`,{children:[t(`h2`,{children:`Request body`}),t(ft,{schema:y,defs:g,section:`data`,notes:f.notes})]}),r.statuses.length>0&&t(`section`,{children:[t(`h2`,{children:`Responses`}),t(`ul`,{class:`statuses`,children:r.statuses.map(e=>t(`li`,{children:[t(`span`,{class:`state-badge ${nt(e)}`,children:e}),` `,tt(e)]}))})]}),(m?.examples.length??0)>1&&t(`section`,{children:[t(`h2`,{children:`Examples`}),t(`ul`,{class:`examples`,children:m?.examples.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var bt=c(``);function xt(e){if(e.kind===`request`){let t=e.steps.find(e=>e.response)??e.steps[0];if(!t?.response)return e.status===`error`?`The request could not be sent.`:`Done.`;let n=t.assertions.filter(e=>!e.pass).length;return`${t.response.status}, ${e.durationMs} milliseconds${n?`, ${n} check${n===1?``:`s`} failed`:``}.`}return`Flow ${e.status===`pass`?`passed`:e.status===`fail`?`failed`:`could not run`}, ${e.totals.passed} of ${e.totals.steps} steps passed.`}var St=class extends e{state={};componentDidCatch(e){console.error(`specbook: a panel could not be drawn`,e),this.setState({error:e instanceof Error?e:Error(String(e))})}render(){let{error:e}=this.state;return e?t(`div`,{class:`panel-error`,role:`alert`,children:[t(`p`,{children:[t(`strong`,{children:`This could not be shown.`}),` The run finished, but what it returned could not be drawn.`]}),t(`pre`,{children:e.message}),t(`button`,{type:`button`,class:`btn`,onClick:()=>this.setState({error:void 0}),children:`Try drawing it again`})]}):this.props.children}},Ct=0,wt=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Tt({title:e,subtitle:i,flush:a,modal:c=!0,variant:u=`side`,onPrev:d,onNext:f,onClose:p,children:m}){let h=s(null),g=o(()=>`sb-panel-title-${++Ct}`,[]);return n(()=>()=>{bt.value=``},[]),n(()=>{let e=h.current?.getRootNode()?.activeElement;return c&&h.current?.focus(),()=>e?.focus?.()},[c]),n(()=>{let e=h.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=e.getAttribute(`role`)===`combobox`,c=r+i*(s?.3:.2);(o>r+i*(s?.55:.4)||o<r)&&(t.scrollTop+=o-c)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s),l=typeof visualViewport>`u`?void 0:visualViewport,u=s.getBoundingClientRect().top>(l?.offsetTop??0)+(l?.height??innerHeight)*.55;c&&r?.box!==c&&(s.getAttribute(`role`)!==`combobox`||u)&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),r(()=>{let e=e=>{if(e.key===`Escape`&&p(),e.key!==`Tab`||!c||!h.current)return;let t=[...h.current.querySelectorAll(wt)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=h.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===h.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))},t=c&&h.current?h.current:window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)},[p,c]),t(l,{children:[c&&t(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:p}),t(`section`,{class:`panel ${c?``:`docked`} ${u===`popover`?`popover`:``}`,part:`panel`,"aria-labelledby":g,"aria-modal":c?!0:void 0,role:c?`dialog`:`complementary`,tabIndex:-1,ref:h,children:[t(`header`,{class:`panel-head`,part:`header`,children:[t(`div`,{class:`panel-title`,children:[t(`h2`,{id:g,children:e}),i&&t(`div`,{class:`muted small`,children:i})]}),t(`span`,{class:`spacer`}),c&&O.value.length>1&&t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Environment`}),t(`select`,{value:F.value,onChange:e=>F.value=e.target.value,children:O.value.map(e=>t(`option`,{value:e,title:I.value[e],children:e}))})]}),(d||f)&&t(`span`,{class:`stepper`,children:[t(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!d,onClick:d,children:`↑`}),t(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!f,onClick:f,children:`↓`})]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:p,children:`×`})]}),t(`div`,{class:`panel-body ${a?`flush`:``}`,children:t(St,{children:m})}),t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:bt.value})]})]})}function Et(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:$e(e,i,t);if(!a)return;let o=q(a,t);if(n.length===0){let e=typeof o.description==`string`?o.description.trim():``;return e?{path:typeof o.title==`string`&&o.title.trim()?o.title.trim():`body`,type:J(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=$e(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Ze(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Ke(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:We(o),parent:c?We(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Dt(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function Ot(e,t,n,r){let i=e&&t?.get(at(n,r));return e&&i?{...e,note:i}:e}var kt={},At=Symbol(),jt=Symbol(),Mt=e=>typeof e==`string`?Nt[e]:e,Nt={plain:kt,plaintext:kt,text:kt,txt:kt},Pt=(e,t)=>(t[jt]||Ft)(e,t),Ft=(e,t)=>{for(var n=[e],r,i=[],a=0;r=Mt(t[At]);)delete t[At],Object.assign(t,r);for(Ht(e,t,n,0);i[a++]=n[0],n=n[1];);return i},It=(e,t,n)=>e.replace(/&/g,`&amp;`).replace(t,n),Lt=`</span>`,Rt=``,zt=``,Bt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=Vt(n);return t},Vt=e=>{if(e instanceof Ut){var{type:t,alias:n,content:r}=e,i=Rt,a=zt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;zt+=Lt,Rt+=o;var s=Vt(r);return Rt=i,zt=a,o+s+Lt}return typeof e==`string`?(e=It(e,/</g,`&lt;`),zt&&e.includes(`
19
+ `)?e.replace(/\n/g,zt+`
20
+ `+Rt):e):Bt(e)},Ht=(e,t,n,r,i)=>{for(var a in t)if(t[a])for(var o=0,s=t[a],c,l=Array.isArray(s)?s:[s];c=l[o];o++){if(i&&i[0]==a&&i[1]==o)return;for(var u=c.pattern||c,d=Mt(c.inside),f=c.lookbehind,p=u.global,m=c.alias,h=n,g=r;h&&(!i||g<i[2]);g+=h[0].length,h=h[1]){var _=h[0],v=0,y;if(!(_ instanceof Ut)){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 Ut)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 Ut(a,d?Pt(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof Ut?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&&(Ht(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Ut(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Wt=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Zt(),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=Pt(o=_.value,Nt[r]||{}),O(`tokenize`,u,r,o);let e=Bt(u).split(`
21
+ `),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
22
+ `;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=Yt(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`,()=>{Qt=null,c=!1,w()}),Y(_,`focus`,()=>{Qt=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),Jt(e)?.append(p),t&&x(t),A},Gt=`u`>typeof window?document:null,Kt=Gt?.createElement(`div`),qt=(e,t)=>(Kt&&(Kt.innerHTML=e,t=Kt.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),Jt=e=>typeof e==`string`?Gt.querySelector(e):e,Yt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
23
+ `,t)+1)&&t<=n;r++);return r},Xt={},Zt=qt(`<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()},Qt;Gt&&Y(Gt,`selectionchange`,()=>Qt?.());var $t=(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) + ${gn&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},en=(e,t)=>t?e.lastIndexOf(`
24
+ `,t-1)+1:0,tn=(e,t)=>(t=e.indexOf(`
25
+ `,t))+1?t:e.length,nn=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),rn=(e,t,n,r)=>nn(e.textarea,t,n,r),an=(e,t)=>parseFloat(getComputedStyle(e)[t]),on=(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}},sn=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var cn,ln=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),un=(e,t)=>e.slice(en(e,t),t),dn=(e,t,n=t)=>[e.slice(t=en(e,t),n=tn(e,n)).split(`
26
+ `),t,n],fn=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[Yt(a,0,i)],s=Gt.createTreeWalker(o,5),c=s.lastChild(),l=tn(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}},pn=(e,t)=>fn(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;cn=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=gn&&!s[r??cn[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,cn[2]),l()})),_n||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),gn||_n?(c&&(o.selectionEnd--,t=t.slice(0,-1)),_n&&(t+=`
27
+ `),Gt.execCommand(t?`insertHTML`:`delete`,!1,It(t,/</g,`&lt;`)),c&&o.selectionStart++):Gt.execCommand(t?`insertText`:`delete`,!1,t),cn=0},mn=(e,t,n=t,r)=>{let i=e.textarea,a=nn(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},hn=Gt?navigator.userAgent:``,Q=Gt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,gn=/Chrome\//.test(hn),_n=!gn&&/AppleWebKit\//.test(hn),vn=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,yn=(e,t)=>e.lines[0].append(t),bn=qt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),xn=qt(`<span> `),Sn=qt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),Cn=(e,t,n=!0)=>{let r=Sn(),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||yn(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 wn=(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(``,xn()),sn(r[o],n.slice(a,a=t[o++])),sn(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();sn(r[s],n.slice(a))},Tn=0,En=qt(`<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>`),Dn=qt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),On={},kn=(e,t)=>{e.forEach(e=>On[e]=t)},An=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=En(),O=bn(),[k,A]=Cn(n,D),[j,M]=D.children,[N,ee,te]=M.children,ne=j.firstChild,re=ne.id=`pce-ac-`+Tn++,ie=ne.children,ae=[],P=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},F=()=>{f=an(ie[0],`height`)},I=e=>{let t=o[e+d],[n,r,i]=ie[e].children,a=t[4],s=a.icon||`variable`;wn(r,t[1],a.label),sn(i.firstChild.firstChild,a.detail||``),ae[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${ae[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),ie[e].setAttribute(`aria-posinset`,e+d)},oe=()=>{F();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,ce(),L()},L=()=>{let e=l;l=ie[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),ee.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(ee),b=!b,ge()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},se=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,oe()},ce=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)I(e++);ne.style.paddingTop=d*f+`px`},R=e=>le(o[e][4],o[e][2],o[e][3]),le=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
28
+ `+un(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||yn(n,O),p=o,m=0,g=n.value.length,fe(),h=E(),z()):n.extensions.cursor?.scrollIntoView()},z=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},ue=e=>{m+=e,mn(n,p[m],p[m+1]),z()},de=()=>{O.remove(),p=null},fe=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),wn(O,e.flat(),n.value)},pe=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=an(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},me=()=>{D.className=`pce-ac-wrapper pce-ac-${pe()}`},he=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,te.textContent=``,te.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,re+`d`))},ge=()=>{b?M.remove():he(),b=!b},_e=t.startQuery=t=>{let[a,l,p]=E(),m=pn(n,u=p<`f`?a:l),h=On[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=un(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;)ie[e].setAttribute(`aria-setsize`,s),I(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}ne.style.paddingTop=``,ne.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,L(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,re),T.setAttribute(`aria-haspopup`,`listbox`)}else P()}else P()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)ne.append(Dn()),ie[e].id=re+`-`+e++;Y(j,`scroll`,()=>{F(),ce()||L()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)de();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));fe()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&de()}a?(a=!1,_e()):(S!=e||C!=t)&&P(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!cn&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&R(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!cn||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&P()}),Y(T,`keydown`,e=>{let t=e.key,n=vn(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?ge():_e(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(se(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(R(c),P(),X(e)):t==`Escape`?(P(),X(e)):t.slice(0,4)==`Page`&&(F(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),oe(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(ue(-2),X(e)):(ue(2),X(e)):!n&&t==`Escape`&&(de(),X(e)))},!0),Y(ne,`mousedown`,e=>{e.target!=ee&&(R([].indexOf.call(ie,e.target.closest(`li`))+d),P()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&P()}),Y(w,`scroll`,()=>{i&&me()}),Y(N,`click`,ge),Y(N,`mousedown`,X),Y(ee,`click`,ge),M.id=re+`d`,ee.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},jn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return Mn(e,t);let i=e.toLowerCase(),a=t.toLowerCase(),o=[],s=a.indexOf(i),c=0,l=0,u=0,d=0;for(;l<r;){let n=s>-1?l+s:a.indexOf(i[l],u),r=n>u;if(n<0)return;r&&(c-=800),(r||!d)&&(o[d]=n,d+=2),o[d-1]=u=n+1,e[l++]!=t[n]&&(c-=100)}return[r<n?c-100:c,o]},Mn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;let i=t.slice(0,r),a=i==e?0:e.toLowerCase()==i.toLowerCase()?-200:null;if(a!=null)return[e?r<n?a-100:a:0,[0,r]]},Nn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Un[e]||0;return t+`+`+r},Pn=e=>{if(!Vn[48]){for(let e=48;e<91;e++)Vn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)Vn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=vn(e),r=Vn[e.keyCode],i=Hn[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},Fn=new WeakMap,In=(e,t,n)=>{let r=new Set,i;try{for(let a of Pn(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)))}},Ln=e=>{let t=Fn.get(e);return t||(Fn.set(e,t={}),rn(e,`keydown`,n=>{In(n,t,e)})),t},Rn=(e,t,n,r)=>zn(Ln(e),t,n,r),zn=(e,t,n,r=2)=>{let i=(e[t==`any`?t:Nn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},Bn=Q?4:2,Vn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Hn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Un={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},Wn=!1,Gn=e=>e.search(/\S|$/),Kn=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),qn=(e,t,n,r,i,a,o)=>{let s=n.join(`
29
+ `);if(s==t.join(`
30
+ `))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+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,_))},Jn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=dn(e.value,n,r),[s,c]=Kn(e);return qn(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)},Yn=(e,t)=>{let[n,r]=Kn(e);return Z(e,n.repeat(r-(t-en(e.value,t))%r)),$(e)},Xn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=tn(r,n[1]));let[i,a]=Kn(e),[o,s]=n,c=Xt[pn(e,o)]?.autoIndent,l=Math.floor(Gn(un(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
31
+ `+i.repeat(l+u)+(d?`
32
+ `+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Zn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?en(i,n)-1:n,o=t?r:i.indexOf(`
33
+ `,r)+1;if(a>-1&&o>0){let[s,c,l]=dn(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
34
+ `),c,l,n+d,r+d)}return $(e)},Qn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=dn(i,n,r),c=a.join(`
35
+ `),l=t?0:c.length+1;return Z(e,c+`
36
+ `+c,o,s,n+l,r+l),$(e)},$n=(e,t)=>(e.container.scrollBy(0,an(e.container,`lineHeight`)*(t?-1:1)),!0),er=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=dn(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=tn(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},tr=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:en(i,n),o=Xt[pn(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=dn(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(ln(t)+` ?$`);s+1&&RegExp(`^ ?`+ln(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=ln(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));qn(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(ln(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${ln(i)}$`),``):l[f]+` `+i;let m=l.join(`
37
+ `),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},nr={Tab(e){if(!Wn){let[t,n]=e.getSelection();return t==n?Yn(e,t):Jn(e)}},"8+Tab":e=>!Wn&&Jn(e,!0),"1+ArrowDown":e=>Zn(e),"1+ArrowUp":e=>Zn(e,!0),"9+ArrowDown":e=>Qn(e),"9+ArrowUp":e=>Qn(e,!0),Enter:e=>Xn(e),"8+Enter":e=>Xn(e),"Mod+Enter":e=>Xn(e,!0),"Mod+]":e=>Jn(e),"Mod+[":e=>Jn(e,!0),"8+Mod+k":er,"Mod+/":e=>tr(e),"9+a":e=>tr(e,!0),[Q?`10+m`:`2+m`]:()=>(Wn=!Wn,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>$n(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>$n(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var rr=Q?5:1;rr+``,rr+``,rr+``,rr+``;var ir=(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&&!mn(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=un(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[pn(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},Rn(r,`Backspace`,u),Rn(r,`8+Backspace`,u);for(let t in e)Rn(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>rn(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=dn(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
38
+ `,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},ar=(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}),rn(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`)&&!cn&&(n!=` `||o==n))||(d[t][2]=cn||u()),i=!0,o=n,s=f,a=l}),rn(e,`input`,()=>f(t+!c)),rn(e,`keydown`,e=>{if(!g.readOnly){let n=vn(e),r=e.keyCode,i=n==Bn&&r==90,a=n==Bn+8&&r==90||!Q&&n==Bn&&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},or=qt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),sr=()=>{let e,t=or(),[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];sn(n,un(i,s)),sn(a,i.slice(s,tn(i,s))+`
39
+ `),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),$t(e,i)},c=t=>{e=t,t.extensions.cursor=c,rn(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),on(e,i)),c.scrollIntoView=s,c.element=i,c};qt(`<div class=pce-cursor>`);var cr=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,lr=/\b(?:false|true)\b/,ur=/\[]|\(\)|{}/,dr=/[([{][^)\]}]*$/,fr=([e,t],n)=>ur.test(n[e-1]+n[t]),pr={line:`//`,block:[`/*`,`*/`]},mr=(e=pr,t=dr)=>({comments:e,autoIndent:[([e],n)=>t.test(un(n,e)),fr]});Xt.json=Xt.json5=Xt.jsonp=mr(),Xt.graphql=mr({line:`#`}),Nt.webmanifest=Nt.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:cr,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:lr,null:{pattern:/\bnull\b/,alias:`keyword`}},Nt.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:lr,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+/,[jt](e,t){for(var n=Ft(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 hr=new WeakMap;kn([`json`],{sources:[(e,t)=>{let n=hr.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 gr({value:e,language:r=`json`,readOnly:i,label:a,onChange:o,onLine:c,complete:l}){let u=s(null),d=s(void 0),f=s({onChange:o,onLine:c});f.current={onChange:o,onLine:c};let p=s(l);return p.current=l,n(()=>{let t=Wt(u.current,{value:e,language:r,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},ir(nr),ar(),...l?[sr(),An({filter:jn})]:[]);return l&&hr.set(t,(e,t)=>p.current?.(e,t)),t.textarea.setAttribute(`aria-label`,a),d.current=t,()=>t.remove()},[]),n(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),n(()=>{d.current?.setOptions({readOnly:i,language:r})},[i,r]),t(`div`,{class:`body-editor`,part:`editor`,ref:u})}var _r=/[\w$.+-]/;function vr(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
40
+ `;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&_r.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&_r.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 yr=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),br=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function xr(e){let t=J(e);return t===`object`?{text:`{}`,stop:1}:t===`array`?{text:`[]`,stop:1}:t===`boolean`?{text:`false`,stop:5}:t===`number`||t===`integer`?{text:`0`,stop:1}:{text:`""`,stop:1}}function Sr(e,t,n,r,i){if(!e)return;let a=vr(r,i);if(!a)return;let o=$e(e,[...n,...a.path],t);if(!o)return;let s=q(o,t);if(a.mode===`key`){if(J(s)!==`object`&&!s.properties)return;let e=Ke(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=q(e.schema,t),r=xr(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${br(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:yr(Ge(We(n),400))}});return{from:a.from,to:a.to,options:n}}let c=[],l=(e,t)=>{let n=JSON.stringify(e);c.push({label:typeof e==`string`?e:n,insert:n,icon:`enum`,detail:t,from:a.inString?a.from+1:void 0})};if(Array.isArray(s.enum))for(let e of s.enum)l(e);else if(J(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var Cr=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function wr(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:me(e.path),query:me(e.query),headers:me(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?ge(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var Tr=e=>Object.keys(e).length?e:void 0;function Er(e,t){let n;if(Cr(e,t))n=ye(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:Tr(he(e.path)),query:Tr(he(e.query)),headers:Tr(he(e.headers)),data:n}}var Dr=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function Or(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 kr({doc:e,hint:n}){return e?t(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[t(`div`,{class:`field-doc-head`,children:[t(`code`,{children:e.path}),t(`span`,{class:`chip`,children:e.type}),e.required&&t(`span`,{class:`chip req`,children:`required`}),e.deprecated&&t(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?t(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:Pe(e.description)}}):e.note?null:t(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&t(l,{children:[` It is part of: `,e.parent]})]}),e.note&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&t(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>t(`code`,{children:e})),e.enum.length>12&&t(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):t(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:n??`Put the cursor on a field to see what the API says about it.`})}function Ar(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 jr(e){let t;try{t=e.variables.trim()?JSON.parse(e.variables):void 0}catch{t=e.variables}return JSON.stringify({query:e.query,variables:t,...e.rest},null,2)}function Mr({value:e,options:r,onChange:i,label:o,placeholder:c,onKeyDown:l,cell:u,readOnly:d}){let[f,p]=a(!1),[m,h]=a(-1),[g,_]=a(),v=s(null),y=()=>{let e=v.current,t=e?.getBoundingClientRect();if(!e||!t)return;let n=document.createElement(`div`);n.style.cssText=`position:fixed;inset:0;visibility:hidden;pointer-events:none`,e.append(n);let r=n.getBoundingClientRect();n.remove();let i=innerHeight-t.bottom-8,a=i<160&&t.top>i;_({left:`${t.left-r.left}px`,width:`${Math.max(t.width,160)}px`,maxHeight:`${Math.min(240,(a?t.top:i)-4)}px`,...a?{bottom:`${r.bottom-t.top+2}px`}:{top:`${t.bottom+2-r.top}px`}})};n(()=>{if(!f){_(void 0);return}y();let e=e=>{if(e.target instanceof Node&&v.current?.contains(e.target))return;let t=v.current?.getBoundingClientRect();!t||t.bottom<0||t.top>innerHeight?p(!1):y()},t=()=>p(!1);return addEventListener(`scroll`,e,!0),addEventListener(`resize`,t),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,t)}},[f]),n(()=>{if(!f)return;let e=e=>{e.composedPath().includes(v.current)||p(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[f]);let b=e=>{i(e),p(!1),h(-1)};return t(`div`,{class:`combo`,ref:v,children:[t(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":f,role:`combobox`,autocomplete:`off`,readOnly:d,onFocus:()=>!d&&p(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{f&&e.key===`ArrowDown`?(e.preventDefault(),h((m+1)%r.length)):f&&e.key===`ArrowUp`?(e.preventDefault(),h((m-1+r.length)%r.length)):f&&e.key===`Enter`&&m>=0?(e.preventDefault(),b(r[m])):e.key===`Escape`&&f?(e.stopPropagation(),p(!1)):((e.key===`Enter`||e.key===`Tab`)&&p(!1),l?.(e))}}),t(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,disabled:d,onClick:()=>p(!f),children:`▾`}),f&&t(`div`,{class:`combo-list`,role:`listbox`,style:g??{top:`0px`,left:`0px`,visibility:`hidden`},children:r.map((n,r)=>t(`button`,{type:`button`,role:`option`,"aria-selected":n===e,class:`${n===e?`on`:``} ${r===m?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(n),children:n}))})]})}var Nr=`specbook:grid-cols`,Pr={key:26,val:34},Fr=10,Ir=c(Lr());function Lr(){try{let e=JSON.parse(E.local.getItem(Nr)??`null`);if(e&&e.key>=Fr&&e.val>=Fr&&e.key+e.val<=90)return e}catch{}return Pr}function Rr(e){let t=e??Pr,n=Math.min(80,Math.max(Fr,t.key)),r=Math.min(100-n-Fr,Math.max(Fr,t.val));Ir.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?E.local.setItem(Nr,JSON.stringify(Ir.value)):E.local.removeItem(Nr)}catch{}}function zr(){return t(`colgroup`,{children:[t(`col`,{style:{width:`36px`}}),t(`col`,{style:{width:`${Ir.value.key}%`}}),t(`col`,{style:{width:`${Ir.value.val}%`}}),t(`col`,{}),t(`col`,{style:{width:`60px`}})]})}function Br({which:e,table:n}){let r=t=>{let n=Ir.value;Rr(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return t(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(Ir.value[e]),"aria-valuemin":Fr,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let t=n()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/t*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>Rr(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var Vr=1,Hr=2;function Ur(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 Wr=({d:e})=>t(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Gr({title:e,rows:r,onChange:i,documented:a=[],docFor:o,fixed:c,bad:u,placeholder:d,bare:f,readOnly:p}){let m=s(null),h=s(null),g=s(void 0),_=new Set(r.map(e=>e.key)),v=a.filter(e=>!_.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),y=[...r,...v],b=e=>a.find(t=>t.name===e),x=e=>b(e)?.doc??o?.(e);n(()=>{if(!g.current)return;let e=m.current?.querySelector(`[data-cell="${g.current}"]`);g.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let S=e=>!e.virtual||e.enabled||e.value!==``||e.file,C=e=>i(e.filter(S).map(({virtual:e,...t})=>t)),w=(e,t)=>C(y.map((n,r)=>r===e?{...n,...t}:n)),T=(e,t)=>m.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),E=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),T(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),T(e-1,t))},D=e=>{let t=y[e],n=x(t.key)?.enum??[],r=new Set(y.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...y];o.splice(e+1,0,a),g.current=`${o.filter(S).indexOf(a)}:${Hr}`,C(o)},O=(e,t)=>{let n=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(n.trim()))return;e.preventDefault();let a=Ur(n).map(e=>({...e,enabled:!0})),o=[...r];o.splice(t,+(t<r.length&&!r[t]?.key),...a),i(o)},k=y.length;return t(`section`,{class:`grid`,"aria-label":e,ref:m,children:[!f&&t(`h3`,{children:e}),t(`table`,{ref:h,children:[t(zr,{}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-check`}),t(`th`,{class:`g-key`,children:[`Key`,t(Br,{which:`key`,table:()=>h.current})]}),t(`th`,{class:`g-val`,children:[`Value`,t(Br,{which:`val`,table:()=>h.current})]}),t(`th`,{class:`g-doc`,children:`Description`}),t(`th`,{class:`g-act`})]})}),t(`tbody`,{children:[y.map((e,n)=>{let r=x(e.key),i=b(e.key)?.file,a=c||p||e.virtual||b(e.key);return t(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[t(`td`,{class:`g-check`,children:t(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:c||p,onChange:e=>w(n,{enabled:e.target.checked})})}),t(`td`,{class:`g-key`,children:a?t(`span`,{class:`key`,children:[t(`code`,{children:e.key}),r?.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}):t(`input`,{class:`cell`,"data-cell":`${n}:${Vr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>w(n,{key:e.target.value}),onKeyDown:E(n,Vr),onPaste:e=>O(e,n)})}),t(`td`,{class:`g-val`,children:i?t(`label`,{class:`file-cell`,children:[t(`input`,{type:`file`,disabled:p,"aria-label":`File for ${e.key}`,onChange:e=>{let t=e.target.files?.[0];t&&w(n,{file:t,value:t.name,enabled:!0})}}),t(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?t(Mr,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${n}:${Hr}`,readOnly:p,placeholder:`value`,onKeyDown:E(n,Hr),onChange:e=>w(n,{value:e,enabled:!0})}):t(`input`,{class:`cell`,"data-cell":`${n}:${Hr}`,value:e.value,readOnly:p,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>w(n,{value:e.target.value,enabled:!0}),onKeyDown:E(n,Hr)})}),t(`td`,{class:`g-doc`,title:Fe(r?.description),children:r&&t(l,{children:[t(`span`,{class:`chip`,children:r.type}),` `,t(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:Re(r.description)}})]})}),t(`td`,{class:`g-act`,children:[!c&&!p&&e.key&&t(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>D(n),children:t(Wr,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!c&&!p&&!e.virtual&&t(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>C(y.filter((e,t)=>t!==n)),children:t(Wr,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},n)}),!c&&!p&&t(`tr`,{class:`ghost`,children:[t(`td`,{class:`g-check`}),t(`td`,{class:`g-key`,children:t(`input`,{class:`cell`,"data-cell":`${k}:${Vr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{g.current=`${r.length}:${Vr}`,i([...r,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:E(k,Vr),onPaste:e=>O(e,r.length)})}),t(`td`,{class:`g-val`}),t(`td`,{class:`g-doc`}),t(`td`,{class:`g-act`})]},k)]})]})]})}function Kr({draft:e,onChange:r,readOnly:i}){let[o,c]=a(()=>Ar(e.body)),l=s(e.body);n(()=>{if(e.body===l.current)return;let t=Ar(e.body);t&&c(t),l.current=e.body},[e.body]);let u=t=>{let n={...o,...t};c(n),l.current=jr(n),r({...e,body:l.current})};return t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Query`}),t(`span`,{class:`chip`,children:`graphql`})]}),t(gr,{readOnly:i,label:`GraphQL query`,language:`graphql`,value:o.query,onChange:e=>u({query:e})}),t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Variables`}),t(`span`,{class:`chip`,children:`json`})]}),t(gr,{readOnly:i,label:`GraphQL variables`,language:`json`,value:o.variables,onChange:e=>u({variables:e})})]})}var qr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function Jr({encoding:e,draft:n,onChange:r,schema:i,defs:s,files:c=[],notes:u,readOnly:d}){let[f,p]=a(0),m=o(()=>Qe(n.body),[n.body]),h=e===`json`||e===`form`,g=o(()=>{let e=m[f];return e&&h?Ot(Et(i,s,e,[`data`]),u,`data`,Ze(e)):void 0},[m,f,i,s,h,u]),_=o(()=>h&&i?(e,t)=>Sr(i,s,[`data`],e,t):void 0,[i,s,h]),v=e=>{if(e!==(n.formView??`grid`)){if(e===`grid`)try{r({...n,formView:`grid`,fields:ge(JSON.parse(n.body||`{}`))})}catch{r({...n,formView:`grid`})}else r({...n,formView:`json`,body:JSON.stringify(ye(n.fields.filter(e=>!e.file)),null,2)})}},y=e===`form`?t(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>t(`button`,{type:`button`,class:`seg-btn ${(n.formView??`grid`)===e?`on`:``}`,"aria-pressed":(n.formView??`grid`)===e,onClick:()=>v(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(Cr(n,e)||e===`binary`){let a=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),o=e=>r({...n,fields:e}),f=(n.fields.length?n.fields.map(e=>e.key):[]).filter(a);return t(l,{children:[y&&t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),y]}),t(Gr,{title:e===`binary`?`File`:`Body`,bare:!!y,rows:n.fields,readOnly:d,onChange:o,documented:[...new Set(f)].map(e=>({name:e,file:!0})),docFor:e=>Ot(Et(i,s,Dt(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&Ar(n.body)?t(Kr,{draft:n,onChange:r,readOnly:d}):t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),e!==`text`&&!d&&t(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...n,body:JSON.stringify(JSON.parse(n.body),null,2)})}catch{}},children:`Format`}),y]}),t(gr,{readOnly:d,label:`Request body`,language:qr(e===`form`?`json`:e),value:n.body,onChange:e=>r({...n,body:e}),onLine:p,complete:_}),h&&t(kr,{doc:g})]})}var Yr=`specbook:code-lang`;function Xr(){try{let e=E.local.getItem(Yr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Zr({service:e,profile:r,secured:i,make:s,sent:c}){let[l,u]=a(Xr),d=l===`sent`?`curl`:l,[f,p]=a(!1),[m,h]=a(),[g,_]=a();n(()=>{let t=!0;return P.config(A.value).then(async n=>{let i=n.services?.[e],a=t=>P.baseUrlOf(e,t,A.value).catch(()=>void 0),o=F.value===`mock`?void 0:await a(F.value);if(o??=await a(`live`),!o&&i&&typeof i.baseUrl==`object`&&(o=Object.values(i.baseUrl)[0]),!t)return;h(o);let s=r===`service`?i?.auth:r;_(s?n.auth?.[s]?.apply:void 0)}),()=>{t=!1}},[e,r,F.value,te.value]);let v=o(()=>{try{return{text:Me(d,s(m??`https://api.example.com`,g))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[s,d,m,g]),y=e=>{if(u(e),e!==`sent`)try{E.local.setItem(Yr,e)}catch{}};return t(`div`,{class:`code-sample`,children:[t(`div`,{class:`code-head`,children:[t(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[Ne.map(e=>t(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>y(e.id),children:e.label})),c!==void 0&&t(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>y(`sent`),children:`Sent`})]}),t(`span`,{class:`spacer`}),l!==`sent`&&t(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(v.text)try{await navigator.clipboard.writeText(v.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!v.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:v.error?t(`p`,{class:`muted`,children:v.error}):t(`pre`,{class:`code-block`,part:`code`,children:t(`code`,{children:v.text})}),l!==`sent`&&i&&t(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Qr({service:e,method:n,path:r,draft:a,encoding:o,vars:s,secured:c,sent:l}){let u=i((e,t)=>{let i=Er(a,o),c={path:i.path??{},query:i.query??{},headers:i.headers??{},data:i.data},l=c;try{l=g(c,s)}catch{}let u=r.replace(/\{([^}]+)\}/g,(e,t)=>{let n=l.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:n,url:`${e.replace(/\/+$/,``)}${u}`,query:{...t?.query??{},...l.query},headers:{...t?.headers??{},...l.headers},body:l.data,encoding:o}},[a,o,s,n,r]);return t(Zr,{service:e,profile:c?`service`:void 0,secured:c,make:u,sent:l})}function $r({request:e,encoding:n,sent:r}){let a=i((t,r)=>({method:e.method,url:`${t.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:n}),[e,n]);return t(Zr,{service:e.service,profile:e.profile,secured:!!e.profile,make:a,sent:r})}function ei(e,t){try{let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return Object.prototype.toString.call(e)}}function ti(e){let t=typeof e==`string`?e:ei(e);return t.length>28?`${t.slice(0,27)}…`:t}var ni=e=>typeof e==`string`?e:ei(e,2);function ri(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 ii({body:e,docs:n}){let[r,i]=a(0),s=ni(e),c=!!n?.schema&&typeof e==`object`&&!!e,u=o(()=>c?Qe(s):[],[c,s]),d=o(()=>{let e=u[r];return e&&n?Ot(Et(n.schema,n.defs,e,[`data`]),n.notes,`data`,Ze(e)):void 0},[u,r,n]);return t(l,{children:[t(gr,{label:`Body as sent`,value:s,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&t(kr,{doc:d})]})}function ai({request:e,hideBar:n,docs:r}){if(!e)return t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing sent yet`}),t(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return t(`div`,{class:`sent-view`,children:[!n&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${e.method}`,children:e.method}),t(`div`,{class:`rq-url`,title:e.url,children:t(`code`,{children:[e.url,ri(e.query)]})})]}),t(`h3`,{children:`Headers`}),i.length===0?t(`p`,{class:`muted`,children:`No headers.`}):t(`table`,{class:`headers`,children:t(`tbody`,{children:i.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]}))})}),e.body!==void 0&&t(l,{children:[t(`h3`,{children:`Body`}),t(ii,{body:e.body,docs:r})]})]})}function oi(e){let t=e.location;if(!t)return;let n=[...T.requests,...T.sequences].map(e=>e.file).filter(e=>t.file.includes(e)).sort((e,t)=>t.length-e.length)[0];return n?`${n}:${t.line}`:void 0}var si={expected:`−`,received:`+`,same:` `,skip:` `},ci={expected:`expected`,received:`received`,same:``,skip:``};function li({lines:e}){return t(`section`,{class:`diff`,tabIndex:0,"aria-label":`Expected and received values`,children:e.map(e=>t(`div`,{class:`diff-line diff-${e.kind}`,children:[t(`span`,{class:`diff-gutter`,"aria-hidden":`true`,children:si[e.kind]}),ci[e.kind]&&t(`span`,{class:`visually-hidden`,children:[ci[e.kind],`: `]}),t(`span`,{class:`diff-text`,children:e.text})]}))})}function ui({a:e}){let n=fe(e),r=oi(e);return t(`fieldset`,{class:`check-fail`,children:[t(`legend`,{class:`visually-hidden`,children:[`Failed check: `,e.label]}),t(`div`,{class:`check-head`,children:[t(`span`,{class:`check-mark`,"aria-hidden":`true`,children:`✗`}),t(`strong`,{children:e.label}),t(`span`,{class:`chip`,children:e.operator})]}),n.length>0&&t(l,{children:[t(`div`,{class:`diff-legend`,"aria-hidden":`true`,children:[t(`span`,{class:`diff-key diff-expected`,children:`− Expected`}),t(`span`,{class:`diff-key diff-received`,children:`+ Received`})]}),t(li,{lines:n})]}),r&&t(`div`,{class:`check-where`,children:[`at `,r]})]})}function di({assertions:e}){return t(`ul`,{class:`checks`,children:e.map(e=>e.pass?t(`li`,{class:`ok`,children:[t(`span`,{class:`tick`,children:`✓`}),` `,e.label]}):t(`li`,{class:`bad`,children:t(ui,{a:e})}))})}var fi=e=>ei(e,2),pi=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function mi({step:e,error:r,schemas:i,defs:s,hideRequest:c}){let[u,d]=a(`body`),[f,p]=a(0),m=e?.response,h=m?i?.[String(m.status)]??i?.default:void 0,g=o(()=>{try{return m&&h?Xe(m.body,h,s,{reportExtra:!0}):[]}catch{return[]}},[m,h,s]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:fi(m.body),v=o(()=>Qe(_),[_]),y=o(()=>{let e=v[f];return e?Et(h,s,e):void 0},[v,f,h,s]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length;n(()=>{e&&x>0&&d(`checks`)},[e]);let S=Object.entries(m?.headers??{}),C=!m&&!r&&!e?.error;return t(`section`,{class:`response`,"aria-label":`Response`,children:[t(`div`,{class:`rs-head`,children:[m&&t(l,{children:[t(`span`,{class:`state-badge ${nt(m.status)}`,children:[m.status,` `,tt(m.status)]}),t(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),t(`span`,{class:`rs-stat`,children:pi(new Blob([_]).size)})]}),t(`span`,{class:`spacer`}),m&&t(`span`,{class:`conf ${h?g.length?`warn`:`ok`:`none`}`,children:h?g.length?`⚠ ${g.length} difference${g.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!c&&t(`p`,{class:`sent`,children:[t(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,t(`code`,{children:[e.request.url,ri(e.request.query)]})]}),r&&t(`p`,{class:`error-text`,children:r}),e?.error&&t(`p`,{class:`error-text`,children:e.error}),C&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`No response yet`}),t(`span`,{class:`muted`,children:[`Press`,` `,t(`kbd`,{class:`icon-key`,children:t(se,{size:12})}),` `,`or `,t(`kbd`,{children:`⌘`}),` `,t(`kbd`,{children:`↵`})]})]}),m&&t(l,{children:[t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":u===e,class:`rq-tab ${u===e?`on`:``}`,onClick:()=>d(e),children:[n,r>0&&t(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,title:e===`checks`&&x?`${x} of ${r} checks failed`:void 0,children:e===`checks`&&x?x:r})]}))}),t(`div`,{class:`rs-pane`,children:[t(`div`,{hidden:u!==`body`,children:[_===``?t(`p`,{class:`muted`,children:`No content.`}):t(gr,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:p}),_!==``&&t(kr,{doc:y}),g.length>0&&t(`details`,{class:`issues`,children:[t(`summary`,{children:`What differs`}),t(`ul`,{children:g.map(e=>t(`li`,{children:[t(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),t(`div`,{hidden:u!==`headers`,children:t(`table`,{class:`headers`,children:t(`tbody`,{children:[S.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]})),S.length===0&&t(`tr`,{children:t(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),t(`div`,{hidden:u!==`checks`,children:b.length===0?t(`p`,{class:`muted`,children:`This request has no checks.`}):t(di,{assertions:b})})]})]})]})}var hi=()=>{let e=document.querySelector(`meta[name="specbook-oauth-callback"]`)?.content.trim();if(e)try{return new URL(e,location.origin).href}catch{}return`${location.origin}${location.pathname}`};async function gi(e){let t=window.open(``,u,`popup,width=520,height=720`);if(!t)throw new C(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(u),r;try{let{verifier:i,challenge:a}=await p(),o=ee(),s=hi(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new C(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new C(`Sign-in was cancelled.`))});let c=(e,n)=>{e?.type===`callback`&&e.state===o&&(s(),n({type:`ack`,state:o}),t(e))};n.onmessage=e=>c(e.data,e=>n.postMessage(e)),r=e=>{e.origin===location.origin&&c(e.data,t=>e.source?.postMessage(t,location.origin))},addEventListener(`message`,r)});t.location.href=m({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=d({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),f=await e.exchange(v({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return N(f)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var _i=`specbook.oauth.clients.v1`,vi=`specbook.oauth.expiry.v1`,yi=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},bi=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},xi=e=>{try{return yi(E.local,_i)[e]}catch{return}},Si=(e,t)=>{try{bi(E.local,_i,{...yi(E.local,_i),[e]:t})}catch{}},Ci=(e,t)=>`${e}\n${t}`,wi=(e,t,n)=>{try{let r=yi(E.session,vi);n===void 0?delete r[Ci(e,t)]:r[Ci(e,t)]=Date.now()+n*1e3,bi(E.session,vi,r)}catch{}},Ti=(e,t)=>{try{return yi(E.session,vi)[Ci(e,t)]}catch{return}};function Ei({service:e,profile:r,origin:i,secret:o,oauth:c,onSignedIn:l}){let u=b(c)?c.openIdConnectUrl:c.authorizationUrl,[d,f]=a(()=>c.clientId??xi(u)??``);n(()=>{f(c.clientId??xi(u)??``)},[u,c.clientId]);let[p,m]=a(void 0),[h,g]=a([]),[_,v]=a({kind:`idle`}),y=s(void 0),x=_.kind===`busy`,[S,C]=a(0);n(()=>{let e=!0;return m(void 0),v(e=>e.kind===`busy`?e:{kind:`idle`}),P.oauthEndpoints({env:F.value,version:A.value,profile:r}).then(t=>{e&&(m(t),g(b(c)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&v({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[r,F.value,A.value,S,te.value]);let w=Object.keys(p?.scopes??{}),T=()=>{if(!p)return C(e=>e+1);let e=d.trim();if(!e)return v({kind:`error`,message:`Enter the client id registered for this page.`});let t=new AbortController;y.current=t,v({kind:`busy`}),Si(u,e),gi({authorizationUrl:p.authorizationUrl,clientId:e,scopes:h,signal:t.signal,exchange:(e,t)=>P.oauthExchange({env:F.value,version:A.value,profile:r,fields:e,signal:t})}).then(e=>{ce.set(i,o,e.accessToken),wi(i,o,e.expiresIn),v({kind:`idle`}),l()}).catch(e=>v({kind:`error`,message:e instanceof Error?e.message:String(e)}))},E=!p&&_.kind===`error`,D=!x&&_.kind!==`error`&&!!p;return t(`span`,{class:`needs-var oauth-signin`,children:[t(`input`,{type:`text`,autocomplete:`off`,"aria-label":`Client id for ${e}`,placeholder:`client id`,value:d,disabled:x,onInput:e=>f(e.target.value)}),x?t(`button`,{type:`button`,class:`link`,onClick:()=>y.current?.abort(),children:`Cancel`}):t(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&t(`details`,{children:[t(`summary`,{class:`muted small`,children:[`Scopes (`,h.length,` of `,w.length,`)`]}),w.map(e=>t(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[t(`input`,{type:`checkbox`,checked:h.includes(e),disabled:x,onChange:t=>g(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,t(`code`,{children:e})]}))]}),t(`span`,{class:`muted small oauth-status ${D?`oauth-hint`:``}`,role:`status`,"aria-live":`polite`,children:x?`Waiting for the sign-in window…`:_.kind===`error`?_.message:p?`Register this redirect URI with the provider: ${hi()}`:`Looking up the provider…`})]})}var Di=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),Oi={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function ki({services:e,enabled:r=!0,supplied:i}){let[o,s]=a([]),[c,u]=a({}),d=i??c,[,f]=a(0),[p,m]=a(!1),h=r&&F.value!==`mock`,g=e?.join(`
41
+ `)??`*`;if(n(()=>{if(!h){s([]);return}let t=!0;return i||P.managedSecrets(F.value).then(e=>t&&u(e)),P.config(A.value).then(async n=>{let r=[],i=await P.addressesIn(n,F.value);for(let[t,a]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let o=a.auth?n.auth?.[a.auth]:void 0,s=i.baseUrl(t),c=oe(s?L(s,globalThis.location?.href):void 0);if(!o||!c)continue;let l=a.auth?i.oauth(a.auth):void 0,u=[...new Set([...JSON.stringify(o.apply).matchAll(w)].map(e=>e[1]))];u.length&&r.push({service:t,origin:c,title:o.title??a.auth??``,names:u,profile:a.auth,oauth:l})}t&&s(r)}),()=>{t=!1}},[h,F.value,g,A.value,te.value]),!h||o.length===0)return null;let _=(e,t)=>ce.get(e.origin,t)!==void 0||d[t]!==void 0,v=o.some(e=>e.names.some(t=>!_(e,t)));return!v&&!p?t(`div`,{class:`secrets-folded`,children:t(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>m(!0),children:[t(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):t(`fieldset`,{class:`needs-vars ${v?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>t(l,{children:[t(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(n=>{let r=ce.get(e.origin,n)!==void 0,i=d[n];return t(`span`,{class:`needs-var`,children:[t(`code`,{children:n}),r?t(l,{children:[t(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&Di(Ti(e.origin,n))!==void 0?` · expires in ${Di(Ti(e.origin,n))} min`:``]}),t(`button`,{type:`button`,class:`link`,onClick:()=>{ce.remove(e.origin,n),wi(e.origin,n,void 0),f(e=>e+1)},children:`Clear`})]}):t(l,{children:[i&&t(`span`,{class:`muted`,children:[`from `,Oi[i]??i]}),e.oauth&&t(Ei,{service:e.service,profile:e.profile,origin:e.origin,secret:n,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),t(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${n} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:t=>{let r=t.target.value;r!==``&&(ce.set(e.origin,n,r),f(e=>e+1))}})]})]})})]})),t(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!v&&t(`button`,{type:`button`,class:`link`,onClick:()=>m(!1),children:`Hide`})]})}var Ai=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`),ji=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Mi(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[ji(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(ji(Ai(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 Ni(e){let{seq:t}=e,[r,i]=a(),[s,c]=a(!1);n(()=>{let n=!0;i(void 0),c(!1);let r=T.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!r)c(!0);else return r.load().then(e=>n&&i(e)).finally(()=>n&&c(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=o(()=>t.nodes.map(e=>e.name),[t]);return o(()=>({...Mi(r??Pe(t.meta.description),l),loaded:s}),[r,l,t,s])}function Pi(e){let[t,r]=a();return n(()=>{let t=!0;return r(void 0),e&&T.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&r(e)),()=>{t=!1}},[e]),t}var Fi=(e,t)=>`specbook:draft:${e}:${t}`,Ii=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Li(e){try{let t=E.local.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Ri=`specbook:saved-example`;function zi(e){try{let t=E.session.getItem(Ri),n=t?JSON.parse(t):void 0;return n?.key===e?(E.session.removeItem(Ri),n):void 0}catch{return}}function Bi({service:e,op:r,variants:i,initial:c,autoRun:u}){let d=`${e}/${r.id}`,f=s(null),p=s(!1),m=s(void 0),g=P.examplesOf(d),[v,y]=a(()=>zi(d)),[b,x]=a(()=>{if(c?.startsWith(`saved:`)&&i.some(e=>`saved:${e.file}`===c))return c;let e=g.find(e=>e.name===(v?.name??c));return e?`ex:${e.name}`:g[0]?`ex:${g[0].name}`:i[0]?`saved:${i[0].file}`:``}),C=b.startsWith(`saved:`)?i.find(e=>`saved:${e.file}`===b):void 0,w=Pi(C?.file),O=mt(d),[N,ee]=a(),[I,oe]=a(),[L,ce]=a(),[R,le]=a({}),[z,ue]=a(),[de,fe]=a(),[pe,me]=a(),[he,ge]=a(),[_e,ve]=a(),[ye,be]=a(),[xe,Se]=a(!1),[Ce,we]=a(),[Te,B]=a(),[Ee,De]=a(``),[V,Oe]=a(),[ke,H]=a();n(()=>{let t=!0;if(H(void 0),F.value===`mock`)De(``);else return P.baseUrlOf(e,F.value,A.value).then(e=>t&&De(e??``)).catch(e=>{t&&(De(``),H(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[e,F.value,A.value,te.value]),n(()=>{let e=!0;return Oe(void 0),P.knownVars(F.value,A.value).then(t=>e&&Oe(t)),()=>{e=!1}},[F.value]),n(()=>{let t=!0;return T.schemas[d]?.().then(e=>t&&ue(e.default)),T.responseSchemas[d]?.().then(e=>t&&fe(e.default)),T.definitions[e]?.().then(e=>t&&me(e.default)),P.operationMeta(d,A.value).then(e=>{t&&ee({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[d,e]);let U=N?.encoding??`json`,Ae=T.manifests[e]?.operations.find(e=>e.id===r.id)?.secured;n(()=>{if(!N)return;let e=!0;return be(void 0),ve(void 0),(async()=>{let t=C?await P.savedExample(C.def,A.value):await P.loadExample(d,b.replace(/^ex:/,``),A.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};oe(n),ce(!C&&Li(Fi(d,b))||wr(n,U))})().catch(t=>e&&be(t instanceof Error?t.message:String(t))),()=>{e=!1}},[d,b,N,C]);let je=o(()=>I?wr(I,U):void 0,[I,U]),Me=!!L&&!!je&&JSON.stringify(Dr(L))!==JSON.stringify(Dr(je)),Ne=e=>{if(ce(e),!C)try{let t=Fi(d,b);je&&JSON.stringify(Dr(e))===JSON.stringify(Dr(je))?E.local.removeItem(t):E.local.setItem(t,JSON.stringify(Dr(e)))}catch{}},W=o(()=>{let e=z?q(z,pe):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Ke(r,pe).map(e=>({name:e.name,doc:Ot(Et(z,pe,[e.name],[n]),O.notes,n,e.name),repeat:q(e.schema,pe).type===`array`})))}return t},[z,pe,O.notes]),G=o(()=>{if(!L)return[];try{let e=Er(L,U);return[...h([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(_).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[L,U]),Pe=o(()=>{let e=C?.def.input;if(Object.values(e?.init??{}).some(e=>typeof e==`function`)||typeof e?.data==`function`)return!0;if(!L)return!1;try{let e=Er(L,U);return[...h([e.path,e.query,e.headers,e.data,R])].some(e=>e.startsWith(`faker.`))}catch{return!1}},[C,L,U,R]);n(()=>(k.value=Pe,()=>{k.value=!1}),[Pe]);let Fe=Object.keys(C?.def.input.init??{}),Ie=V?G.filter(e=>!V.includes(e)&&!Fe.includes(e)):[],Le=Ie.filter(e=>(R[e]??``)===``),Re=async e=>{if(!L||m.current)return;be(void 0),Se(!0);let t=new AbortController;m.current=t;try{let n=C?C.def:await P.operationRequest(d,A.value,Er(L,U)),r=await P.run(n,{env:F.value,version:A.value,mockStatus:F.value===`mock`?e??he:void 0,locale:ne.value,seed:j.value,vars:Object.fromEntries(Object.entries(R).filter(([,e])=>e!==``)),fileDir:I?.dir,signal:t.signal});ve(r),bt.value=xt(r)}catch(e){be(e instanceof Error?e.message:String(e))}finally{m.current=void 0,Se(!1),B(`response`)}};n(()=>{u&&L&&!p.current&&(p.current=!0,Re())},[L]);let ze=async t=>{if(!L)return;let n=Er(L,U),i=Ii(t),a={name:i,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${T.project.requestsDir}/${e}/${r.id}/${i}.example.json`,s={key:d,path:o,name:i};try{E.session.setItem(Ri,JSON.stringify(s))}catch{}await ie(o,`${JSON.stringify(a,null,2)}\n`),y(s),we(void 0)},K=_e?.steps.find(e=>e.response)??_e?.steps[0],Be=ye?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Ve=!!L&&(L.path.length>0||L.query.length>0||W.path.length>0||W.query.length>0),He=!!L&&(L.headers.length>0||W.headers.length>0),Ue=!!L&&U!==`none`&&(L.body!==``||L.fields.length>0||!!z?.properties?.data),J=Te??(Ve?`params`:Ue?`body`:He?`headers`:`params`),We=e=>e.filter(e=>e.enabled).length,Ge=L?We(L.query):0,qe=L?We(L.path):0,Je=L?Or(r.path,L.path,L.query,Ee):r.path;return n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Re())},t=f.current?.getRootNode()??window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)}),t(`div`,{class:`request-panel`,"data-op":d,ref:f,children:t(`div`,{class:`rq`,children:[t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),t(`div`,{class:`rq-url`,title:Je,children:t(`code`,{children:Je.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?t(`mark`,{children:e}):e)})}),(K?.response||ye||K?.error)&&t(`button`,{type:`button`,class:`result-chip ${K?.response?nt(K.response.status):`s5`}`,title:`Open the response`,onClick:()=>B(`response`),children:K?.response?`${K.response.status} ${tt(K.response.status)} · ${K.response.durationMs} ms`:`Failed`}),t(`button`,{type:`button`,class:`btn primary send`,title:xe?`Stop`:`Send (⌘/Ctrl + Enter)`,"aria-label":xe?`Stop`:`Send`,disabled:!xe&&!L,onClick:()=>xe?m.current?.abort():Re(),children:t(xe?S:se,{})})]}),ke&&t(`p`,{class:`envmenu-warn`,role:`alert`,children:[ke,`.`,` `,ae.value.environmentSettings&&t(`button`,{type:`button`,class:`link`,onClick:()=>D.value=!0,children:`Open Environment settings`})]}),w&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this request`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:w}})]},C?.file),Ie.length>0&&t(`fieldset`,{class:`needs-vars ${Le.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[t(`span`,{class:`muted`,children:Le.length>0?`Needs a value for`:`Values for`}),Ie.map(e=>t(`label`,{class:`needs-var`,children:[t(`code`,{children:e}),t(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:R[e]??``,onInput:t=>le({...R,[e]:t.target.value})})]}))]}),Ae&&t(ki,{services:[e]}),t(`div`,{class:`rq-meta`,children:[t(`div`,{class:`rq-example`,children:[t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Example`}),t(`select`,{value:b,onChange:e=>x(e.target.value),children:[g.map(e=>t(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),i.map(e=>t(`option`,{value:`saved:${e.file}`,children:[e.name,` · request`]}))]})]}),t(re,{})]}),Me&&t(`span`,{class:`edited`,children:`Edited`}),t(`span`,{class:`spacer`}),Me&&t(`button`,{type:`button`,class:`link`,onClick:()=>je&&Ne(je),children:`↺ Reset`}),!M&&!C&&Me&&Ce===void 0&&t(`button`,{type:`button`,class:`link`,onClick:()=>we(``),children:`Save as example…`}),F.value===`mock`&&r.statuses.length>0&&t(`label`,{class:`rq-status`,children:[t(`span`,{class:`muted`,children:`Respond with`}),t(`select`,{"aria-label":`Mock response`,value:he===void 0?``:String(he),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);ge(n),Re(n)},children:[t(`option`,{value:``,children:`Default`}),r.statuses.map(e=>t(`option`,{value:String(e),children:[e,` `,tt(e)]}))]})]})]}),v&&t(`p`,{class:`saved-note`,role:`status`,children:[t(`span`,{children:[`✓ Saved to `,t(`code`,{children:v.path}),`. It is a normal project file: commit it to share this example with your team.`]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>y(void 0),children:`×`})]}),Ce!==void 0&&t(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),Ce.trim()&&ze(Ce.trim()).catch(e=>be(String(e)))},children:[t(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:Ce,onInput:e=>we(e.target.value)}),t(`button`,{type:`submit`,class:`btn`,children:`Save`}),t(`button`,{type:`button`,class:`link`,onClick:()=>we(void 0),children:`Cancel`})]}),C&&t(`p`,{class:`muted lock`,children:[`A request from your project: it runs with its own values and checks. Edit its file to change it.`,F.value===`mock`&&C.def.mockHook?` Its mock hook shapes the answer.`:``]}),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,Ge+qe],[`headers`,`Headers`,L?We(L.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,G.length]].filter(([e])=>e===`params`?Ve:e===`headers`?He:e===`body`?Ue:G.length>0).map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":J===e,class:`rq-tab ${J===e?`on`:``}`,onClick:()=>B(e),children:[n,r>0&&t(`span`,{class:`count`,children:r}),e===`body`&&t(`span`,{class:`chip`,children:U})]})),t(`span`,{class:`tab-gap`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":J===`request`,class:`rq-tab ${J===`request`?`on`:``}`,onClick:()=>B(`request`),children:`Request`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":J===`response`,class:`rq-tab ${J===`response`?`on`:``}`,onClick:()=>B(`response`),children:[`Response`,K?.response&&t(`span`,{class:`state-dot ${nt(K.response.status)}`,children:K.response.status}),!K?.response&&(ye||K?.error)&&t(`span`,{class:`state-dot s5`,children:`!`})]})]}),t(`div`,{class:`rq-pane`,children:[L&&t(l,{children:[t(`div`,{class:`tab-pane`,hidden:J!==`params`,children:[(L.query.length>0||W.query.length>0)&&t(Gr,{title:`Query`,rows:L.query,documented:W.query,readOnly:!!C,onChange:e=>Ne({...L,query:e})}),(L.path.length>0||W.path.length>0)&&t(Gr,{title:`Path`,rows:L.path,documented:W.path,fixed:!0,readOnly:!!C,onChange:e=>Ne({...L,path:e})})]}),t(`div`,{class:`tab-pane`,hidden:J!==`headers`,children:He&&t(Gr,{title:`Headers`,rows:L.headers,documented:W.headers,readOnly:!!C,onChange:e=>Ne({...L,headers:e})})}),t(`div`,{class:`tab-pane`,hidden:J!==`body`,children:Ue&&t(Jr,{encoding:U,draft:L,onChange:Ne,schema:z,defs:pe,files:N?.files,notes:O.notes,readOnly:!!C})}),t(`div`,{class:`tab-pane`,hidden:J!==`vars`,children:G.length>0&&t(Gr,{title:`Variables`,rows:G.map(e=>({key:e,value:R[e]??``,enabled:!0})),fixed:!0,bad:Be,placeholder:`from the request's init, config or earlier steps`,onChange:e=>le(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),t(`div`,{class:`tab-pane`,hidden:J!==`request`,children:L&&t(Qr,{service:e,method:r.method,path:r.path,draft:L,encoding:U,vars:R,secured:Ae,sent:K?.request?t(ai,{request:K.request,docs:{schema:z,defs:pe,notes:O.notes}}):void 0})}),t(`div`,{class:`tab-pane`,hidden:J!==`response`,children:t(mi,{step:K,error:ye,schemas:de,defs:pe})})]})]})})}function Vi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Hi(e,t),...n}}function Hi(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,Vi(t)]))};case`array`:return{kind:`array`,item:Vi(t.item),default:t.default,min:t.min,max:t.max};default:return typeof t.default==`function`?{kind:e.kind,generate:t.default,min:t.min,max:t.max}:{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function Ui(e){if(e.generate)try{return e.generate()}catch{}return Wi({...e,generate:void 0})}function Wi(e){if(e.generate)return Ui(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,Wi(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Gi={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Ki=e=>typeof e==`string`?e:ei(e);function qi({info:e}){let{seq:n}=e,{intro:r,notes:i}=Ni(e),a=o(()=>Object.entries(n.meta.inputs??{}).map(([e,t])=>{let n=Vi(t);return{name:e,spec:n,initial:Wi(n)}}),[n]);return t(`article`,{class:`doc`,"data-seq":n.meta.id,children:[(n.meta.tags?.length??0)>0&&t(`p`,{class:`doc-tags`,children:n.meta.tags?.map(e=>t(`span`,{class:`chip`,children:e}))}),r&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&t(`section`,{children:[t(`h2`,{children:`Controls`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Name`}),t(`th`,{children:`Type`}),t(`th`,{children:`Default`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:a.map(e=>t(`tr`,{children:[t(`td`,{children:t(`code`,{children:e.name})}),t(`td`,{children:t(`span`,{class:`chip`,children:e.spec.kind})}),t(`td`,{children:t(`code`,{children:Ki(e.initial)})}),t(`td`,{children:e.spec.description})]}))})]})]}),t(`section`,{children:[t(`h2`,{children:`Steps`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`#`}),t(`th`,{children:`Step`}),t(`th`,{children:`What it does`})]})}),t(`tbody`,{children:n.nodes.map((e,n)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return t(l,{children:[t(`tr`,{class:a?`has-note`:``,children:[t(`td`,{children:n+1}),t(`td`,{children:e.name}),t(`td`,{children:r?t(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>f({kind:`op`,key:`${r.service}/${r.id}`}),children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path})]}):t(`span`,{class:`muted`,children:Gi[e.kind]??e.kind})})]}),a&&t(`tr`,{class:`step-note-row`,children:[t(`td`,{}),t(`td`,{colSpan:2,children:t(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var Ji=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Yi(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Xi({name:e,spec:n,value:r,onChange:i}){let[o,s]=a();switch(n.kind){case`number`:return t(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:n.min,max:n.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return t(Mr,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return t(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=n.options??[],o=a.find(e=>Ji(e.value,r));return t(Mr,{label:e,value:o?.label??String(r??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=r??[];return t(`div`,{class:`multi-cell`,children:(n.options??[]).map(n=>t(`label`,{children:[t(`input`,{type:`checkbox`,checked:e.some(e=>Ji(e,n.value)),onChange:t=>i(t.target.checked?[...e,n.value]:e.filter(e=>!Ji(e,n.value)))}),n.label]}))})}case`object`:case`array`:return t(`input`,{class:`cell mono`,"aria-label":e,value:o??JSON.stringify(r??Wi(n)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return t(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function Zi(){return t(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:[t(`rect`,{x:`1.5`,y:`1.5`,width:`13`,height:`13`,rx:`3`,fill:`none`,stroke:`currentColor`}),t(`circle`,{cx:`5.2`,cy:`5.2`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`10.8`,cy:`10.8`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`8`,cy:`8`,r:`1.1`,fill:`currentColor`})]})}function Qi({title:e,specs:n,values:r,onChange:i}){let a=Object.keys(n);if(a.length===0)return null;let o=a.filter(e=>n[e]?.generate);return t(`section`,{class:`grid controls-grid`,"aria-label":e,children:[t(`h3`,{class:`controls-head`,children:[t(`span`,{children:e}),o.length>1&&t(`button`,{type:`button`,class:`btn small gen-all`,title:`Make a new value for every generated input`,onClick:()=>i({...r,...Object.fromEntries(o.map(e=>[e,Ui(n[e])]))}),children:[t(Zi,{}),` Generate all`]})]}),t(`table`,{children:[t(`colgroup`,{children:[t(`col`,{class:`c-key`}),t(`col`,{class:`c-val`}),t(`col`,{})]}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-key`,children:`Name`}),t(`th`,{class:`g-val`,children:`Value`}),t(`th`,{class:`g-doc`,children:`Description`})]})}),t(`tbody`,{children:a.map(e=>{let a=n[e];return t(`tr`,{children:[t(`td`,{class:`g-key`,children:t(`span`,{class:`key`,children:t(`code`,{children:a.label??e})})}),t(`td`,{class:`g-val`,children:t(`div`,{class:a.generate?`cell-gen`:void 0,children:[t(Xi,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})}),a.generate&&t(`button`,{type:`button`,class:`gen`,"aria-label":`Generate ${a.label??e}`,title:`Make another value`,onClick:()=>i({...r,[e]:Ui(a)}),children:t(Zi,{})})]})}),t(`td`,{class:`g-doc`,title:a.description,children:[t(`span`,{class:`chip`,children:Yi(a)}),` `,a.description]})]},e)})})]})]})}function $i({step:e,note:r}){let[i,o]=a(`response`),[s,c]=a(),[l,u]=a(),[d,f]=a(),[p,m]=a(`json`),h=e.request,g=h?.opId?`${h.service}/${h.opId}`:void 0;n(()=>{o(`response`)},[e.name]),n(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),g&&h&&(T.schemas[g]?.().then(t=>e&&f(t.default)),P.operationMeta(g,A.value).then(t=>e&&m(t?.encoding??`json`)),T.responseSchemas[g]?.().then(t=>e&&c(t.default)),T.definitions[h.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[g]);let _=e.response,v=h?`${h.url}${ri(h.query)}`:``;return t(`div`,{class:`step-exchange`,children:[h&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${h.method}`,children:h.method}),t(`div`,{class:`rq-url`,title:v,children:t(`code`,{children:v})}),_&&t(`span`,{class:`result-chip ${nt(_.status)}`,children:[_.status,` `,tt(_.status),` · `,_.durationMs,` ms`]})]}),r&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this step`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}})]},e.name),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,n])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>o(e),children:[n,e===`response`&&_&&t(`span`,{class:`state-dot ${nt(_.status)}`,children:_.status})]}))}),t(`div`,{class:`rq-pane`,children:[t(`div`,{class:`tab-pane`,hidden:i!==`request`,children:h?t($r,{request:h,encoding:p,sent:t(ai,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}):t(ai,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}),t(`div`,{class:`tab-pane`,hidden:i!==`response`,children:t(mi,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var ea=e=>e.replace(/ #\d+$/,``),ta={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``};function na({info:e,preset:r,autoRun:i}){let{seq:c}=e,l=o(()=>Object.fromEntries(Object.entries(c.meta.inputs??{}).map(([e,t])=>[e,Vi(t)])),[c]),u=Ni(e),d=o(()=>{let e=new Set;for(let t of c.nodes)if(t.kind===`step`&&typeof t.def!=`function`)e.add(t.def.op.service);else if(t.kind===`step`||t.kind===`each`)return;return[...e]},[c]),[f,p]=a({}),[m,h]=a(),[g,_]=a({}),[v,y]=a(!1),[b,x]=a(),[S,C]=a({}),[w,T]=a(0),[E,D]=a(!1),[O,M]=a(),N=Object.values(l).some(e=>e.generate),ee=Object.keys(l).length>0||c.nodes.some(e=>e.kind===`input`);n(()=>(k.value=N,()=>{k.value=!1}),[N]);let te=async()=>(N&&await P.fakerReady(A.value,ne.value,j.value).catch(()=>{}),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Wi(t)])));n(()=>{let e=!0,t=e=>({...e,...r??{}});return p(t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Wi(t)])))),N?te().then(n=>{e&&(p(t(n)),i&&R({inputs:t(n),headless:!0}))}):i&&R({inputs:t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Wi(t)]))),headless:!0}),h(void 0),_({}),x(void 0),()=>{e=!1}},[e.file]);let ie=c.nodes.map(e=>e.name),ae=m?m.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):ie.map(e=>({name:e})),I=ae[w]?.step,oe=s(void 0),[L,se]=a(!1),ce=()=>{se(!0),oe.current?.abort(),b?.resolve(S)},R=async(e={})=>{let t=new AbortController;oe.current=t,se(!1),y(!0),h(void 0),M(void 0),_({}),T(0),D(!1);try{let n=await P.run(c,{env:F.value,version:A.value,inputs:e.inputs??f,locale:ne.value,seed:j.value,signal:t.signal,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:e.headless?void 0:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),C(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Wi(t)]))),x({name:e,controls:r,resolve:e=>{x(void 0),n(e)}})})});h(n),bt.value=xt(n);let r=n.steps.filter(e=>e.kind!==`auth`).findIndex(e=>e.status===`fail`||e.status===`error`);r>=0&&T(r)}catch(e){M(e instanceof Error?e.message:String(e))}finally{oe.current=void 0,y(!1),x(void 0)}},le=m?.status;return t(`div`,{class:`sequence-panel ${E&&I?`sheet-open`:``}`,"data-seq":c.meta.id,children:[t(`div`,{class:`seq-left`,children:[t(ki,{services:d}),t(Qi,{title:`Inputs`,specs:l,values:f,onChange:p}),t(`div`,{class:`seq-run`,children:[t(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:()=>R(),children:v?`Running…`:`▶ Run`}),v&&t(`button`,{type:`button`,class:`btn`,onClick:ce,children:`Stop`}),ee&&t(`button`,{type:`button`,class:`btn`,disabled:v,title:`Skip every question and use each input's default, as specbook test does`,onClick:async()=>{let e=await te();p(e),await R({inputs:e,headless:!0})},children:`Run with defaults`}),t(re,{}),m&&t(`span`,{class:`badge ${le}`,children:[ta[le],` `,le===`pass`?`Passed`:L?`Stopped`:le===`fail`?`Failed`:`Error`,` `,`· `,m.totals.passed,`/`,m.totals.steps,` steps · `,m.durationMs,`ms`]})]}),O&&t(`p`,{class:`error-text`,children:O}),t(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:ae.map((e,n)=>{let r=e.step,i=r?.status??g[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return t(`li`,{class:`jstep ${i} ${w===n?`picked`:``}`,children:[t(`div`,{class:`jmark`,children:ta[i]||n+1}),t(`div`,{class:`jbody`,children:[t(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let t=e.currentTarget;T(n),D(!0),requestAnimationFrame(()=>t.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[t(`span`,{class:`jname`,children:e.name}),r?.response&&t(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&t(`span`,{class:a.length?`error-text`:`muted`,children:[r.assertions.length-a.length,`/`,r.assertions.length,` checks`]})]}),r?.uses?.filter(e=>e.source===`capture`).map(e=>t(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,t(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,n])=>t(`span`,{class:`cap make`,title:ei(n),children:[`→ `,e,` `,t(`b`,{children:ti(n)})]})),r?.error&&t(`div`,{class:`error-text`,children:r.error}),a.map(e=>t(ui,{a:e})),i===`skipped`&&t(`div`,{class:`muted`,children:L?`Skipped: you stopped the run.`:`Skipped: an earlier step did not pass.`}),b&&g[e.name]===`paused`&&t(`div`,{class:`pause`,children:[t(`strong`,{children:[`Your turn: `,b.name]}),t(Qi,{title:`Choose`,specs:b.controls,values:S,onChange:C}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>b.resolve(S),children:`Continue ▶`})]})]})]})})})]}),t(`div`,{class:`seq-right ${E&&I?`sheet-open`:``}`,children:[I&&t(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>D(!1),children:[t(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,I.name]}),!I&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing run yet`}),t(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),I&&t($i,{step:I,note:u.notes.get(ea(I.name))})]})]})}function ra(e){let n=e.tab??`try`,r=t(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,class:`rq-tab ${n===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?t(Tt,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(qi,{info:e.info}):t(na,{info:e.info,preset:e.preset,autoRun:e.autoRun})})]})}):t(Tt,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(yt,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):t(Bi,{service:e.service,op:e.op,variants:e.variants,initial:e.example,autoRun:e.autoRun},`${e.service}/${e.op.id}${e.example.startsWith(`saved:`)?`@${e.example}`:``}`)})]})})}export{ra as Host};
@@ -1 +1 @@
1
- import{a as e,d as t,h as n,i as r,o as i,p as a,s as o,t as s,v as c,y as l}from"./panel-nV09I7Wr.js";import{a as u,r as d,t as f}from"./mount-CLHBtIzR.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:t,progress:n}){return e(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[e(`header`,{class:`header`,children:[e(`span`,{class:`sk-brand`,children:[e(`img`,{src:i,alt:``,width:`24`,height:`24`}),`Specbook`]}),e(`span`,{class:`sk-search`,"aria-hidden":`true`}),e(`span`,{class:`spacer`}),m.map(t=>e(`span`,{class:`sk-pill`,style:{width:`${t}px`},"aria-hidden":`true`})),e(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),e(`div`,{class:`layout`,"data-view":`splash`,children:[e(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[e(`span`,{class:`sk-filter`}),p.map(t=>e(`span`,{class:`sk-row`,style:{width:`${t}%`}}))]}),e(`main`,{class:`stage`,children:[e(`p`,{class:`sk-status`,children:n??`Opening…`}),e(`p`,{class:`sk-what`,title:t,children:t})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];o();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${r(e)}`;function M({initial:r}){let[i,o]=n(r),[c,u]=n(k.get(`spec`)??``),[p,m]=n(``),[g,_]=n(!1),b=a(void 0),x=async(e,t,n)=>{b.current??=new d,o({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>o({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?o({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;o({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=s(e.trim());if(t){if(!/^https?:\/\//i.test(t))return o({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};t(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):o({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?e(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):e(`main`,{class:`vw`,children:e(`div`,{class:`vw-card`,children:[e(`h1`,{children:`Specbook`}),e(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),e(`form`,{onSubmit:e=>{e.preventDefault(),S(c)},children:[e(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:c,onInput:e=>u(e.target.value),disabled:w}),e(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&e(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&e(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&e(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&e(N,{onApply:i.apply,title:i.open.title}),e(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,e(`label`,{class:`link`,children:[`choose one`,e(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),e(`details`,{children:[e(`summary`,{children:`Paste the document`}),e(`p`,{}),e(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),e(`p`,{}),e(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),e(`section`,{children:[e(`p`,{children:`Try one`}),e(`ul`,{children:D.map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,onClick:()=>S(t.url),children:t.label})}))})]}),v().length>0&&e(`section`,{children:[e(`p`,{children:`Recent`}),e(`ul`,{children:v().map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,title:t,onClick:()=>S(t),children:t})}))})]})]})})}function N({onApply:t,title:r}){let[i,a]=n(``);return e(`form`,{class:`vw-base`,onSubmit:e=>{e.preventDefault(),/^https?:\/\//i.test(i.trim())&&t(i.trim().replace(/\/$/,``))},children:[e(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),e(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${r}`,value:i,onInput:e=>a(e.target.value)}),e(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),e(`button`,{type:`button`,class:`link`,onClick:()=>t(void 0),children:`Continue with mock data`})]})}u().then(t=>{t||c(e(M,{initial:{kind:`idle`}}),O)});
1
+ import{a as e,d as t,h as n,i as r,o as i,p as a,s as o,t as s,v as c,y as l}from"./panel-nV09I7Wr.js";import{a as u,r as d,t as f}from"./mount-D3holu10.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:t,progress:n}){return e(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[e(`header`,{class:`header`,children:[e(`span`,{class:`sk-brand`,children:[e(`img`,{src:i,alt:``,width:`24`,height:`24`}),`Specbook`]}),e(`span`,{class:`sk-search`,"aria-hidden":`true`}),e(`span`,{class:`spacer`}),m.map(t=>e(`span`,{class:`sk-pill`,style:{width:`${t}px`},"aria-hidden":`true`})),e(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),e(`div`,{class:`layout`,"data-view":`splash`,children:[e(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[e(`span`,{class:`sk-filter`}),p.map(t=>e(`span`,{class:`sk-row`,style:{width:`${t}%`}}))]}),e(`main`,{class:`stage`,children:[e(`p`,{class:`sk-status`,children:n??`Opening…`}),e(`p`,{class:`sk-what`,title:t,children:t})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];o();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${r(e)}`;function M({initial:r}){let[i,o]=n(r),[c,u]=n(k.get(`spec`)??``),[p,m]=n(``),[g,_]=n(!1),b=a(void 0),x=async(e,t,n)=>{b.current??=new d,o({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>o({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?o({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;o({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=s(e.trim());if(t){if(!/^https?:\/\//i.test(t))return o({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};t(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):o({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?e(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):e(`main`,{class:`vw`,children:e(`div`,{class:`vw-card`,children:[e(`h1`,{children:`Specbook`}),e(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),e(`form`,{onSubmit:e=>{e.preventDefault(),S(c)},children:[e(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:c,onInput:e=>u(e.target.value),disabled:w}),e(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&e(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&e(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&e(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&e(N,{onApply:i.apply,title:i.open.title}),e(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,e(`label`,{class:`link`,children:[`choose one`,e(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),e(`details`,{children:[e(`summary`,{children:`Paste the document`}),e(`p`,{}),e(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),e(`p`,{}),e(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),e(`section`,{children:[e(`p`,{children:`Try one`}),e(`ul`,{children:D.map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,onClick:()=>S(t.url),children:t.label})}))})]}),v().length>0&&e(`section`,{children:[e(`p`,{children:`Recent`}),e(`ul`,{children:v().map(t=>e(`li`,{children:e(`button`,{type:`button`,class:`link`,title:t,onClick:()=>S(t),children:t})}))})]})]})})}function N({onApply:t,title:r}){let[i,a]=n(``);return e(`form`,{class:`vw-base`,onSubmit:e=>{e.preventDefault(),/^https?:\/\//i.test(i.trim())&&t(i.trim().replace(/\/$/,``))},children:[e(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),e(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${r}`,value:i,onInput:e=>a(e.target.value)}),e(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),e(`button`,{type:`button`,class:`link`,onClick:()=>t(void 0),children:`Continue with mock data`})]})}u().then(t=>{t||c(e(M,{initial:{kind:`idle`}}),O)});