class NectarColorChangeSections{constructor(){NectarColorChangeSections.instance&&NectarColorChangeSections.instance.destroy(),this.sections=document.querySelectorAll("div[data-color-change-section-bg-color]"),this.currentSection=null,this.observer=null,this.boundHandleIntersection=this.handleIntersection.bind(this),0!==this.sections.length&&(this.init(),this.events(),NectarColorChangeSections.instance=this)}init(){document.documentElement.style.setProperty("--page-color-change-section-transition-time","0s");this.observer=new IntersectionObserver(this.boundHandleIntersection,{root:null,rootMargin:"0px",threshold:.5}),this.sections.forEach(e=>{this.observer.observe(e)}),setTimeout(()=>{this.sections.forEach(e=>{const t=e.querySelector(".row-bg.using-bg-color");t&&t.remove()})},60)}handleIntersection(e){e.forEach(e=>{if(e.isIntersecting&&e.intersectionRatio>=.5&&e.target!==this.currentSection){const t=e.target.getAttribute("data-color-change-section-bg-color"),o=e.target.getAttribute("data-color-change-section-text-color");document.documentElement.style.setProperty("--nectar-page-background-color",t),document.documentElement.style.setProperty("--nectar-page-text-color",o),document.documentElement.style.setProperty("--nectar-page-light-text-color",o),this.currentSection=e.target,setTimeout(()=>{document.documentElement.style.setProperty("--page-color-change-section-transition-time","0.6s")},60)}})}events(){jQuery(window).off("vc_reload.nectarColorChange"),jQuery(window).on("vc_reload.nectarColorChange",()=>{this.init()})}destroy(){this.observer&&(this.observer.disconnect(),this.observer=null),$(window).off("vc_reload.nectarColorChange"),NectarColorChangeSections.instance===this&&(NectarColorChangeSections.instance=null)}}NectarColorChangeSections.instance=null,new NectarColorChangeSections;