1customElements.get("my-store-locator")||customElements.define("my-store-locator",class extends HTMLElement{constructor(){super(),this.dom={mobile:"my-store-locator-mobile",btn:".js-my-store-locator-btn",drawer:"my-store-locator-drawer",drawerBtn:".js-my-store-locator-drawer-btn",info:".js-my-store-locator-info",details:".js-my-store-locator-details",close:".js-my-store-locator-close",location:".js-my-store-locator-location",telephone:".js-my-store-locator-telephone",email:".js-my-store-locator-email",address:".js-my-store-locator-address",hours:".js-my-store-locator-hours",services:".js-my-store-locator-services",distance:".js-my-store-locator-distance",pickupAvailability:"pickup-availability",searchButton:".js-my-store-locator-search-drawer-launcher",filterResults:"ProductGridContainer",filterTag:".js-my-store-pickup-location-text",filterInput:".js-my-store-pickup-location-input",storeLocatorSearch:"storeLocatorSearch"},this.mobileLocator=document.querySelector(this.dom.mobile),this.button=this.querySelector(this.dom.btn),this.drawer=document.querySelector(this.dom.drawer),this.drawerBtn=this.querySelector(this.dom.drawerBtn),this.drawerBtn&&this.drawerBtn.addEventListener("click",this.onClickShowStoreSelector.bind(this)),this.details=this.querySelector(this.dom.details),this.detailsClose=this.details.querySelector(this.dom.close),this.detailsClose.addEventListener("click",this.hideDetails.bind(this)),this.detailsLocation=this.details.querySelector(this.dom.location),this.detailsTelephone=this.details.querySelector(this.dom.telephone),this.detailsEmail=this.details.querySelector(this.dom.email),this.detailsAddress=this.details.querySelector(this.dom.address),this.detailsHours=this.details.querySelector(this.dom.hours),this.detailsServices=this.details.querySelector(this.dom.services),this.distance=this.details.querySelector(this.dom.distance),this.filterResults=document.getElementById(this.dom.filterResults)||null,this.storeLocatorSearch=document.getElementById(this.dom.storeLocatorSearch)||null,this.onBodyClick=this.handleBodyClick.bind(this),this.onClickRefreshList=this.onClickRefreshList.bind(this),this.onClickToggleDetails=this.onClickToggleDetails.bind(this),this.onClickShowStoreSelector=this.onClickShowStoreSelector.bind(this),this.addEventListener("keyup",event=>{event.code.toUpperCase()==="ESCAPE"&&this.hideDetails()}),this?.filterResults&&new MutationObserver(mutations=>{mutations.forEach(mutation=>{mutation?.type==="childList"&&(document.querySelectorAll(this.dom.searchButton).forEach($searchButton=>{$searchButton.addEventListener("click",this.onClickShowStoreSelector.bind(this))}),this.updateFacets(this.button.querySelector(this.dom.info).innerHTML))})}).observe(this.filterResults,{childList:!0}),document.querySelectorAll(this.dom.searchButton).forEach($searchButton=>{$searchButton.addEventListener("click",this.onClickShowStoreSelector.bind(this))}),this.preferredStoreId=null,this.myCoords=null,this.allLocationsData=[],this.itemLocationsData={},this.storeSuggestions=[],this.init(),window.refreshStoreLocator=this.init.bind(this)}localizeUrl($url){const rootWithoutEndingSlash=Shopify.routes.root.slice(0,-1),urlParts=$url.split("/");return urlParts[0]=rootWithoutEndingSlash,urlParts.join("/")}storageAvailable(type){let storage;try{storage=window[type];const x="__storage_test__";return storage.setItem(x,x),storage.removeItem(x),!0}catch(e){return e instanceof DOMException&&(e.code===22||e.code===1014||e.name==="QuotaExceededError"||e.name==="NS_ERROR_DOM_QUOTA_REACHED")&&storage&&storage.length!==0}}getDistanceFromKm(km){let distanceText="";if(this.dataset.distanceUnit==="km")distanceText=`${parseFloat(km.toFixed(1))} ${this.dataset.distanceKmLabel}`;else{const miles=km*.621371;distanceText=`${parseFloat(miles.toFixed(1))} ${this.dataset.distanceMilesLabel}`}return distanceText}init(){const expiry=SDG.Data.locationCookieExpiry||30;function setSecureCookie(name,value,days){var expires="";if(days){var date=new Date;date.setTime(date.getTime()+days*24*60*60*1e3),expires="; expires="+date.toUTCString()}document.cookie=name+"="+(value||"")+expires+"; path=/; secure"}function getCookie(name){for(var nameEQ=name+"=",ca=document.cookie.split(";"),i=0;i<ca.length;i++){for(var c=ca[i];c.charAt(0)==" ";)c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length)}return null}function accept(pos,cookie=!1){if(cookie&&pos){const position={coords:{latitude:pos?.coords?.latitude,longitude:pos?.coords?.longitude}};setSecureCookie("location_sharing","true",expiry),setSecureCookie("location_position",JSON.stringify(position),expiry)}this.fetchLocations(pos)}
1function decline(cookie=!1){cookie&&setSecureCookie("location_sharing","false",expiry),this.fetchLocations(null,!0,()=>{this.updateMyStoreFromPreferredStoreId()||this.renderSelectYourStore()})}function getLocation(){if(SDG.Data.locationCookie||!1){const locationPreference=getCookie("location_sharing")||null;if(locationPreference&&locationPreference==="false"){decline.call(this,!1),this.hasInitialized=!0;return}if(locationPreference&&locationPreference==="true"){const locationPosition=getCookie("location_position")||null;if(locationPosition){const pos=JSON.parse(locationPosition);accept.call(this,pos,!0),this.hasInitialized=!0;return}}navigator.geolocation.getCurrentPosition(pos=>accept.call(this,pos,!0),decline.bind(this)),this.hasInitialized=!0;return}navigator.geolocation.getCurrentPosition(accept.bind(this),decline.call(this,!1)),this.hasInitialized=!0}if(this.dataset.defaultLocationId!==""&&(this.preferredStoreId=`gid://shopify/Location/${this.dataset.defaultLocationId}`),this.storageAvailable("localStorage")){const preferredStoreId=localStorage.getItem("preferredStoreId");preferredStoreId&&(this.preferredStoreId=preferredStoreId)}navigator.geolocation?getLocation.call(this):this.fetchLocations(null,!0,()=>{this.updateMyStoreFromPreferredStoreId()||this.renderSelectYourStore()})}async updateSelectedLocationAttributes(storeLocation=null){const data={updates:{},attributes:{_selected_location:storeLocation}};$.ajax({type:"POST",url:`${window.Shopify.routes.root}cart/update.js`,data,error:function(e){console.log(e)},dataType:"json"})}updateFacets(placeholderText=null){if(!this?.filterResults)return;const $placeholder=document.querySelector(`${this.dom.filterInput}[data-location-id="placeholder"]`),$placeholderButton=$placeholder?.closest("li").querySelector(this.dom.searchButton);placeholderText&&$placeholderButton&&($placeholderButton.innerText=placeholderText);const $prevInput=document.querySelector(`${this.dom.filterInput}.active`),$prevInputChecked=$prevInput?.checked;let $visibleInput=null;if(this.allLocationsData.forEach(location=>{document.querySelectorAll(`${this.dom.filterTag}[data-location-id="${location.id}"]`).forEach($filterTag=>{$filterTag.innerText=location.name}),document.querySelectorAll(this.dom.filterInput).forEach($filterInput=>{const pickupLocationId=$filterInput.dataset?.locationId;if(pickupLocationId===location.id){$filterInput.setAttribute("aria-label",location.name);const $searchButton=$filterInput.closest("li").querySelector(this.dom.searchButton);$searchButton&&($searchButton.innerText=location.name)}pickupLocationId===this.preferredStoreId?($visibleInput=$filterInput,$filterInput.disabled=!1,$filterInput.classList.add("active"),$filterInput.closest("label").classList.remove("facet-checkbox--disabled"),$filterInput.closest("li").classList.add("active")):pickupLocationId!=="placeholder"&&($filterInput.disabled=!0,$filterInput.checked=!1,$filterInput.classList.remove("active"),$filterInput.closest("label").classList.add("facet-checkbox--disabled"),$filterInput.closest("li").classList.remove("active"))})}),$visibleInput&&$prevInput&&$visibleInput?.id!==$prevInput?.id&&$prevInputChecked){const clickEvt=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});$visibleInput.dispatchEvent(clickEvt)}if(!$visibleInput&&$placeholder){$placeholder.closest("li").classList.add("active");const $filterTag=document.querySelector(`${this.dom.filterTag}[data-location-id]`);if($filterTag){const clickEvt=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});$filterTag.closest("a").dispatchEvent(clickEvt)}}else $placeholder&&$placeholder.closest("li").classList.remove("active")}updateMyStoreFromPreferredStoreId(){let hasUpdated=!1,hasLocalStoragePreferredStoreId=!1;if(this.storageAvailable("localStorage")&&localStorage.getItem("preferredStoreId")&&(hasLocalStoragePreferredStoreId=!0),this.preferredStoreId&&(!this.myCoords||hasLocalStoragePreferredStoreId)){const preferredLocation=this.allLocationsData.find(location=>location.id===this.preferredStoreId);preferredLocation&&(this.updateMyStoreWithLocation(preferredLocation),hasUpdated=!0)}return hasUpdated}locationsQuery(productQueryIds=[]){const activeLang=SDG?.Data?.language||"EN",locationQuery=` 2 id 3 name 4 address { 5 formatted 6 address1 7 city 8 province 9 provinceCode 10 zip 11 country 12 phone 13 latitude 14 longitude 15 } 16 enableToggles: metafield(namespace: "apple", key: "apl_EnableToggles") { 17 value 18 } 19 pickupMessages: metafield(namespace: "apple", key: "apl_PickupMessages") { 20 value 21 } 22 phoneOverride: metafield(namespace: "apple", key: "apl_PhoneOverride") { 23 value 24 } 25 email: metafield(namespace: "apple", key: "apl_Email") { 26 value 27 } 28 hours: metafield(namespace: "apple", key: "apl_Hours") { 29 value 30 } 31 services: metafield(namespace: "apple", key: "apl_ServicesContent") { 32 value 33 } 34 image: metafield(namespace: "apple", key: "apl_StoreImage") { 35 reference { 36 ... on MediaImage { 37 image { 38 originalSrc 39 } 40 } 41 } 42 } 43 `,getNearestQuery=` 44 getNearestPickupLocations($first: Int!, $location: GeoCoordinateInput, $s
44ortKey: LocationSortKeys) @inContext(language: ${activeLang}){ 45 locations(near: $location, first: $first, sortKey: $sortKey) { 46 edges { 47 node { 48 ${locationQuery} 49 } 50 } 51 } 52 } 53 `;if(productQueryIds.length>0){let productsQuery="",productIds="",selectedOptions="";return productQueryIds.forEach(key=>{productIds+=`$productId${key}: ID!,`,selectedOptions+=`$selectedOptions${key}: [SelectedOptionInput!]!,`,productsQuery+=` 54 product${key}: product(id: $productId${key}) { 55 variantBySelectedOptions(selectedOptions: $selectedOptions${key}) { 56 storeAvailability(first: $first) { 57 edges { 58 node { 59 available 60 pickUpTime 61 quantityAvailable 62 location { 63 ${locationQuery} 64 } 65 } 66 } 67 } 68 } 69 } 70 `}),` 71 query Products(${productIds} ${selectedOptions} $first: Int!, $location: GeoCoordinateInput, $sortKey: LocationSortKeys) @inContext(language: ${activeLang}){ 72 ${productsQuery} 73 locations(near: $location, first: $first, sortKey: $sortKey) { 74 edges { 75 node { 76 ${locationQuery} 77 } 78 } 79 } 80 } 81 `}return` 82 query ${getNearestQuery} 83 `}async fetchLocations(position=null,setDataOnly=!1,cb=null){const queryVariables={first:parseInt(this.dataset.numberOfLocationsToFetch),sortKey:"NAME"};if(position?.coords){this.myCoords=position.coords;const latitude=position.coords.latitude,longitude=position.coords.longitude;queryVariables.sortKey="DISTANCE",queryVariables.location={latitude,longitude}}let isCart=!1;const pickupAvailabilities=document.querySelectorAll(this.dom.pickupAvailability),productQueryIds=[];pickupAvailabilities.length>0&&[...pickupAvailabilities].every((pickupAvailability,i)=>{const itemKey=pickupAvailability?.dataset?.itemKey,productId=pickupAvailability?.dataset?.productId,selectedOptionsRaw=pickupAvailability?.dataset?.selectedOptions;if(productId&&selectedOptionsRaw){const selectedOptions=JSON.parse(selectedOptionsRaw).map(option=>({name:option.name,value:option.selected_value?option.selected_value:option.values[0]}));return itemKey?(productQueryIds.push(itemKey),queryVariables[`productId${itemKey}`]=`gid://shopify/Product/${productId}`,queryVariables[`selectedOptions${itemKey}`]=selectedOptions,isCart=!0):(productQueryIds.push(i),queryVariables[`productId${i}`]=`gid://shopify/Product/${productId}`,queryVariables[`selectedOptions${i}`]=selectedOptions),itemKey}});const query=this.locationsQuery(productQueryIds),locationsData=await this.fetchStorefrontApi(query,queryVariables);if(locationsData){if(locationsData.locations?.edges?.length&&(locationsData.locations.edges.forEac
83h(location=>{if(location?.node?.services?.value){const parsed=JSON.parse(location.node.services.value),markup=this.serializeRichText(parsed);location.node.services_html=markup}location?.node?.image?.reference?.image?.originalSrc&&(location.node.image_url=location.node.image.reference.image.originalSrc)}),this.allLocationsData=locationsData.locations.edges.map(location=>{const locationData=location.node;return locationsData.product0&&(locationData.available=!1,locationData.productPickupOfferedAtLocation=!1),locationData.distance=this.calculateStoreDistance(locationData.address),locationData}).filter(location=>JSON.parse(location.enableToggles?.value||null)?.storeLocatorEnabled!==!1)),locationsData.product0?.variantBySelectedOptions?.storeAvailability?.edges?.length){const locationsPDPData=locationsData.product0.variantBySelectedOptions.storeAvailability.edges;this.allLocationsData=this.allLocationsData.map(location=>{const locationPDPData=locationsPDPData.find(locationPDP=>locationPDP.node.location.id===location.id);return locationPDPData?{...location,available:locationPDPData.node.available,pickUpTime:locationPDPData.node.pickUpTime,quantityAvailable:locationPDPData.node.quantityAvailable,productPickupOfferedAtLocation:!0}:location})}else isCart&&(this.itemLocationsData={},Object.keys(locationsData).forEach(key=>{if(key.includes("product")){const itemKey=key.replace("product",""),locationsItemData=locationsData[key]?.variantBySelectedOptions?.storeAvailability?.edges||[],lineItemLocations=this.allLocationsData.map(location=>{const locationItemData=locationsItemData.find(locationItem=>locationItem.node.location.id===location.id);return locationItemData?{...location,available:locationItemData.node.available,pickUpTime:locationItemData.node.pickUpTime,quantityAvailable:locationItemData.node.quantityAvailable,productPickupOfferedAtLocation:!0}:{...location,available:!1}});this.itemLocationsData[itemKey]=lineItemLocations}}));if(this.storeSuggestions=[],this.allLocationsData.forEach(location=>{this.storeSuggestions.push(location.address.city,location.address.province,location.address.zip,location.address.country)}),!setDataOnly&&!this.updateMyStoreFromPreferredStoreId()){const firstLocation=this.allLocationsData.find(location=>JSON.parse(location.enableToggles?.value||null)?.checkoutEnabled!==!1);this.updateMyStoreWithLocation(firstLocation)}if(this.drawer){let allLocationsData=this.allLocationsData;if(this.drawer.selectedItemLocationsKey){const selectedItemLocationsData=this.itemLocationsData[this.drawer.selectedItemLocationsKey];selectedItemLocationsData&&(allLocationsData=selectedItemLocationsData)}let searchLocation=this.storeLocatorSearch.value;searchLocation=searchLocation.trim(),this.drawer.updateStoreDetails(allLocationsData,searchLocation)}}cb&&cb()}serializeRichText(richText){let html="";switch(richText.type){case"root":richText.children.forEach(child=>{html+=this.serializeRichText(child)});break;case"list":html+="<ul>",richText.children.forEach(child=>{html+=this.serializeRichText(child)}),html+="</ul>";break;case"list-item":html+="<li>",richText.children.forEach(child=>{html+=this.serializeRichText(child)}),html+="</li>";break;case"text":html+=richText.value;break;case"link":html+=`<a href="${richText.url}">`,richText.children.forEach(child=>{html+=this.serializeRichText(child)}),html+="</a>";break;case"paragraph":html+="<p>",richText.children.forEach(child=>{html+=this.serializeRichText(child)}),html+="</p>";break;default:break}return html}onClickRefreshList(evt){evt.currentTarget.disabled=!0,this.init()}onClickToggleDetails(){this.details.hasAttribute("open")?this.hideDetails():this.showDetail
83s()}onClickShowStoreSelector(evt){document.querySelector("my-store-locator-drawer").show(evt.currentTarget)}handleBodyClick(evt){const target=evt.target;target!=this.details&&!target.closest(this.dom.btn)&&!target.closest(this.dom.details)&&this.hideDetails()}hideDetails(){this.details.removeAttribute("open"),document.body.removeEventListener("click",this.onBodyClick),removeTrapFocus(this.focusElement)}showDetails(focusElement){this.focusElement=focusElement,this.details.setAttribute("open",""),document.body.addEventListener("click",this.onBodyClick),trapFocus(this.details)}removeButtonEvents(){this.button.removeEventListener("click",this.onClickRefreshList),this.button.removeEventListener("click",this.onClickToggleDetails),this.button.removeEventListener("click",this.onClickShowStoreSelector)}renderError(){this.removeButtonEvents(),this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=this.dataset.errorText,this.button.addEventListener("click",this.onClickRefreshList),this.mobileLocator&&this.mobileLocator.renderError();const pickupAvailabilities=document.querySelectorAll(this.dom.pickupAvailability);pickupAvailabilities.length>0&&pickupAvailabilities.forEach(pickupAvailability=>{pickupAvailability.renderError()}),this.updateFacets(this.dataset.errorText)}renderSelectYourStore(){this.removeButtonEvents(),this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=this.dataset.selectText,this.button.addEventListener("click",this.onClickShowStoreSelector),this.drawer.loading.classList.add("hidden"),this.mobileLocator&&this.mobileLocator.renderSelectYourStore();const pickupAvailabilities=document.querySelectorAll(this.dom.pickupAvailability);pickupAvailabilities.length>0&&pickupAvailabilities.forEach(pickupAvailability=>{pickupAvailability.renderPreview()}),this.updateFacets(this.dataset.selectText)}updateMyStoreWithLocation(location){if(!location)return;this.removeButtonEvents();const{name,address,email,hours,phoneOverride,id,distance}=location;this.preferredStoreId=id,this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=name,this.button.addEventListener("click",this.onClickToggleDetails);function resetValue(element,attribute=!1){element&&(element.value="",attribute&&element.setAttribute(attribute,""))}if(this.updateFacets(name),this.updateSelectedLocationAttributes(name),this.details.querySelector("h2").innerHTML=name,this.detailsLocation.innerHTML=address?.city&&address?.provinceCode?`${address.city}, ${address.provinceCode}`:`${address.city}`,address?.phone&&address?.phone!==""){this.detailsTelephone.classList.remove("hidden");const phoneLink=this.detailsTelephone.querySelector("a");phoneLink.href=`tel:${address.phone}`,phoneLink.innerHTML=address.phone}else{const phoneLink=this.detailsTelephone.querySelector("a");resetValue(phoneLink,"href"),this.detailsTelephone.classList.add("hidden")}if(phoneOverride?.value&&phoneOverride?.value!==""){this.detailsTelephone.classList.remove("hidden");const phoneLink=this.detailsTelephone.querySelector("a");phoneLink.href=`tel:${phoneOverride.value}`,phoneLink.innerHTML=phoneOverride.value}if(address?.address1&&address?.address1!==""){this.detailsAddress.classList.remove("hidden");const apiProvider=SDG?.Data?.mapProvider||null,addressLink=this.detailsAddress.querySelector("a");if(apiProvider==="google_maps"){const encodedName=encodeURIComponent(name),latitude=address.latitude,longitude=address.longitude,href=`https://www.google.com/maps/search/?api=1&query=${encodedName}&query_place_id=${latitude},${longitude}`;addressLink.href=href,addressLink.innerHTML=address.address1}if(apiProvider==="apple_maps"){const href=`https://maps.apple.com/place?q=${name}&address=${address.formatted}&ll=${address.latitude},${address.longitude}`;addressLink.href=href,addressLink.innerHTML=address.address1}}else{const addressLink=this.detailsAddress.querySelector("a");resetValue(addressLink,"href"),this.detailsAddress.classList.add("hidden")}if(email?.value&&email?.value!==""){this.detailsEmail.classList.remove("hidden");const emailLink=this.detailsEmail.querySelector("a");emailLink.href=`mailto:${email.value}`,emailLink.innerHTML=email.value}else{const emailLink=this.detailsEmail.querySelector("a");resetValue(emailLink,"href"),this.detailsEmail.classList.add("hidden")}if(hours?.value&&hours?.value!==""){this.detailsHours.classList.remove("hidden");const hoursSpan=this.detailsHours.querySelector("span");hoursSpan.innerHTML=hours.value}else{const hoursSpan=this.detailsHours.querySelector("span");resetValue(hoursSpan),this.detailsHours.classList.add("hidden")}if(location?.services_html){let openAcc2=function(el){el.setAttribute("aria-expanded",!0),el.classList.add("is-active")},closeAcc2=function(el){el.setAttribute("aria-expanded",!1),el.classList.remove("is-active")};
83var openAcc=openAcc2,closeAcc=closeAcc2;const servicesHtml=new DOMParser().parseFromString(location.services_html,"text/html"),servicesLinks=servicesHtml.querySelectorAll("a");let localizedServices;servicesLinks&&servicesLinks.length>0&&(Array.from(servicesLinks).forEach(link=>{const href=link.getAttribute("href");if(href.indexOf("/")===0){const localizedUrl=this.localizeUrl(href);link.setAttribute("href",localizedUrl)}}),localizedServices=servicesHtml.body.innerHTML),this.detailsServices.classList.remove("hidden"),this.detailsServices.innerHTML=` 84 <button class="my-location-result__services-btn js-acc-button" type="button"> 85 <span>${SDG?.Data?.storeServiceTrigger?SDG.Data.storeServiceTrigger:"View store services"}</span> 86 <i class="js-acc-icon myarrow fa fa-chevron-down my-location-result__services-icon" aria-hidden="true"></i> 87 </button> 88 <div class="my-location-result__services js-acc-details" aria-expanded="false">${localizedServices}</div> 89 `;const $accButton=this.detailsServices.querySelector(".js-acc-button"),$accDetail
89s=this.detailsServices.querySelector(".js-acc-details"),$accIcon=this.detailsServices.querySelector(".js-acc-icon");$accButton.addEventListener("click",()=>{$accDetails.classList.contains("is-active")?(closeAcc2($accDetails),$accIcon&&closeAcc2($accIcon)):(openAcc2($accDetails),$accIcon&&openAcc2($accIcon))})}else this.detailsServices.classList.add("hidden");this.updateMyStoreDistance(distance),this.mobileLocator&&this.mobileLocator.updateMyStoreWithLocation(location);const pickupAvailabilities=document.querySelectorAll(this.dom.pickupAvailability);pickupAvailabilities.length>0&&pickupAvailabilities.forEach(pickupAvailability=>{pickupAvailability.renderPreview(location)})}updateMyStoreDistance(distance){distance?(this.distance.innerHTML=distance,this.distance.classList.remove("hidden"),this.mobileLocator?.distance&&(this.mobileLocator.distance.innerHTML=distance,this.mobileLocator.distance.classList.remove("hidden"))):(this.distance.classList.add("hidden"),this.mobileLocator?.distance&&this.mobileLocator.distance.classList.add("hidden"))}getDistanceFromLatLon(lat1,lon1,lat2,lon2){var R=6371,dLat=this.deg2rad(lat2-lat1),dLon=this.deg2rad(lon2-lon1),a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(this.deg2rad(lat1))*Math.cos(this.deg2rad(lat2))*Math.sin(dLon/2)*Math.sin(dLon/2),c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)),d=R*c;return this.getDistanceFromKm(d)}deg2rad(deg){return deg*(Math.PI/180)}calculateStoreDistance(locationAddress){return this.myCoords?.latitude&&this.myCoords?.longitude&&locationAddress?.latitude&&locationAddress?.longitude?this.getDistanceFromLatLon(this.myCoords.latitude,this.myCoords.longitude,locationAddress.latitude,locationAddress.longitude):null}async fetchStorefrontApi(query,variables={}){const endpoint=`https://${Shopify.shop}/api/2024-07/graphql.json`,response=await fetch(endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":this.dataset.storefrontApiAccessToken},body:JSON.stringify({query,variables})}),{data,errors}=await response.json();if(errors)throw this.renderError(),new Error(errors[0].message);return data}}),customElements.get("my-store-locator-mobile")||customElements.define("my-store-locator-mobile",class extends HTMLElement{constructor(){super(),this.dom={desktop:"my-store-locator",btn:".js-my-store-locator-btn",drawerBtn:".js-my-store-locator-drawer-btn",info:".js-my-store-locator-info",details:".js-my-store-locator-details",close:".js-my-store-locator-close",location:".js-my-store-locator-location",telephone:".js-my-store-locator-telephone",email:".js-my-store-locator-email",address:".js-my-store-locator-address",hours:".js-my-store-locator-hours",services:".js-my-store-locator-services",distance:".js-my-store-locator-distance"},this.desktopLocator=document.querySelector(this.dom.desktop),this.button=this.querySelector(this.dom.btn),this.drawerBtn=this.querySelector(this.dom.drawerBtn),this.drawerBtn&&this.drawerBtn.addEventListener("click",this.onClickShowStoreSelector.bind(this)),this.details=this.querySelector(this.dom.details),this.detailsClose=this.details.querySelector(this.dom.close),this.detailsClose.addEventListener("click",this.hideDetails.bind(this)),this.detailsLocation=this.details.querySelector(this.dom.location),this.detailsTelephone=this.details.querySelector(this.dom.telephone),this.detailsEmail=this.details.querySelector(this.dom.email),this.detailsAddress=this.details.querySelector(this.dom.address),this.detailsHours=this.details.querySelector(this.dom.hours),this.detailsServices=this.details.querySelector(this.dom.services),this.distance=this.details.querySelector(this.dom.distance),this.onBodyClick=this.handleBodyClick.bind(this),this.onClickRefreshList=this.onClickRefreshList.bind(this),this.onClickToggleDetails=this.onClickToggleDetails.bind(this),this.onClickShowStoreSelector=this.onClickShowStoreSelector.bind(this),this.addEventListener("keyup",event=>{event.code.toUpperCase()==="ESCAPE"&&this.hideDetails()})}localizeUrl($url){const rootWithoutEndingSlash=Shopify.routes.root.slice(0,-1),urlParts=$url.split("/");return urlParts[0]=rootWithoutEndingSlash,urlParts.join("/")}onClickRefreshList(evt){evt.currentTarget.disabled=!0,this.desktopLocator.init()}onClickToggleDetails(){this.details.hasAttribute("open")?this.hideDetails():this.showDetail
89s()}onClickShowStoreSelector(evt){document.querySelector("my-store-locator-drawer").show(evt.currentTarget)}handleBodyClick(evt){const target=evt.target;target!=this.details&&!target.closest(this.dom.btn)&&!target.closest(this.dom.details)&&this.hideDetails()}hideDetails(){this.details.removeAttribute("open"),document.body.removeEventListener("click",this.onBodyClick),removeTrapFocus(this.focusElement)}showDetails(focusElement){const menuDrawer=document.getElementById("Details-menu-drawer-container");menuDrawer&&menuDrawer?.hasAttribute("open")&&menuDrawer.querySelector("summary").click(),this.focusElement=focusElement,this.details.setAttribute("open",""),document.body.addEventListener("click",this.onBodyClick),trapFocus(this.details)}removeButtonEvents(){this.button.removeEventListener("click",this.onClickRefreshList),this.button.removeEventListener("click",this.onClickToggleDetails),this.button.removeEventListener("click",this.onClickShowStoreSelector)}renderError(){this.removeButtonEvents(),this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=this.dataset.errorText,this.button.addEventListener("click",this.onClickRefreshList)}renderSelectYourStore(){this.removeButtonEvents(),this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=this.dataset.selectText,this.button.addEventListener("click",this.onClickShowStoreSelector)}updateMyStoreWithLocation(location){this.removeButtonEvents();const{name,address,email,hours,phoneOverride}=location;this.button.disabled=!1,this.button.querySelector(this.dom.info).innerHTML=name,this.button.addEventListener("click",this.onClickToggleDetails);function resetValue(element,attribute=!1){element&&(element.value="",attribute&&element.setAttribute(attribute,""))}if(this.details.querySelector("h2").innerHTML=name,this.detailsLocation.innerHTML=address?.city&&address?.provinceCode?`${address.city}, ${address.provinceCode}`:`${address.city}`,address?.phone&&address?.phone!==""){this.detailsTelephone.classList.remove("hidden");const phoneLink=this.detailsTelephone.querySelector("a");phoneLink.href=`tel:${address.phone}`,phoneLink.innerHTML=address.phone}else{const phoneLink=this.detailsTelephone.querySelector("a");resetValue(phoneLink,"href"),this.detailsTelephone.classList.add("hidden")}if(phoneOverride?.value&&phoneOverride?.value!==""){this.detailsTelephone.classList.remove("hidden");const phoneLink=this.detailsTelephone.querySelector("a");phoneLink.href=`tel:${phoneOverride.value}`,phoneLink.innerHTML=phoneOverride.value}if(address?.address1&&address?.address1!==""){this.detailsAddress.classList.remove("hidden");const apiProvider=SDG?.Data?.mapProvider||null,addressLink=this.detailsAddress.querySelector("a");if(apiProvider==="google_maps"){const encodedName=encodeURIComponent(name),latitude=address.latitude,longitude=address.longitude,href=`https://www.google.com/maps/search/?api=1&query=${encodedName}&query_place_id=${latitude},${longitude}`;addressLink.href=href,addressLink.innerHTML=address.address1}if(apiProvider==="apple_maps"){const href=`https://maps.apple.com/place?q=${name}&address=${address.formatted}&ll=${address.latitude},${address.longitude}`;addressLink.href=href,addressLink.innerHTML=address.address1}}else{const addressLink=this.detailsAddress.querySelector("a");resetValue(addressLink,"href"),this.detailsAddress.classList.add("hidden")}if(email?.value&&email?.value!==""){this.detailsEmail.classList.remove("hidden");const emailLink=this.detailsEmail.querySelector("a");emailLink.href=`mailto:${email.value}`,emailLink.innerHTML=email.value}else{const emailLink=this.detailsEmail.querySelector("a");resetValue(emailLink,"href"),this.detailsEmail.classList.add("hidden")}if(hours?.value&&hours?.value!==""){this.detailsHours.classList.remove("hidden");const hoursSpan=this.detailsHours.querySelector("span");hoursSpan.innerHTML=hours.value}else{const hoursSpan=this.detailsHours.querySelector("span");resetValue(hoursSpan),this.detailsHours.classList.add("hidden")}if(location?.services_html){let openAcc2=function(el){el.setAttribute("aria-expanded",!0),el.classList.add("is-active")},closeAcc2=function(el){el.setAttribute("aria-expanded",!1),el.classList.remove("is-active")};
89var openAcc=openAcc2,closeAcc=closeAcc2;const servicesHtml=new DOMParser().parseFromString(location.services_html,"text/html"),servicesLinks=servicesHtml.querySelectorAll("a");let localizedServices;servicesLinks&&servicesLinks.length>0&&(Array.from(servicesLinks).forEach(link=>{const href=link.getAttribute("href");if(href.indexOf("/")===0){const localizedUrl=this.localizeUrl(href);link.setAttribute("href",localizedUrl)}}),localizedServices=servicesHtml.body.innerHTML),this.detailsServices.classList.remove("hidden"),this.detailsServices.innerHTML=` 90 <button class="my-location-result__services-btn js-acc-button" type="button"> 91 <span>${SDG?.Data?.storeServiceTrigger?SDG.Data.storeServiceTrigger:"View store services"}</span> 92 <i class="js-acc-icon myarrow fa fa-chevron-down my-location-result__services-icon" aria-hidden="true"></i> 93 </button> 94 <div class="my-location-result__services js-acc-details" aria-expanded="false">${localizedServices}</div> 95 `;const $accButton=this.detailsServices.querySelector(".js-acc-button"),$accDetail
95s=this.detailsServices.querySelector(".js-acc-details"),$accIcon=this.detailsServices.querySelector(".js-acc-icon");$accButton.addEventListener("click",()=>{$accDetails.classList.contains("is-active")?(closeAcc2($accDetails),$accIcon&&closeAcc2($accIcon)):(openAcc2($accDetails),$accIcon&&openAcc2($accIcon))})}else this.detailsServices.classList.add("hidden")}}),customElements.get("my-store-locator-drawer")||customElements.define("my-store-locator-drawer",class extends HTMLElement{constructor(){super(),this.dom={storeLocatorSearch:"storeLocatorSearch",form:"storeLocatorSearchForm",storeLocator:"my-store-locator",suggestions:".js-store-locator-search-suggestions",error:".js-store-locator-search-error",loading:"storeLocatorDrawerLoading",results:"myLocationResults",resultsCount:".js-store-locator-results-count",activeResult:'.js-my-location-result[data-active="true"]',close:".js-store-locator-drawer-close",useLocationBtn:".js-store-locator-use-location-btn",resultsDistance:".js-store-locator-results-distance",selectBtn:".js-store-locator-select-btn",productInfo:".js-store-locator-product-info",acc_button:".js-acc-button",acc_icon:".js-acc-icon",acc_details:".js-acc-details"},this.cls={active:"is-active"},this.form=document.getElementById(this.dom.form),this.results=document.getElementById(this.dom.results),this.resultsCount=this.querySelector(this.dom.resultsCount),this.resultsDistance=this.querySelector(this.dom.resultsDistance),this.storeLocatorSearch=document.getElementById(this.dom.storeLocatorSearch),this.storeLocator=document.querySelector(this.dom.storeLocator),this.suggestions=this.querySelector(this.dom.suggestions),this.error=this.querySelector(this.dom.error),this.loading=document.getElementById(this.dom.loading),this.close=this.querySelector(this.dom.close),this.useLocationBtn=this.querySelector(this.dom.useLocationBtn),this.selectBtn=this.querySelector(this.dom.selectBtn),this.onBodyClick=this.handleBodyClick.bind(this),this.close.addEventListener("click",()=>{this.hide()}),this.useLocationBtn.addEventListener("click",()=>{this.useLocation()}),this.selectBtn.addEventListener("click",this.selectPreferredLocation.bind(this)),this.addEventListener("keyup",event=>{event.code.toUpperCase()==="ESCAPE"&&this.hide()}),this.init()}init(){this.form.addEventListener("submit",event=>{event.preventDefault(),this.searchLocations()}),this.resultsDistance.addEventListener("change",()=>{this.searchLocations(!0)}),this.storeLocatorSearch.onkeyup=debounce(this.storeLocatorSearchOnKeyUp.bind(this),200)}async storeLocatorSearchOnKeyUp(e){const userData=e.target.value;let emptyArray=[];if(userData&&e.code.toUpperCase()!=="ENTER")if(emptyArray=await this.getPlaceSuggestions(userData),emptyArray.length>0){const suggestionsHtml=emptyArray.map(data=>typeof data=="object"?`<button data-latitude="${data.latitude}" data-longitude="${data.longitude}"> 96 ${data.title} 97 </button>`:`<button>${data}</button>`);this.suggestions.innerHTML=suggestionsHtml.join(""),this.suggestions.querySelectorAll("button").forEach(item=>{item.addEventListener("click",e2=>{this.selectSuggestion(e2.target)})}),this.suggestions.classList.remove("hidden")}else this.suggestions.classList.add("hidden");else this.suggestions.classList.add("hidden")}localizeUrl($url){const rootWithoutEndingSlash=Shopify.routes.root.slice(0,-1),urlParts=$url.split("/");return urlParts[0]=rootWithoutEndingSlash,urlParts.join("/")}getPlaceSuggestions(address){const apiProvider=SDG?.Data?.mapProvider||null,countriesLimit=this.storeLocator.dataset.limitSearchToCountries;if(apiProvider==="google_maps")return new Promise((resolve,reject)=>{const componentRestrictions=countriesLimit!==""?{country:countriesLimit.split(",")}:null,autocompleteService=new google.maps.places.AutocompleteService,request={input:address,types:["(regions)"],componentRestrictions};autocompleteService.getPlacePredictions(request,(predictions,status)=>{if(status===google.maps.places.PlacesServiceStatus.OK){const suggestions=predictions.map(prediction=>prediction.description);resolve(suggestions)}else resolve([])})});if(apiProvider==="apple_maps")return new Promise((resolve,reject)=>{const limitToCountries=countriesLimit!==""?countriesLimit:null;new mapkit.Search({getsUserLocation:!0,includeAddresses:!0,includePointsOfInterest:!1,includeQueries:!1,limitToCountries}).autocomplete(address,(error,data)=>
97{if(error)resolve([]);else{const suggestions=data?.results?.map(result=>({title:result.displayLines[0],latitude:result.coordinate.latitude,longitude:result.coordinate.longitude}));resolve(suggestions)}})})}selectPreferredLocation(){const activeResult=this.querySelector(this.dom.activeResult);if(activeResult){const id=activeResult.dataset.id;if(this.storeLocator.allLocationsData){const location=this.storeLocator.allLocationsData.find(location2=>location2.id===id);location&&(this.storeLocator.storageAvailable("localStorage")&&localStorage.setItem("preferredStoreId",location.id),this.storeLocator.updateMyStoreWithLocation(location),this.searchLocations(!0),this.hide())}}}useLocation(){this.storeLocatorSearch.value="",this.loading.classList.remove("hidden"),navigator.geolocation?navigator.geolocation.getCurrentPosition(this.updateDrawerStoreDetails.bind(this),this.updateDrawerStoreDetails.bind(this)):this.updateDrawerStoreDetails()}updateDrawerStoreDetails(position){this.storeLocator.fetchLocations(position,!0,()=>{this.loading.classList.add("hidden")})}selectSuggestion(element){let selectData=element.textContent;this.storeLocatorSearch.value=selectData.trim(),this.suggestions.classList.add("hidden"),this.searchLocations(!1,element.dataset)}getObjects(obj,key,val){return obj.filter(location=>{const locationData=location.address;return locationData&&locationData[key]?locationData[key].toLowerCase()===val?.toLowerCase():null})}async searchLocations(noErrors=!1,dataset=null){let allLocationsData=this.storeLocator.allLocationsData;if(this.selectedItemLocationsKey){const selectedItemLocationsData=this.storeLocator.itemLocationsData[this.selectedItemLocationsKey];selectedItemLocationsData&&(allLocationsData=selectedItemLocationsData)}let searchLocation=this.storeLocatorSearch.value;if(searchLocation=searchLocation.trim(),noErrors)this.error.classList.add("hidden");else if(searchLocation===""){this.error.classList.remove("hidden");return}else this.error.classList.add("hidden");if(this.loading.classList.add("hidden"),dataset&&dataset.latitude&&dataset.longitude){this.updateDrawerStoreDetails({coords:{latitude:parseFloat(dataset.latitude),longitude:parseFloat(dataset.longitude)}});return}const geocodedPosition=await this.geocodePosition(searchLocation);if(geocodedPosition)this.updateDrawerStoreDetails(geocodedPosition);else{let storeDetails=[],searchCity=this.getObjects(allLocationsData,"city",searchLocation),searchZipcode=this.getObjects(allLocationsData,"zip",searchLocation),searchProvince=this.getObjects(allLocationsData,"province",searchLocation),country=this.getObjects(allLocationsData,"country",searchLocation);if(searchCity.length>0||searchZipcode.length>0||searchProvince.length>0||country.length>0)searchCity.length>0?storeDetails=searchCity:searchProvince.length>0?storeDetails=searchProvince:searchZipcode.length>0?storeDetails=searchZipcode:country.length>0&&(storeDetails=country),this.updateStoreDetails(storeDetails,searchLocation);else{if(!this.suggestions.classList.contains("hidden")){const firstSuggestion=this.suggestions.querySelector("button")||null;if(firstSuggestion){this.selectSuggestion(firstSuggestion);return}}noErrors&&(storeDetails=allLocationsData),searchLocation?this.updateStoreDetails([],searchLocation):this.updateStoreDetails(storeDetails,searchLocation)}}}geocodePosition(address){const apiProvider=SDG?.Data?.mapProvider||null;if(apiProvider==="google_maps")return new Promise((resolve,reject)=>{new google.maps.Geocoder().geocode({address},(results,status)=>{if(status==="OK"){const latitude=results?.[0]?.geometry?.location?.lat(),longitude=results?.[0]?.geometry?.location?.lng();if(latitude&&longitude){const position={coords:{latitude,longitude},timestamp:Date.now()};resolve(position)}}resolve(null)})});if(apiProvider==="apple_maps"&&apiProvider==="apple_maps")return new Promise((resolve,reject)=>{new mapkit.Geocoder().lookup(address,(error,data)=>
97{if(!error){const result=data?.results?.[0],latitude=result?.coordinate?.latitude,longitude=result?.coordinate?.longitude;if(latitude&&longitude){const position={coords:{latitude,longitude},timestamp:Date.now()};resolve(position)}}resolve(null)})})}updateStoreDetails(locationData,nearbyValue){let resultCount=0;const{mapPage}=SDG.Data||!1,activeIndex=locationData.findIndex(location=>location.id===this.storeLocator.preferredStoreId);activeIndex>-1&&locationData.splice(0,0,locationData.splice(activeIndex,1)[0]),this.results.innerHTML="";function setCityAndStateHTML(location){const{address}=location||null;let html;if(address){if(address?.city&&address?.provinceCode)return html=`${address.city}, ${address.provinceCode}`,html;if(address?.city&&!address?.provinceCode)return html=`${address.city}`,html}}locationData.forEach(location=>{if(location.distance){if(this.resultsDistance.classList.remove("hidden"),this.resultsDistance.value!=="all"){const parsedLocationDistance=parseFloat(location.distance),parsedDistance=parseFloat(this.resultsDistance.value);if(parsedLocationDistance>parsedDistance)return}}else this.resultsDistance.classList.add("hidden");const isActive=location.id===this.storeLocator.preferredStoreId,distanceHidden=location.distance?"":" hidden";let availabilityHtml="";const $ctoPickupElement=this.selectedItemLocationsKey?document.querySelector(`pickup-availability[data-message-type][data-item-key="${this.selectedItemLocationsKey}"]`):document.querySelector("pickup-availability[data-message-type]");let overridePickupMessage=$ctoPickupElement?.dataset?.overridePickupMessage;const messageType=$ctoPickupElement?.dataset?.messageType;if(!overridePickupMessage&&messageType){const languageKey=SDG.Data.language?.toLowerCase()||"en",pickupMessagesJson=JSON.parse(location.pickupMessages?.value||null),pickupMessages=pickupMessagesJson?.[languageKey]||pickupMessagesJson?.en;switch(messageType){case"cto":overridePickupMessage=pickupMessages?.cto;break;case"preorder":overridePickupMessage=pickupMessages?.preOrder;break;case"in stock":overridePickupMessage=pickupMessages?.inStock;break}}if(JSON.parse(location.enableToggles?.value||null)?.checkoutEnabled===!1){const overrideUnavailableMessage=$ctoPickupElement?.dataset?.overrideUnavailableMessage;availabilityHtml=` 98 <div class="my-location-result__availability asd ${location.enableToggles?.value}"> 99 ${overrideUnavailableMessage?`<span>${overrideUnavailableMessage}</span>`:this.storeLocator.dataset.unavailableText} 100 </div> 101 `}else if(overridePickupMessage&&location.productPickupOfferedAtLocation&&!(messageType==="in stock"&&!location.available))availabilityHtml=` 102 <div class="my-location-result__availability"> 103 <div class="my-location-result__availability-time my-location-result__availability-time--overridden">${overridePickupMessage}</div> 104 </div> 105 `;else if(location.available){let stockHtml="",pickUpTimeTranslated="";if(location.pickUpTime){const key=location.pickUpTime,languageKey=SDG.Data.language?.toLowerCase()||"en";pickUpTimeTranslated=window.deliveryOptionsStrings?.[languageKey]?.[key]||location.pickUpTime}location.quantityAvailable<10&&(stockHtml=` 106 <div class="my-location-result__availability-stock">${this.storeLocator.dataset.lowStockHtml.replace("{{ quantity }}",location.quantityAvailable)}</div> 107 `),availabilityHtml=` 108 <div class="my-location-result__availability"> 109 <div class="my-location-result__availability-time">${pickUpTimeTranslated}</div> 110 ${stockHtml} 111 </div> 112 `}else if(location.available===!1){const overrideUnavailableMessage=$ctoPickupElement?.dataset?.overrideUnavailableMessage;availabilityHtml=` 113 <div class="my-location-result__availability qwe"> 114 ${overrideUnavailableMessage?`<span>${overrideUnavailableMessage}</span>`:this.storeLocator.dataset.unavailableText} 115 </div> 116 `}location.name=="Jurong Point";let itemKeyAttr="";location.itemKey&&(itemKeyAttr=`data-item-key="${location.itemKey}"`);let resultHtml;const{address,name}=location||null,apiProvider=SDG?.Data?.mapProvider||null;if(!address)return;const{latitude,longitude}=address||null;let locationImageHtml="",serviceHtml="",telephoneVal=null,calloutHref=null,addressHref=null,url=window.location.href;if(location?.services_html){const servicesHtml=new DOMParser().parseFromString(location.services_html,"text/html"),servicesLinks=servicesHtml.querySelectorAll("a");let localizedServices;servicesLinks&&servicesLinks.length>
1160&&Array.from(servicesLinks).forEach(link=>{const href=link.getAttribute("href");if(href.indexOf("/")===0){const localizedUrl=this.localizeUrl(href);link.setAttribute("href",localizedUrl),link.classList.add("apl-section-stores-locator-store-services-link")}}),localizedServices=servicesHtml.body.innerHTML,url.includes("store-locator")?serviceHtml=` 117 <button class="my-location-result__services-btn js-acc-button apl-section-stores-locator-store-services-btn" type="button"> 118 <span class="underlined-text">${SDG?.Data?.storeServiceTrigger?SDG.Data.storeServiceTrigger:"View store services"}</span> 119 <i class="myarrow fa fa-chevron-down my-location-result__services-icon js-acc-icon" aria-hidden="true"></i> 120 </button> 121 <div class="my-location-result__services js-acc-details" aria-expanded="false">${localizedServices}</div> 122 `:serviceHtml=` 123 <li> 124 <button class="my-location-result__services-btn js-acc-button apl-section-stores-locator-store-services-btn" type="button"> 125 <span class="underlined-text">${SDG?.Data?.storeServiceTrigger?SDG.Data.storeServiceTrigger:"View store services"}</span> 126 <i class="myarrow fa fa-chevron-down my-location-result__services-icon js-acc-icon" aria-hidden="true"></i> 127 </button> 128 </li> 129 <li class="my-location-result__services js-acc-details" aria-expanded="false">${localizedServices}</li> 130 `}if(location?.image_url&&(locationImageHtml=` 131 <div class="my-location-result__image"> 132 <img src="${location.image_url}" alt="${name}" /> 133 </div> 134 `),location?.address?.phone&&(telephoneVal=location.address.phone),location?.phoneOverride?.value&&(telephoneVal=location.phoneOverride.value),apiProvider==="apple_maps"&&(addressHref=`https://maps.apple.com/place?q=${name}&address=${address.formatted}&ll=${address.latitude},${address.longitude}`,calloutHref=`https://maps.apple.com/place?q=${name}&address=${address.formatted}&ll=${address.latitude},${address.longitude}`),apiProvider==="google_maps"){const encodedName=encodeURIComponent(name),latitude2=address.latitude,longitude2=address.longitude;addressHref=`https://www.google.com/maps/search/?api=1&query=${encodedName}&query_place_id=${latitude2},${longitude2}`,calloutHref=`https://www.google.com/maps/search/?api=1&query=${encodedName}&query_place_id=${latitude2},${longitude2}`}if(mapPage){resultHtml=` 135 <div 136 class="js-my-location-result my-location-result" 137 data-active="${isActive}" 138 data-id="${location.id}" 139 data-name="${name}" 140 data-latitude="${latitude}" 141 data-longitude="${longitude}" 142 role="group" 143 ${itemKeyAttr} 144 > 145 <div class="my-location-result__my-store">${SDG.Data.myStore}</div> 146 ${locationImageHtml} 147 <section class="js-my-results-details"> 148 <div class="my-location-result__details"> 149 <div class="my-location-result__name">${location.name}</div> 150 <div class="js-my-location-result-distance my-store-locator__details-distance${distanceHidden}"> 151 ${location.distance} 152 </div> 153 </div> 154 <div class="my-location-result__address my-location-result__location"> 155 ${setCityAndStateHTML(location)} 156 </div> 157 <ul class="list-unstyled my-location-result__business"> 158 ${location?.address?.address1?`<li class="my-location-result__address"> 159 <span>${SDG.Data.storeAddress||"Address"}: </span> 160 <a href="${calloutHref}" target="_blank">${location.address.formatted.join(", ")}</a> 161 </li>`:""} 162 ${telephoneVal?`<li class="my-location-result__address">
163 <span>${SDG.Data.storePhone||"Telephone"}: </span> 164 <a href="tel:${telephoneVal}">${telephoneVal}</a> 165 </li>`:""} 166 ${location?.email?.value?`<li class="my-location-result__address"> 167 <span>${SDG.Data.storeEmail||"E-Mail"}: </span> 168 <a href="mailto:${location.email.value}">${location.email.value}</a> 169 </li>`:""} 170 ${location.hours?.value?`<li class="my-location-result__address"> 171 <span>${SDG.Data.storeHours||"Hours"}: </span> 172 <span>${location.hours.value}</span> 173 </li>`:""} 174 </ul> 175 <div class="my-location-result__link js-my-location-link visually-hidden"> 176 <a href="${calloutHref}" target="_blank" rel="noopener noreferrer">Get Directions</a> 177 </div> 178 </section> 179 ${serviceHtml} 180 ${JSON.parse(location.enableToggles?.value||null)?.checkoutEnabled!==!1?` 181 <button class="js-make-my-store-btn button button--secondary button--full-width my-location-result__make-my-store-btn"> 182 ${SDG.Data.makeThisMyStore} 183 </button> 184 `:""} 185 </div>`;const resultNode=new DOMParser().parseFromString(resultHtml,"text/html").body.childNodes[0];resultNode.querySelector(".js-make-my-store-btn")?.addEventListener("click",e=>{const activeResult=this.querySelector(this.dom.activeResult);activeResult&&(activeResult.dataset.active="false"),e.currentTarget.parentNode.dataset.active="true",this.selectPreferredLocation()}),this.results.append(resultNode),resultCount++}else{resultHtml=` 186 <div 187 class="js-my-location-result my-location-result my-location-result--drawer" 188 data-active="${isActive}" 189 data-id="${location.id}" 190 data-name="${name}" 191 data-latitude="${latitude}" 192 data-longitude="${longitude}" 193 role="group" 194 ${itemKeyAttr} 195 > 196 <div class="my-location-result-details"> 197 <div class="my-location-result__my-store">${SDG.Data.myStore}</div> 198 <section class="js-my-results-details"> 199 <div class="my-location-result__details"> 200 <div class="my-location-result__name">${location.name}</div> 201 <div class="js-my-location-result-distance my-store-locator__details-distance${distanceHidden}"> 202 ${location.distance} 203 </div> 204 </div> 205 <div class="my-location-result__address"> 206 ${setCityAndStateHTML(location)} 207 </div> 208 ${availabilityHtml} 209 </section> 210 </div> 211 <ul class="list-unstyled my-location-result-details--contact"> 212 ${location?.address?.address1?`<li class="my-location-result__address"> 213 <span>${SDG.Data.storeAddress||"Address"}: </span> 214 <a href="${addressHref}" target="_blank" rel="noopener noreferrer">${location.address.formatted.join(", ")}</a> 215 </li>`:""} 216 ${telephoneVal?`<li class="my-location-result__address"> 217 <span>${SDG.Data.storePhone||"Telephone"}: </span> 218 <a href="tel:${telephoneVal}">${telephoneVal}</a> 219 </li>`:""} 220 ${location?.email?.value?`<li class="my-location-result__address"> 221 <span>${SDG.Data.storeEmail||"E-Mail"}: </span> 222 <a href="mailto:${location.email.value}">${location.email.value}</a> 223 </li>`:""} 224 ${location.hours?.value?`<li class="my-location-result__address"> 225 <span>${SDG.Data.storeHours||"Hours"}: </span> 226 <span>${location.hours.value}</span> 227 </li>`:""} 228 ${serviceHtml} 229 </ul> 230 </div>`;const openAcc=el=>{el.setAttribute("aria-expanded",!0),el.classList.add(this.cls.active)},closeAcc=el=>{el.setAttribute("aria-expanded",!1),el.classList.remove(this.cls.active)},resultNode=new DOMParser().parseFromString(resultHtml,"text/html").body.childNodes[0],$accButton=resultNode?.querySelector(this.dom.acc_button)||null,$accIcon=resultNode?.querySelector(this.dom.acc_icon)||null,$accDetail
230s=resultNode?.querySelector(this.dom.acc_details)||null;resultNode.addEventListener("click",e=>{const activeResult=this.querySelector(this.dom.activeResult);activeResult&&(activeResult.dataset.active="false"),e.currentTarget.dataset.active="true",JSON.parse(location.enableToggles?.value||null)?.checkoutEnabled!==!1?this.selectBtn.disabled=!1:this.selectBtn.disabled=!0}),$accButton&&$accDetails&&$accButton.addEventListener("click",()=>{$accDetails.classList.contains(this.cls.active)?(closeAcc($accDetails),$accIcon&&closeAcc($accIcon)):(openAcc($accDetails),$accIcon&&openAcc($accIcon)),$accButton.setAttribute("data-acc",!0)}),this.results.append(resultNode),resultCount++}});let resultsText="";nearbyValue===""?this.storeLocator.myCoords?resultCount>1||resultCount===0?resultsText=this.resultsCount.dataset.resultsNearYou:resultsText=this.resultsCount.dataset.resultNearYou:resultCount>1||resultCount===0?resultsText=this.resultsCount.dataset.results:resultsText=this.resultsCount.dataset.result:resultCount>1||resultCount===0?resultsText=`${this.resultsCount.dataset.resultsNear} "${nearbyValue}"`:resultsText=`${this.resultsCount.dataset.resultNear} "${nearbyValue}"`,this.resultsCount.innerHTML=`${resultCount} ${resultsText}`,resultCount===0&&(this.results.innerHTML=` 231 <div class="my-location-result"> 232 <div class="my-location-result__address">${this.resultsCount.dataset.noResultsFound}</div> 233 </div> 234 `),this.loading.classList.add("hidden"),this.results.scrollTop=0}handleBodyClick(evt){const target=evt.target;target.classList.contains("js-my-store-locator-search-drawer-launcher")||(target!==this&&!target.closest("my-store-locator-drawer")&&!target.closest(".js-my-store-locator-btn")&&!target.classList.contains("js-my-store-locator-btn")&&!target.classList.contains("js-my-store-locator-drawer-btn")&&this.hide(),this.suggestions.classList.add("hidden"))}hide(){this.removeAttribute("open"),document.body.removeEventListener("click",this.onBodyClick),document.documentElement.classList.remove("overflow-hidden"),removeTrapFocus(this.focusElement)}show(focusElement){focusElement.dataset?.itemKey?document.querySelectorAll(this.dom.productInfo).forEach(productInfo=>{productInfo.dataset.itemKey===focusElement.dataset.itemKey?productInfo.classList.remove("hidden"):productInfo.classList.add("hidden")}):focusElement.dataset?.productInfo==="false"&&document.querySelectorAll(this.dom.productInfo).forEach(productInfo=>{productInfo.classList.add("hidden")}),this.setAttribute("data-hide-availability",focusElement.dataset?.hideAvailability||!1),this.focusElement=focusElement,this.setAttribute("open",""),document.body.addEventListener("click",this.onBodyClick),document.documentElement.classList.add("overflow-hidden"),trapFocus(this)}}); 235//# sourceMappingURL=/cdn/shop/t/14/assets/my-store-locator.js.map?v=142963705601107651211766555929
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.