<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">//
//  20250205 - wll - Created to hold the JavaScript for LiveChat
const ACI_CHAT_AUTHORIZATION = "ACI_CHAT_AUTHORIZATION";
const ACI_CHAT_INITIAL_MESSAGE_SHORT = "&lt;div style='width:200px'&gt;ACI’s AI customer service agent, Harvey, is provided as a convenient option solely for customer service questions. Harvey is &lt;b&gt;NOT&lt;/b&gt; programmed to give technical answers or advice.&lt;/div&gt;";
const ACI_CHAT_INITIAL_MESSAGE_LONG = "&lt;div style='width:200px'&gt;ACI’s AI customer service agent, Harvey, is provided as a convenient option solely for customer service questions. Harvey is &lt;b&gt;NOT&lt;/b&gt; programmed to give technical answers or advice.&lt;br&gt;&lt;br&gt;  For answers to technical questions related to an ACI resource, please &lt;a href='https://www.concrete.org/frequentlyaskedquestions/submitaquestion.aspx'&gt;[Click here]&lt;/a&gt;&lt;/div&gt;";
window.addEventListener("load", function () {

    console.log("Kayako Version: " + kayako.version);

    // XPKNMvUGVsD5oxLsMQ6Nz
    //window.embeddedChatbotConfig = { chatbotId: "-eHDxG8Effp1DfWB8B2yh", domain: "www.chatbase.co" } // Foundation bot
    window.embeddedChatbotConfig = { chatbotId: "XPKNMvUGVsD5oxLsMQ6Nz", domain: "www.chatbase.co" } // harvey bot

    // btn.style.display = "none";
    window.setTimeout(DoLoadTasks, 1000);

    //document.getElementById("btnACIInitiateChat").addEventListener("click", DisclaimChat, false);
    // 20250212 - wll - Dont show disclaimer dialog yet. Just show the chatbot
    document.getElementById("btnACIInitiateChat").addEventListener("click", DisplayChat, false);


}, false);


function DisplayChat() {

    console.log("ChatBase initilized: " + window.chatbase("getState"));

    //var x = window.chatbase;
    //debugger;

    window.chatbase.setInitialMessages([ACI_CHAT_INITIAL_MESSAGE_LONG]);

    var oCB = document.getElementById("chatbase-bubble-button");
    oCB.style.display = "";
    oCB.click();
    //  hide the out button
    document.getElementById("divACILiveChatControllPanel").style.display = "none";

}

function LastMessage(event) {
    debugger;
    console.log("bot message received:", event.data);
}

async function DoLoadTasks() {
    console.log("Kayako Version: " + kayako.version);

    console.log("ChatBase initilized: " + window.chatbase("getState"));

    //debugger;

    window.chatbase.addEventListener("assistant-message", (event) =&gt; {
        LastMessage(event);
    });

    window.chatbase.setInitialMessages([ACI_CHAT_INITIAL_MESSAGE_SHORT]);


    //var sUser = GetUserDisplayName();
    //window.chatbase.setInitialMessages([
    //    "Welcome to our chatbot!",
    //    "How can I assist you today?"
    //]);

    // hide chatbot
    var oCCP = document.getElementById("divACILiveChatControllPanel");
    var oCB = document.getElementById("chatbase-bubble-button");
    var oKY = document.getElementById("kayako-messenger");

    oCB.style.display = "none";

    if (sessionStorage.getItem(ACI_CHAT_AUTHORIZATION) == "1") {
        oCCP.style.display = "none";
        oCB.style.display = "";
    } 
     // Hide Kayako
    oKY.style.display = "none";

    // try to move the elements inside LiveChatControllerPanel
    var oControllerPanel = document.getElementById("divACILiveChatControllPanel");


    // try to insert a button on the cb window
    // chatbase-message-bubbles
    var divCW = document.getElementById("chatbase-bubble-window");

    var btn = document.createElement("input");
    btn.type = "button";
    btn.value = "Chat with a human ACI staff member instead »";
    btn.classList.add("btnSTH");
    btn.classList.add("button");

    divCW.prepend(btn);


    // add event to toggle chat windows
    btn.addEventListener("click", ToggleChats);

    // do the same for kayako
    var btn = document.createElement("input");
    btn.id =  "btnSpeakToBot"
    btn.type = "button";
    btn.value = "Chat with Harvey, ACI's AI assistant instead »";
    btn.classList.add("btnSTB");
    btn.classList.add("button");
    btn.style.display = "none";

    oKY.append(btn);
    btn.addEventListener("click", ToggleChats);

    kayako.on('chat_window_maximized', function () {
        // set position of spb button
        var btnSTB = document.getElementById("btnSpeakToBot");
        btn.style.display = "";
    })

    kayako.on('chat_window_minimized', function () {
        // set position of spb button
        //var btnSTB = document.getElementById("btnSpeakToBot");
        //btn.style.display = "";
        // make sure the Harvey button is displayed
        console.log("chat_window_minimized");
        ToggleChats();
    })

    // load dialog templates
    await FetchTemplate("divDynamicContent", "divDisclaimerHolder", "/desktopmodules/LiveChat/templates/Disclaimer.html");
}

function ToggleChats() {
    var oCB = document.getElementById("chatbase-bubble-button");
    var oKY = document.getElementById("kayako-messenger");
    var divCW = document.getElementById("chatbase-bubble-window");
    var btnSTB = document.getElementById("btnSpeakToBot");

    //if (oCB.style.display == "none") oCB.style.display = "";
    //else oCB.style.display = "none";
    //debugger;
    

    if (oKY.style.display == "none") {
        oCB.style.display = "none";
        if (divCW.style.display != "none") oCB.click();
        //divCW.style.display = "none";
        oKY.style.display = "";
        kayako.show();
        //if (kayako.visibility() === 'minimized') {
            kayako.maximize();
            btnSTB.style.display = "";

        //} else {
        //    kayako.minimize();
        //}

    } else {

        window.chatbase.setInitialMessages([ACI_CHAT_INITIAL_MESSAGE_LONG]);
        oKY.style.display = "none";
        btnSTB.style.display = "none";
        oCB.style.display = "";
        if (divCW.style.display == "none") oCB.click();
        //divCW.style.display = "flex";
    }

}

function HideIt(sjunk) {
    console.log("HideIt: " + sjunk);
    document.getElementById("chatbase-bubble-button").display = "none";
}
</pre></body></html>