define(function(require){let text=require("text");let Class=require("Class");let Modal;const TrackingController=require("TrackingController");let footerInView=!1;const UiVersion={RENAISSANCE_2024:'renaissance2024',};let MainController=Class.extend({options:{heightOffset:90,seenDelay:2000,markNotificationsSeenUrl:"",dismissNotificationUrl:"",isDesigner:!1,isProduction:!1,isStaging:!1,isUpgradedFramework:!1,uiDesignVersion:null,priceMatchShown:0,csrfToken:null,csrfTokenName:null,scoopEmail:null,},model:{isNotificationsListOpen:!1,markAsSeenTimeoutHandler:null,},initialize:function(options){this.options=$.extend({},this.options,options||{});Modal=MainController.requireModal(this.options);if(this.options.correctedLanguageUrl){history.replaceState({},"",this.options.correctedLanguageUrl)}
if($.fn.tooltip){$('.badge-help,.apply-tooltip').tooltip()}
if(this.options.isProduction||this.options.isStaging){$.ajaxSetup({cache:!0})}
$('#reviewLink').on('click',function(){let projectId=$('#projectMetaContainer').data('projectid');let logClickReviewLinkUrl='/project/logClickReviewLink/'+projectId;$.post(logClickReviewLinkUrl)});$('.flash-close').on('click',function(){if($(this).parents('.flash-row-reviewbanner').length>0){let projectId=$('#projectMetaContainer').data('projectid');let logCloseReviewBannerUrl='/project/logCloseReviewBanner/'+projectId;$.post(logCloseReviewBannerUrl)}
$(this).parents('.flash-row-container').slideUp().addClass('flash-closed')});if(this.options.isUpgradedFramework){$('#footerEmail').keypress($.proxy(function(evt){if(evt.which==13){this.handleSubscribe(evt)}},this));$('.btn-footer-subscribe').on('click',$.proxy(this.handleSubscribe,this))}
$('#dec-notify').on('mouseenter',$.proxy(this.onNotificationsListOpen,this));$('#dec-notify').on('mouseleave',$.proxy(this.onNotificationsListClose,this));$(document).on('notifications-panel-open',$.proxy(this.onNotificationsPanelOpen,this));$(document).on('notifications-panel-close',$.proxy(this.onNotificationsPanelClose,this));$('.dec-notify-lnk .rem-notify').on('click',$.proxy(this.dismissNotification,this));$('.dropdown-notifications .mark-all-notes-read').on('click',$.proxy(this.dismissAllNotification,this));$('.simple-nav-contact').on('click',$.proxy(this.simpleNavContact,this));$('.show-image-rotation').on('click',$.proxy(this.showImageRotation,this));$('div#content').on('click','.prod-link-match',$.proxy(this.handleLinkOut,this));$('.decorilla-navbar-responsive .nav-collapse').on('show',function(){$(this).parents('.decorilla-navbar-responsive').addClass('showing-menu');window.scrollTo(0,0)}).on('hide',function(){$(this).parents('.decorilla-navbar-responsive').removeClass('showing-menu')});$('.js-vid-link').on('click',$.proxy(this.handleVidLaunch,this));$('.dec-share-btn').on('click',$.proxy(this.handleShareBtn,this));if(typeof Waypoint!="undefined"&&(($('#top-hero-bottom').length||$('.after-top-hero').length))){let element=document.querySelector('#top-hero-bottom');if(!element){console.log('No top-hero-bottom element found, using after-top-hero');element=document.querySelector('.after-top-hero')}
const waypoint=new Waypoint({element:element,handler:this.handleWaypointTransition,offset:'15%'})}
$('#navbar-collapse-1').on('show.dec.collapse',function(evt){$('#navbar').addClass('showing-menu');$('#chatstack-container').css('z-index',190)}).on('hide.dec.collapse',function(evt){$('#navbar').removeClass('showing-menu');$('#chatstack-container').css('z-index',1050)}).on('shown.dec.collapse hidden.dec.collapse',function(evt){if(typeof Waypoint!="undefined"){Waypoint.refreshAll()}});$(document).on('chatstackUploadImage',$.proxy(this.handleChatstackUploadImage,this));$('.edit-container-margin-guide').on('click',$.proxy(this.handleEditContainerMarginGuideClick,this));this.fixNotificationsDropdownStyle();this.trackingController=new TrackingController(options);this.initFooterObserver();const urlParams=new URLSearchParams(window.location.search);const smsSignup=urlParams.get('smssignup');if(smsSignup&&smsSignup==='true'){this.launchSmsSignupModal(!0)}
this.injectNavigationParameters()},handleWaypointTransition:function(direction){const $body=$('body');const $navbar=$('#navbar');if(direction=='down'){const $decNavbarToggle=$('.dec-navbar-toggle');if(!$decNavbarToggle.hasClass('dec-collapsed')){$decNavbarToggle.click()}
if($body.hasClass('transparent-navbar')){$navbar.hide();$body.addClass('below-top-hero');$navbar.fadeIn()}else{$body.addClass('below-top-hero')}}else{if($body.hasClass('below-top-hero')){if($body.hasClass('transparent-navbar')){$navbar.fadeOut({duration:200,complete:()=>{$body.removeClass('below-top-hero');$navbar.show()}})}else{$body.removeClass('below-top-hero')}}}},handleLinkOut:function(evt){if(this.options.priceMatchShown==0){evt.preventDefault();let $btn=$(evt.currentTarget);this.modal=new Modal({modalId:"price-match-modal",title:"We Price Match OR Do Better!",content:""+"If you see a lower price from this vendor, we'll happily match it and see if we can do better! Contact us at "+"orders@decorilla.com "+"with the link and we'll help ensure you're getting the best price."+"
Continue ",buttons:[]});this.options.priceMatchShown=1}},showImageRotation:function(evt){evt.preventDefault();let $btn=$(evt.delegateTarget);if($btn.hasClass('setup-done')){return}
$btn.addClass('setup-done');let encodedLoc=encodeURIComponent(window.location.href);let csrfToken=this.options.csrfToken;let csrfTokenName=this.options.csrfTokenName;$('img').each(function(index,elem){let src=$(this).attr('src');if(src.indexOf('/images/')>=0){let encodedSrc=encodeURIComponent(src);let imageRef='imgRotID'+index;$(this).addClass(imageRef);let urlPartial="/upload/imageRotation?imgUrl="+encodedSrc+"&"+csrfTokenName+"="+csrfToken+"&dir=";$(this).after($(""+"
"+"left 1"+"left 2"+"right 1"+"right 2"+"
"))}});$('body').on('click','.img-rot-btn',function(evt){evt.preventDefault();let $btn=$(evt.currentTarget);let $img=$($btn.data('image-class'));$img.attr('alt','');let w=$img.css('width');let h=$img.css('height');$img.css({backgroundImage:"url('https://cdn.decorilla.com/img/loading.gif')",backgroundRepeat:"no-repeat",backgroundPosition:"center",width:w,height:h});$img.attr('src','');let rotUrl=$btn.attr('href');let postRotation=$.post(rotUrl);let onSuccess=$.proxy(function(response){$img.attr('src',response);$img.css({backgroundImage:"none",width:"auto",height:"auto"})},this);let onFailure=$.proxy(function(error){alert('Whoops! Something went wrong, please try again later.')},this);postRotation.then(onSuccess,onFailure)})},simpleNavContact:function IndexPageView_simpleNavContact(evt){evt.preventDefault();window.HubSpotConversations.widget.open()},handleSubscribe:function IndexPageView_handleSubscribe(evt){evt.preventDefault();let $btn=$(evt.delegateTarget);if($btn.hasClass('btn-footer-subscribe')){$btn=$($btn).parent("div").children("input")}
const email=$('#'+$btn.data('input-id')).val();this.options.scoopEmail=email;const source=$btn.data('source');const ourStr="our";if(source.indexOf('southernliving_')===0){ourStr="Southern Living"}
const postScoopSubscribe=$.post('/site/scoop/email/',{email:email,source:source});const onSuccess=$.proxy(function(response){if(response=="OK"){this.updateSubscribeMessage("Your email was successfully added","success");this.launchSmsSignupModal();$('#ScoopEmail').val('')}else if(response=="DUPLICATE_EMAIL_NO_PHONE"){this.launchSmsSignupModal();$('#ScoopEmail').val('')}else if(response=="DUPLICATE_EMAIL"){this.updateSubscribeMessage("Your info is already on our list!","warning");$('#ScoopEmail').val('');this.options.scoopEmail=null}else if(response=="BLANK_EMAIL"){this.updateSubscribeMessage("Sorry. This email is not valid","danger");this.options.scoopEmail=null}else if(response=="INVALID_EMAIL"){this.updateSubscribeMessage("Sorry. This email is not valid","danger");this.options.scoopEmail=null}else{this.updateSubscribeMessage("Something appears to have gone wrong adding your email to the list. Please try again later.","danger")}},this);const onFailure=$.proxy(function(error){this.updateSubscribeMessage("Something appears to have gone wrong adding your email to the list. Please try again later.","danger")},this);postScoopSubscribe.then(onSuccess,onFailure)},updateSubscribeMessage:function(message,cssClass){const $subscribeNewsletter=$('.subscribe-newsletter');const $subscribeMessage=$subscribeNewsletter.find('.subscribe-message');$subscribeNewsletter.removeClass('danger warning success').addClass(cssClass);$subscribeMessage.text(message)},launchSmsSignupModal:function(auto=!1){const controller=this;const urlParams=new URLSearchParams(window.location.search);let email=null;if(auto){if(!(email=urlParams.get('email'))){email='no-email'}}else{email=this.options.scoopEmail}
controller.modal=new Modal({modalId:"sms-signup-modal",remoteUrl:`/site/smsSignupModal/auto/${auto ? 1 : 0}?email=${encodeURIComponent(email)}`,buttons:[],})},onNotificationsListOpen:function(evt){this.model.isNotificationsListOpen=!0},onNotificationsListClose:function(evt){this.model.isNotificationsListOpen=!1},onNotificationsPanelOpen:function(){this.clearMarkAsSeenTimeout();if($('.dec-notification-unseen').length>0){this.model.markAsSeenTimeoutHandler=setTimeout($.proxy(this.markAsSeen,this),this.options.seenDelay)}
const self=this;setTimeout(function(){self.updateNotificationsFade();const $ul=$('#notifications-dropdown .notifications-list-box ul');const $dropdown=$('#notifications-dropdown');$ul.off('scroll.notificationsfade').on('scroll.notificationsfade',function(){self.updateNotificationsFade()});$(window).off('resize.notificationsfade').on('resize.notificationsfade',function(){if($dropdown.hasClass('open')){self.updateNotificationsFade()}})},400)},onNotificationsPanelClose:function(){this.clearMarkAsSeenTimeout();$('#notifications-dropdown .dec-dropdown-content.dropdown-notifications').removeClass('notifications-panel-has-more-below');$('#notifications-dropdown .notifications-list-box ul').off('scroll.notificationsfade');$(window).off('resize.notificationsfade')},updateNotificationsFade:function(){const $dropdown=$('#notifications-dropdown');const $content=$dropdown.find('.dec-dropdown-content.dropdown-notifications');if(!$dropdown.hasClass('open')){return}
const ul=$dropdown.find('.notifications-list-box ul')[0];if(!ul){$content.removeClass('notifications-panel-has-more-below');return}
const hasMoreBelow=ul.scrollHeight>ul.clientHeight&&(ul.scrollTop+ul.clientHeight