;(() => { function getWindowTop(w) { try { if (w.parent.document) { return getWindowTop(w.parent) } } catch (e) { return w } } const webchatWindow = getWindowTop(window) if (webchatWindow.responsa == null) { webchatWindow.responsa = { alreadyLaunched: false, configuration: undefined } } const responsa = webchatWindow.responsa if (responsa.api == null) { responsa.api = new Proxy({}, (target, prop) => { return function () { setTimeout(() => { responsa.api[prop](arguments) }, 100) } }) } responsa.init = function (configuration = {}, channelHostUri = undefined) { if (this.alreadyLaunched || (!this.configuration && !configuration)) { return } const botId = null const managerUri = 'https://mediolanum-selfy.manager.channel.prod.goresponsa.com' channelHostUri = channelHostUri ?? 'https://mediolanum-selfy.webchat.channel.prod.goresponsa.com' this.configuration = Object.assign(this.configuration || { managerUri }, configuration || {}) if (!this.configuration.botId && botId) this.configuration.botId = botId if (this.configuration.managerUri == null) this.configuration.managerUri = managerUri this.alreadyLaunched = true const doc = webchatWindow.document const now = new Date() //now.setMinutes(0) now.setSeconds(0) now.setMilliseconds(0) const scriptPolyfillShadowDOM = doc.createElement('script') scriptPolyfillShadowDOM.src = 'https://cdnjs.cloudflare.com/ajax/libs/shadydom/1.9.0/shadydom.min.js' doc.body.append(scriptPolyfillShadowDOM) const src = '{channel_host_uri}/responsa-webchat.min.js?timestamp={timestamp}' .replace('{channel_host_uri}', channelHostUri) .replace('{timestamp}', now.getTime()) const scriptEl = doc.createElement('script') scriptEl.src = src scriptEl.defer = true doc.body.append(scriptEl) this.loadedScripts = [scriptPolyfillShadowDOM, scriptEl] }.bind(responsa) responsa.unload = function () { this.loadedScripts?.forEach((s) => { s.remove() }) this.alreadyLaunched = false }.bind(responsa) window.addEventListener('load', () => responsa.init(false)) })()