@clarify-labs/renderer 0.10.3 → 0.11.1

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 (83) hide show
  1. package/output/{ClarifyShell-UsefuuLS.cjs → ClarifyShell-C2XnkFQ6.cjs} +119 -100
  2. package/output/ClarifyShell-C2XnkFQ6.cjs.map +1 -0
  3. package/output/{ClarifyShell-Cq5Af46F.js → ClarifyShell-CwRtof1h.js} +119 -100
  4. package/output/ClarifyShell-CwRtof1h.js.map +1 -0
  5. package/output/{MermaidViewer-Db7qsyVk.cjs → MermaidViewer-CTvMCE19.cjs} +2 -2
  6. package/output/{MermaidViewer-Db7qsyVk.cjs.map → MermaidViewer-CTvMCE19.cjs.map} +1 -1
  7. package/output/{MermaidViewer-Bc9H25yK.js → MermaidViewer-CwkiQ2gO.js} +2 -2
  8. package/output/{MermaidViewer-Bc9H25yK.js.map → MermaidViewer-CwkiQ2gO.js.map} +1 -1
  9. package/output/{OpenApiOperation-BZWeCbvy.js → OpenApiOperation-CFo6_otd.js} +1964 -292
  10. package/output/OpenApiOperation-CFo6_otd.js.map +1 -0
  11. package/output/{OpenApiOperation-DbZjxIuj.cjs → OpenApiOperation-D1WNrj5X.cjs} +1967 -289
  12. package/output/OpenApiOperation-D1WNrj5X.cjs.map +1 -0
  13. package/output/{PageActions-BQeEmXbT.js → PageActions-3eo05fb_.js} +60 -19
  14. package/output/PageActions-3eo05fb_.js.map +1 -0
  15. package/output/{PageActions-Dg1l9KB1.cjs → PageActions-Lp_NeIKr.cjs} +59 -18
  16. package/output/PageActions-Lp_NeIKr.cjs.map +1 -0
  17. package/output/{SearchDialog-B67VA0Ut.js → SearchDialog-BvCBIFqs.js} +3 -3
  18. package/output/{SearchDialog-B67VA0Ut.js.map → SearchDialog-BvCBIFqs.js.map} +1 -1
  19. package/output/{SearchDialog-DjKvqN7p.cjs → SearchDialog-CM9DrE2Y.cjs} +3 -3
  20. package/output/{SearchDialog-DjKvqN7p.cjs.map → SearchDialog-CM9DrE2Y.cjs.map} +1 -1
  21. package/output/app/PageFooter.d.ts +1 -1
  22. package/output/client.cjs +3 -3
  23. package/output/client.js +3 -3
  24. package/output/components/Tooltip.d.ts +1 -0
  25. package/output/core/i18n.d.ts +1 -1
  26. package/output/core/types.d.ts +37 -19
  27. package/output/{i18n-Bqth9d6Q.js → i18n-BxXpRSFX.js} +106 -2
  28. package/output/i18n-BxXpRSFX.js.map +1 -0
  29. package/output/{i18n-C-fReCj-.cjs → i18n-DsjZ51U1.cjs} +106 -2
  30. package/output/i18n-DsjZ51U1.cjs.map +1 -0
  31. package/output/index.cjs +26 -5
  32. package/output/index.cjs.map +1 -1
  33. package/output/index.d.ts +3 -3
  34. package/output/index.js +26 -6
  35. package/output/index.js.map +1 -1
  36. package/output/mdx/components.d.ts +2 -1
  37. package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
  38. package/output/openapi/components/EndpointSections.d.ts +2 -2
  39. package/output/openapi/components/ExamplePanels.d.ts +2 -2
  40. package/output/openapi/components/InlineListbox.d.ts +14 -0
  41. package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
  42. package/output/openapi/components/OpenApiOperation.d.ts +1 -9
  43. package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
  44. package/output/openapi/components/OpenApiRequest.d.ts +18 -0
  45. package/output/openapi/components/OpenApiRequestBodyEditor.d.ts +14 -0
  46. package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
  47. package/output/openapi/components/OpenApiResponseViewer.d.ts +14 -0
  48. package/output/openapi/components/SendRequestButton.d.ts +9 -0
  49. package/output/openapi/components/helpers.d.ts +6 -1
  50. package/output/openapi/components/useOpenApiRequestState.d.ts +48 -0
  51. package/output/openapi/entry.d.ts +2 -0
  52. package/output/openapi/index.d.ts +2 -2
  53. package/output/openapi/lib/api-exchange-code.d.ts +8 -0
  54. package/output/openapi/lib/api-exchange.d.ts +30 -0
  55. package/output/openapi/lib/api-request.d.ts +25 -0
  56. package/output/openapi/lib/helpers.d.ts +8 -0
  57. package/output/openapi/lib/request-code.d.ts +2 -2
  58. package/output/openapi/lib/request-parameters.d.ts +5 -0
  59. package/output/openapi/store.d.ts +10 -0
  60. package/output/openapi/types.d.ts +6 -0
  61. package/output/preview.cjs +46 -40
  62. package/output/preview.cjs.map +1 -1
  63. package/output/preview.js +46 -40
  64. package/output/preview.js.map +1 -1
  65. package/output/{render-Dc9wxg_r.cjs → render-CKG4X-me.cjs} +2 -2
  66. package/output/{render-Dc9wxg_r.cjs.map → render-CKG4X-me.cjs.map} +1 -1
  67. package/output/{render-aS-w4fK4.js → render-vlp3hwW3.js} +2 -2
  68. package/output/{render-aS-w4fK4.js.map → render-vlp3hwW3.js.map} +1 -1
  69. package/output/renderer.css +630 -152
  70. package/output/server.cjs +2 -2
  71. package/output/server.js +2 -2
  72. package/output/theme/ThemeEditor.d.ts +8 -4
  73. package/output/theme/variables.d.ts +8 -4
  74. package/package.json +2 -1
  75. package/output/ClarifyShell-Cq5Af46F.js.map +0 -1
  76. package/output/ClarifyShell-UsefuuLS.cjs.map +0 -1
  77. package/output/OpenApiOperation-BZWeCbvy.js.map +0 -1
  78. package/output/OpenApiOperation-DbZjxIuj.cjs.map +0 -1
  79. package/output/PageActions-BQeEmXbT.js.map +0 -1
  80. package/output/PageActions-Dg1l9KB1.cjs.map +0 -1
  81. package/output/core/index.d.ts +0 -3
  82. package/output/i18n-Bqth9d6Q.js.map +0 -1
  83. package/output/i18n-C-fReCj-.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
2
- const require_i18n = require("./i18n-C-fReCj-.cjs");
3
- const require_PageActions = require("./PageActions-Dg1l9KB1.cjs");
2
+ const require_i18n = require("./i18n-DsjZ51U1.cjs");
3
+ const require_PageActions = require("./PageActions-Lp_NeIKr.cjs");
4
4
  const require_remark = require("./remark-DTLbG8PK.cjs");
5
5
  let clsx = require("clsx");
6
6
  clsx = require_rolldown_runtime.__toESM(clsx, 1);
@@ -18,6 +18,7 @@ rehype_raw = require_rolldown_runtime.__toESM(rehype_raw, 1);
18
18
  let github_slugger = require("github-slugger");
19
19
  let shiki = require("shiki");
20
20
  let _scalar_snippetz = require("@scalar/snippetz");
21
+ let yaml = require("yaml");
21
22
  //#region source/components/AccordionGroup.tsx
22
23
  function AccordionGroup(arg0) {
23
24
  const { children, multiple = false, className, ...props } = arg0;
@@ -244,7 +245,7 @@ function Card(arg0) {
244
245
  }
245
246
  //#endregion
246
247
  //#region source/components/Mermaid.tsx
247
- var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-Db7qsyVk.cjs")));
248
+ var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-CTvMCE19.cjs")));
248
249
  var mermaidModulePromise;
249
250
  async function loadMermaid() {
250
251
  mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
@@ -391,7 +392,7 @@ function getCodePanelTitle(node, fallbackTitle) {
391
392
  fallbackTitle
392
393
  });
393
394
  }
394
- function CopyButton(arg0) {
395
+ function CopyButton$1(arg0) {
395
396
  const { code } = arg0;
396
397
  const t = require_i18n.useBuiltInText();
397
398
  const [copyCount, setCopyCount] = (0, react.useState)(0);
@@ -452,7 +453,7 @@ function CodePanel(arg0) {
452
453
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
453
454
  className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
454
455
  children
455
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { code: copyText })]
456
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton$1, { code: copyText })]
456
457
  })]
457
458
  });
458
459
  }
@@ -1049,28 +1050,61 @@ function Tabs(arg0) {
1049
1050
  //#endregion
1050
1051
  //#region source/components/Tooltip.tsx
1051
1052
  function Tooltip(arg0) {
1052
- const { content, children, side = "top", className, ...props } = arg0;
1053
+ const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
1053
1054
  const contentId = (0, react.useId)();
1054
1055
  const [open, setOpen] = (0, react.useState)(false);
1056
+ const triggerRef = (0, react.useRef)(null);
1057
+ const tooltipRef = (0, react.useRef)(null);
1058
+ const [position, setPosition] = (0, react.useState)();
1059
+ (0, react.useEffect)(() => {
1060
+ if (!open) return;
1061
+ function updatePosition() {
1062
+ const bounds = triggerRef.current?.getBoundingClientRect();
1063
+ if (!bounds) return;
1064
+ setPosition({
1065
+ left: bounds.left + bounds.width / 2,
1066
+ top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
1067
+ });
1068
+ }
1069
+ updatePosition();
1070
+ window.addEventListener("resize", updatePosition);
1071
+ window.addEventListener("scroll", updatePosition, true);
1072
+ return () => {
1073
+ window.removeEventListener("resize", updatePosition);
1074
+ window.removeEventListener("scroll", updatePosition, true);
1075
+ };
1076
+ }, [open, side]);
1077
+ (0, react.useEffect)(() => {
1078
+ const tooltip = tooltipRef.current;
1079
+ if (!tooltip || typeof tooltip.showPopover !== "function") return;
1080
+ if (open) tooltip.showPopover();
1081
+ else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
1082
+ }, [open]);
1055
1083
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1056
- className: (0, clsx.default)("clarify-tooltip group relative inline-flex align-baseline", className),
1084
+ className: (0, clsx.default)("clarify-tooltip group inline-flex align-baseline", className),
1057
1085
  onMouseEnter: () => setOpen(true),
1058
1086
  onMouseLeave: () => setOpen(false),
1059
1087
  ...props,
1060
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1061
- tabIndex: 0,
1088
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1089
+ type: "button",
1090
+ ref: triggerRef,
1062
1091
  "aria-describedby": contentId,
1063
- className: "cursor-help rounded-sm border-b border-dotted border-current focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
1092
+ "aria-expanded": open,
1093
+ className: (0, clsx.default)("cursor-help appearance-none rounded-sm border-0 border-b border-dotted border-current bg-transparent p-0 font-inherit text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", triggerClassName),
1064
1094
  onFocus: () => setOpen(true),
1065
1095
  onBlur: () => setOpen(false),
1096
+ onClick: () => setOpen(true),
1066
1097
  onKeyDown: (event) => {
1067
1098
  if (event.key === "Escape") setOpen(false);
1068
1099
  },
1069
1100
  children
1070
1101
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1102
+ ref: tooltipRef,
1071
1103
  id: contentId,
1072
1104
  role: "tooltip",
1073
- className: (0, clsx.default)("pointer-events-none absolute left-1/2 z-30 w-max max-w-64 -translate-x-1/2 rounded-md bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", open ? "opacity-100" : "opacity-0", side === "top" ? "bottom-[calc(100%+0.5rem)]" : "top-[calc(100%+0.5rem)]"),
1105
+ popover: "manual",
1106
+ style: position,
1107
+ className: (0, clsx.default)("pointer-events-none fixed right-auto bottom-auto z-60 m-0 w-max max-w-64 -translate-x-1/2 rounded-md border-0 bg-(--clarify-theme-tokens-colors-foreground) px-2.5 py-1.5 text-center text-xs/5 font-normal text-(--clarify-theme-tokens-colors-background) shadow-lg transition duration-150", side === "top" && "-translate-y-full", open && position ? "visible opacity-100" : "invisible opacity-0"),
1074
1108
  children: content
1075
1109
  })]
1076
1110
  });
@@ -1413,6 +1447,31 @@ function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
1413
1447
  seen.add(schema.$ref);
1414
1448
  return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
1415
1449
  }
1450
+ function mergeAllOfSchemas(spec, schemas) {
1451
+ const merged = {};
1452
+ const properties = {};
1453
+ const required = /* @__PURE__ */ new Set();
1454
+ for (const schema of schemas) {
1455
+ const resolved = resolveRequestSchema(spec, schema);
1456
+ if (!isRecord$1(resolved)) continue;
1457
+ Object.assign(merged, resolved);
1458
+ if (isRecord$1(resolved.properties)) Object.assign(properties, resolved.properties);
1459
+ if (Array.isArray(resolved.required)) resolved.required.forEach((name) => required.add(String(name)));
1460
+ }
1461
+ if (Object.keys(properties).length > 0) merged.properties = properties;
1462
+ if (required.size > 0) merged.required = [...required];
1463
+ delete merged.allOf;
1464
+ return merged;
1465
+ }
1466
+ function resolveRequestSchema(spec, schema) {
1467
+ const resolved = resolveSchema(spec, schema);
1468
+ if (!isRecord$1(resolved)) return resolved;
1469
+ const ownSchema = { ...resolved };
1470
+ const allOf = Array.isArray(ownSchema.allOf) ? ownSchema.allOf : [];
1471
+ if (allOf.length === 0) return ownSchema;
1472
+ delete ownSchema.allOf;
1473
+ return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
1474
+ }
1416
1475
  function getPathItem$1(spec, path) {
1417
1476
  return resolveObjectRef(spec, spec.paths?.[path]);
1418
1477
  }
@@ -1432,6 +1491,7 @@ function resolveObjectRef(spec, value) {
1432
1491
  }
1433
1492
  function schemaHasType(schema, type) {
1434
1493
  if (!isRecord$1(schema)) return false;
1494
+ if (type === "null" && schema.nullable === true) return true;
1435
1495
  return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
1436
1496
  }
