import { _ as __assign } from '../../chunks/bundle-B9I7KCZ2.js';
import React__default, { useState, useContext } from 'react';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import { useChannelSettingsContext } from '../context.js';
import { ChannelSettingsHeader } from './ChannelSettingsHeader.js';
import PlaceHolder, { PlaceHolderTypes } from '../../ui/PlaceHolder.js';
import { L as Label, a as LabelTypography, b as LabelColors } from '../../chunks/bundle-B1gHpFXu.js';
import { L as LocalizationContext } from '../../chunks/bundle-BPLoGpIy.js';
import Icon, { IconTypes, IconColors } from '../../ui/Icon.js';
import ChannelProfile from './ChannelProfile.js';
import LeaveChannel from './LeaveChannel.js';
import { d as deleteNullish, c as classnames } from '../../chunks/bundle-B628FXKZ.js';
import { M as MenuItem } from '../../chunks/bundle-DfkIV7Yk.js';
import { MenuListByRole } from './ChannelSettingMenuList.js';
import { useMenuItems } from '../hooks/useMenuList.js';
export { B as BannedUserList, M as MutedMemberList, O as OperatorList } from '../../chunks/bundle-CjetZNxA.js';
export { M as MemberList } from '../../chunks/bundle-Bc2fRy19.js';
import '../../withSendbird.js';
import '../../chunks/bundle-DUd6AS_D.js';
import '../../chunks/bundle-B97onQ-B.js';
import '../../ui/Header.js';
import '../../chunks/bundle-BydEbpDQ.js';
import '../../ui/TextButton.js';
import '../../chunks/bundle-DDIIh2iG.js';
import '../../ui/IconButton.js';
import '../../ui/Loader.js';
import '../../chunks/bundle-BwafidOs.js';
import '../../chunks/bundle-CMgJTzYH.js';
import '../../ui/ChannelAvatar.js';
import '../../chunks/bundle-D89r5O-w.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-DVCGbhaI.js';
import '../../chunks/bundle-BaEyjChY.js';
import './EditDetailsModal.js';
import '../../chunks/bundle-DAF0GGlr.js';
import '../../chunks/bundle-BGoByD2z.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-ByuZy4m8.js';
import '../../chunks/bundle-DnVyKahm.js';
import 'react-dom';
import '../../ui/Button.js';
import '@sendbird/uikit-tools';
import 'css-vars-ponyfill';
import '@sendbird/chat';
import '@sendbird/chat/openChannel';
import '../../chunks/bundle-jVDgtxRn.js';
import '../../chunks/bundle-Mfnn12A9.js';
import '../../chunks/bundle-BfonFE4n.js';
import '../../ui/SortByRow.js';
import '../../ui/Input.js';
import '../../chunks/bundle-CmAD8QUZ.js';
import '@sendbird/chat/message';
import '../../ui/Badge.js';
import '../../ui/Toggle.js';
import '../../chunks/bundle-CQV5GP72.js';
import '../../ui/UserListItem.js';
import '../../ui/MutedAvatarOverlay.js';
import '../../ui/Checkbox.js';
import '../../ui/UserProfile.js';
import '../../sendbirdSelectors.js';
import '../../chunks/bundle-D6I-uHp_.js';
import '../../chunks/bundle-B6LYNEOD.js';
import '../../chunks/bundle-B1rkq8k3.js';

var ChannelSettingsUI = function (props) {
    var _a;
    var menuItems = useMenuItems({ renderUserListItem: props === null || props === void 0 ? void 0 : props.renderUserListItem });
    var _b = deleteNullish(props), _c = _b.renderHeader, renderHeader = _c === void 0 ? function (props) { return React__default.createElement(ChannelSettingsHeader, __assign({}, props)); } : _c, renderLeaveChannel = _b.renderLeaveChannel, renderChannelProfile = _b.renderChannelProfile, _d = _b.renderModerationPanel, renderModerationPanel = _d === void 0 ? function (props) { return React__default.createElement(MenuListByRole, __assign({}, props)); } : _d, renderPlaceholderError = _b.renderPlaceholderError, renderPlaceholderLoading = _b.renderPlaceholderLoading;
    var state = useSendbirdStateContext();
    var _e = useChannelSettingsContext(), channel = _e.channel, invalidChannel = _e.invalidChannel, onCloseClick = _e.onCloseClick, loading = _e.loading;
    var _f = useState(false), showLeaveChannelModal = _f[0], setShowLeaveChannelModal = _f[1];
    var isOnline = (_a = state === null || state === void 0 ? void 0 : state.config) === null || _a === void 0 ? void 0 : _a.isOnline;
    var stringSet = useContext(LocalizationContext).stringSet;
    if (loading) {
        if (renderPlaceholderLoading)
            return renderPlaceholderLoading();
        return React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.LOADING });
    }
    var headerProps = { onCloseClick: onCloseClick };
    if (invalidChannel || !channel) {
        return (React__default.createElement("div", null,
            renderHeader(headerProps),
            React__default.createElement("div", null, renderPlaceholderError ? renderPlaceholderError() : React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.WRONG }))));
    }
    return (React__default.createElement(React__default.Fragment, null,
        renderHeader(headerProps),
        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({ menuItems: menuItems }),
            (renderLeaveChannel === null || renderLeaveChannel === void 0 ? void 0 : renderLeaveChannel()) || (React__default.createElement(MenuItem, { className: classnames(!isOnline ? 'sendbird-channel-settings__panel-item__disabled' : '', 'sendbird-channel-settings__panel-item__leave-channel'), onKeyDown: function () {
                    if (!isOnline)
                        return;
                    setShowLeaveChannelModal(true);
                }, onClick: function () {
                    if (!isOnline)
                        return;
                    setShowLeaveChannelModal(true);
                }, renderLeft: function () { return (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" })); }, renderMiddle: function () { return (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
