import React__default, { useContext } from 'react';
import useSendbirdStateContext from '../../useSendbirdStateContext.js';
import { useOpenChannelSettingsContext } from '../context.js';
import { U as UserProfileProvider } from '../../UserProfileContext-74e9a128.js';
import { a as LocalizationContext } from '../../LocalizationContext-1701e5c8.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../../index-f50d7ab0.js';
import Icon, { IconTypes } from '../../ui/Icon.js';
import { P as PlaceHolder, b as PlaceHolderTypes } from '../../index-11fe17e1.js';
import { OperatorUI } from './OperatorUI.js';
import { P as ParticipantList } from '../../index-581e7610.js';
import '../../withSendbird.js';
import '../../_rollupPluginBabelHelpers-cc035350.js';
import '@sendbird/chat/openChannel';
import '../../uuid-8b344dd2.js';
import 'prop-types';
import '../../stringSet-e9bb0333.js';
import '../../index-ff8f2f61.js';
import '../../ui/Loader.js';
import './OpenChannelProfile.js';
import '../../ui/TextButton.js';
import '../../color-ea3bf5b8.js';
import '../../ui/OpenChannelAvatar.js';
import '../../ui/Avatar.js';
import '../../ui/ImageRenderer.js';
import '../../utils-cd7ab927.js';
import './EditDetailsModal.js';
import '../../topics-0b30f52b.js';
import '../../ui/Modal.js';
import 'react-dom';
import '../../index-44c86e58.js';
import '../../ui/Button.js';
import '../../ui/IconButton.js';
import '../../MediaQueryContext-e5b401d0.js';
import '../../ui/Input.js';
import '../../ui/Accordion.js';
import '../../ui/AccordionGroup.js';
import '../../context-b513d868.js';
import '../../utils-05aa9060.js';
import '../../ui/ContextMenu.js';
import '../../ui/SortByRow.js';
import '../../index-99ab01f6.js';
import '../../utils/message/getOutgoingMessageState.js';
import '../../ui/UserListItem.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';

function InvalidChannel(_ref) {
  let {
    onCloseClick
  } = _ref;
  const {
    stringSet
  } = useContext(LocalizationContext);
  return /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings"
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings__header"
  }, /*#__PURE__*/React__default.createElement(Label, {
    type: LabelTypography.H_2,
    color: LabelColors.ONBACKGROUND_1
  }, stringSet.CHANNEL_SETTING__HEADER__TITLE), /*#__PURE__*/React__default.createElement(Icon, {
    type: IconTypes.CLOSE,
    className: "sendbird-openchannel-settings__close-icon",
    height: "24px",
    width: "24px",
    onClick: () => {
      onCloseClick();
    }
  })), /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings__placeholder"
  }, /*#__PURE__*/React__default.createElement(PlaceHolder, {
    type: PlaceHolderTypes.WRONG
  })));
}

const OpenChannelUI = _ref => {
  var _globalStore$config, _globalStore$stores, _globalStore$stores$u;
  let {
    renderOperatorUI,
    renderParticipantList
  } = _ref;
  const {
    channel,
    onCloseClick,
    isChannelInitialized
  } = useOpenChannelSettingsContext();
  const globalStore = useSendbirdStateContext();
  const logger = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$config = globalStore.config) === null || _globalStore$config === void 0 ? void 0 : _globalStore$config.logger;
  const user = globalStore === null || globalStore === void 0 ? void 0 : (_globalStore$stores = globalStore.stores) === null || _globalStore$stores === void 0 ? void 0 : (_globalStore$stores$u = _globalStore$stores.userStore) === null || _globalStore$stores$u === void 0 ? void 0 : _globalStore$stores$u.user;
  const {
    stringSet
  } = useContext(LocalizationContext);
  if (isChannelInitialized && !channel) {
    return /*#__PURE__*/React__default.createElement(InvalidChannel, {
      onCloseClick: () => {
        logger.info('OpenChannelSettings: Click close');
        if (onCloseClick) {
          onCloseClick();
        }
      }
    });
  }
  return /*#__PURE__*/React__default.createElement(UserProfileProvider, {
    isOpenChannel: true
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings"
  }, (channel === null || channel === void 0 ? void 0 : channel.isOperator(user)) && ((renderOperatorUI === null || renderOperatorUI === void 0 ? void 0 : renderOperatorUI()) || /*#__PURE__*/React__default.createElement(OperatorUI, null)), !(channel !== null && channel !== void 0 && channel.isOperator(user)) && /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings__participant"
  }, /*#__PURE__*/React__default.createElement("div", {
    className: "sendbird-openchannel-settings__header"
  }, /*#__PURE__*/React__default.createElement(Label, {
    type: LabelTypography.H_2,
    color: LabelColors.ONBACKGROUND_1
  }, stringSet.OPEN_CHANNEL_SETTINGS__PARTICIPANTS_TITLE), /*#__PURE__*/React__default.createElement(Icon, {
    type: IconTypes.CLOSE,
    className: "sendbird-openchannel-settings__close-icon",
    height: "24px",
    width: "24px",
    onClick: () => {
      onCloseClick();
    }
  })), (renderParticipantList === null || renderParticipantList === void 0 ? void 0 : renderParticipantList()) || /*#__PURE__*/React__default.createElement(ParticipantList, null))));
};

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