1(()=>{if(window.SmkProductColorNavigation)return;const CACHE_TTL=600*1e3,MAX_CACHE_SIZE=24,MAX_IDLE_PREFETCH=3,cache=new Map;let navigationSequence=0,prefetchScheduled=!1;const updateCacheStats=()=>{const readyCount=Array.from(cache.values()).filter(entry=>entry.status==="ready").length;document.documentElement.dataset.smkColorCacheReady=String(readyCount),document.documentElement.dataset.smkColorCacheTotal=String(cache.size)},normalizeUrl=href=>{const url=new URL(href,window.location.href);return url.hash="",url},cacheKey=url=>`${url.pathname}${url.search}`,isProductUrl=url=>url.origin===window.location.origin&&url.pathname.includes("/products/"),trimCache=()=>{for(;cache.size>MAX_CACHE_SIZE;){const oldestKey=cache.keys().next().value;cache.delete(oldestKey)}},fetchProductPage=href=>{const url=normalizeUrl(href),key=cacheKey(url),cached=cache.get(key);if(cached&&Date.now()-cached.createdAt<CACHE_TTL)return cached.promise;const promise=fetch(url.href,{credentials:"same-origin",headers:{Accept:"text/html","X-Requested-With":"XMLHttpRequest"}}).then(response=>{if(!response.ok)throw new Error(`Product page request failed: ${response.status}`);return response.text()}).then(html=>{const parsedDocument=new DOMParser().parseFromString(html,"text/html");if(!parsedDocument.querySelector("#MainContent"))throw new Error("Product page response did not contain MainContent");return{document:parsedDocument,url}}).catch(error=>{throw cache.delete(key),error}),entry={createdAt:Date.now(),promise,status:"loading"};return cache.set(key,entry),updateCacheStats(),promise.then(()=>{entry.status="ready",updateCacheStats()},()=>updateCacheStats()),trimCache(),promise},syncHead=sourceDocument=>{document.title=sourceDocument.title||document.title,document.documentElement.lang=sourceDocument.documentElement.lang||document.documentElement.lang,['link[rel="canonical"]','meta[name="description"]','meta[property="og:title"]','meta[property="og:description"]','meta[property="og:url"]','meta[property="og:image"]','meta[name="twitter:title"]','meta[name="twitter:description"]','meta[name="twitter:image"]'].forEach(selector=>{const current=document.head.querySelector(selector),incoming=sourceDocument.head.querySelector(selector);!current||!incoming||(current.tagName==="LINK"?current.setAttribute("href",incoming.getAttribute("href")||""):current.setAttribute("content",incoming.getAttribute("content")||""))})},updateContactLinks=root=>{root.querySelectorAll("[data-product-contact-link]").forEach(link=>{const params=new URLSearchParams,productTitle=link.getAttribute("data-product-title");productTitle&¶ms.set("product",productTitle),params.set("product_url",window.location.href),link.href=`/pages/contact?${params.toString()}`})},refreshPaidy=root=>{const message=root.querySelector("._paidy-promotional-messaging");if(message)try{window.Paidy&&typeof window.Paidy.render=="function"?window.Paidy.render(message):window.dispatchEvent(new Event("resize"))}catch{}},replaceMainContent=({document:sourceDocument,url},options={})=>{const currentMain=document.querySelector("#MainContent"),sourceMain=sourceDocument.querySelector("#MainContent");if(!currentMain||!sourceMain)throw new Error("Unable to replace product content");const oldSwitcher=currentMain.querySelector(".smk-product-color-switcher"),oldSwitcherTop=oldSwitcher?oldSwitcher.getBoundingClientRect().top:null,nextMain=document.importNode(sourceMain,!0),currentPaidy=currentMain.querySelector(".product__paidy"),incomingPaidy=nextMain.querySelector(".product__paidy"),currentPaidyMessage=currentPaidy&¤tPaidy.querySelector("._paidy-promotional-messaging"),incomingPaidyMessage=incomingPaidy&&incomingPaidy.querySelector("._paidy-promotional-messaging");currentPaidy&&incomingPaidy&¤tPaidyMessage&&incomingPaidyMessage&¤tPaidyMessage.dataset.amount===incomingPaidyMessage.dataset.amount&¤tPaidyMessage.dataset.currency===incomingPaidyMessage.dataset.currency&&incomingPaidy.replaceWith(currentPaidy),syncHead(sourceDocument),currentMain.replaceWith(nextMain),options.historyMode==="push"&&window.history.pushState({...window.history.state||{},smkColorProduct:!0},"",url.href),updateContactLinks(nextMain),refreshPaidy(nextMain);const nextSwitcher=nextMain.querySelector(".smk-product-color-switcher");if(oldSwitcherTop!==null&&nextSwitcher){const offset=nextSwitcher.getBoundingClientRect().top-oldSwitcherTop;Math.abs(offset)>1&&window.scrollBy(0,offset)}nextMain.removeAttribute("aria-busy"),document.documentElement.classList.remove("smk-color-navigation-pending"),typeof options.startedAt=="number"&&(document.documentElement.dataset.smkColorLastSwapMs=String(Math.round(performance.now()-options.startedAt))),document.dispatchEvent(new CustomEvent("smk:product:changed",{detail:{url:url.href}})),schedulePrefetch()},navigate=async(href,options={})=>{const url=normalizeUrl(href),sequence=++navigationSequence,currentMain=document.querySelector("#MainContent");document.documentElement.classList.add("smk-color-navigation-pending"),currentMain&¤tMain.setAttribute("aria-busy","true");try{const page=await fetchProductPage(url.href);if(sequence!==navigationSequence)return;replaceMainContent(page,options)}catch{if(sequence!==navigationSequence)return;options.historyMode==="pop"?window.location.reload():window.location.assign(url.href)}},colorLinks=()=>Array.from(document.querySelectorAll(".smk-product-color-switcher__link")),idlePrefetchLinks=()=>{const links=colorLinks(),currentIndex=links.findIndex(link=>link.hasAttribute("aria-current"));if(currentIndex<0)return links.filter(link=>!link.hasAttribute("aria-current")).slice(0,MAX_IDLE_PREFETCH);const prioritized=[];for(let distance=1;prioritized.length<MAX_IDLE_PREFETCH&&distance<links.length;distance+=1){const next=links[currentIndex+distance],previous=links[currentIndex-distance];next&&!next.hasAttribute("aria-current")&&prioritized.push(next),previous&&!previous.hasAttribute("aria-current")&&prioritized.length<MAX_IDLE_PREFETCH&&prioritized.push(previous)}return prioritized},prefetchVisibleColors=async()=>{prefetchScheduled=!1;const connection=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(connection&&(connection.saveData||/(^|-)2g$/.test(connection.effectiveType||"")))return;const effectiveType=connection&&connection.effectiveType||"",prefetchLimit=/(^|-)3g$/.test(effectiveType)?1:MAX_IDLE_PREFETCH,urls=Array.from(new Set(idlePrefetchLinks().slice(0,prefetchLimit).map(link=>normalizeUrl(link.href).href)));let cursor=0;const worker=async()=>{for(;cursor<urls.length;){const url=urls[cursor];cursor+=1;try{await fetchProductPage(url)}catch{}}},concurrency=/(^|-)3g$/.test(effectiveType)||"ontouchstart"in window?1:2;await Promise.all(Array.from({length:Math.min(concurrency,urls.length)},worker))};function schedulePrefetch(){prefetchScheduled||(prefetchScheduled=!0,window.setTimeout(()=>{"requestIdleCallback"in window?window.requestIdleCallback(prefetchVisibleColors,{timeout:3e3}):prefetchVisibleColors()},1500))}document.addEventListener("pointerover",event=>{const link=event.target.closest(".smk-product-color-switcher__link");!link||link.hasAttribute("aria-current")||fetchProductPage(link.href).
1catch(()=>{})},{passive:!0}),document.addEventListener("focusin",event=>{const link=event.target.closest(".smk-product-color-switcher__link");!link||link.hasAttribute("aria-current")||fetchProductPage(link.href).catch(()=>{})}),document.addEventListener("touchstart",event=>{const link=event.target.closest(".smk-product-color-switcher__link");!link||link.hasAttribute("aria-current")||fetchProductPage(link.href).catch(()=>{})},{passive:!0}),document.addEventListener("click",event=>{const link=event.target.closest(".smk-product-color-switcher__link");if(!link||event.button!==0||event.metaKey||event.ctrlKey||event.shiftKey||event.altKey)return;const url=normalizeUrl(link.href);isProductUrl(url)&&(event.preventDefault(),!link.hasAttribute("aria-current")&&(colorLinks().forEach(item=>item.classList.remove("is-pending")),link.classList.add("is-pending"),navigate(url.href,{historyMode:"push",startedAt:performance.now()})))}),window.addEventListener("popstate",()=>{const url=normalizeUrl(window.location.href);if(!isProductUrl(url)){window.location.reload();return}navigate(url.href,{historyMode:"pop",startedAt:performance.now()})}),window.history.replaceState({...window.history.state||{},smkColorProduct:!0},"",window.location.href),document.documentElement.dataset.smkColorNavigation="ready",updateCacheStats(),document.readyState==="complete"?schedulePrefetch():window.addEventListener("load",schedulePrefetch,{once:!0}),window.SmkProductColorNavigation={prefetch:fetchProductPage,navigate,get cacheSize(){return cache.size}}})(); 2//# sourceMappingURL=/cdn/shop/t/27/assets/smk-product-color-navigation.js.map?v=1561934666951108991786948921
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.