1437
1497
  function getOperationParameters(spec, path, operation, source = "path") {
@@ -1501,7 +1561,7 @@ function getExampleEntries(mediaType, spec) {
1501
1561
  title: "Example",
1502
1562
  value: mediaType.example
1503
1563
  }];
1504
- const generated = schemaToExample(spec ? resolveSchema(spec, mediaType.schema) : mediaType.schema);
1564
+ const generated = schemaToExample(spec ? resolveRequestSchema(spec, mediaType.schema) : mediaType.schema);
1505
1565
  return typeof generated === "undefined" ? [] : [{
1506
1566
  key: "schema",
1507
1567
  title: "schema",
@@ -1509,6 +1569,34 @@ function getExampleEntries(mediaType, spec) {
1509
1569
  generated: true
1510
1570
  }];
1511
1571
  }
1572
+ function getParameterExampleEntries(parameter) {
1573
+ if (isRecord$1(parameter.examples)) {
1574
+ const examples = [];
1575
+ for (const [key, example] of Object.entries(parameter.examples)) {
1576
+ const value = getExampleValue(example);
1577
+ if (typeof value === "undefined") continue;
1578
+ const { title, summary } = getExampleTitle(key, example);
1579
+ examples.push({
1580
+ key,
1581
+ title,
1582
+ summary,
1583
+ value
1584
+ });
1585
+ }
1586
+ if (examples.length > 0) return examples;
1587
+ }
1588
+ return typeof parameter.example === "undefined" ? [] : [{
1589
+ key: "default",
1590
+ title: "Example",
1591
+ value: parameter.example
1592
+ }];
1593
+ }
1594
+ function getRequestExampleEntries(parameters, mediaType) {
1595
+ const entries = /* @__PURE__ */ new Map();
1596
+ for (const example of getExampleEntries(mediaType).filter((entry) => !entry.generated)) entries.set(example.key, example);
1597
+ for (const parameter of parameters) for (const example of getParameterExampleEntries(parameter)) if (!entries.has(example.key)) entries.set(example.key, example);
1598
+ return [...entries.values()];
1599
+ }
1512
1600
  function getContentExample(mediaType) {
1513
1601
  return getExampleEntries(mediaType)[0]?.value;
1514
1602
  }
@@ -1522,7 +1610,8 @@ function schemaToType(schema) {
1522
1610
  if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
1523
1611
  if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
1524
1612
  const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
1525
- return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
1613
+ const nullableType = schema.nullable === true && type !== "null" ? [type, "null"].filter(Boolean).join(" | ") : type;
1614
+ return typeof nullableType === "string" ? [nullableType, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
1526
1615
  }
1527
1616
  function schemaToExample(schema, depth = 0) {
1528
1617
  if (!isRecord$1(schema) || depth > 3) return void 0;
@@ -1530,10 +1619,12 @@ function schemaToExample(schema, depth = 0) {
1530
1619
  if (typeof schema.default !== "undefined") return schema.default;
1531
1620
  if (Array.isArray(schema.enum)) return schema.enum[0];
1532
1621
  if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
1622
+ const variant = Array.isArray(schema.oneOf) ? schema.oneOf[0] : Array.isArray(schema.anyOf) ? schema.anyOf[0] : void 0;
1623
+ if (typeof variant !== "undefined") return schemaToExample(variant, depth + 1);
1533
1624
  if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
1534
1625
  if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
1535
1626
  const properties = isRecord$1(schema.properties) ? schema.properties : {};
1536
- return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
1627
+ return Object.fromEntries(Object.entries(properties).filter(([, propertySchema]) => !isRecord$1(propertySchema) || propertySchema.readOnly !== true).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
1537
1628
  }
1538
1629
  return exampleForType(schemaToType(schema));
1539
1630
  }
@@ -1649,6 +1740,23 @@ function listOpenApiOperations(spec) {
1649
1740
  return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
1650
1741
  }
1651
1742
  //#endregion
1743
+ //#region source/openapi/components/EndpointMethodBadge.tsx
1744
+ var endpointMethodStyleVars = {
1745
+ GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
1746
+ POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
1747
+ PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
1748
+ PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
1749
+ DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
1750
+ WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
1751
+ };
1752
+ function EndpointMethodBadge(arg0) {
1753
+ const { method } = arg0;
1754
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1755
+ className: (0, clsx.default)("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
1756
+ children: method
1757
+ });
1758
+ }
1759
+ //#endregion
1652
1760
  //#region source/components/HighlightedCode.tsx
1653
1761
  var cssVariablesTheme = (0, shiki.createCssVariablesTheme)();
1654
1762
  function HighlightedCode(arg0) {
@@ -1706,6 +1814,15 @@ var snippetControlCharacters = [
1706
1814
  }
1707
1815
  ];
1708
1816
  var snippetGenerator = (0, _scalar_snippetz.snippetz)();
1817
+ function getAuthPlaceholder(name) {
1818
+ return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
1819
+ }
1820
+ function redactAuth(auth = []) {
1821
+ return auth.map((input) => ({
1822
+ ...input,
1823
+ value: getAuthPlaceholder(input.name)
1824
+ }));
1825
+ }
1709
1826
  function protectSnippetControlCharacters(value) {
1710
1827
  if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
1711
1828
  if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
@@ -1724,7 +1841,7 @@ function getDefaultServer(spec) {
1724
1841
  function getDefaultWebhookServer() {
1725
1842
  return { url: "https://webhook.example.com" };
1726
1843
  }
1727
- function expandServerUrl(server, serverVariables = {}) {
1844
+ function expandServerUrl$1(server, serverVariables = {}) {
1728
1845
  return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
1729
1846
  const fallback = server.variables?.[name]?.default ?? name;
1730
1847
  return serverVariables[name] ?? fallback;
@@ -1732,23 +1849,23 @@ function expandServerUrl(server, serverVariables = {}) {
1732
1849
  }
1733
1850
  function buildOperationUrl(input) {
1734
1851
  const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
1735
- return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
1852
+ return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
1736
1853
  }
1737
- function getQueryString(parameters, auth) {
1854
+ function getQueryString(parameters, auth = []) {
1738
1855
  const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
1739
1856
  name: parameter.name,
1740
1857
  value: encodeUrlPlaceholders(`{${parameter.name}}`)
1741
1858
  }));
1742
- if (auth?.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) queryString.push({
1743
- name: auth.scheme.name,
1744
- value: auth.value
1859
+ for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
1860
+ name: input.scheme.name,
1861
+ value: input.value
1745
1862
  });
1746
1863
  return queryString;
1747
1864
  }
1748
- function isFormMediaType(mediaType) {
1865
+ function isFormMediaType$1(mediaType) {
1749
1866
  return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
1750
1867
  }
1751
- function isBinarySchema(schema) {
1868
+ function isBinarySchema$1(schema) {
1752
1869
  return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
1753
1870
  }
1754
1871
  function getSchemaProperties(schema) {
@@ -1756,7 +1873,7 @@ function getSchemaProperties(schema) {
1756
1873
  }
1757
1874
  function getFieldValue(name, value, schema) {
1758
1875
  if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
1759
- if (isBinarySchema(schema)) return `@${name}`;
1876
+ if (isBinarySchema$1(schema)) return `@${name}`;
1760
1877
  }
1761
1878
  function getFormParams(value, requestContent) {
1762
1879
  const properties = getSchemaProperties(requestContent.value.schema);
@@ -1778,7 +1895,7 @@ function getBodySize(requestBody) {
1778
1895
  function getRequestBody(requestContent) {
1779
1896
  const value = getContentExample(requestContent?.value);
1780
1897
  if (!requestContent || typeof value === "undefined") return void 0;
1781
- if (isFormMediaType(requestContent.mediaType)) {
1898
+ if (isFormMediaType$1(requestContent.mediaType)) {
1782
1899
  const params = getFormParams(value, requestContent);
1783
1900
  return params.length > 0 ? { params } : void 0;
1784
1901
  }
@@ -1789,15 +1906,14 @@ function getAuthorizationValue(auth) {
1789
1906
  if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
1790
1907
  if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
1791
1908
  }
1792
- function getAuthHeaders(auth) {
1793
- if (!auth) return {};
1909
+ function getAuthHeader(auth) {
1794
1910
  if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
1795
1911
  const authorization = getAuthorizationValue(auth);
1796
1912
  return authorization ? { Authorization: authorization } : {};
1797
1913
  }
1798
- function getRequestHeaders(requestContent, auth) {
1914
+ function getRequestHeaders(requestContent, auth = []) {
1799
1915
  return {
1800
- ...getAuthHeaders(auth),
1916
+ ...Object.assign({}, ...auth.map(getAuthHeader)),
1801
1917
  Accept: "application/json",
1802
1918
  ...requestContent ? { "Content-Type": requestContent.mediaType } : {}
1803
1919
  };
@@ -2115,6 +2231,10 @@ var requestSnippetOptions = [
2115
2231
  }
2116
2232
  ];
2117
2233
  function buildRequestCodeExamples(input) {
2234
+ const redactedInput = {
2235
+ ...input,
2236
+ auth: redactAuth(input.auth)
2237
+ };
2118
2238
  return requestSnippetOptions.map((option) => ({
2119
2239
  key: `${option.languageKey}:${option.client}`,
2120
2240
  title: option.title,
@@ -2122,7 +2242,7 @@ function buildRequestCodeExamples(input) {
2122
2242
  languageKey: option.languageKey,
2123
2243
  clientKey: option.client,
2124
2244
  clientTitle: option.clientTitle,
2125
- code: buildSnippet(input, option)
2245
+ code: buildSnippet(redactedInput, option)
2126
2246
  }));
2127
2247
  }
2128
2248
  //#endregion
@@ -2144,7 +2264,7 @@ function SelectControl(arg0) {
2144
2264
  className: wrapperClassName,
2145
2265
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
2146
2266
  "aria-label": label,
2147
- className: `clarify-openai-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)`,
2267
+ className: `clarify-openai-select-button flex min-h-8 ${buttonSizeClassName} items-center justify-between gap-2 rounded-(--clarify-theme-tokens-radius-md) 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-(--clarify-code-border) hover:bg-(--clarify-code-control-background-hover) focus:ring-2 focus:ring-(--clarify-ui-accent-border) data-open:border-(--clarify-code-border) data-open:bg-(--clarify-code-control-background-active) data-open:ring-2 data-open:ring-(--clarify-ui-accent-border)`,
2148
2268
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2149
2269
  className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
2150
2270
  children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -2160,10 +2280,10 @@ function SelectControl(arg0) {
2160
2280
  })]
2161
2281
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
2162
2282
  anchor: "bottom end",
2163
- className: "clarify-openai-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",
2283
+ className: "clarify-openai-select-options z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) 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",
2164
2284
  children: normalizedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
2165
2285
  value: option.value,
2166
- className: "clarify-openai-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)",
2286
+ className: "clarify-openai-select-option group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) 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)",
2167
2287
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
2168
2288
  className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
2169
2289
  "aria-hidden": "true"
@@ -2277,12 +2397,17 @@ function getSecurityRequirements(spec, operation) {
2277
2397
  }
2278
2398
  function getAuthOptions(spec, operation) {
2279
2399
  const schemes = getSecuritySchemes(spec);
2280
- const requirements = getSecurityRequirements(spec, operation);
2281
- const names = new Set(requirements.flatMap((requirement) => Object.keys(requirement)));
2282
- return Array.from(names).map((name) => ({
2283
- name,
2284
- scheme: schemes[name]
2285
- })).filter((option) => Boolean(option.scheme));
2400
+ return getSecurityRequirements(spec, operation).map((requirement, index) => {
2401
+ const requirementSchemes = Object.keys(requirement).map((name) => ({
2402
+ name,
2403
+ scheme: schemes[name]
2404
+ })).filter((option) => Boolean(option.scheme));
2405
+ return {
2406
+ key: `requirement:${index}`,
2407
+ label: requirementSchemes.map((option) => option.name).join(" + "),
2408
+ schemes: requirementSchemes
2409
+ };
2410
+ });
2286
2411
  }
2287
2412
  function authPlaceholder(auth) {
2288
2413
  if (!auth) return "";
@@ -2315,7 +2440,7 @@ function getClientOptions(codeOptions, languageKey) {
2315
2440
  function ApiExampleCodeGroup(arg0) {
2316
2441
  const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, metaInToolbar = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
2317
2442
  const t = require_i18n.useBuiltInText();
2318
- const metaClassName = comfortableMeta ? "flex min-h-11 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4 py-2" : "flex h-9 min-w-0 items-center gap-2 border-y border-(--clarify-code-border) border-t-transparent bg-(--clarify-code-background) px-4";
2443
+ const metaClassName = comfortableMeta ? "flex min-h-10 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5 py-2" : "flex h-9 min-w-0 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-background) px-3.5";
2319
2444
  const meta = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2320
2445
  tag ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
2321
2446
  label: t("openapi.status"),
@@ -2334,14 +2459,14 @@ function ApiExampleCodeGroup(arg0) {
2334
2459
  }) : null
2335
2460
  ] });
2336
2461
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2337
- className: "clarify-openai-example my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)",
2462
+ className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
2338
2463
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2339
2464
  className: "not-prose",
2340
2465
  children: [
2341
2466
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2342
- className: "clarify-openai-example-header flex min-h-(--clarify-code-header-min-height) items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-4 py-2",
2467
+ className: "clarify-openai-example-header flex min-h-11 items-center gap-3 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-3.5 py-1.5",
2343
2468
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2344
- className: "mr-auto min-w-16 truncate py-1 text-xs font-semibold text-(--clarify-code-text)",
2469
+ className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
2345
2470
  children: title
2346
2471
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2347
2472
  className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
@@ -2778,11 +2903,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
2778
2903
  };
2779
2904
  }
2780
2905
  function EnumValueNode(arg0) {
2781
- const { node, depth = 0 } = arg0;
2906
+ const { node } = arg0;
2782
2907
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
2783
- className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2908
+ className: "clarify-schema-node m-0 p-0",
2784
2909
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2785
- className: (0, clsx.default)("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1"),
2910
+ className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
2786
2911
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2787
2912
  className: "min-w-0 flex-1",
2788
2913
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
@@ -2816,7 +2941,7 @@ function SchemaNode(arg0) {
2816
2941
  });
2817
2942
  const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
2818
2943
  const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
2819
- const rowClassName = (0, clsx.default)("flex min-w-0 items-start rounded py-0.5 text-left", depth > 0 ? "-mx-2 w-(--clarify-schema-row-nested-width) px-2" : "w-full px-1");
2944
+ const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
2820
2945
  const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2821
2946
  className: "min-w-0 flex-1",
2822
2947
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2844,7 +2969,7 @@ function SchemaNode(arg0) {
2844
2969
  children: expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "h-4 w-4" })
2845
2970
  }) : null] });
2846
2971
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2847
- className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2972
+ className: "clarify-schema-node m-0 p-0",
2848
2973
  children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2849
2974
  type: "button",
2850
2975
  "aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
@@ -2866,7 +2991,7 @@ function SchemaTree(arg0) {
2866
2991
  if (nodes.length === 0) return null;
2867
2992
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2868
2993
  role: "list",
2869
- className: (0, clsx.default)("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border) p-0", depth > 0 && "mt-2 rounded-lg bg-(--clarify-ui-subtle-background) px-2 py-1"),
2994
+ className: (0, clsx.default)("m-0 list-none p-0", depth === 0 ? "divide-y divide-(--clarify-theme-tokens-colors-border)" : "ml-2 border-l border-(--clarify-theme-tokens-colors-border) pl-2"),
2870
2995
  children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
2871
2996
  node,
2872
2997
  depth,
@@ -2879,7 +3004,7 @@ function SchemaProperties(arg0) {
2879
3004
  const root = getRootSchemaNode(spec, schema, defaultExpanded);
2880
3005
  if (!root || root.children.length === 0) return null;
2881
3006
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2882
- className: "clarify-schema-properties my-6",
3007
+ className: "clarify-schema-properties not-prose my-6",
2883
3008
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, { nodes: root.children })
2884
3009
  })] });
