import*as t from"@wordpress/interactivity";var e={1064:t=>{t.exports=import("@woocommerce/stores/woocommerce/cart")}},o={};function n(t){var a=o[t];if(void 0!==a)return a.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,n),r.exports}n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const a=(i={getContext:()=>t.getContext,store:()=>t.store,useLayoutEffect:()=>t.useLayoutEffect},s={},n.d(s,i),s),r="I acknowledge that using a private store means my plugin will inevitably break on the next store release.";var i,s,c=function(t){return t.IDLE="IDLE",t.SLIDE_OUT="SLIDE-OUT",t.SLIDE_IN="SLIDE-IN",t}(c||{});const{state:u}=(0,a.store)("woocommerce",{},{lock:r}),{state:d}=(0,a.store)("woocommerce/add-to-cart-with-options",{},{lock:r}),m={state:{get quantity(){const t=u.cart?.items.find((t=>t.id===p.productId));return t?.quantity||0},get slideInAnimation(){const{animationStatus:t}=(0,a.getContext)();return t===c.SLIDE_IN},get slideOutAnimation(){const{animationStatus:t}=(0,a.getContext)();return t===c.SLIDE_OUT},get addToCartText(){const{animationStatus:t,tempQuantity:e,addToCartText:o,productType:n,groupedProductIds:r,hasPressedButton:i}=(0,a.getContext)(),s=t===c.IDLE||t===c.SLIDE_OUT?e||0:p.quantity;if("grouped"===n){const t=r?.map((t=>{const e=u.cart?.items.find((e=>e.id===t));return e?.quantity||0}));return t?.some((t=>t>0))&&i?p.inTheCartText:o}return s>0?p.inTheCartText.replace("###",s.toString()):o},get displayViewCart(){const{displayViewCart:t}=(0,a.getContext)();return!!t&&p.quantity>0},get productId(){return d?.variationId||(0,a.getContext)().productId}},actions:{*addCartItem(){const t=(0,a.getContext)();yield Promise.resolve().then(n.bind(n,1064));const{actions:e}=(0,a.store)("woocommerce",{},{lock:r});yield e.addCartItem({id:p.productId,quantity:p.quantity+t.quantityToAdd}),t.displayViewCart=!0},*refreshCartItems(){yield Promise.resolve().then(n.bind(n,1064));const{actions:t}=(0,a.store)("woocommerce",{},{lock:r});t.refreshCartItems()},handleAnimationEnd(t){const e=(0,a.getContext)();"slideOut"===t.animationName?e.animationStatus=c.SLIDE_IN:"slideIn"===t.animationName&&(e.tempQuantity=p.quantity,e.animationStatus=c.IDLE)},handlePressedState(){(0,a.getContext)().hasPressedButton=!0}},callbacks:{syncTempQuantityOnLoad(){const t=(0,a.getContext)();(0,a.useLayoutEffect)((()=>{t.tempQuantity=p.quantity}),[])},startAnimation(){const t=(0,a.getContext)();t.tempQuantity!==p.quantity&&t.animationStatus===c.IDLE&&(t.animationStatus=c.SLIDE_OUT)}}},{state:p}=(0,a.store)("woocommerce/product-button",m,{lock:!0});