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