function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
import { ConfigProvider } from "antd";
import classNames from "clsx";
import React, { useContext, useRef } from "react";
import { MarkdownRenderer } from "../MarkdownRenderer";
import I18nBoundary from "./I18nBoundary";
import { PluginContext } from "./plugin";
import { useStyle } from "./style";
import { sanitizeEditorChromeStyle } from "./utils/sanitizeChromeStyle";
/**
 * 只读 + renderMode=markdown 专用外壳：不挂载 Slate / EditorStore，不执行 parserMdToSchema 等编辑侧逻辑。
 * 与 BaseMarkdownEditorSlate 二选一，由 BaseMarkdownEditor 根入口按 props 分流。
 */ var ReadonlyMarkdownEditorView = function ReadonlyMarkdownEditorView(props) {
    var _ref, _props_streaming, _props_isFinished;
    var id = props.id, _props_initValue = props.initValue, initValue = _props_initValue === void 0 ? '' : _props_initValue, width = props.width, className = props.className, reportMode = props.reportMode, slideMode = props.slideMode, tmp = props.contentStyle, rawContentStyle = tmp === void 0 ? {
        height: '100%'
    } : tmp, rawStyle = props.style, height = props.height, children = props.children;
    var contentStyle = sanitizeEditorChromeStyle(rawContentStyle);
    var rootStyle = sanitizeEditorChromeStyle(rawStyle);
    var markdownContainerRef = useRef(null);
    var isStreaming = (_ref = (_props_streaming = props.streaming) !== null && _props_streaming !== void 0 ? _props_streaming : props.typewriter) !== null && _ref !== void 0 ? _ref : false;
    var context = useContext(ConfigProvider.ConfigContext);
    var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor');
    var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    var _obj;
    return wrapSSR(/*#__PURE__*/ React.createElement(I18nBoundary, null, /*#__PURE__*/ React.createElement(PluginContext.Provider, {
        value: props.plugins || []
    }, /*#__PURE__*/ React.createElement("div", {
        id: id ? String(id) || undefined : undefined,
        className: classNames(baseClassName, 'markdown-editor', hashId, className, (_obj = {}, _define_property(_obj, "".concat(baseClassName, "-readonly"), true), _define_property(_obj, "".concat(baseClassName, "-report"), reportMode), _define_property(_obj, "".concat(baseClassName, "-slide"), slideMode), _obj)),
        "data-testid": "markdown-editor",
        style: _object_spread({
            width: width || '100%',
            height: height || 'auto'
        }, rootStyle),
        ref: markdownContainerRef
    }, /*#__PURE__*/ React.createElement(MarkdownRenderer, {
        content: initValue,
        streaming: isStreaming,
        isFinished: (_props_isFinished = props.isFinished) !== null && _props_isFinished !== void 0 ? _props_isFinished : !isStreaming,
        queueOptions: props.queueOptions,
        streamingParagraphAnimation: props.streamingParagraphAnimation,
        plugins: props.plugins,
        remarkPlugins: props.markdownToHtmlOptions,
        codeProps: props.codeProps,
        apaasify: props.apaasify,
        style: _object_spread({
            height: '100%'
        }, contentStyle),
        prefixCls: baseClassName,
        fncProps: props.fncProps,
        linkConfig: props.linkConfig,
        eleRender: props.eleRender,
        fileMapConfig: props.fileMapConfig
    }), children))));
};
export default ReadonlyMarkdownEditorView;
