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;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
import { ConfigProvider } from "antd";
import classNames from "classnames";
import React, { useContext } from "react";
import { MarkdownEditor } from "../../MarkdownEditor";
import { useBrowserStyle } from "./style";
var EDITOR_FULL_WIDTH_STYLE = {
    width: '100%'
};
var EDITOR_NO_PADDING_STYLE = {
    padding: 0
};
var isTestEnvironment = function() {
    return process.env.NODE_ENV === 'test';
};
var getDefaultEditorProps = function() {
    return _object_spread({
        readonly: true,
        toc: false,
        style: EDITOR_FULL_WIDTH_STYLE,
        contentStyle: EDITOR_NO_PADDING_STYLE
    }, isTestEnvironment() ? {
        typewriter: false
    } : {});
};
var mergeEditorProps = function(customProps) {
    return _object_spread({}, getDefaultEditorProps(), customProps);
};
/**
 * BrowserList 组件
 *
 * 在工作空间中显示浏览器内容，支持 Markdown 渲染
 *
 * @example
 * ```tsx
 * <BrowserList
 *   data={{
 *     title: "网页内容",
 *     content: "# 标题\n内容"
 *   }}
 * />
 * ```
 */ export var BrowserList = function(param) {
    var data = param.data;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var prefixCls = getPrefixCls('workspace-browser');
    var _useBrowserStyle = useBrowserStyle(prefixCls), wrapSSR = _useBrowserStyle.wrapSSR, hashId = _useBrowserStyle.hashId;
    var editorProps = mergeEditorProps(data.markdownEditorProps);
    return wrapSSR(/*#__PURE__*/ React.createElement("div", {
        className: classNames(prefixCls, hashId),
        "data-testid": "browser-list"
    }, data.title && /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-header"), hashId)
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(prefixCls, "-title"), hashId)
    }, data.title)), /*#__PURE__*/ React.createElement(MarkdownEditor, _object_spread_props(_object_spread({}, editorProps), {
        initValue: data.content
    }))));
};
