'use strict';

var React = require('react');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
var ChannelSettings_context = require('../context.js');
var ui_PlaceHolder = require('../../ui/PlaceHolder.js');
var ui_Label = require('../../chunks/bundle-VxcYXhwp.js');
var LocalizationContext = require('../../chunks/bundle-6SzyBwQ5.js');
var ui_Icon = require('../../ui/Icon.js');
var ui_IconButton = require('../../ui/IconButton.js');
var ChannelSettings_components_ChannelProfile = require('./ChannelProfile.js');
var ChannelSettings_components_ModerationPanel = require('./ModerationPanel.js');
var ChannelSettings_components_LeaveChannel = require('./LeaveChannel.js');
var ChannelSettings_components_UserPanel = require('./UserPanel.js');
require('../../withSendbird.js');
require('../../chunks/bundle-DhtZdKsr.js');
require('../../chunks/bundle-TPy0gj60.js');
require('../../chunks/bundle-TB_UEIPg.js');
require('../../ui/Loader.js');
require('../../chunks/bundle-H9rcn1PJ.js');
require('../../chunks/bundle-AN4eZ2xs.js');
require('../../chunks/bundle-Y-_KhZFq.js');
require('../../ui/ChannelAvatar.js');
require('../../chunks/bundle-w0ATt2gt.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-HQAiUNev.js');
require('../../chunks/bundle-iY19D_aw.js');
require('../../ui/TextButton.js');
require('../../chunks/bundle-vMF9NM5u.js');
require('./EditDetailsModal.js');
require('../../chunks/bundle-6L4HCLmb.js');
require('react-dom');
require('../../chunks/bundle-6zBNmPOP.js');
require('../../ui/Button.js');
require('../../ui/Input.js');
require('../../ui/Accordion.js');
require('../../ui/AccordionGroup.js');
require('../../chunks/bundle-v5-SR4v4.js');
require('../../ui/Badge.js');
require('../../ui/Toggle.js');
require('../../ui/ContextMenu.js');
require('../../ui/SortByRow.js');
require('../../chunks/bundle-nox41MG6.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-xM2DAzE6.js');
require('./UserListItem.js');
require('../../ui/MutedAvatarOverlay.js');
require('../../ui/UserProfile.js');
require('../../sendbirdSelectors.js');
require('../../chunks/bundle-77qvrXp8.js');
require('../../ui/UserListItem.js');
require('../../ui/Checkbox.js');
require('../../chunks/bundle-bDQKUQ5r.js');
require('../../chunks/bundle-zHDXCFIb.js');
require('../../chunks/bundle-UAspU0bH.js');
require('../../chunks/bundle-CrbMqpah.js');
require('@sendbird/chat/message');
require('@sendbird/uikit-tools');
require('../../chunks/bundle-Njt4gDEW.js');

var ChannelSettingsUI = function (props) {
    var _a, _b;
    var stringSet = React.useContext(LocalizationContext.LocalizationContext).stringSet;
    var state = useSendbirdStateContext.useSendbirdStateContext();
    var channelSettingStore = ChannelSettings_context.useChannelSettingsContext();
    var _c = React.useState(false), showLeaveChannelModal = _c[0], setShowLeaveChannelModal = _c[1];
    var isOnline = (_a = state === null || state === void 0 ? void 0 : state.config) === null || _a === void 0 ? void 0 : _a.isOnline;
    var logger = (_b = state === null || state === void 0 ? void 0 : state.config) === null || _b === void 0 ? void 0 : _b.logger;
    var channel = channelSettingStore.channel, invalidChannel = channelSettingStore.invalidChannel, onCloseClick = channelSettingStore.onCloseClick;
    var renderPlaceholderError = props.renderPlaceholderError, renderChannelProfile = props.renderChannelProfile, renderModerationPanel = props.renderModerationPanel, renderLeaveChannel = props.renderLeaveChannel;
    if (!channel || invalidChannel) {
        return (React.createElement("div", null,
            React.createElement("div", { className: "sendbird-channel-settings__header" },
                React.createElement(ui_Label.Label, { type: ui_Label.LabelTypography.H_2, color: ui_Label.LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__HEADER__TITLE),
                React.createElement(ui_Icon.default, { className: "sendbird-channel-settings__close-icon", type: ui_Icon.IconTypes.CLOSE, height: "24px", width: "24px", onClick: function () {
                        logger.info('ChannelSettings: Click close');
                        onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                    } })),
            React.createElement("div", null, renderPlaceholderError
                ? renderPlaceholderError()
                : (React.createElement(ui_PlaceHolder.default, { type: ui_PlaceHolder.PlaceHolderTypes.WRONG })))));
    }
    return (React.createElement(React.Fragment, null,
        React.createElement("div", { className: "sendbird-channel-settings__header" },
            React.createElement(ui_Label.Label, { type: ui_Label.LabelTypography.H_2, color: ui_Label.LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__HEADER__TITLE),
            React.createElement("div", { className: "sendbird-channel-settings__header-icon" },
                React.createElement(ui_IconButton, { width: "32px", height: "32px", onClick: function () {
                        logger.info('ChannelSettings: Click close');
                        onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                    } },
                    React.createElement(ui_Icon.default, { className: "sendbird-channel-settings__close-icon", type: ui_Icon.IconTypes.CLOSE, height: "22px", width: "22px" })))),
        React.createElement("div", { className: "sendbird-channel-settings__scroll-area" },
            (renderChannelProfile === null || renderChannelProfile === void 0 ? void 0 : renderChannelProfile()) || (React.createElement(ChannelSettings_components_ChannelProfile, null)),
            (renderModerationPanel === null || renderModerationPanel === void 0 ? void 0 : renderModerationPanel()) || ((channel === null || channel === void 0 ? void 0 : channel.myRole) === 'operator'
                ? (React.createElement(ChannelSettings_components_ModerationPanel, null))
                : (React.createElement(ChannelSettings_components_UserPanel, null))),
            (renderLeaveChannel === null || renderLeaveChannel === void 0 ? void 0 : renderLeaveChannel()) || (React.createElement("div", { className: [
                    'sendbird-channel-settings__panel-item',
                    'sendbird-channel-settings__leave-channel',
                    !isOnline ? 'sendbird-channel-settings__panel-item__disabled' : '',
                ].join(' '), role: "button", onKeyDown: function () {
                    if (!isOnline) {
                        return;
                    }
                    setShowLeaveChannelModal(true);
                }, onClick: function () {
                    if (!isOnline) {
                        return;
                    }
                    setShowLeaveChannelModal(true);
                }, tabIndex: 0 },
                React.createElement(ui_Icon.default, { className: [
                        'sendbird-channel-settings__panel-icon-left',
                        'sendbird-channel-settings__panel-icon__leave',
                    ].join(' '), type: ui_Icon.IconTypes.LEAVE, fillColor: ui_Icon.IconColors.ERROR, height: "24px", width: "24px" }),
                React.createElement(ui_Label.Label, { type: ui_Label.LabelTypography.SUBTITLE_1, color: ui_Label.LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__LEAVE_CHANNEL__TITLE))),
            showLeaveChannelModal && (React.createElement(ChannelSettings_components_LeaveChannel, { onCancel: function () {
                    setShowLeaveChannelModal(false);
                }, onSubmit: function () {
                    setShowLeaveChannelModal(false);
                    onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                } })))));
};

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