import{r as i,h as e}from"./p-e97fde0a.js";import{g as t}from"./p-93127aa7.js";import{a as o}from"./p-401e165e.js";const a=":host{display:block}.sc-product-variation-choice-wrap{display:flex;flex-direction:column;gap:var(--sc-variation-gap, 12px)}";const s=a;const n=class{constructor(e){i(this,e);this.heading=undefined;this.product=undefined;this.price=undefined;this.subscription=undefined;this.busy=false;this.variantValues=[];this.handleSubmit=this.handleSubmit.bind(this)}componentWillLoad(){var i;this.variantValues=(i=this.subscription)===null||i===void 0?void 0:i.variant_options}async handleSubmit(){var i,e,a,s;this.busy=true;const n=t({variants:(e=(i=this.product)===null||i===void 0?void 0:i.variants)===null||e===void 0?void 0:e.data,values:this.variantValues});if((a=this.price)===null||a===void 0?void 0:a.ad_hoc){return window.location.assign(o(window.location.href,{action:"confirm_amount",price_id:(s=this.price)===null||s===void 0?void 0:s.id,variant:n===null||n===void 0?void 0:n.id}))}return window.location.assign(o(window.location.href,{action:"confirm",variant:n===null||n===void 0?void 0:n.id}))}buttonText(){var i,e,t,o;if((i=this.price)===null||i===void 0?void 0:i.ad_hoc){if(((e=this.price)===null||e===void 0?void 0:e.id)===((o=(t=this.subscription)===null||t===void 0?void 0:t.price)===null||o===void 0?void 0:o.id)){return wp.i18n.__("Update Amount","surecart")}return wp.i18n.__("Choose Amount","surecart")}return wp.i18n.__("Next","surecart")}render(){var i,t;return e("sc-dashboard-module",{key:"4402b00b493dadd56991b26fa552f6384dba6720",heading:this.heading||wp.i18n.__("Enter An Amount","surecart"),class:"subscription-switch"},e("sc-card",{key:"c04edf5fd9238472c1a79642d8756a692239d1ae"},e("sc-form",{key:"83238ef57e3b388bd828e56ac7c57b0d733aa4db",onScSubmit:this.handleSubmit},e("div",{key:"a0d8c947f12262c7ab7fd48b8fe445326b73f053",class:"sc-product-variation-choice-wrap"},(((t=(i=this.product)===null||i===void 0?void 0:i.variant_options)===null||t===void 0?void 0:t.data)||[]).map((({name:i,values:t,id:o},a)=>{var s,n;return e("sc-select",{exportparts:"base:select__base, input, form-control, label, help-text, trigger, panel, caret, menu__base, spinner__base, empty",part:"name__input",value:((n=(s=this.subscription)===null||s===void 0?void 0:s.variant_options)===null||n===void 0?void 0:n[a])||"",onScChange:i=>{this.variantValues[a]=i.detail.value},label:i,choices:t===null||t===void 0?void 0:t.map((i=>({label:i,value:i}))),unselect:false,key:o})}))),e("sc-button",{key:"ae33d7f2eb9788f952dbfa5faee6fca1fe45380e",type:"primary",full:true,submit:true,loading:this.busy},this.buttonText()," ",e("sc-icon",{key:"f1cd8ef26168282bd3e015791259608b9c7946ec",name:"arrow-right",slot:"suffix"})))),this.busy&&e("sc-block-ui",{key:"344bbc679bc86bdd483184cbe35817dbb43f54a0",style:{zIndex:"9"}}))}};n.style=s;export{n as sc_subscription_variation_confirm};
//# sourceMappingURL=p-a79e494e.entry.js.map