import { _ as __assign } from './bundle-0vtSUcHY.js';
import React__default from 'react';
import { useChannelContext } from '../Channel/context.js';
import { useSendbirdStateContext } from '../useSendbirdStateContext.js';
import { T as TypingIndicator } from './bundle-4JVMIRVC.js';
import { T as TypingIndicatorType, M as MessageList } from './bundle-jamufWw7.js';
import ConnectionStatus from '../ui/ConnectionStatus.js';
import PlaceHolder, { PlaceHolderTypes } from '../ui/PlaceHolder.js';
import { C as ChannelHeader } from './bundle-Dpt_A2Sv.js';
import { MessageInputWrapper } from '../Channel/components/MessageInput.js';

var GroupChannelUIView = function (props) {
    var _a, _b, _c, _d;
    var loading = props.loading, isInvalid = props.isInvalid, channelUrl = props.channelUrl, renderChannelHeader = props.renderChannelHeader, renderMessageList = props.renderMessageList, renderMessageInput = props.renderMessageInput, renderTypingIndicator = props.renderTypingIndicator, renderPlaceholderLoader = props.renderPlaceholderLoader, renderPlaceholderInvalid = props.renderPlaceholderInvalid;
    var _e = useSendbirdStateContext(), stores = _e.stores, config = _e.config;
    var sdkError = (_a = stores === null || stores === void 0 ? void 0 : stores.sdkStore) === null || _a === void 0 ? void 0 : _a.error;
    var logger = config.logger, isOnline = config.isOnline;
    if (loading) {
        return React__default.createElement("div", { className: "sendbird-conversation" }, (renderPlaceholderLoader === null || renderPlaceholderLoader === void 0 ? void 0 : renderPlaceholderLoader()) || React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.LOADING }));
    }
    if (!channelUrl) {
        return (React__default.createElement("div", { className: "sendbird-conversation" }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.NO_CHANNELS })));
    }
    if (isInvalid) {
        return React__default.createElement("div", { className: "sendbird-conversation" }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.WRONG }));
    }
    if (sdkError) {
        return (React__default.createElement("div", { className: "sendbird-conversation" }, (renderPlaceholderInvalid === null || renderPlaceholderInvalid === void 0 ? void 0 : renderPlaceholderInvalid()) || (React__default.createElement(PlaceHolder, { type: PlaceHolderTypes.WRONG, retryToConnect: function () {
                logger.info('Channel: reconnecting');
                // reconnect();
            } }))));
    }
    return (React__default.createElement("div", { className: "sendbird-conversation" }, renderChannelHeader === null || renderChannelHeader === void 0 ? void 0 :
        renderChannelHeader({ className: 'sendbird-conversation__channel-header' }), renderMessageList === null || renderMessageList === void 0 ? void 0 :
        renderMessageList(props),
        React__default.createElement("div", { className: "sendbird-conversation__footer" }, renderMessageInput === null || renderMessageInput === void 0 ? void 0 :
            renderMessageInput(),
            React__default.createElement("div", { className: "sendbird-conversation__footer__typing-indicator" },
                (renderTypingIndicator === null || renderTypingIndicator === void 0 ? void 0 : renderTypingIndicator())
                    || (((_b = config === null || config === void 0 ? void 0 : config.groupChannel) === null || _b === void 0 ? void 0 : _b.enableTypingIndicator) && ((_d = (_c = config === null || config === void 0 ? void 0 : config.groupChannel) === null || _c === void 0 ? void 0 : _c.typingIndicatorTypes) === null || _d === void 0 ? void 0 : _d.has(TypingIndicatorType.Text)) && (React__default.createElement(TypingIndicator, { channelUrl: channelUrl }))),
                !isOnline && React__default.createElement(ConnectionStatus, null)))));
};

var ChannelUI = function (props) {
    var _a;
    var context = useChannelContext();
    var channelUrl = context.channelUrl, isInvalid = context.isInvalid, loading = context.loading;
    // Inject components to presentation layer
    var _b = props.renderChannelHeader, renderChannelHeader = _b === void 0 ? function (p) { return React__default.createElement(ChannelHeader, __assign({}, p)); } : _b, _c = props.renderMessageList, renderMessageList = _c === void 0 ? function (p) { return React__default.createElement(MessageList, __assign({}, p, { className: "sendbird-conversation__message-list" })); } : _c, _d = props.renderMessageInput, renderMessageInput = _d === void 0 ? function () { return React__default.createElement(MessageInputWrapper, __assign({}, props)); } : _d;
    return (React__default.createElement(GroupChannelUIView, __assign({}, props, context, { loading: (_a = props === null || props === void 0 ? void 0 : props.isLoading) !== null && _a !== void 0 ? _a : loading, isInvalid: isInvalid, channelUrl: channelUrl, renderChannelHeader: renderChannelHeader, renderMessageList: renderMessageList, renderMessageInput: renderMessageInput })));
};

export { ChannelUI as C, GroupChannelUIView as G };
//# sourceMappingURL=bundle-RVuTQS9f.js.map
