'use strict';

var React = require('react');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var Channel_context = require('../../ChannelProvider-a05d259f.js');
var ui_PlaceHolder = require('../../index-9a5e4383.js');
var ui_ConnectionStatus = require('../../ui/ConnectionStatus.js');
var Channel_components_ChannelHeader = require('./ChannelHeader.js');
var Channel_components_MessageList = require('./MessageList.js');
var Channel_components_TypingIndicator = require('./TypingIndicator.js');
var Channel_components_MessageInput = require('./MessageInput.js');
require('../../withSendbird.js');
require('../../_rollupPluginBabelHelpers-21ae158b.js');
require('../../UserProfileContext-9d843d68.js');
require('prop-types');
require('../../const-1ea78727.js');
require('../../index-892b4b7f.js');
require('../../index-88e8fdfa.js');
require('../../topics-373d2156.js');
require('../../index-1b3c69da.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../compareIds-a846891d.js');
require('@sendbird/chat/groupChannel');
require('../../uuid-dee74248.js');
require('@sendbird/chat/message');
require('../../consts-900e72b9.js');
require('../../resolvedReplyType-14fa0f85.js');
require('../../LocalizationContext-44d2f61b.js');
require('../../stringSet-7aebf034.js');
require('../../ui/Icon.js');
require('../../index-2bfd366f.js');
require('../../ui/Loader.js');
require('../../utils-6a43371d.js');
require('../../ui/IconButton.js');
require('../../ui/ChannelAvatar.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../utils-c71f0bea.js');
require('../../MediaQueryContext-5d311a86.js');
require('../../utils-6a748c02.js');
require('./Message.js');
require('./SuggestedMentionList.js');
require('../../const-bd02657f.js');
require('../../ThreadProvider-bac1bea8.js');
require('../../Thread/context/types.js');
require('@sendbird/chat');
require('../../ui/DateSeparator.js');
require('../../color-0c04efbd.js');
require('../../ui/MessageInput.js');
require('../../ui/Button.js');
require('dompurify');
require('../../consts-867f1ae6.js');
require('../../consts-b93ef9ea.js');
require('../../consts-bce71b24.js');
require('../../tokenize-44139f1e.js');
require('../../index.module-5a6a79b6.js');
require('../../ui/MessageContent.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../index-b6657c80.js');
require('../../index-24f791d1.js');
require('../../index-a3268370.js');
require('../../ui/MessageItemMenu.js');
require('../../ui/ContextMenu.js');
require('react-dom');
require('../../ui/SortByRow.js');
require('../../types-df5bd4e5.js');
require('../../ui/MessageItemReactionMenu.js');
require('../../ui/ReactionButton.js');
require('../../useLongPress-83b6a2f1.js');
require('../../ui/EmojiReactions.js');
require('../../ui/ReactionBadge.js');
require('../../ui/BottomSheet.js');
require('../../index-0a446cca.js');
require('../../ui/UserListItem.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/Checkbox.js');
require('../../ui/Tooltip.js');
require('../../ui/TooltipWrapper.js');
require('../../Message/context.js');
require('../../ui/AdminMessage.js');
require('../../ui/TextMessageItemBody.js');
require('../../index-8cd9b25d.js');
require('../../ui/MentionLabel.js');
require('../../ui/LinkLabel.js');
require('../../ui/FileMessageItemBody.js');
require('../../ui/TextButton.js');
require('../../ui/ThumbnailMessageItemBody.js');
require('../../ui/OGMessageItemBody.js');
require('../../ui/UnknownMessageItemBody.js');
require('../../ui/QuoteMessage.js');
require('../../index-78a1037e.js');
require('../../ui/ThreadReplies.js');
require('../../ui/VoiceMessageItemBody.js');
require('../../ui/ProgressBar.js');
require('../../VoicePlayer/useVoicePlayer.js');
require('../../index-50c4a83b.js');
require('../../VoiceRecorder/context.js');
require('../../ui/Modal.js');
require('../../ui/PlaybackTime.js');
require('./FileViewer.js');
require('./RemoveMessageModal.js');
require('../../index-c08f5bf5.js');
require('../../useDirtyGetMentions-1500af53.js');
require('./UnreadCount.js');
require('./FrozenNotification.js');
require('../../ui/QuoteMessageInput.js');
require('../../VoiceMessageInputWrapper-6625f53a.js');
require('../../VoiceRecorder/useVoiceRecorder.js');
require('../../index-4d2879d6.js');

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

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

