const isObject=o=>o&&"object"==typeof o&&!Array.isArray(o),getSerializedState=()=>{const o=document.querySelector('script[type="application/json"]#sc-store-data');if(!o)return{};try{const t=JSON.parse(o.textContent);if(isObject(t))return t;throw Error("Parsed state is not an object")}catch(o){console.error(o)}return{}},isProductVariantOptionSoldOut=(o,t,i,a)=>{var n,l,r,e,s;if(!(null==a?void 0:a.stock_enabled)||(null==a?void 0:a.allow_out_of_stock_purchases))return!1;if(1===o){const o=null===(r=(l=(null===(n=a.variants)||void 0===n?void 0:n.data)||[]).filter)||void 0===r?void 0:r.call(l,(o=>o.option_1===t));return Math.max(...o.map((o=>o.available_stock)))<=0}if(2===o){const o=((null===(e=a.variants)||void 0===e?void 0:e.data)||[]).filter((o=>(null==o?void 0:o.option_1)===i.option_1&&o.option_2===t));return Math.max(...o.map((o=>o.available_stock)))<=0}const d=((null===(s=a.variants)||void 0===s?void 0:s.data)||[]).filter((o=>(null==o?void 0:o.option_1)===i.option_1&&(null==o?void 0:o.option_2)===i.option_2&&o.option_3===t));return Math.max(...d.map((o=>o.available_stock)))<=0},isProductVariantOptionMissing=(o,t,i,a)=>{var n,l,r;return 1===o?!((null===(n=null==a?void 0:a.variants)||void 0===n?void 0:n.data)||[]).some((o=>o.option_1===t)):2===o?!((null===(l=null==a?void 0:a.variants)||void 0===l?void 0:l.data)||[]).some((o=>(null==o?void 0:o.option_1)===i.option_1&&o.option_2===t)):!((null===(r=null==a?void 0:a.variants)||void 0===r?void 0:r.data)||[]).some((o=>(null==o?void 0:o.option_1)===i.option_1&&(null==o?void 0:o.option_2)===i.option_2&&o.option_3===t))};export{isProductVariantOptionMissing as a,getSerializedState as g,isProductVariantOptionSoldOut as i};