"use strict";(self.webpackChunkLHCReactAPP=self.webpackChunkLHCReactAPP||[]).push([[307],{307:function(e,t,a){a.r(t);var n,r=a(4575),i=a.n(r),s=a(3913),o=a.n(s),c=a(2205),d=a.n(c),p=a(8585),h=a.n(p),l=a(9754),u=a.n(l),m=a(7294),f=a(6458),g=a(6512);var y=(0,f.$j)((function(e){return{chatwidget:e.chatwidget}}))(n=function(e){d()(r,e);var t,a,n=(t=r,a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=u()(t);if(a){var r=u()(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return h()(this,e)});function r(e){return i()(this,r),n.call(this,e)}return o()(r,[{key:"getDocument",value:function(e){return e.contentWindow?e.contentWindow.document:e.contentDocument?e.contentDocument:e.document?e.document:null}},{key:"insertCssRemoteFile",value:function(e,t){var a=null;if(t.id&&t.href&&null!==(a=e.getElementById(t.id)))a.href=t.href;else{var n=e.getElementsByTagName("head")[0],r=e.createDocumentFragment(),i=e.createElement("link");for(var s in i.rel="stylesheet",i.crossOrigin="*",t)i[s]=t[s];r.appendChild(i),n.appendChild(r)}}},{key:"insertJSFile",value:function(e,t,a,n){var r=e.getElementsByTagName("head")[0],i=e.createDocumentFragment(),s=e.createElement("script");s.type="text/javascript",void 0!==a&&!0!==a||(s.async=!0),s.crossOrigin="*",s.src=t,n&&(delete n.src,void 0!==n.async&&delete n.async,Object.keys(n).forEach((function(e){s.setAttribute(e,n[e])}))),i.appendChild(s),r.appendChild(i)}},{key:"prepareIframe",value:function(e){var t=this,a=this.getDocument(e);a.getElementsByTagName("head")[0].innerHTML='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />';var n=a.getElementsByTagName("html")[0];n.setAttribute("lang","en"),n.setAttribute("dir","ltr");var r=document.implementation.createDocumentType("html","","");return a.doctype?a.replaceChild(r,a.doctype):a.insertBefore(r,a.childNodes[0]),this.props["data-css"]&&JSON.parse(this.props["data-css"]).forEach((function(e){t.insertCssRemoteFile(a,e)})),this.props["data-js"]&&JSON.parse(this.props["data-js"]).forEach((function(e){t.insertJSFile(a,e.src,!!e.async&&e.async,e)})),a.body.innerHTML=this.props["data-body"],a}},{key:"prependURL",value:function(){var e=[],t="?",a=this.props.chatwidget.get("jsVars");return Object.keys(a).forEach((function(t){e.push("jsvar["+t+"]="+encodeURIComponent(a[t]))})),e.length>0&&(t=t+"&"+e.join("&")),this.props.chatwidget.hasIn(["chatData","id"])&&(t=t+"&chat_id="+this.props.chatwidget.getIn(["chatData","id"])+"&hash="+this.props.chatwidget.getIn(["chatData","hash"])+"&msg_id="+this.props["data-id"]),t}},{key:"componentDidMount",value:function(){var e=this,t=document.createElement("iframe");if(this.props["data-form"]&&(t.src=this.props["data-form"]+this.prependURL()),t.onload=function(){if(!e.props["data-form"])for(var a=e.prepareIframe(t).body.getElementsByClassName("lhc-iframe-close"),n=0;n<a.length;n++)a[n].addEventListener("click",(function(){(0,g.$y)({id:e.props.chatwidget.getIn(["chatData","id"]),hash:e.props.chatwidget.getIn(["chatData","hash"]),msg_id:e.props["data-id"]},{action:"iframe_close"}).then((function(){e.props.updateMessage(e.props["data-id"])}))}));var r=document.getElementById("messages-scroll");if(null!==r&&(r.scrollTop=r.scrollHeight+1e3),!e.props["data-form"]&&e.props["data-js-body"]){var i=documentFrame.createElement("script");i.textContent=e.props["data-js-body"],documentFrame.head.appendChild(i)}},t.onerror=function(){console.log("Something wrong happened")},this.props["data-style"]&&(t.style=this.props["data-style"]),this.props["data-iframe"]){var a=JSON.parse(this.props["data-iframe"]);a.one_per_chat&&1==a.one_per_chat&&a["iframe-identifier"]&&function(){for(var t=document.getElementsByClassName(a["iframe-identifier"]),n=function(a){t[a].parentNode&&(0,g.$y)({id:e.props.chatwidget.getIn(["chatData","id"]),hash:e.props.chatwidget.getIn(["chatData","hash"]),msg_id:t[a].getAttribute("data-msg-id")},{action:"iframe_close"}).then((function(){e.props.updateMessage(t[a].getAttribute("data-msg-id"))}))},r=0;r<t.length;r++)n(r)}(),a["iframe-identifier"]&&(t.className=a["iframe-identifier"]),t.setAttribute("data-msg-id",this.props["data-id"])}document.getElementById("iframe-msg-"+this.props["data-id"]).appendChild(t)}},{key:"render",value:function(){return this.props.t,m.createElement("div",{id:"iframe-msg-"+this.props["data-id"]})}}]),r}(m.Component))||n;t.default=y}}]);
//# sourceMappingURL=307.40312c53f609f1919d8b.js.map