"use strict";(self.webpackChunkLiveHelperChat=self.webpackChunkLiveHelperChat||[]).push([[398],{7398:function(e,t,s){s.r(t),s.d(t,{screenShare:function(){return i}});var r=s(5671),n=s(3144),o=s(2137),i=new(function(){function e(){(0,r.Z)(this,e),this.params={},this.attributes=null,this.chatEvents=null,this.isSharing=!1,this.sharemode="chat",this.sharehash=null,this.cobrowser=null}return(0,n.Z)(e,[{key:"startCoBrowse",value:function(e){var t=this;if(void 0===s)var s=!1;this.isSharing=!0,this.cobrowser=new LHCCoBrowser({formsenabled:s,chat_hash:this.sharehash,event_emitter:this.attributes.eventEmitter,nodejssettings:e.nodejssettings,nodejsenabled:e.nodejsenabled,trans:e.trans,url:e.url+"/(hash)/"+this.sharehash+"/?url="+encodeURIComponent(location.href.match(/^(.*\/)[^\/]*$/)[1])}),this.cobrowser.startMirroring();var r=function(e){t.cobrowser&&t.cobrowser.handleMessage(e.split(":"))};this.attributes.eventEmitter.addListener("screenshareCommand",r),this.attributes.eventEmitter.addOnceListener("finishScreenSharing",(function(e){o.a.removeById("lhc_status_mirror"),t.attributes.storageHandler.removeSessionStorage(t.attributes.prefixStorage+"_screenshare"),t.isSharing=!1;var s=document.getElementsByTagName("head")[0],n=document.createElement("script");encodeURIComponent(window.location.href.substring(window.location.protocol.length)),n.setAttribute("id","lhc_finish_shr"),n.setAttribute("type","text/javascript"),n.setAttribute("src",t.attributes.LHC_API.args.lhc_base_url+"/cobrowse/finishsession/(sharemode)/chat/(hash)/"+t.sharehash),s.appendChild(n),t.cobrowser=null,t.attributes.eventEmitter.removeListener("screenshareCommand",r)})),this.attributes.storageHandler.setSessionStorage(this.attributes.prefixStorage+"_screenshare",1)}},{key:"setParams",value:function(e,t,s){var r=this;this.params=e,this.attributes=t,this.chatEvents=s;var n=this.attributes.userSession.getSessionAttributes();this.sharehash=n.id+"_"+n.hash,0==this.isSharing&&o.a.makeRequest(this.attributes.LHC_API.args.lhc_base_url+"/widgetrestapi/screensharesettings",{},(function(e){if(r.params.auto_start||1==e.auto_share)r.initCoBrowsing(e);else{r.addCss(".lhc-modal {display: none; position: fixed; z-index: 1000001 !important;padding-top: 100px;left: 0;top: 0;  width: 100%;height: 100%; overflow: auto; background-color: rgb(0,0,0);  background-color: rgba(0,0,0,0.4); }.lhc-modal-content {background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 60%;border-radius:5px; }#lhc-close { color: #aaaaaa;    float: right;  font-size: 28px;    font-weight: bold;  }#lhc-close:hover,#lhc-close:focus {color: #000; text-decoration: none; cursor: pointer;}"),r.appendHTML('<div id="lhc-co-browsing-modal" style="display: block" class="lhc-modal"><div class="lhc-modal-content"><span id="lhc-close">&times;</span><p style="text-align: center"><button id="lhc-start-share-session" style="background-color: #4CAF50;  border: none;  color: white;  padding: 7px 16px;  text-align: center;border-radius:5px;  text-decoration: none;  display: inline-block;  font-size: 16px;  margin: 4px 2px;  cursor: pointer;">'+e.trans.start_share+'</button><button id="lhc-deny-share-session" style="background-color: #d2404a;  border: none;  color: white;  padding: 7px 16px;  text-align: center;border-radius:5px;  text-decoration: none;  display: inline-block;  font-size: 16px;  margin: 4px 2px;  cursor: pointer;">'+e.trans.deny+"</button></p></div></div>");var t=document.getElementById("lhc-close"),s=document.getElementById("lhc-deny-share-session"),n=document.getElementById("lhc-co-browsing-modal");s.onclick=t.onclick=function(){r.removeById("lhc-co-browsing-modal")},window.addEventListener("click",(function(e){e.target==n&&r.removeById("lhc-co-browsing-modal")})),document.getElementById("lhc-start-share-session").onclick=function(){r.removeById("lhc-co-browsing-modal"),r.initCoBrowsing(e)}}}))}},{key:"removeById",value:function(e){var t=null;return!!(t=document.getElementById(e))&&t.parentNode.removeChild(t)}},{key:"appendHTML",value:function(e){var t=document.createDocumentFragment(),s=document.createElement("div");for(s.innerHTML=e;s.firstChild;)t.appendChild(s.firstChild);document.body.insertBefore(t,document.body.childNodes[0])}},{key:"addCss",value:function(e){var t=document.getElementsByTagName("head")[0],s=document.createElement("style");if(s.type="text/css",s.styleSheet)s.styleSheet.cssText=e;else{var r=document.createTextNode(e);s.appendChild(r)}t.appendChild(s)}},{key:"initCoBrowsing",value:function(e){var t=this;if("undefined"==typeof TreeMirror){var s=document.getElementsByTagName("head")[0],r=document.createElement("script");r.setAttribute("type","text/javascript"),r.setAttribute("src",e.cobrowser),s.appendChild(r),r.onreadystatechange=r.onload=function(){t.startCoBrowse(e)}}else this.startCoBrowse(e)}}]),e}())}}]);
//# sourceMappingURL=16da6b6586a6fd6028ae.js.map