"use strict";(self.__LOADABLE_LOADED_CHUNKS__=self.__LOADABLE_LOADED_CHUNKS__||[]).push([[1586,796],{17602:function(e,t,o){o.d(t,{Z:function(){return w}});var r=o(48834).Buffer,c=Object.defineProperty,n=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,l=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))u.call(t,o)&&l(e,o,t[o]);if(n)for(var o of n(t))i.call(t,o)&&l(e,o,t[o]);return e},s=(e,t,o)=>new Promise((r,c)=>{var n=e=>{try{i(o.next(e))}catch(e){c(e)}},u=e=>{try{i(o.throw(e))}catch(e){c(e)}},i=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,u);i((o=o.apply(e,t)).next())});function a({id:e,webUrl:t,completedAt:o,lineItems:r,discountApplications:c}){return{id:e,url:t,completed:!!o,lines:r.edges.map(e=>e.node),discounts:c.edges.map(e=>e.node)}}function d(e,...t){return e.reduce((e,o,r)=>`${e}${o}${t[r]||""}`,"")}function f(e,{caller:t,message:o}={}){let r="";throw t&&(r=`[${t}] `),Error(r=r+(o||"Shopify Storefront API Errors:")+(e?"\n"+JSON.stringify(e,null,2):""))}function p(e){return null!=e&&!!e.length&&(e.includes("Z2lkOi8vc2hvcGlmeS9DaGVja291dC")||e.includes("gid://shopify/Checkout"))}function k({metafields:e}){return Array.isArray(e)&&(null==e?void 0:e.length)?null==e?void 0:e.reduce((e,t)=>("string"==typeof t.value?e.push({key:t.key,value:t.value}):console.warn(`Omitting custom attribute "${t.key}" because it has a non-string value.`),e),[]):[]}function y(e){return e.startsWith("gid://shopify/")}let v=d`fragment CheckoutLineItem_lineItem on CheckoutLineItem { customAttributes { key value } discountAllocations { allocatedAmount { amount currencyCode } } id quantity title unitPrice { amount currencyCode } variant { id } }`,m=d`fragment DiscountApplication_discountApplication on DiscountApplication { allocationMethod targetSelection targetType ... on ScriptDiscountApplication { title } value { ... on MoneyV2 { amount currencyCode } ... on PricingPercentageValue { percentage } } }`;var C=d`fragment Checkout_checkout on Checkout { id completedAt webUrl lineItems(first: 100) { edges { node { ...CheckoutLineItem_lineItem } } } discountApplications(first: 100) { edges { node { ...DiscountApplication_discountApplication } } } }${v}${m}`,E=d`fragment CheckoutUserError_checkoutUserError on CheckoutUserError { code field message }`;let I=d`mutation checkoutCreate($input: CheckoutCreateInput!) { checkoutCreate(input: $input) { checkout { ...Checkout_checkout } checkoutUserErrors { ...CheckoutUserError_checkoutUserError } } }${C}${E}`,g=d`mutation checkoutLineItemsReplace( $lineItems: [CheckoutLineItemInput!]! $checkoutId: ID! ) { checkoutLineItemsReplace(lineItems: $lineItems, checkoutId: $checkoutId) { checkout { ...Checkout_checkout } userErrors { ...CheckoutUserError_checkoutUserError } } }${C}${E}`,b=d`mutation checkoutAttributesUpdate( $checkoutId: ID! $input: CheckoutAttributesUpdateV2Input! ) { checkoutAttributesUpdateV2(checkoutId: $checkoutId, input: $input) { checkout { ...Checkout_checkout } checkoutUserErrors { ...CheckoutUserError_checkoutUserError } } }${C}${E}`,$=d`mutation checkoutDiscountCodeApplyV2( $checkoutId: ID! $discountCode: String! ) { checkoutDiscountCodeApplyV2( checkoutId: $checkoutId discountCode: $discountCode ) { checkout { ...Checkout_checkout } checkoutUserErrors { ...CheckoutUserError_checkoutUserError } } }${C}${E}`,A=d`mutation checkoutDiscountCodeRemove($checkoutId: ID!) { checkoutDiscountCodeRemove(checkoutId: $checkoutId) { checkout { ...Checkout_checkout } checkoutUserErrors { ...CheckoutUserError_checkoutUserError } } }${C}${E}`,D=d`query getCheckout($id: ID!) { node(id: $id) { ... on Checkout { ...Checkout_checkout } } }${C}`;function w({storefrontCheckoutToken:e,myshopifyDomain:t,customEndpoint:o,fetchClient:c}){let n=function({customEndpoint:e,fetchClient:t,myshopifyDomain:o,storefrontCheckoutToken:r}){return({query:c,variables:n})=>{let u=e||"";if(!r)throw Error("[@nacelle/shopify-checkout]: missing required parameter `storefrontCheckoutToken`.");if(!u){var i,l,h;if(!o)throw Error("[@nacelle/shopify-checkout]: missing required parameters. You must provide a `myshopifyDomain` or a `customEndpoint`.");let e=(null==(h=null==(l=null==(i=o||"")?void 0:i.split(".myshopify").shift())?void 0:l.split("//").pop())?void 0:h.split(".").pop())||i;u=`https://${e}.myshopify.com/api/2022-07/graphql`}let s=t;if(!s){if("undefined"!=typeof window)s=window.fetch;else throw Error("[@nacelle/shopify-checkout] in order to create a checkout server-side, you must provide a fetch API-compatible `fetchClient` capable of running on both the client & server. Examples include `isomorphic-unfetch` and `cross-fetch`.")}return s(u,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","X-Shopify-Storefront-Access-Token":r},body:JSON.stringify({query:c,variables:n})}).then(e=>e.json())}}({customEndpoint:o,fetchClient:c,myshopifyDomain:t,storefrontCheckoutToken:e});return{get:function(e){return s(this,arguments,function*({id:e}){return yield function(e){return s(this,arguments,function*({gqlClient:e,id:t}){let{data:o,errors:r}=yield e({query:D,variables:{id:t}}).catch(e=>{throw Error(e)});if(r&&f(r,{caller:"findCheckout"}),null==o?void 0:o.node)return a(o.node);f(void 0,{caller:"findCheckout",message:"Checkout response has no data"})})}({gqlClient:n,id:e})})},process:function(e){return s(this,arguments,function*({cartItems:e,id:t,metafields:o,note:c,queueToken:u}){let i=(null==e?void 0:e.length)?function({cartItems:e}){return e.map(e=>{let{quantity:t,variantId:o}=e,c=function(e){if(y(e))return e;if(!Number.isNaN(Number(e)))return`gid://shopify/ProductVariant/${e}`;let t=function(e){try{if("undefined"!=typeof window)return window.atob(e);if(r.from(e,"base64").toString("base64")===e)return r.from(e,"base64").toString();return e}catch(t){return e}}(e);if(y(t))return t;throw Error(`${e} is an invalid shopify variant id`)}(o);return{customAttributes:k({metafields:e.metafields}),quantity:t,variantId:c}})}({cartItems:e}):void 0,l=(null==o?void 0:o.length)?k({metafields:o}):void 0;return yield function(e){return s(this,arguments,function*({gqlClient:e,id:t,lineItems:o,customAttributes:r,note:c,queueToken:n}){let u;let i=null==o?void 0:o.length,l=(null==r?void 0:r.length)||c;try{if(t){if(!p(t))throw Error(`Invalid checkout ID. Expected a Shopify Global ID. Received: ${t}`);let n=[];i&&n.push(function(e){return s(this,arguments,function*({gqlClient:e,lineItems:t,id:o}){let{data:r,errors:c}=yield e({query:g,variables:{checkoutId:o,lineItems:t}}).catch(e=>{throw Error(e)}),n=c||(null==r?void 0:r.checkoutLineItemsReplace.userErrors);if((null==n?void 0:n.length)&&f(n,{caller:"checkoutLineItemsReplace"}),null==r?void 0:r.checkoutLineItemsReplace.checkout)return a(r.checkoutLineItemsReplace.checkout)})}({gqlClient:e,id:t,lineItems:o})),l&&n.push(function(e){return s(this,arguments,function*({gqlClient:e,id:t,customAttributes:o,note:r}){let{data:c,errors:n}=yield e({query:b,variables:{checkoutId:t,input:{customAttributes:o,note:r}}}).catch(e=>{throw Error(e)}),u=n||(null==c?void 0:c.checkoutAttributesUpdateV2.checkoutUserErrors);if((null==u?void 0:u.length)&&f(u,{caller:"checkoutAttributesUpdate"}),null==c?void 0:c.checkoutAttributesUpdateV2.checkout)return a(c.checkoutAttributesUpdateV2.checkout)})}({gqlClient:e,id:t,customAttributes:r,note:c})),yield Promise.allSettled(n).then(e=>e.forEach(e=>{if("fulfilled"===e.status&&e.value)u=h(h({},u||{}),e.value);else if("rejected"===e.status)throw Error(e.reason)}))}return void 0===u&&void 0!==o&&(u=yield function(e){return s(this,arguments,function*({gqlClient:e,lineItems:t,customAttributes:o,note:r,queueToken:c}){try{let{data:n,errors:u}=yield e({query:I,variables:{input:{customAttributes:o,lineItems:t,note:r},queueToken:c}}).catch(e=>{throw Error(e)}),i=u||(null==n?void 0:n.checkoutCreate.checkoutUserErrors);if((null==i?void 0:i.length)&&f(i,{caller:"checkoutCreate"}),null==n?void 0:n.checkoutCreate.checkout)return a(n.checkoutCreate.checkout)}catch(e){throw Error(String(e))}})}({gqlClient:e,customAttributes:r,note:c,lineItems:o,queueToken:n})),u}catch(e){throw Error(String(e))}})}({gqlClient:n,lineItems:i,id:t,customAttributes:l,note:c,queueToken:u})})},discountApply:function(e){return s(this,arguments,function*({id:e,discountCode:t,queueToken:o}){return yield function(e){return s(this,arguments,function*({gqlClient:e,id:t,discountCode:o,queueToken:r}){try{if(!p(t))throw Error(`Invalid checkout ID. Expected a Shopify Global ID. Received: ${t}`);let{data:c,errors:n}=yield e({query:$,variables:{checkoutId:t,discountCode:o,queueToken:r}}).catch(e=>{throw Error(e)}),u=n||(null==c?void 0:c.checkoutDiscountCodeApplyV2.checkoutUserErrors);if((null==u?void 0:u.length)&&f(u,{caller:"checkoutDiscountCodeApplyV2"}),null==c?void 0:c.checkoutDiscountCodeApplyV2.checkout)return a(c.checkoutDiscountCodeApplyV2.checkout)}catch(e){throw Error(String(e))}})}({gqlClient:n,id:e,discountCode:t,queueToken:o})})},discountRemove:function(e){return s(this,arguments,function*({id:e,queueToken:t}){return yield function(e){return s(this,arguments,function*({gqlClient:e,id:t,queueToken:o}){try{if(!p(t))throw Error(`Invalid checkout ID. Expected a Shopify Global ID. Received: ${t}`);let{data:r,errors:c}=yield e({query:A,variables:{checkoutId:t,queueToken:o}}).catch(e=>{throw Error(e)}),n=c||(null==r?void 0:r.checkoutDiscountCodeRemove.checkoutUserErrors);if((null==n?void 0:n.length)&&f(n,{caller:"checkoutDiscountCodeRemove"}),null==r?void 0:r.checkoutDiscountCodeRemove.checkout)return a(r.checkoutDiscountCodeRemove.checkout)}catch(e){throw Error(String(e))}})}({gqlClient:n,id:e,queueToken:t})})},query:function(e){return s(this,arguments,function*({query:e,variables:t}){return yield function({gqlClient:e,query:t,variables:o}){return e({query:t,variables:o})}({gqlClient:n,query:e,variables:t})})}}}},10806:function(e,t,o){o.d(t,{Z:function(){return n}});var r=o(66700),c=o(19785);function n(e){return(0,c.Z)(1,arguments),(0,r.Z)(e).getTime()>Date.now()}},75549:function(e,t,o){o.d(t,{Z:function(){return n}});var r=o(66700),c=o(19785);function n(e){(0,c.Z)(1,arguments);var t=(0,r.Z)(e).getDay();return 0===t||6===t}},13621:function(e,t,o){o.d(t,{Z:function(){return u}});var r=o(86522),c=o(66700),n=o(19785);function u(e){var t,o;if((0,n.Z)(1,arguments),e&&"function"==typeof e.forEach)t=e;else{if("object"!==(0,r.Z)(e)||null===e)return new Date(NaN);t=Array.prototype.slice.call(e)}return t.forEach(function(e){var t=(0,c.Z)(e);(void 0===o||o<t||isNaN(Number(t)))&&(o=t)}),o||new Date(NaN)}}}]);