!function(){"use strict";function t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class e extends GP.Component{constructor(){super(),t(this,"moneyFormat",void 0),t(this,"getSetting",()=>this.getState("setting")),t(this,"getShopLocale",()=>this.getState("locale")),t(this,"getShopCurrency",()=>this.getState("currency")),t(this,"getPriceText",t=>{var e,i,l;let{customContent:n}=null!==(e=this.getSetting())&&void 0!==e?e:{},r=null!==(i=null==t?void 0:t.price)&&void 0!==i?i:0,a=null!==(l=null==t?void 0:t.compare_at_price)&&void 0!==l?l:0,o=a-r,u=window.Shopify.formatMoney(`${o<0?0:o}`,this.moneyFormat);if(!a||!r)return`${null==n?void 0:n.prefix} ${(null==n?void 0:n.unit)==="percentage"?"0%":u} ${null==n?void 0:n.suffix}`;if((null==n?void 0:n.unit)==="percentage"){let t=Math.round(o/(a/100));return`${null==n?void 0:n.prefix} ${t<0?0:t}% ${null==n?void 0:n.suffix}`}return`${null==n?void 0:n.prefix} ${u} ${null==n?void 0:n.suffix}`});let e=this.getState("id");this.moneyFormat=this.getState("moneyFormat"),this.subscribeContext((t,i)=>{if(t.variantSelected!==i.variantSelected){let i=`#p-tag-${e} [data-gp-text]`;if(!t.variantSelected){this.dataset.disabled="true";let t=this.getPriceText(null),e=this.querySelector(i);e&&(e.innerHTML=t)}if(t.variantSelected){var l,n,r,a;let e=null!==(r=null===(l=t.variantSelected)||void 0===l?void 0:l.price)&&void 0!==r?r:0,o=null!==(a=null===(n=t.variantSelected)||void 0===n?void 0:n.compare_at_price)&&void 0!==a?a:0;o<=0||0>=Math.round((o-e)/(o/100))?this.dataset.disabled="true":this.dataset.disabled="false";let u=this.getPriceText(t.variantSelected),d=this.querySelector(i);d&&(d.innerHTML=u)}}})}}customElements.get("gp-product-tag")||customElements.define("gp-product-tag",e)}();
