import{proxyCustomElement,HTMLElement,h,Host,Fragment}from"@stencil/core/internal/client";import{i as intervalString}from"./price.js";import{d as defineCustomElement$3}from"./sc-format-number2.js";import{d as defineCustomElement$2}from"./sc-tag2.js";import{d as defineCustomElement$1}from"./sc-visually-hidden2.js";const scPriceCss=":host{display:block}.price{display:inline-flex;flex-direction:column;gap:var(--sc-spacing-xxx-small);text-align:var(--sc-product-price-alignment, left);justify-content:var(--sc-product-price-alignment, left)}.price__amounts{display:inline-flex;flex-wrap:wrap;align-items:baseline;gap:var(--sc-spacing-xx-small);justify-content:var(--sc-product-price-alignment, left);text-align:var(--sc-product-price-alignment, left)}.price__scratch{text-decoration:line-through;opacity:0.75}.price__interval{font-size:min(var(--sc-font-size-small), 16px);opacity:0.75}.price__details{font-size:min(var(--sc-font-size-small), 16px);opacity:0.75}.price__sale-badge{font-size:min(1em, 14px);align-self:center}",ScPriceStyle0=scPriceCss,ScProductPrice=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.currency=void 0,this.amount=void 0,this.scratchAmount=void 0,this.scratchDisplayAmount=void 0,this.displayAmount=void 0,this.saleText=void 0,this.adHoc=void 0,this.recurringPeriodCount=void 0,this.recurringIntervalCount=void 0,this.recurringInterval=void 0,this.setupFeeAmount=void 0,this.setupFeeText=void 0,this.trialDurationDays=void 0,this.setupFeeName=void 0}render(){return this.adHoc?h(Host,{role:"paragraph"},wp.i18n.__("Custom Amount","surecart")):h(Host,{role:"paragraph"},h("div",{class:"price",id:"price"},h("div",{class:"price__amounts"},!!this.scratchAmount&&this.scratchAmount!==this.amount&&h(Fragment,null,0===this.scratchAmount?wp.i18n.__("Free","surecart"):h(Fragment,null,h("sc-visually-hidden",null,wp.i18n.__("The price was","surecart")," "),this.scratchDisplayAmount?h("span",{class:"price__scratch"},this.scratchDisplayAmount):h("sc-format-number",{class:"price__scratch",part:"price__scratch",type:"currency",currency:this.currency,value:this.scratchAmount}),h("sc-visually-hidden",null," ",wp.i18n.__("now discounted to","surecart")))),0===this.amount?wp.i18n.__("Free","surecart"):this.displayAmount?this.displayAmount:h("sc-format-number",{class:"price__amount",type:"currency",value:this.amount,currency:this.currency}),h("div",{class:"price__interval"},this.recurringPeriodCount&&1<this.recurringPeriodCount&&h("sc-visually-hidden",null," ",wp.i18n.__("This is a repeating price. Payment will happen","surecart")," ",intervalString({recurring_interval_count:this.recurringIntervalCount,recurring_interval:this.recurringInterval,recurring_period_count:this.recurringPeriodCount},{showOnce:!0,abbreviate:!1,labels:{interval:wp.i18n.__("every","surecart"),period:
/** translators: used as in time period: "for 3 months" */
wp.i18n.__("for","surecart")}})),h("span",{"aria-hidden":"true"},intervalString({recurring_interval_count:this.recurringIntervalCount,recurring_interval:this.recurringInterval,recurring_period_count:this.recurringPeriodCount},{showOnce:!0,abbreviate:!1,labels:{interval:"/",period:
/** translators: used as in time period: "for 3 months" */
wp.i18n.__("for","surecart")}}))),!!this.scratchAmount&&h("sc-tag",{type:"primary",pill:!0,class:"price__sale-badge"},this.saleText||h(Fragment,null,h("sc-visually-hidden",null,wp.i18n.__("This product is available for sale.","surecart")," "),h("span",{"aria-hidden":"true"},wp.i18n.__("Sale","surecart"))))),(!!(null==this?void 0:this.trialDurationDays)||!!(null==this?void 0:this.setupFeeAmount))&&h("div",{class:"price__details"},!!(null==this?void 0:this.trialDurationDays)&&h(Fragment,null,h("sc-visually-hidden",null,wp.i18n.sprintf(wp.i18n.__("You have a %d-day trial before payment becomes necessary.","surecart"),null==this?void 0:this.trialDurationDays)),h("span",{class:"price__trial","aria-hidden":"true"},wp.i18n.sprintf(wp.i18n._n("Starting in %s day.","Starting in %s days.",null==this?void 0:this.trialDurationDays,"surecart"),null==this?void 0:this.trialDurationDays))),!!(null==this?void 0:this.setupFeeAmount)&&h("span",{class:"price__setup-fee"},h("sc-visually-hidden",null,wp.i18n.__("This product has","surecart")," ")," ",this.setupFeeText?this.setupFeeText:h(Fragment,null,h("sc-format-number",{type:"currency",value:null==this?void 0:this.setupFeeAmount,currency:this.currency}),(null==this?void 0:this.setupFeeName)||wp.i18n.__("Setup Fee","surecart"))))))}static get style(){return ScPriceStyle0}},[1,"sc-price",{currency:[1],amount:[2],scratchAmount:[2,"scratch-amount"],scratchDisplayAmount:[1,"scratch-display-amount"],displayAmount:[1,"display-amount"],saleText:[1,"sale-text"],adHoc:[4,"ad-hoc"],recurringPeriodCount:[2,"recurring-period-count"],recurringIntervalCount:[2,"recurring-interval-count"],recurringInterval:[1,"recurring-interval"],setupFeeAmount:[2,"setup-fee-amount"],setupFeeText:[1,"setup-fee-text"],trialDurationDays:[2,"trial-duration-days"],setupFeeName:[1,"setup-fee-name"]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["sc-price","sc-format-number","sc-tag","sc-visually-hidden"].forEach((e=>{switch(e){case"sc-price":customElements.get(e)||customElements.define(e,ScProductPrice);break;case"sc-format-number":customElements.get(e)||defineCustomElement$3();break;case"sc-tag":customElements.get(e)||defineCustomElement$2();break;case"sc-visually-hidden":customElements.get(e)||defineCustomElement$1()}}))}export{ScProductPrice as S,defineCustomElement as d};