@specbook/ui 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-viewer/THIRD-PARTY-NOTICES.txt +0 -66
- package/dist-viewer/assets/Host-ClcN3YPO.js +41 -0
- package/dist-viewer/assets/{index-D59fkVA9.js → index-BcHcUWbc.js} +1 -1
- package/dist-viewer/assets/main-CAlriyIm.js +15 -0
- package/dist-viewer/assets/{mount-CLHBtIzR.js → mount-D3holu10.js} +2 -2
- package/dist-viewer/assets/{worker-BmvGpsJS.js → worker-13v89DyZ.js} +13 -13
- package/dist-viewer/index.html +2 -2
- package/dist-viewer/specbook.js +1 -1
- package/package.json +4 -4
- package/src/app.tsx +10 -3
- package/src/branding.ts +2 -1
- package/src/engine.ts +17 -0
- package/src/panel/RequestPanel.tsx +33 -1
- package/src/panel/SequencePanel.tsx +8 -1
- package/src/store.ts +2 -0
- package/src/styles/app.css +1 -1
- package/src/viewer/mount.ts +1 -18
- package/src/viewer/registry.ts +7 -13
- package/dist-viewer/assets/Host-DsO9W5X8.js +0 -41
- package/dist-viewer/assets/faker-B3c03STC.js +0 -11
- package/dist-viewer/assets/main-i06Egg5h.js +0 -14
- package/dist-viewer/assets/registry-b_jzfqy0.js +0 -2
- package/src/viewer/faker-en.ts +0 -3
package/dist-viewer/index.html
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
<title>Specbook</title>
|
|
8
8
|
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
|
|
9
9
|
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-BcHcUWbc.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="./assets/panel-nV09I7Wr.js">
|
|
12
|
-
<link rel="modulepreload" crossorigin href="./assets/mount-
|
|
12
|
+
<link rel="modulepreload" crossorigin href="./assets/mount-D3holu10.js">
|
|
13
13
|
<link rel="stylesheet" crossorigin href="./assets/panel-l1xvY4kI.css">
|
|
14
14
|
<link rel="stylesheet" crossorigin href="./assets/index-Ds6DZpGP.css">
|
|
15
15
|
</head>
|
package/dist-viewer/specbook.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t,t as n}from"./assets/mount-
|
|
1
|
+
import{a as e,r as t,t as n}from"./assets/mount-D3holu10.js";function r(){let e=document.getElementById(`specbook-config`);if(e?.textContent)try{return JSON.parse(e.textContent)}catch{}let t=document.querySelector(`script[src$="specbook.js"][data-spec]`);return{spec:t?.dataset.spec,baseUrl:t?.dataset.baseUrl,defaultEnv:t?.dataset.defaultEnv}}function i(e){let t=e?document.querySelector(e):document.getElementById(`app`);if(t)return t;let n=document.createElement(`div`);return n.id=`app`,document.body.append(n),n}var a=(e,t,n=!1)=>{e.textContent=t,e.style.cssText=`font:16px system-ui,sans-serif;padding:24px;color:${n?`#b42318`:`#5b6270`}`};async function o(){if(await e({stripWhenUnclaimed:!1}))return;let o=r(),s=i(o.target);if(!o.spec)return a(s,`Specbook: no spec was given (set "spec" in #specbook-config).`,!0);let c;try{c=new URL(o.spec,location.href).toString()}catch{return a(s,`Specbook: "${o.spec}" is not a valid address.`,!0)}a(s,`Loading the API…`);let l=new t;try{let e=await l.open({kind:`url`,url:c}).promise;s.textContent=``,s.removeAttribute(`style`),await n({result:e,worker:l,source:{kind:`url`,url:c},baseUrl:o.baseUrl,defaultEnv:typeof o.defaultEnv==`string`?o.defaultEnv:void 0,shareable:!1,setTitle:!1})}catch(e){a(s,`Specbook: ${e instanceof Error?e.message:String(e)}`,!0)}}o();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@specbook/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "The Specbook docs app, spec viewer and embeddable specbook.js.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"specbook",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@preact/signals": "2.11.3",
|
|
32
|
-
"@specbook/codegen": "0.
|
|
33
|
-
"@specbook/core": "0.
|
|
32
|
+
"@specbook/codegen": "0.5.0",
|
|
33
|
+
"@specbook/core": "0.5.0",
|
|
34
34
|
"preact": "11.0.1",
|
|
35
35
|
"prism-code-editor": "^5.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@faker-js/faker": "9.3.0",
|
|
39
|
-
"@specbook/vite": "0.
|
|
39
|
+
"@specbook/vite": "0.5.0",
|
|
40
40
|
"@vitest/browser-playwright": "5.0.3",
|
|
41
41
|
"playwright": "1.64.0",
|
|
42
42
|
"typescript": "7.0.2",
|
package/src/app.tsx
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
environmentNote,
|
|
20
20
|
environmentRisk,
|
|
21
21
|
environments,
|
|
22
|
+
fakerInUse,
|
|
22
23
|
locale,
|
|
23
24
|
newEnvironmentOpen,
|
|
24
25
|
seed,
|
|
@@ -291,12 +292,17 @@ export function App() {
|
|
|
291
292
|
{registry.loadFaker && (
|
|
292
293
|
<span
|
|
293
294
|
class="row muted"
|
|
294
|
-
title=
|
|
295
|
+
title={
|
|
296
|
+
fakerInUse.value
|
|
297
|
+
? 'Generated values such as {{faker.person.fullName}}: new on every run, or fixed so the same number always gives the same data. `specbook test --seed` reproduces a run.'
|
|
298
|
+
: 'Applies when the open request or flow uses {{faker.*}}'
|
|
299
|
+
}
|
|
295
300
|
>
|
|
296
301
|
<label class="row">
|
|
297
|
-
|
|
302
|
+
Generated values
|
|
298
303
|
<select
|
|
299
|
-
aria-label="
|
|
304
|
+
aria-label="Generated values"
|
|
305
|
+
disabled={!fakerInUse.value}
|
|
300
306
|
value={seed.value === undefined ? 'random' : 'fixed'}
|
|
301
307
|
onChange={(e) => {
|
|
302
308
|
const fixed = (e.target as HTMLSelectElement).value === 'fixed'
|
|
@@ -313,6 +319,7 @@ export function App() {
|
|
|
313
319
|
class="seed-input"
|
|
314
320
|
aria-label="Seed number"
|
|
315
321
|
title="The same number gives the same data every run"
|
|
322
|
+
disabled={!fakerInUse.value}
|
|
316
323
|
value={seed.value}
|
|
317
324
|
onInput={(e) => {
|
|
318
325
|
const n = (e.target as HTMLInputElement).valueAsNumber
|
package/src/branding.ts
CHANGED
|
@@ -87,7 +87,8 @@ export function applyBranding(
|
|
|
87
87
|
}
|
|
88
88
|
style.textContent = cfg ? brandCss(cfg) : ''
|
|
89
89
|
const name = resolved.name ?? fallbackName
|
|
90
|
-
|
|
90
|
+
if (globalThis.__SPECBOOK_VIEWER__?.setTitle !== false)
|
|
91
|
+
document.title = resolved.title ? `${name} · ${resolved.title}` : name
|
|
91
92
|
if (resolved.favicon || resolved.logo) {
|
|
92
93
|
let link = document.querySelector<HTMLLinkElement>('link[rel="icon"]')
|
|
93
94
|
if (!link) {
|
package/src/engine.ts
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
runSequence,
|
|
27
27
|
type Sequence,
|
|
28
28
|
type SpecbookConfig,
|
|
29
|
+
setFaker,
|
|
29
30
|
type Transport,
|
|
30
31
|
usesFaker,
|
|
31
32
|
withMock,
|
|
@@ -75,6 +76,8 @@ export interface Registry {
|
|
|
75
76
|
loadConfig: (v: number) => Promise<{ default: any }>
|
|
76
77
|
/** Project's @faker-js/faker (ESM), when installed. */
|
|
77
78
|
loadFaker?: ((v: number) => Promise<Record<string, any>>) | null
|
|
79
|
+
/** Said when a run uses `{{faker.*}}` and there is no faker (the hosted viewer ships none). */
|
|
80
|
+
fakerUnavailable?: string
|
|
78
81
|
mode?: 'dev' | 'static'
|
|
79
82
|
/** variables from `.specbook/environments/<env>.env`, baked in at build time */
|
|
80
83
|
environmentVars?: Record<string, Record<string, string>>
|
|
@@ -138,6 +141,20 @@ const text = (v: unknown) =>
|
|
|
138
141
|
v !== null && typeof v === 'object' ? JSON.stringify(v) : String(v ?? '')
|
|
139
142
|
|
|
140
143
|
export function createEngine(reg: Registry, opts: EngineOptions = {}) {
|
|
144
|
+
// no faker to load: a `{{faker.*}}` ends the run with the registry's message, not "install @faker-js/faker"
|
|
145
|
+
if (!reg.loadFaker && reg.fakerUnavailable) {
|
|
146
|
+
const message = reg.fakerUnavailable
|
|
147
|
+
setFaker(
|
|
148
|
+
new Proxy(
|
|
149
|
+
{},
|
|
150
|
+
{
|
|
151
|
+
get() {
|
|
152
|
+
throw new Error(message)
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
),
|
|
156
|
+
)
|
|
157
|
+
}
|
|
141
158
|
const mockLoader = {
|
|
142
159
|
statuses: (service: string, opId: string) =>
|
|
143
160
|
reg.manifests[service]?.operations.find((o) => o.id === opId)?.statuses ?? [],
|
|
@@ -13,7 +13,16 @@ import { engine, isStatic, registry, saveFile } from '../runtime'
|
|
|
13
13
|
import { type Defs, type JsonSchema, propsOf, unwrap } from '../schema'
|
|
14
14
|
import { statusClass, statusName } from '../status'
|
|
15
15
|
import { kv } from '../storage'
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
env,
|
|
18
|
+
envSettingsOpen,
|
|
19
|
+
envVarsVersion,
|
|
20
|
+
fakerInUse,
|
|
21
|
+
features,
|
|
22
|
+
locale,
|
|
23
|
+
seed,
|
|
24
|
+
version,
|
|
25
|
+
} from '../store'
|
|
17
26
|
import { announcement, describeRun } from './announce'
|
|
18
27
|
import { Body } from './Body'
|
|
19
28
|
import { DraftCodeSample } from './CodeSample'
|
|
@@ -248,6 +257,29 @@ export function RequestPanel({ service, op, variants, initial, autoRun }: Props)
|
|
|
248
257
|
}
|
|
249
258
|
}, [draft, encoding])
|
|
250
259
|
|
|
260
|
+
// the header's Generated values control applies while this request can use faker: a `{{faker.*}}` in what is
|
|
261
|
+
// typed, or an `init`/`data` function in a saved request
|
|
262
|
+
const usesFakerNow = useMemo(() => {
|
|
263
|
+
const input = saved?.def.input
|
|
264
|
+
if (Object.values(input?.init ?? {}).some((v) => typeof v === 'function')) return true
|
|
265
|
+
if (typeof input?.data === 'function') return true
|
|
266
|
+
if (!draft) return false
|
|
267
|
+
try {
|
|
268
|
+
const parts = requestParts(draft, encoding)
|
|
269
|
+
return [
|
|
270
|
+
...collectPlaceholders([parts.path, parts.query, parts.headers, parts.data, vars]),
|
|
271
|
+
].some((n) => n.startsWith('faker.'))
|
|
272
|
+
} catch {
|
|
273
|
+
return false
|
|
274
|
+
}
|
|
275
|
+
}, [saved, draft, encoding, vars])
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
fakerInUse.value = usesFakerNow
|
|
278
|
+
return () => {
|
|
279
|
+
fakerInUse.value = false
|
|
280
|
+
}
|
|
281
|
+
}, [usesFakerNow])
|
|
282
|
+
|
|
251
283
|
// placeholders nothing supplies: not in config or the environment's files. They stay listed while
|
|
252
284
|
// you type, so the field you are filling does not disappear under you.
|
|
253
285
|
// a saved request brings the values of its own `init`: they are what a run uses, so nothing is missing
|
|
@@ -4,7 +4,7 @@ import { EnvBadge } from '../components/EnvBadge'
|
|
|
4
4
|
import { defaultFor, type FieldSpec, specFromControl } from '../components/Fields'
|
|
5
5
|
import type { SequenceInfo } from '../engine'
|
|
6
6
|
import { engine } from '../runtime'
|
|
7
|
-
import { env, locale, seed, version } from '../store'
|
|
7
|
+
import { env, fakerInUse, locale, seed, version } from '../store'
|
|
8
8
|
import { announcement, describeRun } from './announce'
|
|
9
9
|
import { Failure } from './Checks'
|
|
10
10
|
import { ControlsGrid } from './ControlsGrid'
|
|
@@ -80,6 +80,13 @@ export function SequencePanel({
|
|
|
80
80
|
// a flow with inputs can run on their defaults alone, as `specbook test` does
|
|
81
81
|
const hasInputs = Object.keys(specs).length > 0 || seq.nodes.some((n) => n.kind === 'input')
|
|
82
82
|
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
fakerInUse.value = hasGenerated
|
|
85
|
+
return () => {
|
|
86
|
+
fakerInUse.value = false
|
|
87
|
+
}
|
|
88
|
+
}, [hasGenerated])
|
|
89
|
+
|
|
83
90
|
/** Every input at its default; a generated one needs faker, which is made ready first. */
|
|
84
91
|
const freshInputs = async () => {
|
|
85
92
|
if (hasGenerated)
|
package/src/store.ts
CHANGED
|
@@ -10,6 +10,8 @@ export const environmentRisk = signal<Record<string, 'production' | 'sandbox'>>(
|
|
|
10
10
|
export const environmentNote = signal<Record<string, string>>({})
|
|
11
11
|
export const locale = signal<string | undefined>(undefined)
|
|
12
12
|
export const seed = signal<number | undefined>(undefined)
|
|
13
|
+
/** Whether the request or flow that is open can use generated values; the header's control is enabled while it is. */
|
|
14
|
+
export const fakerInUse = signal(false)
|
|
13
15
|
/** Bumped when an environment's variables change, so what is derived from them (addresses, origins) is redone. */
|
|
14
16
|
export const envVarsVersion = signal(0)
|
|
15
17
|
/** Whether Environment settings is open; set from elsewhere to point a person at it. */
|
package/src/styles/app.css
CHANGED
|
@@ -749,7 +749,7 @@
|
|
|
749
749
|
width: 56%;
|
|
750
750
|
min-width: 0;
|
|
751
751
|
}
|
|
752
|
-
/*
|
|
752
|
+
/* Generated values is a row inside a row (its label and, once fixed, a seed field): the inner one fills it */
|
|
753
753
|
.header-controls .row > .row {
|
|
754
754
|
flex: 1 1 100%;
|
|
755
755
|
}
|
package/src/viewer/mount.ts
CHANGED
|
@@ -21,6 +21,7 @@ export async function mountOpened(o: {
|
|
|
21
21
|
open: o.result,
|
|
22
22
|
baseUrl: o.baseUrl,
|
|
23
23
|
defaultEnv: o.defaultEnv,
|
|
24
|
+
setTitle: o.setTitle,
|
|
24
25
|
source:
|
|
25
26
|
o.shareable === false
|
|
26
27
|
? undefined
|
|
@@ -33,22 +34,4 @@ export async function mountOpened(o: {
|
|
|
33
34
|
globalThis.__SPECBOOK_VIEWER__ = g
|
|
34
35
|
if (o.setTitle !== false) document.title = `${o.result.title} · Specbook`
|
|
35
36
|
await import('../main')
|
|
36
|
-
warmFaker()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Mock responses are generated with the spec, so the first mock request needs no faker. Faker (a
|
|
41
|
-
* sizeable chunk) is only used by "Dynamic" examples and `{{faker.*}}` values, so it is fetched when the
|
|
42
|
-
* page has been idle for a moment instead of up front: by the time someone picks Dynamic it is cached.
|
|
43
|
-
*/
|
|
44
|
-
function warmFaker() {
|
|
45
|
-
if ((navigator as Navigator & { connection?: { saveData?: boolean } }).connection?.saveData)
|
|
46
|
-
return
|
|
47
|
-
const idle: (f: () => void) => void =
|
|
48
|
-
(window as unknown as { requestIdleCallback?: (f: () => void) => void }).requestIdleCallback ??
|
|
49
|
-
((f) => setTimeout(f, 1500))
|
|
50
|
-
idle(() => {
|
|
51
|
-
// the registry's loader is the same import the run would make
|
|
52
|
-
void import('./registry').then((r) => r.loadFaker()).catch(() => {})
|
|
53
|
-
})
|
|
54
37
|
}
|
package/src/viewer/registry.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface ViewerGlobal {
|
|
|
14
14
|
baseUrl?: string
|
|
15
15
|
/** the environment to show first, when it is one the document offers (otherwise `mock`) */
|
|
16
16
|
defaultEnv?: string
|
|
17
|
+
/** false on a page that is not the viewer's own (an embed), where the host's title stays */
|
|
18
|
+
setTitle?: boolean
|
|
17
19
|
/** where the document came from, which decides whether a link to this view can be shared */
|
|
18
20
|
source?: import('./share').ViewerSource
|
|
19
21
|
}
|
|
@@ -126,18 +128,12 @@ export const operations = Object.fromEntries(
|
|
|
126
128
|
) as Record<string, () => Promise<Record<string, any>>>
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
+
* The hosted viewer and the embed ship no faker: a spec's mock and example values come from the generator, and a
|
|
132
|
+
* `{{faker.*}}` someone types is refused with this message instead of being sent as it is.
|
|
131
133
|
*/
|
|
132
|
-
export const loadFaker =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
// a run asks for its locale and `base`, the fallback every locale chain ends in
|
|
136
|
-
locales: {
|
|
137
|
-
en: () => Promise.resolve(m.en),
|
|
138
|
-
base: () => Promise.resolve(m.base),
|
|
139
|
-
},
|
|
140
|
-
}))
|
|
134
|
+
export const loadFaker = null
|
|
135
|
+
export const fakerUnavailable =
|
|
136
|
+
'Generated values ({{faker.…}}) work in a Specbook project, not in the hosted viewer. Type a value instead.'
|
|
141
137
|
|
|
142
138
|
// `live` is the document's first server, or the address the person typed for it; the rest keep their own
|
|
143
139
|
// names. Each address is the variable `baseUrl` in its environment, so a copy of one can point elsewhere.
|
|
@@ -187,8 +183,6 @@ export const loadConfig = () =>
|
|
|
187
183
|
auth: open.auth,
|
|
188
184
|
...(Object.keys(vars).length ? { vars } : {}),
|
|
189
185
|
...(Object.keys(environmentSettings).length ? { environments: environmentSettings } : {}),
|
|
190
|
-
// one locale, so the header offers no locale choice
|
|
191
|
-
faker: { default: 'en', locales: { en: ['en', 'base'] } },
|
|
192
186
|
services: {
|
|
193
187
|
[service]: {
|
|
194
188
|
spec: '',
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,d as n,f as r,g as i,h as a,m as o,p as s,u as c,y as l}from"./panel-nV09I7Wr.js";import{i as u}from"./mount-CLHBtIzR.js";import{d,i as f,l as p}from"./registry-b_jzfqy0.js";import{A as m,C as h,D as g,E as _,M as v,N as y,O as b,S as x,T as S,_ as C,a as w,b as T,c as E,d as D,f as O,g as k,h as A,i as j,j as M,k as ee,l as te,m as ne,n as re,o as ie,p as ae,r as N,s as P,u as F,v as I,w as oe,x as se,y as L}from"./main-i06Egg5h.js";var R={200:`OK`,201:`Created`,202:`Accepted`,204:`No Content`,301:`Moved Permanently`,302:`Found`,304:`Not Modified`,400:`Bad Request`,401:`Unauthorized`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,422:`Unprocessable Entity`,429:`Too Many Requests`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`},ce=e=>R[e]??``;function le(e){if(typeof e==`string`)return e.includes(`
|
|
2
|
-
`)?e.split(`
|
|
3
|
-
`):[JSON.stringify(e)];if(e===void 0)return[`undefined`];try{return(JSON.stringify(e,null,2)??String(e)).split(`
|
|
4
|
-
`)}catch{return[String(e)]}}function ue(e,t){let n=[];if(e.length*t.length>25e4){for(let t of e)n.push({kind:`expected`,text:t});for(let e of t)n.push({kind:`received`,text:e});return n}let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=0,s=0;for(;o<r&&s<i;)e[o]===t[s]?(n.push({kind:`same`,text:e[o]}),o++,s++):a[o+1][s]>=a[o][s+1]?n.push({kind:`expected`,text:e[o++]}):n.push({kind:`received`,text:t[s++]});for(;o<r;)n.push({kind:`expected`,text:e[o++]});for(;s<i;)n.push({kind:`received`,text:t[s++]});return n}function de(e,t){let n=Array(e.length).fill(!1);e.forEach((r,i)=>{if(r.kind!==`same`)for(let r=Math.max(0,i-t);r<=Math.min(e.length-1,i+t);r++)n[r]=!0});let r=[],i=0,a=()=>{i>0&&r.push({kind:`skip`,text:`… ${i} unchanged line${i>1?`s`:``}`}),i=0};return e.forEach((e,t)=>{n[t]?(a(),r.push(e)):i++}),a(),r}function fe(e,t=3){if(e.operator===`status`){let t=typeof e.actual==`number`?`${e.actual} ${ce(e.actual)}`.trim():String(e.actual);return[{kind:`expected`,text:`status ${e.expected}`},{kind:`received`,text:`status ${t}`}]}return`expected`in e||`actual`in e?de(ue(le(e.expected),le(e.actual)),t):e.diff?e.diff.split(`
|
|
5
|
-
`).map(e=>({kind:`same`,text:e})):[]}var z=e=>typeof e==`string`?e:typeof e==`object`&&e?JSON.stringify(e):String(e);function pe(e={}){return Object.entries(e).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>e!=null).map(t=>({key:e,value:z(t),enabled:!0})))}function me(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 he(e){return typeof e!=`object`||!e?[]:v(e).map(([e,t])=>({key:e,value:t,enabled:!0}))}var ge=/[^[\]]+|\[\]/g;function _e(e,t,n){let[r,...i]=t;if(r===`[]`){let t=e??[];return t.push(i.length?_e(void 0,i,n):n),t}let a=e??(/^\d+$/.test(r)?[]:{}),o=a[r];return a[r]=i.length?_e(o,i,n):o===void 0?n:[...[].concat(o),n],a}function ve(e){let t={};for(let{key:n,value:r,enabled:i,file:a}of e)i&&n!==``&&(t=_e(t,n.match(ge)??[n],a&&y(a)?a:r));return t}var ye=/\{\{\s*(?:secrets\.([\w$-]+)|session\.([\w$.-]+))\s*\}\}/g,be=e=>new RegExp(ye.source).test(e),xe=e=>e.replace(/[^A-Za-z0-9_]/g,`_`);function Se(e){let t=[],n=0;for(let r of e.matchAll(ye))r.index>n&&t.push(e.slice(n,r.index)),t.push({env:r[1]?xe(r[1]):`SESSION_${xe(r[2])}`.toUpperCase()}),n=r.index+r[0].length;return n<e.length&&t.push(e.slice(n)),t}var Ce=e=>{let t=[];for(let[n,r]of Object.entries(e??{}))for(let e of Array.isArray(r)?r:[r])t.push(`${encodeURIComponent(n)}=${we(e)}`);return t.length?`?${t.join(`&`)}`:``};function we(e){return Se(e).map(e=>typeof e==`string`?encodeURIComponent(e):`{{secrets.${e.env}}}`).join(``)}function B(e){if(y(e))return!0;let t=e;return!!t&&typeof t==`object`&&typeof t.file==`string`&&`size`in t&&`type`in t}var Te=e=>e.name??e.file??`file`,Ee=e=>`'${e.replace(/'/g,`'\\''`)}'`;function V(e){return be(e)?`"${Se(e).map(e=>typeof e==`string`?e.replace(/[\\"`$]/g,e=>`\\${e}`):`\${${e.env}}`).join(``)}"`:Ee(e)}function De(e){let t=e.encoding??`json`,n=[V(`${e.url}${Ce(e.query)}`)],r=e.method.toUpperCase(),i={...e.headers??{}},a=e=>Object.keys(i).some(t=>t.toLowerCase()===e),o=e.body,s=[];if(o!==void 0&&o!==``&&t!==`none`){if(t===`json`||t===`graphql`){let e=JSON.stringify(typeof o==`string`&&t===`graphql`?{query:o}:o);s.push(`-d ${V(e)}`),a(`content-type`)||(i[`Content-Type`]=`application/json`)}else if(t===`form`)for(let[t,n]of v(o,e.formArrays))s.push(`--data-urlencode ${V(`${t}=${n}`)}`);else if(t===`multipart`)for(let[e,t]of Object.entries(o??{}))for(let n of Array.isArray(t)?t:[t])n!=null&&(B(n)?s.push(`-F ${V(`${e}=@${Te(n)}`)}`):s.push(`-F ${V(`${e}=${typeof n==`object`?JSON.stringify(n):String(n)}`)}`));else t===`binary`?(s.push(`--data-binary ${V(`@${B(o)?Te(o):`file`}`)}`),a(`content-type`)||(i[`Content-Type`]=B(o)&&o.type?o.type:`application/octet-stream`)):(s.push(`-d ${V(String(o))}`),a(`content-type`)||(i[`Content-Type`]=`text/plain`))}r!==(s.length?`POST`:`GET`)&&n.push(`-X ${r}`);for(let[e,t]of Object.entries(i))n.push(`-H ${V(`${e}: ${t}`)}`);return n.push(...s),`curl ${n.join(` \\
|
|
6
|
-
`)}`}var Oe=/^[A-Za-z_$][\w$]*$/;function H(e){return be(e)?`\`${Se(e).map(e=>typeof e==`string`?e.replace(/[\\`]|\$\{/g,e=>`\\${e}`):`\${process.env.${e.env}}`).join(``)}\``:`'${e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`).replace(/\n/g,`\\n`)}'`}var U=e=>Oe.test(e)?e:H(e);function ke(e,t){if(e==null)return`null`;if(typeof e==`string`)return H(e);if(typeof e!=`object`)return String(e);let n=`${t} `;if(Array.isArray(e))return e.length===0?`[]`:`[\n${e.map(e=>`${n}${ke(e,n)},`).join(`
|
|
7
|
-
`)}\n${t}]`;let r=Object.entries(e);return r.length===0?`{}`:`{\n${r.map(([e,t])=>`${n}${U(e)}: ${ke(t,n)},`).join(`
|
|
8
|
-
`)}\n${t}}`}function Ae(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(${ke(typeof a==`string`&&t===`graphql`?{query:a}:a,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/json`);else if(t===`form`){let t=v(a,e.formArrays);c=new Set(t.map(([e])=>e)).size===t.length?`new URLSearchParams(${ke(Object.fromEntries(t),` `)})`:`new URLSearchParams(${ke(t,` `)})`,i(`content-type`)||(r[`Content-Type`]=`application/x-www-form-urlencoded`)}else if(t===`multipart`){s.push(`const form = new FormData()`);for(let[e,t]of Object.entries(a??{}))for(let n of Array.isArray(t)?t:[t])if(n!=null){if(B(n)){l=!0;let t=Te(n);s.push(`form.append(${H(e)}, await openAsBlob(${H(t)}), ${H(t)})`)}else s.push(`form.append(${H(e)}, ${H(typeof n==`object`?JSON.stringify(n):String(n))})`)}c=`form`}else t===`binary`?(l=!0,c=`await openAsBlob(${H(B(a)?Te(a):`file`)})`,i(`content-type`)||(r[`Content-Type`]=B(a)&&a.type?a.type:`application/octet-stream`)):(c=H(String(a)),i(`content-type`)||(r[`Content-Type`]=`text/plain`))}let u=`${e.url}${Ce(e.query)}`,d=[];n!==`GET`&&d.push(` method: ${H(n)},`),Object.keys(r).length&&d.push(` headers: {\n${Object.entries(r).map(([e,t])=>` ${U(e)}: ${H(t)},`).join(`
|
|
9
|
-
`)}\n },`),c&&d.push(` body: ${c},`);let f=l?[`import { openAsBlob } from 'node:fs'`,``]:[],p=d.length===0?`const res = await fetch(${H(u)})`:`const res = await fetch(${H(u)}, {\n${d.join(`
|
|
10
|
-
`)}\n})`;return[...f,...s,p,`console.log(res.status, await res.text())`].join(`
|
|
11
|
-
`)}function je(e,t){return e===`curl`?De(t):Ae(t)}var Me=[{id:`curl`,label:`cURL`},{id:`fetch`,label:`Node fetch`}],W=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`);function Ne(e){let t=[],n=e.replace(/`([^`]+)`/g,(e,n)=>(t.push(`<code>${n}</code>`),`\uE000${t.length-1}\uE000`));return n=n.replace(/\[([^\]]+)\]\(((?:https?:\/\/|mailto:)[^)\s]+)\)/g,(e,t,n)=>`<a href="${n}" target="_blank" rel="noreferrer">${t}</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/(^|[\s(])\*([^*\s][^*]*)\*(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`).replace(/(^|[\s(])_([^_\s][^_]*)_(?=[\s).,;:!?]|$)/g,`$1<em>$2</em>`),n.replace(/\uE000(\d+)\uE000/g,(e,n)=>t[Number(n)]??``)}function Pe(e){if(!e)return``;let t=e.replace(/\r\n?/g,`
|
|
12
|
-
`).split(`
|
|
13
|
-
`),n=[],r=[],i,a=()=>{r.length&&n.push(`<p>${Ne(W(r.join(` `)))}</p>`),r=[]},o=()=>{i&&n.push(`<${i.tag}>${i.items.map(e=>`<li>${Ne(W(e))}</li>`).join(``)}</${i.tag}>`),i=void 0};for(let e=0;e<t.length;e++){let s=t[e];if(/^```/.test(s)){a(),o();let r=[];for(e++;e<t.length&&!/^```/.test(t[e]);)r.push(t[e++]);n.push(`<pre><code>${W(r.join(`
|
|
14
|
-
`))}</code></pre>`);continue}let c=/^(#{1,4})\s+(.*)$/.exec(s);if(c){a(),o();let e=Math.min(4,c[1].length+1);n.push(`<h${e}>${Ne(W(c[2]))}</h${e}>`);continue}let l=/^>\s?(.*)$/.exec(s);if(l){a(),o();let r=[l[1]];for(;e+1<t.length&&/^>\s?/.test(t[e+1]);)r.push(t[++e].replace(/^>\s?/,``));n.push(`<blockquote>${Ne(W(r.join(` `)))}</blockquote>`);continue}let u=/^\s*[-*+]\s+(.*)$/.exec(s),d=/^\s*\d+[.)]\s+(.*)$/.exec(s);if(u||d){a();let e=u?`ul`:`ol`;i&&i.tag!==e&&o(),i??={tag:e,items:[]},i.items.push((u??d)?.[1])}else s.trim()===``?(a(),o()):(o(),r.push(s.trim()))}return a(),o(),n.join(``)}function Fe(e){return e?e.replace(/```[\s\S]*?```/g,` `).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,``).replace(/^>\s?/gm,``).replace(/[`*]|(^|\s)_|_(?=\s|$)/g,`$1`).replace(/\s+/g,` `).trim():``}function Ie(e){return e?(e.trim().split(/\n\s*\n/)[0]??``).replace(/\s*\n\s*/g,` `).trim():``}function Le(e){return e?Ne(W(e)):``}function Re(e,t=300){let n=Ie(e);if(!n)return``;let r=Fe(n);return r.length>t?W(`${r.slice(0,t-1).trimEnd()}…`):Le(n)}var G=/^\s*\{\{[^}]+\}\}\s*$/,ze=e=>typeof e==`string`&&G.test(e);function Be(e){return e?.type===`string`&&typeof e.pattern==`string`&&e.pattern.includes(`\\{\\{`)}var Ve=[`title`,`description`,`default`,`examples`,`deprecated`];function He(e,t){let n={...e};for(let e of Ve)t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);return n}function K(e,t){let n=e??{};for(let e=0;e<12&&n.$ref;e++){let e=String(n.$ref).split(`/`).pop(),r=t?.$defs?.[e];if(!r)return{...n,type:void 0};n=He(r,n)}return n}function q(e,t,n=0){let r=K(e,t);if(n>10)return r;if(Array.isArray(r.anyOf)){let e=r.anyOf.filter(e=>!Be(e));if(e.length===1||e.length>1)return q(He(e[0],r),t,n+1)}if(Array.isArray(r.oneOf)&&r.oneOf.length)return q(He(r.oneOf[0],r),t,n+1);if(Array.isArray(r.allOf)){let e={...r};Reflect.deleteProperty(e,`allOf`);let i={...e.properties??{}},a=new Set(e.required??[]);for(let o of r.allOf){let r=q(o,t,n+1);Object.assign(i,r.properties??{});for(let e of r.required??[])a.add(e);for(let t of Ve)r[t]!==void 0&&e[t]===void 0&&(e[t]=r[t]);r.type&&!e.type&&(e.type=r.type),r.items&&!e.items&&(e.items=r.items),r.enum&&!e.enum&&(e.enum=r.enum)}e.properties=i,e.required=[...a],!e.type&&Object.keys(i).length&&(e.type=`object`),r=e}return r}function J(e){let t=Array.isArray(e.type)?e.type.find(e=>e!==`null`):e.type;return t===`object`||t===`array`||t===`string`||t===`integer`||t===`number`||t===`boolean`?t:e.properties?`object`:e.items?`array`:e.enum?typeof e.enum[0]==`number`?`number`:`string`:t===`null`?`null`:`unknown`}function Ue(e){let t=e.description??e.title;return typeof t==`string`&&t.trim()?t.trim():void 0}function We(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 Ge(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 Ke(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 qe=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e;function Je(e,t,n){let r=K(e,n),i=(r.oneOf??r.anyOf)?.filter(e=>!Be(e));if(!i?.length)return q(r,n);let a=qe(t);return q(He(i.find(e=>{let t=J(q(e,n));return t===a||t===`integer`&&a===`number`||t===`number`&&a===`number`})??i[0],r),n)}function Ye(e,t,n,r={},i=``,a=0){if(!t||a>12||ze(e))return[];let o=Je(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=qe(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(...Ye(c,l[e],n,r,t,a+1)):o.additionalProperties&&typeof o.additionalProperties==`object`?s.push(...Ye(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(...Ye(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 Xe=e=>e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``);function Ze(e){let t=[void 0],n=[],r=0,i=e=>{t[r]===void 0&&(t[r]=e)},a=()=>n[n.length-1],o=e=>e?e.type===`arr`?[...e.path,e.idx]:e.key===void 0?void 0:[...e.path,e.key]:[];for(let s=0;s<e.length;s++){let c=e[s];if(c===`
|
|
15
|
-
`)r++,t[r]=void 0;else if(c===`"`){let t=s+1,n=``;for(;t<e.length&&e[t]!==`"`;)e[t]===`\\`?(n+=e[t+1]??``,t+=2):n+=e[t++];let r=t+1;for(;r<e.length&&/\s/.test(e[r])&&e[r]!==`
|
|
16
|
-
`;)r++;let o=a();o?.type===`obj`&&e[r]===`:`?(o.key=n,i([...o.path,n])):o?.type===`arr`&&i([...o.path,o.idx]),s=t}else if(c===`{`||c===`[`){let e=o(a());e&&i(e),n.push({type:c===`{`?`obj`:`arr`,path:e??[],idx:0})}else if(c===`}`||c===`]`){n.pop();let e=a();e?.type===`arr`&&e.idx++}else if(c===`,`)a();else if(/[-\d]|[tfn]/.test(c)){let t=a();if(t?.type===`arr`){i([...t.path,t.idx]);let n=s;for(;n<e.length&&!/[,\]\n]/.test(e[n]);)n++;e[n]===`,`&&t.idx++,s=n-1}}}return t}function Qe(e,t,n){let r=e;for(let e of t){if(!r)return;r=Ke(r,e,n)}return r}var $e={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`},et=e=>$e[e]??(e>=500?`Server error`:e>=400?`Client error`:`Response`),tt=e=>e>=500?`s5`:e>=400?`s4`:e>=300?`s3`:`s2`,nt=new Set([`path`,`query`,`headers`,`data`]),rt=e=>(e.match(/[^.[\]]+/g)??[]).filter(e=>!/^\d+$/.test(e));function it(e,t){return[e,...rt(t)].join(`.`)}function at(e){let t=rt(e.trim());if(t.length===0)return;let n=t[0];return t.length>=2&&nt.has(n)?t.join(`.`):[`data`,...t].join(`.`)}var ot=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`);function st(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?at(ot(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 ct=60;function lt(e,t){let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n}function ut(e,t,n=0,r=``){if(!e||n>2)return[];let i=[];for(let a of Ge(e,t)){let e=q(a.schema,t),o=r?`${r}.${a.name}`:a.name;i.push({name:o,depth:n,type:lt(e,t),required:a.required,description:Ue(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(...ut(s,t,n+1,o))}return i}function dt({schema:e,defs:n,section:r=`data`,notes:i}){let a=ut(e,n);return a.length===0?null:t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Field`}),t(`th`,{children:`Type`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:[a.slice(0,ct).map(e=>t(`tr`,{children:[t(`td`,{style:{paddingLeft:`${e.depth*16+8}px`},children:[t(`code`,{children:e.name.split(`.`).pop()}),e.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}),t(`td`,{children:t(`span`,{class:`chip`,children:e.type})}),t(`td`,{children:[t(`span`,{class:`doc-inline wrap`,dangerouslySetInnerHTML:{__html:Re(e.description,220)}}),i?.get(it(r,e.name))&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:i.get(it(r,e.name))}}),e.enum&&t(`span`,{class:`field-doc-enum`,children:[` `,e.enum.map(e=>t(`code`,{children:e}))]})]})]})),a.length>ct&&t(`tr`,{children:t(`td`,{colSpan:3,class:`muted`,children:[`+`,a.length-ct,` more fields in the spec`]})})]})]})}var ft={intro:``,notes:new Map,replace:!1,found:!1};function pt(e){let[t,r]=a(),[i,s]=a(!1),c=w.docs.find(t=>t.operation===e);return n(()=>{let e=!0;return r(void 0),s(!c),c?.load().then(t=>e&&r(t)).catch(()=>{}).finally(()=>e&&s(!0)),()=>{e=!1}},[e,c]),o(()=>!c||t===void 0?{...ft,loaded:i}:{...st(t),replace:!!c.replace,found:!0,loaded:i},[t,c,i])}var mt=[[`path`,`Path`],[`query`,`Query`],[`headers`,`Headers`]],ht=e=>(e??Promise.resolve(void 0)).catch(()=>void 0);function gt(e,t,n){return Promise.all([ht(w.operationDocs[e]?.().then(e=>e.default)),ht(w.schemas[e]?.().then(e=>e.default)),ht(w.definitions[t]?.().then(e=>e.default)),Promise.all(n.map(e=>ht(w.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 _t({variant:e,html:n}){return n?t(`section`,{class:`saved-note-doc`,children:[t(`h2`,{children:[`Request `,t(`code`,{children:e.name})]}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:n}})]}):null}function vt({service:e,op:r,variants:i=[],onTry:o}){let s=`${e}/${r.id}`,[c,u]=a(),d=i.map(e=>e.file).join(`
|
|
17
|
-
`);n(()=>{let t=!0;return u(void 0),gt(s,e,d?d.split(`
|
|
18
|
-
`):[]).then(e=>t&&u(e)),()=>{t=!1}},[s,e,d]);let f=pt(s),p=!!c&&f.loaded,{long:m,req:h,defs:g}=c??{saved:{}},_=h?q(h,g):void 0,v=e=>_?.properties?.[e],y=v(`data`);return t(`article`,{class:`doc`,"data-op":s,children:[t(`div`,{class:`doc-intro`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path}),t(`span`,{class:`spacer`}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>o(),children:`Try it`})]}),p&&t(l,{children:[!(f.found&&f.replace)&&m?.description&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:Pe(m.description)}}),f.intro&&t(`div`,{class:`doc-custom ${f.replace?``:`doc-project`}`,dangerouslySetInnerHTML:{__html:f.intro}}),i.map(e=>t(_t,{variant:e,html:c?.saved[e.file]},e.file)),mt.map(([e,n])=>v(e)?t(`section`,{children:[t(`h2`,{children:[n,` parameters`]}),t(dt,{schema:v(e),defs:g,section:e,notes:f.notes})]}):null),y&&t(`section`,{children:[t(`h2`,{children:`Request body`}),t(dt,{schema:y,defs:g,section:`data`,notes:f.notes})]}),r.statuses.length>0&&t(`section`,{children:[t(`h2`,{children:`Responses`}),t(`ul`,{class:`statuses`,children:r.statuses.map(e=>t(`li`,{children:[t(`span`,{class:`state-badge ${tt(e)}`,children:e}),` `,et(e)]}))})]}),(m?.examples.length??0)>1&&t(`section`,{children:[t(`h2`,{children:`Examples`}),t(`ul`,{class:`examples`,children:m?.examples.map(e=>t(`li`,{children:t(`button`,{type:`button`,class:`link`,onClick:()=>o(e.name),children:[`▶ `,e.title]})}))})]})]})]})}var yt=c(``);function bt(e){if(e.kind===`request`){let t=e.steps.find(e=>e.response)??e.steps[0];if(!t?.response)return e.status===`error`?`The request could not be sent.`:`Done.`;let n=t.assertions.filter(e=>!e.pass).length;return`${t.response.status}, ${e.durationMs} milliseconds${n?`, ${n} check${n===1?``:`s`} failed`:``}.`}return`Flow ${e.status===`pass`?`passed`:e.status===`fail`?`failed`:`could not run`}, ${e.totals.passed} of ${e.totals.steps} steps passed.`}var xt=class extends e{state={};componentDidCatch(e){console.error(`specbook: a panel could not be drawn`,e),this.setState({error:e instanceof Error?e:Error(String(e))})}render(){let{error:e}=this.state;return e?t(`div`,{class:`panel-error`,role:`alert`,children:[t(`p`,{children:[t(`strong`,{children:`This could not be shown.`}),` The run finished, but what it returned could not be drawn.`]}),t(`pre`,{children:e.message}),t(`button`,{type:`button`,class:`btn`,onClick:()=>this.setState({error:void 0}),children:`Try drawing it again`})]}):this.props.children}},St=0,Ct=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function wt({title:e,subtitle:i,flush:a,modal:c=!0,variant:u=`side`,onPrev:d,onNext:f,onClose:p,children:m}){let h=s(null),g=o(()=>`sb-panel-title-${++St}`,[]);return n(()=>()=>{yt.value=``},[]),n(()=>{let e=h.current?.getRootNode()?.activeElement;return c&&h.current?.focus(),()=>e?.focus?.()},[c]),n(()=>{let e=h.current;if(!e||typeof matchMedia>`u`)return;let t=matchMedia(`(max-width: 820px)`),n=`input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea`,r,i=[],a=t=>{for(let n=t.parentElement;n&&n!==e;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`)return n}return null},o=e=>{let t=a(e);if(!t)return;let n=typeof visualViewport>`u`?void 0:visualViewport,r=n?.offsetTop??0,i=n?.height??innerHeight,o=e.getBoundingClientRect().top,s=e.getAttribute(`role`)===`combobox`,c=r+i*(s?.3:.2);(o>r+i*(s?.55:.4)||o<r)&&(t.scrollTop+=o-c)},s=e=>{let s=e.target;if(!t.matches||!s.matches?.(n))return;let c=a(s),l=typeof visualViewport>`u`?void 0:visualViewport,u=s.getBoundingClientRect().top>(l?.offsetTop??0)+(l?.height??innerHeight)*.55;c&&r?.box!==c&&(s.getAttribute(`role`)!==`combobox`||u)&&(r&&(r.box.style.paddingBottom=r.was),r={box:c,was:c.style.paddingBottom},c.style.paddingBottom=`70vh`);for(let e of i)clearTimeout(e);i=[0,150,400,800].map(e=>window.setTimeout(()=>o(s),e))},c=()=>{i.push(window.setTimeout(()=>{!e.getRootNode().activeElement?.matches?.(n)&&r&&(r.box.style.paddingBottom=r.was,r=void 0)},200))};return e.addEventListener(`focusin`,s),e.addEventListener(`focusout`,c),()=>{e.removeEventListener(`focusin`,s),e.removeEventListener(`focusout`,c);for(let e of i)clearTimeout(e);r&&(r.box.style.paddingBottom=r.was)}},[]),r(()=>{let e=e=>{if(e.key===`Escape`&&p(),e.key!==`Tab`||!c||!h.current)return;let t=[...h.current.querySelectorAll(Ct)].filter(e=>e.offsetParent!==null),n=t[0],r=t[t.length-1],i=h.current.getRootNode().activeElement;n&&r&&(e.shiftKey&&(i===n||i===h.current)?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus()))},t=c&&h.current?h.current:window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)},[p,c]),t(l,{children:[c&&t(`button`,{type:`button`,class:`panel-backdrop`,"aria-label":`Close`,onClick:p}),t(`section`,{class:`panel ${c?``:`docked`} ${u===`popover`?`popover`:``}`,part:`panel`,"aria-labelledby":g,"aria-modal":c?!0:void 0,role:c?`dialog`:`complementary`,tabIndex:-1,ref:h,children:[t(`header`,{class:`panel-head`,part:`header`,children:[t(`div`,{class:`panel-title`,children:[t(`h2`,{id:g,children:e}),i&&t(`div`,{class:`muted small`,children:i})]}),t(`span`,{class:`spacer`}),c&&D.value.length>1&&t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Environment`}),t(`select`,{value:P.value,onChange:e=>P.value=e.target.value,children:D.value.map(e=>t(`option`,{value:e,title:F.value[e],children:e}))})]}),(d||f)&&t(`span`,{class:`stepper`,children:[t(`button`,{type:`button`,class:`icon`,title:`Previous`,"aria-label":`Previous`,disabled:!d,onClick:d,children:`↑`}),t(`button`,{type:`button`,class:`icon`,title:`Next`,"aria-label":`Next`,disabled:!f,onClick:f,children:`↓`})]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Close panel`,onClick:p,children:`×`})]}),t(`div`,{class:`panel-body ${a?`flush`:``}`,children:t(xt,{children:m})}),t(`div`,{class:`visually-hidden`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:yt.value})]})]})}function Tt(e,t,n,r=[]){if(!e)return;let i=[...r,...n],a=i.length===0?e:Qe(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=Qe(e,i.slice(0,-1),t),l=J(o),u=l===`array`?J(q(o.items,t)):void 0;return{path:Xe(n),type:u?`${u}[]`:o.format?`${l} · ${o.format}`:l,required:typeof s==`string`&&!!c&&Ge(c,t).some(e=>e.name===s&&e.required),enum:Array.isArray(o.enum)?o.enum.map(String):void 0,description:Ue(o),parent:c?Ue(q(c,t)):void 0,deprecated:o.deprecated===!0||void 0}}function Et(e){return(e.match(/[^[\]]+/g)??[e]).map(e=>/^\d+$/.test(e)?Number(e):e)}function Dt(e,t,n,r){let i=e&&t?.get(it(n,r));return e&&i?{...e,note:i}:e}var Ot={},kt=Symbol(),At=Symbol(),jt=e=>typeof e==`string`?Mt[e]:e,Mt={plain:Ot,plaintext:Ot,text:Ot,txt:Ot},Nt=(e,t)=>(t[At]||Pt)(e,t),Pt=(e,t)=>{for(var n=[e],r,i=[],a=0;r=jt(t[kt]);)delete t[kt],Object.assign(t,r);for(Vt(e,t,n,0);i[a++]=n[0],n=n[1];);return i},Ft=(e,t,n)=>e.replace(/&/g,`&`).replace(t,n),It=`</span>`,Lt=``,Rt=``,zt=e=>{for(var t=``,n,r=0;n=e[r++];)t+=Bt(n);return t},Bt=e=>{if(e instanceof Ht){var{type:t,alias:n,content:r}=e,i=Lt,a=Rt,o=`<span class="token ${t+(n?` `+n:``)+(t==`keyword`&&typeof r==`string`?` keyword-`+r.replace(/"|\s/g,``):``)}">`;Rt+=It,Lt+=o;var s=Bt(r);return Lt=i,Rt=a,o+s+It}return typeof e==`string`?(e=Ft(e,/</g,`<`),Rt&&e.includes(`
|
|
19
|
-
`)?e.replace(/\n/g,Rt+`
|
|
20
|
-
`+Lt):e):zt(e)},Vt=(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=jt(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 Ht)){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 Ht)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 Ht(a,d?Nt(S,d):S,S,m),O=h,k=0,A;O=O[1],k++<v;);T&&(!O||O[0]instanceof Ht?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&&(Vt(e,t,h,g,A=[a,o,E]),E=A[2]),i&&E>i[2]&&(i[2]=E)}}}}};function Ht(e,t,n,r){this.type=e,this.content=t,this.alias=r,this.length=n.length}var Ut=(e,t,...n)=>{let r,i=[],a,o=``,s,c=!1,l=!0,u=[],d,f=0,p=Xt(),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=Nt(o=_.value,Mt[r]||{}),O(`tokenize`,u,r,o);let e=zt(u).split(`
|
|
21
|
-
`),t=0,n=f,a=f=e.length;for(;e[t]==i[t]&&t<a;)++t;for(;a&&e[--a]==i[--n];);if(t==a&&t==n)h[t+1].innerHTML=e[t]+`
|
|
22
|
-
`;else{let r=n<t?n:t-1,i=r,o=``;for(;i<a;)o+=`<div class=pce-line aria-hidden=true>${e[++i]}\n</div>`;for(i=a<t?a:t-1;i<n;i++)h[t+1].remove();o&&h[r+1].insertAdjacentHTML(`afterend`,o),p.style.setProperty(`--number-width`,(0|Math.log10(f))+1+`.001ch`)}O(`update`,o),k(!0),l&&setTimeout(setTimeout,0,()=>l=!0),i=e,l=!1},C=e=>{(e||y).forEach(t=>{typeof t==`object`?(t.update(A,v),e&&y.add(t)):(t(A,v),e||y.delete(t))})},w=([e,t]=T())=>{p.className=`prism-code-editor language-${r}${v.lineNumbers==0?``:` show-line-numbers`} pce-${v.wordWrap?``:`no`}wrap${v.rtl?` pce-rtl`:``} pce-${e<t?`has`:`no`}-selection${c?` pce-focus`:``}${d?` pce-readonly`:``}${v.class?` `+v.class:``}`},T=()=>[_.selectionStart,_.selectionEnd,_.selectionDirection],E={Escape(){_.blur()}},D={},O=(e,...t)=>{b[e]?.forEach(e=>e.apply(A,t)),v[`on`+e[0].toUpperCase()+e.slice(1)]?.(...t,A)},k=e=>{if(e||l){let e=T(),t=h[s=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)}},A={container:p,wrapper:m,lines:h,textarea:_,get activeLine(){return s},get value(){return o},options:v,get focused(){return c},get tokens(){return u},inputCommandMap:D,keyCommandMap:E,extensions:{},setOptions:x,update:S,getSelection:T,addExtensions(...e){C(e)},on:(e,t)=>((b[e]||=new Set).add(t),()=>b[e].delete(t)),remove(){p.remove()}};return Y(_,`keydown`,e=>{E[e.key]?.(e,T(),o)&&X(e)}),Y(_,`beforeinput`,e=>{(d||e.inputType==`insertText`&&D[e.data]?.(e,T(),o))&&X(e)}),Y(_,`input`,S),Y(_,`blur`,()=>{Zt=null,c=!1,w()}),Y(_,`focus`,()=>{Zt=k,c=!0,w()}),Y(_,`selectionchange`,e=>{k(!e.isTrusted),X(e)}),qt(e)?.append(p),t&&x(t),A},Wt=`u`>typeof window?document:null,Gt=Wt?.createElement(`div`),Kt=(e,t)=>(Gt&&(Gt.innerHTML=e,t=Gt.firstChild),()=>t.cloneNode(!0)),Y=(e,t,n,r)=>e.addEventListener(t,n,r),qt=e=>typeof e==`string`?Wt.querySelector(e):e,Jt=(e,t=0,n=1/0)=>{let r=1;for(;(t=e.indexOf(`
|
|
23
|
-
`,t)+1)&&t<=n;r++);return r},Yt={},Xt=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()},Zt;Wt&&Y(Wt,`selectionchange`,()=>Zt?.());var Qt=(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) + ${hn&&!t.offsetWidth?t.offsetHeight:0}px)`,t.scrollIntoView({block:`nearest`}),r.scrollPaddingBlock=``,r.removeProperty(`--_sp`)},$t=(e,t)=>t?e.lastIndexOf(`
|
|
24
|
-
`,t-1)+1:0,en=(e,t)=>(t=e.indexOf(`
|
|
25
|
-
`,t))+1?t:e.length,tn=(e,t,n,r)=>(Y(e,t,n,r),()=>e.removeEventListener(t,n,r)),nn=(e,t,n,r)=>tn(e.textarea,t,n,r),rn=(e,t)=>parseFloat(getComputedStyle(e)[t]),an=(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}},on=(e,t)=>{e.data!=t&&(e.data=t)};new Set(`xml,rss,atom,jsx,tsx,xquery,xeora,xeoracube,actionscript`.split(`,`));var sn,cn=e=>e.replace(/[$+?|.^*()[\]{}\\]/g,`\\$&`),ln=(e,t)=>e.slice($t(e,t),t),un=(e,t,n=t)=>[e.slice(t=$t(e,t),n=en(e,n)).split(`
|
|
26
|
-
`),t,n],dn=(e,t,n=0,r=n,i=e.getSelection()[0])=>{let a=e.value,o=e.lines[Jt(a,0,i)],s=Wt.createTreeWalker(o,5),c=s.lastChild(),l=en(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}},fn=(e,t)=>dn(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;sn=e.getSelection(),r??=n;let o=e.textarea,s=e.value,c=hn&&!s[r??sn[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,sn[2]),l()})),gn||o.dispatchEvent(new InputEvent(`beforeinput`,{data:t})),hn||gn?(c&&(o.selectionEnd--,t=t.slice(0,-1)),gn&&(t+=`
|
|
27
|
-
`),Wt.execCommand(t?`insertHTML`:`delete`,!1,Ft(t,/</g,`<`)),c&&o.selectionStart++):Wt.execCommand(t?`insertText`:`delete`,!1,t),sn=0},pn=(e,t,n=t,r)=>{let i=e.textarea,a=tn(i,`focus`,e=>{let t=e.relatedTarget;t?t.focus():i.blur()});i.setSelectionRange(t,n,r),a(),i.dispatchEvent(new Event(`selectionchange`))},mn=Wt?navigator.userAgent:``,Q=Wt?/Mac|iPhone|iP[ao]d/.test(navigator.platform):!1,hn=/Chrome\//.test(mn),gn=!hn&&/AppleWebKit\//.test(mn),_n=e=>e.altKey+e.ctrlKey*2+e.metaKey*4+e.shiftKey*8,vn=(e,t)=>e.lines[0].append(t),yn=Kt(`<div style="color:#0000;contain:strict;padding:0 var(--_pse) 0 var(--padding-left)" aria-hidden=true> `),bn=Kt(`<span> `),xn=Kt(`<div class=pce-tooltip style=z-index:5;top:auto;display:flex;overflow-x:clip><div>`),Sn=(e,t,n=!0)=>{let r=xn(),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||vn(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 Cn=(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(``,bn()),on(r[o],n.slice(a,a=t[o++])),on(r[o].firstChild,n.slice(a,a=t[o++]));for(;i>o;)r[--i].remove();on(r[s],n.slice(a))},wn=0,Tn=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>`),En=Kt(`<li class=pce-ac-row role=option><div></div><div class=pce-ac-label> </div><div class=pce-ac-details><span> `),Dn={},On=(e,t)=>{e.forEach(e=>Dn[e]=t)},kn=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=Tn(),O=yn(),[k,A]=Sn(n,D),[j,M]=D.children,[ee,te,ne]=M.children,re=j.firstChild,ie=re.id=`pce-ac-`+wn++,ae=re.children,N=[],P=()=>{i&&=(A(),T.removeAttribute(`aria-controls`),T.removeAttribute(`aria-haspopup`),T.removeAttribute(`aria-activedescendant`),b&&M.remove(),!1)},F=()=>{f=rn(ae[0],`height`)},I=e=>{let t=o[e+d],[n,r,i]=ae[e].children,a=t[4],s=a.icon||`variable`;Cn(r,t[1],a.label),on(i.firstChild.firstChild,a.detail||``),N[e]!=s&&(n.className=`pce-ac-icon pce-ac-icon-${N[e]=s}`,n.style.color=`var(--pce-ac-icon-${s})`),ae[e].setAttribute(`aria-posinset`,e+d)},oe=()=>{F();let e=j.scrollTop,t=f*c,n=f*(c+1)-j.clientHeight;j.scrollTop=e>t?t:e<n?n:e,R(),se()},se=()=>{let e=l;l=ae[c-d],e?.removeAttribute(`aria-selected`),e?.removeAttribute(`aria-describedby`),te.remove(),l?(T.setAttribute(`aria-activedescendant`,l.id),l.setAttribute(`aria-selected`,!0),o[c][4].renderDocs?(l.append(te),b=!b,ge()):M.remove()):e&&T.removeAttribute(`aria-activedescendant`)},L=e=>{c=e?c?c-1:s-1:c+1<s?c+1:0,oe()},R=()=>{let e=Math.min(Math.floor(j.scrollTop/f),s-13);if(e==d||e<0)return!0;d=e;for(let e=0;e<13;)I(e++);re.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=`
|
|
28
|
-
`+ln(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||vn(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,pn(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]),Cn(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=rn(w,`fontSize`);if(e>=46*o){if(a+45.5*o<t+e)return v+`-end`;if(a-20.5*o>t)return v+`-start`}return v},me=()=>{D.className=`pce-ac-wrapper pce-ac-${pe()}`},he=()=>{let e=o[c][4];e.renderDocs&&(M.parentNode||D.append(M),y!=e&&(y=e,ne.textContent=``,ne.append(...e.renderDocs(e,x,n))),l?.setAttribute(`aria-describedby`,ie+`d`))},ge=()=>{b?M.remove():he(),b=!b},_e=t.startQuery=t=>{let[a,l,p]=E(),m=fn(n,u=p<`f`?a:l),h=Dn[m],g=n.extensions.cursor;if(g&&h&&(t||a==l)&&!r.readOnly){let r=n.value,a=ln(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;)ae[e].setAttribute(`aria-setsize`,s),I(e++);if(!i){let{clientHeight:e,clientWidth:t}=w,n=g.getPosition(),r=Math.max(n.bottom,n.top);M.style.maxWidth=j.style.width=`min(25em, ${t}px - var(--padding-left) - 1em)`,D.style.maxHeight=`min(${r}px + .25em, ${e}px - 2em)`}re.style.paddingTop=``,re.style.height=f?f*s+`px`:1.4*s+`em`,j.scrollTop=0,se(),i=!0,k(e.preferAbove),v=D.parentElement.style.top==`auto`?`top`:`bottom`,me(),T.setAttribute(`aria-controls`,ie),T.setAttribute(`aria-haspopup`,`listbox`)}else P()}else P()};O.className=`pce-tabstops`,T.setAttribute(`aria-autocomplete`,`list`);for(let e=0;e<13;)re.append(En()),ae[e].id=ie+`-`+e++;Y(j,`scroll`,()=>{F(),R()||se()}),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,_e()):(S!=e||C!=t)&&P(),S=e,C=t}),Y(T,`beforeinput`,t=>{let n=t.inputType,r=n[0]==`d`,s=n==`insertText`,l=t.data;i&&s&&!sn&&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&&!sn||r&&i)},!0),Y(T,`blur`,t=>{e.closeOnBlur!=0&&!D.contains(t.relatedTarget)&&P()}),Y(T,`keydown`,e=>{let t=e.key,n=_n(e),r,a,o;n==2&&t==` `||n==(Q?4:2)&&t==`i`||Q&&!i&&n==1&&t==`Escape`?(i?ge():_e(!0),X(e)):i?n||(/^Arrow[UD]/.test(t)?(L(t[5]==`U`),X(e)):t==`Tab`||t==`Enter`?(ce(c),P(),X(e)):t==`Escape`?(P(),X(e)):t.slice(0,4)==`Page`&&(F(),r=j.scrollTop,a=j.clientHeight,t[4]==`U`?(o=Math.ceil(r/f),c=c==o||o-1==c?Math.ceil(Math.max(0,(r-a)/f+1)):o):(r+=a+1,o=Math.ceil(r/f-2),c=c==o||o+1==c?Math.ceil(Math.min(s-1,(r+a)/f-3)):o),oe(),X(e))):p&&(!(n&7)&&t==`Tab`?n?m&&(de(-2),X(e)):(de(2),X(e)):!n&&t==`Escape`&&(fe(),X(e)))},!0),Y(re,`mousedown`,e=>{e.target!=te&&(ce([].indexOf.call(ae,e.target.closest(`li`))+d),P()),X(e)}),Y(D,`focusout`,t=>{e.closeOnBlur!=0&&t.relatedTarget!=T&&P()}),Y(w,`scroll`,()=>{i&&me()}),Y(ee,`click`,ge),Y(ee,`mousedown`,X),Y(te,`click`,ge),M.id=ie+`d`,te.remove(),M.remove(),n.extensions.autoComplete=t};return t.startQuery=t.insertCompletion=()=>{},t},An=(e,t)=>{let n=t.length,r=e.length;if(r>n)return;if(r==1||r==n)return jn(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]},jn=(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]]},Mn=e=>{let t=0,n=e.toLowerCase().split(`+`),r=n.pop()||`+`;for(let e of n)t|=+e||Hn[e]||0;return t+`+`+r},Nn=e=>{if(!Bn[48]){for(let e=48;e<91;e++)Bn[e]=String.fromCharCode(e>64?e+32:e);for(let e=96;e<112;e++)Bn[e]=String.fromCharCode(e<106?e-48:e-64)}let t=e.key||``,n=_n(e),r=Bn[e.keyCode],i=Vn[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},Pn=new WeakMap,Fn=(e,t,n)=>{let r=new Set,i;try{for(let a of Nn(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)))}},In=e=>{let t=Pn.get(e);return t||(Pn.set(e,t={}),nn(e,`keydown`,n=>{Fn(n,t,e)})),t},Ln=(e,t,n,r)=>Rn(In(e),t,n,r),Rn=(e,t,n,r=2)=>{let i=(e[t==`any`?t:Mn(t)]||=[])[r]||=new Set;return i.add(n),()=>{i.delete(n)}},zn=Q?4:2,Bn={32:` `,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Vn={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Hn={alt:1,control:2,ctrl:2,meta:4,cmd:4,shift:8,mod:Q?4:2},Un=!1,Wn=e=>e.search(/\S|$/),Gn=({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(`
|
|
29
|
-
`);if(s==t.join(`
|
|
30
|
-
`))return;let c=t.length-1,l=n[c],u=t[c],d=u.length-l.length,f=n[0].length-t[0].length,p=r+Wn((f<0?n:t)[0]),m=i-u.length+Wn(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,_))},qn=(e,t)=>{let[n,r]=e.getSelection(),[i,a,o]=un(e.value,n,r),[s,c]=Gn(e);return Kn(e,i,i.map(t?e=>e.slice(Wn(e)?c-Wn(e)%c:0):e=>e&&s.repeat(c-Wn(e)%c)+e),a,o,n,r),$(e)},Jn=(e,t)=>{let[n,r]=Gn(e);return Z(e,n.repeat(r-(t-$t(e.value,t))%r)),$(e)},Yn=(e,t)=>{let n=e.getSelection(),r=e.value;t&&(n[0]=n[1]=en(r,n[1]));let[i,a]=Gn(e),[o,s]=n,c=Yt[fn(e,o)]?.autoIndent,l=Math.floor(Wn(ln(r,o))/a)*a,u=c?.[0]?.(n,r,e)?a:0,d=c?.[1]?.(n,r,e),f=`
|
|
31
|
-
`+i.repeat(l+u)+(d?`
|
|
32
|
-
`+i.repeat(l):``);if(f[1]||r[s])return Z(e,f,o,s,o+l+u+1),$(e)},Xn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?$t(i,n)-1:n,o=t?r:i.indexOf(`
|
|
33
|
-
`,r)+1;if(a>-1&&o>0){let[s,c,l]=un(i,a,o),u=s[t?`shift`:`pop`](),d=(u.length+1)*(t?-1:1);s[t?`push`:`unshift`](u),Z(e,s.join(`
|
|
34
|
-
`),c,l,n+d,r+d)}return $(e)},Zn=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,[a,o,s]=un(i,n,r),c=a.join(`
|
|
35
|
-
`),l=t?0:c.length+1;return Z(e,c+`
|
|
36
|
-
`+c,o,s,n+l,r+l),$(e)},Qn=(e,t)=>(e.container.scrollBy(0,rn(e.container,`lineHeight`)*(t?-1:1)),!0),$n=e=>{let[t,n,r]=e.getSelection(),i=e.value,[a,o,s]=un(i,t,n),c=r>`f`?n-s+a.pop().length:t-o,l=en(i,s+1)-s-1;return Z(e,``,o-!!o,s+!o,o+Math.min(c,l)),$(e)},er=(e,t)=>{let[n,r]=e.getSelection(),i=e.value,a=t?n:$t(i,n),o=Yt[fn(e,a)]||{},{line:s,block:c}=o.getComments?.(e,a,i)||o.comments||{},[l,u,d]=un(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(cn(t)+` ?$`);s+1&&RegExp(`^ ?`+cn(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=cn(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=Wn(a),s=a.startsWith(t,o)&&l[f].endsWith(i);l[0]=a.replace(s?RegExp(cn(t)+` ?`):/(?!\s)/,s?``:t+` `);let p=l[0].length-a.length;l[f]=s?l[f].replace(RegExp(` ?${cn(i)}$`),``):l[f]+` `+i;let m=l.join(`
|
|
37
|
-
`),h=o+u,g=h>n?n:Math.max(n+p,h),_=h>r-(n!=r)?r:Math.min(Math.max(h,r+p),u+m.length);Z(e,m,u,d,g,Math.max(g,_))}return c||s&&!t?$(e):!1},tr={Tab(e){if(!Un){let[t,n]=e.getSelection();return t==n?Jn(e,t):qn(e)}},"8+Tab":e=>!Un&&qn(e,!0),"1+ArrowDown":e=>Xn(e),"1+ArrowUp":e=>Xn(e,!0),"9+ArrowDown":e=>Zn(e),"9+ArrowUp":e=>Zn(e,!0),Enter:e=>Yn(e),"8+Enter":e=>Yn(e),"Mod+Enter":e=>Yn(e,!0),"Mod+]":e=>qn(e),"Mod+[":e=>qn(e,!0),"8+Mod+k":$n,"Mod+/":e=>er(e),"9+a":e=>er(e,!0),[Q?`10+m`:`2+m`]:()=>(Un=!Un,!0),[`2+${Q?`Page`:`Arrow`}Down`]:e=>Qn(e),[`2+${Q?`Page`:`Arrow`}Up`]:e=>Qn(e,!0)};[...Q?[[`1+Escape`,`Trigger suggestion`]]:[]];var nr=Q?5:1;nr+``,nr+``,nr+``,nr+``;var rr=(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&&!pn(r,e+1),u=()=>{let[e,n]=r.getSelection();if(e==n){let a=r.value,o=ln(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=Yt[fn(r)]?.autoCloseTags?.(t,n,r);i&&(Z(r,`>`+i,null,null,t[0]+1),X(e))},Ln(r,`Backspace`,u),Ln(r,`8+Backspace`,u);for(let t in e)Ln(r,t,e[t]);[`copy`,`cut`,`paste`].forEach(e=>nn(r,e,t=>{let[n,i]=r.getSelection();if(n==i&&s){let[[o],c,l]=un(r.value,n,i);e==`paste`?t.clipboardData.getData(`text/plain`)==a&&(Z(r,a+`
|
|
38
|
-
`,c,c,n+a.length+1),$(r),X(t)):(s.writeText(a=o),e==`cut`&&(Z(r,``,c,l+1),$(r)),X(t))}}))},ir=(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}),nn(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`)&&!sn&&(n!=` `||o==n))||(d[t][2]=sn||u()),i=!0,o=n,s=f,a=l}),nn(e,`input`,()=>f(t+!c)),nn(e,`keydown`,e=>{if(!g.readOnly){let n=_n(e),r=e.keyCode,i=n==zn&&r==90,a=n==zn+8&&r==90||!Q&&n==zn&&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},ar=Kt(`<div style=position:absolute;top:0;opacity:0;padding-inline-end:inherit> <span><span></span> `),or=()=>{let e,t=ar(),[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];on(n,ln(i,s)),on(a,i.slice(s,en(i,s))+`
|
|
39
|
-
`),t.parentNode!=o&&o.prepend(t)},s=()=>{o(),Qt(e,i)},c=t=>{e=t,t.extensions.cursor=c,nn(t,`input`,e=>{/history/.test(e.inputType)&&s()})};return c.getPosition=()=>(o(),an(e,i)),c.scrollIntoView=s,c.element=i,c};Kt(`<div class=pce-cursor>`);var sr=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,cr=/\b(?:false|true)\b/,lr=/\[]|\(\)|{}/,ur=/[([{][^)\]}]*$/,dr=([e,t],n)=>lr.test(n[e-1]+n[t]),fr={line:`//`,block:[`/*`,`*/`]},pr=(e=fr,t=ur)=>({comments:e,autoIndent:[([e],n)=>t.test(ln(n,e)),dr]});Yt.json=Yt.json5=Yt.jsonp=pr(),Yt.graphql=pr({line:`#`}),Mt.webmanifest=Mt.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:sr,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:cr,null:{pattern:/\bnull\b/,alias:`keyword`}},Mt.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:cr,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+/,[At](e,t){for(var n=Pt(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 mr=new WeakMap;On([`json`],{sources:[(e,t)=>{let n=mr.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 hr({value:e,language:r=`json`,readOnly:i,label:a,onChange:o,onLine:c,complete:l}){let u=s(null),d=s(void 0),f=s({onChange:o,onLine:c});f.current={onChange:o,onLine:c};let p=s(l);return p.current=l,n(()=>{let t=Ut(u.current,{value:e,language:r,readOnly:i,lineNumbers:!1,wordWrap:!0,onUpdate:e=>f.current.onChange?.(e),onSelectionChange:(e,t,n)=>f.current.onLine?.(n.activeLine-1)},rr(tr),ir(),...l?[or(),kn({filter:An})]:[]);return l&&mr.set(t,(e,t)=>p.current?.(e,t)),t.textarea.setAttribute(`aria-label`,a),d.current=t,()=>t.remove()},[]),n(()=>{let t=d.current;t&&t.value!==e&&t.setOptions({value:e})},[e]),n(()=>{d.current?.setOptions({readOnly:i,language:r})},[i,r]),t(`div`,{class:`body-editor`,part:`editor`,ref:u})}var gr=/[\w$.+-]/;function _r(e,t){let n=[],r=()=>n[n.length-1],i=0;for(;i<t;){let a=e[i];if(a===`"`){let n=i+1,a=``;for(;n<e.length&&e[n]!==`"`&&e[n]!==`
|
|
40
|
-
`;)e[n]===`\\`?(a+=e[n+1]??``,n+=2):a+=e[n++];let o=e[n]===`"`,s=r();if(t<=n||!o&&t<=e.length&&n>=t){let r=s?.t===`o`&&s.expectKey,a=o?n+1:t,l=a;for(;/\s/.test(e[l]??``);)l++;return c({mode:r?`key`:`value`,from:i,to:a,inString:!0,prefix:e.slice(i+1,t),hasColon:e[l]===`:`})}s?.t===`o`&&s.expectKey&&(s.key=a,s.keys.add(a),s.expectKey=!1),i=n+1}else{if(a===`{`)n.push({t:`o`,expectKey:!0,keys:new Set});else if(a===`[`)n.push({t:`a`,index:0});else if(a===`}`||a===`]`)n.pop();else if(a===`,`){let e=r();e?.t===`o`?(e.expectKey=!0,e.key=void 0):e?.t===`a`&&e.index++}i++}}let a=t;for(;a>0&&gr.test(e[a-1]??``);)a--;let o=t;for(;o<e.length&&gr.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 vr=e=>e?.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/[`*_]{1,2}/g,``),yr=(e,t)=>{let n=J(e);return n===`array`?`${J(q(e.items,t))}[]`:e.format?`${n} · ${e.format}`:n};function br(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 xr(e,t,n,r,i){if(!e)return;let a=_r(r,i);if(!a)return;let o=Qe(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=Ge(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=br(n),i=JSON.stringify(e.name),o=a.hasColon?i:`${i}: `,s=a.hasColon?i:`${o}${r.text}`;return{label:e.name,detail:`${yr(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:vr(We(Ue(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 Sr=(e,t)=>t===`multipart`||t===`form`&&(e.formView??`grid`)===`grid`;function Cr(e,t){let n=e.body,r=t===`multipart`||t===`form`;return{path:pe(e.path),query:pe(e.query),headers:pe(e.headers),body:n===void 0||t===`multipart`||t===`binary`?``:typeof n==`string`&&t===`text`?n:JSON.stringify(n,null,2),fields:r?he(n):t===`binary`&&typeof n==`string`?[{key:`file`,value:n,enabled:!0}]:[],formView:t===`form`?`json`:void 0}}var wr=e=>Object.keys(e).length?e:void 0;function Tr(e,t){let n;if(Sr(e,t))n=ve(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:wr(me(e.path)),query:wr(me(e.query)),headers:wr(me(e.headers)),data:n}}var Er=e=>({...e,fields:e.fields.map(({file:e,...t})=>t)});function Dr(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 Or({doc:e,hint:n}){return e?t(`div`,{class:`field-doc`,part:`field-doc`,"aria-live":`polite`,children:[t(`div`,{class:`field-doc-head`,children:[t(`code`,{children:e.path}),t(`span`,{class:`chip`,children:e.type}),e.required&&t(`span`,{class:`chip req`,children:`required`}),e.deprecated&&t(`span`,{class:`chip warn`,children:`deprecated`})]}),e.description?t(`div`,{class:`field-doc-text`,dangerouslySetInnerHTML:{__html:Pe(e.description)}}):e.note?null:t(`p`,{class:`muted`,children:[`The spec has no description for this field.`,e.parent&&t(l,{children:[` It is part of: `,e.parent]})]}),e.note&&t(`div`,{class:`field-note`,dangerouslySetInnerHTML:{__html:e.note}}),e.enum&&t(`p`,{class:`field-doc-enum`,children:[e.enum.slice(0,12).map(e=>t(`code`,{children:e})),e.enum.length>12&&t(`span`,{class:`muted`,children:[`+`,e.enum.length-12,` more`]})]})]}):t(`div`,{class:`field-doc empty`,part:`field-doc`,"aria-live":`polite`,children:n??`Put the cursor on a field to see what the API says about it.`})}function kr(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 Ar(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 jr({value:e,options:r,onChange:i,label:o,placeholder:c,onKeyDown:l,cell:u,readOnly:d}){let[f,p]=a(!1),[m,h]=a(-1),[g,_]=a(),v=s(null),y=()=>{let e=v.current,t=e?.getBoundingClientRect();if(!e||!t)return;let n=document.createElement(`div`);n.style.cssText=`position:fixed;inset:0;visibility:hidden;pointer-events:none`,e.append(n);let r=n.getBoundingClientRect();n.remove();let i=innerHeight-t.bottom-8,a=i<160&&t.top>i;_({left:`${t.left-r.left}px`,width:`${Math.max(t.width,160)}px`,maxHeight:`${Math.min(240,(a?t.top:i)-4)}px`,...a?{bottom:`${r.bottom-t.top+2}px`}:{top:`${t.bottom+2-r.top}px`}})};n(()=>{if(!f){_(void 0);return}y();let e=e=>{if(e.target instanceof Node&&v.current?.contains(e.target))return;let t=v.current?.getBoundingClientRect();!t||t.bottom<0||t.top>innerHeight?p(!1):y()},t=()=>p(!1);return addEventListener(`scroll`,e,!0),addEventListener(`resize`,t),()=>{removeEventListener(`scroll`,e,!0),removeEventListener(`resize`,t)}},[f]),n(()=>{if(!f)return;let e=e=>{e.composedPath().includes(v.current)||p(!1)};return document.addEventListener(`mousedown`,e,!0),()=>document.removeEventListener(`mousedown`,e,!0)},[f]);let b=e=>{i(e),p(!1),h(-1)};return t(`div`,{class:`combo`,ref:v,children:[t(`input`,{class:`cell`,"data-cell":u,value:e,placeholder:c,"aria-label":o,"aria-expanded":f,role:`combobox`,autocomplete:`off`,readOnly:d,onFocus:()=>!d&&p(!0),onInput:e=>i(e.target.value),onKeyDown:e=>{f&&e.key===`ArrowDown`?(e.preventDefault(),h((m+1)%r.length)):f&&e.key===`ArrowUp`?(e.preventDefault(),h((m-1+r.length)%r.length)):f&&e.key===`Enter`&&m>=0?(e.preventDefault(),b(r[m])):e.key===`Escape`&&f?(e.stopPropagation(),p(!1)):((e.key===`Enter`||e.key===`Tab`)&&p(!1),l?.(e))}}),t(`button`,{type:`button`,class:`combo-toggle`,tabIndex:-1,"aria-label":`Show ${o} options`,disabled:d,onClick:()=>p(!f),children:`▾`}),f&&t(`div`,{class:`combo-list`,role:`listbox`,style:g??{top:`0px`,left:`0px`,visibility:`hidden`},children:r.map((n,r)=>t(`button`,{type:`button`,role:`option`,"aria-selected":n===e,class:`${n===e?`on`:``} ${r===m?`at`:``}`,onMouseDown:e=>e.preventDefault(),onClick:()=>b(n),children:n}))})]})}var Mr=`specbook:grid-cols`,Nr={key:26,val:34},Pr=10,Fr=c(Ir());function Ir(){try{let e=JSON.parse(L.local.getItem(Mr)??`null`);if(e&&e.key>=Pr&&e.val>=Pr&&e.key+e.val<=90)return e}catch{}return Nr}function Lr(e){let t=e??Nr,n=Math.min(80,Math.max(Pr,t.key)),r=Math.min(100-n-Pr,Math.max(Pr,t.val));Fr.value={key:Math.round(n*10)/10,val:Math.round(r*10)/10};try{e?L.local.setItem(Mr,JSON.stringify(Fr.value)):L.local.removeItem(Mr)}catch{}}function Rr(){return t(`colgroup`,{children:[t(`col`,{style:{width:`36px`}}),t(`col`,{style:{width:`${Fr.value.key}%`}}),t(`col`,{style:{width:`${Fr.value.val}%`}}),t(`col`,{}),t(`col`,{style:{width:`60px`}})]})}function zr({which:e,table:n}){let r=t=>{let n=Fr.value;Lr(e===`key`?{key:n.key+t,val:n.val-t}:{key:n.key,val:n.val+t})};return t(`span`,{class:`col-resizer`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the ${e===`key`?`Key`:`Value`} column`,"aria-valuenow":Math.round(Fr.value[e]),"aria-valuemin":Pr,"aria-valuemax":80,tabIndex:0,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.preventDefault();let t=n()?.getBoundingClientRect().width??1,i=e.clientX;document.body.classList.add(`resizing`);let a=e=>{r((e.clientX-i)/t*100),i=e.clientX},o=()=>{document.body.classList.remove(`resizing`),removeEventListener(`pointermove`,a),removeEventListener(`pointerup`,o)};addEventListener(`pointermove`,a),addEventListener(`pointerup`,o)},onDblClick:()=>Lr(void 0),onKeyDown:e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),r(e.key===`ArrowLeft`?-2:2))}})}var Br=1,Vr=2;function Hr(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 Ur=({d:e})=>t(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,"aria-hidden":`true`,children:t(`path`,{d:e,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})});function Wr({title:e,rows:r,onChange:i,documented:a=[],docFor:o,fixed:c,bad:u,placeholder:d,bare:f,readOnly:p}){let m=s(null),h=s(null),g=s(void 0),_=new Set(r.map(e=>e.key)),v=a.filter(e=>!_.has(e.name)).map(e=>({key:e.name,value:``,enabled:!1,virtual:!0})),y=[...r,...v],b=e=>a.find(t=>t.name===e),x=e=>b(e)?.doc??o?.(e);n(()=>{if(!g.current)return;let e=m.current?.querySelector(`[data-cell="${g.current}"]`);g.current=void 0,e&&(e.focus(),e.setSelectionRange?.(e.value.length,e.value.length))});let S=e=>!e.virtual||e.enabled||e.value!==``||e.file,C=e=>i(e.filter(S).map(({virtual:e,...t})=>t)),w=(e,t)=>C(y.map((n,r)=>r===e?{...n,...t}:n)),T=(e,t)=>m.current?.querySelector(`[data-cell="${e}:${t}"]`)?.focus(),E=(e,t)=>n=>{n.key===`Enter`||n.key===`ArrowDown`?(n.preventDefault(),T(e+(n.shiftKey?-1:1),t)):n.key===`ArrowUp`&&(n.preventDefault(),T(e-1,t))},D=e=>{let t=y[e],n=x(t.key)?.enum??[],r=new Set(y.filter(e=>e.key===t.key).map(e=>e.value)),i=n.find(e=>!r.has(e))??``,a={key:t.key,value:i,enabled:!0},o=[...y];o.splice(e+1,0,a),g.current=`${o.filter(S).indexOf(a)}:${Vr}`,C(o)},O=(e,t)=>{let n=e.clipboardData?.getData(`text`)??``;if(!/\r?\n/.test(n.trim()))return;e.preventDefault();let a=Hr(n).map(e=>({...e,enabled:!0})),o=[...r];o.splice(t,+(t<r.length&&!r[t]?.key),...a),i(o)},k=y.length;return t(`section`,{class:`grid`,"aria-label":e,ref:m,children:[!f&&t(`h3`,{children:e}),t(`table`,{ref:h,children:[t(Rr,{}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-check`}),t(`th`,{class:`g-key`,children:[`Key`,t(zr,{which:`key`,table:()=>h.current})]}),t(`th`,{class:`g-val`,children:[`Value`,t(zr,{which:`val`,table:()=>h.current})]}),t(`th`,{class:`g-doc`,children:`Description`}),t(`th`,{class:`g-act`})]})}),t(`tbody`,{children:[y.map((e,n)=>{let r=x(e.key),i=b(e.key)?.file,a=c||p||e.virtual||b(e.key);return t(`tr`,{class:`${e.enabled?``:`off`} ${u===e.key?`bad`:``}`,children:[t(`td`,{class:`g-check`,children:t(`input`,{type:`checkbox`,"aria-label":`Send ${e.key}`,checked:e.enabled,disabled:c||p,onChange:e=>w(n,{enabled:e.target.checked})})}),t(`td`,{class:`g-key`,children:a?t(`span`,{class:`key`,children:[t(`code`,{children:e.key}),r?.required&&t(`span`,{class:`req`,title:`required`,children:`*`})]}):t(`input`,{class:`cell`,"data-cell":`${n}:${Br}`,value:e.key,placeholder:`key`,"aria-label":`Name`,onInput:e=>w(n,{key:e.target.value}),onKeyDown:E(n,Br),onPaste:e=>O(e,n)})}),t(`td`,{class:`g-val`,children:i?t(`label`,{class:`file-cell`,children:[t(`input`,{type:`file`,disabled:p,"aria-label":`File for ${e.key}`,onChange:e=>{let t=e.target.files?.[0];t&&w(n,{file:t,value:t.name,enabled:!0})}}),t(`span`,{class:e.value?``:`muted`,children:e.value||`Choose a file…`})]}):r?.enum?t(jr,{value:e.value,options:r.enum.map(String),label:e.key,cell:`${n}:${Vr}`,readOnly:p,placeholder:`value`,onKeyDown:E(n,Vr),onChange:e=>w(n,{value:e,enabled:!0})}):t(`input`,{class:`cell`,"data-cell":`${n}:${Vr}`,value:e.value,readOnly:p,placeholder:d??`value`,"aria-label":`Value of ${e.key}`,onInput:e=>w(n,{value:e.target.value,enabled:!0}),onKeyDown:E(n,Vr)})}),t(`td`,{class:`g-doc`,title:Fe(r?.description),children:r&&t(l,{children:[t(`span`,{class:`chip`,children:r.type}),` `,t(`span`,{class:`doc-inline`,dangerouslySetInnerHTML:{__html:Re(r.description)}})]})}),t(`td`,{class:`g-act`,children:[!c&&!p&&e.key&&t(`button`,{type:`button`,class:`icon`,title:`Repeat this key with another value`,"aria-label":`Repeat ${e.key}`,onClick:()=>D(n),children:t(Ur,{d:`M5.5 5.5h7v7h-7zM3.5 10.5v-7h7`})}),!c&&!p&&!e.virtual&&t(`button`,{type:`button`,class:`icon`,title:`Remove`,"aria-label":`Remove ${e.key}`,onClick:()=>C(y.filter((e,t)=>t!==n)),children:t(Ur,{d:`M4.5 4.5l7 7M11.5 4.5l-7 7`})})]})]},n)}),!c&&!p&&t(`tr`,{class:`ghost`,children:[t(`td`,{class:`g-check`}),t(`td`,{class:`g-key`,children:t(`input`,{class:`cell`,"data-cell":`${k}:${Br}`,value:``,placeholder:`Add a key`,"aria-label":`New key`,onInput:e=>{g.current=`${r.length}:${Br}`,i([...r,{key:e.target.value,value:``,enabled:!0}])},onKeyDown:E(k,Br),onPaste:e=>O(e,r.length)})}),t(`td`,{class:`g-val`}),t(`td`,{class:`g-doc`}),t(`td`,{class:`g-act`})]},k)]})]})]})}function Gr({draft:e,onChange:r,readOnly:i}){let[o,c]=a(()=>kr(e.body)),l=s(e.body);n(()=>{if(e.body===l.current)return;let t=kr(e.body);t&&c(t),l.current=e.body},[e.body]);let u=t=>{let n={...o,...t};c(n),l.current=Ar(n),r({...e,body:l.current})};return t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Query`}),t(`span`,{class:`chip`,children:`graphql`})]}),t(hr,{readOnly:i,label:`GraphQL query`,language:`graphql`,value:o.query,onChange:e=>u({query:e})}),t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Variables`}),t(`span`,{class:`chip`,children:`json`})]}),t(hr,{readOnly:i,label:`GraphQL variables`,language:`json`,value:o.variables,onChange:e=>u({variables:e})})]})}var Kr=e=>e===`graphql`?`graphql`:e===`text`?`text`:`json`;function qr({encoding:e,draft:n,onChange:r,schema:i,defs:s,files:c=[],notes:u,readOnly:d}){let[f,p]=a(0),m=o(()=>Ze(n.body),[n.body]),h=e===`json`||e===`form`,g=o(()=>{let e=m[f];return e&&h?Dt(Tt(i,s,e,[`data`]),u,`data`,Xe(e)):void 0},[m,f,i,s,h,u]),_=o(()=>h&&i?(e,t)=>xr(i,s,[`data`],e,t):void 0,[i,s,h]),v=e=>{if(e!==(n.formView??`grid`)){if(e===`grid`)try{r({...n,formView:`grid`,fields:he(JSON.parse(n.body||`{}`))})}catch{r({...n,formView:`grid`})}else r({...n,formView:`json`,body:JSON.stringify(ve(n.fields.filter(e=>!e.file)),null,2)})}},y=e===`form`?t(`fieldset`,{class:`seg`,"aria-label":`Body view`,children:[`json`,`grid`].map(e=>t(`button`,{type:`button`,class:`seg-btn ${(n.formView??`grid`)===e?`on`:``}`,"aria-pressed":(n.formView??`grid`)===e,onClick:()=>v(e),children:e===`json`?`JSON`:`Grid`}))}):null;if(Sr(n,e)||e===`binary`){let a=t=>e===`binary`||c.includes(t.replace(/\[\d+\]/g,``)),o=e=>r({...n,fields:e}),f=(n.fields.length?n.fields.map(e=>e.key):[]).filter(a);return t(l,{children:[y&&t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),y]}),t(Wr,{title:e===`binary`?`File`:`Body`,bare:!!y,rows:n.fields,readOnly:d,onChange:o,documented:[...new Set(f)].map(e=>({name:e,file:!0})),docFor:e=>Dt(Tt(i,s,Et(e),[`data`]),u,`data`,e)})]})}return e===`graphql`&&kr(n.body)?t(Gr,{draft:n,onChange:r,readOnly:d}):t(`section`,{class:`body`,"aria-label":`Body`,children:[t(`div`,{class:`section-head`,children:[t(`h3`,{children:`Body`}),t(`span`,{class:`chip`,children:e}),t(`span`,{class:`spacer`}),e!==`text`&&!d&&t(`button`,{type:`button`,class:`link`,onClick:()=>{try{r({...n,body:JSON.stringify(JSON.parse(n.body),null,2)})}catch{}},children:`Format`}),y]}),t(hr,{readOnly:d,label:`Request body`,language:Kr(e===`form`?`json`:e),value:n.body,onChange:e=>r({...n,body:e}),onLine:p,complete:_}),h&&t(Or,{doc:g})]})}var Jr=`specbook:code-lang`;function Yr(){try{let e=L.local.getItem(Jr);if(e===`curl`||e===`fetch`)return e}catch{}return`curl`}function Xr({service:e,profile:r,secured:i,make:s,sent:c}){let[l,u]=a(Yr),d=l===`sent`?`curl`:l,[f,p]=a(!1),[m,h]=a(),[g,_]=a();n(()=>{let t=!0;return N.config(A.value).then(async n=>{let i=n.services?.[e],a=t=>N.baseUrlOf(e,t,A.value).catch(()=>void 0),o=P.value===`mock`?void 0:await a(P.value);if(o??=await a(`live`),!o&&i&&typeof i.baseUrl==`object`&&(o=Object.values(i.baseUrl)[0]),!t)return;h(o);let s=r===`service`?i?.auth:r;_(s?n.auth?.[s]?.apply:void 0)}),()=>{t=!1}},[e,r,P.value,te.value]);let v=o(()=>{try{return{text:je(d,s(m??`https://api.example.com`,g))}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},[s,d,m,g]),y=e=>{if(u(e),e!==`sent`)try{L.local.setItem(Jr,e)}catch{}};return t(`div`,{class:`code-sample`,children:[t(`div`,{class:`code-head`,children:[t(`fieldset`,{class:`seg`,"aria-label":`Code sample`,children:[Me.map(e=>t(`button`,{type:`button`,"aria-pressed":l===e.id,class:`seg-btn ${l===e.id?`on`:``}`,onClick:()=>y(e.id),children:e.label})),c!==void 0&&t(`button`,{type:`button`,"aria-pressed":l===`sent`,class:`seg-btn ${l===`sent`?`on`:``}`,onClick:()=>y(`sent`),children:`Sent`})]}),t(`span`,{class:`spacer`}),l!==`sent`&&t(`button`,{type:`button`,class:`btn small`,onClick:async()=>{if(v.text)try{await navigator.clipboard.writeText(v.text),p(!0),setTimeout(()=>p(!1),1500)}catch{}},disabled:!v.text,children:f?`Copied`:`Copy`})]}),l===`sent`?c:v.error?t(`p`,{class:`muted`,children:v.error}):t(`pre`,{class:`code-block`,part:`code`,children:t(`code`,{children:v.text})}),l!==`sent`&&i&&t(`p`,{class:`muted small`,children:`Secrets are read from environment variables; set them first.`})]})}function Zr({service:e,method:n,path:r,draft:a,encoding:o,vars:s,secured:c,sent:l}){let u=i((e,t)=>{let i=Tr(a,o),c={path:i.path??{},query:i.query??{},headers:i.headers??{},data:i.data},l=c;try{l=p(c,s)}catch{}let u=r.replace(/\{([^}]+)\}/g,(e,t)=>{let n=l.path[t];return n===void 0||n===``?e:encodeURIComponent(String(n))});return{method:n,url:`${e.replace(/\/+$/,``)}${u}`,query:{...t?.query??{},...l.query},headers:{...t?.headers??{},...l.headers},body:l.data,encoding:o}},[a,o,s,n,r]);return t(Xr,{service:e,profile:c?`service`:void 0,secured:c,make:u,sent:l})}function Qr({request:e,encoding:n,sent:r}){let a=i((t,r)=>({method:e.method,url:`${t.replace(/\/+$/,``)}${e.url}`,query:{...r?.query??{},...e.query},headers:{...r?.headers??{},...e.headers},body:e.body,encoding:n}),[e,n]);return t(Xr,{service:e.service,profile:e.profile,secured:!!e.profile,make:a,sent:r})}function $r(e,t){try{let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return Object.prototype.toString.call(e)}}function ei(e){let t=typeof e==`string`?e:$r(e);return t.length>28?`${t.slice(0,27)}…`:t}var ti=e=>typeof e==`string`?e:$r(e,2);function ni(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 ri({body:e,docs:n}){let[r,i]=a(0),s=ti(e),c=!!n?.schema&&typeof e==`object`&&!!e,u=o(()=>c?Ze(s):[],[c,s]),d=o(()=>{let e=u[r];return e&&n?Dt(Tt(n.schema,n.defs,e,[`data`]),n.notes,`data`,Xe(e)):void 0},[u,r,n]);return t(l,{children:[t(hr,{label:`Body as sent`,value:s,readOnly:!0,language:typeof e==`string`?`text`:`json`,onLine:i}),c&&t(Or,{doc:d})]})}function ii({request:e,hideBar:n,docs:r}){if(!e)return t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing sent yet`}),t(`span`,{class:`muted`,children:`The request, with every value filled in, appears here after Send.`})]});let i=Object.entries(e.headers);return t(`div`,{class:`sent-view`,children:[!n&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${e.method}`,children:e.method}),t(`div`,{class:`rq-url`,title:e.url,children:t(`code`,{children:[e.url,ni(e.query)]})})]}),t(`h3`,{children:`Headers`}),i.length===0?t(`p`,{class:`muted`,children:`No headers.`}):t(`table`,{class:`headers`,children:t(`tbody`,{children:i.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]}))})}),e.body!==void 0&&t(l,{children:[t(`h3`,{children:`Body`}),t(ri,{body:e.body,docs:r})]})]})}function ai(e){let t=e.location;if(!t)return;let n=[...w.requests,...w.sequences].map(e=>e.file).filter(e=>t.file.includes(e)).sort((e,t)=>t.length-e.length)[0];return n?`${n}:${t.line}`:void 0}var oi={expected:`−`,received:`+`,same:` `,skip:` `},si={expected:`expected`,received:`received`,same:``,skip:``};function ci({lines:e}){return t(`section`,{class:`diff`,tabIndex:0,"aria-label":`Expected and received values`,children:e.map(e=>t(`div`,{class:`diff-line diff-${e.kind}`,children:[t(`span`,{class:`diff-gutter`,"aria-hidden":`true`,children:oi[e.kind]}),si[e.kind]&&t(`span`,{class:`visually-hidden`,children:[si[e.kind],`: `]}),t(`span`,{class:`diff-text`,children:e.text})]}))})}function li({a:e}){let n=fe(e),r=ai(e);return t(`fieldset`,{class:`check-fail`,children:[t(`legend`,{class:`visually-hidden`,children:[`Failed check: `,e.label]}),t(`div`,{class:`check-head`,children:[t(`span`,{class:`check-mark`,"aria-hidden":`true`,children:`✗`}),t(`strong`,{children:e.label}),t(`span`,{class:`chip`,children:e.operator})]}),n.length>0&&t(l,{children:[t(`div`,{class:`diff-legend`,"aria-hidden":`true`,children:[t(`span`,{class:`diff-key diff-expected`,children:`− Expected`}),t(`span`,{class:`diff-key diff-received`,children:`+ Received`})]}),t(ci,{lines:n})]}),r&&t(`div`,{class:`check-where`,children:[`at `,r]})]})}function ui({assertions:e}){return t(`ul`,{class:`checks`,children:e.map(e=>e.pass?t(`li`,{class:`ok`,children:[t(`span`,{class:`tick`,children:`✓`}),` `,e.label]}):t(`li`,{class:`bad`,children:t(li,{a:e})}))})}var di=e=>$r(e,2),fi=e=>e<1024?`${e} B`:`${(e/1024).toFixed(1)} KB`;function pi({step:e,error:r,schemas:i,defs:s,hideRequest:c}){let[u,d]=a(`body`),[f,p]=a(0),m=e?.response,h=m?i?.[String(m.status)]??i?.default:void 0,g=o(()=>{try{return m&&h?Ye(m.body,h,s,{reportExtra:!0}):[]}catch{return[]}},[m,h,s]),_=m===void 0||m.body===void 0||m.body===``?``:typeof m.body==`string`?m.body:di(m.body),v=o(()=>Ze(_),[_]),y=o(()=>{let e=v[f];return e?Tt(h,s,e):void 0},[v,f,h,s]),b=e?.assertions??[],x=b.filter(e=>!e.pass).length;n(()=>{e&&x>0&&d(`checks`)},[e]);let S=Object.entries(m?.headers??{}),C=!m&&!r&&!e?.error;return t(`section`,{class:`response`,"aria-label":`Response`,children:[t(`div`,{class:`rs-head`,children:[m&&t(l,{children:[t(`span`,{class:`state-badge ${tt(m.status)}`,children:[m.status,` `,et(m.status)]}),t(`span`,{class:`rs-stat`,children:[m.durationMs,` ms`]}),t(`span`,{class:`rs-stat`,children:fi(new Blob([_]).size)})]}),t(`span`,{class:`spacer`}),m&&t(`span`,{class:`conf ${h?g.length?`warn`:`ok`:`none`}`,children:h?g.length?`⚠ ${g.length} difference${g.length>1?`s`:``} from spec`:`✓ Matches spec`:`No schema for this response`})]}),e?.request&&!c&&t(`p`,{class:`sent`,children:[t(`span`,{class:`method ${e.request.method}`,children:e.request.method}),` `,t(`code`,{children:[e.request.url,ni(e.request.query)]})]}),r&&t(`p`,{class:`error-text`,children:r}),e?.error&&t(`p`,{class:`error-text`,children:e.error}),C&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`No response yet`}),t(`span`,{class:`muted`,children:[`Press`,` `,t(`kbd`,{class:`icon-key`,children:t(T,{size:12})}),` `,`or `,t(`kbd`,{children:`⌘`}),` `,t(`kbd`,{children:`↵`})]})]}),m&&t(l,{children:[t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`body`,`Body`,0],[`headers`,`Headers`,S.length],[`checks`,`Checks`,b.length]].map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":u===e,class:`rq-tab ${u===e?`on`:``}`,onClick:()=>d(e),children:[n,r>0&&t(`span`,{class:`count ${e===`checks`&&x?`bad`:``}`,title:e===`checks`&&x?`${x} of ${r} checks failed`:void 0,children:e===`checks`&&x?x:r})]}))}),t(`div`,{class:`rs-pane`,children:[t(`div`,{hidden:u!==`body`,children:[_===``?t(`p`,{class:`muted`,children:`No content.`}):t(hr,{label:`Response body`,value:_,readOnly:!0,language:typeof m.body==`string`?`text`:`json`,onLine:p}),_!==``&&t(Or,{doc:y}),g.length>0&&t(`details`,{class:`issues`,children:[t(`summary`,{children:`What differs`}),t(`ul`,{children:g.map(e=>t(`li`,{children:[t(`code`,{children:e.path||`(root)`}),` `,e.message]}))})]})]}),t(`div`,{hidden:u!==`headers`,children:t(`table`,{class:`headers`,children:t(`tbody`,{children:[S.map(([e,n])=>t(`tr`,{children:[t(`th`,{children:e}),t(`td`,{children:n})]})),S.length===0&&t(`tr`,{children:t(`td`,{class:`muted`,children:`No headers recorded`})})]})})}),t(`div`,{hidden:u!==`checks`,children:b.length===0?t(`p`,{class:`muted`,children:`This request has no checks.`}):t(ui,{assertions:b})})]})]})]})}var mi=()=>{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 hi(e){let t=window.open(``,u,`popup,width=520,height=720`);if(!t)throw new oe(`The browser blocked the sign-in window. Allow pop-ups for this page and try again.`);let n=new BroadcastChannel(u),r;try{let{verifier:i,challenge:a}=await _(),o=b(),s=mi(),c=new Promise((t,i)=>{let a=setTimeout(()=>i(new oe(`Sign-in timed out. Try again.`)),e.timeoutMs??3e5),s=()=>clearTimeout(a);e.signal?.addEventListener(`abort`,()=>{s(),i(new oe(`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=S({authorizationUrl:e.authorizationUrl,clientId:e.clientId,redirectUri:s,scopes:e.scopes,state:o,challenge:a});let l=await c,{code:u}=ee({state:l.state,...l.code?{code:l.code}:{},...l.error?{error:l.error}:{},...l.description?{error_description:l.description}:{}},o),d=await e.exchange(M({code:u,verifier:i,clientId:e.clientId,redirectUri:s}),e.signal);return m(d)}finally{n.close(),r&&removeEventListener(`message`,r);try{t.close()}catch{}}}var gi=`specbook.oauth.clients.v1`,_i=`specbook.oauth.expiry.v1`,vi=(e,t)=>{try{return JSON.parse(e.getItem(t)??`{}`)}catch{return{}}},yi=(e,t,n)=>{try{e.setItem(t,JSON.stringify(n))}catch{}},bi=e=>{try{return vi(L.local,gi)[e]}catch{return}},xi=(e,t)=>{try{yi(L.local,gi,{...vi(L.local,gi),[e]:t})}catch{}},Si=(e,t)=>`${e}\n${t}`,Ci=(e,t,n)=>{try{let r=vi(L.session,_i);n===void 0?delete r[Si(e,t)]:r[Si(e,t)]=Date.now()+n*1e3,yi(L.session,_i,r)}catch{}},wi=(e,t)=>{try{return vi(L.session,_i)[Si(e,t)]}catch{return}};function Ti({service:e,profile:r,origin:i,secret:o,oauth:c,onSignedIn:l}){let u=g(c)?c.openIdConnectUrl:c.authorizationUrl,[d,f]=a(()=>c.clientId??bi(u)??``);n(()=>{f(c.clientId??bi(u)??``)},[u,c.clientId]);let[p,m]=a(void 0),[h,_]=a([]),[v,y]=a({kind:`idle`}),b=s(void 0),x=v.kind===`busy`,[S,C]=a(0);n(()=>{let e=!0;return m(void 0),y(e=>e.kind===`busy`?e:{kind:`idle`}),N.oauthEndpoints({env:P.value,version:A.value,profile:r}).then(t=>{e&&(m(t),_(g(c)?[`openid`]:Object.keys(t.scopes)))}).catch(t=>{e&&y({kind:`error`,message:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[r,P.value,A.value,S,te.value]);let w=Object.keys(p?.scopes??{}),T=()=>{if(!p)return C(e=>e+1);let e=d.trim();if(!e)return y({kind:`error`,message:`Enter the client id registered for this page.`});let t=new AbortController;b.current=t,y({kind:`busy`}),xi(u,e),hi({authorizationUrl:p.authorizationUrl,clientId:e,scopes:h,signal:t.signal,exchange:(e,t)=>N.oauthExchange({env:P.value,version:A.value,profile:r,fields:e,signal:t})}).then(e=>{I.set(i,o,e.accessToken),Ci(i,o,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 t(`span`,{class:`needs-var oauth-signin`,children:[t(`input`,{type:`text`,autocomplete:`off`,"aria-label":`Client id for ${e}`,placeholder:`client id`,value:d,disabled:x,onInput:e=>f(e.target.value)}),x?t(`button`,{type:`button`,class:`link`,onClick:()=>b.current?.abort(),children:`Cancel`}):t(`button`,{type:`button`,class:`btn`,disabled:!p&&!E,onClick:T,children:E?`Try again`:`Sign in`}),w.length>0&&t(`details`,{children:[t(`summary`,{class:`muted small`,children:[`Scopes (`,h.length,` of `,w.length,`)`]}),w.map(e=>t(`label`,{class:`small`,title:p?.scopes[e]||void 0,children:[t(`input`,{type:`checkbox`,checked:h.includes(e),disabled:x,onChange:t=>_(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),` `,t(`code`,{children:e})]}))]}),t(`span`,{class:`muted small oauth-status ${D?`oauth-hint`:``}`,role:`status`,"aria-live":`polite`,children:x?`Waiting for the sign-in window…`:v.kind===`error`?v.message:p?`Register this redirect URI with the provider: ${mi()}`:`Looking up the provider…`})]})}var Ei=e=>e===void 0?void 0:Math.max(0,Math.round((e-Date.now())/6e4)),Di={session:`this session`,process:`environment variable`,environment:`environment file`,shared:`shared file`};function Oi({services:e,enabled:r=!0,supplied:i}){let[o,s]=a([]),[c,u]=a({}),d=i??c,[,f]=a(0),[p,m]=a(!1),g=r&&P.value!==`mock`,_=e?.join(`
|
|
41
|
-
`)??`*`;if(n(()=>{if(!g){s([]);return}let t=!0;return i||N.managedSecrets(P.value).then(e=>t&&u(e)),N.config(A.value).then(async n=>{let r=[],i=await N.addressesIn(n,P.value);for(let[t,a]of Object.entries(n.services??{})){if(e&&!e.includes(t))continue;let o=a.auth?n.auth?.[a.auth]:void 0,s=i.baseUrl(t),c=C(s?h(s,globalThis.location?.href):void 0);if(!o||!c)continue;let l=a.auth?i.oauth(a.auth):void 0,u=[...new Set([...JSON.stringify(o.apply).matchAll(k)].map(e=>e[1]))];u.length&&r.push({service:t,origin:c,title:o.title??a.auth??``,names:u,profile:a.auth,oauth:l})}t&&s(r)}),()=>{t=!1}},[g,P.value,_,A.value,te.value]),!g||o.length===0)return null;let v=(e,t)=>I.get(e.origin,t)!==void 0||d[t]!==void 0,y=o.some(e=>e.names.some(t=>!v(e,t)));return!y&&!p?t(`div`,{class:`secrets-folded`,children:t(`button`,{type:`button`,class:`secrets-chip`,"aria-expanded":`false`,title:`Credentials are available. Tap to change or clear the ones set in this tab.`,onClick:()=>m(!0),children:[t(`span`,{"aria-hidden":`true`,children:`🔑`}),` `,o.map(e=>e.title||e.service).join(` · `),` ✓`]})}):t(`fieldset`,{class:`needs-vars ${y?``:`ok`}`,"aria-label":`Credentials for this request`,children:[o.map(e=>t(l,{children:[t(`span`,{class:`muted`,title:`Sent from this browser to ${e.origin}`,children:[e.service,` · `,e.title]}),e.names.map(n=>{let r=I.get(e.origin,n)!==void 0,i=d[n];return t(`span`,{class:`needs-var`,children:[t(`code`,{children:n}),r?t(l,{children:[t(`span`,{class:`muted`,children:[`✓ set`,e.oauth&&Ei(wi(e.origin,n))!==void 0?` · expires in ${Ei(wi(e.origin,n))} min`:``]}),t(`button`,{type:`button`,class:`link`,onClick:()=>{I.remove(e.origin,n),Ci(e.origin,n,void 0),f(e=>e+1)},children:`Clear`})]}):t(l,{children:[i&&t(`span`,{class:`muted`,children:[`from `,Di[i]??i]}),e.oauth&&t(Ti,{service:e.service,profile:e.profile,origin:e.origin,secret:n,oauth:e.oauth,onSignedIn:()=>f(e=>e+1)}),t(`input`,{type:`password`,autocomplete:`off`,"aria-label":`${n} for ${e.service}`,placeholder:i?`use another value`:`paste value`,onChange:t=>{let r=t.target.value;r!==``&&(I.set(e.origin,n,r),f(e=>e+1))}})]})]})})]})),t(`span`,{class:`muted small secrets-note`,children:`Kept in this tab only; sent from your browser to the API.`}),!y&&t(`button`,{type:`button`,class:`link`,onClick:()=>m(!1),children:`Hide`})]})}var ki=e=>e.replace(/<[^>]+>/g,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Ai=e=>e.replace(/\s+/g,` `).trim().toLowerCase();function ji(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(ki(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 Mi(e){let{seq:t}=e,[r,i]=a(),[s,c]=a(!1);n(()=>{let n=!0;i(void 0),c(!1);let r=w.docs.find(n=>n.sequence===t.meta.id||n.sequenceFile===e.file);if(!r)c(!0);else return r.load().then(e=>n&&i(e)).finally(()=>n&&c(!0)),()=>{n=!1}},[t.meta.id,e.file]);let l=o(()=>t.nodes.map(e=>e.name),[t]);return o(()=>({...ji(r??Pe(t.meta.description),l),loaded:s}),[r,l,t,s])}function Ni(e){let[t,r]=a();return n(()=>{let t=!0;return r(void 0),e&&w.docs.find(t=>t.requestFile===e)?.load().then(e=>t&&r(e)),()=>{t=!1}},[e]),t}var Pi=(e,t)=>`specbook:draft:${e}:${t}`,Fi=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);function Ii(e){try{let t=L.local.getItem(e);return t?JSON.parse(t):void 0}catch{return}}var Li=`specbook:saved-example`;function Ri(e){try{let t=L.session.getItem(Li),n=t?JSON.parse(t):void 0;return n?.key===e?(L.session.removeItem(Li),n):void 0}catch{return}}function zi({service:e,op:r,variants:i,initial:c,autoRun:u}){let p=`${e}/${r.id}`,m=s(null),h=s(!1),g=s(void 0),_=N.examplesOf(p),[v,y]=a(()=>Ri(p)),[b,x]=a(()=>{if(c?.startsWith(`saved:`)&&i.some(e=>`saved:${e.file}`===c))return c;let e=_.find(e=>e.name===(v?.name??c));return e?`ex:${e.name}`:_[0]?`ex:${_[0].name}`:i[0]?`saved:${i[0].file}`:``}),S=b.startsWith(`saved:`)?i.find(e=>`saved:${e.file}`===b):void 0,C=Ni(S?.file),D=pt(p),[k,M]=a(),[ee,F]=a(),[I,oe]=a(),[R,ce]=a({}),[le,ue]=a(),[de,fe]=a(),[z,pe]=a(),[me,he]=a(),[ge,_e]=a(),[ve,ye]=a(),[be,xe]=a(!1),[Se,Ce]=a(),[we,B]=a(),[Te,Ee]=a(``),[V,De]=a(),[Oe,H]=a();n(()=>{let t=!0;if(H(void 0),P.value===`mock`)Ee(``);else return N.baseUrlOf(e,P.value,A.value).then(e=>t&&Ee(e??``)).catch(e=>{t&&(Ee(``),H(e instanceof Error?e.message:String(e)))}),()=>{t=!1}},[e,P.value,A.value,te.value]),n(()=>{let e=!0;return De(void 0),N.knownVars(P.value,A.value).then(t=>e&&De(t)),()=>{e=!1}},[P.value]),n(()=>{let t=!0;return w.schemas[p]?.().then(e=>t&&ue(e.default)),w.responseSchemas[p]?.().then(e=>t&&fe(e.default)),w.definitions[e]?.().then(e=>t&&pe(e.default)),N.operationMeta(p,A.value).then(e=>{t&&M({encoding:e?.encoding??`json`,files:e?.files??[]})}),()=>{t=!1}},[p,e]);let U=k?.encoding??`json`,ke=w.manifests[e]?.operations.find(e=>e.id===r.id)?.secured;n(()=>{if(!k)return;let e=!0;return ye(void 0),_e(void 0),(async()=>{let t=S?await N.savedExample(S.def,A.value):await N.loadExample(p,b.replace(/^ex:/,``),A.value);if(!e)return;let n=t??{name:`empty`,source:`generated`};F(n),oe(!S&&Ii(Pi(p,b))||Cr(n,U))})().catch(t=>e&&ye(t instanceof Error?t.message:String(t))),()=>{e=!1}},[p,b,k,S]);let Ae=o(()=>ee?Cr(ee,U):void 0,[ee,U]),je=!!I&&!!Ae&&JSON.stringify(Er(I))!==JSON.stringify(Er(Ae)),Me=e=>{if(oe(e),!S)try{let t=Pi(p,b);Ae&&JSON.stringify(Er(e))===JSON.stringify(Er(Ae))?L.local.removeItem(t):L.local.setItem(t,JSON.stringify(Er(e)))}catch{}},W=o(()=>{let e=le?q(le,z):void 0,t={path:[],query:[],headers:[]};for(let n of[`path`,`query`,`headers`]){let r=e?.properties?.[n];r&&(t[n]=Ge(r,z).map(e=>({name:e.name,doc:Dt(Tt(le,z,[e.name],[n]),D.notes,n,e.name),repeat:q(e.schema,z).type===`array`})))}return t},[le,z,D.notes]),Ne=o(()=>{if(!I)return[];try{let e=Tr(I,U);return[...f([e.path,e.query,e.headers,e.data])].filter(e=>!e.startsWith(`faker.`)&&!e.startsWith(`secrets.`)&&!e.startsWith(`session.`)).map(d).filter((e,t,n)=>n.indexOf(e)===t)}catch{return[]}},[I,U]),Pe=Object.keys(S?.def.input.init??{}),Fe=V?Ne.filter(e=>!V.includes(e)&&!Pe.includes(e)):[],Ie=Fe.filter(e=>(R[e]??``)===``),Le=async e=>{if(!I||g.current)return;ye(void 0),xe(!0);let t=new AbortController;g.current=t;try{let n=S?S.def:await N.operationRequest(p,A.value,Tr(I,U)),r=await N.run(n,{env:P.value,version:A.value,mockStatus:P.value===`mock`?e??me:void 0,locale:ae.value,seed:ne.value,vars:Object.fromEntries(Object.entries(R).filter(([,e])=>e!==``)),fileDir:ee?.dir,signal:t.signal});_e(r),yt.value=bt(r)}catch(e){ye(e instanceof Error?e.message:String(e))}finally{g.current=void 0,xe(!1),B(`response`)}};n(()=>{u&&I&&!h.current&&(h.current=!0,Le())},[I]);let Re=async t=>{if(!I)return;let n=Tr(I,U),i=Fi(t),a={name:i,title:t,source:`project`,path:n.path,query:n.query,headers:n.headers,body:typeof n.data==`object`&&n.data instanceof Blob?void 0:n.data},o=`${w.project.requestsDir}/${e}/${r.id}/${i}.example.json`,s={key:p,path:o,name:i};try{L.session.setItem(Li,JSON.stringify(s))}catch{}await ie(o,`${JSON.stringify(a,null,2)}\n`),y(s),Ce(void 0)},G=ge?.steps.find(e=>e.response)??ge?.steps[0],ze=ve?.match(/Missing variable "\{\{([^}.]+)/)?.[1],Be=!!I&&(I.path.length>0||I.query.length>0||W.path.length>0||W.query.length>0),Ve=!!I&&(I.headers.length>0||W.headers.length>0),He=!!I&&U!==`none`&&(I.body!==``||I.fields.length>0||!!le?.properties?.data),K=we??(Be?`params`:He?`body`:Ve?`headers`:`params`),J=e=>e.filter(e=>e.enabled).length,Ue=I?J(I.query):0,We=I?J(I.path):0,Ke=I?Dr(r.path,I.path,I.query,Te):r.path;return n(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),Le())},t=m.current?.getRootNode()??window;return t.addEventListener(`keydown`,e),()=>t.removeEventListener(`keydown`,e)}),t(`div`,{class:`request-panel`,"data-op":p,ref:m,children:t(`div`,{class:`rq`,children:[t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${r.method}`,children:r.method}),t(`div`,{class:`rq-url`,title:Ke,children:t(`code`,{children:Ke.split(/(\{\{[^}]*\}\}|\{[^}]+\})/).map(e=>/^\{/.test(e)?t(`mark`,{children:e}):e)})}),(G?.response||ve||G?.error)&&t(`button`,{type:`button`,class:`result-chip ${G?.response?tt(G.response.status):`s5`}`,title:`Open the response`,onClick:()=>B(`response`),children:G?.response?`${G.response.status} ${et(G.response.status)} · ${G.response.durationMs} ms`:`Failed`}),t(`button`,{type:`button`,class:`btn primary send`,title:be?`Stop`:`Send (⌘/Ctrl + Enter)`,"aria-label":be?`Stop`:`Send`,disabled:!be&&!I,onClick:()=>be?g.current?.abort():Le(),children:t(be?se:T,{})})]}),Oe&&t(`p`,{class:`envmenu-warn`,role:`alert`,children:[Oe,`.`,` `,O.value.environmentSettings&&t(`button`,{type:`button`,class:`link`,onClick:()=>E.value=!0,children:`Open Environment settings`})]}),C&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this request`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:C}})]},S?.file),Fe.length>0&&t(`fieldset`,{class:`needs-vars ${Ie.length===0?`ok`:``}`,"aria-label":`Values this request needs`,children:[t(`span`,{class:`muted`,children:Ie.length>0?`Needs a value for`:`Values for`}),Fe.map(e=>t(`label`,{class:`needs-var`,children:[t(`code`,{children:e}),t(`input`,{type:`text`,"aria-label":e,placeholder:`value`,value:R[e]??``,onInput:t=>ce({...R,[e]:t.target.value})})]}))]}),ke&&t(Oi,{services:[e]}),t(`div`,{class:`rq-meta`,children:[t(`div`,{class:`rq-example`,children:[t(`label`,{class:`row`,children:[t(`span`,{class:`muted`,children:`Example`}),t(`select`,{value:b,onChange:e=>x(e.target.value),children:[_.map(e=>t(`option`,{value:`ex:${e.name}`,children:[e.name,e.source===`project`?` · yours`:``]})),i.map(e=>t(`option`,{value:`saved:${e.file}`,children:[e.name,` · request`]}))]})]}),t(re,{})]}),je&&t(`span`,{class:`edited`,children:`Edited`}),t(`span`,{class:`spacer`}),je&&t(`button`,{type:`button`,class:`link`,onClick:()=>Ae&&Me(Ae),children:`↺ Reset`}),!j&&!S&&je&&Se===void 0&&t(`button`,{type:`button`,class:`link`,onClick:()=>Ce(``),children:`Save as example…`}),P.value===`mock`&&r.statuses.length>0&&t(`label`,{class:`rq-status`,children:[t(`span`,{class:`muted`,children:`Respond with`}),t(`select`,{"aria-label":`Mock response`,value:me===void 0?``:String(me),onChange:e=>{let t=e.target.value,n=t===``?void 0:Number(t);he(n),Le(n)},children:[t(`option`,{value:``,children:`Default`}),r.statuses.map(e=>t(`option`,{value:String(e),children:[e,` `,et(e)]}))]})]})]}),v&&t(`p`,{class:`saved-note`,role:`status`,children:[t(`span`,{children:[`✓ Saved to `,t(`code`,{children:v.path}),`. It is a normal project file: commit it to share this example with your team.`]}),t(`button`,{type:`button`,class:`icon`,"aria-label":`Dismiss`,onClick:()=>y(void 0),children:`×`})]}),Se!==void 0&&t(`form`,{class:`row naming`,onSubmit:e=>{e.preventDefault(),Se.trim()&&Re(Se.trim()).catch(e=>ye(String(e)))},children:[t(`input`,{autofocus:!0,placeholder:`Name this example`,"aria-label":`Example name`,value:Se,onInput:e=>Ce(e.target.value)}),t(`button`,{type:`submit`,class:`btn`,children:`Save`}),t(`button`,{type:`button`,class:`link`,onClick:()=>Ce(void 0),children:`Cancel`})]}),S&&t(`p`,{class:`muted lock`,children:[`A request from your project: it runs with its own values and checks. Edit its file to change it.`,P.value===`mock`&&S.def.mockHook?` Its mock hook shapes the answer.`:``]}),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[[`params`,`Params`,Ue+We],[`headers`,`Headers`,I?J(I.headers):0],[`body`,`Body`,0],[`vars`,`Variables`,Ne.length]].filter(([e])=>e===`params`?Be:e===`headers`?Ve:e===`body`?He:Ne.length>0).map(([e,n,r])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":K===e,class:`rq-tab ${K===e?`on`:``}`,onClick:()=>B(e),children:[n,r>0&&t(`span`,{class:`count`,children:r}),e===`body`&&t(`span`,{class:`chip`,children:U})]})),t(`span`,{class:`tab-gap`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`request`,class:`rq-tab ${K===`request`?`on`:``}`,onClick:()=>B(`request`),children:`Request`}),t(`button`,{type:`button`,role:`tab`,"aria-selected":K===`response`,class:`rq-tab ${K===`response`?`on`:``}`,onClick:()=>B(`response`),children:[`Response`,G?.response&&t(`span`,{class:`state-dot ${tt(G.response.status)}`,children:G.response.status}),!G?.response&&(ve||G?.error)&&t(`span`,{class:`state-dot s5`,children:`!`})]})]}),t(`div`,{class:`rq-pane`,children:[I&&t(l,{children:[t(`div`,{class:`tab-pane`,hidden:K!==`params`,children:[(I.query.length>0||W.query.length>0)&&t(Wr,{title:`Query`,rows:I.query,documented:W.query,readOnly:!!S,onChange:e=>Me({...I,query:e})}),(I.path.length>0||W.path.length>0)&&t(Wr,{title:`Path`,rows:I.path,documented:W.path,fixed:!0,readOnly:!!S,onChange:e=>Me({...I,path:e})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`headers`,children:Ve&&t(Wr,{title:`Headers`,rows:I.headers,documented:W.headers,readOnly:!!S,onChange:e=>Me({...I,headers:e})})}),t(`div`,{class:`tab-pane`,hidden:K!==`body`,children:He&&t(qr,{encoding:U,draft:I,onChange:Me,schema:le,defs:z,files:k?.files,notes:D.notes,readOnly:!!S})}),t(`div`,{class:`tab-pane`,hidden:K!==`vars`,children:Ne.length>0&&t(Wr,{title:`Variables`,rows:Ne.map(e=>({key:e,value:R[e]??``,enabled:!0})),fixed:!0,bad:ze,placeholder:`from the request's init, config or earlier steps`,onChange:e=>ce(Object.fromEntries(e.map(e=>[e.key,e.value])))})})]}),t(`div`,{class:`tab-pane`,hidden:K!==`request`,children:I&&t(Zr,{service:e,method:r.method,path:r.path,draft:I,encoding:U,vars:R,secured:ke,sent:G?.request?t(ii,{request:G.request,docs:{schema:le,defs:z,notes:D.notes}}):void 0})}),t(`div`,{class:`tab-pane`,hidden:K!==`response`,children:t(pi,{step:G,error:ve,schemas:de,defs:z})})]})]})})}function Bi(e){let t=e.opts??{},n={...typeof t.label==`string`?{label:t.label}:{},...typeof t.description==`string`?{description:t.description}:{}};return{...Vi(e,t),...n}}function Vi(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,Bi(t)]))};case`array`:return{kind:`array`,item:Bi(t.item),default:t.default,min:t.min,max:t.max};default:return typeof t.default==`function`?{kind:e.kind,generate:t.default,min:t.min,max:t.max}:{kind:e.kind,default:t.default,min:t.min,max:t.max}}}function Hi(e){if(e.generate)try{return e.generate()}catch{}return Ui({...e,generate:void 0})}function Ui(e){if(e.generate)return Hi(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,Ui(t)]));case`array`:return e.default??[];case`boolean`:return e.default??!1;case`number`:return e.default??0;default:return e.default??``}}var Wi={step:`request`,each:`for each item`,input:`you choose`,check:`check`},Gi=e=>typeof e==`string`?e:$r(e);function Ki({info:e}){let{seq:n}=e,{intro:r,notes:i}=Mi(e),a=o(()=>Object.entries(n.meta.inputs??{}).map(([e,t])=>{let n=Bi(t);return{name:e,spec:n,initial:Ui(n)}}),[n]);return t(`article`,{class:`doc`,"data-seq":n.meta.id,children:[(n.meta.tags?.length??0)>0&&t(`p`,{class:`doc-tags`,children:n.meta.tags?.map(e=>t(`span`,{class:`chip`,children:e}))}),r&&t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}}),a.length>0&&t(`section`,{children:[t(`h2`,{children:`Controls`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`Name`}),t(`th`,{children:`Type`}),t(`th`,{children:`Default`}),t(`th`,{children:`Description`})]})}),t(`tbody`,{children:a.map(e=>t(`tr`,{children:[t(`td`,{children:t(`code`,{children:e.name})}),t(`td`,{children:t(`span`,{class:`chip`,children:e.spec.kind})}),t(`td`,{children:t(`code`,{children:Gi(e.initial)})}),t(`td`,{children:e.spec.description})]}))})]})]}),t(`section`,{children:[t(`h2`,{children:`Steps`}),t(`table`,{class:`fields`,children:[t(`thead`,{children:t(`tr`,{children:[t(`th`,{children:`#`}),t(`th`,{children:`Step`}),t(`th`,{children:`What it does`})]})}),t(`tbody`,{children:n.nodes.map((e,n)=>{let r=(e.kind===`step`&&typeof e.def!=`function`?e.def:void 0)?.op,a=i.get(e.name);return t(l,{children:[t(`tr`,{class:a?`has-note`:``,children:[t(`td`,{children:n+1}),t(`td`,{children:e.name}),t(`td`,{children:r?t(`button`,{type:`button`,class:`link`,title:`Open this operation`,onClick:()=>x({kind:`op`,key:`${r.service}/${r.id}`}),children:[t(`span`,{class:`method ${r.method}`,children:r.method}),` `,t(`code`,{children:r.path})]}):t(`span`,{class:`muted`,children:Wi[e.kind]??e.kind})})]}),a&&t(`tr`,{class:`step-note-row`,children:[t(`td`,{}),t(`td`,{colSpan:2,children:t(`div`,{class:`doc-custom step-note`,dangerouslySetInnerHTML:{__html:a}})})]})]})})})]})]})]})}var qi=(e,t)=>e===t||JSON.stringify(e)===JSON.stringify(t);function Ji(e){let t=[e.kind];return(e.min!==void 0||e.max!==void 0)&&t.push(`${e.min??``}–${e.max??``}`),t.join(` · `)}function Yi({name:e,spec:n,value:r,onChange:i}){let[o,s]=a();switch(n.kind){case`number`:return t(`input`,{class:`cell`,type:`number`,"aria-label":e,value:String(r??``),min:n.min,max:n.max,onInput:e=>{let t=e.target.value;i(t===``?void 0:Number(t))}});case`boolean`:return t(jr,{label:e,value:String(!!r),options:[`true`,`false`],onChange:e=>e===`true`||e===`false`?i(e===`true`):void 0});case`date`:return t(`input`,{class:`cell`,type:`date`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)});case`select`:{let a=n.options??[],o=a.find(e=>qi(e.value,r));return t(jr,{label:e,value:o?.label??String(r??``),options:a.map(e=>e.label),onChange:e=>{let t=a.find(t=>t.label===e);t&&i(t.value)}})}case`multiselect`:{let e=r??[];return t(`div`,{class:`multi-cell`,children:(n.options??[]).map(n=>t(`label`,{children:[t(`input`,{type:`checkbox`,checked:e.some(e=>qi(e,n.value)),onChange:t=>i(t.target.checked?[...e,n.value]:e.filter(e=>!qi(e,n.value)))}),n.label]}))})}case`object`:case`array`:return t(`input`,{class:`cell mono`,"aria-label":e,value:o??JSON.stringify(r??Ui(n)),onInput:e=>{let t=e.target.value;s(t);try{i(JSON.parse(t))}catch{}},onBlur:()=>s(void 0)});default:return t(`input`,{class:`cell`,"aria-label":e,value:String(r??``),onInput:e=>i(e.target.value)})}}function Xi(){return t(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,"aria-hidden":`true`,focusable:`false`,children:[t(`rect`,{x:`1.5`,y:`1.5`,width:`13`,height:`13`,rx:`3`,fill:`none`,stroke:`currentColor`}),t(`circle`,{cx:`5.2`,cy:`5.2`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`10.8`,cy:`10.8`,r:`1.1`,fill:`currentColor`}),t(`circle`,{cx:`8`,cy:`8`,r:`1.1`,fill:`currentColor`})]})}function Zi({title:e,specs:n,values:r,onChange:i}){let a=Object.keys(n);if(a.length===0)return null;let o=a.filter(e=>n[e]?.generate);return t(`section`,{class:`grid controls-grid`,"aria-label":e,children:[t(`h3`,{class:`controls-head`,children:[t(`span`,{children:e}),o.length>1&&t(`button`,{type:`button`,class:`btn small gen-all`,title:`Make a new value for every generated input`,onClick:()=>i({...r,...Object.fromEntries(o.map(e=>[e,Hi(n[e])]))}),children:[t(Xi,{}),` Generate all`]})]}),t(`table`,{children:[t(`colgroup`,{children:[t(`col`,{class:`c-key`}),t(`col`,{class:`c-val`}),t(`col`,{})]}),t(`thead`,{children:t(`tr`,{children:[t(`th`,{class:`g-key`,children:`Name`}),t(`th`,{class:`g-val`,children:`Value`}),t(`th`,{class:`g-doc`,children:`Description`})]})}),t(`tbody`,{children:a.map(e=>{let a=n[e];return t(`tr`,{children:[t(`td`,{class:`g-key`,children:t(`span`,{class:`key`,children:t(`code`,{children:a.label??e})})}),t(`td`,{class:`g-val`,children:t(`div`,{class:a.generate?`cell-gen`:void 0,children:[t(Yi,{name:e,spec:a,value:r[e],onChange:t=>i({...r,[e]:t})}),a.generate&&t(`button`,{type:`button`,class:`gen`,"aria-label":`Generate ${a.label??e}`,title:`Make another value`,onClick:()=>i({...r,[e]:Hi(a)}),children:t(Xi,{})})]})}),t(`td`,{class:`g-doc`,title:a.description,children:[t(`span`,{class:`chip`,children:Ji(a)}),` `,a.description]})]},e)})})]})]})}function Qi({step:e,note:r}){let[i,o]=a(`response`),[s,c]=a(),[l,u]=a(),[d,f]=a(),[p,m]=a(`json`),h=e.request,g=h?.opId?`${h.service}/${h.opId}`:void 0;n(()=>{o(`response`)},[e.name]),n(()=>{let e=!0;return c(void 0),u(void 0),f(void 0),g&&h&&(w.schemas[g]?.().then(t=>e&&f(t.default)),N.operationMeta(g,A.value).then(t=>e&&m(t?.encoding??`json`)),w.responseSchemas[g]?.().then(t=>e&&c(t.default)),w.definitions[h.service]?.().then(t=>e&&u(t.default))),()=>{e=!1}},[g]);let _=e.response,v=h?`${h.url}${ni(h.query)}`:``;return t(`div`,{class:`step-exchange`,children:[h&&t(`div`,{class:`rq-bar`,children:[t(`span`,{class:`method ${h.method}`,children:h.method}),t(`div`,{class:`rq-url`,title:v,children:t(`code`,{children:v})}),_&&t(`span`,{class:`result-chip ${tt(_.status)}`,children:[_.status,` `,et(_.status),` · `,_.durationMs,` ms`]})]}),r&&t(`details`,{class:`step-about`,children:[t(`summary`,{children:`About this step`}),t(`div`,{class:`doc-custom`,dangerouslySetInnerHTML:{__html:r}})]},e.name),t(`div`,{class:`rq-tabs`,role:`tablist`,children:[[`request`,`Request`],[`response`,`Response`]].map(([e,n])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":i===e,class:`rq-tab ${i===e?`on`:``}`,onClick:()=>o(e),children:[n,e===`response`&&_&&t(`span`,{class:`state-dot ${tt(_.status)}`,children:_.status})]}))}),t(`div`,{class:`rq-pane`,children:[t(`div`,{class:`tab-pane`,hidden:i!==`request`,children:h?t(Qr,{request:h,encoding:p,sent:t(ii,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}):t(ii,{request:h,hideBar:!0,docs:{schema:d,defs:l}})}),t(`div`,{class:`tab-pane`,hidden:i!==`response`,children:t(pi,{step:e,schemas:s,defs:l,hideRequest:!0})})]})]})}var $i=e=>e.replace(/ #\d+$/,``),ea={pass:`✓`,fail:`✗`,error:`!`,skipped:`–`,running:`…`,paused:`⏸`,pending:``};function ta({info:e,preset:r,autoRun:i}){let{seq:c}=e,l=o(()=>Object.fromEntries(Object.entries(c.meta.inputs??{}).map(([e,t])=>[e,Bi(t)])),[c]),u=Mi(e),d=o(()=>{let e=new Set;for(let t of c.nodes)if(t.kind===`step`&&typeof t.def!=`function`)e.add(t.def.op.service);else if(t.kind===`step`||t.kind===`each`)return;return[...e]},[c]),[f,p]=a({}),[m,h]=a(),[g,_]=a({}),[v,y]=a(!1),[b,x]=a(),[S,C]=a({}),[w,T]=a(0),[E,D]=a(!1),[O,k]=a(),j=Object.values(l).some(e=>e.generate),M=Object.keys(l).length>0||c.nodes.some(e=>e.kind===`input`),ee=async()=>(j&&await N.fakerReady(A.value,ae.value,ne.value).catch(()=>{}),Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)])));n(()=>{let e=!0,t=e=>({...e,...r??{}});return p(t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)])))),j?ee().then(n=>{e&&(p(t(n)),i&&R({inputs:t(n),headless:!0}))}):i&&R({inputs:t(Object.fromEntries(Object.entries(l).map(([e,t])=>[e,Ui(t)]))),headless:!0}),h(void 0),_({}),x(void 0),()=>{e=!1}},[e.file]);let te=c.nodes.map(e=>e.name),ie=m?m.steps.filter(e=>e.kind!==`auth`).map(e=>({name:e.name,step:e})):te.map(e=>({name:e})),F=ie[w]?.step,I=s(void 0),[oe,se]=a(!1),L=()=>{se(!0),I.current?.abort(),b?.resolve(S)},R=async(e={})=>{let t=new AbortController;I.current=t,se(!1),y(!0),h(void 0),k(void 0),_({}),T(0),D(!1);try{let n=await N.run(c,{env:P.value,version:A.value,inputs:e.inputs??f,locale:ae.value,seed:ne.value,signal:t.signal,onEvent:e=>{e.type===`step:start`&&_(t=>({...t,[e.name]:`running`})),e.type===`step:end`&&_(t=>({...t,[e.name]:e.status}))},onInput:e.headless?void 0:({name:e,controls:t})=>new Promise(n=>{let r=t;_(t=>({...t,[e]:`paused`})),C(Object.fromEntries(Object.entries(r).map(([e,t])=>[e,Ui(t)]))),x({name:e,controls:r,resolve:e=>{x(void 0),n(e)}})})});h(n),yt.value=bt(n);let r=n.steps.filter(e=>e.kind!==`auth`).findIndex(e=>e.status===`fail`||e.status===`error`);r>=0&&T(r)}catch(e){k(e instanceof Error?e.message:String(e))}finally{I.current=void 0,y(!1),x(void 0)}},ce=m?.status;return t(`div`,{class:`sequence-panel ${E&&F?`sheet-open`:``}`,"data-seq":c.meta.id,children:[t(`div`,{class:`seq-left`,children:[t(Oi,{services:d}),t(Zi,{title:`Inputs`,specs:l,values:f,onChange:p}),t(`div`,{class:`seq-run`,children:[t(`button`,{type:`button`,class:`btn primary`,disabled:v,onClick:()=>R(),children:v?`Running…`:`▶ Run`}),v&&t(`button`,{type:`button`,class:`btn`,onClick:L,children:`Stop`}),M&&t(`button`,{type:`button`,class:`btn`,disabled:v,title:`Skip every question and use each input's default, as specbook test does`,onClick:async()=>{let e=await ee();p(e),await R({inputs:e,headless:!0})},children:`Run with defaults`}),t(re,{}),m&&t(`span`,{class:`badge ${ce}`,children:[ea[ce],` `,ce===`pass`?`Passed`:oe?`Stopped`:ce===`fail`?`Failed`:`Error`,` `,`· `,m.totals.passed,`/`,m.totals.steps,` steps · `,m.durationMs,`ms`]})]}),O&&t(`p`,{class:`error-text`,children:O}),t(`ol`,{class:`journey`,part:`timeline`,"aria-label":`Timeline`,children:ie.map((e,n)=>{let r=e.step,i=r?.status??g[e.name]??`pending`,a=r?.assertions.filter(e=>!e.pass)??[];return t(`li`,{class:`jstep ${i} ${w===n?`picked`:``}`,children:[t(`div`,{class:`jmark`,children:ea[i]||n+1}),t(`div`,{class:`jbody`,children:[t(`button`,{type:`button`,class:`jhead`,disabled:!r,onClick:e=>{let t=e.currentTarget;T(n),D(!0),requestAnimationFrame(()=>t.scrollIntoView?.({block:`start`,behavior:`smooth`}))},children:[t(`span`,{class:`jname`,children:e.name}),r?.response&&t(`span`,{class:`muted`,children:[r.response.status,` · `,r.durationMs,`ms`]}),r&&r.assertions.length>0&&t(`span`,{class:a.length?`error-text`:`muted`,children:[r.assertions.length-a.length,`/`,r.assertions.length,` checks`]})]}),r?.uses?.filter(e=>e.source===`capture`).map(e=>t(`span`,{class:`cap use`,title:`from step "${e.step}"`,children:[`← `,e.key,` `,t(`em`,{children:[`from `,e.step]})]})),r&&Object.entries(r.captured).map(([e,n])=>t(`span`,{class:`cap make`,title:$r(n),children:[`→ `,e,` `,t(`b`,{children:ei(n)})]})),r?.error&&t(`div`,{class:`error-text`,children:r.error}),a.map(e=>t(li,{a:e})),i===`skipped`&&t(`div`,{class:`muted`,children:oe?`Skipped: you stopped the run.`:`Skipped: an earlier step did not pass.`}),b&&g[e.name]===`paused`&&t(`div`,{class:`pause`,children:[t(`strong`,{children:[`Your turn: `,b.name]}),t(Zi,{title:`Choose`,specs:b.controls,values:S,onChange:C}),t(`button`,{type:`button`,class:`btn primary`,onClick:()=>b.resolve(S),children:`Continue ▶`})]})]})]})})})]}),t(`div`,{class:`seq-right ${E&&F?`sheet-open`:``}`,children:[F&&t(`button`,{type:`button`,class:`sheet-close`,"aria-label":`Hide step details`,onClick:()=>D(!1),children:[t(`span`,{"aria-hidden":`true`,children:`⌄`}),` `,F.name]}),!F&&t(`div`,{class:`rs-empty`,children:[t(`strong`,{children:`Nothing run yet`}),t(`span`,{class:`muted`,children:`Press Run, then pick a step to see its request and response.`})]}),F&&t(Qi,{step:F,note:u.notes.get($i(F.name))})]})]})}function na(e){let n=e.tab??`try`,r=t(`div`,{class:`rq-tabs panel-tabs`,role:`tablist`,children:[[`try`,e.kind===`seq`?`Run`:`Try`],[`docs`,`Docs`]].map(([r,i])=>t(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,class:`rq-tab ${n===r?`on`:``}`,onClick:()=>e.onNavigate({tab:r}),children:i}))});return e.kind===`seq`?t(wt,{title:e.info.seq.meta.title,subtitle:`Sequence`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(Ki,{info:e.info}):t(ta,{info:e.info,preset:e.preset,autoRun:e.autoRun})})]})}):t(wt,{title:e.op.summary?.replace(/\.$/,``)||e.op.path,subtitle:`${e.op.method} ${e.op.path}`,flush:!0,modal:e.modal,variant:e.variant,onPrev:e.onPrev,onNext:e.onNext,onClose:e.onClose,children:t(`div`,{class:`panel-split`,children:[r,t(`div`,{class:`panel-main ${n===`docs`?`scroll`:``}`,children:n===`docs`?t(vt,{service:e.service,op:e.op,variants:e.variants,onTry:t=>e.onNavigate({tab:`try`,example:t})},`${e.service}/${e.op.id}`):t(zi,{service:e.service,op:e.op,variants:e.variants,initial:e.example,autoRun:e.autoRun},`${e.service}/${e.op.id}${e.example.startsWith(`saved:`)?`@${e.example}`:``}`)})]})})}export{na as Host};
|