import*as t from"@wordpress/interactivity";var e,r,o,a,n={446:(t,e,r)=>{r.a(t,(async(t,e)=>{try{var o=r(2833),a=r(2192),n=t([a]);a=(n.then?(await n)():n)[0];const i="I acknowledge that using a private store means my plugin will inevitably break on the next store release.",{state:c}=(0,o.store)("woocommerce",{},{lock:i}),s=t=>{let e=null;return t.target instanceof HTMLButtonElement&&(e=t.target.parentElement?.querySelector(".input-text.qty.text")),t.target instanceof HTMLInputElement&&(e=t.target),e},u=t=>{var e;const r=s(t);if(!r)return;const o=parseInt(r.value,10),a=parseInt(r.min,10),n=parseInt(r.max,10),i=parseInt(r.step,10);return{currentValue:isNaN(o)?0:o,minValue:isNaN(a)?1:a,maxValue:isNaN(n)?void 0:n,step:isNaN(i)?1:i,childProductId:parseInt(null!==(e=r.name.match(/\[(\d+)\]/)?.[1])&&void 0!==e?e:"0",10),inputElement:r}},l=(t,e)=>Array.isArray(t)&&Array.isArray(e)&&0!==t.length&&0!==e.length?t.find((t=>Object.entries(t.attributes).every((([t,r])=>e.some((e=>!(e.attribute!==t)&&(e.value===r||e.value&&""===r))))))):null,d=(t,e)=>{const r=c.cart?.items.find((e=>e.id===t));return(r?.quantity||0)+e},p=t=>{const e=new Event("change");t.dispatchEvent(e)},m=(0,o.store)("woocommerce/add-to-cart-with-options",{state:{get isFormValid(){const{availableVariations:t,selectedAttributes:e,productType:r}=(0,o.getContext)();if("variable"!==r)return!0;const a=l(t,e);return!!a?.variation_id},get variationId(){const t=(0,o.getContext)();if(!t)return null;const{availableVariations:e,selectedAttributes:r}=t,a=l(e,r);return a?.variation_id||null}},actions:{setQuantity(t,e){const r=(0,o.getContext)(),a=e&&e>0?e:r.productId;r.quantity={...r.quantity,[a]:t}},setAttribute(t,e){const{selectedAttributes:r}=(0,o.getContext)(),a=r.findIndex((e=>e.attribute===t));a>=0?r[a]={attribute:t,value:e}:r.push({attribute:t,value:e})},removeAttribute(t){const{selectedAttributes:e}=(0,o.getContext)(),r=e.findIndex((e=>e.attribute===t));r>=0&&e.splice(r,1)},increaseQuantity:t=>{const e=u(t);if(!e)return;const{currentValue:r,maxValue:o,step:a,childProductId:n,inputElement:i}=e,c=r+a;(void 0===o||c<=o)&&(m.actions.setQuantity(c,n),i.value=c.toString(),p(i))},decreaseQuantity:t=>{const e=u(t);if(!e)return;const{currentValue:r,minValue:o,step:a,childProductId:n,inputElement:i}=e,c=r-a;c>=o&&(m.actions.setQuantity(c,n),i.value=c.toString(),p(i))},handleQuantityInputChange:t=>{const e=u(t);if(!e)return;const{childProductId:r,currentValue:o}=e;m.actions.setQuantity(o,r)},handleQuantityCheckboxChange:t=>{const e=u(t);if(!e)return;const{inputElement:r,childProductId:o}=e;m.actions.setQuantity(r.checked?1:0,o)},*handleSubmit(t){t.preventDefault(),yield Promise.resolve().then(r.bind(r,1064));const{productId:e,quantity:a,selectedAttributes:n,productType:c,groupedProductIds:s}=(0,o.getContext)();if("grouped"===c&&s.length>0){const t=[];for(const e of s){const r=d(e,a[e]);0!==r&&t.push({id:e,quantity:r,variation:n})}if(0===t.length)return;const{actions:e}=(0,o.store)("woocommerce",{},{lock:i});yield e.batchAddCartItems(t)}else{const t=d(e,a[e]),{actions:r}=(0,o.store)("woocommerce",{},{lock:i});yield r.addCartItem({id:e,quantity:t,variation:n})}}},callbacks:{setProductData:()=>{const{availableVariations:t,selectedAttributes:e}=(0,o.getContext)(),r=l(t,e),{actions:a}=(0,o.store)("woocommerce/product-data",{},{lock:i});r?a.setProductData("price_html",r.price_html):a.setProductData("price_html",null)}}},{lock:!0});e()}catch(t){e(t)}}))},1064:t=>{t.exports=import("@woocommerce/stores/woocommerce/cart")},2192:t=>{t.exports=import("@woocommerce/stores/woocommerce/product-data")},2833:(e,r,o)=>{var a,n;e.exports=(a={getContext:()=>t.getContext,store:()=>t.store},n={},o.d(n,a),n)}},i={};function c(t){var e=i[t];if(void 0!==e)return e.exports;var r=i[t]={exports:{}};return n[t](r,r.exports,c),r.exports}e="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",r="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",o="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",a=t=>{t&&t.d<1&&(t.d=1,t.forEach((t=>t.r--)),t.forEach((t=>t.r--?t.r++:t())))},c.a=(t,n,i)=>{var c;i&&((c=[]).d=-1);var s,u,l,d=new Set,p=t.exports,m=new Promise(((t,e)=>{l=e,u=t}));m[r]=p,m[e]=t=>(c&&t(c),d.forEach(t),m.catch((t=>{}))),t.exports=m,n((t=>{var n;s=(t=>t.map((t=>{if(null!==t&&"object"==typeof t){if(t[e])return t;if(t.then){var n=[];n.d=0,t.then((t=>{i[r]=t,a(n)}),(t=>{i[o]=t,a(n)}));var i={};return i[e]=t=>t(n),i}}var c={};return c[e]=t=>{},c[r]=t,c})))(t);var i=()=>s.map((t=>{if(t[o])throw t[o];return t[r]})),u=new Promise((t=>{(n=()=>t(i)).r=0;var r=t=>t!==c&&!d.has(t)&&(d.add(t),t&&!t.d&&(n.r++,t.push(n)));s.map((t=>t[e](r)))}));return n.r?u:i()}),(t=>(t?l(m[o]=t):u(p),a(c)))),c&&c.d<0&&(c.d=0)},c.d=(t,e)=>{for(var r in e)c.o(e,r)&&!c.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},c.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s=c(446);s=await s;