"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withMermaid = withMermaid;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@diplodoc/mermaid-extension/react");
const useMermaidRuntime_1 = require("./useMermaidRuntime.js");
function withMermaid(opts) {
    return (Component) => (0, react_1.forwardRef)(function WithLatex(props, ref) {
        const { meta, html, mermaidConfig } = props;
        const renderMermaid = (0, react_2.useMermaid)();
        (0, useMermaidRuntime_1.useMermaidRuntime)(meta, opts.runtime);
        (0, react_1.useEffect)(() => {
            renderMermaid(mermaidConfig);
        }, [html, mermaidConfig, renderMermaid]);
        return (0, jsx_runtime_1.jsx)(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
