"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

const ToolbarButton = props => {
  const size = !props.inlineMode ? props.size || 'medium' : 'small';
  const toolbarId = props.inlineMode ? '-toolbar' : '';
  const editorId = props.editorId || 'rte';
  const elemId = editorId + '-' + (props.id || props.label) + '-button' + toolbarId;
  const sharedProps = {
    id: elemId,
    onMouseDown: e => {
      e.preventDefault();

      if (props.onClick) {
        props.onClick(props.style, props.type, elemId, props.inlineMode);
      }
    },
    disabled: props.disabled || false
  };

  if (props.icon) {
    return /*#__PURE__*/_react.default.createElement(_IconButton.default, _extends({}, sharedProps, {
      "aria-label": props.label,
      color: props.active ? 'primary' : 'default',
      size: size
    }), props.icon);
  }

  if (props.component) {
    return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, sharedProps, {
      active: props.active || false
    }));
  }

  return null;
};

var _default = ToolbarButton;
exports.default = _default;