@clarify-labs/renderer 0.9.2 → 0.9.4

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 (49) hide show
  1. package/output/{ClarifyShell-DdYRgrfY.cjs → ClarifyShell-7r92MZg9.cjs} +134 -75
  2. package/output/ClarifyShell-7r92MZg9.cjs.map +1 -0
  3. package/output/{ClarifyShell-C38EkErX.js → ClarifyShell-D2P0iZ_m.js} +128 -75
  4. package/output/ClarifyShell-D2P0iZ_m.js.map +1 -0
  5. package/output/{OpenApiOperation-CP_fxT_F.cjs → OpenApiOperation-CyyPlZL6.cjs} +389 -135
  6. package/output/OpenApiOperation-CyyPlZL6.cjs.map +1 -0
  7. package/output/{OpenApiOperation-DIFaYAe5.js → OpenApiOperation-Dhlz3JSx.js} +391 -137
  8. package/output/OpenApiOperation-Dhlz3JSx.js.map +1 -0
  9. package/output/{PageActions-B08cDCzq.cjs → PageActions-CTn2XkPg.cjs} +16 -31
  10. package/output/PageActions-CTn2XkPg.cjs.map +1 -0
  11. package/output/{PageActions-tmnpzi23.js → PageActions-D0PA8Zv5.js} +11 -26
  12. package/output/PageActions-D0PA8Zv5.js.map +1 -0
  13. package/output/app/ContentDiagnostic.d.ts +9 -0
  14. package/output/app/ErrorBoundary.d.ts +0 -2
  15. package/output/app/RenderErrorPanel.d.ts +20 -0
  16. package/output/client.cjs +3 -3
  17. package/output/client.js +3 -3
  18. package/output/components/Tabs.d.ts +16 -0
  19. package/output/components/index.d.ts +1 -0
  20. package/output/core/context.d.ts +1 -0
  21. package/output/core/i18n.d.ts +1 -1
  22. package/output/core/types.d.ts +1 -0
  23. package/output/index.cjs +43 -4
  24. package/output/index.cjs.map +1 -1
  25. package/output/index.d.ts +5 -3
  26. package/output/index.js +42 -5
  27. package/output/index.js.map +1 -1
  28. package/output/openapi/components/EndpointSections.d.ts +2 -0
  29. package/output/openapi/components/ExamplePanels.d.ts +2 -0
  30. package/output/openapi/components/OpenApiOperation.d.ts +6 -0
  31. package/output/openapi/components/SchemaProperties.d.ts +3 -0
  32. package/output/openapi/entry.d.ts +5 -0
  33. package/output/openapi/index.d.ts +2 -2
  34. package/output/preview.cjs +2 -2
  35. package/output/preview.js +2 -2
  36. package/output/{render-6gHfrR9h.js → render-CwSsfrs7.js} +2 -2
  37. package/output/{render-6gHfrR9h.js.map → render-CwSsfrs7.js.map} +1 -1
  38. package/output/{render-Bvf5ZMZb.cjs → render-DXDSIfZ8.cjs} +2 -2
  39. package/output/{render-Bvf5ZMZb.cjs.map → render-DXDSIfZ8.cjs.map} +1 -1
  40. package/output/renderer.css +47 -1
  41. package/output/server.cjs +2 -2
  42. package/output/server.js +2 -2
  43. package/package.json +1 -1
  44. package/output/ClarifyShell-C38EkErX.js.map +0 -1
  45. package/output/ClarifyShell-DdYRgrfY.cjs.map +0 -1
  46. package/output/OpenApiOperation-CP_fxT_F.cjs.map +0 -1
  47. package/output/OpenApiOperation-DIFaYAe5.js.map +0 -1
  48. package/output/PageActions-B08cDCzq.cjs.map +0 -1
  49. package/output/PageActions-tmnpzi23.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-DakpK96I.cjs");
2
- const require_PageActions = require("./PageActions-B08cDCzq.cjs");
2
+ const require_PageActions = require("./PageActions-CTn2XkPg.cjs");
3
3
  const require_remark = require("./remark-Dv3owbSH.cjs");
4
4
  let clsx = require("clsx");
5
5
  clsx = require_chunk.__toESM(clsx, 1);
@@ -906,6 +906,44 @@ function Prose(arg0) {
906
906
  });
907
907
  }
908
908
  //#endregion
