import{r as t,h as i,H as e,a as o}from"./p-e97fde0a.js";import{a as s,d as a,s as r}from"./p-53e7f7d7.js";import"./p-03631502.js";import"./p-9dbc54d6.js";import"./p-d3366af3.js";import"./p-401e165e.js";import"./p-830ab1a3.js";import"./p-ec182234.js";import"./p-3f6362a4.js";import"./p-95325ec5.js";import"./p-4df6e0c5.js";const c=":host{display:inline-block;vertical-align:middle;line-height:1}::slotted(*){display:block !important;line-height:1}.cart__button{padding:0 4px;height:100%;display:grid;align-items:center}.cart__content{position:relative}.cart__count{box-sizing:border-box;position:absolute;inset:-12px -16px auto auto;text-align:center;font-size:10px;font-weight:bold;border-radius:var(--sc-cart-icon-counter-border-radius, 9999px);color:var(--sc-cart-icon-counter-color, var(--sc-color-primary-text, var(--sc-color-white)));background:var(--sc-cart-icon-counter-background, var(--sc-color-primary-500));box-shadow:var(--sc-cart-icon-box-shadow, var(--sc-shadow-x-large));padding:2px 6px;line-height:14px;min-width:14px;z-index:1}.cart__icon{font-size:var(--sc-cart-icon-size, 1.1em);cursor:pointer}.cart__icon sc-icon{display:block}";const n=c;const d=class{constructor(i){t(this,i);this.open=null;this.count=0;this.formId=undefined;this.mode="live";this.cartMenuAlwaysShown=true;this.showEmptyCount=false}getItemsCount(){var t,i;const e=(i=(t=r===null||r===void 0?void 0:r.checkout)===null||t===void 0?void 0:t.line_items)===null||i===void 0?void 0:i.data;let o=0;(e||[]).forEach((t=>{o=o+(t===null||t===void 0?void 0:t.quantity)}));return o}componentDidLoad(){this.link=this.el.closest("a");this.link.addEventListener("click",(t=>{t.preventDefault();t.stopImmediatePropagation();s.state.cart={...s.state.cart,open:!s.state.cart.open};return false}));this.handleParentLinkDisplay();a(this.mode,(()=>this.handleParentLinkDisplay()))}handleParentLinkDisplay(){this.link.style.display=!this.cartMenuAlwaysShown&&!this.getItemsCount()?"none":null}render(){return i(e,{key:"ee0061e65293ec1bef40f1d28274249b70a6bc9b",tabindex:0,role:"button","aria-label":wp.i18n.sprintf(wp.i18n.__("Open Cart Menu Icon with %d items.","surecart"),this.getItemsCount()),onKeyDown:t=>{if("Enter"===(t===null||t===void 0?void 0:t.code)||"Space"===(t===null||t===void 0?void 0:t.code)){s.state.cart={...s.state.cart,open:!s.state.cart.open};t.preventDefault()}}},i("div",{key:"76ee51bc6bb47d33eefc711f433103dcd4b2b6c4",class:"cart__button",part:"base"},i("div",{key:"70ff0a08813d894e4e4eec0e2bf35f4597285f2b",class:"cart__content"},(this.showEmptyCount||!!this.getItemsCount())&&i("span",{key:"0187458c305d4d643e7cb854ce6bff648a9b8269",class:"cart__count",part:"count"},this.getItemsCount()),i("div",{key:"703006c400629df69914afab4f8bb20d03a4574a",class:"cart__icon"},i("slot",{key:"3e0443b4837e4ff0d7f9dc3506496204026b45d6"})))))}get el(){return o(this)}};d.style=n;export{d as sc_cart_button};
//# sourceMappingURL=p-4e8225e4.entry.js.map