import React__default, { useContext } from 'react';
import { a as UserProfileContext } from '../UserProfileContext-a59f0533.js';
import { a as LocalizationContext } from '../LocalizationContext-426f3d58.js';
import Avatar from './Avatar.js';
import MutedAvatarOverlay from './MutedAvatarOverlay.js';
import Checkbox from './Checkbox.js';
import UserProfile from './UserProfile.js';
import ContextMenu, { MenuItems } from './ContextMenu.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../index-4105bc4d.js';
import 'prop-types';
import '../stringSet-a62108b2.js';
import '../index-90420b99.js';
import './ImageRenderer.js';
import './Icon.js';
import '../uuid-2e8efc75.js';
import '../sendbirdSelectors.js';
import '../_rollupPluginBabelHelpers-a69fd1ce.js';
import '../topics-247fcf3a.js';
import '../utils-4bf6e4e6.js';
import './Button.js';
import '../useSendbirdStateContext.js';
import '../withSendbird.js';
import 'react-dom';
import './SortByRow.js';
import '../index-f83f0aac.js';
import '../utils/message/getOutgoingMessageState.js';

function UserListItem(_ref) {
  let {
    user,
    className,
    checked,
    checkBox,
    isOperator,
    disabled,
    disableMessaging,
    currentUser,
    action,
    onChange,
    avatarSize = '40px'
  } = _ref;
  const uniqueKey = user.userId;
  const actionRef = React__default.useRef(null);
  const parentRef = React__default.useRef(null);
  const avatarRef = React__default.useRef(null);
  const {
    disableUserProfile,
    renderUserProfile
  } = useContext(UserProfileContext);
  const {
    stringSet
  } = useContext(LocalizationContext);
  return /*#__PURE__*/React__default.createElement("div", {
    className: [...(Array.isArray(className) ? className : [className]), 'sendbird-user-list-item'].join(' '),
    ref: parentRef
  }, (user === null || user === void 0 ? void 0 : user.isMuted) && /*#__PURE__*/React__default.createElement(MutedAvatarOverlay, {
    height: 40,
    width: 40
  }), /*#__PURE__*/React__default.createElement(ContextMenu, {
    menuTrigger: toggleDropdown => /*#__PURE__*/React__default.createElement(Avatar, {
      className: "sendbird-user-list-item__avatar",
      ref: avatarRef,
      src: user.profileUrl,
      width: avatarSize,
      height: avatarSize,
      onClick: () => {
        if (!disableUserProfile) {
          toggleDropdown();
        }
      }
    }),
    menuItems: closeDropdown => /*#__PURE__*/React__default.createElement(MenuItems, {
      openLeft: true,
      parentRef: avatarRef
      // for catching location(x, y) of MenuItems
      ,
      parentContainRef: avatarRef
      // for toggling more options(menus & reactions)
      ,
      closeDropdown: closeDropdown,
      style: {
        paddingTop: '0px',
        paddingBottom: '0px'
      }
    }, renderUserProfile ? renderUserProfile({
      user,
      currentUserId: currentUser,
      close: closeDropdown
    }) : /*#__PURE__*/React__default.createElement(UserProfile, {
      disableMessaging: disableMessaging,
      user: user,
      currentUserId: currentUser,
      onSuccess: closeDropdown
    }))
  }), /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-user-list-item__title",
    type: LabelTypography.SUBTITLE_1,
    color: LabelColors.ONBACKGROUND_1
  }, user.nickname || stringSet.NO_NAME, currentUser === user.userId && ' (You)'),
  // if there is now nickname, display userId
  !user.nickname && /*#__PURE__*/React__default.createElement(Label, {
    className: "sendbird-user-list-item__subtitle",
    type: LabelTypography.CAPTION_3,
    color: LabelColors.ONBACKGROUND_2
  }, user.userId), checkBox && /*#__PURE__*/React__default.createElement("label", {
    className: "sendbird-user-list-item__checkbox",
    htmlFor: uniqueKey
  }, /*#__PURE__*/React__default.createElement(Checkbox, {
    id: uniqueKey,
    checked: checked,
    disabled: disabled,
    onChange: event => onChange(event)
  })), isOperator && /*#__PURE__*/React__default.createElement(Label, {
    className: ['sendbird-user-list-item__operator', checkBox ? 'checkbox' : ''].join(' '),
    type: LabelTypography.SUBTITLE_2,
    color: LabelColors.ONBACKGROUND_2
  }, "Operator"), action && /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-user-list-item__action",
    ref: actionRef
  }, action({
    actionRef,
    parentRef
  })));
}

export { UserListItem as default };
//# sourceMappingURL=UserListItem.js.map
