'use strict';

var React = require('react');
var utils = require('../../utils-df6bf1c0.js');
var ui_Label = require('../../index-bff918b2.js');
var ui_Icon = require('../../ui/Icon.js');
var ui_IconButton = require('../../ui/IconButton.js');
var ui_ChannelAvatar = require('../../ui/ChannelAvatar.js');
var LocalizationContext = require('../../LocalizationContext-6adf6aa8.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var Channel_context = require('../../ChannelProvider-5e48d37b.js');
var MediaQueryContext = require('../../MediaQueryContext-1dd78ce3.js');
var utils$1 = require('../../utils-58f8eea0.js');
require('prop-types');
require('../../stringSet-5157206d.js');
require('../../_rollupPluginBabelHelpers-ea66c137.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../uuid-f1d9be11.js');
require('../../utils-82da2619.js');
require('../../index-6a7f94de.js');
require('../../withSendbird.js');
require('../../UserProfileContext-2ff8462c.js');
require('../../const-f6c8086e.js');
require('../../index-358554d2.js');
require('../../topics-2fe6fef6.js');
require('../../index-86e680cb.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../compareIds-7b0e4960.js');
require('@sendbird/chat/groupChannel');
require('@sendbird/chat/message');
require('../../consts-a6f34df8.js');
require('../../resolvedReplyType-fb851d3a.js');

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

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

const ChannelHeader = _ref => {
  var _globalStore$config, _globalStore$config2, _currentGroupChannel$;
  let {
    className = ''
  } = _ref;
  const globalStore = useSendbirdStateContext();
  const userId = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config = globalStore.config) === null || _globalStore$config === void 0 ? void 0 : _globalStore$config.userId;
  const theme = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config2 = globalStore.config) === null || _globalStore$config2 === void 0 ? void 0 : _globalStore$config2.theme;
  const channelStore = Channel_context.useChannelContext();
  const {
    isMobile
  } = MediaQueryContext.useMediaQueryContext();
  const {
    currentGroupChannel,
    showSearchIcon,
    onSearchClick,
    onChatHeaderActionClick,
    onBackClick = utils$1.noop
  } = channelStore;
  const subTitle = (currentGroupChannel === null || currentGroupChannel === void 0 ? void 0 : currentGroupChannel.members) && (currentGroupChannel === null || currentGroupChannel === void 0 ? void 0 : (_currentGroupChannel$ = currentGroupChannel.members) === null || _currentGroupChannel$ === void 0 ? void 0 : _currentGroupChannel$.length) !== 2;
  const isMuted = (currentGroupChannel === null || currentGroupChannel === void 0 ? void 0 : currentGroupChannel.myMutedState) === 'muted';
  const {
    stringSet
  } = React.useContext(LocalizationContext.LocalizationContext);
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: `sendbird-chat-header ${className}`
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-chat-header__left"
  }, isMobile && /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    className: "sendbird-chat-header__icon_back",
    onClick: onBackClick,
    fillColor: ui_Icon.IconColors.PRIMARY,
    width: "24px",
    height: "24px",
    type: ui_Icon.IconTypes.ARROW_LEFT
  }), /*#__PURE__*/React__default["default"].createElement(ui_ChannelAvatar, {
    theme: theme,
    channel: currentGroupChannel,
    userId: userId,
    height: 32,
    width: 32
  }), /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    className: "sendbird-chat-header__left__title",
    type: ui_Label.LabelTypography.H_2,
    color: ui_Label.LabelColors.ONBACKGROUND_1
  }, utils.getChannelTitle(currentGroupChannel, userId, stringSet)), /*#__PURE__*/React__default["default"].createElement(ui_Label.Label, {
    className: "sendbird-chat-header__left__subtitle",
    type: ui_Label.LabelTypography.BODY_1,
    color: ui_Label.LabelColors.ONBACKGROUND_2
  }, subTitle)), /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-chat-header__right"
  }, (typeof isMuted === 'string' && isMuted === 'true' || typeof isMuted === 'boolean' && isMuted) && /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    className: "sendbird-chat-header__right__mute",
    type: ui_Icon.IconTypes.NOTIFICATIONS_OFF_FILLED,
    fillColor: ui_Icon.IconColors.ON_BACKGROUND_2,
    width: "24px",
    height: "24px"
  }), showSearchIcon && !(currentGroupChannel !== null && currentGroupChannel !== void 0 && currentGroupChannel.isEphemeral) && /*#__PURE__*/React__default["default"].createElement(ui_IconButton, {
    className: "sendbird-chat-header__right__search",
    width: "32px",
    height: "32px",
    onClick: onSearchClick
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.SEARCH,
    fillColor: ui_Icon.IconColors.PRIMARY,
    width: "24px",
    height: "24px"
  })), /*#__PURE__*/React__default["default"].createElement(ui_IconButton, {
    className: "sendbird-chat-header__right__info",
    width: "32px",
    height: "32px",
    onClick: onChatHeaderActionClick
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.INFO,
    fillColor: ui_Icon.IconColors.PRIMARY,
    width: "24px",
    height: "24px"
  }))));
};

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