(function(){function init(){setTimeout(function(){const styles=`
`;const enableHiding=('0'==='1'&&''!=='1');if(enableHiding){if(localStorage.getItem('sitespeak-chatbot-hide')==='true'){return;}}
document.head.insertAdjacentHTML('beforeend',styles);let unread=0;let isOpen=false;let welcomeBubble=null;let identifyTraits={};function getChatbotState(){const key=`sitespeak-chatbot-state-66f87ce4-f189-400f-ba2a-5d588845b6c8`;try{const state=localStorage.getItem(key);return state?JSON.parse(state):{isOpen:false};}catch{return{isOpen:false};}}
function saveChatbotState(state){const key=`sitespeak-chatbot-state-66f87ce4-f189-400f-ba2a-5d588845b6c8`;localStorage.setItem(key,JSON.stringify(state));}
const persistedState=getChatbotState();isOpen=persistedState.isOpen&&!(''==='1');const welcomeMessages=`Hi there! What can I help you with today?`.split('\n').filter(msg=>msg.trim());const autoShowWelcomeMessage='3s';let logo=``;const launcherIcon='';const xIcon=``;const minWidth='640';if(''!==''){logo=`
`;}
const iframe=document.createElement('iframe');iframe.setAttribute('id','sitespeak-iframe');iframe.setAttribute('allow','microphone');const pageLang=document.documentElement.lang||navigator.language||'en';const langParam='&lang='+encodeURIComponent(pageLang);iframe.src='https://chatbot.sitespeak.ai/embed/66f87ce4-f189-400f-ba2a-5d588845b6c8?title=BeamAI&theme=light&em=1'+langParam;iframe.style.display='none';iframe.onload=()=>{if(!(''==='1')&&persistedState.isOpen){iframe.style.display='block';isOpen=true;launcher.classList.add('open');launcherInner.innerHTML=xIcon+launcherText;setTimeout(()=>{iframe.contentWindow.postMessage({openChat:true},'*');},100);if(enableHiding){hideChat.style.display='none';}}};iframe.style.bottom=window.innerWidth':'');launcher.setAttribute('id','sitespeak-launcher');const launcherInner=document.createElement('div');launcherInner.setAttribute('id','sitespeak-launcher-inner');launcher.appendChild(launcherInner);const hideChat=document.createElement('button');if(enableHiding){hideChat.setAttribute('id','sitespeak-hide-chatbot');}
setTimeout(()=>{launcher.classList.add('loaded');},100);if(launcherText){launcherInner.style.padding='0 14px';}
if(!persistedState.isOpen){launcherInner.innerHTML=(launcherText?logo:'')+launcherText;if(enableHiding){launcherInner.innerHTML=(launcherText?logo:'')+launcherText+xIcon;}}
launcher.onclick=()=>{if(welcomeBubble&&welcomeBubble.classList.contains('show')){welcomeBubble.classList.remove('show');setWelcomeDismissed();setTimeout(()=>{if(welcomeBubble){welcomeBubble.remove();welcomeBubble=null;}},300);}
if(iframe.style.display==='none'){isOpen=true;saveChatbotState({isOpen:true});iframe.contentWindow.postMessage({openChat:true},'*');iframe.style.display='block';launcherInner.innerHTML=xIcon+launcherText;launcher.classList.add('open');setTimeout(()=>{launcher.classList.remove('unread');unread=0;},1000);if(enableHiding){hideChat.style.display='none';}}else{isOpen=false;saveChatbotState({isOpen:false});iframe.contentWindow.postMessage({closeChat:true},'*');iframe.style.display='none';launcherInner.innerHTML=(launcherText?logo:'')+launcherText;launcher.classList.remove('open');if(enableHiding){hideChat.style.display='block';launcherInner.innerHTML=(!launcherIcon?logo:'')+launcherText+xIcon;}}};if(enableHiding){hideChat.onclick=()=>{iframe.style.display='none';launcher.style.display='none';hideChat.style.display='none';window.localStorage.setItem('sitespeak-chatbot-hide','true');};}
if(window.innerWidth>=minWidth||true){document.body.appendChild(launcher);if(enableHiding){const rightOffset=window.innerWidth-launcher.getBoundingClientRect().right;const bottomOffset=window.innerHeight-launcher.getBoundingClientRect().bottom;hideChat.style.right=rightOffset+'px';hideChat.style.bottom=bottomOffset+'px';document.body.appendChild(hideChat);}}
window.addEventListener('resize',()=>{iframe.style.bottom=window.innerWidth{if(event.origin!=='https://chatbot.sitespeak.ai'){return}
if(event.data.closeChat){isOpen=false;saveChatbotState({isOpen:false});iframe.style.display='none';launcherInner.innerHTML=(launcherText?logo:'')+launcherText
launcher.classList.remove('open');if(enableHiding){hideChat.style.display='flex';launcherInner.innerHTML=(!launcherIcon?logo:'')+launcherText+xIcon;}}
if(event.data.openIntercom&&window.Intercom){window.Intercom('show');}
if(!isOpen&&event.data.unreadMessages>0){unread=unread<9?unread+event.data.unreadMessages:9;const notification=document.createElement('div');notification.setAttribute('id','sitespeak-notification-badge');notification.innerHTML=unread;launcher.appendChild(notification);launcher.classList.add('unread');}
if(event.data.onChatReady){if(window.sitespeak&&window.sitespeak.init){window.sitespeak.init();}}});window.sitespeak={init:()=>{var _sitespeak=window._sitespeak||[];for(var i=_sitespeak.length-1;i>=0;i--){if(_sitespeak[i][0]==='onReady'){_onReady(_sitespeak[i][1]);}}},identify:(userId,traits)=>{identifyTraits=traits||{};iframe.contentWindow.postMessage({identify:{userId,traits}},'*');}};function _onReady(callback){if(typeof callback==='function'){callback();}}
function processTemplates(message){return message.replace(/\{\{\s*([^|]+?)\s*\|\s*([^}]+?)\s*\}\}/g,(match,traitName,fallback)=>{const trait=traitName.trim();const fallbackValue=fallback.trim();return identifyTraits[trait]!==undefined?identifyTraits[trait]:fallbackValue;});}
function isWelcomeDismissed(){const key=`sitespeak-welcome-dismissed-66f87ce4-f189-400f-ba2a-5d588845b6c8`;const dismissalData=localStorage.getItem(key);if(!dismissalData){return false;}
try{const data=JSON.parse(dismissalData);const now=Date.now();const thirtyDaysInMs=30*24*60*60*1000;if(now-data.timestamp>thirtyDaysInMs){localStorage.removeItem(key);return false;}
return data.dismissed;}catch(error){localStorage.removeItem(key);return false;}}
function setWelcomeDismissed(){const key=`sitespeak-welcome-dismissed-66f87ce4-f189-400f-ba2a-5d588845b6c8`;const dismissalData={dismissed:true,timestamp:Date.now()};localStorage.setItem(key,JSON.stringify(dismissalData));}
function createWelcomeBubble(){if(welcomeMessages.length===0||isWelcomeDismissed()||''==='1'||autoShowWelcomeMessage==='never'){return;}
welcomeBubble=document.createElement('div');welcomeBubble.setAttribute('id','sitespeak-welcome-bubble');welcomeMessages.forEach((message,index)=>{const messageDiv=document.createElement('div');const messageParagraph=document.createElement('p');messageDiv.className='sitespeak-welcome-message';messageDiv.setAttribute('data-original-message',message.trim());messageParagraph.innerHTML=message.trim();messageDiv.appendChild(messageParagraph);messageDiv.style.opacity='0';messageDiv.style.transform='translateY(10px) scale(0.95)';messageDiv.style.transition='all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1)';messageDiv.style.cursor='pointer';messageDiv.onclick=(e)=>{if(e.target.classList.contains('sitespeak-welcome-close')){return;}
welcomeBubble.classList.remove('show');setWelcomeDismissed();setTimeout(()=>{if(welcomeBubble){welcomeBubble.remove();welcomeBubble=null;}},300);if(iframe.style.display==='none'){isOpen=true;iframe.contentWindow.postMessage({openChat:true},'*');iframe.style.display='block';launcherInner.innerHTML=xIcon+launcherText;launcher.classList.add('open');setTimeout(()=>{launcher.classList.remove('unread');unread=0;},1000);if(enableHiding){hideChat.style.display='none';}}};if(index===0){const closeButton=document.createElement('button');closeButton.className='sitespeak-welcome-close';closeButton.innerHTML='×';closeButton.title='Close';closeButton.onclick=(e)=>{e.stopPropagation();welcomeBubble.classList.remove('show');setWelcomeDismissed();setTimeout(()=>{if(welcomeBubble){welcomeBubble.remove();welcomeBubble=null;}},300);};messageDiv.appendChild(closeButton);}
welcomeBubble.appendChild(messageDiv);});document.body.appendChild(welcomeBubble);const delayMap={'1s':1000,'3s':3000,'5s':5000,'10s':10000};const delay=delayMap[autoShowWelcomeMessage]||3000;setTimeout(()=>{if(welcomeBubble&&!isOpen){const messages=welcomeBubble.querySelectorAll('.sitespeak-welcome-message');messages.forEach((messageDiv)=>{const originalMessage=messageDiv.getAttribute('data-original-message');const processedMessage=processTemplates(originalMessage);const paragraph=messageDiv.querySelector('p');paragraph.innerHTML=processedMessage;});welcomeBubble.classList.add('show');messages.forEach((message,index)=>{setTimeout(()=>{message.style.opacity='1';message.style.transform='translateY(0) scale(1)';},index*150);});}},delay);}
setTimeout(()=>{createWelcomeBubble();},1000);},'900');}
if(document.readyState==='complete'){init();}else{window.addEventListener('load',init);}})();