document.addEventListener("DOMContentLoaded", async function() { let idChat_324981_8821 = "cs_Vdog__vaa_"; const sleepMAI = (delay) => new Promise((resolve) => setTimeout(resolve, delay)) const baseUrl = "https://hcb.makeai.it/chat" await sleepMAI(4000) console.log("Start MakeAIBot 🤖") var tk = "2342-rmll-r-da-asdf-g-tr-74km32-g-tegf"; var co = conf(baseUrl, tk).then((co)=>{ if(co == undefined){ console.log("Error T:011"); const elementoDaRimuovere = document.getElementById(idChat_324981_8821); if (elementoDaRimuovere) { elementoDaRimuovere.remove(); } else { console.log("Elemento non trovato!"); } return; } let firstColor = co.c[0]; let secondColor = co.c[1]; let name = co.n; let logo = co.l; let style = `#` + idChat_324981_8821 + ` { margin: 0; padding: 0; font-family: "Lato", sans-serif; background-color: #f6f7f9; z-index: 100000000; position: fixed; } #` + idChat_324981_8821 + `_b { display: flex; flex-direction: row-reverse; position: fixed; bottom: 0; right: 0; width: auto; height: 84px; } #` + idChat_324981_8821 + ` *::-webkit-scrollbar { width: 6px; } #` + idChat_324981_8821 + ` *::-webkit-scrollbar-track { background: #f1f1f100; } #` + idChat_324981_8821 + ` *::-webkit-scrollbar-thumb { background: #a6acb0; border-radius:3px; } #` + idChat_324981_8821 + ` *::-webkit-scrollbar-thumb:hover { background: #555; } /* #` + idChat_324981_8821 + ` *::-webkit-scrollbar { display: none; } */ #` + idChat_324981_8821 + ` h1 { margin: 0; font-size: 16px; line-height: 1; color:white; } #` + idChat_324981_8821 + ` button { color: inherit; background-color: transparent; border: 0; outline: 0 !important; cursor: pointer; border-radius: 50% !important; text-align: center; padding: 0; } #` + idChat_324981_8821 + `_b a:first-child button{ margin: 16px 16px 16px 8px; } #` + idChat_324981_8821 + `_b .bc-chatbox { width: 52px; height: 52px; color: #fff; background-color: ` + firstColor + `; background-position: center center; background-repeat: no-repeat; box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.15); border: 0; border-radius: 50% !important; cursor: pointer; margin: 16px 8px 16px 8px; } #` + idChat_324981_8821 + ` textarea { box-sizing: border-box; width: 100%; margin: 0; max-height: 200px!important; height: 24px; padding: 0 calc(16px / 2); font-family: inherit; font-size: 16px; line-height: calc(16px + 16px / 2)!important; color: #696969; background-color: white!important; border: 0; outline: 0 !important; resize: none; overflow-y: scroll; } #` + idChat_324981_8821 + ` textarea::placeholder { color: #696969; } #` + idChat_324981_8821 + ` .chatbox-popup { display: flex!important; position: fixed; box-shadow: 5px 5px 25px 0 rgba(46, 61, 73, 0.2); flex-direction: column; display: none; bottom: calc(2 * 16px + 52px); right: 16px; width: 377px; height: auto; max-height: 80%; background-color: #fff; border-radius: 16px !important; } #` + idChat_324981_8821 + ` .chatbox-popup .chatbox-popup__header { box-sizing: border-box; display: flex; width: 100%; padding: 16px; color: #fff; background-color: ` + firstColor + `; align-items: center; justify-content: space-around; border-top-right-radius: 12px; border-top-left-radius: 12px; } #` + idChat_324981_8821 + ` .chatbox-popup .chatbox-popup__header .chatbox-popup__avatar { margin-top: -32px; background-color: ` + firstColor + `; border: 5px solid rgba(0, 0, 0, 0.1); border-radius: 50%!important; } #` + idChat_324981_8821 + ` .chatbox-popup .chatbox-popup__main { box-sizing: border-box; width: 100%; padding: calc(2 * 16px) 16px; line-height: calc(16px + 16px / 2); color: #696969; text-align: center; display: flex; flex-direction: column; flex-wrap: nowrap; max-height: calc(100% - 300px); overflow-y:scroll; } #` + idChat_324981_8821 + ` .chatbox-popup .chatbox-popup__footer { box-sizing: border-box; display: flex; width: 100%; padding: 16px; border-top: 1px solid #ddd; align-items: center; justify-content: space-around; border-bottom-right-radius: 12px; border-bottom-left-radius: 12px; } #` + idChat_324981_8821 + ` .chatbox-panel { display: flex; position: absolute; box-shadow: 5px 5px 25px 0 rgba(46, 61, 73, 0.2); flex-direction: column; display: none; top: 0; right: 0; bottom: 0; width: 377px; background-color: #fff; } #` + idChat_324981_8821 + ` .chatbox-panel .chatbox-panel__header { box-sizing: border-box; display: flex; width: 100%; padding: 16px; color: #fff; background-color: ` + firstColor + `; align-items: center; justify-content: space-around; flex: 0 0 auto; } #` + idChat_324981_8821 + ` .chatbox-panel .chatbox-panel__main { box-sizing: border-box; width: 100%; padding: calc(2 * 16px) 16px; line-height: calc(16px + 16px / 2); color: #696969; text-align: center; flex: 1 1 auto; } #` + idChat_324981_8821 + ` .chatbox-panel .chatbox-panel__footer { box-sizing: border-box; display: flex; width: 100%; padding: 16px; border-top: 1px solid #ddd; align-items: center; justify-content: space-around; flex: 0 0 auto; } #` + idChat_324981_8821 + ` .chatbox-panel .chatbox-panel__footer { box-sizing: border-box; display: flex; width: 100%; padding: 16px; border-top: 1px solid #ddd; align-items: center; justify-content: space-around; flex: 0 0 auto; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.l-msg,.chatbox-popup__main__msg.r-msg{ width: auto; max-width: 80%; overflow: hidden; text-align: left; border: 1px solid #a6acb0; border-radius: 14px!important; overflow-y: visible; overflow-x: clip; padding: 12px; margin-bottom: 10px; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.l-msg{ background-color: rgb(253, 253, 253); align-self: start; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.r-msg{ background-color: ` + secondColor + `; align-self: end; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.l-msg.typing{ display: flex; flex-direction: row; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.l-msg.typing *{ margin: 3px; } #` + idChat_324981_8821 + ` .chatbox-popup__main__msg.l-msg.typing div:nth-child(2) svg{ fill: ` + firstColor + `; } #` + idChat_324981_8821 + ` .loader { text-align: center; } #` + idChat_324981_8821 + ` .loader span { display: inline-block; vertical-align: middle; width: 10px; height: 10px; background: black; border-radius: 50px!important; animation: loader 0.8s infinite alternate; } #` + idChat_324981_8821 + ` .loader span:nth-of-type(2) { animation-delay: 0.2s; } #` + idChat_324981_8821 + ` .loader span:nth-of-type(3) { animation-delay: 0.6s; } @keyframes loader { 0% { opacity: 0.9; transform: scale(0.5); } 100% { opacity: 0.1; transform: scale(1); } } `; let c_324981_8821 = ""; const styleSheet = document.createElement("style"); styleSheet.innerText = style, document.head.appendChild(styleSheet); const container = createElementFromHTML("
") , btnCont = createElementFromHTML("
") , buttonUno = createElementFromHTML('') , buttonDue = createElementFromHTML('') , section = createElementFromHTML('
'); container.appendChild(btnCont), btnCont.appendChild(buttonUno), container.appendChild(section); if('w' in co && co.w != undefined && co.w.length > 0){ let message = "https://wa.me/" + co.w[0]; if (co.m.length >=2){ message += "?text=" + co.w[1]; } btnCont.appendChild(createElementFromHTML('')); } if('p' in co && co.p != undefined){ buttonP = createElementFromHTML(''); btnCont.appendChild(buttonP); } if('m' in co && co.m != undefined && co.m.length > 0){ let message = "mailto:" + co.m[0]; if (co.m.length >=2){ message += "?subject=" + co.m[1]; } if (co.m.length >=3){ message += "&body=" + co.m[2]; } btnCont.appendChild(createElementFromHTML('')); } btnCont.appendChild(buttonDue); const body = document.querySelector("body"); body.appendChild(container); let messageStack = []; const loader = createElementFromHTML("
") , clientText = document.getElementById("client-text-area") , mainPanel = document.getElementById("chatbox-popup__main"); function addMessage(t, e) { let a = "l-msg"; "user" == e && (a = "r-msg"); let o = createElementFromHTML('
' + t + "
"); mainPanel.appendChild(o); document.getElementById("chatbox-popup__main").scrollTop = document.getElementById("chatbox-popup__main").scrollHeight; } function fadeOut(t) { t.style.opacity = 1, function e() { (t.style.opacity -= .1) < 0 ? t.style.display = "none" : requestAnimationFrame(e) }() } function fadeIn(t, e) { t.style.opacity = 0, t.style.display = e || "block", function e() { var a = parseFloat(t.style.opacity); (a += .1) > 1 || (t.style.opacity = a, requestAnimationFrame(e)) }() } function createElementFromHTML(t) { var e = document.createElement("div"); return e.innerHTML = t.trim(), e.firstChild } function t() { clientText.style.height = "24px"; msg = clientText.value.split("\n").join(""), document.getElementById("chatbox-popup__main").scrollTop = document.getElementById("chatbox-popup__main").scrollHeight, messageStack.push({ content: msg, role: "user" }), addMessage(msg, "user"), clientText.value = "", sendMessage() } document.querySelectorAll(".chatbox-open").forEach(t=>{ t.addEventListener("click", ()=>{ document.querySelectorAll(".chatbox-popup, .chatbox-close").forEach(t=>{ fadeIn(t) } ) } ) } ), document.querySelectorAll(".chatbox-close").forEach(t=>{ t.addEventListener("click", ()=>{ document.querySelectorAll(".chatbox-popup, .chatbox-close").forEach(t=>{ fadeOut(t) } ) } ) } ), document.querySelectorAll(".chatbox-maximize").forEach(t=>{ t.addEventListener("click", ()=>{ document.querySelectorAll(".chatbox-popup, .chatbox-open, .chatbox-close").forEach(t=>{ fadeOut(t) } ), document.querySelectorAll(".chatbox-panel").forEach(t=>{ fadeIn(t) } ) } ) } ), document.querySelectorAll(".chatbox-minimize").forEach(t=>{ t.addEventListener("click", ()=>{ document.querySelectorAll(".chatbox-popup, .chatbox-open, .chatbox-close").forEach(t=>{ fadeIn(t) } ), document.querySelectorAll(".chatbox-panel").forEach(t=>{ fadeOut(t) } ) } ) } ), document.querySelectorAll(".chatbox-panel-close").forEach(t=>{ t.addEventListener("click", ()=>{ document.querySelectorAll(".chatbox-open").forEach(t=>{ fadeIn(t) } ), document.querySelectorAll(".chatbox-panel").forEach(t=>{ fadeOut(t) } ) } ) } ), clientText.addEventListener("keyup", e=>{ var a; "Enter" == e.key && t(), (a = e.target).style.height = "1px", a.style.height = a.scrollHeight + "px" } ), document.querySelectorAll(".btn.send-msg").forEach(e=>{ e.addEventListener("click", ()=>{ t() } ) } ); async function callDema(body){ let t = await fetch( baseUrl + "/msg", { method: "POST", headers: { Authorization: "Bearer " + tk }, body: JSON.stringify(body) }); if (!t.ok) { let e = await t.json(); throw Error(e.message) } return t; } async function sendMessage() { mainPanel.append(loader); let t = await fetch(baseUrl + "/msg", { method: "POST", headers: { Authorization: "Bearer " + tk, "Content-Type":"application/json" }, body: JSON.stringify({ m: messageStack, c:c_324981_8821 }) }); if (!t.ok) { let e = await t.json(); throw Error(e.message) } let a = await t.json(); a = a["response"] a = a.replace(/\n/g, "
"); a = a.replace(/\[([^\]]+)\]\((https?:\/\/[^\s]+?)\)/g, '$1'); messageStack.push({ content: a, role: "assistant" }), addMessage(a, "assistant"), loader.remove() } function writeCookie(k, v) { if( v == "" ){ return; } document.cookie = k + " = " + v + ";"; } function readCookie(key) { var allcookies = document.cookie; cookiearray = allcookies.split(';'); for(var i = 0; i