import React from "react"; import CopyBtn from "@/components/ui/copy-button"; import { cn } from "@/lib/utils"; import Markdown from "react-markdown"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { dracula } from "react-syntax-highlighter/dist/cjs/styles/prism"; import remarkBreaks from "remark-breaks"; import remarkGfm from "remark-gfm"; function PreWithCopyBtn({ className, ...props }: React.ComponentProps<"pre">) { const ref = React.useRef(null); return ( { return ref.current?.textContent ?? ""; }} />
    
  );
}

export function MarkdownComponent({
  children: markdown,
}: {
  children: string;
}) {
  return (
    ;
        },
        code({ className, children, ...props }) {
          const match = /language-(\w+)/.exec(className ?? "");
          return match ? (
            // @ts-expect-error -- Refs are not compatible for some reason
            
              {String(children).replace(/\n$/, "")}
            
          ) : (
            
              {children}
            
          );
        },
      }}
    >
      {markdown}
    
  );
}