From e2c8c51074dd98d49fa8c3598234f52228ab209c Mon Sep 17 00:00:00 2001 From: Hakim Cassimally Date: Tue, 2 Apr 2024 18:04:26 +0100 Subject: [PATCH] [Improving] CSS fix for overflow Invisible parts of the iFrame are overlapping links below. This fix from https://github.com/couchbaselabs/lex-bot-ui/pull/15 (vendored in here) should fix. --- src/css/chatbot.css | 33 +++++++++++++++++++++++++-------- src/js/vendor/chatbox-ui.min.js | 3 ++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/css/chatbot.css b/src/css/chatbot.css index d74cab32..2df90b4c 100644 --- a/src/css/chatbot.css +++ b/src/css/chatbot.css @@ -15,7 +15,7 @@ .lex-web-ui-iframe iframe { border-radius: 8px 8px 10px 10px; - overflow: hidden; + /* overflow: hidden; */ width: 100%; height: 100%; } @@ -25,10 +25,21 @@ } .lex-web-ui-iframe--minimize { - max-width: 230px !important; - max-height: 185px !important; + max-width: 90px !important; + max-height: 90px !important; border-radius: 85px !important; - min-width: 230px !important; + min-width: 90px !important; +} + +.lex-web-ui-iframe--minimize:hover { + max-width: 200px !important; +} + +.lex-web-ui-iframe--minimize.add-space-for-bubble { + max-width: 250px !important; + max-height: 150px !important; + border-radius: 85px !important; + min-width: 250px !important; } .lex-web-ui-iframe--maximize { @@ -85,10 +96,16 @@ min-width: 90vw !important; } - .lex-web-ui-iframe.lex-web-ui-iframe--show.lex-web-ui-iframe--minimize { - max-width: 300px !important; - max-height: 185px !important; + /* .lex-web-ui-iframe.lex-web-ui-iframe--show.lex-web-ui-iframe--minimize { + max-width: 245px !important; + max-height: 145px !important; + border-radius: 85px !important; + min-width: 245px !important; + } */ + .lex-web-ui-iframe.lex-web-ui-iframe--show.lex-web-ui-iframe--minimize--bubble { + max-width: 245px !important; + max-height: 145px !important; border-radius: 85px !important; - min-width: 230px !important; + min-width: 245px !important; } } diff --git a/src/js/vendor/chatbox-ui.min.js b/src/js/vendor/chatbox-ui.min.js index 61f58a60..27f620a5 100644 --- a/src/js/vendor/chatbox-ui.min.js +++ b/src/js/vendor/chatbox-ui.min.js @@ -1 +1,2 @@ -var ChatBotUiLoader;(()=>{var e={40:e=>{class t{constructor({config:e={},containerClass:t="lex-web-ui",elementId:i="lex-web-ui"}){this.elementId=i,this.config=e,this.containerClass=t,this.iframeElement=null,this.containerElement=null,this.credentials=null,this.isChatBotReady=!1,this.initIframeMessageHandlers()}load(e){this.config=t.mergeConfig(this.config,e),"iframe"in this.config||(this.config.iframe={});const i=this.config.iframe;return"iframeOrigin"in i&&i.iframeOrigin||(this.config.iframe.iframeOrigin=this.config.ui.parentOrigin||window.location.origin),void 0===i.shouldLoadIframeMinimized&&(this.config.iframe.shouldLoadIframeMinimized=!0),this.config.ui.parentOrigin||(this.config.ui.parentOrigin=this.config.iframe.iframeOrigin||window.location.origin),t.validateConfig(this.config)?Promise.all([this.initContainer(),this.setupIframeMessageListener()]).then((()=>this.initIframe())).then((()=>this.initParentToIframeApi())).then((()=>this.showIframe())):Promise.reject(new Error("config object is missing required fields"))}static validateConfig(e){const{iframe:t,ui:i}=e;return t?"iframeOrigin"in t&&t.iframeOrigin?"iframeSrcPath"in t&&t.iframeSrcPath?"parentOrigin"in i&&i.parentOrigin?"shouldLoadIframeMinimized"in t||(console.error("missing shouldLoadIframeMinimized config field"),!1):(console.error("missing parentOrigin config field"),!1):(console.error("missing iframeSrcPath config field"),!1):(console.error("missing iframeOrigin config field"),!1):(console.error("missing iframe config field"),!1)}initContainer(){return new Promise(((e,t)=>{if(!this.elementId||!this.containerClass)return t(new Error("invalid chatbot container parameters"));let i=document.getElementById(this.elementId);if(i)return console.warn("chatbot iframe container already exists"),this.containerElement=i,e(i);try{i=document.createElement("div"),i.classList.add(this.containerClass),i.setAttribute("id",this.elementId),document.body.appendChild(i)}catch(e){return t(new Error(`error initializing container: ${e}`))}return this.containerElement=i,e()}))}setupIframeMessageListener(){try{window.addEventListener("message",this.onMessageFromIframe.bind(this),!1)}catch(e){return Promise.reject(new Error(`could not add iframe message listener ${e}`))}return Promise.resolve()}onMessageFromIframe(e){const t="iframe"in this.config&&"string"==typeof this.config.iframe.iframeOrigin?this.config.iframe.iframeOrigin:window.location.origin;"data"in e&&"source"in e.data&&"lex-web-ui"!==e.data.source||(e.origin===t?e.ports&&Array.isArray(e.ports)&&e.ports.length?this.iframeMessageHandlers?e.data.event?Object.prototype.hasOwnProperty.call(this.iframeMessageHandlers,e.data.event)?this.iframeMessageHandlers[e.data.event].call(this,e):console.error("unknown message in event",e.data):console.error("event from iframe does not have the event field",e):console.error("invalid iframe message handler"):console.warn("postMessage not sent over MessageChannel",e):console.warn("postMessage from invalid origin",e.origin))}initIframe(){const{iframeOrigin:e,iframeSrcPath:t}=this.config.iframe;if(!e||!t)return Promise.reject(new Error("invalid iframe url fields"));const i=`${e}${t}`;if(!i)return Promise.reject(new Error("invalid iframe url"));if(!this.containerElement||!("appendChild"in this.containerElement))return Promise.reject(new Error("invalid node element to append iframe"));let r=this.containerElement.querySelector("iframe");if(r)return Promise.resolve(r);try{r=document.createElement("iframe"),r.setAttribute("src",i),r.setAttribute("frameBorder","0"),r.setAttribute("scrolling","no"),r.setAttribute("title","chatbot"),r.setAttribute("allow","microphone; clipboard-read; clipboard-write;"),this.containerElement.appendChild(r)}catch(e){return Promise.reject(new Error(`failed to initialize iframe element ${e}`))}return this.iframeElement=r,this.waitForIframe(r).then((()=>this.waitForChatBotReady()))}waitForIframe(){const e={timeoutInMs:2e4,timeoutId:null,onIframeLoaded:null,onIframeTimeout:null};return new Promise(((t,i)=>{e.onIframeLoaded=()=>(clearTimeout(e.timeoutId),this.iframeElement.removeEventListener("load",e.onIframeLoaded,!1),t()),e.onIframeTimeout=()=>(this.iframeElement.removeEventListener("load",e.onIframeLoaded,!1),i(new Error("iframe load timeout"))),e.timeoutId=setTimeout(e.onIframeTimeout,e.timeoutInMs),this.iframeElement.addEventListener("load",e.onIframeLoaded,!1)}))}waitForChatBotReady(){const e={timeoutId:null,intervalId:null,checkIsChtBotReady:null,onConfigEventTimeout:null};return new Promise(((t,i)=>{e.checkIsChatBotReady=()=>{this.isChatBotReady&&(clearTimeout(e.timeoutId),clearInterval(e.intervalId),t())},e.onConfigEventTimeout=()=>(clearInterval(e.intervalId),i(new Error("chatbot loading time out"))),e.timeoutId=setTimeout(e.onConfigEventTimeout,15e3),e.intervalId=setInterval(e.checkIsChatBotReady,500)}))}initIframeMessageHandlers(){this.iframeMessageHandlers={ready(e){this.isChatBotReady=!0,e.ports[0].postMessage({event:"resolve",type:e.data.event})},getCredentials(e){return this.getCredentials().then((t=>{const i=JSON.parse(JSON.stringify(t));e.ports[0].postMessage({event:"resolve",type:e.data.event,data:i})})).catch((t=>{console.error("failed to get credentials",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to get credentials"})}))},initIframeConfig(e){e.ports[0].postMessage({event:"resolve",type:e.data.event,data:this.config})},toggleMinimizeUi(e){this.toggleMinimizeUiClass().then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to toggleMinimizeUi",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to toggleMinimizeUi"})}))},toggleIsUiExpanded(e){this.toggleMaximizeUiClass().then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to toggleIsUiExpanded",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to toggleIsUiExpanded"})}))},updateLexState(e){e.ports[0].postMessage({event:"resolve",type:e.data.event});const t=new CustomEvent("updatelexstate",{detail:e.data});document.dispatchEvent(t)}}}sendMessageToIframe(e){if(!this.iframeElement||!("contentWindow"in this.iframeElement)||!("postMessage"in this.iframeElement.contentWindow))return Promise.reject(new Error("invalid iframe element"));const{iframeOrigin:t}=this.config.iframe;return t?new Promise(((i,r)=>{const n=new MessageChannel;n.port1.onmessage=e=>{n.port1.close(),n.port2.close(),"resolve"===e.data.event?i(e.data):r(new Error(`iframe failed to handle message - ${e.data.error}`))},this.iframeElement.contentWindow.postMessage(e,t,[n.port2])})):Promise.reject(new Error("invalid iframe origin"))}toggleShowUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--show`),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle show UI ${e}`))}}toggleMinimizeUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--minimize`),this.containerElement.classList.contains(`${this.containerClass}--minimize`)?localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"true"):localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"false"),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle minimize UI ${e}`))}}toggleMaximizeUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--maximize`),this.containerElement.classList.contains(`${this.containerClass}--maximize`)?localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMaximized`,"true"):localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMaximized`,"false"),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle maximize UI ${e}`))}}showIframe(){return Promise.resolve().then((()=>{this.config.iframe.shouldLoadIframeMinimized?(this.api.toggleMinimizeUi(),localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"true")):localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&"true"===localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)?this.api.toggleMinimizeUi():localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&"false"===localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&this.api.ping()})).then((()=>this.toggleShowUiClass()))}onMessageToIframe(e){return e&&"detail"in e&&e.detail&&"message"in e.detail?this.sendMessageToIframe(e.detail.message):Promise.reject(new Error("malformed message to iframe event"))}initParentToIframeApi(){return this.api={MESSAGE_TYPE_HUMAN:"human",MESSAGE_TYPE_BUTTON:"button",ping:()=>this.sendMessageToIframe({event:"ping"}),sendParentReady:()=>this.sendMessageToIframe({event:"parentReady"}),toggleMinimizeUi:()=>this.sendMessageToIframe({event:"toggleMinimizeUi"}),toggleIsUiExpanded:()=>this.sendMessageToIframe({event:"toggleIsUiExpanded"}),postText:(e,t)=>this.sendMessageToIframe({event:"postText",message:e,messageType:t}),deleteSession:()=>this.sendMessageToIframe({event:"deleteSession"}),startNewSession:()=>this.sendMessageToIframe({event:"startNewSession"}),setSessionAttribute:(e,t)=>this.sendMessageToIframe({event:"setSessionAttribute",key:e,value:t})},Promise.resolve().then((()=>{document.addEventListener("lexWebUiMessage",this.onMessageToIframe.bind(this),!1)})).then((()=>this.api.sendParentReady())).then((()=>{document.dispatchEvent(new CustomEvent("lexWebUiReady"))}))}static mergeConfig(e,i={}){function r(e){return"number"!=typeof e&&"boolean"!=typeof e&&(null==e||(void 0!==e.length?0===e.length:0===Object.keys(e).length))}return r(i)?{...e}:Object.keys(e).map((n=>{const s={};let o=e[n];return n in i&&!r(i[n])&&(o="object"==typeof e[n]?{...t.mergeConfig(i[n],e[n]),...t.mergeConfig(e[n],i[n])}:i[n]),s[n]=o,s})).reduce(((e,t)=>({...e,...t})),{})}}e.exports=t},203:(e,t,i)=>{const r=i(40);class n{constructor(e){const{baseUrl:t}=e;this.options=e,this.options.baseUrl=this.options.baseUrl&&"/"===t[t.length-1]?this.options.baseUrl:`${this.options.baseUrl}/`}load(e={}){return this.config=r.mergeConfig(this.config,e),this.compLoader.load(this.config)}}const s={baseUrl:"/",configEventTimeoutInMs:1e4,configUrl:"./lex-web-ui-loader-config.json",shouldIgnoreConfigWhenEmbedded:!0,shouldLoadConfigFromEvent:!1,shouldLoadConfigFromJsonFile:!0,shouldLoadMinDeps:!1,elementId:"lex-web-ui-iframe",containerClass:"lex-web-ui-iframe",iframeSrcPath:"/index.html#/?lexWebUiEmbed=true",shouldLoadConfigFromEvent:!0,shouldLoadMinDeps:!1},o={ui:{parentOrigin:""},iframe:{iframeOrigin:"",iframeSrcPath:""}},a={IframeLoader:class extends n{constructor(e={}){super({...s,...e}),this.config=o,this.compLoader=new r({config:this.config,containerClass:this.options.containerClass||"lex-web-ui",elementId:this.options.elementId||"lex-web-ui"})}load(e={}){return super.load(e).then((()=>{this.api=this.compLoader.api,this.config.iframe=this.config.iframe||{},this.config.iframe.iframeSrcPath=this.config.iframe.iframeSrcPath||this.mergeSrcPath(e)}))}mergeSrcPath(e){const{iframe:t}=e,i=t&&t.iframeSrcPath,{iframe:r}=this.config,n=r&&r.iframeSrcPath;return i||this.options.iframeSrcPath||n}}};e.exports=a}},t={},i=function i(r){var n=t[r];if(void 0!==n)return n.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,i),s.exports}(203);ChatBotUiLoader=i})(); \ No newline at end of file +/* eslint-disable */ +var ChatBotUiLoader;(()=>{var e={40:e=>{class t{constructor({config:e={},containerClass:t="lex-web-ui",elementId:i="lex-web-ui"}){this.elementId=i,this.config=e,this.containerClass=t,this.iframeElement=null,this.containerElement=null,this.credentials=null,this.isChatBotReady=!1,this.initIframeMessageHandlers()}load(e){this.config=t.mergeConfig(this.config,e),"iframe"in this.config||(this.config.iframe={});const i=this.config.iframe;return"iframeOrigin"in i&&i.iframeOrigin||(this.config.iframe.iframeOrigin=this.config.ui.parentOrigin||window.location.origin),void 0===i.shouldLoadIframeMinimized&&(this.config.iframe.shouldLoadIframeMinimized=!0),this.config.ui.parentOrigin||(this.config.ui.parentOrigin=this.config.iframe.iframeOrigin||window.location.origin),t.validateConfig(this.config)?Promise.all([this.initContainer(),this.setupIframeMessageListener()]).then((()=>this.initIframe())).then((()=>this.initParentToIframeApi())).then((()=>this.showIframe())):Promise.reject(new Error("config object is missing required fields"))}static validateConfig(e){const{iframe:t,ui:i}=e;return t?"iframeOrigin"in t&&t.iframeOrigin?"iframeSrcPath"in t&&t.iframeSrcPath?"parentOrigin"in i&&i.parentOrigin?"shouldLoadIframeMinimized"in t||(console.error("missing shouldLoadIframeMinimized config field"),!1):(console.error("missing parentOrigin config field"),!1):(console.error("missing iframeSrcPath config field"),!1):(console.error("missing iframeOrigin config field"),!1):(console.error("missing iframe config field"),!1)}initContainer(){return new Promise(((e,t)=>{if(!this.elementId||!this.containerClass)return t(new Error("invalid chatbot container parameters"));let i=document.getElementById(this.elementId);if(i)return console.warn("chatbot iframe container already exists"),this.containerElement=i,e(i);try{i=document.createElement("div"),i.classList.add(this.containerClass),i.setAttribute("id",this.elementId),document.body.appendChild(i)}catch(e){return t(new Error(`error initializing container: ${e}`))}return this.containerElement=i,e()}))}setupIframeMessageListener(){try{window.addEventListener("message",this.onMessageFromIframe.bind(this),!1)}catch(e){return Promise.reject(new Error(`could not add iframe message listener ${e}`))}return Promise.resolve()}onMessageFromIframe(e){const t="iframe"in this.config&&"string"==typeof this.config.iframe.iframeOrigin?this.config.iframe.iframeOrigin:window.location.origin;"data"in e&&"source"in e.data&&"lex-web-ui"!==e.data.source||(e.origin===t?e.ports&&Array.isArray(e.ports)&&e.ports.length?this.iframeMessageHandlers?e.data.event?Object.prototype.hasOwnProperty.call(this.iframeMessageHandlers,e.data.event)?this.iframeMessageHandlers[e.data.event].call(this,e):console.error("unknown message in event",e.data):console.error("event from iframe does not have the event field",e):console.error("invalid iframe message handler"):console.warn("postMessage not sent over MessageChannel",e):console.warn("postMessage from invalid origin",e.origin))}initIframe(){const{iframeOrigin:e,iframeSrcPath:t}=this.config.iframe;if(!e||!t)return Promise.reject(new Error("invalid iframe url fields"));const i=`${e}${t}`;if(!i)return Promise.reject(new Error("invalid iframe url"));if(!this.containerElement||!("appendChild"in this.containerElement))return Promise.reject(new Error("invalid node element to append iframe"));let r=this.containerElement.querySelector("iframe");if(r)return Promise.resolve(r);try{r=document.createElement("iframe"),r.setAttribute("src",i),r.setAttribute("frameBorder","0"),r.setAttribute("scrolling","no"),r.setAttribute("title","chatbot"),r.setAttribute("allow","microphone; clipboard-read; clipboard-write;"),this.containerElement.appendChild(r)}catch(e){return Promise.reject(new Error(`failed to initialize iframe element ${e}`))}return this.iframeElement=r,this.waitForIframe(r).then((()=>this.waitForChatBotReady()))}waitForIframe(){const e={timeoutInMs:2e4,timeoutId:null,onIframeLoaded:null,onIframeTimeout:null};return new Promise(((t,i)=>{e.onIframeLoaded=()=>(clearTimeout(e.timeoutId),this.iframeElement.removeEventListener("load",e.onIframeLoaded,!1),t()),e.onIframeTimeout=()=>(this.iframeElement.removeEventListener("load",e.onIframeLoaded,!1),i(new Error("iframe load timeout"))),e.timeoutId=setTimeout(e.onIframeTimeout,e.timeoutInMs),this.iframeElement.addEventListener("load",e.onIframeLoaded,!1)}))}waitForChatBotReady(){const e={timeoutId:null,intervalId:null,checkIsChtBotReady:null,onConfigEventTimeout:null};return new Promise(((t,i)=>{e.checkIsChatBotReady=()=>{this.isChatBotReady&&(clearTimeout(e.timeoutId),clearInterval(e.intervalId),t())},e.onConfigEventTimeout=()=>(clearInterval(e.intervalId),i(new Error("chatbot loading time out"))),e.timeoutId=setTimeout(e.onConfigEventTimeout,15e3),e.intervalId=setInterval(e.checkIsChatBotReady,500)}))}initIframeMessageHandlers(){this.iframeMessageHandlers={ready(e){this.isChatBotReady=!0,e.ports[0].postMessage({event:"resolve",type:e.data.event})},getCredentials(e){return this.getCredentials().then((t=>{const i=JSON.parse(JSON.stringify(t));e.ports[0].postMessage({event:"resolve",type:e.data.event,data:i})})).catch((t=>{console.error("failed to get credentials",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to get credentials"})}))},initIframeConfig(e){e.ports[0].postMessage({event:"resolve",type:e.data.event,data:this.config})},toggleMinimizeUi(e){this.toggleMinimizeUiClass().then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to toggleMinimizeUi",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to toggleMinimizeUi"})}))},addSpaceForBubble(e){this.setSpaceForBubble(!0).then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to addSpaceForBubble",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to addSpaceForBubble"})}))},removeSpaceForBubble(e){this.setSpaceForBubble(!1).then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to removeSpaceForBubble",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to removeSpaceForBubble"})}))},toggleIsUiExpanded(e){this.toggleMaximizeUiClass().then((()=>e.ports[0].postMessage({event:"resolve",type:e.data.event}))).catch((t=>{console.error("failed to toggleIsUiExpanded",t),e.ports[0].postMessage({event:"reject",type:e.data.event,error:"failed to toggleIsUiExpanded"})}))},updateLexState(e){e.ports[0].postMessage({event:"resolve",type:e.data.event});const t=new CustomEvent("updatelexstate",{detail:e.data});document.dispatchEvent(t)}}}sendMessageToIframe(e){if(!this.iframeElement||!("contentWindow"in this.iframeElement)||!("postMessage"in this.iframeElement.contentWindow))return Promise.reject(new Error("invalid iframe element"));const{iframeOrigin:t}=this.config.iframe;return t?new Promise(((i,r)=>{const n=new MessageChannel;n.port1.onmessage=e=>{n.port1.close(),n.port2.close(),"resolve"===e.data.event?i(e.data):r(new Error(`iframe failed to handle message - ${e.data.error}`))},this.iframeElement.contentWindow.postMessage(e,t,[n.port2])})):Promise.reject(new Error("invalid iframe origin"))}toggleShowUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--show`),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle show UI ${e}`))}}setSpaceForBubble(e=!1){try{return this.containerElement.classList.toggle("add-space-for-bubble",e),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle space for bubble ${e}`))}}toggleMinimizeUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--minimize`),this.containerElement.classList.contains(`${this.containerClass}--minimize`)?localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"true"):localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"false"),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle minimize UI ${e}`))}}toggleMaximizeUiClass(){try{return this.containerElement.classList.toggle(`${this.containerClass}--maximize`),this.containerElement.classList.contains(`${this.containerClass}--maximize`)?localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMaximized`,"true"):localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMaximized`,"false"),Promise.resolve()}catch(e){return Promise.reject(new Error(`failed to toggle maximize UI ${e}`))}}showIframe(){return Promise.resolve().then((()=>{this.config.iframe.shouldLoadIframeMinimized?(this.api.toggleMinimizeUi(),localStorage.setItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`,"true")):localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&"true"===localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)?this.api.toggleMinimizeUi():localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&"false"===localStorage.getItem(`${this.config.ui.toolbarTitle}lastUiIsMinimized`)&&this.api.ping()})).then((()=>this.toggleShowUiClass()))}onMessageToIframe(e){return e&&"detail"in e&&e.detail&&"message"in e.detail?this.sendMessageToIframe(e.detail.message):Promise.reject(new Error("malformed message to iframe event"))}initParentToIframeApi(){return this.api={MESSAGE_TYPE_HUMAN:"human",MESSAGE_TYPE_BUTTON:"button",ping:()=>this.sendMessageToIframe({event:"ping"}),sendParentReady:()=>this.sendMessageToIframe({event:"parentReady"}),toggleMinimizeUi:()=>this.sendMessageToIframe({event:"toggleMinimizeUi"}),toggleIsUiExpanded:()=>this.sendMessageToIframe({event:"toggleIsUiExpanded"}),postText:(e,t)=>this.sendMessageToIframe({event:"postText",message:e,messageType:t}),deleteSession:()=>this.sendMessageToIframe({event:"deleteSession"}),startNewSession:()=>this.sendMessageToIframe({event:"startNewSession"}),setSessionAttribute:(e,t)=>this.sendMessageToIframe({event:"setSessionAttribute",key:e,value:t})},Promise.resolve().then((()=>{document.addEventListener("lexWebUiMessage",this.onMessageToIframe.bind(this),!1)})).then((()=>this.api.sendParentReady())).then((()=>{document.dispatchEvent(new CustomEvent("lexWebUiReady"))}))}static mergeConfig(e,i={}){function r(e){return"number"!=typeof e&&"boolean"!=typeof e&&(null==e||(void 0!==e.length?0===e.length:0===Object.keys(e).length))}return r(i)?{...e}:Object.keys(e).map((n=>{const o={};let s=e[n];return n in i&&!r(i[n])&&(s="object"==typeof e[n]?{...t.mergeConfig(i[n],e[n]),...t.mergeConfig(e[n],i[n])}:i[n]),o[n]=s,o})).reduce(((e,t)=>({...e,...t})),{})}}e.exports=t},203:(e,t,i)=>{const r=i(40);class n{constructor(e){const{baseUrl:t}=e;this.options=e,this.options.baseUrl=this.options.baseUrl&&"/"===t[t.length-1]?this.options.baseUrl:`${this.options.baseUrl}/`}load(e={}){return this.config=r.mergeConfig(this.config,e),this.compLoader.load(this.config)}}const o={baseUrl:"/",configEventTimeoutInMs:1e4,configUrl:"./lex-web-ui-loader-config.json",shouldIgnoreConfigWhenEmbedded:!0,shouldLoadConfigFromEvent:!1,shouldLoadConfigFromJsonFile:!0,shouldLoadMinDeps:!1,elementId:"lex-web-ui-iframe",containerClass:"lex-web-ui-iframe",iframeSrcPath:"/index.html#/?lexWebUiEmbed=true",shouldLoadConfigFromEvent:!0,shouldLoadMinDeps:!1},s={ui:{parentOrigin:""},iframe:{iframeOrigin:"",iframeSrcPath:""}},a={IframeLoader:class extends n{constructor(e={}){super({...o,...e}),this.config=s,this.compLoader=new r({config:this.config,containerClass:this.options.containerClass||"lex-web-ui",elementId:this.options.elementId||"lex-web-ui"})}load(e={}){return super.load(e).then((()=>{this.api=this.compLoader.api,this.config.iframe=this.config.iframe||{},this.config.iframe.iframeSrcPath=this.config.iframe.iframeSrcPath||this.mergeSrcPath(e)}))}mergeSrcPath(e){const{iframe:t}=e,i=t&&t.iframeSrcPath,{iframe:r}=this.config,n=r&&r.iframeSrcPath;return i||this.options.iframeSrcPath||n}}};e.exports=a}},t={},i=function i(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,i),o.exports}(203);ChatBotUiLoader=i})(); \ No newline at end of file