'use strict';

var React = require('react');
var ui_Modal = require('./ui/Modal.js');
var ui_Button = require('./ui/Button.js');
var LocalizationContext = require('./LocalizationContext-6adf6aa8.js');
var Thread_context = require('./ThreadProvider-593ade0c.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

const RemoveMessage = props => {
  var _message$threadInfo;
  const {
    onCancel,
    onSubmit,
    message
  } = props;
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  const {
    deleteMessage
  } = Thread_context.useThreadContext();
  return /*#__PURE__*/React__default["default"].createElement(ui_Modal["default"], {
    type: ui_Button.ButtonTypes.DANGER,
    disabled: (message === null || message === void 0 ? void 0 : (_message$threadInfo = message.threadInfo) === null || _message$threadInfo === void 0 ? void 0 : _message$threadInfo.replyCount) > 0,
    onCancel: onCancel,
    onSubmit: () => {
      deleteMessage(message).then(() => {
        onCancel === null || onCancel === void 0 ? void 0 : onCancel();
        onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
      });
    },
    submitText: stringSet.MESSAGE_MENU__DELETE,
    titleText: stringSet.MODAL__DELETE_MESSAGE__TITLE
  });
};

exports.RemoveMessage = RemoveMessage;
//# sourceMappingURL=RemoveMessageModal-84c513e4.js.map
