import { jsx } from "react/jsx-runtime";
import { tcv, ScrollArea } from "@choiceform/design-system";
import { CodeBlockCode } from "./code-block-code.js";
const codeBlockTv = tcv({
  slots: {
    code: "overflow-hidden",
    content: "flex w-fit flex-col overflow-clip"
  }
});
function BlockCode(props) {
  const { code, className, codeBlock } = props;
  if (!codeBlock) return null;
  const { language, isExpanded, codeExpanded, scrollRef, contentRef, lineCount, lineThreshold } = codeBlock;
  if (!isExpanded) {
    return null;
  }
  const tv = codeBlockTv();
  const shouldLimitHeight = lineCount > lineThreshold && !codeExpanded;
  return /* @__PURE__ */ jsx("div", { className: tv.code(), children: /* @__PURE__ */ jsx(ScrollArea, { orientation: "both", children: /* @__PURE__ */ jsx(
    ScrollArea.Viewport,
    {
      ref: scrollRef,
      style: {
        maxHeight: shouldLimitHeight ? `${lineThreshold * 14 + 32}px` : "none"
      },
      children: /* @__PURE__ */ jsx(
        ScrollArea.Content,
        {
          ref: contentRef,
          className: tv.content(),
          children: /* @__PURE__ */ jsx(
            CodeBlockCode,
            {
              code,
              language,
              className
            }
          )
        }
      )
    }
  ) }) });
}
export {
  BlockCode
};
//# sourceMappingURL=block-code.js.map
