"use client";
import { j as r } from "./index.esm38.js";
import { useState as d, useEffect as j } from "react";
import h from "./index.esm40.js";
import t from "./index.esm63.js";
import { Root as p } from "./index.esm8.js";
import { Typography as u } from "./index.esm9.js";
const g = ({
  code: s,
  lang: n = "text",
  filename: i,
  className: f,
  testId: a
}) => {
  const [l, x] = d(""), [c, m] = d(null);
  return j(() => {
    let o = !1;
    return m(null), import("./index.esm62.js").then(
      ({ codeToHtml: e }) => e(s, {
        lang: n,
        themes: {
          light: "github-light",
          dark: "github-dark"
        }
      })
    ).then((e) => {
      o || x(e);
    }).catch((e) => {
      o || m(e instanceof Error ? e : new Error(String(e)));
    }), () => {
      o = !0;
    };
  }, [s, n]), c ? /* @__PURE__ */ r.jsx(
    p,
    {
      as: "div",
      className: h(t.root, t.error),
      testId: a,
      role: "alert",
      children: /* @__PURE__ */ r.jsxs(u, { variant: "caption", as: "span", color: "secondary", children: [
        "Ошибка подсветки: ",
        c.message
      ] })
    }
  ) : /* @__PURE__ */ r.jsxs(p, { className: h(t.root, f), testId: a, children: [
    i != null && /* @__PURE__ */ r.jsx(u, { variant: "caption", as: "div", className: t.filename, children: i }),
    /* @__PURE__ */ r.jsx("div", { className: t.code, children: l ? /* @__PURE__ */ r.jsx(
      "div",
      {
        dangerouslySetInnerHTML: { __html: l },
        suppressHydrationWarning: !0
      }
    ) : /* @__PURE__ */ r.jsx("pre", { children: /* @__PURE__ */ r.jsx("code", { children: s }) }) })
  ] });
};
g.displayName = "CodeBlock";
export {
  g as CodeBlock
};
//# sourceMappingURL=index.esm26.js.map