909
+ //#region source/components/Tabs.tsx
910
+ function Tabs(arg0) {
911
+ const { items, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
912
+ const [internalIndex, setInternalIndex] = (0, react.useState)(0);
913
+ const resolvedIndex = typeof selectedIndex === "number" ? selectedIndex : internalIndex;
914
+ const indicatorLayoutId = (0, react.useId)();
915
+ const handleChange = (index) => {
916
+ if (typeof selectedIndex !== "number") setInternalIndex(index);
917
+ onChange?.(index);
918
+ };
919
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.TabGroup, {
920
+ selectedIndex: resolvedIndex,
921
+ onChange: handleChange,
922
+ className,
923
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabList, {
924
+ className: (0, clsx.default)("flex flex-wrap items-center gap-6 border-b border-(--clarify-theme-tokens-colors-border) pb-0", listClassName),
925
+ children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Tab, {
926
+ className: ({ selected }) => (0, clsx.default)("clarify-ui-tab relative inline-flex h-10 shrink-0 items-center px-0 py-0 text-sm font-medium transition focus:outline-none", selected && "clarify-ui-tab-active"),
927
+ children: ({ selected }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: item.label }), selected ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
928
+ layoutId: indicatorLayoutId,
929
+ className: "absolute inset-x-0 bottom-0 h-0.5 rounded-full bg-(--clarify-theme-tokens-colors-foreground)",
930
+ transition: {
931
+ type: "tween",
932
+ duration: .16,
933
+ ease: "easeOut"
934
+ }
935
+ }) : null] })
936
+ }, item.id))
937
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, {
938
+ className: (0, clsx.default)("mt-4", panelsClassName),
939
+ children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
940
+ className: "focus:outline-none",
941
+ children: item.panel
942
+ }, item.id))
943
+ })]
944
+ });
945
+ }
946
+ //#endregion
909
947
  //#region source/components/WebFrame.tsx
910
948
  function WebFrame(arg0) {
911
949
  const { src, title = "Embedded content", children, showWindow = true, className, iframeClassName, height = 420, style, ...props } = arg0;
@@ -1265,10 +1303,10 @@ function schemaToType(schema) {
1265
1303
  if (!isRecord(schema)) return void 0;
1266
1304
  if (isReference(schema)) return resolveReferenceName(schema.$ref);
1267
1305
  if (typeof schema.const !== "undefined") return JSON.stringify(schema.const);
1268
- if (Array.isArray(schema.enum)) return schema.enum.map(String).join(" | ");
1306
+ if (Array.isArray(schema.enum)) return "enum";
1269
1307
  const oneOf = schema.oneOf ?? schema.anyOf;
1270
- if (Array.isArray(oneOf)) return oneOf.map(schemaToType).filter(Boolean).join(" | ");
1271
- if (Array.isArray(schema.allOf)) return schema.allOf.map(schemaToType).filter(Boolean).join(" & ");
1308
+ if (Array.isArray(oneOf)) return oneOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" | ");
1309
+ if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
1272
1310
  if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
1273
1311
  const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
1274
1312
  return typeof type === "string" ? [type, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
@@ -2077,19 +2115,36 @@ function firstExampleKeyForResponseContent(content) {
2077
2115
  return getExampleEntries(content?.value)[0]?.key ?? "";
2078
2116
  }
2079
2117
  function useResponseExamplesState(arg0) {
2080
- const { operation, spec, sharedExampleKey, onSelectExampleKey } = arg0;
2081
- const responses = getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0);
2082
- const [selectedStatus, setSelectedStatus] = (0, react.useState)(responses.find(({ status }) => status.startsWith("2"))?.status ?? responses[0]?.status ?? "");
2083
- const selectedResponse = responses.find(({ status }) => status === selectedStatus) ?? responses[0];
2118
+ const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2119
+ const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
2120
+ if (left.status === "default") return -1;
2121
+ if (right.status === "default") return 1;
2122
+ const leftCode = Number(left.status);
2123
+ const rightCode = Number(right.status);
2124
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2125
+ return left.status.localeCompare(right.status);
2126
+ });
2127
+ const [internalSelectedStatus, setInternalSelectedStatus] = (0, react.useState)(orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "");
2128
+ const activeStatus = selectedStatus ?? internalSelectedStatus;
2129
+ const selectedResponse = orderedResponses.find(({ status }) => status === activeStatus) ?? orderedResponses[0];
2084
2130
  const responseContents = getMediaTypeEntries(selectedResponse?.response.content, spec);
2085
- const [selectedMediaType, setSelectedMediaType] = (0, react.useState)(responseContents[0]?.mediaType ?? "");
2086
- const selectedContent = responseContents.find((content) => content.mediaType === selectedMediaType) ?? responseContents[0];
2131
+ const [selection, setSelection] = (0, react.useState)(() => ({
2132
+ status: activeStatus,
2133
+ mediaType: responseContents[0]?.mediaType ?? "",
2134
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2135
+ }));
2136
+ const resolvedSelection = selection.status === activeStatus ? selection : {
2137
+ status: activeStatus,
2138
+ mediaType: responseContents[0]?.mediaType ?? "",
2139
+ exampleKey: firstExampleKeyForResponseContent(responseContents[0])
2140
+ };
2141
+ const selectedContent = responseContents.find((content) => content.mediaType === resolvedSelection.mediaType) ?? responseContents[0];
2087
2142
  const examples = getExampleEntries(selectedContent?.value);
