'use strict';

var React = require('react');
var utils = require('../../utils-4b74ea64.js');
var ui_Label = require('../../index-73643285.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-af96cf5f.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var Channel_context = require('../../ChannelProvider-620bb354.js');
var MediaQueryContext = require('../../MediaQueryContext-8ec3f647.js');
var utils$1 = require('../../utils-d5176360.js');
require('prop-types');
require('../../stringSet-68748705.js');
require('../../_rollupPluginBabelHelpers-c5955c81.js');
require('../../ui/Avatar.js');
require('../../ui/ImageRenderer.js');
require('../../uuid-0b4ed44c.js');
require('../../utils-7f75ad97.js');
require('../../index-83d1d15e.js');
require('../../withSendbird.js');
require('../../UserProfileContext-f068b0ba.js');
require('../../index-f65677b1.js');
require('../../topics-825e5d42.js');
require('../../index-f2146bae.js');
require('../../utils/message/getOutgoingMessageState.js');
require('../../compareIds-18b3b1d6.js');
require('../../const-6691e574.js');
require('@sendbird/chat/groupChannel');
require('@sendbird/chat/message');
require('../../ui/ContextMenu.js');
require('react-dom');
require('../../ui/SortByRow.js');
require('../../ui/ReactionButton.js');
require('../../consts-a5382bc1.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
