import{Fragment,h}from"@stencil/core";import{state}from"../../../../store/product/index";import{isOptionMissing,isOptionSoldOut}from"../../../../store/product/getters";import{__,sprintf}from"@wordpress/i18n";import{setProduct}from"../../../../store/product/setters";export class ScProductPillsVariantOption{constructor(){this.label=void 0,this.optionNumber=1,this.productId=void 0}render(){return h("sc-form-control",{key:"f1c78f2082f946c68b432c063907082cbe22d69f",label:this.label},h("span",{key:"fddfbc7e181a541a90384c5795be4244c21d21c7",slot:"label"},this.label),h("div",{key:"572ea81173ead6249640aa77a833cfc81290f257",class:"sc-product-pills-variant-option__wrapper"},(state[this.productId].variant_options[this.optionNumber-1].values||[]).map((t=>{const e=isOptionSoldOut(this.productId,this.optionNumber,t)||isOptionMissing(this.productId,this.optionNumber,t);return h("sc-pill-option",{isUnavailable:e,isSelected:state[this.productId].variantValues[`option_${this.optionNumber}`]===t,onClick:()=>setProduct(this.productId,{variantValues:{...state[this.productId].variantValues,[`option_${this.optionNumber}`]:t}})},h("span",{"aria-hidden":"true"},t),h("sc-visually-hidden",null,sprintf(__("Select %s: %s.","surecart"),this.label,t),e&&h(Fragment,null," ",__("(option unavailable)","surecart")),state[this.productId].variantValues[`option_${this.optionNumber}`]===t&&h(Fragment,null," ",__("This option is currently selected.","surecart"))))}))))}static get is(){return"sc-product-pills-variant-option"}static get originalStyleUrls(){return{$:["sc-product-pills-variant-option.scss"]}}static get styleUrls(){return{$:["sc-product-pills-variant-option.css"]}}static get properties(){return{label:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Label"},attribute:"label",reflect:!1},optionNumber:{type:"number",mutable:!1,complexType:{original:"1 | 2 | 3",resolved:"1 | 2 | 3",references:{}},required:!1,optional:!1,docs:{tags:[],text:"Which option number?"},attribute:"option-number",reflect:!1,defaultValue:"1"},productId:{type:"string",mutable:!1,complexType:{original:"string",resolved:"string",references:{}},required:!1,optional:!1,docs:{tags:[],text:"The product id"},attribute:"product-id",reflect:!1}}}}