!(function(){let t={},n=!1,e=!1;function o(){localStorage.setItem("closePopupMsg",!0);const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat"),o=document.getElementById("toggle-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60"),a=document.getElementsByClassName("cnx-glow-container");for(let t=0;t',e=!0),t.classList.add("open"),o.classList.add("open"),n=!0}function a(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat"),e=document.getElementById("toggle-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60");window.parent.postMessage({type:"closeChat"},"*"),t&&t.classList.remove("open"),e&&e.classList.remove("open"),n=!1}function i(){const n=document.getElementById("inner-iframe");n?.contentWindow&&n.contentWindow.postMessage({type:"setUserInfo",...t},"*")}function s(){n?a():o()}function r(){if(Object.keys(t).length)return;const o=document.currentScript;if(o){const n=o.getAttributeNames().filter(t=>t.startsWith("data-"));if(n.length)for(const e of n)t[e.replace("data-","")]=o.getAttribute(e);const e=(function(){const t=new URL(window.location.href),n=new URLSearchParams(t.search),e=[];for(const[t,o]of n.entries())e.push({key:t,value:o});return e})();if(e.length)for(const n of e)t[n.key.replace("data-","")]=n.value}try{const t=["*"];if(t.includes("*")||t.includes(window.location.host)){const t=document.querySelector("body");t.insertAdjacentHTML("beforeend",'
Need help? We are here 24/7!
'),t.style.margin="0",(async function(){document.getElementById("toggle-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60");const t=Boolean(localStorage.getItem("closePopupMsg")),e=document.getElementById("cnx-glow-main");e&&(e.style.display="none");if(!t){const t=document.getElementsByClassName("cnx-glow-box");d(2e3).then(()=>{e&&(e.style.display="flex");for(let n=0;n{const e=t[n];e&&(e.style.opacity=1)},300*n)})(n)})}function o(){const t=document.getElementById("inner-iframe");if(t){t.contentWindow.postMessage({type:"parentSize",width:window.innerWidth,height:window.innerHeight},"*")}}function a(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat"),e=document.getElementById("toggle-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60"),o=document.getElementById("chat-popup-tooltip");document.getElementById("close-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60");t.classList.remove("open"),e.classList.remove("open"),n&&(t.classList.remove("open"),o&&(o.style.display="none"),n=!1)}function s(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat"),n=window.innerHeight;t.style.height=n+"px"}function r(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat");t.style.maxHeight="calc(100vh - 114px)",t.style.width="auto"}function c(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat");t.style.maxHeight=null,t.style.width=null}window.addEventListener("message",t=>{"closeChat"===t.data.type?a():"expandChat"===t.data.type?r():"restoreChat"===t.data.type?c():"headerReady"===t.data.type&&(o(),i())}),window.addEventListener("resize",()=>{s(),o()});document.getElementById("toggle-btn-d8641675-5cad-4ef7-9b71-f27f51ca8f60").addEventListener("click",t=>{document.documentElement.clientWidth<767&&s()}),document.documentElement.clientWidth<767&&setTimeout(()=>{document.getElementById("cnx-glow-main").style.display="none"},5e3)})();const o=document.getElementById("close-btn-glow-id"),a=document.getElementById("cnx-glow-main");a?.addEventListener("mouseenter",function(){o.style.display="flex"}),a?.addEventListener("mouseleave",function(){o.style.display="none"}),localStorage.getItem("d8641675-5cad-4ef7-9b71-f27f51ca8f60-for-agent")&&(function(){const t=document.getElementById("agent-d8641675-5cad-4ef7-9b71-f27f51ca8f60-chat");e||(t.insertAdjacentHTML(''),e=!0)})()}}catch(t){console.error("Error initializing the agent script:",t)}}function d(t){return new Promise(n=>setTimeout(n,t))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",r):r();const c={},l={};const f=window.chatnode;if(window.chatnode=new Proxy(function(n,...e){switch(n){case"getState":return"initialized";case"open":o();break;case"close":a();break;case"toggle":s();break;case"closePopups":!(function(){localStorage.setItem("closePopupMsg",!0);const t=document.getElementsByClassName("cnx-glow-container");for(let n=0;nt!==h),0===l[g].length&&delete l[g]);break;case"dispatchEvent":const[m,u]=e,y=l[m];Array.isArray(y)&&y.forEach(t=>{try{t({type:m,payload:u})}catch(t){console.error("Error in event listener:",t)}});break;default:console.warn("Unknown method: "+n)}var r},{get:(t,n)=>"q"===n?[]:(...e)=>t(n,...e)}),f&&f.q)for(const t of f.q)window.chatnode(...t);function d(t){return new Promise(n=>setTimeout(n,t))}window.addEventListener("message",async t=>{const{data:n}=t;if(n&&"chatnode.message.user"===n.type&&n.payload&&window.chatnode.dispatchEvent("message.user",n.payload),n&&"chatnode.message.assistant"===n.type&&n.payload&&window.chatnode.dispatchEvent("message.assistant",n.payload),n&&"chatnode.action.call"===n.type&&n.payload&&window.chatnode.dispatchEvent("action.call",n.payload),n&&"chatnode.action.result"===n.type&&n.payload&&window.chatnode.dispatchEvent("action.result",n.payload),n&&"chatnode.action.execute"===n.type&&n.payload){const t=document.getElementById("inner-iframe");let e={status:"error",error:"Something went wrong."};if(c[n.payload.name])try{e=(function(t){if("object"!=typeof t||null===t||Array.isArray(t))throw new Error("Invalid tool result");const{status:n,data:e,message:o,error:a}=t;if("success"!==n&&"error"!==n)throw new Error("Invalid tool result");const i={status:n};if("string"==typeof o){const t=o.trim();""!==t&&(i.message=t)}if("success"===n){if(void 0!==e)try{const t=JSON.stringify(e);"{}"!==t&&"[]"!==t&&'""'!==t&&(i.data=JSON.parse(t))}catch{throw new Error("Invalid tool result")}return i}if("string"==typeof a){const t=a.trim();""!==t&&(i.error=t)}return i})(await c[n.payload.name](n.payload.args))}catch(t){e.error=String(t?.message||t)}else e.error="Tool "+n.payload.name+" not registered.";window.chatnode.dispatchEvent("action.result",{...n.payload,result:e}),t&&t.contentWindow.postMessage({type:"chatnode.action.result",payload:{id:n.payload.id,result:e}},"*")}})})();