define(function(require){const Class=require("Class");const MainController=require("main");const HelloBarController=Class.extend({defaults:{proxiedHandler:null,},initialize:function EditPageController_initialize(options){this.options=$.extend({},this.defaults,options||{});this.showHelloBar=!1;this.scrollTimer=!1;this.$helloBarElement=$('#hellobar-bar');this.options.proxiedHandler=$.proxy(this.handleWindowScroll,this);$(window).on('scroll',this.options.proxiedHandler);this.$helloBarElement.find('.hb-icon-close').on('click',$.proxy(this.handleCloseButtonClicked,this));this.$helloBarElement.find('a').on('click',$.proxy(this.handleLinkClicked,this))},handleWindowScroll:function(evt){if(this.showHelloBar){return} if($(window).scrollTop()>$('body').height()/4){this.showHelloBar=!0;this.$helloBarElement.fadeIn();$(window).off('scroll',this.options.proxiedHandler);this.changeChatstackWidgetPosition(!0);if(this.scrollTimer){clearTimeout(this.scrollTimer);this.scrollTimer=null}}else if(!this.scrollTimer){this.scrollTimer=setTimeout(()=>{if(!this.showHelloBar){this.showHelloBar=!0;this.$helloBarElement.fadeIn();$(window).off('scroll',this.options.proxiedHandler);this.changeChatstackWidgetPosition(!0)}},5000)}},handleCloseButtonClicked:function(evt){evt.preventDefault();this.fadeOutEffect(this.$helloBarElement[0]);fetch('/site/setExitIntentSession/type/hellobar').then(response=>response.json())},handleLinkClicked:function(evt){this.fadeOutEffect(this.$helloBarElement[0])},fadeOutEffect:function(element){this.showHelloBar=!1;const fadeEffect=setInterval(()=>{if(!element.style.opacity){element.style.opacity=1} if(element.style.opacity<0.1){clearInterval(fadeEffect);element.style.display='none';const footerInView=MainController.prototype.isFooterInView();if(window.innerWidth>768||(window.innerWidth<=768&&!footerInView)){this.changeChatstackWidgetPosition(!1)}}else{element.style.opacity-=0.1}},40)},changeChatstackWidgetPosition:function(hellobarVisible){if(hellobarVisible){$("#chatstack-launcher-frame").addClass('with-hellobar')}else{$("#chatstack-launcher-frame").removeClass('with-hellobar')}},});return HelloBarController})