@specbook/ui 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist-viewer/assets/Host-DsO9W5X8.js +41 -0
  2. package/dist-viewer/assets/index-D59fkVA9.js +1 -0
  3. package/dist-viewer/assets/main-i06Egg5h.js +14 -0
  4. package/dist-viewer/assets/{mount-CGL2tOpN.js → mount-CLHBtIzR.js} +2 -2
  5. package/dist-viewer/assets/panel-l1xvY4kI.css +1 -0
  6. package/dist-viewer/assets/{panel-C8Ve3LeS.js → panel-nV09I7Wr.js} +1 -1
  7. package/dist-viewer/assets/registry-b_jzfqy0.js +2 -0
  8. package/dist-viewer/assets/worker-BmvGpsJS.js +181 -0
  9. package/dist-viewer/index.html +4 -4
  10. package/dist-viewer/specbook.js +1 -1
  11. package/package.json +6 -5
  12. package/src/app.tsx +67 -12
  13. package/src/branding.ts +12 -4
  14. package/src/components/Catalog.tsx +128 -51
  15. package/src/components/EnvBadge.tsx +21 -3
  16. package/src/components/EnvironmentMenu.tsx +237 -127
  17. package/src/components/Fields.tsx +18 -1
  18. package/src/components/NewEnvironmentDialog.tsx +118 -0
  19. package/src/components/Palette.tsx +7 -2
  20. package/src/custom-environments.ts +63 -0
  21. package/src/embed/panel.tsx +286 -44
  22. package/src/embed/styles.ts +2 -0
  23. package/src/embed/target.ts +82 -0
  24. package/src/embed/theme.ts +75 -0
  25. package/src/embed.ts +44 -15
  26. package/src/engine.ts +274 -32
  27. package/src/environment-list.ts +16 -0
  28. package/src/main.tsx +7 -2
  29. package/src/nav.ts +12 -1
  30. package/src/oauth.ts +9 -8
  31. package/src/panel/Body.tsx +27 -4
  32. package/src/panel/Checks.tsx +79 -0
  33. package/src/panel/CodeSample.tsx +16 -9
  34. package/src/panel/Combo.tsx +52 -13
  35. package/src/panel/ControlsGrid.tsx +54 -9
  36. package/src/panel/ErrorBoundary.tsx +36 -0
  37. package/src/panel/Host.tsx +14 -2
  38. package/src/panel/OAuthSignIn.tsx +6 -2
  39. package/src/panel/OperationDocs.tsx +1 -1
  40. package/src/panel/Panel.tsx +43 -10
  41. package/src/panel/ParamGrid.tsx +15 -8
  42. package/src/panel/RequestPanel.tsx +102 -39
  43. package/src/panel/RequestView.tsx +2 -1
  44. package/src/panel/ResponseView.tsx +25 -14
  45. package/src/panel/SecretsBar.tsx +10 -9
  46. package/src/panel/SequenceDocs.tsx +7 -6
  47. package/src/panel/SequencePanel.tsx +124 -32
  48. package/src/panel/announce.ts +17 -0
  49. package/src/panel/icons.tsx +9 -0
  50. package/src/panel/short.ts +24 -0
  51. package/src/routing.ts +0 -9
  52. package/src/runtime.ts +19 -1
  53. package/src/secrets.ts +4 -2
  54. package/src/storage.ts +58 -0
  55. package/src/store.ts +8 -0
  56. package/src/styles/app.css +82 -6
  57. package/src/styles/embed.css +116 -0
  58. package/src/styles/panel.css +235 -4
  59. package/src/viewer/embed.ts +9 -2
  60. package/src/viewer/manifests.ts +2 -0
  61. package/src/viewer/mount.ts +2 -0
  62. package/src/viewer/protocol.ts +6 -0
  63. package/src/viewer/registry.ts +48 -10
  64. package/src/viewer/worker.ts +9 -1
  65. package/src/virtual.d.ts +8 -0
  66. package/dist-viewer/assets/Host-CSrM9wY1.js +0 -37
  67. package/dist-viewer/assets/index-ez9c20v3.js +0 -1
  68. package/dist-viewer/assets/main-38QGGpNT.js +0 -14
  69. package/dist-viewer/assets/panel-C-vBZrep.css +0 -1
  70. package/dist-viewer/assets/registry-ChKCFBt1.js +0 -2
  71. package/dist-viewer/assets/worker-ClGb0tE1.js +0 -181
@@ -3,7 +3,7 @@
3
3
  * the document in a worker and puts the result on `globalThis.__SPECBOOK_VIEWER__` before the app is
4
4
  * imported; this module turns that into the same named exports the dev server and the static build give.
5
5
  */
6
- import { defineOperation, type OpMeta } from '@specbook/core'
6
+ import { defineOperation, environmentsFromServers, type OpMeta } from '@specbook/core'
7
7
  import type { OpenResult } from './protocol'
8
8
 
9
9
  export interface ViewerGlobal {
@@ -12,6 +12,8 @@ export interface ViewerGlobal {
12
12
  definitions(): Promise<Record<string, any>>
13
13
  /** the base URL the person gave, when the document has none of its own */
14
14
  baseUrl?: string
15
+ /** the environment to show first, when it is one the document offers (otherwise `mock`) */
16
+ defaultEnv?: string
15
17
  /** where the document came from, which decides whether a link to this view can be shared */
16
18
  source?: import('./share').ViewerSource
17
19
  }
@@ -32,7 +34,10 @@ const ids = Object.keys(open.metas)
32
34
  export const mode = 'static' as const
33
35
  export const project = { root: '', outDir: '', requestsDir: 'requests' }
34
36
  export const manifests = { [service]: open.manifest }
37
+ export const loadManifests = async (_services?: string[]) => {}
35
38
  export const requests: never[] = []
39
+ export const requestMeta = {}
40
+ export const unresolvedRequests: string[] = []
36
41
  export const sequences: never[] = []
37
42
  export const sequenceMeta = {}
38
43
  export const unresolvedSequences: string[] = []
@@ -134,28 +139,61 @@ export const loadFaker = () =>
134
139
  },
135
140
  }))
136
141
 
137
- // `live` is the document's first server, or the address the person typed for it; the rest keep their own names
142
+ // `live` is the document's first server, or the address the person typed for it; the rest keep their own
143
+ // names. Each address is the variable `baseUrl` in its environment, so a copy of one can point elsewhere.
138
144
  const live = v.baseUrl ?? open.baseUrl
