@clarify-labs/renderer 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/output/{ClarifyShell-CxhXBtsR.js → ClarifyShell-1LuBliwt.js} +124 -40
  2. package/output/ClarifyShell-1LuBliwt.js.map +1 -0
  3. package/output/{ClarifyShell-DjLRRW8T.cjs → ClarifyShell-C6li72Ce.cjs} +136 -52
  4. package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
  5. package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
  6. package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
  7. package/output/MermaidViewer-dXsomvM7.js +98 -0
  8. package/output/MermaidViewer-dXsomvM7.js.map +1 -0
  9. package/output/{OpenApiOperation-qp5tFaWP.cjs → OpenApiOperation-B52IWlKb.cjs} +405 -243
  10. package/output/OpenApiOperation-B52IWlKb.cjs.map +1 -0
  11. package/output/{OpenApiOperation-CyBkzvob.js → OpenApiOperation-DgrqzeiS.js} +377 -228
  12. package/output/OpenApiOperation-DgrqzeiS.js.map +1 -0
  13. package/output/{PageActions-GS_cxeJN.cjs → PageActions-BjB6PYmL.cjs} +73 -734
  14. package/output/PageActions-BjB6PYmL.cjs.map +1 -0
  15. package/output/{PageActions-Dn8IGWoL.js → PageActions-D7K9LDGf.js} +67 -680
  16. package/output/PageActions-D7K9LDGf.js.map +1 -0
  17. package/output/SearchDialog-CIPvXMT3.cjs +414 -0
  18. package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
  19. package/output/SearchDialog-CxYLjRi5.js +411 -0
  20. package/output/SearchDialog-CxYLjRi5.js.map +1 -0
  21. package/output/app/AppShell.d.ts +2 -2
  22. package/output/app/SectionHashSync.d.ts +6 -0
  23. package/output/client.cjs +3 -3
  24. package/output/client.js +3 -3
  25. package/output/components/HighlightedCode.d.ts +7 -0
  26. package/output/components/MermaidViewer.d.ts +7 -0
  27. package/output/context.d.ts +1 -1
  28. package/output/core/context.d.ts +3 -4
  29. package/output/core/i18n.d.ts +1 -1
  30. package/output/core/index.d.ts +1 -1
  31. package/output/core/types.d.ts +36 -19
  32. package/output/i18n-DnqZHFT7.js +247 -0
  33. package/output/i18n-DnqZHFT7.js.map +1 -0
  34. package/output/i18n-b4iTLeia.cjs +294 -0
  35. package/output/i18n-b4iTLeia.cjs.map +1 -0
  36. package/output/index.cjs +91 -94
  37. package/output/index.cjs.map +1 -1
  38. package/output/index.d.ts +7 -7
  39. package/output/index.js +83 -87
  40. package/output/index.js.map +1 -1
  41. package/output/markdown.cjs +2 -1
  42. package/output/markdown.d.ts +1 -1
  43. package/output/markdown.js +2 -2
  44. package/output/mdx/remark.d.ts +1 -0
  45. package/output/openapi/components/EndpointSections.d.ts +3 -1
  46. package/output/openapi/components/ExamplePanels.d.ts +5 -2
  47. package/output/openapi/components/OpenApiOperation.d.ts +3 -1
  48. package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
  49. package/output/openapi/components/SchemaProperties.d.ts +1 -0
  50. package/output/openapi/components/helpers.d.ts +2 -2
  51. package/output/openapi/entry.d.ts +0 -1
  52. package/output/openapi/lib/helpers.d.ts +5 -3
  53. package/output/openapi/lib/request-code.d.ts +2 -1
  54. package/output/openapi/lib/spec-path.d.ts +6 -1
  55. package/output/openapi/lib/utils.d.ts +10 -4
  56. package/output/preview.cjs +7 -5
  57. package/output/preview.cjs.map +1 -1
  58. package/output/preview.js +5 -3
  59. package/output/preview.js.map +1 -1
  60. package/output/{remark-Dd2WU50s.js → remark-C9iRQM0R.js} +4 -3
  61. package/output/remark-C9iRQM0R.js.map +1 -0
  62. package/output/{remark-zSQT0MBv.cjs → remark-DTLbG8PK.cjs} +9 -2
  63. package/output/remark-DTLbG8PK.cjs.map +1 -0
  64. package/output/{render-CV0a-qtD.js → render-DKj24Jqw.js} +15 -8
  65. package/output/render-DKj24Jqw.js.map +1 -0
  66. package/output/{render-CCCoUWDP.cjs → render-Di5B6Zc0.cjs} +15 -8
  67. package/output/render-Di5B6Zc0.cjs.map +1 -0
  68. package/output/renderer.css +234 -20
  69. package/output/runtime/ClarifyShell.d.ts +5 -6
  70. package/output/server.cjs +4 -4
  71. package/output/server.cjs.map +1 -1
  72. package/output/server.js +4 -4
  73. package/output/server.js.map +1 -1
  74. package/output/shell/Navigation.d.ts +1 -0
  75. package/output/shell/search/SearchDialog.d.ts +1 -1
  76. package/output/slots/RuntimeSlot.d.ts +7 -7
  77. package/output/slots/context.d.ts +5 -5
  78. package/output/slots/index.d.ts +2 -2
  79. package/output/slots/types.d.ts +1 -1
  80. package/output/utils/path.d.ts +1 -1
  81. package/package.json +3 -1
  82. package/output/ClarifyShell-CxhXBtsR.js.map +0 -1
  83. package/output/ClarifyShell-DjLRRW8T.cjs.map +0 -1
  84. package/output/OpenApiOperation-CyBkzvob.js.map +0 -1
  85. package/output/OpenApiOperation-qp5tFaWP.cjs.map +0 -1
  86. package/output/PageActions-Dn8IGWoL.js.map +0 -1
  87. package/output/PageActions-GS_cxeJN.cjs.map +0 -1
  88. package/output/remark-Dd2WU50s.js.map +0 -1
  89. package/output/remark-zSQT0MBv.cjs.map +0 -1
  90. package/output/render-CCCoUWDP.cjs.map +0 -1
  91. package/output/render-CV0a-qtD.js.map +0 -1
@@ -1,16 +1,18 @@
1
- import { C as isExternalHref, D as useBuiltInText, E as copyTextToClipboard, N as useLocale, c as lucideIconRegistry, h as useTheme, j as useConfig, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-Dn8IGWoL.js";
2
- import { t as markdownRemarkPlugins } from "./remark-Dd2WU50s.js";
1
+ import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-DnqZHFT7.js";
2
+ import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, n as PageTitleActions, o as useSectionStore, s as remToPx, w as localizeHref } from "./PageActions-D7K9LDGf.js";
3
+ import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
3
4
  import clsx from "clsx";
