import React__default, { useContext, useMemo } from 'react';
import { L as Label, a as LabelTypography, b as LabelColors } from '../index-4105bc4d.js';
import { h as getClassName, B as isEditedMessage } from '../index-f83f0aac.js';
import { a as LocalizationContext } from '../LocalizationContext-426f3d58.js';
import { t as tokenizeMessage } from '../tokenize-eec42500.js';
import { T as TextFragment } from '../index-89c84c27.js';
import { T as TEXT_MESSAGE_BODY_CLASSNAME } from '../consts-f99cd0da.js';
import 'prop-types';
import '../stringSet-a62108b2.js';
import '../_rollupPluginBabelHelpers-a69fd1ce.js';
import '../utils/message/getOutgoingMessageState.js';
import '../index-90420b99.js';
import '../index.module-8bb7760e.js';
import '../Message/context.js';
import './MentionLabel.js';
import './ContextMenu.js';
import 'react-dom';
import './SortByRow.js';
import '../uuid-2e8efc75.js';
import './UserProfile.js';
import '../UserProfileContext-a59f0533.js';
import '../sendbirdSelectors.js';
import '../topics-247fcf3a.js';
import '../utils-4bf6e4e6.js';
import './Avatar.js';
import './ImageRenderer.js';
import './Icon.js';
import './Button.js';
import '../useSendbirdStateContext.js';
import '../withSendbird.js';
import './LinkLabel.js';

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

export { TextMessageItemBody as default };
//# sourceMappingURL=TextMessageItemBody.js.map