2885
3010
  }
@@ -2964,7 +3089,8 @@ function ResponseList(arg0) {
2964
3089
  response
2965
3090
  })
2966
3091
  })),
2967
- panelsClassName: "mt-4"
3092
+ className: "mt-4 mb-6",
3093
+ panelsClassName: "mt-5"
2968
3094
  })] });
2969
3095
  }
2970
3096
  //#endregion
@@ -2989,7 +3115,7 @@ function EndpointRequest(arg0) {
2989
3115
  })] });
2990
3116
  };
2991
3117
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderDescription(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2992
- className: "relative mt-6",
3118
+ className: "clarify-openapi-request-workspace relative mt-8 pt-6",
2993
3119
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2994
3120
  className: "w-full",
2995
3121
  children: [
@@ -3036,9 +3162,9 @@ function EndpointResponse(arg0) {
3036
3162
  const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
3037
3163
  const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
3038
3164
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3039
- className: "mt-6",
3165
+ className: "mt-10 pt-6",
3040
3166
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
3041
- className: "relative",
3167
+ className: "clarify-openapi-response-workspace relative",
3042
3168
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3043
3169
  className: "w-full",
3044
3170
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
@@ -3068,49 +3194,129 @@ function EndpointResponse(arg0) {
3068
3194
  }
3069
3195
  //#endregion
3070
3196
  //#region source/openapi/components/InlineListbox.tsx
3197
+ var defaultButtonClassName = "inline-flex min-w-0 items-center justify-between gap-1 border-0 bg-transparent font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary) data-disabled:cursor-not-allowed data-open:bg-(--clarify-ui-active-background)";
3198
+ var optionsClassName = "z-30 mt-1 max-h-64 w-max min-w-(--button-width) max-w-(--clarify-popover-max-width) overflow-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 text-xs shadow-lg shadow-black/10 [--anchor-gap:--spacing(1)] focus:outline-none";
3199
+ var optionClassName = "group flex min-h-9 cursor-default items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-md) 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)";
3200
+ function OptionContent(arg0) {
3201
+ const { option } = arg0;
3202
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3203
+ className: "min-w-0",
3204
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3205
+ className: "block truncate",
3206
+ children: option.label
3207
+ }), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3208
+ className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
3209
+ children: option.description
3210
+ }) : null]
3211
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3212
+ className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
3213
+ "aria-hidden": "true"
3214
+ })] });
3215
+ }
3071
3216
  function InlineListbox(arg0) {
3072
- const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className } = arg0;
3073
- const selected = options.find((option) => option.value === value) ?? options[0];
3217
+ const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false, title } = arg0;
3218
+ const selected = options.find((option) => option.value === value);
3074
3219
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
3075
- value: selected?.value ?? value,
3220
+ value,
3076
3221
  onChange,
3222
+ disabled,
3077
3223
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3078
- className: (0, clsx.default)("pointer-events-auto relative inline-flex min-w-0", className),
3224
+ className: (0, clsx.default)("pointer-events-auto relative inline-flex min-w-0 w-full", className),
3079
3225
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxButton, {
3080
3226
  "aria-label": label,
3081
- className: (0, clsx.default)(buttonClassName ?? "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)", buttonClassName ? null : 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"),
3227
+ "aria-invalid": invalid || void 0,
3228
+ "aria-describedby": describedBy,
3229
+ title,
3230
+ className: (0, clsx.default)(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
3082
3231
  children: buttonContent ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3083
3232
  className: "truncate",
3084
- children: selected?.label ?? value
3233
+ children: selected?.label ?? (value || label)
3085
3234
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3086
3235
  className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
3087
3236
  "aria-hidden": "true"
3088
3237
  })] })
3089
3238
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
3090
3239
  anchor: "bottom start",
3091
- 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",
3092
- children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
3240
+ className: optionsClassName,
3241
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
3093
3242
  value: option.value,
3094
- 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)",
3095
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3096
- className: "min-w-0",
3097
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3098
- className: "block truncate",
3099
- children: option.label
3100
- }), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3101
- className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
3102
- children: option.description
3103
- }) : null]
3104
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3105
- className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
3106
- "aria-hidden": "true"
3107
- })]
3243
+ className: optionClassName,
3244
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
3245
+ }, option.value))
3246
+ })]
3247
+ })
3248
+ });
3249
+ }
3250
+ function MultiInlineListbox(arg0) {
3251
+ const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
3252
+ const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
3253
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
3254
+ value,
3255
+ onChange,
3256
+ multiple: true,
3257
+ disabled,
3258
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3259
+ className: "pointer-events-auto relative inline-flex min-w-0 w-full",
3260
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
3261
+ "aria-label": label,
3262
+ "aria-invalid": invalid || void 0,
3263
+ "aria-describedby": describedBy,
3264
+ className: (0, clsx.default)(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
3265
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3266
+ className: "truncate",
3267
+ children: selectedLabel || label
3268
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3269
+ className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
3270
+ "aria-hidden": "true"
3271
+ })]
3272
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
3273
+ anchor: "bottom start",
3274
+ className: optionsClassName,
3275
+ children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
3276
+ value: option.value,
3277
+ className: optionClassName,
3278
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
3108
3279
  }, option.value))
3109
3280
  })]
3110
3281
  })
3111
3282
  });
3112
3283
  }
3113
3284
  //#endregion
3285
+ //#region source/openapi/store.ts
3286
+ var credentialScopes = /* @__PURE__ */ new WeakMap();
3287
+ var emptyOpenApiCredentials = Object.freeze({});
3288
+ var nextCredentialScope = 0;
3289
+ function getOpenApiCredentialScope(spec) {
3290
+ const current = credentialScopes.get(spec);
3291
+ if (current) return current;
3292
+ const scope = `openapi-${nextCredentialScope += 1}`;
3293
+ credentialScopes.set(spec, scope);
3294
+ return scope;
3295
+ }
3296
+ var useOpenApiStore = (0, zustand.create)()((set) => ({
3297
+ credentials: {},
3298
+ setCredential: (scope, name, value) => set((state) => ({ credentials: {
3299
+ ...state.credentials,
3300
+ [scope]: {
3301
+ ...state.credentials[scope],
3302
+ [name]: value
3303
+ }
3304
+ } })),
3305
+ clearCredential: (scope, name) => set((state) => {
3306
+ const scoped = { ...state.credentials[scope] };
3307
+ delete scoped[name];
3308
+ return { credentials: {
3309
+ ...state.credentials,
3310
+ [scope]: scoped
3311
+ } };
3312
+ }),
3313
+ clearCredentials: (scope) => set((state) => {
3314
+ const credentials = { ...state.credentials };
3315
+ delete credentials[scope];
3316
+ return { credentials };
3317
+ })
3318
+ }));
3319
+ //#endregion
3114
3320
  //#region source/openapi/components/OpenApiOperation.state.ts
3115
3321
  function useOperationRequestState(spec, path, operation, source = "path") {
3116
3322
  const parameters = getOperationParameters(spec, path, operation, source);
@@ -3161,9 +3367,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
3161
3367
  }
3162
3368
  function useOperationAuthState(spec, operation) {
3163
3369
  const authOptions = getAuthOptions(spec, operation);
3164
- const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.name ?? "");
3165
- const selectedAuth = authOptions.find((option) => option.name === selectedAuthName);
3166
- const [authValues, setAuthValues] = (0, react.useState)({});
3370
+ const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
3371
+ const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
3372
+ const credentialScope = getOpenApiCredentialScope(spec);
3373
+ const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
3374
+ const setCredential = useOpenApiStore((state) => state.setCredential);
3375
+ const clearCredential = useOpenApiStore((state) => state.clearCredential);
3376
+ const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
3167
3377
  const [authOpen, setAuthOpen] = (0, react.useState)(false);
3168
3378
  return {
3169
3379
  authOptions,
@@ -3171,119 +3381,1647 @@ function useOperationAuthState(spec, operation) {
3171
3381
  selectedAuth,
3172
3382
  authValues,
3173
3383
  authOpen,
3174
- authInput: selectedAuth ? {
3175
- name: selectedAuth.name,
3176
- scheme: selectedAuth.scheme,
3177
- value: authValues[selectedAuth.name] ?? authPlaceholder(selectedAuth)
3178
- } : void 0,
3384
+ authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
3385
+ name: option.name,
3386
+ scheme: option.scheme,
3387
+ value: authValues[option.name] ?? ""
3388
+ })) : void 0,
3179
3389
  onSelectAuth: setSelectedAuthName,
3180
- onChangeAuthValue: (name, value) => setAuthValues((current) => ({
3181
- ...current,
3182
- [name]: value
3183
- })),
3390
+ onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
3391
+ onClearAuthValue: (name) => clearCredential(credentialScope, name),
3392
+ onClearAuthValues: () => clearCredentials(credentialScope),
3184
3393
  onToggleAuth: () => setAuthOpen((current) => !current),
3185
3394
  closeAuth: () => setAuthOpen(false)
3186
3395
  };
3187
3396
  }
3188
3397
  //#endregion
3189
- //#region source/openapi/components/OpenApiOperation.tsx
3190
- var endpointMethodStyleVars = {
3191
- GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
3192
- POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
3193
- PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
3194
- PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
3195
- DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
3196
- WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
3197
- };
3198
- function EndpointMethodBadge(arg0) {
3199
- const { method } = arg0;
3200
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3201
- className: (0, clsx.default)("rounded-(--clarify-theme-tokens-radius-md) px-2.5 py-0.5 text-xs/6 font-black tracking-wide", endpointMethodStyleVars[method] ?? "bg-(--clarify-http-method-default-background) text-(--clarify-http-method-default-text)"),
3202
- children: method
3203
- });
3398
+ //#region source/openapi/lib/api-request.ts
3399
+ function parseBodyObject(body) {
3400
+ try {
3401
+ const parsed = JSON.parse(body);
3402
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
3403
+ } catch {
3404
+ return;
3405
+ }
3204
3406
  }