2088
- const [selectedExampleKey, setSelectedExampleKey] = (0, react.useState)(examples[0]?.key ?? "");
2143
+ const selectedExampleKey = examples.some((example) => example.key === resolvedSelection.exampleKey) ? resolvedSelection.exampleKey : examples[0]?.key ?? "";
2089
2144
  const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
2090
2145
  const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
2091
2146
  return {
2092
- responses,
2147
+ responses: orderedResponses,
2093
2148
  selectedResponse,
2094
2149
  responseContents,
2095
2150
  selectedContent,
@@ -2097,29 +2152,42 @@ function useResponseExamplesState(arg0) {
2097
2152
  selectedExample,
2098
2153
  responseCode: stringifyExample(selectedExample?.value),
2099
2154
  onSelectStatus: (value) => {
2100
- const nextContents = getMediaTypeEntries(responses.find(({ status }) => status === value)?.response.content, spec);
2101
- setSelectedStatus(value);
2102
- setSelectedMediaType(nextContents[0]?.mediaType ?? "");
2103
- setSelectedExampleKey(firstExampleKeyForResponseContent(nextContents[0]));
2155
+ const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
2156
+ if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
2157
+ onSelectStatus?.(value);
2158
+ setSelection({
2159
+ status: value,
2160
+ mediaType: nextContents[0]?.mediaType ?? "",
2161
+ exampleKey: firstExampleKeyForResponseContent(nextContents[0])
2162
+ });
2104
2163
  },
2105
2164
  onSelectMediaType: (value) => {
2106
- setSelectedMediaType(value);
2107
- setSelectedExampleKey(firstExampleKeyForResponseContent(responseContents.find((content) => content.mediaType === value)));
2165
+ const nextContent = responseContents.find((content) => content.mediaType === value);
2166
+ setSelection((current) => ({
2167
+ ...current,
2168
+ mediaType: value,
2169
+ exampleKey: firstExampleKeyForResponseContent(nextContent)
2170
+ }));
2108
2171
  },
2109
2172
  onSelectExample: (value) => {
2110
- setSelectedExampleKey(value);
2173
+ setSelection((current) => ({
2174
+ ...current,
2175
+ exampleKey: value
2176
+ }));
2111
2177
  onSelectExampleKey?.(value);
2112
2178
  }
2113
2179
  };
2114
2180
  }