4
- import { Children, createContext, createElement, forwardRef, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
5
+ import { Children, Suspense, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
5
6
  import { Link } from "react-router-dom";
6
7
  import { Listbox, ListboxButton, ListboxOption, ListboxOptions, Tab, TabGroup, TabList, TabPanel, TabPanels, Transition } from "@headlessui/react";
7
- import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon, Maximize2, PackageIcon, ServerIcon, UnlockKeyholeIcon, XCircle, ZoomIn, ZoomOut } from "lucide-react";
8
+ import { AlertTriangle, ArrowRight, Check, CheckCircle2, CheckIcon, ChevronDown, ChevronDownIcon, ChevronRight, ChevronsUpDownIcon, CircleCheck, Clipboard, ClipboardIcon, CodeIcon, CopyIcon, Info, Lightbulb, LinkIcon, LockKeyholeIcon, PackageIcon, ServerIcon, UnlockKeyholeIcon, XCircle } from "lucide-react";
8
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
10
  import { motion, useInView } from "framer-motion";
10
11
  import { create } from "zustand";
11
- import { TransformComponent, TransformWrapper, useControls } from "react-zoom-pan-pinch";
12
12
  import ReactMarkdown from "react-markdown";
13
+ import rehypeRaw from "rehype-raw";
13
14
  import { slug } from "github-slugger";
15
+ import { codeToTokens, createCssVariablesTheme } from "shiki";
14
16
  import { snippetz } from "@scalar/snippetz";
15
17
  //#region \0rolldown/runtime.js
16
18
  var __defProp = Object.defineProperty;
@@ -209,63 +211,19 @@ function Card(arg0) {
209
211
  }
210
212
  //#endregion
211
213
  //#region source/components/Mermaid.tsx
214
+ var MermaidViewer = lazy(() => import("./MermaidViewer-dXsomvM7.js"));
212
215
  var mermaidModulePromise;
213
216
  async function loadMermaid() {
214
217
  mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
215
218
  return mermaidModulePromise;
216
219
  }
217
- function ZoomControls() {
218
- const { zoomIn, zoomOut, resetTransform } = useControls();
219
- const t = useBuiltInText();
220
- const buttonClassName = "flex h-7 w-7 items-center justify-center rounded-md bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)";
221
- return /* @__PURE__ */ jsxs("div", {
222
- className: "clarify-mermaid-controls absolute top-2 right-2 z-10 flex gap-1 opacity-0 transition group-hover:opacity-100 focus-within:opacity-100",
223
- children: [
224
- /* @__PURE__ */ jsx("button", {
225
- type: "button",
226
- "aria-label": t("mermaid.zoomIn"),
227
- title: t("mermaid.zoomIn"),
228
- onClick: () => zoomIn(),
229
- className: buttonClassName,
230
- children: /* @__PURE__ */ jsx(ZoomIn, {
231
- className: "h-4 w-4",
232
- "aria-hidden": "true"
233
- })
234
- }),
235
- /* @__PURE__ */ jsx("button", {
236
- type: "button",
237
- "aria-label": t("mermaid.zoomOut"),
238
- title: t("mermaid.zoomOut"),
239
- onClick: () => zoomOut(),
240
- className: buttonClassName,
241
- children: /* @__PURE__ */ jsx(ZoomOut, {
242
- className: "h-4 w-4",
243
- "aria-hidden": "true"
244
- })
245
- }),
246
- /* @__PURE__ */ jsx("button", {
247
- type: "button",
248
- "aria-label": t("mermaid.resetZoom"),
249
- title: t("mermaid.resetZoom"),
250
- onClick: () => resetTransform(),
251
- className: buttonClassName,
252
- children: /* @__PURE__ */ jsx(Maximize2, {
253
- className: "h-4 w-4",
254
- "aria-hidden": "true"
255
- })
256
- })
257
- ]
258
- });
259
- }
260
220
  function Mermaid(arg0) {
261
221
  const { chart, className } = arg0;
262
222
  const t = useBuiltInText();
263
223
  const { resolvedTheme } = useTheme();
264
224
  const renderId = `clarify-mermaid-${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
265
- const containerRef = useRef(null);
266
225
  const [svg, setSvg] = useState("");
267
226
  const [error, setError] = useState(void 0);
268
- const [focused, setFocused] = useState(false);
269
227
  useEffect(() => {
270
228
  let cancelled = false;
271
229
  async function renderChart() {
@@ -328,42 +286,24 @@ function Mermaid(arg0) {
328
286
  children: chart.trim()
329
287
  })
330
288
  });
289
+ return /* @__PURE__ */ jsx(Suspense, {
290
+ fallback: /* @__PURE__ */ jsx(MermaidStaticSvg, {
291
+ svg,
292
+ className
293
+ }),
294
+ children: /* @__PURE__ */ jsx(MermaidViewer, {
295
+ svg,
296
+ className
297
+ })
298
+ });
299
+ }
300
+ function MermaidStaticSvg(arg0) {
301
+ const { svg, className } = arg0;
331
302
  return /* @__PURE__ */ jsx("div", {
332
- ref: containerRef,
333
- tabIndex: 0,
334
- role: "group",
335
- onPointerDown: () => containerRef.current?.focus(),
336
- onFocus: () => setFocused(true),
337
- onBlur: () => setFocused(false),
338
- className: clsx("clarify-mermaid group not-prose relative my-6 overflow-hidden rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", className),
339
- children: /* @__PURE__ */ jsxs(TransformWrapper, {
340
- minScale: .5,
341
- maxScale: 8,
342
- initialScale: 1,
343
- centerOnInit: true,
344
- smooth: true,
345
- wheel: {
346
- step: .05,
347
- wheelDisabled: !focused,
348
- touchPadDisabled: !focused
349
- },
350
- doubleClick: { mode: "reset" },
351
- children: [
352
- /* @__PURE__ */ jsx(ZoomControls, {}),
353
- /* @__PURE__ */ jsx(TransformComponent, {
354
- wrapperClass: "!w-full !cursor-grab active:!cursor-grabbing",
355
- contentClass: "!w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
356
- wrapperStyle: { height: "min(70vh, 32rem)" },
357
- children: /* @__PURE__ */ jsx("div", {
358
- className: "flex h-full w-full items-center justify-center p-4",
359
- dangerouslySetInnerHTML: { __html: svg }
360
- })
361
- }),
362
- /* @__PURE__ */ jsx("p", {
363
- className: clsx("clarify-mermaid-hint pointer-events-none absolute bottom-2 left-1/2 z-10 -translate-x-1/2 rounded-full bg-(--clarify-theme-tokens-colors-surface)/90 px-2.5 py-1 text-2xs text-(--clarify-ui-text-soft) shadow-xs ring-1 ring-(--clarify-theme-tokens-colors-border) backdrop-blur-sm transition", focused ? "opacity-0" : "opacity-0 group-hover:opacity-100"),
364
- children: t("mermaid.scrollHint")
365
- })
366
- ]
303
+ className: clsx("clarify-mermaid not-prose my-6 overflow-x-auto rounded-2xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-4", className),
304
+ children: /* @__PURE__ */ jsx("div", {
305
+ className: "flex w-full justify-center [&_svg]:h-auto [&_svg]:max-w-full",
306
+ dangerouslySetInnerHTML: { __html: svg }
367
307
  })
368
308
  });
369
309
  }
@@ -397,6 +337,14 @@ function getNodeText(node) {
397
337
  if (isValidElement(node)) return getNodeText(node.props.children);
398
338
  return "";
399
339
  }
340
+ function getCodeLanguage(node) {
341
+ if (!isValidElement(node)) return void 0;
342
+ const { className, language, children } = node.props;
343
+ if (language) return language;
344
+ const languageClass = className?.split(/\s+/).find((value) => value.startsWith("language-"));
345
+ if (languageClass) return languageClass.slice(9);
346
+ return Children.toArray(children).map(getCodeLanguage).find(Boolean);
347
+ }
400
348
  function CopyButton(arg0) {
401
349
  const { code } = arg0;
402
350
  const t = useBuiltInText();
@@ -404,8 +352,8 @@ function CopyButton(arg0) {
404
352
  const copied = copyCount > 0;
405
353
  useEffect(() => {
406
354
  if (copyCount === 0) return void 0;
407
- const timeout = window.setTimeout(() => setCopyCount(0), 1e3);
408
- return () => window.clearTimeout(timeout);
355
+ const timeout = setTimeout(() => setCopyCount(0), 1e3);
356
+ return () => clearTimeout(timeout);
409
357
  }, [copyCount]);
410
358
  if (!code) return null;
411
359
  return /* @__PURE__ */ jsx("button", {
@@ -466,6 +414,7 @@ function CodeGroupHeader(arg0) {
466
414
  const { title, children, selectedIndex } = arg0;
467
415
  const t = useBuiltInText();
468
416
  const hasTabs = Children.count(children) > 1;
417
+ const indicatorLayoutId = useId();
469
418
  if (!title && !hasTabs) return null;
470
419
  return /* @__PURE__ */ jsxs("div", {
471
420
  className: "clarify-code-group-header flex min-h-(--clarify-code-header-min-height) flex-wrap items-start gap-x-4 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-4",
@@ -473,13 +422,22 @@ function CodeGroupHeader(arg0) {
473
422
  className: "mr-auto pt-3 text-xs font-semibold text-(--clarify-code-text)",
474
423
  children: title
475
424
  }) : null, hasTabs ? /* @__PURE__ */ jsx(TabList, {
476
- className: "clarify-code-tabs -mb-px flex gap-4 text-xs font-medium",
477
- children: Children.map(children, (child, childIndex) => /* @__PURE__ */ jsx(Tab, {
478
- className: clsx("clarify-code-tab border-b py-3 transition data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-theme-tokens-colors-primary)" : "border-transparent text-(--clarify-code-muted) hover:text-(--clarify-code-text)"),
479
- children: getPanelTitle({
425
+ className: "clarify-code-tabs -mr-2 -mb-px flex gap-0 text-xs font-medium",
426
+ children: Children.map(children, (child, childIndex) => /* @__PURE__ */ jsxs(Tab, {
427
+ className: clsx("clarify-code-tab relative border-b border-transparent px-2 py-3 transition-colors hover:bg-(--clarify-code-control-background-hover) data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "text-(--clarify-code-accent-text)" : "text-(--clarify-code-control-text) hover:text-(--clarify-code-text)"),
428
+ children: [getPanelTitle({
480
429
  ...isValidElement(child) ? child.props : {},
481
430
  fallbackTitle: t("actions.code")
482
- })
431
+ }), childIndex === selectedIndex ? /* @__PURE__ */ jsx(motion.span, {
432
+ layoutId: indicatorLayoutId,
433
+ className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-code-accent-text)",
434
+ transition: {
435
+ type: "spring",
436
+ stiffness: 460,
437
+ damping: 34,
438
+ mass: .7
439
+ }
440
+ }) : null]
483
441
  }))
484
442
  }) : null]
485
443
  });
@@ -591,7 +549,9 @@ function Code(arg0) {
591
549
  function Pre(arg0) {
592
550
  const { children, language, code, ...props } = arg0;
593
551
  const isGrouped = useContext(CodeGroupContext);
594
- if (language === "mermaid") return /* @__PURE__ */ jsx(Mermaid, { chart: code ?? getNodeText(children) });
552
+ const resolvedLanguage = language ?? getCodeLanguage(children);
553
+ const resolvedCode = code ?? getNodeText(children);
554
+ if (resolvedLanguage === "mermaid") return /* @__PURE__ */ jsx(Mermaid, { chart: resolvedCode });
595
555
  if (isGrouped) return children;
596
556
  return /* @__PURE__ */ jsx(CodeGroup, {
597
557
  ...props,
@@ -930,16 +890,17 @@ function Tabs(arg0) {
930
890
  onChange: handleChange,
931
891
  className,
932
892
  children: [/* @__PURE__ */ jsx(TabList, {
933
- className: clsx("flex flex-wrap items-center gap-6 border-b border-(--clarify-theme-tokens-colors-border) pb-0", listClassName),
893
+ className: clsx("-mx-2 flex flex-wrap items-center gap-2 border-b border-(--clarify-theme-tokens-colors-border) px-2 pb-0", listClassName),
934
894
  children: items.map((item) => /* @__PURE__ */ jsx(Tab, {
935
- className: ({ selected }) => clsx("clarify-ui-tab relative inline-flex h-10 shrink-0 items-center px-0 py-0 text-sm font-medium transition focus:outline-none", selected && "clarify-ui-tab-active"),
895
+ className: ({ selected }) => clsx("clarify-content-tab clarify-ui-tab relative inline-flex h-10 shrink-0 items-center rounded-t-md px-2 py-0 text-sm font-medium transition-colors focus:outline-none", selected && "clarify-ui-tab-active"),
936
896
  children: ({ selected }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", { children: item.label }), selected ? /* @__PURE__ */ jsx(motion.span, {
937
897
  layoutId: indicatorLayoutId,
938
- className: "absolute inset-x-0 bottom-0 h-0.5 rounded-full bg-(--clarify-theme-tokens-colors-foreground)",
898
+ className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-ui-tab-indicator) shadow-[0_0_0.5rem_var(--clarify-ui-accent-glow)]",
939
899
  transition: {
940
- type: "tween",
941
- duration: .16,
942
- ease: "easeOut"
900
+ type: "spring",
901
+ stiffness: 460,
902
+ damping: 34,
903
+ mass: .7
943
904
  }
944
905
  }) : null] })
945
906
  }, item.id))
@@ -1194,44 +1155,55 @@ function Markdown(arg0) {
1194
1155
  children: /* @__PURE__ */ jsx(ReactMarkdown, {
1195
1156
  components: markdownComponents,
1196
1157
  remarkPlugins: markdownRemarkPlugins,
1158
+ rehypePlugins: [rehypeRaw],
1197
1159
  children
1198
1160
  })
1199
1161
  });
1200
1162
  }
1201
1163
  //#endregion
1202
1164
  //#region source/openapi/lib/helpers.ts
1203
- function isRecord(value) {
1165
+ function isRecord$1(value) {
1204
1166
  return typeof value === "object" && value !== null && !Array.isArray(value);
1205
1167
  }
1206
1168
  function isReference(value) {
1207
- return isRecord(value) && typeof value.$ref === "string";
1169
+ return isRecord$1(value) && typeof value.$ref === "string";
1208
1170
  }
1209
1171
  function resolveReferenceName(ref) {
1210
1172
  return ref.split("/").filter(Boolean).at(-1) ?? ref;
1211
1173
  }
1212
- function resolveOpenApiRef(spec, ref) {
1174
+ function resolveOpenApiRef$1(spec, ref) {
1213
1175
  if (!ref.startsWith("#/")) return void 0;
1214
- return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
1176
+ return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord$1(current) ? current[part] : void 0, spec);
1215
1177
  }
1216
1178
  function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
1217
1179
  if (!isReference(schema)) return schema;
1218
1180
  if (seen.has(schema.$ref)) return schema;
1219
1181
  seen.add(schema.$ref);
1220
- return resolveSchema(spec, resolveOpenApiRef(spec, schema.$ref), seen) ?? schema;
1182
+ return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
1221
1183
  }
1222
- function getPathItem(spec, path) {
1184
+ function getPathItem$1(spec, path) {
1223
1185
  return resolveObjectRef(spec, spec.paths?.[path]);
1224
1186
  }
1187
+ function getOperationPathItem(spec, path, source = "path") {
1188
+ if (source === "path") return getPathItem$1(spec, path);
1189
+ const webhooks = spec.webhooks;
1190
+ return resolveObjectRef(spec, isRecord$1(webhooks) ? webhooks[path] : void 0);
1191
+ }
1192
+ function joinPath(base, path) {
1193
+ if (!base) return path || "/";
1194
+ if (!path) return base;
1195
+ return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
1196
+ }
1225
1197
  function resolveObjectRef(spec, value) {
1226
- const resolved = spec && isReference(value) ? resolveOpenApiRef(spec, value.$ref) : value;
1227
- return isRecord(resolved) && !isReference(resolved) ? resolved : void 0;
1198
+ const resolved = spec && isReference(value) ? resolveOpenApiRef$1(spec, value.$ref) : value;
1199
+ return isRecord$1(resolved) && !isReference(resolved) ? resolved : void 0;
1228
1200
  }
1229
1201
  function schemaHasType(schema, type) {
1230
- if (!isRecord(schema)) return false;
1202
+ if (!isRecord$1(schema)) return false;
1231
1203
  return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
1232
1204
  }
1233
- function getOperationParameters(spec, path, operation) {
1234
- const pathParameters = getPathItem(spec, path)?.parameters;
1205
+ function getOperationParameters(spec, path, operation, source = "path") {
1206
+ const pathParameters = getOperationPathItem(spec, path, source)?.parameters;
1235
1207
  const operationParameters = operation.parameters;
1236
1208
  const parameters = [...Array.isArray(pathParameters) ? pathParameters : [], ...Array.isArray(operationParameters) ? operationParameters : []].map((parameter) => resolveObjectRef(spec, parameter)).filter((parameter) => Boolean(parameter));
1237
1209
  const deduped = /* @__PURE__ */ new Map();
@@ -1249,7 +1221,7 @@ function getRequestBody$1(spec, operation) {
1249
1221
  return resolveObjectRef(spec, requestBody);
1250
1222
  }
1251
1223
  function getMediaTypeEntries(content, spec) {
1252
- if (!isRecord(content)) return [];
1224
+ if (!isRecord$1(content)) return [];
1253
1225
  return Object.entries(content).map(([mediaType, value]) => ({
1254
1226
  mediaType,
1255
1227
  value: resolveObjectRef(spec, value)
@@ -1261,12 +1233,12 @@ function getJsonLikeContent(content, spec) {
1261
1233
  return getMediaTypeEntries(content, spec)[0];
1262
1234
  }
1263
1235
  function getExampleValue(example) {
1264
- if (isRecord(example) && "value" in example) return example.value;
1265
- if (isRecord(example) && "externalValue" in example) return void 0;
1236
+ if (isRecord$1(example) && "value" in example) return example.value;
1237
+ if (isRecord$1(example) && "externalValue" in example) return void 0;
1266
1238
  return example;
1267
1239
  }
1268
1240
  function getExampleTitle(key, example) {
1269
- if (isRecord(example)) {
1241
+ if (isRecord$1(example)) {
1270
1242
  const summary = typeof example.summary === "string" ? example.summary : void 0;
1271
1243
  return {
1272
1244
  title: summary ?? key,
@@ -1275,9 +1247,9 @@ function getExampleTitle(key, example) {
1275
1247
  }
1276
1248
  return { title: key };
1277
1249
  }
1278
- function getExampleEntries(mediaType) {
1250
+ function getExampleEntries(mediaType, spec) {
1279
1251
  if (!mediaType) return [];
1280
- if (isRecord(mediaType.examples)) {
1252
+ if (isRecord$1(mediaType.examples)) {
1281
1253
  const examples = [];
1282
1254
  for (const [key, example] of Object.entries(mediaType.examples)) {
1283
1255
  const value = getExampleValue(example);
@@ -1297,7 +1269,7 @@ function getExampleEntries(mediaType) {
1297
1269
  title: "Example",
1298
1270
  value: mediaType.example
1299
1271
  }];
1300
- const generated = schemaToExample(mediaType.schema);
1272
+ const generated = schemaToExample(spec ? resolveSchema(spec, mediaType.schema) : mediaType.schema);
1301
1273
  return typeof generated === "undefined" ? [] : [{
1302
1274
  key: "schema",
1303
1275
  title: "schema",
@@ -1309,7 +1281,7 @@ function getContentExample(mediaType) {
1309
1281
  return getExampleEntries(mediaType)[0]?.value;
1310
1282
  }
1311
1283
  function schemaToType(schema) {
1312
- if (!isRecord(schema)) return void 0;
1284
+ if (!isRecord$1(schema)) return void 0;
1313
1285
  if (isReference(schema)) return resolveReferenceName(schema.$ref);
1314
1286
  if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
1315
1287
  if (Array.isArray(schema.enum)) return "enum";
@@ -1321,14 +1293,14 @@ function schemaToType(schema) {
1321
1293
  return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
1322
1294
  }
1323
1295
  function schemaToExample(schema, depth = 0) {
1324
- if (!isRecord(schema) || depth > 3) return void 0;
1296
+ if (!isRecord$1(schema) || depth > 3) return void 0;
1325
1297
  if (typeof schema.example !== "undefined") return schema.example;
1326
1298
  if (typeof schema.default !== "undefined") return schema.default;
1327
1299
  if (Array.isArray(schema.enum)) return schema.enum[0];
1328
1300
  if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
1329
1301
  if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
1330
- if (schemaHasType(schema, "object") || isRecord(schema.properties)) {
1331
- const properties = isRecord(schema.properties) ? schema.properties : {};
1302
+ if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
1303
+ const properties = isRecord$1(schema.properties) ? schema.properties : {};
1332
1304
  return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
1333
1305
  }
1334
1306
  return exampleForType(schemaToType(schema));
@@ -1348,7 +1320,7 @@ function stringifyExample(value) {
1348
1320
  }
1349
1321
  function getResponseEntries(operation, spec) {
1350
1322
  const responses = operation.responses;
1351
- if (!isRecord(responses)) return [];
1323
+ if (!isRecord$1(responses)) return [];
1352
1324
  return Object.entries(responses).map(([status, response]) => ({
1353
1325
  status,
1354
1326
  response: resolveObjectRef(spec, response)
@@ -1363,14 +1335,163 @@ function codeLanguageForMediaType(mediaType) {
1363
1335
  return "text";
1364
1336
  }
1365
1337
  //#endregion
1338
+ //#region source/openapi/lib/utils.ts
1339
+ var OPENAPI_HTTP_METHODS = [
1340
+ "get",
1341
+ "put",
1342
+ "post",
1343
+ "delete",
1344
+ "options",
1345
+ "head",
1346
+ "patch",
1347
+ "trace"
1348
+ ];
1349
+ var CLARIFY_OPENAPI_SECTION_ID_EXTENSION = "x-clarify-section-id";
1350
+ function getOpenApiOperationSectionId(operation) {
1351
+ const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
1352
+ return typeof sectionId === "string" ? sectionId : "";
1353
+ }
1354
+ function createOpenApiOperationSectionId(operation, method, path, source) {
1355
+ return (typeof operation.operationId === "string" ? operation.operationId.trim() : "") || slug(`${source === "webhook" ? "webhook " : ""}${method.toLowerCase()} ${path}`);
1356
+ }
1357
+ function normalizeOpenApiOperationSectionId(operation, method, path, source) {
1358
+ const sectionId = operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION];
1359
+ if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
1360
+ return operation;
1361
+ }
1362
+ function isOpenAPIHttpMethod(method) {
1363
+ return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
1364
+ }
1365
+ function isRecord(value) {
1366
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1367
+ }
1368
+ function resolveOpenApiRef(spec, ref) {
1369
+ if (!ref.startsWith("#/")) return void 0;
1370
+ return ref.slice(2).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~")).reduce((current, part) => isRecord(current) ? current[part] : void 0, spec);
1371
+ }
1372
+ function getPathItem(spec, path) {
1373
+ const pathItem = spec.paths?.[path];
1374
+ const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
1375
+ return isRecord(resolved) ? resolved : void 0;
1376
+ }
1377
+ function getWebhookItem(spec, path) {
1378
+ const webhooks = spec.webhooks;
1379
+ const pathItem = isRecord(webhooks) ? webhooks[path] : void 0;
1380
+ const resolved = isRecord(pathItem) && typeof pathItem.$ref === "string" ? resolveOpenApiRef(spec, pathItem.$ref) : pathItem;
1381
+ return isRecord(resolved) ? resolved : void 0;
1382
+ }
1383
+ function listOperationsFromPathItems(items, source, spec) {
1384
+ const operations = [];
1385
+ for (const path of Object.keys(items)) {
1386
+ const pathItem = source === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path);
1387
+ if (!pathItem) continue;
1388
+ for (const method of OPENAPI_HTTP_METHODS) {
1389
+ const operation = pathItem[method];
1390
+ if (isRecord(operation)) operations.push({
1391
+ path,
1392
+ method,
1393
+ operation: normalizeOpenApiOperationSectionId(operation, method, path, source),
1394
+ source
1395
+ });
1396
+ }
1397
+ }
1398
+ return operations;
1399
+ }
1400
+ function getOpenApiOperationEntry(spec, path, method, source) {
1401
+ if (!isOpenAPIHttpMethod(method)) return void 0;
1402
+ const normalizedMethod = method.toLowerCase();
1403
+ const sources = source ? [source] : ["path", "webhook"];
1404
+ for (const currentSource of sources) {
1405
+ const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
1406
+ if (isRecord(operation)) return {
1407
+ path,
1408
+ method: normalizedMethod,
1409
+ operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
1410
+ source: currentSource
1411
+ };
1412
+ }
1413
+ }
1414
+ function listOpenApiOperations(spec) {
1415
+ const paths = spec.paths ?? {};
1416
+ const webhooks = spec.webhooks;
1417
+ return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
1418
+ }
1419
+ //#endregion
1420
+ //#region source/components/HighlightedCode.tsx
1421
+ var cssVariablesTheme = createCssVariablesTheme();
1422
+ function HighlightedCode(arg0) {
1423
+ const { code, language } = arg0;
1424
+ const [lines, setLines] = useState();
1425
+ useEffect(() => {
1426
+ let active = true;
1427
+ codeToTokens(code, {
1428
+ lang: language,
1429
+ theme: cssVariablesTheme
1430
+ }).then((result) => {
1431
+ if (active) setLines(result.tokens);
1432
+ }).catch(() => {
1433
+ if (active) setLines(void 0);
1434
+ });
1435
+ return () => {
1436
+ active = false;
1437
+ };
1438
+ }, [code, language]);
1439
+ if (!lines) return /* @__PURE__ */ jsx("code", {
1440
+ className: `language-${language}`,
1441
+ children: code
1442
+ });
1443
+ return /* @__PURE__ */ jsx("code", {
1444
+ className: `language-${language}`,
1445
+ children: lines.map((line, lineIndex) => /* @__PURE__ */ jsxs("span", {
1446
+ className: "line",
1447
+ children: [line.map((token, tokenIndex) => /* @__PURE__ */ jsx("span", {
1448
+ style: {
1449
+ color: token.color,
1450
+ ...token.htmlStyle
1451
+ },
1452
+ children: token.content
1453
+ }, tokenIndex)), lineIndex < lines.length - 1 ? "\n" : null]
1454
+ }, lineIndex))
1455
+ });
1456
+ }
1457
+ //#endregion
1366
1458
  //#region source/openapi/lib/request-code.ts
1459
+ var snippetControlCharacters = [
1460
+ {
1461
+ character: "\n",
1462
+ placeholder: "",
1463
+ escape: "\\n"
1464
+ },
1465
+ {
1466
+ character: "\r",
1467
+ placeholder: "",
1468
+ escape: "\\r"
1469
+ },
1470
+ {
1471
+ character: " ",
1472
+ placeholder: "",
1473
+ escape: "\\t"
1474
+ }
1475
+ ];
1367
1476
  var snippetGenerator = snippetz();
1477
+ function protectSnippetControlCharacters(value) {
1478
+ if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
1479
+ if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
1480
+ if (!isRecord$1(value)) return value;
1481
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, protectSnippetControlCharacters(item)]));
1482
+ }
1483
+ function restoreSnippetControlCharacters(code) {
1484
+ return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.placeholder, item.escape), code);
1485
+ }
1368
1486
  function getDefaultServer(spec) {
1369
1487
  const servers = spec.servers;
1370
1488
  if (!Array.isArray(servers)) return { url: "https://api.example.com" };
1371
- const firstServer = servers.find(isRecord);
1489
+ const firstServer = servers.find(isRecord$1);
1372
1490
  return firstServer && typeof firstServer.url === "string" ? firstServer : { url: "https://api.example.com" };
1373
1491
  }
1492
+ function getDefaultWebhookServer() {
1493
+ return { url: "https://webhook.example.com" };
1494
+ }
1374
1495
  function expandServerUrl(server, serverVariables = {}) {
1375
1496
  return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
1376
1497
  const fallback = server.variables?.[name]?.default ?? name;
@@ -1378,7 +1499,8 @@ function expandServerUrl(server, serverVariables = {}) {
1378
1499
  });
1379
1500
  }
1380
1501
  function buildOperationUrl(input) {
1381
- return `${expandServerUrl(input.server ?? getDefaultServer(input.spec), input.serverVariables).replace(/\/$/, "")}${input.path}`;
1502
+ const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
1503
+ return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
1382
1504
  }
1383
1505
  function getQueryString(parameters, auth) {
1384
1506
  const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
@@ -1395,18 +1517,18 @@ function isFormMediaType(mediaType) {
1395
1517
  return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
1396
1518
  }
1397
1519
  function isBinarySchema(schema) {
1398
- return isRecord(schema) && schema.type === "string" && schema.format === "binary";
1520
+ return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
1399
1521
  }
1400
1522
  function getSchemaProperties(schema) {
1401
- return isRecord(schema) && isRecord(schema.properties) ? schema.properties : {};
1523
+ return isRecord$1(schema) && isRecord$1(schema.properties) ? schema.properties : {};
1402
1524
  }
1403
1525
  function getFieldValue(name, value, schema) {
1404
- if (isRecord(value) && typeof value[name] !== "undefined") return value[name];
1526
+ if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
1405
1527
  if (isBinarySchema(schema)) return `@${name}`;
1406
1528
  }
1407
1529
  function getFormParams(value, requestContent) {
1408
1530
  const properties = getSchemaProperties(requestContent.value.schema);
1409
- return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord(value) ? Object.keys(value) : []])).flatMap((name) => {
1531
+ return Array.from(/* @__PURE__ */ new Set([...Object.keys(properties), ...isRecord$1(value) ? Object.keys(value) : []])).flatMap((name) => {
1410
1532
  const fieldValue = getFieldValue(name, value, properties[name]);
1411
1533
  if (typeof fieldValue === "undefined") return [];
1412
1534
  const contentType = requestContent.value.encoding?.[name]?.contentType;
@@ -1428,7 +1550,7 @@ function getRequestBody(requestContent) {
1428
1550
  const params = getFormParams(value, requestContent);
1429
1551
  return params.length > 0 ? { params } : void 0;
1430
1552
  }
1431
- return { serialized: stringifyExample(value) };
1553
+ return { serialized: stringifyExample(protectSnippetControlCharacters(value)) };
1432
1554
  }
1433
1555
  function getAuthorizationValue(auth) {
1434
1556
  if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "bearer") return `Bearer ${auth.value}`;
@@ -1481,7 +1603,7 @@ function buildSnippetErrorMessage(error) {
1481
1603
  }
1482
1604
  function buildSnippet(input, target) {
1483
1605
  try {
1484
- return decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || "");
1606
+ return restoreSnippetControlCharacters(decodeUrlPlaceholders(snippetGenerator.print(target.target, target.client, buildHarRequest(input)) || ""));
1485
1607
  } catch (error) {
1486
1608
  return buildSnippetErrorMessage(error);
1487
1609
  }
@@ -1790,7 +1912,7 @@ function SelectControl(arg0) {
1790
1912
  className: wrapperClassName,
1791
1913
  children: [/* @__PURE__ */ jsxs(ListboxButton, {
1792
1914
  "aria-label": label,
1793
- className: `clarify-api-select-button flex ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg bg-(--clarify-code-control-background) px-2 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:bg-(--clarify-code-control-background-hover) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
1915
+ className: `clarify-api-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-control-background) px-2.5 py-1 text-xs font-medium whitespace-nowrap text-(--clarify-code-text) outline-hidden transition hover:border-white/20 hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-white/20 data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
1794
1916
  children: [/* @__PURE__ */ jsxs("span", {
1795
1917
  className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
1796
1918
  children: [icon ? /* @__PURE__ */ jsx("span", {
@@ -1809,7 +1931,7 @@ function SelectControl(arg0) {
1809
1931
  className: "clarify-api-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-code-surface) p-1 text-xs shadow-lg shadow-black/20 ring-1 ring-(--clarify-code-border) [--anchor-gap:--spacing(1)] focus:outline-none",
1810
1932
  children: normalizedOptions.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
1811
1933
  value: option.value,
1812
- className: "clarify-api-select-option group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-muted) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:text-(--clarify-theme-tokens-colors-primary)",
1934
+ className: "clarify-api-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs whitespace-nowrap text-(--clarify-code-control-text) select-none data-focus:bg-(--clarify-code-control-background-hover) data-focus:text-(--clarify-code-text) data-selected:bg-(--clarify-code-accent-background) data-selected:text-(--clarify-code-accent-text)",
1813
1935
  children: [/* @__PURE__ */ jsx("span", { children: option.label }), /* @__PURE__ */ jsx(CheckIcon, {
1814
1936
  className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
1815
1937
  "aria-hidden": "true"
@@ -1831,10 +1953,10 @@ function CopyCodeButton(arg0) {
1831
1953
  copyTextToClipboard(code).then((ok) => {
1832
1954
  if (!ok) return;
1833
1955
  setCopied(true);
1834
- window.setTimeout(() => setCopied(false), 1e3);
1956
+ setTimeout(() => setCopied(false), 1e3);
1835
1957
  });
1836
1958
  },
1837
- className: "flex items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
1959
+ className: "ml-auto flex shrink-0 items-center gap-1.5 rounded-full bg-(--clarify-code-control-background) px-2.5 py-1.5 text-2xs font-medium whitespace-nowrap text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus:bg-(--clarify-code-control-background-hover) focus:text-(--clarify-code-text)",
1838
1960
  children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {
1839
1961
  className: "h-3.5 w-3.5 text-(--clarify-theme-tokens-colors-primary)",
1840
1962
  "aria-hidden": "true"
@@ -1861,9 +1983,9 @@ function CodeToolbar(arg0) {
1861
1983
  const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
1862
1984
  const t = useBuiltInText();
1863
1985
  return /* @__PURE__ */ jsxs("div", {
1864
- className: "absolute top-3.5 right-4 left-4 z-10 flex items-center justify-between gap-3",
1986
+ className: "clarify-api-code-toolbar flex items-center gap-2 px-4 pt-3",
1865
1987
  children: [/* @__PURE__ */ jsxs("div", {
1866
- className: "flex min-w-0 items-center gap-2",
1988
+ className: "clarify-api-code-toolbar-controls flex min-w-0 flex-1 flex-wrap items-center gap-2",
1867
1989
  children: [languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ jsx(SelectControl, {
1868
1990
  label: t("openapi.language"),
1869
1991
  value: selectedLanguageKey,
@@ -1888,12 +2010,12 @@ function CodeToolbar(arg0) {
1888
2010
  }
1889
2011
  //#endregion
1890
2012
  //#region source/openapi/components/helpers.ts
1891
- function getServers(spec, operation, path) {
2013
+ function getServers(spec, operation, path, source = "path") {
1892
2014
  const operationServers = operation.servers;
1893
- const pathServers = path ? getPathItem(spec, path)?.servers : void 0;
1894
- const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : spec.servers;
2015
+ const pathServers = path ? getOperationPathItem(spec, path, source)?.servers : void 0;
2016
+ const servers = Array.isArray(operationServers) ? operationServers : Array.isArray(pathServers) ? pathServers : source === "webhook" ? [{ url: "https://webhook.example.com" }] : spec.servers;
1895
2017
  if (!Array.isArray(servers)) return [{ url: "https://api.example.com" }];
1896
- const validServers = servers.filter((server) => isRecord(server) && typeof server.url === "string");
2018
+ const validServers = servers.filter((server) => isRecord$1(server) && typeof server.url === "string");
1897
2019
  return validServers.length > 0 ? validServers : [{ url: "https://api.example.com" }];
1898
2020
  }
1899
2021
  function getServerKey(server, index) {
@@ -1907,14 +2029,14 @@ function defaultServerVariables(server) {
1907
2029
  }
1908
2030
  function getSecuritySchemes(spec) {
1909
2031
  const schemes = spec.components;
1910
- if (!isRecord(schemes) || !isRecord(schemes.securitySchemes)) return {};
1911
- return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord(entry[1])));
2032
+ if (!isRecord$1(schemes) || !isRecord$1(schemes.securitySchemes)) return {};
2033
+ return Object.fromEntries(Object.entries(schemes.securitySchemes).filter((entry) => isRecord$1(entry[1])));
1912
2034
  }
1913
2035
  function getSecurityRequirements(spec, operation) {
1914
2036
  const operationSecurity = operation.security;
1915
- if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord);
2037
+ if (Array.isArray(operationSecurity)) return operationSecurity.filter(isRecord$1);
1916
2038
  const specSecurity = spec.security;
1917
- return Array.isArray(specSecurity) ? specSecurity.filter(isRecord) : [];
2039
+ return Array.isArray(specSecurity) ? specSecurity.filter(isRecord$1) : [];
1918
2040
  }
1919
2041
  function getAuthOptions(spec, operation) {
1920
2042
  const schemes = getSecuritySchemes(spec);
@@ -1968,7 +2090,7 @@ function ApiExampleCodeGroup(arg0) {
1968
2090
  className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-(--clarify-code-text)",
1969
2091
  children: title
1970
2092
  }), /* @__PURE__ */ jsxs("div", {
1971
- className: "ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
2093
+ className: "clarify-api-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
1972
2094
  children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ jsx(SelectControl, {
1973
2095
  label: t("openapi.mediaType"),
1974
2096
  value: selectedMediaType,
@@ -2008,7 +2130,7 @@ function ApiExampleCodeGroup(arg0) {
2008
2130
  ]
2009
2131
  }) : null,
2010
2132
  /* @__PURE__ */ jsxs("div", {
2011
- className: "clarify-api-example-code group relative bg-(--clarify-code-background)",
2133
+ className: "clarify-api-example-code group bg-(--clarify-code-background)",
2012
2134
  children: [/* @__PURE__ */ jsx(CodeToolbar, {
2013
2135
  code,
2014
2136
  languageOptions,
@@ -2018,10 +2140,10 @@ function ApiExampleCodeGroup(arg0) {
2018
2140
  selectedClientKey,
2019
2141
  onSelectClient
2020
2142
  }), /* @__PURE__ */ jsx("pre", {
2021
- className: `max-h-128 overflow-auto overscroll-contain p-4 text-xs text-(--clarify-code-text) ${languageOptions && languageOptions.length > 1 ? "pt-14" : ""}`,
2022
- children: /* @__PURE__ */ jsx("code", {
2023
- className: `language-${language}`,
2024
- children: code
2143
+ className: "max-h-128 overflow-auto overscroll-contain px-4 pt-3 pb-4 text-xs text-(--clarify-code-text)",
2144
+ children: /* @__PURE__ */ jsx(HighlightedCode, {
2145
+ code,
2146
+ language
2025
2147
  })
2026
2148
  })]
2027
2149
  })
@@ -2029,13 +2151,13 @@ function ApiExampleCodeGroup(arg0) {
2029
2151
  })
2030
2152
  });
2031
2153
  }
2032
- function firstExampleKeyForMediaType(requestContents, mediaType) {
2033
- return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value)[0]?.key ?? "";
2154
+ function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
2155
+ return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
2034
2156
  }
2035
2157
  function useRequestExamplesState(arg0) {
2036
- const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2158
+ const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
2037
2159
  const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
2038
- const examples = getExampleEntries(selectedContent?.value);
2160
+ const examples = getExampleEntries(selectedContent?.value, spec);
2039
2161
  const [selectedExampleKey, setSelectedExampleKey] = useState(examples[0]?.key ?? "");
2040
2162
  const [selectedLanguageKey, setSelectedLanguageKey] = useState("shell");
2041
2163
  const [selectedClientKey, setSelectedClientKey] = useState("curl");
@@ -2056,7 +2178,8 @@ function useRequestExamplesState(arg0) {
2056
2178
  } : void 0,
2057
2179
  server: selectedServer,
2058
2180
  serverVariables,
2059
- auth
2181
+ auth,
2182
+ operationSource
2060
2183
  });
2061
2184
  const selectedLanguage = codeOptions.find((option) => option.languageKey === selectedLanguageKey) ?? codeOptions[0];
2062
2185
  const selectedCode = codeOptions.find((option) => option.languageKey === selectedLanguage.languageKey && option.clientKey === selectedClientKey) ?? selectedLanguage;
@@ -2069,7 +2192,7 @@ function useRequestExamplesState(arg0) {
2069
2192
  examples,
2070
2193
  onSelectMediaType: (value) => {
2071
2194
  onSelectMediaType(value);
2072
- setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value));
2195
+ setSelectedExampleKey(firstExampleKeyForMediaType(requestContents, value, spec));
2073
2196
  },
2074
2197
  onSelectExample: (value) => {
2075
2198
  setSelectedExampleKey(value);
@@ -2084,7 +2207,7 @@ function useRequestExamplesState(arg0) {
2084
2207
  };
2085
2208
  }
2086
2209
  function RequestExamplesPanel(arg0) {
2087
- const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2210
+ const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
2088
2211
  const t = useBuiltInText();
2089
2212
  const state = useRequestExamplesState({
2090
2213
  spec,
@@ -2097,6 +2220,7 @@ function RequestExamplesPanel(arg0) {
2097
2220
  selectedServer,
2098
2221
  serverVariables,
2099
2222
  auth,
2223
+ operationSource,
2100
2224
  sharedExampleKey,
2101
2225
  onSelectExampleKey
2102
2226
  });
@@ -2120,12 +2244,15 @@ function RequestExamplesPanel(arg0) {
2120
2244
  onSelectClient: state.onSelectClient
2121
2245
  });
2122
2246
  }
2123
- function firstExampleKeyForResponseContent(content) {
2124
- return getExampleEntries(content?.value)[0]?.key ?? "";
2247
+ function firstExampleKeyForResponseContent(content, spec) {
2248
+ return getExampleEntries(content?.value, spec)[0]?.key ?? "";
2249
+ }
2250
+ function getResponseExampleBody(content, example) {
2251
+ return content ? stringifyExample(example?.value) : "";
2125
2252
  }
2126
2253
  function useResponseExamplesState(arg0) {
2127
2254
  const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2128
- const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
2255
+ const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
2129
2256
  if (left.status === "default") return -1;
2130
2257
  if (right.status === "default") return 1;
2131
2258
  const leftCode = Number(left.status);
@@ -2140,15 +2267,15 @@ function useResponseExamplesState(arg0) {
2140
2267
  const [selection, setSelection] = useState(() => ({
2141
2268
  status: activeStatus,
2142
2269
  mediaType: responseContents[0]?.mediaType ?? "",
2143
- exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2270
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
2144
2271
  }));
2145
2272
  const resolvedSelection = selection.status === activeStatus ? selection : {
2146
2273
  status: activeStatus,
2147
2274
  mediaType: responseContents[0]?.mediaType ?? "",
2148
- exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2275
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0], spec)
2149
2276
  };
2150
2277
  const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
2151
- const examples = getExampleEntries(selectedContent?.value);
2278
+ const examples = getExampleEntries(selectedContent?.value, spec);
2152
2279
  const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
2153
2280
  const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
2154
2281
  const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
@@ -2159,7 +2286,7 @@ function useResponseExamplesState(arg0) {
2159
2286
  selectedContent,
2160
2287
  examples,
2161
2288
  selectedExample,
2162
- responseCode: stringifyExample(selectedExample?.value),
2289
+ responseBody: getResponseExampleBody(selectedContent, selectedExample),
2163
2290
  onSelectStatus: (value) => {
2164
2291
  const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
2165
2292
  if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
@@ -2167,7 +2294,7 @@ function useResponseExamplesState(arg0) {
2167
2294
  setSelection({
2168
2295
  status: value,
2169
2296
  mediaType: nextContents[0]?.mediaType ?? "",
2170
- exampleKey: firstExampleKeyForResponseContent(nextContents[0])
2297
+ exampleKey: firstExampleKeyForResponseContent(nextContents[0], spec)
2171
2298
  });
2172
2299
  },
2173
2300
  onSelectMediaType: (value) => {
@@ -2175,7 +2302,7 @@ function useResponseExamplesState(arg0) {
2175
2302
  setSelection((current) => ({
2176
2303
  ...current,
2177
2304
  mediaType: value,
2178
- exampleKey: firstExampleKeyForResponseContent(nextContent)
2305
+ exampleKey: firstExampleKeyForResponseContent(nextContent, spec)
2179
2306
  }));
2180
2307
  },
2181
2308
  onSelectExample: (value) => {
@@ -2188,7 +2315,7 @@ function useResponseExamplesState(arg0) {
2188
2315
  };
2189
2316
  }
2190
2317
  function ResponseExamplesPanel(arg0) {
2191
- const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2318
+ const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2192
2319
  const t = useBuiltInText();
2193
2320
  const state = useResponseExamplesState({
2194
2321
  operation,
@@ -2198,17 +2325,13 @@ function ResponseExamplesPanel(arg0) {
2198
2325
  selectedStatus,
2199
2326
  onSelectStatus
2200
2327
  });
2201
- if (!state.selectedResponse || !state.selectedContent || !state.responseCode) return null;
2328
+ if (!state.selectedContent || !state.responseBody) return null;
2202
2329
  return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
2203
- title: t("openapi.response"),
2204
- tag: state.selectedResponse.status,
2205
- tagOptions: state.responses.map(({ status }) => status),
2206
- onSelectTag: state.onSelectStatus,
2207
- label: state.selectedContent.mediaType,
2330
+ title: title ?? t("openapi.response"),
2331
+ label: state.selectedContent?.mediaType,
2208
2332
  labelOptions: state.responseContents.map((content) => content.mediaType),
2209
- onSelectLabel: state.onSelectMediaType,
2210
- comfortableMeta: true,
2211
- code: state.responseCode,
2333
+ onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
2334
+ code: state.responseBody,
2212
2335
  language: codeLanguageForMediaType(state.selectedContent.mediaType),
2213
2336
  examples: state.examples,
2214
2337
  selectedExampleKey: state.selectedExample?.key,
@@ -2220,7 +2343,7 @@ function ResponseExamplesPanel(arg0) {
2220
2343
  function getEnumDescriptions(schema) {
2221
2344
  const descriptions = schema["x-enumDescriptions"];
2222
2345
  if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
2223
- if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
2346
+ if (isRecord$1(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
2224
2347
  const description = descriptions[String(value)];
2225
2348
  return typeof description === "string" ? description : void 0;
2226
2349
  }) : [];
@@ -2286,7 +2409,7 @@ function getSchemaChildren(arg0) {
2286
2409
  defaultExpanded
2287
2410
  });
2288
2411
  }
2289
- if (!isRecord(schema)) return [];
2412
+ if (!isRecord$1(schema)) return [];
2290
2413
  const arrayChildren = schemaHasType(schema, "array") ? getSchemaChildren({
2291
2414
  spec,
2292
2415
  schema: schema.items,
@@ -2297,10 +2420,10 @@ function getSchemaChildren(arg0) {
2297
2420
  }) : [];
2298
2421
  const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
2299
2422
  const enumChildren = getEnumChildren(schema, path);
2300
- const properties = isRecord(schema.properties) ? schema.properties : {};
2423
+ const properties = isRecord$1(schema.properties) ? schema.properties : {};
2301
2424
  const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
2302
2425
  const resolvedProperty = resolveSchema(spec, propertySchema);
2303
- const property = isRecord(resolvedProperty) ? resolvedProperty : isRecord(propertySchema) ? propertySchema : {};
2426
+ const property = isRecord$1(resolvedProperty) ? resolvedProperty : isRecord$1(propertySchema) ? propertySchema : {};
2304
2427
  const isArray = schemaHasType(property, "array");
2305
2428
  const childPath = path ? `${path}.${name}` : name;
2306
2429
  const children = getSchemaChildren({
@@ -2324,7 +2447,7 @@ function getSchemaChildren(arg0) {
2324
2447
  children
2325
2448
  };
2326
2449
  });
2327
- const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
2450
+ const additionalPropertyChildren = isRecord$1(schema.additionalProperties) ? [{
2328
2451
  key: `${path || "root"}.*`,
2329
2452
  name: "*",
2330
2453
  kind: "property",
@@ -2344,7 +2467,7 @@ function getSchemaChildren(arg0) {
2344
2467
  }] : [];
2345
2468
  const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
2346
2469
  const resolvedBranch = resolveSchema(spec, branchSchema);
2347
- const branch = isRecord(resolvedBranch) ? resolvedBranch : void 0;
2470
+ const branch = isRecord$1(resolvedBranch) ? resolvedBranch : void 0;
2348
2471
  return {
2349
2472
  key: `${path || "root"}.${label}`,
2350
2473
  name: label,
@@ -2376,7 +2499,7 @@ function getSchemaChildren(arg0) {
2376
2499
  function getRootSchemaNode(spec, schema, defaultExpanded) {
2377
2500
  if (isReference(schema)) {
2378
2501
  const resolvedSchema = resolveSchema(spec, schema);
2379
- const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
2502
+ const resolved = isRecord$1(resolvedSchema) ? resolvedSchema : {};
2380
2503
  return {
2381
2504
  key: schema.$ref,
2382
2505
  name: resolveReferenceName(schema.$ref),
@@ -2394,7 +2517,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
2394
2517
  })
2395
2518
  };
2396
2519
  }
2397
- if (!isRecord(schema)) return void 0;
2520
+ if (!isRecord$1(schema)) return void 0;
2398
2521
  return {
2399
2522
  key: "root",
2400
2523
  name: "body",
@@ -2468,7 +2591,7 @@ function SchemaNode(arg0) {
2468
2591
  className: "*:first:mt-0 *:last:mb-0",
2469
2592
  children: node.description
2470
2593
  }) : fallbackDescription, node.details ? /* @__PURE__ */ jsx("p", {
2471
- className: "text-xs text-(--clarify-ui-text-faint)",
2594
+ className: "text-xs text-(--clarify-ui-text-soft)",
2472
2595
  children: node.details
2473
2596
  }) : null]
2474
2597
  })]
@@ -2484,7 +2607,7 @@ function SchemaNode(arg0) {
2484
2607
  "aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
2485
2608
  "aria-expanded": expanded,
2486
2609
  onClick: () => setExpanded((value) => !value),
2487
- className: clsx(rowClassName, "cursor-pointer transition"),
2610
+ className: clsx(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)"),
2488
2611
  children: content
2489
2612
  }) : /* @__PURE__ */ jsx("div", {
2490
2613
  className: rowClassName,
@@ -2531,7 +2654,7 @@ function ParameterList(arg0) {
2531
2654
  }, `${parameter.in}-${parameter.name}`)) })] });
2532
2655
  }
2533
2656
  function ResponseList(arg0) {
2534
- const { operation, spec, selectedStatus, onSelectStatus } = arg0;
2657
+ const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
2535
2658
  const t = useBuiltInText();
2536
2659
  const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
2537
2660
  if (left.status === "default") return -1;
@@ -2552,10 +2675,10 @@ function ResponseList(arg0) {
2552
2675
  children: [
2553
2676
  /* @__PURE__ */ jsxs("div", {
2554
2677
  className: "flex flex-wrap items-center gap-2",
2555
- children: [/* @__PURE__ */ jsx("span", {
2678
+ children: [orderedResponses.length === 1 ? /* @__PURE__ */ jsx("span", {
2556
2679
  className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
2557
2680
  children: status
2558
- }), type ? /* @__PURE__ */ jsx("span", {
2681
+ }) : null, type ? /* @__PURE__ */ jsx("span", {
2559
2682
  className: "text-xs text-(--clarify-theme-tokens-colors-muted)",
2560
2683
  children: type
2561
2684
  }) : null]
@@ -2580,12 +2703,12 @@ function ResponseList(arg0) {
2580
2703
  };
2581
2704
  if (orderedResponses.length === 1) {
2582
2705
  const [{ status, response }] = orderedResponses;
2583
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), renderResponsePanel({
2706
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title ?? t("openapi.responses") }), renderResponsePanel({
2584
2707
  status,
2585
2708
  response
2586
2709
  })] });
2587
2710
  }
2588
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: t("openapi.responses") }), /* @__PURE__ */ jsx(Tabs, {
2711
+ return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h3", { children: title ?? t("openapi.responses") }), /* @__PURE__ */ jsx(Tabs, {
2589
2712
  selectedIndex,
2590
2713
  onChange: (index) => {
2591
2714
  onSelectStatus?.(orderedResponses[index]?.status ?? "");
@@ -2604,7 +2727,7 @@ function ResponseList(arg0) {
2604
2727
  //#endregion
2605
2728
  //#region source/openapi/components/EndpointSections.tsx
2606
2729
  function EndpointRequest(arg0) {
2607
- const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2730
+ const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2608
2731
  const t = useBuiltInText();
2609
2732
  const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
2610
2733
  const renderDescription = () => {
@@ -2656,6 +2779,7 @@ function EndpointRequest(arg0) {
2656
2779
  selectedServer,
2657
2780
  serverVariables,
2658
2781
  auth,
2782
+ operationSource,
2659
2783
  sharedExampleKey,
2660
2784
  onSelectExampleKey
2661
2785
  })
@@ -2664,7 +2788,10 @@ function EndpointRequest(arg0) {
2664
2788
  })] });
2665
2789
  }
2666
2790
  function EndpointResponse(arg0) {
2667
- const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2791
+ const { spec, operation, operationSource = "path", sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2792
+ const t = useBuiltInText();
2793
+ const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
2794
+ const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
2668
2795
  return /* @__PURE__ */ jsx("div", {
2669
2796
  className: "mt-6",
2670
2797
  children: /* @__PURE__ */ jsxs(Row, {
@@ -2672,6 +2799,7 @@ function EndpointResponse(arg0) {
2672
2799
  children: [/* @__PURE__ */ jsx(Col, { children: /* @__PURE__ */ jsx("div", {
2673
2800
  className: "w-full",
2674
2801
  children: /* @__PURE__ */ jsx(ResponseList, {
2802
+ title: responseTitle,
2675
2803
  operation,
2676
2804
  spec,
2677
2805
  selectedStatus,
@@ -2684,6 +2812,7 @@ function EndpointResponse(arg0) {
2684
2812
  children: /* @__PURE__ */ jsx(ResponseExamplesPanel, {
2685
2813
  operation,
2686
2814
  spec,
2815
+ title: responseExampleTitle,
2687
2816
  sharedExampleKey,
2688
2817
  onSelectExampleKey,
2689
2818
  selectedStatus,
@@ -2696,8 +2825,8 @@ function EndpointResponse(arg0) {
2696
2825
  }
2697
2826
  //#endregion
2698
2827
  //#region source/openapi/components/OpenApiOperation.state.ts
2699
- function useOperationRequestState(spec, path, operation) {
2700
- const parameters = getOperationParameters(spec, path, operation);
2828
+ function useOperationRequestState(spec, path, operation, source = "path") {
2829
+ const parameters = getOperationParameters(spec, path, operation, source);
2701
2830
  const requestBody = getRequestBody$1(spec, operation);
2702
2831
  const requestContents = getMediaTypeEntries(requestBody?.content, spec);
2703
2832
  const [selectedRequestMediaType, setSelectedRequestMediaType] = useState(requestContents[0]?.mediaType ?? "");
@@ -2718,8 +2847,8 @@ function useOperationRequestState(spec, path, operation) {
2718
2847
  groupedParameters
2719
2848
  };
2720
2849
  }
2721
- function useOperationServerState(spec, operation, path) {
2722
- const servers = getServers(spec, operation, path);
2850
+ function useOperationServerState(spec, operation, path, source = "path") {
2851
+ const servers = getServers(spec, operation, path, source);
2723
2852
  const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
2724
2853
  const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
2725
2854
  const [serverVariables, setServerVariables] = useState(defaultServerVariables(selectedServer));
@@ -2776,7 +2905,8 @@ var endpointMethodStyleVars = {
2776
2905
  POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
2777
2906
  PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
2778
2907
  PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
2779
- DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)"
2908
+ DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
2909
+ WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
2780
2910
  };
2781
2911
  function EndpointMethodBadge(arg0) {
2782
2912
  const { method } = arg0;
@@ -2801,7 +2931,7 @@ function EndpointPath(arg0) {
2801
2931
  "aria-label": copied ? t("actions.copied") : t("actions.copy"),
2802
2932
  title: copied ? t("actions.copied") : t("actions.copy"),
2803
2933
  onClick: onCopy,
2804
- className: clsx("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
2934
+ className: clsx("flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) text-(--clarify-ui-text-soft) transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
2805
2935
  children: copied ? /* @__PURE__ */ jsx(CheckIcon, {
2806
2936
  className: "h-3.5 w-3.5",
2807
2937
  "aria-hidden": "true"
@@ -2822,7 +2952,7 @@ function InlineListbox(arg0) {
2822
2952
  className: "pointer-events-auto relative inline-flex min-w-0",
2823
2953
  children: [/* @__PURE__ */ jsxs(ListboxButton, {
2824
2954
  "aria-label": label,
2825
- className: clsx("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) data-open:border-(--clarify-ui-text-faint) data-open:bg-(--clarify-ui-hover-background)", compact ? "max-w-32 px-1.5 py-0.5 text-xs" : "w-full px-2.5 py-1.5 text-xs"),
2955
+ className: clsx("inline-flex min-w-0 items-center gap-1 rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) font-semibold text-(--clarify-ui-text-strong) shadow-xs outline-hidden transition hover:border-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) data-open:border-(--clarify-ui-accent-border) data-open:bg-(--clarify-ui-active-background) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)", compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2.5 py-1.5 text-xs"),
2826
2956
  children: [/* @__PURE__ */ jsx("span", {
2827
2957
  className: "truncate",
2828
2958
  children: selected?.label ?? value
@@ -2835,7 +2965,7 @@ function InlineListbox(arg0) {
2835
2965
  className: "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-xl bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 ring-1 ring-(--clarify-theme-tokens-colors-border) [--anchor-gap:--spacing(1)] focus:outline-none",
2836
2966
  children: options.map((option) => /* @__PURE__ */ jsxs(ListboxOption, {
2837
2967
  value: option.value,
2838
- className: "group flex cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-selected:text-(--clarify-theme-tokens-colors-primary)",
2968
+ className: "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-lg px-2.5 py-2 text-xs text-(--clarify-ui-text) select-none data-focus:bg-(--clarify-ui-hover-background) data-focus:text-(--clarify-ui-text-strong) data-selected:bg-(--clarify-ui-active-background) data-selected:text-(--clarify-ui-accent-text)",
2839
2969
  children: [/* @__PURE__ */ jsxs("span", {
2840
2970
  className: "min-w-0",
2841
2971
  children: [/* @__PURE__ */ jsx("span", {
@@ -2858,9 +2988,12 @@ function getServerPreviewUrl(server, variables) {
2858
2988
  return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
2859
2989
  }
2860
2990
  function getFullEndpointUrl(server, variables, path) {
2861
- const base = getServerPreviewUrl(server, variables);
2862
- if (!base) return path;
2863
- return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
2991
+ return joinPath(getServerPreviewUrl(server, variables), path);
2992
+ }
2993
+ function getServerProtocolLabel(server, variables) {
2994
+ const url = getServerPreviewUrl(server, variables);
2995
+ const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
2996
+ return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
2864
2997
  }
2865
2998
  function getDefaultResponseStatus(operation, spec) {
2866
2999
  const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
@@ -2876,21 +3009,25 @@ function getDefaultResponseStatus(operation, spec) {
2876
3009
  function ServerUrlValue(arg0) {
2877
3010
  const { server, variables, open, interactive, onToggle } = arg0;
2878
3011
  const url = getServerPreviewUrl(server, variables);
3012
+ const protocolLabel = getServerProtocolLabel(server, variables);
2879
3013
  if (!interactive) return /* @__PURE__ */ jsxs("span", {
2880
3014
  "aria-label": "Server",
2881
- className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-foreground) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
3015
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5",
2882
3016
  children: [/* @__PURE__ */ jsx("span", {
2883
3017
  className: "sm:hidden",
2884
3018
  children: /* @__PURE__ */ jsx(ServerIcon, {
2885
3019
  className: "h-4 w-4",
2886
3020
  "aria-hidden": "true"
2887
3021
  })
2888
- }), /* @__PURE__ */ jsx("span", {
2889
- className: "hidden min-w-0 items-center overflow-hidden sm:flex",
2890
- children: /* @__PURE__ */ jsx("span", {
3022
+ }), /* @__PURE__ */ jsxs("span", {
3023
+ className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
3024
+ children: [protocolLabel ? /* @__PURE__ */ jsx("span", {
3025
+ className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
3026
+ children: protocolLabel
3027
+ }) : null, /* @__PURE__ */ jsx("span", {
2891
3028
  className: "truncate font-semibold text-xs",
2892
3029
  children: url
2893
- })
3030
+ })]
2894
3031
  })]
2895
3032
  });
2896
3033
  return /* @__PURE__ */ jsxs("button", {
@@ -2898,7 +3035,7 @@ function ServerUrlValue(arg0) {
2898
3035
  "aria-expanded": open,
2899
3036
  "aria-label": "Server",
2900
3037
  onClick: onToggle,
2901
- className: clsx("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-foreground) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
3038
+ className: clsx("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
2902
3039
  children: [/* @__PURE__ */ jsx("span", {
2903
3040
  className: "sm:hidden",
2904
3041
  children: /* @__PURE__ */ jsx(ServerIcon, {
@@ -2907,13 +3044,20 @@ function ServerUrlValue(arg0) {
2907
3044
  })
2908
3045
  }), /* @__PURE__ */ jsxs("span", {
2909
3046
  className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
2910
- children: [/* @__PURE__ */ jsx("span", {
2911
- className: "truncate font-semibold text-xs",
2912
- children: url
2913
- }), /* @__PURE__ */ jsx(ChevronDownIcon, {
2914
- className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
2915
- "aria-hidden": "true"
2916
- })]
3047
+ children: [
3048
+ protocolLabel ? /* @__PURE__ */ jsx("span", {
3049
+ className: "shrink-0 rounded bg-sky-100 px-1.5 py-0.5 text-2xs font-black text-sky-700 dark:bg-sky-400/15 dark:text-sky-200",
3050
+ children: protocolLabel
3051
+ }) : null,
3052
+ /* @__PURE__ */ jsx("span", {
3053
+ className: "truncate font-semibold text-xs",
3054
+ children: url
3055
+ }),
3056
+ /* @__PURE__ */ jsx(ChevronDownIcon, {
3057
+ className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
3058
+ "aria-hidden": "true"
3059
+ })
3060
+ ]
2917
3061
  })]
2918
3062
  });
2919
3063
  }
@@ -3010,7 +3154,8 @@ function AuthPanel(arg0) {
3010
3154
  className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
3011
3155
  children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
3012
3156
  }), /* @__PURE__ */ jsx("input", {
3013
- value: authValues[selectedAuth.name] ?? authPlaceholder(selectedAuth),
3157
+ value: authValues[selectedAuth.name] ?? "",
3158
+ placeholder: authPlaceholder(selectedAuth),
3014
3159
  onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
3015
3160
  className: "min-w-0 flex-1 border-0 bg-transparent px-0 py-0 text-xs font-semibold text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
3016
3161
  })]
@@ -3020,14 +3165,14 @@ function AuthPanel(arg0) {
3020
3165
  });
3021
3166
  }
3022
3167
  function EndpointIdentity(arg0) {
3023
- const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
3168
+ const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
3024
3169
  const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
3025
3170
  const [copiedUrl, setCopiedUrl] = useState(false);
3026
3171
  const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
3027
3172
  useEffect(() => {
3028
3173
  if (!copiedUrl) return void 0;
3029
- const timeout = window.setTimeout(() => setCopiedUrl(false), 1200);
3030
- return () => window.clearTimeout(timeout);
3174
+ const timeout = setTimeout(() => setCopiedUrl(false), 1200);
3175
+ return () => clearTimeout(timeout);
3031
3176
  }, [copiedUrl]);
3032
3177
  async function handleCopyUrl() {
3033
3178
  if (await copyTextToClipboard(fullUrl)) setCopiedUrl(true);
@@ -3039,6 +3184,7 @@ function EndpointIdentity(arg0) {
3039
3184
  className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
3040
3185
  children: [
3041
3186
  /* @__PURE__ */ jsx(EndpointMethodBadge, { method }),
3187
+ operationSource === "webhook" ? /* @__PURE__ */ jsx(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
3042
3188
  /* @__PURE__ */ jsx(ServerUrlValue, {
3043
3189
  server: selectedServer,
3044
3190
  variables: serverVariables,
@@ -3056,7 +3202,7 @@ function EndpointIdentity(arg0) {
3056
3202
  "aria-expanded": authOpen,
3057
3203
  "aria-label": "Auth",
3058
3204
  onClick: onToggleAuth,
3059
- className: clsx("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
3205
+ className: clsx("ml-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-emerald-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) dark:hover:text-emerald-200", authOpen ? "bg-emerald-100 text-emerald-800 dark:bg-emerald-400/15 dark:text-emerald-100" : "bg-(--clarify-ui-subtle-background)"),
3060
3206
  children: authOpen ? /* @__PURE__ */ jsx(UnlockKeyholeIcon, {
3061
3207
  className: "h-4 w-4",
3062
3208
  "aria-hidden": "true"
@@ -3087,12 +3233,12 @@ function EndpointIdentity(arg0) {
3087
3233
  });
3088
3234
  }
3089
3235
  function OpenApiOperation(arg0) {
3090
- const { spec, path, method, operation } = arg0;
3091
- const id = slug(`${method.toLowerCase()} ${path}`);
3236
+ const { spec, path, method, operation, operationSource = "path" } = arg0;
3237
+ const id = getOpenApiOperationSectionId(operation);
3092
3238
  const summary = operation.summary ?? `${method} ${path}`;
3093
3239
  const description = operation.description;
3094
- const requestState = useOperationRequestState(spec, path, operation);
3095
- const serverState = useOperationServerState(spec, operation, path);
3240
+ const requestState = useOperationRequestState(spec, path, operation, operationSource);
3241
+ const serverState = useOperationServerState(spec, operation, path, operationSource);
3096
3242
  const authState = useOperationAuthState(spec, operation);
3097
3243
  const [linkedExampleKey, setLinkedExampleKey] = useState("");
3098
3244
  const [selectedResponseStatus, setSelectedResponseStatus] = useState(() => getDefaultResponseStatus(operation, spec));
@@ -3106,6 +3252,7 @@ function OpenApiOperation(arg0) {
3106
3252
  }),
3107
3253
  /* @__PURE__ */ jsx(EndpointIdentity, {
3108
3254
  method,
3255
+ operationSource,
3109
3256
  path,
3110
3257
  servers: serverState.servers,
3111
3258
  selectedServerKey: serverState.selectedServerKey,
@@ -3134,6 +3281,7 @@ function OpenApiOperation(arg0) {
3134
3281
  spec,
3135
3282
  path,
3136
3283
  method,
3284
+ operationSource,
3137
3285
  description,
3138
3286
  groupedParameters: requestState.groupedParameters,
3139
3287
  parameters: requestState.parameters,
@@ -3151,6 +3299,7 @@ function OpenApiOperation(arg0) {
3151
3299
  /* @__PURE__ */ jsx(EndpointResponse, {
3152
3300
  spec,
3153
3301
  operation,
3302
+ operationSource,
3154
3303
  sharedExampleKey: linkedExampleKey,
3155
3304
  onSelectExampleKey: setLinkedExampleKey,
3156
3305
  selectedStatus: selectedResponseStatus,
@@ -3160,6 +3309,6 @@ function OpenApiOperation(arg0) {
3160
3309
  });
3161
3310
  }
3162
3311
  //#endregion
3163
- export { Button as A, Code as C, Card as D, Mermaid as E, CardGroup as O, Collapse as S, Pre as T, HeroPattern as _, authPlaceholder as a, Tag as b, getServerKey as c, getRequestBody$1 as d, Markdown as f, GridPattern as g, Prose as h, ResponseExamplesPanel as i, Callout as k, getServers as l, WebFrame as m, OpenApiOperation as n, defaultServerVariables as o, primitives_exports as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getMediaTypeEntries as u, Logo as v, CodeGroup as w, Feedback as x, Heading as y };
3312
+ export { CardGroup as A, Feedback as C, Pre as D, CodeGroup as E, Button as M, Mermaid as O, Tag as S, Code as T, Prose as _, authPlaceholder as a, Logo as b, getServerKey as c, listOpenApiOperations as d, getMediaTypeEntries as f, WebFrame as g, primitives_exports as h, ResponseExamplesPanel as i, Callout as j, Card as k, getServers as l, Markdown as m, OpenApiOperation as n, defaultServerVariables as o, getRequestBody$1 as p, RequestExamplesPanel as r, getAuthOptions as s, EndpointIdentity as t, getOpenApiOperationEntry as u, GridPattern as v, Collapse as w, Heading as x, HeroPattern as y };
3164
3313
 
3165
- //# sourceMappingURL=OpenApiOperation-CyBkzvob.js.map
3314
+ //# sourceMappingURL=OpenApiOperation-DgrqzeiS.js.map