'use client' import { isValidElement, type ReactNode } from 'react' import { CopyButton } from './CopyButton' type CodeWrapperProps = { language?: string children?: ReactNode } function getTextContent(node: ReactNode): string { if (node === null || typeof node === 'boolean') return '' if (typeof node === 'string' || typeof node === 'number') return String(node) if (Array.isArray(node)) return node.map(getTextContent).join('') if (isValidElement(node)) { const props = node.props as { children?: ReactNode } return getTextContent(props.children) } return '' } export function CodeWrapper({ language, children }: CodeWrapperProps) { const text = getTextContent(children).replace(/\n$/, '') const lineCount = text.length === 0 ? 1 : text.split('\n').length return (
{Array.from({ length: lineCount }, (_, i) => ( {i + 1} ))}
          {children}
        
) }