@specbook/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist-viewer/apple-touch-icon.png +0 -0
- package/dist-viewer/assets/Host-DdTTHeXU.js +37 -0
- package/dist-viewer/assets/faker-B3c03STC.js +11 -0
- package/dist-viewer/assets/index-DnYdlDXQ.js +1 -0
- package/dist-viewer/assets/index-Ds6DZpGP.css +1 -0
- package/dist-viewer/assets/main-uV4JzQPd.js +14 -0
- package/dist-viewer/assets/mount-B-qFOcWp.js +2 -0
- package/dist-viewer/assets/panel-CoQ6iQpX.js +1 -0
- package/dist-viewer/assets/panel-Coi9H1nv.css +1 -0
- package/dist-viewer/assets/registry-DI74Wtj8.js +2 -0
- package/dist-viewer/assets/worker-Dw3Ps3hk.js +181 -0
- package/dist-viewer/favicon.svg +1 -0
- package/dist-viewer/index.html +19 -0
- package/dist-viewer/specbook.js +1 -0
- package/index.html +12 -0
- package/package.json +60 -3
- package/src/app.tsx +363 -0
- package/src/assets/mark.svg +1 -0
- package/src/badge.ts +14 -0
- package/src/branding.ts +92 -0
- package/src/components/Catalog.tsx +324 -0
- package/src/components/EnvBadge.tsx +46 -0
- package/src/components/EnvironmentMenu.tsx +262 -0
- package/src/components/Fields.tsx +220 -0
- package/src/components/GitHubStar.tsx +22 -0
- package/src/components/ListResizer.tsx +70 -0
- package/src/components/ModeHint.tsx +17 -0
- package/src/components/Palette.tsx +85 -0
- package/src/components/PoweredBy.tsx +15 -0
- package/src/components/ShareMenu.tsx +94 -0
- package/src/components/ThemeToggle.tsx +52 -0
- package/src/embed/panel.tsx +114 -0
- package/src/embed/styles.ts +27 -0
- package/src/embed.ts +65 -0
- package/src/engine.ts +432 -0
- package/src/extension.ts +101 -0
- package/src/fielddoc.ts +83 -0
- package/src/main.tsx +16 -0
- package/src/markdown.ts +133 -0
- package/src/nav.ts +118 -0
- package/src/panel/Body.tsx +182 -0
- package/src/panel/BodyEditor.tsx +92 -0
- package/src/panel/CodeSample.tsx +237 -0
- package/src/panel/Combo.tsx +124 -0
- package/src/panel/ControlsGrid.tsx +189 -0
- package/src/panel/FieldDoc.tsx +42 -0
- package/src/panel/FieldTable.tsx +113 -0
- package/src/panel/Host.tsx +100 -0
- package/src/panel/OperationDocs.tsx +181 -0
- package/src/panel/Panel.tsx +193 -0
- package/src/panel/ParamGrid.tsx +396 -0
- package/src/panel/RequestPanel.tsx +625 -0
- package/src/panel/RequestView.tsx +108 -0
- package/src/panel/ResponseView.tsx +182 -0
- package/src/panel/SecretsBar.tsx +156 -0
- package/src/panel/SequenceDocs.tsx +132 -0
- package/src/panel/SequencePanel.tsx +247 -0
- package/src/panel/StepExchange.tsx +118 -0
- package/src/panel/completions.ts +114 -0
- package/src/panel/draft.ts +106 -0
- package/src/panel/fieldnotes-split.ts +55 -0
- package/src/panel/fieldnotes.ts +40 -0
- package/src/panel/graphql.ts +31 -0
- package/src/panel/icons.tsx +85 -0
- package/src/panel/jsonCursor.ts +115 -0
- package/src/panel/stepnotes-split.ts +38 -0
- package/src/panel/stepnotes.ts +58 -0
- package/src/routing.ts +120 -0
- package/src/runtime.ts +32 -0
- package/src/schema.ts +359 -0
- package/src/secrets.ts +61 -0
- package/src/status.ts +27 -0
- package/src/store.ts +10 -0
- package/src/styles/app.css +821 -0
- package/src/styles/panel.css +1897 -0
- package/src/styles/tokens.css +122 -0
- package/src/theme.ts +37 -0
- package/src/viewer/Opening.tsx +43 -0
- package/src/viewer/bundles.ts +74 -0
- package/src/viewer/client.ts +54 -0
- package/src/viewer/embed.ts +78 -0
- package/src/viewer/faker-en.ts +3 -0
- package/src/viewer/main.tsx +285 -0
- package/src/viewer/mount.ts +52 -0
- package/src/viewer/protocol.ts +51 -0
- package/src/viewer/recent.ts +22 -0
- package/src/viewer/registry-data.ts +4 -0
- package/src/viewer/registry.ts +154 -0
- package/src/viewer/share.ts +134 -0
- package/src/viewer/site.ts +3 -0
- package/src/viewer/uploads.ts +53 -0
- package/src/viewer/viewer.css +184 -0
- package/src/viewer/worker-factory.ts +14 -0
- package/src/viewer/worker.ts +171 -0
- package/src/virtual.d.ts +104 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ajai Shankar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @specbook/ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Specbook docs app, spec viewer and embeddable specbook.js.
|
|
4
|
+
|
|
5
|
+
Part of [Specbook](https://github.com/specbook-dev/specbook), Storybook for APIs. See the repository for documentation.
|
|
6
|
+
|
|
7
|
+
MIT licensed.
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{c as e,r as t}from"./registry-DI74Wtj8.js";import{_ as n,a as r,d as i,f as a,h as o,m as s,p as c,u as l}from"./panel-CoQ6iQpX.js";import{_ as u,a as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,u as T,v as E,y as D}from"./main-uV4JzQPd.js";var O=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function k(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:O(t),enabled:!0})))}function A(e){let t={};for(let{key:n,value:r,enabled:i}of e){if(!i||n===``)continue;let e=t[n];t[n]=e===void 0?r:[...Array.isArray(e)?e:[e],r]}return t}function j(e){return typeof e!=`object`||!e?[]:p(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var M=/[^[\]]+|\[\]/g;function N(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?N(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?N(o,i,n):o===void 0?n:[...[].concat(o),n],a}function P(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=N(t,n.match(M)??[n],a&&m(a)?a:r));return t}var F=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,I=e=>new RegExp(F.source).test(e),L=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function R(e){let t=[],n=0;for(let r of e.matchAll(F))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?L(r[1]):`SESSION_${L(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var ee=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${te(e)}`);return t.length?`?${t.join(`&`)}`:``};function te(e){return R(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function z(e){if(m(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var ne=e=>e.name??e.file??`file`,re=e=>`'${e.replace(/'/g,`'\\''`)}'`;function B(e){return I(e)?`"${R(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:re(e)}function ie(e){let t=e.encoding??`json`,n=[B(`${e.url}${ee(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${B(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of p(o,e.formArrays))s.push(`--data-urlencode ${B(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(z(n)?s.push(`-F ${B(`${e}=@${ne(n)}`)}`):s.push(`-F ${B(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${B(`@${z(o)?ne(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=z(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${B(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${B(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
|
|
2
|
+
`)}`}var ae=/^[A-Za-z_$][\w$]*$/;function V(e){return I(e)?`\`${R(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var oe=e=>ae.test(e)?e:V(e);function se(e,t){if(e==null)return`null`;if(typeof e==`string`)return V(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${se(e,n)},`).join(`
|
|
3
|
+
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${oe(e)}: ${se(t,n)},`).join(`
|
|
4
|
+
`)}\n${t}}`}function ce(e){let t=e.encoding??`json`,n=e.method.toUpperCase(),r={...e.headers??{}},i=e=>Object.keys(r).some(t=>t.toLowerCase()===e),a=e.body,o=a!==void 0&&a!==``&&t!==`none`,s=[],c,l=!1;if(o){if(t===`json`||t===`graphql`)c=`JSON.stringify(${se(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=p(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${se(Object.fromEntries(t),` `)})`:`new URLSearchParams(${se(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(z(n)){l=!0;let t=ne(n);s.push(`form.append(${V(e)}, await openAsBlob(${V(t)}), ${V(t)})`)}else s.push(`form.append(${V(e)}, ${V(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${V(z(a)?ne(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=z(a)&&a.type?a.type:`application/octet-stream`)):(c=V(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${ee(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${V(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${oe(e)}: ${V(t)},`).join(`
|
|
5
|
+
`)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],m=d.length===0?`const res = await fetch(${V(u)})`:`const res = await fetch(${V(u)}, {\n${d.join(`
|
|
6
|
+
`)}\n})`;return[...f,...s,m,`console.log(res.status, await res.text())`].join(`
|
|
7
|
+
`)}function le(e,t){return e===`curl`?ie(t):ce(t)}var ue=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],de=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function H(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function fe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
8
|
+
`).split(`
|
|
9
|
+
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${H(de(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${H(de(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${de(r.join(`
|
|
10
|
+
`))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${H(de(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${H(de(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function pe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function me(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function he(e){return e?H(de(e)):``}function U(e,t=300){let n=me(e);if(!n)return``;let r=pe(n);return r.length>t?de(`${r.slice(0,t-1).trimEnd()}…`):he(n)}var ge=/^\s*\{\{[^}]+\}\}\s*$/,_e=e=>typeof e==`string`&&ge.test(e);function ve(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var ye=[`title`,`description`,`default`,`examples`,`deprecated`];function W(e,t){let n={...e};for(let e of ye)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function be(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=W(r,n)}return n}function G(e,t,n=0){let r=be(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!ve(e));if(e.length===1||e.length>1)return G(W(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return G(W(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=G(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of ye)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function K(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function xe(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function Se(e,t=120){if(!e)return;let n=e.split(/\n+/)[0],r=(n.match(/^.*?[.!?](\s|$)/)?.[0]?.trim()??n).replace(/\s+/g,` `);return r.length>t?`${r.slice(0,t-1)}…`:r}function Ce(e,t){let n=G(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function we(e,t,n){let r=G(e,n);if(typeof t==`number`)return r.items;if(r.properties?.[t])return r.properties[t];if(r.additionalProperties&&typeof r.additionalProperties==`object`)return r.additionalProperties}var q=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Te(e,t,n){let r=be(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!ve(e));if(!i?.length)return G(r,n);let a=q(t);return G(W(i.find(e=>{let t=K(G(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Ee(e,t,n,r={},i=``,a=0){if(!t||a>12||_e(e))return[];let o=Te(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&K(o)!==`null`&&K(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${K(o)}, got null`}),s;let u=K(o),d=q(e);switch(u){case`object`:{if(d!==`object`)return[{path:c,kind:`type`,message:`expected object, got ${d}`}];let t=e,l=o.properties??{};for(let e of o.required??[])e in t||s.push({path:i?`${i}.${e}`:e,kind:`required`,message:`required field is missing`});for(let[e,c]of Object.entries(t)){let t=i?`${i}.${e}`:e;l[e]?s.push(...Ee(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ee(c,o.additionalProperties,n,r,t,a+1)):r.reportExtra&&o.additionalProperties!==!0&&Object.keys(l).length>0&&s.push({path:t,kind:`extra`,message:`not in the spec`})}return s}case`array`:return d===`array`?(e.forEach((e,t)=>{s.push(...Ee(e,o.items,n,r,`${i}[${t}]`,a+1))}),s):[{path:c,kind:`type`,message:`expected array, got ${d}`}];case`string`:return d===`string`?(o.enum&&!o.enum.includes(e)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s):[{path:c,kind:`type`,message:`expected string, got ${d}`}];case`integer`:case`number`:{if(d!==`number`)return[{path:c,kind:`type`,message:`expected ${u}, got ${d}`}];let t=e;return u===`integer`&&!Number.isInteger(t)&&s.push({path:c,kind:`type`,message:`expected an integer`}),o.minimum!==void 0&&t<o.minimum&&s.push({path:c,kind:`range`,message:`must be ≥ ${o.minimum}`}),o.maximum!==void 0&&t>o.maximum&&s.push({path:c,kind:`range`,message:`must be ≤ ${o.maximum}`}),o.enum&&!o.enum.includes(t)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s}case`boolean`:return d===`boolean`?[]:[{path:c,kind:`type`,message:`expected boolean, got ${d}`}];default:return[]}}var De=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Oe(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
|
|
11
|
+
`)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
|
|
12
|
+
`;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function J(e,t,n){let r=e;for(let e of t){if(!r)return;r=we(r,e,n)}return r}var ke={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,301:`Moved`,304:`Not modified`,400:`Bad request`,401:`Unauthorized`,402:`Payment required`,403:`Forbidden`,404:`Not found`,405:`Invalid input`,409:`Conflict`,410:`Gone`,412:`Precondition failed`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`},Ae=e=>ke[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),je=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,Me=new Set([`path`,`query`,`headers`,`data`]),Ne=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function Pe(e,t){return[e,...Ne(t)].join(`.`)}function Fe(e){let t=Ne(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&Me.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var Ie=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function Le(e){let t=new Map;if(!e)return{intro:e,notes:t};let n=[];for(let r of e.split(/(?=<h[1-6][ >])/)){let e=/^<h([1-6])[^>]*>\s*<code>([^<]+)<\/code>\s*<\/h\1>/.exec(r),i=e?Fe(Ie(e[2])):void 0;if(e&&i){let n=t.get(i),a=r.slice(e[0].length);t.set(i,n?n+a:a)}else n.push(r)}return{intro:n.join(``),notes:t}}var Re=60;function ze(e,t){let n=K(e);return n===`array`?`${K(G(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function Be(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Ce(e,t)){let e=G(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:ze(e,t),required:a.required,description:xe(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=K(e)===`array`?G(e.items,t):e;K(s)===`object`&&i.push(...Be(s,t,n+1,o))}return i}function Ve({schema:e,defs:t,section:n=`data`,notes:i}){let a=Be(e,t);return a.length===0?null:r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`Field`}),r(`th`,{children:`Type`}),r(`th`,{children:`Description`})]})}),r(`tbody`,{children:[a.slice(0,Re).map(e=>r(`tr`,{children:[r(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[r(`code`,{children:e.name.split(`.`).pop()}),e.required&&r(`span`,{class:`req`,title:`required`,children:`*`})]}),r(`td`,{children:r(`span`,{class:`chip`,children:e.type})}),r(`td`,{children:[r(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:U(e.description,220)}}),i?.get(Pe(n,e.name))&&r(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(Pe(n,e.name))}}),e.enum&&r(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>r(`code`,{children:e}))]})]})]})),a.length>Re&&r(`tr`,{children:r(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-Re,` more fields in the spec`]})})]})]})}var He={intro:``,notes:new Map,replace:!1,found:!1};function Ue(e){let[t,n]=s(),[r,a]=s(!1),o=d.docs.find(t=>t.operation===e);return i(()=>{let e=!0;return n(void 0),a(!o),o?.load().then(t=>e&&n(t)).catch(()=>{}).finally(()=>e&&a(!0)),()=>{e=!1}},[e,o]),c(()=>!o||t===void 0?{...He,loaded:r}:{...Le(t),replace:!!o.replace,found:!0,loaded:r},[t,o,r])}var We=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],Ge=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function Ke(e,t,n){return Promise.all([Ge(d.operationDocs[e]?.().then(e=>e.default)),Ge(d.schemas[e]?.().then(e=>e.default)),Ge(d.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>Ge(d.docs.find(t=>t.requestFile===e)?.load())))]).then(([e,t,r,i])=>({long:e,req:t,defs:r,saved:Object.fromEntries(n.flatMap((e,t)=>i[t]?[[e,i[t]]]:[]))}))}function qe({variant:e,html:t}){return t?r(`section`,{class:`saved-note-doc`,children:[r(`h2`,{children:[`Saved request `,r(`code`,{children:e.name})]}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]}):null}function Je({service:e,op:t,variants:a=[],onTry:o}){let c=`${e}/${t.id}`,[l,u]=s(),d=a.map(e=>e.file).join(`
|
|
13
|
+
`);i(()=>{let t=!0;return u(void 0),Ke(c,e,d?d.split(`
|
|
14
|
+
`):[]).then(e=>t&&u(e)),()=>{t=!1}},[c,e,d]);let f=Ue(c),p=!!l&&f.loaded,{long:m,req:h,defs:g}=l??{saved:{}},_=h?G(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return r(`article`,{class:`doc`,"data-op":c,children:[r(`div`,{class:`doc-intro`,children:[r(`span`,{class:`method ${t.method}`,children:t.method}),` `,r(`code`,{children:t.path}),r(`span`,{class:`spacer`}),r(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&r(n,{children:[!(f.found&&f.replace)&&m?.description&&r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:fe(m.description)}}),f.intro&&r(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),a.map(e=>r(qe,{variant:e,html:l?.saved[e.file]},e.file)),We.map(([e,t])=>v(e)?r(`section`,{children:[r(`h2`,{children:[t,` parameters`]}),r(Ve,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&r(`section`,{children:[r(`h2`,{children:`Request body`}),r(Ve,{schema:y,defs:g,section:`data`,notes:f.notes})]}),t.statuses.length>0&&r(`section`,{children:[r(`h2`,{children:`Responses`}),r(`ul`,{class:`statuses`,children:t.statuses.map(e=>r(`li`,{children:[r(`span`,{class:`state-badge ${je(e)}`,children:e}),` `,Ae(e)]}))})]}),(m?.examples.length??0)>1&&r(`section`,{children:[r(`h2`,{children:`Examples`}),r(`ul`,{class:`examples`,children:m?.examples.map(e=>r(`li`,{children:r(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var Ye=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function Xe({title:e,subtitle:t,flush:o,modal:s=!0,onPrev:c,onNext:l,onClose:u,children:d}){let f=a(null);return i(()=>{let e=f.current?.getRootNode()?.activeElement;return s&&f.current?.focus(),()=>e?.focus?.()},[s]),i(()=>{let e=f.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=r+i*.2;(o>r+i*.4||o<r)&&(t.scrollTop+=o-s)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s);c&&r?.box!==c&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),i(()=>{let e=e=>{if(e.key===`Escape`&&u(),e.key!==`Tab`||!s||!f.current)return;let t=[...f.current.querySelectorAll(Ye)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=f.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===f.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[u,s]),r(n,{children:[s&&r(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:u}),r(`section`,{class:`panel ${s?``:`docked`}`,part:`panel`,"aria-label":e,"aria-modal":s?!0:void 0,role:s?`dialog`:`complementary`,tabIndex:-1,ref:f,children:[r(`header`,{class:`panel-head`,part:`header`,children:[r(`div`,{class:`panel-title`,children:[r(`h2`,{children:e}),t&&r(`div`,{class:`muted small`,children:t})]}),r(`span`,{class:`spacer`}),s&&y.value.length>1&&r(`label`,{class:`row`,children:[r(`span`,{class:`muted`,children:`Environment`}),r(`select`,{value:S.value,onChange:e=>S.value=e.target.value,children:y.value.map(e=>r(`option`,{value:e,children:e}))})]}),(c||l)&&r(`span`,{class:`stepper`,children:[r(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!c,onClick:c,children:`↑`}),r(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!l,onClick:l,children:`↓`})]}),r(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:u,children:`×`})]}),r(`div`,{class:`panel-body ${o?`flush`:``}`,children:d})]})]})}function Ze(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:J(e,i,t);if(!a)return;let o=G(a,t);if(n.length===0){let e=typeof o.description==`string`?o.description.trim():``;return e?{path:typeof o.title==`string`&&o.title.trim()?o.title.trim():`body`,type:K(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=J(e,i.slice(0,-1),t),l=K(o),u=l===`array`?K(G(o.items,t)):void 0;return{path:De(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Ce(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:xe(o),parent:c?xe(G(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Qe(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function $e(e,t,n,r){let i=e&&t?.get(Pe(n,r));return e&&i?{...e,note:i}:e}var et={},tt=Symbol(),nt=Symbol(),rt=e=>typeof e==`string`?it[e]:e,it={plain:et,plaintext:et,text:et,txt:et},at=(e,t)=>(t[nt]||ot)(e,t),ot=(e,t)=>{for(var n=[e],r,i=[],a=0;r=rt(t[tt]);)delete t[tt],Object.assign(t,r);for(pt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},st=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),ct=`</span>`,lt=``,ut=``,dt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=ft(n);return t},ft=e=>{if(e instanceof mt){var{type:t,alias:n,content:r}=e,i=lt,a=ut,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;ut+=ct,lt+=o;var s=ft(r);return lt=i,ut=a,o+s+ct}return typeof e==`string`?(e=st(e,/</g,`<`),ut&&e.includes(`
|
|
15
|
+
`)?e.replace(/\n/g,ut+`
|
|
16
|
+
`+lt):e):dt(e)},pt=(e,t,n,r,i)=>{for(var a in t)if(t[a])for(var o=0,s=t[a],c,l=Array.isArray(s)?s:[s];c=l[o];o++){if(i&&i[0]==a&&i[1]==o)return;for(var u=c.pattern||c,d=rt(c.inside),f=c.lookbehind,p=u.global,m=c.alias,h=n,g=r;h&&(!i||g<i[2]);g+=h[0].length,h=h[1]){var _=h[0],v=0,y;if(!(_ instanceof mt)){if(u.lastIndex=p?g:0,y=u.exec(p?e:_),!y&&p)break;if(y&&y[0]){var b=f&&y[1]?y[1].length:0,x=y.index+b,S=y[0].slice(b),C=x+S.length,w,s;if(p){for(;s=g+h[0].length,x>=s;h=h[1],g=s);if(h[0]instanceof mt)continue;for(w=h,s=g;(s+=w[0].length)<C;w=w[1],v++);_=e.slice(g,s),x-=g,C-=g}for(var T=_.slice(C),E=g+_.length,D=new mt(a,d?at(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof mt?O=[T,O]:O[0]=T+O[0]),g+=x,h[0]=x?_.slice(0,x):D,x?h=h[1]=[D,O]:h[1]=O,v&&(pt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function mt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var ht=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=St(),m=p.firstChild,h=m.children,g=h[0],_=g.firstChild,v={language:`text`,value:o},y=new Set(n),b={},x=e=>{Object.assign(v,e);let t=o!=(o=e.value??o),n=r!=(r=v.language);d=!!v.readOnly,p.style.tabSize=v.tabSize||2,_.inputMode=d?`none`:``,_.setAttribute(`aria-readonly`,d),w(),C(),t&&(c||_.remove(),_.value=o,_.selectionEnd=0,c||g.prepend(_)),(t||n)&&S()},S=()=>{u=at(o=_.value,it[r]||{}),O(`tokenize`,u,r,o);let e=dt(u).split(`
|
|
17
|
+
`),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
|
|
18
|
+
`;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=bt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},A={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Ct=null,c=!1,w()}),Y(_,`focus`,()=>{Ct=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),yt(e)?.append(p),t&&x(t),A},gt=`u`>typeof window?document:null,_t=gt?.createElement(`div`),vt=(e,t)=>(_t&&(_t.innerHTML=e,t=_t.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),yt=e=>typeof e==`string`?gt.querySelector(e):e,bt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
19
|
+
`,t)+1)&&t<=n;r++);return r},xt={},St=vt(`<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>`),X=e=>{e.preventDefault(),e.stopImmediatePropagation()},Ct;gt&&Y(gt,`selectionchange`,()=>Ct?.());var wt=(e,t,n=0)=>{let r=e.container.style;r.setProperty(`--_sp`,`var(--pce-scroll-padding, 2ch)`),r.scrollPaddingBlock=`calc(var(--_sp) + ${n}px) calc(var(--_sp) + ${Bt&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},Tt=(e,t)=>t?e.lastIndexOf(`
|
|
20
|
+
`,t-1)+1:0,Et=(e,t)=>(t=e.indexOf(`
|
|
21
|
+
`,t))+1?t:e.length,Dt=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),Ot=(e,t,n,r)=>Dt(e.textarea,t,n,r),kt=(e,t)=>parseFloat(getComputedStyle(e)[t]),At=(e,t)=>{let n=t.getBoundingClientRect(),r=e.lines[0].getBoundingClientRect();return{top:n.y-r.y,bottom:r.bottom-n.bottom,left:n.x-r.x,right:r.right-n.right,height:n.height}},jt=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var Mt,Nt=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),Pt=(e,t)=>e.slice(Tt(e,t),t),Ft=(e,t,n=t)=>[e.slice(t=Tt(e,t),n=Et(e,n)).split(`
|
|
22
|
+
`),t,n],It=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[bt(a,0,i)],s=gt.createTreeWalker(o,5),c=s.lastChild(),l=Et(a,i)+1-i-c.length;for(;-l<=r&&(c=s.previousNode());)if(!c.lastChild&&(l-=c.length||0,l<=n)){for(;c!=o;c=c.parentNode)if(c.matches?.(t))return c}},Lt=(e,t)=>It(e,`[class*=language-]`,0,0,t)?.className.match(/language-(\S*)/)[1]||e.options.language,Z=(e,t,n,r,i,a)=>{if(e.options.readOnly)return;Mt=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=Bt&&!s[r??Mt[1]]&&/\n$/.test(t)&&/^$|\n$/.test(s),l;e.focused||o.focus(),n!=null&&o.setSelectionRange(n,r),i!=null&&(l=e.on(`update`,()=>{o.setSelectionRange(i,a??i,Mt[2]),l()})),Vt||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),Bt||Vt?(c&&(o.selectionEnd--,t=t.slice(0,-1)),Vt&&(t+=`
|
|
23
|
+
`),gt.execCommand(t?`insertHTML`:`delete`,!1,st(t,/</g,`<`)),c&&o.selectionStart++):gt.execCommand(t?`insertText`:`delete`,!1,t),Mt=0},Rt=(e,t,n=t,r)=>{let i=e.textarea,a=Dt(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},zt=gt?navigator.userAgent:``,Q=gt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,Bt=/Chrome\//.test(zt),Vt=!Bt&&/AppleWebKit\//.test(zt),Ht=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,Ut=(e,t)=>e.lines[0].append(t),Wt=vt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),Gt=vt(`<span> `),Kt=vt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),qt=(e,t,n=!0)=>{let r=Kt(),i=r.style,a=r.firstChild;return r.append(t),(n?t:a).style.flexShrink=0,[t=>{let n=e.extensions.cursor?.getPosition();if(n){r.parentNode||Ut(e,r),a.style.width=(e.options.rtl?n.right:n.left)+`px`;let o=n.top,s=n.bottom,c=!t==o>s&&(t?o:s)<r.clientHeight?!t:t,l=n.height+(c?s:o)+`px`;i.bottom=c?l:`auto`,i.top=c?`auto`:l}},()=>r.remove()]};window.ResizeObserver;var Jt=(e,t,n)=>{let r=e.childNodes,i=r.length-1,a=0,o=0,s=t.length;for(;o<s;)o>=i&&r[o].before(``,Gt()),jt(r[o],n.slice(a,a=t[o++])),jt(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();jt(r[s],n.slice(a))},Yt=0,Xt=vt(`<div class="pce-ac-wrapper pce-ac-top"><div class=pce-ac-tooltip><ul role=listbox></ul></div><div class=pce-ac-docs tabindex=-1><button class=pce-ac-close tabindex=-1 title=Close></button><button class=pce-ac-toggle tabindex=-1 title="Read More"></button><div class=pce-ac-content>`),Zt=vt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),Qt={},$t=(e,t)=>{e.forEach(e=>Qt[e]=t)},en=e=>{let t=(n,r)=>{let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=n.container,T=n.textarea,E=n.getSelection,D=Xt(),O=Wt(),[k,A]=qt(n,D),[j,M]=D.children,[N,P,F]=M.children,I=j.firstChild,L=I.id=`pce-ac-`+Yt++,R=I.children,ee=[],te=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},z=()=>{f=kt(R[0],`height`)},ne=e=>{let t=o[e+d],[n,r,i]=R[e].children,a=t[4],s=a.icon||`variable`;Jt(r,t[1],a.label),jt(i.firstChild.firstChild,a.detail||``),ee[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${ee[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),R[e].setAttribute(`aria-posinset`,e+d)},re=()=>{z();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,ae(),B()},B=()=>{let e=l;l=R[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),P.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(P),b=!b,pe()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},ie=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,re()},ae=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)ne(e++);I.style.paddingTop=d*f+`px`},V=e=>oe(o[e][4],o[e][2],o[e][3]),oe=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
|
|
24
|
+
`+Pt(n.value,u).match(/\s*/)[0],i=r.insertSpaces==0?` `:` `.repeat(r.tabSize||2),a=o.slice();s=s.replace(/\n| /g,(n,r)=>{let s=n==` `?i:e,l=s.length-1,u=0;for(;u<c;)a[u]>r+t&&(o[u]+=l),u++;return s})}else s=a;c%2&&(o[c]=o[c-1]),Z(n,s,t,i,o[0],o[1]),c>2?(p||Ut(n,O),p=o,m=0,g=n.value.length,ue(),h=E(),se()):n.extensions.cursor?.scrollIntoView()},se=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},ce=e=>{m+=e,Rt(n,p[m],p[m+1]),se()},le=()=>{O.remove(),p=null},ue=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),Jt(O,e.flat(),n.value)},de=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=kt(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},H=()=>{D.className=`pce-ac-wrapper pce-ac-${de()}`},fe=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,F.textContent=``,F.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,L+`d`))},pe=()=>{b?M.remove():fe(),b=!b},me=t.startQuery=t=>{let[a,l,p]=E(),m=Lt(n,u=p<`f`?a:l),h=Qt[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=Pt(r,u),p=r.slice(0,u),_=e.filter;if(x={before:p,lineBefore:a,language:m,explicit:!!t,pos:u},Object.assign(x,h.context?.(x,n)),o=[],h.sources.forEach(e=>{let t=e(x,n),r=t?.from;t?.options.forEach(e=>{let n=_(p.slice(e.from??r),e.label);n&&(n[0]+=e.boost||0,n.push(r,t.to??l,e),o.push(n))})}),o[0]){o.sort((e,t)=>t[0]-e[0]||e[4].label.localeCompare(t[4].label)),s=o.length,c=d=0;for(let e=0,t=s<13?s:13;e<t;)R[e].setAttribute(`aria-setsize`,s),ne(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}I.style.paddingTop=``,I.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,B(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,H(),T.setAttribute(`aria-controls`,L),T.setAttribute(`aria-haspopup`,`listbox`)}else te()}else te()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)I.append(Zt()),R[e].id=L+`-`+e++;Y(j,`scroll`,()=>{z(),ae()||B()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)le();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));ue()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&le()}a?(a=!1,me()):(S!=e||C!=t)&&te(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!Mt&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&V(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!Mt||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&te()}),Y(T,`keydown`,e=>{let t=e.key,n=Ht(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?pe():me(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(ie(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(V(c),te(),X(e)):t==`Escape`?(te(),X(e)):t.slice(0,4)==`Page`&&(z(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),re(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(ce(-2),X(e)):(ce(2),X(e)):!n&&t==`Escape`&&(le(),X(e)))},!0),Y(I,`mousedown`,e=>{e.target!=P&&(V([].indexOf.call(R,e.target.closest(`li`))+d),te()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&te()}),Y(w,`scroll`,()=>{i&&H()}),Y(N,`click`,pe),Y(N,`mousedown`,X),Y(P,`click`,pe),M.id=L+`d`,P.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},tn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return nn(e,t);let i=e.toLowerCase(),a=t.toLowerCase(),o=[],s=a.indexOf(i),c=0,l=0,u=0,d=0;for(;l<r;){let n=s>-1?l+s:a.indexOf(i[l],u),r=n>u;if(n<0)return;r&&(c-=800),(r||!d)&&(o[d]=n,d+=2),o[d-1]=u=n+1,e[l++]!=t[n]&&(c-=100)}return[r<n?c-100:c,o]},nn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;let i=t.slice(0,r),a=i==e?0:e.toLowerCase()==i.toLowerCase()?-200:null;if(a!=null)return[e?r<n?a-100:a:0,[0,r]]},rn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||mn[e]||0;return t+`+`+r},an=e=>{if(!fn[48]){for(let e=48;e<91;e++)fn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)fn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=Ht(e),r=fn[e.keyCode],i=pn[e.keyCode],a=n>7,o=(Q&&n==12||t==`Dead`||t==`Unidentified`)&&(a&&i||r)||t.toLowerCase(),s=/\w\w| /.test(o.slice(0,2)),c=n&7,l=new Set([`${s||/\p{L}/u.test(o)?n:c}+${o}`]);return s||(c&&!(Q&&c==1)&&r?(l.add(n+`+`+r),a&&i&&l.add(c+`+`+i)):a&&l.add(n+`+`+o)),l},on=new WeakMap,sn=(e,t,n)=>{let r=new Set,i;try{for(let a of an(e)){i||=a;for(let i of t[a]||[])for(let t of i||[])if(!r.has(t)){if(t(n,e,a))return X(e),!0;r.add(t)}}}finally{t.any?.forEach(t=>t?.forEach(t=>t(n,e,i)))}},cn=e=>{let t=on.get(e);return t||(on.set(e,t={}),Ot(e,`keydown`,n=>{sn(n,t,e)})),t},ln=(e,t,n,r)=>un(cn(e),t,n,r),un=(e,t,n,r=2)=>{let i=(e[t==`any`?t:rn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},dn=Q?4:2,fn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},pn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},mn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},hn=!1,gn=e=>e.search(/\S|$/),_n=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),vn=(e,t,n,r,i,a,o)=>{let s=n.join(`
|
|
25
|
+
`);if(s==t.join(`
|
|
26
|
+
`))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+gn((f<0?n:t)[0]),m=i-u.length+gn(d>0?l:u),h=r-i+s.length+d,g=p>a?a:Math.max(p,a+f),_=o+r-i+s.length;Z(e,s,r,i,g,o<m?_+d:Math.max(m+h,_))},yn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=Ft(e.value,n,r),[s,c]=_n(e);return vn(e,i,i.map(t?e=>e.slice(gn(e)?c-gn(e)%c:0):e=>e&&s.repeat(c-gn(e)%c)+e),a,o,n,r),$(e)},bn=(e,t)=>{let[n,r]=_n(e);return Z(e,n.repeat(r-(t-Tt(e.value,t))%r)),$(e)},xn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=Et(r,n[1]));let[i,a]=_n(e),[o,s]=n,c=xt[Lt(e,o)]?.autoIndent,l=Math.floor(gn(Pt(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
|
|
27
|
+
`+i.repeat(l+u)+(d?`
|
|
28
|
+
`+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Sn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?Tt(i,n)-1:n,o=t?r:i.indexOf(`
|
|
29
|
+
`,r)+1;if(a>-1&&o>0){let[s,c,l]=Ft(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
|
|
30
|
+
`),c,l,n+d,r+d)}return $(e)},Cn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=Ft(i,n,r),c=a.join(`
|
|
31
|
+
`),l=t?0:c.length+1;return Z(e,c+`
|
|
32
|
+
`+c,o,s,n+l,r+l),$(e)},wn=(e,t)=>(e.container.scrollBy(0,kt(e.container,`lineHeight`)*(t?-1:1)),!0),Tn=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=Ft(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=Et(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},En=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:Tt(i,n),o=xt[Lt(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=Ft(i,n,r),f=l.length-1;if(t){if(c){let[t,a]=c,o=i.slice(n,r),s=i.slice(0,n).search(Nt(t)+` ?$`);s+1&&RegExp(`^ ?`+Nt(a)).test(i.slice(r))?Z(e,o,s,r+(i[r]==` `)+a.length,s,s+r-n):Z(e,`${t} ${o} ${a}`,n,r,n+t.length+1,r+t.length+1)}}else if(s){let t=Nt(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));vn(e,l,l.map(!c&&l.every(e=>a.test(e))?e=>e.replace(o,``):e=>c||/\S/.test(e)?e.replace(/(?!\s)/,s+` `):e),u,d,n,r)}else if(c){let[t,i]=c,a=l[0],o=gn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(Nt(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${Nt(i)}$`),``):l[f]+` `+i;let m=l.join(`
|
|
33
|
+
`),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},Dn={Tab(e){if(!hn){let[t,n]=e.getSelection();return t==n?bn(e,t):yn(e)}},"8+Tab":e=>!hn&&yn(e,!0),"1+ArrowDown":e=>Sn(e),"1+ArrowUp":e=>Sn(e,!0),"9+ArrowDown":e=>Cn(e),"9+ArrowUp":e=>Cn(e,!0),Enter:e=>xn(e),"8+Enter":e=>xn(e),"Mod+Enter":e=>xn(e,!0),"Mod+]":e=>yn(e),"Mod+[":e=>yn(e,!0),"8+Mod+k":Tn,"Mod+/":e=>En(e),"9+a":e=>En(e,!0),[Q?`10+m`:`2+m`]:()=>(hn=!hn,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>wn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>wn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var On=Q?5:1;On+``,On+``,On+``,On+``;var kn=(e,t=[`""`,`''`,"``",`()`,`[]`,`{}`],n=/([^$\w'"`]["'`]|.[[({])[.,:;\])}>\s]|.[[({]`/s)=>(r,i)=>{let a,o=r.inputCommandMap,s=navigator.clipboard,c=([e,t],[i,a],o,s)=>(e<t||!s&&n.test((o[t-1]||` `)+i+(o[t]||` `)))&&!Z(r,i+o.slice(e,t)+a,null,null,e+1,t+1),l=([e,t],n,i)=>e==t&&i[t]==n&&!Rt(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=Pt(a,e),s=i.tabSize||2,c=t.includes(a.slice(e-1,e+1)),l=/[^ ]/.test(o)?0:(o.length-1)%s+1;if((c||l>1)&&e==n)return Z(r,``,e-(c?1:l),e+c),$(r)}};o[`<`]=(e,t,n)=>c(t,`<>`,n,!0),t.forEach(([e,t])=>{let n=e==t;o[e]=(i,a,o)=>(n&&l(a,t,o)||c(a,e+t,o))&&$(r),n||(o[t]=(e,n,i)=>l(n,t,i)&&$(r))}),o[`>`]=(e,t,n)=>{let i=xt[Lt(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},ln(r,`Backspace`,u),ln(r,`8+Backspace`,u);for(let t in e)ln(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>Ot(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=Ft(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
|
|
34
|
+
`,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},An=(e=999)=>{let t=0,n,r,i=!1,a,o,s,c,l,u,d=[],f=r=>{r>=e&&(r--,d.shift()),d.splice(t=r,e,[n.value,u(),u()])},p=e=>{d[e]&&(l.value=d[e][0],l.setSelectionRange(...d[e][e<t?2:1]),n.update(),n.extensions.cursor?.scrollIntoView(),t=e,r=!1)},m=(e,g)=>{e.extensions.history=m,n=e,u=e.getSelection,l||f(0),l=e.textarea,e.on(`selectionChange`,()=>{r=i,i=!1}),Ot(e,`beforeinput`,e=>{let n=e.data,l=e.inputType,f=e.timeStamp;/history/.test(l)?(p(t+(l[7]==`U`?-1:1)),X(e)):(c=r&&(a==l||f-s<99&&l.slice(-4)==`Drop`)&&!Mt&&(n!=` `||o==n))||(d[t][2]=Mt||u()),i=!0,o=n,s=f,a=l}),Ot(e,`input`,()=>f(t+!c)),Ot(e,`keydown`,e=>{if(!g.readOnly){let n=Ht(e),r=e.keyCode,i=n==dn&&r==90,a=n==dn+8&&r==90||!Q&&n==dn&&r==89;i?(p(t-1),X(e)):a&&(p(t+1),X(e))}}),e.addExtensions({update(){e.value!=l.value&&h()}})},h=m.clear=()=>{f(0),r=!1};return m.has=e=>t+e in d,m.go=e=>p(t+e),m},jn=vt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),Mn=()=>{let e,t=jn(),[n,r]=t.childNodes,[i,a]=r.childNodes,o=()=>{let r=e.getSelection(),i=e.value,o=e.lines[e.activeLine],s=r[r[2]<`f`?0:1];jt(n,Pt(i,s)),jt(a,i.slice(s,Et(i,s))+`
|
|
35
|
+
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),wt(e,i)},c=t=>{e=t,t.extensions.cursor=c,Ot(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),At(e,i)),c.scrollIntoView=s,c.element=i,c};vt(`<div class=pce-cursor>`);var Nn=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,Pn=/\b(?:false|true)\b/,Fn=/\[]|\(\)|{}/,In=/[([{][^)\]}]*$/,Ln=([e,t],n)=>Fn.test(n[e-1]+n[t]),Rn={line:`//`,block:[`/*`,`*/`]},zn=(e=Rn,t=In)=>({comments:e,autoIndent:[([e],n)=>t.test(Pt(n,e)),Ln]});xt.json=xt.json5=xt.jsonp=zn(),xt.graphql=zn({line:`#`}),it.webmanifest=it.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:Nn,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:Pn,null:{pattern:/\bnull\b/,alias:`keyword`}},it.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|"(?!""))*"""|"(?:\\.|[^\\\n"])*")(?=\s*[a-z_])/gi,alias:`string`,inside:{"language-markdown":{pattern:/("(?!")|""")[^]+(?=\1)/,lookbehind:!0,inside:`md`}}},string:/"""[^]*?"""|"(?:\\.|[^\\\n"])*"/g,number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:Pn,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:`function`},"attr-name":/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\\n"])*")*\))?:)/gi,"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:`class-name`},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-mutation":{pattern:/(\bmutation\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-query":{pattern:/(\bquery\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[&|!=]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[()[\]{},:!=]/,property:/\w+/,[nt](e,t){for(var n=ot(e,t),r=n.filter(({type:e})=>e&&e!=`comment`&&e!=`scalar`),i=r.length,a=0,o=e=>{for(var t=0;t<e.length;t++)if(a+t==i||r[a+t].type!=e[t])return!0},s=(e,t)=>{for(var n=1,o=a;o<i;o++){var s=r[o],c=s.content;if(s.type==`punctuation`){if(e==c)n++;else if(t==c&&!--n)return o}}};a<i;){var c=r[a++];if(c.type==`keyword`&&c.content==`mutation`){var l=[];if(!o([`definition-mutation`,`punctuation`])&&r[a+1].content==`(`){a+=2;var u=s(`(`,`)`);if(!u)continue;for(;a<u;a++){var d=r[a];d.type==`variable`&&(d.alias=`variable-input`,l.push(d.content))}a=u+1}if(!o([`punctuation`,`property-query`])&&r[a].content==`{`&&(r[++a].alias=`property-mutation`,l[0])){var f=s(`{`,`}`);if(f)for(var p=a;p<f;p++){var m=r[p];m.type==`variable`&&l.indexOf(m.content)>=0&&(m.alias=`variable-input`)}}}}return n}};var Bn=new WeakMap;$t([`json`],{sources:[(e,t)=>{let n=Bn.get(t)?.(t.value,e.pos);return n?{from:n.from,to:n.to,options:n.options.map(e=>({...e,renderDocs:e.doc?()=>[e.doc]:void 0}))}:null}]});function Vn({value:e,language:t=`json`,readOnly:n,label:o,onChange:s,onLine:c,complete:l}){let u=a(null),d=a(void 0),f=a({onChange:s,onLine:c});f.current={onChange:s,onLine:c};let p=a(l);return p.current=l,i(()=>{let r=ht(u.current,{value:e,language:t,readOnly:n,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},kn(Dn),An(),...l?[Mn(),en({filter:tn})]:[]);return l&&Bn.set(r,(e,t)=>p.current?.(e,t)),r.textarea.setAttribute(`aria-label`,o),d.current=r,()=>r.remove()},[]),i(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),i(()=>{d.current?.setOptions({readOnly:n,language:t})},[n,t]),r(`div`,{class:`body-editor`,part:`editor`,ref:u})}var Hn=/[\w$.+-]/;function Un(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
|
|
36
|
+
`;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&Hn.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&Hn.test(e[o]??``);)o++;let s=r();return c({mode:s?.t===`o`&&s.expectKey?`key`:`value`,from:a,to:o,inString:!1,prefix:e.slice(a,t),hasColon:!1});function c(e){if(n.length===0)return;let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=r===n.length-1;if(i.t===`o`){if(a&&e.mode===`key`)break;if(i.key===void 0)return;t.push(i.key)}else t.push(i.index)}let i=r();return{...e,path:t,existing:i?.t===`o`?i.keys:new Set}}}var Wn=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),Gn=(e,t)=>{let n=K(e);return n===`array`?`${K(G(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function Kn(e){let t=K(e);return t===`object`?{text:`{}`,stop:1}:t===`array`?{text:`[]`,stop:1}:t===`boolean`?{text:`false`,stop:5}:t===`number`||t===`integer`?{text:`0`,stop:1}:{text:`""`,stop:1}}function qn(e,t,n,r,i){if(!e)return;let a=Un(r,i);if(!a)return;let o=J(e,[...n,...a.path],t);if(!o)return;let s=G(o,t);if(a.mode===`key`){if(K(s)!==`object`&&!s.properties)return;let e=Ce(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=G(e.schema,t),r=Kn(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${Gn(n,t)}${e.required?` · required`:``}`,icon:n.deprecated?`text`:`property`,insert:s,tabStops:a.hasColon?void 0:[o.length+r.stop],boost:e.required?10:0,from:a.inString?a.from+1:void 0,doc:Wn(Se(xe(n),400))}});return{from:a.from,to:a.to,options:n}}let c=[],l=(e,t)=>{let n=JSON.stringify(e);c.push({label:typeof e==`string`?e:n,insert:n,icon:`enum`,detail:t,from:a.inString?a.from+1:void 0})};if(Array.isArray(s.enum))for(let e of s.enum)l(e);else if(K(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var Jn=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Yn(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:k(e.path),query:k(e.query),headers:k(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?j(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var Xn=e=>Object.keys(e).length?e:void 0;function Zn(e,t){let n;if(Jn(e,t))n=P(e.fields);else if(t===`binary`){let t=e.fields.find(e=>e.enabled);n=t?.file??t?.value}else if(e.body.trim()!==``){if(t===`text`)n=e.body;else try{n=JSON.parse(e.body)}catch(e){throw Error(`Invalid JSON: ${e.message}`)}}return{path:Xn(A(e.path)),query:Xn(A(e.query)),headers:Xn(A(e.headers)),data:n}}var Qn=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function $n(e,t,n,r=``){let i=e=>e.includes(`{{`)?e:encodeURIComponent(e),a=e.replace(/\{([^}]+)\}/g,(e,n)=>{let r=t.find(e=>e.key===n&&e.enabled&&e.value!==``);return r?i(r.value):e}),o=n.filter(e=>e.enabled&&e.key!==``).map(e=>`${i(e.key)}=${i(e.value)}`).join(`&`);return`${r.replace(/\/+$/,``)}${a}${o?`?${o}`:``}`}function er({doc:e,hint:t}){return e?r(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[r(`div`,{class:`field-doc-head`,children:[r(`code`,{children:e.path}),r(`span`,{class:`chip`,children:e.type}),e.required&&r(`span`,{class:`chip req`,children:`required`}),e.deprecated&&r(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?r(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:fe(e.description)}}):e.note?null:r(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&r(n,{children:[` It is part of: `,e.parent]})]}),e.note&&r(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&r(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>r(`code`,{children:e})),e.enum.length>12&&r(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):r(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:t??`Put the cursor on a field to see what the API says about it.`})}function tr(e){try{let{query:t,variables:n,...r}=JSON.parse(e);return typeof t==`string`?{query:t,variables:n===void 0?``:JSON.stringify(n,null,2),rest:r}:void 0}catch{return}}function nr(e){let t;try{t=e.variables.trim()?JSON.parse(e.variables):void 0}catch{t=e.variables}return JSON.stringify({query:e.query,variables:t,...e.rest},null,2)}function rr({value:e,options:t,onChange:n,label:o,placeholder:c,onKeyDown:l,cell:u}){let[d,f]=s(!1),[p,m]=s(-1),[h,g]=s(),_=a(null),v=()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-8,n=t<160&&e.top>t;g({left:`${e.left}px`,width:`${Math.max(e.width,160)}px`,maxHeight:`${Math.min(240,(n?e.top:t)-4)}px`,...n?{bottom:`${innerHeight-e.top+2}px`}:{top:`${e.bottom+2}px`}})};i(()=>{if(!d)return;v();let e=e=>{e.target instanceof Node&&_.current?.contains(e.target)||f(!1)};return addEventListener(`scroll`,e,!0),addEventListener(`resize`,e),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,e)}},[d]),i(()=>{if(!d)return;let e=e=>{e.composedPath().includes(_.current)||f(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[d]);let y=e=>{n(e),f(!1),m(-1)};return r(`div`,{class:`combo`,ref:_,children:[r(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":d,role:`combobox`,autocomplete:`off`,onFocus:()=>f(!0),onInput:e=>n(e.target.value),onKeyDown:e=>{d&&e.key===`ArrowDown`?(e.preventDefault(),m((p+1)%t.length)):d&&e.key===`ArrowUp`?(e.preventDefault(),m((p-1+t.length)%t.length)):d&&e.key===`Enter`&&p>=0?(e.preventDefault(),y(t[p])):e.key===`Escape`&&d?(e.stopPropagation(),f(!1)):((e.key===`Enter`||e.key===`Tab`)&&f(!1),l?.(e))}}),r(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,onClick:()=>f(!d),children:`▾`}),d&&r(`div`,{class:`combo-list`,role:`listbox`,style:h,children:t.map((t,n)=>r(`button`,{type:`button`,role:`option`,"aria-selected":t===e,class:`${t===e?`on`:``} ${n===p?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>y(t),children:t}))})]})}var ir=`specbook:grid-cols`,ar={key:26,val:34},or=10,sr=l(cr());function cr(){try{let e=JSON.parse(localStorage.getItem(ir)??`null`);if(e&&e.key>=or&&e.val>=or&&e.key+e.val<=90)return e}catch{}return ar}function lr(e){let t=e??ar,n=Math.min(80,Math.max(or,t.key)),r=Math.min(100-n-or,Math.max(or,t.val));sr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?localStorage.setItem(ir,JSON.stringify(sr.value)):localStorage.removeItem(ir)}catch{}}function ur(){return r(`colgroup`,{children:[r(`col`,{style:{width:`36px`}}),r(`col`,{style:{width:`${sr.value.key}%`}}),r(`col`,{style:{width:`${sr.value.val}%`}}),r(`col`,{}),r(`col`,{style:{width:`60px`}})]})}function dr({which:e,table:t}){let n=t=>{let n=sr.value;lr(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return r(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(sr.value[e]),"aria-valuemin":or,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let r=t()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{n((e.clientX-i)/r*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>lr(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),n(e.key===`ArrowLeft`?-2:2))}})}var fr=1,pr=2;function mr(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.search(/[=\t]|:\s/);return t<0?{key:e,value:``}:{key:e.slice(0,t).trim(),value:e.slice(t+1).trim()}})}var hr=({d:e})=>r(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:r(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function gr({title:e,rows:t,onChange:o,documented:s=[],docFor:c,fixed:l,bad:u,placeholder:d,bare:f}){let p=a(null),m=a(null),h=a(void 0),g=new Set(t.map(e=>e.key)),_=s.filter(e=>!g.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),v=[...t,..._],y=e=>s.find(t=>t.name===e),b=e=>y(e)?.doc??c?.(e);i(()=>{if(!h.current)return;let e=p.current?.querySelector(`[data-cell="${h.current}"]`);h.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let x=e=>!e.virtual||e.enabled||e.value!==``||e.file,S=e=>o(e.filter(x).map(({virtual:e,...t})=>t)),C=(e,t)=>S(v.map((n,r)=>r===e?{...n,...t}:n)),w=(e,t)=>p.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),T=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),w(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),w(e-1,t))},E=e=>{let t=v[e],n=b(t.key)?.enum??[],r=new Set(v.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...v];o.splice(e+1,0,a),h.current=`${o.filter(x).indexOf(a)}:${pr}`,S(o)},D=(e,n)=>{let r=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(r.trim()))return;e.preventDefault();let i=mr(r).map(e=>({...e,enabled:!0})),a=[...t];a.splice(n,+(n<t.length&&!t[n]?.key),...i),o(a)},O=v.length;return r(`section`,{class:`grid`,"aria-label":e,ref:p,children:[!f&&r(`h3`,{children:e}),r(`table`,{ref:m,children:[r(ur,{}),r(`thead`,{children:r(`tr`,{children:[r(`th`,{class:`g-check`}),r(`th`,{class:`g-key`,children:[`Key`,r(dr,{which:`key`,table:()=>m.current})]}),r(`th`,{class:`g-val`,children:[`Value`,r(dr,{which:`val`,table:()=>m.current})]}),r(`th`,{class:`g-doc`,children:`Description`}),r(`th`,{class:`g-act`})]})}),r(`tbody`,{children:[v.map((e,t)=>{let i=b(e.key),a=y(e.key)?.file,o=l||e.virtual||y(e.key);return r(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[r(`td`,{class:`g-check`,children:r(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:l,onChange:e=>C(t,{enabled:e.target.checked})})}),r(`td`,{class:`g-key`,children:o?r(`span`,{class:`key`,children:[r(`code`,{children:e.key}),i?.required&&r(`span`,{class:`req`,title:`required`,children:`*`})]}):r(`input`,{class:`cell`,"data-cell":`${t}:${fr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>C(t,{key:e.target.value}),onKeyDown:T(t,fr),onPaste:e=>D(e,t)})}),r(`td`,{class:`g-val`,children:a?r(`label`,{class:`file-cell`,children:[r(`input`,{type:`file`,"aria-label":`File for ${e.key}`,onChange:e=>{let n=e.target.files?.[0];n&&C(t,{file:n,value:n.name,enabled:!0})}}),r(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):i?.enum?r(rr,{value:e.value,options:i.enum.map(String),label:e.key,cell:`${t}:${pr}`,placeholder:`value`,onKeyDown:T(t,pr),onChange:e=>C(t,{value:e,enabled:!0})}):r(`input`,{class:`cell`,"data-cell":`${t}:${pr}`,value:e.value,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>C(t,{value:e.target.value,enabled:!0}),onKeyDown:T(t,pr)})}),r(`td`,{class:`g-doc`,title:pe(i?.description),children:i&&r(n,{children:[r(`span`,{class:`chip`,children:i.type}),` `,r(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:U(i.description)}})]})}),r(`td`,{class:`g-act`,children:[!l&&e.key&&r(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>E(t),children:r(hr,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!l&&!e.virtual&&r(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>S(v.filter((e,n)=>n!==t)),children:r(hr,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},t)}),!l&&r(`tr`,{class:`ghost`,children:[r(`td`,{class:`g-check`}),r(`td`,{class:`g-key`,children:r(`input`,{class:`cell`,"data-cell":`${O}:${fr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{h.current=`${t.length}:${fr}`,o([...t,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:T(O,fr),onPaste:e=>D(e,t.length)})}),r(`td`,{class:`g-val`}),r(`td`,{class:`g-doc`}),r(`td`,{class:`g-act`})]},O)]})]})]})}function _r({draft:e,onChange:t}){let[n,o]=s(()=>tr(e.body)),c=a(e.body);i(()=>{if(e.body===c.current)return;let t=tr(e.body);t&&o(t),c.current=e.body},[e.body]);let l=r=>{let i={...n,...r};o(i),c.current=nr(i),t({...e,body:c.current})};return r(`section`,{class:`body`,"aria-label":`Body`,children:[r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Query`}),r(`span`,{class:`chip`,children:`graphql`})]}),r(Vn,{label:`GraphQL query`,language:`graphql`,value:n.query,onChange:e=>l({query:e})}),r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Variables`}),r(`span`,{class:`chip`,children:`json`})]}),r(Vn,{label:`GraphQL variables`,language:`json`,value:n.variables,onChange:e=>l({variables:e})})]})}var vr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function yr({encoding:e,draft:t,onChange:i,schema:a,defs:o,files:l=[],notes:u}){let[d,f]=s(0),p=c(()=>Oe(t.body),[t.body]),m=e===`json`||e===`form`,h=c(()=>{let e=p[d];return e&&m?$e(Ze(a,o,e,[`data`]),u,`data`,De(e)):void 0},[p,d,a,o,m,u]),g=c(()=>m&&a?(e,t)=>qn(a,o,[`data`],e,t):void 0,[a,o,m]),_=e=>{if(e!==(t.formView??`grid`)){if(e===`grid`)try{i({...t,formView:`grid`,fields:j(JSON.parse(t.body||`{}`))})}catch{i({...t,formView:`grid`})}else i({...t,formView:`json`,body:JSON.stringify(P(t.fields.filter(e=>!e.file)),null,2)})}},v=e===`form`?r(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>r(`button`,{type:`button`,class:`seg-btn ${(t.formView??`grid`)===e?`on`:``}`,"aria-pressed":(t.formView??`grid`)===e,onClick:()=>_(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(Jn(t,e)||e===`binary`){let s=t=>e===`binary`||l.includes(t.replace(/\[\d+\]/g,``)),c=e=>i({...t,fields:e}),d=(t.fields.length?t.fields.map(e=>e.key):[]).filter(s);return r(n,{children:[v&&r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Body`}),r(`span`,{class:`chip`,children:e}),r(`span`,{class:`spacer`}),v]}),r(gr,{title:e===`binary`?`File`:`Body`,bare:!!v,rows:t.fields,onChange:c,documented:[...new Set(d)].map(e=>({name:e,file:!0})),docFor:e=>$e(Ze(a,o,Qe(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&tr(t.body)?r(_r,{draft:t,onChange:i}):r(`section`,{class:`body`,"aria-label":`Body`,children:[r(`div`,{class:`section-head`,children:[r(`h3`,{children:`Body`}),r(`span`,{class:`chip`,children:e}),r(`span`,{class:`spacer`}),e!==`text`&&r(`button`,{type:`button`,class:`link`,onClick:()=>{try{i({...t,body:JSON.stringify(JSON.parse(t.body),null,2)})}catch{}},children:`Format`}),v]}),r(Vn,{label:`Request body`,language:vr(e===`form`?`json`:e),value:t.body,onChange:e=>i({...t,body:e}),onLine:f,complete:g}),m&&r(er,{doc:h})]})}var br=`specbook:code-lang`;function xr(){try{let e=localStorage.getItem(br);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Sr({service:e,profile:t,secured:n,make:a,sent:o}){let[l,d]=s(xr),f=l===`sent`?`curl`:l,[p,m]=s(!1),[h,g]=s(),[_,v]=s();i(()=>{let n=!0;return C.config(u.value).then(r=>{if(!n)return;let i=r.services?.[e],a=i?.baseUrl??{};g(a.live??Object.values(a)[0]);let o=t===`service`?i?.auth:t;v(o?r.auth?.[o]?.apply:void 0)}),()=>{n=!1}},[e,t]);let y=c(()=>{try{return{text:le(f,a(h??`https://api.example.com`,_))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[a,f,h,_]),b=e=>{if(d(e),e!==`sent`)try{localStorage.setItem(br,e)}catch{}};return r(`div`,{class:`code-sample`,children:[r(`div`,{class:`code-head`,children:[r(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[ue.map(e=>r(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>b(e.id),children:e.label})),o!==void 0&&r(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>b(`sent`),children:`Sent`})]}),r(`span`,{class:`spacer`}),l!==`sent`&&r(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(y.text)try{await navigator.clipboard.writeText(y.text),m(!0),setTimeout(()=>m(!1),1500)}catch{}},disabled:!y.text,children:p?`Copied`:`Copy`})]}),l===`sent`?o:y.error?r(`p`,{class:`muted`,children:y.error}):r(`pre`,{class:`code-block`,part:`code`,children:r(`code`,{children:y.text})}),l!==`sent`&&n&&r(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Cr({service:t,method:n,path:i,draft:a,encoding:s,vars:c,secured:l,sent:u}){let d=o((t,r)=>{let o=Zn(a,s),l={path:o.path??{},query:o.query??{},headers:o.headers??{},data:o.data},u=l;try{u=e(l,c)}catch{}let d=i.replace(/\{([^}]+)\}/g,(e,t)=>{let n=u.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:n,url:`${t.replace(/\/+$/,``)}${d}`,query:{...r?.query??{},...u.query},headers:{...r?.headers??{},...u.headers},body:u.data,encoding:s}},[a,s,c,n,i]);return r(Sr,{service:t,profile:l?`service`:void 0,secured:l,make:d,sent:u})}function wr({request:e,encoding:t,sent:n}){let i=o((n,r)=>({method:e.method,url:`${n.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:t}),[e,t]);return r(Sr,{service:e.service,profile:e.profile,secured:!!e.profile,make:i,sent:n})}var Tr=e=>typeof e==`string`?e:JSON.stringify(e,null,2);function Er(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r])t.append(n,e);let n=t.toString();return n?`?${n}`:``}function Dr({body:e,docs:t}){let[i,a]=s(0),o=Tr(e),l=!!t?.schema&&typeof e==`object`&&!!e,u=c(()=>l?Oe(o):[],[l,o]),d=c(()=>{let e=u[i];return e&&t?$e(Ze(t.schema,t.defs,e,[`data`]),t.notes,`data`,De(e)):void 0},[u,i,t]);return r(n,{children:[r(Vn,{label:`Body as sent`,value:o,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:a}),l&&r(er,{doc:d})]})}function Or({request:e,hideBar:t,docs:i}){if(!e)return r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`Nothing sent yet`}),r(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let a=Object.entries(e.headers);return r(`div`,{class:`sent-view`,children:[!t&&r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${e.method}`,children:e.method}),r(`div`,{class:`rq-url`,title:e.url,children:r(`code`,{children:[e.url,Er(e.query)]})})]}),r(`h3`,{children:`Headers`}),a.length===0?r(`p`,{class:`muted`,children:`No headers.`}):r(`table`,{class:`headers`,children:r(`tbody`,{children:a.map(([e,t])=>r(`tr`,{children:[r(`th`,{children:e}),r(`td`,{children:t})]}))})}),e.body!==void 0&&r(n,{children:[r(`h3`,{children:`Body`}),r(Dr,{body:e.body,docs:i})]})]})}var kr=e=>JSON.stringify(e,null,2),Ar=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function jr({step:e,error:t,schemas:i,defs:a,hideRequest:o}){let[l,u]=s(`body`),[d,f]=s(0),p=e?.response,m=p?i?.[String(p.status)]??i?.default:void 0,h=c(()=>p&&m?Ee(p.body,m,a,{reportExtra:!0}):[],[p,m,a]),g=p===void 0||p.body===void 0||p.body===``?``:typeof p.body==`string`?p.body:kr(p.body),_=c(()=>Oe(g),[g]),v=c(()=>{let e=_[d];return e?Ze(m,a,e):void 0},[_,d,m,a]),y=e?.assertions??[],b=y.filter(e=>!e.pass).length,x=Object.entries(p?.headers??{}),S=!p&&!t&&!e?.error;return r(`section`,{class:`response`,"aria-label":`Response`,children:[r(`div`,{class:`rs-head`,children:[p&&r(n,{children:[r(`span`,{class:`state-badge ${je(p.status)}`,children:[p.status,` `,Ae(p.status)]}),r(`span`,{class:`rs-stat`,children:[p.durationMs,` ms`]}),r(`span`,{class:`rs-stat`,children:Ar(new Blob([g]).size)})]}),r(`span`,{class:`spacer`}),p&&r(`span`,{class:`conf ${m?h.length?`warn`:`ok`:`none`}`,children:m?h.length?`⚠ ${h.length} difference${h.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!o&&r(`p`,{class:`sent`,children:[r(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,r(`code`,{children:[e.request.url,Er(e.request.query)]})]}),t&&r(`p`,{class:`error-text`,children:t}),e?.error&&r(`p`,{class:`error-text`,children:e.error}),S&&r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`No response yet`}),r(`span`,{class:`muted`,children:[`Press`,` `,r(`kbd`,{class:`icon-key`,children:r(E,{size:12})}),` `,`or `,r(`kbd`,{children:`⌘`}),` `,r(`kbd`,{children:`↵`})]})]}),p&&r(n,{children:[r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,x.length],[`checks`,`Checks`,y.length]].map(([e,t,n])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":l===e,class:`rq-tab ${l===e?`on`:``}`,onClick:()=>u(e),children:[t,n>0&&r(`span`,{class:`count ${e===`checks`&&b?`bad`:``}`,children:n})]}))}),r(`div`,{class:`rs-pane`,children:[r(`div`,{hidden:l!==`body`,children:[g===``?r(`p`,{class:`muted`,children:`No content.`}):r(Vn,{label:`Response body`,value:g,readOnly:!0,language:typeof p.body==`string`?`text`:`json`,onLine:f}),g!==``&&r(er,{doc:v}),h.length>0&&r(`details`,{class:`issues`,children:[r(`summary`,{children:`What differs`}),r(`ul`,{children:h.map(e=>r(`li`,{children:[r(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),r(`div`,{hidden:l!==`headers`,children:r(`table`,{class:`headers`,children:r(`tbody`,{children:[x.map(([e,t])=>r(`tr`,{children:[r(`th`,{children:e}),r(`td`,{children:t})]})),x.length===0&&r(`tr`,{children:r(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),r(`div`,{hidden:l!==`checks`,children:y.length===0?r(`p`,{class:`muted`,children:`This request has no checks.`}):r(`ul`,{class:`checks`,children:y.map(e=>r(`li`,{class:e.pass?`ok`:`bad`,children:[e.pass?`✓`:`✗`,` `,e.label]}))})})]})]})]})}var Mr={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Nr({services:e,enabled:t=!0,supplied:a}){let[o,c]=s([]),[l,d]=s({}),p=a??l,[,m]=s(0),[h,g]=s(!1),_=t&&S.value!==`mock`,y=e?.join(`
|
|
37
|
+
`)??`*`;if(i(()=>{if(!_){c([]);return}let t=!0;return a||C.managedSecrets(S.value).then(e=>t&&d(e)),C.config(u.value).then(n=>{if(!t)return;let r=[];for(let[t,i]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let a=i.auth?n.auth?.[i.auth]:void 0,o=i.baseUrl?.[S.value],s=v(o?w(o,globalThis.location?.href):void 0);if(!a||!s)continue;let c=[...new Set([...JSON.stringify(a.apply).matchAll(f)].map(e=>e[1]))];c.length&&r.push({service:t,origin:s,title:a.title??i.auth??``,names:c})}c(r)}),()=>{t=!1}},[_,S.value,y,u.value]),!_||o.length===0)return null;let b=(e,t)=>T.get(e.origin,t)!==void 0||p[t]!==void 0,x=o.some(e=>e.names.some(t=>!b(e,t)));return!x&&!h?r(`div`,{class:`secrets-folded`,children:r(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>g(!0),children:[r(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):r(`fieldset`,{class:`needs-vars ${x?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>r(n,{children:[r(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(t=>{let i=T.get(e.origin,t)!==void 0,a=p[t];return r(`span`,{class:`needs-var`,children:[r(`code`,{children:t}),i?r(n,{children:[r(`span`,{class:`muted`,children:`✓ set`}),r(`button`,{type:`button`,class:`link`,onClick:()=>{T.remove(e.origin,t),m(e=>e+1)},children:`Clear`})]}):r(n,{children:[a&&r(`span`,{class:`muted`,children:[`from `,Mr[a]??a]}),r(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${t} for ${e.service}`,placeholder:a?`use another value`:`paste value`,onChange:n=>{let r=n.target.value;r!==``&&(T.set(e.origin,t,r),m(e=>e+1))}})]})]})})]})),r(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!x&&r(`button`,{type:`button`,class:`link`,onClick:()=>g(!1),children:`Hide`})]})}var Pr=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Fr=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function Ir(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[Fr(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(Fr(Pr(e[1]))):void 0;e&&a!==void 0?n.has(a)||n.set(a,t.slice(e[0].length)):i.push(t)}return{intro:i.join(``),notes:n}}function Lr(e){let{seq:t}=e,[n,r]=s(),[a,o]=s(!1);i(()=>{let n=!0;r(void 0),o(!1);let i=d.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!i)o(!0);else return i.load().then(e=>n&&r(e)).finally(()=>n&&o(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=c(()=>t.nodes.map(e=>e.name),[t]);return c(()=>({...Ir(n??fe(t.meta.description),l),loaded:a}),[n,l,t,a])}function Rr(e){let[t,n]=s();return i(()=>{let t=!0;return n(void 0),e&&d.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&n(e)),()=>{t=!1}},[e]),t}var zr=(e,t)=>`specbook:draft:${e}:${t}`,Br=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Vr(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Hr=`specbook:saved-example`;function Ur(e){try{let t=sessionStorage.getItem(Hr),n=t?JSON.parse(t):void 0;return n?.key===e?(sessionStorage.removeItem(Hr),n):void 0}catch{return}}function Wr({service:e,op:a,variants:o,initial:l}){let f=`${e}/${a.id}`,p=C.examplesOf(f),[m,v]=s(()=>Ur(f)),[y,w]=s(()=>{let e=p.find(e=>e.name===(m?.name??l));return e?`ex:${e.name}`:p[0]?`ex:${p[0].name}`:o[0]?`saved:${o[0].file}`:``}),T=y.startsWith(`saved:`)?o.find(e=>`saved:${e.file}`===y):void 0,D=Rr(T?.file),O=Ue(f),[k,A]=s(),[j,M]=s(),[N,P]=s(),[F,I]=s({}),[L,R]=s(),[ee,te]=s(),[z,ne]=s(),[re,B]=s(),[ie,ae]=s(),[V,oe]=s(),[se,ce]=s(!1),[le,ue]=s(),[de,H]=s(),[fe,pe]=s(``),[me,he]=s();i(()=>{C.config(u.value).then(t=>pe(t.services?.[e]?.baseUrl?.[S.value]??``))},[e,S.value]),i(()=>{let e=!0;return he(void 0),C.knownVars(S.value,u.value).then(t=>e&&he(t)),()=>{e=!1}},[S.value]),i(()=>{let t=!0;return d.schemas[f]?.().then(e=>t&&R(e.default)),d.responseSchemas[f]?.().then(e=>t&&te(e.default)),d.definitions[e]?.().then(e=>t&&ne(e.default)),C.operationMeta(f,u.value).then(e=>{t&&A({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[f,e]);let U=k?.encoding??`json`,ge=d.manifests[e]?.operations.find(e=>e.id===a.id)?.secured;i(()=>{if(!k)return;let e=!0;return oe(void 0),ae(void 0),(async()=>{let t=T?await C.savedExample(T.def,u.value):await C.loadExample(f,y.replace(/^ex:/,``),u.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};M(n),P(!T&&Vr(zr(f,y))||Yn(n,U))})().catch(t=>e&&oe(t instanceof Error?t.message:String(t))),()=>{e=!1}},[f,y,k,T]);let _e=c(()=>j?Yn(j,U):void 0,[j,U]),ve=!!N&&!!_e&&JSON.stringify(Qn(N))!==JSON.stringify(Qn(_e)),ye=e=>{if(P(e),!T)try{let t=zr(f,y);_e&&JSON.stringify(Qn(e))===JSON.stringify(Qn(_e))?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(Qn(e)))}catch{}},W=c(()=>{let e=L?G(L,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Ce(r,z).map(e=>({name:e.name,doc:$e(Ze(L,z,[e.name],[n]),O.notes,n,e.name),repeat:G(e.schema,z).type===`array`})))}return t},[L,z,O.notes]),be=c(()=>{if(!N)return[];try{let e=Zn(N,U);return[...t([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(e=>e.split(`.`)[0]).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[N,U]),K=me?be.filter(e=>!me.includes(e)):[],xe=K.filter(e=>(F[e]??``)===``),Se=async e=>{if(N){oe(void 0),ce(!0);try{let t=T?T.def:await C.operationRequest(f,u.value,Zn(N,U));ae(await C.run(t,{env:S.value,version:u.value,mockStatus:S.value===`mock`?e??re:void 0,locale:g.value,seed:h.value,vars:Object.fromEntries(Object.entries(F).filter(([,e])=>e!==``)),fileDir:j?.dir}))}catch(e){oe(e instanceof Error?e.message:String(e))}finally{ce(!1)}}},we=async t=>{if(!N)return;let n=Zn(N,U),r=Br(t),i={name:r,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${d.project.requestsDir}/${e}/${a.id}/${r}.example.json`,s={key:f,path:o,name:r};try{sessionStorage.setItem(Hr,JSON.stringify(s))}catch{}await x(o,`${JSON.stringify(i,null,2)}\n`),v(s),ue(void 0)},q=ie?.steps.find(e=>e.response)??ie?.steps[0],Te=V?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Ee=!!N&&(N.path.length>0||N.query.length>0||W.path.length>0||W.query.length>0),De=!!N&&(N.headers.length>0||W.headers.length>0),Oe=!!N&&U!==`none`&&(N.body!==``||N.fields.length>0||!!L?.properties?.data),J=de??(Ee?`params`:Oe?`body`:De?`headers`:`params`),ke=e=>e.filter(e=>e.enabled).length,Me=N?ke(N.query):0,Ne=N?ke(N.path):0,Pe=N?$n(a.path,N.path,N.query,fe):a.path;return i(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Se())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)}),r(`div`,{class:`request-panel`,"data-op":f,children:r(`div`,{class:`rq`,children:[r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${a.method}`,children:a.method}),r(`div`,{class:`rq-url`,title:Pe,children:r(`code`,{children:Pe.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?r(`mark`,{children:e}):e)})}),(q?.response||V||q?.error)&&r(`button`,{type:`button`,class:`result-chip ${q?.response?je(q.response.status):`s5`}`,title:`Open the response`,onClick:()=>H(`response`),children:q?.response?`${q.response.status} ${Ae(q.response.status)} · ${q.response.durationMs} ms`:`Failed`}),r(`button`,{type:`button`,class:`btn primary send`,title:`Send (⌘/Ctrl + Enter)`,"aria-label":`Send`,disabled:se||!N,onClick:()=>Se(),children:se?`…`:r(E,{})})]}),D&&r(`details`,{class:`step-about`,children:[r(`summary`,{children:`About this request`}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:D}})]},T?.file),K.length>0&&r(`fieldset`,{class:`needs-vars ${xe.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[r(`span`,{class:`muted`,children:xe.length>0?`Needs a value for`:`Values for`}),K.map(e=>r(`label`,{class:`needs-var`,children:[r(`code`,{children:e}),r(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:F[e]??``,onInput:t=>I({...F,[e]:t.target.value})})]}))]}),ge&&r(Nr,{services:[e]}),r(`div`,{class:`rq-meta`,children:[r(`div`,{class:`rq-example`,children:[r(`label`,{class:`row`,children:[r(`span`,{class:`muted`,children:`Example`}),r(`select`,{value:y,onChange:e=>w(e.target.value),children:[p.map(e=>r(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),o.map(e=>r(`option`,{value:`saved:${e.file}`,children:[e.name,` · saved request`]}))]})]}),r(b,{})]}),ve&&r(`span`,{class:`edited`,children:`Edited`}),r(`span`,{class:`spacer`}),ve&&r(`button`,{type:`button`,class:`link`,onClick:()=>_e&&ye(_e),children:`↺ Reset`}),!_&&!T&&ve&&le===void 0&&r(`button`,{type:`button`,class:`link`,onClick:()=>ue(``),children:`Save as example…`}),S.value===`mock`&&a.statuses.length>0&&r(`label`,{class:`rq-status`,children:[r(`span`,{class:`muted`,children:`Respond with`}),r(`select`,{"aria-label":`Mock response`,value:re===void 0?``:String(re),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);B(n),Se(n)},children:[r(`option`,{value:``,children:`Default`}),a.statuses.map(e=>r(`option`,{value:String(e),children:[e,` `,Ae(e)]}))]})]})]}),m&&r(`p`,{class:`saved-note`,role:`status`,children:[r(`span`,{children:[`✓ Saved to `,r(`code`,{children:m.path}),`. It is a normal project file: commit it to share this example with your team.`]}),r(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>v(void 0),children:`×`})]}),le!==void 0&&r(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),le.trim()&&we(le.trim()).catch(e=>oe(String(e)))},children:[r(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:le,onInput:e=>ue(e.target.value)}),r(`button`,{type:`submit`,class:`btn`,children:`Save`}),r(`button`,{type:`button`,class:`link`,onClick:()=>ue(void 0),children:`Cancel`})]}),T&&r(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock responses apply, and it is read-only here.`}),r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,Me+Ne],[`headers`,`Headers`,N?ke(N.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,be.length]].filter(([e])=>e===`params`?Ee:e===`headers`?De:e===`body`?Oe:be.length>0).map(([e,t,n])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":J===e,class:`rq-tab ${J===e?`on`:``}`,onClick:()=>H(e),children:[t,n>0&&r(`span`,{class:`count`,children:n}),e===`body`&&r(`span`,{class:`chip`,children:U})]})),r(`span`,{class:`tab-gap`}),r(`button`,{type:`button`,role:`tab`,"aria-selected":J===`request`,class:`rq-tab ${J===`request`?`on`:``}`,onClick:()=>H(`request`),children:`Request`}),r(`button`,{type:`button`,role:`tab`,"aria-selected":J===`response`,class:`rq-tab ${J===`response`?`on`:``}`,onClick:()=>H(`response`),children:[`Response`,q?.response&&r(`span`,{class:`state-dot ${je(q.response.status)}`,children:q.response.status}),!q?.response&&(V||q?.error)&&r(`span`,{class:`state-dot s5`,children:`!`})]})]}),r(`div`,{class:`rq-pane`,children:[N&&r(n,{children:[r(`div`,{class:`tab-pane`,hidden:J!==`params`,children:[(N.query.length>0||W.query.length>0)&&r(gr,{title:`Query`,rows:N.query,documented:W.query,onChange:e=>ye({...N,query:e})}),(N.path.length>0||W.path.length>0)&&r(gr,{title:`Path`,rows:N.path,documented:W.path,fixed:!0,onChange:e=>ye({...N,path:e})})]}),r(`div`,{class:`tab-pane`,hidden:J!==`headers`,children:De&&r(gr,{title:`Headers`,rows:N.headers,documented:W.headers,onChange:e=>ye({...N,headers:e})})}),r(`div`,{class:`tab-pane`,hidden:J!==`body`,children:Oe&&r(yr,{encoding:U,draft:N,onChange:ye,schema:L,defs:z,files:k?.files,notes:O.notes})}),r(`div`,{class:`tab-pane`,hidden:J!==`vars`,children:be.length>0&&r(gr,{title:`Variables`,rows:be.map(e=>({key:e,value:F[e]??``,enabled:!0})),fixed:!0,bad:Te,placeholder:`from the request's init, config or earlier steps`,onChange:e=>I(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),r(`div`,{class:`tab-pane`,hidden:J!==`request`,children:N&&r(Cr,{service:e,method:a.method,path:a.path,draft:N,encoding:U,vars:F,secured:ge,sent:q?.request?r(Or,{request:q.request,docs:{schema:L,defs:z,notes:O.notes}}):void 0})}),r(`div`,{class:`tab-pane`,hidden:J!==`response`,children:r(jr,{step:q,error:V,schemas:ee,defs:z})})]})]})})}function Gr(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Kr(e,t),...n}}function Kr(e,t){switch(e.kind){case`select`:case`multiselect`:{let n=e=>typeof t.value==`function`?t.value(e):e,r=e=>typeof t.label==`function`?t.label(e):String(n(e));return{kind:e.kind,options:t.options.map(e=>({label:r(e),value:n(e)}))}}case`object`:return{kind:`object`,shape:Object.fromEntries(Object.entries(t.shape).map(([e,t])=>[e,Gr(t)]))};case`array`:return{kind:`array`,item:Gr(t.item),default:t.default,min:t.min,max:t.max};default:return{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function qr(e){switch(e.kind){case`select`:return e.options?.[0]?.value;case`multiselect`:return[];case`object`:return Object.fromEntries(Object.entries(e.shape??{}).map(([e,t])=>[e,qr(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Jr={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Yr=e=>typeof e==`string`?e:JSON.stringify(e);function Xr({info:e}){let{seq:t}=e,{intro:i,notes:a}=Lr(e),o=c(()=>Object.entries(t.meta.params??{}).map(([e,t])=>{let n=Gr(t);return{name:e,spec:n,initial:qr(n)}}),[t]);return r(`article`,{class:`doc`,"data-seq":t.meta.id,children:[(t.meta.tags?.length??0)>0&&r(`p`,{class:`doc-tags`,children:t.meta.tags?.map(e=>r(`span`,{class:`chip`,children:e}))}),i&&r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:i}}),o.length>0&&r(`section`,{children:[r(`h2`,{children:`Controls`}),r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`Name`}),r(`th`,{children:`Type`}),r(`th`,{children:`Default`}),r(`th`,{children:`Description`})]})}),r(`tbody`,{children:o.map(e=>r(`tr`,{children:[r(`td`,{children:r(`code`,{children:e.name})}),r(`td`,{children:r(`span`,{class:`chip`,children:e.spec.kind})}),r(`td`,{children:r(`code`,{children:Yr(e.initial)})}),r(`td`,{children:e.spec.description})]}))})]})]}),r(`section`,{children:[r(`h2`,{children:`Steps`}),r(`table`,{class:`fields`,children:[r(`thead`,{children:r(`tr`,{children:[r(`th`,{children:`#`}),r(`th`,{children:`Step`}),r(`th`,{children:`What it does`})]})}),r(`tbody`,{children:t.nodes.map((e,t)=>{let i=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,o=a.get(e.name);return r(n,{children:[r(`tr`,{class:o?`has-note`:``,children:[r(`td`,{children:t+1}),r(`td`,{children:e.name}),r(`td`,{children:i?r(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>D({kind:`op`,key:`${i.service}/${i.id}`}),children:[r(`span`,{class:`method ${i.method}`,children:i.method}),` `,r(`code`,{children:i.path})]}):r(`span`,{class:`muted`,children:Jr[e.kind]??e.kind})})]}),o&&r(`tr`,{class:`step-note-row`,children:[r(`td`,{}),r(`td`,{colSpan:2,children:r(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:o}})})]})]})})})]})]})]})}var Zr=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Qr(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function $r({name:e,spec:t,value:n,onChange:i}){let[a,o]=s();switch(t.kind){case`number`:return r(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(n??``),min:t.min,max:t.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return r(rr,{label:e,value:String(!!n),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return r(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(n??``),onInput:e=>i(e.target.value)});case`select`:{let a=t.options??[],o=a.find(e=>Zr(e.value,n));return r(rr,{label:e,value:o?.label??String(n??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=n??[];return r(`div`,{class:`multi-cell`,children:(t.options??[]).map(t=>r(`label`,{children:[r(`input`,{type:`checkbox`,checked:e.some(e=>Zr(e,t.value)),onChange:n=>i(n.target.checked?[...e,t.value]:e.filter(e=>!Zr(e,t.value)))}),t.label]}))})}case`object`:case`array`:return r(`input`,{class:`cell mono`,"aria-label":e,value:a??JSON.stringify(n??qr(t)),onInput:e=>{let t=e.target.value;o(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>o(void 0)});default:return r(`input`,{class:`cell`,"aria-label":e,value:String(n??``),onInput:e=>i(e.target.value)})}}function ei({title:e,specs:t,values:n,onChange:i}){let a=Object.keys(t);return a.length===0?null:r(`section`,{class:`grid controls-grid`,"aria-label":e,children:[r(`h3`,{children:e}),r(`table`,{children:[r(`colgroup`,{children:[r(`col`,{class:`c-key`}),r(`col`,{class:`c-val`}),r(`col`,{})]}),r(`thead`,{children:r(`tr`,{children:[r(`th`,{class:`g-key`,children:`Name`}),r(`th`,{class:`g-val`,children:`Value`}),r(`th`,{class:`g-doc`,children:`Description`})]})}),r(`tbody`,{children:a.map(e=>{let a=t[e];return r(`tr`,{children:[r(`td`,{class:`g-key`,children:r(`span`,{class:`key`,children:r(`code`,{children:a.label??e})})}),r(`td`,{class:`g-val`,children:r($r,{name:e,spec:a,value:n[e],onChange:t=>i({...n,[e]:t})})}),r(`td`,{class:`g-doc`,title:a.description,children:[r(`span`,{class:`chip`,children:Qr(a)}),` `,a.description]})]},e)})})]})]})}function ti({step:e,note:t}){let[n,a]=s(`response`),[o,c]=s(),[l,f]=s(),[p,m]=s(),[h,g]=s(`json`),_=e.request,v=_?.opId?`${_.service}/${_.opId}`:void 0;i(()=>{a(`response`)},[e.name]),i(()=>{let e=!0;return c(void 0),f(void 0),m(void 0),v&&_&&(d.schemas[v]?.().then(t=>e&&m(t.default)),C.operationMeta(v,u.value).then(t=>e&&g(t?.encoding??`json`)),d.responseSchemas[v]?.().then(t=>e&&c(t.default)),d.definitions[_.service]?.().then(t=>e&&f(t.default))),()=>{e=!1}},[v]);let y=e.response,b=_?`${_.url}${Er(_.query)}`:``;return r(`div`,{class:`step-exchange`,children:[_&&r(`div`,{class:`rq-bar`,children:[r(`span`,{class:`method ${_.method}`,children:_.method}),r(`div`,{class:`rq-url`,title:b,children:r(`code`,{children:b})}),y&&r(`span`,{class:`result-chip ${je(y.status)}`,children:[y.status,` `,Ae(y.status),` · `,y.durationMs,` ms`]})]}),t&&r(`details`,{class:`step-about`,children:[r(`summary`,{children:`About this step`}),r(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]},e.name),r(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,t])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":n===e,class:`rq-tab ${n===e?`on`:``}`,onClick:()=>a(e),children:[t,e===`response`&&y&&r(`span`,{class:`state-dot ${je(y.status)}`,children:y.status})]}))}),r(`div`,{class:`rq-pane`,children:[r(`div`,{class:`tab-pane`,hidden:n!==`request`,children:_?r(wr,{request:_,encoding:h,sent:r(Or,{request:_,hideBar:!0,docs:{schema:p,defs:l}})}):r(Or,{request:_,hideBar:!0,docs:{schema:p,defs:l}})}),r(`div`,{class:`tab-pane`,hidden:n!==`response`,children:r(jr,{step:e,schemas:o,defs:l,hideRequest:!0})})]})]})}var ni=e=>e.replace(/ #\d+$/,``),ri={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``},ii=e=>{let t=typeof e==`string`?e:JSON.stringify(e);return t.length>28?`${t.slice(0,27)}…`:t};function ai({info:e}){let{seq:t}=e,n=c(()=>Object.fromEntries(Object.entries(t.meta.params??{}).map(([e,t])=>[e,Gr(t)])),[t]),a=Lr(e),o=c(()=>{let e=new Set;for(let n of t.nodes)if(n.kind===`step`&&typeof n.def!=`function`)e.add(n.def.op.service);else if(n.kind===`step`||n.kind===`each`)return;return[...e]},[t]),[l,d]=s({}),[f,p]=s(),[m,_]=s({}),[v,y]=s(!1),[x,w]=s(),[T,E]=s({}),[D,O]=s(0),[k,A]=s(!1),[j,M]=s();i(()=>{d(Object.fromEntries(Object.entries(n).map(([e,t])=>[e,qr(t)]))),p(void 0),_({}),w(void 0)},[e.file]);let N=t.nodes.map(e=>e.name),P=f?f.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):N.map(e=>({name:e})),F=P[D]?.step,I=async()=>{y(!0),p(void 0),M(void 0),_({}),O(0),A(!1);try{let e=await C.run(t,{env:S.value,version:u.value,params:l,locale:g.value,seed:h.value,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),E(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,qr(t)]))),w({name:e,controls:r,resolve:e=>{w(void 0),n(e)}})})});p(e)}catch(e){M(e instanceof Error?e.message:String(e))}finally{y(!1),w(void 0)}},L=f?.status;return r(`div`,{class:`sequence-panel ${k&&F?`sheet-open`:``}`,"data-seq":t.meta.id,children:[r(`div`,{class:`seq-left`,children:[r(Nr,{services:o}),r(ei,{title:`Controls`,specs:n,values:l,onChange:d}),r(`div`,{class:`seq-run`,children:[r(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:I,children:v?`Running…`:`▶ Run`}),r(b,{}),f&&r(`span`,{class:`badge ${L}`,children:[ri[L],` `,L===`pass`?`Passed`:L===`fail`?`Failed`:`Error`,` ·`,` `,f.totals.passed,`/`,f.totals.steps,` steps · `,f.durationMs,`ms`]})]}),j&&r(`p`,{class:`error-text`,children:j}),r(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:P.map((e,t)=>{let n=e.step,i=n?.status??m[e.name]??`pending`,a=n?.assertions.filter(e=>!e.pass)??[];return r(`li`,{class:`jstep ${i} ${D===t?`picked`:``}`,children:[r(`div`,{class:`jmark`,children:ri[i]||t+1}),r(`div`,{class:`jbody`,children:[r(`button`,{type:`button`,class:`jhead`,disabled:!n,onClick:e=>{let n=e.currentTarget;O(t),A(!0),requestAnimationFrame(()=>n.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[r(`span`,{class:`jname`,children:e.name}),n?.response&&r(`span`,{class:`muted`,children:[n.response.status,` · `,n.durationMs,`ms`]}),n&&n.assertions.length>0&&r(`span`,{class:a.length?`error-text`:`muted`,children:[n.assertions.length-a.length,`/`,n.assertions.length,` checks`]})]}),n?.uses?.filter(e=>e.source===`capture`).map(e=>r(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,r(`em`,{children:[`from `,e.step]})]})),n&&Object.entries(n.captured).map(([e,t])=>r(`span`,{class:`cap make`,title:JSON.stringify(t),children:[`→ `,e,` `,r(`b`,{children:ii(t)})]})),n?.error&&r(`div`,{class:`error-text`,children:n.error}),a.map(e=>r(`div`,{class:`error-text`,children:[`✗ `,e.label]})),i===`skipped`&&r(`div`,{class:`muted`,children:`Skipped: an earlier step did not pass.`}),x&&m[e.name]===`paused`&&r(`div`,{class:`pause`,children:[r(`strong`,{children:[`Your turn: `,x.name]}),r(ei,{title:`Choose`,specs:x.controls,values:T,onChange:E}),r(`button`,{type:`button`,class:`btn primary`,onClick:()=>x.resolve(T),children:`Continue ▶`})]})]})]})})})]}),r(`div`,{class:`seq-right ${k&&F?`sheet-open`:``}`,children:[F&&r(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>A(!1),children:[r(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,F.name]}),!F&&r(`div`,{class:`rs-empty`,children:[r(`strong`,{children:`Nothing run yet`}),r(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),F&&r(ti,{step:F,note:a.notes.get(ni(F.name))})]})]})}function oi(e){let t=e.tab??`try`,n=r(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([n,i])=>r(`button`,{type:`button`,role:`tab`,"aria-selected":t===n,class:`rq-tab ${t===n?`on`:``}`,onClick:()=>e.onNavigate({tab:n}),children:i}))});return e.kind===`seq`?r(Xe,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:r(`div`,{class:`panel-split`,children:[n,r(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:r(t===`docs`?Xr:ai,{info:e.info})})]})}):r(Xe,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:r(`div`,{class:`panel-split`,children:[n,r(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:t===`docs`?r(Je,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):r(Wr,{service:e.service,op:e.op,variants:e.variants,initial:e.example},`${e.service}/${e.op.id}`)})]})})}export{oi as Host};
|