1class ProductLabels extends HTMLElement{constructor(){super(),this.productLabelsConfigs=JSON.parse(document.querySelector("[data-product-labels]")?.innerHTML),this.productLabels=this.productLabelsConfigs.labels,this.product={id:this.getAttribute("data-product-id"),collections:this.getAttribute("data-product-collections").split(","),price:parseInt(this.getAttribute("data-product-price")??0),compare_at_price:parseInt(this.getAttribute("data-product-compare-at-price")??0)}}connectedCallback(){const product=this.product;this.productLabels.forEach(label=>this.renderProductLabel(product,label))}renderProductLabel(product,label){const id=label.id;let text=label.text,has_reduction=!1;if(label.is_reduction_label&&(product.compare_at_price>product.price&&(has_reduction=!0),has_reduction))switch(!0){case/\[percent\]/.test(text):const percent=100/product.compare_at_price*(product.compare_at_price-product.price);text=text.replace("[percent]",percent.toFixed(0)+"%");break;case/\[amount\]/.test(text):const amount=product.compare_at_price/100-product.price/100,money=Intl.NumberFormat("en",{style:"currency",currency:window.Shopify.currency.active}).format(0)[0]+amount.toFixed(2).replace(".",",");text=text.replace("[amount]",money);break;default:break}const active=label.active,show_on_desktop=label.show_on_desktop,show_on_mobile=label.show_on_mobile,image=label.image,text_color=label.text_color,bg_color=label.bg_color,is_bold=label.is_bold,link=label.link,current_product_id=product.id,current_product_collections=product.collections,label_only_for_products=label.label_products,label_only_for_collections=label.label_collections;if(!active)return;if(Object.keys(label_only_for_products).length>0){var matching_product=!1;label_only_for_products.forEach(product2=>{product2.id==current_product_id&&(matching_product=!0)})}if(Object.keys(label_only_for_collections).length>0){var matching_collection=!1;label_only_for_collections.forEach(collection=>{current_product_collections.forEach(col=>{col==collection.handle&&(matching_collection=!0)})})}if(label.is_reduction_label){if(!has_reduction||(Object.keys(label_only_for_collections).length>0||Object.keys(label_only_for_products).length>0)&&!matching_product&&!matching_collection)return}else if(!matching_product&&!matching_collection)return;const labelWrapper=document.createElement("div");labelWrapper.setAttribute("data-label-id",id),show_on_desktop?labelWrapper.classList.contains("desktop-hidden")&&labelWrapper.classList.remove("desktop-hidden"):labelWrapper.classList.add("desktop-hidden"),show_on_mobile?labelWrapper.classList.contains("mobile-hidden")&&labelWrapper.classList.remove("mobile-hidden"):labelWrapper.classList.add("mobile-hidden");const labelEl=document.createElement("span");if(labelEl.setAttribute("data-label-id",id),image){const imageEl=document.createElement("img");imageEl.setAttribute("loading","lazy"),imageEl.setAttribute("src",image),labelEl.appendChild(imageEl)}else labelEl.style.color=text_color,labelEl.style.backgroundColor=bg_color,labelEl.innerText=text;if(is_bold&&(labelEl.style.fontWeight="bold"),link){const linkEl=document.createElement("a");linkEl.setAttribute("href",link),linkEl.appendChild(labelEl),labelWrapper.appendChild(linkEl)}else labelWrapper.appendChild(labelEl);this.appendChild(labelWrapper)}}customElements.define("product-labels",ProductLabels); 2//# sourceMappingURL=/cdn/shop/t/99/assets/custom-product-labels.js.map?v=3525372503832435421741783404
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.