'use strict';

var React = require('react');
var ui_Avatar = require('./Avatar.js');
var ui_Icon = require('./Icon.js');
var utils = require('../utils-d9c99217.js');
require('./ImageRenderer.js');
require('../uuid-1eceb0c8.js');
require('prop-types');

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

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

function ChannelAvatar(_ref) {
  let {
    channel,
    userId,
    theme,
    width = 56,
    height = 56
  } = _ref;
  const isBroadcast = channel === null || channel === void 0 ? void 0 : channel.isBroadcast;
  const memoizedAvatar = React.useMemo(() => isBroadcast ? utils.generateDefaultAvatar(channel) ? /*#__PURE__*/React__default["default"].createElement("div", {
    className: "sendbird-chat-header--default-avatar",
    style: {
      width,
      height,
      display: 'flex',
      justifyContent: 'center',
      alignItems: 'center'
    }
  }, /*#__PURE__*/React__default["default"].createElement(ui_Icon["default"], {
    type: ui_Icon.IconTypes.BROADCAST,
    fillColor: ui_Icon.IconColors.CONTENT,
    width: width * 0.575,
    height: height * 0.575
  })) : /*#__PURE__*/React__default["default"].createElement(ui_Avatar["default"], {
    className: "sendbird-chat-header--avatar--broadcast-channel",
    src: utils.getChannelAvatarSource(channel, userId),
    width: width,
    height: height,
    alt: channel === null || channel === void 0 ? void 0 : channel.name
  }) : /*#__PURE__*/React__default["default"].createElement(ui_Avatar["default"], {
    className: "sendbird-chat-header--avatar--group-channel",
    src: utils.getChannelAvatarSource(channel, userId),
    width: `${width}px`,
    height: `${height}px`,
    alt: channel === null || channel === void 0 ? void 0 : channel.name
  }), [channel === null || channel === void 0 ? void 0 : channel.members, channel === null || channel === void 0 ? void 0 : channel.coverUrl, theme]);
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, memoizedAvatar);
}

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