import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef, useEffect } from 'react';
import { useDiplodocEmbeddedContentController } from '@diplodoc/html-extension/react';
import { useYfmHtmlBlockRuntime } from "./useYfmHtmlBlockRuntime.js";
export function withYfmHtmlBlock(opts) {
    return (Component) => forwardRef(function WithYfmHtml(props, ref) {
        const { meta, html, yfmHtmlBlockConfig, htmlRuntimeConfig } = props;
        useYfmHtmlBlockRuntime(meta, opts.runtime, htmlRuntimeConfig);
        const yfmHtmlBlock = useDiplodocEmbeddedContentController();
        useEffect(() => {
            if (yfmHtmlBlock) {
                if (yfmHtmlBlockConfig) {
                    yfmHtmlBlock.setConfig(yfmHtmlBlockConfig);
                }
                yfmHtmlBlock.initialize();
            }
        }, [yfmHtmlBlock, html, yfmHtmlBlockConfig]);
        return _jsx(Component, { ...props, ref: ref });
    });
}
//# sourceMappingURL=index.js.map
