integration-tour 1.0.10 → 1.0.11
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/README.md +1 -1
- package/dist/cli.js +68 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ integration-tour check openapi.yaml --edits docs/flows/
|
|
|
57
57
|
|
|
58
58
|
`--allow-private-refs` lets the spec's references reach this machine and private networks, which they otherwise don't (see below): pass it for a spec you trust that references an internal schema server.
|
|
59
59
|
|
|
60
|
-
Before `render` writes anything in a terminal, it
|
|
60
|
+
Before `render` writes anything in a terminal, it lists anything that may be personal or internal (an email address, a phone number, a private host, a long random value that may be a key), then asks you to confirm that everything is correct and holds no secrets or personal data. `--yes` confirms, for a script. It never asks in CI or where nothing can answer.
|
|
61
61
|
|
|
62
62
|
Both commands exit with 1 when something failed, and 2 when the command itself is wrong. `--help`, alone or after a command, prints a summary of them, and `--version` the package's version.
|
|
63
63
|
|
package/dist/cli.js
CHANGED
|
@@ -2718,6 +2718,7 @@ var cli_exports = {};
|
|
|
2718
2718
|
__export(cli_exports, {
|
|
2719
2719
|
didYouMean: () => didYouMean,
|
|
2720
2720
|
main: () => main,
|
|
2721
|
+
oneLine: () => oneLine,
|
|
2721
2722
|
progressLine: () => progressLine
|
|
2722
2723
|
});
|
|
2723
2724
|
module.exports = __toCommonJS(cli_exports);
|
|
@@ -2880,15 +2881,31 @@ function canonical(value) {
|
|
|
2880
2881
|
var REPEATED_GROUP = /\)(?:[*+]|\{\d+,?\d*\})/;
|
|
2881
2882
|
var compiled = /* @__PURE__ */ new Map();
|
|
2882
2883
|
function patternVerdict(pattern, value) {
|
|
2883
|
-
if (value.length > 40
|
|
2884
|
+
if (value.length > Math.min(40, quickLength(pattern))) return void 0;
|
|
2884
2885
|
const re = compiledPattern(pattern);
|
|
2885
2886
|
return re === null ? void 0 : re.test(value);
|
|
2886
2887
|
}
|
|
2887
2888
|
function matchesPattern(pattern, value) {
|
|
2888
|
-
if (value.length > 2e3
|
|
2889
|
+
if (value.length > Math.min(2e3, quickLength(pattern))) return true;
|
|
2889
2890
|
const re = compiledPattern(pattern);
|
|
2890
2891
|
return re === null || re.test(value);
|
|
2891
2892
|
}
|
|
2893
|
+
var STEP_BUDGET = 1e6;
|
|
2894
|
+
var quickLengths = /* @__PURE__ */ new Map();
|
|
2895
|
+
function quickLength(pattern) {
|
|
2896
|
+
let length = quickLengths.get(pattern);
|
|
2897
|
+
if (length === void 0) {
|
|
2898
|
+
if (REPEATED_GROUP.test(pattern)) length = 0;
|
|
2899
|
+
else {
|
|
2900
|
+
const bare2 = pattern.replace(/\\./g, "x").replace(/\[(?:\\.|[^\]\\])*\]/g, "x");
|
|
2901
|
+
const repeats = (bare2.match(/[*+]|\{\d*,(\d*)\}/g) ?? []).filter((q) => !/,\d{1,2}\}$/.test(q)).length;
|
|
2902
|
+
length = repeats <= 1 ? Infinity : Math.floor(Math.round(STEP_BUDGET ** (1 / repeats) * 1e3) / 1e3);
|
|
2903
|
+
}
|
|
2904
|
+
if (quickLengths.size > 2e3) quickLengths.clear();
|
|
2905
|
+
quickLengths.set(pattern, length);
|
|
2906
|
+
}
|
|
2907
|
+
return length;
|
|
2908
|
+
}
|
|
2892
2909
|
function compiledPattern(pattern) {
|
|
2893
2910
|
let re = compiled.get(pattern);
|
|
2894
2911
|
if (re === void 0) {
|
|
@@ -3894,7 +3911,7 @@ function uuidLike(name) {
|
|
|
3894
3911
|
function idWords(name) {
|
|
3895
3912
|
const all = name.replace(/[_-]?(uu|s|g)?id$/i, "").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase().split(/[^a-z]+/).filter(Boolean);
|
|
3896
3913
|
const kept = all.filter((w) => !ID_NOISE.test(w));
|
|
3897
|
-
return (kept.length ? kept : all).map((w, i,
|
|
3914
|
+
return (kept.length ? kept : all).map((w, i, list7) => i === list7.length - 1 ? singular(w) : w);
|
|
3898
3915
|
}
|
|
3899
3916
|
function seedHash(seed) {
|
|
3900
3917
|
let h = 2166136261;
|
|
@@ -4326,7 +4343,7 @@ function python(req) {
|
|
|
4326
4343
|
const files = typed.length ? typed : parts;
|
|
4327
4344
|
const fields = typed.length ? parts.filter((p) => !p.file && !p.type) : [];
|
|
4328
4345
|
const file = (p) => p.file ? `open(${jsString(filePath(p.name))}, "rb")` : p.type ? `(None, ${jsString(p.text)}, ${jsString(p.type)})` : `(None, ${jsString(p.text)})`;
|
|
4329
|
-
const twice = (
|
|
4346
|
+
const twice = (list7) => new Set(list7.map((p) => p.name)).size < list7.length;
|
|
4330
4347
|
if (files.length) {
|
|
4331
4348
|
args.push(twice(files) ? ["files=[", ...files.map((p) => ` (${jsString(p.name)}, ${file(p)}),`), "],"] : ["files={", ...files.map((p) => ` ${jsString(p.name)}: ${file(p)},`), "},"]);
|
|
4332
4349
|
}
|
|
@@ -5436,9 +5453,9 @@ function withoutCredentials(value, hid, name = "", depth = 0) {
|
|
|
5436
5453
|
if (isObj2(value)) return Object.fromEntries(Object.entries(value).map(([key, v]) => [key, withoutCredentials(v, hid, key, depth + 1)]));
|
|
5437
5454
|
return value;
|
|
5438
5455
|
}
|
|
5439
|
-
function readVariables(
|
|
5440
|
-
if (!Array.isArray(
|
|
5441
|
-
for (const v of
|
|
5456
|
+
function readVariables(list7, into) {
|
|
5457
|
+
if (!Array.isArray(list7)) return;
|
|
5458
|
+
for (const v of list7) {
|
|
5442
5459
|
if (!isObj2(v) || v.disabled === true || v.enabled === false) continue;
|
|
5443
5460
|
const key = typeof v.key === "string" ? v.key.trim() : typeof v.id === "string" ? v.id.trim() : "";
|
|
5444
5461
|
const value = typeof v.value === "string" ? v.value : typeof v.value === "number" || typeof v.value === "boolean" ? String(v.value) : isObj2(v.value) || Array.isArray(v.value) ? JSON.stringify(v.value) : "";
|
|
@@ -6198,9 +6215,9 @@ function v5Environment(env) {
|
|
|
6198
6215
|
const secret = new Set(Array.isArray(env.confidentialKeys) ? env.confidentialKeys.filter((k) => typeof k === "string") : []);
|
|
6199
6216
|
return { name: textOrUndefined(env.name) ?? "Environment", data: isObj3(env.data) ? env.data : {}, secret, private: meta.isPrivate === true, sortKey: sortKey(meta.sortKey) };
|
|
6200
6217
|
}
|
|
6201
|
-
function v5Nodes(
|
|
6202
|
-
if (!Array.isArray(
|
|
6203
|
-
return
|
|
6218
|
+
function v5Nodes(list7, depth) {
|
|
6219
|
+
if (!Array.isArray(list7) || depth > 50) return [];
|
|
6220
|
+
return list7.filter(isObj3).map((item) => {
|
|
6204
6221
|
const meta = isObj3(item.meta) ? item.meta : {};
|
|
6205
6222
|
const id = text(meta.id);
|
|
6206
6223
|
const base = { id, name: text(item.name).trim(), ...textOrUndefined(meta.description) ? { description: textOrUndefined(meta.description) } : {}, private: meta.isPrivate === true, sortKey: sortKey(meta.sortKey) };
|
|
@@ -6395,9 +6412,9 @@ function tagValue(tag2, args, names, context) {
|
|
|
6395
6412
|
}
|
|
6396
6413
|
}
|
|
6397
6414
|
var OWN_HEADER = (name, value) => /^user-agent$/i.test(name) && /^insomnia\//i.test(value.trim());
|
|
6398
|
-
function pairsOf(
|
|
6399
|
-
if (!Array.isArray(
|
|
6400
|
-
return
|
|
6415
|
+
function pairsOf(list7) {
|
|
6416
|
+
if (!Array.isArray(list7)) return [];
|
|
6417
|
+
return list7.filter(isObj3).flatMap((p) => {
|
|
6401
6418
|
const name = text(p.name);
|
|
6402
6419
|
if (!name.trim()) return [];
|
|
6403
6420
|
return [{ name, value: typeof p.value === "string" ? p.value : p.value === void 0 || p.value === null ? "" : String(p.value), disabled: p.disabled === true, ...textOrUndefined(p.description) ? { description: textOrUndefined(p.description) } : {} }];
|
|
@@ -6415,22 +6432,22 @@ var GRANTS2 = {
|
|
|
6415
6432
|
};
|
|
6416
6433
|
function postmanAuth(auth, tr) {
|
|
6417
6434
|
const s = (key) => tr(text(auth[key]));
|
|
6418
|
-
const
|
|
6435
|
+
const list7 = (entries) => Object.entries(entries).map(([key, value]) => ({ key, value, type: "string" }));
|
|
6419
6436
|
switch (auth.type) {
|
|
6420
6437
|
case "bearer": {
|
|
6421
6438
|
const prefix = text(auth.prefix).trim();
|
|
6422
6439
|
if (prefix && !/^bearer$/i.test(prefix)) return { header: { name: "Authorization", value: `${prefix} ${s("token")}`, disabled: false } };
|
|
6423
|
-
return { auth: { type: "bearer", bearer:
|
|
6440
|
+
return { auth: { type: "bearer", bearer: list7({ token: s("token") }) } };
|
|
6424
6441
|
}
|
|
6425
6442
|
case "singleToken":
|
|
6426
|
-
return { auth: { type: "bearer", bearer:
|
|
6443
|
+
return { auth: { type: "bearer", bearer: list7({ token: s("token") }) } };
|
|
6427
6444
|
case "basic":
|
|
6428
|
-
return { auth: { type: "basic", basic:
|
|
6445
|
+
return { auth: { type: "basic", basic: list7({ username: s("username"), password: s("password") }) } };
|
|
6429
6446
|
case "apikey":
|
|
6430
|
-
return { auth: { type: "apikey", apikey:
|
|
6447
|
+
return { auth: { type: "apikey", apikey: list7({ key: s("key"), value: s("value"), in: auth.addTo === "queryParams" ? "query" : auth.addTo === "cookie" ? "cookie" : "header" }) } };
|
|
6431
6448
|
case "oauth2": {
|
|
6432
6449
|
const grant = GRANTS2[text(auth.grantType)] ?? "authorization_code";
|
|
6433
|
-
return { auth: { type: "oauth2", oauth2:
|
|
6450
|
+
return { auth: { type: "oauth2", oauth2: list7({ grant_type: auth.usePkce === true && grant === "authorization_code" ? "authorization_code_with_pkce" : grant, accessTokenUrl: s("accessTokenUrl"), authUrl: s("authorizationUrl"), scope: s("scope") }) } };
|
|
6434
6451
|
}
|
|
6435
6452
|
case "iam":
|
|
6436
6453
|
return { auth: { type: "awsv4" } };
|
|
@@ -8698,7 +8715,7 @@ function inPreview(doc, op, item) {
|
|
|
8698
8715
|
if (typeof op.summary === "string" && /[[(](beta|preview|alpha|experimental)[\])]/i.test(op.summary)) return true;
|
|
8699
8716
|
let tags = previewTagsOf.get(doc);
|
|
8700
8717
|
if (!tags) {
|
|
8701
|
-
const named = (
|
|
8718
|
+
const named = (list7) => Array.isArray(list7) ? list7 : [];
|
|
8702
8719
|
tags = new Set(named(doc.tags).flatMap((tag2) => isObject2(tag2) && typeof tag2.name === "string" && PRE_RELEASE.test(tag2.name) ? [tag2.name] : []));
|
|
8703
8720
|
for (const group of named(doc["x-tagGroups"])) {
|
|
8704
8721
|
if (isObject2(group) && typeof group.name === "string" && PRE_RELEASE.test(group.name)) for (const tag2 of named(group.tags)) tags.add(String(tag2));
|
|
@@ -9162,8 +9179,8 @@ function hooksOf(ops, webhooks) {
|
|
|
9162
9179
|
const writes = /* @__PURE__ */ new Map();
|
|
9163
9180
|
for (const op of ops) {
|
|
9164
9181
|
if (isRead(op)) continue;
|
|
9165
|
-
const
|
|
9166
|
-
if (
|
|
9182
|
+
const list7 = writes.get(op.resource);
|
|
9183
|
+
if (list7) list7.push(op);
|
|
9167
9184
|
else writes.set(op.resource, [op]);
|
|
9168
9185
|
}
|
|
9169
9186
|
return { named: webhooks.filter((w) => !w.sourceOperationId).map((hook) => ({ hook, name: words(hook.name).map(singular) })), writes };
|
|
@@ -11315,14 +11332,14 @@ function mergeReviews(reviews) {
|
|
|
11315
11332
|
}
|
|
11316
11333
|
return found.review();
|
|
11317
11334
|
}
|
|
11335
|
+
function confirmLine(holds, videos = 2) {
|
|
11336
|
+
return `${videos === 1 ? "The video shows" : "The videos show"} what the ${holds} holds. Confirm that everything is correct and it holds no secrets or personal data`;
|
|
11337
|
+
}
|
|
11318
11338
|
function reviewLines(review, max = 8) {
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
for (const f of review.check.slice(0, max)) lines.push(` ${f.value} (${KIND_WORDS[f.kind]}), in ${f.where}`);
|
|
11324
|
-
if (review.check.length > max) lines.push(` \u2026and ${review.check.length - max} more.`);
|
|
11325
|
-
} else lines.push("Nothing else in it looks personal or internal, but a name or a password can look like any word: look through it.");
|
|
11339
|
+
if (!review.check.length) return [];
|
|
11340
|
+
const lines = ["May be personal or internal:"];
|
|
11341
|
+
for (const f of review.check.slice(0, max)) lines.push(` ${f.value} (${KIND_WORDS[f.kind]}), in ${f.where}`);
|
|
11342
|
+
if (review.check.length > max) lines.push(` \u2026and ${review.check.length - max} more.`);
|
|
11326
11343
|
return lines;
|
|
11327
11344
|
}
|
|
11328
11345
|
function callName(summaryLine, caption) {
|
|
@@ -11330,10 +11347,6 @@ function callName(summaryLine, caption) {
|
|
|
11330
11347
|
return name || caption.slice(0, 60);
|
|
11331
11348
|
}
|
|
11332
11349
|
var isObj7 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
11333
|
-
function list6(names, max) {
|
|
11334
|
-
if (names.length <= max) return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names.join("");
|
|
11335
|
-
return `${names.slice(0, max).join(", ")} and ${names.length - max} more`;
|
|
11336
|
-
}
|
|
11337
11350
|
var Findings = class {
|
|
11338
11351
|
hiddenNames = /* @__PURE__ */ new Set();
|
|
11339
11352
|
checks = /* @__PURE__ */ new Map();
|
|
@@ -11431,7 +11444,7 @@ function decodeURIComponentSafe(text3) {
|
|
|
11431
11444
|
}
|
|
11432
11445
|
|
|
11433
11446
|
// package.json
|
|
11434
|
-
var version = "1.0.
|
|
11447
|
+
var version = "1.0.11";
|
|
11435
11448
|
|
|
11436
11449
|
// src/files.ts
|
|
11437
11450
|
var import_node_fs = require("node:fs");
|
|
@@ -14926,8 +14939,8 @@ function arazzoTitle(doc) {
|
|
|
14926
14939
|
}
|
|
14927
14940
|
function arazzoWorkflows(doc, model, source) {
|
|
14928
14941
|
const notes = /* @__PURE__ */ new Set();
|
|
14929
|
-
const
|
|
14930
|
-
const byId = new Map(
|
|
14942
|
+
const list7 = (Array.isArray(doc.workflows) ? doc.workflows : []).filter((w) => isObject2(w) && typeof w.workflowId === "string");
|
|
14943
|
+
const byId = new Map(list7.map((w) => [w.workflowId, w]));
|
|
14931
14944
|
const byOperationId = new Map(model.operations.map((op) => [op.id, op]));
|
|
14932
14945
|
const prefix = `$sourceDescriptions.${source}.`;
|
|
14933
14946
|
const operationFor = (step) => {
|
|
@@ -15045,7 +15058,7 @@ function arazzoWorkflows(doc, model, source) {
|
|
|
15045
15058
|
return isObject2(resolved) ? resolved : {};
|
|
15046
15059
|
};
|
|
15047
15060
|
const workflows = [];
|
|
15048
|
-
for (const workflow of
|
|
15061
|
+
for (const workflow of list7) {
|
|
15049
15062
|
const steps = expand(workflow, { inputs: inputsOf(workflow) }, 0);
|
|
15050
15063
|
if (!steps.length) {
|
|
15051
15064
|
notes.add(`The workflow ${workflow.workflowId} has no steps on this API description, so it isn't offered.`);
|
|
@@ -15646,7 +15659,7 @@ var import_promises2 = require("node:fs/promises");
|
|
|
15646
15659
|
var import_node_path3 = require("node:path");
|
|
15647
15660
|
|
|
15648
15661
|
// ../../lib/embed/playerScript.generated.ts
|
|
15649
|
-
var PLAYER_SCRIPT = '(function () {\n"use strict";\nvar defs = {\n"lib/embed/player": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nconst frame_1 = require("../render/frame");\nconst timing_1 = require("../storyboard/timing");\nconst ICONS = {\n play: \'<path d="M8 5.2v13.6a.6.6 0 0 0 .9.5l10.6-6.8a.6.6 0 0 0 0-1L8.9 4.7a.6.6 0 0 0-.9.5z" fill="currentColor"/>\',\n pause: \'<path d="M7 5h3.2v14H7zM13.8 5H17v14h-3.2z" fill="currentColor"/>\',\n replay: \'<path d="M19.5 11.5A7.5 7.5 0 1 0 17.3 17M19.5 5v6.5H13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n prev: \'<path d="M6.5 5.5v13M17.5 6.2v11.6a.5.5 0 0 1-.8.4l-8.3-5.8a.5.5 0 0 1 0-.8l8.3-5.8a.5.5 0 0 1 .8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n next: \'<path d="M17.5 5.5v13M6.5 6.2v11.6a.5.5 0 0 0 .8.4l8.3-5.8a.5.5 0 0 0 0-.8L7.3 5.8a.5.5 0 0 0-.8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n copy: \'<path d="M9 9.5h9.5v10H9zM6 15.5H5.5v-10h9.5V6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n expand: \'<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n};\nconst icon = (name) => `<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">${ICONS[name]}</svg>`;\nfunction fmt(ms) {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;\n}\nfunction button(label, name, className = "") {\n const b = document.createElement("button");\n b.type = "button";\n b.className = className;\n b.setAttribute("aria-label", label);\n b.title = label;\n b.innerHTML = icon(name);\n return b;\n}\nconst SITE = "https://integrationtour.com/";\nfunction credit(aspect) {\n const a = document.createElement("a");\n a.className = "credit";\n a.href = SITE;\n a.target = "_blank";\n a.rel = "noopener";\n a.setAttribute("aria-label", `${frame_1.WATERMARK} (opens in a new tab)`);\n a.addEventListener("click", (e) => e.stopPropagation());\n place(a, aspect, (0, frame_1.watermarkBox)(aspect));\n return a;\n}\nfunction place(link, aspect, box) {\n const size = (0, frame_1.sizeFor)(aspect);\n const pad = 8;\n const share = (value, of) => `${((value / of) * 100).toFixed(3)}%`;\n link.style.left = share(box.x - pad, size.width);\n link.style.top = share(box.y - pad, size.height);\n link.style.width = share(box.w + 2 * pad, size.width);\n link.style.height = share(box.h + 2 * pad, size.height);\n}\nfunction fit(link, frame, aspect) {\n const text = frame.querySelector("svg > text:last-child");\n if (!(text instanceof SVGTextElement) || text.textContent !== frame_1.WATERMARK)\n return false;\n let width = 0;\n try {\n width = text.getComputedTextLength();\n }\n catch {\n }\n if (!(width > 0))\n return false;\n const box = (0, frame_1.watermarkBox)(aspect);\n place(link, aspect, { ...box, x: box.x + box.w - width, w: width });\n return true;\n}\nfunction start(root, sb) {\n const total = (0, timing_1.totalDuration)(sb);\n const starts = (0, frame_1.sceneStarts)(sb);\n let time = 0;\n let playing = false;\n let last = null;\n const stage = document.createElement("div");\n stage.className = `stage ${sb.settings.aspect === "9:16" ? "portrait" : sb.settings.aspect === "1:1" ? "square" : "wide"}`;\n const frame = document.createElement("div");\n frame.setAttribute("role", "img");\n stage.append(frame);\n const link = sb.settings.watermark ? credit(sb.settings.aspect) : undefined;\n if (link)\n stage.append(link);\n let fitted = false;\n const controls = document.createElement("div");\n controls.className = "controls";\n const prev = button("Previous scene", "prev");\n const play = button("Play", "play", "play");\n const next = button("Next scene", "next");\n const seek = document.createElement("input");\n seek.type = "range";\n seek.min = "0";\n seek.max = String(total);\n seek.step = "50";\n seek.setAttribute("aria-label", "Seek");\n const clock = document.createElement("span");\n clock.className = "time";\n const copy = button("Copy this payload as JSON", "copy");\n const full = button("Full screen", "expand");\n controls.append(prev, play, next, seek, clock, copy, full);\n const status = document.createElement("p");\n status.className = "status";\n status.setAttribute("role", "status");\n root.append(stage, controls, status);\n root.tabIndex = 0;\n const draw = () => {\n const at = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n frame.innerHTML = (0, frame_1.renderFrame)(sb, time);\n frame.setAttribute("aria-label", at.scene.caption);\n if (link && !fitted)\n fitted = fit(link, frame, sb.settings.aspect);\n seek.value = String(Math.round(time));\n clock.textContent = `${fmt(time)} / ${fmt(total)} \xB7 ${at.index + 1}/${at.count}`;\n const ended = !playing && time >= total;\n play.innerHTML = icon(playing ? "pause" : ended ? "replay" : "play");\n play.setAttribute("aria-label", playing ? "Pause" : ended ? "Replay" : "Play");\n prev.disabled = at.index === 0;\n next.disabled = at.index === at.count - 1;\n };\n const tick = (now) => {\n if (!playing)\n return;\n time = Math.min(total, time + (last === null ? 0 : now - last));\n last = now;\n if (time >= total)\n playing = false;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const toggle = () => {\n if (!playing && time >= total)\n time = 0;\n playing = !playing;\n last = null;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const step = (delta) => {\n const index = Math.max(0, Math.min(starts.length - 1, (0, frame_1.sceneAt)(sb, Math.min(time, total)).index + delta));\n playing = false;\n time = starts[index] + Math.min(900, total - starts[index]);\n draw();\n };\n const payload = () => {\n const { scene, progress } = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n if (scene.kind === "call" || scene.kind === "auth")\n return progress < 0.52 ? scene.request : scene.response;\n return scene.kind === "webhook" ? scene.payload : undefined;\n };\n const say = (text) => {\n status.textContent = text;\n window.setTimeout(() => status.textContent === text && (status.textContent = ""), 2500);\n };\n copy.addEventListener("click", async () => {\n const value = payload();\n if (value === undefined)\n return say("This scene has no payload to copy.");\n const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);\n try {\n await navigator.clipboard.writeText(text);\n }\n catch {\n const area = document.createElement("textarea");\n area.value = text;\n document.body.append(area);\n area.select();\n document.execCommand("copy");\n area.remove();\n }\n say("Copied the payload as JSON.");\n });\n full.addEventListener("click", () => {\n if (document.fullscreenElement)\n void document.exitFullscreen();\n else if (root.requestFullscreen)\n void root.requestFullscreen().catch(() => root.classList.toggle("filled"));\n else\n root.classList.toggle("filled");\n });\n play.addEventListener("click", toggle);\n prev.addEventListener("click", () => step(-1));\n next.addEventListener("click", () => step(1));\n stage.addEventListener("click", toggle);\n seek.addEventListener("input", () => {\n playing = false;\n time = Number(seek.value);\n draw();\n });\n root.addEventListener("keydown", (e) => {\n if (e.target.tagName === "INPUT" && e.key !== " ")\n return;\n if (e.key === " ") {\n e.preventDefault();\n toggle();\n }\n else if (e.key === "ArrowRight")\n step(1);\n else if (e.key === "ArrowLeft")\n step(-1);\n else if (e.key === "f")\n full.click();\n else if (e.key === "Escape")\n root.classList.remove("filled");\n });\n draw();\n}\nconst root = document.getElementById("flow-player");\nconst data = document.getElementById("flow-storyboard");\nif (root && (data === null || data === void 0 ? void 0 : data.textContent))\n start(root, JSON.parse(data.textContent));\n\n}, {"../render/frame":"lib/render/frame","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/render/frame": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.WATERMARK = void 0;\nexports.paletteFor = paletteFor;\nexports.sizeFor = sizeFor;\nexports.outputSize = outputSize;\nexports.sceneAt = sceneAt;\nexports.sceneStarts = sceneStarts;\nexports.renderFrame = renderFrame;\nexports.watermarkBox = watermarkBox;\nexports.jsonLines = jsonLines;\nexports.wrap = wrap;\nexports.esc = esc;\nconst timing_1 = require("../storyboard/timing");\nconst code_1 = require("./code");\nconst text_1 = require("../text");\nexports.WATERMARK = "Made with integrationtour.com";\nconst DARK = {\n bg: "#0b1120",\n panel: "#131c31",\n panelEdge: "#26324d",\n text: "#e6ebf5",\n muted: "#8e9ab3",\n client: "#5cc8ff",\n api: "#a58bff",\n accent: "#5cc8ff",\n ok: "#3ddc97",\n bad: "#ff6b6b",\n hook: "#ffb547",\n key: "#ffd166",\n jsonKey: "#7cc7ff",\n jsonString: "#b8e986",\n jsonOther: "#f7b17a",\n};\nconst LIGHT = {\n bg: "#f5f7fb",\n panel: "#ffffff",\n panelEdge: "#d5dce8",\n text: "#0f172a",\n muted: "#5b6a82",\n client: "#0369a1",\n api: "#6d28d9",\n accent: "#0369a1",\n ok: "#047857",\n bad: "#c81e1e",\n hook: "#b45309",\n key: "#a16207",\n jsonKey: "#0f5f8f",\n jsonString: "#166534",\n jsonOther: "#b4410c",\n};\nconst HEX_COLOR = /^#[0-9a-f]{6}$/i;\nfunction paletteFor(settings) {\n const base = settings.theme === "light" ? LIGHT : DARK;\n return settings.brandColor && HEX_COLOR.test(settings.brandColor) ? { ...base, api: settings.brandColor, accent: settings.brandColor } : base;\n}\nlet C = DARK;\nconst SANS = "Inter, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif";\nconst MONO = "\'JetBrains Mono\', \'SFMono-Regular\', Menlo, Consolas, monospace";\nfunction sizeFor(aspect) {\n if (aspect === "9:16")\n return { width: 720, height: 1280 };\n return aspect === "1:1" ? { width: 720, height: 720 } : { width: 1280, height: 720 };\n}\nfunction outputSize(settings) {\n var _a;\n const { width, height } = sizeFor(settings.aspect);\n const scale = ((_a = settings.resolution) !== null && _a !== void 0 ? _a : 720) / 720;\n return { width: Math.round(width * scale), height: Math.round(height * scale) };\n}\nfunction layoutFor(aspect) {\n if (aspect === "9:16") {\n const client = { x: 48, y: 290, w: 624, h: 110 };\n const api = { x: 48, y: 1040, w: 624, h: 110 };\n return {\n width: 720,\n height: 1280,\n stacked: true,\n caption: { x: 48, y: 110, width: 624, size: 32, minSize: 26, maxLines: 4 },\n client,\n api,\n webhook: client,\n card: { x: 136, y: 450, w: 536, h: 550 },\n lane: { from: [92, 400], to: [92, 1040] },\n hookLane: { from: [92, 1040], to: [92, 400] },\n monoSize: 16,\n title: { size: 52, logo: 120, subtitle: 26 },\n stepSize: 18,\n summary: { left: 64, top: 360, bottom: 100, size: 26, gap: 64 },\n };\n }\n if (aspect === "1:1") {\n const client = { x: 40, y: 200, w: 240, h: 92 };\n return {\n width: 720,\n height: 720,\n stacked: true,\n caption: { x: 40, y: 72, width: 640, size: 30, minSize: 24, maxLines: 3 },\n client,\n api: { x: 440, y: 200, w: 240, h: 92 },\n webhook: client,\n card: { x: 40, y: 324, w: 640, h: 326 },\n lane: { from: [280, 246], to: [440, 246] },\n hookLane: { from: [440, 246], to: [280, 246] },\n monoSize: 15,\n title: { size: 44, logo: 80, subtitle: 22 },\n stepSize: 16,\n summary: { left: 56, top: 200, bottom: 70, size: 22, gap: 48 },\n };\n }\n const client = { x: 64, y: 250, w: 250, h: 130 };\n const api = { x: 966, y: 250, w: 250, h: 130 };\n const webhook = { x: 64, y: 480, w: 250, h: 110 };\n return {\n width: 1280,\n height: 720,\n stacked: false,\n caption: { x: 64, y: 92, width: 1152, size: 30, minSize: 24, maxLines: 2 },\n client,\n api,\n webhook,\n card: { x: 354, y: 352, w: 572, h: 300 },\n lane: { from: [314, 315], to: [966, 315] },\n hookLane: { from: [966, 380], to: [314, 535] },\n monoSize: 15,\n title: { size: 56, logo: 92, subtitle: 24 },\n stepSize: 15,\n summary: { left: 200, top: 220, bottom: 70, size: 24, gap: 56 },\n };\n}\nfunction sceneAt(sb, t) {\n const scenes = (0, timing_1.activeScenes)(sb);\n let start = 0;\n for (let i = 0; i < scenes.length; i++) {\n const duration = (0, timing_1.sceneDuration)(sb, scenes[i]);\n const end = start + duration;\n if (t < end || i === scenes.length - 1) {\n return { scene: scenes[i], index: i, count: scenes.length, start, duration, progress: clamp01((t - start) / duration) };\n }\n start = end;\n }\n throw new Error("Storyboard has no scenes.");\n}\nfunction sceneStarts(sb) {\n const starts = [];\n let t = 0;\n for (const s of (0, timing_1.activeScenes)(sb)) {\n starts.push(t);\n t += (0, timing_1.sceneDuration)(sb, s);\n }\n return starts;\n}\nfunction renderFrame(sb, t, size) {\n var _a, _b;\n C = paletteFor(sb.settings);\n const L = layoutFor(sb.settings.aspect);\n const total = (0, timing_1.totalDuration)(sb);\n const at = sceneAt(sb, Math.max(0, Math.min(t, total)));\n const fade = at.index === 0 ? 1 : clamp01((at.progress * at.duration) / 300);\n let body;\n switch (at.scene.kind) {\n case "title":\n body = titleScene(L, at.scene, at.progress, sb.settings.logo);\n break;\n case "summary":\n body = summaryScene(L, at.scene, at.progress, (0, timing_1.summaryItems)(sb));\n break;\n case "auth":\n body = authScene(L, sb, at.scene, at.progress);\n break;\n case "webhook":\n body = webhookScene(L, sb, at.scene, at.progress);\n break;\n default:\n body = callScene(L, sb, at.scene, at.progress);\n }\n const parts = [\n `<svg xmlns="http://www.w3.org/2000/svg" width="${(_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : L.width}" height="${(_b = size === null || size === void 0 ? void 0 : size.height) !== null && _b !== void 0 ? _b : L.height}" viewBox="0 0 ${L.width} ${L.height}" font-family="${esc(SANS)}">`,\n `<rect width="${L.width}" height="${L.height}" fill="${C.bg}"/>`,\n grid(L),\n `<g opacity="${fade.toFixed(3)}">${body}</g>`,\n progressBar(L, total ? Math.min(t, total) / total : 0),\n sb.settings.watermark ? watermark(L) : "",\n `</svg>`,\n ];\n return parts.join("");\n}\nfunction titleScene(L, scene, p, logo) {\n let size = L.title.size;\n while (size > L.title.size * 0.72 && wrap(scene.title, L.width - 160, size, Infinity).length > 3)\n size -= 2;\n const lines = wrap(scene.title, L.width - 160, size, 3);\n const mark = logo && /^data:image\\/(png|jpeg|gif|webp);base64,[a-z0-9+/=]+$/i.test(logo) ? { h: L.title.logo, gap: 34 } : undefined;\n const top = L.height / 2 - (lines.length * size * 1.15) / 2 + (mark ? (mark.h + mark.gap) / 2 : 0);\n const out = lines.map((line, i) => `<text x="${L.width / 2}" y="${top + i * size * 1.15}" text-anchor="middle" font-size="${size}" font-weight="700" fill="${C.text}">${esc(line)}</text>`);\n const subY = top + lines.length * size * 1.15 + 24;\n out.push(`<text x="${L.width / 2}" y="${subY}" text-anchor="middle" font-size="${L.title.subtitle}" fill="${C.muted}">${esc(fit(scene.subtitle, L.width - 160, L.title.subtitle))}</text>`);\n if (mark) {\n const bottom = top - size * 0.78 - mark.gap;\n out.push(`<image href="${esc(logo)}" x="${L.width / 2 - 200}" y="${(bottom - mark.h).toFixed(1)}" width="400" height="${mark.h}" preserveAspectRatio="xMidYMid meet"/>`);\n }\n const dotsY = subY + 70;\n [C.client, C.api, C.hook].forEach((color, i) => {\n const glow = pulse(p, 0.25 + i * 0.15, 0.55 + i * 0.15);\n const cx = L.width / 2 + (i - 1) * 40;\n if (glow > 0)\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="${(8 + 10 * glow).toFixed(1)}" fill="${color}" opacity="${(0.25 * glow).toFixed(3)}"/>`);\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="8" fill="${color}"/>`);\n });\n return out.join("");\n}\nconst MIN_SUMMARY_GAP = 34;\nconst MIN_SUMMARY_SIZE = 18;\nfunction summaryScene(L, scene, p, items) {\n const out = [captionText(L, scene.caption)];\n const { left, top, bottom, size, gap } = L.summary;\n const textX = left + 44;\n const room = L.height - bottom - top;\n const plan = summaryPlan(items, L.width - textX - 56, room, size, gap);\n const r = Math.min(14, plan.gap * 0.32);\n const stagger = Math.min(0.08, 0.6 / plan.blocks.length);\n let y = top;\n plan.blocks.forEach((lines, i) => {\n const appear = clamp01((p - 0.08 - i * stagger) / 0.12);\n const more = plan.more && i === plan.blocks.length - 1;\n out.push(`<g opacity="${appear.toFixed(3)}">`, more\n ? ""\n : `<circle cx="${left + 14}" cy="${(y - 8).toFixed(1)}" r="${r.toFixed(1)}" fill="${C.ok}" opacity="0.18"/><path d="M${left + 7} ${(y - 8).toFixed(1)} l5 5 l9 -10" stroke="${C.ok}" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`, ...lines.map((line, j) => `<text x="${textX}" y="${(y + j * plan.lineHeight).toFixed(1)}" font-size="${plan.size}" fill="${more ? C.muted : C.text}">${esc(line)}</text>`), `</g>`);\n y += plan.gap + (lines.length - 1) * plan.lineHeight;\n });\n return out.join("");\n}\nfunction summaryPlan(items, width, room, baseSize, baseGap) {\n const measure = (size) => {\n const lineHeight = Math.round(size * 1.2);\n const blocks = items.map((item) => wrap(item, width, size, 2));\n const extra = blocks.reduce((n, lines) => n + lines.length - 1, 0) * lineHeight;\n return { blocks, lineHeight, extra, minGap: Math.max(MIN_SUMMARY_GAP, size * 1.45) };\n };\n for (let size = baseSize; size >= MIN_SUMMARY_SIZE; size--) {\n const { blocks, lineHeight, extra, minGap } = measure(size);\n const gaps = Math.max(1, blocks.length - 1);\n if (gaps * minGap + extra <= room)\n return { blocks, size, lineHeight, gap: Math.min(baseGap, (room - extra) / gaps), more: false };\n }\n const { blocks, lineHeight, minGap } = measure(MIN_SUMMARY_SIZE);\n const kept = [];\n let used = 0;\n for (const lines of blocks) {\n const need = (kept.length ? minGap : 0) + (lines.length - 1) * lineHeight;\n if (used + need + minGap > room)\n break;\n kept.push(lines);\n used += need;\n }\n kept.push([`+${items.length - kept.length} more`]);\n return { blocks: kept, size: MIN_SUMMARY_SIZE, lineHeight, gap: minGap, more: true };\n}\nfunction callScene(L, sb, scene, p) {\n var _a;\n const failed = scene.outcome === "failure";\n const responseColor = failed ? C.bad : C.ok;\n const requestPhase = p < 0.52;\n const mcp = sb.api.protocol === "mcp";\n const call = `${scene.method} ${scene.path}`.trim();\n const outcome = outcomeText(scene.status);\n const out = [\n stepLabel(L, `Step ${scene.step} of ${scene.stepCount}${failed ? " \xB7 failure path" : ""}`, failed ? C.bad : C.muted),\n captionText(L, scene.caption),\n ...nodes(L, sb, pulse(p, 0.4, 0.52)),\n lane(L),\n ];\n if (!L.stacked)\n out.push(laneLabel(L, call));\n if (!L.stacked && sb.scenes.some((s) => s.kind === "webhook"))\n out.push(node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, 0, 0.35));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), responseColor));\n const cardIn = clamp01((p - 0.08) / 0.08);\n if (requestPhase) {\n const code = sb.settings.code ? (0, code_1.callCode)(sb, scene, sb.settings.code) : undefined;\n out.push(card(L, call, C.client, scene.request, scene.request === undefined && !code ? (mcp ? "No params" : "No request body") : undefined, cardIn, { code }));\n }\n else {\n out.push(card(L, mcp && failed ? `result \xB7 ${outcome}` : outcome, responseColor, scene.response, scene.response === undefined ? "No response body" : undefined, 1, { fold: mcp ? SCHEMA_KEYS : undefined }));\n }\n if (p >= 0.8) {\n const appear = clamp01((p - 0.8) / 0.06);\n out.push(badge(L.client, outcome, responseColor, appear));\n if (failed && scene.recovery)\n out.push(recoveryNote(L, scene.recovery, appear));\n }\n if (requestPhase ? scene.requestGenerated && p >= 0.08 : scene.responseGenerated) {\n const written = mcp && (requestPhase ? scene.method === "prompts/get" : isRecord(scene.response) && !("structuredContent" in scene.response));\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">${written ? "Example text written for the video" : "Example generated from the schema"}</text>`);\n }\n return out.join("");\n}\nfunction nodes(L, sb, glow, clientOpacity = 1) {\n const mcp = sb.api.protocol === "mcp";\n return [node(L.client, mcp ? "MCP CLIENT" : "CLIENT", sb.nodes.client, C.client, 0, clientOpacity), node(L.api, mcp ? "MCP SERVER" : "API", sb.nodes.api, C.api, glow)];\n}\nfunction outcomeText(status) {\n if (status === "result")\n return "result";\n if (status === "isError")\n return "isError: true";\n const why = reason(status);\n return why ? `${status} ${why}` : status;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction authScene(L, sb, scene, p) {\n var _a;\n const out = [stepLabel(L, `Authentication \xB7 ${scene.scheme}`, C.key), captionText(L, scene.caption), ...nodes(L, sb, pulse(p, 0.4, 0.52)), lane(L)];\n if (scene.requestLine) {\n if (!L.stacked)\n out.push(laneLabel(L, scene.requestLine));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), C.key));\n const code = sb.settings.code && sb.api.protocol !== "mcp" && scene.requestType ? (0, code_1.authCode)(sb, scene, sb.settings.code) : undefined;\n const form = !code && /form-urlencoded/i.test((_a = scene.requestType) !== null && _a !== void 0 ? _a : "") && isRecord(scene.request);\n if (p < 0.52)\n out.push(card(L, scene.requestLine, C.client, form ? formText(scene.request) : scene.request, undefined, clamp01((p - 0.08) / 0.08), { code, form }));\n else\n out.push(card(L, "200 OK \xB7 access token", C.key, scene.response, undefined, 1));\n if (p >= 0.8)\n out.push(badge(L.client, "Token stored", C.key, clamp01((p - 0.8) / 0.06)));\n }\n else {\n if (!L.stacked)\n out.push(laneLabel(L, scene.headerLine.split("\\n")[0]));\n if (p >= 0.2 && p < 0.6)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.2) / 0.4), C.key));\n const every = sb.scenes.every((s) => s.kind !== "call" || s.credentials === undefined);\n out.push(card(L, every ? "Sent with every request" : "Sent with each call that needs it", C.key, undefined, scene.headerLine, clamp01((p - 0.08) / 0.08)));\n if (p >= 0.62)\n out.push(badge(L.api, "Authenticated", C.ok, clamp01((p - 0.62) / 0.06)));\n }\n return out.join("");\n}\nfunction webhookScene(L, sb, scene, p) {\n var _a, _b, _c;\n const receiver = L.stacked ? node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, pulse(p, 0.55, 0.7)) : "";\n const out = [\n stepLabel(L, `Webhook \xB7 ${scene.event}`, C.hook),\n captionText(L, scene.caption),\n L.stacked ? receiver : node(L.client, "CLIENT", sb.nodes.client, C.client, 0, 0.45),\n node(L.api, "API", sb.nodes.api, C.api, pulse(p, 0.05, 0.18)),\n ];\n if (!L.stacked)\n out.push(node(L.webhook, "WEBHOOKS", (_b = sb.nodes.webhook) !== null && _b !== void 0 ? _b : "Your server", C.hook, pulse(p, 0.55, 0.7)));\n out.push(`<line x1="${L.hookLane.from[0]}" y1="${L.hookLane.from[1]}" x2="${L.hookLane.to[0]}" y2="${L.hookLane.to[1]}" stroke="${C.hook}" stroke-opacity="0.35" stroke-width="2" stroke-dasharray="6 8"/>`);\n if (p >= 0.18 && p < 0.55)\n out.push(packet(L.hookLane.from, L.hookLane.to, ease((p - 0.18) / 0.37), C.hook));\n out.push(card(L, `${scene.method} ${scene.event}`, C.hook, scene.payload, scene.payload === undefined ? "Event payload" : undefined, clamp01((p - 0.1) / 0.08)));\n if (scene.payloadGenerated && scene.payload !== undefined) {\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">Example generated from the schema</text>`);\n }\n if (p >= 0.72) {\n const ack = (_c = scene.ack) !== null && _c !== void 0 ? _c : "2XX";\n const said = `${outcomeText(ack)} \xB7 acknowledged`;\n out.push(badge(L.webhook, said.length <= Math.floor((L.webhook.w - 20) / (15 * 0.6)) ? said : `${ack} \xB7 acknowledged`, C.ok, clamp01((p - 0.72) / 0.06)));\n }\n return out.join("");\n}\nfunction grid(L) {\n const dots = [];\n for (let x = 32; x < L.width; x += 48) {\n for (let y = 32; y < L.height; y += 48)\n dots.push(`M${x} ${y}h1`);\n }\n return `<path d="${dots.join("")}" stroke="${C.panelEdge}" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`;\n}\nfunction stepLabel(L, text, color) {\n return `<text x="${L.caption.x}" y="${L.caption.y - L.caption.size - 10}" font-size="${L.stepSize}" font-weight="600" letter-spacing="1.5" fill="${color}">${esc(text.toUpperCase())}</text>`;\n}\nfunction captionText(L, caption) {\n const { x, y } = L.caption;\n const { size, lines } = fitCaption(L, caption);\n return lines.map((line, i) => `<text x="${x}" y="${y + i * size * 1.25}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(line)}</text>`).join("");\n}\nfunction fitCaption(L, caption) {\n const { width, size, minSize, maxLines } = L.caption;\n const whole = caption.split(/\\s+/).filter(Boolean).join(" ");\n for (const limit of [maxLines, maxLines + 1]) {\n for (let s = size; s >= minSize; s--) {\n const lines = wrap(caption, width, s, Infinity);\n if (lines.length <= limit && lines.join(" ") === whole)\n return { size: s, lines };\n }\n }\n return { size: minSize, lines: wrap(caption, width, minSize, maxLines + 1) };\n}\nfunction node(box, kicker, name, color, glow, opacity = 1) {\n const size = 22;\n return [\n `<g opacity="${opacity}">`,\n glow > 0 ? `<rect x="${box.x - 6}" y="${box.y - 6}" width="${box.w + 12}" height="${box.h + 12}" rx="20" fill="none" stroke="${color}" stroke-width="3" opacity="${(glow * 0.6).toFixed(3)}"/>` : "",\n `<rect x="${box.x}" y="${box.y}" width="${box.w}" height="${box.h}" rx="16" fill="${C.panel}" stroke="${color}" stroke-width="2"/>`,\n `<rect x="${box.x}" y="${box.y}" width="6" height="${box.h}" rx="3" fill="${color}"/>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 - 8}" font-size="13" font-weight="700" letter-spacing="2" fill="${color}">${esc(kicker)}</text>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 + 22}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(fit(name, box.w - 48, size))}</text>`,\n `</g>`,\n ].join("");\n}\nfunction lane(L) {\n const [x1, y1] = L.lane.from;\n const [x2, y2] = L.lane.to;\n return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${C.panelEdge}" stroke-width="2" stroke-dasharray="6 8"/>`;\n}\nfunction laneLabel(L, text) {\n const [x1, y1] = L.lane.from;\n const [x2] = L.lane.to;\n return `<text x="${(x1 + x2) / 2}" y="${y1 - 16}" text-anchor="middle" font-family="${esc(MONO)}" font-size="16" fill="${C.muted}">${esc(fit(text, x2 - x1 - 40, 16, true))}</text>`;\n}\nfunction packet(from, to, t, color) {\n const x = from[0] + (to[0] - from[0]) * t;\n const y = from[1] + (to[1] - from[1]) * t;\n return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="18" fill="${color}" opacity="0.2"/><circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="9" fill="${color}"/>`;\n}\nconst SCHEMA_KEYS = new Set(["inputSchema", "outputSchema"]);\nfunction card(L, header, color, value, note, opacity, { code, fold, form } = {}) {\n const { x, y, w, h } = L.card;\n const size = code ? L.monoSize - 2 : L.monoSize;\n const lineHeight = Math.round(size * 1.4);\n const maxLines = Math.floor((h - 64) / lineHeight);\n const maxChars = Math.floor((w - 40) / (size * 0.6));\n const out = [\n `<g opacity="${opacity.toFixed(3)}">`,\n `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="14" fill="${C.panel}" stroke="${C.panelEdge}" stroke-width="1.5"/>`,\n `<rect x="${x}" y="${y}" width="${w}" height="44" rx="14" fill="${color}" opacity="0.14"/>`,\n `<text x="${x + 20}" y="${y + 28}" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(header, w - 40, size, true))}</text>`,\n ];\n if (note !== undefined) {\n note\n .split("\\n")\n .slice(0, maxLines)\n .forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" fill="${C.muted}">${esc(fit(line, w - 40, size, true))}</text>`));\n }\n else {\n const lines = code ? codeTspans(code, maxLines, maxChars) : form ? formTspans(String(value), maxLines, maxChars) : jsonLines(value, maxLines, maxChars, fold);\n lines.forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" xml:space="preserve">${line}</text>`));\n }\n out.push(`</g>`);\n return out.join("");\n}\nfunction badge(box, text, color, opacity) {\n const size = 15;\n const w = Math.min(box.w, textWidth(text, size, true) + 28);\n const x = box.x + box.w - w;\n const y = box.y - 40;\n return `<g opacity="${opacity.toFixed(3)}"><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="${color}" opacity="0.18"/><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="none" stroke="${color}" stroke-width="1.5"/><text x="${x + w / 2}" y="${y + 20}" text-anchor="middle" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(text, w - 20, size, true))}</text></g>`;\n}\nfunction recoveryNote(L, text, opacity) {\n const box = L.stacked ? { x: L.card.x, y: L.client.y + L.client.h + 6 } : { x: L.client.x, y: L.client.y + L.client.h + 22 };\n const width = L.stacked ? L.card.w : L.client.w;\n const lines = wrap(`\u21BB ${text}`, width, 17, L.stacked ? 1 : 3);\n return `<g opacity="${opacity.toFixed(3)}">${lines\n .map((line, i) => `<text x="${box.x}" y="${box.y + 18 + i * 22}" font-size="17" font-weight="600" fill="${C.hook}">${esc(line)}</text>`)\n .join("")}</g>`;\n}\nfunction progressBar(L, fraction) {\n return `<rect x="0" y="${L.height - 4}" width="${L.width}" height="4" fill="${C.panelEdge}"/><rect x="0" y="${L.height - 4}" width="${(L.width * clamp01(fraction)).toFixed(1)}" height="4" fill="${C.accent}"/>`;\n}\nconst MARK = { size: 15, right: 24, bottom: 20 };\nfunction watermark(L) {\n return `<text x="${L.width - MARK.right}" y="${L.height - MARK.bottom}" text-anchor="end" font-size="${MARK.size}" font-weight="600" fill="${C.muted}" opacity="0.75">${esc(exports.WATERMARK)}</text>`;\n}\nfunction watermarkBox(aspect) {\n const L = layoutFor(aspect);\n const w = exports.WATERMARK.length * MARK.size * 0.6;\n return { x: L.width - MARK.right - w, y: L.height - MARK.bottom - MARK.size, w, h: MARK.size * 1.3 };\n}\nconst FOLDED = "\\uE000";\nfunction jsonLines(value, maxLines, maxChars, fold) {\n var _a, _b;\n let text;\n try {\n const replacer = fold ? (key, v) => (fold.has(key) && isRecord(v) ? FOLDED : v) : undefined;\n text = typeof value === "string" ? value : ((_b = (_a = JSON.stringify(value, replacer, 2)) === null || _a === void 0 ? void 0 : _a.replace(/"\\uE000"/g, "{ \u2026 }")) !== null && _b !== void 0 ? _b : "");\n }\n catch {\n text = String(value);\n }\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n const xml = typeof value === "string" && /^\\s*</.test(value);\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n if (xml)\n return xmlTspans(line);\n const field = typeof value === "string" ? line.match(/^(event|data|id|retry):( ?)(.*)$/) : null;\n if (field)\n return `<tspan fill="${C.jsonKey}">${esc(field[1])}</tspan><tspan fill="${C.muted}">:${field[2]}</tspan>${colorValue(field[3])}`;\n const m = line.match(/^(\\s*)("(?:[^"\\\\]|\\\\.)*")(:\\s?)(.*)$/);\n if (!m)\n return colorValue(line);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan>${colorValue(m[4])}`;\n });\n}\nfunction formText(fields) {\n return Object.entries(fields)\n .map(([key, value], i) => `${i ? "&" : ""}${key}=${typeof value === "string" ? value : JSON.stringify(value)}`)\n .join("\\n");\n}\nfunction formTspans(text, maxLines, maxChars) {\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), "\u2026"];\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n const m = line.match(/^(&?)([^=]*)(=?)(.*)$/);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan><tspan fill="${C.jsonString}">${esc(m[4])}</tspan>`;\n });\n}\nconst XML_TOKEN = /(<\\/?[\\w.:-]+|\\/?>)|("[^"]*"?)|([\\w.:-]+=)/g;\nfunction xmlTspans(line) {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(XML_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, tag, str] = m;\n out.push(`<tspan fill="${tag ? C.jsonKey : str ? C.jsonString : C.muted}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n}\nfunction codeTspans(code, maxLines, maxChars) {\n let lines = code.flatMap((line) => softWrap(line, maxChars));\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n return lines.map((line) => {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(CODE_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, str, num, word] = m;\n const color = str ? (/^\\s*:/.test(line.slice(m.index + token.length)) ? C.jsonKey : C.jsonString) : num ? C.jsonOther : word ? C.key : m.index === 0 || /\\s/.test(line[m.index - 1]) ? C.client : C.text;\n out.push(`<tspan fill="${color}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n });\n}\nconst CODE_TOKEN = /("(?:[^"\\\\]|\\\\.)*"?|\'(?:[^\'\\\\]|\\\\.)*\'?)|(\\b\\d+(?:\\.\\d+)?\\b)|(\\b(?:curl|await|fetch|requests|new|JSON|FormData|URLSearchParams|open|True|False|None|true|false|null)\\b)|(--?[a-zA-Z][\\w-]*)/g;\nfunction softWrap(line, max) {\n const indent = line.match(/^\\s*/)[0].length + 4;\n const out = [];\n let rest = line;\n while (rest.length > max && out.length < 40) {\n const window = rest.slice(0, max);\n const at = Math.max(window.lastIndexOf("/"), window.lastIndexOf(" "), window.lastIndexOf(","));\n const piece = at > indent ? rest.slice(0, at + 1) : (0, text_1.cut)(rest, max);\n out.push(piece);\n rest = " ".repeat(indent) + rest.slice(piece.length).trimStart();\n }\n return [...out, (0, text_1.clip)(rest, max)];\n}\nfunction colorValue(text) {\n const trimmed = text.trim();\n const color = trimmed.startsWith(\'"\') ? C.jsonString : /^[\\d\\-tfn]/.test(trimmed) ? C.jsonOther : C.muted;\n return `<tspan fill="${color}">${esc(text)}</tspan>`;\n}\nfunction textWidth(text, size, mono = false) {\n return text.length * size * (mono ? 0.6 : 0.54);\n}\nfunction fit(text, width, size, mono = false) {\n const max = Math.floor(width / (size * (mono ? 0.6 : 0.54)));\n return text.length > max ? (0, text_1.cut)(text, Math.max(1, max - 1)) + "\u2026" : text;\n}\nfunction wrap(text, width, size, maxLines) {\n const max = Math.max(8, Math.floor(width / (size * 0.54)));\n const words = text.split(/\\s+/).filter(Boolean);\n const lines = [];\n let current = "";\n for (const word of words) {\n const next = current ? `${current} ${word}` : word;\n if (next.length <= max)\n current = next;\n else {\n if (current)\n lines.push(current);\n current = (0, text_1.clip)(word, max);\n }\n }\n if (current)\n lines.push(current);\n if (lines.length > maxLines) {\n const kept = lines.slice(0, maxLines);\n kept[maxLines - 1] = fit(`${kept[maxLines - 1]} \u2026`, width, size);\n return kept;\n }\n return lines;\n}\nconst NOT_XML = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\uD800-\\uDFFF\uFFFE\uFFFF]/g;\nfunction esc(text) {\n return text\n .replace(NOT_XML, (c) => (c.length === 2 ? c : c < " " ? " " : ""))\n .replace(/&/g, "&")\n .replace(/</g, "<")\n .replace(/>/g, ">")\n .replace(/"/g, """)\n .replace(/\'/g, "'");\n}\nconst REASONS = {\n "200": "OK",\n "201": "Created",\n "202": "Accepted",\n "204": "No Content",\n "206": "Partial Content",\n "301": "Moved Permanently",\n "302": "Found",\n "303": "See Other",\n "304": "Not Modified",\n "307": "Temporary Redirect",\n "308": "Permanent Redirect",\n "400": "Bad Request",\n "401": "Unauthorized",\n "402": "Payment Required",\n "403": "Forbidden",\n "404": "Not Found",\n "405": "Method Not Allowed",\n "409": "Conflict",\n "410": "Gone",\n "412": "Precondition Failed",\n "413": "Content Too Large",\n "422": "Unprocessable",\n "429": "Too Many Requests",\n "500": "Server Error",\n "502": "Bad Gateway",\n "503": "Unavailable",\n "504": "Gateway Timeout",\n};\nfunction reason(status) {\n var _a;\n return (_a = REASONS[status]) !== null && _a !== void 0 ? _a : "";\n}\nfunction clamp01(n) {\n return Math.max(0, Math.min(1, n));\n}\nfunction ease(t) {\n const x = clamp01(t);\n return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\nfunction pulse(p, a, b) {\n if (p < a || p > b)\n return 0;\n return Math.sin(((p - a) / (b - a)) * Math.PI);\n}\n\n}, {"../storyboard/timing":"lib/storyboard/timing","./code":"lib/render/code","../text":"lib/text"}],\n"lib/storyboard/timing": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.VOICE_LEAD = void 0;\nexports.activeScenes = activeScenes;\nexports.sceneDuration = sceneDuration;\nexports.totalDuration = totalDuration;\nexports.voiceCues = voiceCues;\nexports.summaryItems = summaryItems;\nexports.VOICE_LEAD = 400;\nconst VOICE_TAIL = 600;\nfunction activeScenes(sb) {\n return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);\n}\nfunction sceneDuration(sb, scene) {\n if (!sb.settings.voiceover || !scene.voiceMs)\n return scene.duration;\n return Math.max(scene.duration, Math.ceil(exports.VOICE_LEAD + scene.voiceMs + VOICE_TAIL));\n}\nfunction totalDuration(sb) {\n return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);\n}\nfunction voiceCues(sb) {\n if (!sb.settings.voiceover)\n return [];\n const cues = [];\n let t = 0;\n for (const scene of activeScenes(sb)) {\n if (scene.voiceMs)\n cues.push({ sceneId: scene.id, at: t + exports.VOICE_LEAD });\n t += sceneDuration(sb, scene);\n }\n return cues;\n}\nfunction summaryItems(sb) {\n const items = [];\n let failure;\n for (const scene of activeScenes(sb)) {\n if (!scene.summaryLine)\n continue;\n if (scene.kind === "call" && scene.outcome === "failure") {\n failure = scene.summaryLine;\n continue;\n }\n items.push(scene.summaryLine);\n if (failure)\n items.push(failure);\n failure = undefined;\n }\n if (failure)\n items.push(failure);\n return items;\n}\n\n}, {}],\n"lib/render/code": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CODE_STYLES = void 0;\nexports.codeRequest = codeRequest;\nexports.authCode = authCode;\nexports.callCode = callCode;\nexports.codeLines = codeLines;\nconst examples_1 = require("../oas/examples");\nconst timing_1 = require("../storyboard/timing");\nexports.CODE_STYLES = [\n { style: "curl", label: "curl" },\n { style: "javascript", label: "JavaScript" },\n { style: "python", label: "Python" },\n];\nfunction codeRequest(sb, scene) {\n var _a, _b, _c, _d;\n let url = /^[a-z][a-z\\d+.-]*:\\/\\//i.test(scene.path) ? scene.path : `${sb.api.baseUrl}${scene.path}`;\n const body = /^(GET|HEAD)$/.test(scene.method) && isEmptyValue(scene.request) ? undefined : scene.request;\n const req = { method: scene.method, url, headers: [], body, contentType: scene.requestType, ...(scene.encoding ? { encoding: scene.encoding } : {}) };\n const auth = sb.scenes.find((s) => s.kind === "auth");\n const credentials = (_a = scene.credentials) !== null && _a !== void 0 ? _a : ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth" ? ((_b = auth.credentials) !== null && _b !== void 0 ? _b : auth.headerLine.split("\\n").map(fromLine)) : []);\n const cookies = ((_c = scene.cookies) !== null && _c !== void 0 ? _c : []).map(([name, value]) => `${name}=${value}`);\n for (const credential of credentials) {\n if (!credential)\n continue;\n const c = { ...credential, value: credential.value.replace(/\u2026/g, "...") };\n if (c.in === "query")\n url += (url.includes("?") ? "&" : "?") + `${c.name}=${c.value}`;\n else if (c.in === "cookie")\n cookies.unshift(`${c.name}=${c.value}`);\n else if (c.in === "certificate")\n req.certificate = { cert: c.name, key: c.value };\n else if (c.in === "digest")\n req.digest = { username: c.name, password: c.value };\n else\n req.headers.push([c.name, c.value]);\n }\n req.headers.push(...((_d = scene.headers) !== null && _d !== void 0 ? _d : []));\n if (cookies.length)\n req.headers.push(["Cookie", cookies.join("; ")]);\n return { ...req, url };\n}\nfunction fromLine(line) {\n if (line.startsWith("?")) {\n const eq = line.indexOf("=");\n return eq > 1 ? { in: "query", name: line.slice(1, eq), value: line.slice(eq + 1) } : undefined;\n }\n const colon = line.indexOf(":");\n return colon > 0 ? { in: "header", name: line.slice(0, colon).trim(), value: line.slice(colon + 1).trim() } : undefined;\n}\nfunction bodyKind(req) {\n var _a, _b;\n const type = (_b = (_a = req.contentType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "";\n if (req.body === undefined)\n return "none";\n if (type.includes("multipart/form-data") && isObject(req.body))\n return "multipart";\n if (type.includes("x-www-form-urlencoded") && isObject(req.body))\n return "form";\n if (typeof req.body === "string" && req.body === examples_1.BINARY_PLACEHOLDER)\n return "binary";\n if (typeof req.body === "string" && type && !/json/.test(type))\n return "text";\n return "json";\n}\nconst isFile = (value) => value === examples_1.BINARY_PLACEHOLDER;\nfunction fieldText(value) {\n return typeof value === "string" ? value : value === undefined || value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);\n}\nfunction formPairs(body, encoding = {}) {\n var _a, _b, _c, _d;\n const out = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const style = (_b = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : "form";\n const explode = (_d = (_c = encoding[name]) === null || _c === void 0 ? void 0 : _c.explode) !== null && _d !== void 0 ? _d : style === "form";\n if (style === "deepObject" && typeof value === "object" && value !== null)\n out.push(...bracketed(name, value));\n else if (Array.isArray(value)) {\n if (explode && style === "form")\n out.push(...value.map((item) => [name, fieldText(item)]));\n else\n out.push([name, value.map(fieldText).join(style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",")]);\n }\n else if (isObject(value)) {\n if (explode)\n out.push(...Object.entries(value).map(([key, v]) => [key, fieldText(v)]));\n else\n out.push([name, Object.entries(value).flatMap(([key, v]) => [key, fieldText(v)]).join(",")]);\n }\n else\n out.push([name, fieldText(value)]);\n }\n return out;\n}\nfunction bracketed(name, value) {\n if (Array.isArray(value))\n return value.flatMap((item, i) => bracketed(`${name}[${i}]`, item));\n if (isObject(value))\n return Object.entries(value).flatMap(([key, v]) => bracketed(`${name}[${key}]`, v));\n return [[name, fieldText(value)]];\n}\nfunction formObject(body) {\n return Object.fromEntries(Object.entries(body).flatMap(([key, value]) => (value === null || value === undefined ? [] : [[key, typeof value === "boolean" ? String(value) : value]])));\n}\nfunction flat(body) {\n return Object.values(body).every((value) => typeof value !== "object" || value === null);\n}\nfunction multipartParts(body, encoding = {}) {\n var _a;\n const parts = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const type = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.contentType;\n const items = Array.isArray(value) && !value.some((v) => typeof v === "object" && v !== null) ? value : [value];\n for (const item of items) {\n if (isFile(item))\n parts.push({ name, file: true });\n else if (typeof item === "object" && item !== null)\n parts.push({ name, text: JSON.stringify(item), type: type !== null && type !== void 0 ? type : "application/json" });\n else\n parts.push({ name, text: fieldText(item), ...(type && !/^text\\/plain\\b/i.test(type) ? { type } : {}) });\n }\n }\n return parts;\n}\nfunction filePath(name) {\n return /^[\\w-]+$/.test(name) ? name : "file";\n}\nfunction isObject(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isEmptyValue(value) {\n return value === undefined || (typeof value === "object" && value !== null && Object.keys(value).length === 0);\n}\nfunction authCode(sb, scene, style) {\n var _a, _b, _c, _d;\n const target = (_b = (_a = scene.requestLine) === null || _a === void 0 ? void 0 : _a.replace(/^POST\\s+/, "")) !== null && _b !== void 0 ? _b : "";\n const url = (_c = scene.tokenUrl) !== null && _c !== void 0 ? _c : (/^https?:\\/\\//i.test(target) ? target : `${sb.api.baseUrl}${target}`);\n return codeLines({ method: "POST", url, headers: [], body: scene.request, contentType: (_d = scene.requestType) !== null && _d !== void 0 ? _d : "application/x-www-form-urlencoded" }, style);\n}\nfunction callCode(sb, scene, style) {\n return sb.api.protocol === "mcp" ? mcpCode(sb, scene, style) : codeLines(codeRequest(sb, scene), style);\n}\nfunction codeLines(req, style) {\n switch (style) {\n case "curl":\n return curl(req);\n case "javascript":\n return javascript(req);\n default:\n return python(req);\n }\n}\nfunction curl(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const parts = [];\n const method = req.method === "HEAD" ? " -I" : req.method === "GET" || (req.method === "POST" && kind !== "none") ? "" : ` -X ${shellQuote(req.method)}`;\n const glob = /[[\\]{}]/.test(req.url) ? " -g" : "";\n parts.push([`curl${glob}${method} ${shellQuote(req.url, /[?&]/.test(req.url))}`]);\n if (req.certificate)\n parts.push([` --cert ${shellQuote(req.certificate.cert)} --key ${shellQuote(req.certificate.key)}`]);\n if (req.digest)\n parts.push([` --digest -u ${shellQuote(`${req.digest.username}:${req.digest.password}`, true)}`]);\n for (const [name, value] of req.headers)\n parts.push([` -H ${shellQuote(`${name}: ${value}`, true)}`]);\n const body = req.body;\n const contentType = (type) => [` -H ${shellQuote(`Content-Type: ${type}`, true)}`];\n if (kind === "json") {\n parts.push(contentType((_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"));\n parts.push(quotedData(pretty(body, "json", 2)));\n }\n else if (kind === "form" && isObject(body)) {\n for (const [key, value] of formPairs(body, req.encoding))\n parts.push([` --data-urlencode ${shellQuote(`${key}=${value}`, true)}`]);\n }\n else if (kind === "multipart" && isObject(body)) {\n for (const part of multipartParts(body, req.encoding))\n parts.push([` ${formPart(part)}`]);\n }\n else if (kind === "binary") {\n parts.push(contentType((_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"), [" --data-binary @file"]);\n }\n else if (kind === "text") {\n parts.push(contentType((_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"), quotedData(String(body).split("\\n")));\n }\n return parts.flatMap((part, p) => part.map((line, i) => (p < parts.length - 1 && i === part.length - 1 ? `${line} \\\\` : line)));\n}\nfunction formPart(part) {\n const value = part.file ? `@${filePath(part.name)}` : part.text;\n if (part.name.includes("="))\n return `--form-string ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.file)\n return `-F ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.type) {\n const text = readsMore(value) ? `"${value.replace(/[\\\\"]/g, "\\\\$&")}"` : value;\n return `-F \'${escapeSingle(`${part.name}=${text}${formType(part.type)}`)}\'`;\n }\n return `${readsMore(value) ? "--form-string" : "-F"} ${shellQuote(`${part.name}=${value}`, true)}`;\n}\nfunction formType(type) {\n const [essence, ...params] = type.split(",")[0].split(";").map((s) => s.trim());\n if (!/^[\\w.+*-]+\\/[\\w.+*-]+$/.test(essence))\n return "";\n const kept = params.filter((p) => /^[\\w.+-]+=[^\\s"\\\\]*$/.test(p) && !/^(type|filename|headers|encoder)=/i.test(p));\n return `;type=${[essence, ...kept].join("; ")}`;\n}\nfunction readsMore(text) {\n return /^[@<"\\s]|;|\\s$/.test(text);\n}\nfunction quotedData(lines) {\n const body = lines.map(escapeSingle);\n return body.length === 1 ? [` -d \'${body[0]}\'`] : [` -d \'${body[0]}`, ...body.slice(1, -1).map((l) => ` ${l}`), ` ${body.at(-1)}\'`];\n}\nfunction shellQuote(text, always = false) {\n if (!always && !/[^\\w@%+=:,./-]/.test(text))\n return text;\n return /["\\\\$`!]/.test(text) ? `\'${escapeSingle(text)}\'` : `"${text}"`;\n}\nfunction escapeSingle(text) {\n return text.replace(/\'/g, `\'\\\\\'\'`);\n}\nfunction javascript(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const lines = [];\n const headers = [...req.headers];\n let body = [];\n if (req.certificate)\n lines.push(`// Sent over mutual TLS with ${req.certificate.cert} and ${req.certificate.key}`);\n if (req.digest) {\n lines.push("// Answer the API\'s Digest challenge with your username and password");\n headers.push(["Authorization", `Digest username="${req.digest.username}", nonce="...", response="..."`]);\n }\n if (kind === "json") {\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"]);\n body = wrapLines("body: JSON.stringify(", pretty(req.body, "json", 2), "),");\n }\n else if (kind === "multipart" && isObject(req.body)) {\n lines.push("const form = new FormData();");\n for (const part of multipartParts(req.body, req.encoding)) {\n const value = part.file ? "file" : part.type ? `new Blob([${jsString(part.text)}], { type: ${jsString(part.type)} })` : jsString(part.text);\n lines.push(`form.append(${jsString(part.name)}, ${value});`);\n }\n body = ["body: form,"];\n }\n else if (kind === "form" && isObject(req.body)) {\n body = flat(req.body) && !req.encoding\n ? wrapLines("body: new URLSearchParams(", pretty(formObject(req.body), "json", 2), "),")\n : ["body: new URLSearchParams([", ...formPairs(req.body, req.encoding).map(([k, v]) => ` [${jsString(k)}, ${jsString(v)}],`), "]),"];\n }\n else if (kind === "binary") {\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"]);\n body = ["body: file,"];\n }\n else if (kind === "text") {\n headers.push(["Content-Type", (_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"]);\n const text = String(req.body);\n body = text.includes("\\n") ? wrapLines("body: `", text.replace(/[`\\\\]|\\$\\{/g, (m) => `\\\\${m}`).split("\\n"), "`,") : [`body: ${jsString(text)},`];\n }\n const options = [\n ...(req.method === "GET" ? [] : [`method: ${jsString(req.method)},`]),\n ...(headers.length ? ["headers: {", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"] : []),\n ...body,\n ];\n if (!options.length)\n return [...lines, `await fetch(${jsString(req.url)});`];\n return [...lines, `await fetch(${jsString(req.url)}, {`, ...options.map((l) => ` ${l}`), "});"];\n}\nfunction jsString(text) {\n return JSON.stringify(text);\n}\nconst PYTHON_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);\nfunction python(req) {\n var _a, _b;\n const kind = bodyKind(req);\n const args = [[`${jsString(req.url)},`]];\n const headers = [...req.headers];\n if (kind === "binary")\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/octet-stream"]);\n if (kind === "text")\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "text/plain"]);\n if (headers.length === 1)\n args.push([`headers={${jsString(headers[0][0])}: ${jsString(headers[0][1])}},`]);\n else if (headers.length)\n args.push(["headers={", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"]);\n if (req.certificate)\n args.push([`cert=(${jsString(req.certificate.cert)}, ${jsString(req.certificate.key)}),`]);\n if (req.digest)\n args.push([`auth=requests.auth.HTTPDigestAuth(${jsString(req.digest.username)}, ${jsString(req.digest.password)}),`]);\n if (kind === "json")\n args.push(wrapLines("json=", pretty(req.body, "python", 4), ","));\n else if (kind === "form" && isObject(req.body)) {\n if (flat(req.body) && !req.encoding)\n args.push(wrapLines("data=", pretty(formObject(req.body), "python", 4), ","));\n else\n args.push(["data=[", ...formPairs(req.body, req.encoding).map(([k, v]) => ` (${jsString(k)}, ${jsString(v)}),`), "],"]);\n }\n else if (kind === "multipart" && isObject(req.body)) {\n const parts = multipartParts(req.body, req.encoding);\n const typed = parts.filter((p) => p.file || p.type);\n const files = typed.length ? typed : parts;\n const fields = typed.length ? parts.filter((p) => !p.file && !p.type) : [];\n const file = (p) => (p.file ? `open(${jsString(filePath(p.name))}, "rb")` : p.type ? `(None, ${jsString(p.text)}, ${jsString(p.type)})` : `(None, ${jsString(p.text)})`);\n const twice = (list) => new Set(list.map((p) => p.name)).size < list.length;\n if (files.length) {\n args.push(twice(files) ? ["files=[", ...files.map((p) => ` (${jsString(p.name)}, ${file(p)}),`), "],"] : ["files={", ...files.map((p) => ` ${jsString(p.name)}: ${file(p)},`), "},"]);\n }\n if (fields.length) {\n args.push(twice(fields) ? ["data=[", ...fields.map((p) => ` (${jsString(p.name)}, ${jsString(p.text)}),`), "],"] : ["data={", ...fields.map((p) => ` ${jsString(p.name)}: ${jsString(p.text)},`), "},"]);\n }\n }\n else if (kind === "binary")\n args.push([`data=open("file", "rb"),`]);\n else if (kind === "text") {\n const text = String(req.body);\n args.push(text.includes("\\n") ? wrapLines(\'data="""\', text.replace(/\\\\/g, "\\\\\\\\").replace(/"""/g, \'\\\\"\\\\"\\\\"\').split("\\n"), \'""",\') : [`data=${jsString(text)},`]);\n }\n const call = PYTHON_METHODS.has(req.method) ? `requests.${req.method.toLowerCase()}(` : `requests.request(${jsString(req.method)},`;\n return [call, ...args.flat().map((l) => ` ${l}`), ")"];\n}\nconst MCP_VERSION = "2026-07-28";\nconst VERSION_HEADER_SINCE = "2025-06-18";\nconst SESSION_ID = "1868a90c...";\nconst CLIENT_INFO = { name: "your-agent", version: "1.0.0" };\nfunction mcpCode(sb, scene, style) {\n const http = /^https?:\\/\\//i.test(sb.api.baseUrl);\n const auth = sb.scenes.some((s) => s.kind === "auth");\n switch (style) {\n case "curl":\n return mcpWire(sb, scene, http);\n case "javascript":\n return mcpJavaScript(sb, scene, http, auth);\n default:\n return mcpPython(sb, scene, http, auth);\n }\n}\nfunction rpcBody(sb, scene, modern) {\n var _a;\n const meta = { "io.modelcontextprotocol/protocolVersion": MCP_VERSION, "io.modelcontextprotocol/clientInfo": CLIENT_INFO, "io.modelcontextprotocol/clientCapabilities": {} };\n const params = scene.method === "tools/call"\n ? { name: scene.path, arguments: (_a = scene.request) !== null && _a !== void 0 ? _a : {} }\n : scene.method === "resources/read"\n ? { uri: scene.path }\n : scene.method === "prompts/get"\n ? { name: scene.path, ...(scene.request !== undefined ? { arguments: scene.request } : {}) }\n : {};\n if (!modern)\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, ...(Object.keys(params).length ? { params } : {}) };\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, params: { ...params, _meta: meta } };\n}\nfunction rpcId(sb, scene) {\n const index = (0, timing_1.activeScenes)(sb)\n .filter((s) => s.kind === "call")\n .indexOf(scene);\n return index >= 0 ? index + 1 : scene.step;\n}\nfunction mcpWire(sb, scene, http) {\n var _a, _b, _c;\n const revision = (_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION;\n const modern = revision >= MCP_VERSION;\n const body = JSON.stringify(rpcBody(sb, scene, modern));\n if (!http) {\n if (modern)\n return [`echo \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n const init = JSON.stringify({ jsonrpc: "2.0", id: 0, method: "initialize", params: { protocolVersion: revision, capabilities: {}, clientInfo: CLIENT_INFO } });\n return [`printf \'%s\\\\n\' \\\\`, ` \'${escapeSingle(init)}\' \\\\`, ` \'{"jsonrpc":"2.0","method":"notifications/initialized"}\' \\\\`, ` \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n }\n const headers = [["Accept", "application/json, text/event-stream"]];\n if (modern) {\n headers.push(["MCP-Protocol-Version", MCP_VERSION], ["Mcp-Method", scene.method]);\n if (scene.method !== "tools/list")\n headers.push(["Mcp-Name", headerValue(scene.path)]);\n for (const { name, path } of (_b = scene.paramHeaders) !== null && _b !== void 0 ? _b : []) {\n const value = path.reduce((at, key) => (isObject(at) ? at[key] : undefined), scene.request);\n if (typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isSafeInteger(value)))\n headers.push([`Mcp-Param-${name}`, headerValue(String(value))]);\n }\n }\n else {\n if (revision >= VERSION_HEADER_SINCE)\n headers.push(["MCP-Protocol-Version", revision]);\n if (sb.api.session !== false)\n headers.push(["Mcp-Session-Id", SESSION_ID]);\n }\n const auth = sb.scenes.find((s) => s.kind === "auth");\n if ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth")\n for (const c of (_c = auth.credentials) !== null && _c !== void 0 ? _c : [])\n if (c.in === "header")\n headers.push([c.name, c.value.replace(/\u2026/g, "...")]);\n return [`curl ${shellQuote(sb.api.baseUrl)} \\\\`, ...headers.map(([n, v]) => ` -H ${shellQuote(`${n}: ${v}`, true)} \\\\`), ` --json \'${escapeSingle(body)}\'`];\n}\nfunction headerValue(text) {\n const plain = /^[\\x21-\\x7e]([\\x20-\\x7e\\t]*[\\x21-\\x7e])?$/.test(text) && !/^=\\?base64\\?.*\\?=$/.test(text);\n if (plain)\n return text;\n const bytes = new TextEncoder().encode(text);\n let binary = "";\n for (const byte of bytes)\n binary += String.fromCharCode(byte);\n return `=?base64?${btoa(binary)}?=`;\n}\nfunction mcpJavaScript(sb, scene, http, auth) {\n var _a, _b, _c;\n switch (scene.method) {\n case "tools/list": {\n const command = sb.api.baseUrl.split(" ");\n const transport = http\n ? [` new StreamableHTTPClientTransport(new URL(${jsString(sb.api.baseUrl)})${auth ? ", { authProvider }" : ""}),`]\n : [` new StdioClientTransport({ command: ${jsString(command[0])}, args: ${list(command.slice(1))} }),`];\n const negotiate = ((_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION) >= MCP_VERSION ? `, { versionNegotiation: { mode: "auto" } }` : "";\n return [\n `import { Client${http ? ", StreamableHTTPClientTransport" : ""} } from "@modelcontextprotocol/client";`,\n ...(http ? [] : [`import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";`]),\n "",\n `const client = new Client({ name: "your-agent", version: "1.0.0" }${negotiate});`,\n "await client.connect(",\n ...transport,\n ");",\n "const { tools } = await client.listTools();",\n ];\n }\n case "resources/read":\n return [`const { contents } = await client.readResource({ uri: ${jsString(scene.path)} });`];\n case "prompts/get":\n return ["const { messages } = await client.getPrompt({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "json", 2), ",")), "});"];\n default:\n return ["const result = await client.callTool({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_c = scene.request) !== null && _c !== void 0 ? _c : {}, "json", 2), ",")), "});"];\n }\n}\nfunction mcpPython(sb, scene, http, auth) {\n var _a, _b;\n switch (scene.method) {\n case "tools/list": {\n if (http && auth) {\n return [\n "import httpx2",\n "from mcp import Client",\n "from mcp.client.streamable_http import streamable_http_client",\n "",\n "http = httpx2.AsyncClient(auth=oauth) # an OAuthClientProvider",\n `async with Client(streamable_http_client(${jsString(sb.api.baseUrl)}, http_client=http)) as client:`,\n " result = await client.list_tools()",\n ];\n }\n if (http)\n return ["from mcp import Client", "", `async with Client(${jsString(sb.api.baseUrl)}) as client:`, " result = await client.list_tools()"];\n const [command, ...args] = sb.api.baseUrl.split(" ");\n return [\n "from mcp import Client, StdioServerParameters",\n "",\n `server = StdioServerParameters(command=${jsString(command)}, args=${list(args)})`,\n "async with Client(server) as client:",\n " result = await client.list_tools()",\n ];\n }\n case "resources/read":\n return [`result = await client.read_resource(${jsString(scene.path)})`];\n case "prompts/get":\n return ["result = await client.get_prompt(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_a = scene.request) !== null && _a !== void 0 ? _a : {}, "python", 4), ",")), ")"];\n default:\n return ["result = await client.call_tool(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "python", 4), ",")), ")"];\n }\n}\nfunction list(items) {\n return `[${items.map(jsString).join(", ")}]`;\n}\nfunction indented(indent, lines) {\n return lines.map((line) => `${indent}${line}`);\n}\nfunction wrapLines(head, lines, tail) {\n if (lines.length === 1)\n return [`${head}${lines[0]}${tail}`];\n return [`${head}${lines[0]}`, ...lines.slice(1, -1), `${lines.at(-1)}${tail}`];\n}\nfunction pretty(value, as, indent) {\n var _a;\n const text = (_a = JSON.stringify(value, null, indent)) !== null && _a !== void 0 ? _a : "null";\n if (as === "json")\n return text.split("\\n");\n return text.split("\\n").map((line) => line.replace(/("(?:[^"\\\\]|\\\\.)*")|\\b(true|false|null)\\b/g, (_, str, word) => str !== null && str !== void 0 ? str : { true: "True", false: "False", null: "None" }[word]));\n}\n\n}, {"../oas/examples":"lib/oas/examples","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/oas/examples": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.PLACEHOLDER_UUID = exports.BINARY_PLACEHOLDER = void 0;\nexports.mediaKind = mediaKind;\nexports.isTextKind = isTextKind;\nexports.exampleForMedia = exampleForMedia;\nexports.toXml = toXml;\nexports.exampleForParameter = exampleForParameter;\nexports.exampleFromSchema = exampleFromSchema;\nexports.conform = conform;\nexports.placeholder = placeholder;\nexports.isPlaceholder = isPlaceholder;\nexports.patternExample = patternExample;\nexports.isIdName = isIdName;\nexports.idLike = idLike;\nexports.uuidLike = uuidLike;\nexports.singular = singular;\nconst fit_1 = require("./fit");\nexports.BINARY_PLACEHOLDER = "<binary data>";\nconst BINARY_MEDIA = /octet-stream|^(image|audio|video|font)\\/|application\\/(pdf|zip|gzip|x-tar)/i;\nfunction mediaKind(contentType) {\n const type = contentType.toLowerCase().split(";")[0].trim();\n if (/^application\\/(x-)?(ndjson|jsonl|jsonlines|json-lines)$|json-seq$/.test(type))\n return "sequence";\n if (/json/.test(type))\n return "json";\n if (type === "application/x-www-form-urlencoded")\n return "form";\n if (type.startsWith("multipart/"))\n return "multipart";\n if (/[/+]xml$/.test(type))\n return "xml";\n if (type === "text/event-stream")\n return "events";\n if (BINARY_MEDIA.test(type))\n return "binary";\n if (type.startsWith("text/") || /^application\\/(x-)?(yaml|csv|graphql|javascript|sql)$/.test(type))\n return "text";\n return "json";\n}\nfunction isTextKind(kind) {\n return kind === "xml" || kind === "sequence" || kind === "events" || kind === "text";\n}\nfunction exampleForMedia(media, mode = "response", contentType = "", subject) {\n if (!media)\n return { value: undefined, generated: false };\n const kind = mediaKind(contentType);\n const given = documentedExample(media, kind);\n if (given !== undefined && !isTextKind(kind) && media.schema && otherShape(given, media.schema)) {\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n }\n if (given !== undefined) {\n if (!isTextKind(kind) && kind !== "binary" && media.schema) {\n const fixed = conform(given, media.schema, mode, "", 0, undefined, subject);\n return { value: fixed, generated: fixed !== given };\n }\n return { value: serialize(given, kind, media, contentType), generated: false };\n }\n if (BINARY_MEDIA.test(contentType) && (!media.schema || media.schema.type === "string" || media.schema.format === "binary")) {\n return { value: exports.BINARY_PLACEHOLDER, generated: true };\n }\n if (isTextKind(kind) && (media.schema || media.itemSchema))\n return { value: textFromSchema(media, kind, mode, contentType), generated: true };\n if (media.schema)\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n return { value: undefined, generated: false };\n}\nfunction otherShape(example, schema) {\n if (!isRecord(example) || !Object.keys(example).length)\n return false;\n const names = new Set();\n const patterns = [];\n let open = false;\n const collect = (s, depth) => {\n var _a, _b, _c, _d, _e;\n if (!s || typeof s !== "object" || depth > 6)\n return;\n const target = (0, fit_1.circularTarget)(s);\n if (target)\n return collect(target, depth + 1);\n for (const key of Object.keys((_a = s.properties) !== null && _a !== void 0 ? _a : {}))\n names.add(key);\n patterns.push(...Object.keys((_b = s.patternProperties) !== null && _b !== void 0 ? _b : {}));\n if (isRecord(s.additionalProperties))\n open = true;\n for (const part of [...((_c = s.allOf) !== null && _c !== void 0 ? _c : []), ...((_d = s.oneOf) !== null && _d !== void 0 ? _d : []), ...((_e = s.anyOf) !== null && _e !== void 0 ? _e : [])])\n collect(part, depth + 1);\n };\n collect(schema, 0);\n if (!names.size || open)\n return false;\n return !Object.keys(example).some((key) => names.has(key) || patterns.some((pattern) => (0, fit_1.matchesPattern)(pattern, key)));\n}\nfunction documentedExample(media, kind) {\n var _a;\n if (media.example !== undefined)\n return media.example;\n for (const example of Object.values((_a = media.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = exampleValue(example, isTextKind(kind));\n if (value !== undefined)\n return kind === "json" && (example === null || example === void 0 ? void 0 : example.dataValue) === undefined && (example === null || example === void 0 ? void 0 : example.value) === undefined ? parseJsonText(value) : value;\n }\n return undefined;\n}\nfunction exampleValue(example, text) {\n if (!example || typeof example !== "object")\n return undefined;\n const serialized = typeof example.serializedValue === "string" ? example.serializedValue : undefined;\n if (text && serialized !== undefined)\n return serialized;\n if (example.dataValue !== undefined)\n return example.dataValue;\n return example.value !== undefined ? example.value : serialized;\n}\nfunction parseJsonText(value) {\n if (typeof value !== "string")\n return value;\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nfunction serialize(value, kind, media, contentType) {\n if (!isTextKind(kind) || typeof value === "string")\n return value;\n switch (kind) {\n case "xml":\n return toXml(value, media.schema);\n case "sequence":\n return (Array.isArray(value) ? value : [value]).map((item) => JSON.stringify(item)).join("\\n");\n case "events":\n return (Array.isArray(value) ? value : [value]).map((event) => toEvent(event, media.itemSchema)).join("\\n\\n");\n default:\n return toText(value, contentType);\n }\n}\nfunction textFromSchema(media, kind, mode, contentType) {\n var _a, _b;\n const schema = (_a = media.schema) !== null && _a !== void 0 ? _a : {};\n const made = (s) => conform(exampleFromSchema(s, "", 0, mode), s, mode);\n if (kind === "xml")\n return toXml(made(schema), schema);\n if (kind === "sequence" || kind === "events") {\n const item = (_b = media.itemSchema) !== null && _b !== void 0 ? _b : (schema.items && (schema.type === "array" || Array.isArray(schema.type)) ? schema.items : schema);\n const value = made(item);\n return kind === "sequence" ? JSON.stringify(value) : toEvent(value, item);\n }\n return toText(made(schema), contentType);\n}\nfunction toEvent(value, schema) {\n var _a, _b, _c;\n const fields = isRecord(value) && "data" in value ? value : { data: value };\n const lines = [];\n for (const key of ["event", "id", "retry"])\n if (fields[key] !== undefined && fields[key] !== null)\n lines.push(`${key}: ${String(fields[key])}`);\n let data = fields.data;\n const dataSchema = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a.data;\n if (typeof data === "string" && (dataSchema === null || dataSchema === void 0 ? void 0 : dataSchema.contentSchema) && /json/i.test((_b = dataSchema.contentMediaType) !== null && _b !== void 0 ? _b : "json"))\n data = exampleFromSchema(dataSchema.contentSchema, "data");\n for (const line of (typeof data === "string" ? data : (_c = JSON.stringify(data)) !== null && _c !== void 0 ? _c : "").split("\\n"))\n lines.push(`data: ${line}`);\n return lines.join("\\n");\n}\nfunction toText(value, contentType) {\n if (typeof value === "string")\n return value;\n if (/csv/i.test(contentType) && Array.isArray(value) && value.every(isRecord)) {\n const columns = [...new Set(value.flatMap((row) => Object.keys(row)))];\n const cell = (v) => (/[",\\n]/.test(String(v !== null && v !== void 0 ? v : "")) ? `"${String(v).replace(/"/g, \'""\')}"` : String(v !== null && v !== void 0 ? v : ""));\n return [columns.join(","), ...value.map((row) => columns.map((c) => cell(row[c])).join(","))].join("\\n");\n }\n return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);\n}\nfunction toXml(value, schema, name) {\n var _a, _b, _c, _d, _e, _f, _g;\n const lines = [];\n const rootName = (_d = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : name) !== null && _c !== void 0 ? _c : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _d !== void 0 ? _d : (Array.isArray(value) ? "items" : "data");\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_g = (_f = (_e = items === null || items === void 0 ? void 0 : items.xml) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : items === null || items === void 0 ? void 0 : items.title) !== null && _g !== void 0 ? _g : singular(rootName);\n lines.push(`<${xmlName(rootName, schema)}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, 1);\n lines.push(`</${xmlName(rootName, schema)}>`);\n }\n else {\n writeXml(lines, rootName, value, schema, 0, true);\n }\n return lines.join("\\n");\n}\nfunction writeXml(lines, name, value, schema, depth, root = false) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n const pad = " ".repeat(depth);\n const xml = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) !== null && _a !== void 0 ? _a : {};\n const qname = xmlName((_b = xml.name) !== null && _b !== void 0 ? _b : name, schema);\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_d = (_c = items === null || items === void 0 ? void 0 : items.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : name;\n if (xml.nodeType === "element" || xml.wrapped === true) {\n lines.push(`${pad}<${qname}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, depth + 1);\n lines.push(`${pad}</${qname}>`);\n }\n else {\n for (const item of value)\n writeXml(lines, itemName, item, items, depth);\n }\n return;\n }\n if (value === null || value === undefined) {\n lines.push(`${pad}<${qname} xsi:nil="true"/>`);\n return;\n }\n if (!isRecord(value)) {\n lines.push(`${pad}<${qname}${root ? namespaceAttr(schema) : ""}>${escapeXml(String(value))}</${qname}>`);\n return;\n }\n const properties = propertiesOf(schema);\n const attributes = [];\n const children = [];\n let text;\n for (const [key, child] of Object.entries(value)) {\n const prop = properties[key];\n const nodeType = (_f = (_e = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _e === void 0 ? void 0 : _e.nodeType) !== null && _f !== void 0 ? _f : (((_g = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _g === void 0 ? void 0 : _g.attribute) ? "attribute" : undefined);\n if (nodeType === "attribute") {\n if (child !== null && child !== undefined)\n attributes.push(` ${xmlName((_j = (_h = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : key, prop)}="${escapeXml(String(child), true)}"`);\n }\n else if (nodeType === "text" || nodeType === "cdata") {\n text = nodeType === "cdata" ? `<![CDATA[${String(child)}]]>` : escapeXml(String(child));\n }\n else {\n children.push([key, child, prop]);\n }\n }\n const open = `${pad}<${qname}${namespaceAttr(schema)}${attributes.join("")}`;\n if (!children.length) {\n lines.push(text === undefined ? `${open}/>` : `${open}>${text}</${qname}>`);\n return;\n }\n lines.push(`${open}>${text !== null && text !== void 0 ? text : ""}`);\n for (const [key, child, prop] of children)\n writeXml(lines, key, child, prop, depth + 1);\n lines.push(`${pad}</${qname}>`);\n}\nfunction propertiesOf(schema, depth = 0) {\n var _a, _b;\n if (!schema || depth > 4)\n return {};\n const out = {};\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n Object.assign(out, propertiesOf(part, depth + 1));\n return Object.assign(out, (_b = schema.properties) !== null && _b !== void 0 ? _b : {});\n}\nfunction xmlName(name, schema) {\n var _a;\n let clean = name.replace(/[^\\w.:-]/g, "_");\n if (!/^[A-Za-z_]/.test(clean))\n clean = `_${clean}`;\n const prefix = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.prefix;\n return prefix && !clean.includes(":") ? `${prefix}:${clean}` : clean;\n}\nfunction namespaceAttr(schema) {\n var _a, _b;\n const ns = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.namespace;\n if (!ns)\n return "";\n return ` xmlns${((_b = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _b === void 0 ? void 0 : _b.prefix) ? `:${schema.xml.prefix}` : ""}="${escapeXml(ns, true)}"`;\n}\nfunction escapeXml(text, attribute = false) {\n if (isPlaceholder(text))\n return `{${text.slice(1, -1)}}`;\n const out = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");\n return attribute ? out.replace(/"/g, """) : out;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction exampleForParameter(param) {\n var _a;\n const typed = (value) => (value === undefined || !param.schema ? value : asType(value, param.schema));\n const given = typed(param.example);\n if (given !== undefined)\n return given;\n for (const example of Object.values((_a = param.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = typed(exampleValue(example, false));\n if (value !== undefined)\n return value;\n }\n const content = param.content && Object.entries(param.content)[0];\n if (content)\n return exampleForMedia(content[1], "request", content[0]).value;\n if (param.schema)\n return exampleFromSchema(param.schema, param.name);\n return idLike(param.name);\n}\nconst MAX_DEPTH = 4;\nconst HARD_DEPTH = 12;\nconst MAX_PROPERTIES = 12;\nconst NODE_BUDGET = 250;\nconst MAX_LIST = 20;\nconst MAX_TRIES = 6;\nfunction exampleFromSchema(schema, name = "", depth = 0, mode = "response", budget = { left: NODE_BUDGET }, owner) {\n var _a;\n if (!schema || typeof schema !== "object")\n return null;\n budget.left--;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return depth >= HARD_DEPTH ? {} : exampleFromSchema(target, name, Math.max(depth + 1, MAX_DEPTH), mode, budget, owner);\n if (schema["x-circular"])\n return depth > 1 ? null : { id: idLike((_a = schema.title) !== null && _a !== void 0 ? _a : name) };\n for (const example of [schema.example, ...(Array.isArray(schema.examples) ? schema.examples.slice(0, 1) : [])]) {\n const value = example === undefined ? undefined : asType(example, schema);\n if (value !== undefined)\n return fitted(value, schema, name, depth, mode, budget, owner);\n }\n if (schema.const !== undefined)\n return schema.const;\n const fallback = schema.default === undefined ? undefined : asType(schema.default, schema);\n if (fallback !== undefined)\n return fitted(fallback, schema, name, depth, mode, budget, owner);\n return fromSchema(schema, name, depth, mode, budget, owner);\n}\nfunction fromSchema(schema, name, depth, mode, budget, owner) {\n var _a, _b;\n if (Array.isArray(schema.enum) && schema.enum.length)\n return enumValue(schema.enum, schema.description);\n if ((_a = schema.allOf) === null || _a === void 0 ? void 0 : _a.length)\n return fromParts(schema, name, depth, mode, budget, owner);\n const variants = ((_b = schema.oneOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.oneOf : schema.anyOf;\n if (variants === null || variants === void 0 ? void 0 : variants.length)\n return fromVariant(schema, variants, name, depth, mode, budget, owner);\n const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;\n const inferred = type !== null && type !== void 0 ? type : (schema.properties ? "object" : schema.items || schema.prefixItems ? "array" : undefined);\n switch (inferred) {\n case "object":\n return objectFor(schema, depth, mode, budget, owner);\n case "array":\n return listFor(schema, name, depth, mode, budget, owner);\n case "integer":\n case "number":\n return numberFor(schema, name, inferred === "integer");\n case "boolean":\n return booleanFor(name);\n case "string":\n return stringFor(schema, name, owner);\n default:\n return null;\n }\n}\nfunction objectFor(schema, depth, mode, budget, owner) {\n var _a, _b;\n const out = {};\n if (depth >= HARD_DEPTH)\n return out;\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n let props = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {}).filter(([, prop]) => !(mode === "request" ? prop === null || prop === void 0 ? void 0 : prop.readOnly : prop === null || prop === void 0 ? void 0 : prop.writeOnly));\n props = props.filter(([key, prop]) => required.has(key) || (prop === null || prop === void 0 ? void 0 : prop.deprecated) !== true);\n const answer = mode === "response" && !budget.full;\n if (answer)\n props = props.filter(([key, prop]) => required.has(key) || ((ID_FIELDS.has(key) || saysSomething(prop)) && !brokenExample(prop, mode)));\n if (depth >= MAX_DEPTH)\n props = props.filter(([key]) => required.has(key));\n props.sort(([a], [b]) => Number(required.has(b)) - Number(required.has(a)));\n if (mode === "request")\n props = telling(props, required);\n for (const [key, prop] of props) {\n if (!required.has(key) && (budget.left <= 0 || Object.keys(out).length >= MAX_PROPERTIES))\n continue;\n if (!required.has(key) && recursive(prop))\n continue;\n const value = fieldValue(prop, key, depth + 1, mode, budget, (_b = schema.title) !== null && _b !== void 0 ? _b : owner);\n if (!required.has(key) && (value === null || (mode === "request" && isEmpty(value))))\n continue;\n out[key] = value;\n }\n return out;\n}\nfunction fieldValue(prop, key, depth, mode, budget, owner) {\n if (mode === "response" && !budget.full && allowsNull(prop) && (!givesValue(prop) || brokenExample(prop, mode)))\n return null;\n return exampleFromSchema(prop, key, depth, mode, budget, owner);\n}\nfunction brokenExample(prop, mode) {\n if (!prop || typeof prop !== "object" || prop.example === undefined || prop.example === null)\n return false;\n if ((0, fit_1.fits)(prop.example, prop, mode))\n return false;\n const typed = asType(prop.example, prop);\n if (typed === undefined)\n return true;\n const plain = (v) => v === null || typeof v !== "object";\n return (plain(typed) || (Array.isArray(typed) && typed.every(plain))) && !(0, fit_1.fits)(typed, prop, mode);\n}\nfunction recursive(schema) {\n const own = (s) => isRecord(s) && s["x-circular"] !== undefined;\n return own(schema) || (isRecord(schema) && own(schema.items));\n}\nconst ID_FIELDS = new Set(["id", "sid", "gid", "uuid"]);\nfunction givesValue(schema, depth = 0) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return false;\n if (schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0) || schema.default !== undefined || schema.const !== undefined)\n return true;\n if (Array.isArray(schema.enum) && schema.enum.filter((v) => v !== null).length === 1 && !allowsNull(schema))\n return true;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return givesValue(target, depth + 1);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.oneOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.anyOf) !== null && _c !== void 0 ? _c : [])];\n return parts.some((part) => part && typeof part === "object" && part.type !== "null" && givesValue(part, depth + 1));\n}\nconst saying = new WeakMap();\nfunction saysSomething(schema, depth = 0) {\n var _a, _b, _c, _d, _e, _f;\n if (!schema || typeof schema !== "object" || depth > 1)\n return false;\n const found = (_a = saying.get(schema)) !== null && _a !== void 0 ? _a : [];\n if (found[depth] !== undefined)\n return found[depth];\n found[depth] = false;\n saying.set(schema, found);\n const target = (0, fit_1.circularTarget)(schema);\n const parts = [...((_b = schema.allOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.oneOf) !== null && _c !== void 0 ? _c : []), ...((_d = schema.anyOf) !== null && _d !== void 0 ? _d : []), ...(target ? [target] : [])];\n const inside = [...Object.values((_e = schema.properties) !== null && _e !== void 0 ? _e : {}), ...(schema.items && typeof schema.items === "object" ? [schema.items] : []), ...((_f = schema.prefixItems) !== null && _f !== void 0 ? _f : [])];\n const usable = (part) => part && typeof part === "object" && part.type !== "null";\n const own = depth === 0 ? givesValue(schema) : schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0);\n const says = own || parts.some((part) => usable(part) && saysSomething(part, depth)) || inside.some((part) => usable(part) && saysSomething(part, depth + 1));\n found[depth] = says;\n return says;\n}\nfunction allowsNull(schema) {\n var _a, _b;\n if (!schema || typeof schema !== "object")\n return false;\n if (schema.nullable === true || (Array.isArray(schema.type) && schema.type.includes("null")) || schema.type === "null")\n return true;\n if (Array.isArray(schema.enum) && schema.enum.includes(null))\n return true;\n const variants = [...((_a = schema.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.anyOf) !== null && _b !== void 0 ? _b : [])];\n const isNull = (v) => v.type === "null" || (Array.isArray(v.type) && v.type.length === 1 && v.type[0] === "null") || (Array.isArray(v.enum) && v.enum.length === 1 && v.enum[0] === null);\n return variants.some((v) => v && typeof v === "object" && isNull(v));\n}\nfunction listFor(schema, name, depth, mode, budget, owner) {\n var _a;\n const least = Math.min(Math.max(0, typeof schema.minItems === "number" ? schema.minItems : 0), MAX_LIST);\n const most = typeof schema.maxItems === "number" ? Math.max(0, schema.maxItems) : Infinity;\n if (most === 0)\n return [];\n if ((depth >= MAX_DEPTH || budget.left <= 0) && least === 0)\n return [];\n const itemName = singular(name);\n const itemOwner = itemName && !CONTAINERS.test(itemName) ? itemName : owner;\n const prefix = ((_a = schema.prefixItems) !== null && _a !== void 0 ? _a : []).slice(0, most);\n const out = prefix.map((item) => exampleFromSchema(item, itemName, depth + 1, mode, budget, itemOwner));\n const items = isRecord(schema.items) ? schema.items : undefined;\n const answer = mode === "response" && !budget.full;\n const shows = !answer || depth === 0 || (depth === 1 && CONTAINERS.test(name)) || saysSomething(items);\n const want = Math.min(most, Math.max(least, prefix.length ? prefix.length : items && shows ? 1 : 0));\n while (out.length < want) {\n if (!items) {\n out.push(null);\n continue;\n }\n const value = exampleFromSchema(items, itemName, depth + 1, mode, budget, itemOwner);\n if (answer && out.length >= least && isRecord(value) && !Object.keys(value).length)\n break;\n out.push(out.length > prefix.length ? distinct(value, out, items, mode) : value);\n }\n return out;\n}\nconst CONTAINERS = /^(data|items?|results?|list|entr(y|ie)|records?|values?|objects?|nodes?|edges?|elements?|rows?|hits?|match(e)?|contents?|resources?)$/i;\nfunction distinct(value, taken, schema, mode) {\n var _a, _b, _c, _d;\n const n = taken.length + 1;\n const free = (candidate) => !taken.some((t) => (0, fit_1.equal)(t, candidate)) && (0, fit_1.fits)(candidate, schema, mode);\n if (!taken.some((t) => (0, fit_1.equal)(t, value)))\n return value;\n const candidates = [];\n if (Array.isArray(schema.enum))\n candidates.push(...schema.enum);\n if (typeof value === "string" && isPlaceholder(value))\n candidates.push(`${value.slice(0, -1)}_${n}>`);\n if (typeof value === "string") {\n const at = value.indexOf("@");\n if (at > 0)\n candidates.push(`${value.slice(0, at)}+${n}${value.slice(at)}`);\n candidates.push(`${value}_${n}`, `${value}${n}`, `${n}${value.slice(1)}`);\n }\n else if (typeof value === "number")\n candidates.push(value + n - 1, value + (n - 1) * 10, value - (n - 1));\n else if (typeof value === "boolean")\n candidates.push(!value);\n else if (isRecord(value)) {\n const key = (_a = Object.keys(value).find((k) => k === "id" || isIdName(k))) !== null && _a !== void 0 ? _a : Object.keys(value).find((k) => typeof value[k] === "string" || typeof value[k] === "number");\n if (key !== undefined) {\n const inner = (_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : {};\n const varied = distinct(value[key], taken.flatMap((t) => (isRecord(t) ? [t[key]] : [])), inner, mode);\n candidates.push({ ...value, [key]: varied });\n }\n }\n return (_d = candidates.find(free)) !== null && _d !== void 0 ? _d : value;\n}\nconst ON_FLAGS = /^(is_?|has_?|can_?)?(enabled|active|verified|valid|available|visible|confirmed|success|successful|ok|allowed|approved|ready|supported)$/i;\nfunction booleanFor(name) {\n return ON_FLAGS.test(name.replace(/-/g, "_"));\n}\nfunction fitted(value, schema, name, depth, mode, budget, owner) {\n return (0, fit_1.fits)(value, schema, mode) ? value : conform(value, schema, mode, name, depth, budget, owner);\n}\nfunction conform(value, schema, mode = "response", name = "", depth = 0, budget = { left: NODE_BUDGET }, owner) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > HARD_DEPTH || (0, fit_1.fits)(value, schema, mode))\n return value;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return conform(value, target, mode, name, depth + 1, budget, owner);\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const variants = ((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length) ? schema.oneOf : ((_b = schema.anyOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.anyOf : undefined;\n if (variants) {\n const base = { ...schema, oneOf: undefined, anyOf: undefined };\n const ranked = variants\n .filter((v) => isRecord(v))\n .map((v) => ({ v, misses: (0, fit_1.misfits)(value, { allOf: [base, v] }, mode, 40).length }))\n .sort((a, b) => a.misses - b.misses);\n let closest;\n for (const { v } of ranked.slice(0, MAX_TRIES)) {\n const fixed = conform(value, { allOf: [base, v] }, mode, name, depth + 1, budget, owner);\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n closest !== null && closest !== void 0 ? closest : (closest = fixed);\n }\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) || closest === undefined ? made : closest;\n }\n if ((_c = schema.allOf) === null || _c === void 0 ? void 0 : _c.length) {\n let fixed = value;\n const required = requiredIn(schema);\n for (const part of [...schema.allOf, { ...schema, allOf: undefined }]) {\n if (isRecord(part))\n fixed = conform(fixed, required.length ? { ...part, required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : part, mode, name, depth + 1, budget, owner);\n }\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) ? made : fixed;\n }\n return conformOne(value, schema, mode, name, depth, budget, owner);\n}\nfunction conformOne(value, schema, mode, name, depth, budget, owner) {\n var _a, _b, _c, _d, _e;\n if ((0, fit_1.fits)(value, { ...schema, allOf: undefined, oneOf: undefined, anyOf: undefined, not: undefined }, mode))\n return value;\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const types = typesOf(schema);\n if (types.length && !(value === null && schema.nullable) && !ofType(value, schema)) {\n const typed = asType(value, schema);\n return typed !== undefined && (0, fit_1.fits)(typed, schema, mode) ? typed : fresh();\n }\n if (schema.const !== undefined && !(0, fit_1.equal)(value, schema.const))\n return schema.const;\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => (0, fit_1.equal)(e, value)))\n return enumValue(schema.enum, schema.description);\n if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null)\n return fresh();\n if (Array.isArray(value)) {\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n const items = !legacy && isRecord(schema.items) ? schema.items : undefined;\n let out = value.map((item, i) => conform(item, i < prefix.length ? prefix[i] : items, mode, singular(name), depth + 1, budget, singular(name) || owner));\n if (schema.uniqueItems === true)\n out = out.filter((item, i) => out.findIndex((other) => (0, fit_1.equal)(other, item)) === i);\n if (typeof schema.maxItems === "number")\n out = out.slice(0, Math.max(0, schema.maxItems));\n const least = Math.min(typeof schema.minItems === "number" ? schema.minItems : 0, MAX_LIST);\n while (out.length < least) {\n const index = out.length;\n const sub = index < prefix.length ? prefix[index] : items;\n const made = sub ? exampleFromSchema(sub, singular(name), depth + 1, mode, budget, singular(name) || owner) : null;\n out.push(sub ? distinct(made, out, sub, mode) : made);\n }\n return out;\n }\n if (isRecord(value)) {\n const props = (isRecord(schema.properties) ? schema.properties : {});\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n const extra = schema.additionalProperties;\n const title = (_c = schema.title) !== null && _c !== void 0 ? _c : owner;\n const out = {};\n for (const [key, item] of Object.entries(value)) {\n const prop = Object.prototype.hasOwnProperty.call(props, key) ? props[key] : undefined;\n const matched = (_d = patterns.find(([pattern]) => (0, fit_1.matchesPattern)(pattern, key))) === null || _d === void 0 ? void 0 : _d[1];\n if (!prop && !matched && extra === false)\n continue;\n const sub = (_e = prop !== null && prop !== void 0 ? prop : matched) !== null && _e !== void 0 ? _e : (isRecord(extra) ? extra : undefined);\n const optional = !(Array.isArray(schema.required) && schema.required.includes(key));\n if (item === null && sub && !allowsNull(sub) && optional)\n continue;\n if (mode === "response" && !budget.full && optional && sub && item !== null && typeof item !== "object" && !(0, fit_1.fits)(item, sub, mode)) {\n const typed = asType(item, sub);\n if (typed === undefined || !(0, fit_1.fits)(typed, sub, mode))\n continue;\n }\n setField(out, key, sub ? conform(item, sub, mode, key, depth + 1, budget, title) : item);\n }\n for (const key of Array.isArray(schema.required) ? schema.required : []) {\n if (typeof key !== "string" || key in out)\n continue;\n const prop = props[key];\n if (prop && (mode === "request" ? prop.readOnly : prop.writeOnly))\n continue;\n const sub = prop !== null && prop !== void 0 ? prop : (isRecord(extra) ? extra : undefined);\n setField(out, key, sub ? fieldValue(sub, key, depth + 1, mode, budget, title) : null);\n }\n for (const [key, prop] of Object.entries(props)) {\n if (typeof schema.minProperties !== "number" || Object.keys(out).length >= schema.minProperties)\n break;\n if (!(key in out))\n setField(out, key, exampleFromSchema(prop, key, depth + 1, mode, budget, title));\n }\n return out;\n }\n return fresh();\n}\nfunction setField(out, key, value) {\n if (key === "__proto__")\n Object.defineProperty(out, key, { value, enumerable: true, writable: true, configurable: true });\n else\n out[key] = value;\n}\nfunction asType(value, schema) {\n const types = typesOf(schema);\n if (ofType(value, schema))\n return value;\n if (typeof value === "string" && (types.includes("object") || types.includes("array"))) {\n try {\n const parsed = JSON.parse(value);\n if (ofType(parsed, schema))\n return parsed;\n }\n catch {\n }\n }\n if (types.includes("string") && Array.isArray(value) && value.length && value.every((v) => typeof v === "string" || typeof v === "number"))\n return value.join(",");\n if (types.includes("object") && Array.isArray(value) && value.length === 1 && isRecord(value[0]))\n return value[0];\n if (typeof value === "string" && value.trim() && (types.includes("number") || types.includes("integer")) && ofType(Number(value), schema))\n return Number(value);\n if (typeof value === "string" && types.includes("boolean") && /^(true|false)$/.test(value))\n return value === "true";\n if (typeof value === "number" && types.includes("string") && Number.isFinite(value))\n return String(value);\n return undefined;\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction ofType(value, schema) {\n const types = typesOf(schema);\n if (!types.length || (value === null && schema.nullable))\n return true;\n return types.some((t) => (t === "integer" ? Number.isInteger(value) : t === "number" ? typeof value === "number" : t === "object" ? isRecord(value) : t === "array" ? Array.isArray(value) : t === "null" ? value === null : typeof value === t));\n}\nfunction sharedProperties(parts) {\n const all = new Map();\n const collect = (schema, title, depth) => {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return;\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n collect(part, title, depth + 1);\n for (const [key, def] of Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {})) {\n if (!def || typeof def !== "object")\n continue;\n const entry = (_c = all.get(key)) !== null && _c !== void 0 ? _c : { defs: [] };\n if (!entry.defs.includes(def))\n entry.defs.push(def);\n entry.title = title;\n all.set(key, entry);\n }\n };\n for (const part of parts)\n collect(part, part.title, 0);\n return new Map([...all].filter(([, entry]) => entry.defs.length > 1));\n}\nfunction requiredIn(schema, depth = 0) {\n var _a;\n if (!schema || typeof schema !== "object" || depth > 4)\n return [];\n const own = Array.isArray(schema.required) ? schema.required.filter((r) => typeof r === "string") : [];\n return [...new Set([...own, ...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []).flatMap((part) => requiredIn(part, depth + 1))])];\n}\nfunction fromParts(schema, name, depth, mode, budget, owner) {\n var _a, _b, _c;\n const merged = {};\n const plain = [];\n const required = requiredIn(schema);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...(schema.properties ? [{ ...schema, allOf: undefined }] : [])].filter((part) => part && typeof part === "object");\n const again = { left: budget.left, full: budget.full };\n for (const part of parts) {\n const whole = { ...part, ...(schema.title ? { title: schema.title } : {}), ...(required.length ? { required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : {}) };\n const value = exampleFromSchema(whole, name, depth, mode, budget, owner);\n if (isRecord(value))\n Object.assign(merged, value);\n else if (value !== null && value !== undefined)\n plain.push(value);\n }\n for (const [key, { defs, title }] of sharedProperties(parts)) {\n if (!(key in merged) || defs.every((def) => (0, fit_1.fits)(merged[key], def, mode)))\n continue;\n const value = exampleFromSchema({ allOf: defs }, key, depth + 1, mode, again, (_c = (_b = schema.title) !== null && _b !== void 0 ? _b : title) !== null && _c !== void 0 ? _c : owner);\n if (value !== null && value !== undefined)\n merged[key] = value;\n }\n if (plain.length && Object.keys(merged).length === 0) {\n const fitting = [...plain].reverse().find((value) => parts.every((part) => (0, fit_1.fits)(value, part, mode)));\n if (fitting !== undefined)\n return fitting;\n for (const variant of parts.flatMap((part) => { var _a, _b; return [...((_a = part.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = part.anyOf) !== null && _b !== void 0 ? _b : [])]; })) {\n if (!isRecord(variant) || variant.type === "null")\n continue;\n const value = exampleFromSchema(variant, name, depth, mode, again, owner);\n if (value !== null && value !== undefined && parts.every((part) => (0, fit_1.fits)(value, part, mode)))\n return value;\n }\n const items = parts.flatMap((part) => (part.items && typeof part.items === "object" ? [part.items] : []));\n if (items.length > 1 && plain.some(Array.isArray))\n return exampleFromSchema({ type: "array", items: { allOf: items } }, name, depth, mode, again, owner);\n return plain[0];\n }\n return merged;\n}\nconst ENDINGS = /^(cancel+ed|cancel+ing|failed|failure|errored|error|declined|rejected|expired|deleted|voided|void|refunded|disputed|revoked|suspended|blocked|disabled|inactive|abandoned|lost|unpaid|past_due|incomplete_expired)$/i;\nfunction enumValue(values, description) {\n var _a, _b;\n const said = values.filter((v) => v !== "" && v !== null);\n const mentioned = (v) => {\n if (typeof v !== "string" || !description)\n return Infinity;\n const at = description.search(new RegExp(`[\\`\'"]${v.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}[\\`\'"]`));\n return at < 0 ? Infinity : at;\n };\n const ordered = said.map((v, i) => ({ v, i, at: mentioned(v) })).sort((a, b) => a.at - b.at || a.i - b.i).map(({ v }) => v);\n return (_b = (_a = ordered.find((v) => typeof v !== "string" || !ENDINGS.test(v))) !== null && _a !== void 0 ? _a : ordered[0]) !== null && _b !== void 0 ? _b : values[0];\n}\nfunction fromVariant(schema, variants, name, depth, mode, budget, owner) {\n var _a;\n const usable = variants.filter((v) => v && typeof v === "object" && v.type !== "null" && Object.keys(v).some((k) => !/^(description|title|nullable)$/.test(k)));\n const first = (schema.properties && usable.find((v) => v.properties || v.type === "object")) || usable[0] || variants[0];\n const exclusive = Boolean((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length);\n let made;\n for (const variant of [first, ...usable.filter((v) => v !== first)].slice(0, MAX_TRIES)) {\n const value = fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner);\n if (made === undefined)\n made = value;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n if (mode === "response" && !budget.full) {\n const full = { left: budget.left, full: true };\n const value = fromVariant(schema, variants, name, depth, mode, full, owner);\n budget.left = full.left;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n return made;\n}\nfunction fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner) {\n var _a, _b, _c, _d, _e;\n if (variant && typeof variant === "object" && !describesValue(variant)) {\n const required = [...new Set([...(Array.isArray(schema.required) ? schema.required : []), ...(Array.isArray(variant.required) ? variant.required : [])])];\n const others = exclusive ? new Set(variants.filter((v) => v !== variant && isRecord(v) && Array.isArray(v.required)).flatMap((v) => v.required).filter((k) => !required.includes(k))) : new Set();\n const properties = schema.properties && others.size ? Object.fromEntries(Object.entries(schema.properties).filter(([key]) => !others.has(key))) : schema.properties;\n return exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined, ...(properties ? { properties } : {}), ...(required.length ? { required } : {}) }, name, depth, mode, budget, owner);\n }\n const value = exampleFromSchema(variant, name, depth, mode, budget, owner);\n if (!value || typeof value !== "object" || Array.isArray(value))\n return value;\n const out = schema.properties ? { ...exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined }, name, depth, mode, budget, owner), ...value } : { ...value };\n const discriminator = schema.discriminator;\n const property = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;\n const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;\n if (property && isRecord(mapping) && !((_b = (_a = variant.properties) === null || _a === void 0 ? void 0 : _a[property]) === null || _b === void 0 ? void 0 : _b.enum) && ((_d = (_c = variant.properties) === null || _c === void 0 ? void 0 : _c[property]) === null || _d === void 0 ? void 0 : _d.const) === undefined) {\n const entries = Object.entries(mapping);\n const named = entries.find(([, target]) => variant.title && typeof target === "string" && target.split("/").pop() === variant.title);\n const entry = (_e = named !== null && named !== void 0 ? named : entries[variants.indexOf(variant)]) !== null && _e !== void 0 ? _e : entries[0];\n if (entry)\n out[property] = entry[0];\n }\n return out;\n}\nconst VALUE_KEYWORDS = ["type", "properties", "items", "prefixItems", "allOf", "oneOf", "anyOf", "enum", "const", "example", "examples", "default", "format", "pattern", "additionalProperties", "$ref", "x-circular"];\nfunction describesValue(schema) {\n return VALUE_KEYWORDS.some((key) => key in schema);\n}\nconst MAX_OPTIONAL = 3;\nconst TELLING_NAMES = /^(to|from|subject|text|html|body|content|message|title|name|email|description|amount|currency|quantity|customer|price|product|channel|phone|url|\\w+_url)$/i;\nfunction telling(props, required) {\n const must = props.filter(([key]) => required.has(key));\n const rank = ([key, prop]) => (TELLING_NAMES.test(key) || isIdName(key) ? 0 : 2) + (looksReal(key, prop) ? 0 : 1);\n const optional = props\n .filter(([key]) => !required.has(key))\n .map((entry, i) => ({ entry, i, rank: rank(entry) }))\n .sort((a, b) => a.rank - b.rank || a.i - b.i)\n .slice(0, must.length ? MAX_OPTIONAL : MAX_OPTIONAL + 1)\n .sort((a, b) => a.i - b.i);\n return [...must, ...optional.map((o) => o.entry)];\n}\nfunction looksReal(key, prop) {\n if (!prop || typeof prop !== "object")\n return false;\n if (prop.example !== undefined || prop.examples !== undefined || prop.default !== undefined || prop.enum || prop.const !== undefined)\n return true;\n const type = Array.isArray(prop.type) ? prop.type.find((t) => t !== "null") : prop.type;\n if ((type && type !== "string") || prop.format || prop.pattern)\n return true;\n return saysWhatItHolds(key, prop);\n}\nfunction isEmpty(value) {\n return value === undefined || (Array.isArray(value) && value.length === 0) || (isRecord(value) && Object.keys(value).length === 0);\n}\nconst WHOLE_NUMBER = /(^|[_-])(number|num|no|index|idx|page|position|pos|id|count|version|year|port|rank|level|step|line|row|column|col|size)$|[a-z0-9](Number|Num|Index|Page|Position|Id|Count|Version|Year|Port|Rank|Level|Step|Line|Row|Column|Size)$|^(number|num|index|page|position|id|count|version|year|port|rank|level|step|line|row|column|size|offset|depth)$/;\nfunction numberFor(schema, name, integer) {\n const lower = name.toLowerCase();\n const step = integer ? 1 : 0.5;\n let value;\n if (/(created|updated|timestamp|_at$|time)/.test(lower) || /[a-z0-9]At$/.test(name))\n value = 1767225600;\n else if (/(amount|price|total|cost|balance)/.test(lower))\n value = integer ? 2000 : 20.0;\n else if (/(quantity|count|qty)/.test(lower))\n value = 1;\n else if (/(limit|page_size|per_page)/.test(lower))\n value = 10;\n else if (/(retry|seconds|delay)/.test(lower))\n value = 30;\n else\n value = integer || WHOLE_NUMBER.test(name) ? 1 : 1.5;\n if (schema.minimum !== undefined && value < schema.minimum)\n value = schema.minimum;\n if (schema.maximum !== undefined && value > schema.maximum)\n value = schema.maximum;\n const exclusiveMin = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.exclusiveMinimum === true ? schema.minimum : undefined;\n const exclusiveMax = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.exclusiveMaximum === true ? schema.maximum : undefined;\n if (exclusiveMin !== undefined && value <= exclusiveMin)\n value = exclusiveMin + step;\n if (exclusiveMax !== undefined && value >= exclusiveMax)\n value = exclusiveMax - step;\n return value;\n}\nconst HOOKISH = /(webhook|callback|hook|notif)/i;\nfunction stringFor(schema, name, owner) {\n var _a, _b;\n switch (schema.format) {\n case "date-time":\n return "2026-01-01T12:00:00Z";\n case "date":\n return "2026-01-01";\n case "time":\n return "12:00:00Z";\n case "duration":\n return "PT1H";\n case "email":\n case "idn-email":\n return `${(name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "") || "email").toLowerCase()}@example.com`;\n case "uri":\n case "url":\n case "iri":\n case "uri-reference":\n case "iri-reference":\n return HOOKISH.test(name) ? "https://example.com/webhooks" : "https://example.com";\n case "uri-template":\n return "https://example.com/{id}";\n case "hostname":\n case "idn-hostname":\n return "example.com";\n case "uuid":\n return name === "id" && owner ? uuidLike(owner) : isIdName(name) ? uuidLike(name) : exports.PLACEHOLDER_UUID;\n case "ipv4":\n return "203.0.113.10";\n case "ipv6":\n return "2001:db8::10";\n case "byte":\n return "aGVsbG8=";\n case "binary":\n return exports.BINARY_PLACEHOLDER;\n case "password":\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n case "regex":\n return "^[a-z]+$";\n case "json-pointer":\n return "/data";\n }\n if (schema.contentMediaType && !schema.contentEncoding) {\n if (/json/i.test(schema.contentMediaType))\n return JSON.stringify(schema.contentSchema ? exampleFromSchema(schema.contentSchema, name) : {});\n return exports.BINARY_PLACEHOLDER;\n }\n const value = sized((_a = namedValue(name, schema, owner)) !== null && _a !== void 0 ? _a : placeholder(name || "value"), schema);\n const pattern = schema.pattern;\n if (typeof pattern !== "string")\n return value;\n const told = (0, fit_1.patternVerdict)(pattern, value);\n if (told === true)\n return value;\n const patterned = patternExample(pattern);\n if (patterned)\n return patterned;\n const shapes = [idLike(name), "12345678901", "+15555550123", "email@example.com", "https://example.com", "example", "EXAMPLE", "Example", "1", "a", "A1"];\n const fitting = shapes.map((shape) => sized(shape, schema)).find((shape) => (0, fit_1.patternVerdict)(pattern, shape) === true);\n if (fitting !== undefined)\n return fitting;\n return (_b = (told === undefined ? shapeNamed(name, schema) : undefined)) !== null && _b !== void 0 ? _b : value;\n}\nfunction shapeNamed(name, schema) {\n const lower = name.toLowerCase();\n const shape = /phone|fax|mobile|(^|_)tel(_|$)|msisdn/.test(lower) ? "+15555550123" : /e-?mail/.test(lower) ? "email@example.com" : /(^|_)(url|uri|link|href|website)$|[a-z](Url|Uri)$/i.test(name) ? "https://example.com" : undefined;\n return shape === undefined ? undefined : sized(shape, schema);\n}\nfunction sized(value, schema) {\n let out = value;\n const held = isPlaceholder(out);\n if (schema.maxLength !== undefined && out.length > schema.maxLength)\n out = held && schema.maxLength >= 3 ? `${out.slice(0, schema.maxLength - 1)}>` : out.slice(0, schema.maxLength);\n if (schema.minLength !== undefined && out.length < schema.minLength)\n out = held ? `${out.slice(0, -1).padEnd(schema.minLength - 1, "_")}>` : out.padEnd(schema.minLength, "x");\n return out;\n}\nfunction placeholder(name) {\n const clean = name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "");\n return `<${clean.slice(0, 60) || "value"}>`;\n}\nfunction isPlaceholder(value) {\n return typeof value === "string" && /^<[A-Za-z0-9_.-]{1,64}>$/.test(value);\n}\nexports.PLACEHOLDER_UUID = "00000000-0000-4000-8000-000000000000";\nfunction namedValue(name, schema, owner) {\n var _a, _b;\n const lower = name.toLowerCase().replace(/-/g, "_");\n const about = ((_a = schema.description) !== null && _a !== void 0 ? _a : "").toLowerCase();\n if (lower === "id" && owner)\n return idLike(owner);\n if (isIdName(name) || /\\bID\\b/.test((_b = schema.description) !== null && _b !== void 0 ? _b : ""))\n return idLike(name);\n if ((lower === "object" || lower === "type") && schema.title)\n return schema.title.toLowerCase();\n if ((lower === "name" || lower.endsWith("_name")) && (/\\b(domain|hostname)s?\\b/.test(about) || nounOf(owner) === "domain"))\n return "example.com";\n if (/^(domain|host|hostname)$/.test(lower))\n return "example.com";\n if (/(^|_)password$/.test(lower))\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n return undefined;\n}\nconst TELLING_FIELD = [\n /^(from|sender|to|recipients?|reply_?to|cc|bcc|subject|title|headline|html|text|body|content|message|comment|notes?|caption|prompt|input|slug|language|lang|locale|tz|locality|date|object|type|domain|host|hostname)$/,\n /email|currency|phone|country|url|uri|status|description/,\n /^(first_?name|given_?name|last_?name|family_?name|surname|company|company_?name|business_?name|organi[sz]ation(_?name)?|user_?name|handle|login|screen_?name)$/,\n /(^|_)(name|date|fax|city|state|province|postal_?code|zip|zip_?code|postcode|street|line_?[12]|address_?(line_?)?[12]|time_?zone|colou?r|password)$/,\n /(_at|_time|^time|timestamp)$/,\n];\nfunction saysWhatItHolds(name, schema) {\n var _a;\n const lower = name.toLowerCase().replace(/-/g, "_");\n return isIdName(name) || /\\bID\\b/.test((_a = schema.description) !== null && _a !== void 0 ? _a : "") || TELLING_FIELD.some((re) => re.test(lower));\n}\nfunction nounOf(owner) {\n const words = (owner !== null && owner !== void 0 ? owner : "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((w) => w && !/^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/.test(w));\n return words.length ? singular(words.slice(-2).join("_")) : undefined;\n}\nfunction patternExample(pattern) {\n let whole;\n try {\n whole = new RegExp(pattern);\n }\n catch {\n return undefined;\n }\n const readable = [pattern, ...(REPEATED_GROUP.test(pattern) ? [] : [withoutLookarounds(pattern)])];\n for (const text of readable) {\n if (text === undefined)\n continue;\n const node = parsePattern(text);\n if (!node)\n continue;\n const value = sample(node, { next: 0 });\n if (value !== undefined && value.length <= 200 && whole.test(value))\n return value;\n }\n return undefined;\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nfunction withoutLookarounds(pattern) {\n if (!/\\(\\?<?[=!]/.test(pattern))\n return undefined;\n let out = "";\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === "\\\\") {\n out += pattern.slice(i, i + 2);\n i++;\n continue;\n }\n if (/^\\(\\?<?[=!]/.test(pattern.slice(i, i + 4))) {\n let depth = 0;\n let j = i;\n for (; j < pattern.length; j++) {\n if (pattern[j] === "\\\\")\n j++;\n else if (pattern[j] === "[") {\n j = pattern.indexOf("]", j + 2);\n if (j < 0)\n return undefined;\n }\n else if (pattern[j] === "(")\n depth++;\n else if (pattern[j] === ")" && --depth === 0)\n break;\n }\n if (j >= pattern.length)\n return undefined;\n i = j;\n continue;\n }\n out += pattern[i];\n }\n return out;\n}\nconst POOLS = [[..."1a2b3c4d5e6f7a8b9c0d"], [..."ABCDEFGHJKxyz_-."], [..."LMNPQRSTUVWXYZghijklmnopqrstuvw+=:/@~!*\'(),;$&? "]];\nconst CONTROL = { t: "\\t", n: "\\n", r: "\\r", v: "\\v", f: "\\f" };\nfunction parsePattern(pattern) {\n let i = 0;\n const fail = () => {\n i = pattern.length + 1;\n return undefined;\n };\n const choice = () => {\n var _a;\n const options = [];\n let parts = [];\n while (i < pattern.length && pattern[i] !== ")") {\n const c = pattern[i];\n if (c === "|") {\n options.push({ kind: "sequence", parts });\n parts = [];\n i++;\n continue;\n }\n let atom;\n if (c === "^" || c === "$") {\n i++;\n continue;\n }\n else if (c === "(") {\n if (pattern.startsWith("(?:", i))\n i += 3;\n else if (pattern[i + 1] === "?")\n return fail();\n else\n i++;\n atom = choice();\n if (pattern[i] !== ")")\n return fail();\n i++;\n }\n else if (c === "[") {\n const close = pattern.indexOf("]", pattern[i + 1] === "]" ? i + 2 : i + 1);\n if (close < 0)\n return fail();\n const text = pattern.slice(i, close + 1);\n i = close + 1;\n let set;\n try {\n set = new RegExp(`^${text}$`);\n }\n catch {\n return fail();\n }\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else if (c === "\\\\") {\n const e = pattern[i + 1];\n i += 2;\n if (e === undefined || /[0-9bBkpPc]/.test(e))\n return fail();\n if (/[dwsDWS]/.test(e)) {\n const set = new RegExp(`^\\\\${e}$`);\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else {\n const code = (e === "x" && pattern.slice(i).match(/^[0-9a-fA-F]{2}/)) || (e === "u" && pattern.slice(i).match(/^[0-9a-fA-F]{4}/));\n if (code)\n i += code[0].length;\n const literal = code ? String.fromCharCode(parseInt(code[0], 16)) : ((_a = CONTROL[e]) !== null && _a !== void 0 ? _a : e);\n atom = { kind: "chars", accepts: (ch) => ch === literal, literal };\n }\n }\n else if (c === ".") {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch !== "\\n", literal: "." };\n }\n else if ("*+?{".includes(c)) {\n return fail();\n }\n else {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch === c, literal: c };\n }\n if (!atom)\n return fail();\n const q = pattern.slice(i).match(/^(\\*|\\+|\\?|\\{(\\d+)(?:(,)(\\d*))?\\})\\??/);\n if (q) {\n i += q[0].length;\n const min = q[2] !== undefined ? Number(q[2]) : q[1] === "+" ? 1 : 0;\n const max = q[2] !== undefined ? (q[3] ? (q[4] ? Number(q[4]) : Infinity) : min) : q[1] === "?" ? 1 : Infinity;\n const count = q[1] === "?" ? 1 : Math.min(Math.max(min, Math.min(10, max)), 64);\n if (count < min)\n return fail();\n atom = { kind: "repeat", node: atom, count };\n }\n parts.push(atom);\n }\n options.push({ kind: "sequence", parts });\n return options.length === 1 ? options[0] : { kind: "choice", options };\n };\n const node = choice();\n return i === pattern.length ? node : undefined;\n}\nfunction sample(node, state) {\n var _a;\n switch (node.kind) {\n case "chars": {\n if (node.literal !== undefined)\n return node.literal;\n for (const pool of POOLS) {\n for (let n = 0; n < pool.length; n++) {\n const ch = pool[(state.next + n) % pool.length];\n if (node.accepts(ch)) {\n state.next = (state.next + n + 1) % pool.length;\n return ch;\n }\n }\n }\n return undefined;\n }\n case "sequence": {\n let out = "";\n for (const part of node.parts) {\n const value = sample(part, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "repeat": {\n let out = "";\n for (let n = 0; n < node.count; n++) {\n const value = sample(node.node, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "choice": {\n const values = node.options.map((option) => sample(option, { ...state })).filter((v) => v !== undefined);\n return (_a = values.find((v) => v.length > 1)) !== null && _a !== void 0 ? _a : values[0];\n }\n }\n}\nfunction isIdName(name) {\n const lower = name.toLowerCase();\n return lower === "id" || lower.endsWith("_id") || lower.endsWith("-id") || /[a-z0-9]Id$/.test(name);\n}\nconst ID_NOISE = /^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|output|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/;\nfunction idLike(name) {\n const words = idWords(name);\n return words.length ? `<${words.join("_")}_id>` : "<id>";\n}\nfunction uuidLike(name) {\n const words = idWords(name);\n const n = 1 + (seedHash(`uuid:${words.length ? words.join("_") : "obj"}`) % 9999);\n return `${exports.PLACEHOLDER_UUID.slice(0, -12)}${String(n).padStart(12, "0")}`;\n}\nfunction idWords(name) {\n const all = name\n .replace(/[_-]?(uu|s|g)?id$/i, "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z]+/)\n .filter(Boolean);\n const kept = all.filter((w) => !ID_NOISE.test(w));\n return (kept.length ? kept : all).map((w, i, list) => (i === list.length - 1 ? singular(w) : w));\n}\nfunction seedHash(seed) {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++)\n h = Math.imul(h ^ seed.charCodeAt(i), 16777619) >>> 0;\n return h || 1;\n}\nfunction singular(word) {\n if (/ies$/i.test(word))\n return word.slice(0, -3) + "y";\n if (/(ses|xes|ches|shes)$/i.test(word))\n return word.slice(0, -2);\n if (/s$/i.test(word) && !/ss$/i.test(word))\n return word.slice(0, -1);\n return word;\n}\n\n}, {"./fit":"lib/oas/fit"}],\n"lib/oas/fit": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CIRCULAR_TARGET = void 0;\nexports.circularTarget = circularTarget;\nexports.fits = fits;\nexports.misfits = misfits;\nexports.typesOf = typesOf;\nexports.equal = equal;\nexports.patternVerdict = patternVerdict;\nexports.matchesPattern = matchesPattern;\nexports.formatFits = formatFits;\nexports.CIRCULAR_TARGET = "x-circular-target";\nfunction circularTarget(schema) {\n const target = schema[exports.CIRCULAR_TARGET];\n return target && typeof target === "object" ? target : undefined;\n}\nconst MAX_DEPTH = 40;\nconst MAX_STEPS = 50000;\nfunction fits(value, schema, mode = "response") {\n return misfits(value, schema, mode, 1).length === 0;\n}\nfunction misfits(value, schema, mode = "response", limit = 20) {\n const out = [];\n check(value, schema, [], 0, out, { counter: { steps: 0 }, limit, mode });\n return out;\n}\nfunction check(value, schema, path, depth, out, state) {\n var _a, _b, _c;\n if (out.length >= state.limit || schema === undefined || schema === true || depth > MAX_DEPTH || ++state.counter.steps > MAX_STEPS)\n return;\n if (schema === false)\n return void out.push({ path, keyword: "false" });\n if (typeof schema !== "object" || schema === null)\n return;\n const miss = (keyword, at = path) => void out.push({ path: at, keyword });\n const target = circularTarget(schema);\n if (target)\n return check(value, target, path, depth + 1, out, state);\n const nullable = schema.nullable === true;\n const types = typesOf(schema);\n if (value === null && nullable)\n return;\n if (types.length && !types.some((t) => isType(value, t)))\n return miss("type");\n if (schema.const !== undefined && !equal(value, schema.const))\n miss("const");\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => equal(e, value)))\n miss("enum");\n if (typeof value === "string") {\n const length = [...value].length;\n if (typeof schema.minLength === "number" && length < schema.minLength)\n miss("minLength");\n if (typeof schema.maxLength === "number" && length > schema.maxLength)\n miss("maxLength");\n if (typeof schema.pattern === "string" && !matchesPattern(schema.pattern, value))\n miss("pattern");\n if (typeof schema.format === "string" && !formatFits(schema.format, value))\n miss("format");\n }\n else if (typeof value === "number") {\n const { minimum, maximum, exclusiveMinimum: exMin, exclusiveMaximum: exMax } = schema;\n if (typeof minimum === "number" && (exMin === true ? value <= minimum : value < minimum))\n miss("minimum");\n if (typeof maximum === "number" && (exMax === true ? value >= maximum : value > maximum))\n miss("maximum");\n if (typeof exMin === "number" && value <= exMin)\n miss("exclusiveMinimum");\n if (typeof exMax === "number" && value >= exMax)\n miss("exclusiveMaximum");\n if (typeof schema.multipleOf === "number" && schema.multipleOf > 0 && !multipleOf(value, schema.multipleOf))\n miss("multipleOf");\n if (schema.format === "int32" && !(Number.isInteger(value) && value >= -(2 ** 31) && value < 2 ** 31))\n miss("format");\n }\n else if (Array.isArray(value)) {\n if (typeof schema.minItems === "number" && value.length < schema.minItems)\n miss("minItems");\n if (typeof schema.maxItems === "number" && value.length > schema.maxItems)\n miss("maxItems");\n if (schema.uniqueItems === true && new Set(value.map((v) => canonical(v))).size < value.length)\n miss("uniqueItems");\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n value.forEach((item, i) => {\n if (i < prefix.length)\n check(item, prefix[i], [...path, i], depth + 1, out, state);\n else if (!legacy && isSchema(schema.items))\n check(item, schema.items, [...path, i], depth + 1, out, state);\n });\n }\n else if (isRecord(value)) {\n const props = isRecord(schema.properties) ? schema.properties : {};\n const omitted = (key) => {\n const prop = props[key];\n return isSchema(prop) && (state.mode === "request" ? prop.readOnly === true : prop.writeOnly === true);\n };\n if (Array.isArray(schema.required))\n for (const key of schema.required)\n if (typeof key === "string" && !(key in value) && !omitted(key))\n miss("required", [...path, key]);\n const count = Object.keys(value).length;\n if (typeof schema.minProperties === "number" && count < schema.minProperties)\n miss("minProperties");\n if (typeof schema.maxProperties === "number" && count > schema.maxProperties)\n miss("maxProperties");\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n for (const [key, item] of Object.entries(value)) {\n if (out.length >= state.limit)\n break;\n let known = false;\n if (Object.prototype.hasOwnProperty.call(props, key)) {\n known = true;\n check(item, props[key], [...path, key], depth + 1, out, state);\n }\n for (const [pattern, sub] of patterns) {\n if (matchesPattern(pattern, key)) {\n known = true;\n check(item, sub, [...path, key], depth + 1, out, state);\n }\n }\n if (!known) {\n const extra = schema.additionalProperties;\n if (extra === false)\n miss("additionalProperties", [...path, key]);\n else if (isSchema(extra))\n check(item, extra, [...path, key], depth + 1, out, state);\n }\n }\n }\n for (const part of (_c = schema.allOf) !== null && _c !== void 0 ? _c : [])\n if (isSchema(part))\n check(value, part, path, depth + 1, out, state);\n if (Array.isArray(schema.anyOf) && schema.anyOf.length && !schema.anyOf.some((v) => fitsAt(value, v, depth, state)))\n miss("anyOf");\n if (Array.isArray(schema.oneOf) && schema.oneOf.length) {\n const fitting = countIn(value, schema.oneOf, depth, state, 2);\n if (fitting !== 1)\n miss(fitting === 0 ? "oneOf" : "oneOf-many");\n }\n if (isSchema(schema.not) && fitsAt(value, schema.not, depth, state))\n miss("not");\n const conditional = schema;\n if (isSchema(conditional.if)) {\n const branch = fitsAt(value, conditional.if, depth, state) ? conditional.then : conditional.else;\n if (isSchema(branch))\n check(value, branch, path, depth + 1, out, state);\n }\n}\nfunction fitsAt(value, schema, depth, state) {\n const found = [];\n check(value, schema, [], depth + 1, found, { counter: state.counter, limit: 1, mode: state.mode });\n return found.length === 0;\n}\nfunction countIn(value, variants, depth, s, stop) {\n let n = 0;\n for (const v of variants) {\n if (isSchema(v) && fitsAt(value, v, depth, s) && ++n >= stop)\n break;\n }\n return n;\n}\nfunction isSchema(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction isType(value, type) {\n switch (type) {\n case "integer":\n return typeof value === "number" && Number.isInteger(value);\n case "number":\n return typeof value === "number" && Number.isFinite(value);\n case "string":\n return typeof value === "string";\n case "boolean":\n return typeof value === "boolean";\n case "array":\n return Array.isArray(value);\n case "object":\n return isRecord(value);\n case "null":\n return value === null;\n default:\n return true;\n }\n}\nfunction multipleOf(value, step) {\n const quotient = value / step;\n return Math.abs(quotient - Math.round(quotient)) < 1e-9;\n}\nfunction equal(a, b) {\n return canonical(a) === canonical(b);\n}\nfunction canonical(value) {\n var _a;\n if (Array.isArray(value))\n return `[${value.map(canonical).join(",")}]`;\n if (isRecord(value))\n return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical(value[k])}`).join(",")}}`;\n return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : "undefined";\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nconst compiled = new Map();\nfunction patternVerdict(pattern, value) {\n if (value.length > 40 || REPEATED_GROUP.test(pattern))\n return undefined;\n const re = compiledPattern(pattern);\n return re === null ? undefined : re.test(value);\n}\nfunction matchesPattern(pattern, value) {\n if (value.length > 2000 || REPEATED_GROUP.test(pattern))\n return true;\n const re = compiledPattern(pattern);\n return re === null || re.test(value);\n}\nfunction compiledPattern(pattern) {\n let re = compiled.get(pattern);\n if (re === undefined) {\n try {\n re = new RegExp(pattern, "u");\n }\n catch {\n try {\n re = new RegExp(pattern);\n }\n catch {\n re = null;\n }\n }\n if (compiled.size > 2000)\n compiled.clear();\n compiled.set(pattern, re);\n }\n return re;\n}\nconst DATE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst TIME = /^(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?(z|[+-]\\d{2}(:?\\d{2})?)$/i;\nconst FORMATS = {\n "date-time": (text) => {\n const [date, time] = text.split(/t|\\s/i);\n return time !== undefined && FORMATS.date(date) && FORMATS.time(time);\n },\n date: (text) => {\n const m = text.match(DATE);\n if (!m)\n return false;\n const month = Number(m[2]);\n const day = Number(m[3]);\n return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(Number(m[1]), month, 0)).getUTCDate();\n },\n time: (text) => {\n const m = text.match(TIME);\n return Boolean(m) && Number(m[1]) <= 23 && Number(m[2]) <= 59 && Number(m[3]) <= 60;\n },\n email: (text) => /^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(text),\n uri: (text) => /^[a-z][a-z0-9+.-]*:[^\\s]*$/i.test(text) && !/\\s/.test(text),\n url: (text) => /^[a-z][a-z0-9+.-]*:\\/\\/[^\\s]+$/i.test(text),\n "uri-reference": (text) => !/[\\s<>"\\\\^`{}|]/.test(text),\n "uri-template": (text) => !/[\\s<>"\\\\^`|]/.test(text),\n uuid: (text) => /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(text),\n ipv4: (text) => /^((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test(text),\n ipv6: (text) => { var _a; return /^[0-9a-f:.]+$/i.test(text) && text.includes(":") && ((_a = text.match(/::/g)) !== null && _a !== void 0 ? _a : []).length <= 1; },\n hostname: (text) => text.length <= 253 && /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\\.?$/i.test(text),\n byte: (text) => /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text),\n duration: (text) => /^P(?!$)(\\d+(?:\\.\\d+)?Y)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?W)?(\\d+(?:\\.\\d+)?D)?(T(?=\\d)(\\d+(?:\\.\\d+)?H)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?S)?)?$/.test(text),\n regex: (text) => {\n try {\n new RegExp(text);\n return true;\n }\n catch {\n return false;\n }\n },\n "json-pointer": (text) => /^(?:\\/(?:[^~/]|~0|~1)*)*$/.test(text),\n};\nfunction formatFits(format, text) {\n const test = FORMATS[format];\n return test ? test(text) : true;\n}\n\n}, {}],\n"lib/text": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.cut = cut;\nexports.firstSentence = firstSentence;\nexports.wellFormed = wellFormed;\nexports.clip = clip;\nexports.plainText = plainText;\nfunction cut(text, max) {\n const end = Math.max(0, max);\n const last = text.charCodeAt(end - 1);\n return text.slice(0, last >= 0xd800 && last <= 0xdbff ? end - 1 : end);\n}\nfunction firstSentence(text) {\n if (!text)\n return undefined;\n const plain = text.replace(/<[^<>]+>/g, "").replace(/\\s+/g, " ").trim();\n const match = plain.match(/^(.{1,90}?[.!?])(\\s|$)/);\n return match ? match[1] : cut(plain, 90);\n}\nconst HALVES = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDFFF]/g;\nfunction wellFormed(text) {\n return text.replace(HALVES, (c) => (c.length === 2 ? c : ""));\n}\nfunction clip(text, max) {\n return text.length > max ? `${cut(text, max - 1)}\u2026` : text;\n}\nfunction plainText(markdown) {\n return markdown\n .replace(/<[^>]+>/g, " ")\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\*\\*|__|`/g, "")\n .replace(/(^|\\s)[*_]([^*_\\s][^*_]*?)[*_](?=[\\s.,;:!?)]|$)/g, "$1$2")\n .replace(/^\\s{0,3}(#{1,6}|>)\\s+/gm, "")\n .replace(/\\s+/g, " ")\n .trim();\n}\n\n}, {}]\n};\nvar cache = {};\nfunction load(id) {\n var m = cache[id];\n if (m) return m.exports;\n m = cache[id] = { exports: {} };\n defs[id][0](m, m.exports, function (spec) { return load(defs[id][1][spec]); });\n return m.exports;\n}\nload("lib/embed/player");\n})();';
|
|
15662
|
+
var PLAYER_SCRIPT = '(function () {\n"use strict";\nvar defs = {\n"lib/embed/player": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nconst frame_1 = require("../render/frame");\nconst timing_1 = require("../storyboard/timing");\nconst ICONS = {\n play: \'<path d="M8 5.2v13.6a.6.6 0 0 0 .9.5l10.6-6.8a.6.6 0 0 0 0-1L8.9 4.7a.6.6 0 0 0-.9.5z" fill="currentColor"/>\',\n pause: \'<path d="M7 5h3.2v14H7zM13.8 5H17v14h-3.2z" fill="currentColor"/>\',\n replay: \'<path d="M19.5 11.5A7.5 7.5 0 1 0 17.3 17M19.5 5v6.5H13" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n prev: \'<path d="M6.5 5.5v13M17.5 6.2v11.6a.5.5 0 0 1-.8.4l-8.3-5.8a.5.5 0 0 1 0-.8l8.3-5.8a.5.5 0 0 1 .8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n next: \'<path d="M17.5 5.5v13M6.5 6.2v11.6a.5.5 0 0 0 .8.4l8.3-5.8a.5.5 0 0 0 0-.8L7.3 5.8a.5.5 0 0 0-.8.4z" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n copy: \'<path d="M9 9.5h9.5v10H9zM6 15.5H5.5v-10h9.5V6" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n expand: \'<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>\',\n};\nconst icon = (name) => `<svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true">${ICONS[name]}</svg>`;\nfunction fmt(ms) {\n const s = Math.floor(ms / 1000);\n return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;\n}\nfunction button(label, name, className = "") {\n const b = document.createElement("button");\n b.type = "button";\n b.className = className;\n b.setAttribute("aria-label", label);\n b.title = label;\n b.innerHTML = icon(name);\n return b;\n}\nconst SITE = "https://integrationtour.com/";\nfunction credit(aspect) {\n const a = document.createElement("a");\n a.className = "credit";\n a.href = SITE;\n a.target = "_blank";\n a.rel = "noopener";\n a.setAttribute("aria-label", `${frame_1.WATERMARK} (opens in a new tab)`);\n a.addEventListener("click", (e) => e.stopPropagation());\n place(a, aspect, (0, frame_1.watermarkBox)(aspect));\n return a;\n}\nfunction place(link, aspect, box) {\n const size = (0, frame_1.sizeFor)(aspect);\n const pad = 8;\n const share = (value, of) => `${((value / of) * 100).toFixed(3)}%`;\n link.style.left = share(box.x - pad, size.width);\n link.style.top = share(box.y - pad, size.height);\n link.style.width = share(box.w + 2 * pad, size.width);\n link.style.height = share(box.h + 2 * pad, size.height);\n}\nfunction fit(link, frame, aspect) {\n const text = frame.querySelector("svg > text:last-child");\n if (!(text instanceof SVGTextElement) || text.textContent !== frame_1.WATERMARK)\n return false;\n let width = 0;\n try {\n width = text.getComputedTextLength();\n }\n catch {\n }\n if (!(width > 0))\n return false;\n const box = (0, frame_1.watermarkBox)(aspect);\n place(link, aspect, { ...box, x: box.x + box.w - width, w: width });\n return true;\n}\nfunction start(root, sb) {\n const total = (0, timing_1.totalDuration)(sb);\n const starts = (0, frame_1.sceneStarts)(sb);\n let time = 0;\n let playing = false;\n let last = null;\n const stage = document.createElement("div");\n stage.className = `stage ${sb.settings.aspect === "9:16" ? "portrait" : sb.settings.aspect === "1:1" ? "square" : "wide"}`;\n const frame = document.createElement("div");\n frame.setAttribute("role", "img");\n stage.append(frame);\n const link = sb.settings.watermark ? credit(sb.settings.aspect) : undefined;\n if (link)\n stage.append(link);\n let fitted = false;\n const controls = document.createElement("div");\n controls.className = "controls";\n const prev = button("Previous scene", "prev");\n const play = button("Play", "play", "play");\n const next = button("Next scene", "next");\n const seek = document.createElement("input");\n seek.type = "range";\n seek.min = "0";\n seek.max = String(total);\n seek.step = "50";\n seek.setAttribute("aria-label", "Seek");\n const clock = document.createElement("span");\n clock.className = "time";\n const copy = button("Copy this payload as JSON", "copy");\n const full = button("Full screen", "expand");\n controls.append(prev, play, next, seek, clock, copy, full);\n const status = document.createElement("p");\n status.className = "status";\n status.setAttribute("role", "status");\n root.append(stage, controls, status);\n root.tabIndex = 0;\n const draw = () => {\n const at = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n frame.innerHTML = (0, frame_1.renderFrame)(sb, time);\n frame.setAttribute("aria-label", at.scene.caption);\n if (link && !fitted)\n fitted = fit(link, frame, sb.settings.aspect);\n seek.value = String(Math.round(time));\n clock.textContent = `${fmt(time)} / ${fmt(total)} \xB7 ${at.index + 1}/${at.count}`;\n const ended = !playing && time >= total;\n play.innerHTML = icon(playing ? "pause" : ended ? "replay" : "play");\n play.setAttribute("aria-label", playing ? "Pause" : ended ? "Replay" : "Play");\n prev.disabled = at.index === 0;\n next.disabled = at.index === at.count - 1;\n };\n const tick = (now) => {\n if (!playing)\n return;\n time = Math.min(total, time + (last === null ? 0 : now - last));\n last = now;\n if (time >= total)\n playing = false;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const toggle = () => {\n if (!playing && time >= total)\n time = 0;\n playing = !playing;\n last = null;\n draw();\n if (playing)\n requestAnimationFrame(tick);\n };\n const step = (delta) => {\n const index = Math.max(0, Math.min(starts.length - 1, (0, frame_1.sceneAt)(sb, Math.min(time, total)).index + delta));\n playing = false;\n time = starts[index] + Math.min(900, total - starts[index]);\n draw();\n };\n const payload = () => {\n const { scene, progress } = (0, frame_1.sceneAt)(sb, Math.min(time, total));\n if (scene.kind === "call" || scene.kind === "auth")\n return progress < 0.52 ? scene.request : scene.response;\n return scene.kind === "webhook" ? scene.payload : undefined;\n };\n const say = (text) => {\n status.textContent = text;\n window.setTimeout(() => status.textContent === text && (status.textContent = ""), 2500);\n };\n copy.addEventListener("click", async () => {\n const value = payload();\n if (value === undefined)\n return say("This scene has no payload to copy.");\n const text = typeof value === "string" ? value : JSON.stringify(value, null, 2);\n try {\n await navigator.clipboard.writeText(text);\n }\n catch {\n const area = document.createElement("textarea");\n area.value = text;\n document.body.append(area);\n area.select();\n document.execCommand("copy");\n area.remove();\n }\n say("Copied the payload as JSON.");\n });\n full.addEventListener("click", () => {\n if (document.fullscreenElement)\n void document.exitFullscreen();\n else if (root.requestFullscreen)\n void root.requestFullscreen().catch(() => root.classList.toggle("filled"));\n else\n root.classList.toggle("filled");\n });\n play.addEventListener("click", toggle);\n prev.addEventListener("click", () => step(-1));\n next.addEventListener("click", () => step(1));\n stage.addEventListener("click", toggle);\n seek.addEventListener("input", () => {\n playing = false;\n time = Number(seek.value);\n draw();\n });\n root.addEventListener("keydown", (e) => {\n if (e.target.tagName === "INPUT" && e.key !== " ")\n return;\n if (e.key === " ") {\n e.preventDefault();\n toggle();\n }\n else if (e.key === "ArrowRight")\n step(1);\n else if (e.key === "ArrowLeft")\n step(-1);\n else if (e.key === "f")\n full.click();\n else if (e.key === "Escape")\n root.classList.remove("filled");\n });\n draw();\n}\nconst root = document.getElementById("flow-player");\nconst data = document.getElementById("flow-storyboard");\nif (root && (data === null || data === void 0 ? void 0 : data.textContent))\n start(root, JSON.parse(data.textContent));\n\n}, {"../render/frame":"lib/render/frame","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/render/frame": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.WATERMARK = void 0;\nexports.paletteFor = paletteFor;\nexports.sizeFor = sizeFor;\nexports.outputSize = outputSize;\nexports.sceneAt = sceneAt;\nexports.sceneStarts = sceneStarts;\nexports.renderFrame = renderFrame;\nexports.watermarkBox = watermarkBox;\nexports.jsonLines = jsonLines;\nexports.wrap = wrap;\nexports.esc = esc;\nconst timing_1 = require("../storyboard/timing");\nconst code_1 = require("./code");\nconst text_1 = require("../text");\nexports.WATERMARK = "Made with integrationtour.com";\nconst DARK = {\n bg: "#0b1120",\n panel: "#131c31",\n panelEdge: "#26324d",\n text: "#e6ebf5",\n muted: "#8e9ab3",\n client: "#5cc8ff",\n api: "#a58bff",\n accent: "#5cc8ff",\n ok: "#3ddc97",\n bad: "#ff6b6b",\n hook: "#ffb547",\n key: "#ffd166",\n jsonKey: "#7cc7ff",\n jsonString: "#b8e986",\n jsonOther: "#f7b17a",\n};\nconst LIGHT = {\n bg: "#f5f7fb",\n panel: "#ffffff",\n panelEdge: "#d5dce8",\n text: "#0f172a",\n muted: "#5b6a82",\n client: "#0369a1",\n api: "#6d28d9",\n accent: "#0369a1",\n ok: "#047857",\n bad: "#c81e1e",\n hook: "#b45309",\n key: "#a16207",\n jsonKey: "#0f5f8f",\n jsonString: "#166534",\n jsonOther: "#b4410c",\n};\nconst HEX_COLOR = /^#[0-9a-f]{6}$/i;\nfunction paletteFor(settings) {\n const base = settings.theme === "light" ? LIGHT : DARK;\n return settings.brandColor && HEX_COLOR.test(settings.brandColor) ? { ...base, api: settings.brandColor, accent: settings.brandColor } : base;\n}\nlet C = DARK;\nconst SANS = "Inter, \'Segoe UI\', Roboto, Helvetica, Arial, sans-serif";\nconst MONO = "\'JetBrains Mono\', \'SFMono-Regular\', Menlo, Consolas, monospace";\nfunction sizeFor(aspect) {\n if (aspect === "9:16")\n return { width: 720, height: 1280 };\n return aspect === "1:1" ? { width: 720, height: 720 } : { width: 1280, height: 720 };\n}\nfunction outputSize(settings) {\n var _a;\n const { width, height } = sizeFor(settings.aspect);\n const scale = ((_a = settings.resolution) !== null && _a !== void 0 ? _a : 720) / 720;\n return { width: Math.round(width * scale), height: Math.round(height * scale) };\n}\nfunction layoutFor(aspect) {\n if (aspect === "9:16") {\n const client = { x: 48, y: 290, w: 624, h: 110 };\n const api = { x: 48, y: 1040, w: 624, h: 110 };\n return {\n width: 720,\n height: 1280,\n stacked: true,\n caption: { x: 48, y: 110, width: 624, size: 32, minSize: 26, maxLines: 4 },\n client,\n api,\n webhook: client,\n card: { x: 136, y: 450, w: 536, h: 550 },\n lane: { from: [92, 400], to: [92, 1040] },\n hookLane: { from: [92, 1040], to: [92, 400] },\n monoSize: 16,\n title: { size: 52, logo: 120, subtitle: 26 },\n stepSize: 18,\n summary: { left: 64, top: 360, bottom: 100, size: 26, gap: 64 },\n };\n }\n if (aspect === "1:1") {\n const client = { x: 40, y: 200, w: 240, h: 92 };\n return {\n width: 720,\n height: 720,\n stacked: true,\n caption: { x: 40, y: 72, width: 640, size: 30, minSize: 24, maxLines: 3 },\n client,\n api: { x: 440, y: 200, w: 240, h: 92 },\n webhook: client,\n card: { x: 40, y: 324, w: 640, h: 326 },\n lane: { from: [280, 246], to: [440, 246] },\n hookLane: { from: [440, 246], to: [280, 246] },\n monoSize: 15,\n title: { size: 44, logo: 80, subtitle: 22 },\n stepSize: 16,\n summary: { left: 56, top: 200, bottom: 70, size: 22, gap: 48 },\n };\n }\n const client = { x: 64, y: 250, w: 250, h: 130 };\n const api = { x: 966, y: 250, w: 250, h: 130 };\n const webhook = { x: 64, y: 480, w: 250, h: 110 };\n return {\n width: 1280,\n height: 720,\n stacked: false,\n caption: { x: 64, y: 92, width: 1152, size: 30, minSize: 24, maxLines: 2 },\n client,\n api,\n webhook,\n card: { x: 354, y: 352, w: 572, h: 300 },\n lane: { from: [314, 315], to: [966, 315] },\n hookLane: { from: [966, 380], to: [314, 535] },\n monoSize: 15,\n title: { size: 56, logo: 92, subtitle: 24 },\n stepSize: 15,\n summary: { left: 200, top: 220, bottom: 70, size: 24, gap: 56 },\n };\n}\nfunction sceneAt(sb, t) {\n const scenes = (0, timing_1.activeScenes)(sb);\n let start = 0;\n for (let i = 0; i < scenes.length; i++) {\n const duration = (0, timing_1.sceneDuration)(sb, scenes[i]);\n const end = start + duration;\n if (t < end || i === scenes.length - 1) {\n return { scene: scenes[i], index: i, count: scenes.length, start, duration, progress: clamp01((t - start) / duration) };\n }\n start = end;\n }\n throw new Error("Storyboard has no scenes.");\n}\nfunction sceneStarts(sb) {\n const starts = [];\n let t = 0;\n for (const s of (0, timing_1.activeScenes)(sb)) {\n starts.push(t);\n t += (0, timing_1.sceneDuration)(sb, s);\n }\n return starts;\n}\nfunction renderFrame(sb, t, size) {\n var _a, _b;\n C = paletteFor(sb.settings);\n const L = layoutFor(sb.settings.aspect);\n const total = (0, timing_1.totalDuration)(sb);\n const at = sceneAt(sb, Math.max(0, Math.min(t, total)));\n const fade = at.index === 0 ? 1 : clamp01((at.progress * at.duration) / 300);\n let body;\n switch (at.scene.kind) {\n case "title":\n body = titleScene(L, at.scene, at.progress, sb.settings.logo);\n break;\n case "summary":\n body = summaryScene(L, at.scene, at.progress, (0, timing_1.summaryItems)(sb));\n break;\n case "auth":\n body = authScene(L, sb, at.scene, at.progress);\n break;\n case "webhook":\n body = webhookScene(L, sb, at.scene, at.progress);\n break;\n default:\n body = callScene(L, sb, at.scene, at.progress);\n }\n const parts = [\n `<svg xmlns="http://www.w3.org/2000/svg" width="${(_a = size === null || size === void 0 ? void 0 : size.width) !== null && _a !== void 0 ? _a : L.width}" height="${(_b = size === null || size === void 0 ? void 0 : size.height) !== null && _b !== void 0 ? _b : L.height}" viewBox="0 0 ${L.width} ${L.height}" font-family="${esc(SANS)}">`,\n `<rect width="${L.width}" height="${L.height}" fill="${C.bg}"/>`,\n grid(L),\n `<g opacity="${fade.toFixed(3)}">${body}</g>`,\n progressBar(L, total ? Math.min(t, total) / total : 0),\n sb.settings.watermark ? watermark(L) : "",\n `</svg>`,\n ];\n return parts.join("");\n}\nfunction titleScene(L, scene, p, logo) {\n let size = L.title.size;\n while (size > L.title.size * 0.72 && wrap(scene.title, L.width - 160, size, Infinity).length > 3)\n size -= 2;\n const lines = wrap(scene.title, L.width - 160, size, 3);\n const mark = logo && /^data:image\\/(png|jpeg|gif|webp);base64,[a-z0-9+/=]+$/i.test(logo) ? { h: L.title.logo, gap: 34 } : undefined;\n const top = L.height / 2 - (lines.length * size * 1.15) / 2 + (mark ? (mark.h + mark.gap) / 2 : 0);\n const out = lines.map((line, i) => `<text x="${L.width / 2}" y="${top + i * size * 1.15}" text-anchor="middle" font-size="${size}" font-weight="700" fill="${C.text}">${esc(line)}</text>`);\n const subY = top + lines.length * size * 1.15 + 24;\n out.push(`<text x="${L.width / 2}" y="${subY}" text-anchor="middle" font-size="${L.title.subtitle}" fill="${C.muted}">${esc(fit(scene.subtitle, L.width - 160, L.title.subtitle))}</text>`);\n if (mark) {\n const bottom = top - size * 0.78 - mark.gap;\n out.push(`<image href="${esc(logo)}" x="${L.width / 2 - 200}" y="${(bottom - mark.h).toFixed(1)}" width="400" height="${mark.h}" preserveAspectRatio="xMidYMid meet"/>`);\n }\n const dotsY = subY + 70;\n [C.client, C.api, C.hook].forEach((color, i) => {\n const glow = pulse(p, 0.25 + i * 0.15, 0.55 + i * 0.15);\n const cx = L.width / 2 + (i - 1) * 40;\n if (glow > 0)\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="${(8 + 10 * glow).toFixed(1)}" fill="${color}" opacity="${(0.25 * glow).toFixed(3)}"/>`);\n out.push(`<circle cx="${cx}" cy="${dotsY}" r="8" fill="${color}"/>`);\n });\n return out.join("");\n}\nconst MIN_SUMMARY_GAP = 34;\nconst MIN_SUMMARY_SIZE = 18;\nfunction summaryScene(L, scene, p, items) {\n const out = [captionText(L, scene.caption)];\n const { left, top, bottom, size, gap } = L.summary;\n const textX = left + 44;\n const room = L.height - bottom - top;\n const plan = summaryPlan(items, L.width - textX - 56, room, size, gap);\n const r = Math.min(14, plan.gap * 0.32);\n const stagger = Math.min(0.08, 0.6 / plan.blocks.length);\n let y = top;\n plan.blocks.forEach((lines, i) => {\n const appear = clamp01((p - 0.08 - i * stagger) / 0.12);\n const more = plan.more && i === plan.blocks.length - 1;\n out.push(`<g opacity="${appear.toFixed(3)}">`, more\n ? ""\n : `<circle cx="${left + 14}" cy="${(y - 8).toFixed(1)}" r="${r.toFixed(1)}" fill="${C.ok}" opacity="0.18"/><path d="M${left + 7} ${(y - 8).toFixed(1)} l5 5 l9 -10" stroke="${C.ok}" stroke-width="3" fill="none" stroke-linecap="round" stroke-linejoin="round"/>`, ...lines.map((line, j) => `<text x="${textX}" y="${(y + j * plan.lineHeight).toFixed(1)}" font-size="${plan.size}" fill="${more ? C.muted : C.text}">${esc(line)}</text>`), `</g>`);\n y += plan.gap + (lines.length - 1) * plan.lineHeight;\n });\n return out.join("");\n}\nfunction summaryPlan(items, width, room, baseSize, baseGap) {\n const measure = (size) => {\n const lineHeight = Math.round(size * 1.2);\n const blocks = items.map((item) => wrap(item, width, size, 2));\n const extra = blocks.reduce((n, lines) => n + lines.length - 1, 0) * lineHeight;\n return { blocks, lineHeight, extra, minGap: Math.max(MIN_SUMMARY_GAP, size * 1.45) };\n };\n for (let size = baseSize; size >= MIN_SUMMARY_SIZE; size--) {\n const { blocks, lineHeight, extra, minGap } = measure(size);\n const gaps = Math.max(1, blocks.length - 1);\n if (gaps * minGap + extra <= room)\n return { blocks, size, lineHeight, gap: Math.min(baseGap, (room - extra) / gaps), more: false };\n }\n const { blocks, lineHeight, minGap } = measure(MIN_SUMMARY_SIZE);\n const kept = [];\n let used = 0;\n for (const lines of blocks) {\n const need = (kept.length ? minGap : 0) + (lines.length - 1) * lineHeight;\n if (used + need + minGap > room)\n break;\n kept.push(lines);\n used += need;\n }\n kept.push([`+${items.length - kept.length} more`]);\n return { blocks: kept, size: MIN_SUMMARY_SIZE, lineHeight, gap: minGap, more: true };\n}\nfunction callScene(L, sb, scene, p) {\n var _a;\n const failed = scene.outcome === "failure";\n const responseColor = failed ? C.bad : C.ok;\n const requestPhase = p < 0.52;\n const mcp = sb.api.protocol === "mcp";\n const call = `${scene.method} ${scene.path}`.trim();\n const outcome = outcomeText(scene.status);\n const out = [\n stepLabel(L, `Step ${scene.step} of ${scene.stepCount}${failed ? " \xB7 failure path" : ""}`, failed ? C.bad : C.muted),\n captionText(L, scene.caption),\n ...nodes(L, sb, pulse(p, 0.4, 0.52)),\n lane(L),\n ];\n if (!L.stacked)\n out.push(laneLabel(L, call));\n if (!L.stacked && sb.scenes.some((s) => s.kind === "webhook"))\n out.push(node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, 0, 0.35));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), responseColor));\n const cardIn = clamp01((p - 0.08) / 0.08);\n if (requestPhase) {\n const code = sb.settings.code ? (0, code_1.callCode)(sb, scene, sb.settings.code) : undefined;\n out.push(card(L, call, C.client, scene.request, scene.request === undefined && !code ? (mcp ? "No params" : "No request body") : undefined, cardIn, { code }));\n }\n else {\n out.push(card(L, mcp && failed ? `result \xB7 ${outcome}` : outcome, responseColor, scene.response, scene.response === undefined ? "No response body" : undefined, 1, { fold: mcp ? SCHEMA_KEYS : undefined }));\n }\n if (p >= 0.8) {\n const appear = clamp01((p - 0.8) / 0.06);\n out.push(badge(L.client, outcome, responseColor, appear));\n if (failed && scene.recovery)\n out.push(recoveryNote(L, scene.recovery, appear));\n }\n if (requestPhase ? scene.requestGenerated && p >= 0.08 : scene.responseGenerated) {\n const written = mcp && (requestPhase ? scene.method === "prompts/get" : isRecord(scene.response) && !("structuredContent" in scene.response));\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">${written ? "Example text written for the video" : "Example generated from the schema"}</text>`);\n }\n return out.join("");\n}\nfunction nodes(L, sb, glow, clientOpacity = 1) {\n const mcp = sb.api.protocol === "mcp";\n return [node(L.client, mcp ? "MCP CLIENT" : "CLIENT", sb.nodes.client, C.client, 0, clientOpacity), node(L.api, mcp ? "MCP SERVER" : "API", sb.nodes.api, C.api, glow)];\n}\nfunction outcomeText(status) {\n if (status === "result")\n return "result";\n if (status === "isError")\n return "isError: true";\n const why = reason(status);\n return why ? `${status} ${why}` : status;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction authScene(L, sb, scene, p) {\n var _a;\n const out = [stepLabel(L, `Authentication \xB7 ${scene.scheme}`, C.key), captionText(L, scene.caption), ...nodes(L, sb, pulse(p, 0.4, 0.52)), lane(L)];\n if (scene.requestLine) {\n if (!L.stacked)\n out.push(laneLabel(L, scene.requestLine));\n if (p >= 0.1 && p < 0.4)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.1) / 0.3), C.client));\n if (p >= 0.52 && p < 0.8)\n out.push(packet(L.lane.to, L.lane.from, ease((p - 0.52) / 0.28), C.key));\n const code = sb.settings.code && sb.api.protocol !== "mcp" && scene.requestType ? (0, code_1.authCode)(sb, scene, sb.settings.code) : undefined;\n const form = !code && /form-urlencoded/i.test((_a = scene.requestType) !== null && _a !== void 0 ? _a : "") && isRecord(scene.request);\n if (p < 0.52)\n out.push(card(L, scene.requestLine, C.client, form ? formText(scene.request) : scene.request, undefined, clamp01((p - 0.08) / 0.08), { code, form }));\n else\n out.push(card(L, "200 OK \xB7 access token", C.key, scene.response, undefined, 1));\n if (p >= 0.8)\n out.push(badge(L.client, "Token stored", C.key, clamp01((p - 0.8) / 0.06)));\n }\n else {\n if (!L.stacked)\n out.push(laneLabel(L, scene.headerLine.split("\\n")[0]));\n if (p >= 0.2 && p < 0.6)\n out.push(packet(L.lane.from, L.lane.to, ease((p - 0.2) / 0.4), C.key));\n const every = sb.scenes.every((s) => s.kind !== "call" || s.credentials === undefined);\n out.push(card(L, every ? "Sent with every request" : "Sent with each call that needs it", C.key, undefined, scene.headerLine, clamp01((p - 0.08) / 0.08)));\n if (p >= 0.62)\n out.push(badge(L.api, "Authenticated", C.ok, clamp01((p - 0.62) / 0.06)));\n }\n return out.join("");\n}\nfunction webhookScene(L, sb, scene, p) {\n var _a, _b, _c;\n const receiver = L.stacked ? node(L.webhook, "WEBHOOKS", (_a = sb.nodes.webhook) !== null && _a !== void 0 ? _a : "Your server", C.hook, pulse(p, 0.55, 0.7)) : "";\n const out = [\n stepLabel(L, `Webhook \xB7 ${scene.event}`, C.hook),\n captionText(L, scene.caption),\n L.stacked ? receiver : node(L.client, "CLIENT", sb.nodes.client, C.client, 0, 0.45),\n node(L.api, "API", sb.nodes.api, C.api, pulse(p, 0.05, 0.18)),\n ];\n if (!L.stacked)\n out.push(node(L.webhook, "WEBHOOKS", (_b = sb.nodes.webhook) !== null && _b !== void 0 ? _b : "Your server", C.hook, pulse(p, 0.55, 0.7)));\n out.push(`<line x1="${L.hookLane.from[0]}" y1="${L.hookLane.from[1]}" x2="${L.hookLane.to[0]}" y2="${L.hookLane.to[1]}" stroke="${C.hook}" stroke-opacity="0.35" stroke-width="2" stroke-dasharray="6 8"/>`);\n if (p >= 0.18 && p < 0.55)\n out.push(packet(L.hookLane.from, L.hookLane.to, ease((p - 0.18) / 0.37), C.hook));\n out.push(card(L, `${scene.method} ${scene.event}`, C.hook, scene.payload, scene.payload === undefined ? "Event payload" : undefined, clamp01((p - 0.1) / 0.08)));\n if (scene.payloadGenerated && scene.payload !== undefined) {\n out.push(`<text x="${L.card.x + L.card.w}" y="${L.card.y + L.card.h + 22}" text-anchor="end" font-size="13" fill="${C.muted}">Example generated from the schema</text>`);\n }\n if (p >= 0.72) {\n const ack = (_c = scene.ack) !== null && _c !== void 0 ? _c : "2XX";\n const said = `${outcomeText(ack)} \xB7 acknowledged`;\n out.push(badge(L.webhook, said.length <= Math.floor((L.webhook.w - 20) / (15 * 0.6)) ? said : `${ack} \xB7 acknowledged`, C.ok, clamp01((p - 0.72) / 0.06)));\n }\n return out.join("");\n}\nfunction grid(L) {\n const dots = [];\n for (let x = 32; x < L.width; x += 48) {\n for (let y = 32; y < L.height; y += 48)\n dots.push(`M${x} ${y}h1`);\n }\n return `<path d="${dots.join("")}" stroke="${C.panelEdge}" stroke-width="2" stroke-linecap="round" opacity="0.5"/>`;\n}\nfunction stepLabel(L, text, color) {\n return `<text x="${L.caption.x}" y="${L.caption.y - L.caption.size - 10}" font-size="${L.stepSize}" font-weight="600" letter-spacing="1.5" fill="${color}">${esc(text.toUpperCase())}</text>`;\n}\nfunction captionText(L, caption) {\n const { x, y } = L.caption;\n const { size, lines } = fitCaption(L, caption);\n return lines.map((line, i) => `<text x="${x}" y="${y + i * size * 1.25}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(line)}</text>`).join("");\n}\nfunction fitCaption(L, caption) {\n const { width, size, minSize, maxLines } = L.caption;\n const whole = caption.split(/\\s+/).filter(Boolean).join(" ");\n for (const limit of [maxLines, maxLines + 1]) {\n for (let s = size; s >= minSize; s--) {\n const lines = wrap(caption, width, s, Infinity);\n if (lines.length <= limit && lines.join(" ") === whole)\n return { size: s, lines };\n }\n }\n return { size: minSize, lines: wrap(caption, width, minSize, maxLines + 1) };\n}\nfunction node(box, kicker, name, color, glow, opacity = 1) {\n const size = 22;\n return [\n `<g opacity="${opacity}">`,\n glow > 0 ? `<rect x="${box.x - 6}" y="${box.y - 6}" width="${box.w + 12}" height="${box.h + 12}" rx="20" fill="none" stroke="${color}" stroke-width="3" opacity="${(glow * 0.6).toFixed(3)}"/>` : "",\n `<rect x="${box.x}" y="${box.y}" width="${box.w}" height="${box.h}" rx="16" fill="${C.panel}" stroke="${color}" stroke-width="2"/>`,\n `<rect x="${box.x}" y="${box.y}" width="6" height="${box.h}" rx="3" fill="${color}"/>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 - 8}" font-size="13" font-weight="700" letter-spacing="2" fill="${color}">${esc(kicker)}</text>`,\n `<text x="${box.x + 28}" y="${box.y + box.h / 2 + 22}" font-size="${size}" font-weight="600" fill="${C.text}">${esc(fit(name, box.w - 48, size))}</text>`,\n `</g>`,\n ].join("");\n}\nfunction lane(L) {\n const [x1, y1] = L.lane.from;\n const [x2, y2] = L.lane.to;\n return `<line x1="${x1}" y1="${y1}" x2="${x2}" y2="${y2}" stroke="${C.panelEdge}" stroke-width="2" stroke-dasharray="6 8"/>`;\n}\nfunction laneLabel(L, text) {\n const [x1, y1] = L.lane.from;\n const [x2] = L.lane.to;\n return `<text x="${(x1 + x2) / 2}" y="${y1 - 16}" text-anchor="middle" font-family="${esc(MONO)}" font-size="16" fill="${C.muted}">${esc(fit(text, x2 - x1 - 40, 16, true))}</text>`;\n}\nfunction packet(from, to, t, color) {\n const x = from[0] + (to[0] - from[0]) * t;\n const y = from[1] + (to[1] - from[1]) * t;\n return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="18" fill="${color}" opacity="0.2"/><circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="9" fill="${color}"/>`;\n}\nconst SCHEMA_KEYS = new Set(["inputSchema", "outputSchema"]);\nfunction card(L, header, color, value, note, opacity, { code, fold, form } = {}) {\n const { x, y, w, h } = L.card;\n const size = code ? L.monoSize - 2 : L.monoSize;\n const lineHeight = Math.round(size * 1.4);\n const maxLines = Math.floor((h - 64) / lineHeight);\n const maxChars = Math.floor((w - 40) / (size * 0.6));\n const out = [\n `<g opacity="${opacity.toFixed(3)}">`,\n `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="14" fill="${C.panel}" stroke="${C.panelEdge}" stroke-width="1.5"/>`,\n `<rect x="${x}" y="${y}" width="${w}" height="44" rx="14" fill="${color}" opacity="0.14"/>`,\n `<text x="${x + 20}" y="${y + 28}" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(header, w - 40, size, true))}</text>`,\n ];\n if (note !== undefined) {\n note\n .split("\\n")\n .slice(0, maxLines)\n .forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" fill="${C.muted}">${esc(fit(line, w - 40, size, true))}</text>`));\n }\n else {\n const lines = code ? codeTspans(code, maxLines, maxChars) : form ? formTspans(String(value), maxLines, maxChars) : jsonLines(value, maxLines, maxChars, fold);\n lines.forEach((line, i) => out.push(`<text x="${x + 20}" y="${y + 44 + (i + 1) * lineHeight + 4}" font-family="${esc(MONO)}" font-size="${size}" xml:space="preserve">${line}</text>`));\n }\n out.push(`</g>`);\n return out.join("");\n}\nfunction badge(box, text, color, opacity) {\n const size = 15;\n const w = Math.min(box.w, textWidth(text, size, true) + 28);\n const x = box.x + box.w - w;\n const y = box.y - 40;\n return `<g opacity="${opacity.toFixed(3)}"><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="${color}" opacity="0.18"/><rect x="${x}" y="${y}" width="${w}" height="30" rx="15" fill="none" stroke="${color}" stroke-width="1.5"/><text x="${x + w / 2}" y="${y + 20}" text-anchor="middle" font-family="${esc(MONO)}" font-size="${size}" font-weight="700" fill="${color}">${esc(fit(text, w - 20, size, true))}</text></g>`;\n}\nfunction recoveryNote(L, text, opacity) {\n const box = L.stacked ? { x: L.card.x, y: L.client.y + L.client.h + 6 } : { x: L.client.x, y: L.client.y + L.client.h + 22 };\n const width = L.stacked ? L.card.w : L.client.w;\n const lines = wrap(`\u21BB ${text}`, width, 17, L.stacked ? 1 : 3);\n return `<g opacity="${opacity.toFixed(3)}">${lines\n .map((line, i) => `<text x="${box.x}" y="${box.y + 18 + i * 22}" font-size="17" font-weight="600" fill="${C.hook}">${esc(line)}</text>`)\n .join("")}</g>`;\n}\nfunction progressBar(L, fraction) {\n return `<rect x="0" y="${L.height - 4}" width="${L.width}" height="4" fill="${C.panelEdge}"/><rect x="0" y="${L.height - 4}" width="${(L.width * clamp01(fraction)).toFixed(1)}" height="4" fill="${C.accent}"/>`;\n}\nconst MARK = { size: 15, right: 24, bottom: 20 };\nfunction watermark(L) {\n return `<text x="${L.width - MARK.right}" y="${L.height - MARK.bottom}" text-anchor="end" font-size="${MARK.size}" font-weight="600" fill="${C.muted}" opacity="0.75">${esc(exports.WATERMARK)}</text>`;\n}\nfunction watermarkBox(aspect) {\n const L = layoutFor(aspect);\n const w = exports.WATERMARK.length * MARK.size * 0.6;\n return { x: L.width - MARK.right - w, y: L.height - MARK.bottom - MARK.size, w, h: MARK.size * 1.3 };\n}\nconst FOLDED = "\\uE000";\nfunction jsonLines(value, maxLines, maxChars, fold) {\n var _a, _b;\n let text;\n try {\n const replacer = fold ? (key, v) => (fold.has(key) && isRecord(v) ? FOLDED : v) : undefined;\n text = typeof value === "string" ? value : ((_b = (_a = JSON.stringify(value, replacer, 2)) === null || _a === void 0 ? void 0 : _a.replace(/"\\uE000"/g, "{ \u2026 }")) !== null && _b !== void 0 ? _b : "");\n }\n catch {\n text = String(value);\n }\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n const xml = typeof value === "string" && /^\\s*</.test(value);\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n if (xml)\n return xmlTspans(line);\n const field = typeof value === "string" ? line.match(/^(event|data|id|retry):( ?)(.*)$/) : null;\n if (field)\n return `<tspan fill="${C.jsonKey}">${esc(field[1])}</tspan><tspan fill="${C.muted}">:${field[2]}</tspan>${colorValue(field[3])}`;\n const m = line.match(/^(\\s*)("(?:[^"\\\\]|\\\\.)*")(:\\s?)(.*)$/);\n if (!m)\n return colorValue(line);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan>${colorValue(m[4])}`;\n });\n}\nfunction formText(fields) {\n return Object.entries(fields)\n .map(([key, value], i) => `${i ? "&" : ""}${key}=${typeof value === "string" ? value : JSON.stringify(value)}`)\n .join("\\n");\n}\nfunction formTspans(text, maxLines, maxChars) {\n let lines = text.split("\\n");\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), "\u2026"];\n return lines.map((raw) => {\n const line = (0, text_1.clip)(raw, maxChars);\n const m = line.match(/^(&?)([^=]*)(=?)(.*)$/);\n return `<tspan fill="${C.muted}">${esc(m[1])}</tspan><tspan fill="${C.jsonKey}">${esc(m[2])}</tspan><tspan fill="${C.muted}">${esc(m[3])}</tspan><tspan fill="${C.jsonString}">${esc(m[4])}</tspan>`;\n });\n}\nconst XML_TOKEN = /(<\\/?[\\w.:-]+|\\/?>)|("[^"]*"?)|([\\w.:-]+=)/g;\nfunction xmlTspans(line) {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(XML_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, tag, str] = m;\n out.push(`<tspan fill="${tag ? C.jsonKey : str ? C.jsonString : C.muted}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.jsonString}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n}\nfunction codeTspans(code, maxLines, maxChars) {\n let lines = code.flatMap((line) => softWrap(line, maxChars));\n if (lines.length > maxLines)\n lines = [...lines.slice(0, Math.max(1, maxLines - 1)), " \u2026"];\n return lines.map((line) => {\n const out = [];\n let last = 0;\n for (const m of line.matchAll(CODE_TOKEN)) {\n if (m.index > last)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last, m.index))}</tspan>`);\n const [token, str, num, word] = m;\n const color = str ? (/^\\s*:/.test(line.slice(m.index + token.length)) ? C.jsonKey : C.jsonString) : num ? C.jsonOther : word ? C.key : m.index === 0 || /\\s/.test(line[m.index - 1]) ? C.client : C.text;\n out.push(`<tspan fill="${color}">${esc(token)}</tspan>`);\n last = m.index + token.length;\n }\n if (last < line.length)\n out.push(`<tspan fill="${C.text}">${esc(line.slice(last))}</tspan>`);\n return out.join("");\n });\n}\nconst CODE_TOKEN = /("(?:[^"\\\\]|\\\\.)*"?|\'(?:[^\'\\\\]|\\\\.)*\'?)|(\\b\\d+(?:\\.\\d+)?\\b)|(\\b(?:curl|await|fetch|requests|new|JSON|FormData|URLSearchParams|open|True|False|None|true|false|null)\\b)|(--?[a-zA-Z][\\w-]*)/g;\nfunction softWrap(line, max) {\n const indent = line.match(/^\\s*/)[0].length + 4;\n const out = [];\n let rest = line;\n while (rest.length > max && out.length < 40) {\n const window = rest.slice(0, max);\n const at = Math.max(window.lastIndexOf("/"), window.lastIndexOf(" "), window.lastIndexOf(","));\n const piece = at > indent ? rest.slice(0, at + 1) : (0, text_1.cut)(rest, max);\n out.push(piece);\n rest = " ".repeat(indent) + rest.slice(piece.length).trimStart();\n }\n return [...out, (0, text_1.clip)(rest, max)];\n}\nfunction colorValue(text) {\n const trimmed = text.trim();\n const color = trimmed.startsWith(\'"\') ? C.jsonString : /^[\\d\\-tfn]/.test(trimmed) ? C.jsonOther : C.muted;\n return `<tspan fill="${color}">${esc(text)}</tspan>`;\n}\nfunction textWidth(text, size, mono = false) {\n return text.length * size * (mono ? 0.6 : 0.54);\n}\nfunction fit(text, width, size, mono = false) {\n const max = Math.floor(width / (size * (mono ? 0.6 : 0.54)));\n return text.length > max ? (0, text_1.cut)(text, Math.max(1, max - 1)) + "\u2026" : text;\n}\nfunction wrap(text, width, size, maxLines) {\n const max = Math.max(8, Math.floor(width / (size * 0.54)));\n const words = text.split(/\\s+/).filter(Boolean);\n const lines = [];\n let current = "";\n for (const word of words) {\n const next = current ? `${current} ${word}` : word;\n if (next.length <= max)\n current = next;\n else {\n if (current)\n lines.push(current);\n current = (0, text_1.clip)(word, max);\n }\n }\n if (current)\n lines.push(current);\n if (lines.length > maxLines) {\n const kept = lines.slice(0, maxLines);\n kept[maxLines - 1] = fit(`${kept[maxLines - 1]} \u2026`, width, size);\n return kept;\n }\n return lines;\n}\nconst NOT_XML = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F\\uD800-\\uDFFF\uFFFE\uFFFF]/g;\nfunction esc(text) {\n return text\n .replace(NOT_XML, (c) => (c.length === 2 ? c : c < " " ? " " : ""))\n .replace(/&/g, "&")\n .replace(/</g, "<")\n .replace(/>/g, ">")\n .replace(/"/g, """)\n .replace(/\'/g, "'");\n}\nconst REASONS = {\n "200": "OK",\n "201": "Created",\n "202": "Accepted",\n "204": "No Content",\n "206": "Partial Content",\n "301": "Moved Permanently",\n "302": "Found",\n "303": "See Other",\n "304": "Not Modified",\n "307": "Temporary Redirect",\n "308": "Permanent Redirect",\n "400": "Bad Request",\n "401": "Unauthorized",\n "402": "Payment Required",\n "403": "Forbidden",\n "404": "Not Found",\n "405": "Method Not Allowed",\n "409": "Conflict",\n "410": "Gone",\n "412": "Precondition Failed",\n "413": "Content Too Large",\n "422": "Unprocessable",\n "429": "Too Many Requests",\n "500": "Server Error",\n "502": "Bad Gateway",\n "503": "Unavailable",\n "504": "Gateway Timeout",\n};\nfunction reason(status) {\n var _a;\n return (_a = REASONS[status]) !== null && _a !== void 0 ? _a : "";\n}\nfunction clamp01(n) {\n return Math.max(0, Math.min(1, n));\n}\nfunction ease(t) {\n const x = clamp01(t);\n return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;\n}\nfunction pulse(p, a, b) {\n if (p < a || p > b)\n return 0;\n return Math.sin(((p - a) / (b - a)) * Math.PI);\n}\n\n}, {"../storyboard/timing":"lib/storyboard/timing","./code":"lib/render/code","../text":"lib/text"}],\n"lib/storyboard/timing": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.VOICE_LEAD = void 0;\nexports.activeScenes = activeScenes;\nexports.sceneDuration = sceneDuration;\nexports.totalDuration = totalDuration;\nexports.voiceCues = voiceCues;\nexports.summaryItems = summaryItems;\nexports.VOICE_LEAD = 400;\nconst VOICE_TAIL = 600;\nfunction activeScenes(sb) {\n return sb.scenes.filter((s) => sb.settings.showFailure || !s.failurePath);\n}\nfunction sceneDuration(sb, scene) {\n if (!sb.settings.voiceover || !scene.voiceMs)\n return scene.duration;\n return Math.max(scene.duration, Math.ceil(exports.VOICE_LEAD + scene.voiceMs + VOICE_TAIL));\n}\nfunction totalDuration(sb) {\n return activeScenes(sb).reduce((sum, s) => sum + sceneDuration(sb, s), 0);\n}\nfunction voiceCues(sb) {\n if (!sb.settings.voiceover)\n return [];\n const cues = [];\n let t = 0;\n for (const scene of activeScenes(sb)) {\n if (scene.voiceMs)\n cues.push({ sceneId: scene.id, at: t + exports.VOICE_LEAD });\n t += sceneDuration(sb, scene);\n }\n return cues;\n}\nfunction summaryItems(sb) {\n const items = [];\n let failure;\n for (const scene of activeScenes(sb)) {\n if (!scene.summaryLine)\n continue;\n if (scene.kind === "call" && scene.outcome === "failure") {\n failure = scene.summaryLine;\n continue;\n }\n items.push(scene.summaryLine);\n if (failure)\n items.push(failure);\n failure = undefined;\n }\n if (failure)\n items.push(failure);\n return items;\n}\n\n}, {}],\n"lib/render/code": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CODE_STYLES = void 0;\nexports.codeRequest = codeRequest;\nexports.authCode = authCode;\nexports.callCode = callCode;\nexports.codeLines = codeLines;\nconst examples_1 = require("../oas/examples");\nconst timing_1 = require("../storyboard/timing");\nexports.CODE_STYLES = [\n { style: "curl", label: "curl" },\n { style: "javascript", label: "JavaScript" },\n { style: "python", label: "Python" },\n];\nfunction codeRequest(sb, scene) {\n var _a, _b, _c, _d;\n let url = /^[a-z][a-z\\d+.-]*:\\/\\//i.test(scene.path) ? scene.path : `${sb.api.baseUrl}${scene.path}`;\n const body = /^(GET|HEAD)$/.test(scene.method) && isEmptyValue(scene.request) ? undefined : scene.request;\n const req = { method: scene.method, url, headers: [], body, contentType: scene.requestType, ...(scene.encoding ? { encoding: scene.encoding } : {}) };\n const auth = sb.scenes.find((s) => s.kind === "auth");\n const credentials = (_a = scene.credentials) !== null && _a !== void 0 ? _a : ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth" ? ((_b = auth.credentials) !== null && _b !== void 0 ? _b : auth.headerLine.split("\\n").map(fromLine)) : []);\n const cookies = ((_c = scene.cookies) !== null && _c !== void 0 ? _c : []).map(([name, value]) => `${name}=${value}`);\n for (const credential of credentials) {\n if (!credential)\n continue;\n const c = { ...credential, value: credential.value.replace(/\u2026/g, "...") };\n if (c.in === "query")\n url += (url.includes("?") ? "&" : "?") + `${c.name}=${c.value}`;\n else if (c.in === "cookie")\n cookies.unshift(`${c.name}=${c.value}`);\n else if (c.in === "certificate")\n req.certificate = { cert: c.name, key: c.value };\n else if (c.in === "digest")\n req.digest = { username: c.name, password: c.value };\n else\n req.headers.push([c.name, c.value]);\n }\n req.headers.push(...((_d = scene.headers) !== null && _d !== void 0 ? _d : []));\n if (cookies.length)\n req.headers.push(["Cookie", cookies.join("; ")]);\n return { ...req, url };\n}\nfunction fromLine(line) {\n if (line.startsWith("?")) {\n const eq = line.indexOf("=");\n return eq > 1 ? { in: "query", name: line.slice(1, eq), value: line.slice(eq + 1) } : undefined;\n }\n const colon = line.indexOf(":");\n return colon > 0 ? { in: "header", name: line.slice(0, colon).trim(), value: line.slice(colon + 1).trim() } : undefined;\n}\nfunction bodyKind(req) {\n var _a, _b;\n const type = (_b = (_a = req.contentType) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : "";\n if (req.body === undefined)\n return "none";\n if (type.includes("multipart/form-data") && isObject(req.body))\n return "multipart";\n if (type.includes("x-www-form-urlencoded") && isObject(req.body))\n return "form";\n if (typeof req.body === "string" && req.body === examples_1.BINARY_PLACEHOLDER)\n return "binary";\n if (typeof req.body === "string" && type && !/json/.test(type))\n return "text";\n return "json";\n}\nconst isFile = (value) => value === examples_1.BINARY_PLACEHOLDER;\nfunction fieldText(value) {\n return typeof value === "string" ? value : value === undefined || value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);\n}\nfunction formPairs(body, encoding = {}) {\n var _a, _b, _c, _d;\n const out = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const style = (_b = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.style) !== null && _b !== void 0 ? _b : "form";\n const explode = (_d = (_c = encoding[name]) === null || _c === void 0 ? void 0 : _c.explode) !== null && _d !== void 0 ? _d : style === "form";\n if (style === "deepObject" && typeof value === "object" && value !== null)\n out.push(...bracketed(name, value));\n else if (Array.isArray(value)) {\n if (explode && style === "form")\n out.push(...value.map((item) => [name, fieldText(item)]));\n else\n out.push([name, value.map(fieldText).join(style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",")]);\n }\n else if (isObject(value)) {\n if (explode)\n out.push(...Object.entries(value).map(([key, v]) => [key, fieldText(v)]));\n else\n out.push([name, Object.entries(value).flatMap(([key, v]) => [key, fieldText(v)]).join(",")]);\n }\n else\n out.push([name, fieldText(value)]);\n }\n return out;\n}\nfunction bracketed(name, value) {\n if (Array.isArray(value))\n return value.flatMap((item, i) => bracketed(`${name}[${i}]`, item));\n if (isObject(value))\n return Object.entries(value).flatMap(([key, v]) => bracketed(`${name}[${key}]`, v));\n return [[name, fieldText(value)]];\n}\nfunction formObject(body) {\n return Object.fromEntries(Object.entries(body).flatMap(([key, value]) => (value === null || value === undefined ? [] : [[key, typeof value === "boolean" ? String(value) : value]])));\n}\nfunction flat(body) {\n return Object.values(body).every((value) => typeof value !== "object" || value === null);\n}\nfunction multipartParts(body, encoding = {}) {\n var _a;\n const parts = [];\n for (const [name, value] of Object.entries(body)) {\n if (value === null || value === undefined)\n continue;\n const type = (_a = encoding[name]) === null || _a === void 0 ? void 0 : _a.contentType;\n const items = Array.isArray(value) && !value.some((v) => typeof v === "object" && v !== null) ? value : [value];\n for (const item of items) {\n if (isFile(item))\n parts.push({ name, file: true });\n else if (typeof item === "object" && item !== null)\n parts.push({ name, text: JSON.stringify(item), type: type !== null && type !== void 0 ? type : "application/json" });\n else\n parts.push({ name, text: fieldText(item), ...(type && !/^text\\/plain\\b/i.test(type) ? { type } : {}) });\n }\n }\n return parts;\n}\nfunction filePath(name) {\n return /^[\\w-]+$/.test(name) ? name : "file";\n}\nfunction isObject(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isEmptyValue(value) {\n return value === undefined || (typeof value === "object" && value !== null && Object.keys(value).length === 0);\n}\nfunction authCode(sb, scene, style) {\n var _a, _b, _c, _d;\n const target = (_b = (_a = scene.requestLine) === null || _a === void 0 ? void 0 : _a.replace(/^POST\\s+/, "")) !== null && _b !== void 0 ? _b : "";\n const url = (_c = scene.tokenUrl) !== null && _c !== void 0 ? _c : (/^https?:\\/\\//i.test(target) ? target : `${sb.api.baseUrl}${target}`);\n return codeLines({ method: "POST", url, headers: [], body: scene.request, contentType: (_d = scene.requestType) !== null && _d !== void 0 ? _d : "application/x-www-form-urlencoded" }, style);\n}\nfunction callCode(sb, scene, style) {\n return sb.api.protocol === "mcp" ? mcpCode(sb, scene, style) : codeLines(codeRequest(sb, scene), style);\n}\nfunction codeLines(req, style) {\n switch (style) {\n case "curl":\n return curl(req);\n case "javascript":\n return javascript(req);\n default:\n return python(req);\n }\n}\nfunction curl(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const parts = [];\n const method = req.method === "HEAD" ? " -I" : req.method === "GET" || (req.method === "POST" && kind !== "none") ? "" : ` -X ${shellQuote(req.method)}`;\n const glob = /[[\\]{}]/.test(req.url) ? " -g" : "";\n parts.push([`curl${glob}${method} ${shellQuote(req.url, /[?&]/.test(req.url))}`]);\n if (req.certificate)\n parts.push([` --cert ${shellQuote(req.certificate.cert)} --key ${shellQuote(req.certificate.key)}`]);\n if (req.digest)\n parts.push([` --digest -u ${shellQuote(`${req.digest.username}:${req.digest.password}`, true)}`]);\n for (const [name, value] of req.headers)\n parts.push([` -H ${shellQuote(`${name}: ${value}`, true)}`]);\n const body = req.body;\n const contentType = (type) => [` -H ${shellQuote(`Content-Type: ${type}`, true)}`];\n if (kind === "json") {\n parts.push(contentType((_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"));\n parts.push(quotedData(pretty(body, "json", 2)));\n }\n else if (kind === "form" && isObject(body)) {\n for (const [key, value] of formPairs(body, req.encoding))\n parts.push([` --data-urlencode ${shellQuote(`${key}=${value}`, true)}`]);\n }\n else if (kind === "multipart" && isObject(body)) {\n for (const part of multipartParts(body, req.encoding))\n parts.push([` ${formPart(part)}`]);\n }\n else if (kind === "binary") {\n parts.push(contentType((_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"), [" --data-binary @file"]);\n }\n else if (kind === "text") {\n parts.push(contentType((_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"), quotedData(String(body).split("\\n")));\n }\n return parts.flatMap((part, p) => part.map((line, i) => (p < parts.length - 1 && i === part.length - 1 ? `${line} \\\\` : line)));\n}\nfunction formPart(part) {\n const value = part.file ? `@${filePath(part.name)}` : part.text;\n if (part.name.includes("="))\n return `--form-string ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.file)\n return `-F ${shellQuote(`${part.name}=${value}`, true)}`;\n if (part.type) {\n const text = readsMore(value) ? `"${value.replace(/[\\\\"]/g, "\\\\$&")}"` : value;\n return `-F \'${escapeSingle(`${part.name}=${text}${formType(part.type)}`)}\'`;\n }\n return `${readsMore(value) ? "--form-string" : "-F"} ${shellQuote(`${part.name}=${value}`, true)}`;\n}\nfunction formType(type) {\n const [essence, ...params] = type.split(",")[0].split(";").map((s) => s.trim());\n if (!/^[\\w.+*-]+\\/[\\w.+*-]+$/.test(essence))\n return "";\n const kept = params.filter((p) => /^[\\w.+-]+=[^\\s"\\\\]*$/.test(p) && !/^(type|filename|headers|encoder)=/i.test(p));\n return `;type=${[essence, ...kept].join("; ")}`;\n}\nfunction readsMore(text) {\n return /^[@<"\\s]|;|\\s$/.test(text);\n}\nfunction quotedData(lines) {\n const body = lines.map(escapeSingle);\n return body.length === 1 ? [` -d \'${body[0]}\'`] : [` -d \'${body[0]}`, ...body.slice(1, -1).map((l) => ` ${l}`), ` ${body.at(-1)}\'`];\n}\nfunction shellQuote(text, always = false) {\n if (!always && !/[^\\w@%+=:,./-]/.test(text))\n return text;\n return /["\\\\$`!]/.test(text) ? `\'${escapeSingle(text)}\'` : `"${text}"`;\n}\nfunction escapeSingle(text) {\n return text.replace(/\'/g, `\'\\\\\'\'`);\n}\nfunction javascript(req) {\n var _a, _b, _c;\n const kind = bodyKind(req);\n const lines = [];\n const headers = [...req.headers];\n let body = [];\n if (req.certificate)\n lines.push(`// Sent over mutual TLS with ${req.certificate.cert} and ${req.certificate.key}`);\n if (req.digest) {\n lines.push("// Answer the API\'s Digest challenge with your username and password");\n headers.push(["Authorization", `Digest username="${req.digest.username}", nonce="...", response="..."`]);\n }\n if (kind === "json") {\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/json"]);\n body = wrapLines("body: JSON.stringify(", pretty(req.body, "json", 2), "),");\n }\n else if (kind === "multipart" && isObject(req.body)) {\n lines.push("const form = new FormData();");\n for (const part of multipartParts(req.body, req.encoding)) {\n const value = part.file ? "file" : part.type ? `new Blob([${jsString(part.text)}], { type: ${jsString(part.type)} })` : jsString(part.text);\n lines.push(`form.append(${jsString(part.name)}, ${value});`);\n }\n body = ["body: form,"];\n }\n else if (kind === "form" && isObject(req.body)) {\n body = flat(req.body) && !req.encoding\n ? wrapLines("body: new URLSearchParams(", pretty(formObject(req.body), "json", 2), "),")\n : ["body: new URLSearchParams([", ...formPairs(req.body, req.encoding).map(([k, v]) => ` [${jsString(k)}, ${jsString(v)}],`), "]),"];\n }\n else if (kind === "binary") {\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "application/octet-stream"]);\n body = ["body: file,"];\n }\n else if (kind === "text") {\n headers.push(["Content-Type", (_c = req.contentType) !== null && _c !== void 0 ? _c : "text/plain"]);\n const text = String(req.body);\n body = text.includes("\\n") ? wrapLines("body: `", text.replace(/[`\\\\]|\\$\\{/g, (m) => `\\\\${m}`).split("\\n"), "`,") : [`body: ${jsString(text)},`];\n }\n const options = [\n ...(req.method === "GET" ? [] : [`method: ${jsString(req.method)},`]),\n ...(headers.length ? ["headers: {", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"] : []),\n ...body,\n ];\n if (!options.length)\n return [...lines, `await fetch(${jsString(req.url)});`];\n return [...lines, `await fetch(${jsString(req.url)}, {`, ...options.map((l) => ` ${l}`), "});"];\n}\nfunction jsString(text) {\n return JSON.stringify(text);\n}\nconst PYTHON_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);\nfunction python(req) {\n var _a, _b;\n const kind = bodyKind(req);\n const args = [[`${jsString(req.url)},`]];\n const headers = [...req.headers];\n if (kind === "binary")\n headers.push(["Content-Type", (_a = req.contentType) !== null && _a !== void 0 ? _a : "application/octet-stream"]);\n if (kind === "text")\n headers.push(["Content-Type", (_b = req.contentType) !== null && _b !== void 0 ? _b : "text/plain"]);\n if (headers.length === 1)\n args.push([`headers={${jsString(headers[0][0])}: ${jsString(headers[0][1])}},`]);\n else if (headers.length)\n args.push(["headers={", ...headers.map(([n, v]) => ` ${jsString(n)}: ${jsString(v)},`), "},"]);\n if (req.certificate)\n args.push([`cert=(${jsString(req.certificate.cert)}, ${jsString(req.certificate.key)}),`]);\n if (req.digest)\n args.push([`auth=requests.auth.HTTPDigestAuth(${jsString(req.digest.username)}, ${jsString(req.digest.password)}),`]);\n if (kind === "json")\n args.push(wrapLines("json=", pretty(req.body, "python", 4), ","));\n else if (kind === "form" && isObject(req.body)) {\n if (flat(req.body) && !req.encoding)\n args.push(wrapLines("data=", pretty(formObject(req.body), "python", 4), ","));\n else\n args.push(["data=[", ...formPairs(req.body, req.encoding).map(([k, v]) => ` (${jsString(k)}, ${jsString(v)}),`), "],"]);\n }\n else if (kind === "multipart" && isObject(req.body)) {\n const parts = multipartParts(req.body, req.encoding);\n const typed = parts.filter((p) => p.file || p.type);\n const files = typed.length ? typed : parts;\n const fields = typed.length ? parts.filter((p) => !p.file && !p.type) : [];\n const file = (p) => (p.file ? `open(${jsString(filePath(p.name))}, "rb")` : p.type ? `(None, ${jsString(p.text)}, ${jsString(p.type)})` : `(None, ${jsString(p.text)})`);\n const twice = (list) => new Set(list.map((p) => p.name)).size < list.length;\n if (files.length) {\n args.push(twice(files) ? ["files=[", ...files.map((p) => ` (${jsString(p.name)}, ${file(p)}),`), "],"] : ["files={", ...files.map((p) => ` ${jsString(p.name)}: ${file(p)},`), "},"]);\n }\n if (fields.length) {\n args.push(twice(fields) ? ["data=[", ...fields.map((p) => ` (${jsString(p.name)}, ${jsString(p.text)}),`), "],"] : ["data={", ...fields.map((p) => ` ${jsString(p.name)}: ${jsString(p.text)},`), "},"]);\n }\n }\n else if (kind === "binary")\n args.push([`data=open("file", "rb"),`]);\n else if (kind === "text") {\n const text = String(req.body);\n args.push(text.includes("\\n") ? wrapLines(\'data="""\', text.replace(/\\\\/g, "\\\\\\\\").replace(/"""/g, \'\\\\"\\\\"\\\\"\').split("\\n"), \'""",\') : [`data=${jsString(text)},`]);\n }\n const call = PYTHON_METHODS.has(req.method) ? `requests.${req.method.toLowerCase()}(` : `requests.request(${jsString(req.method)},`;\n return [call, ...args.flat().map((l) => ` ${l}`), ")"];\n}\nconst MCP_VERSION = "2026-07-28";\nconst VERSION_HEADER_SINCE = "2025-06-18";\nconst SESSION_ID = "1868a90c...";\nconst CLIENT_INFO = { name: "your-agent", version: "1.0.0" };\nfunction mcpCode(sb, scene, style) {\n const http = /^https?:\\/\\//i.test(sb.api.baseUrl);\n const auth = sb.scenes.some((s) => s.kind === "auth");\n switch (style) {\n case "curl":\n return mcpWire(sb, scene, http);\n case "javascript":\n return mcpJavaScript(sb, scene, http, auth);\n default:\n return mcpPython(sb, scene, http, auth);\n }\n}\nfunction rpcBody(sb, scene, modern) {\n var _a;\n const meta = { "io.modelcontextprotocol/protocolVersion": MCP_VERSION, "io.modelcontextprotocol/clientInfo": CLIENT_INFO, "io.modelcontextprotocol/clientCapabilities": {} };\n const params = scene.method === "tools/call"\n ? { name: scene.path, arguments: (_a = scene.request) !== null && _a !== void 0 ? _a : {} }\n : scene.method === "resources/read"\n ? { uri: scene.path }\n : scene.method === "prompts/get"\n ? { name: scene.path, ...(scene.request !== undefined ? { arguments: scene.request } : {}) }\n : {};\n if (!modern)\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, ...(Object.keys(params).length ? { params } : {}) };\n return { jsonrpc: "2.0", id: rpcId(sb, scene), method: scene.method, params: { ...params, _meta: meta } };\n}\nfunction rpcId(sb, scene) {\n const index = (0, timing_1.activeScenes)(sb)\n .filter((s) => s.kind === "call")\n .indexOf(scene);\n return index >= 0 ? index + 1 : scene.step;\n}\nfunction mcpWire(sb, scene, http) {\n var _a, _b, _c;\n const revision = (_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION;\n const modern = revision >= MCP_VERSION;\n const body = JSON.stringify(rpcBody(sb, scene, modern));\n if (!http) {\n if (modern)\n return [`echo \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n const init = JSON.stringify({ jsonrpc: "2.0", id: 0, method: "initialize", params: { protocolVersion: revision, capabilities: {}, clientInfo: CLIENT_INFO } });\n return [`printf \'%s\\\\n\' \\\\`, ` \'${escapeSingle(init)}\' \\\\`, ` \'{"jsonrpc":"2.0","method":"notifications/initialized"}\' \\\\`, ` \'${escapeSingle(body)}\' \\\\`, ` | ${sb.api.baseUrl}`];\n }\n const headers = [["Accept", "application/json, text/event-stream"]];\n if (modern) {\n headers.push(["MCP-Protocol-Version", MCP_VERSION], ["Mcp-Method", scene.method]);\n if (scene.method !== "tools/list")\n headers.push(["Mcp-Name", headerValue(scene.path)]);\n for (const { name, path } of (_b = scene.paramHeaders) !== null && _b !== void 0 ? _b : []) {\n const value = path.reduce((at, key) => (isObject(at) ? at[key] : undefined), scene.request);\n if (typeof value === "string" || typeof value === "boolean" || (typeof value === "number" && Number.isSafeInteger(value)))\n headers.push([`Mcp-Param-${name}`, headerValue(String(value))]);\n }\n }\n else {\n if (revision >= VERSION_HEADER_SINCE)\n headers.push(["MCP-Protocol-Version", revision]);\n if (sb.api.session !== false)\n headers.push(["Mcp-Session-Id", SESSION_ID]);\n }\n const auth = sb.scenes.find((s) => s.kind === "auth");\n if ((auth === null || auth === void 0 ? void 0 : auth.kind) === "auth")\n for (const c of (_c = auth.credentials) !== null && _c !== void 0 ? _c : [])\n if (c.in === "header")\n headers.push([c.name, c.value.replace(/\u2026/g, "...")]);\n return [`curl ${shellQuote(sb.api.baseUrl)} \\\\`, ...headers.map(([n, v]) => ` -H ${shellQuote(`${n}: ${v}`, true)} \\\\`), ` --json \'${escapeSingle(body)}\'`];\n}\nfunction headerValue(text) {\n const plain = /^[\\x21-\\x7e]([\\x20-\\x7e\\t]*[\\x21-\\x7e])?$/.test(text) && !/^=\\?base64\\?.*\\?=$/.test(text);\n if (plain)\n return text;\n const bytes = new TextEncoder().encode(text);\n let binary = "";\n for (const byte of bytes)\n binary += String.fromCharCode(byte);\n return `=?base64?${btoa(binary)}?=`;\n}\nfunction mcpJavaScript(sb, scene, http, auth) {\n var _a, _b, _c;\n switch (scene.method) {\n case "tools/list": {\n const command = sb.api.baseUrl.split(" ");\n const transport = http\n ? [` new StreamableHTTPClientTransport(new URL(${jsString(sb.api.baseUrl)})${auth ? ", { authProvider }" : ""}),`]\n : [` new StdioClientTransport({ command: ${jsString(command[0])}, args: ${list(command.slice(1))} }),`];\n const negotiate = ((_a = sb.api.revision) !== null && _a !== void 0 ? _a : MCP_VERSION) >= MCP_VERSION ? `, { versionNegotiation: { mode: "auto" } }` : "";\n return [\n `import { Client${http ? ", StreamableHTTPClientTransport" : ""} } from "@modelcontextprotocol/client";`,\n ...(http ? [] : [`import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";`]),\n "",\n `const client = new Client({ name: "your-agent", version: "1.0.0" }${negotiate});`,\n "await client.connect(",\n ...transport,\n ");",\n "const { tools } = await client.listTools();",\n ];\n }\n case "resources/read":\n return [`const { contents } = await client.readResource({ uri: ${jsString(scene.path)} });`];\n case "prompts/get":\n return ["const { messages } = await client.getPrompt({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "json", 2), ",")), "});"];\n default:\n return ["const result = await client.callTool({", ` name: ${jsString(scene.path)},`, ...indented(" ", wrapLines("arguments: ", pretty((_c = scene.request) !== null && _c !== void 0 ? _c : {}, "json", 2), ",")), "});"];\n }\n}\nfunction mcpPython(sb, scene, http, auth) {\n var _a, _b;\n switch (scene.method) {\n case "tools/list": {\n if (http && auth) {\n return [\n "import httpx2",\n "from mcp import Client",\n "from mcp.client.streamable_http import streamable_http_client",\n "",\n "http = httpx2.AsyncClient(auth=oauth) # an OAuthClientProvider",\n `async with Client(streamable_http_client(${jsString(sb.api.baseUrl)}, http_client=http)) as client:`,\n " result = await client.list_tools()",\n ];\n }\n if (http)\n return ["from mcp import Client", "", `async with Client(${jsString(sb.api.baseUrl)}) as client:`, " result = await client.list_tools()"];\n const [command, ...args] = sb.api.baseUrl.split(" ");\n return [\n "from mcp import Client, StdioServerParameters",\n "",\n `server = StdioServerParameters(command=${jsString(command)}, args=${list(args)})`,\n "async with Client(server) as client:",\n " result = await client.list_tools()",\n ];\n }\n case "resources/read":\n return [`result = await client.read_resource(${jsString(scene.path)})`];\n case "prompts/get":\n return ["result = await client.get_prompt(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_a = scene.request) !== null && _a !== void 0 ? _a : {}, "python", 4), ",")), ")"];\n default:\n return ["result = await client.call_tool(", ` ${jsString(scene.path)},`, ...indented(" ", wrapLines("", pretty((_b = scene.request) !== null && _b !== void 0 ? _b : {}, "python", 4), ",")), ")"];\n }\n}\nfunction list(items) {\n return `[${items.map(jsString).join(", ")}]`;\n}\nfunction indented(indent, lines) {\n return lines.map((line) => `${indent}${line}`);\n}\nfunction wrapLines(head, lines, tail) {\n if (lines.length === 1)\n return [`${head}${lines[0]}${tail}`];\n return [`${head}${lines[0]}`, ...lines.slice(1, -1), `${lines.at(-1)}${tail}`];\n}\nfunction pretty(value, as, indent) {\n var _a;\n const text = (_a = JSON.stringify(value, null, indent)) !== null && _a !== void 0 ? _a : "null";\n if (as === "json")\n return text.split("\\n");\n return text.split("\\n").map((line) => line.replace(/("(?:[^"\\\\]|\\\\.)*")|\\b(true|false|null)\\b/g, (_, str, word) => str !== null && str !== void 0 ? str : { true: "True", false: "False", null: "None" }[word]));\n}\n\n}, {"../oas/examples":"lib/oas/examples","../storyboard/timing":"lib/storyboard/timing"}],\n"lib/oas/examples": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.PLACEHOLDER_UUID = exports.BINARY_PLACEHOLDER = void 0;\nexports.mediaKind = mediaKind;\nexports.isTextKind = isTextKind;\nexports.exampleForMedia = exampleForMedia;\nexports.toXml = toXml;\nexports.exampleForParameter = exampleForParameter;\nexports.exampleFromSchema = exampleFromSchema;\nexports.conform = conform;\nexports.placeholder = placeholder;\nexports.isPlaceholder = isPlaceholder;\nexports.patternExample = patternExample;\nexports.isIdName = isIdName;\nexports.idLike = idLike;\nexports.uuidLike = uuidLike;\nexports.singular = singular;\nconst fit_1 = require("./fit");\nexports.BINARY_PLACEHOLDER = "<binary data>";\nconst BINARY_MEDIA = /octet-stream|^(image|audio|video|font)\\/|application\\/(pdf|zip|gzip|x-tar)/i;\nfunction mediaKind(contentType) {\n const type = contentType.toLowerCase().split(";")[0].trim();\n if (/^application\\/(x-)?(ndjson|jsonl|jsonlines|json-lines)$|json-seq$/.test(type))\n return "sequence";\n if (/json/.test(type))\n return "json";\n if (type === "application/x-www-form-urlencoded")\n return "form";\n if (type.startsWith("multipart/"))\n return "multipart";\n if (/[/+]xml$/.test(type))\n return "xml";\n if (type === "text/event-stream")\n return "events";\n if (BINARY_MEDIA.test(type))\n return "binary";\n if (type.startsWith("text/") || /^application\\/(x-)?(yaml|csv|graphql|javascript|sql)$/.test(type))\n return "text";\n return "json";\n}\nfunction isTextKind(kind) {\n return kind === "xml" || kind === "sequence" || kind === "events" || kind === "text";\n}\nfunction exampleForMedia(media, mode = "response", contentType = "", subject) {\n if (!media)\n return { value: undefined, generated: false };\n const kind = mediaKind(contentType);\n const given = documentedExample(media, kind);\n if (given !== undefined && !isTextKind(kind) && media.schema && otherShape(given, media.schema)) {\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n }\n if (given !== undefined) {\n if (!isTextKind(kind) && kind !== "binary" && media.schema) {\n const fixed = conform(given, media.schema, mode, "", 0, undefined, subject);\n return { value: fixed, generated: fixed !== given };\n }\n return { value: serialize(given, kind, media, contentType), generated: false };\n }\n if (BINARY_MEDIA.test(contentType) && (!media.schema || media.schema.type === "string" || media.schema.format === "binary")) {\n return { value: exports.BINARY_PLACEHOLDER, generated: true };\n }\n if (isTextKind(kind) && (media.schema || media.itemSchema))\n return { value: textFromSchema(media, kind, mode, contentType), generated: true };\n if (media.schema)\n return { value: conform(exampleFromSchema(media.schema, "", 0, mode, undefined, subject), media.schema, mode, "", 0, undefined, subject), generated: true };\n return { value: undefined, generated: false };\n}\nfunction otherShape(example, schema) {\n if (!isRecord(example) || !Object.keys(example).length)\n return false;\n const names = new Set();\n const patterns = [];\n let open = false;\n const collect = (s, depth) => {\n var _a, _b, _c, _d, _e;\n if (!s || typeof s !== "object" || depth > 6)\n return;\n const target = (0, fit_1.circularTarget)(s);\n if (target)\n return collect(target, depth + 1);\n for (const key of Object.keys((_a = s.properties) !== null && _a !== void 0 ? _a : {}))\n names.add(key);\n patterns.push(...Object.keys((_b = s.patternProperties) !== null && _b !== void 0 ? _b : {}));\n if (isRecord(s.additionalProperties))\n open = true;\n for (const part of [...((_c = s.allOf) !== null && _c !== void 0 ? _c : []), ...((_d = s.oneOf) !== null && _d !== void 0 ? _d : []), ...((_e = s.anyOf) !== null && _e !== void 0 ? _e : [])])\n collect(part, depth + 1);\n };\n collect(schema, 0);\n if (!names.size || open)\n return false;\n return !Object.keys(example).some((key) => names.has(key) || patterns.some((pattern) => (0, fit_1.matchesPattern)(pattern, key)));\n}\nfunction documentedExample(media, kind) {\n var _a;\n if (media.example !== undefined)\n return media.example;\n for (const example of Object.values((_a = media.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = exampleValue(example, isTextKind(kind));\n if (value !== undefined)\n return kind === "json" && (example === null || example === void 0 ? void 0 : example.dataValue) === undefined && (example === null || example === void 0 ? void 0 : example.value) === undefined ? parseJsonText(value) : value;\n }\n return undefined;\n}\nfunction exampleValue(example, text) {\n if (!example || typeof example !== "object")\n return undefined;\n const serialized = typeof example.serializedValue === "string" ? example.serializedValue : undefined;\n if (text && serialized !== undefined)\n return serialized;\n if (example.dataValue !== undefined)\n return example.dataValue;\n return example.value !== undefined ? example.value : serialized;\n}\nfunction parseJsonText(value) {\n if (typeof value !== "string")\n return value;\n try {\n return JSON.parse(value);\n }\n catch {\n return value;\n }\n}\nfunction serialize(value, kind, media, contentType) {\n if (!isTextKind(kind) || typeof value === "string")\n return value;\n switch (kind) {\n case "xml":\n return toXml(value, media.schema);\n case "sequence":\n return (Array.isArray(value) ? value : [value]).map((item) => JSON.stringify(item)).join("\\n");\n case "events":\n return (Array.isArray(value) ? value : [value]).map((event) => toEvent(event, media.itemSchema)).join("\\n\\n");\n default:\n return toText(value, contentType);\n }\n}\nfunction textFromSchema(media, kind, mode, contentType) {\n var _a, _b;\n const schema = (_a = media.schema) !== null && _a !== void 0 ? _a : {};\n const made = (s) => conform(exampleFromSchema(s, "", 0, mode), s, mode);\n if (kind === "xml")\n return toXml(made(schema), schema);\n if (kind === "sequence" || kind === "events") {\n const item = (_b = media.itemSchema) !== null && _b !== void 0 ? _b : (schema.items && (schema.type === "array" || Array.isArray(schema.type)) ? schema.items : schema);\n const value = made(item);\n return kind === "sequence" ? JSON.stringify(value) : toEvent(value, item);\n }\n return toText(made(schema), contentType);\n}\nfunction toEvent(value, schema) {\n var _a, _b, _c;\n const fields = isRecord(value) && "data" in value ? value : { data: value };\n const lines = [];\n for (const key of ["event", "id", "retry"])\n if (fields[key] !== undefined && fields[key] !== null)\n lines.push(`${key}: ${String(fields[key])}`);\n let data = fields.data;\n const dataSchema = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a.data;\n if (typeof data === "string" && (dataSchema === null || dataSchema === void 0 ? void 0 : dataSchema.contentSchema) && /json/i.test((_b = dataSchema.contentMediaType) !== null && _b !== void 0 ? _b : "json"))\n data = exampleFromSchema(dataSchema.contentSchema, "data");\n for (const line of (typeof data === "string" ? data : (_c = JSON.stringify(data)) !== null && _c !== void 0 ? _c : "").split("\\n"))\n lines.push(`data: ${line}`);\n return lines.join("\\n");\n}\nfunction toText(value, contentType) {\n if (typeof value === "string")\n return value;\n if (/csv/i.test(contentType) && Array.isArray(value) && value.every(isRecord)) {\n const columns = [...new Set(value.flatMap((row) => Object.keys(row)))];\n const cell = (v) => (/[",\\n]/.test(String(v !== null && v !== void 0 ? v : "")) ? `"${String(v).replace(/"/g, \'""\')}"` : String(v !== null && v !== void 0 ? v : ""));\n return [columns.join(","), ...value.map((row) => columns.map((c) => cell(row[c])).join(","))].join("\\n");\n }\n return typeof value === "object" && value !== null ? JSON.stringify(value, null, 2) : String(value);\n}\nfunction toXml(value, schema, name) {\n var _a, _b, _c, _d, _e, _f, _g;\n const lines = [];\n const rootName = (_d = (_c = (_b = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : name) !== null && _c !== void 0 ? _c : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _d !== void 0 ? _d : (Array.isArray(value) ? "items" : "data");\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_g = (_f = (_e = items === null || items === void 0 ? void 0 : items.xml) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : items === null || items === void 0 ? void 0 : items.title) !== null && _g !== void 0 ? _g : singular(rootName);\n lines.push(`<${xmlName(rootName, schema)}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, 1);\n lines.push(`</${xmlName(rootName, schema)}>`);\n }\n else {\n writeXml(lines, rootName, value, schema, 0, true);\n }\n return lines.join("\\n");\n}\nfunction writeXml(lines, name, value, schema, depth, root = false) {\n var _a, _b, _c, _d, _e, _f, _g, _h, _j;\n const pad = " ".repeat(depth);\n const xml = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) !== null && _a !== void 0 ? _a : {};\n const qname = xmlName((_b = xml.name) !== null && _b !== void 0 ? _b : name, schema);\n if (Array.isArray(value)) {\n const items = schema === null || schema === void 0 ? void 0 : schema.items;\n const itemName = (_d = (_c = items === null || items === void 0 ? void 0 : items.xml) === null || _c === void 0 ? void 0 : _c.name) !== null && _d !== void 0 ? _d : name;\n if (xml.nodeType === "element" || xml.wrapped === true) {\n lines.push(`${pad}<${qname}${namespaceAttr(schema)}>`);\n for (const item of value)\n writeXml(lines, itemName, item, items, depth + 1);\n lines.push(`${pad}</${qname}>`);\n }\n else {\n for (const item of value)\n writeXml(lines, itemName, item, items, depth);\n }\n return;\n }\n if (value === null || value === undefined) {\n lines.push(`${pad}<${qname} xsi:nil="true"/>`);\n return;\n }\n if (!isRecord(value)) {\n lines.push(`${pad}<${qname}${root ? namespaceAttr(schema) : ""}>${escapeXml(String(value))}</${qname}>`);\n return;\n }\n const properties = propertiesOf(schema);\n const attributes = [];\n const children = [];\n let text;\n for (const [key, child] of Object.entries(value)) {\n const prop = properties[key];\n const nodeType = (_f = (_e = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _e === void 0 ? void 0 : _e.nodeType) !== null && _f !== void 0 ? _f : (((_g = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _g === void 0 ? void 0 : _g.attribute) ? "attribute" : undefined);\n if (nodeType === "attribute") {\n if (child !== null && child !== undefined)\n attributes.push(` ${xmlName((_j = (_h = prop === null || prop === void 0 ? void 0 : prop.xml) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : key, prop)}="${escapeXml(String(child), true)}"`);\n }\n else if (nodeType === "text" || nodeType === "cdata") {\n text = nodeType === "cdata" ? `<![CDATA[${String(child)}]]>` : escapeXml(String(child));\n }\n else {\n children.push([key, child, prop]);\n }\n }\n const open = `${pad}<${qname}${namespaceAttr(schema)}${attributes.join("")}`;\n if (!children.length) {\n lines.push(text === undefined ? `${open}/>` : `${open}>${text}</${qname}>`);\n return;\n }\n lines.push(`${open}>${text !== null && text !== void 0 ? text : ""}`);\n for (const [key, child, prop] of children)\n writeXml(lines, key, child, prop, depth + 1);\n lines.push(`${pad}</${qname}>`);\n}\nfunction propertiesOf(schema, depth = 0) {\n var _a, _b;\n if (!schema || depth > 4)\n return {};\n const out = {};\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n Object.assign(out, propertiesOf(part, depth + 1));\n return Object.assign(out, (_b = schema.properties) !== null && _b !== void 0 ? _b : {});\n}\nfunction xmlName(name, schema) {\n var _a;\n let clean = name.replace(/[^\\w.:-]/g, "_");\n if (!/^[A-Za-z_]/.test(clean))\n clean = `_${clean}`;\n const prefix = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.prefix;\n return prefix && !clean.includes(":") ? `${prefix}:${clean}` : clean;\n}\nfunction namespaceAttr(schema) {\n var _a, _b;\n const ns = (_a = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _a === void 0 ? void 0 : _a.namespace;\n if (!ns)\n return "";\n return ` xmlns${((_b = schema === null || schema === void 0 ? void 0 : schema.xml) === null || _b === void 0 ? void 0 : _b.prefix) ? `:${schema.xml.prefix}` : ""}="${escapeXml(ns, true)}"`;\n}\nfunction escapeXml(text, attribute = false) {\n if (isPlaceholder(text))\n return `{${text.slice(1, -1)}}`;\n const out = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");\n return attribute ? out.replace(/"/g, """) : out;\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction exampleForParameter(param) {\n var _a;\n const typed = (value) => (value === undefined || !param.schema ? value : asType(value, param.schema));\n const given = typed(param.example);\n if (given !== undefined)\n return given;\n for (const example of Object.values((_a = param.examples) !== null && _a !== void 0 ? _a : {})) {\n const value = typed(exampleValue(example, false));\n if (value !== undefined)\n return value;\n }\n const content = param.content && Object.entries(param.content)[0];\n if (content)\n return exampleForMedia(content[1], "request", content[0]).value;\n if (param.schema)\n return exampleFromSchema(param.schema, param.name);\n return idLike(param.name);\n}\nconst MAX_DEPTH = 4;\nconst HARD_DEPTH = 12;\nconst MAX_PROPERTIES = 12;\nconst NODE_BUDGET = 250;\nconst MAX_LIST = 20;\nconst MAX_TRIES = 6;\nfunction exampleFromSchema(schema, name = "", depth = 0, mode = "response", budget = { left: NODE_BUDGET }, owner) {\n var _a;\n if (!schema || typeof schema !== "object")\n return null;\n budget.left--;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return depth >= HARD_DEPTH ? {} : exampleFromSchema(target, name, Math.max(depth + 1, MAX_DEPTH), mode, budget, owner);\n if (schema["x-circular"])\n return depth > 1 ? null : { id: idLike((_a = schema.title) !== null && _a !== void 0 ? _a : name) };\n for (const example of [schema.example, ...(Array.isArray(schema.examples) ? schema.examples.slice(0, 1) : [])]) {\n const value = example === undefined ? undefined : asType(example, schema);\n if (value !== undefined)\n return fitted(value, schema, name, depth, mode, budget, owner);\n }\n if (schema.const !== undefined)\n return schema.const;\n const fallback = schema.default === undefined ? undefined : asType(schema.default, schema);\n if (fallback !== undefined)\n return fitted(fallback, schema, name, depth, mode, budget, owner);\n return fromSchema(schema, name, depth, mode, budget, owner);\n}\nfunction fromSchema(schema, name, depth, mode, budget, owner) {\n var _a, _b;\n if (Array.isArray(schema.enum) && schema.enum.length)\n return enumValue(schema.enum, schema.description);\n if ((_a = schema.allOf) === null || _a === void 0 ? void 0 : _a.length)\n return fromParts(schema, name, depth, mode, budget, owner);\n const variants = ((_b = schema.oneOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.oneOf : schema.anyOf;\n if (variants === null || variants === void 0 ? void 0 : variants.length)\n return fromVariant(schema, variants, name, depth, mode, budget, owner);\n const type = Array.isArray(schema.type) ? schema.type.find((t) => t !== "null") : schema.type;\n const inferred = type !== null && type !== void 0 ? type : (schema.properties ? "object" : schema.items || schema.prefixItems ? "array" : undefined);\n switch (inferred) {\n case "object":\n return objectFor(schema, depth, mode, budget, owner);\n case "array":\n return listFor(schema, name, depth, mode, budget, owner);\n case "integer":\n case "number":\n return numberFor(schema, name, inferred === "integer");\n case "boolean":\n return booleanFor(name);\n case "string":\n return stringFor(schema, name, owner);\n default:\n return null;\n }\n}\nfunction objectFor(schema, depth, mode, budget, owner) {\n var _a, _b;\n const out = {};\n if (depth >= HARD_DEPTH)\n return out;\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n let props = Object.entries((_a = schema.properties) !== null && _a !== void 0 ? _a : {}).filter(([, prop]) => !(mode === "request" ? prop === null || prop === void 0 ? void 0 : prop.readOnly : prop === null || prop === void 0 ? void 0 : prop.writeOnly));\n props = props.filter(([key, prop]) => required.has(key) || (prop === null || prop === void 0 ? void 0 : prop.deprecated) !== true);\n const answer = mode === "response" && !budget.full;\n if (answer)\n props = props.filter(([key, prop]) => required.has(key) || ((ID_FIELDS.has(key) || saysSomething(prop)) && !brokenExample(prop, mode)));\n if (depth >= MAX_DEPTH)\n props = props.filter(([key]) => required.has(key));\n props.sort(([a], [b]) => Number(required.has(b)) - Number(required.has(a)));\n if (mode === "request")\n props = telling(props, required);\n for (const [key, prop] of props) {\n if (!required.has(key) && (budget.left <= 0 || Object.keys(out).length >= MAX_PROPERTIES))\n continue;\n if (!required.has(key) && recursive(prop))\n continue;\n const value = fieldValue(prop, key, depth + 1, mode, budget, (_b = schema.title) !== null && _b !== void 0 ? _b : owner);\n if (!required.has(key) && (value === null || (mode === "request" && isEmpty(value))))\n continue;\n out[key] = value;\n }\n return out;\n}\nfunction fieldValue(prop, key, depth, mode, budget, owner) {\n if (mode === "response" && !budget.full && allowsNull(prop) && (!givesValue(prop) || brokenExample(prop, mode)))\n return null;\n return exampleFromSchema(prop, key, depth, mode, budget, owner);\n}\nfunction brokenExample(prop, mode) {\n if (!prop || typeof prop !== "object" || prop.example === undefined || prop.example === null)\n return false;\n if ((0, fit_1.fits)(prop.example, prop, mode))\n return false;\n const typed = asType(prop.example, prop);\n if (typed === undefined)\n return true;\n const plain = (v) => v === null || typeof v !== "object";\n return (plain(typed) || (Array.isArray(typed) && typed.every(plain))) && !(0, fit_1.fits)(typed, prop, mode);\n}\nfunction recursive(schema) {\n const own = (s) => isRecord(s) && s["x-circular"] !== undefined;\n return own(schema) || (isRecord(schema) && own(schema.items));\n}\nconst ID_FIELDS = new Set(["id", "sid", "gid", "uuid"]);\nfunction givesValue(schema, depth = 0) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return false;\n if (schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0) || schema.default !== undefined || schema.const !== undefined)\n return true;\n if (Array.isArray(schema.enum) && schema.enum.filter((v) => v !== null).length === 1 && !allowsNull(schema))\n return true;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return givesValue(target, depth + 1);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.oneOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.anyOf) !== null && _c !== void 0 ? _c : [])];\n return parts.some((part) => part && typeof part === "object" && part.type !== "null" && givesValue(part, depth + 1));\n}\nconst saying = new WeakMap();\nfunction saysSomething(schema, depth = 0) {\n var _a, _b, _c, _d, _e, _f;\n if (!schema || typeof schema !== "object" || depth > 1)\n return false;\n const found = (_a = saying.get(schema)) !== null && _a !== void 0 ? _a : [];\n if (found[depth] !== undefined)\n return found[depth];\n found[depth] = false;\n saying.set(schema, found);\n const target = (0, fit_1.circularTarget)(schema);\n const parts = [...((_b = schema.allOf) !== null && _b !== void 0 ? _b : []), ...((_c = schema.oneOf) !== null && _c !== void 0 ? _c : []), ...((_d = schema.anyOf) !== null && _d !== void 0 ? _d : []), ...(target ? [target] : [])];\n const inside = [...Object.values((_e = schema.properties) !== null && _e !== void 0 ? _e : {}), ...(schema.items && typeof schema.items === "object" ? [schema.items] : []), ...((_f = schema.prefixItems) !== null && _f !== void 0 ? _f : [])];\n const usable = (part) => part && typeof part === "object" && part.type !== "null";\n const own = depth === 0 ? givesValue(schema) : schema.example !== undefined || (Array.isArray(schema.examples) && schema.examples.length > 0);\n const says = own || parts.some((part) => usable(part) && saysSomething(part, depth)) || inside.some((part) => usable(part) && saysSomething(part, depth + 1));\n found[depth] = says;\n return says;\n}\nfunction allowsNull(schema) {\n var _a, _b;\n if (!schema || typeof schema !== "object")\n return false;\n if (schema.nullable === true || (Array.isArray(schema.type) && schema.type.includes("null")) || schema.type === "null")\n return true;\n if (Array.isArray(schema.enum) && schema.enum.includes(null))\n return true;\n const variants = [...((_a = schema.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = schema.anyOf) !== null && _b !== void 0 ? _b : [])];\n const isNull = (v) => v.type === "null" || (Array.isArray(v.type) && v.type.length === 1 && v.type[0] === "null") || (Array.isArray(v.enum) && v.enum.length === 1 && v.enum[0] === null);\n return variants.some((v) => v && typeof v === "object" && isNull(v));\n}\nfunction listFor(schema, name, depth, mode, budget, owner) {\n var _a;\n const least = Math.min(Math.max(0, typeof schema.minItems === "number" ? schema.minItems : 0), MAX_LIST);\n const most = typeof schema.maxItems === "number" ? Math.max(0, schema.maxItems) : Infinity;\n if (most === 0)\n return [];\n if ((depth >= MAX_DEPTH || budget.left <= 0) && least === 0)\n return [];\n const itemName = singular(name);\n const itemOwner = itemName && !CONTAINERS.test(itemName) ? itemName : owner;\n const prefix = ((_a = schema.prefixItems) !== null && _a !== void 0 ? _a : []).slice(0, most);\n const out = prefix.map((item) => exampleFromSchema(item, itemName, depth + 1, mode, budget, itemOwner));\n const items = isRecord(schema.items) ? schema.items : undefined;\n const answer = mode === "response" && !budget.full;\n const shows = !answer || depth === 0 || (depth === 1 && CONTAINERS.test(name)) || saysSomething(items);\n const want = Math.min(most, Math.max(least, prefix.length ? prefix.length : items && shows ? 1 : 0));\n while (out.length < want) {\n if (!items) {\n out.push(null);\n continue;\n }\n const value = exampleFromSchema(items, itemName, depth + 1, mode, budget, itemOwner);\n if (answer && out.length >= least && isRecord(value) && !Object.keys(value).length)\n break;\n out.push(out.length > prefix.length ? distinct(value, out, items, mode) : value);\n }\n return out;\n}\nconst CONTAINERS = /^(data|items?|results?|list|entr(y|ie)|records?|values?|objects?|nodes?|edges?|elements?|rows?|hits?|match(e)?|contents?|resources?)$/i;\nfunction distinct(value, taken, schema, mode) {\n var _a, _b, _c, _d;\n const n = taken.length + 1;\n const free = (candidate) => !taken.some((t) => (0, fit_1.equal)(t, candidate)) && (0, fit_1.fits)(candidate, schema, mode);\n if (!taken.some((t) => (0, fit_1.equal)(t, value)))\n return value;\n const candidates = [];\n if (Array.isArray(schema.enum))\n candidates.push(...schema.enum);\n if (typeof value === "string" && isPlaceholder(value))\n candidates.push(`${value.slice(0, -1)}_${n}>`);\n if (typeof value === "string") {\n const at = value.indexOf("@");\n if (at > 0)\n candidates.push(`${value.slice(0, at)}+${n}${value.slice(at)}`);\n candidates.push(`${value}_${n}`, `${value}${n}`, `${n}${value.slice(1)}`);\n }\n else if (typeof value === "number")\n candidates.push(value + n - 1, value + (n - 1) * 10, value - (n - 1));\n else if (typeof value === "boolean")\n candidates.push(!value);\n else if (isRecord(value)) {\n const key = (_a = Object.keys(value).find((k) => k === "id" || isIdName(k))) !== null && _a !== void 0 ? _a : Object.keys(value).find((k) => typeof value[k] === "string" || typeof value[k] === "number");\n if (key !== undefined) {\n const inner = (_c = (_b = schema.properties) === null || _b === void 0 ? void 0 : _b[key]) !== null && _c !== void 0 ? _c : {};\n const varied = distinct(value[key], taken.flatMap((t) => (isRecord(t) ? [t[key]] : [])), inner, mode);\n candidates.push({ ...value, [key]: varied });\n }\n }\n return (_d = candidates.find(free)) !== null && _d !== void 0 ? _d : value;\n}\nconst ON_FLAGS = /^(is_?|has_?|can_?)?(enabled|active|verified|valid|available|visible|confirmed|success|successful|ok|allowed|approved|ready|supported)$/i;\nfunction booleanFor(name) {\n return ON_FLAGS.test(name.replace(/-/g, "_"));\n}\nfunction fitted(value, schema, name, depth, mode, budget, owner) {\n return (0, fit_1.fits)(value, schema, mode) ? value : conform(value, schema, mode, name, depth, budget, owner);\n}\nfunction conform(value, schema, mode = "response", name = "", depth = 0, budget = { left: NODE_BUDGET }, owner) {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > HARD_DEPTH || (0, fit_1.fits)(value, schema, mode))\n return value;\n const target = (0, fit_1.circularTarget)(schema);\n if (target)\n return conform(value, target, mode, name, depth + 1, budget, owner);\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const variants = ((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length) ? schema.oneOf : ((_b = schema.anyOf) === null || _b === void 0 ? void 0 : _b.length) ? schema.anyOf : undefined;\n if (variants) {\n const base = { ...schema, oneOf: undefined, anyOf: undefined };\n const ranked = variants\n .filter((v) => isRecord(v))\n .map((v) => ({ v, misses: (0, fit_1.misfits)(value, { allOf: [base, v] }, mode, 40).length }))\n .sort((a, b) => a.misses - b.misses);\n let closest;\n for (const { v } of ranked.slice(0, MAX_TRIES)) {\n const fixed = conform(value, { allOf: [base, v] }, mode, name, depth + 1, budget, owner);\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n closest !== null && closest !== void 0 ? closest : (closest = fixed);\n }\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) || closest === undefined ? made : closest;\n }\n if ((_c = schema.allOf) === null || _c === void 0 ? void 0 : _c.length) {\n let fixed = value;\n const required = requiredIn(schema);\n for (const part of [...schema.allOf, { ...schema, allOf: undefined }]) {\n if (isRecord(part))\n fixed = conform(fixed, required.length ? { ...part, required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : part, mode, name, depth + 1, budget, owner);\n }\n if ((0, fit_1.fits)(fixed, schema, mode))\n return fixed;\n const made = fresh();\n return (0, fit_1.fits)(made, schema, mode) ? made : fixed;\n }\n return conformOne(value, schema, mode, name, depth, budget, owner);\n}\nfunction conformOne(value, schema, mode, name, depth, budget, owner) {\n var _a, _b, _c, _d, _e;\n if ((0, fit_1.fits)(value, { ...schema, allOf: undefined, oneOf: undefined, anyOf: undefined, not: undefined }, mode))\n return value;\n const fresh = () => fromSchema({ ...schema, example: undefined, examples: undefined, default: undefined }, name, depth, mode, budget, owner);\n const types = typesOf(schema);\n if (types.length && !(value === null && schema.nullable) && !ofType(value, schema)) {\n const typed = asType(value, schema);\n return typed !== undefined && (0, fit_1.fits)(typed, schema, mode) ? typed : fresh();\n }\n if (schema.const !== undefined && !(0, fit_1.equal)(value, schema.const))\n return schema.const;\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => (0, fit_1.equal)(e, value)))\n return enumValue(schema.enum, schema.description);\n if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null)\n return fresh();\n if (Array.isArray(value)) {\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n const items = !legacy && isRecord(schema.items) ? schema.items : undefined;\n let out = value.map((item, i) => conform(item, i < prefix.length ? prefix[i] : items, mode, singular(name), depth + 1, budget, singular(name) || owner));\n if (schema.uniqueItems === true)\n out = out.filter((item, i) => out.findIndex((other) => (0, fit_1.equal)(other, item)) === i);\n if (typeof schema.maxItems === "number")\n out = out.slice(0, Math.max(0, schema.maxItems));\n const least = Math.min(typeof schema.minItems === "number" ? schema.minItems : 0, MAX_LIST);\n while (out.length < least) {\n const index = out.length;\n const sub = index < prefix.length ? prefix[index] : items;\n const made = sub ? exampleFromSchema(sub, singular(name), depth + 1, mode, budget, singular(name) || owner) : null;\n out.push(sub ? distinct(made, out, sub, mode) : made);\n }\n return out;\n }\n if (isRecord(value)) {\n const props = (isRecord(schema.properties) ? schema.properties : {});\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n const extra = schema.additionalProperties;\n const title = (_c = schema.title) !== null && _c !== void 0 ? _c : owner;\n const out = {};\n for (const [key, item] of Object.entries(value)) {\n const prop = Object.prototype.hasOwnProperty.call(props, key) ? props[key] : undefined;\n const matched = (_d = patterns.find(([pattern]) => (0, fit_1.matchesPattern)(pattern, key))) === null || _d === void 0 ? void 0 : _d[1];\n if (!prop && !matched && extra === false)\n continue;\n const sub = (_e = prop !== null && prop !== void 0 ? prop : matched) !== null && _e !== void 0 ? _e : (isRecord(extra) ? extra : undefined);\n const optional = !(Array.isArray(schema.required) && schema.required.includes(key));\n if (item === null && sub && !allowsNull(sub) && optional)\n continue;\n if (mode === "response" && !budget.full && optional && sub && item !== null && typeof item !== "object" && !(0, fit_1.fits)(item, sub, mode)) {\n const typed = asType(item, sub);\n if (typed === undefined || !(0, fit_1.fits)(typed, sub, mode))\n continue;\n }\n setField(out, key, sub ? conform(item, sub, mode, key, depth + 1, budget, title) : item);\n }\n for (const key of Array.isArray(schema.required) ? schema.required : []) {\n if (typeof key !== "string" || key in out)\n continue;\n const prop = props[key];\n if (prop && (mode === "request" ? prop.readOnly : prop.writeOnly))\n continue;\n const sub = prop !== null && prop !== void 0 ? prop : (isRecord(extra) ? extra : undefined);\n setField(out, key, sub ? fieldValue(sub, key, depth + 1, mode, budget, title) : null);\n }\n for (const [key, prop] of Object.entries(props)) {\n if (typeof schema.minProperties !== "number" || Object.keys(out).length >= schema.minProperties)\n break;\n if (!(key in out))\n setField(out, key, exampleFromSchema(prop, key, depth + 1, mode, budget, title));\n }\n return out;\n }\n return fresh();\n}\nfunction setField(out, key, value) {\n if (key === "__proto__")\n Object.defineProperty(out, key, { value, enumerable: true, writable: true, configurable: true });\n else\n out[key] = value;\n}\nfunction asType(value, schema) {\n const types = typesOf(schema);\n if (ofType(value, schema))\n return value;\n if (typeof value === "string" && (types.includes("object") || types.includes("array"))) {\n try {\n const parsed = JSON.parse(value);\n if (ofType(parsed, schema))\n return parsed;\n }\n catch {\n }\n }\n if (types.includes("string") && Array.isArray(value) && value.length && value.every((v) => typeof v === "string" || typeof v === "number"))\n return value.join(",");\n if (types.includes("object") && Array.isArray(value) && value.length === 1 && isRecord(value[0]))\n return value[0];\n if (typeof value === "string" && value.trim() && (types.includes("number") || types.includes("integer")) && ofType(Number(value), schema))\n return Number(value);\n if (typeof value === "string" && types.includes("boolean") && /^(true|false)$/.test(value))\n return value === "true";\n if (typeof value === "number" && types.includes("string") && Number.isFinite(value))\n return String(value);\n return undefined;\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction ofType(value, schema) {\n const types = typesOf(schema);\n if (!types.length || (value === null && schema.nullable))\n return true;\n return types.some((t) => (t === "integer" ? Number.isInteger(value) : t === "number" ? typeof value === "number" : t === "object" ? isRecord(value) : t === "array" ? Array.isArray(value) : t === "null" ? value === null : typeof value === t));\n}\nfunction sharedProperties(parts) {\n const all = new Map();\n const collect = (schema, title, depth) => {\n var _a, _b, _c;\n if (!schema || typeof schema !== "object" || depth > 4)\n return;\n for (const part of (_a = schema.allOf) !== null && _a !== void 0 ? _a : [])\n collect(part, title, depth + 1);\n for (const [key, def] of Object.entries((_b = schema.properties) !== null && _b !== void 0 ? _b : {})) {\n if (!def || typeof def !== "object")\n continue;\n const entry = (_c = all.get(key)) !== null && _c !== void 0 ? _c : { defs: [] };\n if (!entry.defs.includes(def))\n entry.defs.push(def);\n entry.title = title;\n all.set(key, entry);\n }\n };\n for (const part of parts)\n collect(part, part.title, 0);\n return new Map([...all].filter(([, entry]) => entry.defs.length > 1));\n}\nfunction requiredIn(schema, depth = 0) {\n var _a;\n if (!schema || typeof schema !== "object" || depth > 4)\n return [];\n const own = Array.isArray(schema.required) ? schema.required.filter((r) => typeof r === "string") : [];\n return [...new Set([...own, ...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []).flatMap((part) => requiredIn(part, depth + 1))])];\n}\nfunction fromParts(schema, name, depth, mode, budget, owner) {\n var _a, _b, _c;\n const merged = {};\n const plain = [];\n const required = requiredIn(schema);\n const parts = [...((_a = schema.allOf) !== null && _a !== void 0 ? _a : []), ...(schema.properties ? [{ ...schema, allOf: undefined }] : [])].filter((part) => part && typeof part === "object");\n const again = { left: budget.left, full: budget.full };\n for (const part of parts) {\n const whole = { ...part, ...(schema.title ? { title: schema.title } : {}), ...(required.length ? { required: [...new Set([...(Array.isArray(part.required) ? part.required : []), ...required])] } : {}) };\n const value = exampleFromSchema(whole, name, depth, mode, budget, owner);\n if (isRecord(value))\n Object.assign(merged, value);\n else if (value !== null && value !== undefined)\n plain.push(value);\n }\n for (const [key, { defs, title }] of sharedProperties(parts)) {\n if (!(key in merged) || defs.every((def) => (0, fit_1.fits)(merged[key], def, mode)))\n continue;\n const value = exampleFromSchema({ allOf: defs }, key, depth + 1, mode, again, (_c = (_b = schema.title) !== null && _b !== void 0 ? _b : title) !== null && _c !== void 0 ? _c : owner);\n if (value !== null && value !== undefined)\n merged[key] = value;\n }\n if (plain.length && Object.keys(merged).length === 0) {\n const fitting = [...plain].reverse().find((value) => parts.every((part) => (0, fit_1.fits)(value, part, mode)));\n if (fitting !== undefined)\n return fitting;\n for (const variant of parts.flatMap((part) => { var _a, _b; return [...((_a = part.oneOf) !== null && _a !== void 0 ? _a : []), ...((_b = part.anyOf) !== null && _b !== void 0 ? _b : [])]; })) {\n if (!isRecord(variant) || variant.type === "null")\n continue;\n const value = exampleFromSchema(variant, name, depth, mode, again, owner);\n if (value !== null && value !== undefined && parts.every((part) => (0, fit_1.fits)(value, part, mode)))\n return value;\n }\n const items = parts.flatMap((part) => (part.items && typeof part.items === "object" ? [part.items] : []));\n if (items.length > 1 && plain.some(Array.isArray))\n return exampleFromSchema({ type: "array", items: { allOf: items } }, name, depth, mode, again, owner);\n return plain[0];\n }\n return merged;\n}\nconst ENDINGS = /^(cancel+ed|cancel+ing|failed|failure|errored|error|declined|rejected|expired|deleted|voided|void|refunded|disputed|revoked|suspended|blocked|disabled|inactive|abandoned|lost|unpaid|past_due|incomplete_expired)$/i;\nfunction enumValue(values, description) {\n var _a, _b;\n const said = values.filter((v) => v !== "" && v !== null);\n const mentioned = (v) => {\n if (typeof v !== "string" || !description)\n return Infinity;\n const at = description.search(new RegExp(`[\\`\'"]${v.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")}[\\`\'"]`));\n return at < 0 ? Infinity : at;\n };\n const ordered = said.map((v, i) => ({ v, i, at: mentioned(v) })).sort((a, b) => a.at - b.at || a.i - b.i).map(({ v }) => v);\n return (_b = (_a = ordered.find((v) => typeof v !== "string" || !ENDINGS.test(v))) !== null && _a !== void 0 ? _a : ordered[0]) !== null && _b !== void 0 ? _b : values[0];\n}\nfunction fromVariant(schema, variants, name, depth, mode, budget, owner) {\n var _a;\n const usable = variants.filter((v) => v && typeof v === "object" && v.type !== "null" && Object.keys(v).some((k) => !/^(description|title|nullable)$/.test(k)));\n const first = (schema.properties && usable.find((v) => v.properties || v.type === "object")) || usable[0] || variants[0];\n const exclusive = Boolean((_a = schema.oneOf) === null || _a === void 0 ? void 0 : _a.length);\n let made;\n for (const variant of [first, ...usable.filter((v) => v !== first)].slice(0, MAX_TRIES)) {\n const value = fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner);\n if (made === undefined)\n made = value;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n if (mode === "response" && !budget.full) {\n const full = { left: budget.left, full: true };\n const value = fromVariant(schema, variants, name, depth, mode, full, owner);\n budget.left = full.left;\n if ((0, fit_1.fits)(value, schema, mode))\n return value;\n }\n return made;\n}\nfunction fromOneVariant(schema, variants, variant, exclusive, name, depth, mode, budget, owner) {\n var _a, _b, _c, _d, _e;\n if (variant && typeof variant === "object" && !describesValue(variant)) {\n const required = [...new Set([...(Array.isArray(schema.required) ? schema.required : []), ...(Array.isArray(variant.required) ? variant.required : [])])];\n const others = exclusive ? new Set(variants.filter((v) => v !== variant && isRecord(v) && Array.isArray(v.required)).flatMap((v) => v.required).filter((k) => !required.includes(k))) : new Set();\n const properties = schema.properties && others.size ? Object.fromEntries(Object.entries(schema.properties).filter(([key]) => !others.has(key))) : schema.properties;\n return exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined, ...(properties ? { properties } : {}), ...(required.length ? { required } : {}) }, name, depth, mode, budget, owner);\n }\n const value = exampleFromSchema(variant, name, depth, mode, budget, owner);\n if (!value || typeof value !== "object" || Array.isArray(value))\n return value;\n const out = schema.properties ? { ...exampleFromSchema({ ...schema, oneOf: undefined, anyOf: undefined }, name, depth, mode, budget, owner), ...value } : { ...value };\n const discriminator = schema.discriminator;\n const property = discriminator === null || discriminator === void 0 ? void 0 : discriminator.propertyName;\n const mapping = discriminator === null || discriminator === void 0 ? void 0 : discriminator.mapping;\n if (property && isRecord(mapping) && !((_b = (_a = variant.properties) === null || _a === void 0 ? void 0 : _a[property]) === null || _b === void 0 ? void 0 : _b.enum) && ((_d = (_c = variant.properties) === null || _c === void 0 ? void 0 : _c[property]) === null || _d === void 0 ? void 0 : _d.const) === undefined) {\n const entries = Object.entries(mapping);\n const named = entries.find(([, target]) => variant.title && typeof target === "string" && target.split("/").pop() === variant.title);\n const entry = (_e = named !== null && named !== void 0 ? named : entries[variants.indexOf(variant)]) !== null && _e !== void 0 ? _e : entries[0];\n if (entry)\n out[property] = entry[0];\n }\n return out;\n}\nconst VALUE_KEYWORDS = ["type", "properties", "items", "prefixItems", "allOf", "oneOf", "anyOf", "enum", "const", "example", "examples", "default", "format", "pattern", "additionalProperties", "$ref", "x-circular"];\nfunction describesValue(schema) {\n return VALUE_KEYWORDS.some((key) => key in schema);\n}\nconst MAX_OPTIONAL = 3;\nconst TELLING_NAMES = /^(to|from|subject|text|html|body|content|message|title|name|email|description|amount|currency|quantity|customer|price|product|channel|phone|url|\\w+_url)$/i;\nfunction telling(props, required) {\n const must = props.filter(([key]) => required.has(key));\n const rank = ([key, prop]) => (TELLING_NAMES.test(key) || isIdName(key) ? 0 : 2) + (looksReal(key, prop) ? 0 : 1);\n const optional = props\n .filter(([key]) => !required.has(key))\n .map((entry, i) => ({ entry, i, rank: rank(entry) }))\n .sort((a, b) => a.rank - b.rank || a.i - b.i)\n .slice(0, must.length ? MAX_OPTIONAL : MAX_OPTIONAL + 1)\n .sort((a, b) => a.i - b.i);\n return [...must, ...optional.map((o) => o.entry)];\n}\nfunction looksReal(key, prop) {\n if (!prop || typeof prop !== "object")\n return false;\n if (prop.example !== undefined || prop.examples !== undefined || prop.default !== undefined || prop.enum || prop.const !== undefined)\n return true;\n const type = Array.isArray(prop.type) ? prop.type.find((t) => t !== "null") : prop.type;\n if ((type && type !== "string") || prop.format || prop.pattern)\n return true;\n return saysWhatItHolds(key, prop);\n}\nfunction isEmpty(value) {\n return value === undefined || (Array.isArray(value) && value.length === 0) || (isRecord(value) && Object.keys(value).length === 0);\n}\nconst WHOLE_NUMBER = /(^|[_-])(number|num|no|index|idx|page|position|pos|id|count|version|year|port|rank|level|step|line|row|column|col|size)$|[a-z0-9](Number|Num|Index|Page|Position|Id|Count|Version|Year|Port|Rank|Level|Step|Line|Row|Column|Size)$|^(number|num|index|page|position|id|count|version|year|port|rank|level|step|line|row|column|size|offset|depth)$/;\nfunction numberFor(schema, name, integer) {\n const lower = name.toLowerCase();\n const step = integer ? 1 : 0.5;\n let value;\n if (/(created|updated|timestamp|_at$|time)/.test(lower) || /[a-z0-9]At$/.test(name))\n value = 1767225600;\n else if (/(amount|price|total|cost|balance)/.test(lower))\n value = integer ? 2000 : 20.0;\n else if (/(quantity|count|qty)/.test(lower))\n value = 1;\n else if (/(limit|page_size|per_page)/.test(lower))\n value = 10;\n else if (/(retry|seconds|delay)/.test(lower))\n value = 30;\n else\n value = integer || WHOLE_NUMBER.test(name) ? 1 : 1.5;\n if (schema.minimum !== undefined && value < schema.minimum)\n value = schema.minimum;\n if (schema.maximum !== undefined && value > schema.maximum)\n value = schema.maximum;\n const exclusiveMin = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum : schema.exclusiveMinimum === true ? schema.minimum : undefined;\n const exclusiveMax = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum : schema.exclusiveMaximum === true ? schema.maximum : undefined;\n if (exclusiveMin !== undefined && value <= exclusiveMin)\n value = exclusiveMin + step;\n if (exclusiveMax !== undefined && value >= exclusiveMax)\n value = exclusiveMax - step;\n return value;\n}\nconst HOOKISH = /(webhook|callback|hook|notif)/i;\nfunction stringFor(schema, name, owner) {\n var _a, _b;\n switch (schema.format) {\n case "date-time":\n return "2026-01-01T12:00:00Z";\n case "date":\n return "2026-01-01";\n case "time":\n return "12:00:00Z";\n case "duration":\n return "PT1H";\n case "email":\n case "idn-email":\n return `${(name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "") || "email").toLowerCase()}@example.com`;\n case "uri":\n case "url":\n case "iri":\n case "uri-reference":\n case "iri-reference":\n return HOOKISH.test(name) ? "https://example.com/webhooks" : "https://example.com";\n case "uri-template":\n return "https://example.com/{id}";\n case "hostname":\n case "idn-hostname":\n return "example.com";\n case "uuid":\n return name === "id" && owner ? uuidLike(owner) : isIdName(name) ? uuidLike(name) : exports.PLACEHOLDER_UUID;\n case "ipv4":\n return "203.0.113.10";\n case "ipv6":\n return "2001:db8::10";\n case "byte":\n return "aGVsbG8=";\n case "binary":\n return exports.BINARY_PLACEHOLDER;\n case "password":\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n case "regex":\n return "^[a-z]+$";\n case "json-pointer":\n return "/data";\n }\n if (schema.contentMediaType && !schema.contentEncoding) {\n if (/json/i.test(schema.contentMediaType))\n return JSON.stringify(schema.contentSchema ? exampleFromSchema(schema.contentSchema, name) : {});\n return exports.BINARY_PLACEHOLDER;\n }\n const value = sized((_a = namedValue(name, schema, owner)) !== null && _a !== void 0 ? _a : placeholder(name || "value"), schema);\n const pattern = schema.pattern;\n if (typeof pattern !== "string")\n return value;\n const told = (0, fit_1.patternVerdict)(pattern, value);\n if (told === true)\n return value;\n const patterned = patternExample(pattern);\n if (patterned)\n return patterned;\n const shapes = [idLike(name), "12345678901", "+15555550123", "email@example.com", "https://example.com", "example", "EXAMPLE", "Example", "1", "a", "A1"];\n const fitting = shapes.map((shape) => sized(shape, schema)).find((shape) => (0, fit_1.patternVerdict)(pattern, shape) === true);\n if (fitting !== undefined)\n return fitting;\n return (_b = (told === undefined ? shapeNamed(name, schema) : undefined)) !== null && _b !== void 0 ? _b : value;\n}\nfunction shapeNamed(name, schema) {\n const lower = name.toLowerCase();\n const shape = /phone|fax|mobile|(^|_)tel(_|$)|msisdn/.test(lower) ? "+15555550123" : /e-?mail/.test(lower) ? "email@example.com" : /(^|_)(url|uri|link|href|website)$|[a-z](Url|Uri)$/i.test(name) ? "https://example.com" : undefined;\n return shape === undefined ? undefined : sized(shape, schema);\n}\nfunction sized(value, schema) {\n let out = value;\n const held = isPlaceholder(out);\n if (schema.maxLength !== undefined && out.length > schema.maxLength)\n out = held && schema.maxLength >= 3 ? `${out.slice(0, schema.maxLength - 1)}>` : out.slice(0, schema.maxLength);\n if (schema.minLength !== undefined && out.length < schema.minLength)\n out = held ? `${out.slice(0, -1).padEnd(schema.minLength - 1, "_")}>` : out.padEnd(schema.minLength, "x");\n return out;\n}\nfunction placeholder(name) {\n const clean = name.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^[_.-]+|[_.-]+$/g, "");\n return `<${clean.slice(0, 60) || "value"}>`;\n}\nfunction isPlaceholder(value) {\n return typeof value === "string" && /^<[A-Za-z0-9_.-]{1,64}>$/.test(value);\n}\nexports.PLACEHOLDER_UUID = "00000000-0000-4000-8000-000000000000";\nfunction namedValue(name, schema, owner) {\n var _a, _b;\n const lower = name.toLowerCase().replace(/-/g, "_");\n const about = ((_a = schema.description) !== null && _a !== void 0 ? _a : "").toLowerCase();\n if (lower === "id" && owner)\n return idLike(owner);\n if (isIdName(name) || /\\bID\\b/.test((_b = schema.description) !== null && _b !== void 0 ? _b : ""))\n return idLike(name);\n if ((lower === "object" || lower === "type") && schema.title)\n return schema.title.toLowerCase();\n if ((lower === "name" || lower.endsWith("_name")) && (/\\b(domain|hostname)s?\\b/.test(about) || nounOf(owner) === "domain"))\n return "example.com";\n if (/^(domain|host|hostname)$/.test(lower))\n return "example.com";\n if (/(^|_)password$/.test(lower))\n return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";\n return undefined;\n}\nconst TELLING_FIELD = [\n /^(from|sender|to|recipients?|reply_?to|cc|bcc|subject|title|headline|html|text|body|content|message|comment|notes?|caption|prompt|input|slug|language|lang|locale|tz|locality|date|object|type|domain|host|hostname)$/,\n /email|currency|phone|country|url|uri|status|description/,\n /^(first_?name|given_?name|last_?name|family_?name|surname|company|company_?name|business_?name|organi[sz]ation(_?name)?|user_?name|handle|login|screen_?name)$/,\n /(^|_)(name|date|fax|city|state|province|postal_?code|zip|zip_?code|postcode|street|line_?[12]|address_?(line_?)?[12]|time_?zone|colou?r|password)$/,\n /(_at|_time|^time|timestamp)$/,\n];\nfunction saysWhatItHolds(name, schema) {\n var _a;\n const lower = name.toLowerCase().replace(/-/g, "_");\n return isIdName(name) || /\\bID\\b/.test((_a = schema.description) !== null && _a !== void 0 ? _a : "") || TELLING_FIELD.some((re) => re.test(lower));\n}\nfunction nounOf(owner) {\n const words = (owner !== null && owner !== void 0 ? owner : "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter((w) => w && !/^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/.test(w));\n return words.length ? singular(words.slice(-2).join("_")) : undefined;\n}\nfunction patternExample(pattern) {\n let whole;\n try {\n whole = new RegExp(pattern);\n }\n catch {\n return undefined;\n }\n const readable = [pattern, ...(REPEATED_GROUP.test(pattern) ? [] : [withoutLookarounds(pattern)])];\n for (const text of readable) {\n if (text === undefined)\n continue;\n const node = parsePattern(text);\n if (!node)\n continue;\n const value = sample(node, { next: 0 });\n if (value !== undefined && value.length <= 200 && whole.test(value))\n return value;\n }\n return undefined;\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nfunction withoutLookarounds(pattern) {\n if (!/\\(\\?<?[=!]/.test(pattern))\n return undefined;\n let out = "";\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === "\\\\") {\n out += pattern.slice(i, i + 2);\n i++;\n continue;\n }\n if (/^\\(\\?<?[=!]/.test(pattern.slice(i, i + 4))) {\n let depth = 0;\n let j = i;\n for (; j < pattern.length; j++) {\n if (pattern[j] === "\\\\")\n j++;\n else if (pattern[j] === "[") {\n j = pattern.indexOf("]", j + 2);\n if (j < 0)\n return undefined;\n }\n else if (pattern[j] === "(")\n depth++;\n else if (pattern[j] === ")" && --depth === 0)\n break;\n }\n if (j >= pattern.length)\n return undefined;\n i = j;\n continue;\n }\n out += pattern[i];\n }\n return out;\n}\nconst POOLS = [[..."1a2b3c4d5e6f7a8b9c0d"], [..."ABCDEFGHJKxyz_-."], [..."LMNPQRSTUVWXYZghijklmnopqrstuvw+=:/@~!*\'(),;$&? "]];\nconst CONTROL = { t: "\\t", n: "\\n", r: "\\r", v: "\\v", f: "\\f" };\nfunction parsePattern(pattern) {\n let i = 0;\n const fail = () => {\n i = pattern.length + 1;\n return undefined;\n };\n const choice = () => {\n var _a;\n const options = [];\n let parts = [];\n while (i < pattern.length && pattern[i] !== ")") {\n const c = pattern[i];\n if (c === "|") {\n options.push({ kind: "sequence", parts });\n parts = [];\n i++;\n continue;\n }\n let atom;\n if (c === "^" || c === "$") {\n i++;\n continue;\n }\n else if (c === "(") {\n if (pattern.startsWith("(?:", i))\n i += 3;\n else if (pattern[i + 1] === "?")\n return fail();\n else\n i++;\n atom = choice();\n if (pattern[i] !== ")")\n return fail();\n i++;\n }\n else if (c === "[") {\n const close = pattern.indexOf("]", pattern[i + 1] === "]" ? i + 2 : i + 1);\n if (close < 0)\n return fail();\n const text = pattern.slice(i, close + 1);\n i = close + 1;\n let set;\n try {\n set = new RegExp(`^${text}$`);\n }\n catch {\n return fail();\n }\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else if (c === "\\\\") {\n const e = pattern[i + 1];\n i += 2;\n if (e === undefined || /[0-9bBkpPc]/.test(e))\n return fail();\n if (/[dwsDWS]/.test(e)) {\n const set = new RegExp(`^\\\\${e}$`);\n atom = { kind: "chars", accepts: (ch) => set.test(ch) };\n }\n else {\n const code = (e === "x" && pattern.slice(i).match(/^[0-9a-fA-F]{2}/)) || (e === "u" && pattern.slice(i).match(/^[0-9a-fA-F]{4}/));\n if (code)\n i += code[0].length;\n const literal = code ? String.fromCharCode(parseInt(code[0], 16)) : ((_a = CONTROL[e]) !== null && _a !== void 0 ? _a : e);\n atom = { kind: "chars", accepts: (ch) => ch === literal, literal };\n }\n }\n else if (c === ".") {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch !== "\\n", literal: "." };\n }\n else if ("*+?{".includes(c)) {\n return fail();\n }\n else {\n i++;\n atom = { kind: "chars", accepts: (ch) => ch === c, literal: c };\n }\n if (!atom)\n return fail();\n const q = pattern.slice(i).match(/^(\\*|\\+|\\?|\\{(\\d+)(?:(,)(\\d*))?\\})\\??/);\n if (q) {\n i += q[0].length;\n const min = q[2] !== undefined ? Number(q[2]) : q[1] === "+" ? 1 : 0;\n const max = q[2] !== undefined ? (q[3] ? (q[4] ? Number(q[4]) : Infinity) : min) : q[1] === "?" ? 1 : Infinity;\n const count = q[1] === "?" ? 1 : Math.min(Math.max(min, Math.min(10, max)), 64);\n if (count < min)\n return fail();\n atom = { kind: "repeat", node: atom, count };\n }\n parts.push(atom);\n }\n options.push({ kind: "sequence", parts });\n return options.length === 1 ? options[0] : { kind: "choice", options };\n };\n const node = choice();\n return i === pattern.length ? node : undefined;\n}\nfunction sample(node, state) {\n var _a;\n switch (node.kind) {\n case "chars": {\n if (node.literal !== undefined)\n return node.literal;\n for (const pool of POOLS) {\n for (let n = 0; n < pool.length; n++) {\n const ch = pool[(state.next + n) % pool.length];\n if (node.accepts(ch)) {\n state.next = (state.next + n + 1) % pool.length;\n return ch;\n }\n }\n }\n return undefined;\n }\n case "sequence": {\n let out = "";\n for (const part of node.parts) {\n const value = sample(part, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "repeat": {\n let out = "";\n for (let n = 0; n < node.count; n++) {\n const value = sample(node.node, state);\n if (value === undefined)\n return undefined;\n out += value;\n }\n return out;\n }\n case "choice": {\n const values = node.options.map((option) => sample(option, { ...state })).filter((v) => v !== undefined);\n return (_a = values.find((v) => v.length > 1)) !== null && _a !== void 0 ? _a : values[0];\n }\n }\n}\nfunction isIdName(name) {\n const lower = name.toLowerCase();\n return lower === "id" || lower.endsWith("_id") || lower.endsWith("-id") || /[a-z0-9]Id$/.test(name);\n}\nconst ID_NOISE = /^(create|update|new|send|add|get|list|post|put|patch|set|make|place|request|response|body|input|output|params|parameters|payload|object|data|schema|model|dto|options?|opts|args|arguments|events?|created|updated|deleted|changed|v\\d+)$/;\nfunction idLike(name) {\n const words = idWords(name);\n return words.length ? `<${words.join("_")}_id>` : "<id>";\n}\nfunction uuidLike(name) {\n const words = idWords(name);\n const n = 1 + (seedHash(`uuid:${words.length ? words.join("_") : "obj"}`) % 9999);\n return `${exports.PLACEHOLDER_UUID.slice(0, -12)}${String(n).padStart(12, "0")}`;\n}\nfunction idWords(name) {\n const all = name\n .replace(/[_-]?(uu|s|g)?id$/i, "")\n .replace(/([a-z0-9])([A-Z])/g, "$1_$2")\n .replace(/([A-Z])([A-Z][a-z])/g, "$1_$2")\n .toLowerCase()\n .split(/[^a-z]+/)\n .filter(Boolean);\n const kept = all.filter((w) => !ID_NOISE.test(w));\n return (kept.length ? kept : all).map((w, i, list) => (i === list.length - 1 ? singular(w) : w));\n}\nfunction seedHash(seed) {\n let h = 2166136261;\n for (let i = 0; i < seed.length; i++)\n h = Math.imul(h ^ seed.charCodeAt(i), 16777619) >>> 0;\n return h || 1;\n}\nfunction singular(word) {\n if (/ies$/i.test(word))\n return word.slice(0, -3) + "y";\n if (/(ses|xes|ches|shes)$/i.test(word))\n return word.slice(0, -2);\n if (/s$/i.test(word) && !/ss$/i.test(word))\n return word.slice(0, -1);\n return word;\n}\n\n}, {"./fit":"lib/oas/fit"}],\n"lib/oas/fit": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.CIRCULAR_TARGET = void 0;\nexports.circularTarget = circularTarget;\nexports.fits = fits;\nexports.misfits = misfits;\nexports.typesOf = typesOf;\nexports.equal = equal;\nexports.patternVerdict = patternVerdict;\nexports.matchesPattern = matchesPattern;\nexports.quickLength = quickLength;\nexports.formatFits = formatFits;\nexports.CIRCULAR_TARGET = "x-circular-target";\nfunction circularTarget(schema) {\n const target = schema[exports.CIRCULAR_TARGET];\n return target && typeof target === "object" ? target : undefined;\n}\nconst MAX_DEPTH = 40;\nconst MAX_STEPS = 50000;\nfunction fits(value, schema, mode = "response") {\n return misfits(value, schema, mode, 1).length === 0;\n}\nfunction misfits(value, schema, mode = "response", limit = 20) {\n const out = [];\n check(value, schema, [], 0, out, { counter: { steps: 0 }, limit, mode });\n return out;\n}\nfunction check(value, schema, path, depth, out, state) {\n var _a, _b, _c;\n if (out.length >= state.limit || schema === undefined || schema === true || depth > MAX_DEPTH || ++state.counter.steps > MAX_STEPS)\n return;\n if (schema === false)\n return void out.push({ path, keyword: "false" });\n if (typeof schema !== "object" || schema === null)\n return;\n const miss = (keyword, at = path) => void out.push({ path: at, keyword });\n const target = circularTarget(schema);\n if (target)\n return check(value, target, path, depth + 1, out, state);\n const nullable = schema.nullable === true;\n const types = typesOf(schema);\n if (value === null && nullable)\n return;\n if (types.length && !types.some((t) => isType(value, t)))\n return miss("type");\n if (schema.const !== undefined && !equal(value, schema.const))\n miss("const");\n if (Array.isArray(schema.enum) && schema.enum.length && !schema.enum.some((e) => equal(e, value)))\n miss("enum");\n if (typeof value === "string") {\n const length = [...value].length;\n if (typeof schema.minLength === "number" && length < schema.minLength)\n miss("minLength");\n if (typeof schema.maxLength === "number" && length > schema.maxLength)\n miss("maxLength");\n if (typeof schema.pattern === "string" && !matchesPattern(schema.pattern, value))\n miss("pattern");\n if (typeof schema.format === "string" && !formatFits(schema.format, value))\n miss("format");\n }\n else if (typeof value === "number") {\n const { minimum, maximum, exclusiveMinimum: exMin, exclusiveMaximum: exMax } = schema;\n if (typeof minimum === "number" && (exMin === true ? value <= minimum : value < minimum))\n miss("minimum");\n if (typeof maximum === "number" && (exMax === true ? value >= maximum : value > maximum))\n miss("maximum");\n if (typeof exMin === "number" && value <= exMin)\n miss("exclusiveMinimum");\n if (typeof exMax === "number" && value >= exMax)\n miss("exclusiveMaximum");\n if (typeof schema.multipleOf === "number" && schema.multipleOf > 0 && !multipleOf(value, schema.multipleOf))\n miss("multipleOf");\n if (schema.format === "int32" && !(Number.isInteger(value) && value >= -(2 ** 31) && value < 2 ** 31))\n miss("format");\n }\n else if (Array.isArray(value)) {\n if (typeof schema.minItems === "number" && value.length < schema.minItems)\n miss("minItems");\n if (typeof schema.maxItems === "number" && value.length > schema.maxItems)\n miss("maxItems");\n if (schema.uniqueItems === true && new Set(value.map((v) => canonical(v))).size < value.length)\n miss("uniqueItems");\n const legacy = Array.isArray(schema.items) ? schema.items : undefined;\n const prefix = (_b = (_a = schema.prefixItems) !== null && _a !== void 0 ? _a : legacy) !== null && _b !== void 0 ? _b : [];\n value.forEach((item, i) => {\n if (i < prefix.length)\n check(item, prefix[i], [...path, i], depth + 1, out, state);\n else if (!legacy && isSchema(schema.items))\n check(item, schema.items, [...path, i], depth + 1, out, state);\n });\n }\n else if (isRecord(value)) {\n const props = isRecord(schema.properties) ? schema.properties : {};\n const omitted = (key) => {\n const prop = props[key];\n return isSchema(prop) && (state.mode === "request" ? prop.readOnly === true : prop.writeOnly === true);\n };\n if (Array.isArray(schema.required))\n for (const key of schema.required)\n if (typeof key === "string" && !(key in value) && !omitted(key))\n miss("required", [...path, key]);\n const count = Object.keys(value).length;\n if (typeof schema.minProperties === "number" && count < schema.minProperties)\n miss("minProperties");\n if (typeof schema.maxProperties === "number" && count > schema.maxProperties)\n miss("maxProperties");\n const patterns = isRecord(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];\n for (const [key, item] of Object.entries(value)) {\n if (out.length >= state.limit)\n break;\n let known = false;\n if (Object.prototype.hasOwnProperty.call(props, key)) {\n known = true;\n check(item, props[key], [...path, key], depth + 1, out, state);\n }\n for (const [pattern, sub] of patterns) {\n if (matchesPattern(pattern, key)) {\n known = true;\n check(item, sub, [...path, key], depth + 1, out, state);\n }\n }\n if (!known) {\n const extra = schema.additionalProperties;\n if (extra === false)\n miss("additionalProperties", [...path, key]);\n else if (isSchema(extra))\n check(item, extra, [...path, key], depth + 1, out, state);\n }\n }\n }\n for (const part of (_c = schema.allOf) !== null && _c !== void 0 ? _c : [])\n if (isSchema(part))\n check(value, part, path, depth + 1, out, state);\n if (Array.isArray(schema.anyOf) && schema.anyOf.length && !schema.anyOf.some((v) => fitsAt(value, v, depth, state)))\n miss("anyOf");\n if (Array.isArray(schema.oneOf) && schema.oneOf.length) {\n const fitting = countIn(value, schema.oneOf, depth, state, 2);\n if (fitting !== 1)\n miss(fitting === 0 ? "oneOf" : "oneOf-many");\n }\n if (isSchema(schema.not) && fitsAt(value, schema.not, depth, state))\n miss("not");\n const conditional = schema;\n if (isSchema(conditional.if)) {\n const branch = fitsAt(value, conditional.if, depth, state) ? conditional.then : conditional.else;\n if (isSchema(branch))\n check(value, branch, path, depth + 1, out, state);\n }\n}\nfunction fitsAt(value, schema, depth, state) {\n const found = [];\n check(value, schema, [], depth + 1, found, { counter: state.counter, limit: 1, mode: state.mode });\n return found.length === 0;\n}\nfunction countIn(value, variants, depth, s, stop) {\n let n = 0;\n for (const v of variants) {\n if (isSchema(v) && fitsAt(value, v, depth, s) && ++n >= stop)\n break;\n }\n return n;\n}\nfunction isSchema(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction isRecord(value) {\n return typeof value === "object" && value !== null && !Array.isArray(value);\n}\nfunction typesOf(schema) {\n return (Array.isArray(schema.type) ? schema.type : [schema.type]).filter((t) => typeof t === "string");\n}\nfunction isType(value, type) {\n switch (type) {\n case "integer":\n return typeof value === "number" && Number.isInteger(value);\n case "number":\n return typeof value === "number" && Number.isFinite(value);\n case "string":\n return typeof value === "string";\n case "boolean":\n return typeof value === "boolean";\n case "array":\n return Array.isArray(value);\n case "object":\n return isRecord(value);\n case "null":\n return value === null;\n default:\n return true;\n }\n}\nfunction multipleOf(value, step) {\n const quotient = value / step;\n return Math.abs(quotient - Math.round(quotient)) < 1e-9;\n}\nfunction equal(a, b) {\n return canonical(a) === canonical(b);\n}\nfunction canonical(value) {\n var _a;\n if (Array.isArray(value))\n return `[${value.map(canonical).join(",")}]`;\n if (isRecord(value))\n return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical(value[k])}`).join(",")}}`;\n return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : "undefined";\n}\nconst REPEATED_GROUP = /\\)(?:[*+]|\\{\\d+,?\\d*\\})/;\nconst compiled = new Map();\nfunction patternVerdict(pattern, value) {\n if (value.length > Math.min(40, quickLength(pattern)))\n return undefined;\n const re = compiledPattern(pattern);\n return re === null ? undefined : re.test(value);\n}\nfunction matchesPattern(pattern, value) {\n if (value.length > Math.min(2000, quickLength(pattern)))\n return true;\n const re = compiledPattern(pattern);\n return re === null || re.test(value);\n}\nconst STEP_BUDGET = 1e6;\nconst quickLengths = new Map();\nfunction quickLength(pattern) {\n var _a;\n let length = quickLengths.get(pattern);\n if (length === undefined) {\n if (REPEATED_GROUP.test(pattern))\n length = 0;\n else {\n const bare = pattern.replace(/\\\\./g, "x").replace(/\\[(?:\\\\.|[^\\]\\\\])*\\]/g, "x");\n const repeats = ((_a = bare.match(/[*+]|\\{\\d*,(\\d*)\\}/g)) !== null && _a !== void 0 ? _a : []).filter((q) => !/,\\d{1,2}\\}$/.test(q)).length;\n length = repeats <= 1 ? Infinity : Math.floor(Math.round(STEP_BUDGET ** (1 / repeats) * 1000) / 1000);\n }\n if (quickLengths.size > 2000)\n quickLengths.clear();\n quickLengths.set(pattern, length);\n }\n return length;\n}\nfunction compiledPattern(pattern) {\n let re = compiled.get(pattern);\n if (re === undefined) {\n try {\n re = new RegExp(pattern, "u");\n }\n catch {\n try {\n re = new RegExp(pattern);\n }\n catch {\n re = null;\n }\n }\n if (compiled.size > 2000)\n compiled.clear();\n compiled.set(pattern, re);\n }\n return re;\n}\nconst DATE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\nconst TIME = /^(\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?(z|[+-]\\d{2}(:?\\d{2})?)$/i;\nconst FORMATS = {\n "date-time": (text) => {\n const [date, time] = text.split(/t|\\s/i);\n return time !== undefined && FORMATS.date(date) && FORMATS.time(time);\n },\n date: (text) => {\n const m = text.match(DATE);\n if (!m)\n return false;\n const month = Number(m[2]);\n const day = Number(m[3]);\n return month >= 1 && month <= 12 && day >= 1 && day <= new Date(Date.UTC(Number(m[1]), month, 0)).getUTCDate();\n },\n time: (text) => {\n const m = text.match(TIME);\n return Boolean(m) && Number(m[1]) <= 23 && Number(m[2]) <= 59 && Number(m[3]) <= 60;\n },\n email: (text) => /^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(text),\n uri: (text) => /^[a-z][a-z0-9+.-]*:[^\\s]*$/i.test(text) && !/\\s/.test(text),\n url: (text) => /^[a-z][a-z0-9+.-]*:\\/\\/[^\\s]+$/i.test(text),\n "uri-reference": (text) => !/[\\s<>"\\\\^`{}|]/.test(text),\n "uri-template": (text) => !/[\\s<>"\\\\^`|]/.test(text),\n uuid: (text) => /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test(text),\n ipv4: (text) => /^((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test(text),\n ipv6: (text) => { var _a; return /^[0-9a-f:.]+$/i.test(text) && text.includes(":") && ((_a = text.match(/::/g)) !== null && _a !== void 0 ? _a : []).length <= 1; },\n hostname: (text) => text.length <= 253 && /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*\\.?$/i.test(text),\n byte: (text) => /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(text),\n duration: (text) => /^P(?!$)(\\d+(?:\\.\\d+)?Y)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?W)?(\\d+(?:\\.\\d+)?D)?(T(?=\\d)(\\d+(?:\\.\\d+)?H)?(\\d+(?:\\.\\d+)?M)?(\\d+(?:\\.\\d+)?S)?)?$/.test(text),\n regex: (text) => {\n try {\n new RegExp(text);\n return true;\n }\n catch {\n return false;\n }\n },\n "json-pointer": (text) => /^(?:\\/(?:[^~/]|~0|~1)*)*$/.test(text),\n};\nfunction formatFits(format, text) {\n const test = FORMATS[format];\n return test ? test(text) : true;\n}\n\n}, {}],\n"lib/text": [function (module, exports, require) {\n"use strict";\nObject.defineProperty(exports, "__esModule", { value: true });\nexports.cut = cut;\nexports.firstSentence = firstSentence;\nexports.wellFormed = wellFormed;\nexports.clip = clip;\nexports.plainText = plainText;\nfunction cut(text, max) {\n const end = Math.max(0, max);\n const last = text.charCodeAt(end - 1);\n return text.slice(0, last >= 0xd800 && last <= 0xdbff ? end - 1 : end);\n}\nfunction firstSentence(text) {\n if (!text)\n return undefined;\n const plain = text.replace(/<[^<>]+>/g, "").replace(/\\s+/g, " ").trim();\n const match = plain.match(/^(.{1,90}?[.!?])(\\s|$)/);\n return match ? match[1] : cut(plain, 90);\n}\nconst HALVES = /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDFFF]/g;\nfunction wellFormed(text) {\n return text.replace(HALVES, (c) => (c.length === 2 ? c : ""));\n}\nfunction clip(text, max) {\n return text.length > max ? `${cut(text, max - 1)}\u2026` : text;\n}\nfunction plainText(markdown) {\n return markdown\n .replace(/<[^>]+>/g, " ")\n .replace(/!\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g, "$1")\n .replace(/\\*\\*|__|`/g, "")\n .replace(/(^|\\s)[*_]([^*_\\s][^*_]*?)[*_](?=[\\s.,;:!?)]|$)/g, "$1$2")\n .replace(/^\\s{0,3}(#{1,6}|>)\\s+/gm, "")\n .replace(/\\s+/g, " ")\n .trim();\n}\n\n}, {}]\n};\nvar cache = {};\nfunction load(id) {\n var m = cache[id];\n if (m) return m.exports;\n m = cache[id] = { exports: {} };\n defs[id][0](m, m.exports, function (spec) { return load(defs[id][1][spec]); });\n return m.exports;\n}\nload("lib/embed/player");\n})();';
|
|
15650
15663
|
|
|
15651
15664
|
// ../../lib/embed/exportHtml.ts
|
|
15652
15665
|
function interactiveHtml(sb, title) {
|
|
@@ -16586,11 +16599,9 @@ render Without --edits, makes a video of each of the top three flows the spec s
|
|
|
16586
16599
|
check Builds each video, and fails when a spec change lost a call, an edit or the failure
|
|
16587
16600
|
a flow file shows, so a pull request can't break a video unnoticed.
|
|
16588
16601
|
|
|
16589
|
-
In a terminal, render first
|
|
16590
|
-
|
|
16591
|
-
|
|
16592
|
-
personal data before it writes them. --yes answers yes, for a script. It never asks in CI, or
|
|
16593
|
-
where nothing can answer.
|
|
16602
|
+
In a terminal, render first lists anything the videos show that may be personal or internal,
|
|
16603
|
+
then asks you to confirm that everything is correct and holds no secrets or personal data.
|
|
16604
|
+
--yes confirms, for a script. It never asks in CI, or where nothing can answer.
|
|
16594
16605
|
|
|
16595
16606
|
Files the spec references are read from its repo, and only JSON and YAML files there. URLs it
|
|
16596
16607
|
references aren't read from this machine or a private network (such as a cloud's metadata
|
|
@@ -16701,18 +16712,18 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
|
|
|
16701
16712
|
progress?.clear();
|
|
16702
16713
|
failed = true;
|
|
16703
16714
|
const { message, details } = err;
|
|
16704
|
-
console.error(` ${message}`);
|
|
16705
|
-
for (const detail of details ?? []) console.error(` ${detail}`);
|
|
16715
|
+
console.error(` ${oneLine(message)}`);
|
|
16716
|
+
for (const detail of details ?? []) console.error(` ${oneLine(detail)}`);
|
|
16706
16717
|
};
|
|
16707
16718
|
const madeFor = /* @__PURE__ */ new Map();
|
|
16708
16719
|
const announce = (total) => {
|
|
16709
|
-
const made = command === "render" ? `, as ${
|
|
16720
|
+
const made = command === "render" ? `, as ${list6(formats.map((format) => format.toUpperCase()))}` : "";
|
|
16710
16721
|
console.log(` ${command === "render" ? "Making" : "Checking"} ${total} video${total === 1 ? "" : "s"}${made}:`);
|
|
16711
16722
|
};
|
|
16712
|
-
const heading = (n, total, label) => ` Video ${n} of ${total} \xB7 ${label}`;
|
|
16723
|
+
const heading = (n, total, label) => ` Video ${n} of ${total} \xB7 ${oneLine(label)}`;
|
|
16713
16724
|
const make = async (built, from, folder, edited, n, total) => {
|
|
16714
16725
|
console.log(heading(n, total, `${edited ? from : built.name}: ${built.flow}`));
|
|
16715
|
-
for (const line of reportLines(built.report)) console.log(` ${line}`);
|
|
16726
|
+
for (const line of reportLines(built.report)) console.log(` ${oneLine(line)}`);
|
|
16716
16727
|
if (command === "check") {
|
|
16717
16728
|
if (lostSomething(built.report)) failed = true;
|
|
16718
16729
|
else console.log(` ${edited ? "Every call and edit still fits." : "It builds."}`);
|
|
@@ -16741,15 +16752,14 @@ async function main(argv, env = process.env, fontsDir = (0, import_node_path4.jo
|
|
|
16741
16752
|
fail(err);
|
|
16742
16753
|
return 1;
|
|
16743
16754
|
}
|
|
16744
|
-
for (const note of opened.notes.slice(0, MAX_NOTES)) console.log(` Note: ${note}`);
|
|
16755
|
+
for (const note of opened.notes.slice(0, MAX_NOTES)) console.log(` Note: ${oneLine(note)}`);
|
|
16745
16756
|
if (opened.notes.length > MAX_NOTES) console.log(` \u2026and ${opened.notes.length - MAX_NOTES} more notes.`);
|
|
16746
16757
|
const cleared = async (videos) => {
|
|
16747
16758
|
if (command !== "render" || yes || !ask || !videos.length) return true;
|
|
16748
|
-
|
|
16749
|
-
|
|
16750
|
-
const answer = (await ask(` ${videos.length === 1 ? "Does it" : "Do they"} hold no secrets or personal data? (y/N) `)).trim().toLowerCase();
|
|
16759
|
+
for (const line of reviewLines(mergeReviews(videos.map((v) => reviewOf(v.storyboard))))) console.log(` ${oneLine(line)}`);
|
|
16760
|
+
const answer = (await ask(` ${confirmLine("spec or collection", videos.length)} (y/N) `)).trim().toLowerCase();
|
|
16751
16761
|
if (answer === "y" || answer === "yes") return true;
|
|
16752
|
-
console.log(" Nothing was written.
|
|
16762
|
+
console.log(" Nothing was written. Fix the spec or flow file, or run it again with --yes once you've checked it.");
|
|
16753
16763
|
return false;
|
|
16754
16764
|
};
|
|
16755
16765
|
if (flowFiles.length) {
|
|
@@ -16826,6 +16836,9 @@ function progressLine(stream, env) {
|
|
|
16826
16836
|
}
|
|
16827
16837
|
};
|
|
16828
16838
|
}
|
|
16839
|
+
function oneLine(text3) {
|
|
16840
|
+
return String(text3).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\u202a-\u202e\u2066-\u2069]+/g, " ");
|
|
16841
|
+
}
|
|
16829
16842
|
function usage(problem) {
|
|
16830
16843
|
console.error(`${problem}
|
|
16831
16844
|
|
|
@@ -16846,7 +16859,7 @@ function distance(a, b) {
|
|
|
16846
16859
|
}
|
|
16847
16860
|
return above[b.length];
|
|
16848
16861
|
}
|
|
16849
|
-
function
|
|
16862
|
+
function list6(items) {
|
|
16850
16863
|
return items.length < 2 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`;
|
|
16851
16864
|
}
|
|
16852
16865
|
function size(bytes) {
|
|
@@ -16865,5 +16878,6 @@ if (require.main === module) {
|
|
|
16865
16878
|
0 && (module.exports = {
|
|
16866
16879
|
didYouMean,
|
|
16867
16880
|
main,
|
|
16881
|
+
oneLine,
|
|
16868
16882
|
progressLine
|
|
16869
16883
|
});
|
package/package.json
CHANGED