(function() {
    const endChat = document.getElementById('endChat');
    const endChatConfirmationContainer = document.getElementById("endChatConfirmationContainer");
    const closeConfirmationMessage = document.getElementById('closeConfirmationMessage');
    const endChatConfirmed = document.getElementById('endChatComfirmed');
    

    endChat.addEventListener("click", function() {
        if (endChatConfirmationContainer) {
            endChatConfirmationContainer.classList.remove("hidden");
        }
    });

    closeConfirmationMessage.addEventListener("click", function() {
        if (closeConfirmationMessage) {
            endChatConfirmationContainer.classList.add("hidden");
        }
    });

    endChatConfirmed.addEventListener("click", function() {
        const eventMessage = {
            event_type: 'end_chat',
        };
        osichatSocket.send(JSON.stringify(eventMessage));

    });

})();
