@dropins/storefront-cart 0.3.0-alpha15 → 0.3.0-alpha16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m,C as u,a as l,j as f,f as s,h as o,t as p}from"./resetCart.js";import{Initializer as C}from"@dropins/tools/lib.js";const d=new C({init:async t=>{const r={disableGuestCart:!1,...t};d.config.setConfig(r),c().catch(console.error)},listeners:()=>[i.on("authenticated",t=>{a.authenticated&&!t?i.emit("cart/reset",void 0):t&&!a.authenticated&&(a.authenticated=t,c().catch(console.error))},{eager:!0}),i.on("locale",async t=>{t!==a.locale&&(a.locale=t,c().catch(console.error))}),i.on("cart/reset",()=>{y().catch(console.error),i.emit("cart/data",null)}),i.on("cart/data",t=>{m(t)})]}),h=d.config;function T(t){if(!t)return null;const r=e=>{switch(e){case 1:return"EXCLUDING_TAX";case 2:return"INCLUDING_TAX";case 3:return"INCLUDING_EXCLUDING_TAX";default:return"EXCLUDING_TAX"}};return{displayMiniCart:t.minicart_display,miniCartMaxItemsDisplay:t.minicart_max_items,cartExpiresInDays:t.cart_expires_in_days,cartSummaryDisplayTotal:t.cart_summary_display_quantity,defaultCountry:t.default_country,categoryFixedProductTaxDisplaySetting:t.category_fixed_product_tax_display_setting,productFixedProductTaxDisplaySetting:t.product_fixed_product_tax_display_setting,salesFixedProductTaxDisplaySetting:t.sales_fixed_product_tax_display_setting,shoppingCartDisplaySetting:{zeroTax:t.shopping_cart_display_zero_tax,subtotal:r(t.shopping_cart_display_subtotal),price:r(t.shopping_cart_display_price),shipping:r(t.shopping_cart_display_shipping),fullSummary:t.shopping_cart_display_full_summary,grandTotal:t.shopping_cart_display_grand_total,taxGiftWrapping:t.shopping_cart_display_tax_gift_wrapping},useConfigurableParentThumbnail:t.configurable_thumbnail_source==="parent"}}const x=`
1
+ import{events as e}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as f,C as u,a as l,j as m,f as s,h as o,t as p}from"./resetCart.js";import{Initializer as C}from"@dropins/tools/lib.js";const d=new C({init:async t=>{const r={disableGuestCart:!1,...t};d.config.setConfig(r),c().catch(console.error)},listeners:()=>[e.on("authenticated",t=>{a.authenticated&&!t?e.emit("cart/reset",void 0):t&&!a.authenticated&&(a.authenticated=t,c().catch(console.error))},{eager:!0}),e.on("locale",async t=>{t!==a.locale&&(a.locale=t,c().catch(console.error))}),e.on("cart/reset",()=>{y().catch(console.error),e.emit("cart/data",null)}),e.on("cart/data",t=>{f(t)})]}),h=d.config;function T(t){if(!t)return null;const r=i=>{switch(i){case 1:return"EXCLUDING_TAX";case 2:return"INCLUDING_TAX";case 3:return"INCLUDING_EXCLUDING_TAX";default:return"EXCLUDING_TAX"}};return{displayMiniCart:t.minicart_display,miniCartMaxItemsDisplay:t.minicart_max_items,cartExpiresInDays:t.cart_expires_in_days,cartSummaryDisplayTotal:t.cart_summary_display_quantity,defaultCountry:t.default_country,categoryFixedProductTaxDisplaySetting:t.category_fixed_product_tax_display_setting,productFixedProductTaxDisplaySetting:t.product_fixed_product_tax_display_setting,salesFixedProductTaxDisplaySetting:t.sales_fixed_product_tax_display_setting,shoppingCartDisplaySetting:{zeroTax:t.shopping_cart_display_zero_tax,subtotal:r(t.shopping_cart_display_subtotal),price:r(t.shopping_cart_display_price),shipping:r(t.shopping_cart_display_shipping),fullSummary:t.shopping_cart_display_full_summary,grandTotal:t.shopping_cart_display_grand_total,taxGiftWrapping:t.shopping_cart_display_tax_gift_wrapping},useConfigurableParentThumbnail:t.configurable_thumbnail_source==="parent"}}const x=`
2
2
  query GUEST_CART_QUERY(
3
3
  $cartId: String!,
4
4
  ${u}
@@ -14,7 +14,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
14
14
  query CUSTOMER_CART_QUERY(
15
15
  ${u}
16
16
  ) {
17
- ${f}
17
+ ${m}
18
18
 
19
19
  cart: customerCart {
20
20
  ...CartFragment
@@ -22,7 +22,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
22
22
  }
23
23
 
24
24
  ${l}
25
- `,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:e,data:n})=>{if(e)return o(e);const g={...n.cart,...n.customer};return p(g)});if(!r)throw new Error("No cart ID found");return s(x,{method:"POST",cache:"no-cache",variables:{cartId:r}}).then(({errors:e,data:n})=>e?o(e):p(n.cart))},E=`
25
+ `,_=async()=>{const t=a.authenticated,r=a.cartId;if(t)return s(I,{method:"POST"}).then(({errors:i,data:n})=>{if(i)return o(i);const g={...n.cart,...n.customer};return p(g)});if(!r)throw new Error("No cart ID found");return s(x,{method:"POST",cache:"no-cache",variables:{cartId:r}}).then(({errors:i,data:n})=>i?o(i):p(n.cart))},E=`
26
26
  mutation MERGE_CARTS_MUTATION(
27
27
  $guestCartId: String!,
28
28
  $customerCartId: String!,
@@ -37,7 +37,7 @@ import{events as i}from"@dropins/tools/event-bus.js";import{s as a,e as y,i as m
37
37
  }
38
38
 
39
39
  ${l}
40
- `,c=async()=>{a.config=await A();const t=a.authenticated?await S():await R();return i.emit("cart/initialized",t),i.emit("cart/data",t),t};async function S(){const t=a.cartId,r=await _();return r?(a.cartId=r.id,!t||r.id===t?r:await s(E,{variables:{guestCartId:t,customerCartId:r.id}}).then(()=>_()).then(e=>{const n={oldCartItems:r.items,newCart:e};return i.emit("cart/merged",n),e}).catch(()=>(console.error("Could not merge carts"),r))):null}async function R(){if(h.getConfig().disableGuestCart===!0||!a.cartId)return null;try{return await _()}catch(t){return console.error(t),null}}const G=`
40
+ `,c=async()=>{if(a.initializing)return null;a.initializing=!0,a.config=await A();const t=a.authenticated?await S():await R();return e.emit("cart/initialized",t),e.emit("cart/data",t),a.initializing=!1,t};async function S(){const t=a.cartId,r=await _();return r?(a.cartId=r.id,!t||r.id===t?r:await s(E,{variables:{guestCartId:t,customerCartId:r.id}}).then(()=>_()).then(i=>{const n={oldCartItems:r.items,newCart:i};return e.emit("cart/merged",n),i}).catch(()=>(console.error("Could not merge carts"),r))):null}async function R(){if(h.getConfig().disableGuestCart===!0||!a.cartId)return null;try{return await _()}catch(t){return console.error(t),null}}const G=`
41
41
  query STORE_CONFIG_QUERY {
42
42
  storeConfig {
43
43
  minicart_display
@@ -1,4 +1,4 @@
1
- import{FetchGraphQL as A}from"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";function D(r){const n=document.cookie.split(";");for(let t=0;t<n.length;t++){const e=n[t].trim();if(e.indexOf(`${r}=`)===0)return e.substring(r.length+1)}return null}function q(r){r?sessionStorage.setItem("DROPIN__CART__CART__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__CART__DATA")}function R(){const r=sessionStorage.getItem("DROPIN__CART__CART__DATA");return r?JSON.parse(r):null}function Q(r){r?sessionStorage.setItem("DROPIN__CART__SHIPPING__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__SHIPPING__DATA")}const S=(()=>{const r=R();return{cartId:null,authenticated:r?!r.isGuestCart:!1}})(),a=new Proxy(S,{set(r,n,t){var e;if(r[n]=t,n==="cartId"){if(t===a.cartId)return!0;if(t===null)return document.cookie="DROPIN__CART__CART-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const u=(e=a.config)==null?void 0:e.cartExpiresInDays;u||console.warn('Missing "expiresInDays" config. Cookie expiration will default to 30 days.');const l=new Date;l.setDate(l.getDate()+(u??30)),document.cookie=`DROPIN__CART__CART-ID=${t}; expires=${l.toUTCString()}; path=/`}return!0},get(r,n){return n==="cartId"?D("DROPIN__CART__CART-ID"):r[n]}}),{setEndpoint:B,setFetchGraphQlHeader:V,removeFetchGraphQlHeader:j,setFetchGraphQlHeaders:U,fetchGraphQl:H,getConfig:J}=new A().getMethods();function L(r){var n,t,e,u,l,c,i;return r?{id:r.id,totalQuantity:N(r),errors:w(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=a.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(t=r.prices.subtotal_excluding_tax)==null?void 0:t.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(u=r.prices.subtotal_including_tax)==null?void 0:u.value,currency:(l=r.prices.subtotal_including_tax)==null?void 0:l.currency},includingDiscountOnly:{value:(c=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:c.value,currency:(i=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:i.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:O(r.prices.applied_taxes),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&z(r)},isGuestCart:!a.authenticated}:null}function O(r){return r!=null&&r.length?r.reduce((n,t)=>({value:n.value+t.amount.value,currency:t.amount.currency}),{value:0,currency:""}):null}function h(r){var t;if(!((t=r==null?void 0:r.items)!=null&&t.length))return[];const n=a.config;return r.items.map(e=>{var u,l,c,i,s,_,p,g,d,m,y,f,b,v,C;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(T=>T.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((l=(u=e.configured_variant)==null?void 0:u.thumbnail)==null?void 0:l.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((i=(c=e.configured_variant)==null?void 0:c.thumbnail)==null?void 0:i.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:k(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(s=e.prices.original_row_total)==null?void 0:s.value,currency:(_=e.prices.original_row_total)==null?void 0:_.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(p=e.configured_variant)==null?void 0:p.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(d=e.configured_variant)==null?void 0:d.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(y=e.product.price_range)==null?void 0:y.maximum_price.regular_price.value,currency:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(b=e.configured_variant)==null?void 0:b.price_range)==null?void 0:v.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?P(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:G(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency}}})}function w(r){var t;const n=(t=r==null?void 0:r.items)==null?void 0:t.reduce((e,u)=>{var l;return(l=u.errors)==null||l.forEach(c=>{e.push({uid:u.uid,text:c.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function P(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(u=>u.label).join(", ")})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function G(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(u=>({uid:u.customizable_option_value_uid,label:u.label,value:u.value}))})),t={};return n==null||n.forEach(e=>{switch(e.type){case"field":case"area":case"date_time":t[e.label]=e.values[0].value;break;case"radio":case"drop_down":t[e.label]=e.values[0].label;break;case"multiple":case"checkbox":t[e.label]=e.values.reduce((u,l)=>u?`${u}, ${l.label}`:l.label,"");break}}),t}function N(r){var n,t;return((n=a.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((t=a.config)==null?void 0:t.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function k(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function z(r){var n,t,e,u;return(n=r.shipping_addresses)!=null&&n.length?(t=r.shipping_addresses)==null?void 0:t.map(l=>({countryCode:l.country.code,zipCode:l.postcode,regionCode:l.region.code})):(e=r.addresses)!=null&&e.length?(u=r.addresses)==null?void 0:u.filter(l=>l.default_shipping).map(l=>{var c;return l.default_shipping&&{countryCode:l.country_id,zipCode:l.postcode,regionCode:(c=l.region)==null?void 0:c.region_code}}):null}const K=r=>{const n=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-authorization")>-1,t=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-no-such-entity")>-1,e=r.map(u=>u.message).join(" ");if(n||t)return $(),console.error(e),null;throw Error(e)},o=`
1
+ import{FetchGraphQL as A}from"@dropins/tools/fetch-graphql.js";import"@dropins/tools/event-bus.js";function D(r){const n=document.cookie.split(";");for(let t=0;t<n.length;t++){const e=n[t].trim();if(e.indexOf(`${r}=`)===0)return e.substring(r.length+1)}return null}function q(r){r?sessionStorage.setItem("DROPIN__CART__CART__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__CART__DATA")}function R(){const r=sessionStorage.getItem("DROPIN__CART__CART__DATA");return r?JSON.parse(r):null}function Q(r){r?sessionStorage.setItem("DROPIN__CART__SHIPPING__DATA",JSON.stringify(r)):sessionStorage.removeItem("DROPIN__CART__SHIPPING__DATA")}const S=(()=>{const r=R();return{cartId:null,authenticated:r?!r.isGuestCart:!1}})(),a=new Proxy(S,{set(r,n,t){var e;if(r[n]=t,n==="cartId"){if(t===a.cartId)return!0;if(t===null)return document.cookie="DROPIN__CART__CART-ID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/",!0;const u=(e=a.config)==null?void 0:e.cartExpiresInDays;u||console.warn('Missing "expiresInDays" config. Cookie expiration will default to 30 days.');const l=new Date;l.setDate(l.getDate()+(u??30)),document.cookie=`DROPIN__CART__CART-ID=${t}; expires=${l.toUTCString()}; path=/`}return!0},get(r,n){return n==="cartId"?D("DROPIN__CART__CART-ID"):r[n]}}),{setEndpoint:B,setFetchGraphQlHeader:V,removeFetchGraphQlHeader:j,setFetchGraphQlHeaders:H,fetchGraphQl:U,getConfig:J}=new A().getMethods();function L(r){var n,t,e,u,l,c,i;return r?{id:r.id,totalQuantity:N(r),errors:w(r==null?void 0:r.itemsV2),items:h(r==null?void 0:r.itemsV2),miniCartMaxItems:h(r==null?void 0:r.itemsV2).slice(0,((n=a.config)==null?void 0:n.miniCartMaxItemsDisplay)??10),total:{includingTax:{value:r.prices.grand_total.value,currency:r.prices.grand_total.currency},excludingTax:{value:r.prices.grand_total_excluding_tax.value,currency:r.prices.grand_total_excluding_tax.currency}},subtotal:{excludingTax:{value:(t=r.prices.subtotal_excluding_tax)==null?void 0:t.value,currency:(e=r.prices.subtotal_excluding_tax)==null?void 0:e.currency},includingTax:{value:(u=r.prices.subtotal_including_tax)==null?void 0:u.value,currency:(l=r.prices.subtotal_including_tax)==null?void 0:l.currency},includingDiscountOnly:{value:(c=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:c.value,currency:(i=r.prices.subtotal_with_discount_excluding_tax)==null?void 0:i.currency}},appliedTaxes:I(r.prices.applied_taxes),totalTax:O(r.prices.applied_taxes),appliedDiscounts:I(r.prices.discounts),isVirtual:r.is_virtual,addresses:{shipping:r.shipping_addresses&&z(r)},isGuestCart:!a.authenticated}:null}function O(r){return r!=null&&r.length?r.reduce((n,t)=>({value:n.value+t.amount.value,currency:t.amount.currency}),{value:0,currency:""}):null}function h(r){var t;if(!((t=r==null?void 0:r.items)!=null&&t.length))return[];const n=a.config;return r.items.map(e=>{var u,l,c,i,_,o,s,g,d,m,y,f,b,v,C;return{itemType:e.__typename,uid:e.uid,url:{urlKey:e.product.url_key,categories:e.product.categories.map(T=>T.url_key)},quantity:e.quantity,sku:e.product.sku,name:e.product.name,image:{src:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.url:((l=(u=e.configured_variant)==null?void 0:u.thumbnail)==null?void 0:l.url)||e.product.thumbnail.url,alt:n!=null&&n.useConfigurableParentThumbnail?e.product.thumbnail.label:((i=(c=e.configured_variant)==null?void 0:c.thumbnail)==null?void 0:i.label)||e.product.thumbnail.label},price:{value:e.prices.price.value,currency:e.prices.price.currency},taxedPrice:{value:e.prices.price_including_tax.value,currency:e.prices.price_including_tax.currency},rowTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency},rowTotalIncludingTax:{value:e.prices.row_total_including_tax.value,currency:e.prices.row_total_including_tax.currency},links:k(e.links),total:e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.row_total.value,currency:e.prices.row_total.currency}:{value:(_=e.prices.original_row_total)==null?void 0:_.value,currency:(o=e.prices.original_row_total)==null?void 0:o.currency},discount:{value:e.prices.total_item_discount.value,currency:e.prices.total_item_discount.currency},regularPrice:e.__typename==="ConfigurableCartItem"?{value:(g=(s=e.configured_variant)==null?void 0:s.price_range)==null?void 0:g.maximum_price.regular_price.value,currency:(m=(d=e.configured_variant)==null?void 0:d.price_range)==null?void 0:m.maximum_price.regular_price.currency}:e.__typename==="GiftCardCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0||e.__typename==="BundleCartItem"?{value:e.prices.price.value,currency:e.prices.price.currency}:{value:(y=e.product.price_range)==null?void 0:y.maximum_price.regular_price.value,currency:(f=e.product.price_range)==null?void 0:f.maximum_price.regular_price.currency},discounted:e.__typename==="BundleCartItem"||e.__typename==="SimpleCartItem"&&e.customizable_options.length!==0?!1:e.__typename==="ConfigurableCartItem"?((v=(b=e.configured_variant)==null?void 0:b.price_range)==null?void 0:v.maximum_price.discount.amount_off)>0:((C=e.product.price_range)==null?void 0:C.maximum_price.discount.amount_off)>0,bundleOptions:e.__typename==="BundleCartItem"?P(e.bundle_options):null,selectedOptions:E(e.configurable_options),customizableOptions:G(e.customizable_options),sender:e.__typename==="GiftCardCartItem"?e.sender_name:null,senderEmail:e.__typename==="GiftCardCartItem"?e.sender_email:null,recipient:e.__typename==="GiftCardCartItem"?e.recipient_name:null,recipientEmail:e.__typename==="GiftCardCartItem"?e.recipient_email:null,message:e.__typename==="GiftCardCartItem"?e.message:null,discountedTotal:{value:e.prices.row_total.value,currency:e.prices.row_total.currency}}})}function w(r){var t;const n=(t=r==null?void 0:r.items)==null?void 0:t.reduce((e,u)=>{var l;return(l=u.errors)==null||l.forEach(c=>{e.push({uid:u.uid,text:c.message})}),e},[]);return n!=null&&n.length?n:null}function I(r){return r!=null&&r.length?r.map(n=>({amount:{value:n.amount.value,currency:n.amount.currency},label:n.label})):[]}function P(r){const n=r==null?void 0:r.map(e=>({uid:e.uid,label:e.label,value:e.values.map(u=>u.label).join(", ")})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function E(r){const n=r==null?void 0:r.map(e=>({uid:e.configurable_product_option_uid,label:e.option_label,value:e.value_label})),t={};return n==null||n.forEach(e=>{t[e.label]=e.value}),Object.keys(t).length>0?t:null}function G(r){const n=r==null?void 0:r.map(e=>({uid:e.customizable_option_uid,label:e.label,type:e.type,values:e.values.map(u=>({uid:u.customizable_option_value_uid,label:u.label,value:u.value}))})),t={};return n==null||n.forEach(e=>{var u;switch(e.type){case"field":case"area":case"date_time":t[e.label]=e.values[0].value;break;case"radio":case"drop_down":t[e.label]=e.values[0].label;break;case"multiple":case"checkbox":t[e.label]=e.values.reduce((o,s)=>o?`${o}, ${s.label}`:s.label,"");break;case"file":const l=new DOMParser,c=e.values[0].value,_=((u=l.parseFromString(c,"text/html").querySelector("a"))==null?void 0:u.textContent)||"";t[e.label]=_;break}}),t}function N(r){var n,t;return((n=a.config)==null?void 0:n.cartSummaryDisplayTotal)===0?r.itemsV2.items.length:((t=a.config)==null?void 0:t.cartSummaryDisplayTotal)===1?r.total_quantity:r.itemsV2.items.length}function k(r){return(r==null?void 0:r.length)>0?{count:r.length,result:r.map(n=>n.title).join(", ")}:null}function z(r){var n,t,e,u;return(n=r.shipping_addresses)!=null&&n.length?(t=r.shipping_addresses)==null?void 0:t.map(l=>({countryCode:l.country.code,zipCode:l.postcode,regionCode:l.region.code})):(e=r.addresses)!=null&&e.length?(u=r.addresses)==null?void 0:u.filter(l=>l.default_shipping).map(l=>{var c;return l.default_shipping&&{countryCode:l.country_id,zipCode:l.postcode,regionCode:(c=l.region)==null?void 0:c.region_code}}):null}const K=r=>{const n=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-authorization")>-1,t=r.findIndex(({extensions:u})=>(u==null?void 0:u.category)==="graphql-no-such-entity")>-1,e=r.map(u=>u.message).join(" ");if(n||t)return $(),console.error(e),null;throw Error(e)},p=`
2
2
  customizable_options {
3
3
  type
4
4
  customizable_option_uid
@@ -151,7 +151,7 @@ fragment CartFragment on Cart {
151
151
  ${x}
152
152
  }
153
153
  ...on SimpleCartItem {
154
- ${o}
154
+ ${p}
155
155
  }
156
156
  ... on ConfigurableCartItem {
157
157
  configurable_options {
@@ -168,14 +168,14 @@ fragment CartFragment on Cart {
168
168
  }
169
169
  ${x}
170
170
  }
171
- ${o}
171
+ ${p}
172
172
  }
173
173
  ... on DownloadableCartItem {
174
174
  links {
175
175
  sort_order
176
176
  title
177
177
  }
178
- ${o}
178
+ ${p}
179
179
  }
180
180
  ... on BundleCartItem {
181
181
  bundle_options {
@@ -227,4 +227,4 @@ customer {
227
227
  region_id
228
228
  }
229
229
  }
230
- }`,$=()=>(a.cartId=null,a.authenticated=!1,Promise.resolve(null));export{W as C,Z as a,B as b,V as c,U as d,$ as e,H as f,J as g,K as h,q as i,X as j,R as k,Q as l,j as r,a as s,L as t};
230
+ }`,$=()=>(a.cartId=null,a.authenticated=!1,Promise.resolve(null));export{W as C,Z as a,B as b,V as c,H as d,$ as e,U as f,J as g,K as h,q as i,X as j,R as k,Q as l,j as r,a as s,L as t};
@@ -323,7 +323,7 @@ declare const simple: {
323
323
  };
324
324
  declare const simpleCustomizable: {
325
325
  __typename: string;
326
- customizable_options: {
326
+ customizable_options: ({
327
327
  type: string;
328
328
  customizable_option_uid: string;
329
329
  label: string;
@@ -332,7 +332,15 @@ declare const simpleCustomizable: {
332
332
  label: string;
333
333
  value: string;
334
334
  }[];
335
- }[];
335
+ } | {
336
+ type: string;
337
+ customizable_option_uid: string;
338
+ label: string;
339
+ values: {
340
+ label: string;
341
+ value: string;
342
+ }[];
343
+ })[];
336
344
  uid: string;
337
345
  quantity: number;
338
346
  errors: null;
@@ -482,7 +490,7 @@ declare const configurable: {
482
490
  };
483
491
  };
484
492
  declare const configurableCustomizable: {
485
- customizable_options: {
493
+ customizable_options: ({
486
494
  type: string;
487
495
  customizable_option_uid: string;
488
496
  label: string;
@@ -491,7 +499,15 @@ declare const configurableCustomizable: {
491
499
  label: string;
492
500
  value: string;
493
501
  }[];
494
- }[];
502
+ } | {
503
+ type: string;
504
+ customizable_option_uid: string;
505
+ label: string;
506
+ values: {
507
+ label: string;
508
+ value: string;
509
+ }[];
510
+ })[];
495
511
  __typename: string;
496
512
  configurable_options: {
497
513
  configurable_product_option_uid: string;
package/lib/state.d.ts CHANGED
@@ -3,6 +3,7 @@ import { StoreConfigModel } from '../data/models/store-models';
3
3
  type State = {
4
4
  cartId: string | null;
5
5
  authenticated: boolean;
6
+ initializing?: boolean;
6
7
  locale?: string;
7
8
  config?: StoreConfigModel | null;
8
9
  };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-cart", "version": "0.3.0-alpha15", "@dropins/tools": "~0.26.0"}
1
+ {"name": "@dropins/storefront-cart", "version": "0.3.0-alpha16", "@dropins/tools": "~0.26.0"}