import Prism from "prismjs" import * as React from "react" import { Codicon } from "./Codicon" export function CodeBlock({ children, "data-language": language }) { const ref = React.useRef(null) const timeoutRef = React.useRef(null) const [copied, setCopied] = React.useState(false) React.useEffect(() => { if (ref.current) Prism.highlightElement(ref.current, false) }, [children]) React.useEffect(() => { return () => { if (timeoutRef.current) { clearTimeout(timeoutRef.current) } } }, []) const handleCopy = async () => { const code = ref.current?.textContent || "" try { await navigator.clipboard.writeText(code) setCopied(true) if (timeoutRef.current) { clearTimeout(timeoutRef.current) } timeoutRef.current = setTimeout(() => setCopied(false), 2000) } catch (err) { console.error("Failed to copy code:", err) } } return (
        {children}
      
) }