import { Dropdown } from "antd";
import classnames from "classnames";
import React from "react";
import { ToolBarItem } from "./ToolBarItem";
var HeatTextMap = {
    1: '大标题',
    2: '段落标题',
    3: '小标题',
    4: '正文',
    Text: '正文'
};
export var HeadingDropdown = /*#__PURE__*/ React.memo(function(param) {
    var baseClassName = param.baseClassName, hashId = param.hashId, i18n = param.i18n, node = param.node, hideTools = param.hideTools, onHeadingChange = param.onHeadingChange;
    var _i18n_locale;
    var headingItems = React.useMemo(function() {
        return [
            'H1',
            'H2',
            'H3',
            'Text'
        ].map(function(item, index) {
            if (hideTools === null || hideTools === void 0 ? void 0 : hideTools.includes(item)) {
                return null;
            }
            return {
                label: HeatTextMap[item.replace('H', '')] || item,
                key: "head-".concat(item),
                onClick: function() {
                    return onHeadingChange(index + 1);
                }
            };
        }).filter(Boolean);
    }, [
        hideTools,
        onHeadingChange
    ]);
    var currentText = React.useMemo(function() {
        var _node_;
        if (node === null || node === void 0 ? void 0 : (_node_ = node[0]) === null || _node_ === void 0 ? void 0 : _node_.level) {
            return HeatTextMap[node[0].level + ''] || "H".concat(node[0].level);
        }
        return '正文';
    }, [
        node
    ]);
    return /*#__PURE__*/ React.createElement(Dropdown, {
        menu: {
            items: headingItems
        }
    }, /*#__PURE__*/ React.createElement(ToolBarItem, {
        title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.heading) || '标题',
        icon: null,
        className: classnames("".concat(baseClassName, "-item"), hashId),
        style: {
            minWidth: 36,
            textAlign: 'center',
            fontSize: 12,
            justifyContent: 'center',
            lineHeight: 1
        }
    }, currentText));
});
HeadingDropdown.displayName = 'HeadingDropdown';