const ChannelUI = _ref => {
  var _globalStore$stores, _globalStore$stores$s, _globalStore$config, _globalStore$config2, _globalStore$config3, _globalStore$config3$;
  let {
    isLoading,
    renderPlaceholderLoader,
    renderPlaceholderInvalid,
    renderPlaceholderEmpty,
    renderChannelHeader,
    renderMessage,
    renderMessageInput,
    renderTypingIndicator,
    renderCustomSeparator,
    renderFileUploadIcon,
    renderVoiceMessageIcon,
    renderSendMessageIcon
  } = _ref;
  const {
    channelUrl,
    isInvalid
  } = Channel_context.useChannelContext();
  const globalStore = useSendbirdStateContext();
  const sdkError = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$stores = globalStore.stores) === null || _globalStore$stores === void 0 ? void 0 : (_globalStore$stores$s = _globalStore$stores.sdkStore) === null || _globalStore$stores$s === void 0 ? void 0 : _globalStore$stores$s.error;
  const logger = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config = globalStore.config) === null || _globalStore$config === void 0 ? void 0 : _globalStore$config.logger;
  const isOnline = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config2 = globalStore.config) === null || _globalStore$config2 === void 0 ? void 0 : _globalStore$config2.isOnline;
  if (isLoading) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderLoader === null || renderPlaceholderLoader === void 0 ? void 0 : renderPlaceholderLoader()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.LOADING
    }));
  }
  if (!channelUrl) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.NO_CHANNELS
    }));
  }
  if (isInvalid) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.WRONG
    }));
  }
  if (sdkError) {
    return /*#__PURE__*/React__default["default"].createElement("div", {
      className: "sendbird-conversation"
    }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || /*#__PURE__*/React__default["default"].createElement(ui_PlaceHolder.PlaceHolder, {
      type: ui_PlaceHolder.PlaceHolderTypes.WRONG,
      retryToConnect: () => {
        logger.info('Channel: reconnecting');
        // reconnect();
      }
    }));
  }

  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation"
  }, (renderChannelHeader === null || renderChannelHeader === void 0 ? void 0 : renderChannelHeader()) || /*#__PURE__*/React__default["default"].createElement(Channel_components_ChannelHeader, {
    className: "sendbird-conversation__channel-header"
  }), /*#__PURE__*/React__default["default"].createElement(Channel_components_MessageList, {
    className: "sendbird-conversation__message-list",
    renderMessage: renderMessage,
    renderPlaceholderEmpty: renderPlaceholderEmpty,
    renderCustomSeparator: renderCustomSeparator,
    renderPlaceholderLoader: renderPlaceholderLoader
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation__footer"
  }, (renderMessageInput === null || renderMessageInput === void 0 ? void 0 : renderMessageInput()) || /*#__PURE__*/React__default["default"].createElement(Channel_components_MessageInput, {
    renderFileUploadIcon: renderFileUploadIcon,
    renderVoiceMessageIcon: renderVoiceMessageIcon,
    renderSendMessageIcon: renderSendMessageIcon
  }), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-conversation__footer__typing-indicator"
  }, (renderTypingIndicator === null || renderTypingIndicator === void 0 ? void 0 : renderTypingIndicator()) || (globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config3 = globalStore.config) === null || _globalStore$config3 === void 0 ? void 0 : (_globalStore$config3$ = _globalStore$config3.groupChannel) === null || _globalStore$config3$ === void 0 ? void 0 : _globalStore$config3$.enableTypingIndicator) && /*#__PURE__*/React__default["default"].createElement(Channel_components_TypingIndicator["default"], null), !isOnline && /*#__PURE__*/React__default["default"].createElement(ui_ConnectionStatus, null))));
};

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