import*as t from"@woocommerce/stores/woocommerce/cart";import*as e from"@wordpress/interactivity";import*as o from"@woocommerce/stores/woocommerce/products";var r={1401:e=>{e.exports=t}},i={};function s(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return r[t](o,o.exports,s),o.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const a=(n={getConfig:()=>e.getConfig,getContext:()=>e.getContext,store:()=>e.store},d={},s.d(d,n),d);var n,d;s.d({},{});const c="I acknowledge that using a private store means my plugin will inevitably break on the next store release.",{state:u}=(0,a.store)("woocommerce/products",{},{lock:c}),{actions:m}=(0,a.store)("woocommerce/add-to-cart-with-options",{actions:{validateGroupedProductQuantity(){m.clearErrors("invalid-quantities");const{errorMessages:t}=(0,a.getConfig)(),e=(0,a.getContext)();Object.values(e.quantity).some(t=>t>0)?Object.entries(e.quantity).some(([t,o])=>{const r=u.findProduct({id:Number(t),selectedAttributes:e.selectedAttributes});if(!r)return!1;const{minimum:i,maximum:s}=r.add_to_cart;return 0!==o&&(o<i||o>s)})&&m.addError({code:"invalidQuantities",message:t?.invalidQuantities||"",group:"invalid-quantities"}):m.addError({code:"groupedProductAddToCartMissingItems",message:t?.groupedProductAddToCartMissingItems||"",group:"invalid-quantities"})},*batchAddToCart(){yield Promise.resolve().then(s.bind(s,1401));const{quantity:t,selectedAttributes:e,groupedProductIds:o}=(0,a.getContext)(),r=[];for(const i of o){if(0===t[i])continue;const o=u.findProduct({id:Number(i),selectedAttributes:e});o&&r.push({id:Number(i),quantityToAdd:t[i],variation:e,type:o.type})}const{actions:i}=(0,a.store)("woocommerce",{},{lock:c});yield i.batchAddCartItems(r,{showCartUpdatesNotices:!1})}},callbacks:{validateQuantities(){m.validateGroupedProductQuantity()}}},{lock:c});