1const ALGOLIA_INSIGHTS_ENDPOINT="https://insights.algolia.io/1/events",ALGOLIA_USER_TOKEN_KEY="lyleAlgoliaUserToken";let fallbackUserToken="";export function algoliaUserToken(){try{const existing=localStorage.getItem(ALGOLIA_USER_TOKEN_KEY);if(existing)return existing;const token=createUserToken();return localStorage.setItem(ALGOLIA_USER_TOKEN_KEY,token),token}catch{return fallbackUserToken||=createUserToken(),fallbackUserToken}}export function createMoneyFormatter({currencyCode,language}){try{return new Intl.NumberFormat(language||void 0,{style:"currency",currency:currencyCode})}catch{return null}}export function escapeAttribute(value){return escapeHtml(value).replace(/`/g,"`")}export function escapeHtml(value){return String(value??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export function formatMoney(value,{currencySymbol="",formatter=null}={}){const amount=Number(value||0);return formatter?formatter.format(amount):`${currencySymbol}${amount.toFixed(2)}`}export function trackAlgoliaProductClick(config,index,element){return trackAlgoliaProductEvent({config,element,eventName:"Product Clicked",eventType:"click",index})}export function trackAlgoliaProductConversion(config,index,element){return trackAlgoliaProductEvent({config,element,eventName:"Product Added to Cart",eventType:"conversion",index})}export function hiddenSaleLineItemProperties(tags=[]){return typeof document>"u"||!document.cookie.includes(`${encodeURIComponent("ls-can-view-hidden-sale")}=`)?{}:tags.reduce((properties,tag)=>{if(!tag.startsWith("vip-price-"))return properties;const separator=tag.indexOf(":"),currency=tag.slice(10,separator).trim(),price=Number(tag.slice(separator+1).trim());return separator>10&¤cy&&Number.isFinite(price)&&(properties[`_hidden_sale_price_${currency}`]=price),properties},{})}export function imageUrl(image,width){const src=image?.src||"";if(!src)return"";try{const url=new URL(src,window.location.origin);return url.searchParams.set("width",String(width)),url.toString()}catch{const separator=src.includes("?")?"&":"?";return`${src}${separator}width=${width}`}}export function isSameProduct(productA,productB){return String(productA?.id||"")===String(productB?.id||"")||!!productA?.handle&&productA.handle===productB?.handle}export function isWhiteSwatch(color){const value=String(color||"").trim().toLowerCase();return value==="#fff"||value==="#ffffff"}export function parseSwatchColour(colour){if(!colour)return null;const normalised=String(colour).trim().toLowerCase();if(normalised.startsWith("#")){let hex=normalised.slice(1);return hex.length===3&&(hex=hex.split("").map(character=>character+character).join("")),hex.length!==6?null:{r:parseInt(hex.slice(0,2),16),g:parseInt(hex.slice(2,4),16),b:parseInt(hex.slice(4,6),16)}}const rgbMatch=normalised.match(/rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/);return rgbMatch?{r:parseInt(rgbMatch[1],10),g:parseInt(rgbMatch[2],10),b:parseInt(rgbMatch[3],10)}:null}export function getRelativeLuminance({r,g,b}){const channel=value=>{const normalised=value/255;return normalised<=.03928?normalised/12.92:((normalised+.055)/1.055)**2.4};return .2126*channel(r)+.7152*channel(g)+.0722*channel(b)}export function isLightSwatchColour(colour){const rgb=parseSwatchColour(colour);return rgb?getRelativeLuminance(rgb)>=.7:!1}export function isSwatchSoldOut(swatch,selectedOptionValues=[]){if(!swatch)return!1;const selectedSize=selectedSizeValue(swatch,selectedOptionValues);if(selectedSize){const stock=sizeStockValue(swatch,selectedSize);if(stock!==void 0)return Number(stock)===0;if(Array.isArray(swatch.sizesAvailable))return swatch.sizesAvailable.length===0?hasSizeChart(swatch)||isProductUnavailable(swatch):!swatch.sizesAvailable.includes(selectedSize);const matchingVariant=findVariantForSize(swatch,selectedSize);return matchingVariant?!isVariantAvailable(matchingVariant):hasSizeInventoryData(swatch)?!0:isProductUnavailable(swatch)}if(isProductUnavailable(swatch)||isSizeStockFullySoldOut(swatch)||isSizesAvailableEmpty(swatch))return!0;const variants=swatch.variants;return!!(variants?.length&&variants.every(variant=>!isVariantAvailable(variant)))}function isProductUnavailable(swatch){const value=swatch?.available;return value===!1||value==="false"||value===0}function isVariantAvailable(variant){if(!variant)return!1;const value=variant.available;return value===!1||value==="false"||value===0?!1:value===!0||value==="true"?!0:typeof variant.inventory_quantity=="number"?variant.inventory_quantity>0:!!value}function selectedSizeValue(swatch,selectedOptionValues){if(!selectedOptionValues?.length)return"";const sizeStock=swatch?.sizeStock;if(sizeStock&&typeof sizeStock=="object"){for(const value of selectedOptionValues)if(Object.prototype.hasOwnProperty.call(sizeStock,value))return value}const sizeChart=[...Array.isArray(swatch?.sizes)?swatch.sizes:[],...Array.isArray(swatch?.sizesAvailable)?swatch.sizesAvailable:[]];for(const value of selectedOptionValues)if(sizeChart.includes(value))return value;for(const variant of swatch?.variants||[]){const values=variantOptionValues(variant);for(const value of selectedOptionValues)if(values.includes(value))return value}return selectedOptionValues[0]||""}function sizeStockValue(swatch,size){const sizeStock=swatch?.sizeStock;if(!(!sizeStock||typeof sizeStock!="object")&&Object.prototype.hasOwnProperty.call(sizeStock,size))return sizeStock[size]}function isSizeStockFullySoldOut(swatch){const sizeStock=swatch?.sizeStock;if(!sizeStock||typeof sizeStock!="object")return!1;const stocks=Object.values(sizeStock);return stocks.length>0&&stocks.every(stock=>Number(stock)===0)}function isSizesAvailableEmpty(swatch){return!Array.isArray(swatch?.sizesAvailable)||swatch.sizesAvailable.length>0?!1:hasSizeChart(swatch)}function hasSizeChart(swatch){return!!(Array.isArray(swatch?.sizes)&&swatch.sizes.length>0||swatch?.sizeStock&&Object.keys(swatch.sizeStock).length>0||swatch?.variants?.length)}function hasSizeInventoryData(swatch){return!!(swatch?.sizeStock&&Object.keys(swatch.sizeStock).length>0||swatch?.sizes?.length||swatch?.sizesAvailable?.length||swatch?.variants?.length)}function findVariantForSize(swatch,size){return(swatch?.variants||[]).find(variant=>variantLabel(variant)===size?!0:variantOptionValues(variant).includes(size))}function variantOptionValues(variant){if(variant?.selectedOptions?.length)return variant.selectedOptions.map(option=>
1option.value).filter(Boolean);if(Array.isArray(variant?.options))return variant.options.filter(Boolean);if(variant?.option1)return[variant.option1,variant.option2,variant.option3].filter(Boolean);if(variant?.title&&variant.title!=="Default Title")return variant.title.split(" / ").map(part=>part.trim());const label=variantLabel(variant);return label?[label]:[]}export function metafieldValue(product,name){return product?.metafields?.find(field=>field?.name===name||field?.key===name)?.value||""}export function numericId(id){return String(id||"").split("/").pop()}export function parseJson(value){if(!value)return null;try{return JSON.parse(value)}catch{return null}}export function variantLabel(variant){return variant?.displayOption||variant?.selectedOptions?.[0]?.value||variant?.title||""}function createUserToken(){return globalThis.crypto?.randomUUID?.()||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}async function trackAlgoliaProductEvent({config,element,eventName,eventType,index}){const objectID=element?.dataset.objectId,resolvedIndex=element?.closest("[data-product-card]")?.dataset.algoliaIndex||index;if(!objectID||!resolvedIndex||!config?.algolia?.appId||!config.algolia.apiKey)return;const event={eventName,eventType,index:resolvedIndex,objectIDs:[objectID],userToken:algoliaUserToken()};element.dataset.queryId&&(event.queryID=element.dataset.queryId),eventType==="click"&&Number(element.dataset.position)>0&&(event.positions=[Number(element.dataset.position)]);try{await fetch(ALGOLIA_INSIGHTS_ENDPOINT,{method:"POST",headers:{"Content-Type":"application/json","X-Algolia-API-Key":config.algolia.apiKey,"X-Algolia-Application-Id":config.algolia.appId},body:JSON.stringify({events:[event]}),keepalive:!0})}catch{return}} 2//# sourceMappingURL=/cdn/shop/t/458/assets/algolia-product-utils.js.map?v=45073705369143770561788364386
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.