'use strict';

var React = require('react');
var ui_Label = require('../index-35633fb6.js');
var index = require('../index-a91b85d9.js');
var LocalizationContext = require('../LocalizationContext-8cc9717d.js');
var tokenize = require('../tokenize-88b021e0.js');
var index$1 = require('../index-db8116c0.js');
var consts = require('../consts-016f07ac.js');
require('prop-types');
require('../stringSet-ce782136.js');
require('../_rollupPluginBabelHelpers-acf412a3.js');
require('../utils/message/getOutgoingMessageState.js');
require('../index-d749c4c2.js');
require('../index.module-e3392caa.js');
require('../Message/context.js');
require('./MentionLabel.js');
require('./ContextMenu.js');
require('react-dom');
require('./SortByRow.js');
require('../uuid-1eceb0c8.js');
require('./UserProfile.js');
require('../UserProfileContext-d993c96b.js');
require('../sendbirdSelectors.js');
require('../topics-e24ef339.js');
require('../utils-5aa0708e.js');
require('./Avatar.js');
require('./ImageRenderer.js');
require('./Icon.js');
require('./Button.js');
require('../useSendbirdStateContext.js');
require('../withSendbird.js');
require('./LinkLabel.js');

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

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

function TextMessageItemBody(_ref) {
  var _message$mentionedMes, _message$mentionedUse, _message$reactions;
  let {
    className = '',
    message,
    isByMe = false,
    mouseHover = false,
    isMentionEnabled = false,
    isReactionEnabled = false
  } = _ref;
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  const isMessageMentioned = isMentionEnabled && (message === null || message === void 0 ? void 0 : (_message$mentionedMes = message.mentionedMessageTemplate) === null || _message$mentionedMes === void 0 ? void 0 : _message$mentionedMes.length) > 0 && (message === null || message === void 0 ? void 0 : (_message$mentionedUse = message.mentionedUsers) === null || _message$mentionedUse === void 0 ? void 0 : _message$mentionedUse.length) > 0;
  const tokens = React.useMemo(() => {
    if (isMessageMentioned) {
      return tokenize.tokenizeMessage({
        mentionedUsers: message === null || message === void 0 ? void 0 : message.mentionedUsers,
        messageText: message === null || message === void 0 ? void 0 : message.mentionedMessageTemplate
      });
    }
    return tokenize.tokenizeMessage({
      messageText: message === null || message === void 0 ? void 0 : message.message
    });
  }, [message === null || message === void 0 ? void 0 : message.updatedAt]);
  return /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    type: ui_Label.LabelTypography.BODY_1,
    color: isByMe ? ui_Label.LabelColors.ONCONTENT_1 : ui_Label.LabelColors.ONBACKGROUND_1
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: index.getClassName([className, consts.TEXT_MESSAGE_BODY_CLASSNAME, isByMe ? 'outgoing' : 'incoming', mouseHover ? 'mouse-hover' : '', isReactionEnabled && (message === null || message === void 0 ? void 0 : (_message$reactions = message.reactions) === null || _message$reactions === void 0 ? void 0 : _message$reactions.length) > 0 ? 'reactions' : ''])
  }, /*#__PURE__*/React__default["default"].createElement(index$1.TextFragment, {
    tokens: tokens
  }), index.isEditedMessage(message) && /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    className: "sendbird-text-message-item-body__message edited",
    type: ui_Label.LabelTypography.BODY_1,
    color: isByMe ? ui_Label.LabelColors.ONCONTENT_2 : ui_Label.LabelColors.ONBACKGROUND_2
  }, ` ${stringSet.MESSAGE_EDITED} `)));
}

module.exports = TextMessageItemBody;
//# sourceMappingURL=TextMessageItemBody.js.map