3205
- function EndpointPath(arg0) {
3206
- const { path, copied = false, onCopy } = arg0;
3407
+ function buildRequestBody(body, mediaType, files) {
3408
+ if (files[""] && !mediaType.includes("multipart/form-data")) return files[""];
3409
+ const values = parseBodyObject(body);
3410
+ if (mediaType.includes("application/x-www-form-urlencoded") && values) {
3411
+ const params = new URLSearchParams();
3412
+ Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
3413
+ return params;
3414
+ }
3415
+ if (mediaType.includes("multipart/form-data") && values) {
3416
+ const form = new FormData();
3417
+ Object.entries(values).forEach(([name, value]) => {
3418
+ const file = files[name];
3419
+ form.append(name, file ?? (typeof value === "string" ? value : JSON.stringify(value)));
3420
+ });
3421
+ Object.entries(files).forEach(([name, file]) => {
3422
+ if (name && !(name in values)) form.append(name, file);
3423
+ });
3424
+ return form;
3425
+ }
3426
+ if (mediaType.includes("multipart/form-data") && Object.keys(files).length > 0) {
3427
+ const form = new FormData();
3428
+ Object.entries(files).forEach(([name, file]) => form.append(name, file));
3429
+ return form;
3430
+ }
3431
+ return body;
3432
+ }
3433
+ function expandServerUrl(server, variables) {
3434
+ return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
3435
+ }
3436
+ function authorizationValue(auth) {
3437
+ const scheme = auth.scheme.scheme?.toLowerCase();
3438
+ if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
3439
+ if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
3440
+ if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
3441
+ }
3442
+ function parameterKey(parameter) {
3443
+ return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
3444
+ }
3445
+ function parseParameterValue(value) {
3446
+ const trimmed = value.trim();
3447
+ if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
3448
+ try {
3449
+ return JSON.parse(trimmed);
3450
+ } catch {
3451
+ return value;
3452
+ }
3453
+ }
3454
+ function primitiveValue(value) {
3455
+ if (typeof value === "string") return value;
3456
+ if (value === null || typeof value === "undefined") return "";
3457
+ return String(value);
3458
+ }
3459
+ function serializedParameterValues(parameter, rawValue) {
3460
+ const value = parseParameterValue(rawValue);
3461
+ const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
3462
+ const explode = parameter.explode ?? style === "form";
3463
+ if (Array.isArray(value)) {
3464
+ if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
3465
+ const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
3466
+ return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
3467
+ }
3468
+ if (typeof value === "object" && value !== null) {
3469
+ const entries = Object.entries(value);
3470
+ if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
3471
+ if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
3472
+ return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
3473
+ }
3474
+ return [[parameter.name ?? "", primitiveValue(value)]];
3475
+ }
3476
+ function pathParameterValue(parameter, rawValue) {
3477
+ const value = parseParameterValue(rawValue);
3478
+ const style = parameter.style ?? "simple";
3479
+ const explode = parameter.explode ?? false;
3480
+ const encode = (item) => encodeURIComponent(primitiveValue(item));
3481
+ if (Array.isArray(value)) {
3482
+ if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
3483
+ if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
3484
+ return value.map(encode).join(",");
3485
+ }
3486
+ if (typeof value === "object" && value !== null) {
3487
+ const entries = Object.entries(value);
3488
+ if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
3489
+ if (style === "matrix") return explode ? entries.map(([key, item]) => `;${encode(key)}=${encode(item)}`).join("") : `;${parameter.name}=${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
3490
+ return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
3491
+ }
3492
+ const encoded = encode(value);
3493
+ if (style === "label") return `.${encoded}`;
3494
+ if (style === "matrix") return `;${parameter.name}=${encoded}`;
3495
+ return encoded;
3496
+ }
3497
+ function headerParameterValue(parameter, rawValue) {
3498
+ const value = parseParameterValue(rawValue);
3499
+ if (Array.isArray(value)) return value.map(primitiveValue).join(",");
3500
+ if (typeof value === "object" && value !== null) {
3501
+ const entries = Object.entries(value);
3502
+ return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
3503
+ }
3504
+ return primitiveValue(value);
3505
+ }
3506
+ function buildApiRequest(input) {
3507
+ const headers = new Headers({ Accept: "application/json" });
3508
+ const query = new URLSearchParams();
3509
+ let path = input.path;
3510
+ for (const parameter of input.parameters) {
3511
+ if (!parameter.name) continue;
3512
+ const key = parameterKey(parameter);
3513
+ if (input.parameterEnabled?.[key] === false) continue;
3514
+ const value = input.parameterValues[key] ?? "";
3515
+ if (!value && !parameter.allowEmptyValue) continue;
3516
+ if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
3517
+ if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
3518
+ if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
3519
+ }
3520
+ for (const auth of input.auth ?? []) {
3521
+ if (!auth.value) continue;
3522
+ if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
3523
+ else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
3524
+ else {
3525
+ const authorization = authorizationValue(auth);
3526
+ if (authorization) headers.set("Authorization", authorization);
3527
+ }
3528
+ }
3529
+ const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
3530
+ query.forEach((value, key) => url.searchParams.append(key, value));
3531
+ const body = input.body?.trim() ?? "";
3532
+ const mediaType = input.mediaType || "application/json";
3533
+ const requestBody = (Boolean(body) || Object.keys(input.bodyFiles ?? {}).length > 0) && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType, input.bodyFiles ?? {}) : void 0;
3534
+ if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
3535
+ return {
3536
+ url: url.toString(),
3537
+ init: {
3538
+ method: input.method.toUpperCase(),
3539
+ headers,
3540
+ credentials: "include",
3541
+ ...requestBody ? { body: requestBody } : {}
3542
+ }
3543
+ };
3544
+ }
3545
+ //#endregion
3546
+ //#region source/openapi/components/OpenApiAuthPanel.tsx
3547
+ function OpenApiAuthPanel(arg0) {
3548
+ const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
3207
3549
  const t = require_i18n.useBuiltInText();
3550
+ if (authOptions.length === 0) return null;
3208
3551
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3209
- className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
3210
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3211
- className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
3212
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3213
- className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
3214
- children: path || "/"
3215
- })
3216
- }), onCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3217
- type: "button",
3218
- "aria-label": copied ? t("actions.copied") : t("actions.copy"),
3219
- title: copied ? t("actions.copied") : t("actions.copy"),
3220
- onClick: onCopy,
3221
- className: (0, clsx.default)("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"),
3222
- children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
3223
- className: "h-3.5 w-3.5",
3224
- "aria-hidden": "true"
3225
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
3226
- className: "h-3.5 w-3.5",
3227
- "aria-hidden": "true"
3228
- })
3229
- }) : null]
3552
+ className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
3553
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3554
+ className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
3555
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3556
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
3557
+ children: "Auth"
3558
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3559
+ label: "Auth",
3560
+ value: selectedAuthName,
3561
+ options: authOptions.map((option) => ({
3562
+ value: option.key,
3563
+ label: option.label || t("openapi.none")
3564
+ })),
3565
+ onChange: onSelectAuth
3566
+ })]
3567
+ }), selectedAuth?.schemes.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3568
+ className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
3569
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3570
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
3571
+ children: authLabel(option.name, option.scheme)
3572
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3573
+ className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
3574
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3575
+ type: "password",
3576
+ value: authValues[option.name] ?? "",
3577
+ placeholder: authPlaceholder(option),
3578
+ onChange: (event) => onChangeAuthValue(option.name, event.target.value),
3579
+ autoComplete: "off",
3580
+ className: "h-8 min-w-0 flex-1 border-0 bg-transparent px-2 text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden placeholder:text-(--clarify-ui-text-faint)"
3581
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3582
+ type: "button",
3583
+ onClick: () => onClearAuthValue(option.name),
3584
+ className: "mr-1 h-6 shrink-0 rounded-(--clarify-theme-tokens-radius-md) px-1 text-2xs font-medium text-(--clarify-ui-text-faint) opacity-0 transition-opacity hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) group-hover:opacity-100",
3585
+ children: t("openapi.clear")
3586
+ })]
3587
+ })]
3588
+ }, option.name))]
3230
3589
  });
3231
3590
  }
3232
- function getServerPreviewUrl(server, variables) {
3233
- return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
3591
+ //#endregion
3592
+ //#region source/openapi/components/OpenApiRequestBodyEditor.tsx
3593
+ function parseBodyRecord(body) {
3594
+ try {
3595
+ const value = JSON.parse(body);
3596
+ return isRecord$1(value) ? value : {};
3597
+ } catch {
3598
+ return {};
3599
+ }
3234
3600
  }
3235
- function getFullEndpointUrl(server, variables, path) {
3236
- return joinPath(getServerPreviewUrl(server, variables), path);
3601
+ function isBinarySchema(schema) {
3602
+ return isRecord$1(schema) && schema.format === "binary";
3237
3603
  }
3238
- function getServerProtocolLabel(server, variables) {
3239
- const url = getServerPreviewUrl(server, variables);
3240
- const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
3241
- return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
3604
+ function isTextMediaType(mediaType) {
3605
+ return mediaType.startsWith("text/") || mediaType.includes("json") || mediaType.includes("xml") || mediaType.includes("yaml") || mediaType.includes("javascript") || mediaType.includes("form");
3242
3606
  }
3243
- function getDefaultResponseStatus(operation, spec) {
3244
- const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
3245
- if (left.status === "default") return -1;
3246
- if (right.status === "default") return 1;
3247
- const leftCode = Number(left.status);
3248
- const rightCode = Number(right.status);
3249
- if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
3250
- return left.status.localeCompare(right.status);
3607
+ function isFormMediaType(mediaType) {
3608
+ const normalized = mediaType.split(";", 1)[0].trim().toLowerCase();
3609
+ return normalized === "application/x-www-form-urlencoded" || normalized === "multipart/form-data";
3610
+ }
3611
+ function valueFromInput(schema, value) {
3612
+ if (!isRecord$1(schema)) return value;
3613
+ if (schemaHasType(schema, "integer")) return value === "" ? "" : Number.parseInt(value, 10);
3614
+ if (schemaHasType(schema, "number")) return value === "" ? "" : Number(value);
3615
+ if (schemaHasType(schema, "boolean")) return value === "true";
3616
+ if (schemaHasType(schema, "array") || schemaHasType(schema, "object")) try {
3617
+ return JSON.parse(value);
3618
+ } catch {
3619
+ return value;
3620
+ }
3621
+ return value;
3622
+ }
3623
+ function OpenApiRequestBodyEditor(arg0) {
3624
+ const { spec, mediaType, content, body, files, onBodyChange, onFileChange } = arg0;
3625
+ const schema = resolveSchema(spec, content?.schema);
3626
+ const schemaRecord = isRecord$1(schema) ? schema : void 0;
3627
+ const properties = isRecord$1(schemaRecord?.properties) ? schemaRecord.properties : void 0;
3628
+ const required = new Set(Array.isArray(schemaRecord?.required) ? schemaRecord.required.map(String) : []);
3629
+ const values = parseBodyRecord(body);
3630
+ function updateProperty(name, propertySchema, value) {
3631
+ onBodyChange(JSON.stringify({
3632
+ ...values,
3633
+ [name]: valueFromInput(propertySchema, value)
3634
+ }, null, 2));
3635
+ }
3636
+ function renderProperty(name, unresolvedSchema) {
3637
+ const propertySchema = resolveSchema(spec, unresolvedSchema);
3638
+ const propertyRecord = isRecord$1(propertySchema) ? propertySchema : void 0;
3639
+ const type = schemaToType(propertySchema) ?? "string";
3640
+ const value = values[name];
3641
+ const fieldId = `openapi-request-body-${name}`.replace(/[^a-zA-Z0-9_-]/g, "-");
3642
+ const options = Array.isArray(propertyRecord?.enum) ? propertyRecord.enum : [];
3643
+ const structured = schemaHasType(propertySchema, "array") || schemaHasType(propertySchema, "object");
3644
+ const serializedValue = structured && typeof value !== "undefined" ? JSON.stringify(value, null, 2) : String(value ?? "");
3645
+ let control;
3646
+ if (isBinarySchema(propertySchema)) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3647
+ id: fieldId,
3648
+ "aria-label": name,
3649
+ type: "file",
3650
+ required: required.has(name),
3651
+ onChange: (event) => onFileChange(name, event.target.files?.[0]),
3652
+ className: "min-h-8 w-full px-2 py-1 text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
3653
+ });
3654
+ else if (options.length > 0) control = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
3655
+ id: fieldId,
3656
+ "aria-label": name,
3657
+ value: serializedValue,
3658
+ required: required.has(name),
3659
+ onChange: (event) => updateProperty(name, propertySchema, event.target.value),
3660
+ className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)",
3661
+ children: [!required.has(name) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", { value: "" }) : null, options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
3662
+ value: String(option),
3663
+ children: String(option)
3664
+ }, String(option)))]
3665
+ });
3666
+ else if (schemaHasType(propertySchema, "boolean")) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3667
+ id: fieldId,
3668
+ "aria-label": name,
3669
+ type: "checkbox",
3670
+ checked: value === true,
3671
+ onChange: (event) => updateProperty(name, propertySchema, String(event.target.checked)),
3672
+ className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
3673
+ });
3674
+ else if (structured) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
3675
+ id: fieldId,
3676
+ "aria-label": name,
3677
+ value: serializedValue,
3678
+ required: required.has(name),
3679
+ rows: 3,
3680
+ spellCheck: false,
3681
+ onChange: (event) => updateProperty(name, propertySchema, event.target.value),
3682
+ className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
3683
+ });
3684
+ else control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3685
+ id: fieldId,
3686
+ "aria-label": name,
3687
+ value: serializedValue,
3688
+ type: schemaHasType(propertySchema, "integer") || schemaHasType(propertySchema, "number") ? "number" : propertyRecord?.format === "date" ? "date" : propertyRecord?.format === "date-time" ? "datetime-local" : "text",
3689
+ required: required.has(name),
3690
+ onChange: (event) => updateProperty(name, propertySchema, event.target.value),
3691
+ className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
3692
+ });
3693
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3694
+ className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",
3695
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3696
+ htmlFor: fieldId,
3697
+ className: "flex min-h-8 min-w-0 items-center gap-1.5 border-r border-(--clarify-theme-tokens-colors-border) px-2 text-xs text-(--clarify-ui-text-strong)",
3698
+ children: [
3699
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3700
+ className: "truncate font-mono",
3701
+ children: name
3702
+ }),
3703
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3704
+ className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
3705
+ children: type
3706
+ }),
3707
+ required.has(name) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3708
+ className: "text-(--clarify-error-accent-text)",
3709
+ children: "*"
3710
+ }) : null
3711
+ ]
3712
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3713
+ className: "flex min-w-0 items-center",
3714
+ children: [control, files[name] ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3715
+ className: "sr-only",
3716
+ children: files[name].name
3717
+ }) : null]
3718
+ })]
3719
+ }, name);
3720
+ }
3721
+ if (properties && isFormMediaType(mediaType)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3722
+ className: "divide-y divide-(--clarify-theme-tokens-colors-border)",
3723
+ children: Object.entries(properties).map(([name, propertySchema]) => renderProperty(name, propertySchema))
3724
+ });
3725
+ if (isBinarySchema(schema) || !isTextMediaType(mediaType)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3726
+ className: "flex min-h-44 items-start p-3",
3727
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3728
+ "aria-label": mediaType,
3729
+ type: "file",
3730
+ onChange: (event) => onFileChange("", event.target.files?.[0]),
3731
+ className: "w-full text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
3732
+ })
3733
+ });
3734
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
3735
+ "aria-label": mediaType,
3736
+ value: body,
3737
+ onChange: (event) => onBodyChange(event.target.value),
3738
+ spellCheck: false,
3739
+ className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
3251
3740
  });
3252
- return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
3253
3741
  }
3254
- function ServerUrlValue(arg0) {
3255
- const { servers, selectedKey, server, variables, open, interactive, directSelect, onSelect, onToggle } = arg0;
3256
- const url = getServerPreviewUrl(server, variables);
3257
- const protocolLabel = getServerProtocolLabel(server, variables);
3258
- if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3259
- "aria-label": "Server",
3260
- 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",
3261
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3262
- className: "sm:hidden",
3263
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
3264
- className: "h-4 w-4",
3265
- "aria-hidden": "true"
3266
- })
3267
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
3268
- className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
3269
- children: [protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3270
- 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",
3271
- children: protocolLabel
3272
- }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3273
- className: "truncate font-semibold text-xs",
3274
- children: url
3275
- })]
3742
+ //#endregion
3743
+ //#region source/openapi/components/OpenApiRequestFields.tsx
3744
+ function RequestField(arg0) {
3745
+ const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
3746
+ const t = require_i18n.useBuiltInText();
3747
+ const schema = resolveSchema(spec, parameter.schema);
3748
+ const schemaRecord = isRecord$1(schema) ? schema : void 0;
3749
+ const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
3750
+ const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
3751
+ const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
3752
+ const type = schemaToType(schema) ?? "string";
3753
+ const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
3754
+ const structured = type.includes("[]") || type.includes("object");
3755
+ const boolean = type.includes("boolean");
3756
+ const numeric = type.includes("integer") || type.includes("number");
3757
+ const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
3758
+ const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
3759
+ const controlProps = {
3760
+ "aria-label": parameter.name,
3761
+ "aria-invalid": issue ? true : void 0,
3762
+ "aria-describedby": issue ? `${fieldId}-issue` : void 0,
3763
+ disabled: !enabled
3764
+ };
3765
+ const arrayValue = (() => {
3766
+ try {
3767
+ const parsed = JSON.parse(value);
3768
+ return Array.isArray(parsed) ? parsed.map(String) : [];
3769
+ } catch {
3770
+ return [];
3771
+ }
3772
+ })();
3773
+ const descriptionTip = description ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
3774
+ content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
3775
+ className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
3776
+ children: description
3777
+ }),
3778
+ side: "bottom",
3779
+ className: "mr-1 shrink-0 *:[[role=tooltip]]:w-80 *:[[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] *:[[role=tooltip]]:border *:[[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) *:[[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) *:[[role=tooltip]]:p-3 *:[[role=tooltip]]:text-(--clarify-ui-text) *:[[role=tooltip]]:shadow-xl",
3780
+ triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
3781
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.InfoIcon, {
3782
+ className: "size-4",
3783
+ "aria-hidden": "true"
3784
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3785
+ className: "sr-only",
3786
+ children: t("openapi.fieldDescription")
3276
3787
  })]
3277
- });
3278
- if (directSelect) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3279
- label: "Server",
3280
- value: selectedKey,
3281
- options: servers.map((option, index) => ({
3282
- value: getServerKey(option, index),
3283
- label: getServerLabel(option, index),
3284
- description: option.description
3285
- })),
3286
- onChange: onSelect,
3788
+ }) : null;
3789
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3790
+ className: "group grid min-w-0 grid-cols-[2rem_minmax(0,1fr)] sm:grid-cols-[2rem_minmax(0,1fr)_minmax(0,1fr)] sm:items-stretch",
3791
+ children: [
3792
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3793
+ className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
3794
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3795
+ type: "checkbox",
3796
+ checked: enabled,
3797
+ disabled: parameter.required,
3798
+ onChange: (event) => onEnabledChange(event.target.checked),
3799
+ "aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
3800
+ className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
3801
+ })
3802
+ }),
3803
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3804
+ className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
3805
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3806
+ htmlFor: fieldId,
3807
+ className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
3808
+ children: [
3809
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3810
+ className: "truncate font-mono",
3811
+ children: parameter.name
3812
+ }),
3813
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3814
+ className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
3815
+ children: type
3816
+ }),
3817
+ parameter.required ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3818
+ className: "text-(--clarify-error-accent-text)",
3819
+ children: "*"
3820
+ }) : null
3821
+ ]
3822
+ })
3823
+ }),
3824
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3825
+ className: (0, clsx.default)("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "bg-(--clarify-ui-subtle-background)"),
3826
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3827
+ className: "min-w-0 flex-1",
3828
+ children: itemOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiInlineListbox, {
3829
+ label: parameter.name ?? "",
3830
+ value: arrayValue,
3831
+ options: itemOptions.map((option) => ({
3832
+ value: option,
3833
+ label: option
3834
+ })),
3835
+ onChange: (next) => onChange(JSON.stringify(next)),
3836
+ invalid: Boolean(issue),
3837
+ describedBy: issue ? `${fieldId}-issue` : void 0,
3838
+ disabled: !enabled
3839
+ }) : options.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3840
+ label: parameter.name ?? "",
3841
+ value,
3842
+ options: [...parameter.required ? [] : [{
3843
+ value: "",
3844
+ label: t("openapi.none")
3845
+ }], ...options.map((option) => ({
3846
+ value: option,
3847
+ label: option
3848
+ }))],
3849
+ onChange,
3850
+ invalid: Boolean(issue),
3851
+ describedBy: issue ? `${fieldId}-issue` : void 0,
3852
+ disabled: !enabled
3853
+ }) : boolean ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3854
+ ...controlProps,
3855
+ id: fieldId,
3856
+ type: "checkbox",
3857
+ checked: value === "true",
3858
+ onChange: (event) => onChange(String(event.target.checked)),
3859
+ className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
3860
+ }) : structured ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
3861
+ ...controlProps,
3862
+ id: fieldId,
3863
+ value,
3864
+ required: parameter.required,
3865
+ onChange: (event) => onChange(event.target.value),
3866
+ rows: 3,
3867
+ spellCheck: false,
3868
+ placeholder: type.includes("[]") ? "[]" : "{}",
3869
+ className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden aria-invalid:text-(--clarify-error-accent-text) focus:bg-(--clarify-ui-hover-background)"
3870
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3871
+ ...controlProps,
3872
+ id: fieldId,
3873
+ value,
3874
+ type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
3875
+ required: parameter.required,
3876
+ onChange: (event) => onChange(event.target.value),
3877
+ className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden transition placeholder:text-(--clarify-ui-text-faint) focus:bg-(--clarify-ui-hover-background) aria-invalid:text-(--clarify-error-accent-text)"
3878
+ })
3879
+ }), descriptionTip]
3880
+ }),
3881
+ issueText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3882
+ id: `${fieldId}-issue`,
3883
+ className: "col-start-2 border-t border-(--clarify-theme-tokens-colors-border) px-2 py-1 text-xs/5 font-medium text-(--clarify-error-accent-text) sm:col-start-3",
3884
+ children: issueText
3885
+ }) : null
3886
+ ]
3887
+ });
3888
+ }
3889
+ function RequestSection(arg0) {
3890
+ const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
3891
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
3892
+ open: defaultOpen,
3893
+ className: (0, clsx.default)("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
3894
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
3895
+ className: "flex min-h-11 cursor-pointer list-none items-center gap-2 bg-(--clarify-ui-subtle-background) px-2.5 text-sm font-medium text-(--clarify-ui-text-strong) hover:bg-(--clarify-ui-hover-background) group-open:border-b group-open:border-(--clarify-theme-tokens-colors-border)",
3896
+ children: [
3897
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
3898
+ className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
3899
+ "aria-hidden": "true"
3900
+ }),
3901
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3902
+ className: "flex-1",
3903
+ children: title
3904
+ }),
3905
+ typeof count === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3906
+ className: "font-mono text-xs text-(--clarify-ui-text-faint)",
3907
+ children: count
3908
+ }) : null,
3909
+ actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3910
+ className: "flex items-center gap-1",
3911
+ onClick: (event) => {
3912
+ event.preventDefault();
3913
+ event.stopPropagation();
3914
+ },
3915
+ children: actions
3916
+ }) : null
3917
+ ]
3918
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3919
+ className: (0, clsx.default)("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
3920
+ children
3921
+ })]
3922
+ });
3923
+ }
3924
+ //#endregion
3925
+ //#region source/openapi/components/OpenApiResponseViewer.tsx
3926
+ function formatBytes(size) {
3927
+ if (size < 1024) return `${size} B`;
3928
+ if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
3929
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`;
3930
+ }
3931
+ function parseJson(value) {
3932
+ try {
3933
+ return JSON.parse(value);
3934
+ } catch {
3935
+ return;
3936
+ }
3937
+ }
3938
+ var textLanguages = {
3939
+ "application/graphql": "graphql",
3940
+ "application/javascript": "javascript",
3941
+ "application/sql": "sql",
3942
+ "application/typescript": "typescript",
3943
+ "application/xml": "xml",
3944
+ "application/x-httpd-php": "php",
3945
+ "application/x-sh": "shellscript",
3946
+ "application/xhtml+xml": "html",
3947
+ "application/x-www-form-urlencoded": "http",
3948
+ "text/css": "css",
3949
+ "text/csv": "csv",
3950
+ "text/html": "html",
3951
+ "text/javascript": "javascript",
3952
+ "text/markdown": "markdown",
3953
+ "text/plain": "text",
3954
+ "text/xml": "xml"
3955
+ };
3956
+ function normalizedMediaType(contentType) {
3957
+ return contentType.split(";", 1)[0].trim().toLowerCase();
3958
+ }
3959
+ function getResponseTextPreview(contentType, body) {
3960
+ const mediaType = normalizedMediaType(contentType);
3961
+ if (mediaType === "application/json" || mediaType.endsWith("+json")) {
3962
+ const parsed = parseJson(body);
3963
+ return {
3964
+ code: typeof parsed === "undefined" ? body : JSON.stringify(parsed, null, 2),
3965
+ language: "json"
3966
+ };
3967
+ }
3968
+ if (mediaType === "application/yaml" || mediaType === "application/x-yaml" || mediaType === "text/yaml" || mediaType === "text/x-yaml" || mediaType.endsWith("+yaml")) try {
3969
+ return {
3970
+ code: (0, yaml.stringify)((0, yaml.parse)(body)).trimEnd(),
3971
+ language: "yaml"
3972
+ };
3973
+ } catch {
3974
+ return {
3975
+ code: body,
3976
+ language: "yaml"
3977
+ };
3978
+ }
3979
+ const language = textLanguages[mediaType] ?? (mediaType.startsWith("text/") ? mediaType.slice(5) || "text" : void 0);
3980
+ return language ? {
3981
+ code: body,
3982
+ language
3983
+ } : void 0;
3984
+ }
3985
+ function canPreviewResponse(contentType) {
3986
+ const mediaType = normalizedMediaType(contentType);
3987
+ return Boolean(getResponseTextPreview(contentType, "") || mediaType.startsWith("image/") || mediaType.startsWith("audio/") || mediaType.startsWith("video/"));
3988
+ }
3989
+ function ResponseState(arg0) {
3990
+ const { icon: Icon, title, description, tone = "default" } = arg0;
3991
+ const error = tone === "error";
3992
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3993
+ className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
3994
+ role: error ? "alert" : "status",
3995
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3996
+ className: "max-w-sm",
3997
+ children: [
3998
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3999
+ className: (0, clsx.default)("mx-auto mb-3 grid size-10 place-items-center rounded-full border", error ? "border-(--clarify-code-danger-border) bg-(--clarify-code-danger-background) text-(--clarify-code-danger)" : "border-(--clarify-code-border) bg-(--clarify-code-control-background) text-(--clarify-code-muted)"),
4000
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
4001
+ className: "size-4.5",
4002
+ "aria-hidden": "true"
4003
+ })
4004
+ }),
4005
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4006
+ className: (0, clsx.default)("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
4007
+ children: title
4008
+ }),
4009
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4010
+ className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
4011
+ children: description
4012
+ })
4013
+ ]
4014
+ })
4015
+ });
4016
+ }
4017
+ function CopyButton(arg0) {
4018
+ const { value } = arg0;
4019
+ const t = require_i18n.useBuiltInText();
4020
+ const [copied, setCopied] = (0, react.useState)(false);
4021
+ async function copy() {
4022
+ const success = await require_PageActions.copyTextToClipboard(value);
4023
+ setCopied(success);
4024
+ if (success) window.setTimeout(() => setCopied(false), 1600);
4025
+ }
4026
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4027
+ type: "button",
4028
+ onClick: copy,
4029
+ "aria-label": copied ? t("actions.copied") : t("actions.copy"),
4030
+ title: copied ? t("actions.copied") : t("actions.copy"),
4031
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4032
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
4033
+ className: "size-4 text-(--clarify-code-success)",
4034
+ "aria-hidden": "true"
4035
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
4036
+ className: "size-4",
4037
+ "aria-hidden": "true"
4038
+ })
4039
+ });
4040
+ }
4041
+ function ResponseMedia(arg0) {
4042
+ const { blob, type } = arg0;
4043
+ const elementRef = (0, react.useRef)(null);
4044
+ (0, react.useEffect)(() => {
4045
+ const element = elementRef.current;
4046
+ if (!element) return;
4047
+ const url = URL.createObjectURL(blob);
4048
+ element.src = url;
4049
+ return () => {
4050
+ element.removeAttribute("src");
4051
+ URL.revokeObjectURL(url);
4052
+ };
4053
+ }, [blob]);
4054
+ if (type === "image") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
4055
+ ref: elementRef,
4056
+ alt: "",
4057
+ className: "max-h-128 max-w-full object-contain"
4058
+ });
4059
+ if (type === "audio") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
4060
+ ref: elementRef,
4061
+ controls: true,
4062
+ className: "w-full"
4063
+ });
4064
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
4065
+ ref: elementRef,
4066
+ controls: true,
4067
+ className: "max-h-128 max-w-full"
4068
+ });
4069
+ }
4070
+ function ResponsePreview(arg0) {
4071
+ const { exchange } = arg0;
4072
+ const t = require_i18n.useBuiltInText();
4073
+ const contentType = normalizedMediaType(exchange.contentType);
4074
+ if (!exchange.size) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
4075
+ icon: lucide_react.FileX2Icon,
4076
+ title: t("openapi.responseBodyEmptyTitle"),
4077
+ description: t("openapi.responseBodyEmpty")
4078
+ });
4079
+ if (contentType.startsWith("image/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
4080
+ blob: exchange.blob,
4081
+ type: "image"
4082
+ });
4083
+ if (contentType.startsWith("audio/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
4084
+ blob: exchange.blob,
4085
+ type: "audio"
4086
+ });
4087
+ if (contentType.startsWith("video/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
4088
+ blob: exchange.blob,
4089
+ type: "video"
4090
+ });
4091
+ if (contentType === "text/html" || contentType === "application/xhtml+xml") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
4092
+ srcDoc: exchange.body,
4093
+ sandbox: "",
4094
+ title: "Response preview",
4095
+ className: "h-96 w-full border-0 bg-white"
4096
+ });
4097
+ const textPreview = getResponseTextPreview(exchange.contentType, exchange.body);
4098
+ if (textPreview) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
4099
+ className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
4100
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HighlightedCode, {
4101
+ code: textPreview.code,
4102
+ language: textPreview.language
4103
+ })
4104
+ });
4105
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4106
+ className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
4107
+ children: t("openapi.binaryPreview")
4108
+ });
4109
+ }
4110
+ function ResponseHeaders(arg0) {
4111
+ const { headers: sourceHeaders } = arg0;
4112
+ const t = require_i18n.useBuiltInText();
4113
+ const [query, setQuery] = (0, react.useState)("");
4114
+ const normalizedQuery = query.trim().toLowerCase();
4115
+ const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
4116
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
4117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
4118
+ className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
4119
+ children: [
4120
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
4121
+ className: "size-4 shrink-0 text-(--clarify-code-muted)",
4122
+ "aria-hidden": "true"
4123
+ }),
4124
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4125
+ className: "sr-only",
4126
+ children: t("openapi.searchHeaders")
4127
+ }),
4128
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4129
+ value: query,
4130
+ onChange: (event) => setQuery(event.target.value),
4131
+ placeholder: t("openapi.searchHeaders"),
4132
+ className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
4133
+ })
4134
+ ]
4135
+ }),
4136
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4137
+ className: "overflow-x-auto",
4138
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
4139
+ className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
4140
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
4141
+ className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
4142
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
4143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4144
+ className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
4145
+ children: t("openapi.headerName")
4146
+ }),
4147
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4148
+ className: "px-3 py-2 font-semibold",
4149
+ children: t("openapi.headerValue")
4150
+ }),
4151
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4152
+ className: "w-10",
4153
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4154
+ className: "sr-only",
4155
+ children: t("actions.copy")
4156
+ })
4157
+ })
4158
+ ] })
4159
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
4160
+ className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
4161
+ children: [
4162
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
4163
+ className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
4164
+ children: name
4165
+ }),
4166
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
4167
+ className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
4168
+ children: value
4169
+ }),
4170
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
4171
+ className: "pr-1",
4172
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: `${name}: ${value}` })
4173
+ })
4174
+ ]
4175
+ }, `${name}:${index}`)) })]
4176
+ })
4177
+ }),
4178
+ headers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4179
+ className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
4180
+ children: t("openapi.noHeaders")
4181
+ }) : null
4182
+ ] });
4183
+ }
4184
+ function HiddenCookies() {
4185
+ const t = require_i18n.useBuiltInText();
4186
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
4187
+ className: "w-full table-fixed border-collapse text-left text-xs/5",
4188
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
4189
+ className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
4190
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4191
+ className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
4192
+ children: t("openapi.headerName")
4193
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
4194
+ className: "px-3 py-2 font-semibold",
4195
+ children: t("openapi.headerValue")
4196
+ })] })
4197
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
4198
+ className: "border-t border-(--clarify-code-border)",
4199
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
4200
+ colSpan: 2,
4201
+ className: "px-3 py-5 text-center text-(--clarify-code-faint)",
4202
+ children: t("openapi.cookiesBrowserHidden")
4203
+ })
4204
+ }) })]
4205
+ });
4206
+ }
4207
+ function OpenApiResponseViewer(arg0) {
4208
+ const { exchange, error } = arg0;
4209
+ const t = require_i18n.useBuiltInText();
4210
+ const [bodyModeSelection, setBodyModeSelection] = (0, react.useState)();
4211
+ const previewAvailable = exchange ? canPreviewResponse(exchange.contentType) : false;
4212
+ const selectedBodyMode = bodyModeSelection && bodyModeSelection.exchange === exchange ? bodyModeSelection.mode : "preview";
4213
+ const activeBodyMode = previewAvailable ? selectedBodyMode : "raw";
4214
+ function downloadBody() {
4215
+ if (!exchange) return;
4216
+ const url = URL.createObjectURL(exchange.blob);
4217
+ const anchor = document.createElement("a");
4218
+ anchor.href = url;
4219
+ anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
4220
+ anchor.click();
4221
+ URL.revokeObjectURL(url);
4222
+ }
4223
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
4224
+ className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
4225
+ "aria-label": t("openapi.response"),
4226
+ children: [
4227
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4228
+ className: "sticky top-0 z-10 flex min-h-11 flex-wrap items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-header-background) px-2.5 text-sm font-medium",
4229
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4230
+ className: "mr-auto text-(--clarify-code-text)",
4231
+ children: t("openapi.response")
4232
+ }), exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
4233
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4234
+ className: "text-xs font-semibold text-(--clarify-code-muted)",
4235
+ children: [exchange.duration, " ms"]
4236
+ }),
4237
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4238
+ className: "text-xs text-(--clarify-code-faint)",
4239
+ children: formatBytes(exchange.size)
4240
+ }),
4241
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: (0, clsx.default)("size-2 rounded-full", exchange.status < 400 ? "bg-(--clarify-code-success)" : "bg-(--clarify-code-danger)") }),
4242
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4243
+ className: (0, clsx.default)("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
4244
+ children: [
4245
+ exchange.status,
4246
+ " ",
4247
+ exchange.statusText
4248
+ ]
4249
+ })
4250
+ ] }) : null]
4251
+ }),
4252
+ error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
4253
+ icon: lucide_react.CircleAlertIcon,
4254
+ title: t("openapi.responseErrorTitle"),
4255
+ description: error,
4256
+ tone: "error"
4257
+ }) : null,
4258
+ !error && !exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
4259
+ icon: lucide_react.SendIcon,
4260
+ title: t("openapi.responseEmptyTitle"),
4261
+ description: t("openapi.responseEmpty")
4262
+ }) : null,
4263
+ exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4264
+ className: "min-h-0 flex-1 overflow-auto",
4265
+ children: [
4266
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4267
+ title: t("openapi.cookies"),
4268
+ count: 0,
4269
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HiddenCookies, {})
4270
+ }),
4271
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4272
+ title: t("openapi.requestHeaders"),
4273
+ count: exchange.request.headers.length,
4274
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.request.headers })
4275
+ }),
4276
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4277
+ title: t("openapi.responseHeaders"),
4278
+ count: exchange.headers.length,
4279
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.headers })
4280
+ }),
4281
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4282
+ title: t("openapi.body"),
4283
+ defaultOpen: true,
4284
+ actions: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4285
+ className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
4286
+ children: exchange.contentType || t("openapi.unknownContentType")
4287
+ }),
4288
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4289
+ className: "min-h-72",
4290
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4291
+ className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
4292
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4293
+ role: "tablist",
4294
+ className: "flex",
4295
+ children: ["preview", "raw"].filter((mode) => mode === "raw" || previewAvailable).map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4296
+ type: "button",
4297
+ role: "tab",
4298
+ "aria-selected": activeBodyMode === mode,
4299
+ onClick: () => setBodyModeSelection({
4300
+ exchange,
4301
+ mode
4302
+ }),
4303
+ className: (0, clsx.default)("border-b-2 px-2.5 py-1 text-2xs font-semibold", activeBodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
4304
+ children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
4305
+ }, mode))
4306
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4307
+ className: "flex",
4308
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: exchange.body }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4309
+ type: "button",
4310
+ onClick: downloadBody,
4311
+ "aria-label": t("openapi.downloadBody"),
4312
+ title: t("openapi.downloadBody"),
4313
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-code-muted) transition hover:bg-(--clarify-code-control-background-hover) hover:text-(--clarify-code-text) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4314
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.DownloadIcon, {
4315
+ className: "size-4",
4316
+ "aria-hidden": "true"
4317
+ })
4318
+ })]
4319
+ })]
4320
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4321
+ className: "p-4",
4322
+ children: activeBodyMode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
4323
+ className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
4324
+ children: exchange.body
4325
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4326
+ className: "py-8 text-center text-xs text-(--clarify-code-faint)",
4327
+ children: t("openapi.responseBodyEmpty")
4328
+ })
4329
+ })]
4330
+ })
4331
+ })
4332
+ ]
4333
+ }) : null
4334
+ ]
4335
+ });
4336
+ }
4337
+ //#endregion
4338
+ //#region source/openapi/components/SendRequestButton.tsx
4339
+ function SendRequestButton(arg0) {
4340
+ const { label, busy = false, text, onClick } = arg0;
4341
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
4342
+ type: "button",
4343
+ disabled: busy,
4344
+ "aria-label": label,
4345
+ title: label,
4346
+ onClick,
4347
+ className: Boolean(text) ? "flex h-8 shrink-0 items-center gap-1.5 rounded bg-(--clarify-theme-tokens-colors-foreground) px-3 text-xs font-semibold text-(--clarify-theme-tokens-colors-background) transition hover:opacity-85 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60" : "grid size-7 shrink-0 place-items-center rounded bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors hover:bg-(--clarify-theme-tokens-colors-foreground) hover:text-(--clarify-theme-tokens-colors-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-foreground) focus-visible:ring-offset-2 disabled:cursor-wait disabled:opacity-60",
4348
+ children: [busy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LoaderCircleIcon, {
4349
+ className: "size-4 animate-spin",
4350
+ "aria-hidden": "true"
4351
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SendIcon, {
4352
+ className: "size-4",
4353
+ "aria-hidden": "true"
4354
+ }), text]
4355
+ });
4356
+ }
4357
+ //#endregion
4358
+ //#region source/openapi/lib/api-exchange.ts
4359
+ var ApiRequestError = class extends Error {
4360
+ category;
4361
+ constructor(message, options) {
4362
+ super(message, options);
4363
+ this.name = "ApiRequestError";
4364
+ this.category = "network";
4365
+ }
4366
+ };
4367
+ function requestBodySnapshot(body) {
4368
+ if (typeof body === "string") return body;
4369
+ if (body instanceof URLSearchParams) return body.toString();
4370
+ }
4371
+ function requestSnapshot(request) {
4372
+ return {
4373
+ url: request.url,
4374
+ method: request.init.method ?? "GET",
4375
+ headers: Array.from(new Headers(request.init.headers).entries()),
4376
+ body: requestBodySnapshot(request.init.body)
4377
+ };
4378
+ }
4379
+ async function executeApiRequest(request, options = {}) {
4380
+ const fetchRequest = options.fetch ?? fetch;
4381
+ const now = options.now ?? (() => performance.now());
4382
+ const startedAt = now();
4383
+ let response;
4384
+ try {
4385
+ response = await fetchRequest(request.url, {
4386
+ ...request.init,
4387
+ signal: options.signal
4388
+ });
4389
+ } catch (cause) {
4390
+ if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
4391
+ throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
4392
+ }
4393
+ const blob = await response.blob();
4394
+ return {
4395
+ request: requestSnapshot(request),
4396
+ status: response.status,
4397
+ statusText: response.statusText,
4398
+ url: response.url || request.url,
4399
+ redirected: response.redirected,
4400
+ duration: Math.round(now() - startedAt),
4401
+ size: blob.size,
4402
+ headers: Array.from(response.headers.entries()),
4403
+ contentType: response.headers.get("content-type") ?? blob.type,
4404
+ body: await blob.text(),
4405
+ blob
4406
+ };
4407
+ }
4408
+ //#endregion
4409
+ //#region source/openapi/lib/request-parameters.ts
4410
+ function structuredIssue(value, type) {
4411
+ if (!type.includes("[]") && !type.includes("object")) return void 0;
4412
+ try {
4413
+ const parsed = JSON.parse(value);
4414
+ if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
4415
+ if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
4416
+ } catch {
4417
+ return type.includes("[]") ? "invalidArray" : "invalidObject";
4418
+ }
4419
+ }
4420
+ function scalarIssue(value, type, format) {
4421
+ if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
4422
+ if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
4423
+ if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
4424
+ if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
4425
+ }
4426
+ function validateRequestParameter(spec, parameter, value) {
4427
+ if (!value) return parameter.required ? "required" : void 0;
4428
+ const schema = resolveSchema(spec, parameter.schema);
4429
+ const schemaRecord = isRecord$1(schema) ? schema : void 0;
4430
+ const type = schemaToType(schema) ?? "string";
4431
+ const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
4432
+ if (options.length > 0 && !options.includes(value)) return "invalidEnum";
4433
+ return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
4434
+ }
4435
+ function validateRequestParameters(spec, parameters, values) {
4436
+ return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
4437
+ const key = parameterKey(parameter);
4438
+ const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
4439
+ return issue ? [[key, issue]] : [];
4440
+ }));
4441
+ }
4442
+ //#endregion
4443
+ //#region source/openapi/components/useOpenApiRequestState.ts
4444
+ function initialRequestBody(spec, content) {
4445
+ const example = getExampleEntries(content, spec)[0];
4446
+ if (!example?.generated) return stringifyExample(example?.value);
4447
+ const schema = resolveSchema(spec, content?.schema);
4448
+ if (isRecord$1(schema) && schema.format === "binary") return "";
4449
+ if (!isRecord$1(example.value) || !isRecord$1(schema) || !isRecord$1(schema.properties)) return stringifyExample(example.value);
4450
+ const value = { ...example.value };
4451
+ Object.entries(schema.properties).forEach(([name, propertySchema]) => {
4452
+ const resolved = resolveSchema(spec, propertySchema);
4453
+ if (isRecord$1(resolved) && resolved.format === "binary") delete value[name];
4454
+ });
4455
+ return stringifyExample(value);
4456
+ }
4457
+ function requestBodyForExample(spec, content, exampleKey) {
4458
+ const example = getExampleEntries(content, spec).find((entry) => !entry.generated && entry.key === exampleKey);
4459
+ return example ? stringifyExample(example.value) : initialRequestBody(spec, content);
4460
+ }
4461
+ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
4462
+ const servers = getServers(spec, operation, path, operationSource);
4463
+ const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
4464
+ const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
4465
+ const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
4466
+ const authOptions = getAuthOptions(spec, operation);
4467
+ const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
4468
+ const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
4469
+ const credentialScope = getOpenApiCredentialScope(spec);
4470
+ const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
4471
+ const setCredential = useOpenApiStore((state) => state.setCredential);
4472
+ const clearCredential = useOpenApiStore((state) => state.clearCredential);
4473
+ const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
4474
+ const [mediaType, setMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
4475
+ const selectedContent = requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0];
4476
+ const [body, setBody] = (0, react.useState)(initialRequestBody(spec, selectedContent?.value));
4477
+ const [bodyFiles, setBodyFiles] = (0, react.useState)({});
4478
+ function selectServer(value) {
4479
+ const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
4480
+ setSelectedServerKey(value);
4481
+ setServerVariables(defaultServerVariables(nextServer));
4482
+ }
4483
+ function selectMediaType(value) {
4484
+ const content = requestContents.find((entry) => entry.mediaType === value)?.value;
4485
+ setMediaType(value);
4486
+ setBody(initialRequestBody(spec, content));
4487
+ setBodyFiles({});
4488
+ }
4489
+ function applyBodyExample(exampleKey) {
4490
+ setBody(requestBodyForExample(spec, selectedContent?.value, exampleKey));
4491
+ setBodyFiles({});
4492
+ }
4493
+ function setBodyFile(name, file) {
4494
+ setBodyFiles((current) => {
4495
+ const next = { ...current };
4496
+ if (file) next[name] = file;
4497
+ else delete next[name];
4498
+ return next;
4499
+ });
4500
+ }
4501
+ return {
4502
+ servers,
4503
+ selectedServer,
4504
+ selectedServerKey,
4505
+ serverVariables,
4506
+ setServerVariables,
4507
+ serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
4508
+ selectServer,
4509
+ authOptions,
4510
+ selectedAuthName,
4511
+ setSelectedAuthName,
4512
+ selectedAuth,
4513
+ credentialScope,
4514
+ credentials,
4515
+ setCredential,
4516
+ clearCredential,
4517
+ requestContents,
4518
+ mediaType,
4519
+ selectedContent,
4520
+ body,
4521
+ setBody,
4522
+ bodyFiles,
4523
+ setBodyFile,
4524
+ applyBodyExample,
4525
+ selectMediaType
4526
+ };
4527
+ }
4528
+ function useOpenApiParameterState(spec, parameters, initialParameterValue, initialExampleKey = "") {
4529
+ const [parameterValues, setParameterValues] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => {
4530
+ const example = getParameterExampleEntries(parameter).find((entry) => entry.key === initialExampleKey);
4531
+ return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
4532
+ })));
4533
+ const [parameterEnabled, setParameterEnabled] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
4534
+ const [parameterIssues, setParameterIssues] = (0, react.useState)({});
4535
+ function setParameterGroupValues(grouped, mode) {
4536
+ const keys = new Set(grouped.map(parameterKey));
4537
+ setParameterValues((current) => ({
4538
+ ...current,
4539
+ ...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
4540
+ }));
4541
+ setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
4542
+ }
4543
+ function setParameterIncluded(parameter, enabled) {
4544
+ const key = parameterKey(parameter);
4545
+ setParameterEnabled((current) => ({
4546
+ ...current,
4547
+ [key]: enabled
4548
+ }));
4549
+ if (!enabled) setParameterIssues((current) => {
4550
+ const next = { ...current };
4551
+ delete next[key];
4552
+ return next;
4553
+ });
4554
+ }
4555
+ function updateParameterValue(parameter, value) {
4556
+ const key = parameterKey(parameter);
4557
+ setParameterValues((current) => ({
4558
+ ...current,
4559
+ [key]: value
4560
+ }));
4561
+ setParameterIssues((current) => {
4562
+ const next = { ...current };
4563
+ delete next[key];
4564
+ return next;
4565
+ });
4566
+ }
4567
+ function applyParameterExample(exampleKey) {
4568
+ setParameterValues(Object.fromEntries(parameters.map((parameter) => {
4569
+ const example = getParameterExampleEntries(parameter).find((entry) => entry.key === exampleKey);
4570
+ return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
4571
+ })));
4572
+ setParameterIssues({});
4573
+ }
4574
+ function validate(parametersToValidate) {
4575
+ const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
4576
+ setParameterIssues(issues);
4577
+ return issues;
4578
+ }
4579
+ return {
4580
+ parameterValues,
4581
+ parameterEnabled,
4582
+ parameterIssues,
4583
+ setParameterGroupValues,
4584
+ setParameterIncluded,
4585
+ updateParameterValue,
4586
+ applyParameterExample,
4587
+ validate
4588
+ };
4589
+ }
4590
+ function useOpenApiRequestExecution() {
4591
+ const [exchange, setExchange] = (0, react.useState)();
4592
+ const [error, setError] = (0, react.useState)("");
4593
+ const [sending, setSending] = (0, react.useState)(false);
4594
+ const requestController = (0, react.useRef)(null);
4595
+ (0, react.useEffect)(() => () => requestController.current?.abort(), []);
4596
+ async function execute(request, corsHint) {
4597
+ requestController.current?.abort();
4598
+ const controller = new AbortController();
4599
+ requestController.current = controller;
4600
+ setSending(true);
4601
+ setError("");
4602
+ setExchange(void 0);
4603
+ try {
4604
+ setExchange(await executeApiRequest(request, { signal: controller.signal }));
4605
+ } catch (cause) {
4606
+ if (cause instanceof DOMException && cause.name === "AbortError") return;
4607
+ const message = cause instanceof Error ? cause.message : String(cause);
4608
+ setError(`${message}. ${corsHint}`);
4609
+ } finally {
4610
+ if (requestController.current === controller) {
4611
+ requestController.current = null;
4612
+ setSending(false);
4613
+ }
4614
+ }
4615
+ }
4616
+ return {
4617
+ exchange,
4618
+ error,
4619
+ sending,
4620
+ execute
4621
+ };
4622
+ }
4623
+ //#endregion
4624
+ //#region source/openapi/components/OpenApiRequest.tsx
4625
+ function initialParameterValue(spec, parameter) {
4626
+ if (typeof parameter.example !== "undefined") return stringifyExample(parameter.example);
4627
+ const schema = resolveSchema(spec, parameter.schema);
4628
+ if (!isRecord$1(schema)) return "";
4629
+ return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
4630
+ }
4631
+ function parameterGroupLabel(location, t) {
4632
+ if (location === "path") return t("openapi.pathParameters");
4633
+ if (location === "header") return t("openapi.headers");
4634
+ if (location === "cookie") return t("openapi.cookies");
4635
+ return t("openapi.queryParameters");
4636
+ }
4637
+ function OpenApiRequestWorkbench(arg0) {
4638
+ const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
4639
+ const t = require_i18n.useBuiltInText();
4640
+ const parameters = getOperationParameters(spec, path, operation, operationSource);
4641
+ const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, selectedContent, body, setBody, bodyFiles, setBodyFile, applyBodyExample, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
4642
+ const requestExamples = getRequestExampleEntries(parameters, selectedContent?.value);
4643
+ const [selectedRequestExampleKey, setSelectedRequestExampleKey] = (0, react.useState)(requestExamples[0]?.key ?? "");
4644
+ const currentRequestExampleKey = requestExamples.some((example) => example.key === selectedRequestExampleKey) ? selectedRequestExampleKey : requestExamples[0]?.key ?? "";
4645
+ const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter), currentRequestExampleKey);
4646
+ const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue, applyParameterExample } = parameterState;
4647
+ const { exchange, error, sending, execute } = useOpenApiRequestExecution();
4648
+ const parameterGroups = [
4649
+ "cookie",
4650
+ "header",
4651
+ "query"
4652
+ ].map((location) => ({
4653
+ location,
4654
+ parameters: parameters.filter((parameter) => parameter.in === location)
4655
+ })).filter((group) => group.parameters.length > 0);
4656
+ const pathParameters = parameters.filter((parameter) => parameter.in === "path");
4657
+ const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
4658
+ function applyRequestExample(exampleKey) {
4659
+ setSelectedRequestExampleKey(exampleKey);
4660
+ applyParameterExample(exampleKey);
4661
+ applyBodyExample(exampleKey);
4662
+ }
4663
+ function selectRequestMediaType(value) {
4664
+ const content = requestContents.find((entry) => entry.mediaType === value)?.value;
4665
+ const nextExampleKey = getRequestExampleEntries(parameters, content)[0]?.key ?? "";
4666
+ selectMediaType(value);
4667
+ setSelectedRequestExampleKey(nextExampleKey);
4668
+ applyParameterExample(nextExampleKey);
4669
+ }
4670
+ async function sendRequest() {
4671
+ const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
4672
+ const issues = parameterState.validate(enabledParameters);
4673
+ if (Object.keys(issues).length > 0) return;
4674
+ await execute(buildApiRequest({
4675
+ method,
4676
+ path,
4677
+ server: selectedServer,
4678
+ serverVariables,
4679
+ parameters,
4680
+ parameterValues,
4681
+ parameterEnabled,
4682
+ auth: selectedAuth?.schemes.map((option) => ({
4683
+ scheme: option.scheme,
4684
+ value: credentials[option.name] ?? ""
4685
+ })),
4686
+ mediaType,
4687
+ body,
4688
+ bodyFiles,
4689
+ baseUrl: window.location.href
4690
+ }), t("openapi.requestCorsHint"));
4691
+ }
4692
+ function renderParameterField(parameter) {
4693
+ const key = parameterKey(parameter);
4694
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestField, {
4695
+ spec,
4696
+ parameter,
4697
+ value: parameterValues[key] ?? "",
4698
+ enabled: parameterEnabled[key] !== false,
4699
+ issue: parameterIssues[key],
4700
+ onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
4701
+ onChange: (value) => updateParameterValue(parameter, value)
4702
+ }, key);
4703
+ }
4704
+ function renderParameterGroup(group) {
4705
+ const { location, parameters: grouped } = group;
4706
+ const actions = location === "cookie" ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4707
+ type: "button",
4708
+ title: t("openapi.resetToExample"),
4709
+ "aria-label": t("openapi.resetToExample"),
4710
+ onClick: () => setParameterGroupValues(grouped, "reset"),
4711
+ className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4712
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcwIcon, {
4713
+ className: "size-3.5",
4714
+ "aria-hidden": "true"
4715
+ })
4716
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4717
+ type: "button",
4718
+ title: t("openapi.clear"),
4719
+ "aria-label": t("openapi.clear"),
4720
+ onClick: () => setParameterGroupValues(grouped, "clear"),
4721
+ className: "grid size-7 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4722
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EraserIcon, {
4723
+ className: "size-3.5",
4724
+ "aria-hidden": "true"
4725
+ })
4726
+ })] });
4727
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4728
+ title: parameterGroupLabel(location, t),
4729
+ count: grouped.length,
4730
+ defaultOpen: true,
4731
+ actions,
4732
+ children: location === "cookie" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4733
+ className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
4734
+ children: t("openapi.cookieParametersBrowserManaged")
4735
+ }) : grouped.map(renderParameterField)
4736
+ }, location);
4737
+ }
4738
+ function renderHeader() {
4739
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4740
+ className: "border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface)",
4741
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4742
+ className: "grid min-w-0 grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 px-2.5 py-2 lg:grid-cols-[auto_auto_minmax(0,1fr)_minmax(0,14rem)_auto_auto]",
4743
+ children: [
4744
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4745
+ className: "col-start-1 row-start-1",
4746
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: method.toUpperCase() })
4747
+ }),
4748
+ servers.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
4749
+ label: t("openapi.server"),
4750
+ value: selectedServerKey,
4751
+ options: servers.map((server, index) => ({
4752
+ value: getServerKey(server, index),
4753
+ label: server.url ?? `Server ${index + 1}`,
4754
+ description: server.description
4755
+ })),
4756
+ onChange: selectServer,
4757
+ title: selectedServer.url ?? t("openapi.server"),
4758
+ buttonContent: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
4759
+ className: "size-4",
4760
+ "aria-hidden": "true"
4761
+ }),
4762
+ className: "col-start-2 row-start-1 size-8 shrink-0",
4763
+ buttonClassName: "grid size-8 place-items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-soft) outline-hidden transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background)"
4764
+ }) : null,
4765
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4766
+ className: "col-start-3 row-start-1 min-w-0 truncate border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
4767
+ title: path || "/",
4768
+ children: path || "/"
4769
+ }),
4770
+ requestExamples.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4771
+ className: "col-span-full row-start-2 flex min-w-0 items-center gap-0.5 border-t border-(--clarify-theme-tokens-colors-border) pt-2 lg:col-span-1 lg:col-start-4 lg:row-start-1 lg:border-t-0 lg:pt-0",
4772
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
4773
+ label: t("openapi.requestExample"),
4774
+ value: currentRequestExampleKey,
4775
+ options: requestExamples.map((example) => ({
4776
+ value: example.key,
4777
+ label: example.title,
4778
+ description: example.summary
4779
+ })),
4780
+ onChange: applyRequestExample,
4781
+ className: "min-w-0 flex-1",
4782
+ buttonClassName: "flex h-8 w-full min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
4783
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4784
+ type: "button",
4785
+ title: t("openapi.resetToExample"),
4786
+ "aria-label": t("openapi.resetToExample"),
4787
+ onClick: () => applyRequestExample(currentRequestExampleKey),
4788
+ className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
4789
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcwIcon, {
4790
+ className: "size-3.5",
4791
+ "aria-hidden": "true"
4792
+ })
4793
+ })]
4794
+ }) : null,
4795
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4796
+ className: "col-start-4 row-start-1 lg:col-start-5",
4797
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
4798
+ label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
4799
+ busy: sending,
4800
+ text: t("openapi.sendRequest"),
4801
+ onClick: sendRequest
4802
+ })
4803
+ }),
4804
+ onClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4805
+ type: "button",
4806
+ onClick: onClose,
4807
+ "aria-label": t("openapi.closeRequest"),
4808
+ title: t("openapi.closeRequest"),
4809
+ className: "col-start-5 row-start-1 grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) 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) lg:col-start-6",
4810
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
4811
+ className: "size-4",
4812
+ "aria-hidden": "true"
4813
+ })
4814
+ }) : null
4815
+ ]
4816
+ })
4817
+ });
4818
+ }
4819
+ function renderVariables() {
4820
+ if (serverVariableEntries.length === 0) return null;
4821
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4822
+ title: t("openapi.variables"),
4823
+ count: serverVariableEntries.length,
4824
+ defaultOpen: true,
4825
+ children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
4826
+ className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
4827
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4828
+ className: "flex min-h-8 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2 font-mono text-xs text-(--clarify-ui-text-strong)",
4829
+ children: name
4830
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
4831
+ value: serverVariables[name] ?? variable.default ?? "",
4832
+ onChange: (event) => setServerVariables((current) => ({
4833
+ ...current,
4834
+ [name]: event.target.value
4835
+ })),
4836
+ className: "h-8 min-w-0 border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background) focus:ring-0"
4837
+ })]
4838
+ }, name))
4839
+ });
4840
+ }
4841
+ function renderRequestBody() {
4842
+ if (requestContents.length === 0) return null;
4843
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RequestSection, {
4844
+ title: t("openapi.requestBody"),
4845
+ count: 1,
4846
+ defaultOpen: true,
4847
+ className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
4848
+ contentClassName: (0, clsx.default)("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
4849
+ children: [requestContents.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
4850
+ label: t("openapi.mediaType"),
4851
+ value: mediaType,
4852
+ options: requestContents.map((entry) => ({
4853
+ value: entry.mediaType,
4854
+ label: entry.mediaType
4855
+ })),
4856
+ onChange: selectRequestMediaType
4857
+ }) }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestBodyEditor, {
4858
+ spec,
4859
+ mediaType,
4860
+ content: selectedContent?.value,
4861
+ body,
4862
+ files: bodyFiles,
4863
+ onBodyChange: setBody,
4864
+ onFileChange: setBodyFile
4865
+ })]
4866
+ });
4867
+ }
4868
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4869
+ className: (0, clsx.default)("clarify-api-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-theme-tokens-radius-lg:6px] [--clarify-theme-tokens-radius-md:4px] [--clarify-theme-tokens-radius-sm:2px] [--clarify-theme-tokens-radius-xl:8px] [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6"),
4870
+ children: [renderHeader(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4871
+ className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
4872
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4873
+ className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
4874
+ children: [
4875
+ authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4876
+ title: t("openapi.authentication"),
4877
+ count: selectedAuth?.schemes.length ?? 0,
4878
+ defaultOpen: true,
4879
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiAuthPanel, {
4880
+ authOptions,
4881
+ selectedAuthName,
4882
+ selectedAuth,
4883
+ authValues: credentials,
4884
+ onSelectAuth: setSelectedAuthName,
4885
+ onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
4886
+ onClearAuthValue: (name) => clearCredential(credentialScope, name)
4887
+ })
4888
+ }) : null,
4889
+ renderVariables(),
4890
+ pathParameters.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4891
+ title: t("openapi.pathParameters"),
4892
+ count: pathParameters.length,
4893
+ defaultOpen: true,
4894
+ children: pathParameters.map(renderParameterField)
4895
+ }) : null,
4896
+ parameterGroups.map(renderParameterGroup),
4897
+ renderRequestBody(),
4898
+ !hasRequestConfiguration ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
4899
+ title: t("openapi.requestConfiguration"),
4900
+ count: 0,
4901
+ defaultOpen: true,
4902
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
4903
+ className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
4904
+ children: t("openapi.noRequestConfiguration")
4905
+ })
4906
+ }) : null
4907
+ ]
4908
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4909
+ className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
4910
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiResponseViewer, {
4911
+ exchange,
4912
+ error
4913
+ })
4914
+ })]
4915
+ })]
4916
+ });
4917
+ }
4918
+ function OpenApiRequestDialog(arg0) {
4919
+ const { open, onClose, ...workbenchProps } = arg0;
4920
+ const t = require_i18n.useBuiltInText();
4921
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Dialog, {
4922
+ open,
4923
+ onClose: () => {},
4924
+ className: "relative z-50",
4925
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4926
+ className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
4927
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.DialogPanel, {
4928
+ className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
4929
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogTitle, {
4930
+ className: "sr-only",
4931
+ children: t("openapi.tryRequest")
4932
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestWorkbench, {
4933
+ ...workbenchProps,
4934
+ compact: true,
4935
+ onClose
4936
+ })]
4937
+ })
4938
+ })]
4939
+ });
4940
+ }
4941
+ //#endregion
4942
+ //#region source/openapi/components/OpenApiOperation.tsx
4943
+ function EndpointPath(arg0) {
4944
+ const { path, copied = false, onCopy } = arg0;
4945
+ const t = require_i18n.useBuiltInText();
4946
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
4947
+ className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
4948
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
4949
+ className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
4950
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
4951
+ className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
4952
+ children: path || "/"
4953
+ })
4954
+ }), onCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
4955
+ type: "button",
4956
+ "aria-label": copied ? t("actions.copied") : t("actions.copy"),
4957
+ title: copied ? t("actions.copied") : t("actions.copy"),
4958
+ onClick: onCopy,
4959
+ className: (0, clsx.default)("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"),
4960
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
4961
+ className: "h-3.5 w-3.5",
4962
+ "aria-hidden": "true"
4963
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
4964
+ className: "h-3.5 w-3.5",
4965
+ "aria-hidden": "true"
4966
+ })
4967
+ }) : null]
4968
+ });
4969
+ }
4970
+ function getServerPreviewUrl(server, variables) {
4971
+ return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
4972
+ }
4973
+ function getFullEndpointUrl(server, variables, path) {
4974
+ return joinPath(getServerPreviewUrl(server, variables), path);
4975
+ }
4976
+ function getServerProtocolLabel(server, variables) {
4977
+ const url = getServerPreviewUrl(server, variables);
4978
+ const protocol = /^([a-z][a-z0-9+.-]*):/i.exec(url)?.[1]?.toUpperCase();
4979
+ return protocol === "WS" || protocol === "WSS" ? protocol : void 0;
4980
+ }
4981
+ function getDefaultResponseStatus(operation, spec) {
4982
+ const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
4983
+ if (left.status === "default") return -1;
4984
+ if (right.status === "default") return 1;
4985
+ const leftCode = Number(left.status);
4986
+ const rightCode = Number(right.status);
4987
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
4988
+ return left.status.localeCompare(right.status);
4989
+ });
4990
+ return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
4991
+ }
4992
+ function ServerUrlValue(arg0) {
4993
+ const { servers, selectedKey, server, variables, open, interactive, directSelect, onSelect, onToggle } = arg0;
4994
+ const url = getServerPreviewUrl(server, variables);
4995
+ const protocolLabel = getServerProtocolLabel(server, variables);
4996
+ if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
4997
+ "aria-label": "Server",
4998
+ 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",
4999
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5000
+ className: "sm:hidden",
5001
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
5002
+ className: "h-4 w-4",
5003
+ "aria-hidden": "true"
5004
+ })
5005
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
5006
+ className: "hidden min-w-0 items-center gap-1.5 overflow-hidden sm:flex",
5007
+ children: [protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5008
+ 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",
5009
+ children: protocolLabel
5010
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
5011
+ className: "truncate font-semibold text-xs",
5012
+ children: url
5013
+ })]
5014
+ })]
5015
+ });
5016
+ if (directSelect) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
5017
+ label: "Server",
5018
+ value: selectedKey,
5019
+ options: servers.map((option, index) => ({
5020
+ value: getServerKey(option, index),
5021
+ label: getServerLabel(option, index),
5022
+ description: option.description
5023
+ })),
5024
+ onChange: onSelect,
3287
5025
  className: "w-8 shrink-0 sm:w-fit sm:min-w-16 sm:max-w-(--clarify-server-url-max-width)",