2115
2181
  function ResponseExamplesPanel(arg0) {
2116
- const { operation, spec, sharedExampleKey, onSelectExampleKey } = arg0;
2182
+ const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2117
2183
  const t = require_PageActions.useBuiltInText();
2118
2184
  const state = useResponseExamplesState({
2119
2185
  operation,
2120
2186
  spec,
2121
2187
  sharedExampleKey,
2122
- onSelectExampleKey
2188
+ onSelectExampleKey,
2189
+ selectedStatus,
2190
+ onSelectStatus
2123
2191
  });
2124
2192
  if (!state.selectedResponse || !state.selectedContent || !state.responseCode) return null;
2125
2193
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
@@ -2140,9 +2208,17 @@ function ResponseExamplesPanel(arg0) {
2140
2208
  }
2141
2209
  //#endregion
2142
2210
  //#region source/openapi/components/SchemaProperties.tsx
2211
+ function getEnumDescriptions(schema) {
2212
+ const descriptions = schema["x-enumDescriptions"];
2213
+ if (Array.isArray(descriptions)) return descriptions.map((value) => typeof value === "string" ? value : void 0);
2214
+ if (isRecord(descriptions)) return Array.isArray(schema.enum) ? schema.enum.map((value) => {
2215
+ const description = descriptions[String(value)];
2216
+ return typeof description === "string" ? description : void 0;
2217
+ }) : [];
2218
+ return [];
2219
+ }
2143
2220
  function getSchemaDetails(schema) {
2144
2221
  const details = [
2145
- Array.isArray(schema.enum) ? `enum: ${schema.enum.map(String).join(", ")}` : void 0,
2146
2222
  typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
2147
2223
  typeof schema.default !== "undefined" ? `default: ${String(schema.default)}` : void 0,
2148
2224
  typeof schema.pattern === "string" ? `pattern: ${schema.pattern}` : void 0,
@@ -2155,6 +2231,21 @@ function getSchemaDetails(schema) {
2155
2231
  function getSchemaDescription(schema) {
2156
2232
  return typeof schema.description === "string" ? schema.description : void 0;
2157
2233
  }
2234
+ function getSchemaNodeType(schema) {
2235
+ return schemaToType(schema);
2236
+ }
2237
+ function getEnumChildren(schema, path) {
2238
+ if (!Array.isArray(schema.enum) || schema.enum.length === 0) return [];
2239
+ const descriptions = getEnumDescriptions(schema);
2240
+ return schema.enum.map((value, index) => ({
2241
+ key: `${path || "root"}.enum[${index}]`,
2242
+ name: String(value),
2243
+ kind: "enum",
2244
+ description: descriptions[index],
2245
+ required: false,
2246
+ children: []
2247
+ }));
2248
+ }
2158
2249
  function getComposedBranches(schema) {
2159
2250
  const entries = [];
2160
2251
  for (const key of [
@@ -2172,7 +2263,7 @@ function getComposedBranches(schema) {
2172
2263
  return entries;
2173
2264
  }
2174
2265
  function getSchemaChildren(arg0) {
2175
- const { spec, schema, path, required = [], depth = 0, seen = /* @__PURE__ */ new Set() } = arg0;
2266
+ const { spec, path, schema, depth = 0, required = [], seen = /* @__PURE__ */ new Set(), defaultExpanded } = arg0;
2176
2267
  if (depth > 12) return [];
2177
2268
  if (isReference(schema)) {
2178
2269
  if (seen.has(schema.$ref)) return [];
@@ -2182,7 +2273,8 @@ function getSchemaChildren(arg0) {
2182
2273
  path,
2183
2274
  required,
2184
2275
  depth,
2185
- seen: new Set([...seen, schema.$ref])
2276
+ seen: new Set([...seen, schema.$ref]),
2277
+ defaultExpanded
2186
2278
  });
2187
2279
  }
2188
2280
  if (!isRecord(schema)) return [];
@@ -2191,9 +2283,11 @@ function getSchemaChildren(arg0) {
2191
2283
  schema: schema.items,
2192
2284
  path: `${path}[]`,
2193
2285
  depth: depth + 1,
2194
- seen
2286
+ seen,
2287
+ defaultExpanded
2195
2288
  }) : [];
2196
2289
  const objectRequired = Array.isArray(schema.required) ? schema.required.map(String) : required;
2290
+ const enumChildren = getEnumChildren(schema, path);
2197
2291
  const properties = isRecord(schema.properties) ? schema.properties : {};
2198
2292
  const propertyChildren = Object.entries(properties).map(([name, propertySchema]) => {
2199
2293
  const resolvedProperty = resolveSchema(spec, propertySchema);
@@ -2205,31 +2299,38 @@ function getSchemaChildren(arg0) {
2205
2299
  schema: isArray ? property.items : propertySchema,
2206
2300
  path: isArray ? `${childPath}[]` : childPath,
2207
2301
  depth: depth + 1,
2208
- seen
2302
+ seen,
2303
+ defaultExpanded
2209
2304
  });
2305
+ const hasEnumValues = Array.isArray(property.enum) && property.enum.length > 0;
2210
2306
  return {
2211
2307
  key: childPath,
2212
2308
  name,
2213
- type: schemaToType(propertySchema),
2309
+ kind: "property",
2310
+ type: getSchemaNodeType(property),
2214
2311
  description: getSchemaDescription(property),
2215
2312
  details: getSchemaDetails(property),
2216
2313
  required: objectRequired.includes(name),
2314
+ defaultExpanded: hasEnumValues ? defaultExpanded === true : defaultExpanded ?? depth < 1,
2217
2315
  children
2218
2316
  };
2219
2317
  });
2220
2318
  const additionalPropertyChildren = isRecord(schema.additionalProperties) ? [{
2221
2319
  key: `${path || "root"}.*`,
2222
2320
  name: "*",
2223
- type: schemaToType(schema.additionalProperties),
2321
+ kind: "property",
2322
+ type: getSchemaNodeType(schema.additionalProperties),
2224
2323
  description: getSchemaDescription(schema.additionalProperties),
2225
2324
  details: getSchemaDetails(schema.additionalProperties),
2226
2325
  required: false,
2326
+ defaultExpanded: defaultExpanded ?? depth < 1,
2227
2327
  children: getSchemaChildren({
2228
2328
  spec,
2229
2329
  schema: schema.additionalProperties,
2230
2330
  path: `${path || "root"}.*`,
2231
2331
  depth: depth + 1,
2232
- seen
2332
+ seen,
2333
+ defaultExpanded
2233
2334
  })
2234
2335
  }] : [];
2235
2336
  const composedChildren = getComposedBranches(schema).map(({ label, schema: branchSchema }) => {
@@ -2238,35 +2339,40 @@ function getSchemaChildren(arg0) {
2238
2339
  return {
2239
2340
  key: `${path || "root"}.${label}`,
2240
2341
  name: label,
2241
- type: schemaToType(branchSchema),
2342
+ kind: "property",
2343
+ type: getSchemaNodeType(branch),
2242
2344
  description: branch ? getSchemaDescription(branch) : void 0,
2243
2345
  details: branch ? getSchemaDetails(branch) : void 0,
2244
2346
  required: false,
2347
+ defaultExpanded: defaultExpanded ?? depth < 1,
2245
2348
  children: getSchemaChildren({
2246
2349
  spec,
2247
2350
  schema: branchSchema,
2248
2351
  path: `${path || "root"}.${label}`,
2249
2352
  required: objectRequired,
2250
2353
  depth: depth + 1,
2251
- seen
2354
+ seen,
2355
+ defaultExpanded
2252
2356
  })
2253
2357
  };
2254
2358
  });
2255
2359
  return [
2256
2360
  ...arrayChildren,
2361
+ ...enumChildren,
2257
2362
  ...propertyChildren,
2258
2363
  ...additionalPropertyChildren,
2259
2364
  ...composedChildren
2260
2365
  ];
2261
2366
  }
2262
- function getRootSchemaNode(spec, schema) {
2367
+ function getRootSchemaNode(spec, schema, defaultExpanded) {
2263
2368
  if (isReference(schema)) {
2264
2369
  const resolvedSchema = resolveSchema(spec, schema);
2265
2370
  const resolved = isRecord(resolvedSchema) ? resolvedSchema : {};
2266
2371
  return {
2267
2372
  key: schema.$ref,
2268
2373
  name: resolveReferenceName(schema.$ref),
2269
- type: schemaToType(schema),
2374
+ kind: "property",
2375
+ type: getSchemaNodeType(resolved),
2270
2376
  description: getSchemaDescription(resolved),
2271
2377
  details: getSchemaDetails(resolved),
2272
2378
  required: false,
@@ -2274,7 +2380,8 @@ function getRootSchemaNode(spec, schema) {
2274
2380
  spec,
2275
2381
  schema: resolvedSchema,
2276
2382
  path: resolveReferenceName(schema.$ref),
2277
- seen: new Set([schema.$ref])
2383
+ seen: new Set([schema.$ref]),
2384
+ defaultExpanded
2278
2385
  })
2279
2386
  };
2280
2387
  }
@@ -2282,24 +2389,58 @@ function getRootSchemaNode(spec, schema) {
2282
2389
  return {
2283
2390
  key: "root",
2284
2391
  name: "body",
2285
- type: schemaToType(schema),
2392
+ kind: "property",
2393
+ type: getSchemaNodeType(schema),
2286
2394
  description: getSchemaDescription(schema),
2287
2395
  details: getSchemaDetails(schema),
2288
2396
  required: false,
2289
2397
  children: getSchemaChildren({
2290
2398
  spec,
2291
2399
  schema,
2292
- path: ""
2400
+ path: "",
2401
+ defaultExpanded
2293
2402
  })
2294
2403
  };
2295
2404
  }
2296
- function SchemaNode(arg0) {
2405
+ function EnumValueNode(arg0) {
2297
2406
  const { node, depth = 0 } = arg0;
2407
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
2408
+ className: "clarify-schema-node m-0 px-0 py-2 first:pt-0 last:pb-0",
2409
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2410
+ 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"),
2411
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2412
+ className: "min-w-0 flex-1",
2413
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2414
+ className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
2415
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2416
+ className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
2417
+ children: node.name
2418
+ })
2419
+ }), node.description || node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2420
+ className: "mt-0.5 text-sm/5 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2421
+ children: [node.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2422
+ className: "*:first:mt-0 *:last:mb-0",
2423
+ children: node.description
2424
+ }) : null, node.details ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2425
+ className: "text-xs text-(--clarify-ui-text-faint)",
2426
+ children: node.details
2427
+ }) : null]
2428
+ }) : null]
2429
+ })
2430
+ })
2431
+ });
2432
+ }
2433
+ function SchemaNode(arg0) {
2434
+ const { node, depth = 0, defaultExpanded } = arg0;
2298
2435
  const t = require_PageActions.useBuiltInText();
2299
- const [expanded, setExpanded] = (0, react.useState)(depth < 1);
2436
+ const [expanded, setExpanded] = (0, react.useState)(defaultExpanded ?? depth < 1);
2300
2437
  const hasChildren = node.children.length > 0;
2438
+ if (node.kind === "enum") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EnumValueNode, {
2439
+ node,
2440
+ depth
2441
+ });
2301
2442
  const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
