import{r as t,h as i,H as o,a as s}from"./p-9add63ef.js";import{g as a,s as n,a as d,b as e}from"./p-bd4f636c.js";import{s as c,b as r,o as u,i as p,c as l}from"./p-b3860daf.js";import"./p-1282ed4a.js";import"./p-2b28ea49.js";import"./p-dd24e53c.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-31faf2b8.js";import"./p-610295e2.js";import"./p-0646489c.js";import"./p-78468e45.js";import"./p-c1ecac8a.js";import"./p-445fd8b4.js";import"./p-259c3935.js";import"./p-13f5e4e1.js";import"./p-fb28f84f.js";const b="sc-product-buy-button{position:relative}sc-product-buy-button a.wp-block-button__link{position:relative;text-decoration:none}sc-product-buy-button .sc-block-button--sold-out,sc-product-buy-button .sc-block-button--unavailable{display:none !important}sc-product-buy-button.is-unavailable a{display:none !important}sc-product-buy-button.is-unavailable .sc-block-button--unavailable{display:initial !important}sc-product-buy-button.is-sold-out a{display:none !important}sc-product-buy-button.is-sold-out .sc-block-button--sold-out{display:initial !important}sc-product-buy-button sc-spinner::part(base){--indicator-color:currentColor;--spinner-size:12px;position:absolute;top:calc(50% - var(--spinner-size) + var(--spinner-size) / 4);left:calc(50% - var(--spinner-size) + var(--spinner-size) / 4)}sc-product-buy-button [data-text],sc-product-buy-button [data-loader]{transition:opacity var(--sc-transition-fast) ease-in-out, visibility var(--sc-transition-fast) ease-in-out}sc-product-buy-button [data-loader]{opacity:0;visibility:hidden}sc-product-buy-button.is-disabled{pointer-events:none}sc-product-buy-button.is-busy [data-text]{opacity:0;visibility:hidden}sc-product-buy-button.is-busy [data-loader]{opacity:1;visibility:visible}sc-product-buy-button sc-alert{margin-bottom:var(--sc-spacing-medium)}sc-product-buy-button.is-out-of-stock [data-text]{opacity:0.6}";const v=b;const h=class{constructor(i){t(this,i);this.addToCart=undefined;this.productId=undefined;this.formId=undefined;this.mode="live";this.checkoutLink=undefined;this.error=undefined}async handleCartClick(t){var i,o,s,d,e;t.preventDefault();console.log(t);if((i=c[this.productId])===null||i===void 0?void 0:i.busy)return;if((s=(o=c[this.productId])===null||o===void 0?void 0:o.selectedPrice)===null||s===void 0?void 0:s.ad_hoc){r(this.productId,{dialog:this.addToCart?"ad_hoc_cart":"ad_hoc_buy"});return}if(!this.addToCart){const t=(e=(d=window===null||window===void 0?void 0:window.scData)===null||d===void 0?void 0:d.pages)===null||e===void 0?void 0:e.checkout;if(!t)return;return window.location.assign(a(this.productId,t,{no_cart:!this.addToCart}))}try{await n(this.productId)}catch(t){console.error(t);this.error=t}}componentDidLoad(){this.link=this.el.querySelector("a");this.updateProductLink();u(this.productId,(()=>this.updateProductLink()))}updateProductLink(){var t,i;const o=(i=(t=window===null||window===void 0?void 0:window.scData)===null||t===void 0?void 0:t.pages)===null||i===void 0?void 0:i.checkout;if(!o||!this.link)return;this.link.href=a(this.productId,o,!this.addToCart?{no_cart:true}:{})}render(){var t,s;return i(o,{key:"c442ebf91769db5b2a48715cac1776ba68a19416",class:{"is-busy":((t=c[this.productId])===null||t===void 0?void 0:t.busy)&&!!this.addToCart,"is-disabled":(s=c[this.productId])===null||s===void 0?void 0:s.disabled,"is-sold-out":p(this.productId)&&!l(this.productId),"is-unavailable":l(this.productId)},onClick:t=>this.handleCartClick(t)},!!this.error&&i("sc-alert",{key:"9daa185d3276c7e0cb152eda6d6bd54b0c7d11e6",onClick:t=>{t.stopPropagation()},type:"danger",scrollOnOpen:true,open:!!this.error,closable:false},!!d(this.error)&&i("span",{key:"ad1c1ccb753da64c5fd4c956b0ddb4a12a5a5b52",slot:"title",innerHTML:d(this.error)}),(e(this.error)||[]).map(((t,o)=>i("div",{innerHTML:t,key:o})))),i("slot",{key:"ee46a642601529da83f2e0cc1aa7458b2501dd95"}))}get el(){return s(this)}};h.style=v;export{h as sc_product_buy_button};
//# sourceMappingURL=p-6a4e8085.entry.js.map