import { jsx as _jsx } from "react/jsx-runtime";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { visit, SKIP } from 'unist-util-visit';
function remarkRemoveComments() {
    return (tree) => {
        visit(tree, 'html', (node, index, parent) => {
            if (node.value && /<!--[\s\S]*?-->/.test(node.value)) {
                if (parent && typeof index === 'number' && parent.children) {
                    parent.children.splice(index, 1);
                    return [SKIP, index];
                }
            }
        });
    };
}
export function MarkdownRenderer({ children, components, remarkPlugins = [], removeComments = true }) {
    const plugins = [remarkGfm, ...remarkPlugins];
    if (removeComments) {
        plugins.push(remarkRemoveComments);
    }
    return (_jsx(Markdown, { remarkPlugins: plugins, components: components, children: children }));
}
//# sourceMappingURL=MarkdownRenderer.js.map