const isObject=o=>o&&"object"==typeof o&&!Array.isArray(o);export const 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{}};export const isProductVariantOptionSoldOut=(o,t,i,n)=>{var a,l,r,e,s;if(!(null==n?void 0:n.stock_enabled)||(null==n?void 0:n.allow_out_of_stock_purchases))return!1;if(1===o){const o=null===(r=(l=(null===(a=n.variants)||void 0===a?void 0:a.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=n.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=n.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};export const isProductVariantOptionMissing=(o,t,i,n)=>{var a,l,r;return 1===o?!((null===(a=null==n?void 0:n.variants)||void 0===a?void 0:a.data)||[]).some((o=>o.option_1===t)):2===o?!((null===(l=null==n?void 0:n.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==n?void 0:n.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))};