139
- const baseUrl: Record<string, string> = {
140
- ...(live ? { live } : {}),
141
- ...Object.fromEntries(open.servers.filter((s) => s.name !== 'live').map((s) => [s.name, s.url])),
142
- }
143
- const described = Object.fromEntries(
144
- open.servers.filter((s) => s.description).map((s) => [s.name, { description: s.description }]),
145
+ const liveServer = open.servers.find((s) => s.name === 'live')
146
+ const addresses = environmentsFromServers(
147
+ [
148
+ ...(live ? [{ name: 'live', url: live, description: liveServer?.description }] : []),
149
+ ...open.servers.filter((s) => s.name !== 'live'),
150
+ ],
151
+ 'baseUrl',
145
152
  )
153
+ // a sign-in address the document gave relative to its server needs the address the person typed
154
+ const absolute = (value: string) => {
155
+ if (/^https?:\/\//i.test(value) || !v.baseUrl) return value
156
+ try {
157
+ return new URL(value, `${v.baseUrl.replace(/\/+$/, '')}/`).toString()
158
+ } catch {
159
+ return value
160
+ }
161
+ }
162
+ const vars = {
163
+ ...addresses.vars,
164
+ ...Object.fromEntries(Object.entries(open.authVars).map(([k, x]) => [k, absolute(x)])),
165
+ }
166
+ const environmentSettings: Record<string, { description?: string; vars?: Record<string, string> }> =
167
+ {
168
+ ...addresses.environments,
169
+ }
170
+ for (const [name, evars] of Object.entries(open.authEnvironmentVars))
171
+ environmentSettings[name] = {
172
+ ...environmentSettings[name],
173
+ vars: { ...environmentSettings[name]?.vars, ...evars },
174
+ }
175
+ /** Where environments made in this browser are kept: per spec address, or for the tab for an upload. */
176
+ export const environmentStore: { scope: string; session: boolean } | null = v.source
177
+ ? {
178
+ scope: v.source.kind === 'url' ? v.source.url : `upload:${service}`,
179
+ session: v.source.kind !== 'url',
180
+ }
181
+ : null
146
182
  export const loadConfig = () =>
147
183
  Promise.resolve({
148
184
  default: {
149
185
  project: service,
150
186
  secrets: open.secrets,
151
187
  auth: open.auth,
152
- ...(Object.keys(described).length ? { environments: described } : {}),
188
+ ...(Object.keys(vars).length ? { vars } : {}),
189
+ ...(Object.keys(environmentSettings).length ? { environments: environmentSettings } : {}),
153
190
  // one locale, so the header offers no locale choice
154
191
  faker: { default: 'en', locales: { en: ['en', 'base'] } },
155
192
  services: {
156
193
  [service]: {
157
194
  spec: '',
158
- baseUrl,
195
+ // a document that gives no address at all has no live environment either
196
+ baseUrl: live || open.servers.length ? addresses.baseUrl : {},
159
197
  ...(open.defaultProfile ? { auth: open.defaultProfile } : {}),
160
198
  },
161
199
  },
@@ -113,8 +113,14 @@ async function open(id: number, source: Source, signal: AbortSignal): Promise<Op
113
113
  ]),
114
114
  )
115
115
  const sourceUrl = source.kind === 'url' ? source.url : undefined
116
- const { auth, secrets, defaultProfile } = authFromSpec(doc, sourceUrl)
117
116
  const { servers, needsBaseUrl, omitted } = openApiServers(doc, sourceUrl ?? name ?? '')
117
+ const {
118
+ auth,
119
+ secrets,
120
+ defaultProfile,
121
+ vars: authVars,
122
+ environmentVars: authEnvironmentVars,
123
+ } = authFromSpec(doc, sourceUrl, servers)
118
124
  const baseUrl = servers.find((s) => s.name === 'live')?.url
119
125
  return {
120
126
  service,
@@ -125,6 +131,8 @@ async function open(id: number, source: Source, signal: AbortSignal): Promise<Op
125
131
  auth,
126
132
  secrets,
127
133
  defaultProfile,
134
+ authVars,
135
+ authEnvironmentVars,
128
136
  baseUrl,
129
137
  servers,
130
138
  needsBaseUrl,
package/src/virtual.d.ts CHANGED
@@ -6,6 +6,8 @@ declare module 'virtual:specbook/registry' {
6
6
  source?: () => Promise<string>
7
7
  }
8
8
  export const mode: 'dev' | 'static'
9
+ /** A build that publishes only the operations the project's requests and flows use. */
10
+ export const minimal: boolean | undefined
9
11
  export const project: { root: string; outDir: string; requestsDir: string }
10
12
  export const manifests: Record<
11
13
  string,
@@ -28,7 +30,13 @@ declare module 'virtual:specbook/registry' {
28
30
  }[]
29
31
  }
30
32
  >
33
+ /** Fetches the manifests of the named services (all when none are named) into `manifests`. A build starts with it empty. */
34
+ export const loadManifests: (services?: string[]) => Promise<void>
31
35
  export const requests: Entry[]
36
+ /** Which `service/Operation` each request file is for, read from its text (no import), by project-relative file. */
37
+ export const requestMeta: Record<string, string>
38
+ /** Request files whose text does not say; these are imported to be listed. */
39
+ export const unresolvedRequests: string[]
32
40
  export const sequences: Entry[]
33
41
  /** Sequence headers read from the `*.seq.ts` text (no import), keyed by id. */
34
42
  export const sequenceMeta: Record<
@@ -1,37 +0,0 @@
1
- import{c as e,r as t}from"./registry-ChKCFBt1.js";import{a as n,d as r,f as i,g as a,h as o,m as s,p as c,u as l,v as u}from"./panel-C8Ve3LeS.js";import{i as d}from"./mount-CGL2tOpN.js";import{C as f,D as p,E as m,O as h,S as g,T as _,_ as v,a as y,b,c as x,d as S,f as C,g as w,h as T,i as E,l as D,m as O,n as ee,o as k,p as A,r as j,s as M,u as N,v as P,w as te,x as F,y as I}from"./main-38QGGpNT.js";var ne=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function L(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:ne(t),enabled:!0})))}function R(e){let t={};for(let{key:n,value:r,enabled:i}of e){if(!i||n===``)continue;let e=t[n];t[n]=e===void 0?r:[...Array.isArray(e)?e:[e],r]}return t}function re(e){return typeof e!=`object`||!e?[]:I(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var ie=/[^[\]]+|\[\]/g;function ae(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?ae(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?ae(o,i,n):o===void 0?n:[...[].concat(o),n],a}function oe(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=ae(t,n.match(ie)??[n],a&&b(a)?a:r));return t}var se=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,ce=e=>new RegExp(se.source).test(e),le=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function ue(e){let t=[],n=0;for(let r of e.matchAll(se))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?le(r[1]):`SESSION_${le(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var de=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${fe(e)}`);return t.length?`?${t.join(`&`)}`:``};function fe(e){return ue(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function z(e){if(b(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var pe=e=>e.name??e.file??`file`,me=e=>`'${e.replace(/'/g,`'\\''`)}'`;function B(e){return ce(e)?`"${ue(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:me(e)}function he(e){let t=e.encoding??`json`,n=[B(`${e.url}${de(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${B(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of I(o,e.formArrays))s.push(`--data-urlencode ${B(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(z(n)?s.push(`-F ${B(`${e}=@${pe(n)}`)}`):s.push(`-F ${B(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${B(`@${z(o)?pe(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=z(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${B(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${B(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
2
- `)}`}var ge=/^[A-Za-z_$][\w$]*$/;function V(e){return ce(e)?`\`${ue(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var H=e=>ge.test(e)?e:V(e);function _e(e,t){if(e==null)return`null`;if(typeof e==`string`)return V(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${_e(e,n)},`).join(`
3
- `)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${H(e)}: ${_e(t,n)},`).join(`
4
- `)}\n${t}}`}function ve(e){let t=e.encoding??`json`,n=e.method.toUpperCase(),r={...e.headers??{}},i=e=>Object.keys(r).some(t=>t.toLowerCase()===e),a=e.body,o=a!==void 0&&a!==``&&t!==`none`,s=[],c,l=!1;if(o){if(t===`json`||t===`graphql`)c=`JSON.stringify(${_e(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=I(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${_e(Object.fromEntries(t),` `)})`:`new URLSearchParams(${_e(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(z(n)){l=!0;let t=pe(n);s.push(`form.append(${V(e)}, await openAsBlob(${V(t)}), ${V(t)})`)}else s.push(`form.append(${V(e)}, ${V(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${V(z(a)?pe(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=z(a)&&a.type?a.type:`application/octet-stream`)):(c=V(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${de(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${V(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${H(e)}: ${V(t)},`).join(`
5
- `)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${V(u)})`:`const res = await fetch(${V(u)}, {\n${d.join(`
6
- `)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
7
- `)}function ye(e,t){return e===`curl`?he(t):ve(t)}var be=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],U=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`);function W(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function xe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
8
- `).split(`
9
- `),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${W(U(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${W(U(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${U(r.join(`
10
- `))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${W(U(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${W(U(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function Se(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function Ce(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function we(e){return e?W(U(e)):``}function G(e,t=300){let n=Ce(e);if(!n)return``;let r=Se(n);return r.length>t?U(`${r.slice(0,t-1).trimEnd()}…`):we(n)}var Te=/^\s*\{\{[^}]+\}\}\s*$/,Ee=e=>typeof e==`string`&&Te.test(e);function De(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Oe=[`title`,`description`,`default`,`examples`,`deprecated`];function K(e,t){let n={...e};for(let e of Oe)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function ke(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=K(r,n)}return n}function q(e,t,n=0){let r=ke(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!De(e));if(e.length===1||e.length>1)return q(K(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(K(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=q(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of Oe)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function J(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function Ae(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function je(e,t=120){if(!e)return;let n=e.split(/\n+/)[0],r=(n.match(/^.*?[.!?](\s|$)/)?.[0]?.trim()??n).replace(/\s+/g,` `);return r.length>t?`${r.slice(0,t-1)}…`:r}function Me(e,t){let n=q(e,t),r=new Set(n.required??[]);return Object.entries(n.properties??{}).map(([e,t])=>({name:e,schema:t,required:r.has(e)}))}function Ne(e,t,n){let r=q(e,n);if(typeof t==`number`)return r.items;if(r.properties?.[t])return r.properties[t];if(r.additionalProperties&&typeof r.additionalProperties==`object`)return r.additionalProperties}var Pe=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Fe(e,t,n){let r=ke(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!De(e));if(!i?.length)return q(r,n);let a=Pe(t);return q(K(i.find(e=>{let t=J(q(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Ie(e,t,n,r={},i=``,a=0){if(!t||a>12||Ee(e))return[];let o=Fe(t,e,n),s=[],c=i||`(root)`,l=Array.isArray(o.type)&&o.type.includes(`null`);if(e===null)return!l&&J(o)!==`null`&&J(o)!==`unknown`&&o.nullable!==!0&&s.push({path:c,kind:`type`,message:`expected ${J(o)}, got null`}),s;let u=J(o),d=Pe(e);switch(u){case`object`:{if(d!==`object`)return[{path:c,kind:`type`,message:`expected object, got ${d}`}];let t=e,l=o.properties??{};for(let e of o.required??[])e in t||s.push({path:i?`${i}.${e}`:e,kind:`required`,message:`required field is missing`});for(let[e,c]of Object.entries(t)){let t=i?`${i}.${e}`:e;l[e]?s.push(...Ie(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ie(c,o.additionalProperties,n,r,t,a+1)):r.reportExtra&&o.additionalProperties!==!0&&Object.keys(l).length>0&&s.push({path:t,kind:`extra`,message:`not in the spec`})}return s}case`array`:return d===`array`?(e.forEach((e,t)=>{s.push(...Ie(e,o.items,n,r,`${i}[${t}]`,a+1))}),s):[{path:c,kind:`type`,message:`expected array, got ${d}`}];case`string`:return d===`string`?(o.enum&&!o.enum.includes(e)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s):[{path:c,kind:`type`,message:`expected string, got ${d}`}];case`integer`:case`number`:{if(d!==`number`)return[{path:c,kind:`type`,message:`expected ${u}, got ${d}`}];let t=e;return u===`integer`&&!Number.isInteger(t)&&s.push({path:c,kind:`type`,message:`expected an integer`}),o.minimum!==void 0&&t<o.minimum&&s.push({path:c,kind:`range`,message:`must be ≥ ${o.minimum}`}),o.maximum!==void 0&&t>o.maximum&&s.push({path:c,kind:`range`,message:`must be ≤ ${o.maximum}`}),o.enum&&!o.enum.includes(t)&&s.push({path:c,kind:`enum`,message:`must be one of: ${o.enum.join(` · `)}`}),s}case`boolean`:return d===`boolean`?[]:[{path:c,kind:`type`,message:`expected boolean, got ${d}`}];default:return[]}}var Le=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Re(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
11
- `)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
12
- `;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function ze(e,t,n){let r=e;for(let e of t){if(!r)return;r=Ne(r,e,n)}return r}var Be={200:`OK`,201:`Created`,202:`Accepted`,204:`No content`,301:`Moved`,304:`Not modified`,400:`Bad request`,401:`Unauthorized`,402:`Payment required`,403:`Forbidden`,404:`Not found`,405:`Invalid input`,409:`Conflict`,410:`Gone`,412:`Precondition failed`,422:`Invalid input`,429:`Too many requests`,500:`Server error`,502:`Bad gateway`,503:`Unavailable`},Ve=e=>Be[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),He=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,Ue=new Set([`path`,`query`,`headers`,`data`]),We=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function Ge(e,t){return[e,...We(t)].join(`.`)}function Ke(e){let t=We(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&Ue.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var qe=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`);function Je(e){let t=new Map;if(!e)return{intro:e,notes:t};let n=[];for(let r of e.split(/(?=<h[1-6][ >])/)){let e=/^<h([1-6])[^>]*>\s*<code>([^<]+)<\/code>\s*<\/h\1>/.exec(r),i=e?Ke(qe(e[2])):void 0;if(e&&i){let n=t.get(i),a=r.slice(e[0].length);t.set(i,n?n+a:a)}else n.push(r)}return{intro:n.join(``),notes:t}}var Ye=60;function Xe(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function Ze(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Me(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:Xe(e,t),required:a.required,description:Ae(e),enum:Array.isArray(e.enum)&&e.enum.length<=10?e.enum.map(String):void 0});let s=J(e)===`array`?q(e.items,t):e;J(s)===`object`&&i.push(...Ze(s,t,n+1,o))}return i}function Qe({schema:e,defs:t,section:r=`data`,notes:i}){let a=Ze(e,t);return a.length===0?null:n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`Field`}),n(`th`,{children:`Type`}),n(`th`,{children:`Description`})]})}),n(`tbody`,{children:[a.slice(0,Ye).map(e=>n(`tr`,{children:[n(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[n(`code`,{children:e.name.split(`.`).pop()}),e.required&&n(`span`,{class:`req`,title:`required`,children:`*`})]}),n(`td`,{children:n(`span`,{class:`chip`,children:e.type})}),n(`td`,{children:[n(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:G(e.description,220)}}),i?.get(Ge(r,e.name))&&n(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(Ge(r,e.name))}}),e.enum&&n(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>n(`code`,{children:e}))]})]})]})),a.length>Ye&&n(`tr`,{children:n(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-Ye,` more fields in the spec`]})})]})]})}var $e={intro:``,notes:new Map,replace:!1,found:!1};function et(e){let[t,n]=o(),[i,a]=o(!1),c=y.docs.find(t=>t.operation===e);return r(()=>{let e=!0;return n(void 0),a(!c),c?.load().then(t=>e&&n(t)).catch(()=>{}).finally(()=>e&&a(!0)),()=>{e=!1}},[e,c]),s(()=>!c||t===void 0?{...$e,loaded:i}:{...Je(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var tt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],nt=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function rt(e,t,n){return Promise.all([nt(y.operationDocs[e]?.().then(e=>e.default)),nt(y.schemas[e]?.().then(e=>e.default)),nt(y.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>nt(y.docs.find(t=>t.requestFile===e)?.load())))]).then(([e,t,r,i])=>({long:e,req:t,defs:r,saved:Object.fromEntries(n.flatMap((e,t)=>i[t]?[[e,i[t]]]:[]))}))}function it({variant:e,html:t}){return t?n(`section`,{class:`saved-note-doc`,children:[n(`h2`,{children:[`Saved request `,n(`code`,{children:e.name})]}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]}):null}function at({service:e,op:t,variants:i=[],onTry:a}){let s=`${e}/${t.id}`,[c,l]=o(),d=i.map(e=>e.file).join(`
13
- `);r(()=>{let t=!0;return l(void 0),rt(s,e,d?d.split(`
14
- `):[]).then(e=>t&&l(e)),()=>{t=!1}},[s,e,d]);let f=et(s),p=!!c&&f.loaded,{long:m,req:h,defs:g}=c??{saved:{}},_=h?q(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return n(`article`,{class:`doc`,"data-op":s,children:[n(`div`,{class:`doc-intro`,children:[n(`span`,{class:`method ${t.method}`,children:t.method}),` `,n(`code`,{children:t.path}),n(`span`,{class:`spacer`}),n(`button`,{type:`button`,class:`btn primary`,onClick:()=>a(),children:`Try it`})]}),p&&n(u,{children:[!(f.found&&f.replace)&&m?.description&&n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:xe(m.description)}}),f.intro&&n(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>n(it,{variant:e,html:c?.saved[e.file]},e.file)),tt.map(([e,t])=>v(e)?n(`section`,{children:[n(`h2`,{children:[t,` parameters`]}),n(Qe,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&n(`section`,{children:[n(`h2`,{children:`Request body`}),n(Qe,{schema:y,defs:g,section:`data`,notes:f.notes})]}),t.statuses.length>0&&n(`section`,{children:[n(`h2`,{children:`Responses`}),n(`ul`,{class:`statuses`,children:t.statuses.map(e=>n(`li`,{children:[n(`span`,{class:`state-badge ${He(e)}`,children:e}),` `,Ve(e)]}))})]}),(m?.examples.length??0)>1&&n(`section`,{children:[n(`h2`,{children:`Examples`}),n(`ul`,{class:`examples`,children:m?.examples.map(e=>n(`li`,{children:n(`button`,{type:`button`,class:`link`,onClick:()=>a(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var ot=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function st({title:e,subtitle:t,flush:a,modal:o=!0,onPrev:s,onNext:l,onClose:d,children:p}){let m=c(null);return r(()=>{let e=m.current?.getRootNode()?.activeElement;return o&&m.current?.focus(),()=>e?.focus?.()},[o]),r(()=>{let e=m.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=r+i*.2;(o>r+i*.4||o<r)&&(t.scrollTop+=o-s)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s);c&&r?.box!==c&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),i(()=>{let e=e=>{if(e.key===`Escape`&&d(),e.key!==`Tab`||!o||!m.current)return;let t=[...m.current.querySelectorAll(ot)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=m.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===m.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[d,o]),n(u,{children:[o&&n(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:d}),n(`section`,{class:`panel ${o?``:`docked`}`,part:`panel`,"aria-label":e,"aria-modal":o?!0:void 0,role:o?`dialog`:`complementary`,tabIndex:-1,ref:m,children:[n(`header`,{class:`panel-head`,part:`header`,children:[n(`div`,{class:`panel-title`,children:[n(`h2`,{children:e}),t&&n(`div`,{class:`muted small`,children:t})]}),n(`span`,{class:`spacer`}),o&&f.value.length>1&&n(`label`,{class:`row`,children:[n(`span`,{class:`muted`,children:`Environment`}),n(`select`,{value:F.value,onChange:e=>F.value=e.target.value,children:f.value.map(e=>n(`option`,{value:e,title:g.value[e],children:e}))})]}),(s||l)&&n(`span`,{class:`stepper`,children:[n(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!s,onClick:s,children:`↑`}),n(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!l,onClick:l,children:`↓`})]}),n(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:d,children:`×`})]}),n(`div`,{class:`panel-body ${a?`flush`:``}`,children:p})]})]})}function ct(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:ze(e,i,t);if(!a)return;let o=q(a,t);if(n.length===0){let e=typeof o.description==`string`?o.description.trim():``;return e?{path:typeof o.title==`string`&&o.title.trim()?o.title.trim():`body`,type:J(o),required:!1,description:e,deprecated:o.deprecated===!0||void 0}:void 0}let s=n[n.length-1],c=ze(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Le(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Me(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:Ae(o),parent:c?Ae(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function lt(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function ut(e,t,n,r){let i=e&&t?.get(Ge(n,r));return e&&i?{...e,note:i}:e}var dt={},ft=Symbol(),pt=Symbol(),mt=e=>typeof e==`string`?ht[e]:e,ht={plain:dt,plaintext:dt,text:dt,txt:dt},gt=(e,t)=>(t[pt]||_t)(e,t),_t=(e,t)=>{for(var n=[e],r,i=[],a=0;r=mt(t[ft]);)delete t[ft],Object.assign(t,r);for(wt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},vt=(e,t,n)=>e.replace(/&/g,`&amp;`).replace(t,n),yt=`</span>`,bt=``,xt=``,St=e=>{for(var t=``,n,r=0;n=e[r++];)t+=Ct(n);return t},Ct=e=>{if(e instanceof Tt){var{type:t,alias:n,content:r}=e,i=bt,a=xt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;xt+=yt,bt+=o;var s=Ct(r);return bt=i,xt=a,o+s+yt}return typeof e==`string`?(e=vt(e,/</g,`&lt;`),xt&&e.includes(`
15
- `)?e.replace(/\n/g,xt+`
16
- `+bt):e):St(e)},wt=(e,t,n,r,i)=>{for(var a in t)if(t[a])for(var o=0,s=t[a],c,l=Array.isArray(s)?s:[s];c=l[o];o++){if(i&&i[0]==a&&i[1]==o)return;for(var u=c.pattern||c,d=mt(c.inside),f=c.lookbehind,p=u.global,m=c.alias,h=n,g=r;h&&(!i||g<i[2]);g+=h[0].length,h=h[1]){var _=h[0],v=0,y;if(!(_ instanceof Tt)){if(u.lastIndex=p?g:0,y=u.exec(p?e:_),!y&&p)break;if(y&&y[0]){var b=f&&y[1]?y[1].length:0,x=y.index+b,S=y[0].slice(b),C=x+S.length,w,s;if(p){for(;s=g+h[0].length,x>=s;h=h[1],g=s);if(h[0]instanceof Tt)continue;for(w=h,s=g;(s+=w[0].length)<C;w=w[1],v++);_=e.slice(g,s),x-=g,C-=g}for(var T=_.slice(C),E=g+_.length,D=new Tt(a,d?gt(S,d):S,S,m),O=h,ee=0,k;O=O[1],ee++<v;);T&&(!O||O[0]instanceof Tt?O=[T,O]:O[0]=T+O[0]),g+=x,h[0]=x?_.slice(0,x):D,x?h=h[1]=[D,O]:h[1]=O,v&&(wt(e,t,h,g,k=[a,o,E]),E=k[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Tt(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Et=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Nt(),m=p.firstChild,h=m.children,g=h[0],_=g.firstChild,v={language:`text`,value:o},y=new Set(n),b={},x=e=>{Object.assign(v,e);let t=o!=(o=e.value??o),n=r!=(r=v.language);d=!!v.readOnly,p.style.tabSize=v.tabSize||2,_.inputMode=d?`none`:``,_.setAttribute(`aria-readonly`,d),w(),C(),t&&(c||_.remove(),_.value=o,_.selectionEnd=0,c||g.prepend(_)),(t||n)&&S()},S=()=>{u=gt(o=_.value,ht[r]||{}),O(`tokenize`,u,r,o);let e=St(u).split(`
17
- `),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
18
- `;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),ee(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(k,v),e&&y.add(t)):(t(k,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(k,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,k)},ee=e=>{if(e||l){let e=T(),t=h[s=jt(o,0,e[e[2]<`f`?0:1])];t!=a&&(a?.classList.remove(`active-line`),t.classList.add(`active-line`),a=t),w(e),O(`selectionChange`,e,o)}},k={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Pt=null,c=!1,w()}),Y(_,`focus`,()=>{Pt=ee,c=!0,w()}),Y(_,`selectionchange`,e=>{ee(!e.isTrusted),X(e)}),At(e)?.append(p),t&&x(t),k},Dt=`u`>typeof window?document:null,Ot=Dt?.createElement(`div`),kt=(e,t)=>(Ot&&(Ot.innerHTML=e,t=Ot.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),At=e=>typeof e==`string`?Dt.querySelector(e):e,jt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
19
- `,t)+1)&&t<=n;r++);return r},Mt={},Nt=kt(`<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>`),X=e=>{e.preventDefault(),e.stopImmediatePropagation()},Pt;Dt&&Y(Dt,`selectionchange`,()=>Pt?.());var Ft=(e,t,n=0)=>{let r=e.container.style;r.setProperty(`--_sp`,`var(--pce-scroll-padding, 2ch)`),r.scrollPaddingBlock=`calc(var(--_sp) + ${n}px) calc(var(--_sp) + ${Zt&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},It=(e,t)=>t?e.lastIndexOf(`
20
- `,t-1)+1:0,Lt=(e,t)=>(t=e.indexOf(`
21
- `,t))+1?t:e.length,Rt=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),zt=(e,t,n,r)=>Rt(e.textarea,t,n,r),Bt=(e,t)=>parseFloat(getComputedStyle(e)[t]),Vt=(e,t)=>{let n=t.getBoundingClientRect(),r=e.lines[0].getBoundingClientRect();return{top:n.y-r.y,bottom:r.bottom-n.bottom,left:n.x-r.x,right:r.right-n.right,height:n.height}},Ht=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var Ut,Wt=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),Gt=(e,t)=>e.slice(It(e,t),t),Kt=(e,t,n=t)=>[e.slice(t=It(e,t),n=Lt(e,n)).split(`
22
- `),t,n],qt=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[jt(a,0,i)],s=Dt.createTreeWalker(o,5),c=s.lastChild(),l=Lt(a,i)+1-i-c.length;for(;-l<=r&&(c=s.previousNode());)if(!c.lastChild&&(l-=c.length||0,l<=n)){for(;c!=o;c=c.parentNode)if(c.matches?.(t))return c}},Jt=(e,t)=>qt(e,`[class*=language-]`,0,0,t)?.className.match(/language-(\S*)/)[1]||e.options.language,Z=(e,t,n,r,i,a)=>{if(e.options.readOnly)return;Ut=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=Zt&&!s[r??Ut[1]]&&/\n$/.test(t)&&/^$|\n$/.test(s),l;e.focused||o.focus(),n!=null&&o.setSelectionRange(n,r),i!=null&&(l=e.on(`update`,()=>{o.setSelectionRange(i,a??i,Ut[2]),l()})),Qt||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),Zt||Qt?(c&&(o.selectionEnd--,t=t.slice(0,-1)),Qt&&(t+=`
23
- `),Dt.execCommand(t?`insertHTML`:`delete`,!1,vt(t,/</g,`&lt;`)),c&&o.selectionStart++):Dt.execCommand(t?`insertText`:`delete`,!1,t),Ut=0},Yt=(e,t,n=t,r)=>{let i=e.textarea,a=Rt(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},Xt=Dt?navigator.userAgent:``,Q=Dt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,Zt=/Chrome\//.test(Xt),Qt=!Zt&&/AppleWebKit\//.test(Xt),$t=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,en=(e,t)=>e.lines[0].append(t),tn=kt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),nn=kt(`<span> `),rn=kt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),an=(e,t,n=!0)=>{let r=rn(),i=r.style,a=r.firstChild;return r.append(t),(n?t:a).style.flexShrink=0,[t=>{let n=e.extensions.cursor?.getPosition();if(n){r.parentNode||en(e,r),a.style.width=(e.options.rtl?n.right:n.left)+`px`;let o=n.top,s=n.bottom,c=!t==o>s&&(t?o:s)<r.clientHeight?!t:t,l=n.height+(c?s:o)+`px`;i.bottom=c?l:`auto`,i.top=c?`auto`:l}},()=>r.remove()]};window.ResizeObserver;var on=(e,t,n)=>{let r=e.childNodes,i=r.length-1,a=0,o=0,s=t.length;for(;o<s;)o>=i&&r[o].before(``,nn()),Ht(r[o],n.slice(a,a=t[o++])),Ht(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();Ht(r[s],n.slice(a))},sn=0,cn=kt(`<div class="pce-ac-wrapper pce-ac-top"><div class=pce-ac-tooltip><ul role=listbox></ul></div><div class=pce-ac-docs tabindex=-1><button class=pce-ac-close tabindex=-1 title=Close></button><button class=pce-ac-toggle tabindex=-1 title="Read More"></button><div class=pce-ac-content>`),ln=kt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),un={},dn=(e,t)=>{e.forEach(e=>un[e]=t)},fn=e=>{let t=(n,r)=>{let i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=n.container,T=n.textarea,E=n.getSelection,D=cn(),O=tn(),[ee,k]=an(n,D),[A,j]=D.children,[M,N,P]=j.children,te=A.firstChild,F=te.id=`pce-ac-`+sn++,I=te.children,ne=[],L=()=>{i&&=(k(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&j.remove(),!1)},R=()=>{f=Bt(I[0],`height`)},re=e=>{let t=o[e+d],[n,r,i]=I[e].children,a=t[4],s=a.icon||`variable`;on(r,t[1],a.label),Ht(i.firstChild.firstChild,a.detail||``),ne[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${ne[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),I[e].setAttribute(`aria-posinset`,e+d)},ie=()=>{R();let e=A.scrollTop,t=f*c,n=f*(c+1)-A.clientHeight;A.scrollTop=e>t?t:e<n?n:e,se(),ae()},ae=()=>{let e=l;l=I[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),N.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(N),b=!b,he()):j.remove()):e&&T.removeAttribute(`aria-activedescendant`)},oe=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,ie()},se=()=>{let e=Math.min(Math.floor(A.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)re(e++);te.style.paddingTop=d*f+`px`},ce=e=>le(o[e][4],o[e][2],o[e][3]),le=t.insertCompletion=(e,t,i=t)=>{if(r.readOnly)return;let{label:a,tabStops:o=[],insert:s}=e,c=o.length;if(o=o.map(e=>e+t),s){let e=`
24
- `+Gt(n.value,u).match(/\s*/)[0],i=r.insertSpaces==0?` `:` `.repeat(r.tabSize||2),a=o.slice();s=s.replace(/\n| /g,(n,r)=>{let s=n==` `?i:e,l=s.length-1,u=0;for(;u<c;)a[u]>r+t&&(o[u]+=l),u++;return s})}else s=a;c%2&&(o[c]=o[c-1]),Z(n,s,t,i,o[0],o[1]),c>2?(p||en(n,O),p=o,m=0,g=n.value.length,z(),h=E(),ue()):n.extensions.cursor?.scrollIntoView()},ue=()=>{O.children[m/2].scrollIntoView({block:`nearest`})},de=e=>{m+=e,Yt(n,p[m],p[m+1]),ue()},fe=()=>{O.remove(),p=null},z=()=>{let e=[],t=0;for(;t<p.length;)e[t/2]=[p[t++],p[t++]];e.sort((e,t)=>e[0]-t[0]),on(O,e.flat(),n.value)},pe=()=>{let e=w.clientWidth,t=Math.abs(w.scrollLeft),i=n.extensions.cursor.getPosition(),a=r.rtl?i.right:i.left,o=Bt(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},me=()=>{D.className=`pce-ac-wrapper pce-ac-${pe()}`},B=()=>{let e=o[c][4];e.renderDocs&&(j.parentNode||D.append(j),y!=e&&(y=e,P.textContent=``,P.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,F+`d`))},he=()=>{b?j.remove():B(),b=!b},ge=t.startQuery=t=>{let[a,l,p]=E(),m=Jt(n,u=p<`f`?a:l),h=un[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=Gt(r,u),p=r.slice(0,u),_=e.filter;if(x={before:p,lineBefore:a,language:m,explicit:!!t,pos:u},Object.assign(x,h.context?.(x,n)),o=[],h.sources.forEach(e=>{let t=e(x,n),r=t?.from;t?.options.forEach(e=>{let n=_(p.slice(e.from??r),e.label);n&&(n[0]+=e.boost||0,n.push(r,t.to??l,e),o.push(n))})}),o[0]){o.sort((e,t)=>t[0]-e[0]||e[4].label.localeCompare(t[4].label)),s=o.length,c=d=0;for(let e=0,t=s<13?s:13;e<t;)I[e].setAttribute(`aria-setsize`,s),re(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);j.style.maxWidth=A.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}te.style.paddingTop=``,te.style.height=f?f*s+`px`:1.4*s+`em`,A.scrollTop=0,ae(),i=!0,ee(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,F),T.setAttribute(`aria-haspopup`,`listbox`)}else L()}else L()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)te.append(ln()),I[e].id=F+`-`+e++;Y(A,`scroll`,()=>{R(),se()||ae()}),n.on(`update`,()=>{if(p){let e=n.value,t=g-(g=e.length),[r,i]=h,a=0,o=p.length,s=p[m],c=p[m+1];if(r<p[m]||i>c)fe();else{for(_&&i++,i<=c&&(p[m+1]-=t),i<=s&&t>0&&(p[m]-=t);a<o;a+=2)a!=m&&p[a]>=c&&(p[a]=Math.max(p[a]-t,p[m+1]),p[a+1]=Math.max(p[a+1]-t,p[m+1]));z()}_=!1,h=E()}}),n.on(`selectionChange`,([e,t])=>{if(p){if(e<p[m]||t>p[m+1]){for(let n=0;n<p.length;n+=2)if(e>=p[n]&&t<=p[n+1]){m=n;break}}(m+3>p.length||e<p[m]||t>p[m+1])&&fe()}a?(a=!1,ge()):(S!=e||C!=t)&&L(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!Ut&&l&&!l[1]&&o[c][4].commitChars?.includes(l)&&ce(c),p&&(h=E(),_=r&&n[13]==`F`&&h[0]==h[1]),a=!e.explicitOnly&&(a||s&&!Ut||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&L()}),Y(T,`keydown`,e=>{let t=e.key,n=$t(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?he():ge(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(oe(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(ce(c),L(),X(e)):t==`Escape`?(L(),X(e)):t.slice(0,4)==`Page`&&(R(),r=A.scrollTop,a=A.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),ie(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(de(-2),X(e)):(de(2),X(e)):!n&&t==`Escape`&&(fe(),X(e)))},!0),Y(te,`mousedown`,e=>{e.target!=N&&(ce([].indexOf.call(I,e.target.closest(`li`))+d),L()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&L()}),Y(w,`scroll`,()=>{i&&me()}),Y(M,`click`,he),Y(M,`mousedown`,X),Y(N,`click`,he),j.id=F+`d`,N.remove(),j.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},pn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return mn(e,t);let i=e.toLowerCase(),a=t.toLowerCase(),o=[],s=a.indexOf(i),c=0,l=0,u=0,d=0;for(;l<r;){let n=s>-1?l+s:a.indexOf(i[l],u),r=n>u;if(n<0)return;r&&(c-=800),(r||!d)&&(o[d]=n,d+=2),o[d-1]=u=n+1,e[l++]!=t[n]&&(c-=100)}return[r<n?c-100:c,o]},mn=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;let i=t.slice(0,r),a=i==e?0:e.toLowerCase()==i.toLowerCase()?-200:null;if(a!=null)return[e?r<n?a-100:a:0,[0,r]]},hn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Tn[e]||0;return t+`+`+r},gn=e=>{if(!Cn[48]){for(let e=48;e<91;e++)Cn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)Cn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=$t(e),r=Cn[e.keyCode],i=wn[e.keyCode],a=n>7,o=(Q&&n==12||t==`Dead`||t==`Unidentified`)&&(a&&i||r)||t.toLowerCase(),s=/\w\w| /.test(o.slice(0,2)),c=n&7,l=new Set([`${s||/\p{L}/u.test(o)?n:c}+${o}`]);return s||(c&&!(Q&&c==1)&&r?(l.add(n+`+`+r),a&&i&&l.add(c+`+`+i)):a&&l.add(n+`+`+o)),l},_n=new WeakMap,vn=(e,t,n)=>{let r=new Set,i;try{for(let a of gn(e)){i||=a;for(let i of t[a]||[])for(let t of i||[])if(!r.has(t)){if(t(n,e,a))return X(e),!0;r.add(t)}}}finally{t.any?.forEach(t=>t?.forEach(t=>t(n,e,i)))}},yn=e=>{let t=_n.get(e);return t||(_n.set(e,t={}),zt(e,`keydown`,n=>{vn(n,t,e)})),t},bn=(e,t,n,r)=>xn(yn(e),t,n,r),xn=(e,t,n,r=2)=>{let i=(e[t==`any`?t:hn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},Sn=Q?4:2,Cn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},wn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Tn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},En=!1,Dn=e=>e.search(/\S|$/),On=({options:{insertSpaces:e=!0,tabSize:t}})=>[e?` `:` `,e?t||2:1],$=e=>!e.options.readOnly&&!e.extensions.cursor?.scrollIntoView(),kn=(e,t,n,r,i,a,o)=>{let s=n.join(`
25
- `);if(s==t.join(`
26
- `))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+Dn((f<0?n:t)[0]),m=i-u.length+Dn(d>0?l:u),h=r-i+s.length+d,g=p>a?a:Math.max(p,a+f),_=o+r-i+s.length;Z(e,s,r,i,g,o<m?_+d:Math.max(m+h,_))},An=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=Kt(e.value,n,r),[s,c]=On(e);return kn(e,i,i.map(t?e=>e.slice(Dn(e)?c-Dn(e)%c:0):e=>e&&s.repeat(c-Dn(e)%c)+e),a,o,n,r),$(e)},jn=(e,t)=>{let[n,r]=On(e);return Z(e,n.repeat(r-(t-It(e.value,t))%r)),$(e)},Mn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=Lt(r,n[1]));let[i,a]=On(e),[o,s]=n,c=Mt[Jt(e,o)]?.autoIndent,l=Math.floor(Dn(Gt(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
27
- `+i.repeat(l+u)+(d?`
28
- `+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Nn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?It(i,n)-1:n,o=t?r:i.indexOf(`
29
- `,r)+1;if(a>-1&&o>0){let[s,c,l]=Kt(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
30
- `),c,l,n+d,r+d)}return $(e)},Pn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=Kt(i,n,r),c=a.join(`
31
- `),l=t?0:c.length+1;return Z(e,c+`
32
- `+c,o,s,n+l,r+l),$(e)},Fn=(e,t)=>(e.container.scrollBy(0,Bt(e.container,`lineHeight`)*(t?-1:1)),!0),In=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=Kt(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=Lt(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},Ln=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:It(i,n),o=Mt[Jt(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=Kt(i,n,r),f=l.length-1;if(t){if(c){let[t,a]=c,o=i.slice(n,r),s=i.slice(0,n).search(Wt(t)+` ?$`);s+1&&RegExp(`^ ?`+Wt(a)).test(i.slice(r))?Z(e,o,s,r+(i[r]==` `)+a.length,s,s+r-n):Z(e,`${t} ${o} ${a}`,n,r,n+t.length+1,r+t.length+1)}}else if(s){let t=Wt(s),a=RegExp(`^\\s*(${t} ?|$)`),o=RegExp(t+` ?`),c=!/\S/.test(i.slice(u,d));kn(e,l,l.map(!c&&l.every(e=>a.test(e))?e=>e.replace(o,``):e=>c||/\S/.test(e)?e.replace(/(?!\s)/,s+` `):e),u,d,n,r)}else if(c){let[t,i]=c,a=l[0],o=Dn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(Wt(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${Wt(i)}$`),``):l[f]+` `+i;let m=l.join(`
33
- `),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},Rn={Tab(e){if(!En){let[t,n]=e.getSelection();return t==n?jn(e,t):An(e)}},"8+Tab":e=>!En&&An(e,!0),"1+ArrowDown":e=>Nn(e),"1+ArrowUp":e=>Nn(e,!0),"9+ArrowDown":e=>Pn(e),"9+ArrowUp":e=>Pn(e,!0),Enter:e=>Mn(e),"8+Enter":e=>Mn(e),"Mod+Enter":e=>Mn(e,!0),"Mod+]":e=>An(e),"Mod+[":e=>An(e,!0),"8+Mod+k":In,"Mod+/":e=>Ln(e),"9+a":e=>Ln(e,!0),[Q?`10+m`:`2+m`]:()=>(En=!En,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Fn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Fn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var zn=Q?5:1;zn+``,zn+``,zn+``,zn+``;var Bn=(e,t=[`""`,`''`,"``",`()`,`[]`,`{}`],n=/([^$\w'"`]["'`]|.[[({])[.,:;\])}>\s]|.[[({]`/s)=>(r,i)=>{let a,o=r.inputCommandMap,s=navigator.clipboard,c=([e,t],[i,a],o,s)=>(e<t||!s&&n.test((o[t-1]||` `)+i+(o[t]||` `)))&&!Z(r,i+o.slice(e,t)+a,null,null,e+1,t+1),l=([e,t],n,i)=>e==t&&i[t]==n&&!Yt(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=Gt(a,e),s=i.tabSize||2,c=t.includes(a.slice(e-1,e+1)),l=/[^ ]/.test(o)?0:(o.length-1)%s+1;if((c||l>1)&&e==n)return Z(r,``,e-(c?1:l),e+c),$(r)}};o[`<`]=(e,t,n)=>c(t,`<>`,n,!0),t.forEach(([e,t])=>{let n=e==t;o[e]=(i,a,o)=>(n&&l(a,t,o)||c(a,e+t,o))&&$(r),n||(o[t]=(e,n,i)=>l(n,t,i)&&$(r))}),o[`>`]=(e,t,n)=>{let i=Mt[Jt(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},bn(r,`Backspace`,u),bn(r,`8+Backspace`,u);for(let t in e)bn(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>zt(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=Kt(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
34
- `,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},Vn=(e=999)=>{let t=0,n,r,i=!1,a,o,s,c,l,u,d=[],f=r=>{r>=e&&(r--,d.shift()),d.splice(t=r,e,[n.value,u(),u()])},p=e=>{d[e]&&(l.value=d[e][0],l.setSelectionRange(...d[e][e<t?2:1]),n.update(),n.extensions.cursor?.scrollIntoView(),t=e,r=!1)},m=(e,g)=>{e.extensions.history=m,n=e,u=e.getSelection,l||f(0),l=e.textarea,e.on(`selectionChange`,()=>{r=i,i=!1}),zt(e,`beforeinput`,e=>{let n=e.data,l=e.inputType,f=e.timeStamp;/history/.test(l)?(p(t+(l[7]==`U`?-1:1)),X(e)):(c=r&&(a==l||f-s<99&&l.slice(-4)==`Drop`)&&!Ut&&(n!=` `||o==n))||(d[t][2]=Ut||u()),i=!0,o=n,s=f,a=l}),zt(e,`input`,()=>f(t+!c)),zt(e,`keydown`,e=>{if(!g.readOnly){let n=$t(e),r=e.keyCode,i=n==Sn&&r==90,a=n==Sn+8&&r==90||!Q&&n==Sn&&r==89;i?(p(t-1),X(e)):a&&(p(t+1),X(e))}}),e.addExtensions({update(){e.value!=l.value&&h()}})},h=m.clear=()=>{f(0),r=!1};return m.has=e=>t+e in d,m.go=e=>p(t+e),m},Hn=kt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),Un=()=>{let e,t=Hn(),[n,r]=t.childNodes,[i,a]=r.childNodes,o=()=>{let r=e.getSelection(),i=e.value,o=e.lines[e.activeLine],s=r[r[2]<`f`?0:1];Ht(n,Gt(i,s)),Ht(a,i.slice(s,Lt(i,s))+`
35
- `),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Ft(e,i)},c=t=>{e=t,t.extensions.cursor=c,zt(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),Vt(e,i)),c.scrollIntoView=s,c.element=i,c};kt(`<div class=pce-cursor>`);var Wn=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,Gn=/\b(?:false|true)\b/,Kn=/\[]|\(\)|{}/,qn=/[([{][^)\]}]*$/,Jn=([e,t],n)=>Kn.test(n[e-1]+n[t]),Yn={line:`//`,block:[`/*`,`*/`]},Xn=(e=Yn,t=qn)=>({comments:e,autoIndent:[([e],n)=>t.test(Gt(n,e)),Jn]});Mt.json=Mt.json5=Mt.jsonp=Xn(),Mt.graphql=Xn({line:`#`}),ht.webmanifest=ht.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:Wn,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:Gn,null:{pattern:/\bnull\b/,alias:`keyword`}},ht.graphql={comment:/#.*/,description:{pattern:/(?:"""(?:[^"]|"(?!""))*"""|"(?:\\.|[^\\\n"])*")(?=\s*[a-z_])/gi,alias:`string`,inside:{"language-markdown":{pattern:/("(?!")|""")[^]+(?=\1)/,lookbehind:!0,inside:`md`}}},string:/"""[^]*?"""|"(?:\\.|[^\\\n"])*"/g,number:/(?:\B-|\b)\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,boolean:Gn,variable:/\$[a-z_]\w*/i,directive:{pattern:/@[a-z_]\w*/i,alias:`function`},"attr-name":/\b[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\\n"])*")*\))?:)/gi,"atom-input":{pattern:/\b[A-Z]\w*Input\b/,alias:`class-name`},scalar:/\b(?:Boolean|Float|ID|Int|String)\b/,constant:/\b[A-Z][A-Z_\d]*\b/,"class-name":{pattern:/(\b(?:enum|implements|interface|on|scalar|type|union)\s+|&\s*|:\s*|\[)[A-Z_]\w*/,lookbehind:!0},fragment:{pattern:/(\bfragment\s+|\.{3}\s*(?!on\b))(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-mutation":{pattern:/(\bmutation\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},"definition-query":{pattern:/(\bquery\s+)(?!\d)\w+/,lookbehind:!0,alias:`function`},keyword:/\b(?:directive|enum|extend|fragment|implements|input|interface|mutation|on|query|repeatable|scalar|schema|subscription|type|union)\b/,operator:/[&|!=]|\.{3}/,"property-query":/\w+(?=\s*\()/,object:/\w+(?=\s*\{)/,punctuation:/[()[\]{},:!=]/,property:/\w+/,[pt](e,t){for(var n=_t(e,t),r=n.filter(({type:e})=>e&&e!=`comment`&&e!=`scalar`),i=r.length,a=0,o=e=>{for(var t=0;t<e.length;t++)if(a+t==i||r[a+t].type!=e[t])return!0},s=(e,t)=>{for(var n=1,o=a;o<i;o++){var s=r[o],c=s.content;if(s.type==`punctuation`){if(e==c)n++;else if(t==c&&!--n)return o}}};a<i;){var c=r[a++];if(c.type==`keyword`&&c.content==`mutation`){var l=[];if(!o([`definition-mutation`,`punctuation`])&&r[a+1].content==`(`){a+=2;var u=s(`(`,`)`);if(!u)continue;for(;a<u;a++){var d=r[a];d.type==`variable`&&(d.alias=`variable-input`,l.push(d.content))}a=u+1}if(!o([`punctuation`,`property-query`])&&r[a].content==`{`&&(r[++a].alias=`property-mutation`,l[0])){var f=s(`{`,`}`);if(f)for(var p=a;p<f;p++){var m=r[p];m.type==`variable`&&l.indexOf(m.content)>=0&&(m.alias=`variable-input`)}}}}return n}};var Zn=new WeakMap;dn([`json`],{sources:[(e,t)=>{let n=Zn.get(t)?.(t.value,e.pos);return n?{from:n.from,to:n.to,options:n.options.map(e=>({...e,renderDocs:e.doc?()=>[e.doc]:void 0}))}:null}]});function Qn({value:e,language:t=`json`,readOnly:i,label:a,onChange:o,onLine:s,complete:l}){let u=c(null),d=c(void 0),f=c({onChange:o,onLine:s});f.current={onChange:o,onLine:s};let p=c(l);return p.current=l,r(()=>{let n=Et(u.current,{value:e,language:t,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},Bn(Rn),Vn(),...l?[Un(),fn({filter:pn})]:[]);return l&&Zn.set(n,(e,t)=>p.current?.(e,t)),n.textarea.setAttribute(`aria-label`,a),d.current=n,()=>n.remove()},[]),r(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),r(()=>{d.current?.setOptions({readOnly:i,language:t})},[i,t]),n(`div`,{class:`body-editor`,part:`editor`,ref:u})}var $n=/[\w$.+-]/;function er(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
36
- `;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&$n.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&$n.test(e[o]??``);)o++;let s=r();return c({mode:s?.t===`o`&&s.expectKey?`key`:`value`,from:a,to:o,inString:!1,prefix:e.slice(a,t),hasColon:!1});function c(e){if(n.length===0)return;let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=r===n.length-1;if(i.t===`o`){if(a&&e.mode===`key`)break;if(i.key===void 0)return;t.push(i.key)}else t.push(i.index)}let i=r();return{...e,path:t,existing:i?.t===`o`?i.keys:new Set}}}var tr=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),nr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function rr(e){let t=J(e);return t===`object`?{text:`{}`,stop:1}:t===`array`?{text:`[]`,stop:1}:t===`boolean`?{text:`false`,stop:5}:t===`number`||t===`integer`?{text:`0`,stop:1}:{text:`""`,stop:1}}function ir(e,t,n,r,i){if(!e)return;let a=er(r,i);if(!a)return;let o=ze(e,[...n,...a.path],t);if(!o)return;let s=q(o,t);if(a.mode===`key`){if(J(s)!==`object`&&!s.properties)return;let e=Me(s,t).filter(e=>!a.existing.has(e.name));if(e.length===0)return;let n=e.map(e=>{let n=q(e.schema,t),r=rr(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${nr(n,t)}${e.required?` · required`:``}`,icon:n.deprecated?`text`:`property`,insert:s,tabStops:a.hasColon?void 0:[o.length+r.stop],boost:e.required?10:0,from:a.inString?a.from+1:void 0,doc:tr(je(Ae(n),400))}});return{from:a.from,to:a.to,options:n}}let c=[],l=(e,t)=>{let n=JSON.stringify(e);c.push({label:typeof e==`string`?e:n,insert:n,icon:`enum`,detail:t,from:a.inString?a.from+1:void 0})};if(Array.isArray(s.enum))for(let e of s.enum)l(e);else if(J(s)===`boolean`)l(!0),l(!1);else return;return s.nullable===!0&&l(null,`null`),{from:a.from,to:a.to,options:c}}var ar=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function or(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:L(e.path),query:L(e.query),headers:L(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?re(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var sr=e=>Object.keys(e).length?e:void 0;function cr(e,t){let n;if(ar(e,t))n=oe(e.fields);else if(t===`binary`){let t=e.fields.find(e=>e.enabled);n=t?.file??t?.value}else if(e.body.trim()!==``){if(t===`text`)n=e.body;else try{n=JSON.parse(e.body)}catch(e){throw Error(`Invalid JSON: ${e.message}`)}}return{path:sr(R(e.path)),query:sr(R(e.query)),headers:sr(R(e.headers)),data:n}}var lr=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function ur(e,t,n,r=``){let i=e=>e.includes(`{{`)?e:encodeURIComponent(e),a=e.replace(/\{([^}]+)\}/g,(e,n)=>{let r=t.find(e=>e.key===n&&e.enabled&&e.value!==``);return r?i(r.value):e}),o=n.filter(e=>e.enabled&&e.key!==``).map(e=>`${i(e.key)}=${i(e.value)}`).join(`&`);return`${r.replace(/\/+$/,``)}${a}${o?`?${o}`:``}`}function dr({doc:e,hint:t}){return e?n(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[n(`div`,{class:`field-doc-head`,children:[n(`code`,{children:e.path}),n(`span`,{class:`chip`,children:e.type}),e.required&&n(`span`,{class:`chip req`,children:`required`}),e.deprecated&&n(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?n(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:xe(e.description)}}):e.note?null:n(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&n(u,{children:[` It is part of: `,e.parent]})]}),e.note&&n(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&n(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>n(`code`,{children:e})),e.enum.length>12&&n(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):n(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:t??`Put the cursor on a field to see what the API says about it.`})}function fr(e){try{let{query:t,variables:n,...r}=JSON.parse(e);return typeof t==`string`?{query:t,variables:n===void 0?``:JSON.stringify(n,null,2),rest:r}:void 0}catch{return}}function pr(e){let t;try{t=e.variables.trim()?JSON.parse(e.variables):void 0}catch{t=e.variables}return JSON.stringify({query:e.query,variables:t,...e.rest},null,2)}function mr({value:e,options:t,onChange:i,label:a,placeholder:s,onKeyDown:l,cell:u}){let[d,f]=o(!1),[p,m]=o(-1),[h,g]=o(),_=c(null),v=()=>{let e=_.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-8,n=t<160&&e.top>t;g({left:`${e.left}px`,width:`${Math.max(e.width,160)}px`,maxHeight:`${Math.min(240,(n?e.top:t)-4)}px`,...n?{bottom:`${innerHeight-e.top+2}px`}:{top:`${e.bottom+2}px`}})};r(()=>{if(!d)return;v();let e=e=>{e.target instanceof Node&&_.current?.contains(e.target)||f(!1)};return addEventListener(`scroll`,e,!0),addEventListener(`resize`,e),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,e)}},[d]),r(()=>{if(!d)return;let e=e=>{e.composedPath().includes(_.current)||f(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[d]);let y=e=>{i(e),f(!1),m(-1)};return n(`div`,{class:`combo`,ref:_,children:[n(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:s,"aria-label":a,"aria-expanded":d,role:`combobox`,autocomplete:`off`,onFocus:()=>f(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{d&&e.key===`ArrowDown`?(e.preventDefault(),m((p+1)%t.length)):d&&e.key===`ArrowUp`?(e.preventDefault(),m((p-1+t.length)%t.length)):d&&e.key===`Enter`&&p>=0?(e.preventDefault(),y(t[p])):e.key===`Escape`&&d?(e.stopPropagation(),f(!1)):((e.key===`Enter`||e.key===`Tab`)&&f(!1),l?.(e))}}),n(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${a} options`,onClick:()=>f(!d),children:`▾`}),d&&n(`div`,{class:`combo-list`,role:`listbox`,style:h,children:t.map((t,r)=>n(`button`,{type:`button`,role:`option`,"aria-selected":t===e,class:`${t===e?`on`:``} ${r===p?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>y(t),children:t}))})]})}var hr=`specbook:grid-cols`,gr={key:26,val:34},_r=10,vr=l(yr());function yr(){try{let e=JSON.parse(localStorage.getItem(hr)??`null`);if(e&&e.key>=_r&&e.val>=_r&&e.key+e.val<=90)return e}catch{}return gr}function br(e){let t=e??gr,n=Math.min(80,Math.max(_r,t.key)),r=Math.min(100-n-_r,Math.max(_r,t.val));vr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?localStorage.setItem(hr,JSON.stringify(vr.value)):localStorage.removeItem(hr)}catch{}}function xr(){return n(`colgroup`,{children:[n(`col`,{style:{width:`36px`}}),n(`col`,{style:{width:`${vr.value.key}%`}}),n(`col`,{style:{width:`${vr.value.val}%`}}),n(`col`,{}),n(`col`,{style:{width:`60px`}})]})}function Sr({which:e,table:t}){let r=t=>{let n=vr.value;br(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return n(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(vr.value[e]),"aria-valuemin":_r,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let n=t()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/n*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>br(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var Cr=1,wr=2;function Tr(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.search(/[=\t]|:\s/);return t<0?{key:e,value:``}:{key:e.slice(0,t).trim(),value:e.slice(t+1).trim()}})}var Er=({d:e})=>n(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:n(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Dr({title:e,rows:t,onChange:i,documented:a=[],docFor:o,fixed:s,bad:l,placeholder:d,bare:f}){let p=c(null),m=c(null),h=c(void 0),g=new Set(t.map(e=>e.key)),_=a.filter(e=>!g.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),v=[...t,..._],y=e=>a.find(t=>t.name===e),b=e=>y(e)?.doc??o?.(e);r(()=>{if(!h.current)return;let e=p.current?.querySelector(`[data-cell="${h.current}"]`);h.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let x=e=>!e.virtual||e.enabled||e.value!==``||e.file,S=e=>i(e.filter(x).map(({virtual:e,...t})=>t)),C=(e,t)=>S(v.map((n,r)=>r===e?{...n,...t}:n)),w=(e,t)=>p.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),T=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),w(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),w(e-1,t))},E=e=>{let t=v[e],n=b(t.key)?.enum??[],r=new Set(v.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...v];o.splice(e+1,0,a),h.current=`${o.filter(x).indexOf(a)}:${wr}`,S(o)},D=(e,n)=>{let r=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(r.trim()))return;e.preventDefault();let a=Tr(r).map(e=>({...e,enabled:!0})),o=[...t];o.splice(n,+(n<t.length&&!t[n]?.key),...a),i(o)},O=v.length;return n(`section`,{class:`grid`,"aria-label":e,ref:p,children:[!f&&n(`h3`,{children:e}),n(`table`,{ref:m,children:[n(xr,{}),n(`thead`,{children:n(`tr`,{children:[n(`th`,{class:`g-check`}),n(`th`,{class:`g-key`,children:[`Key`,n(Sr,{which:`key`,table:()=>m.current})]}),n(`th`,{class:`g-val`,children:[`Value`,n(Sr,{which:`val`,table:()=>m.current})]}),n(`th`,{class:`g-doc`,children:`Description`}),n(`th`,{class:`g-act`})]})}),n(`tbody`,{children:[v.map((e,t)=>{let r=b(e.key),i=y(e.key)?.file,a=s||e.virtual||y(e.key);return n(`tr`,{class:`${e.enabled?``:`off`} ${l===e.key?`bad`:``}`,children:[n(`td`,{class:`g-check`,children:n(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:s,onChange:e=>C(t,{enabled:e.target.checked})})}),n(`td`,{class:`g-key`,children:a?n(`span`,{class:`key`,children:[n(`code`,{children:e.key}),r?.required&&n(`span`,{class:`req`,title:`required`,children:`*`})]}):n(`input`,{class:`cell`,"data-cell":`${t}:${Cr}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>C(t,{key:e.target.value}),onKeyDown:T(t,Cr),onPaste:e=>D(e,t)})}),n(`td`,{class:`g-val`,children:i?n(`label`,{class:`file-cell`,children:[n(`input`,{type:`file`,"aria-label":`File for ${e.key}`,onChange:e=>{let n=e.target.files?.[0];n&&C(t,{file:n,value:n.name,enabled:!0})}}),n(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?n(mr,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${t}:${wr}`,placeholder:`value`,onKeyDown:T(t,wr),onChange:e=>C(t,{value:e,enabled:!0})}):n(`input`,{class:`cell`,"data-cell":`${t}:${wr}`,value:e.value,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>C(t,{value:e.target.value,enabled:!0}),onKeyDown:T(t,wr)})}),n(`td`,{class:`g-doc`,title:Se(r?.description),children:r&&n(u,{children:[n(`span`,{class:`chip`,children:r.type}),` `,n(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:G(r.description)}})]})}),n(`td`,{class:`g-act`,children:[!s&&e.key&&n(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>E(t),children:n(Er,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!s&&!e.virtual&&n(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>S(v.filter((e,n)=>n!==t)),children:n(Er,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},t)}),!s&&n(`tr`,{class:`ghost`,children:[n(`td`,{class:`g-check`}),n(`td`,{class:`g-key`,children:n(`input`,{class:`cell`,"data-cell":`${O}:${Cr}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{h.current=`${t.length}:${Cr}`,i([...t,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:T(O,Cr),onPaste:e=>D(e,t.length)})}),n(`td`,{class:`g-val`}),n(`td`,{class:`g-doc`}),n(`td`,{class:`g-act`})]},O)]})]})]})}function Or({draft:e,onChange:t}){let[i,a]=o(()=>fr(e.body)),s=c(e.body);r(()=>{if(e.body===s.current)return;let t=fr(e.body);t&&a(t),s.current=e.body},[e.body]);let l=n=>{let r={...i,...n};a(r),s.current=pr(r),t({...e,body:s.current})};return n(`section`,{class:`body`,"aria-label":`Body`,children:[n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Query`}),n(`span`,{class:`chip`,children:`graphql`})]}),n(Qn,{label:`GraphQL query`,language:`graphql`,value:i.query,onChange:e=>l({query:e})}),n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Variables`}),n(`span`,{class:`chip`,children:`json`})]}),n(Qn,{label:`GraphQL variables`,language:`json`,value:i.variables,onChange:e=>l({variables:e})})]})}var kr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function Ar({encoding:e,draft:t,onChange:r,schema:i,defs:a,files:c=[],notes:l}){let[d,f]=o(0),p=s(()=>Re(t.body),[t.body]),m=e===`json`||e===`form`,h=s(()=>{let e=p[d];return e&&m?ut(ct(i,a,e,[`data`]),l,`data`,Le(e)):void 0},[p,d,i,a,m,l]),g=s(()=>m&&i?(e,t)=>ir(i,a,[`data`],e,t):void 0,[i,a,m]),_=e=>{if(e!==(t.formView??`grid`)){if(e===`grid`)try{r({...t,formView:`grid`,fields:re(JSON.parse(t.body||`{}`))})}catch{r({...t,formView:`grid`})}else r({...t,formView:`json`,body:JSON.stringify(oe(t.fields.filter(e=>!e.file)),null,2)})}},v=e===`form`?n(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>n(`button`,{type:`button`,class:`seg-btn ${(t.formView??`grid`)===e?`on`:``}`,"aria-pressed":(t.formView??`grid`)===e,onClick:()=>_(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(ar(t,e)||e===`binary`){let o=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),s=e=>r({...t,fields:e}),d=(t.fields.length?t.fields.map(e=>e.key):[]).filter(o);return n(u,{children:[v&&n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Body`}),n(`span`,{class:`chip`,children:e}),n(`span`,{class:`spacer`}),v]}),n(Dr,{title:e===`binary`?`File`:`Body`,bare:!!v,rows:t.fields,onChange:s,documented:[...new Set(d)].map(e=>({name:e,file:!0})),docFor:e=>ut(ct(i,a,lt(e),[`data`]),l,`data`,e)})]})}return e===`graphql`&&fr(t.body)?n(Or,{draft:t,onChange:r}):n(`section`,{class:`body`,"aria-label":`Body`,children:[n(`div`,{class:`section-head`,children:[n(`h3`,{children:`Body`}),n(`span`,{class:`chip`,children:e}),n(`span`,{class:`spacer`}),e!==`text`&&n(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...t,body:JSON.stringify(JSON.parse(t.body),null,2)})}catch{}},children:`Format`}),v]}),n(Qn,{label:`Request body`,language:kr(e===`form`?`json`:e),value:t.body,onChange:e=>r({...t,body:e}),onLine:f,complete:g}),m&&n(dr,{doc:h})]})}var jr=`specbook:code-lang`;function Mr(){try{let e=localStorage.getItem(jr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Nr({service:e,profile:t,secured:i,make:a,sent:c}){let[l,u]=o(Mr),d=l===`sent`?`curl`:l,[f,p]=o(!1),[h,g]=o(),[_,v]=o();r(()=>{let n=!0;return j.config(m.value).then(r=>{if(!n)return;let i=r.services?.[e],a=i?.baseUrl??{};g(a[F.value]??a.live??Object.values(a)[0]);let o=t===`service`?i?.auth:t;v(o?r.auth?.[o]?.apply:void 0)}),()=>{n=!1}},[e,t,F.value]);let y=s(()=>{try{return{text:ye(d,a(h??`https://api.example.com`,_))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[a,d,h,_]),b=e=>{if(u(e),e!==`sent`)try{localStorage.setItem(jr,e)}catch{}};return n(`div`,{class:`code-sample`,children:[n(`div`,{class:`code-head`,children:[n(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[be.map(e=>n(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>b(e.id),children:e.label})),c!==void 0&&n(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>b(`sent`),children:`Sent`})]}),n(`span`,{class:`spacer`}),l!==`sent`&&n(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(y.text)try{await navigator.clipboard.writeText(y.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!y.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:y.error?n(`p`,{class:`muted`,children:y.error}):n(`pre`,{class:`code-block`,part:`code`,children:n(`code`,{children:y.text})}),l!==`sent`&&i&&n(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Pr({service:t,method:r,path:i,draft:o,encoding:s,vars:c,secured:l,sent:u}){let d=a((t,n)=>{let a=cr(o,s),l={path:a.path??{},query:a.query??{},headers:a.headers??{},data:a.data},u=l;try{u=e(l,c)}catch{}let d=i.replace(/\{([^}]+)\}/g,(e,t)=>{let n=u.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:r,url:`${t.replace(/\/+$/,``)}${d}`,query:{...n?.query??{},...u.query},headers:{...n?.headers??{},...u.headers},body:u.data,encoding:s}},[o,s,c,r,i]);return n(Nr,{service:t,profile:l?`service`:void 0,secured:l,make:d,sent:u})}function Fr({request:e,encoding:t,sent:r}){let i=a((n,r)=>({method:e.method,url:`${n.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:t}),[e,t]);return n(Nr,{service:e.service,profile:e.profile,secured:!!e.profile,make:i,sent:r})}var Ir=e=>typeof e==`string`?e:JSON.stringify(e,null,2);function Lr(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))for(let e of Array.isArray(r)?r:[r])t.append(n,e);let n=t.toString();return n?`?${n}`:``}function Rr({body:e,docs:t}){let[r,i]=o(0),a=Ir(e),c=!!t?.schema&&typeof e==`object`&&!!e,l=s(()=>c?Re(a):[],[c,a]),d=s(()=>{let e=l[r];return e&&t?ut(ct(t.schema,t.defs,e,[`data`]),t.notes,`data`,Le(e)):void 0},[l,r,t]);return n(u,{children:[n(Qn,{label:`Body as sent`,value:a,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&n(dr,{doc:d})]})}function zr({request:e,hideBar:t,docs:r}){if(!e)return n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`Nothing sent yet`}),n(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return n(`div`,{class:`sent-view`,children:[!t&&n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${e.method}`,children:e.method}),n(`div`,{class:`rq-url`,title:e.url,children:n(`code`,{children:[e.url,Lr(e.query)]})})]}),n(`h3`,{children:`Headers`}),i.length===0?n(`p`,{class:`muted`,children:`No headers.`}):n(`table`,{class:`headers`,children:n(`tbody`,{children:i.map(([e,t])=>n(`tr`,{children:[n(`th`,{children:e}),n(`td`,{children:t})]}))})}),e.body!==void 0&&n(u,{children:[n(`h3`,{children:`Body`}),n(Rr,{body:e.body,docs:r})]})]})}var Br=e=>JSON.stringify(e,null,2),Vr=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function Hr({step:e,error:t,schemas:r,defs:i,hideRequest:a}){let[c,l]=o(`body`),[d,f]=o(0),m=e?.response,h=m?r?.[String(m.status)]??r?.default:void 0,g=s(()=>m&&h?Ie(m.body,h,i,{reportExtra:!0}):[],[m,h,i]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:Br(m.body),v=s(()=>Re(_),[_]),y=s(()=>{let e=v[d];return e?ct(h,i,e):void 0},[v,d,h,i]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length,S=Object.entries(m?.headers??{}),C=!m&&!t&&!e?.error;return n(`section`,{class:`response`,"aria-label":`Response`,children:[n(`div`,{class:`rs-head`,children:[m&&n(u,{children:[n(`span`,{class:`state-badge ${He(m.status)}`,children:[m.status,` `,Ve(m.status)]}),n(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),n(`span`,{class:`rs-stat`,children:Vr(new Blob([_]).size)})]}),n(`span`,{class:`spacer`}),m&&n(`span`,{class:`conf ${h?g.length?`warn`:`ok`:`none`}`,children:h?g.length?`⚠ ${g.length} difference${g.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!a&&n(`p`,{class:`sent`,children:[n(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,n(`code`,{children:[e.request.url,Lr(e.request.query)]})]}),t&&n(`p`,{class:`error-text`,children:t}),e?.error&&n(`p`,{class:`error-text`,children:e.error}),C&&n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`No response yet`}),n(`span`,{class:`muted`,children:[`Press`,` `,n(`kbd`,{class:`icon-key`,children:n(p,{size:12})}),` `,`or `,n(`kbd`,{children:`⌘`}),` `,n(`kbd`,{children:`↵`})]})]}),m&&n(u,{children:[n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,t,r])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":c===e,class:`rq-tab ${c===e?`on`:``}`,onClick:()=>l(e),children:[t,r>0&&n(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,children:r})]}))}),n(`div`,{class:`rs-pane`,children:[n(`div`,{hidden:c!==`body`,children:[_===``?n(`p`,{class:`muted`,children:`No content.`}):n(Qn,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:f}),_!==``&&n(dr,{doc:y}),g.length>0&&n(`details`,{class:`issues`,children:[n(`summary`,{children:`What differs`}),n(`ul`,{children:g.map(e=>n(`li`,{children:[n(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),n(`div`,{hidden:c!==`headers`,children:n(`table`,{class:`headers`,children:n(`tbody`,{children:[S.map(([e,t])=>n(`tr`,{children:[n(`th`,{children:e}),n(`td`,{children:t})]})),S.length===0&&n(`tr`,{children:n(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),n(`div`,{hidden:c!==`checks`,children:b.length===0?n(`p`,{class:`muted`,children:`This request has no checks.`}):n(`ul`,{class:`checks`,children:b.map(e=>n(`li`,{class:e.pass?`ok`:`bad`,children:[e.pass?`✓`:`✗`,` `,e.label]}))})})]})]})]})}var Ur=()=>{let e=document.querySelector(`meta[name="specbook-oauth-callback"]`)?.content.trim();if(e)try{return new URL(e,location.origin).href}catch{}return`${location.origin}${location.pathname}`};async function Wr(e){let t=window.open(``,d,`popup,width=520,height=720`);if(!t)throw new S(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(d),r;try{let{verifier:i,challenge:a}=await A(),o=T(),s=Ur(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new S(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new S(`Sign-in was cancelled.`))});let c=(e,n)=>{e?.type===`callback`&&e.state===o&&(s(),n({type:`ack`,state:o}),t(e))};n.onmessage=e=>c(e.data,e=>n.postMessage(e)),r=e=>{e.origin===location.origin&&c(e.data,t=>e.source?.postMessage(t,location.origin))},addEventListener(`message`,r)});t.location.href=C({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=w({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(P({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return v(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var Gr=`specbook.oauth.clients.v1`,Kr=`specbook.oauth.expiry.v1`,qr=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},Jr=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},Yr=e=>{try{return qr(localStorage,Gr)[e]}catch{return}},Xr=(e,t)=>{try{Jr(localStorage,Gr,{...qr(localStorage,Gr),[e]:t})}catch{}},Zr=(e,t)=>`${e}\n${t}`,Qr=(e,t,n)=>{try{let r=qr(sessionStorage,Kr);n===void 0?delete r[Zr(e,t)]:r[Zr(e,t)]=Date.now()+n*1e3,Jr(sessionStorage,Kr,r)}catch{}},$r=(e,t)=>{try{return qr(sessionStorage,Kr)[Zr(e,t)]}catch{return}};function ei({service:e,profile:t,origin:i,secret:a,oauth:s,onSignedIn:l}){let u=O(s)?s.openIdConnectUrl:s.authorizationUrl,[d,f]=o(()=>s.clientId??Yr(u)??``),[p,h]=o(void 0),[g,_]=o([]),[v,y]=o({kind:`idle`}),b=c(void 0),x=v.kind===`busy`,[S,C]=o(0);r(()=>{let e=!0;return h(void 0),y(e=>e.kind===`busy`?e:{kind:`idle`}),j.oauthEndpoints({env:F.value,version:m.value,profile:t}).then(t=>{e&&(h(t),_(O(s)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&y({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[t,F.value,m.value,S]);let w=Object.keys(p?.scopes??{}),T=()=>{if(!p)return C(e=>e+1);let e=d.trim();if(!e)return y({kind:`error`,message:`Enter the client id registered for this page.`});let n=new AbortController;b.current=n,y({kind:`busy`}),Xr(u,e),Wr({authorizationUrl:p.authorizationUrl,clientId:e,scopes:g,signal:n.signal,exchange:(e,n)=>j.oauthExchange({env:F.value,version:m.value,profile:t,fields:e,signal:n})}).then(e=>{N.set(i,a,e.accessToken),Qr(i,a,e.expiresIn),y({kind:`idle`}),l()}).catch(e=>y({kind:`error`,message:e instanceof Error?e.message:String(e)}))},E=!p&&v.kind===`error`,D=!x&&v.kind!==`error`&&!!p;return n(`span`,{class:`needs-var oauth-signin`,children:[n(`input`,{type:`text`,autocomplete:`off`,"aria-label":`Client id for ${e}`,placeholder:`client id`,value:d,disabled:x,onInput:e=>f(e.target.value)}),x?n(`button`,{type:`button`,class:`link`,onClick:()=>b.current?.abort(),children:`Cancel`}):n(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&n(`details`,{children:[n(`summary`,{class:`muted small`,children:[`Scopes (`,g.length,` of `,w.length,`)`]}),w.map(e=>n(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[n(`input`,{type:`checkbox`,checked:g.includes(e),disabled:x,onChange:t=>_(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,n(`code`,{children:e})]}))]}),n(`span`,{class:`muted small oauth-status ${D?`oauth-hint`:``}`,role:`status`,"aria-live":`polite`,children:x?`Waiting for the sign-in window…`:v.kind===`error`?v.message:p?`Register this redirect URI with the provider: ${Ur()}`:`Looking up the provider…`})]})}var ti=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),ni={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function ri({services:e,enabled:t=!0,supplied:i}){let[a,s]=o([]),[c,l]=o({}),d=i??c,[,f]=o(0),[p,h]=o(!1),g=t&&F.value!==`mock`,_=e?.join(`
37
- `)??`*`;if(r(()=>{if(!g){s([]);return}let t=!0;return i||j.managedSecrets(F.value).then(e=>t&&l(e)),j.config(m.value).then(n=>{if(!t)return;let r=[];for(let[t,i]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let a=i.auth?n.auth?.[i.auth]:void 0,o=i.baseUrl?.[F.value],s=D(o?M(o,globalThis.location?.href):void 0);if(!a||!s)continue;let c=[...new Set([...JSON.stringify(a.apply).matchAll(x)].map(e=>e[1]))];c.length&&r.push({service:t,origin:s,title:a.title??i.auth??``,names:c,profile:i.auth,oauth:a.oauth})}s(r)}),()=>{t=!1}},[g,F.value,_,m.value]),!g||a.length===0)return null;let v=(e,t)=>N.get(e.origin,t)!==void 0||d[t]!==void 0,y=a.some(e=>e.names.some(t=>!v(e,t)));return!y&&!p?n(`div`,{class:`secrets-folded`,children:n(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>h(!0),children:[n(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,a.map(e=>e.title||e.service).join(` · `),` ✓`]})}):n(`fieldset`,{class:`needs-vars ${y?``:`ok`}`,"aria-label":`Credentials for this request`,children:[a.map(e=>n(u,{children:[n(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(t=>{let r=N.get(e.origin,t)!==void 0,i=d[t];return n(`span`,{class:`needs-var`,children:[n(`code`,{children:t}),r?n(u,{children:[n(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&ti($r(e.origin,t))!==void 0?` · expires in ${ti($r(e.origin,t))} min`:``]}),n(`button`,{type:`button`,class:`link`,onClick:()=>{N.remove(e.origin,t),Qr(e.origin,t,void 0),f(e=>e+1)},children:`Clear`})]}):n(u,{children:[i&&n(`span`,{class:`muted`,children:[`from `,ni[i]??i]}),e.oauth&&n(ei,{service:e.service,profile:e.profile,origin:e.origin,secret:t,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),n(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${t} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:n=>{let r=n.target.value;r!==``&&(N.set(e.origin,t,r),f(e=>e+1))}})]})]})})]})),n(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!y&&n(`button`,{type:`button`,class:`link`,onClick:()=>h(!1),children:`Hide`})]})}var ii=e=>e.replace(/<[^>]+>/g,``).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#39;/g,`'`),ai=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function oi(e,t){let n=new Map;if(!e||t.length===0)return{intro:e,notes:n};let r=new Map(t.map(e=>[ai(e),e])),i=[];for(let t of e.split(/(?=<h2[ >])/)){let e=/^<h2[^>]*>([\s\S]*?)<\/h2>/.exec(t),a=e?r.get(ai(ii(e[1]))):void 0;e&&a!==void 0?n.has(a)||n.set(a,t.slice(e[0].length)):i.push(t)}return{intro:i.join(``),notes:n}}function si(e){let{seq:t}=e,[n,i]=o(),[a,c]=o(!1);r(()=>{let n=!0;i(void 0),c(!1);let r=y.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!r)c(!0);else return r.load().then(e=>n&&i(e)).finally(()=>n&&c(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=s(()=>t.nodes.map(e=>e.name),[t]);return s(()=>({...oi(n??xe(t.meta.description),l),loaded:a}),[n,l,t,a])}function ci(e){let[t,n]=o();return r(()=>{let t=!0;return n(void 0),e&&y.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&n(e)),()=>{t=!1}},[e]),t}var li=(e,t)=>`specbook:draft:${e}:${t}`,ui=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function di(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var fi=`specbook:saved-example`;function pi(e){try{let t=sessionStorage.getItem(fi),n=t?JSON.parse(t):void 0;return n?.key===e?(sessionStorage.removeItem(fi),n):void 0}catch{return}}function mi({service:e,op:i,variants:a,initial:c}){let l=`${e}/${i.id}`,d=j.examplesOf(l),[f,h]=o(()=>pi(l)),[g,v]=o(()=>{let e=d.find(e=>e.name===(f?.name??c));return e?`ex:${e.name}`:d[0]?`ex:${d[0].name}`:a[0]?`saved:${a[0].file}`:``}),b=g.startsWith(`saved:`)?a.find(e=>`saved:${e.file}`===g):void 0,x=ci(b?.file),S=et(l),[C,w]=o(),[T,D]=o(),[O,A]=o(),[M,N]=o({}),[P,I]=o(),[ne,L]=o(),[R,re]=o(),[ie,ae]=o(),[oe,se]=o(),[ce,le]=o(),[ue,de]=o(!1),[fe,z]=o(),[pe,me]=o(),[B,he]=o(``),[ge,V]=o();r(()=>{j.config(m.value).then(t=>he(t.services?.[e]?.baseUrl?.[F.value]??``))},[e,F.value]),r(()=>{let e=!0;return V(void 0),j.knownVars(F.value,m.value).then(t=>e&&V(t)),()=>{e=!1}},[F.value]),r(()=>{let t=!0;return y.schemas[l]?.().then(e=>t&&I(e.default)),y.responseSchemas[l]?.().then(e=>t&&L(e.default)),y.definitions[e]?.().then(e=>t&&re(e.default)),j.operationMeta(l,m.value).then(e=>{t&&w({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[l,e]);let H=C?.encoding??`json`,_e=y.manifests[e]?.operations.find(e=>e.id===i.id)?.secured;r(()=>{if(!C)return;let e=!0;return le(void 0),se(void 0),(async()=>{let t=b?await j.savedExample(b.def,m.value):await j.loadExample(l,g.replace(/^ex:/,``),m.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};D(n),A(!b&&di(li(l,g))||or(n,H))})().catch(t=>e&&le(t instanceof Error?t.message:String(t))),()=>{e=!1}},[l,g,C,b]);let ve=s(()=>T?or(T,H):void 0,[T,H]),ye=!!O&&!!ve&&JSON.stringify(lr(O))!==JSON.stringify(lr(ve)),be=e=>{if(A(e),!b)try{let t=li(l,g);ve&&JSON.stringify(lr(e))===JSON.stringify(lr(ve))?localStorage.removeItem(t):localStorage.setItem(t,JSON.stringify(lr(e)))}catch{}},U=s(()=>{let e=P?q(P,R):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Me(r,R).map(e=>({name:e.name,doc:ut(ct(P,R,[e.name],[n]),S.notes,n,e.name),repeat:q(e.schema,R).type===`array`})))}return t},[P,R,S.notes]),W=s(()=>{if(!O)return[];try{let e=cr(O,H);return[...t([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(e=>e.split(`.`)[0]).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[O,H]),xe=ge?W.filter(e=>!ge.includes(e)):[],Se=xe.filter(e=>(M[e]??``)===``),Ce=async e=>{if(O){le(void 0),de(!0);try{let t=b?b.def:await j.operationRequest(l,m.value,cr(O,H));se(await j.run(t,{env:F.value,version:m.value,mockStatus:F.value===`mock`?e??ie:void 0,locale:te.value,seed:_.value,vars:Object.fromEntries(Object.entries(M).filter(([,e])=>e!==``)),fileDir:T?.dir}))}catch(e){le(e instanceof Error?e.message:String(e))}finally{de(!1),me(`response`)}}},we=async t=>{if(!O)return;let n=cr(O,H),r=ui(t),a={name:r,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${y.project.requestsDir}/${e}/${i.id}/${r}.example.json`,s={key:l,path:o,name:r};try{sessionStorage.setItem(fi,JSON.stringify(s))}catch{}await k(o,`${JSON.stringify(a,null,2)}\n`),h(s),z(void 0)},G=oe?.steps.find(e=>e.response)??oe?.steps[0],Te=ce?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Ee=!!O&&(O.path.length>0||O.query.length>0||U.path.length>0||U.query.length>0),De=!!O&&(O.headers.length>0||U.headers.length>0),Oe=!!O&&H!==`none`&&(O.body!==``||O.fields.length>0||!!P?.properties?.data),K=pe??(Ee?`params`:Oe?`body`:De?`headers`:`params`),ke=e=>e.filter(e=>e.enabled).length,J=O?ke(O.query):0,Ae=O?ke(O.path):0,je=O?ur(i.path,O.path,O.query,B):i.path;return r(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Ce())};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)}),n(`div`,{class:`request-panel`,"data-op":l,children:n(`div`,{class:`rq`,children:[n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${i.method}`,children:i.method}),n(`div`,{class:`rq-url`,title:je,children:n(`code`,{children:je.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?n(`mark`,{children:e}):e)})}),(G?.response||ce||G?.error)&&n(`button`,{type:`button`,class:`result-chip ${G?.response?He(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>me(`response`),children:G?.response?`${G.response.status} ${Ve(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),n(`button`,{type:`button`,class:`btn primary send`,title:`Send (⌘/Ctrl + Enter)`,"aria-label":`Send`,disabled:ue||!O,onClick:()=>Ce(),children:ue?`…`:n(p,{})})]}),x&&n(`details`,{class:`step-about`,children:[n(`summary`,{children:`About this request`}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:x}})]},b?.file),xe.length>0&&n(`fieldset`,{class:`needs-vars ${Se.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[n(`span`,{class:`muted`,children:Se.length>0?`Needs a value for`:`Values for`}),xe.map(e=>n(`label`,{class:`needs-var`,children:[n(`code`,{children:e}),n(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:M[e]??``,onInput:t=>N({...M,[e]:t.target.value})})]}))]}),_e&&n(ri,{services:[e]}),n(`div`,{class:`rq-meta`,children:[n(`div`,{class:`rq-example`,children:[n(`label`,{class:`row`,children:[n(`span`,{class:`muted`,children:`Example`}),n(`select`,{value:g,onChange:e=>v(e.target.value),children:[d.map(e=>n(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),a.map(e=>n(`option`,{value:`saved:${e.file}`,children:[e.name,` · saved request`]}))]})]}),n(ee,{})]}),ye&&n(`span`,{class:`edited`,children:`Edited`}),n(`span`,{class:`spacer`}),ye&&n(`button`,{type:`button`,class:`link`,onClick:()=>ve&&be(ve),children:`↺ Reset`}),!E&&!b&&ye&&fe===void 0&&n(`button`,{type:`button`,class:`link`,onClick:()=>z(``),children:`Save as example…`}),F.value===`mock`&&i.statuses.length>0&&n(`label`,{class:`rq-status`,children:[n(`span`,{class:`muted`,children:`Respond with`}),n(`select`,{"aria-label":`Mock response`,value:ie===void 0?``:String(ie),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);ae(n),Ce(n)},children:[n(`option`,{value:``,children:`Default`}),i.statuses.map(e=>n(`option`,{value:String(e),children:[e,` `,Ve(e)]}))]})]})]}),f&&n(`p`,{class:`saved-note`,role:`status`,children:[n(`span`,{children:[`✓ Saved to `,n(`code`,{children:f.path}),`. It is a normal project file: commit it to share this example with your team.`]}),n(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>h(void 0),children:`×`})]}),fe!==void 0&&n(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),fe.trim()&&we(fe.trim()).catch(e=>le(String(e)))},children:[n(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:fe,onInput:e=>z(e.target.value)}),n(`button`,{type:`submit`,class:`btn`,children:`Save`}),n(`button`,{type:`button`,class:`link`,onClick:()=>z(void 0),children:`Cancel`})]}),b&&n(`p`,{class:`muted lock`,children:`A saved request: its own values, checks and mock responses apply, and it is read-only here.`}),n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,J+Ae],[`headers`,`Headers`,O?ke(O.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,W.length]].filter(([e])=>e===`params`?Ee:e===`headers`?De:e===`body`?Oe:W.length>0).map(([e,t,r])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":K===e,class:`rq-tab ${K===e?`on`:``}`,onClick:()=>me(e),children:[t,r>0&&n(`span`,{class:`count`,children:r}),e===`body`&&n(`span`,{class:`chip`,children:H})]})),n(`span`,{class:`tab-gap`}),n(`button`,{type:`button`,role:`tab`,"aria-selected":K===`request`,class:`rq-tab ${K===`request`?`on`:``}`,onClick:()=>me(`request`),children:`Request`}),n(`button`,{type:`button`,role:`tab`,"aria-selected":K===`response`,class:`rq-tab ${K===`response`?`on`:``}`,onClick:()=>me(`response`),children:[`Response`,G?.response&&n(`span`,{class:`state-dot ${He(G.response.status)}`,children:G.response.status}),!G?.response&&(ce||G?.error)&&n(`span`,{class:`state-dot s5`,children:`!`})]})]}),n(`div`,{class:`rq-pane`,children:[O&&n(u,{children:[n(`div`,{class:`tab-pane`,hidden:K!==`params`,children:[(O.query.length>0||U.query.length>0)&&n(Dr,{title:`Query`,rows:O.query,documented:U.query,onChange:e=>be({...O,query:e})}),(O.path.length>0||U.path.length>0)&&n(Dr,{title:`Path`,rows:O.path,documented:U.path,fixed:!0,onChange:e=>be({...O,path:e})})]}),n(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:De&&n(Dr,{title:`Headers`,rows:O.headers,documented:U.headers,onChange:e=>be({...O,headers:e})})}),n(`div`,{class:`tab-pane`,hidden:K!==`body`,children:Oe&&n(Ar,{encoding:H,draft:O,onChange:be,schema:P,defs:R,files:C?.files,notes:S.notes})}),n(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:W.length>0&&n(Dr,{title:`Variables`,rows:W.map(e=>({key:e,value:M[e]??``,enabled:!0})),fixed:!0,bad:Te,placeholder:`from the request's init, config or earlier steps`,onChange:e=>N(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),n(`div`,{class:`tab-pane`,hidden:K!==`request`,children:O&&n(Pr,{service:e,method:i.method,path:i.path,draft:O,encoding:H,vars:M,secured:_e,sent:G?.request?n(zr,{request:G.request,docs:{schema:P,defs:R,notes:S.notes}}):void 0})}),n(`div`,{class:`tab-pane`,hidden:K!==`response`,children:n(Hr,{step:G,error:ce,schemas:ne,defs:R})})]})]})})}function hi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...gi(e,t),...n}}function gi(e,t){switch(e.kind){case`select`:case`multiselect`:{let n=e=>typeof t.value==`function`?t.value(e):e,r=e=>typeof t.label==`function`?t.label(e):String(n(e));return{kind:e.kind,options:t.options.map(e=>({label:r(e),value:n(e)}))}}case`object`:return{kind:`object`,shape:Object.fromEntries(Object.entries(t.shape).map(([e,t])=>[e,hi(t)]))};case`array`:return{kind:`array`,item:hi(t.item),default:t.default,min:t.min,max:t.max};default:return{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function _i(e){switch(e.kind){case`select`:return e.options?.[0]?.value;case`multiselect`:return[];case`object`:return Object.fromEntries(Object.entries(e.shape??{}).map(([e,t])=>[e,_i(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var vi={step:`request`,each:`for each item`,input:`you choose`,check:`check`},yi=e=>typeof e==`string`?e:JSON.stringify(e);function bi({info:e}){let{seq:t}=e,{intro:r,notes:i}=si(e),a=s(()=>Object.entries(t.meta.params??{}).map(([e,t])=>{let n=hi(t);return{name:e,spec:n,initial:_i(n)}}),[t]);return n(`article`,{class:`doc`,"data-seq":t.meta.id,children:[(t.meta.tags?.length??0)>0&&n(`p`,{class:`doc-tags`,children:t.meta.tags?.map(e=>n(`span`,{class:`chip`,children:e}))}),r&&n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&n(`section`,{children:[n(`h2`,{children:`Controls`}),n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`Name`}),n(`th`,{children:`Type`}),n(`th`,{children:`Default`}),n(`th`,{children:`Description`})]})}),n(`tbody`,{children:a.map(e=>n(`tr`,{children:[n(`td`,{children:n(`code`,{children:e.name})}),n(`td`,{children:n(`span`,{class:`chip`,children:e.spec.kind})}),n(`td`,{children:n(`code`,{children:yi(e.initial)})}),n(`td`,{children:e.spec.description})]}))})]})]}),n(`section`,{children:[n(`h2`,{children:`Steps`}),n(`table`,{class:`fields`,children:[n(`thead`,{children:n(`tr`,{children:[n(`th`,{children:`#`}),n(`th`,{children:`Step`}),n(`th`,{children:`What it does`})]})}),n(`tbody`,{children:t.nodes.map((e,t)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return n(u,{children:[n(`tr`,{class:a?`has-note`:``,children:[n(`td`,{children:t+1}),n(`td`,{children:e.name}),n(`td`,{children:r?n(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>h({kind:`op`,key:`${r.service}/${r.id}`}),children:[n(`span`,{class:`method ${r.method}`,children:r.method}),` `,n(`code`,{children:r.path})]}):n(`span`,{class:`muted`,children:vi[e.kind]??e.kind})})]}),a&&n(`tr`,{class:`step-note-row`,children:[n(`td`,{}),n(`td`,{colSpan:2,children:n(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var xi=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Si(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Ci({name:e,spec:t,value:r,onChange:i}){let[a,s]=o();switch(t.kind){case`number`:return n(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:t.min,max:t.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return n(mr,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return n(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=t.options??[],o=a.find(e=>xi(e.value,r));return n(mr,{label:e,value:o?.label??String(r??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=r??[];return n(`div`,{class:`multi-cell`,children:(t.options??[]).map(t=>n(`label`,{children:[n(`input`,{type:`checkbox`,checked:e.some(e=>xi(e,t.value)),onChange:n=>i(n.target.checked?[...e,t.value]:e.filter(e=>!xi(e,t.value)))}),t.label]}))})}case`object`:case`array`:return n(`input`,{class:`cell mono`,"aria-label":e,value:a??JSON.stringify(r??_i(t)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return n(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function wi({title:e,specs:t,values:r,onChange:i}){let a=Object.keys(t);return a.length===0?null:n(`section`,{class:`grid controls-grid`,"aria-label":e,children:[n(`h3`,{children:e}),n(`table`,{children:[n(`colgroup`,{children:[n(`col`,{class:`c-key`}),n(`col`,{class:`c-val`}),n(`col`,{})]}),n(`thead`,{children:n(`tr`,{children:[n(`th`,{class:`g-key`,children:`Name`}),n(`th`,{class:`g-val`,children:`Value`}),n(`th`,{class:`g-doc`,children:`Description`})]})}),n(`tbody`,{children:a.map(e=>{let a=t[e];return n(`tr`,{children:[n(`td`,{class:`g-key`,children:n(`span`,{class:`key`,children:n(`code`,{children:a.label??e})})}),n(`td`,{class:`g-val`,children:n(Ci,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})})}),n(`td`,{class:`g-doc`,title:a.description,children:[n(`span`,{class:`chip`,children:Si(a)}),` `,a.description]})]},e)})})]})]})}function Ti({step:e,note:t}){let[i,a]=o(`response`),[s,c]=o(),[l,u]=o(),[d,f]=o(),[p,h]=o(`json`),g=e.request,_=g?.opId?`${g.service}/${g.opId}`:void 0;r(()=>{a(`response`)},[e.name]),r(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),_&&g&&(y.schemas[_]?.().then(t=>e&&f(t.default)),j.operationMeta(_,m.value).then(t=>e&&h(t?.encoding??`json`)),y.responseSchemas[_]?.().then(t=>e&&c(t.default)),y.definitions[g.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[_]);let v=e.response,b=g?`${g.url}${Lr(g.query)}`:``;return n(`div`,{class:`step-exchange`,children:[g&&n(`div`,{class:`rq-bar`,children:[n(`span`,{class:`method ${g.method}`,children:g.method}),n(`div`,{class:`rq-url`,title:b,children:n(`code`,{children:b})}),v&&n(`span`,{class:`result-chip ${He(v.status)}`,children:[v.status,` `,Ve(v.status),` · `,v.durationMs,` ms`]})]}),t&&n(`details`,{class:`step-about`,children:[n(`summary`,{children:`About this step`}),n(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:t}})]},e.name),n(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,t])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>a(e),children:[t,e===`response`&&v&&n(`span`,{class:`state-dot ${He(v.status)}`,children:v.status})]}))}),n(`div`,{class:`rq-pane`,children:[n(`div`,{class:`tab-pane`,hidden:i!==`request`,children:g?n(Fr,{request:g,encoding:p,sent:n(zr,{request:g,hideBar:!0,docs:{schema:d,defs:l}})}):n(zr,{request:g,hideBar:!0,docs:{schema:d,defs:l}})}),n(`div`,{class:`tab-pane`,hidden:i!==`response`,children:n(Hr,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var Ei=e=>e.replace(/ #\d+$/,``),Di={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``},Oi=e=>{let t=typeof e==`string`?e:JSON.stringify(e);return t.length>28?`${t.slice(0,27)}…`:t};function ki({info:e}){let{seq:t}=e,i=s(()=>Object.fromEntries(Object.entries(t.meta.params??{}).map(([e,t])=>[e,hi(t)])),[t]),a=si(e),c=s(()=>{let e=new Set;for(let n of t.nodes)if(n.kind===`step`&&typeof n.def!=`function`)e.add(n.def.op.service);else if(n.kind===`step`||n.kind===`each`)return;return[...e]},[t]),[l,u]=o({}),[d,f]=o(),[p,h]=o({}),[g,v]=o(!1),[y,b]=o(),[x,S]=o({}),[C,w]=o(0),[T,E]=o(!1),[D,O]=o();r(()=>{u(Object.fromEntries(Object.entries(i).map(([e,t])=>[e,_i(t)]))),f(void 0),h({}),b(void 0)},[e.file]);let k=t.nodes.map(e=>e.name),A=d?d.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):k.map(e=>({name:e})),M=A[C]?.step,N=async()=>{v(!0),f(void 0),O(void 0),h({}),w(0),E(!1);try{let e=await j.run(t,{env:F.value,version:m.value,params:l,locale:te.value,seed:_.value,onEvent:e=>{e.type===`step:start`&&h(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&h(t=>({...t,[e.name]:e.status}))},onInput:({name:e,controls:t})=>new Promise(n=>{let r=t;h(t=>({...t,[e]:`paused`})),S(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,_i(t)]))),b({name:e,controls:r,resolve:e=>{b(void 0),n(e)}})})});f(e)}catch(e){O(e instanceof Error?e.message:String(e))}finally{v(!1),b(void 0)}},P=d?.status;return n(`div`,{class:`sequence-panel ${T&&M?`sheet-open`:``}`,"data-seq":t.meta.id,children:[n(`div`,{class:`seq-left`,children:[n(ri,{services:c}),n(wi,{title:`Controls`,specs:i,values:l,onChange:u}),n(`div`,{class:`seq-run`,children:[n(`button`,{type:`button`,class:`btn primary`,disabled:g,onClick:N,children:g?`Running…`:`▶ Run`}),n(ee,{}),d&&n(`span`,{class:`badge ${P}`,children:[Di[P],` `,P===`pass`?`Passed`:P===`fail`?`Failed`:`Error`,` ·`,` `,d.totals.passed,`/`,d.totals.steps,` steps · `,d.durationMs,`ms`]})]}),D&&n(`p`,{class:`error-text`,children:D}),n(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:A.map((e,t)=>{let r=e.step,i=r?.status??p[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return n(`li`,{class:`jstep ${i} ${C===t?`picked`:``}`,children:[n(`div`,{class:`jmark`,children:Di[i]||t+1}),n(`div`,{class:`jbody`,children:[n(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let n=e.currentTarget;w(t),E(!0),requestAnimationFrame(()=>n.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[n(`span`,{class:`jname`,children:e.name}),r?.response&&n(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&n(`span`,{class:a.length?`error-text`:`muted`,children:[r.assertions.length-a.length,`/`,r.assertions.length,` checks`]})]}),r?.uses?.filter(e=>e.source===`capture`).map(e=>n(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,n(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,t])=>n(`span`,{class:`cap make`,title:JSON.stringify(t),children:[`→ `,e,` `,n(`b`,{children:Oi(t)})]})),r?.error&&n(`div`,{class:`error-text`,children:r.error}),a.map(e=>n(`div`,{class:`error-text`,children:[`✗ `,e.label]})),i===`skipped`&&n(`div`,{class:`muted`,children:`Skipped: an earlier step did not pass.`}),y&&p[e.name]===`paused`&&n(`div`,{class:`pause`,children:[n(`strong`,{children:[`Your turn: `,y.name]}),n(wi,{title:`Choose`,specs:y.controls,values:x,onChange:S}),n(`button`,{type:`button`,class:`btn primary`,onClick:()=>y.resolve(x),children:`Continue ▶`})]})]})]})})})]}),n(`div`,{class:`seq-right ${T&&M?`sheet-open`:``}`,children:[M&&n(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>E(!1),children:[n(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,M.name]}),!M&&n(`div`,{class:`rs-empty`,children:[n(`strong`,{children:`Nothing run yet`}),n(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),M&&n(Ti,{step:M,note:a.notes.get(Ei(M.name))})]})]})}function Ai(e){let t=e.tab??`try`,r=n(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>n(`button`,{type:`button`,role:`tab`,"aria-selected":t===r,class:`rq-tab ${t===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?n(st,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:n(`div`,{class:`panel-split`,children:[r,n(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:n(t===`docs`?bi:ki,{info:e.info})})]})}):n(st,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:n(`div`,{class:`panel-split`,children:[r,n(`div`,{class:`panel-main ${t===`docs`?`scroll`:``}`,children:t===`docs`?n(at,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):n(mi,{service:e.service,op:e.op,variants:e.variants,initial:e.example},`${e.service}/${e.op.id}`)})]})})}export{Ai as Host};
@@ -1 +0,0 @@
1
- import{_ as e,a as t,d as n,h as r,i,o as a,p as o,s,t as c,v as l}from"./panel-C8Ve3LeS.js";import{a as u,r as d,t as f}from"./mount-CGL2tOpN.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var p=[78,92,64,84,70,88,60,80,72,90,66,76],m=[93,118,81,72,46,46,32];function h({what:e,progress:n}){return t(`div`,{class:`app sk`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[t(`header`,{class:`header`,children:[t(`span`,{class:`sk-brand`,children:[t(`img`,{src:a,alt:``,width:`24`,height:`24`}),`Specbook`]}),t(`span`,{class:`sk-search`,"aria-hidden":`true`}),t(`span`,{class:`spacer`}),m.map(e=>t(`span`,{class:`sk-pill`,style:{width:`${e}px`},"aria-hidden":`true`})),t(`span`,{class:`sk-menu`,"aria-hidden":`true`})]}),t(`div`,{class:`layout`,"data-view":`splash`,children:[t(`nav`,{class:`list-col`,"aria-hidden":`true`,children:[t(`span`,{class:`sk-filter`}),p.map(e=>t(`span`,{class:`sk-row`,style:{width:`${e}%`}}))]}),t(`main`,{class:`stage`,children:[t(`p`,{class:`sk-status`,children:n??`Opening…`}),t(`p`,{class:`sk-what`,title:e,children:e})]})]})]})}var g=`specbook:recent-specs`,_=10;function v(){try{let e=JSON.parse(localStorage.getItem(g)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(0,_):[]}catch{return[]}}function y(e){try{localStorage.setItem(g,JSON.stringify([e,...v().filter(t=>t!==e)].slice(0,_)))}catch{}}var b=`specbook-viewer`,x=`uploads`,S=5;function C(){return new Promise((e,t)=>{let n=indexedDB.open(b,1);n.onupgradeneeded=()=>n.result.createObjectStore(x,{keyPath:`id`}),n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)})}var w=e=>new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)});async function T(e,t){try{let n=await C(),r=Math.random().toString(36).slice(2,10),i=n.transaction(x,`readwrite`).objectStore(x);await w(i.put({id:r,name:e,text:t,at:Date.now()}));let a=await w(i.getAll());for(let e of a.sort((e,t)=>t.at-e.at).slice(S))i.delete(e.id);return r}catch{return}}async function E(e){try{let t=await w((await C()).transaction(x).objectStore(x).get(e));return t?{name:t.name,text:t.text}:void 0}catch{return}}var D=[{label:`Petstore`,url:`https://petstore3.swagger.io/api/v3/openapi.json`},{label:`httpbin (live requests work)`,url:`https://httpbin.org/spec.json`},{label:`Stripe (form-encoded requests)`,url:`https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.json`},{label:`OpenAI`,url:`https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml`},{label:`GitHub (large)`,url:`https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json`}];s();var O=document.getElementById(`app`),k=new URLSearchParams(location.search),A=k.has(`spec`)||k.has(`upload`),j=e=>`${location.origin}${location.pathname}?spec=${i(e)}`;function M({initial:e}){let[i,a]=r(e),[s,u]=r(k.get(`spec`)??``),[p,m]=r(``),[g,_]=r(!1),b=o(void 0),x=async(e,t,n)=>{b.current??=new d,a({kind:`loading`,what:t});let{promise:r}=b.current.open(e,e=>a({kind:`loading`,what:t,progress:e}));try{let t=await r,i=async r=>{n&&y(n),await f({result:t,worker:b.current,source:e,baseUrl:r})};t.needsBaseUrl?a({kind:`base`,open:t,apply:e=>void i(e)}):await i()}catch(e){let t=e;a({kind:`error`,message:t.message,code:t.code})}},S=e=>{let t=c(e.trim());if(t){if(!/^https?:\/\//i.test(t))return a({kind:`error`,message:`Enter an address starting with http:// or https://`});history.replaceState(null,``,j(t)),x({kind:`url`,url:t},t,t)}},C=async(e,t)=>{let n=await T(e,t);n&&history.replaceState(null,``,`${location.pathname}?upload=${n}`),x({kind:`text`,text:t,name:e},e)};n(()=>{let e=k.get(`spec`),t=k.get(`upload`);e?S(e):t&&E(t).then(e=>e?x({kind:`text`,text:e.text,name:e.name},e.name):a({kind:`error`,message:`That uploaded document is no longer stored in this browser.`}))},[]);let w=i.kind===`loading`;return A&&(i.kind===`idle`||i.kind===`loading`)?t(h,{what:k.get(`spec`)??`your uploaded document`,progress:i.kind===`loading`?i.progress:void 0}):t(`main`,{class:`vw`,children:t(`div`,{class:`vw-card`,children:[t(`h1`,{children:`Specbook`}),t(`p`,{children:`Open any OpenAPI or Swagger document. It is read in your browser; nothing is uploaded.`}),t(`form`,{onSubmit:e=>{e.preventDefault(),S(s)},children:[t(`input`,{type:`url`,placeholder:`https://example.com/openapi.json`,"aria-label":`Address of an OpenAPI or Swagger document`,value:s,onInput:e=>u(e.target.value),disabled:w}),t(`button`,{type:`submit`,class:`btn primary`,disabled:w,children:`Open`})]}),i.kind===`loading`&&t(`p`,{class:`vw-progress`,role:`status`,children:i.progress??`Opening…`}),i.kind===`error`&&t(`div`,{class:`vw-error`,role:`alert`,children:[i.message,i.code===`cors`&&t(l,{children:` Paste the document below or drop the file instead; it works the same.`})]}),i.kind===`base`&&t(N,{onApply:i.apply,title:i.open.title}),t(`section`,{class:`vw-drop ${g?`over`:``}`,"aria-label":`Drop a document here`,onDragOver:e=>{e.preventDefault(),_(!0)},onDragLeave:()=>_(!1),onDrop:async e=>{e.preventDefault(),_(!1);let t=e.dataTransfer?.files?.[0];t&&await C(t.name,await t.text())},children:[`Drop a file here, or`,` `,t(`label`,{class:`link`,children:[`choose one`,t(`input`,{type:`file`,accept:`.json,.yaml,.yml,application/json`,hidden:!0,onChange:async e=>{let t=e.target.files?.[0];t&&await C(t.name,await t.text())}})]})]}),t(`details`,{children:[t(`summary`,{children:`Paste the document`}),t(`p`,{}),t(`textarea`,{"aria-label":`OpenAPI or Swagger document text`,placeholder:`{ "openapi": "3.0.0", … }`,value:p,onInput:e=>m(e.target.value)}),t(`p`,{}),t(`button`,{type:`button`,class:`btn primary`,disabled:w||p.trim()===``,onClick:()=>void C(`pasted document`,p),children:`Open pasted document`})]}),t(`section`,{children:[t(`p`,{children:`Try one`}),t(`ul`,{children:D.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>S(e.url),children:e.label})}))})]}),v().length>0&&t(`section`,{children:[t(`p`,{children:`Recent`}),t(`ul`,{children:v().map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,title:e,onClick:()=>S(e),children:e})}))})]})]})})}function N({onApply:e,title:n}){let[i,a]=r(``);return t(`form`,{class:`vw-base`,onSubmit:t=>{t.preventDefault(),/^https?:\/\//i.test(i.trim())&&e(i.trim().replace(/\/$/,``))},children:[t(`p`,{children:`This document gives its server as a relative address. Enter where the API is to make live calls, or continue with mock data only.`}),t(`input`,{type:`url`,placeholder:`https://api.example.com`,"aria-label":`Base URL for ${n}`,value:i,onInput:e=>a(e.target.value)}),t(`button`,{type:`submit`,class:`btn primary`,children:`Use this base URL`}),t(`button`,{type:`button`,class:`link`,onClick:()=>e(void 0),children:`Continue with mock data`})]})}u().then(n=>{n||e(t(M,{initial:{kind:`idle`}}),O)});