(function () { var socketScript = document.createElement('script'); socketScript.src = 'https://cdn.socket.io/4.6.1/socket.io.min.js'; const urlParams = new URLSearchParams(window.location.search); host = 'demo.sndrmsg.com'; if(urlParams.get('mode') == 'dev'){ host = 'dev.dany.ai'; } let protocol = 'https:'; if (location.port == '3000' || location.port == '3001') { protocol = location.protocol; host = 'localhost:3000'; } var cssLink = document.createElement('link'); cssLink.rel = 'stylesheet'; cssLink.type = 'text/css'; cssLink.href = `${protocol}//${host}/widget/widget.css`; // cssLink.href = `./widget.css`; // DEV styles for testing if ( urlParams.get('mode') == 'dev' ) { var dev_for_testing = document.createElement('link'); dev_for_testing.rel = 'stylesheet'; dev_for_testing.type = 'text/css'; dev_for_testing.href = `${protocol}//${host}/widget/css/dev_for_testing.css`; document.head.appendChild(dev_for_testing); } var widgetContainer = document.createElement('div'); widgetContainer.id = 'widget-container'; (function (window) { const scriptTag = document.querySelector('script[src*="https://chat.sndrmsg.com"]'); if (scriptTag) { const url = new URL(scriptTag.src); localStorage.setItem('midValue', url.search.split('=')[1] || ''); } class Hooks { constructor() { this.hooks = {}; } addHook(hookName, callback) { if (!this.hooks[hookName]) { this.hooks[hookName] = []; } this.hooks[hookName].push(callback); } removeHook(hookName, callback) { if (!this.hooks[hookName]) return; this.hooks[hookName] = this.hooks[hookName].filter(fn => fn !== callback); } invokeHook(hookName, data) { if (!this.hooks[hookName]) return; this.hooks[hookName].forEach(callback => callback(data)); } } const hooksInstance = new Hooks(); window.widgetInstantHooks = hooksInstance; })(window); document.head.appendChild(socketScript); socketScript.onload = () => { var widgetScript = document.createElement('script'); widgetScript.async = true; widgetScript.src = `${protocol}//${host}/widget/js/dist/index.js?v=${Date.now()}`; widgetScript.id = 'sndrmsg-script-index'; // widgetScript.src = `./index.js`; var sliderScript = document.createElement('script'); sliderScript.async = true; sliderScript.src = `https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.3/min/tiny-slider.js`; var sliderStyle = document.createElement('link'); sliderStyle.rel = 'stylesheet'; sliderStyle.type = 'text/css'; sliderStyle.href = `https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.3/tiny-slider.css`; document.head.appendChild(cssLink); document.head.appendChild(sliderStyle); document.body.appendChild(widgetContainer); document.body.appendChild(widgetScript); document.body.appendChild(sliderScript); } })();