3288
5026
  buttonClassName: "group flex h-8 w-full min-w-0 cursor-pointer items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) px-0 text-(--clarify-ui-text) transition-colors 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) data-open:bg-(--clarify-ui-active-background) data-open:text-(--clarify-theme-tokens-colors-foreground) sm:px-1.5",
3289
5027
  buttonContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -3401,51 +5139,9 @@ function ServerPanel(arg0) {
3401
5139
  })
3402
5140
  });
3403
5141
  }
3404
- function AuthPanel(arg0) {
3405
- const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
3406
- if (authOptions.length === 0) return null;
3407
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3408
- className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
3409
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3410
- className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
3411
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3412
- className: "flex min-w-0 flex-col gap-1.5",
3413
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3414
- className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
3415
- children: "Auth"
3416
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
3417
- label: "Auth",
3418
- value: selectedAuthName,
3419
- options: authOptions.map(({ name, scheme }) => ({
3420
- value: name,
3421
- label: name,
3422
- description: authLabel(name, scheme)
3423
- })),
3424
- onChange: onSelectAuth
3425
- })]
3426
- }), selectedAuth ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
3427
- className: "flex min-w-0 flex-col gap-1.5",
3428
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3429
- className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
3430
- children: "Credential"
3431
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3432
- className: "flex min-w-0 items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-1.5 shadow-xs",
3433
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3434
- className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
3435
- children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
3436
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
3437
- value: authValues[selectedAuth.name] ?? "",
3438
- placeholder: authPlaceholder(selectedAuth),
3439
- onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
3440
- 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)"
3441
- })]
3442
- })]
3443
- }) : null]
3444
- })
3445
- });
3446
- }
3447
5142
  function EndpointIdentity(arg0) {
3448
- const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
5143
+ const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
5144
+ const t = require_i18n.useBuiltInText();
3449
5145
  const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
3450
5146
  const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
3451
5147
  const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
@@ -3460,61 +5156,40 @@ function EndpointIdentity(arg0) {
3460
5156
  }
3461
5157
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3462
5158
  className: "clarify-openai-endpoint-identity not-prose flex w-full flex-col overflow-hidden rounded-xl border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-xs",
3463
- children: [
3464
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3465
- className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
3466
- children: [
3467
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
3468
- operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
3469
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
3470
- servers,
3471
- selectedKey: selectedServerKey,
3472
- server: selectedServer,
3473
- variables: serverVariables,
3474
- open: serverOpen,
3475
- interactive: serverInteractive,
3476
- directSelect: directServerSelect,
3477
- onSelect: onSelectServer,
3478
- onToggle: onToggleServer
3479
- }),
3480
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
3481
- path,
3482
- copied: copiedUrl,
3483
- onCopy: handleCopyUrl
3484
- }),
3485
- authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3486
- type: "button",
3487
- "aria-expanded": authOpen,
3488
- "aria-label": "Auth",
3489
- onClick: onToggleAuth,
3490
- className: (0, clsx.default)("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)"),
3491
- children: authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.UnlockKeyholeIcon, {
3492
- className: "h-4 w-4",
3493
- "aria-hidden": "true"
3494
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LockKeyholeIcon, {
3495
- className: "h-4 w-4",
3496
- "aria-hidden": "true"
3497
- })
3498
- }) : null
3499
- ]
3500
- }),
3501
- serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
3502
- servers,
3503
- selectedKey: selectedServerKey,
3504
- selectedServer,
3505
- variables: serverVariables,
3506
- onSelectServer,
3507
- onChangeVariable: onChangeServerVariable
3508
- }) : null,
3509
- authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AuthPanel, {
3510
- authOptions,
3511
- selectedAuthName,
3512
- selectedAuth,
3513
- authValues,
3514
- onSelectAuth,
3515
- onChangeAuthValue
3516
- }) : null
3517
- ]
5159
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
5160
+ className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
5161
+ children: [
5162
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
5163
+ operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
5164
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
5165
+ servers,
5166
+ selectedKey: selectedServerKey,
5167
+ server: selectedServer,
5168
+ variables: serverVariables,
5169
+ open: serverOpen,
5170
+ interactive: serverInteractive,
5171
+ directSelect: directServerSelect,
5172
+ onSelect: onSelectServer,
5173
+ onToggle: onToggleServer
5174
+ }),
5175
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
5176
+ path,
5177
+ copied: copiedUrl,
5178
+ onCopy: handleCopyUrl
5179
+ }),
5180
+ onTryRequest ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
5181
+ label: t("openapi.tryRequest"),
5182
+ onClick: onTryRequest
5183
+ }) : null
5184
+ ]
5185
+ }), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
5186
+ servers,
5187
+ selectedKey: selectedServerKey,
5188
+ selectedServer,
5189
+ variables: serverVariables,
5190
+ onSelectServer,
5191
+ onChangeVariable: onChangeServerVariable
5192
+ }) : null]
3518
5193
  });
