class LazyloadSection extends HTMLElement{constructor(){super(),this.dataset.renderOnLoad?this.renderSection():this.addEvents()}addEvents(){const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting&&(this.renderSection(),observer.disconnect())})},{rootMargin:"1000px"});observer.observe(this)}renderSection(){var sectionSelector="[id^=shopify-section]";const sectionId=this.closest(sectionSelector)?.id?.split("shopify-section-")[1]||null;sectionId&&fetch(`${window.location.pathname}?section_id=${sectionId}`).then(res=>res.text()).then(html=>{const parser=new DOMParser,doc=parser.parseFromString(html,"text/html");if(this.dataset.selectors)JSON.parse(this.dataset.selectors).forEach(selector=>{const sections=doc.querySelectorAll(selector),sectionsToUpdate=this.querySelectorAll(selector);sections.forEach((section,index)=>{const sectionHtml=section.innerHTML;$(sectionsToUpdate[index]).html(sectionHtml)})});else{const section=this.dataset.selector?doc.querySelector(this.dataset.selector):doc.querySelector(sectionSelector),sectionHtml=this.dataset.selector?section.outerHTML:section.innerHTML;$(this).html(sectionHtml)}this.dataset.callback&&eval(this.dataset.callback)})}}customElements.define("lazyload-section",LazyloadSection);
//# sourceMappingURL=/cdn/shop/t/14/assets/lazyload-section.js.map?v=5359969406261385591742784888
