const chatContainer = document.getElementById("chat-container");         const inputBox = document.getElementById("input-box");         const sendButton = document.getElementById("send-button");         const clearButton = document.getElementById("clear-button");          let loadingIntervalId = null;         let typingInProgress = false;          function addMessage(content, sender) {             const messageElement = document.createElement("div");             messageElement.classList.add("message", sender);              if (sender === "bot") {                 const textContainer = document.createElement("div");                 textContainer.classList.add("text-container");                 textContainer.textContent = content;                 messageElement.appendChild(textContainer);             } else if (sender === "user") {                 const textContainer = document.createElement("div");                 textContainer.textContent = content;                 messageElement.appendChild(textContainer);             }              chatContainer.appendChild(messageElement);             chatContainer.scrollTop = chatContainer.scrollHeight;             return messageElement.querySelector(".text-container");         }          function animateLoadingText(element) {             const loadingText = ["Loading", "Loading.", "Loading..", "Loading..."];             let index = 0;             loadingIntervalId = setInterval(() => {                 element.textContent = loadingText[index];                 index = (index + 1) % loadingText.length;             }, 1000); // Update every 1 second         }          function copyToClipboard(element) {             const text = element.textContent || element.innerText;             console.log("Copying text: ", text);             navigator.clipboard.writeText(text).then(() => {                 alert("Code copied to clipboard!");             }).catch((error) => {                 console.error("Error copying text: ", error);             });         }          async function handleSpecialFormatting(container, text) {             const lines = text.split("\n");             for (const line of lines) {                 if (line.startsWith("###")) {                     // Judul                     const title = document.createElement("h3");                     title.style.color = "#66FFFF"; // Warna khusus untuk judul                     title.style.margin = "10px 0";                     container.appendChild(title);                     await typeText(title, line.replace("###", "").trim());                 } else if (line.includes("**")) {                     // Teks dengan huruf tebal                     const boldRegex = /\*\*(.*?)\*\*/g;                     const formattedText = line.replace(boldRegex, "<strong>$1</strong>");                     const paragraph = document.createElement("p");                     paragraph.style.margin = "5px 0";                     paragraph.style.fontWeight = "bold";                     container.appendChild(paragraph);                     await typeText(paragraph, formattedText);                 } else if (line.includes("<video>") || line.includes("<iframe>")) {                     // Ganti semua tag video dan iframe dengan versi aman                     const sanitizedLine = line.replace(/<\/?(video|iframe)(.*?)>/gi, "&lt;$1&gt;");                      // Ganti tag HTML lainnya (pastikan hanya elemen HTML yang ingin disanitasi)                     const finalSanitizedLine = sanitizedLine.replace(/<\/?([a-z][a-z0-9]*)[^>]*>/gi, "&lt;$1&gt;");                      // Buat elemen <p> dan tampilkan hasil sanitasi                     const paragraph = document.createElement("p");                     paragraph.style.margin = "5px 0";                      // Tambahkan elemen ke kontainer                     container.appendChild(paragraph);                     await typeText(paragraph, finalSanitizedLine);                  } else {                     const paragraph = document.createElement("p");                     paragraph.style.margin = "5px 0";                     container.appendChild(paragraph);                     await typeText(paragraph, line.trim());                 }             }         }          async function typeText(element, text) {             element.innerHTML = ""; // Clear text container             currentTypingElement = element; // Track the current typing element             typingInProgress = true; // Mark typing as in progress             sendButton.disabled = true;              let i = 0;             while (i < text.length && typingInProgress) {                 // If the text contains an HTML tag, render it directly                 if (text[i] === "<") {                     const tagEnd = text.indexOf(">", i);                     if (tagEnd !== -1) {                         element.innerHTML += text.slice(i, tagEnd + 1);                         i = tagEnd + 1;                         continue;                     }                 }                  // Otherwise, add the character one by one                 element.innerHTML += text[i];                 i++;                 await new Promise((resolve) => setTimeout(resolve, 30)); // Delay for typing effect                 chatContainer.scrollTop = chatContainer.scrollHeight;             }              if (typingInProgress) {                 element.innerHTML = text;             }         }          async function sendMessage() {             const userInput = inputBox.value.trim();             if (!userInput) return;              addMessage(userInput, "user");             inputBox.value = "";             sendButton.disabled = true;              const botTextContainer = addMessage("Loading", "bot");             animateLoadingText(botTextContainer);              clearButton.disabled = true              try {                 const endpoint = 'https://api-1.kimzzdev.xyz/wp-admin/admin-ajax.php';                  const response = await fetch(endpoint, {                     method: 'POST',                     headers: {                         'Content-Type': 'application/json',                         'X-kimzz-api-token': '6b696d7a7a2d6170692d323032342d63726561746f722d6d7568642d68616b696d',                         'X-kimzz-api-host': 'api-1.kimzzdev.xyz'                     },                     body: JSON.stringify({ input: userInput }),                 });                  const data = await response.json();                 const botReply = data.message;                  botTextContainer.textContent = ""                 clearInterval(loadingIntervalId);                  if (botReply.includes("```")) {                     // Assuming the response is split by code blocks (i.e. ```code```)                     const parts = botReply.split("```");                     for (const [index, part] of parts.entries()) {                         if (index % 2 === 0) {                             // Regular text                             if (part.trim()) {                                 await handleSpecialFormatting(botTextContainer, part.trim());                             }                         } else {                             // Code block                             const codeBlock = document.createElement("pre");                             const codeElement = document.createElement("code");                              let language = ''; // Initialize language as an empty string                              // Logic to detect the programming language                             if (part.includes('<video>')) {                                 language = 'html';                             } else if (part.includes('html')) language = 'html';                             else if (part.includes('python')) language = 'python';                             else if (part.includes('javascript') || part.includes('js')) language = 'javascript';                             else if (part.includes('nodejs') || part.includes('node')) language = 'javascript';                             else if (part.includes('php')) language = 'php';                             else if (part.includes('json')) language = 'json';                             else if (part.includes('css')) language = 'css';                             else if (part.includes('bash')) language = 'bash';                              codeElement.classList.add(language || 'plaintext'); // Add language class                             codeElement.textContent = part.trim();                             botTextContainer.appendChild(codeBlock);                             codeBlock.appendChild(codeElement);                              hljs.highlightElement(codeElement); // Highlight code                              // Copy button for code block                             const copyButton = document.createElement("button");                             copyButton.textContent = "Copy";                             copyButton.classList.add("copy-button");                             copyButton.onclick = () => copyToClipboard(codeElement);                             codeBlock.appendChild(copyButton);                         }                     }                 } else {                     // No code blocks, just handle normal text                     await handleSpecialFormatting(botTextContainer, botReply);                 }             } catch (error) {                 clearInterval(loadingIntervalId);                 botTextContainer.textContent = "Oops! Something went wrong. Please try again.";                 console.error(error);             } finally {                 sendButton.disabled = false;                 clearButton.disabled = false;             }         }          function clearChat() {             chatContainer.innerHTML = "";         }          sendButton.addEventListener("click", sendMessage);         clearButton.addEventListener("click", clearChat);      apakah telah benar