'use strict';

var React = require('react');
var LocalizationContext = require('../LocalizationContext-da62a103.js');
var ui_Label = require('../index-089e0fba.js');
var ui_Icon = require('./Icon.js');
var ui_IconButton = require('./IconButton.js');
var ui_ChannelAvatar = require('./ChannelAvatar.js');
require('../stringSet-857a128c.js');
require('../index-25336220.js');
require('../_rollupPluginBabelHelpers-4265e501.js');
require('prop-types');
require('../tslib.es6-ba69891c.js');
require('./Avatar.js');
require('./ImageRenderer.js');
require('../uuid-49679ac2.js');
require('../utils-c39eb349.js');

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

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

var getChannelTitle = function getChannelTitle(channel, currentUserId, stringSet) {
  var _a;

  if (!(channel === null || channel === void 0 ? void 0 : channel.name) && !(channel === null || channel === void 0 ? void 0 : channel.members)) {
    return stringSet.NO_TITLE;
  }

  if ((channel === null || channel === void 0 ? void 0 : channel.name) && channel.name !== 'Group Channel') {
    return channel.name;
  }

  if (((_a = channel === null || channel === void 0 ? void 0 : channel.members) === null || _a === void 0 ? void 0 : _a.length) === 1) {
    return stringSet.NO_MEMBERS;
  }

  return ((channel === null || channel === void 0 ? void 0 : channel.members) || []).filter(function (_a) {
    var userId = _a.userId;
    return userId !== currentUserId;
  }).map(function (_a) {
    var nickname = _a.nickname;
    return nickname || stringSet.NO_NAME;
  }).join(', ');
};

// will be deprecated
function ChatHeader(_a) {
  var currentGroupChannel = _a.currentGroupChannel,
      currentUser = _a.currentUser,
      _b = _a.title,
      title = _b === void 0 ? '' : _b,
      _c = _a.subTitle,
      subTitle = _c === void 0 ? '' : _c,
      _d = _a.isMuted,
      isMuted = _d === void 0 ? false : _d,
      _e = _a.theme,
      theme = _e === void 0 ? 'light' : _e,
      _f = _a.showSearchIcon,
      showSearchIcon = _f === void 0 ? false : _f,
      _g = _a.onSearchClick,
      onSearchClick = _g === void 0 ? function () {} : _g,
      _h = _a.onActionClick,
      onActionClick = _h === void 0 ? function () {} : _h;
  var userId = currentUser === null || currentUser === void 0 ? void 0 : currentUser.userId;
  var stringSet = React.useContext(LocalizationContext.LocalizationContext).stringSet;
  React.useEffect(function () {
    // eslint-disable-next-line no-console
    console.warn('SendbirdUIKit: ChatHeader will be deprecated in the next minor version. Recommend to use "@sendbird/uikit-react/Channtl/components/ChannelHeader" instead.');
  }, []);
  return /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-chat-header"
  }, /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-chat-header__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
  }, title || 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,
    width: "24px",
    height: "24px"
  }), showSearchIcon && /*#__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: onActionClick
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.INFO,
    fillColor: ui_Icon.IconColors.PRIMARY,
    width: "24px",
    height: "24px"
  }))));
}

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