import { CallListener, ConversationListener, GroupListener, MessageListener, UserListener, UIListener } from "./Listener";
export class CometChatUIEventHandler {
    static userHandlers = [];
    static uiHandlers = [];
    static messageHandlers = [];
    static conversationHandlers = [];
    static groupHandlers = [];
    static callHandlers = [];
    static panelHandlers = [];
    constructor() {
    }
    static emitPanelEvent(name, param) {
        CometChatUIEventHandler.panelHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccHidePanel?.name:
                    listener._eventListener.ccHidePanel(param);
                    break;
                case listener._eventListener.ccShowPanel?.name:
                    listener._eventListener.ccShowPanel(param);
                    break;
            }
        });
    }
    static emitCallEvent(name, param) {
        CometChatUIEventHandler.callHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccIncomingCallReceived?.name:
                    listener._eventListener.ccIncomingCallReceived(param);
                    break;
                case listener._eventListener.ccOutgoingCallAccepted?.name:
                    listener._eventListener.ccOutgoingCallAccepted(param);
                    break;
                case listener._eventListener.ccOutgoingCallRejected?.name:
                    listener._eventListener.ccOutgoingCallRejected(param);
                    break;
                case listener._eventListener.ccIncomingCallCancelled?.name:
                    listener._eventListener.ccIncomingCallCancelled(param);
                    break;
                case listener._eventListener.ccOutgoingCall?.name:
                    listener._eventListener.ccOutgoingCall(param);
                    break;
                case listener._eventListener.ccCallAccepted?.name:
                    listener._eventListener.ccCallAccepted(param);
                    break;
                case listener._eventListener.ccCallRejected?.name:
                    listener._eventListener.ccCallRejected(param);
                    break;
                case listener._eventListener.ccCallEnded?.name:
                    listener._eventListener.ccCallEnded(param);
                    break;
                case listener._eventListener.ccOutgoingCallCancelled?.name:
                    listener._eventListener.ccOutgoingCallCancelled(param);
                    break;
                case listener._eventListener.ccCallInitiated?.name:
                    listener._eventListener.ccCallInitiated(param);
                    break;
            }
        });
    }
    static addCallListener(name, callHandler) {
        try {
            CometChatUIEventHandler.callHandlers = CometChatUIEventHandler.callHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.callHandlers = [
                ...CometChatUIEventHandler.callHandlers,
                new CallListener(name, callHandler)
            ];
        }
        catch (err) {
            console.log("addCallListener", err);
        }
    }
    static removeCallListener(name) {
        try {
            CometChatUIEventHandler.callHandlers = CometChatUIEventHandler.callHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeCallListener", err);
        }
    }
    static emitMessageEvent(name, param) {
        CometChatUIEventHandler.messageHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccMessageLiveReaction?.name:
                    listener._eventListener.ccMessageLiveReaction(param);
                    break;
                case listener._eventListener.ccMessageDeleted?.name:
                    listener._eventListener.ccMessageDeleted(param);
                    break;
                case listener._eventListener.ccMessageEdited?.name:
                    listener._eventListener.ccMessageEdited(param);
                    break;
                case listener._eventListener.ccMessageRead?.name:
                    listener._eventListener.ccMessageRead(param);
                    break;
                case listener._eventListener.ccMessageSent?.name:
                    listener._eventListener.ccMessageSent(param);
                    break;
                case listener._eventListener.ccMessageDelivered?.name:
                    listener._eventListener.ccMessageSent(param);
                    break;
                case listener._eventListener.ccActiveChatChanged?.name:
                    listener._eventListener.ccActiveChatChanged(param);
                    break;
            }
        });
    }
    static addMessageListener(name, messageHandler) {
        try {
            CometChatUIEventHandler.messageHandlers = CometChatUIEventHandler.messageHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.messageHandlers = [
                ...CometChatUIEventHandler.messageHandlers,
                new MessageListener(name, messageHandler)
            ];
        }
        catch (err) {
            console.log("addMessageListener", err);
        }
    }
    static removeMessageListener(name) {
        try {
            CometChatUIEventHandler.messageHandlers = CometChatUIEventHandler.messageHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeMessageListener", err);
        }
    }
    static emitConversationEvent(name, param) {
        CometChatUIEventHandler.conversationHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccConversationDeleted?.name:
                    listener._eventListener.ccConversationDeleted(param);
                    break;
            }
        });
    }
    static addConversationListener(name, conversationHandler) {
        try {
            CometChatUIEventHandler.conversationHandlers = CometChatUIEventHandler.conversationHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.conversationHandlers = [
                ...CometChatUIEventHandler.conversationHandlers,
                new ConversationListener(name, conversationHandler)
            ];
        }
        catch (err) {
            console.log("addConversationListener", err);
        }
    }
    static removeConversationListener(name) {
        try {
            CometChatUIEventHandler.conversationHandlers = CometChatUIEventHandler.conversationHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeConversationListener", err);
        }
    }
    static emitGroupEvent(name, param) {
        CometChatUIEventHandler.groupHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccGroupCreated?.name:
                    listener._eventListener.ccGroupCreated(param);
                    break;
                case listener._eventListener.ccGroupDeleted?.name:
                    listener._eventListener.ccGroupDeleted(param);
                    break;
                case listener._eventListener.ccGroupLeft?.name:
                    listener._eventListener.ccGroupLeft(param);
                    break;
                case listener._eventListener.ccGroupMemberBanned?.name:
                    listener._eventListener.ccGroupMemberBanned(param);
                    break;
                case listener._eventListener.ccGroupMemberJoined?.name:
                    listener._eventListener.ccGroupMemberJoined(param);
                    break;
                case listener._eventListener.ccGroupMemberKicked?.name:
                    listener._eventListener.ccGroupMemberKicked(param);
                    break;
                case listener._eventListener.ccGroupMemberScopeChanged?.name:
                    listener._eventListener.ccGroupMemberScopeChanged(param);
                    break;
                case listener._eventListener.ccGroupMemberUnBanned?.name:
                    listener._eventListener.ccGroupMemberUnBanned(param);
                    break;
                case listener._eventListener.ccOwnershipChanged?.name:
                    listener._eventListener.ccOwnershipChanged(param);
                    break;
                case listener._eventListener.ccGroupMemberAdded?.name:
                    listener._eventListener.ccGroupMemberAdded(param);
                    break;
            }
        });
    }
    static addGroupListener(name, groupHandler) {
        try {
            CometChatUIEventHandler.groupHandlers = CometChatUIEventHandler.groupHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.groupHandlers = [
                ...CometChatUIEventHandler.groupHandlers,
                new GroupListener(name, groupHandler)
            ];
        }
        catch (err) {
            console.log("addGrouplistener", err);
        }
    }
    static removeGroupListener(name) {
        try {
            CometChatUIEventHandler.groupHandlers = CometChatUIEventHandler.groupHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeGroupListener", err);
        }
    }
    static emitUserEvent(name, param) {
        CometChatUIEventHandler.userHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.ccUserBlocked?.name:
                    listener._eventListener.ccUserBlocked(param);
                    break;
                case listener._eventListener.ccUserUnBlocked?.name:
                    listener._eventListener.ccUserUnBlocked(param);
                    break;
            }
        });
    }
    static addUserListener(name, userHandler) {
        try {
            CometChatUIEventHandler.userHandlers = CometChatUIEventHandler.userHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.userHandlers = [
                ...CometChatUIEventHandler.userHandlers,
                new UserListener(name, userHandler)
            ];
        }
        catch (err) {
            console.log("addUserListener", err);
        }
    }
    static removeUserListener(name) {
        try {
            CometChatUIEventHandler.userHandlers = CometChatUIEventHandler.userHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeUserListener", err);
        }
    }
    static emitUIEvent(name, param) {
        CometChatUIEventHandler.uiHandlers.map(listener => {
            switch (name) {
                case listener._eventListener.hidePanel?.name:
                    listener._eventListener.hidePanel(param);
                    break;
                case listener._eventListener.showPanel?.name:
                    listener._eventListener.showPanel(param);
                    break;
                case listener._eventListener.ccToggleBottomSheet?.name:
                    listener._eventListener.ccToggleBottomSheet(param);
                    break;
            }
        });
    }
    static addUIListener(name, uiHandlers) {
        try {
            CometChatUIEventHandler.uiHandlers = CometChatUIEventHandler.uiHandlers.filter(listener => {
                return listener._name != name;
            });
            CometChatUIEventHandler.uiHandlers = [
                ...CometChatUIEventHandler.uiHandlers,
                new UIListener(name, uiHandlers)
            ];
        }
        catch (err) {
            console.log("addUserListener", err);
        }
    }
    static removeUIListener(name) {
        try {
            CometChatUIEventHandler.userHandlers = CometChatUIEventHandler.userHandlers.filter(listener => {
                return listener._name !== name;
            });
        }
        catch (err) {
            console.log("removeUserListener", err);
        }
    }
}
//# sourceMappingURL=CometChatUIEventHandler.js.map