import classnames from "classnames";
import React from "react";
import { ToolBarItem } from "./ToolBarItem";
export var FormattingTools = /*#__PURE__*/ React.memo(function(param) {
    var baseClassName = param.baseClassName, hashId = param.hashId, i18n = param.i18n, tools = param.tools, editor = param.editor, isCodeNode = param.isCodeNode, onToolClick = param.onToolClick, isFormatActive = param.isFormatActive, _param_isInTable = param.isInTable, isInTable = _param_isInTable === void 0 ? false : _param_isInTable, _param_hideTools = param.hideTools, hideTools = _param_hideTools === void 0 ? [] : _param_hideTools;
    // 在表格内时，只允许这些基本格式化工具：加粗、斜体、删除线、行内代码
    var allowedInTable = [
        'bold',
        'italic',
        'strikethrough',
        'inline-code'
    ];
    // 根据是否在表格内过滤工具，表格内不支持对齐等复杂格式
    var filteredTools = isInTable ? tools.filter(function(tool) {
        return allowedInTable.includes(tool.key);
    }) : tools;
    // 过滤掉隐藏的工具
    filteredTools = filteredTools.filter(function(tool) {
        return !hideTools.includes(tool.key);
    });
    return /*#__PURE__*/ React.createElement(React.Fragment, null, filteredTools.map(function(tool) {
        var _i18n_locale;
        var isActive = tool.isActive ? tool.isActive(editor) : isFormatActive(tool.type);
        return /*#__PURE__*/ React.createElement(ToolBarItem, {
            key: tool.key,
            title: (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale[tool.key]) || tool.title,
            icon: tool.icon,
            onClick: function() {
                return !isCodeNode && onToolClick(tool);
            },
            className: classnames("".concat(baseClassName, "-item"), hashId),
            style: {
                color: isActive ? '#1677ff' : undefined
            }
        });
    }));
});
FormattingTools.displayName = 'FormattingTools';
