https://johnbellcroyden.co.uk/cdn/shop/t/490/assets/algolia-collec…?v=146210750968917302681789724911
1import{AlgoliaClient,publishAlgoliaEvent}from"./algolia-client.js";import{shopifyParamsToAlgolia,baseCollectionFilters,combineFilters,indexForSort,facetForParamName,algoliaFacetParamName,humanizeFacetLabel,EXCLUDED_EXTRA_FACET_ATTRIBUTES}from"./algolia-filter-mapping.js";import{renderProductTile,bindQuickAddDelegate}from"./algolia-product-tile.js";import{E as EVENTS}from"./events-58bc9098.js";function escapeHtml(value){return String(value??"").replace(/[&<>"']/g,c=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[c])}function imageUrlWithWidth(url,width){if(!url)return url;try{const u=new URL(url);return u.searchParams.set("width",String(width)),u.toString()}catch{return url}}function appliedFacetFilters(searchParams){const params=new URLSearchParams(searchParams),filters=[];for(const[key,value]of params.entries()){if(key==="sort_by"||key==="q"||key==="filter.v.price.gte"||key==="filter.v.price.lte")continue;const facet=facetForParamName(key);if(facet){if(facet.type==="availability"){value==="1"&&filters.push("inventory_available:true");continue}filters.push(`${facet.attribute}:${value}`)}}return filters}const{FILTER_REPAINT,FILTER_SORT_CHANGED,SORT_CHANGED,HEADER_HEIGHT_UPDATED,ANNOUNCEMENT_HEIGHT_UPDATED}=EVENTS;function getMediaQuery(querySize){return getComputedStyle(document.documentElement).getPropertyValue(`--js-${querySize}`)||!1}class AlgoliaCollectionProductGrid extends HTMLElement{constructor(){super(),this.selectors={activeFilters:"[js-active-filters]",header:"header-wrapper",announcementBar:"announcement-bar",filterDrawerTrigger:"[js-filter-drawer-trigger]",stickyFilterDrawerTrigger:"[js-filter-drawer-trigger--sticky]",filterDrawerHeading:"[js-filter-drawer-heading]",filterDrawerViewResults:"[js-filter-view-results]",filterDrawerViewResultsIdleLabel:"[js-filter-view-results-label]",filterGroup:"[js-filter-group]",filterGroupParent:"[js-filter-group-parent]",filterSortFormComponent:"[js-filter-sort-form-component]",footer:"footer",pagination:"[js-pagination]",productGrid:"[js-product-grid], [js-result-grid]",sortDrawerTrigger:"[js-sort-drawer-trigger]",sortDropdowns:"[js-sort-top-bar], [js-sort-sticky-button], [js-sort-mobile-drawer]",sortTriggerValue:"[js-sort-trigger-value]",stickyFilterSort:"[js-sticky-filter-sort-button]",topBar:"[js-product-grid-top-bar], [js-result-grid-top-bar]",disclosureWrapper:".disclosure-wrapper",extraFilters:"[js-algolia-extra-filters]",collectionResults:"[js-algolia-collection-results]",articleResults:"[js-algolia-article-results]"},this.maxFacetValues=20,this.classes={active:"active",hidden:"hidden",loading:"loading",visible:"visible"},this.ids={filterDrawer:"filterDrawer",mobileSortDrawer:"mobileSortDrawer"},this.breakpoints={smallDesktop:getMediaQuery("small-desktop")},this.events={openFilterDrawer:new CustomEvent(EVENTS.MODAL_POPUP_OPEN(this.ids.filterDrawer)),closeFilterDrawer:new CustomEvent(EVENTS.MODAL_POPUP_CLOSE(this.ids.filterDrawer)),openSortDrawer:new CustomEvent(EVENTS.MODAL_POPUP_OPEN(this.ids.mobileSortDrawer)),closeSortDrawer:new CustomEvent(EVENTS.MODAL_POPUP_CLOSE(this.ids.mobileSortDrawer))}}connectedCallback(){this.controller=new AbortController;const eventOptions={signal:this.controller.signal};this.eventOptions=eventOptions,this.config=JSON.parse(this.querySelector("[js-algolia-grid-config]").textContent),this.client=new AlgoliaClient({appId:this.config.appId,searchKey:this.config.searchKey}),this.sectionId=this.dataset.sectionId,this.header=document.querySelector(this.selectors.header),this.announcementBar=document.querySelector(this.selectors.announcementBar),this.headerHeight=0,this.announcementHeight=0,this.getHeaderAnnouncementHeight(),document.addEventListener(HEADER_HEIGHT_UPDATED,this.handleHeaderHeightChange.bind(this),eventOptions),document.addEventListener(ANNOUNCEMENT_HEIGHT_UPDATED,this.handleAnnouncementHeightChange.bind(this),eventOptions),this.filterDrawerTriggers=this.querySelectorAll(`${this.selectors.filterDrawerTrigger}, ${this.selectors.stickyFilterDrawerTrigger}`),this.filterDrawerHeading=this.querySelector(this.selectors.filterDrawerHeading),this.filterDrawerViewResults=this.querySelector(this.selectors.filterDrawerViewResults),this.filterDrawerViewResultsIdleLabels=this.querySelectorAll(this.selectors.filterDrawerViewResultsIdleLabel),this.activeFilters=this.querySelector(this.selectors.activeFilters),this.filterGroups=this.querySelectorAll(this.selectors.filterGroup),this.extraFiltersContainer=this.querySelector(this.selectors.extraFilters),this.collectionResultsContainer=this.querySelector(this.selectors.collectionResults),this.articleResultsContainer=this.querySelector(this.selectors.articleResults),this.activeFilters?.addEventListener("click",this.handleActiveFilterRemove.bind(this),eventOptions),this.topBar=this.querySelector(this.selectors.topBar),this.sortTriggerValue=this.querySelector(this.selectors.sortTriggerValue),this.sortDropdowns=this.querySelectorAll(this.selectors.sortDropdowns),this.productGrid=this.querySelector(this.selectors.productGrid),this.filterS
1ortFormComponent=this.querySelector(this.selectors.filterSortFormComponent),this.pagination=this.querySelector(this.selectors.pagination),this.initFilterDrawerTriggers(),this.filterDrawerViewResults?.addEventListener("click",this.handleViewResultsClick.bind(this),eventOptions),this.addEventListener(FILTER_SORT_CHANGED,this.handleFilterSortFormChange.bind(this),eventOptions),this.initSortDropdowns(),(this.dataset.filterEnabled==="true"||this.dataset.sortEnabled==="true")&&this.initStickyFilterSortButton(),this.sortDrawerTrigger?.addEventListener("click",this.openSortDrawer.bind(this),eventOptions),window.addEventListener(EVENTS.MODAL_POPUP_CLOSED(this.ids.mobileSortDrawer),this.showStickyFilterSort.bind(this),eventOptions),this.pagination?.addEventListener("click",this.handlePaginationClick.bind(this),eventOptions),bindQuickAddDelegate(this.productGrid),this.currentPage=1,this.currentSearchParams=new URLSearchParams(window.location.search).toString(),this.runQuery({searchParams:this.currentSearchParams,page:1,isInitialLoad:!0})}initFilterDrawerTriggers(){this.filterDrawerTriggers.forEach(trigger=>{trigger.addEventListener("click",this.handleFilterDrawerOpen.bind(this),this.eventOptions)}),window.addEventListener(EVENTS.MODAL_POPUP_CLOSED(this.ids.filterDrawer),this.handleFilterDrawerClose.bind(this),this.eventOptions)}initStickyFilterSortButton(){this.siteFooter=document.querySelector(this.selectors.footer),this.stickyFilterSort=this.querySelector(this.selectors.stickyFilterSort),this.sortDrawerTrigger=this.querySelector(this.selectors.sortDrawerTrigger)?.parentNode,this.mobileFooterObserver=new IntersectionObserver(([entry])=>{entry.isIntersecting?(this.mobileTopBarObserver?.disconnect(),this.hideStickyFilterSort()):(this.topBar&&this.mobileTopBarObserver?.observe(this.topBar),this.showStickyFilterSort())},{threshold:.05}),this.topBar&&(this.mobileTopBarObserver=new IntersectionObserver(([entry])=>{entry.isIntersecting||entry.boundingClientRect.top<=0?this.showStickyFilterSort():this.hideStickyFilterSort()})),this.dataset.stickyFilterSortEnabled==="true"&&this.topBar&&(this.footerObserver=new IntersectionObserver(([entry])=>{entry.isIntersecting?(this.topBarObserver?.disconnect(),this.hideStickyFilterSort()):this.topBarObserver?.observe(this.topBar)},{threshold:.1}),this.topBarObserver=new IntersectionObserver(([entry])=>{entry.isIntersecting?(this.topBar.classList.add(this.classes.visible),this.hideStickyFilterSort()):(this.topBar.classList.remove(this.classes.visible),entry.boundingClientRect.top<=this.headerHeight+this.announcementHeight?this.showStickyFilterSort():this.hideStickyFilterSort())},{rootMargin:`-${this.headerHeight+this.announcementHeight}px 0px 0px 0px`})),this.smallDesktopMediaQuery=this.breakpoints.smallDesktop?window.matchMedia(this.breakpoints.smallDesktop):null,this.smallDesktopMediaQuery?.addEventListener("change",this.handleWindowResize.bind(this),this.eventOptions),this.handleWindowResize()}handleWindowResize(){this.smallDesktopMediaQuery?.matches?(this.hideStickyFilterSort(),this.mobileFooterObserver.disconnect(),this.mobileTopBarObserver?.disconnect(),this.siteFooter&&this.footerObserver?.observe(this.siteFooter)):(this.hideStickyFilterSort(),this.footerObserver?.disconnect(),this.topBarObserver?.disconnect(),this.siteFooter&&this.mobileFooterObserver.observe(this.siteFooter))}handleFilterDrawerOpen(event){this.hideStickyFilterSort(),event.target.closest(this.selectors.stickyFilterDrawerTrigger)?setTimeout(()=>window.dispatchEvent(this.events.openFilterDrawer),240):window.dispatchEvent(this.events.openFilterDrawer)}handleFilterDrawerClose(){this.smallDesktopMediaQuery?.matches?!this.topBar?.classList.contains(this.classes.visible)&&this.dataset.stickyFilterSortEnabled==="true"&&this.showStickyFilterSort():this.showStickyFilterSort()}handleViewResultsClick(){window.dispatchEvent(this.events.closeFilterDrawer)}handlePaginationClick(event){const link=event.target.closest("a");if(!link)return;event.preventDefault();const url=new URL(link.href,window.location.origin),page=Number(url.searchParams.get("page"))||1;url.searchParams.delete("page"),this.runQuery({searchParams:url.searchParams.toString(),page})}handleFilterSortFormChange(event){const topBarScrollTop=this.topBar.getBoundingClientRect().top+window.scrollY-this.headerHeight-this.announcementHeight;window.scrollTo({top:topBarScrollTop,behavior:"smooth"}),this.updateURLHash(event.detail.searchParams),this.runQuery({searchParams:event.detail.searchParams,page:1,sortBy:event.detail.sortBy})}async runQuery({searchParams,page,sortBy,isInitialLoad}){this.classList.add(this.classes.loading),this.currentSearchParams=searchParams,this.currentPage=page;const{filters:userFilters,sortBy:parsedSortBy,query}=shopifyParamsToAlgolia(searchParams),effectiveSortBy=sortBy??parsedSortBy,indexName=indexF
1orSort(this.config.indexName,effectiveSortBy),filters=combineFilters(baseCollectionFilters(this.config.collectionHandle),userFilters),requests=[{indexName,params:{query:query||"",filters,distinct:!0,facets:["*"],hitsPerPage:this.config.productsPerPage,page:page-1}}],fetchSecondaryResults=isInitialLoad&&query&&(this.config.collectionsIndexName||this.config.articlesIndexName),collectionsRequestIndex=fetchSecondaryResults&&this.config.collectionsIndexName?requests.push({indexName:this.config.collectionsIndexName,params:{query,hitsPerPage:this.config.maxCollectionResults||4,page:0}})-1:null,articlesRequestIndex=fetchSecondaryResults&&this.config.articlesIndexName?requests.push({indexName:this.config.articlesIndexName,params:{query,hitsPerPage:this.config.maxArticleResults||4,page:0}})-1:null;try{const results=await this.client.multiQuery(requests),mainResult=results[0];this.currentQueryID=mainResult.queryID,this.currentIndexName=indexName,this.renderProductGrid(mainResult.hits,page),collectionsRequestIndex!==null&&this.renderCollectionResults(results[collectionsRequestIndex].hits),articlesRequestIndex!==null&&this.renderArticleResults(results[articlesRequestIndex].hits),isInitialLoad&&(this.dataset.algoliaReady="true"),this.dataset.filterEnabled==="true"&&(isInitialLoad&&(this.renderExtraFacets(mainResult.facets||{}),this.filterGroups=this.querySelectorAll(this.selectors.filterGroup)),this.patchFacetCounts(mainResult.facets||{}),this.renderActiveFilters(searchParams),this.updateFilterViewResultsLabel(mainResult.nbHits)),this.renderPagination(mainResult.page,mainResult.nbPages),isInitialLoad||this.updateSortDropdowns(effectiveSortBy),publishAlgoliaEvent("algolia_result_viewed",{index:indexName,queryID:mainResult.queryID,objectIDs:mainResult.hits.map(h=>h.objectID),positions:mainResult.hits.map((_,i)=>i+1)});const facetFilters=appliedFacetFilters(searchParams);if(facetFilters.length&&publishAlgoliaEvent("algolia_result_filters_viewed",{index:this.config.indexName,filters:facetFilters}),!isInitialLoad){const previous=this.appliedFilters||[],added=facetFilters.filter(f=>previous.indexOf(f)===-1);added.length&&publishAlgoliaEvent("algolia_result_filters_clicked",{index:this.config.indexName,filters:added})}this.appliedFilters=facetFilters,this.filterSortFormComponent?.dispatchEvent(new CustomEvent(FILTER_REPAINT,{detail:{}}))}catch(e){console.error("[algolia-collection-grid] query failed",e),isInitialLoad&&(this.dataset.algoliaReady="true")}finally{this.classList.remove(this.classes.loading)}}renderProductGrid(hits,page){const searchContext=this.currentQueryID?{queryID:this.currentQueryID,indexName:this.currentIndexName}:void 0,tiles=hits.map((hit,i)=>renderProductTile(hit,this.config,i,searchContext));page===1&&this.config.promoTiles?.length&&this.config.promoTiles.slice().sort((a,b)=>a.position-b.position).forEach(tile=>{const index=tile.position-1;index>=0&&index<=tiles.length&&tiles.splice(index,0,tile.html)}),this.productGrid.innerHTML=tiles.join(""),this.productGrid.classList.toggle(this.config.resultsEmptyClass||"collection-product-grid__products--empty",hits.length===0)}renderSecondaryResults(container,hits,{type,buildFallbackUrl}){if(!container)return;const list=container.querySelector("[js-algolia-result-list]");
1if(!hits.length){container.hidden=!0,list&&(list.innerHTML="");return}container.hidden=!1,list.innerHTML=hits.map(hit=>{const image=hit.image||hit.image_url,imageHtml=image?`<img src="${escapeHtml(imageUrlWithWidth(image,300))}" alt="" loading="lazy" class="algolia-search-secondary-result__image">`:"",titleHtml=`<span class="algolia-search-secondary-result__title fs-body-100">${escapeHtml(hit.title)}</span>`,url=hit.url||buildFallbackUrl(hit);return url?`<a href="${escapeHtml(url)}" class="algolia-search-secondary-result">${imageHtml}${titleHtml}</a>`:(console.warn(`[algolia-collection-grid] ${type} hit "${hit.title}" (objectID ${hit.objectID}) has no usable url/handle field - check the record shape in Algolia and adjust renderSecondaryResults.`),`<span class="algolia-search-secondary-result algolia-search-secondary-result--no-link">${imageHtml}${titleHtml}</span>`)}).join("")}renderCollectionResults(hits){this.renderSecondaryResults(this.collectionResultsContainer,hits,{type:"collection",buildFallbackUrl:hit=>hit.handle?`${this.config.rootUrl.replace(/\/$/,"")}/collections/${hit.handle}`:null})}renderArticleResults(hits){this.renderSecondaryResults(this.articleResultsContainer,hits,{type:"article",buildFallbackUrl:hit=>hit.handle&&hit.blog_handle?`${this.config.rootUrl.replace(/\/$/,"")}/blogs/${hit.blog_handle}/${hit.handle}`:null})}patchFacetCounts(facets){this.filterGroups.forEach(group=>{const inputs=group.querySelectorAll("input[name]");if(!inputs.length)return;const facet=facetForParamName(inputs[0].name);!facet||facet.type!=="facet"||!facets[facet.attribute]||inputs.forEach(input=>{const count=facets[facet.attribute][input.value]||0,li=input.closest(".filter-item"),countEl=li?.querySelector(".label-count");countEl&&(countEl.textContent=`(${count})`);const disable=count===0&&!input.checked;input.disabled=disable,li?.classList.toggle("filter-item--disabled",disable)})})}renderExtraFacets(facets){if(!this.extraFiltersContainer)return;const covered=new Set;this.filterGroups.forEach(group=>{const input=group.querySelector("input[name]"),facet=input&&facetForParamName(input.name);facet?.type==="facet"&&covered.add(facet.attribute)}),(this.config.facetOrder||[]).forEach(({attribute})=>{!EXCLUDED_EXTRA_FACET_ATTRIBUTES.has(attribute)&&!facets[attribute]&&console.warn(`[algolia-collection-grid] Facet block attribute "${attribute}" has no data in Algolia's response (check for typos). Available: ${Object.keys(facets).join(", ")}`)});const html=(this.config.facetOrder||[]).filter(({attribute})=>facets[attribute]&&!EXCLUDED_EXTRA_FACET_ATTRIBUTES.has(attribute)&&!covered.has(attribute)).map(({attribute,label})=>{const values=Object.entries(facets[attribute]).sort((a,b)=>b[1]-a[1]).slice(0,this.maxFacetValues);if(!values.length)return"";const paramName=algoliaFacetParamName(attribute),items=values.map(([value,count])=>{const id=`algolia-filter--${attribute}-${value}`.replace(/[^a-zA-Z0-9_-]/g,"-");return` 2 <li class="filter-item filter-item--type-checkbox"> 3 <div class="custom-input-wrapper"> 4 <div class="custom-input custom-input--checkbox"> 5 <div class="checkbox-wrapper"> 6 <input type="checkbox" id="${id}" name="${paramName}" value="${value.replace(/"/g,""")}"> 7 <div class="checkbox-checkmark"></div> 8 </div> 9 <label for="${id}"><span><span class="label-text">${value}</span> <span class="label-count">(${count})</span></span></label> 10 </div> 11 </div> 12 </li> 13 `}).join("");return` 14 <accordion-group js-filter-group-parent> 15 <accordion-item> 16 <details class="accordion-item filter-group-wrapper" data-show-default-spacing="true" js-accordion-item> 17 <summary class="accordion-item__title" js-accordion-item-summary> 18 ${label||humanizeFacetLabel(attribute)} 19 <span class="accordion-item-title__icon" style="--icon-width: 14px; --icon-height: 14px;"> 20 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 14" fill="none"> 21 <g transform="rotate(0, 11, 7)"> 22 <path d="M0.875 1.4375L11 11.5625L21.125 1.4375" stroke="currentColor" stroke-width="2.25"/> 23 </g> 24 </svg> 25 </span> 26 </summary> 27 <div class="accordion-item__content" js-accordion-item-content> 28 <ul class="filter-group filter-group--type-checkbox algolia-extra-facet__values" js-filter-group>${items}</ul> 29 </div> 30 </details> 31 </accordion-item> 32 </accordion-group> 33 `}).join("");this.extraFiltersContainer.innerHTML=html,this.renderFacetDiscoveryHelper(facets)}renderFacetDiscoveryHelper(facets){if(!window.Shopify?.designMode||!this.extraFiltersContainer)return;const configured=new Set((this.config.facetOrder||[]).map(f=>f.attribute)),attributes=Object.keys(facets).filter(attribute=>!EXCLUDED_EXTRA_FACET_ATTRIBUTES.has(attribute)).sort();if(!attributes.length)return;const rows=attributes.map(attribute=>{const valueCount=Object.keys(facets[attribute]).length,isConfigured=configured.has(attribute);return` 34 <button 35 type="button" 36 class="algolia-facet-discovery__attribute${isConfigured?" algolia-facet-discovery__attribute--configured":""}" 37 js-algolia-copy-facet-attribute 38 data-attribute="${escapeHtml(attribute)}" 39 title="Click to copy" 40 >${escapeHtml(attribute)} (${valueCount})${isConfigured?" ✓":""}</button> 41 `}).join(""),panel=document.createElement("div");panel.className="algolia-facet-discovery",panel.innerHTML=` 42 <p class="algolia-facet-discovery__heading"> 43 Theme editor only - available Algolia facet attributes (click to copy the exact name into a Facet block). ✓ = already added. 44 </p> 45 <div class="algolia-facet-discovery__list">${rows}</div> 46 `,panel.addEventListener("click",event=>{const button=event.target.closest("[js-algolia-copy-facet-attribute]");button&&(navigator.clipboard?.writeText(button.dataset.attribute).catch(()=>{}),button.classList.add("algolia-facet-discovery__attribute--copied"),setTimeout(()=>button.classList.remove("algolia-facet-discovery__attribute--copied"),1200))}),this.extraFiltersContainer.prepend(panel)}renderActiveFilters(searchParams){const params=new URLSearchParams(searchParams),chips=[];
46for(const[key,value]of params.entries()){if(key==="sort_by")continue;const isPrice=key==="filter.v.price.gte"||key==="filter.v.price.lte";if(!isPrice){const facet=facetForParamName(key);if(!facet||facet.type!=="facet")continue}if(isPrice&&Number(value)<=0)continue;const label=isPrice?`${key==="filter.v.price.gte"?"From":"Up to"} ${value}`:value;chips.push(`<button type="button" class="active-filter-item" data-type="${isPrice?"price-range":"list"}" js-algolia-active-filter-item data-filter-remove-name="${key}" data-filter-remove-value="${value}"> 47 <span class="active-filter-item__label fs-body-100">${label}</span> 48 </button>`)}this.activeFilters&&(this.activeFilters.innerHTML=chips.length?`<div class="active-filters"> 49 <div class="active-filters__header"> 50 <span class="active-filters-header__heading fs-body-100">${this.config.strings.selectedFilters}</span> 51 <button type="button" class="btn btn--style-text btn--size-regular btn--width-regular underlined" js-clear-all-button>${this.config.strings.clearAll}</button> 52 </div> 53 <div class="active-filters__list">${chips.join("")}</div> 54 </div>`:""),this.filterDrawerHeading&&(this.filterDrawerHeading.textContent=this.filterDrawerHeading.textContent.replace(/\(\d+\)/,`(${chips.length})`))}updateFilterViewResultsLabel(nbHits){if(!this.filterDrawerViewResultsIdleLabels?.length)return;const{showResultsZero,showResultsOne,showResultsOther}=this.config.strings,label=nbHits===0?showResultsZero:nbHits===1?showResultsOne:showResultsOther.replace("[[count]]",nbHits);
54this.filterDrawerViewResultsIdleLabels.forEach(el=>{el.textContent=label})}handleActiveFilterRemove(event){if(event.target.closest("[js-clear-all-button]")){this.resetAllFilterInputs();return}const chip=event.target.closest("[js-algolia-active-filter-item]");if(!chip)return;const{filterRemoveName:name,filterRemoveValue:value}=chip.dataset,input=this.querySelector(`input[name="${CSS.escape(name)}"][value="${CSS.escape(value)}"]`);if(input){input.checked=!1,input.dispatchEvent(new Event("change",{bubbles:!0}));return}const priceInput=this.querySelector(`input[name="${CSS.escape(name)}"]`);priceInput&&(priceInput.value="",priceInput.dispatchEvent(new Event("change",{bubbles:!0})))}resetAllFilterInputs(){this.querySelectorAll('[js-filter-group] input[type="checkbox"], [js-filter-group] input[type="radio"]').forEach(input=>{input.checked=!1}),this.querySelectorAll("[js-from-input], [js-to-input]").forEach(input=>{input.value=""})}renderPagination(zeroIndexedPage,totalPages){if(!this.pagination)return;const current=zeroIndexedPage+1;if(totalPages<=1){this.pagination.innerHTML="";return}const buildLink=page=>{const params=new URLSearchParams(this.currentSearchParams);return params.set("page",String(page)),`${window.location.pathname}?${params.toString()}`},items=[];current>1&&items.push(`<li class="pagination__item"><a class="pagination-item__navigation-button" href="${buildLink(current-1)}">←</a></li>`);const start=Math.max(1,current-2),end=Math.min(totalPages,current+2);for(let p=start;p<=end;p++)items.push(`<li class="pagination__item pagination__item--type-${p===current?"active":"none"}"><a class="pagination-item__navigation-button" href="${buildLink(p)}">${p}</a></li>`);current<totalPages&&items.push(`<li class="pagination__item"><a class="pagination-item__navigation-button" href="${buildLink(current+1)}">→</a></li>`),this.pagination.innerHTML=`<div class="pagination pagination--alignment-center"><ul class="pagination__list ff-body">${items.join("")}</ul></div>`}updateURLHash(searchParams){history.pushState({searchParams},"",`${window.location.pathname}${searchParams&&"?".concat(searchParams)}`)}initSortDropdowns(){this.sortDropdowns.forEach(dropdown=>{dropdown.querySelectorAll("input").forEach(input=>{input.addEventListener("click",this.handleSortOptionClick.bind(this),this.eventOptions)})})}updateSortDropdowns(sortBy){this.dataset.currentSort=sortBy,this.sortDropdowns.forEach(dropdown=>{const selected=dropdown.querySelector(`input[value="${sortBy}"]`);
54selected&&(selected.checked=!0)})}handleSortOptionClick(event){if(event.target.value===this.dataset.currentSort)return;const sortChangedEvent=new CustomEvent(SORT_CHANGED,{detail:{sortBy:event.target.value}});this.filterSortFormComponent.dispatchEvent(sortChangedEvent),this.sortTriggerValue&&(this.sortTriggerValue.innerText=event.target.dataset.label);const disclosureWrapper=event.target.closest(this.selectors.sortDropdowns)?.closest(this.selectors.disclosureWrapper);disclosureWrapper?disclosureWrapper.removeAttribute("open"):this.closeSortDrawer()}openSortDrawer(){this.hideStickyFilterSort(),setTimeout(()=>window.dispatchEvent(this.events.openSortDrawer),240)}closeSortDrawer(){window.dispatchEvent(this.events.closeSortDrawer)}hideStickyFilterSort(){this.stickyFilterSort?.classList.remove(this.classes.active)}showStickyFilterSort(){this.stickyFilterSort?.classList.add(this.classes.active)}getHeaderAnnouncementHeight(){this.header?.dataset.enableStickyHeader==="true"&&(this.headerHeight=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--header-height").replace("px",""),10)||0),this.announcementBar?.hasAttribute("data-sticky")&&(this.announcementHeight=parseInt(getComputedStyle(document.documentElement).getPropertyValue("--announcement-height").replace("px",""),10)||0)}handleHeaderHeightChange(event){this.headerHeight=event.detail.height}handleAnnouncementHeightChange(event){this.announcementHeight=event.detail.height}disconnectedCallback(){this.controller.abort(),this.topBarObserver?.disconnect(),this.footerObserver?.disconnect(),this.mobileTopBarObserver?.disconnect(),this.mobileFooterObserver?.disconnect()}}customElements.get("algolia-collection-product-grid")||customElements.define("algolia-collection-product-grid",AlgoliaCollectionProductGrid); 55//# sourceMappingURL=/cdn/shop/t/490/assets/algolia-collection-grid.js.map?v=146210750968917302681789724911
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.