2302
- const fallbackDescription = node.required ? t("openapi.required") : t("openapi.optional");
2443
+ const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
2303
2444
  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");
2304
2445
  const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2305
2446
  className: "min-w-0 flex-1",
@@ -2353,13 +2494,14 @@ function SchemaTree(arg0) {
2353
2494
  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"),
2354
2495
  children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
2355
2496
  node,
2356
- depth
2497
+ depth,
2498
+ defaultExpanded: node.defaultExpanded
2357
2499
  }, node.key))
2358
2500
  });
2359
2501
  }
2360
2502
  function SchemaProperties(arg0) {
2361
- const { title, schema, spec } = arg0;
2362
- const root = getRootSchemaNode(spec, schema);
2503
+ const { title, schema, spec, defaultExpanded } = arg0;
2504
+ const root = getRootSchemaNode(spec, schema, defaultExpanded);
2363
2505
  if (!root || root.children.length === 0) return null;
2364
2506
  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", {
2365
2507
  className: "clarify-schema-properties my-6",
@@ -2369,97 +2511,172 @@ function SchemaProperties(arg0) {
2369
2511
  function ParameterList(arg0) {
2370
2512
  const { title, parameters } = arg0;
2371
2513
  const t = require_PageActions.useBuiltInText();
2372
- if (parameters.length === 0) return null;
2373
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
2514
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: title }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: parameters.length > 0 ? parameters.map((parameter) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
2374
2515
  name: parameter.name ?? t("openapi.parameter"),
2375
2516
  type: [schemaToType(parameter.schema), parameter.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0,
2376
2517
  children: parameter.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2377
2518
  className: "*:first:mt-0 *:last:mb-0",
2378
2519
  children: parameter.description
2379
2520
  }) : t("openapi.operationParameter")
2380
- }, `${parameter.in}-${parameter.name}`)) })] });
2521
+ }, `${parameter.in}-${parameter.name}`)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2522
+ className: "text-sm/5 text-(--clarify-ui-text-soft)",
2523
+ children: t("openapi.none")
2524
+ }) })] });
2381
2525
  }
