// ApiBlock v2 — simplified to URL + body only (no auth headers).
// Both sides get unified syntax highlighting via token-array data.
const { useState: useStateApi } = React;
function ColoredLines({ lines }) {
return (
{lines.map((line, i) => (
{line.length === 0 ? "\u00a0" : line.map((tok, j) => (
{tok.v}
))}
))}
);
}
function ApiBlock() {
const { CODE_LINES, RESPONSE_LINES } = window.__DATA;
const [lang, setLang] = useStateApi("curl");
const [copied, setCopied] = useStateApi(false);
const langs = [
{ k: "curl", l: "cURL" },
{ k: "js", l: "Node.js" },
{ k: "python", l: "Python" },
{ k: "go", l: "Go" },
];
function copy() {
setCopied(true);
setTimeout(() => setCopied(false), 1400);
}
return (
{/* LEFT: request */}
{langs.map((t) => (
setLang(t.k)}
>
{t.l}
))}
{copied ? "✓ скопировано" : "копировать"}
{/* RIGHT: response */}
);
}
Object.assign(window, { ApiBlock });