1class UASizeGuideDrawer extends Drawer{constructor(){super()}}class UASizeGuideDrawerButton extends DrawerButton{static cache={};constructor(){super(),this.productHandle=this.dataset.productHandle,this.handleClick=this.handleClick.bind(this)}connectedCallback(){this.addEventListener("click",this.handleClick)}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}async handleClick(){this.drawerTag=this.dataset.drawerTag,this.drawerTag&&(this.drawer=document.querySelector(`${this.drawerTag}.size-guide-drawer--${this.productHandle}`),this.drawer||(document.querySelectorAll("size-guide-drawer.size-guide-drawer--quick-buy").forEach(drawer=>{drawer.remove()}),await this.fetchSizeGuide(),this.classList.remove("loading"),this.drawer=document.querySelector(this.drawerTag),document.dispatchEvent(new CustomEvent("update-tracking-buttons"))),setTimeout(()=>{this.toggleDrawer()},200))}async fetchSizeGuide(){this.classList.add("loading");const url=`/products/${this.productHandle}`;if(UASizeGuideDrawerButton.cache[this.productHandle]){document.body.appendChild(UASizeGuideDrawerButton.cache[this.productHandle]);return}try{const data=await(await fetch(url)).text(),sizeGuideDrawer=new DOMParser().parseFromString(data,"text/html").querySelector("size-guide-drawer");sizeGuideDrawer?(UASizeGuideDrawerButton.cache[this.productHandle]=sizeGuideDrawer.cloneNode(!0),sizeGuideDrawer.classList.add("size-guide-drawer--quick-buy"),document.body.appendChild(sizeGuideDrawer)):console.error("Size guide drawer element not found in the response")}catch(error){console.error("Error fetching size guide:",error)}}}class UASizeGuideRegion extends HTMLElement{constructor(){super(),this.regions=[],this.selectedRegion="all",this.areaEl=null,this.selectEl=null,this.handleRegionChange=this.handleRegionChange.bind(this),this.preselectLocation=!1|this.dataset.preselectLocation==="true"}connectedCallback(){this.selectEl=this.querySelector("select"),this.areaEl=this.closest(".size-guide-drawer__content"),this.regions=this.getAvailableRegions(),this.regions.length!==0&&(this.populateSelectElement(),this.selectEl.addEventListener("change",this.handleRegionChange),this.preselectVisitorLocation(),this.showRegionSelector())}disconnectedCallback(){this.selectEl.removeEventListener("change",this.handleRegionChange)}showRegionSelector(){this.classList.remove("hidden")}preselectVisitorLocation(){this.preselectLocation&&window.fetchVisitorBrowsingContextSuggestions().then(visitorInfo=>{const visitorCountryName=visitorInfo.detected_values.country.name.toLowerCase();this.regions.includes(visitorCountryName)&&(this.filterRegions(visitorCountryName),this.selectEl.value=visitorCountryName)}).catch(error=>{console.error("Error fetching visitor info:",error)})}populateSelectElement(){this.regions.forEach(region=>{const option=document.createElement("option");option.value=region,region=region.replace(/\b\w/g,char=>char.toUpperCase()),option.textContent=region,this.selectEl.appendChild(option)})}showAllRegions(){this.areaEl.querySelectorAll(".size-guide-table .size-guide-table__row[data-location]:not([data-location=''])").forEach(table=>{table.style.display=""})}filterRegions(selectedRegion){const tables=this.areaEl.querySelectorAll(".size-guide-table");this.showAllRegions(),selectedRegion=selectedRegion||this.selectedRegion,selectedRegion!=="all"&&tables.forEach(table=>{if(!this.tableHasRegion(table,selectedRegion))return;table.querySelectorAll(".size-guide-table__row[data-location]:not([data-location=''])").forEach(regionColumn=>{regionColumn.getAttribute("data-location").toLowerCase()===selectedRegion?regionColumn.style.display="":regionColumn.style.display="none"})})}tableHasRegion(table,region){return table.querySelectorAll(`[data-location="${region}" i]`).length>0}handleRegionChange(event){this.selectedRegion=event.target.value,this.filterRegions()}getAvailableRegions(){let regions=[];return this.parentElement.querySelector("size-guide-table").querySelectorAll(".size-guide-table .size-guide-table__row[data-location]:not([data-location=''])").forEach(table=>
1{regions.push(table.getAttribute("data-location").toLocaleLowerCase())}),regions=regions.filter((region,index,self)=>self.indexOf(region)===index&®ion!==""),regions}}class UASizeGuideRegionSelect extends UASizeGuideRegion{constructor(){super()}}class UASizeGuideFilterButton extends DrawerButton{constructor(){super()}connectedCallback(){this.contentId=this.dataset.contentId,this.contentEls=document.querySelectorAll(`.size-guide-drawer__content[data-content-id="${this.contentId}"]`),this.filterButtons=document.querySelectorAll("size-guide-filter-button"),this.addEventListener("click",this.handleClick)}handleClick(){this.classList.contains("disabled")||this.classList.contains("active")||(this.updateButtons(),this.updateCategoryVisibility(),this.updateContentVisibility())}updateButtons(){const isCategoryButton=this.contentId.includes("category"),categoryNavEl=document.querySelector(".size-guide__filter-nav--cagtegory");for(const button of this.filterButtons){const isButtonCategory=button.dataset.contentId.includes("category");isCategoryButton&&!isButtonCategory||!isCategoryButton&&isButtonCategory||(button.dataset.contentId===this.contentId?button.classList.add("active","button--outline"):button.classList.remove("active","button--outline"))}if(!isCategoryButton&&categoryNavEl){const categoryButtons=categoryNavEl.querySelectorAll("size-guide-filter-button");for(const categoryButton of categoryButtons){const categoryContentId=categoryButton.dataset.contentId,hasClickedButton=document.querySelector(`.size-guide__category[data-content-id="${categoryContentId}"] .size-guide-drawer__content[data-content-id="${this.contentId}"]`),buttons=document.querySelectorAll(`size-guide-filter-button[data-content-id="${categoryContentId}"]`);for(const button of buttons)button.classList.toggle("disabled",!hasClickedButton)}}}updateCategoryVisibility(){if(!this.contentId.includes("category"))return;const categoryEls=document.querySelectorAll(".size-guide__category");for(const categoryEl of categoryEls){const isActive=categoryEl.dataset.contentId===this.contentId;categoryEl.classList.toggle("hidden",!isActive),categoryEl.classList.toggle("active",isActive)}}updateContentVisibility(){if(this.contentId.includes("category"))return;const contentEls=document.querySelectorAll(".size-guide-drawer__content");for(const contentEl of contentEls){const isActive=contentEl.dataset.contentId===this.contentId;contentEl.classList.toggle("active",isActive),contentEl.classList.toggle("hidden",!isActive)}}}class UASizeGuideTable extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListeners()}addEventListeners(){this.querySelectorAll(".size-guide-table__cell").forEach(cell=>{cell.addEventListener("mouseenter",this.highlightCells.bind(this))}),this.addEventListener("mouseleave",this.removeAllHighlightedCells.bind(this))}highlightCells(event){this.removeAllHighlightedCells();const cell=event.target,row=cell.closest(".size-guide-table__row"),colIndex=Array.from(row.children).indexOf(cell);cell.classList.add("highlight"),row.classList.add("active-row"),Array.from(row.children).forEach((rowCell,index)=>{index<=colIndex&&rowCell.classList.add("highlight")});const rows=this.querySelectorAll(".size-guide-table__row");for(let i=0;i<=Array.from(rows).indexOf(row);i++){const cellInRow=rows[i].children[colIndex];cellInRow&&cellInRow.classList.add("highlight")}}removeAllHighlightedCells(){this.querySelectorAll(".size-guide-table__row").forEach(row=>{row.classList.remove("active-row")}),this.querySelectorAll(".size-guide-table__cell").forEach(cell=>{cell.classList.remove("highlight")})}}customElements.define("size-guide-drawer",UASizeGuideDrawer),customElements.define("size-guide-drawer-button",UASizeGuideDrawerButton),customElements.define("size-guide-filter-button",UASizeGuideFilterButton),customElements.define("size-guide-region-select",UASizeGuideRegionSelect),customElements.define("size-guide-table",UASizeGuideTable); 2//# sourceMappingURL=/cdn/shop/t/9/assets/ua_size-guide.js.map?v=68216408653880563301777368148
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.