define(function(require){const Class=require("Class");const MainController=require("main");let Modal;let controller;return Class.extend({options:{styleQuizEmbedLink:'',showPopup:!1,showFilter:!1,endDate:null,},initialize:function(options){this.options=$.extend({},this.defaults,options||{});Modal=MainController.requireModal(this.options);let controller=this;this.showSalesPopup=!1;this.$salesPopup=$('#sales-popup');$("body").on("touchmove",$.proxy(this.handleScrollForMobile,this));$("body").on("mouseleave",$.proxy(this.handleExitIntentForDesktop,this));this.$salesPopup.on('shown.bs.modal',function(){$("#chatstack-launcher-frame").hide()});this.$salesPopup.on('hidden.bs.modal',function(){$("#chatstack-launcher-frame").show()});this.$salesPopup.on('click','.close',function(){fetch('/site/setExitIntentSession/type/defaultSalesOrWaitPopup').then(response=>response.json()).then(data=>console.log(data)) controller.$salesPopup.modal('hide')});this.initializeTimer()},handleScrollForMobile:function(evt){let available;let percentage_of_page;let half_screen;let height;if($(".modal").is(":visible")){return} available=$(document).height();percentage_of_page=0.5;half_screen=available*percentage_of_page;height=$(window).scrollTop();if(height>half_screen){if(!this.options.showPopup){this.handleShowSalesPopup()} this.options.showPopup=!0}},handleExitIntentForDesktop:function(evt){if($(".modal").is(":visible")){return} if(evt.clientY<=0){if(!this.options.showPopup){this.handleShowSalesPopup()}}},handleShowSalesPopup:function(evt){this.options.showPopup=!0;this.$salesPopup.removeAttr("hidden");this.$salesPopup.attr("aria-hidden","false");this.$salesPopup.modal('show')},initializeTimer:function(){if(!this.options.showTimer)return;const self=this;this.currentEndDate=new Date(this.options.endDate);this.$popup=$('#sales-popup');this.$popup.find('.modal-content').addClass('with-timer');this.updateTimer();this.timerInterval=setInterval(function(){self.updateTimer()},1000)},padZero:function(num){return num.toString().padStart(2,'0')},updateTimer:function(){const now=new Date().getTime();const timeLeft=this.currentEndDate.getTime()-now;if(timeLeft<=0){this.onTimerExpired();return} const hours=Math.floor(timeLeft/(1000*60*60));const minutes=Math.floor((timeLeft%(1000*60*60))/(1000*60));const seconds=Math.floor((timeLeft%(1000*60))/1000);this.$popup.find('.timer-value.hours').text(this.padZero(hours));this.$popup.find('.timer-value.minutes').text(this.padZero(minutes));this.$popup.find('.timer-value.seconds').text(this.padZero(seconds))},onTimerExpired:function(){if(this.timerInterval){clearInterval(this.timerInterval);this.timerInterval=null} this.$popup.find('.countdown-timer').html('