@clarify-labs/renderer 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/{ClarifyShell-C6li72Ce.cjs → ClarifyShell-BAjq876Z.cjs} +113 -90
- package/output/ClarifyShell-BAjq876Z.cjs.map +1 -0
- package/output/{ClarifyShell-1LuBliwt.js → ClarifyShell-GoSXvgMg.js} +114 -91
- package/output/ClarifyShell-GoSXvgMg.js.map +1 -0
- package/output/{MermaidViewer-B6-BMCJG.cjs → MermaidViewer-BZ8ghcFP.cjs} +2 -2
- package/output/{MermaidViewer-B6-BMCJG.cjs.map → MermaidViewer-BZ8ghcFP.cjs.map} +1 -1
- package/output/{MermaidViewer-dXsomvM7.js → MermaidViewer-CkIxyqtf.js} +2 -2
- package/output/{MermaidViewer-dXsomvM7.js.map → MermaidViewer-CkIxyqtf.js.map} +1 -1
- package/output/{OpenApiOperation-DgrqzeiS.js → OpenApiOperation-C2vJztWZ.js} +1983 -365
- package/output/OpenApiOperation-C2vJztWZ.js.map +1 -0
- package/output/{OpenApiOperation-B52IWlKb.cjs → OpenApiOperation-D-5uE5v7.cjs} +2009 -361
- package/output/OpenApiOperation-D-5uE5v7.cjs.map +1 -0
- package/output/{PageActions-BjB6PYmL.cjs → PageActions-DJRXlGhz.cjs} +532 -358
- package/output/PageActions-DJRXlGhz.cjs.map +1 -0
- package/output/{PageActions-D7K9LDGf.js → PageActions-bugd7GZh.js} +535 -361
- package/output/PageActions-bugd7GZh.js.map +1 -0
- package/output/{SearchDialog-CIPvXMT3.cjs → SearchDialog-8AdCRp6K.cjs} +3 -3
- package/output/{SearchDialog-CIPvXMT3.cjs.map → SearchDialog-8AdCRp6K.cjs.map} +1 -1
- package/output/{SearchDialog-CxYLjRi5.js → SearchDialog-CBJjDs_9.js} +3 -3
- package/output/{SearchDialog-CxYLjRi5.js.map → SearchDialog-CBJjDs_9.js.map} +1 -1
- package/output/app/ContentDiagnostic.d.ts +2 -1
- package/output/app/PageFooter.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/components/AccordionGroup.d.ts +7 -0
- package/output/components/Collapse.d.ts +2 -0
- package/output/components/FileTree.d.ts +10 -0
- package/output/components/Image.d.ts +6 -0
- package/output/components/Steps.d.ts +12 -0
- package/output/components/Tabs.d.ts +12 -5
- package/output/components/Tooltip.d.ts +8 -0
- package/output/components/index.d.ts +10 -1
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +37 -19
- package/output/{i18n-DnqZHFT7.js → i18n-BPrC45nD.js} +102 -2
- package/output/i18n-BPrC45nD.js.map +1 -0
- package/output/{i18n-b4iTLeia.cjs → i18n-wXINKKV0.cjs} +102 -2
- package/output/i18n-wXINKKV0.cjs.map +1 -0
- package/output/index.cjs +38 -8
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +8 -7
- package/output/index.js +34 -9
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +11 -1
- package/output/mdx/primitives.d.ts +4 -2
- package/output/openapi/components/CodeDisplay.d.ts +1 -0
- package/output/openapi/components/EndpointMethodBadge.d.ts +6 -0
- package/output/openapi/components/EndpointSections.d.ts +2 -2
- package/output/openapi/components/ExamplePanels.d.ts +2 -2
- package/output/openapi/components/InlineListbox.d.ts +31 -0
- package/output/openapi/components/OpenApiAuthPanel.d.ts +12 -0
- package/output/openapi/components/OpenApiOperation.d.ts +1 -9
- package/output/openapi/components/OpenApiOperation.state.d.ts +4 -2
- package/output/openapi/components/OpenApiRequest.d.ts +18 -0
- package/output/openapi/components/OpenApiRequestFields.d.ts +25 -0
- package/output/openapi/components/OpenApiResponseViewer.d.ts +8 -0
- package/output/openapi/components/SendRequestButton.d.ts +9 -0
- package/output/openapi/components/helpers.d.ts +6 -1
- package/output/openapi/components/useOpenApiRequestState.d.ts +41 -0
- package/output/openapi/entry.d.ts +2 -0
- package/output/openapi/index.d.ts +2 -2
- package/output/openapi/lib/api-exchange-code.d.ts +8 -0
- package/output/openapi/lib/api-exchange.d.ts +30 -0
- package/output/openapi/lib/api-request.d.ts +24 -0
- package/output/openapi/lib/request-code.d.ts +2 -2
- package/output/openapi/lib/request-parameters.d.ts +5 -0
- package/output/openapi/store.d.ts +10 -0
- package/output/openapi/types.d.ts +4 -0
- package/output/preview.cjs +37 -27
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +37 -27
- package/output/preview.js.map +1 -1
- package/output/{render-Di5B6Zc0.cjs → render-FICIzeXz.cjs} +2 -2
- package/output/{render-Di5B6Zc0.cjs.map → render-FICIzeXz.cjs.map} +1 -1
- package/output/{render-DKj24Jqw.js → render-XQiw_48i.js} +2 -2
- package/output/{render-DKj24Jqw.js.map → render-XQiw_48i.js.map} +1 -1
- package/output/renderer.css +1310 -318
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/output/theme/ThemeEditor.d.ts +8 -4
- package/output/theme/variables.d.ts +8 -4
- package/package.json +1 -1
- package/output/ClarifyShell-1LuBliwt.js.map +0 -1
- package/output/ClarifyShell-C6li72Ce.cjs.map +0 -1
- package/output/OpenApiOperation-B52IWlKb.cjs.map +0 -1
- package/output/OpenApiOperation-DgrqzeiS.js.map +0 -1
- package/output/PageActions-BjB6PYmL.cjs.map +0 -1
- package/output/PageActions-D7K9LDGf.js.map +0 -1
- package/output/i18n-DnqZHFT7.js.map +0 -1
- package/output/i18n-b4iTLeia.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-
|
|
3
|
-
const require_PageActions = require("./PageActions-
|
|
2
|
+
const require_i18n = require("./i18n-wXINKKV0.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-DJRXlGhz.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,32 @@ 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
|
+
//#region source/components/AccordionGroup.tsx
|
|
22
|
+
function AccordionGroup(arg0) {
|
|
23
|
+
const { children, multiple = false, className, ...props } = arg0;
|
|
24
|
+
const childArray = react.Children.toArray(children);
|
|
25
|
+
const [openIndex, setOpenIndex] = (0, react.useState)(() => {
|
|
26
|
+
const defaultIndex = childArray.findIndex((child) => (0, react.isValidElement)(child) && child.props.defaultOpen);
|
|
27
|
+
return defaultIndex === -1 ? null : defaultIndex;
|
|
28
|
+
});
|
|
29
|
+
const items = childArray.map((child, index) => {
|
|
30
|
+
if (!(0, react.isValidElement)(child)) return child;
|
|
31
|
+
if (multiple) return child;
|
|
32
|
+
return (0, react.cloneElement)(child, {
|
|
33
|
+
open: openIndex === index,
|
|
34
|
+
onOpenChange: (open) => {
|
|
35
|
+
child.props.onOpenChange?.(open);
|
|
36
|
+
setOpenIndex(open ? index : null);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
41
|
+
className: (0, clsx.default)("clarify-accordion-group my-6 divide-y divide-(--clarify-theme-tokens-colors-border) overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) [&_.clarify-collapse]:my-0 [&_.clarify-collapse]:rounded-none [&_.clarify-collapse]:border-0", className),
|
|
42
|
+
...props,
|
|
43
|
+
children: items
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
21
47
|
//#region source/components/LocalizedLink.tsx
|
|
22
48
|
function useLocalizedHref(href) {
|
|
23
49
|
return require_PageActions.localizeHref(href, require_i18n.useConfig(), require_i18n.useLocale());
|
|
@@ -37,15 +63,15 @@ function LocalizedLink(arg0) {
|
|
|
37
63
|
//#endregion
|
|
38
64
|
//#region source/components/Button.tsx
|
|
39
65
|
var buttonVariantStyles = {
|
|
40
|
-
primary: "
|
|
41
|
-
secondary: "
|
|
42
|
-
filled: "
|
|
43
|
-
outline: "
|
|
66
|
+
primary: "bg-(--clarify-theme-tokens-colors-foreground) px-4 text-(--clarify-theme-tokens-colors-background) shadow-sm hover:-translate-y-px hover:shadow-md active:translate-y-0 active:shadow-sm dark:bg-(--clarify-theme-tokens-colors-primary) dark:text-zinc-950",
|
|
67
|
+
secondary: "bg-(--clarify-theme-tokens-colors-code-background) px-4 text-(--clarify-ui-text-soft) ring-1 ring-inset ring-(--clarify-theme-tokens-colors-border) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)",
|
|
68
|
+
filled: "bg-(--clarify-theme-tokens-colors-primary) px-4 text-white shadow-sm hover:-translate-y-px hover:shadow-md active:translate-y-0 dark:text-zinc-950",
|
|
69
|
+
outline: "px-4 text-(--clarify-ui-text-soft) ring-1 ring-inset ring-(--clarify-theme-tokens-colors-border) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)",
|
|
44
70
|
text: "text-(--clarify-theme-tokens-colors-primary) hover:opacity-80 dark:text-(--clarify-theme-tokens-colors-primary) dark:hover:opacity-80"
|
|
45
71
|
};
|
|
46
72
|
function Button(arg0) {
|
|
47
73
|
const { variant = "primary", className, children, arrow, ...props } = arg0;
|
|
48
|
-
const classes = (0, clsx.default)("clarify-button not-prose inline-flex w-fit max-w-full items-center justify-center gap-1 overflow-hidden align-middle text-sm
|
|
74
|
+
const classes = (0, clsx.default)("clarify-button not-prose inline-flex w-fit max-w-full items-center justify-center gap-1.5 overflow-hidden align-middle text-sm font-semibold whitespace-nowrap no-underline transition duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) focus-visible:ring-offset-2 focus-visible:ring-offset-(--clarify-theme-tokens-colors-background)", variant === "text" ? "h-auto rounded-sm" : "h-9 rounded-(--clarify-theme-tokens-radius-lg)", buttonVariantStyles[variant], className);
|
|
49
75
|
const arrowIcon = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowRight, {
|
|
50
76
|
"aria-hidden": "true",
|
|
51
77
|
className: (0, clsx.default)("h-4 w-4 shrink-0", variant === "text" && "relative top-px", arrow === "left" && "-ml-0.5 rotate-180", arrow === "right" && "-mr-0.5")
|
|
@@ -73,37 +99,43 @@ function Button(arg0) {
|
|
|
73
99
|
//#region source/components/Callout.tsx
|
|
74
100
|
var calloutStyles = {
|
|
75
101
|
info: {
|
|
76
|
-
container: "border-sky-500/20 bg-sky-50/
|
|
102
|
+
container: "border-sky-500/20 bg-sky-50/30 dark:border-sky-400/20 dark:bg-sky-400/5",
|
|
103
|
+
iconContainer: "bg-sky-100 ring-sky-500/15 dark:bg-sky-400/10 dark:ring-sky-400/20",
|
|
77
104
|
icon: "text-sky-600 dark:text-sky-400",
|
|
78
105
|
title: "text-sky-900 dark:text-sky-100",
|
|
79
106
|
Icon: lucide_react.Info
|
|
80
107
|
},
|
|
81
108
|
note: {
|
|
82
|
-
container: "border-zinc-500/20 bg-zinc-50
|
|
109
|
+
container: "border-zinc-500/20 bg-zinc-50/50 dark:border-white/10 dark:bg-white/5",
|
|
110
|
+
iconContainer: "bg-zinc-200/70 ring-zinc-500/15 dark:bg-white/10 dark:ring-white/10",
|
|
83
111
|
icon: "text-zinc-500 dark:text-zinc-400",
|
|
84
112
|
title: "text-zinc-900 dark:text-white",
|
|
85
113
|
Icon: lucide_react.Info
|
|
86
114
|
},
|
|
87
115
|
tip: {
|
|
88
|
-
container: "border-emerald-500/20 bg-emerald-50/
|
|
116
|
+
container: "border-emerald-500/20 bg-emerald-50/30 dark:border-emerald-400/20 dark:bg-emerald-400/5",
|
|
117
|
+
iconContainer: "bg-emerald-100 ring-emerald-500/15 dark:bg-emerald-400/10 dark:ring-emerald-400/20",
|
|
89
118
|
icon: "text-emerald-600 dark:text-emerald-400",
|
|
90
119
|
title: "text-emerald-900 dark:text-emerald-100",
|
|
91
120
|
Icon: lucide_react.Lightbulb
|
|
92
121
|
},
|
|
93
122
|
warning: {
|
|
94
|
-
container: "border-amber-500/20 bg-amber-50/
|
|
123
|
+
container: "border-amber-500/20 bg-amber-50/40 dark:border-amber-400/20 dark:bg-amber-400/5",
|
|
124
|
+
iconContainer: "bg-amber-100 ring-amber-500/15 dark:bg-amber-400/10 dark:ring-amber-400/20",
|
|
95
125
|
icon: "text-amber-600 dark:text-amber-400",
|
|
96
126
|
title: "text-amber-900 dark:text-amber-100",
|
|
97
127
|
Icon: lucide_react.AlertTriangle
|
|
98
128
|
},
|
|
99
129
|
danger: {
|
|
100
|
-
container: "border-rose-500/20 bg-rose-50/
|
|
130
|
+
container: "border-rose-500/20 bg-rose-50/40 dark:border-rose-400/20 dark:bg-rose-400/5",
|
|
131
|
+
iconContainer: "bg-rose-100 ring-rose-500/15 dark:bg-rose-400/10 dark:ring-rose-400/20",
|
|
101
132
|
icon: "text-rose-600 dark:text-rose-400",
|
|
102
133
|
title: "text-rose-900 dark:text-rose-100",
|
|
103
134
|
Icon: lucide_react.XCircle
|
|
104
135
|
},
|
|
105
136
|
success: {
|
|
106
|
-
container: "border-emerald-500/20 bg-emerald-50/
|
|
137
|
+
container: "border-emerald-500/20 bg-emerald-50/30 dark:border-emerald-400/20 dark:bg-emerald-400/5",
|
|
138
|
+
iconContainer: "bg-emerald-100 ring-emerald-500/15 dark:bg-emerald-400/10 dark:ring-emerald-400/20",
|
|
107
139
|
icon: "text-emerald-600 dark:text-emerald-400",
|
|
108
140
|
title: "text-emerald-900 dark:text-emerald-100",
|
|
109
141
|
Icon: lucide_react.CheckCircle2
|
|
@@ -124,15 +156,18 @@ function Callout(arg0) {
|
|
|
124
156
|
const Icon = style.Icon;
|
|
125
157
|
const resolvedTitle = title === void 0 ? t(defaultTitleKeys[type]) : title;
|
|
126
158
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
127
|
-
className: (0, clsx.default)("clarify-callout my-6 flex gap-3 rounded-(--clarify-theme-tokens-radius-
|
|
159
|
+
className: (0, clsx.default)("clarify-callout my-6 flex gap-3.5 rounded-(--clarify-theme-tokens-radius-lg) border p-4 text-sm/6 text-(--clarify-ui-text-soft)", style.container, className),
|
|
128
160
|
...props,
|
|
129
|
-
children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
130
|
-
className: (0, clsx.default)("
|
|
131
|
-
|
|
161
|
+
children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
162
|
+
className: (0, clsx.default)("flex size-7 flex-none items-center justify-center rounded-(--clarify-theme-tokens-radius-md) ring-1 ring-inset", style.iconContainer),
|
|
163
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
164
|
+
className: (0, clsx.default)("size-4", style.icon),
|
|
165
|
+
"aria-hidden": "true"
|
|
166
|
+
})
|
|
132
167
|
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
133
168
|
className: "min-w-0 flex-1 *:first:mt-0 *:last:mb-0",
|
|
134
169
|
children: [resolvedTitle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
135
|
-
className: (0, clsx.default)("mb-1 font-semibold", style.title),
|
|
170
|
+
className: (0, clsx.default)("mb-1.5 font-semibold", style.title),
|
|
136
171
|
children: resolvedTitle
|
|
137
172
|
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
138
173
|
className: "*:first:mt-0 *:last:mb-0",
|
|
@@ -151,9 +186,9 @@ function CardIcon(arg0) {
|
|
|
151
186
|
const Icon = require_PageActions.lucideIconRegistry[iconName];
|
|
152
187
|
if (!Icon) return null;
|
|
153
188
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
154
|
-
className: "flex size-
|
|
189
|
+
className: "flex size-8 flex-none items-center justify-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-ui-accent-background) text-(--clarify-ui-accent-text) ring-1 ring-inset ring-(--clarify-ui-accent-border) transition-colors group-hover:bg-(--clarify-theme-tokens-colors-primary) group-hover:text-white dark:group-hover:text-zinc-950",
|
|
155
190
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
156
|
-
className: "size-
|
|
191
|
+
className: "size-4",
|
|
157
192
|
"aria-hidden": "true"
|
|
158
193
|
})
|
|
159
194
|
});
|
|
@@ -167,7 +202,7 @@ var cardGroupColumnStyles = {
|
|
|
167
202
|
function CardGroup(arg0) {
|
|
168
203
|
const { children, cols = 2, className } = arg0;
|
|
169
204
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
170
|
-
className: (0, clsx.default)("not-prose my-
|
|
205
|
+
className: (0, clsx.default)("not-prose my-8 grid gap-3", cardGroupColumnStyles[cols], className),
|
|
171
206
|
children
|
|
172
207
|
});
|
|
173
208
|
}
|
|
@@ -177,11 +212,17 @@ function Card(arg0) {
|
|
|
177
212
|
className: "flex items-start gap-4",
|
|
178
213
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardIcon, { name: icon }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
179
214
|
className: "min-w-0 flex-1",
|
|
180
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
181
|
-
className: "
|
|
182
|
-
children:
|
|
215
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
216
|
+
className: "flex items-start justify-between gap-3",
|
|
217
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
218
|
+
className: "m-0 text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
219
|
+
children: title
|
|
220
|
+
}), href ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUpRight, {
|
|
221
|
+
className: "mt-1 size-3.5 shrink-0 text-(--clarify-ui-text-faint) transition group-hover:-translate-y-0.5 group-hover:translate-x-0.5 group-hover:text-(--clarify-ui-accent-text)",
|
|
222
|
+
"aria-hidden": "true"
|
|
223
|
+
}) : null]
|
|
183
224
|
}), children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
184
|
-
className: "mt-
|
|
225
|
+
className: "mt-1.5 text-sm/6 text-(--clarify-ui-text-soft) *:m-0",
|
|
185
226
|
children
|
|
186
227
|
}) : null]
|
|
187
228
|
})]
|
|
@@ -189,7 +230,7 @@ function Card(arg0) {
|
|
|
189
230
|
className: "absolute inset-0 rounded-(--clarify-theme-tokens-radius-xl)",
|
|
190
231
|
"aria-hidden": "true"
|
|
191
232
|
}) : null] });
|
|
192
|
-
const classes = (0, clsx.default)("group relative block rounded-(--clarify-theme-tokens-radius-
|
|
233
|
+
const classes = (0, clsx.default)("group relative block rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-4 transition duration-200", href && "hover:-translate-y-0.5 hover:border-(--clarify-ui-accent-border) hover:shadow-md hover:shadow-zinc-900/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) focus-visible:ring-offset-2 dark:hover:shadow-none", className);
|
|
193
234
|
if (!href) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
194
235
|
className: classes,
|
|
195
236
|
children: content
|
|
@@ -203,7 +244,7 @@ function Card(arg0) {
|
|
|
203
244
|
}
|
|
204
245
|
//#endregion
|
|
205
246
|
//#region source/components/Mermaid.tsx
|
|
206
|
-
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-
|
|
247
|
+
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-BZ8ghcFP.cjs")));
|
|
207
248
|
var mermaidModulePromise;
|
|
208
249
|
async function loadMermaid() {
|
|
209
250
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -329,6 +370,12 @@ function getNodeText(node) {
|
|
|
329
370
|
if ((0, react.isValidElement)(node)) return getNodeText(node.props.children);
|
|
330
371
|
return "";
|
|
331
372
|
}
|
|
373
|
+
function getCodeTitle(node) {
|
|
374
|
+
if (!(0, react.isValidElement)(node)) return void 0;
|
|
375
|
+
const { title, children } = node.props;
|
|
376
|
+
if (title) return title;
|
|
377
|
+
return react.Children.toArray(children).map(getCodeTitle).find(Boolean);
|
|
378
|
+
}
|
|
332
379
|
function getCodeLanguage(node) {
|
|
333
380
|
if (!(0, react.isValidElement)(node)) return void 0;
|
|
334
381
|
const { className, language, children } = node.props;
|
|
@@ -337,7 +384,14 @@ function getCodeLanguage(node) {
|
|
|
337
384
|
if (languageClass) return languageClass.slice(9);
|
|
338
385
|
return react.Children.toArray(children).map(getCodeLanguage).find(Boolean);
|
|
339
386
|
}
|
|
340
|
-
function
|
|
387
|
+
function getCodePanelTitle(node, fallbackTitle) {
|
|
388
|
+
return getPanelTitle({
|
|
389
|
+
title: getCodeTitle(node),
|
|
390
|
+
language: getCodeLanguage(node),
|
|
391
|
+
fallbackTitle
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
function CopyButton$1(arg0) {
|
|
341
395
|
const { code } = arg0;
|
|
342
396
|
const t = require_i18n.useBuiltInText();
|
|
343
397
|
const [copyCount, setCopyCount] = (0, react.useState)(0);
|
|
@@ -398,7 +452,7 @@ function CodePanel(arg0) {
|
|
|
398
452
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
399
453
|
className: "clarify-code-pre overflow-x-auto p-4 text-xs text-(--clarify-code-text)",
|
|
400
454
|
children
|
|
401
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { code: copyText })]
|
|
455
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton$1, { code: copyText })]
|
|
402
456
|
})]
|
|
403
457
|
});
|
|
404
458
|
}
|
|
@@ -417,10 +471,7 @@ function CodeGroupHeader(arg0) {
|
|
|
417
471
|
className: "clarify-code-tabs -mr-2 -mb-px flex gap-0 text-xs font-medium",
|
|
418
472
|
children: react.Children.map(children, (child, childIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Tab, {
|
|
419
473
|
className: (0, clsx.default)("clarify-code-tab relative border-b border-transparent px-2 py-3 transition-colors hover:bg-(--clarify-code-control-background-hover) data-selected:not-data-focus:outline-hidden", childIndex === selectedIndex ? "text-(--clarify-code-accent-text)" : "text-(--clarify-code-control-text) hover:text-(--clarify-code-text)"),
|
|
420
|
-
children: [
|
|
421
|
-
...(0, react.isValidElement)(child) ? child.props : {},
|
|
422
|
-
fallbackTitle: t("actions.code")
|
|
423
|
-
}), childIndex === selectedIndex ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
|
|
474
|
+
children: [getCodePanelTitle(child, t("actions.code")), childIndex === selectedIndex ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(framer_motion.motion.span, {
|
|
424
475
|
layoutId: indicatorLayoutId,
|
|
425
476
|
className: "absolute inset-x-2 bottom-0 h-0.5 rounded-full bg-(--clarify-code-accent-text)",
|
|
426
477
|
transition: {
|
|
@@ -494,10 +545,7 @@ var CodeGroupContext = (0, react.createContext)(false);
|
|
|
494
545
|
function CodeGroup(arg0) {
|
|
495
546
|
const { children, title, ...props } = arg0;
|
|
496
547
|
const t = require_i18n.useBuiltInText();
|
|
497
|
-
const tabGroupProps = useTabGroupProps(react.Children.map(children, (child) =>
|
|
498
|
-
...(0, react.isValidElement)(child) ? child.props : {},
|
|
499
|
-
fallbackTitle: t("actions.code")
|
|
500
|
-
})) ?? []);
|
|
548
|
+
const tabGroupProps = useTabGroupProps(react.Children.map(children, (child) => getCodePanelTitle(child, t("actions.code"))) ?? []);
|
|
501
549
|
const hasTabs = react.Children.count(children) > 1;
|
|
502
550
|
const containerClassName = "clarify-code-group my-6 overflow-hidden rounded-2xl bg-(--clarify-code-background) shadow-md ring-1 ring-(--clarify-code-border)";
|
|
503
551
|
const header = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeGroupHeader, {
|
|
@@ -553,8 +601,9 @@ function Pre(arg0) {
|
|
|
553
601
|
//#endregion
|
|
554
602
|
//#region source/components/Collapse.tsx
|
|
555
603
|
function Collapse(arg0) {
|
|
556
|
-
const { children, title, summary, defaultOpen = false, className, ...props } = arg0;
|
|
557
|
-
const [
|
|
604
|
+
const { children, title, summary, defaultOpen = false, open: controlledOpen, onOpenChange, className, ...props } = arg0;
|
|
605
|
+
const [uncontrolledOpen, setUncontrolledOpen] = (0, react.useState)(defaultOpen);
|
|
606
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
558
607
|
const contentRef = (0, react.useRef)(null);
|
|
559
608
|
const [maxHeight, setMaxHeight] = (0, react.useState)("0px");
|
|
560
609
|
const summaryLabel = title ?? summary ?? "Details";
|
|
@@ -564,16 +613,20 @@ function Collapse(arg0) {
|
|
|
564
613
|
setMaxHeight(open ? `${contentRef.current.scrollHeight}px` : "0px");
|
|
565
614
|
}, [open, children]);
|
|
566
615
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
567
|
-
className: (0, clsx.default)("clarify-collapse my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
616
|
+
className: (0, clsx.default)("clarify-collapse my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) transition-colors", open && "border-(--clarify-ui-accent-border)", className),
|
|
568
617
|
...props,
|
|
569
618
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
570
619
|
type: "button",
|
|
571
|
-
className: "flex w-full cursor-pointer items-center justify-between gap-3 px-4 py-
|
|
620
|
+
className: "flex min-h-11 w-full cursor-pointer items-center justify-between gap-3 px-4 py-2.5 text-left text-sm font-semibold text-(--clarify-theme-tokens-colors-foreground) transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
572
621
|
"aria-expanded": open,
|
|
573
622
|
"aria-controls": contentId,
|
|
574
|
-
onClick: () =>
|
|
623
|
+
onClick: () => {
|
|
624
|
+
const nextOpen = !open;
|
|
625
|
+
if (controlledOpen === void 0) setUncontrolledOpen(nextOpen);
|
|
626
|
+
onOpenChange?.(nextOpen);
|
|
627
|
+
},
|
|
575
628
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: summaryLabel }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
|
|
576
|
-
className: (0, clsx.default)("
|
|
629
|
+
className: (0, clsx.default)("size-4 rounded-full text-(--clarify-ui-text-faint) transition duration-200", open && "rotate-180"),
|
|
577
630
|
"aria-hidden": "true"
|
|
578
631
|
})]
|
|
579
632
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -585,7 +638,7 @@ function Collapse(arg0) {
|
|
|
585
638
|
},
|
|
586
639
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
587
640
|
ref: contentRef,
|
|
588
|
-
className: (0, clsx.default)("px-4 py-4 text-sm/6 text-(--clarify-
|
|
641
|
+
className: (0, clsx.default)("px-4 py-4 text-sm/6 text-(--clarify-ui-text-soft) transition-opacity duration-200 ease-out *:first:mt-0 *:last:mb-0", open ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-1"),
|
|
589
642
|
children
|
|
590
643
|
})
|
|
591
644
|
})]
|
|
@@ -661,6 +714,55 @@ function Feedback() {
|
|
|
661
714
|
});
|
|
662
715
|
}
|
|
663
716
|
//#endregion
|
|
717
|
+
//#region source/components/FileTree.tsx
|
|
718
|
+
function FileTree(arg0) {
|
|
719
|
+
const { children, className, ...props } = arg0;
|
|
720
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
721
|
+
className: (0, clsx.default)("clarify-file-tree not-prose my-6 overflow-x-auto rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-4 py-3 font-mono text-[13px]/6 text-(--clarify-ui-text-soft)", className),
|
|
722
|
+
...props,
|
|
723
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
724
|
+
role: "tree",
|
|
725
|
+
className: "m-0 min-w-max list-none p-0",
|
|
726
|
+
children
|
|
727
|
+
})
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
function FileTreeItem(arg0) {
|
|
731
|
+
const { name, description, type, children, className, ...props } = arg0;
|
|
732
|
+
const isFolder = type === "folder" || children != null;
|
|
733
|
+
const FolderIcon = children ? lucide_react.FolderOpen : lucide_react.Folder;
|
|
734
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
735
|
+
role: "treeitem",
|
|
736
|
+
"aria-expanded": isFolder ? children != null : void 0,
|
|
737
|
+
className: (0, clsx.default)("clarify-file-tree-item m-0 p-0", className),
|
|
738
|
+
...props,
|
|
739
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
740
|
+
className: "flex min-h-6 items-center gap-2 whitespace-nowrap",
|
|
741
|
+
children: [
|
|
742
|
+
isFolder ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FolderIcon, {
|
|
743
|
+
className: "size-4 flex-none text-(--clarify-ui-accent-text)",
|
|
744
|
+
"aria-hidden": "true"
|
|
745
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.File, {
|
|
746
|
+
className: "size-4 flex-none text-(--clarify-ui-text-faint)",
|
|
747
|
+
"aria-hidden": "true"
|
|
748
|
+
}),
|
|
749
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
750
|
+
className: "font-medium text-(--clarify-theme-tokens-colors-foreground)",
|
|
751
|
+
children: name
|
|
752
|
+
}),
|
|
753
|
+
description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
754
|
+
className: "font-sans text-xs text-(--clarify-ui-text-faint)",
|
|
755
|
+
children: description
|
|
756
|
+
}) : null
|
|
757
|
+
]
|
|
758
|
+
}), children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
759
|
+
role: "group",
|
|
760
|
+
className: "m-0 ml-2.5 list-none border-l border-(--clarify-theme-tokens-colors-border) pl-4",
|
|
761
|
+
children
|
|
762
|
+
}) : null]
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
//#endregion
|
|
664
766
|
//#region source/components/Tag.tsx
|
|
665
767
|
var tagVariantStyles = {
|
|
666
768
|
small: "",
|
|
@@ -867,10 +969,50 @@ function Prose(arg0) {
|
|
|
867
969
|
});
|
|
868
970
|
}
|
|
869
971
|
//#endregion
|
|
972
|
+
//#region source/components/Steps.tsx
|
|
973
|
+
function Steps(arg0) {
|
|
974
|
+
const { children, className, ...props } = arg0;
|
|
975
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
|
|
976
|
+
className: (0, clsx.default)("clarify-steps my-8 ml-3 list-none border-l-2 border-(--clarify-theme-tokens-colors-border) p-0", className),
|
|
977
|
+
...props,
|
|
978
|
+
children
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
function Step(arg0) {
|
|
982
|
+
const { children, title, className, ...props } = arg0;
|
|
983
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
984
|
+
className: (0, clsx.default)("clarify-step relative m-0 pb-10 pl-9 last:pb-0", className),
|
|
985
|
+
...props,
|
|
986
|
+
children: [
|
|
987
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
988
|
+
className: "absolute top-0 -left-3.5 flex size-7 items-center justify-center rounded-full bg-(--clarify-theme-tokens-colors-primary) text-xs font-semibold text-white shadow-[0_0_0_4px_var(--clarify-theme-tokens-colors-background)] before:content-[counter(list-item)] dark:text-zinc-950",
|
|
989
|
+
"aria-hidden": "true"
|
|
990
|
+
}),
|
|
991
|
+
title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
992
|
+
className: "m-0 pt-0.5 text-base font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
993
|
+
children: title
|
|
994
|
+
}) : null,
|
|
995
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
996
|
+
className: (0, clsx.default)("text-sm/6 text-(--clarify-ui-text-soft) *:last:mb-0", title && "mt-2.5", !title && "*:first:mt-0"),
|
|
997
|
+
children
|
|
998
|
+
})
|
|
999
|
+
]
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
//#endregion
|
|
870
1003
|
//#region source/components/Tabs.tsx
|
|
1004
|
+
function TabItem(_props) {
|
|
1005
|
+
return null;
|
|
1006
|
+
}
|
|
871
1007
|
function Tabs(arg0) {
|
|
872
|
-
const { items, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
|
|
873
|
-
const
|
|
1008
|
+
const { items, children, defaultValue, selectedIndex, onChange, className, listClassName, panelsClassName } = arg0;
|
|
1009
|
+
const childItems = react.Children.toArray(children).filter((child) => (0, react.isValidElement)(child) && child.type === TabItem).map((child, index) => ({
|
|
1010
|
+
id: child.props.value ?? `tab-${index}`,
|
|
1011
|
+
label: child.props.title,
|
|
1012
|
+
panel: child.props.children
|
|
1013
|
+
}));
|
|
1014
|
+
const resolvedItems = items ?? childItems;
|
|
1015
|
+
const [internalIndex, setInternalIndex] = (0, react.useState)(defaultValue ? Math.max(0, resolvedItems.findIndex((item) => item.id === defaultValue)) : 0);
|
|
874
1016
|
const resolvedIndex = typeof selectedIndex === "number" ? selectedIndex : internalIndex;
|
|
875
1017
|
const indicatorLayoutId = (0, react.useId)();
|
|
876
1018
|
const handleChange = (index) => {
|
|
@@ -880,32 +1022,93 @@ function Tabs(arg0) {
|
|
|
880
1022
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.TabGroup, {
|
|
881
1023
|
selectedIndex: resolvedIndex,
|
|
882
1024
|
onChange: handleChange,
|
|
883
|
-
className,
|
|
1025
|
+
className: (0, clsx.default)("clarify-tabs my-6", className),
|
|
884
1026
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabList, {
|
|
885
|
-
className: (0, clsx.default)("
|
|
886
|
-
children:
|
|
887
|
-
className: ({ selected }) => (0, clsx.default)("clarify-content-tab clarify-ui-tab relative inline-flex h-
|
|
1027
|
+
className: (0, clsx.default)("flex max-w-full items-stretch gap-1 overflow-x-auto border-b border-(--clarify-theme-tokens-colors-border)", listClassName),
|
|
1028
|
+
children: resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Tab, {
|
|
1029
|
+
className: ({ selected }) => (0, clsx.default)("clarify-content-tab clarify-ui-tab relative my-1 inline-flex h-9 shrink-0 items-center rounded-(--clarify-theme-tokens-radius-md) px-2.5 transition focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)", selected && "clarify-ui-tab-active"),
|
|
888
1030
|
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, {
|
|
889
1031
|
layoutId: indicatorLayoutId,
|
|
890
|
-
className: "absolute inset-x-2 bottom-
|
|
1032
|
+
className: "absolute inset-x-2.5 -bottom-1 h-0.5 rounded-full bg-(--clarify-ui-tab-indicator)",
|
|
891
1033
|
transition: {
|
|
892
|
-
type: "
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
mass: .7
|
|
1034
|
+
type: "tween",
|
|
1035
|
+
duration: .16,
|
|
1036
|
+
ease: "easeOut"
|
|
896
1037
|
}
|
|
897
1038
|
}) : null] })
|
|
898
1039
|
}, item.id))
|
|
899
1040
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanels, {
|
|
900
|
-
className: (0, clsx.default)("mt-
|
|
901
|
-
children:
|
|
902
|
-
className: "focus:outline-none",
|
|
1041
|
+
className: (0, clsx.default)("mt-5", panelsClassName),
|
|
1042
|
+
children: resolvedItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.TabPanel, {
|
|
1043
|
+
className: "focus:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
903
1044
|
children: item.panel
|
|
904
1045
|
}, item.id))
|
|
905
1046
|
})]
|
|
906
1047
|
});
|
|
907
1048
|
}
|
|
908
1049
|
//#endregion
|
|
1050
|
+
//#region source/components/Tooltip.tsx
|
|
1051
|
+
function Tooltip(arg0) {
|
|
1052
|
+
const { content, children, side = "top", className, triggerClassName, ...props } = arg0;
|
|
1053
|
+
const contentId = (0, react.useId)();
|
|
1054
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1055
|
+
const triggerRef = (0, react.useRef)(null);
|
|
1056
|
+
const tooltipRef = (0, react.useRef)(null);
|
|
1057
|
+
const [position, setPosition] = (0, react.useState)();
|
|
1058
|
+
(0, react.useEffect)(() => {
|
|
1059
|
+
if (!open) return;
|
|
1060
|
+
function updatePosition() {
|
|
1061
|
+
const bounds = triggerRef.current?.getBoundingClientRect();
|
|
1062
|
+
if (!bounds) return;
|
|
1063
|
+
setPosition({
|
|
1064
|
+
left: bounds.left + bounds.width / 2,
|
|
1065
|
+
top: side === "top" ? bounds.top - 8 : bounds.bottom + 8
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
updatePosition();
|
|
1069
|
+
window.addEventListener("resize", updatePosition);
|
|
1070
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1071
|
+
return () => {
|
|
1072
|
+
window.removeEventListener("resize", updatePosition);
|
|
1073
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1074
|
+
};
|
|
1075
|
+
}, [open, side]);
|
|
1076
|
+
(0, react.useEffect)(() => {
|
|
1077
|
+
const tooltip = tooltipRef.current;
|
|
1078
|
+
if (!tooltip || typeof tooltip.showPopover !== "function") return;
|
|
1079
|
+
if (open) tooltip.showPopover();
|
|
1080
|
+
else if (tooltip.matches(":popover-open")) tooltip.hidePopover();
|
|
1081
|
+
}, [open]);
|
|
1082
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1083
|
+
className: (0, clsx.default)("clarify-tooltip group inline-flex align-baseline", className),
|
|
1084
|
+
onMouseEnter: () => setOpen(true),
|
|
1085
|
+
onMouseLeave: () => setOpen(false),
|
|
1086
|
+
...props,
|
|
1087
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1088
|
+
type: "button",
|
|
1089
|
+
ref: triggerRef,
|
|
1090
|
+
"aria-describedby": contentId,
|
|
1091
|
+
"aria-expanded": open,
|
|
1092
|
+
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),
|
|
1093
|
+
onFocus: () => setOpen(true),
|
|
1094
|
+
onBlur: () => setOpen(false),
|
|
1095
|
+
onClick: () => setOpen(true),
|
|
1096
|
+
onKeyDown: (event) => {
|
|
1097
|
+
if (event.key === "Escape") setOpen(false);
|
|
1098
|
+
},
|
|
1099
|
+
children
|
|
1100
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1101
|
+
ref: tooltipRef,
|
|
1102
|
+
id: contentId,
|
|
1103
|
+
role: "tooltip",
|
|
1104
|
+
popover: "manual",
|
|
1105
|
+
style: position,
|
|
1106
|
+
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"),
|
|
1107
|
+
children: content
|
|
1108
|
+
})]
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
//#endregion
|
|
909
1112
|
//#region source/components/WebFrame.tsx
|
|
910
1113
|
function WebFrame(arg0) {
|
|
911
1114
|
const { src, title = "Embedded content", children, showWindow = true, className, iframeClassName, height = 420, style, ...props } = arg0;
|
|
@@ -928,53 +1131,122 @@ function WebFrame(arg0) {
|
|
|
928
1131
|
children
|
|
929
1132
|
});
|
|
930
1133
|
if (!showWindow) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
931
|
-
className: (0, clsx.default)("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
1134
|
+
className: (0, clsx.default)("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-lg shadow-zinc-900/5 dark:shadow-none", className),
|
|
932
1135
|
children: frame
|
|
933
1136
|
});
|
|
934
1137
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
935
|
-
className: (0, clsx.default)("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-
|
|
1138
|
+
className: (0, clsx.default)("clarify-web-frame not-prose my-10 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) shadow-lg shadow-zinc-900/5 dark:shadow-none", className),
|
|
936
1139
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
937
|
-
className: "
|
|
1140
|
+
className: "grid h-10 grid-cols-[1fr_minmax(0,2fr)_1fr] items-center gap-3 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-code-background) px-3",
|
|
938
1141
|
children: [
|
|
939
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
940
|
-
className: "
|
|
941
|
-
"aria-hidden": "true"
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
948
|
-
className: "size-3 rounded-full bg-green-400",
|
|
949
|
-
"aria-hidden": "true"
|
|
1142
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1143
|
+
className: "flex items-center gap-1.5",
|
|
1144
|
+
"aria-hidden": "true",
|
|
1145
|
+
children: [
|
|
1146
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "size-2.5 rounded-full bg-red-400/80" }),
|
|
1147
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "size-2.5 rounded-full bg-amber-400/80" }),
|
|
1148
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "size-2.5 rounded-full bg-emerald-400/80" })
|
|
1149
|
+
]
|
|
950
1150
|
}),
|
|
951
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
952
|
-
className: "
|
|
1151
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1152
|
+
className: "truncate rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-3 py-1 text-center text-xs text-(--clarify-ui-text-faint)",
|
|
953
1153
|
children: title
|
|
954
|
-
})
|
|
1154
|
+
}),
|
|
1155
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { "aria-hidden": "true" })
|
|
955
1156
|
]
|
|
956
1157
|
}), frame]
|
|
957
1158
|
});
|
|
958
1159
|
}
|
|
959
1160
|
//#endregion
|
|
1161
|
+
//#region source/components/Image.tsx
|
|
1162
|
+
function Image(arg0) {
|
|
1163
|
+
const { src, alt = "", caption, zoom = false, className, ...props } = arg0;
|
|
1164
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1165
|
+
const image = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
1166
|
+
...props,
|
|
1167
|
+
src,
|
|
1168
|
+
alt,
|
|
1169
|
+
className: (0, clsx.default)("block h-auto max-w-full object-contain", className)
|
|
1170
|
+
});
|
|
1171
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("figure", {
|
|
1172
|
+
className: "clarify-figure not-prose mx-auto my-8 w-fit max-w-full",
|
|
1173
|
+
children: [
|
|
1174
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1175
|
+
className: "group relative w-fit max-w-full overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background)",
|
|
1176
|
+
children: zoom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1177
|
+
type: "button",
|
|
1178
|
+
className: "block max-w-full cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
1179
|
+
"aria-label": `Enlarge image: ${alt}`,
|
|
1180
|
+
onClick: () => setOpen(true),
|
|
1181
|
+
children: [image, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1182
|
+
className: "absolute right-3 bottom-3 grid size-8 place-items-center rounded-md border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background)/90 text-(--clarify-ui-text-soft) opacity-0 shadow-sm transition group-hover:opacity-100 group-focus-within:opacity-100",
|
|
1183
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Maximize2, {
|
|
1184
|
+
className: "size-4",
|
|
1185
|
+
"aria-hidden": "true"
|
|
1186
|
+
})
|
|
1187
|
+
})]
|
|
1188
|
+
}) : image
|
|
1189
|
+
}),
|
|
1190
|
+
caption ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("figcaption", {
|
|
1191
|
+
className: "mt-2 text-center text-xs/5 text-(--clarify-ui-text-faint)",
|
|
1192
|
+
children: caption
|
|
1193
|
+
}) : null,
|
|
1194
|
+
zoom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Dialog, {
|
|
1195
|
+
open,
|
|
1196
|
+
onClose: setOpen,
|
|
1197
|
+
className: "relative z-50",
|
|
1198
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogBackdrop, { className: "fixed inset-0 bg-black/75 backdrop-blur-sm" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1199
|
+
className: "fixed inset-0 flex items-center justify-center p-4 sm:p-8",
|
|
1200
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.DialogPanel, {
|
|
1201
|
+
className: "relative max-h-full max-w-full overflow-auto rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-theme-tokens-colors-background) p-2 shadow-2xl",
|
|
1202
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
1203
|
+
src,
|
|
1204
|
+
alt,
|
|
1205
|
+
className: "max-h-[calc(100dvh-5rem)] max-w-[calc(100vw-5rem)] object-contain"
|
|
1206
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1207
|
+
type: "button",
|
|
1208
|
+
className: "absolute top-4 right-4 grid size-9 place-items-center rounded-md border border-white/20 bg-black/65 text-white transition hover:bg-black/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white",
|
|
1209
|
+
"aria-label": "Close image preview",
|
|
1210
|
+
onClick: () => setOpen(false),
|
|
1211
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
|
|
1212
|
+
className: "size-4",
|
|
1213
|
+
"aria-hidden": "true"
|
|
1214
|
+
})
|
|
1215
|
+
})]
|
|
1216
|
+
})
|
|
1217
|
+
})]
|
|
1218
|
+
}) : null
|
|
1219
|
+
]
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
//#endregion
|
|
960
1223
|
//#region source/mdx/primitives.tsx
|
|
961
1224
|
var primitives_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
1225
|
+
AccordionGroup: () => AccordionGroup,
|
|
962
1226
|
Button: () => Button,
|
|
963
1227
|
Callout: () => Callout,
|
|
964
1228
|
Card: () => Card,
|
|
965
1229
|
CardGroup: () => CardGroup,
|
|
966
1230
|
CodeGroup: () => CodeGroup,
|
|
967
1231
|
Col: () => Col,
|
|
1232
|
+
FileTree: () => FileTree,
|
|
1233
|
+
FileTreeItem: () => FileTreeItem,
|
|
968
1234
|
Note: () => Note,
|
|
969
1235
|
Properties: () => Properties,
|
|
970
1236
|
Property: () => Property,
|
|
971
1237
|
Row: () => Row,
|
|
1238
|
+
Step: () => Step,
|
|
1239
|
+
Steps: () => Steps,
|
|
1240
|
+
Tab: () => TabItem,
|
|
1241
|
+
Tabs: () => Tabs,
|
|
1242
|
+
Tooltip: () => Tooltip,
|
|
972
1243
|
WebFrame: () => WebFrame,
|
|
973
1244
|
a: () => a,
|
|
974
1245
|
code: () => code,
|
|
975
1246
|
h1: () => h1,
|
|
976
1247
|
h2: () => h2,
|
|
977
1248
|
h3: () => h3,
|
|
1249
|
+
img: () => img,
|
|
978
1250
|
pre: () => pre,
|
|
979
1251
|
table: () => table,
|
|
980
1252
|
wrapper: () => wrapper
|
|
@@ -1019,6 +1291,7 @@ function h1(arg0) {
|
|
|
1019
1291
|
}
|
|
1020
1292
|
var code = Code;
|
|
1021
1293
|
var pre = Pre;
|
|
1294
|
+
var img = Image;
|
|
1022
1295
|
function h2(props) {
|
|
1023
1296
|
return (0, react.createElement)(Heading, {
|
|
1024
1297
|
level: 2,
|
|
@@ -1034,8 +1307,8 @@ function h3(props) {
|
|
|
1034
1307
|
function Note(arg0) {
|
|
1035
1308
|
const { children } = arg0;
|
|
1036
1309
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1037
|
-
className: "clarify-note my-6 flex gap-
|
|
1038
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Info, { className: "mt-1
|
|
1310
|
+
className: "clarify-note my-6 flex gap-3 rounded-r-(--clarify-theme-tokens-radius-lg) border-l-2 border-(--clarify-theme-tokens-colors-primary) bg-(--clarify-ui-subtle-background) px-4 py-3 text-sm/6 text-(--clarify-ui-text-soft) [--tw-prose-links-hover:var(--clarify-ui-accent-text)] [--tw-prose-links:var(--clarify-theme-tokens-colors-foreground)]",
|
|
1311
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Info, { className: "mt-1 size-4 flex-none stroke-(--clarify-ui-accent-text)" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1039
1312
|
className: "*:first:mt-0 *:last:mb-0",
|
|
1040
1313
|
children
|
|
1041
1314
|
})]
|
|
@@ -1409,6 +1682,23 @@ function listOpenApiOperations(spec) {
|
|
|
1409
1682
|
return [...listOperationsFromPathItems(paths, "path", spec), ...isRecord(webhooks) ? listOperationsFromPathItems(webhooks, "webhook", spec) : []];
|
|
1410
1683
|
}
|
|
1411
1684
|
//#endregion
|
|
1685
|
+
//#region source/openapi/components/EndpointMethodBadge.tsx
|
|
1686
|
+
var endpointMethodStyleVars = {
|
|
1687
|
+
GET: "bg-(--clarify-http-method-get-background) text-(--clarify-http-method-get-text)",
|
|
1688
|
+
POST: "bg-(--clarify-http-method-post-background) text-(--clarify-http-method-post-text)",
|
|
1689
|
+
PUT: "bg-(--clarify-http-method-put-background) text-(--clarify-http-method-put-text)",
|
|
1690
|
+
PATCH: "bg-(--clarify-http-method-patch-background) text-(--clarify-http-method-patch-text)",
|
|
1691
|
+
DELETE: "bg-(--clarify-http-method-delete-background) text-(--clarify-http-method-delete-text)",
|
|
1692
|
+
WEBHOOK: "bg-(--clarify-http-method-webhook-background) text-(--clarify-http-method-webhook-text)"
|
|
1693
|
+
};
|
|
1694
|
+
function EndpointMethodBadge(arg0) {
|
|
1695
|
+
const { method } = arg0;
|
|
1696
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1697
|
+
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)"),
|
|
1698
|
+
children: method
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
//#endregion
|
|
1412
1702
|
//#region source/components/HighlightedCode.tsx
|
|
1413
1703
|
var cssVariablesTheme = (0, shiki.createCssVariablesTheme)();
|
|
1414
1704
|
function HighlightedCode(arg0) {
|
|
@@ -1466,6 +1756,15 @@ var snippetControlCharacters = [
|
|
|
1466
1756
|
}
|
|
1467
1757
|
];
|
|
1468
1758
|
var snippetGenerator = (0, _scalar_snippetz.snippetz)();
|
|
1759
|
+
function getAuthPlaceholder(name) {
|
|
1760
|
+
return `YOUR_${name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").toUpperCase() || "CREDENTIAL"}`;
|
|
1761
|
+
}
|
|
1762
|
+
function redactAuth(auth = []) {
|
|
1763
|
+
return auth.map((input) => ({
|
|
1764
|
+
...input,
|
|
1765
|
+
value: getAuthPlaceholder(input.name)
|
|
1766
|
+
}));
|
|
1767
|
+
}
|
|
1469
1768
|
function protectSnippetControlCharacters(value) {
|
|
1470
1769
|
if (typeof value === "string") return snippetControlCharacters.reduce((result, item) => result.replaceAll(item.character, item.placeholder), value);
|
|
1471
1770
|
if (Array.isArray(value)) return value.map(protectSnippetControlCharacters);
|
|
@@ -1484,7 +1783,7 @@ function getDefaultServer(spec) {
|
|
|
1484
1783
|
function getDefaultWebhookServer() {
|
|
1485
1784
|
return { url: "https://webhook.example.com" };
|
|
1486
1785
|
}
|
|
1487
|
-
function expandServerUrl(server, serverVariables = {}) {
|
|
1786
|
+
function expandServerUrl$1(server, serverVariables = {}) {
|
|
1488
1787
|
return (server.url ?? "https://api.example.com").replace(/\{([^}]+)\}/g, (_, name) => {
|
|
1489
1788
|
const fallback = server.variables?.[name]?.default ?? name;
|
|
1490
1789
|
return serverVariables[name] ?? fallback;
|
|
@@ -1492,16 +1791,16 @@ function expandServerUrl(server, serverVariables = {}) {
|
|
|
1492
1791
|
}
|
|
1493
1792
|
function buildOperationUrl(input) {
|
|
1494
1793
|
const defaultServer = input.operationSource === "webhook" ? getDefaultWebhookServer() : getDefaultServer(input.spec);
|
|
1495
|
-
return joinPath(expandServerUrl(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1794
|
+
return joinPath(expandServerUrl$1(input.server ?? defaultServer, input.serverVariables), input.path);
|
|
1496
1795
|
}
|
|
1497
|
-
function getQueryString(parameters, auth) {
|
|
1796
|
+
function getQueryString(parameters, auth = []) {
|
|
1498
1797
|
const queryString = parameters.filter((parameter) => parameter.in === "query" && parameter.name).map((parameter) => ({
|
|
1499
1798
|
name: parameter.name,
|
|
1500
1799
|
value: encodeUrlPlaceholders(`{${parameter.name}}`)
|
|
1501
1800
|
}));
|
|
1502
|
-
if (
|
|
1503
|
-
name:
|
|
1504
|
-
value:
|
|
1801
|
+
for (const input of auth) if (input.scheme.type === "apiKey" && input.scheme.in === "query" && input.scheme.name) queryString.push({
|
|
1802
|
+
name: input.scheme.name,
|
|
1803
|
+
value: input.value
|
|
1505
1804
|
});
|
|
1506
1805
|
return queryString;
|
|
1507
1806
|
}
|
|
@@ -1549,15 +1848,14 @@ function getAuthorizationValue(auth) {
|
|
|
1549
1848
|
if (auth.scheme.type === "http" && auth.scheme.scheme?.toLowerCase() === "basic") return `Basic ${auth.value}`;
|
|
1550
1849
|
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
1551
1850
|
}
|
|
1552
|
-
function
|
|
1553
|
-
if (!auth) return {};
|
|
1851
|
+
function getAuthHeader(auth) {
|
|
1554
1852
|
if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) return { [auth.scheme.name]: auth.value };
|
|
1555
1853
|
const authorization = getAuthorizationValue(auth);
|
|
1556
1854
|
return authorization ? { Authorization: authorization } : {};
|
|
1557
1855
|
}
|
|
1558
|
-
function getRequestHeaders(requestContent, auth) {
|
|
1856
|
+
function getRequestHeaders(requestContent, auth = []) {
|
|
1559
1857
|
return {
|
|
1560
|
-
...
|
|
1858
|
+
...Object.assign({}, ...auth.map(getAuthHeader)),
|
|
1561
1859
|
Accept: "application/json",
|
|
1562
1860
|
...requestContent ? { "Content-Type": requestContent.mediaType } : {}
|
|
1563
1861
|
};
|
|
@@ -1875,6 +2173,10 @@ var requestSnippetOptions = [
|
|
|
1875
2173
|
}
|
|
1876
2174
|
];
|
|
1877
2175
|
function buildRequestCodeExamples(input) {
|
|
2176
|
+
const redactedInput = {
|
|
2177
|
+
...input,
|
|
2178
|
+
auth: redactAuth(input.auth)
|
|
2179
|
+
};
|
|
1878
2180
|
return requestSnippetOptions.map((option) => ({
|
|
1879
2181
|
key: `${option.languageKey}:${option.client}`,
|
|
1880
2182
|
title: option.title,
|
|
@@ -1882,7 +2184,7 @@ function buildRequestCodeExamples(input) {
|
|
|
1882
2184
|
languageKey: option.languageKey,
|
|
1883
2185
|
clientKey: option.client,
|
|
1884
2186
|
clientTitle: option.clientTitle,
|
|
1885
|
-
code: buildSnippet(
|
|
2187
|
+
code: buildSnippet(redactedInput, option)
|
|
1886
2188
|
}));
|
|
1887
2189
|
}
|
|
1888
2190
|
//#endregion
|
|
@@ -1894,7 +2196,7 @@ function SelectControl(arg0) {
|
|
|
1894
2196
|
label: option
|
|
1895
2197
|
} : option);
|
|
1896
2198
|
const selectedOption = normalizedOptions.find((option) => option.value === value) ?? normalizedOptions[0];
|
|
1897
|
-
const wrapperClassName = compact ? "clarify-
|
|
2199
|
+
const wrapperClassName = compact ? "clarify-openai-select relative min-w-0 text-xs" : "clarify-openai-select relative shrink-0 text-xs";
|
|
1898
2200
|
const buttonSizeClassName = compact ? "w-full min-w-0 max-w-32" : "min-w-28 max-w-48";
|
|
1899
2201
|
if (normalizedOptions.length <= 1) return null;
|
|
1900
2202
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
@@ -1904,7 +2206,7 @@ function SelectControl(arg0) {
|
|
|
1904
2206
|
className: wrapperClassName,
|
|
1905
2207
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
1906
2208
|
"aria-label": label,
|
|
1907
|
-
className: `clarify-
|
|
2209
|
+
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)`,
|
|
1908
2210
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1909
2211
|
className: "flex min-w-0 items-center gap-1.5 overflow-hidden",
|
|
1910
2212
|
children: [icon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -1920,10 +2222,10 @@ function SelectControl(arg0) {
|
|
|
1920
2222
|
})]
|
|
1921
2223
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
|
|
1922
2224
|
anchor: "bottom end",
|
|
1923
|
-
className: "clarify-
|
|
2225
|
+
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",
|
|
1924
2226
|
children: normalizedOptions.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxOption, {
|
|
1925
2227
|
value: option.value,
|
|
1926
|
-
className: "clarify-
|
|
2228
|
+
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)",
|
|
1927
2229
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: option.label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
1928
2230
|
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
1929
2231
|
"aria-hidden": "true"
|
|
@@ -1972,31 +2274,36 @@ function ExampleMetaValue(arg0) {
|
|
|
1972
2274
|
});
|
|
1973
2275
|
}
|
|
1974
2276
|
function CodeToolbar(arg0) {
|
|
1975
|
-
const { code, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2277
|
+
const { code, leadingControls, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
1976
2278
|
const t = require_i18n.useBuiltInText();
|
|
2279
|
+
const inlineControls = Boolean(leadingControls);
|
|
1977
2280
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1978
|
-
className:
|
|
2281
|
+
className: `clarify-openai-code-toolbar flex items-center gap-2 px-4 pt-3${inlineControls ? " clarify-openai-code-toolbar-inline" : ""}`,
|
|
1979
2282
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1980
|
-
className:
|
|
1981
|
-
children: [
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2283
|
+
className: `clarify-openai-code-toolbar-controls flex min-w-0 flex-1 items-center gap-2${inlineControls ? " flex-nowrap overflow-x-auto" : " flex-wrap"}`,
|
|
2284
|
+
children: [
|
|
2285
|
+
leadingControls,
|
|
2286
|
+
languageOptions && languageOptions.length > 1 && selectedLanguageKey && onSelectLanguage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
2287
|
+
label: t("openapi.language"),
|
|
2288
|
+
value: selectedLanguageKey,
|
|
2289
|
+
options: languageOptions,
|
|
2290
|
+
onChange: onSelectLanguage,
|
|
2291
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CodeIcon, {
|
|
2292
|
+
className: "h-3.5 w-3.5",
|
|
2293
|
+
"aria-hidden": "true"
|
|
2294
|
+
})
|
|
2295
|
+
}) : null,
|
|
2296
|
+
clientOptions && clientOptions.length > 1 && selectedClientKey && onSelectClient ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
2297
|
+
label: t("openapi.client"),
|
|
2298
|
+
value: selectedClientKey,
|
|
2299
|
+
options: clientOptions,
|
|
2300
|
+
onChange: onSelectClient,
|
|
2301
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.PackageIcon, {
|
|
2302
|
+
className: "h-3.5 w-3.5",
|
|
2303
|
+
"aria-hidden": "true"
|
|
2304
|
+
})
|
|
2305
|
+
}) : null
|
|
2306
|
+
]
|
|
2000
2307
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyCodeButton, { code })]
|
|
2001
2308
|
});
|
|
2002
2309
|
}
|
|
@@ -2032,12 +2339,17 @@ function getSecurityRequirements(spec, operation) {
|
|
|
2032
2339
|
}
|
|
2033
2340
|
function getAuthOptions(spec, operation) {
|
|
2034
2341
|
const schemes = getSecuritySchemes(spec);
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
scheme
|
|
2040
|
-
|
|
2342
|
+
return getSecurityRequirements(spec, operation).map((requirement, index) => {
|
|
2343
|
+
const requirementSchemes = Object.keys(requirement).map((name) => ({
|
|
2344
|
+
name,
|
|
2345
|
+
scheme: schemes[name]
|
|
2346
|
+
})).filter((option) => Boolean(option.scheme));
|
|
2347
|
+
return {
|
|
2348
|
+
key: `requirement:${index}`,
|
|
2349
|
+
label: requirementSchemes.map((option) => option.name).join(" + "),
|
|
2350
|
+
schemes: requirementSchemes
|
|
2351
|
+
};
|
|
2352
|
+
});
|
|
2041
2353
|
}
|
|
2042
2354
|
function authPlaceholder(auth) {
|
|
2043
2355
|
if (!auth) return "";
|
|
@@ -2068,21 +2380,38 @@ function getClientOptions(codeOptions, languageKey) {
|
|
|
2068
2380
|
//#endregion
|
|
2069
2381
|
//#region source/openapi/components/ExamplePanels.tsx
|
|
2070
2382
|
function ApiExampleCodeGroup(arg0) {
|
|
2071
|
-
const { title, tag, tagOptions, onSelectTag, label, labelOptions, onSelectLabel, comfortableMeta = false, code, language, mediaTypes, selectedMediaType, onSelectMediaType, examples, selectedExampleKey, onSelectExample, languageOptions, selectedLanguageKey, onSelectLanguage, clientOptions, selectedClientKey, onSelectClient } = arg0;
|
|
2383
|
+
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;
|
|
2072
2384
|
const t = require_i18n.useBuiltInText();
|
|
2073
|
-
const metaClassName = comfortableMeta ? "flex min-h-
|
|
2385
|
+
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";
|
|
2386
|
+
const meta = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
2387
|
+
tag ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
2388
|
+
label: t("openapi.status"),
|
|
2389
|
+
value: tag,
|
|
2390
|
+
options: tagOptions,
|
|
2391
|
+
onChange: onSelectTag,
|
|
2392
|
+
className: "clarify-openai-example-status font-semibold text-emerald-400"
|
|
2393
|
+
}) : null,
|
|
2394
|
+
tag && label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-0.5 w-0.5 shrink-0 rounded-full bg-(--clarify-code-faint)" }) : null,
|
|
2395
|
+
label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
2396
|
+
label: t("openapi.mediaType"),
|
|
2397
|
+
value: label,
|
|
2398
|
+
options: labelOptions,
|
|
2399
|
+
onChange: onSelectLabel,
|
|
2400
|
+
className: "min-w-0 truncate text-xs text-(--clarify-code-muted)"
|
|
2401
|
+
}) : null
|
|
2402
|
+
] });
|
|
2074
2403
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2075
|
-
className: "clarify-
|
|
2404
|
+
className: "clarify-openai-example my-6 overflow-hidden rounded-lg border border-(--clarify-code-border) bg-(--clarify-code-background) shadow-sm",
|
|
2076
2405
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2077
2406
|
className: "not-prose",
|
|
2078
2407
|
children: [
|
|
2079
2408
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2080
|
-
className: "clarify-
|
|
2409
|
+
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",
|
|
2081
2410
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2082
|
-
className: "mr-auto min-w-16 truncate py-1 text-
|
|
2411
|
+
className: "mr-auto min-w-16 truncate py-1 text-sm font-semibold text-(--clarify-code-text)",
|
|
2083
2412
|
children: title
|
|
2084
2413
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2085
|
-
className: "clarify-
|
|
2414
|
+
className: "clarify-openai-example-header-controls ml-auto flex min-w-0 items-center gap-2 whitespace-nowrap",
|
|
2086
2415
|
children: [mediaTypes && mediaTypes.length > 1 && selectedMediaType && onSelectMediaType ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectControl, {
|
|
2087
2416
|
label: t("openapi.mediaType"),
|
|
2088
2417
|
value: selectedMediaType,
|
|
@@ -2101,30 +2430,15 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2101
2430
|
}) : null]
|
|
2102
2431
|
})]
|
|
2103
2432
|
}),
|
|
2104
|
-
tag || label ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
2433
|
+
(tag || label) && !metaInToolbar ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2105
2434
|
className: metaClassName,
|
|
2106
|
-
children:
|
|
2107
|
-
tag ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
2108
|
-
label: t("openapi.status"),
|
|
2109
|
-
value: tag,
|
|
2110
|
-
options: tagOptions,
|
|
2111
|
-
onChange: onSelectTag,
|
|
2112
|
-
className: "clarify-api-example-status font-semibold text-emerald-400"
|
|
2113
|
-
}) : null,
|
|
2114
|
-
tag && label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-0.5 w-0.5 shrink-0 rounded-full bg-(--clarify-code-faint)" }) : null,
|
|
2115
|
-
label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ExampleMetaValue, {
|
|
2116
|
-
label: t("openapi.mediaType"),
|
|
2117
|
-
value: label,
|
|
2118
|
-
options: labelOptions,
|
|
2119
|
-
onChange: onSelectLabel,
|
|
2120
|
-
className: "min-w-0 truncate text-xs text-(--clarify-code-muted)"
|
|
2121
|
-
}) : null
|
|
2122
|
-
]
|
|
2435
|
+
children: meta
|
|
2123
2436
|
}) : null,
|
|
2124
2437
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2125
|
-
className: "clarify-
|
|
2438
|
+
className: "clarify-openai-example-code group bg-(--clarify-code-background)",
|
|
2126
2439
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CodeToolbar, {
|
|
2127
2440
|
code,
|
|
2441
|
+
leadingControls: metaInToolbar ? meta : void 0,
|
|
2128
2442
|
languageOptions,
|
|
2129
2443
|
selectedLanguageKey,
|
|
2130
2444
|
onSelectLanguage,
|
|
@@ -2320,6 +2634,9 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2320
2634
|
if (!state.selectedContent || !state.responseBody) return null;
|
|
2321
2635
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ApiExampleCodeGroup, {
|
|
2322
2636
|
title: title ?? t("openapi.response"),
|
|
2637
|
+
tag: state.selectedResponse?.status,
|
|
2638
|
+
tagOptions: state.responses.map((response) => response.status),
|
|
2639
|
+
onSelectTag: state.responses.length > 0 ? state.onSelectStatus : void 0,
|
|
2323
2640
|
label: state.selectedContent?.mediaType,
|
|
2324
2641
|
labelOptions: state.responseContents.map((content) => content.mediaType),
|
|
2325
2642
|
onSelectLabel: state.responseContents.length > 0 ? state.onSelectMediaType : void 0,
|
|
@@ -2327,7 +2644,8 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2327
2644
|
language: codeLanguageForMediaType(state.selectedContent.mediaType),
|
|
2328
2645
|
examples: state.examples,
|
|
2329
2646
|
selectedExampleKey: state.selectedExample?.key,
|
|
2330
|
-
onSelectExample: state.onSelectExample
|
|
2647
|
+
onSelectExample: state.onSelectExample,
|
|
2648
|
+
metaInToolbar: true
|
|
2331
2649
|
});
|
|
2332
2650
|
}
|
|
2333
2651
|
//#endregion
|
|
@@ -2527,11 +2845,11 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
2527
2845
|
};
|
|
2528
2846
|
}
|
|
2529
2847
|
function EnumValueNode(arg0) {
|
|
2530
|
-
const { node
|
|
2848
|
+
const { node } = arg0;
|
|
2531
2849
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
2532
|
-
className: "clarify-schema-node m-0
|
|
2850
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2533
2851
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2534
|
-
className:
|
|
2852
|
+
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
2535
2853
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2536
2854
|
className: "min-w-0 flex-1",
|
|
2537
2855
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -2565,7 +2883,7 @@ function SchemaNode(arg0) {
|
|
|
2565
2883
|
});
|
|
2566
2884
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
2567
2885
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
2568
|
-
const rowClassName =
|
|
2886
|
+
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
2569
2887
|
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2570
2888
|
className: "min-w-0 flex-1",
|
|
2571
2889
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -2593,7 +2911,7 @@ function SchemaNode(arg0) {
|
|
|
2593
2911
|
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" })
|
|
2594
2912
|
}) : null] });
|
|
2595
2913
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
2596
|
-
className: "clarify-schema-node m-0
|
|
2914
|
+
className: "clarify-schema-node m-0 p-0",
|
|
2597
2915
|
children: [hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
2598
2916
|
type: "button",
|
|
2599
2917
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
@@ -2615,7 +2933,7 @@ function SchemaTree(arg0) {
|
|
|
2615
2933
|
if (nodes.length === 0) return null;
|
|
2616
2934
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
2617
2935
|
role: "list",
|
|
2618
|
-
className: (0, clsx.default)("m-0 list-none divide-y divide-(--clarify-theme-tokens-colors-border)
|
|
2936
|
+
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"),
|
|
2619
2937
|
children: nodes.map((node) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaNode, {
|
|
2620
2938
|
node,
|
|
2621
2939
|
depth,
|
|
@@ -2628,7 +2946,7 @@ function SchemaProperties(arg0) {
|
|
|
2628
2946
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
2629
2947
|
if (!root || root.children.length === 0) return null;
|
|
2630
2948
|
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", {
|
|
2631
|
-
className: "clarify-schema-properties my-6",
|
|
2949
|
+
className: "clarify-schema-properties not-prose my-6",
|
|
2632
2950
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SchemaTree, { nodes: root.children })
|
|
2633
2951
|
})] });
|
|
2634
2952
|
}
|
|
@@ -2713,7 +3031,8 @@ function ResponseList(arg0) {
|
|
|
2713
3031
|
response
|
|
2714
3032
|
})
|
|
2715
3033
|
})),
|
|
2716
|
-
|
|
3034
|
+
className: "mt-4 mb-6",
|
|
3035
|
+
panelsClassName: "mt-5"
|
|
2717
3036
|
})] });
|
|
2718
3037
|
}
|
|
2719
3038
|
//#endregion
|
|
@@ -2738,7 +3057,7 @@ function EndpointRequest(arg0) {
|
|
|
2738
3057
|
})] });
|
|
2739
3058
|
};
|
|
2740
3059
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [renderDescription(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
2741
|
-
className: "relative mt-6",
|
|
3060
|
+
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
2742
3061
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2743
3062
|
className: "w-full",
|
|
2744
3063
|
children: [
|
|
@@ -2785,9 +3104,9 @@ function EndpointResponse(arg0) {
|
|
|
2785
3104
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
2786
3105
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
2787
3106
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2788
|
-
className: "mt-6",
|
|
3107
|
+
className: "mt-10 pt-6",
|
|
2789
3108
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Row, {
|
|
2790
|
-
className: "relative",
|
|
3109
|
+
className: "clarify-openapi-response-workspace relative",
|
|
2791
3110
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2792
3111
|
className: "w-full",
|
|
2793
3112
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseList, {
|
|
@@ -2816,6 +3135,129 @@ function EndpointResponse(arg0) {
|
|
|
2816
3135
|
});
|
|
2817
3136
|
}
|
|
2818
3137
|
//#endregion
|
|
3138
|
+
//#region source/openapi/components/InlineListbox.tsx
|
|
3139
|
+
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)";
|
|
3140
|
+
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";
|
|
3141
|
+
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)";
|
|
3142
|
+
function OptionContent(arg0) {
|
|
3143
|
+
const { option } = arg0;
|
|
3144
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3145
|
+
className: "min-w-0",
|
|
3146
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3147
|
+
className: "block truncate",
|
|
3148
|
+
children: option.label
|
|
3149
|
+
}), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3150
|
+
className: "mt-0.5 block truncate text-2xs text-(--clarify-ui-text-faint)",
|
|
3151
|
+
children: option.description
|
|
3152
|
+
}) : null]
|
|
3153
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
3154
|
+
className: "h-3.5 w-3.5 shrink-0 opacity-0 group-data-selected:opacity-100",
|
|
3155
|
+
"aria-hidden": "true"
|
|
3156
|
+
})] });
|
|
3157
|
+
}
|
|
3158
|
+
function InlineListbox(arg0) {
|
|
3159
|
+
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false } = arg0;
|
|
3160
|
+
const selected = options.find((option) => option.value === value);
|
|
3161
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
3162
|
+
value,
|
|
3163
|
+
onChange,
|
|
3164
|
+
disabled,
|
|
3165
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3166
|
+
className: (0, clsx.default)("pointer-events-auto relative inline-flex min-w-0 w-full", className),
|
|
3167
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxButton, {
|
|
3168
|
+
"aria-label": label,
|
|
3169
|
+
"aria-invalid": invalid || void 0,
|
|
3170
|
+
"aria-describedby": describedBy,
|
|
3171
|
+
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"),
|
|
3172
|
+
children: buttonContent ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3173
|
+
className: "truncate",
|
|
3174
|
+
children: selected?.label ?? (value || label)
|
|
3175
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
3176
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3177
|
+
"aria-hidden": "true"
|
|
3178
|
+
})] })
|
|
3179
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
|
|
3180
|
+
anchor: "bottom start",
|
|
3181
|
+
className: optionsClassName,
|
|
3182
|
+
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
|
|
3183
|
+
value: option.value,
|
|
3184
|
+
className: optionClassName,
|
|
3185
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
|
|
3186
|
+
}, option.value))
|
|
3187
|
+
})]
|
|
3188
|
+
})
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
function MultiInlineListbox(arg0) {
|
|
3192
|
+
const { label, value, options, onChange, disabled = false, invalid, describedBy } = arg0;
|
|
3193
|
+
const selectedLabel = options.filter((option) => value.includes(option.value)).map((option) => option.label).join(", ");
|
|
3194
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
3195
|
+
value,
|
|
3196
|
+
onChange,
|
|
3197
|
+
multiple: true,
|
|
3198
|
+
disabled,
|
|
3199
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3200
|
+
className: "pointer-events-auto relative inline-flex min-w-0 w-full",
|
|
3201
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.ListboxButton, {
|
|
3202
|
+
"aria-label": label,
|
|
3203
|
+
"aria-invalid": invalid || void 0,
|
|
3204
|
+
"aria-describedby": describedBy,
|
|
3205
|
+
className: (0, clsx.default)(defaultButtonClassName, "min-h-8 w-full px-2 text-xs"),
|
|
3206
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3207
|
+
className: "truncate",
|
|
3208
|
+
children: selectedLabel || label
|
|
3209
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
3210
|
+
className: "h-3.5 w-3.5 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3211
|
+
"aria-hidden": "true"
|
|
3212
|
+
})]
|
|
3213
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOptions, {
|
|
3214
|
+
anchor: "bottom start",
|
|
3215
|
+
className: optionsClassName,
|
|
3216
|
+
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.ListboxOption, {
|
|
3217
|
+
value: option.value,
|
|
3218
|
+
className: optionClassName,
|
|
3219
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OptionContent, { option })
|
|
3220
|
+
}, option.value))
|
|
3221
|
+
})]
|
|
3222
|
+
})
|
|
3223
|
+
});
|
|
3224
|
+
}
|
|
3225
|
+
//#endregion
|
|
3226
|
+
//#region source/openapi/store.ts
|
|
3227
|
+
var credentialScopes = /* @__PURE__ */ new WeakMap();
|
|
3228
|
+
var emptyOpenApiCredentials = Object.freeze({});
|
|
3229
|
+
var nextCredentialScope = 0;
|
|
3230
|
+
function getOpenApiCredentialScope(spec) {
|
|
3231
|
+
const current = credentialScopes.get(spec);
|
|
3232
|
+
if (current) return current;
|
|
3233
|
+
const scope = `openapi-${nextCredentialScope += 1}`;
|
|
3234
|
+
credentialScopes.set(spec, scope);
|
|
3235
|
+
return scope;
|
|
3236
|
+
}
|
|
3237
|
+
var useOpenApiStore = (0, zustand.create)()((set) => ({
|
|
3238
|
+
credentials: {},
|
|
3239
|
+
setCredential: (scope, name, value) => set((state) => ({ credentials: {
|
|
3240
|
+
...state.credentials,
|
|
3241
|
+
[scope]: {
|
|
3242
|
+
...state.credentials[scope],
|
|
3243
|
+
[name]: value
|
|
3244
|
+
}
|
|
3245
|
+
} })),
|
|
3246
|
+
clearCredential: (scope, name) => set((state) => {
|
|
3247
|
+
const scoped = { ...state.credentials[scope] };
|
|
3248
|
+
delete scoped[name];
|
|
3249
|
+
return { credentials: {
|
|
3250
|
+
...state.credentials,
|
|
3251
|
+
[scope]: scoped
|
|
3252
|
+
} };
|
|
3253
|
+
}),
|
|
3254
|
+
clearCredentials: (scope) => set((state) => {
|
|
3255
|
+
const credentials = { ...state.credentials };
|
|
3256
|
+
delete credentials[scope];
|
|
3257
|
+
return { credentials };
|
|
3258
|
+
})
|
|
3259
|
+
}));
|
|
3260
|
+
//#endregion
|
|
2819
3261
|
//#region source/openapi/components/OpenApiOperation.state.ts
|
|
2820
3262
|
function useOperationRequestState(spec, path, operation, source = "path") {
|
|
2821
3263
|
const parameters = getOperationParameters(spec, path, operation, source);
|
|
@@ -2866,9 +3308,13 @@ function useOperationServerState(spec, operation, path, source = "path") {
|
|
|
2866
3308
|
}
|
|
2867
3309
|
function useOperationAuthState(spec, operation) {
|
|
2868
3310
|
const authOptions = getAuthOptions(spec, operation);
|
|
2869
|
-
const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.
|
|
2870
|
-
const selectedAuth = authOptions.find((option) => option.
|
|
2871
|
-
const
|
|
3311
|
+
const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
|
|
3312
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
3313
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
3314
|
+
const authValues = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
3315
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
3316
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
3317
|
+
const clearCredentials = useOpenApiStore((state) => state.clearCredentials);
|
|
2872
3318
|
const [authOpen, setAuthOpen] = (0, react.useState)(false);
|
|
2873
3319
|
return {
|
|
2874
3320
|
authOptions,
|
|
@@ -2876,104 +3322,1302 @@ function useOperationAuthState(spec, operation) {
|
|
|
2876
3322
|
selectedAuth,
|
|
2877
3323
|
authValues,
|
|
2878
3324
|
authOpen,
|
|
2879
|
-
authInput: selectedAuth ? {
|
|
2880
|
-
name:
|
|
2881
|
-
scheme:
|
|
2882
|
-
value: authValues[
|
|
2883
|
-
} : void 0,
|
|
3325
|
+
authInput: selectedAuth ? selectedAuth.schemes.map((option) => ({
|
|
3326
|
+
name: option.name,
|
|
3327
|
+
scheme: option.scheme,
|
|
3328
|
+
value: authValues[option.name] ?? ""
|
|
3329
|
+
})) : void 0,
|
|
2884
3330
|
onSelectAuth: setSelectedAuthName,
|
|
2885
|
-
onChangeAuthValue: (name, value) =>
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
})),
|
|
3331
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
3332
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name),
|
|
3333
|
+
onClearAuthValues: () => clearCredentials(credentialScope),
|
|
2889
3334
|
onToggleAuth: () => setAuthOpen((current) => !current),
|
|
2890
3335
|
closeAuth: () => setAuthOpen(false)
|
|
2891
3336
|
};
|
|
2892
3337
|
}
|
|
2893
3338
|
//#endregion
|
|
2894
|
-
//#region source/openapi/
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
};
|
|
2903
|
-
function EndpointMethodBadge(arg0) {
|
|
2904
|
-
const { method } = arg0;
|
|
2905
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2906
|
-
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)"),
|
|
2907
|
-
children: method
|
|
2908
|
-
});
|
|
3339
|
+
//#region source/openapi/lib/api-request.ts
|
|
3340
|
+
function parseBodyObject(body) {
|
|
3341
|
+
try {
|
|
3342
|
+
const parsed = JSON.parse(body);
|
|
3343
|
+
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
|
|
3344
|
+
} catch {
|
|
3345
|
+
return;
|
|
3346
|
+
}
|
|
2909
3347
|
}
|
|
2910
|
-
function
|
|
2911
|
-
const
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
3348
|
+
function buildRequestBody(body, mediaType) {
|
|
3349
|
+
const values = parseBodyObject(body);
|
|
3350
|
+
if (mediaType.includes("application/x-www-form-urlencoded") && values) {
|
|
3351
|
+
const params = new URLSearchParams();
|
|
3352
|
+
Object.entries(values).forEach(([name, value]) => params.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3353
|
+
return params;
|
|
3354
|
+
}
|
|
3355
|
+
if (mediaType.includes("multipart/form-data") && values) {
|
|
3356
|
+
const form = new FormData();
|
|
3357
|
+
Object.entries(values).forEach(([name, value]) => form.append(name, typeof value === "string" ? value : JSON.stringify(value)));
|
|
3358
|
+
return form;
|
|
3359
|
+
}
|
|
3360
|
+
return body;
|
|
3361
|
+
}
|
|
3362
|
+
function expandServerUrl(server, variables) {
|
|
3363
|
+
return (server.url ?? "").replace(/\{([^}]+)\}/g, (_, name) => variables[name] ?? server.variables?.[name]?.default ?? `{${name}}`);
|
|
3364
|
+
}
|
|
3365
|
+
function authorizationValue(auth) {
|
|
3366
|
+
const scheme = auth.scheme.scheme?.toLowerCase();
|
|
3367
|
+
if (auth.scheme.type === "http" && scheme === "basic") return `Basic ${auth.value}`;
|
|
3368
|
+
if (auth.scheme.type === "http" && scheme === "bearer") return `Bearer ${auth.value}`;
|
|
3369
|
+
if (auth.scheme.type === "oauth2" || auth.scheme.type === "openIdConnect") return `Bearer ${auth.value}`;
|
|
3370
|
+
}
|
|
3371
|
+
function parameterKey(parameter) {
|
|
3372
|
+
return `${parameter.in ?? "query"}:${parameter.name ?? ""}`;
|
|
3373
|
+
}
|
|
3374
|
+
function parseParameterValue(value) {
|
|
3375
|
+
const trimmed = value.trim();
|
|
3376
|
+
if (!trimmed || !trimmed.startsWith("[") && !trimmed.startsWith("{")) return value;
|
|
3377
|
+
try {
|
|
3378
|
+
return JSON.parse(trimmed);
|
|
3379
|
+
} catch {
|
|
3380
|
+
return value;
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
function primitiveValue(value) {
|
|
3384
|
+
if (typeof value === "string") return value;
|
|
3385
|
+
if (value === null || typeof value === "undefined") return "";
|
|
3386
|
+
return String(value);
|
|
3387
|
+
}
|
|
3388
|
+
function serializedParameterValues(parameter, rawValue) {
|
|
3389
|
+
const value = parseParameterValue(rawValue);
|
|
3390
|
+
const style = parameter.style ?? (parameter.in === "query" || parameter.in === "cookie" ? "form" : "simple");
|
|
3391
|
+
const explode = parameter.explode ?? style === "form";
|
|
3392
|
+
if (Array.isArray(value)) {
|
|
3393
|
+
if (explode) return value.map((item) => [parameter.name ?? "", primitiveValue(item)]);
|
|
3394
|
+
const delimiter = style === "spaceDelimited" ? " " : style === "pipeDelimited" ? "|" : ",";
|
|
3395
|
+
return [[parameter.name ?? "", value.map(primitiveValue).join(delimiter)]];
|
|
3396
|
+
}
|
|
3397
|
+
if (typeof value === "object" && value !== null) {
|
|
3398
|
+
const entries = Object.entries(value);
|
|
3399
|
+
if (parameter.style === "deepObject") return entries.map(([key, item]) => [`${parameter.name}[${key}]`, primitiveValue(item)]);
|
|
3400
|
+
if (explode) return entries.map(([key, item]) => [key, primitiveValue(item)]);
|
|
3401
|
+
return [[parameter.name ?? "", entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",")]];
|
|
3402
|
+
}
|
|
3403
|
+
return [[parameter.name ?? "", primitiveValue(value)]];
|
|
3404
|
+
}
|
|
3405
|
+
function pathParameterValue(parameter, rawValue) {
|
|
3406
|
+
const value = parseParameterValue(rawValue);
|
|
3407
|
+
const style = parameter.style ?? "simple";
|
|
3408
|
+
const explode = parameter.explode ?? false;
|
|
3409
|
+
const encode = (item) => encodeURIComponent(primitiveValue(item));
|
|
3410
|
+
if (Array.isArray(value)) {
|
|
3411
|
+
if (style === "label") return `.${value.map(encode).join(explode ? "." : ",")}`;
|
|
3412
|
+
if (style === "matrix") return explode ? value.map((item) => `;${parameter.name}=${encode(item)}`).join("") : `;${parameter.name}=${value.map(encode).join(",")}`;
|
|
3413
|
+
return value.map(encode).join(",");
|
|
3414
|
+
}
|
|
3415
|
+
if (typeof value === "object" && value !== null) {
|
|
3416
|
+
const entries = Object.entries(value);
|
|
3417
|
+
if (style === "label") return explode ? `.${entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(".")}` : `.${entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",")}`;
|
|
3418
|
+
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(",")}`;
|
|
3419
|
+
return explode ? entries.map(([key, item]) => `${encode(key)}=${encode(item)}`).join(",") : entries.flatMap(([key, item]) => [encode(key), encode(item)]).join(",");
|
|
3420
|
+
}
|
|
3421
|
+
const encoded = encode(value);
|
|
3422
|
+
if (style === "label") return `.${encoded}`;
|
|
3423
|
+
if (style === "matrix") return `;${parameter.name}=${encoded}`;
|
|
3424
|
+
return encoded;
|
|
3425
|
+
}
|
|
3426
|
+
function headerParameterValue(parameter, rawValue) {
|
|
3427
|
+
const value = parseParameterValue(rawValue);
|
|
3428
|
+
if (Array.isArray(value)) return value.map(primitiveValue).join(",");
|
|
3429
|
+
if (typeof value === "object" && value !== null) {
|
|
3430
|
+
const entries = Object.entries(value);
|
|
3431
|
+
return parameter.explode ? entries.map(([key, item]) => `${key}=${primitiveValue(item)}`).join(",") : entries.flatMap(([key, item]) => [key, primitiveValue(item)]).join(",");
|
|
3432
|
+
}
|
|
3433
|
+
return primitiveValue(value);
|
|
3434
|
+
}
|
|
3435
|
+
function buildApiRequest(input) {
|
|
3436
|
+
const headers = new Headers({ Accept: "application/json" });
|
|
3437
|
+
const query = new URLSearchParams();
|
|
3438
|
+
let path = input.path;
|
|
3439
|
+
for (const parameter of input.parameters) {
|
|
3440
|
+
if (!parameter.name) continue;
|
|
3441
|
+
const key = parameterKey(parameter);
|
|
3442
|
+
if (input.parameterEnabled?.[key] === false) continue;
|
|
3443
|
+
const value = input.parameterValues[key] ?? "";
|
|
3444
|
+
if (!value && !parameter.allowEmptyValue) continue;
|
|
3445
|
+
if (parameter.in === "path") path = path.replaceAll(`{${parameter.name}}`, pathParameterValue(parameter, value));
|
|
3446
|
+
if (parameter.in === "query") serializedParameterValues(parameter, value).forEach(([name, item]) => query.append(name, item));
|
|
3447
|
+
if (parameter.in === "header") headers.set(parameter.name, headerParameterValue(parameter, value));
|
|
3448
|
+
}
|
|
3449
|
+
for (const auth of input.auth ?? []) {
|
|
3450
|
+
if (!auth.value) continue;
|
|
3451
|
+
if (auth.scheme.type === "apiKey" && auth.scheme.in === "query" && auth.scheme.name) query.set(auth.scheme.name, auth.value);
|
|
3452
|
+
else if (auth.scheme.type === "apiKey" && auth.scheme.in === "header" && auth.scheme.name) headers.set(auth.scheme.name, auth.value);
|
|
3453
|
+
else {
|
|
3454
|
+
const authorization = authorizationValue(auth);
|
|
3455
|
+
if (authorization) headers.set("Authorization", authorization);
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
|
|
3459
|
+
query.forEach((value, key) => url.searchParams.append(key, value));
|
|
3460
|
+
const body = input.body?.trim();
|
|
3461
|
+
const mediaType = input.mediaType || "application/json";
|
|
3462
|
+
const requestBody = body && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType) : void 0;
|
|
3463
|
+
if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
|
|
3464
|
+
return {
|
|
3465
|
+
url: url.toString(),
|
|
3466
|
+
init: {
|
|
3467
|
+
method: input.method.toUpperCase(),
|
|
3468
|
+
headers,
|
|
3469
|
+
credentials: "include",
|
|
3470
|
+
...requestBody ? { body: requestBody } : {}
|
|
3471
|
+
}
|
|
3472
|
+
};
|
|
3473
|
+
}
|
|
3474
|
+
//#endregion
|
|
3475
|
+
//#region source/openapi/components/OpenApiAuthPanel.tsx
|
|
3476
|
+
function OpenApiAuthPanel(arg0) {
|
|
3477
|
+
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue, onClearAuthValue } = arg0;
|
|
3478
|
+
const t = require_i18n.useBuiltInText();
|
|
3479
|
+
if (authOptions.length === 0) return null;
|
|
3480
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3481
|
+
className: "grid divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3482
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3483
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3484
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3485
|
+
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)",
|
|
3486
|
+
children: "Auth"
|
|
3487
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
3488
|
+
label: "Auth",
|
|
3489
|
+
value: selectedAuthName,
|
|
3490
|
+
options: authOptions.map((option) => ({
|
|
3491
|
+
value: option.key,
|
|
3492
|
+
label: option.label || t("openapi.none")
|
|
3493
|
+
})),
|
|
3494
|
+
onChange: onSelectAuth
|
|
3495
|
+
})]
|
|
3496
|
+
}), selectedAuth?.schemes.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3497
|
+
className: "group grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
3498
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3499
|
+
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)",
|
|
3500
|
+
children: authLabel(option.name, option.scheme)
|
|
3501
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3502
|
+
className: "flex min-w-0 items-center focus-within:bg-(--clarify-ui-hover-background)",
|
|
3503
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3504
|
+
type: "password",
|
|
3505
|
+
value: authValues[option.name] ?? "",
|
|
3506
|
+
placeholder: authPlaceholder(option),
|
|
3507
|
+
onChange: (event) => onChangeAuthValue(option.name, event.target.value),
|
|
3508
|
+
autoComplete: "off",
|
|
3509
|
+
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)"
|
|
3510
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3511
|
+
type: "button",
|
|
3512
|
+
onClick: () => onClearAuthValue(option.name),
|
|
3513
|
+
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",
|
|
3514
|
+
children: t("openapi.clear")
|
|
3515
|
+
})]
|
|
3516
|
+
})]
|
|
3517
|
+
}, option.name))]
|
|
2935
3518
|
});
|
|
2936
3519
|
}
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
3520
|
+
//#endregion
|
|
3521
|
+
//#region source/openapi/components/OpenApiRequestFields.tsx
|
|
3522
|
+
function RequestField(arg0) {
|
|
3523
|
+
const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
|
|
3524
|
+
const t = require_i18n.useBuiltInText();
|
|
3525
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
3526
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3527
|
+
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
3528
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
3529
|
+
const itemOptions = Array.isArray(itemSchema?.enum) ? itemSchema.enum.map(String) : [];
|
|
3530
|
+
const type = schemaToType(schema) ?? "string";
|
|
3531
|
+
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
3532
|
+
const structured = type.includes("[]") || type.includes("object");
|
|
3533
|
+
const boolean = type.includes("boolean");
|
|
3534
|
+
const numeric = type.includes("integer") || type.includes("number");
|
|
3535
|
+
const fieldId = `openapi-parameter-${parameter.in ?? "query"}-${parameter.name ?? ""}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3536
|
+
const issueText = issue === "required" ? t("openapi.required") : issue ? t(`openapi.parameter${issue[0].toUpperCase()}${issue.slice(1)}`) : void 0;
|
|
3537
|
+
const controlProps = {
|
|
3538
|
+
"aria-label": parameter.name,
|
|
3539
|
+
"aria-invalid": issue ? true : void 0,
|
|
3540
|
+
"aria-describedby": issue ? `${fieldId}-issue` : void 0,
|
|
3541
|
+
disabled: !enabled
|
|
3542
|
+
};
|
|
3543
|
+
const arrayValue = (() => {
|
|
3544
|
+
try {
|
|
3545
|
+
const parsed = JSON.parse(value);
|
|
3546
|
+
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
3547
|
+
} catch {
|
|
3548
|
+
return [];
|
|
3549
|
+
}
|
|
3550
|
+
})();
|
|
3551
|
+
const descriptionTip = description ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Tooltip, {
|
|
3552
|
+
content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
3553
|
+
className: "max-w-80 text-left *:first:mt-0 *:last:mb-0",
|
|
3554
|
+
children: description
|
|
3555
|
+
}),
|
|
3556
|
+
side: "bottom",
|
|
3557
|
+
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",
|
|
3558
|
+
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",
|
|
3559
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.InfoIcon, {
|
|
3560
|
+
className: "size-4",
|
|
3561
|
+
"aria-hidden": "true"
|
|
3562
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3563
|
+
className: "sr-only",
|
|
3564
|
+
children: t("openapi.fieldDescription")
|
|
3565
|
+
})]
|
|
3566
|
+
}) : null;
|
|
3567
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3568
|
+
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",
|
|
3569
|
+
children: [
|
|
3570
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3571
|
+
className: "flex min-h-8 items-center justify-center border-r border-(--clarify-theme-tokens-colors-border)",
|
|
3572
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3573
|
+
type: "checkbox",
|
|
3574
|
+
checked: enabled,
|
|
3575
|
+
disabled: parameter.required,
|
|
3576
|
+
onChange: (event) => onEnabledChange(event.target.checked),
|
|
3577
|
+
"aria-label": `${t("openapi.includeParameter")}: ${parameter.name ?? ""}`,
|
|
3578
|
+
className: "size-3.5 shrink-0 accent-(--clarify-theme-tokens-colors-primary) disabled:cursor-not-allowed"
|
|
3579
|
+
})
|
|
3580
|
+
}),
|
|
3581
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3582
|
+
className: "flex min-h-8 min-w-0 items-center border-r border-(--clarify-theme-tokens-colors-border) px-2",
|
|
3583
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3584
|
+
htmlFor: fieldId,
|
|
3585
|
+
className: "flex min-w-0 flex-wrap items-center gap-x-1.5 text-xs text-(--clarify-ui-text-strong)",
|
|
3586
|
+
children: [
|
|
3587
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3588
|
+
className: "truncate font-mono",
|
|
3589
|
+
children: parameter.name
|
|
3590
|
+
}),
|
|
3591
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3592
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3593
|
+
children: type
|
|
3594
|
+
}),
|
|
3595
|
+
parameter.required ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3596
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3597
|
+
children: "*"
|
|
3598
|
+
}) : null
|
|
3599
|
+
]
|
|
3600
|
+
})
|
|
3601
|
+
}),
|
|
3602
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3603
|
+
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 && "opacity-45"),
|
|
3604
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3605
|
+
className: "min-w-0 flex-1",
|
|
3606
|
+
children: itemOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiInlineListbox, {
|
|
3607
|
+
label: parameter.name ?? "",
|
|
3608
|
+
value: arrayValue,
|
|
3609
|
+
options: itemOptions.map((option) => ({
|
|
3610
|
+
value: option,
|
|
3611
|
+
label: option
|
|
3612
|
+
})),
|
|
3613
|
+
onChange: (next) => onChange(JSON.stringify(next)),
|
|
3614
|
+
invalid: Boolean(issue),
|
|
3615
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3616
|
+
disabled: !enabled
|
|
3617
|
+
}) : options.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
3618
|
+
label: parameter.name ?? "",
|
|
3619
|
+
value,
|
|
3620
|
+
options: [...parameter.required ? [] : [{
|
|
3621
|
+
value: "",
|
|
3622
|
+
label: t("openapi.none")
|
|
3623
|
+
}], ...options.map((option) => ({
|
|
3624
|
+
value: option,
|
|
3625
|
+
label: option
|
|
3626
|
+
}))],
|
|
3627
|
+
onChange,
|
|
3628
|
+
invalid: Boolean(issue),
|
|
3629
|
+
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
3630
|
+
disabled: !enabled
|
|
3631
|
+
}) : boolean ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3632
|
+
...controlProps,
|
|
3633
|
+
id: fieldId,
|
|
3634
|
+
type: "checkbox",
|
|
3635
|
+
checked: value === "true",
|
|
3636
|
+
onChange: (event) => onChange(String(event.target.checked)),
|
|
3637
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3638
|
+
}) : structured ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
3639
|
+
...controlProps,
|
|
3640
|
+
id: fieldId,
|
|
3641
|
+
value,
|
|
3642
|
+
required: parameter.required,
|
|
3643
|
+
onChange: (event) => onChange(event.target.value),
|
|
3644
|
+
rows: 3,
|
|
3645
|
+
spellCheck: false,
|
|
3646
|
+
placeholder: type.includes("[]") ? "[]" : "{}",
|
|
3647
|
+
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)"
|
|
3648
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3649
|
+
...controlProps,
|
|
3650
|
+
id: fieldId,
|
|
3651
|
+
value,
|
|
3652
|
+
type: numeric ? "number" : schemaRecord?.format === "date" ? "date" : schemaRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3653
|
+
required: parameter.required,
|
|
3654
|
+
onChange: (event) => onChange(event.target.value),
|
|
3655
|
+
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)"
|
|
3656
|
+
})
|
|
3657
|
+
}), descriptionTip]
|
|
3658
|
+
}),
|
|
3659
|
+
issueText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3660
|
+
id: `${fieldId}-issue`,
|
|
3661
|
+
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",
|
|
3662
|
+
children: issueText
|
|
3663
|
+
}) : null
|
|
3664
|
+
]
|
|
3665
|
+
});
|
|
3666
|
+
}
|
|
3667
|
+
function RequestSection(arg0) {
|
|
3668
|
+
const { title, count, defaultOpen, actions, className, contentClassName, children } = arg0;
|
|
3669
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
|
|
3670
|
+
open: defaultOpen,
|
|
3671
|
+
className: (0, clsx.default)("group shrink-0 border-b border-(--clarify-theme-tokens-colors-border)", className),
|
|
3672
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("summary", {
|
|
3673
|
+
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)",
|
|
3674
|
+
children: [
|
|
3675
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
3676
|
+
className: "size-4 shrink-0 -rotate-90 transition group-open:rotate-0",
|
|
3677
|
+
"aria-hidden": "true"
|
|
3678
|
+
}),
|
|
3679
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3680
|
+
className: "flex-1",
|
|
3681
|
+
children: title
|
|
3682
|
+
}),
|
|
3683
|
+
typeof count === "number" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3684
|
+
className: "font-mono text-xs text-(--clarify-ui-text-faint)",
|
|
3685
|
+
children: count
|
|
3686
|
+
}) : null,
|
|
3687
|
+
actions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3688
|
+
className: "flex items-center gap-1",
|
|
3689
|
+
onClick: (event) => {
|
|
3690
|
+
event.preventDefault();
|
|
3691
|
+
event.stopPropagation();
|
|
3692
|
+
},
|
|
3693
|
+
children: actions
|
|
3694
|
+
}) : null
|
|
3695
|
+
]
|
|
3696
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3697
|
+
className: (0, clsx.default)("divide-y divide-(--clarify-theme-tokens-colors-border)", contentClassName),
|
|
3698
|
+
children
|
|
3699
|
+
})]
|
|
3700
|
+
});
|
|
3701
|
+
}
|
|
3702
|
+
//#endregion
|
|
3703
|
+
//#region source/openapi/components/OpenApiResponseViewer.tsx
|
|
3704
|
+
function formatBytes(size) {
|
|
3705
|
+
if (size < 1024) return `${size} B`;
|
|
3706
|
+
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
|
|
3707
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
3708
|
+
}
|
|
3709
|
+
function parseJson(value) {
|
|
3710
|
+
try {
|
|
3711
|
+
return JSON.parse(value);
|
|
3712
|
+
} catch {
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
function ResponseState(arg0) {
|
|
3717
|
+
const { icon: Icon, title, description, tone = "default" } = arg0;
|
|
3718
|
+
const error = tone === "error";
|
|
3719
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3720
|
+
className: "grid min-h-56 flex-1 place-items-center px-6 py-10 text-center",
|
|
3721
|
+
role: error ? "alert" : "status",
|
|
2943
3722
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2944
|
-
className: "
|
|
2945
|
-
children: [
|
|
2946
|
-
"
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
3723
|
+
className: "max-w-sm",
|
|
3724
|
+
children: [
|
|
3725
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3726
|
+
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)"),
|
|
3727
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
|
|
3728
|
+
className: "size-4.5",
|
|
3729
|
+
"aria-hidden": "true"
|
|
3730
|
+
})
|
|
3731
|
+
}),
|
|
3732
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3733
|
+
className: (0, clsx.default)("text-sm font-semibold", error ? "text-(--clarify-code-danger)" : "text-(--clarify-code-text)"),
|
|
3734
|
+
children: title
|
|
3735
|
+
}),
|
|
3736
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3737
|
+
className: "mt-1 text-xs/5 text-(--clarify-code-faint)",
|
|
3738
|
+
children: description
|
|
3739
|
+
})
|
|
3740
|
+
]
|
|
3741
|
+
})
|
|
3742
|
+
});
|
|
3743
|
+
}
|
|
3744
|
+
function JsonPreview(arg0) {
|
|
3745
|
+
const { value } = arg0;
|
|
3746
|
+
if (Array.isArray(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3747
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3748
|
+
children: value.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3749
|
+
className: "mr-2 text-(--clarify-code-faint)",
|
|
3750
|
+
children: index
|
|
3751
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })] }, index))
|
|
3752
|
+
});
|
|
3753
|
+
if (isRecord$1(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3754
|
+
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3755
|
+
children: Object.entries(value).map(([key, item]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3756
|
+
className: "grid grid-cols-[minmax(5rem,auto)_1fr] gap-3",
|
|
3757
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3758
|
+
className: "text-(--clarify-code-property)",
|
|
3759
|
+
children: key
|
|
3760
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })]
|
|
3761
|
+
}, key))
|
|
3762
|
+
});
|
|
3763
|
+
if (value === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3764
|
+
className: "text-(--clarify-code-faint)",
|
|
3765
|
+
children: "null"
|
|
3766
|
+
});
|
|
3767
|
+
if (typeof value === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3768
|
+
className: "wrap-break-word text-(--clarify-code-string)",
|
|
3769
|
+
children: value
|
|
3770
|
+
});
|
|
3771
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3772
|
+
className: "text-(--clarify-code-number)",
|
|
3773
|
+
children: String(value)
|
|
3774
|
+
});
|
|
3775
|
+
}
|
|
3776
|
+
function CopyButton(arg0) {
|
|
3777
|
+
const { value } = arg0;
|
|
3778
|
+
const t = require_i18n.useBuiltInText();
|
|
3779
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
3780
|
+
async function copy() {
|
|
3781
|
+
const success = await require_PageActions.copyTextToClipboard(value);
|
|
3782
|
+
setCopied(success);
|
|
3783
|
+
if (success) window.setTimeout(() => setCopied(false), 1600);
|
|
3784
|
+
}
|
|
3785
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
3786
|
+
type: "button",
|
|
3787
|
+
onClick: copy,
|
|
3788
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
3789
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
3790
|
+
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)",
|
|
3791
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
3792
|
+
className: "size-4 text-(--clarify-code-success)",
|
|
3793
|
+
"aria-hidden": "true"
|
|
3794
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
|
|
3795
|
+
className: "size-4",
|
|
3796
|
+
"aria-hidden": "true"
|
|
3797
|
+
})
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
function ResponseMedia(arg0) {
|
|
3801
|
+
const { blob, type } = arg0;
|
|
3802
|
+
const elementRef = (0, react.useRef)(null);
|
|
3803
|
+
(0, react.useEffect)(() => {
|
|
3804
|
+
const element = elementRef.current;
|
|
3805
|
+
if (!element) return;
|
|
3806
|
+
const url = URL.createObjectURL(blob);
|
|
3807
|
+
element.src = url;
|
|
3808
|
+
return () => {
|
|
3809
|
+
element.removeAttribute("src");
|
|
3810
|
+
URL.revokeObjectURL(url);
|
|
3811
|
+
};
|
|
3812
|
+
}, [blob]);
|
|
3813
|
+
if (type === "image") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
3814
|
+
ref: elementRef,
|
|
3815
|
+
alt: "",
|
|
3816
|
+
className: "max-h-128 max-w-full object-contain"
|
|
3817
|
+
});
|
|
3818
|
+
if (type === "audio") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("audio", {
|
|
3819
|
+
ref: elementRef,
|
|
3820
|
+
controls: true,
|
|
3821
|
+
className: "w-full"
|
|
3822
|
+
});
|
|
3823
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("video", {
|
|
3824
|
+
ref: elementRef,
|
|
3825
|
+
controls: true,
|
|
3826
|
+
className: "max-h-128 max-w-full"
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
function ResponsePreview(arg0) {
|
|
3830
|
+
const { exchange } = arg0;
|
|
3831
|
+
const t = require_i18n.useBuiltInText();
|
|
3832
|
+
const contentType = exchange.contentType.toLowerCase();
|
|
3833
|
+
if (!exchange.size) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
|
|
3834
|
+
icon: lucide_react.FileX2Icon,
|
|
3835
|
+
title: t("openapi.responseBodyEmptyTitle"),
|
|
3836
|
+
description: t("openapi.responseBodyEmpty")
|
|
3837
|
+
});
|
|
3838
|
+
if (contentType.includes("json")) {
|
|
3839
|
+
const parsed = parseJson(exchange.body);
|
|
3840
|
+
return typeof parsed === "undefined" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
3841
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3842
|
+
children: exchange.body
|
|
3843
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3844
|
+
className: "overflow-auto font-mono text-xs/5",
|
|
3845
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: parsed })
|
|
3846
|
+
});
|
|
3847
|
+
}
|
|
3848
|
+
if (contentType.startsWith("image/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
|
|
3849
|
+
blob: exchange.blob,
|
|
3850
|
+
type: "image"
|
|
3851
|
+
});
|
|
3852
|
+
if (contentType.startsWith("audio/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
|
|
3853
|
+
blob: exchange.blob,
|
|
3854
|
+
type: "audio"
|
|
3855
|
+
});
|
|
3856
|
+
if (contentType.startsWith("video/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
|
|
3857
|
+
blob: exchange.blob,
|
|
3858
|
+
type: "video"
|
|
3859
|
+
});
|
|
3860
|
+
if (contentType.includes("html")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
|
|
3861
|
+
srcDoc: exchange.body,
|
|
3862
|
+
sandbox: "",
|
|
3863
|
+
title: "Response preview",
|
|
3864
|
+
className: "h-96 w-full border-0 bg-white"
|
|
3865
|
+
});
|
|
3866
|
+
if (contentType.startsWith("text/") || contentType.includes("xml") || contentType.includes("yaml")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
3867
|
+
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3868
|
+
children: exchange.body
|
|
3869
|
+
});
|
|
3870
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3871
|
+
className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
|
|
3872
|
+
children: t("openapi.binaryPreview")
|
|
3873
|
+
});
|
|
3874
|
+
}
|
|
3875
|
+
function ResponseHeaders(arg0) {
|
|
3876
|
+
const { headers: sourceHeaders } = arg0;
|
|
3877
|
+
const t = require_i18n.useBuiltInText();
|
|
3878
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
3879
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
3880
|
+
const headers = normalizedQuery ? sourceHeaders.filter(([name, value]) => `${name} ${value}`.toLowerCase().includes(normalizedQuery)) : sourceHeaders;
|
|
3881
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
3882
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3883
|
+
className: "flex h-9 items-center gap-2 border-b border-(--clarify-code-border) bg-(--clarify-code-control-background) px-3",
|
|
3884
|
+
children: [
|
|
3885
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SearchIcon, {
|
|
3886
|
+
className: "size-4 shrink-0 text-(--clarify-code-muted)",
|
|
2953
3887
|
"aria-hidden": "true"
|
|
2954
|
-
})
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3888
|
+
}),
|
|
3889
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3890
|
+
className: "sr-only",
|
|
3891
|
+
children: t("openapi.searchHeaders")
|
|
3892
|
+
}),
|
|
3893
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3894
|
+
value: query,
|
|
3895
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3896
|
+
placeholder: t("openapi.searchHeaders"),
|
|
3897
|
+
className: "min-w-0 flex-1 bg-transparent text-xs text-(--clarify-code-text) outline-none placeholder:text-(--clarify-code-faint)"
|
|
3898
|
+
})
|
|
3899
|
+
]
|
|
3900
|
+
}),
|
|
3901
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3902
|
+
className: "overflow-x-auto",
|
|
3903
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3904
|
+
className: "w-full min-w-96 table-fixed border-collapse text-left font-mono text-xs/5",
|
|
3905
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
|
|
3906
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3907
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [
|
|
3908
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3909
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3910
|
+
children: t("openapi.headerName")
|
|
3911
|
+
}),
|
|
3912
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3913
|
+
className: "px-3 py-2 font-semibold",
|
|
3914
|
+
children: t("openapi.headerValue")
|
|
3915
|
+
}),
|
|
3916
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3917
|
+
className: "w-10",
|
|
3918
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3919
|
+
className: "sr-only",
|
|
3920
|
+
children: t("actions.copy")
|
|
3921
|
+
})
|
|
3922
|
+
})
|
|
3923
|
+
] })
|
|
3924
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: headers.map(([name, value], index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", {
|
|
3925
|
+
className: "border-t border-(--clarify-code-border) hover:bg-(--clarify-code-control-background)",
|
|
3926
|
+
children: [
|
|
3927
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3928
|
+
className: "break-all border-r border-(--clarify-code-border) px-3 py-2 align-top text-(--clarify-code-property)",
|
|
3929
|
+
children: name
|
|
3930
|
+
}),
|
|
3931
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3932
|
+
className: "break-all px-3 py-2 align-top text-(--clarify-code-text)",
|
|
3933
|
+
children: value
|
|
3934
|
+
}),
|
|
3935
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3936
|
+
className: "pr-1",
|
|
3937
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: `${name}: ${value}` })
|
|
3938
|
+
})
|
|
3939
|
+
]
|
|
3940
|
+
}, `${name}:${index}`)) })]
|
|
3941
|
+
})
|
|
3942
|
+
}),
|
|
3943
|
+
headers.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3944
|
+
className: "border-t border-(--clarify-code-border) py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
3945
|
+
children: t("openapi.noHeaders")
|
|
3946
|
+
}) : null
|
|
3947
|
+
] });
|
|
3948
|
+
}
|
|
3949
|
+
function HiddenCookies() {
|
|
3950
|
+
const t = require_i18n.useBuiltInText();
|
|
3951
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3952
|
+
className: "w-full table-fixed border-collapse text-left text-xs/5",
|
|
3953
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", {
|
|
3954
|
+
className: "bg-(--clarify-code-control-background) text-(--clarify-code-muted)",
|
|
3955
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3956
|
+
className: "w-2/5 border-r border-(--clarify-code-border) px-3 py-2 font-semibold",
|
|
3957
|
+
children: t("openapi.headerName")
|
|
3958
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3959
|
+
className: "px-3 py-2 font-semibold",
|
|
3960
|
+
children: t("openapi.headerValue")
|
|
3961
|
+
})] })
|
|
3962
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
|
|
3963
|
+
className: "border-t border-(--clarify-code-border)",
|
|
3964
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3965
|
+
colSpan: 2,
|
|
3966
|
+
className: "px-3 py-5 text-center text-(--clarify-code-faint)",
|
|
3967
|
+
children: t("openapi.cookiesBrowserHidden")
|
|
3968
|
+
})
|
|
3969
|
+
}) })]
|
|
3970
|
+
});
|
|
3971
|
+
}
|
|
3972
|
+
function OpenApiResponseViewer(arg0) {
|
|
3973
|
+
const { exchange, error } = arg0;
|
|
3974
|
+
const t = require_i18n.useBuiltInText();
|
|
3975
|
+
const [bodyMode, setBodyMode] = (0, react.useState)("preview");
|
|
3976
|
+
function downloadBody() {
|
|
3977
|
+
if (!exchange) return;
|
|
3978
|
+
const url = URL.createObjectURL(exchange.blob);
|
|
3979
|
+
const anchor = document.createElement("a");
|
|
3980
|
+
anchor.href = url;
|
|
3981
|
+
anchor.download = `response.${exchange.contentType.includes("json") ? "json" : "bin"}`;
|
|
3982
|
+
anchor.click();
|
|
3983
|
+
URL.revokeObjectURL(url);
|
|
3984
|
+
}
|
|
3985
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3986
|
+
className: "clarify-api-response flex h-full min-h-96 min-w-0 flex-col bg-(--clarify-code-background) text-(--clarify-code-text)",
|
|
3987
|
+
"aria-label": t("openapi.response"),
|
|
3988
|
+
children: [
|
|
3989
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3990
|
+
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",
|
|
3991
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3992
|
+
className: "mr-auto text-(--clarify-code-text)",
|
|
3993
|
+
children: t("openapi.response")
|
|
3994
|
+
}), exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
3995
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
3996
|
+
className: "text-xs font-semibold text-(--clarify-code-muted)",
|
|
3997
|
+
children: [exchange.duration, " ms"]
|
|
3998
|
+
}),
|
|
3999
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4000
|
+
className: "text-xs text-(--clarify-code-faint)",
|
|
4001
|
+
children: formatBytes(exchange.size)
|
|
4002
|
+
}),
|
|
4003
|
+
/* @__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)") }),
|
|
4004
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4005
|
+
className: (0, clsx.default)("text-xs font-semibold", exchange.status < 400 ? "text-(--clarify-code-success)" : "text-(--clarify-code-danger)"),
|
|
4006
|
+
children: [
|
|
4007
|
+
exchange.status,
|
|
4008
|
+
" ",
|
|
4009
|
+
exchange.statusText
|
|
4010
|
+
]
|
|
4011
|
+
})
|
|
4012
|
+
] }) : null]
|
|
4013
|
+
}),
|
|
4014
|
+
error ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
|
|
4015
|
+
icon: lucide_react.CircleAlertIcon,
|
|
4016
|
+
title: t("openapi.responseErrorTitle"),
|
|
4017
|
+
description: error,
|
|
4018
|
+
tone: "error"
|
|
4019
|
+
}) : null,
|
|
4020
|
+
!error && !exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
|
|
4021
|
+
icon: lucide_react.SendIcon,
|
|
4022
|
+
title: t("openapi.responseEmptyTitle"),
|
|
4023
|
+
description: t("openapi.responseEmpty")
|
|
4024
|
+
}) : null,
|
|
4025
|
+
exchange ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4026
|
+
className: "min-h-0 flex-1 overflow-auto",
|
|
4027
|
+
children: [
|
|
4028
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4029
|
+
title: t("openapi.cookies"),
|
|
4030
|
+
count: 0,
|
|
4031
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HiddenCookies, {})
|
|
4032
|
+
}),
|
|
4033
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4034
|
+
title: t("openapi.requestHeaders"),
|
|
4035
|
+
count: exchange.request.headers.length,
|
|
4036
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.request.headers })
|
|
4037
|
+
}),
|
|
4038
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4039
|
+
title: t("openapi.responseHeaders"),
|
|
4040
|
+
count: exchange.headers.length,
|
|
4041
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseHeaders, { headers: exchange.headers })
|
|
4042
|
+
}),
|
|
4043
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4044
|
+
title: t("openapi.body"),
|
|
4045
|
+
defaultOpen: true,
|
|
4046
|
+
actions: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4047
|
+
className: "font-mono text-2xs font-normal text-(--clarify-code-faint)",
|
|
4048
|
+
children: exchange.contentType || t("openapi.unknownContentType")
|
|
4049
|
+
}),
|
|
4050
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4051
|
+
className: "min-h-72",
|
|
4052
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4053
|
+
className: "flex h-10 items-center justify-between border-b border-(--clarify-code-border) px-3",
|
|
4054
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4055
|
+
role: "tablist",
|
|
4056
|
+
className: "flex",
|
|
4057
|
+
children: ["preview", "raw"].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4058
|
+
type: "button",
|
|
4059
|
+
role: "tab",
|
|
4060
|
+
"aria-selected": bodyMode === mode,
|
|
4061
|
+
onClick: () => setBodyMode(mode),
|
|
4062
|
+
className: (0, clsx.default)("border-b-2 px-2.5 py-1 text-2xs font-semibold", bodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
|
|
4063
|
+
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4064
|
+
}, mode))
|
|
4065
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4066
|
+
className: "flex",
|
|
4067
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, { value: exchange.body }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4068
|
+
type: "button",
|
|
4069
|
+
onClick: downloadBody,
|
|
4070
|
+
"aria-label": t("openapi.downloadBody"),
|
|
4071
|
+
title: t("openapi.downloadBody"),
|
|
4072
|
+
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)",
|
|
4073
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.DownloadIcon, {
|
|
4074
|
+
className: "size-4",
|
|
4075
|
+
"aria-hidden": "true"
|
|
4076
|
+
})
|
|
4077
|
+
})]
|
|
4078
|
+
})]
|
|
4079
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4080
|
+
className: "p-4",
|
|
4081
|
+
children: bodyMode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
4082
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4083
|
+
children: exchange.body
|
|
4084
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4085
|
+
className: "py-8 text-center text-xs text-(--clarify-code-faint)",
|
|
4086
|
+
children: t("openapi.responseBodyEmpty")
|
|
4087
|
+
})
|
|
4088
|
+
})]
|
|
4089
|
+
})
|
|
4090
|
+
})
|
|
4091
|
+
]
|
|
4092
|
+
}) : null
|
|
4093
|
+
]
|
|
4094
|
+
});
|
|
4095
|
+
}
|
|
4096
|
+
//#endregion
|
|
4097
|
+
//#region source/openapi/components/SendRequestButton.tsx
|
|
4098
|
+
function SendRequestButton(arg0) {
|
|
4099
|
+
const { label, busy = false, text, onClick } = arg0;
|
|
4100
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
4101
|
+
type: "button",
|
|
4102
|
+
disabled: busy,
|
|
4103
|
+
"aria-label": label,
|
|
4104
|
+
title: label,
|
|
4105
|
+
onClick,
|
|
4106
|
+
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",
|
|
4107
|
+
children: [busy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.LoaderCircleIcon, {
|
|
4108
|
+
className: "size-4 animate-spin",
|
|
4109
|
+
"aria-hidden": "true"
|
|
4110
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.SendIcon, {
|
|
4111
|
+
className: "size-4",
|
|
4112
|
+
"aria-hidden": "true"
|
|
4113
|
+
}), text]
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
//#endregion
|
|
4117
|
+
//#region source/openapi/lib/api-exchange.ts
|
|
4118
|
+
var ApiRequestError = class extends Error {
|
|
4119
|
+
category;
|
|
4120
|
+
constructor(message, options) {
|
|
4121
|
+
super(message, options);
|
|
4122
|
+
this.name = "ApiRequestError";
|
|
4123
|
+
this.category = "network";
|
|
4124
|
+
}
|
|
4125
|
+
};
|
|
4126
|
+
function requestBodySnapshot(body) {
|
|
4127
|
+
if (typeof body === "string") return body;
|
|
4128
|
+
if (body instanceof URLSearchParams) return body.toString();
|
|
4129
|
+
}
|
|
4130
|
+
function requestSnapshot(request) {
|
|
4131
|
+
return {
|
|
4132
|
+
url: request.url,
|
|
4133
|
+
method: request.init.method ?? "GET",
|
|
4134
|
+
headers: Array.from(new Headers(request.init.headers).entries()),
|
|
4135
|
+
body: requestBodySnapshot(request.init.body)
|
|
4136
|
+
};
|
|
4137
|
+
}
|
|
4138
|
+
async function executeApiRequest(request, options = {}) {
|
|
4139
|
+
const fetchRequest = options.fetch ?? fetch;
|
|
4140
|
+
const now = options.now ?? (() => performance.now());
|
|
4141
|
+
const startedAt = now();
|
|
4142
|
+
let response;
|
|
4143
|
+
try {
|
|
4144
|
+
response = await fetchRequest(request.url, {
|
|
4145
|
+
...request.init,
|
|
4146
|
+
signal: options.signal
|
|
4147
|
+
});
|
|
4148
|
+
} catch (cause) {
|
|
4149
|
+
if (cause instanceof DOMException && cause.name === "AbortError") throw cause;
|
|
4150
|
+
throw new ApiRequestError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
4151
|
+
}
|
|
4152
|
+
const blob = await response.blob();
|
|
4153
|
+
return {
|
|
4154
|
+
request: requestSnapshot(request),
|
|
4155
|
+
status: response.status,
|
|
4156
|
+
statusText: response.statusText,
|
|
4157
|
+
url: response.url || request.url,
|
|
4158
|
+
redirected: response.redirected,
|
|
4159
|
+
duration: Math.round(now() - startedAt),
|
|
4160
|
+
size: blob.size,
|
|
4161
|
+
headers: Array.from(response.headers.entries()),
|
|
4162
|
+
contentType: response.headers.get("content-type") ?? blob.type,
|
|
4163
|
+
body: await blob.text(),
|
|
4164
|
+
blob
|
|
4165
|
+
};
|
|
4166
|
+
}
|
|
4167
|
+
//#endregion
|
|
4168
|
+
//#region source/openapi/lib/request-parameters.ts
|
|
4169
|
+
function structuredIssue(value, type) {
|
|
4170
|
+
if (!type.includes("[]") && !type.includes("object")) return void 0;
|
|
4171
|
+
try {
|
|
4172
|
+
const parsed = JSON.parse(value);
|
|
4173
|
+
if (type.includes("[]") && !Array.isArray(parsed)) return "invalidArray";
|
|
4174
|
+
if (type.includes("object") && !isRecord$1(parsed)) return "invalidObject";
|
|
4175
|
+
} catch {
|
|
4176
|
+
return type.includes("[]") ? "invalidArray" : "invalidObject";
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
function scalarIssue(value, type, format) {
|
|
4180
|
+
if (type.includes("integer") && !Number.isInteger(Number(value))) return "invalidInteger";
|
|
4181
|
+
if (type.includes("number") && !Number.isFinite(Number(value))) return "invalidNumber";
|
|
4182
|
+
if (format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return "invalidDate";
|
|
4183
|
+
if (format === "date-time" && Number.isNaN(Date.parse(value))) return "invalidDateTime";
|
|
4184
|
+
}
|
|
4185
|
+
function validateRequestParameter(spec, parameter, value) {
|
|
4186
|
+
if (!value) return parameter.required ? "required" : void 0;
|
|
4187
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4188
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4189
|
+
const type = schemaToType(schema) ?? "string";
|
|
4190
|
+
const options = Array.isArray(schemaRecord?.enum) ? schemaRecord.enum.map(String) : [];
|
|
4191
|
+
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4192
|
+
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4193
|
+
}
|
|
4194
|
+
function validateRequestParameters(spec, parameters, values) {
|
|
4195
|
+
return Object.fromEntries(parameters.filter((parameter) => parameter.in !== "cookie").flatMap((parameter) => {
|
|
4196
|
+
const key = parameterKey(parameter);
|
|
4197
|
+
const issue = validateRequestParameter(spec, parameter, values[key] ?? "");
|
|
4198
|
+
return issue ? [[key, issue]] : [];
|
|
4199
|
+
}));
|
|
4200
|
+
}
|
|
4201
|
+
//#endregion
|
|
4202
|
+
//#region source/openapi/components/useOpenApiRequestState.ts
|
|
4203
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4204
|
+
const servers = getServers(spec, operation, path, operationSource);
|
|
4205
|
+
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
4206
|
+
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
4207
|
+
const [serverVariables, setServerVariables] = (0, react.useState)(defaultServerVariables(selectedServer));
|
|
4208
|
+
const authOptions = getAuthOptions(spec, operation);
|
|
4209
|
+
const [selectedAuthName, setSelectedAuthName] = (0, react.useState)(authOptions[0]?.key ?? "");
|
|
4210
|
+
const selectedAuth = authOptions.find((option) => option.key === selectedAuthName);
|
|
4211
|
+
const credentialScope = getOpenApiCredentialScope(spec);
|
|
4212
|
+
const credentials = useOpenApiStore((state) => state.credentials[credentialScope] ?? emptyOpenApiCredentials);
|
|
4213
|
+
const setCredential = useOpenApiStore((state) => state.setCredential);
|
|
4214
|
+
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
4215
|
+
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4216
|
+
const [mediaType, setMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
4217
|
+
const [body, setBody] = (0, react.useState)(stringifyExample(getExampleEntries((requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0])?.value, spec)[0]?.value));
|
|
4218
|
+
function selectServer(value) {
|
|
4219
|
+
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
4220
|
+
setSelectedServerKey(value);
|
|
4221
|
+
setServerVariables(defaultServerVariables(nextServer));
|
|
4222
|
+
}
|
|
4223
|
+
function selectMediaType(value) {
|
|
4224
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4225
|
+
setMediaType(value);
|
|
4226
|
+
setBody(stringifyExample(getExampleEntries(content, spec)[0]?.value));
|
|
4227
|
+
}
|
|
4228
|
+
return {
|
|
4229
|
+
servers,
|
|
4230
|
+
selectedServer,
|
|
4231
|
+
selectedServerKey,
|
|
4232
|
+
serverVariables,
|
|
4233
|
+
setServerVariables,
|
|
4234
|
+
serverVariableEntries: Object.entries(selectedServer.variables ?? {}),
|
|
4235
|
+
selectServer,
|
|
4236
|
+
authOptions,
|
|
4237
|
+
selectedAuthName,
|
|
4238
|
+
setSelectedAuthName,
|
|
4239
|
+
selectedAuth,
|
|
4240
|
+
credentialScope,
|
|
4241
|
+
credentials,
|
|
4242
|
+
setCredential,
|
|
4243
|
+
clearCredential,
|
|
4244
|
+
requestContents,
|
|
4245
|
+
mediaType,
|
|
4246
|
+
body,
|
|
4247
|
+
setBody,
|
|
4248
|
+
selectMediaType
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4251
|
+
function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
4252
|
+
const [parameterValues, setParameterValues] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), initialParameterValue(parameter)])));
|
|
4253
|
+
const [parameterEnabled, setParameterEnabled] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
|
|
4254
|
+
const [parameterIssues, setParameterIssues] = (0, react.useState)({});
|
|
4255
|
+
function setParameterGroupValues(grouped, mode) {
|
|
4256
|
+
const keys = new Set(grouped.map(parameterKey));
|
|
4257
|
+
setParameterValues((current) => ({
|
|
4258
|
+
...current,
|
|
4259
|
+
...Object.fromEntries(grouped.map((parameter) => [parameterKey(parameter), mode === "reset" ? initialParameterValue(parameter) : ""]))
|
|
4260
|
+
}));
|
|
4261
|
+
setParameterIssues((current) => Object.fromEntries(Object.entries(current).filter(([key]) => !keys.has(key))));
|
|
4262
|
+
}
|
|
4263
|
+
function setParameterIncluded(parameter, enabled) {
|
|
4264
|
+
const key = parameterKey(parameter);
|
|
4265
|
+
setParameterEnabled((current) => ({
|
|
4266
|
+
...current,
|
|
4267
|
+
[key]: enabled
|
|
4268
|
+
}));
|
|
4269
|
+
if (!enabled) setParameterIssues((current) => {
|
|
4270
|
+
const next = { ...current };
|
|
4271
|
+
delete next[key];
|
|
4272
|
+
return next;
|
|
4273
|
+
});
|
|
4274
|
+
}
|
|
4275
|
+
function updateParameterValue(parameter, value) {
|
|
4276
|
+
const key = parameterKey(parameter);
|
|
4277
|
+
setParameterValues((current) => ({
|
|
4278
|
+
...current,
|
|
4279
|
+
[key]: value
|
|
4280
|
+
}));
|
|
4281
|
+
setParameterIssues((current) => {
|
|
4282
|
+
const next = { ...current };
|
|
4283
|
+
delete next[key];
|
|
4284
|
+
return next;
|
|
4285
|
+
});
|
|
4286
|
+
}
|
|
4287
|
+
function validate(parametersToValidate) {
|
|
4288
|
+
const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
|
|
4289
|
+
setParameterIssues(issues);
|
|
4290
|
+
return issues;
|
|
4291
|
+
}
|
|
4292
|
+
return {
|
|
4293
|
+
parameterValues,
|
|
4294
|
+
parameterEnabled,
|
|
4295
|
+
parameterIssues,
|
|
4296
|
+
setParameterGroupValues,
|
|
4297
|
+
setParameterIncluded,
|
|
4298
|
+
updateParameterValue,
|
|
4299
|
+
validate
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
function useOpenApiRequestExecution() {
|
|
4303
|
+
const [exchange, setExchange] = (0, react.useState)();
|
|
4304
|
+
const [error, setError] = (0, react.useState)("");
|
|
4305
|
+
const [sending, setSending] = (0, react.useState)(false);
|
|
4306
|
+
const requestController = (0, react.useRef)(null);
|
|
4307
|
+
(0, react.useEffect)(() => () => requestController.current?.abort(), []);
|
|
4308
|
+
async function execute(request, corsHint) {
|
|
4309
|
+
requestController.current?.abort();
|
|
4310
|
+
const controller = new AbortController();
|
|
4311
|
+
requestController.current = controller;
|
|
4312
|
+
setSending(true);
|
|
4313
|
+
setError("");
|
|
4314
|
+
setExchange(void 0);
|
|
4315
|
+
try {
|
|
4316
|
+
setExchange(await executeApiRequest(request, { signal: controller.signal }));
|
|
4317
|
+
} catch (cause) {
|
|
4318
|
+
if (cause instanceof DOMException && cause.name === "AbortError") return;
|
|
4319
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
4320
|
+
setError(`${message}. ${corsHint}`);
|
|
4321
|
+
} finally {
|
|
4322
|
+
if (requestController.current === controller) {
|
|
4323
|
+
requestController.current = null;
|
|
4324
|
+
setSending(false);
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
}
|
|
4328
|
+
return {
|
|
4329
|
+
exchange,
|
|
4330
|
+
error,
|
|
4331
|
+
sending,
|
|
4332
|
+
execute
|
|
4333
|
+
};
|
|
4334
|
+
}
|
|
4335
|
+
//#endregion
|
|
4336
|
+
//#region source/openapi/components/OpenApiRequest.tsx
|
|
4337
|
+
function initialParameterValue(spec, parameter) {
|
|
4338
|
+
const schema = resolveSchema(spec, parameter.schema);
|
|
4339
|
+
if (!isRecord$1(schema)) return "";
|
|
4340
|
+
return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
|
|
4341
|
+
}
|
|
4342
|
+
function parameterGroupLabel(location, t) {
|
|
4343
|
+
if (location === "path") return t("openapi.pathParameters");
|
|
4344
|
+
if (location === "header") return t("openapi.headers");
|
|
4345
|
+
if (location === "cookie") return t("openapi.cookies");
|
|
4346
|
+
return t("openapi.queryParameters");
|
|
4347
|
+
}
|
|
4348
|
+
function OpenApiRequestWorkbench(arg0) {
|
|
4349
|
+
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4350
|
+
const t = require_i18n.useBuiltInText();
|
|
4351
|
+
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4352
|
+
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, body, setBody, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4353
|
+
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter));
|
|
4354
|
+
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue } = parameterState;
|
|
4355
|
+
const { exchange, error, sending, execute } = useOpenApiRequestExecution();
|
|
4356
|
+
const parameterGroups = [
|
|
4357
|
+
"cookie",
|
|
4358
|
+
"header",
|
|
4359
|
+
"query"
|
|
4360
|
+
].map((location) => ({
|
|
4361
|
+
location,
|
|
4362
|
+
parameters: parameters.filter((parameter) => parameter.in === location)
|
|
4363
|
+
})).filter((group) => group.parameters.length > 0);
|
|
4364
|
+
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4365
|
+
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4366
|
+
async function sendRequest() {
|
|
4367
|
+
const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
|
|
4368
|
+
const issues = parameterState.validate(enabledParameters);
|
|
4369
|
+
if (Object.keys(issues).length > 0) return;
|
|
4370
|
+
await execute(buildApiRequest({
|
|
4371
|
+
method,
|
|
4372
|
+
path,
|
|
4373
|
+
server: selectedServer,
|
|
4374
|
+
serverVariables,
|
|
4375
|
+
parameters,
|
|
4376
|
+
parameterValues,
|
|
4377
|
+
parameterEnabled,
|
|
4378
|
+
auth: selectedAuth?.schemes.map((option) => ({
|
|
4379
|
+
scheme: option.scheme,
|
|
4380
|
+
value: credentials[option.name] ?? ""
|
|
4381
|
+
})),
|
|
4382
|
+
mediaType,
|
|
4383
|
+
body,
|
|
4384
|
+
baseUrl: window.location.href
|
|
4385
|
+
}), t("openapi.requestCorsHint"));
|
|
4386
|
+
}
|
|
4387
|
+
function renderParameterField(parameter) {
|
|
4388
|
+
const key = parameterKey(parameter);
|
|
4389
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestField, {
|
|
4390
|
+
spec,
|
|
4391
|
+
parameter,
|
|
4392
|
+
value: parameterValues[key] ?? "",
|
|
4393
|
+
enabled: parameterEnabled[key] !== false,
|
|
4394
|
+
issue: parameterIssues[key],
|
|
4395
|
+
onEnabledChange: (enabled) => setParameterIncluded(parameter, enabled),
|
|
4396
|
+
onChange: (value) => updateParameterValue(parameter, value)
|
|
4397
|
+
}, key);
|
|
4398
|
+
}
|
|
4399
|
+
function renderParameterGroup(group) {
|
|
4400
|
+
const { location, parameters: grouped } = group;
|
|
4401
|
+
const actions = location === "cookie" ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4402
|
+
type: "button",
|
|
4403
|
+
title: t("openapi.resetToExample"),
|
|
4404
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4405
|
+
onClick: () => setParameterGroupValues(grouped, "reset"),
|
|
4406
|
+
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)",
|
|
4407
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcwIcon, {
|
|
4408
|
+
className: "size-3.5",
|
|
4409
|
+
"aria-hidden": "true"
|
|
4410
|
+
})
|
|
4411
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4412
|
+
type: "button",
|
|
4413
|
+
title: t("openapi.clear"),
|
|
4414
|
+
"aria-label": t("openapi.clear"),
|
|
4415
|
+
onClick: () => setParameterGroupValues(grouped, "clear"),
|
|
4416
|
+
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)",
|
|
4417
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.EraserIcon, {
|
|
4418
|
+
className: "size-3.5",
|
|
4419
|
+
"aria-hidden": "true"
|
|
4420
|
+
})
|
|
4421
|
+
})] });
|
|
4422
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4423
|
+
title: parameterGroupLabel(location, t),
|
|
4424
|
+
count: grouped.length,
|
|
4425
|
+
defaultOpen: true,
|
|
4426
|
+
actions,
|
|
4427
|
+
children: location === "cookie" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4428
|
+
className: "px-3 py-4 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4429
|
+
children: t("openapi.cookieParametersBrowserManaged")
|
|
4430
|
+
}) : grouped.map(renderParameterField)
|
|
4431
|
+
}, location);
|
|
4432
|
+
}
|
|
4433
|
+
function renderHeader() {
|
|
4434
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4435
|
+
className: "flex min-w-0 items-center gap-1.5 border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-2.5 py-2",
|
|
4436
|
+
children: [
|
|
4437
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: method.toUpperCase() }),
|
|
4438
|
+
servers.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
4439
|
+
label: t("openapi.server"),
|
|
4440
|
+
value: selectedServerKey,
|
|
4441
|
+
options: servers.map((server, index) => ({
|
|
4442
|
+
value: getServerKey(server, index),
|
|
4443
|
+
label: server.url ?? `Server ${index + 1}`,
|
|
4444
|
+
description: server.description
|
|
4445
|
+
})),
|
|
4446
|
+
onChange: selectServer,
|
|
4447
|
+
className: "min-w-0 max-w-48 shrink sm:max-w-48",
|
|
4448
|
+
buttonClassName: "flex h-8 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)"
|
|
4449
|
+
}) : null,
|
|
4450
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4451
|
+
className: "min-w-0 flex-1 overflow-x-auto border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
|
|
4452
|
+
children: path || "/"
|
|
4453
|
+
}),
|
|
4454
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
|
|
4455
|
+
label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
|
|
4456
|
+
busy: sending,
|
|
4457
|
+
text: t("openapi.sendRequest"),
|
|
4458
|
+
onClick: sendRequest
|
|
4459
|
+
}),
|
|
4460
|
+
onClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4461
|
+
type: "button",
|
|
4462
|
+
onClick: onClose,
|
|
4463
|
+
"aria-label": t("openapi.closeRequest"),
|
|
4464
|
+
title: t("openapi.closeRequest"),
|
|
4465
|
+
className: "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)",
|
|
4466
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
|
|
4467
|
+
className: "size-4",
|
|
2972
4468
|
"aria-hidden": "true"
|
|
2973
|
-
})
|
|
2974
|
-
}
|
|
4469
|
+
})
|
|
4470
|
+
}) : null
|
|
4471
|
+
]
|
|
4472
|
+
});
|
|
4473
|
+
}
|
|
4474
|
+
function renderVariables() {
|
|
4475
|
+
if (serverVariableEntries.length === 0) return null;
|
|
4476
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4477
|
+
title: t("openapi.variables"),
|
|
4478
|
+
count: serverVariableEntries.length,
|
|
4479
|
+
defaultOpen: true,
|
|
4480
|
+
children: serverVariableEntries.map(([name, variable]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
4481
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1fr)]",
|
|
4482
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4483
|
+
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)",
|
|
4484
|
+
children: name
|
|
4485
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
4486
|
+
value: serverVariables[name] ?? variable.default ?? "",
|
|
4487
|
+
onChange: (event) => setServerVariables((current) => ({
|
|
4488
|
+
...current,
|
|
4489
|
+
[name]: event.target.value
|
|
4490
|
+
})),
|
|
4491
|
+
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"
|
|
4492
|
+
})]
|
|
4493
|
+
}, name))
|
|
4494
|
+
});
|
|
4495
|
+
}
|
|
4496
|
+
function renderRequestBody() {
|
|
4497
|
+
if (requestContents.length === 0) return null;
|
|
4498
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(RequestSection, {
|
|
4499
|
+
title: t("openapi.requestBody"),
|
|
4500
|
+
count: 1,
|
|
4501
|
+
defaultOpen: true,
|
|
4502
|
+
className: "open:grid open:min-h-55 open:grow open:shrink open:basis-55 open:grid-rows-[auto_minmax(11rem,1fr)]",
|
|
4503
|
+
contentClassName: (0, clsx.default)("grid h-full min-h-0", requestContents.length > 1 ? "grid-rows-[auto_minmax(11rem,1fr)]" : "grid-rows-[minmax(11rem,1fr)]"),
|
|
4504
|
+
children: [requestContents.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
4505
|
+
label: t("openapi.mediaType"),
|
|
4506
|
+
value: mediaType,
|
|
4507
|
+
options: requestContents.map((entry) => ({
|
|
4508
|
+
value: entry.mediaType,
|
|
4509
|
+
label: entry.mediaType
|
|
4510
|
+
})),
|
|
4511
|
+
onChange: selectMediaType
|
|
4512
|
+
}) }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
4513
|
+
"aria-label": t("openapi.requestBody"),
|
|
4514
|
+
value: body,
|
|
4515
|
+
onChange: (event) => setBody(event.target.value),
|
|
4516
|
+
spellCheck: false,
|
|
4517
|
+
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)"
|
|
2975
4518
|
})]
|
|
2976
|
-
})
|
|
4519
|
+
});
|
|
4520
|
+
}
|
|
4521
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4522
|
+
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"),
|
|
4523
|
+
children: [renderHeader(), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4524
|
+
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
4525
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4526
|
+
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4527
|
+
children: [
|
|
4528
|
+
authOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4529
|
+
title: t("openapi.authentication"),
|
|
4530
|
+
count: selectedAuth?.schemes.length ?? 0,
|
|
4531
|
+
defaultOpen: true,
|
|
4532
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiAuthPanel, {
|
|
4533
|
+
authOptions,
|
|
4534
|
+
selectedAuthName,
|
|
4535
|
+
selectedAuth,
|
|
4536
|
+
authValues: credentials,
|
|
4537
|
+
onSelectAuth: setSelectedAuthName,
|
|
4538
|
+
onChangeAuthValue: (name, value) => setCredential(credentialScope, name, value),
|
|
4539
|
+
onClearAuthValue: (name) => clearCredential(credentialScope, name)
|
|
4540
|
+
})
|
|
4541
|
+
}) : null,
|
|
4542
|
+
renderVariables(),
|
|
4543
|
+
pathParameters.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4544
|
+
title: t("openapi.pathParameters"),
|
|
4545
|
+
count: pathParameters.length,
|
|
4546
|
+
defaultOpen: true,
|
|
4547
|
+
children: pathParameters.map(renderParameterField)
|
|
4548
|
+
}) : null,
|
|
4549
|
+
parameterGroups.map(renderParameterGroup),
|
|
4550
|
+
renderRequestBody(),
|
|
4551
|
+
!hasRequestConfiguration ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequestSection, {
|
|
4552
|
+
title: t("openapi.requestConfiguration"),
|
|
4553
|
+
count: 0,
|
|
4554
|
+
defaultOpen: true,
|
|
4555
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
4556
|
+
className: "px-3 py-5 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
4557
|
+
children: t("openapi.noRequestConfiguration")
|
|
4558
|
+
})
|
|
4559
|
+
}) : null
|
|
4560
|
+
]
|
|
4561
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4562
|
+
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",
|
|
4563
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiResponseViewer, {
|
|
4564
|
+
exchange,
|
|
4565
|
+
error
|
|
4566
|
+
})
|
|
4567
|
+
})]
|
|
4568
|
+
})]
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
function OpenApiRequestDialog(arg0) {
|
|
4572
|
+
const { open, onClose, ...workbenchProps } = arg0;
|
|
4573
|
+
const t = require_i18n.useBuiltInText();
|
|
4574
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.Dialog, {
|
|
4575
|
+
open,
|
|
4576
|
+
onClose: () => {},
|
|
4577
|
+
className: "relative z-50",
|
|
4578
|
+
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", {
|
|
4579
|
+
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
4580
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_headlessui_react.DialogPanel, {
|
|
4581
|
+
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))]",
|
|
4582
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.DialogTitle, {
|
|
4583
|
+
className: "sr-only",
|
|
4584
|
+
children: t("openapi.tryRequest")
|
|
4585
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestWorkbench, {
|
|
4586
|
+
...workbenchProps,
|
|
4587
|
+
compact: true,
|
|
4588
|
+
onClose
|
|
4589
|
+
})]
|
|
4590
|
+
})
|
|
4591
|
+
})]
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4594
|
+
//#endregion
|
|
4595
|
+
//#region source/openapi/components/OpenApiOperation.tsx
|
|
4596
|
+
function EndpointPath(arg0) {
|
|
4597
|
+
const { path, copied = false, onCopy } = arg0;
|
|
4598
|
+
const t = require_i18n.useBuiltInText();
|
|
4599
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4600
|
+
className: "flex min-w-0 flex-1 items-center gap-2 overflow-hidden",
|
|
4601
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4602
|
+
className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
4603
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4604
|
+
className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
|
|
4605
|
+
children: path || "/"
|
|
4606
|
+
})
|
|
4607
|
+
}), onCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4608
|
+
type: "button",
|
|
4609
|
+
"aria-label": copied ? t("actions.copied") : t("actions.copy"),
|
|
4610
|
+
title: copied ? t("actions.copied") : t("actions.copy"),
|
|
4611
|
+
onClick: onCopy,
|
|
4612
|
+
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"),
|
|
4613
|
+
children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckIcon, {
|
|
4614
|
+
className: "h-3.5 w-3.5",
|
|
4615
|
+
"aria-hidden": "true"
|
|
4616
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CopyIcon, {
|
|
4617
|
+
className: "h-3.5 w-3.5",
|
|
4618
|
+
"aria-hidden": "true"
|
|
4619
|
+
})
|
|
4620
|
+
}) : null]
|
|
2977
4621
|
});
|
|
2978
4622
|
}
|
|
2979
4623
|
function getServerPreviewUrl(server, variables) {
|
|
@@ -2999,7 +4643,7 @@ function getDefaultResponseStatus(operation, spec) {
|
|
|
2999
4643
|
return orderedResponses.find(({ status }) => status === "default")?.status ?? orderedResponses.find(({ status }) => status.startsWith("2"))?.status ?? orderedResponses[0]?.status ?? "";
|
|
3000
4644
|
}
|
|
3001
4645
|
function ServerUrlValue(arg0) {
|
|
3002
|
-
const { server, variables, open, interactive, onToggle } = arg0;
|
|
4646
|
+
const { servers, selectedKey, server, variables, open, interactive, directSelect, onSelect, onToggle } = arg0;
|
|
3003
4647
|
const url = getServerPreviewUrl(server, variables);
|
|
3004
4648
|
const protocolLabel = getServerProtocolLabel(server, variables);
|
|
3005
4649
|
if (!interactive) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
@@ -3022,12 +4666,47 @@ function ServerUrlValue(arg0) {
|
|
|
3022
4666
|
})]
|
|
3023
4667
|
})]
|
|
3024
4668
|
});
|
|
4669
|
+
if (directSelect) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
4670
|
+
label: "Server",
|
|
4671
|
+
value: selectedKey,
|
|
4672
|
+
options: servers.map((option, index) => ({
|
|
4673
|
+
value: getServerKey(option, index),
|
|
4674
|
+
label: getServerLabel(option, index),
|
|
4675
|
+
description: option.description
|
|
4676
|
+
})),
|
|
4677
|
+
onChange: onSelect,
|
|
4678
|
+
className: "w-8 shrink-0 sm:w-fit sm:min-w-16 sm:max-w-(--clarify-server-url-max-width)",
|
|
4679
|
+
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",
|
|
4680
|
+
buttonContent: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4681
|
+
className: "sm:hidden",
|
|
4682
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
4683
|
+
className: "h-4 w-4",
|
|
4684
|
+
"aria-hidden": "true"
|
|
4685
|
+
})
|
|
4686
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
4687
|
+
className: "hidden min-w-0 items-center gap-1 overflow-hidden sm:flex",
|
|
4688
|
+
children: [
|
|
4689
|
+
protocolLabel ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4690
|
+
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",
|
|
4691
|
+
children: protocolLabel
|
|
4692
|
+
}) : null,
|
|
4693
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4694
|
+
className: "truncate font-semibold text-xs",
|
|
4695
|
+
children: url
|
|
4696
|
+
}),
|
|
4697
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
4698
|
+
className: "h-3.5 w-3.5 shrink-0 text-zinc-400 transition-transform group-data-open:rotate-180",
|
|
4699
|
+
"aria-hidden": "true"
|
|
4700
|
+
})
|
|
4701
|
+
]
|
|
4702
|
+
})] })
|
|
4703
|
+
});
|
|
3025
4704
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
3026
4705
|
type: "button",
|
|
3027
4706
|
"aria-expanded": open,
|
|
3028
4707
|
"aria-label": "Server",
|
|
3029
4708
|
onClick: onToggle,
|
|
3030
|
-
className: (0, clsx.default)("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
|
|
4709
|
+
className: (0, clsx.default)("flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-lg bg-(--clarify-ui-subtle-background) 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) sm:w-auto sm:min-w-16 sm:max-w-(--clarify-server-url-max-width) sm:px-1.5", open ? "bg-(--clarify-ui-active-background) text-(--clarify-theme-tokens-colors-foreground)" : null),
|
|
3031
4710
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3032
4711
|
className: "sm:hidden",
|
|
3033
4712
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
@@ -3046,7 +4725,7 @@ function ServerUrlValue(arg0) {
|
|
|
3046
4725
|
children: url
|
|
3047
4726
|
}),
|
|
3048
4727
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDownIcon, {
|
|
3049
|
-
className: "h-3.5 w-3.5 shrink-0 text-zinc-400",
|
|
4728
|
+
className: (0, clsx.default)("h-3.5 w-3.5 shrink-0 text-zinc-400 transition-transform", open && "rotate-180"),
|
|
3050
4729
|
"aria-hidden": "true"
|
|
3051
4730
|
})
|
|
3052
4731
|
]
|
|
@@ -3113,51 +4792,10 @@ function ServerPanel(arg0) {
|
|
|
3113
4792
|
})
|
|
3114
4793
|
});
|
|
3115
4794
|
}
|
|
3116
|
-
function AuthPanel(arg0) {
|
|
3117
|
-
const { authOptions, selectedAuthName, selectedAuth, authValues, onSelectAuth, onChangeAuthValue } = arg0;
|
|
3118
|
-
if (authOptions.length === 0) return null;
|
|
3119
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3120
|
-
className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-ui-subtle-background) p-3",
|
|
3121
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3122
|
-
className: "grid gap-3 sm:grid-cols-(--clarify-openapi-control-grid)",
|
|
3123
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3124
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3125
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3126
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3127
|
-
children: "Auth"
|
|
3128
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
3129
|
-
label: "Auth",
|
|
3130
|
-
value: selectedAuthName,
|
|
3131
|
-
options: authOptions.map(({ name, scheme }) => ({
|
|
3132
|
-
value: name,
|
|
3133
|
-
label: name,
|
|
3134
|
-
description: authLabel(name, scheme)
|
|
3135
|
-
})),
|
|
3136
|
-
onChange: onSelectAuth
|
|
3137
|
-
})]
|
|
3138
|
-
}), selectedAuth ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3139
|
-
className: "flex min-w-0 flex-col gap-1.5",
|
|
3140
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3141
|
-
className: "text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3142
|
-
children: "Credential"
|
|
3143
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3144
|
-
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",
|
|
3145
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3146
|
-
className: "mr-2 shrink-0 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
3147
|
-
children: selectedAuth.scheme.type === "apiKey" ? selectedAuth.scheme.in ?? "apiKey" : selectedAuth.scheme.scheme ?? selectedAuth.scheme.type ?? "token"
|
|
3148
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3149
|
-
value: authValues[selectedAuth.name] ?? "",
|
|
3150
|
-
placeholder: authPlaceholder(selectedAuth),
|
|
3151
|
-
onChange: (event) => onChangeAuthValue(selectedAuth.name, event.target.value),
|
|
3152
|
-
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)"
|
|
3153
|
-
})]
|
|
3154
|
-
})]
|
|
3155
|
-
}) : null]
|
|
3156
|
-
})
|
|
3157
|
-
});
|
|
3158
|
-
}
|
|
3159
4795
|
function EndpointIdentity(arg0) {
|
|
3160
|
-
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen,
|
|
4796
|
+
const { method, operationSource, path, servers, selectedServerKey, selectedServer, serverVariables, serverOpen, onSelectServer, onChangeServerVariable, onToggleServer, onTryRequest } = arg0;
|
|
4797
|
+
const t = require_i18n.useBuiltInText();
|
|
4798
|
+
const directServerSelect = servers.length > 1 && servers.every((server) => Object.keys(server.variables ?? {}).length === 0);
|
|
3161
4799
|
const serverInteractive = servers.length > 1 || Object.keys(selectedServer.variables ?? {}).length > 0;
|
|
3162
4800
|
const [copiedUrl, setCopiedUrl] = (0, react.useState)(false);
|
|
3163
4801
|
const fullUrl = getFullEndpointUrl(selectedServer, serverVariables, path);
|
|
@@ -3170,58 +4808,41 @@ function EndpointIdentity(arg0) {
|
|
|
3170
4808
|
if (await require_PageActions.copyTextToClipboard(fullUrl)) setCopiedUrl(true);
|
|
3171
4809
|
}
|
|
3172
4810
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3173
|
-
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",
|
|
3174
|
-
children: [
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
serverInteractive && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
|
|
3209
|
-
servers,
|
|
3210
|
-
selectedKey: selectedServerKey,
|
|
3211
|
-
selectedServer,
|
|
3212
|
-
variables: serverVariables,
|
|
3213
|
-
onSelectServer,
|
|
3214
|
-
onChangeVariable: onChangeServerVariable
|
|
3215
|
-
}) : null,
|
|
3216
|
-
authOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AuthPanel, {
|
|
3217
|
-
authOptions,
|
|
3218
|
-
selectedAuthName,
|
|
3219
|
-
selectedAuth,
|
|
3220
|
-
authValues,
|
|
3221
|
-
onSelectAuth,
|
|
3222
|
-
onChangeAuthValue
|
|
3223
|
-
}) : null
|
|
3224
|
-
]
|
|
4811
|
+
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",
|
|
4812
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4813
|
+
className: "flex min-w-0 items-center gap-1.5 overflow-hidden px-2.5 py-2",
|
|
4814
|
+
children: [
|
|
4815
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method }),
|
|
4816
|
+
operationSource === "webhook" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: "WEBHOOK" }) : null,
|
|
4817
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerUrlValue, {
|
|
4818
|
+
servers,
|
|
4819
|
+
selectedKey: selectedServerKey,
|
|
4820
|
+
server: selectedServer,
|
|
4821
|
+
variables: serverVariables,
|
|
4822
|
+
open: serverOpen,
|
|
4823
|
+
interactive: serverInteractive,
|
|
4824
|
+
directSelect: directServerSelect,
|
|
4825
|
+
onSelect: onSelectServer,
|
|
4826
|
+
onToggle: onToggleServer
|
|
4827
|
+
}),
|
|
4828
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointPath, {
|
|
4829
|
+
path,
|
|
4830
|
+
copied: copiedUrl,
|
|
4831
|
+
onCopy: handleCopyUrl
|
|
4832
|
+
}),
|
|
4833
|
+
onTryRequest ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
|
|
4834
|
+
label: t("openapi.tryRequest"),
|
|
4835
|
+
onClick: onTryRequest
|
|
4836
|
+
}) : null
|
|
4837
|
+
]
|
|
4838
|
+
}), serverInteractive && !directServerSelect && serverOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ServerPanel, {
|
|
4839
|
+
servers,
|
|
4840
|
+
selectedKey: selectedServerKey,
|
|
4841
|
+
selectedServer,
|
|
4842
|
+
variables: serverVariables,
|
|
4843
|
+
onSelectServer,
|
|
4844
|
+
onChangeVariable: onChangeServerVariable
|
|
4845
|
+
}) : null]
|
|
3225
4846
|
});
|
|
3226
4847
|
}
|
|
3227
4848
|
function OpenApiOperation(arg0) {
|
|
@@ -3234,8 +4855,9 @@ function OpenApiOperation(arg0) {
|
|
|
3234
4855
|
const authState = useOperationAuthState(spec, operation);
|
|
3235
4856
|
const [linkedExampleKey, setLinkedExampleKey] = (0, react.useState)("");
|
|
3236
4857
|
const [selectedResponseStatus, setSelectedResponseStatus] = (0, react.useState)(() => getDefaultResponseStatus(operation, spec));
|
|
4858
|
+
const [requestOpen, setRequestOpen] = (0, react.useState)(false);
|
|
3237
4859
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3238
|
-
className: "clarify-
|
|
4860
|
+
className: "clarify-openai-endpoint scroll-mt-24 pb-16 first:pt-0 last:pb-0",
|
|
3239
4861
|
"aria-labelledby": id,
|
|
3240
4862
|
children: [
|
|
3241
4863
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Heading, {
|
|
@@ -3251,23 +4873,19 @@ function OpenApiOperation(arg0) {
|
|
|
3251
4873
|
selectedServer: serverState.selectedServer,
|
|
3252
4874
|
serverVariables: serverState.serverVariables,
|
|
3253
4875
|
serverOpen: serverState.serverOpen,
|
|
3254
|
-
authOptions: authState.authOptions,
|
|
3255
|
-
selectedAuthName: authState.selectedAuthName,
|
|
3256
|
-
selectedAuth: authState.selectedAuth,
|
|
3257
|
-
authValues: authState.authValues,
|
|
3258
|
-
authOpen: authState.authOpen,
|
|
3259
4876
|
onSelectServer: serverState.onSelectServer,
|
|
3260
4877
|
onChangeServerVariable: serverState.onChangeServerVariable,
|
|
3261
|
-
onToggleServer:
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
4878
|
+
onToggleServer: serverState.onToggleServer,
|
|
4879
|
+
onTryRequest: () => setRequestOpen(true)
|
|
4880
|
+
}),
|
|
4881
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestDialog, {
|
|
4882
|
+
open: requestOpen,
|
|
4883
|
+
onClose: () => setRequestOpen(false),
|
|
4884
|
+
spec,
|
|
4885
|
+
path,
|
|
4886
|
+
method,
|
|
4887
|
+
operation,
|
|
4888
|
+
operationSource
|
|
3271
4889
|
}),
|
|
3272
4890
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointRequest, {
|
|
3273
4891
|
spec,
|
|
@@ -3397,6 +5015,12 @@ Object.defineProperty(exports, "OpenApiOperation", {
|
|
|
3397
5015
|
return OpenApiOperation;
|
|
3398
5016
|
}
|
|
3399
5017
|
});
|
|
5018
|
+
Object.defineProperty(exports, "OpenApiRequestWorkbench", {
|
|
5019
|
+
enumerable: true,
|
|
5020
|
+
get: function() {
|
|
5021
|
+
return OpenApiRequestWorkbench;
|
|
5022
|
+
}
|
|
5023
|
+
});
|
|
3400
5024
|
Object.defineProperty(exports, "Pre", {
|
|
3401
5025
|
enumerable: true,
|
|
3402
5026
|
get: function() {
|
|
@@ -3421,6 +5045,30 @@ Object.defineProperty(exports, "ResponseExamplesPanel", {
|
|
|
3421
5045
|
return ResponseExamplesPanel;
|
|
3422
5046
|
}
|
|
3423
5047
|
});
|
|
5048
|
+
Object.defineProperty(exports, "Step", {
|
|
5049
|
+
enumerable: true,
|
|
5050
|
+
get: function() {
|
|
5051
|
+
return Step;
|
|
5052
|
+
}
|
|
5053
|
+
});
|
|
5054
|
+
Object.defineProperty(exports, "Steps", {
|
|
5055
|
+
enumerable: true,
|
|
5056
|
+
get: function() {
|
|
5057
|
+
return Steps;
|
|
5058
|
+
}
|
|
5059
|
+
});
|
|
5060
|
+
Object.defineProperty(exports, "TabItem", {
|
|
5061
|
+
enumerable: true,
|
|
5062
|
+
get: function() {
|
|
5063
|
+
return TabItem;
|
|
5064
|
+
}
|
|
5065
|
+
});
|
|
5066
|
+
Object.defineProperty(exports, "Tabs", {
|
|
5067
|
+
enumerable: true,
|
|
5068
|
+
get: function() {
|
|
5069
|
+
return Tabs;
|
|
5070
|
+
}
|
|
5071
|
+
});
|
|
3424
5072
|
Object.defineProperty(exports, "Tag", {
|
|
3425
5073
|
enumerable: true,
|
|
3426
5074
|
get: function() {
|
|
@@ -3494,4 +5142,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
3494
5142
|
}
|
|
3495
5143
|
});
|
|
3496
5144
|
|
|
3497
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5145
|
+
//# sourceMappingURL=OpenApiOperation-D-5uE5v7.cjs.map
|