import React__default, { useContext, useState } from 'react';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import { useChannelSettingsContext } from '../context.js';
import PlaceHolder, { PlaceHolderTypes } from '../../ui/PlaceHolder.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../../chunks/bundle-I8JFwttJ.js';
import { L as LocalizationContext } from '../../chunks/bundle-BBjosDA0.js';
import Icon, { IconTypes, IconColors } from '../../ui/Icon.js';
import IconButton from '../../ui/IconButton.js';
import ChannelProfile from './ChannelProfile.js';
import AdminPannel from './ModerationPanel.js';
import LeaveChannel from './LeaveChannel.js';
import UserPanel from './UserPanel.js';
import '../../withSendbird.js';
import '../../chunks/bundle-BA7tv0JB.js';
import '../../chunks/bundle-vOT5acXc.js';
import '../../chunks/bundle-YoWLsJ0C.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-jy6_UG14.js';
import '../../chunks/bundle-ULVw0l0r.js';
import '../../chunks/bundle-cA_r9HRx.js';
import '../../ui/ChannelAvatar.js';
import '../../chunks/bundle-Qufz6_i_.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-jDjj3eHU.js';
import '../../chunks/bundle-F6-2aFsp.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-LWD0OLz8.js';
import './EditDetailsModal.js';
import '../../chunks/bundle-cvTUkQV_.js';
import 'react-dom';
import '../../chunks/bundle-r9j_eCHc.js';
import '../../ui/Button.js';
import '../../ui/Input.js';
import '../../ui/Accordion.js';
import '../../ui/AccordionGroup.js';
import '../../chunks/bundle-YVEtWFVy.js';
import '../../ui/Badge.js';
import '../../ui/Toggle.js';
import '../../ui/ContextMenu.js';
import '../../ui/SortByRow.js';
import '../../chunks/bundle-N9hMnIRl.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-aKXnhi3A.js';
import './UserListItem.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../chunks/bundle-nlOgiAcu.js';
import '../../ui/UserListItem.js';
import '../../ui/Checkbox.js';
import '../../chunks/bundle-RZWoLRNe.js';
import '../../chunks/bundle-GJ-4hPvC.js';
import '../../chunks/bundle-MBrlu_LK.js';
import '../../chunks/bundle-d5KevIXI.js';
import '@sendbird/chat/message';
import '@sendbird/uikit-tools';
import '../../chunks/bundle-BVtLlpwZ.js';

var ChannelSettingsUI = function (props) {
    var _a, _b;
    var stringSet = useContext(LocalizationContext).stringSet;
    var state = useSendbirdStateContext();
    var channelSettingStore = useChannelSettingsContext();
    var _c = 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__default.createElement("div", null,
            React__default.createElement("div", { className: "sendbird-channel-settings__header" },
                React__default.createElement(Label, { type: LabelTypography.H_2, color: LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__HEADER__TITLE),
                React__default.createElement(Icon, { className: "sendbird-channel-settings__close-icon", type: IconTypes.CLOSE, height: "24px", width: "24px", onClick: function () {
                        logger.info('ChannelSettings: Click close');
                        onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                    } })),
            React__default.createElement("div", null, renderPlaceholderError
                ? renderPlaceholderError()
                : (React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.WRONG })))));
    }
    return (React__default.createElement(React__default.Fragment, null,
        React__default.createElement("div", { className: "sendbird-channel-settings__header" },
            React__default.createElement(Label, { type: LabelTypography.H_2, color: LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__HEADER__TITLE),
            React__default.createElement("div", { className: "sendbird-channel-settings__header-icon" },
                React__default.createElement(IconButton, { width: "32px", height: "32px", onClick: function () {
                        logger.info('ChannelSettings: Click close');
                        onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                    } },
                    React__default.createElement(Icon, { className: "sendbird-channel-settings__close-icon", type: IconTypes.CLOSE, height: "22px", width: "22px" })))),
        React__default.createElement("div", { className: "sendbird-channel-settings__scroll-area" },
            (renderChannelProfile === null || renderChannelProfile === void 0 ? void 0 : renderChannelProfile()) || (React__default.createElement(ChannelProfile, null)),
            (renderModerationPanel === null || renderModerationPanel === void 0 ? void 0 : renderModerationPanel()) || ((channel === null || channel === void 0 ? void 0 : channel.myRole) === 'operator'
                ? (React__default.createElement(AdminPannel, null))
                : (React__default.createElement(UserPanel, null))),
            (renderLeaveChannel === null || renderLeaveChannel === void 0 ? void 0 : renderLeaveChannel()) || (React__default.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__default.createElement(Icon, { className: [
                        'sendbird-channel-settings__panel-icon-left',
                        'sendbird-channel-settings__panel-icon__leave',
                    ].join(' '), type: IconTypes.LEAVE, fillColor: IconColors.ERROR, height: "24px", width: "24px" }),
                React__default.createElement(Label, { type: LabelTypography.SUBTITLE_1, color: LabelColors.ONBACKGROUND_1 }, stringSet.CHANNEL_SETTING__LEAVE_CHANNEL__TITLE))),
            showLeaveChannelModal && (React__default.createElement(LeaveChannel, { onCancel: function () {
                    setShowLeaveChannelModal(false);
                }, onSubmit: function () {
                    setShowLeaveChannelModal(false);
                    onCloseClick === null || onCloseClick === void 0 ? void 0 : onCloseClick();
                } })))));
};

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