2382
2526
  function ResponseList(arg0) {
2383
- const { operation, spec } = arg0;
2527
+ const { operation, spec, selectedStatus, onSelectStatus } = arg0;
2384
2528
  const t = require_PageActions.useBuiltInText();
2385
- const responses = getResponseEntries(operation, spec);
2386
- if (responses.length === 0) return null;
2387
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Properties, { children: responses.map(({ status, response }) => {
2388
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Property, {
2389
- name: status,
2390
- type: schemaToType(getJsonLikeContent(response.content, spec)?.value.schema),
2391
- children: response.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2392
- className: "*:first:mt-0 *:last:mb-0",
2393
- children: response.description
2394
- }) : `${t("openapi.response")}.`
2395
- }, status);
2396
- }) })] });
2529
+ const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
2530
+ if (left.status === "default") return -1;
2531
+ if (right.status === "default") return 1;
2532
+ const leftCode = Number(left.status);
2533
+ const rightCode = Number(right.status);
2534
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2535
+ return left.status.localeCompare(right.status);
2536
+ });
2537
+ const activeStatus = selectedStatus ?? orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
2538
+ const selectedIndex = Math.max(0, orderedResponses.findIndex(({ status }) => status === activeStatus));
2539
+ if (orderedResponses.length === 0) return null;
2540
+ const renderResponsePanel = ({ status, response }) => {
2541
+ const responseSchema = getJsonLikeContent(response.content, spec)?.value.schema;
2542
+ const type = schemaToType(responseSchema);
2543
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2544
+ className: "rounded-(--clarify-theme-tokens-radius-xl) p-0",
2545
+ children: [
2546
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2547
+ className: "flex flex-wrap items-center gap-2",
2548
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2549
+ className: "text-sm/5 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
2550
+ children: status
2551
+ }), type ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2552
+ className: "text-xs text-(--clarify-theme-tokens-colors-muted)",
2553
+ children: type
2554
+ }) : null]
2555
+ }),
2556
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2557
+ className: "mt-3 text-sm/6 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
2558
+ children: response.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
2559
+ className: "*:first:mt-0 *:last:mb-0",
2560
+ children: response.description
2561
+ }) : `${t("openapi.response")}.`
2562
+ }),
2563
+ responseSchema && spec ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2564
+ className: "mt-4",
2565
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
2566
+ title: t("openapi.responseBodyProperties"),
2567
+ schema: responseSchema,
2568
+ spec
2569
+ })
2570
+ }) : null
2571
+ ]
2572
+ });
2573
+ };
2574
+ if (orderedResponses.length === 1) {
2575
+ const [{ status, response }] = orderedResponses;
2576
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), renderResponsePanel({
2577
+ status,
2578
+ response
2579
+ })] });
2580
+ }
2581
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.responses") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tabs, {
2582
+ selectedIndex,
2583
+ onChange: (index) => {
2584
+ onSelectStatus?.(orderedResponses[index]?.status ?? "");
2585
+ },
2586
+ items: orderedResponses.map(({ status, response }) => ({
2587
+ id: status,
2588
+ label: status,
2589
+ panel: renderResponsePanel({
2590
+ status,
2591
+ response
2592
+ })
2593
+ })),
2594
+ panelsClassName: "mt-4"
2595
+ })] });
2397
2596
  }
2398
2597
  //#endregion
2399
2598
  //#region source/openapi/components/EndpointSections.tsx