3519
5194
  }
3520
5195
  function OpenApiOperation(arg0) {
@@ -3527,6 +5202,7 @@ function OpenApiOperation(arg0) {
3527
5202
  const authState = useOperationAuthState(spec, operation);
3528
5203
  const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
3529
5204
  const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
5205
+ const [requestOpen, setRequestOpen] = (0, react.useState)(false);
3530
5206
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
3531
5207
  className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
3532
5208
  "aria-labelledby": id,
@@ -3544,23 +5220,19 @@ function OpenApiOperation(arg0) {
3544
5220
  selectedServer: serverState.selectedServer,
3545
5221
  serverVariables: serverState.serverVariables,
3546
5222
  serverOpen: serverState.serverOpen,
3547
- authOptions: authState.authOptions,
3548
- selectedAuthName: authState.selectedAuthName,
3549
- selectedAuth: authState.selectedAuth,
3550
- authValues: authState.authValues,
3551
- authOpen: authState.authOpen,
3552
5223
  onSelectServer: serverState.onSelectServer,
3553
5224
  onChangeServerVariable: serverState.onChangeServerVariable,
3554
- onToggleServer: () => {
3555
- serverState.onToggleServer();
3556
- authState.closeAuth();
3557
- },
3558
- onToggleAuth: () => {
3559
- authState.onToggleAuth();
3560
- serverState.closeServer();
3561
- },
3562
- onSelectAuth: authState.onSelectAuth,
3563
- onChangeAuthValue: authState.onChangeAuthValue
5225
+ onToggleServer: serverState.onToggleServer,
5226
+ onTryRequest: () => setRequestOpen(true)
5227
+ }),
5228
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestDialog, {
5229
+ open: requestOpen,
5230
+ onClose: () => setRequestOpen(false),
5231
+ spec,
5232
+ path,
5233
+ method,
5234
+ operation,
5235
+ operationSource
3564
5236
  }),
3565
5237
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointRequest, {
3566
5238
  spec,
@@ -3690,6 +5362,12 @@ Object.defineProperty(exports, "OpenApiOperation", {
3690
5362
  return OpenApiOperation;
3691
5363
  }
3692
5364
  });
5365
+ Object.defineProperty(exports, "OpenApiRequestWorkbench", {
5366
+ enumerable: true,
5367
+ get: function() {
5368
+ return OpenApiRequestWorkbench;
5369
+ }
5370
+ });
3693
5371
  Object.defineProperty(exports, "Pre", {
3694
5372
  enumerable: true,
3695
5373
  get: function() {
@@ -3811,4 +5489,4 @@ Object.defineProperty(exports, "primitives_exports", {
3811
5489
  }
3812
5490
  });
3813
5491
 
3814
- //# sourceMappingURL=OpenApiOperation-DbZjxIuj.cjs.map
5492
+ //# sourceMappingURL=OpenApiOperation-D1WNrj5X.cjs.map