1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[7667],{768:(t,e,r)=>{r.r(e),r.d(e,{CollectionViewMore:()=>s});const i=Object.freeze({sectionSelector:".shopify-section",gridSelector:".grid--product",gridItemSelector:".grid-item__wrapper",labelSelector:"label",shownSelector:"[data-shown]",totalSelector:"[data-total]",progressSelector:"progress",buttonSelector:"button",errorNotificationSelector:".notification",errorNotificationTextSelector:".notification__text",loadingAnimationClass:"motion-safe:animate-pulse",hiddenClass:"hidden",gridTransition:"max-height 0.5s ease-in-out",sectionIdPrefix:"shopify-section-"});class s extends HTMLElement{constructor(){super(),this.loading=!1,this.domParser=new DOMParser,this.refs=this.getRefs(),this.sectionId=this.getSectionId(),this.dataNextUrl=this.refs.gridEl.dataset.nextUrl}static get observedAttributes(){return["shown"]}get limit(){return this.getAttributeInt("limit")}get total(){return this.getAttributeInt("total")}get shown(){return this.getAttributeInt("shown")}set shown(t){t>this.total&&(t=this.total),this.setAttribute("shown",String(t))}connectedCallback(){this.setGridStyles(),this.refs.buttonEl.addEventListener("click",this.handleButtonClick.bind(this))}disconnectedCallback(){this.refs.buttonEl.remove()}attributeChangedCallback(t,e,r){"shown"===t&&this.renderProgress()}getAttributeInt(t){const e=this.getAttribute(t);if(!e)throw new ReferenceError(`Missing ${t} attribute`);const r=parseInt(e,10);if(isNaN(r))throw new TypeError(`Invalid ${t} attribute`);return r}setGridStyles(){this.refs.gridEl.style.transition=i.gridTransition,this.refs.gridEl.style.maxHeight=`${this.refs.gridEl.scrollHeight}px`,this.refs.gridEl.style.overflow="hidden"}async handleButtonClick(t){if(t.preventDefault(),!this.loading){this.setLoading(!0),this.hideErrorNotification();try{await this.loadMore()}catch(t){this.handleError(t)}finally{this.setLoading(!1)}}}async loadMore(){const t=this.getNextUrl();if(!t)return;const e=await fetch(t).then((t=>{if(!t.ok)throw new RangeError(`Invalid response status, expected 200-299, got ${t.status}`);return t.text()})),r=this.processResult(e),s=r.querySelectorAll(i.gridItemSelector);s.length<1||(this.dataNextUrl=r.dataset.nextUrl,this.shown+=s.length,this.renderUpdates(r.innerHTML))}getNextUrl(){if(!this.dataNextUrl)return null;const t=new URL(this.dataNextUrl,window.location.origin);return t.searchParams.set("section_id",this.sectionId),t}processResult(t){const e=this.domParser.parseFromString(t,"text/html");return this.getRequiredElement(i.gridSelector,e)}renderUpdates(t){this.refs.gridEl.insertAdjacentHTML("beforeend",t),this.refs.gridEl.style.maxHeight=`${this.refs.gridEl.scrollHeight}px`}renderProgress(){this.refs.shownEl.textContent=String(this.shown),this.refs.progressEl.value=this.shown,this.refs.progressEl.setAttribute("aria-valuenow",String(this.shown)),this.refs.progressEl.innerText=`${this.shown}/${this.total}`,this.shown>=this.total&&this.refs.buttonEl.remove()}setLoading(t){this.loading=t,this.refs.buttonEl.disabled=t,this.refs.buttonEl.classList.toggle(i.loadingAnimationClass,t)}handleError(t){const e=t instanceof Error?t:new Error("Unknown error");this.showErrorNotification(e.message)}showErrorNotification(t){this.refs.errorNotificationEl.classList.remove(i.hiddenClass),this.refs.errorNotificationTextEl.textContent=t}hideErrorNotification(){this.refs.errorNotificationEl.classList.add(i.hiddenClass)}getRefs(){if(this.refs)return this.refs;const t=this.closest(i.sectionSelector);if(!t)throw new ReferenceError("Missing required closest section element");const e=this.getRequiredElement(i.labelSelector);return{sectionEl:t,labelEl:e,gridEl:this.getRequiredElement(i.gridSelector,t),shownEl:this.getRequiredElement(i.shownSelector,e),totalEl:this.getRequiredElement(i.totalSelector,e),progressEl:this.getRequiredElement(i.progressSelector),buttonEl:this.getRequiredElement(i.buttonSelector),errorNotificationEl:this.getRequiredElement(i.errorNotificationSelector),errorNotificationTextEl:this.getRequiredElement(i.errorNotificationTextSelector)}}getRequiredElement(t,e=this){const r=e.querySelector(t);if(!r)throw new ReferenceError(`Missing required element: ${t}`);return r}getSectionId(){if(this.sectionId)return this.sectionId;const t=this.refs.sectionEl.getAttribute("id");if(!t)throw new ReferenceError("Missing section id");return t.replace(i.sectionIdPrefix,"")}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.