2400
2599
  function EndpointRequest(arg0) {
2401
2600
  const { spec, path, method, description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
2402
2601
  const t = require_PageActions.useBuiltInText();
2403
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2602
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: description }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2404
2603
  className: "relative mt-6",
2405
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Col, { children: [
2406
- description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: description }) : null,
2407
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2408
- title: t("openapi.pathParameters"),
2409
- parameters: groupedParameters.path
2410
- }),
2411
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2412
- title: t("openapi.queryParameters"),
2413
- parameters: groupedParameters.query
2414
- }),
2415
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2416
- title: t("openapi.headers"),
2417
- parameters: groupedParameters.header
2418
- }),
2419
- requestBody && requestContents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2420
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.requestBody") }),
2421
- typeof requestBody.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
2422
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
2423
- title: t("openapi.bodyProperties"),
2424
- schema: requestSchema,
2425
- spec
2426
- })
2427
- ] }) : null
2428
- ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2604
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2605
+ className: "w-full",
2606
+ children: [
2607
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2608
+ title: t("openapi.pathParameters"),
2609
+ parameters: groupedParameters.path
2610
+ }),
2611
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2612
+ title: t("openapi.queryParameters"),
2613
+ parameters: groupedParameters.query
2614
+ }),
2615
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
2616
+ title: t("openapi.headers"),
2617
+ parameters: groupedParameters.header
2618
+ }),
2619
+ requestBody && requestContents.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
2620
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.requestBody") }),
2621
+ typeof requestBody.description === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, { children: requestBody.description }) : null,
2622
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaProperties, {
2623
+ title: t("openapi.bodyProperties"),
2624
+ schema: requestSchema,
2625
+ spec
2626
+ })
2627
+ ] }) : null
2628
+ ]
2629
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2429
2630
  sticky: true,
2430
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestExamplesPanel, {
2431
- spec,
2432
- path,
2433
- method,
2434
- parameters,
2435
- requestContents,
2436
- selectedMediaType: selectedRequestMediaType,
2437
- onSelectMediaType: onSelectRequestMediaType,
2438
- selectedServer,
2439
- serverVariables,
2440
- auth,
2441
- sharedExampleKey,
2442
- onSelectExampleKey
2631
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2632
+ className: "w-full",
2633
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestExamplesPanel, {
2634
+ spec,
2635
+ path,
2636
+ method,
2637
+ parameters,
2638
+ requestContents,
2639
+ selectedMediaType: selectedRequestMediaType,
2640
+ onSelectMediaType: onSelectRequestMediaType,
2641
+ selectedServer,
2642
+ serverVariables,
2643
+ auth,
2644
+ sharedExampleKey,
2645
+ onSelectExampleKey
2646
+ })
2443
2647
  })
2444
2648
  })]
2445
- });
2649
+ })] });
2446
2650
  }
2447
2651
  function EndpointResponse(arg0) {
2448
- const { spec, operation, sharedExampleKey, onSelectExampleKey } = arg0;
2449
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2450
- className: "relative mt-6",
2451
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
2452
- operation,
2453
- spec
2454
- }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2455
- sticky: true,
2456
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
2457
- operation,
2458
- spec,
2459
- sharedExampleKey,
2460
- onSelectExampleKey
2461
- })
2462
- })]
2652
+ const { spec, operation, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
2653
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2654
+ className: "mt-6",
2655
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
2656
+ className: "relative",
2657
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2658
+ className: "w-full",
2659
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
2660
+ operation,
2661
+ spec,
2662
+ selectedStatus,
2663
+ onSelectStatus
2664
+ })
2665
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, {
2666
+ sticky: true,
2667
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2668
+ className: "w-full",
2669
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseExamplesPanel, {
2670
+ operation,
2671
+ spec,
2672
+ sharedExampleKey,
2673
+ onSelectExampleKey,
2674
+ selectedStatus,
2675
+ onSelectStatus
2676
+ })
2677
+ })
2678
+ })]
2679
+ })
2463
2680
  });
2464
2681
  }
2465
2682
  //#endregion
@@ -2554,26 +2771,30 @@ function EndpointMethodBadge(arg0) {
2554
2771
  });
2555
2772
  }
2556
2773
  function EndpointPath(arg0) {
2557
- const { path } = arg0;
2558
- const segments = path.split("/").filter(Boolean);
2559
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2560
- className: "flex min-w-0 flex-1 items-center overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
2561
- children: segments.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2562
- className: "text-(--clarify-ui-text-faint)",
2563
- children: "/"
2564
- }), segments.map((segment, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2565
- className: "flex items-center",
2566
- children: [index > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2567
- className: "text-(--clarify-ui-text-faint)",
2568
- children: "/"
2569
- }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2570
- className: "font-bold text-(--clarify-theme-tokens-colors-foreground)",
2571
- children: segment
2572
- })]
2573
- }, `${segment}-${index}`))] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2574
- className: "font-bold text-(--clarify-theme-tokens-colors-foreground)",
2575
- children: "/"
2576
- })
2774
+ const { path, copied = false, onCopy } = arg0;
2775
+ const t = require_PageActions.useBuiltInText();
2776
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2777
+ className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
2778
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2779
+ className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
2780
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2781
+ className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
2782
+ children: path || "/"
2783
+ })
2784
+ }), onCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2785
+ type: "button",
2786
+ "aria-label": copied ? t("actions.copied") : t("actions.copy"),
2787
+ title: copied ? t("actions.copied") : t("actions.copy"),
2788
+ onClick: onCopy,
2789
+ 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)", copied && "border-emerald-400/70 bg-emerald-50 text-emerald-700 dark:bg-emerald-400/10 dark:text-emerald-200"),
2790
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
2791
+ className: "h-3.5 w-3.5",
2792
+ "aria-hidden": "true"
2793
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
2794
+ className: "h-3.5 w-3.5",
2795
+ "aria-hidden": "true"
2796
+ })
2797
+ }) : null]
2577
2798
  });
