!function(){"use strict";var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function R(t,e){return t(e={exports:{}},e.exports),e.exports}var F="object"==typeof E&&E&&E.Object===Object&&E,t="object"==typeof self&&self&&self.Object===Object&&self,i=F||t||Function("return this")(),t=i.Symbol;var P=function(t,e){for(var n=-1,i=null==t?0:t.length,o=Array(i);++n>>0,e>>>=0,Array(o));++i= 0x80 (not a basic code point)","invalid-input":"Invalid input"},p=g-1,y=Math.floor,b=String.fromCharCode;function w(t){throw new RangeError(d[t])}function f(t,e){for(var n=t.length,i=[];n--;)i[n]=e(t[n]);return i}function m(t,e){var n=t.split("@"),i="",n=(1>>10&1023|55296),t=56320|1023&t),e+=b(t)}).join("")}function k(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function S(t,e,n){var i=0;for(t=n?y(t/c):t>>1,t+=y(t/e);p*_>>1y((v-u)/r))&&w("overflow"),u+=a*r,!(a<(a=s<=d?1:d+_<=s?_:s-d));s+=g)r>y(v/(a=g-a))&&w("overflow"),r*=a;d=S(u-o,e=c.length+1,0==o),y(u/e)>v-h&&w("overflow"),h+=y(u/e),u%=e,c.splice(u++,0,h)}return I(c)}function O(t){for(var e,n,i,o,r,s,a,c,l,u,h=[],d=(t=C(t)).length,p=128,f=72,m=e=0;my((v-e)/(c=n+1))&&w("overflow"),e+=(o-p)*c,p=o,m=0;mv&&w("overflow"),a==p){for(r=e,s=g;!(r<(l=s<=f?1:f+_<=s?_:s-f));s+=g)h.push(b(k(l+(u=r-l)%(l=g-l),0))),r=y(u/l);h.push(b(k(r,0))),f=S(e,c,n==i),e=0,++n}++e,++p}return h.join("")}if(r={version:"1.4.1",ucs2:{decode:C,encode:I},decode:A,encode:O,toASCII:function(t){return m(t,function(t){return u.test(t)?"xn--"+O(t):t})},toUnicode:function(t){return m(t,function(t){return l.test(t)?A(t.slice(4).toLowerCase()):t})}},i&&e)if(t.exports==i)e.exports=r;else for(s in r)r.hasOwnProperty(s)&&(i[s]=r[s]);else n.punycode=r}),C={gso:"",forms:"",button:"",promo:""};function An(t){return On(window[t])?null:window[t]}function I(t){for(var e=[],n=arguments.length-1;0=i+n&&(this.scrollParams.is_scroll="N",this.displayGreeting())},A.prototype.afterScrollGreeting=function(){this.debouncedDisplayGreetingOnScrollListener=Ni(this.displayGreetingOnScrollListener,100),S.add({target:window,eventName:"scroll",handler:this.debouncedDisplayGreetingOnScrollListener}),this.displayGreetingOnScrollListener()},A.prototype.checkFrequencyDay=function(){var t=this,e=(parseInt(localStorage.getItem(Bi))||0)+864e5;Date.now()\n
\n
\n
\n '+O("Conversation")+'\n \n '+n+'\n \n
\n
\n '+i+'\n
\n
\n
\n '+o+": "+r+"\n
\n
\n \n "},T.prototype.getSelectorTemplate=function(){return'\n
\n
\n
\n
'+O("Conversations")+'
\n\n
\n \n \n \n
\n\n
\n \n \n \n
\n
\n\n
\n
\n
\n '+O("Show all")+'\n
\n
\n '+O("Create new conversation")+"\n
\n
\n
\n
\n "},T.prototype.getFormattedDate=function(t){var t=new Date(t),e=new Date,n=new Date(Date.now()-864e5),i=t.getDate(),o=t.getMonth()+1,t=t.getFullYear();return i===e.getDate()&&o===e.getMonth()+1&&t===e.getFullYear()?O("Today"):i===n.getDate()&&o===n.getMonth()+1&&t===n.getFullYear()?O("Yesterday"):(i=i<10?"0"+i:i)+"."+(o=o<10?"0"+o:o)+"."+t},T.prototype.getNode=function(t){var e=this.view.querySelector(t);return e||(console.error(t+" node not found"),!1)},T.prototype.initMediaMatcher=function(){var e=this;this._mediaMatcher=matchMedia("(max-width: 450px)"),this._mediaMatcher.onchange=function(t){e.onMediaChange(t.matches)}},c.isMobile.get=function(){return this._mediaMatcher.matches},T.prototype.onMediaChange=function(){this.renderConversations()},T.prototype.calculateSelectorHeight=function(){var t,e,n;this.parentHeight&&(t=this.getNode(this.getSelectors().conversationsWrapper),e=this.visibleConversationsCount,n=this.isOpenedAll?1:2,this.visibleConversationsCount=Math.floor((this.parentHeight-44-42*n-16)/69),this.visibleConversationsCount=this.visibleConversationsCount<2?2:this.visibleConversationsCount,this.visibleConversationsCount>=this.conversations.length?(this.visibleConversationsCount=this.conversations.length,this.setVisibilityAllButton(!1)):this.setVisibilityAllButton(!this.isOpenedAll),this.isMobile?t.style.height="":t.style.height=69*this.visibleConversationsCount+"px",e!==this.visibleConversationsCount&&this.renderConversations())},T.prototype.openSelector=function(t){this.toggleSelector(!0),t&&(this.isBlockedCloseSelector=t,this.getNode(this.getSelectors().headerIcon).classList.add("invisible"))},T.prototype.getHeight=function(){return this.getNode(this.getSelectors().selector).offsetHeight},T.prototype.renderConversations=function(){var n=this;if(!this.conversations.length&&!this.selectedConversation)return this.view.style.display="none",void this.toggleSelector(!1);this.view.style.display="block";var t=this.getNode(this.getSelectors().conversationsWrapper),i=(t||this.render(),"");this.conversations.forEach(function(t,e){e>n.visibleConversationsCount-1&&!n.isOpenedAll||(e={id:t.id,name:t.name,selected:n.selectedConversationId===t.id},(t=t.last_message)?(e.date=n.getFormattedDate(t.created_at),e.author=t.author?t.author.name:O("You"),e.message=t.text):console.error("last message not defined"),i+=n.getConversationTemplate(e))}),t.innerHTML=i,this.setConversationsEvents(),this.calculateSelectorHeight()},c.selectedConversationId.get=function(){return this.selectedConversation?this.selectedConversation.id:null},T.prototype.render=function(){this._shouldOpenSelector=this.firstRender;var t=this.getSelectorTemplate();this.view.innerHTML=t;try{this.renderConversations()}catch(t){console.error("render conversations failure"),console.error(t)}this.conversations.length<2?(this.isSelectorOpened=!1,this.isBlockedCloseSelector=!1,this._shouldOpenSelector=!1,this.toggleSelector(!1)):this.getNode(this.getSelectors().headerIcon).classList.add("invisible"),this.toggleSelector(this._shouldOpenSelector),this.firstRender=!1,this.initDomEvents()},c.shouldOpenSelector.get=function(){return this._shouldOpenSelector},T.prototype.initDomEvents=function(){var e=this;S.add({target:this.getNode(this.getSelectors().selector),eventName:"click",handler:function(t){t.preventDefault()}}),S.add({target:this.getNode(this.getSelectors().header),eventName:"click",handler:function(t){e.isMobile?e.handleMobileHeaderClick(t):e.handleSelectorClick(t)}}),S.add({target:this.getNode(this.getSelectors().addConversation),eventName:"click",handler:function(t){e._shouldOpenSelector=!1,e.setSelectedConversation(null),e.handleAddConversationClick(t),e.onAddConversationClick(t)}}),S.add({target:this.getNode(this.getSelectors().openAll),eventName:"click",handler:function(t){e.handleOpenAllClick(t),e.onOpenAllClick(t)}})},T.prototype.setConversationsEvents=function(){var e=this;this.view.querySelectorAll(this.getSelectors().conversationItem).forEach(function(t){S.add({target:t,eventName:"click",handler:function(t){e._shouldOpenSelector=!1,e.handleItemClick(t),e.onConversationClick(t)}})})},T.prototype.setVisibilityAllButton=function(t){this.getNode(this.getSelectors().openAll).classList.toggle("invisible",!t)},T.prototype.setConversations=function(t){var e;this.selectedConversation&&(e=Wn(t,{id:this.selectedConversation.id}))&&(this.selectedConversation=e),this.conversations=t,this.renderConversations(),this.triggerOnConversationsChange()},T.prototype.setSelectedConversation=function(t){t?(this.context.sendBusMessage({method:"select_conversation",payload:t}),this.selectedConversation=Wn(this.conversations,{id:t})):this.selectedConversation=t,this.renderConversations()},T.prototype.setParentHeight=function(t){t&&(this.parentHeight=parseInt(t),this.calculateSelectorHeight())},T.prototype.busHeaderClick=function(){this.tryToToggleSelector()},T.prototype.handleSelectorClick=function(t){t.stopPropagation(),this.tryToToggleSelector()},T.prototype.tryToToggleSelector=function(){!this.view||this.firstRender||this.isBlockedCloseSelector||this.toggleSelector()},T.prototype.handleMobileHeaderClick=function(t){t.stopPropagation(),t.target.closest(this.getSelectors().closeMobile)?Gi("click_button"):this.tryToToggleSelector()},T.prototype.handleOpenAllClick=function(t){t.stopPropagation(),this.setVisibilityAllButton(!1),this.isOpenedAll=!0,this.renderConversations(),this.calculateSelectorHeight()},c.isOpenedAll.get=function(){return this._isOpenedAll||this.isMobile},c.isOpenedAll.set=function(t){return this._isOpenedAll=t},T.prototype.handleAddConversationClick=function(t){t.stopPropagation(),this.context.sendBusMessage({method:"add_conversation"}),this.toggleSelector(!1),this.isBlockedCloseSelector=!1,this.getNode(this.getSelectors().headerIcon).classList.toggle("invisible",this.isBlockedCloseSelector),this.conversations.length||this.triggerOnConversationsChange()},T.prototype.handleItemClick=function(t){t.stopPropagation();t=t.currentTarget.getAttribute("data-id");this.selectedConversationId!==t&&this.setSelectedConversation(t),this.toggleSelector(!1),this.isBlockedCloseSelector=!1,this.getNode(this.getSelectors().headerIcon).classList.toggle("invisible",this.isBlockedCloseSelector)},T.prototype.triggerOnConversationsChange=function(){function n(t){var e,n,i,o,r,s,a=t.name,c=t.is_closed;return(t=t.last_message)&&(e=t.created_at,n=t.is_out,i=t.text,s=t.media_url,o=t.type,r=t.author,o="picture"===o?"photo":o,s={media:s?{url:s,thumbnail:t[o]?t[o].thumbnail:void 0}:void 0,created_at:e,is_out:n,text:i,type:o,author:r=r?{name:r.name}:void 0}),{name:a,is_closed:c,last_message:s}}var i=this,o=!1,t=this.conversations.map(function(t){var e=t.id;return o=o||e===i.selectedConversationId,n(t)});this.selectedConversation&&!o&&t.push(Object.assign({},n(this.selectedConversation),{is_closed:!0})),I("onConversationsChange",t)},T.prototype.toggleSelector=function(t){void 0===t&&(t=!this.isSelectorOpened),this.isSelectorOpened=t;t="closed";this.isSelectorOpened&&(t=this.shouldOpenSelector?"opened-fully":"opened"),this.getNode(this.getSelectors().selector).classList.toggle("opened",this.isSelectorOpened),this.context.sendBusMessage({method:"selector_open_state",payload:t}),this.onSelectorToggle(t)},Object.defineProperties(T.prototype,c),"amo-livechat"),Ji="amo-livechat_bubble",$i="amo-livechat_chat",Qi="amo-livechat_opening",to="amo-livechat_hiding",eo="amo-livechat_hidden",no="amo-livechat-id",io=(x.prototype.show=function(){var t=this;!this.isActive&&this.isEnabled&&this.isInited&&(this.isActive=!0,this.hideBubble(),this.getUUID()||this.setUUID(),setTimeout(function(){document.documentElement.classList.add(t.activeClassName),t.iframe_wrapper.classList.remove(Qi),t.iframe.focus()},200),document.documentElement.classList.add(this.name),this.iframe_wrapper.style.bottom="",this.iframe_wrapper.classList.remove(eo),this.iframe_wrapper.classList.add(Qi),this.iframe_wrapper.classList.add($i),this.isInline&&"vertical"===this.props.orientation&&(this.iframe_wrapper.style[this.props.position.h]=this.socialServiceSizeWithMargin+25+"px",this.iframe_wrapper.style[this.props.position.v]="top"===this.props.position.v?"-19px":"-22px"),this.sendBusMessage({method:"livechat:onShow"},"socials"),this.sendBusMessage({method:"toggle",payload:{state:!0}},"livechat"),this.handleWindowResize(),I("onChatShow"))},x.prototype.hide=function(){var t=this;this.isActive&&this.isEnabled&&this.isInited&&(this.isActive=!1,document.documentElement.classList.remove(this.activeClassName),this.iframe_wrapper.classList.add(to),setTimeout(function(){document.documentElement.classList.remove(t.name),t.iframe_wrapper.classList.remove(to),t.iframe_wrapper.classList.remove($i),t.iframe_wrapper.classList.contains(Ji)||(t.iframe_wrapper.classList.add(eo),t.iframe_wrapper.style.height="")},200),this.sendBusMessage({method:"toggle",payload:{state:!1}}),I("onChatHide"))},x.prototype.awaitLivechatAnimation=function(t){function e(){return i.iframe_wrapper.classList.contains(Qi)}function n(){return i.iframe_wrapper.classList.contains(to)}var i=this;switch(!0){case e():var o=setInterval(function(){i.isActive?e()||(clearInterval(o),t()):clearInterval(o)},20);break;case n():var r=setInterval(function(){i.isActive?clearInterval(r):n()||(clearInterval(r),t())},20);break;default:t()}},x.prototype.showBubble=function(){var t=this;this.awaitLivechatAnimation(function(){t.isActive||t.props.isButtonOpened()||("widget"===t.mode&&(t.sendBusMessage({method:"bubble",payload:{state:!0}}),t.iframe_wrapper.classList.remove(eo),t.iframe_wrapper.classList.add(Ji)),t.showBadge())})},x.prototype.hideBubble=function(){this.sendBusMessage({method:"bubble",payload:{state:!1}}),this.iframe_wrapper.classList.remove(Ji),this.iframe_wrapper.classList.add(eo),this.resizeIframeWrapper(null),this.hideBadge()},x.prototype.showGreeting=function(){this.isInited?this.isActive||this.sendBusMessage({method:"greeting"}):this.isGreetingAwaited=!0},x.prototype.resizeIframeWrapper=function(t){if(null===t)return this.iframe_wrapper.style.height=null,void(this.iframe_wrapper.style.width=null);this.iframe_wrapper.style.height=parseFloat(t.height)+"px",this.iframe_wrapper.style.width=parseFloat(t.width)+"px"},x.prototype.centrifyIframeWrapper=function(t){var e,t=t.bubbleHeight,n=this.props.container,i=this.iframe_wrapper,o=this.props.position.v;(n||i||o)&&(n=(t-(t=n.offsetHeight))/2,i.style[o]=null,e=getComputedStyle(i).getPropertyValue(o),e=parseInt(e,10)-n,"top"===o?e+=9:"bottom"===o&&t<50&&(e+=2),i.style[o]=e+"px")},x.prototype.updateBadge=function(t){this.badgeCount=t,0<(this.badge.innerText=t)&&!this.isActive&&!this.props.isButtonOpened()?this.showBadge():this.hideBadge(),this.sendBusMessage({method:"badge",payload:{count:t}},"socials")},x.prototype.showBadge=function(){0