<!DOCTYPE html>
<html data-theme="dark" lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>JADE 2.0</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.0/css/bulma.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
    <link href="https://fonts.googleapis.com/css?family=Russo+One" rel="stylesheet">

    <link rel="stylesheet" href="/animations.css">
    <link rel="stylesheet" href="/style.css">

    <script src="https://unpkg.com/htmx.org@1.9.11"></script>
    <script src="https://unpkg.com/htmx.org@1.9.12/dist/ext/sse.js"></script>
</head>

<body hx-ext="sse" sse-connect="/sse">

    {{embed}}

    <script>
        function updateIcon(icon, ConversationAreaId) {
            var selectedIcon = document.getElementById('selectedIcon-' + ConversationAreaId);
            selectedIcon.src = icon;
        }
    </script>

    <script>
        function copyToClipboardCode(button) {
            // Get the code element next to the button
            var codeElement = button.nextElementSibling;

            // Create a temporary textarea element
            var tempTextarea = document.createElement('textarea');
            tempTextarea.value = codeElement.textContent;

            // Append the temporary textarea to the document body
            document.body.appendChild(tempTextarea);

            // Select the text in the temporary textarea
            tempTextarea.select();

            // Copy the selected text to the clipboard
            document.execCommand('copy');

            // Remove the temporary textarea from the document body
            document.body.removeChild(tempTextarea);

            // Change the button text to indicate successful copy
            var originalText = button.innerHTML;
            button.innerHTML = '<i class="fa-solid fa-check"></i>';

            // Revert the button text after a short delay
            setTimeout(function () {
                button.innerHTML = originalText;
            }, 2000);
        }

        function copyToClipboard(button) {
            // Get the container element for all the message content
            var messageContentContainer = button.closest('.message-bot').querySelector('#content-column .content');

            // Get the text content of all the messages
            var messageContent = messageContentContainer.textContent.trim();

            // Create a temporary textarea element
            var tempTextarea = document.createElement('textarea');
            tempTextarea.value = messageContent;

            // Append the temporary textarea to the document body
            document.body.appendChild(tempTextarea);

            // Select the text in the temporary textarea
            tempTextarea.select();

            // Copy the selected text to the clipboard
            document.execCommand('copy');

            // Remove the temporary textarea from the document body
            document.body.removeChild(tempTextarea);

            // Change the button text to indicate successful copy
            var originalText = button.innerHTML;
            button.innerHTML = '<i class="fa-solid fa-check"></i>';

            // Revert the button text after a short delay
            setTimeout(function () {
                button.innerHTML = originalText;
            }, 2000);
        }
    </script>

</body>

</html>