2578
2799
  }
2579
2800
  function InlineListbox(arg0) {
@@ -2621,6 +2842,22 @@ function InlineListbox(arg0) {
2621
2842
  function getServerPreviewUrl(server, variables) {
2622
2843
  return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
2623
2844
  }
2845
+ function getFullEndpointUrl(server, variables, path) {
2846
+ const base = getServerPreviewUrl(server, variables);
2847
+ if (!base) return path;
2848
+ return `${base.endsWith("/") ? base.slice(0, -1) : base}${path.startsWith("/") ? path : `/${path}`}`;
2849
+ }
2850
+ function getDefaultResponseStatus(operation, spec) {
2851
+ const orderedResponses = [...getResponseEntries(operation, spec).filter(({ response }) => getMediaTypeEntries(response.content, spec).length > 0)].sort((left, right) => {
2852
+ if (left.status === "default") return -1;
2853
+ if (right.status === "default") return 1;
2854
+ const leftCode = Number(left.status);
2855
+ const rightCode = Number(right.status);
2856
+ if (!Number.isNaN(leftCode) && !Number.isNaN(rightCode)) return leftCode - rightCode;
2857
+ return left.status.localeCompare(right.status);
2858
+ });
2859
+ return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
2860
+ }
2624
2861
  function ServerUrlValue(arg0) {
2625
2862
  const { server, variables, open, interactive, onToggle } = arg0;
2626
2863
  const url = getServerPreviewUrl(server, variables);
@@ -2770,6 +3007,16 @@ function AuthPanel(arg0) {
2770
3007
  function EndpointIdentity(arg0) {
2771
3008
  const { method, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, authOptions, selectedAuthName, selectedAuth, authValues, authOpen, onSelectServer, onChangeServerVariable, onToggleServer, onToggleAuth, onSelectAuth, onChangeAuthValue } = arg0;
2772
3009
  const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
3010
+ const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
3011
+ const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
3012
+ (0, react.useEffect)(() => {
3013
+ if (!copiedUrl) return void 0;
3014
+ const timeout = window.setTimeout(() => setCopiedUrl(false), 1200);
3015
+ return () => window.clearTimeout(timeout);
3016
+ }, [copiedUrl]);
3017
+ async function handleCopyUrl() {
3018
+ if (await require_PageActions.copyTextToClipboard(fullUrl)) setCopiedUrl(true);
3019
+ }
2773
3020
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2774
3021
  className: "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",
2775
3022
  children: [
@@ -2784,7 +3031,11 @@ function EndpointIdentity(arg0) {
2784
3031
  interactive: serverInteractive,
2785
3032
  onToggle: onToggleServer
2786
3033
  }),
2787
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, { path }),
3034
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
3035
+ path,
3036
+ copied: copiedUrl,
3037
+ onCopy: handleCopyUrl
3038
+ }),
2788
3039
  authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2789
3040
  type: "button",
2790
3041
  "aria-expanded": authOpen,
@@ -2829,6 +3080,7 @@ function OpenApiOperation(arg0) {
2829
3080
  const serverState = useOperationServerState(spec, operation, path);
2830
3081
  const authState = useOperationAuthState(spec, operation);
2831
3082
  const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
3083
+ const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
2832
3084
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
2833
3085
  className: "clarify-api-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
2834
3086
  "aria-labelledby": id,
@@ -2885,7 +3137,9 @@ function OpenApiOperation(arg0) {
2885
3137
  spec,
2886
3138
  operation,
2887
3139
  sharedExampleKey: linkedExampleKey,
2888
- onSelectExampleKey: setLinkedExampleKey
3140
+ onSelectExampleKey: setLinkedExampleKey,
3141
+ selectedStatus: selectedResponseStatus,
3142
+ onSelectStatus: setSelectedResponseStatus
2889
3143
  })
2890
3144
  ]
2891
3145
  });
@@ -3072,4 +3326,4 @@ Object.defineProperty(exports, "primitives_exports", {
3072
3326
  }
3073
3327
  });
3074
3328
 
3075
- //# sourceMappingURL=OpenApiOperation-CP_fxT_F.cjs.map
3329
+ //# sourceMappingURL=OpenApiOperation-CyyPlZL6.cjs.map