<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">(function(window){
	'use strict';
	
	if (window.AGChatpanel)
		return;
	
	window.AGChatpanel = function(arParams)
	{
		this.params = arParams;
		this.settings = {};
		this.objs = {};
		
		// console.log(this.params);

		this.objs.chatpanel = document.querySelector('#ag-chatpanel-wrap');
		if(this.objs.chatpanel)
		{			
			this.settings.linkCount = this.objs.chatpanel.getAttribute('data-count');
			this.settings.pulse = this.objs.chatpanel.getAttribute('data-pulse');
			this.settings.color = this.objs.chatpanel.getAttribute('data-color');
			this.settings.shadow = this.objs.chatpanel.getAttribute('data-shadow');
			this.settings.showtype = this.objs.chatpanel.getAttribute('data-showtype');
			
			
			this.settings.leftStyle = parseInt(this.objs.chatpanel.getAttribute('data-left'));
			this.settings.bottomStyle = parseInt(this.objs.chatpanel.getAttribute('data-bottom'));
			this.settings.mleftStyle = parseInt(this.objs.chatpanel.getAttribute('data-mleft'));
			this.settings.mbottomStyle = parseInt(this.objs.chatpanel.getAttribute('data-mbottom'));
			
			this.settings.call = this.objs.chatpanel.getAttribute('data-call');
			this.settings.calltime = parseInt(this.objs.chatpanel.getAttribute('data-calltime'));
			this.settings.callrepeat = parseInt(this.objs.chatpanel.getAttribute('data-callrepeat'));
			
			this.objs.chatpanel_button = document.querySelector('.js-agchatpanel-button');
			this.objs.chatpanel_href = document.querySelector('.js-agchatpanel-href');
			this.objs.chatpanel_panel = document.querySelector('.js-agchatpanel-panel');
			
			this.objs.animation = document.querySelector('.ag_chatpanel_animation');
			
			if(this.settings.shadow == 'Y')
				this.objs.chatpanel_shadow = document.querySelector('#ag-chatpanel-shadow');
			
			
			if(this.settings.call)
			{
				var closeCookieValue = "N";
				var value = "; " + document.cookie;
				var parts = value.split("; " + "ag_cp_ch" + "=");
				if (parts.length == 2) { closeCookieValue = parts.pop().split(";").shift(); };
				
				if(closeCookieValue == 'Y'){
					this.settings.call = 0;
				}
			}
			
			if(this.settings.call)
			{
				this.objs.chatpanel_call = document.querySelector('.js-agchatpanel-call');
				this.objs.chatpanel_callclose = document.querySelector('.js-agchatpanel-callclose');
				
				if(this.settings.calltime &lt;= 0)
					this.settings.calltime = 100;
				else
					this.settings.calltime = this.settings.calltime * 1000;
			}
			
			this.init();
		}
	};
	
	window.AGChatpanel.prototype = {
		init: function()
		{
			this.initEvents();
			this.setTheme();
			this.initLinks();
			
			this.objs.chatpanel.style.display = 'block';
		},
		
		initLinks: function(){
			var self = this;

			var links = document.querySelectorAll('.ag_chatpanel_panel_item_link');
			if(links.length){
				links.forEach(function(element){
					element.onclick = function(){
						var ctype = element.parentElement.dataset.ctype;
						if(self.params.chat_list[ctype].YM){
							self.sendYmGoal(self.params.chat_list[ctype].YM);
						}

						return true;
					}
				});
			}

			var element = document.querySelector('.ag_chatpanel_panel_item_link_jc');
			if(element){
				element.onclick = function(){
					var apiResult = jivo_api.open();
					if(apiResult &amp;&amp; !!apiResult.opened){
						jivo_api.close();
					}

					return false;
				};
			}
			
			var element = document.querySelector('.ag_chatpanel_panel_item_link_bc');
			if(element){
				element.onclick = function(){
					document.querySelector('.b24-widget-button-crmform span').click();
					return false;
				};
			}
		},

		setTheme: function()
		{
			if(this.settings.color)
			{
				if(this.objs.chatpanel_button){
					this.objs.chatpanel_button.style.backgroundColor = this.settings.color;
				}
				
				if(this.objs.animation){
					this.objs.animation.style.borderColor = this.settings.color;
				}
			}
			
			if(this.settings.call)
			{
				this.objs.chatpanel_call.style.borderColor = this.settings.color;

				var self = this;

				setTimeout(function(){
					self.showCall.call(self);
				}, self.settings.calltime);
			}
			
			if(document.body.clientWidth &gt; 768){
				if(this.settings.bottomStyle &gt; 0){
					this.objs.chatpanel.style.bottom = this.settings.bottomStyle+'px';
				}
				
				if(this.settings.leftStyle &gt; 0)
				{					
					if(this.objs.chatpanel.classList.contains("desctop_position_right")){
						this.objs.chatpanel.style.right = this.settings.leftStyle+'px';
					}
					else if(this.objs.chatpanel.classList.contains("desctop_position_left")){
						this.objs.chatpanel.style.left = this.settings.leftStyle+'px';
					}
				}
				
			}else{
				if(this.settings.mbottomStyle &gt; 0){
					this.objs.chatpanel.style.bottom = this.settings.mbottomStyle+'px';
				}
				
				if(this.settings.mleftStyle &gt; 0)
				{					
					if(this.objs.chatpanel.classList.contains("mobile_position_right")){
						this.objs.chatpanel.style.right = this.settings.mleftStyle+'px';
					}
					else if(this.objs.chatpanel.classList.contains("mobile_position_left")){
						this.objs.chatpanel.style.left = this.settings.mleftStyle+'px';
					}
				}
			}
			
			
		},

		sendYmGoal: function(goal){
			if(typeof Ya == 'object' &amp;&amp; goal){
				Ya._metrika.getCounters().forEach(function(ymetr){
					ym(ymetr.id, 'reachGoal', goal);
				});
			}
		},
		
		initEvents: function()
		{
			var self = this;

			if(self.settings.showtype != 'open' &amp;&amp; self.objs.chatpanel_button){
				self.objs.chatpanel_button.addEventListener('click', function(){
					self.clickChatpanelButton.call(self);
				});
			}
			
			if(self.settings.shadow == 'Y'){
				self.objs.chatpanel_shadow.addEventListener('click', function(){
					self.clickShadow.call(self);
				});
			}
			
			if(self.settings.call){
				self.objs.chatpanel_callclose.addEventListener('click', function(){
					self.hideCall.call(self);
				});
			}
		},
		
		clickShadow: function(){
			if(this.objs.chatpanel_panel.classList.contains("showed"))
				this.hideChatpanel();
		},
		
		clickChatpanelButton: function(){
			if(this.objs.chatpanel_panel.classList.contains("showed")){
				this.hideChatpanel();
			}else{
				this.showChatpanel();

				if(this.params.actions.open.YM){
					this.sendYmGoal(this.params.actions.open.YM);
				}
			}
		},
		
		beforeShowCall: function(){
			this.objs.chatpanel_call.style.display = 'block';
			
			if(this.objs.chatpanel_button){
				var h1 = this.objs.chatpanel_button.offsetHeight;
			}else if(this.objs.chatpanel_href){
				var h1 = this.objs.chatpanel_href.offsetHeight;
			}else{
				var h1 = 0;
			}
			
			var h2 = this.objs.chatpanel_call.offsetHeight, h3 = (h1-h2) / 2;
			
			this.objs.chatpanel_call.style.top = h3 + 'px';

			if(window.innerWidth &lt; 768){
				if(this.objs.chatpanel.classList.contains('mobile_position_right') || this.objs.chatpanel.classList.contains('mobile_position_left')){
					var callMaxWidth = window.innerWidth;

					if(parseInt(this.objs.chatpanel.style.left)){
						callMaxWidth = callMaxWidth - parseInt(this.objs.chatpanel.style.left);
					}else if(parseInt(this.objs.chatpanel.style.right)){
						callMaxWidth = callMaxWidth - parseInt(this.objs.chatpanel.style.right);
					}

					callMaxWidth = callMaxWidth - 68 - 12;

					this.objs.chatpanel_call.style.width = callMaxWidth + 'px';
				}
			}
		},
		
		showCall: function(){
			if(this.settings.call)
			{
				this.beforeShowCall();
				this.objs.chatpanel_call.classList.add('ag_chatpanel_fadein');
			}
		},
		
		hideCall: function(){
			if(this.settings.call)
			{
				if(this.settings.callrepeat)
				{
					var expires = new Date((new Date).getTime() + (1000 * 60 * this.settings.callrepeat));
					document.cookie = "ag_cp_ch = Y; expires=" + expires.toUTCString() + "; path=" + escape ("/");
				}
				
				this.objs.chatpanel_call.classList.remove('ag_chatpanel_fadein');
				this.objs.chatpanel_call.style.display = 'none';
				this.objs.chatpanel_call.style.opacity = '0';
			}
		},
		
		hideChatpanel: function(){
			if(this.settings.pulse &amp;&amp; this.objs.animation){
				this.objs.animation.classList.remove("stoppulseanim");
			}
			
			if(this.settings.shadow == 'Y')
			{
				var self = this;

				this.objs.chatpanel_shadow.classList.remove('ag_chatpanel_fadein');
				this.objs.chatpanel_shadow.classList.add('ag_chatpanel_fadeout');

				setTimeout(function(){
					self.objs.chatpanel_shadow.style.display = 'none';
				}, self.params.settings.duration);
			}
			
			this.objs.chatpanel_panel.classList.remove("showed");

			if(this.objs.chatpanel_button){
				this.objs.chatpanel_button.classList.remove("panel_showed");
			}
			
			this.objs.chatpanel_panel.style.height = '0px';
		},
		
		showChatpanel: function(){
			this.hideCall();
			this.settings.call = 0;
			
			if(this.settings.pulse &amp;&amp; this.objs.animation){
				this.objs.animation.classList.add("stoppulseanim");
			}
			
			if(this.settings.shadow == 'Y')
			{
				this.objs.chatpanel_shadow.style.display = 'block';
				this.objs.chatpanel_shadow.classList.remove('ag_chatpanel_fadeout');
				this.objs.chatpanel_shadow.classList.add('ag_chatpanel_fadein');
			}
			
			this.objs.chatpanel_panel.classList.add("showed");
			
			if(this.objs.chatpanel_button){
				this.objs.chatpanel_button.classList.add("panel_showed");
			}
			
			this.objs.chatpanel_panel.style.height = (this.settings.linkCount*51+42)+'px';
		},
	};
})(window);</pre></body></html>