"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MarkdownRenderer = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const useMarkdownTransform_1 = require("../../../hooks/useMarkdownTransform.js");
const useRemend_1 = require("../../../hooks/useRemend.js");
const cn_1 = require("../../../utils/cn.js");
const markdownUtils_1 = require("../../../utils/markdownUtils.js");
require("./MarkdownRenderer.css");
const b = (0, cn_1.block)('markdown-renderer');
function MarkdownRendererComponent({ content, className, qa, transformOptions, shouldParseIncompleteMarkdown = false, }) {
    const closedContent = (0, useRemend_1.useRemend)(content, shouldParseIncompleteMarkdown);
    const html = (0, useMarkdownTransform_1.useMarkdownTransform)(closedContent, transformOptions);
    return ((0, jsx_runtime_1.jsx)("div", { className: b(null, [className, 'yfm']), "data-qa": qa, dangerouslySetInnerHTML: { __html: html } }));
}
exports.MarkdownRenderer = (0, react_1.memo)(MarkdownRendererComponent, (prevProps, nextProps) => {
    if (prevProps.content !== nextProps.content) {
        return false;
    }
    if (prevProps.shouldParseIncompleteMarkdown !== nextProps.shouldParseIncompleteMarkdown) {
        return false;
    }
    if (prevProps.className !== nextProps.className) {
        return false;
    }
    if (prevProps.qa !== nextProps.qa) {
        return false;
    }
    return (0, markdownUtils_1.areOptionsEqual)(prevProps.transformOptions, nextProps.transformOptions);
});
exports.MarkdownRenderer.displayName = 'MarkdownRenderer';
//# sourceMappingURL=MarkdownRenderer.js.map
