var MapPointPopupDelayFactor=32,MapPoint=function(){function n(n,t,i){var r=this;i===void 0&&(i=!1);this.popupTextLength=0;this.point=n;this.popup=t;this.active=i;this.Popup.querySelectorAll("p").forEach(function(n){r.popupTextLength+=n.innerText.length})}return Object.defineProperty(n.prototype,"Point",{get:function(){return this.point},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"Popup",{get:function(){return this.popup},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"PopupShowDelay",{get:function(){return this.popupTextLength*MapPointPopupDelayFactor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"Active",{get:function(){return this.active},set:function(n){this.active=n;n?this.Point.classList.add("Active"):this.Point.classList.remove("Active")},enumerable:!1,configurable:!0}),n}(),IndexMapController=function(){function n(){var t=this,n;this.mapPoints=[];this.slideIndex=0;n=document.querySelector('[data-control="CommentsMap"]');this.mapContainer=n.querySelector(".MapContainer");n.querySelectorAll(".Point").forEach(function(n){t.mapPoints.push(new MapPoint(n,n.querySelector(".Popup")))});window.addEventListener("resize",this.WindowResize.bind(this));this.mapPoints.forEach(function(n){n.Point.addEventListener("click",t.PointClick.bind(t,n));n.Popup.addEventListener("click",function(n){n.stopPropagation()})});n.addEventListener("click",this.MapClick.bind(this));this.AdjustPopupSizes();this.AdjustPopupPositions();this.InitPlayList(this.mapPoints[this.GetRandomNumber(0,this.mapPoints.length-1)]);this.playList[0].Active=!0;this.AutoPlay()}return Object.defineProperty(n.prototype,"PopupMaxWidth",{get:function(){return 500},enumerable:!1,configurable:!0}),n.prototype.GetRandomNumber=function(n,t){return Math.floor(Math.random()*t)+n},n.prototype.InitPlayList=function(n){var i=this,t;for(this.playList=[],this.playList.push(n);this.playList.length!=this.mapPoints.length;)t=this.mapPoints.filter(function(n){return i.playList.indexOf(n)<0}),this.playList.push(t[this.GetRandomNumber(0,t.length-1)])},n.prototype.AutoPlay=function(){var n=this.playList[this.slideIndex],t=this.GetNextPlayListPoint(n);this.timer=setTimeout(this.AutoPlayPointChange.bind(this,n,t),n.PopupShowDelay)},n.prototype.AutoPlayPointChange=function(n,t){n.Active=!1;t.Active=!0;n=t;t=this.GetNextPlayListPoint(n);this.timer=setTimeout(this.AutoPlayPointChange.bind(this,n,t),n.PopupShowDelay)},n.prototype.GetNextPlayListPoint=function(n){var t=this.playList.indexOf(n);return t++,t>this.playList.length-1&&(t=0),this.playList[t]},n.prototype.StopAutoPlay=function(){this.timer!=null&&clearTimeout(this.timer);this.slideIndex=0},n.prototype.WindowResize=function(){this.AdjustPopupSizes();this.AdjustPopupPositions()},n.prototype.PointClick=function(n,t){(this.StopAutoPlay(),t.stopPropagation(),n.Active)||(this.mapPoints.filter(function(t){return t.Active&&t!=n}).forEach(function(n){n.Active=!1}),n.Active=!0,this.InitPlayList(n))},n.prototype.MapClick=function(){this.StopAutoPlay();this.mapPoints.filter(function(n){return n.Active}).forEach(function(n){n.Active=!1});this.AutoPlay()},n.prototype.AdjustPopupSizes=function(){var n=document.documentElement.clientWidth,t=this.PopupMaxWidth;n<this.PopupMaxWidth&&(t=n-40);this.mapPoints.forEach(function(n){n.Popup.style.width=t+"px"})},n.prototype.AdjustPopupPositions=function(){var n=20,i=this.mapPoints[0].Popup.offsetWidth,f=this.mapPoints[0].Point.clientWidth,e=this.mapPoints[0].Point.clientHeight,t=this.mapContainer.clientWidth,o=this.mapContainer.clientHeight,u=this.mapContainer.$offset().left,r;u<0&&(t+=u*2);r=this.mapContainer.$offset().top;this.mapPoints.forEach(function(u){var s=u.Point.$offset().left,h,c;u.Popup.style.left=f+n+"px";u.Popup.style.bottom=-n+"px";h=!0;s+u.Popup.$offset().left<0&&(u.Popup.style.left=-s+n+"px");s+i+n>t?(c=Math.abs(t-s>0?0:t-s),u.Popup.style.left=-(i+n+c)+"px",u.Popup.$offset().left<n&&(h=!1)):u.Popup.$offset().left+i+n>t&&(h=!1);h||(u.Popup.style.left=(t-i)/2-s+"px",u.Popup.style.bottom=-(u.Popup.offsetHeight+n)+"px");u.Popup.$offset().top-r<n&&(u.Popup.style.bottom=u.Popup.$offset().top-r-n*2+"px");u.Popup.$offset().top+u.Popup.offsetHeight+n>r+o&&(u.Popup.style.bottom=e+n+"px")})},n}(),IndexNewsController=function(){function n(){var n=this;document.querySelectorAll('[data-news-pager="Pager"]').forEach(function(t){for(var f=new Array(0),u=t.previousElementSibling,i,r;u!=null;)u.classList.contains("NewsPage")&&f.unshift(u),u=u.previousElementSibling;i=t.querySelector('[data-news-pager="Prev"]');i===null||i===void 0?void 0:i.classList.add("Disabled");r=t.querySelector('[data-news-pager="Next"]');i===null||i===void 0?void 0:i.addEventListener("click",n.PrevClick.bind(n,f,i,r));r===null||r===void 0?void 0:r.addEventListener("click",n.NextClick.bind(n,f,i,r))})}return n.prototype.NextClick=function(n,t,i,r){r.preventDefault();var e=n.filter(function(n){return!n.classList.contains("Hidden")}),u=e.length===1?e[0]:null,f=u!=null&&n.indexOf(u)<n.length-1?n[n.indexOf(u)+1]:null;f!=null&&(this.SwitchPages(u,f),t.classList.remove("Disabled"),n.indexOf(f)>n.length-2&&i.classList.add("Disabled"))},n.prototype.PrevClick=function(n,t,i,r){r.preventDefault();var e=n.filter(function(n){return!n.classList.contains("Hidden")}),u=e.length===1?e[0]:null,f=u!=null&&n.indexOf(u)>0?n[n.indexOf(u)-1]:null;f!=null&&(this.SwitchPages(u,f),i.classList.remove("Disabled"),n.indexOf(f)<=0&&t.classList.add("Disabled"))},n.prototype.SwitchPages=function(n,t){var i=function(){var u,f,r,e;n.removeEventListener("transitionend",i);u=n.offsetHeight;n.classList.add("Hidden");t.classList.remove("Hidden");n.style.opacity="";t.style.maxHeight="0";t.style.overflow="hidden";f=t.scrollHeight;t.style.overflow="";t.style.maxHeight="";t.style.transition="none";t.flushStyle();t.style.opacity="0";t.style.height=u+"px";t.style.transition="";t.flushStyle();r=1;e=function(){r--;r==0&&(t.removeEventListener("transitionend",e),t.style.height="",t.style.opacity="")};t.addEventListener("transitionend",e);t.style.opacity="1";r+=u!==f?1:0;t.style.height=f+"px"};n.addEventListener("transitionend",i);n.style.opacity="0"},n}()