"use client" import * as React from "react" import { CopyButton } from "@/components/actions/copy-button" import { cn } from "@/lib/utils" export type CodeBlockProps = React.ComponentProps<"div"> & { code: string language?: string title?: React.ReactNode showCopy?: boolean wrap?: boolean lineNumbers?: boolean highlightLines?: number[] | readonly number[] maxHeight?: number | string } function CodeBlock({ code, language, title, showCopy = true, wrap = false, lineNumbers = false, highlightLines = [], maxHeight, className, ...props }: CodeBlockProps) { const lines = React.useMemo(() => code.split("\n"), [code]) const highlightedLineSet = React.useMemo(() => new Set(highlightLines), [highlightLines]) return (
{(title || language || showCopy) && (
{title && {title}} {language && {language}}
{showCopy && }
)}
        {lineNumbers ? (
          
            {lines.map((line, index) => (
              
                {index + 1}
                {line || " "}
              
            ))}
          
        ) : (
          
            {lines.map((line, index) => (
              
                {line || " "}
              
            ))}
          
        )}
      
) } export { CodeBlock }