@dropins/storefront-checkout 0.1.0-alpha40 → 0.1.0-alpha41

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.
Files changed (60) hide show
  1. package/api.js +1 -1
  2. package/chunks/BillToShippingAddress.js +1 -0
  3. package/chunks/EmptyCart.js +1 -0
  4. package/chunks/OutOfStock.js +1 -1
  5. package/chunks/ShippingMethods.js +1 -1
  6. package/chunks/getCart.graphql.js +20 -6
  7. package/chunks/getCustomer.js +1 -1
  8. package/chunks/placeOrder.js +127 -0
  9. package/chunks/resetCustomer.js +1 -1
  10. package/chunks/setBillingAddress.js +3 -3
  11. package/chunks/setShippingMethods.js +85 -3
  12. package/components/Checkout/Checkout.d.ts +8 -12
  13. package/components/ShippingMethods/ShippingMethods.d.ts +1 -1
  14. package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +4 -2
  15. package/containers/BillToShippingAddress.js +1 -1
  16. package/containers/BillingForm/BillingForm.d.ts +4 -2
  17. package/containers/BillingForm.js +1 -1
  18. package/containers/Checkout/Checkout.d.ts +2 -7
  19. package/containers/Checkout.js +1 -1
  20. package/containers/EmptyCart/EmptyCart.d.ts +8 -0
  21. package/containers/EmptyCart/index.d.ts +3 -0
  22. package/containers/EmptyCart.d.ts +3 -0
  23. package/containers/EmptyCart.js +1 -0
  24. package/containers/EstimateShipping.js +1 -1
  25. package/containers/LoginForm/LoginForm.d.ts +4 -2
  26. package/containers/LoginForm.js +1 -1
  27. package/containers/OutOfStock.js +1 -1
  28. package/containers/PaymentMethods/PaymentMethods.d.ts +5 -3
  29. package/containers/PaymentMethods.js +1 -1
  30. package/containers/PlaceOrder/PlaceOrder.d.ts +4 -2
  31. package/containers/PlaceOrder.js +1 -1
  32. package/containers/ShippingForm/ShippingForm.d.ts +5 -3
  33. package/containers/ShippingForm.js +1 -1
  34. package/containers/ShippingMethods/ShippingMethods.d.ts +4 -2
  35. package/containers/ShippingMethods.js +1 -1
  36. package/containers/index.d.ts +1 -0
  37. package/hocs/index.d.ts +1 -0
  38. package/hocs/withConditionalRendering.d.ts +13 -0
  39. package/i18n/en_US.json.d.ts +8 -0
  40. package/package.json +1 -1
  41. package/render.js +3 -3
  42. package/utils/getDisplayName/getDisplayName.d.ts +4 -0
  43. package/utils/getDisplayName/index.d.ts +2 -0
  44. package/utils/index.d.ts +1 -0
  45. package/chunks/BillToShippingAddress2.js +0 -1
  46. package/chunks/BillingForm.js +0 -1
  47. package/chunks/LoginForm.js +0 -1
  48. package/chunks/PlaceOrder.js +0 -1
  49. package/chunks/ShippingForm.js +0 -1
  50. package/chunks/ToggleButton.js +0 -1
  51. package/chunks/ToggleButton2.js +0 -1
  52. package/chunks/constants.js +0 -1
  53. package/chunks/constants2.js +0 -1
  54. package/chunks/constants3.js +0 -1
  55. package/chunks/fixtures.js +0 -15
  56. package/chunks/getMultilineValues.js +0 -43
  57. package/chunks/placeOrder2.js +0 -127
  58. package/chunks/setGuestEmailOnCart.js +0 -17
  59. package/chunks/setPaymentMethod.js +0 -13
  60. package/chunks/setShippingAddress.js +0 -13
package/api.js CHANGED
@@ -1 +1 @@
1
- import{D as g,F as h,I as l,c as f,M as c,d as C,a as x,b as A,S as F,U as u,i as E,g as M,h as S,j as T,r as D,s as G,e as O,f as U}from"./chunks/fixtures.js";import{e as b,g as I}from"./chunks/getMultilineValues.js";import{c as _,f as k,g as v,i as y,a as B,r as H,b as N}from"./chunks/resetCustomer.js";import{g as z,a as L,b as P}from"./chunks/getCustomer.js";import{i as Y,s as q}from"./chunks/setGuestEmailOnCart.js";import{p as K}from"./chunks/placeOrder2.js";import{s as W}from"./chunks/setBillingAddress.js";import{s as Z}from"./chunks/setPaymentMethod.js";import{S as ss,p as es,s as as}from"./chunks/setShippingAddress.js";import{s as rs}from"./chunks/setShippingMethods.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";import"./chunks/getCart.graphql.js";const n=e=>{var s;(s=window==null?void 0:window.location)==null||s.assign(e)};export{g as DEFAULT_COUNTRY,h as FetchError,l as InvalidArgument,f as MissingBillingAddress,c as MissingCart,C as MissingCountry,x as MissingEmail,A as MissingPaymentMethod,ss as STANDARD_ATTRIBUTES,F as STORE_CONFIG_DEFAULTS,u as UnexpectedError,_ as config,E as defaultFormFields,b as estimateShippingMethods,k as fetchAddressFormFields,M as fetchGraphQl,z as getCart,L as getCheckoutData,S as getConfig,v as getCountries,P as getCustomer,I as getRegions,T as getStoreConfig,y as initialize,B as initializeCheckout,Y as isEmailAvailable,K as placeOrder,es as prepareAddress,n as redirect,D as removeFetchGraphQlHeader,H as resetCheckout,N as resetCustomer,W as setBillingAddress,G as setEndpoint,O as setFetchGraphQlHeader,U as setFetchGraphQlHeaders,q as setGuestEmailOnCart,Z as setPaymentMethod,as as setShippingAddress,rs as setShippingMethodsOnCart};
1
+ import{D as g,F as m,I as h,c as l,M as c,d as C,a as f,b as A,S as F,U as u,i as E,g as M,h as S,j as x,r as T,s as D,e as G,f as O}from"./chunks/getCart.graphql.js";import{S as b,e as R,g as I,i as Q,p as _,s as k,a as v,b as y,c as B}from"./chunks/setShippingMethods.js";import{c as N,f as w,g as z,i as L,a as P,r as j,b as Y}from"./chunks/resetCustomer.js";import{g as J,a as K,b as V}from"./chunks/getCustomer.js";import{p as X}from"./chunks/placeOrder.js";import{s as $}from"./chunks/setBillingAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";const n=e=>{var s;(s=window==null?void 0:window.location)==null||s.assign(e)};export{g as DEFAULT_COUNTRY,m as FetchError,h as InvalidArgument,l as MissingBillingAddress,c as MissingCart,C as MissingCountry,f as MissingEmail,A as MissingPaymentMethod,b as STANDARD_ATTRIBUTES,F as STORE_CONFIG_DEFAULTS,u as UnexpectedError,N as config,E as defaultFormFields,R as estimateShippingMethods,w as fetchAddressFormFields,M as fetchGraphQl,J as getCart,K as getCheckoutData,S as getConfig,z as getCountries,V as getCustomer,I as getRegions,x as getStoreConfig,L as initialize,P as initializeCheckout,Q as isEmailAvailable,X as placeOrder,_ as prepareAddress,n as redirect,T as removeFetchGraphQlHeader,j as resetCheckout,Y as resetCustomer,$ as setBillingAddress,D as setEndpoint,G as setFetchGraphQlHeader,O as setFetchGraphQlHeaders,k as setGuestEmailOnCart,v as setPaymentMethod,y as setShippingAddress,B as setShippingMethodsOnCart};
@@ -0,0 +1 @@
1
+ import{jsx as l}from"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import{n as g,v as h,w as k}from"./getCart.graphql.js";import{s as S}from"./setBillingAddress.js";import{classes as b}from"@dropins/tools/lib.js";import{Checkbox as v,Skeleton as C,SkeletonRow as _}from"@dropins/tools/components.js";import{useText as y}from"@dropins/tools/i18n.js";import{useState as A,useEffect as f}from"@dropins/tools/preact-compat.js";function B(t){return t.displayName||t.name||"Component"}const I=({className:t,isInitialized:s=!0,checked:i=!0,...n})=>{const e=y({title:"Checkout.BillToShippingAddress.title"});return s?l("div",{className:b(["checkout-bill-to-shipping-address",t]),children:l(v,{"data-testid":"bill-to-shipping-checkbox",className:"checkout-bill-to-shipping-address__checkbox",checked:i,name:"checkout-bill-to-shipping-address__checkbox",label:e.title,...n})}):l(N,{})},N=()=>l(C,{className:"bill-to-shipping-address__skeleton",children:l(_,{variant:"row",size:"small"})}),m="is_bill_to_shipping_address",x=t=>{const s=B(t),i=({hideOnEmptyCart:n=!0,hideOnVirtualCart:e=!1,...c})=>{const r=g.value.data,a=r!==void 0&&(r===null||r.isEmpty),o=!!(r!=null&&r.isVirtual);return n&&a||e&&o?null:l(t,{...c})};return i.displayName=`Conditional(${s})`,i};function T(t,s,i){const n=t[i],e=s[i];return n===void 0&&e===void 0||n===null&&e===null?!0:typeof n=="object"&&typeof e=="object"?JSON.stringify(n)===JSON.stringify(e):n===e}function w(t,s,i){return!s&&!i?!0:!s||!i?!1:t.every(n=>{const e=n.code;return T(s,i,e)})}const z=({isBillToShipping:t})=>{var u;const[s,i]=A(!1),n=k.value.data,e=g.value.data,c=(e==null?void 0:e.id)||"",r=!!e,a=e==null?void 0:e.billingAddress,o=(u=e==null?void 0:e.shippingAddresses)==null?void 0:u[0],d=!!o;return f(()=>{if(s)return;const p=localStorage.getItem(m);p&&(i(!0),t.value={checked:p==="true",setByUser:!1})},[s,t]),f(()=>{if(s||!n||!r)return;i(!0);const p=w(n,a,o);t.value={checked:a?p:t.value.checked,setByUser:!1}},[a,n,r,t,s,o]),{cartId:c,isInitialized:s,hasShippingAddress:d}},E=({children:t,...s})=>{const i=h.value.checked,{hasShippingAddress:n,isInitialized:e}=z({isBillToShipping:h});return l(I,{...s,checked:i,isInitialized:e,onChange:r=>{const o=r.target.checked;if(h.value={checked:o,setByUser:!0},localStorage.setItem(m,o.toString()),!e||!o||!n)return;const d=new AbortController;return S({signal:d.signal,input:{same_as_shipping:!0}}).catch(u=>{console.error(u)}),()=>{d.abort()}},disabled:g.value.pending})},P=x(E);export{P as B,m as a,w as c,x as w};
@@ -0,0 +1 @@
1
+ import{jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import"./ShippingMethods.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact-hooks.js";import{n as s}from"./getCart.graphql.js";import{classes as i}from"@dropins/tools/lib.js";import{IllustratedMessage as l,Icon as m,Button as p}from"@dropins/tools/components.js";import"./BillToShippingAddress.js";import{useText as h}from"@dropins/tools/i18n.js";import*as e from"@dropins/tools/preact-compat.js";const x=({routeHome:r})=>{const a=s.value.data;return a!==void 0&&(a===null||a.isEmpty)?n(C,{routeHome:r}):null},u=r=>e.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},e.createElement("g",{clipPath:"url(#clip0_102_196)"},e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3601 18.16H6.5601L4.8801 3H2.3501M19.6701 19.59C19.6701 20.3687 19.0388 21 18.2601 21C17.4814 21 16.8501 20.3687 16.8501 19.59C16.8501 18.8113 17.4814 18.18 18.2601 18.18C19.0388 18.18 19.6701 18.8113 19.6701 19.59ZM7.42986 19.59C7.42986 20.3687 6.79858 21 6.01986 21C5.24114 21 4.60986 20.3687 4.60986 19.59C4.60986 18.8113 5.24114 18.18 6.01986 18.18C6.79858 18.18 7.42986 18.8113 7.42986 19.59Z",stroke:"currentColor",strokeLinejoin:"round"}),e.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.25 6.37L20.89 8.06L20.14 14.8H6.19",stroke:"currentColor",strokeLinejoin:"round"})),e.createElement("defs",null,e.createElement("clipPath",{id:"clip0_102_196"},e.createElement("rect",{vectorEffect:"non-scaling-stroke",width:19.29,height:19.5,fill:"white",transform:"translate(2.3501 2.25)"})))),C=({className:r,title:a,routeHome:t,...o})=>{const c=h({Title:"Checkout.EmptyCart.title",Button:"Checkout.EmptyCart.button"});return n(l,{...o,"data-testid":"checkout-empty-cart",className:i(["checkout-empty-cart",r]),heading:a??c.Title,icon:n(m,{className:i(["checkout-empty-cart__icon"]),source:u}),action:t!=null&&t()?n(p,{className:"checkout-empty-cart__button",size:"medium",variant:"primary",type:"submit",href:t==null?void 0:t(),children:c.Button},"routeHome"):void 0})};export{x as E};
@@ -1 +1 @@
1
- import{jsx as c,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"./ToggleButton.js";import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact-hooks.js";import"./fixtures.js";import{classes as h}from"@dropins/tools/lib.js";import{Card as d,Icon as p,Image as O}from"@dropins/tools/components.js";/* empty css */import{useText as g}from"@dropins/tools/i18n.js";import*as t from"@dropins/tools/preact-compat.js";import{useState as L,useCallback as v,useEffect as E}from"@dropins/tools/preact-compat.js";const _=r=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},t.createElement("g",{clipPath:"url(#clip0_4797_15331)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_4797_15331"},t.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),b=({onCartProductsUpdate:r,routeCart:i})=>{const[o,u]=L([]),l=e=>e.outOfStock||e.insufficientQuantity,n=v(()=>{if(!r)return;const e=o.filter(s=>s.outOfStock).map(s=>({uid:s.uid,quantity:0}));r(e)},[o,r]);if(E(()=>{const e=f.on("cart/data",s=>{const m=(s==null?void 0:s.items)||[];u(m.filter(l))},{eager:!0});return()=>{e==null||e.off()}},[]),o.length===0)return null;const a=!o.some(e=>e.insufficientQuantity);return c(S,{items:o,onRemoveOutOfStock:a?n:void 0,routeCart:i==null?void 0:i()})},S=({className:r,items:i,onRemoveOutOfStock:o,routeCart:u,...l})=>{const n=g({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return k(d,{className:h(["checkout-out-of-stock",r]),"data-testid":"checkout-out-of-stock",variant:"secondary",...l,children:[k("h4",{className:"checkout-out-of-stock__title",children:[c(p,{source:_,size:"16",stroke:"1"}),n.title]}),c("p",{className:"checkout-out-of-stock__message",children:n.message}),c("ol",{className:"checkout-out-of-stock__items",children:i.map(a=>c("li",{"data-testid":"out-of-stock-item",className:"checkout-out-of-stock__item",children:c(O,{loading:"eager",src:a.image.src,alt:a.image.alt,width:"100",height:"100",params:{width:100}})},a.sku))}),k("div",{className:"checkout-out-of-stock__actions",children:[u&&c("a",{"data-testid":"review-cart",className:"checkout-out-of-stock__action",href:u,children:n.reviewCart}),o&&c("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:o,children:n.removeOutOfStock})]})]})};export{b as O,_ as S};
1
+ import{jsx as c,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";import"./ShippingMethods.js";import{events as f}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact-hooks.js";import"./getCart.graphql.js";import{classes as h}from"@dropins/tools/lib.js";import{Card as d,Icon as p,Image as O}from"@dropins/tools/components.js";import"./BillToShippingAddress.js";import{useText as g}from"@dropins/tools/i18n.js";import*as t from"@dropins/tools/preact-compat.js";import{useState as L,useCallback as v,useEffect as E}from"@dropins/tools/preact-compat.js";const _=r=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},t.createElement("g",{clipPath:"url(#clip0_4797_15331)"},t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.25 20.91L1.5 17.55V6.51996L10.25 9.92996V20.91Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.24023 4.64001L14.9902 8.06001V11.42",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19 13.31L15.5 19.37H22.5L19 13.31Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{className:"error-icon",vectorEffect:"non-scaling-stroke",d:"M19.0202 17.11H18.9802L18.9502 15.56H19.0502L19.0202 17.11ZM18.9602 18.29V18.06H19.0502V18.29H18.9602Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19 12.16V6.51996L10.25 9.92996V20.91L14.27 19.37L14.4 19.32",stroke:"currentColor",strokeLinejoin:"round"}),t.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.51999L10.25 3.04999L19 6.51999L10.25 9.92999L1.5 6.51999Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_4797_15331"},t.createElement("rect",{width:22,height:18.86,fill:"white",transform:"translate(1 2.54999)"})))),b=({onCartProductsUpdate:r,routeCart:i})=>{const[o,u]=L([]),l=e=>e.outOfStock||e.insufficientQuantity,n=v(()=>{if(!r)return;const e=o.filter(s=>s.outOfStock).map(s=>({uid:s.uid,quantity:0}));r(e)},[o,r]);if(E(()=>{const e=f.on("cart/data",s=>{const m=(s==null?void 0:s.items)||[];u(m.filter(l))},{eager:!0});return()=>{e==null||e.off()}},[]),o.length===0)return null;const a=!o.some(e=>e.insufficientQuantity);return c(S,{items:o,onRemoveOutOfStock:a?n:void 0,routeCart:i==null?void 0:i()})},S=({className:r,items:i,onRemoveOutOfStock:o,routeCart:u,...l})=>{const n=g({title:"Checkout.OutOfStock.title",message:"Checkout.OutOfStock.message",reviewCart:"Checkout.OutOfStock.actions.reviewCart",removeOutOfStock:"Checkout.OutOfStock.actions.removeOutOfStock"});return k(d,{className:h(["checkout-out-of-stock",r]),"data-testid":"checkout-out-of-stock",variant:"secondary",...l,children:[k("h4",{className:"checkout-out-of-stock__title",children:[c(p,{source:_,size:"16",stroke:"1"}),n.title]}),c("p",{className:"checkout-out-of-stock__message",children:n.message}),c("ol",{className:"checkout-out-of-stock__items",children:i.map(a=>c("li",{"data-testid":"out-of-stock-item",className:"checkout-out-of-stock__item",children:c(O,{loading:"eager",src:a.image.src,alt:a.image.alt,width:"100",height:"100",params:{width:100}})},a.sku))}),k("div",{className:"checkout-out-of-stock__actions",children:[u&&c("a",{"data-testid":"review-cart",className:"checkout-out-of-stock__action",href:u,children:n.reviewCart}),o&&c("button",{className:"checkout-out-of-stock__action","data-testid":"remove-out-of-stock",type:"button",onClick:o,children:n.removeOutOfStock})]})]})};export{b as O,_ as S};
@@ -1 +1 @@
1
- import{jsx as n,jsxs as j,Fragment as B}from"@dropins/tools/preact-jsx-runtime.js";import{e as O}from"./getMultilineValues.js";import{events as T}from"@dropins/tools/event-bus.js";import{w as P,x as L,n as w,q,y as V}from"./fixtures.js";import{s as Z}from"./setShippingMethods.js";import{classes as W}from"@dropins/tools/lib.js";import{H as $}from"./ToggleButton.js";import{IllustratedMessage as F,Icon as G,ProgressSpinner as J,RadioButton as K,Price as Q,Divider as X,Skeleton as Y,SkeletonRow as y}from"@dropins/tools/components.js";import{useState as I,useEffect as x}from"@dropins/tools/preact-hooks.js";/* empty css */import*as a from"@dropins/tools/preact-compat.js";import{useCallback as D,useMemo as U,useEffect as A}from"@dropins/tools/preact-compat.js";import{useText as ee}from"@dropins/tools/i18n.js";const v=P(void 0),te=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),ne=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),oe=e=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ie=({className:e,isLoading:t=!1,onSelectionChange:r=()=>{},options:s,selection:o,...m})=>{const u=ee({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return s===void 0?n(re,{}):j("div",{...m,className:W(["checkout-shipping-methods",e]),children:[n($,{level:3,className:"checkout-shipping-methods__title",children:u.Title}),!t&&s.length===0&&n(F,{icon:n(G,{source:oe}),message:n("p",{children:u.EmptyState})}),j("div",{className:W(["checkout-shipping-methods__content"]),children:[t&&n(J,{className:"checkout-shipping-methods__spinner"}),n("div",{className:W(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:s.map(i=>n(K,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:i.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:j(B,{children:[n(Q,{amount:i.amount.value,currency:i.amount.currency})," ",n("span",{children:i.carrier.title})]}),description:i.title,value:i.value,checked:(o==null?void 0:o.value)===i.value,onChange:()=>r(i)},i.value))})]}),n(X,{variant:"primary"})]})},re=()=>j(Y,{"data-testid":"shipping-methods-skeleton",children:[n(y,{variant:"heading",size:"small"}),n(y,{variant:"empty",size:"small"}),n(y,{size:"medium",fullWidth:!0}),n(y,{size:"medium",fullWidth:!0})]});function se(){var c;const[e,t]=I(),[r,s]=I();x(()=>{T.on("checkout/address",({address:M,type:S})=>{S==="shipping"&&t(M)})},[]),x(()=>{s(v.value)},[v.value]),x(()=>{L.value.pending?s(void 0):s(v.value)},[L.value.pending]);const{country_id:o,region_id:m,region:u,postcode:i}=e||{},p=!!e,f=w.value.data,k=!!((c=f==null?void 0:f.shippingAddresses)!=null&&c[0]);x(()=>{k||!r||!p||T.emit("shipping/estimate",{address:te({country_id:o,region_id:m,region:u,postcode:i}),shippingMethod:ne(r)})},[r,o,m,u,i,p,k])}const b=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function ce({onCheckoutDataUpdate:e,preSelectedMethod:t}){const r=q.value.data,s=!r,o=w.value.data,m=w.value.pending,u=L.value.data,i=L.value.pending,p=v.value,f=o==null?void 0:o.id,k=o==null?void 0:o.shippingAddresses,c=k==null?void 0:k[0],M=!!c,S=c==null?void 0:c.availableShippingMethods,E=c==null?void 0:c.selectedShippingMethod,d=S||u,N=D(l=>{if(!M)return;const g={method_code:l.code,carrier_code:l.carrier.code};Z([g]).then(()=>{e==null||e()}).catch(_=>{console.error("setting shipping methods on cart failed:",_)})},[M,e]),R=l=>{v.value=l},h=U(()=>{if(!(d!=null&&d.length))return;const l=d[0],g=p||E;return g?d.some(C=>b(C,g))?g:l:d.find(H=>H.carrier.code===(t==null?void 0:t.carrierCode)&&H.code===(t==null?void 0:t.methodCode))||l},[p,E,d,t]);return A(()=>{h&&((!p||!b(h,p))&&(v.value=h),(!E||!b(h,E))&&N(h))},[h,p,E,N]),A(()=>{if(!f||S)return;const{country:l,selectedRegion:g,selectedRegionId:_}=V.value,C=l||(r==null?void 0:r.defaultCountry);C&&O({criteria:{country_code:C,region_name:g,region_id:_}}).catch(z=>{L.value={pending:!1,data:[]},console.error("shipping methods estimation failed:",z)})},[f,S,r]),{isLoading:m||s||i,options:d,selection:h,onSelectionChange:R}}const Ee=e=>{const{isLoading:t,options:r,selection:s,onSelectionChange:o}=ce(e);return se(),n(ie,{...e,className:"checkout-shipping-methods",isLoading:t,onSelectionChange:o,options:r,selection:s})};export{Ee as S};
1
+ import{jsx as o,Fragment as X,jsxs as M}from"@dropins/tools/preact-jsx-runtime.js";import{d as ve,A as b,f as B,e as _e,D as oe,g as Ue,M as ke,h as Fe,p as Le,i as Ze,s as Ke,a as Xe,b as Je,c as Ye}from"./setShippingMethods.js";import{events as ee}from"@dropins/tools/event-bus.js";import{z as Qe,A as q,y as O,n as T,V as z,w as Me,B as et,m as be,o as de,v as Ie,k as tt,E as Q}from"./getCart.graphql.js";import{useState as H,useCallback as K,useEffect as x,useRef as nt,useMemo as ot}from"@dropins/tools/preact-hooks.js";import{classes as R,getFormErrors as rt,Slot as Ee,VComponent as I}from"@dropins/tools/lib.js";import{Text as j,useText as J}from"@dropins/tools/i18n.js";import{Field as re,Input as ue,Picker as it,Skeleton as me,SkeletonRow as A,IllustratedMessage as Se,Icon as Ae,ProgressSpinner as he,Button as st,Divider as U,RadioButton as Ne,Price as at}from"@dropins/tools/components.js";import{w as Y,c as lt}from"./BillToShippingAddress.js";import{s as we}from"./setBillingAddress.js";import*as $ from"@dropins/tools/preact-compat.js";import{forwardRef as ct,useRef as Pe,useImperativeHandle as dt,useState as G,useEffect as V,useMemo as Re,useCallback as te}from"@dropins/tools/preact-compat.js";import{E as ut}from"./ErrorBanner.js";import{M as mt}from"./MergedCartBanner.js";const Z=Qe(void 0),ht=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),gt=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ge={firstname:"given-name",lastname:"family-name",company:"organization",country:"country",region:"address-level1",city:"address-level2",postcode:"postal-code",telephone:"tel",street:"address-line1",email:"email",middlename:"additional-name",prefix:"honorific-prefix",suffix:"honorific-suffix"};function $e(e){return Object.keys(e).length===0&&e.constructor===Object}const pt=e=>e.map(t=>{var r;const n=((r=t==null?void 0:t.id)==null?void 0:r.toString())||t.code;return{text:t.name,value:n}}),ft=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function vt({address:e,addressType:t,availableCountries:n,availableRegions:r,config:i,dismissError:a,errors:s,fields:l,onBlur:d,onChange:h,onInvalid:c,onSelection:p,setAddress:u}){const E=()=>{u(m=>({...m,[b.Region]:"",[b.RegionId]:""})),a(b.Region)},v=m=>{u(w=>({...w,[b.RegionId]:m}))};return l.map(m=>{var C;let w,F=m.frontendInput,k=p,f=h,L=m.isDisabled,P=m.isRequired,N=[],S;return F===q.Multiline?(S=ve(m.code,e),w=ve(m.code,s)):(S=e[m.code],w=s[m.code]||""),m.code===b.Country&&(N=ft(n),t===B.SHIPPING&&(O.value.country=S,k=g=>{const y=g.target,{value:_}=y;_&&le({country_code:_}),p(g),E()})),m.code===b.RegionId&&t===B.SHIPPING&&(O.value.selectedRegionId=S),m.code===b.Region&&(t===O.value.addressType&&(L=O.value.pending),P=i.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),N=pt(r),!P&&!i.displayStateIfOptional&&(F=q.Undefined),F=N.length>0?q.Select:q.Text,F===q.Select?t===B.SHIPPING?(O.value.selectedRegion=S,k=g=>{const _=g.target.value;le({country_code:O.value.country,region_id:_}),p(g),v(_)}):k=g=>{p(g);const _=g.target.value;v(_)}:F===q.Text&&t===B.SHIPPING&&(O.value.selectedRegion=S,f=g=>{const y=g.target,{value:_}=y;O.value.country&&le({country_code:O.value.country,region_name:_}),h(g)}),S=N.length>0?((C=N.find(g=>g.value===S))==null?void 0:C.value)||"":S),m.code===b.PostCode&&(P=!i.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...m,error:w,frontendInput:F,handleSelect:k,isDisabled:L,isRequired:P,onBlur:d,onChange:f,onInvalid:c,options:N,value:S}})}let Ce;function le(e){var a;const t=T.value.data,n=!!t,r=(a=t==null?void 0:t.shippingAddresses)==null?void 0:a[0],i=r==null?void 0:r.availableShippingMethods;n&&!i&&(clearTimeout(Ce),Ce=setTimeout(()=>{_e({criteria:e})},oe))}const ie=({addressType:e,code:t,index:n})=>n?`${e}-${t}-${n}`:`${e}-${t}`,se=e=>`checkout-address-form__${e}`,kt=({addressType:e,element:t})=>{const{code:n,value:r,defaultValue:i}=t;return o("input",{className:se(n),id:ie({addressType:e,code:n}),name:n,type:"hidden",value:r||i},n)},Ft=({addressType:e,element:t})=>{const{code:n,error:r,isDisabled:i,label:a,onBlur:s,onChange:l,onInvalid:d,validateRules:h,value:c}=t,p=xe(h);return o(re,{disabled:i,error:r,children:o(ue,{"aria-label":a,autocomplete:ge[n]||"off",className:se(n),floatingLabel:`${a} ${t.isRequired?"*":""}`,id:ie({addressType:e,code:n}),onBlur:s,onChange:l,onInvalid:d,placeholder:a,required:t.isRequired||!1,type:"text",name:n,value:c??void 0,...p})})},Et=({addressType:e,element:t})=>{const{code:n,error:r,isDisabled:i,isRequired:a,label:s,multilineCount:l,onBlur:d,onChange:h,onInvalid:c,validateRules:p,value:u}=t,E=l??0,v=xe(p);return o(X,{children:Array.from(Array(E).keys()).map(m=>o(re,{disabled:i,error:(r==null?void 0:r[m])||"",className:"dropin-field--multiline",children:o(ue,{id:ie({addressType:e,code:n,index:m}),className:se(n),floatingLabel:`${s} ${m!=0?m:""} ${a&&m===0?"*":""}`,autocomplete:m===0?ge[n]:"off","aria-label":s,placeholder:`${s} ${m!=0?m:""}`,type:"text",required:a&&m===0,onChange:h,onBlur:d,onInvalid:c,name:`${n}-${m}`,value:(u==null?void 0:u[m])||void 0,...v})},`${n}-${m}`))})},Ct=({addressType:e,element:t})=>{const{code:n,error:r,handleSelect:i,isDisabled:a,isRequired:s,label:l,onBlur:d,onInvalid:h,options:c,value:p}=t,u=i?{handleSelect:i}:{};return o(re,{disabled:a,error:r,children:o(it,{id:ie({addressType:e,code:n}),className:se(n),name:n,floatingLabel:`${l} ${s?"*":""}`,required:s,placeholder:l,"aria-label":l,options:c,value:p,autocomplete:ge[n]||"off",onBlur:d,onInvalid:h,...u},n)})},yt=({addressType:e,element:t})=>{switch(t.frontendInput){case"BOOLEAN":case"DATE":case"DATETIME":case"FILE":case"GALLERY":case"IMAGE":case"MEDIA_IMAGE":case"MULTISELECT":case"PRICE":case"TEXTAREA":case"UNDEFINED":case"WEIGHT":return null;case"HIDDEN":return kt({addressType:e,element:t});case"TEXT":return Ft({addressType:e,element:t});case"MULTILINE":return Et({addressType:e,element:t});case"SELECT":return Ct({addressType:e,element:t});default:return null}},xe=e=>e?e.reduce((t,n)=>{switch(n.name){case z.DateRangeMax:return{...t,max:n.value};case z.DateRangeMin:return{...t,min:n.value};case z.FileExtensions:return{...t,accept:n.value};case z.InputValidation:return{...t,pattern:_t(n.value)};case z.MaxFileSize:case z.MaxImageHeight:case z.MaxImageWidth:return t;case z.MaxTextLength:return{...t,maxLength:n.value};case z.MinTextLength:return{...t,minLength:n.value};default:throw new Error(`Unknown rule: ${n.name}`)}},{}):{},D={alpha:/^[a-zA-Z]+$/,alphanumeric:/^[a-zA-Z0-9]+$/,"alphanumeric-w-space":/^[a-zA-Z0-9 ]+$/,"alphanum-with-spaces":/^[a-zA-Z0-9 ]+$/,email:/^([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!#$%&'*+/=?^_`{|}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i,numeric:/^[0-9]+$/,url:/^((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www\.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w\-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\\w]*))?)$/},_t=e=>{switch(e){case"alpha":return D.alpha.source;case"alphanumeric":return D.alphanumeric.source;case"alphanumeric-w-space":return D["alphanumeric-w-space"].source;case"alphanum-with-spaces":return D["alphanum-with-spaces"].source;case"url":return D.url.source;case"numeric":return D.numeric.source;case"email":return D.email.source;default:throw new Error(`Unknown validation type: ${e}`)}},Lt=e=>M(me,{...e,children:[o(A,{variant:"heading",size:"medium"}),o(A,{variant:"empty",size:"medium"}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large",fullWidth:!0}),o(A,{size:"large",fullWidth:!0,lines:3}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large"}),o(A,{size:"large"})]}),Mt=({addressType:e,className:t,fields:n,formRef:r,headingId:i,name:a,...s})=>M("div",{...s,className:R(["checkout-fields-form",t]),children:[o(ne,{level:2,children:o(j,{id:i}),className:"checkout-fields-form__title"}),o("form",{name:a,ref:r,className:R(["checkout-fields-form__form",t]),noValidate:!0,children:n.sort((l,d)=>!l.sortOrder||!d.sortOrder?l.code<d.code?-1:1:l.sortOrder-d.sortOrder).map(l=>yt({element:l,addressType:e}))})]}),bt=e=>{const t=new FormData(e),n=Object.fromEntries(t);return Object.entries(n).reduce((i,[a])=>{const s=e.elements[a];return s!=null&&s.validationMessage?{...i,[a]:s.validationMessage}:{...i}},{})};function It(e){const[t,n]=G({});return V(()=>{e&&n(r=>({...r,country_id:e}))},[e]),{defaultValues:t}}function St({country:e,addressType:t}){const[n,r]=G([]);return V(()=>{if(!e){r([]);return}Ue(e,t).then(i=>{r(i||[])}).catch(i=>{console.error(i)})},[r,e,t]),{availableRegions:n}}function At({autoFill:e,addressType:t,dismissError:n,loadAutoFill:r}){const[i,a]=G(!1),s=de.value.data,l=!!s,d=T.value.data,h=!!d;V(()=>{var w;if(!e||!h||i)return;let c,p=!1;c=jt({addressType:t,cart:d}),!c&&l&&(c=Gt({addressType:t,customer:s}),p=!0);const u=F=>F?F.split(Fe).length>1:!1;if(!c)return;a(!0);const E={[b.City]:c.city,[b.Company]:c.company||"",[b.Country]:c.country.value,[b.FirstName]:c.firstName,[b.LastName]:c.lastName,[b.PostCode]:c.postCode||"",[b.Telephone]:c.telephone||"",[b.Vat]:c.vatId||""},v=c.region;if(v){const F=(w=v==null?void 0:v.id)==null?void 0:w.toString();F?(E[b.Region]=F,E[b.RegionId]=F):E[b.Region]=v.code}c!=null&&c.street&&c.street.length>0&&c.street.forEach((F,k)=>{E[`${b.Street}${ke}${k}`]=F}),((c==null?void 0:c.customAttributes)||[]).forEach(F=>{u(F.code)?F.value.split(Fe).forEach((f,L)=>{E[`${F.code}${ke}${L}`]=f}):E[F.code]=F.value}),r({values:E,triggerAutoSave:p})},[t,e,d,s,i,h,l,r,n])}const Be=ct(({addressType:e,autoFill:t=!0,children:n,headingId:r,name:i,preselectedFields:a,saveAddressHandler:s,onCheckoutDataUpdate:l,...d},h)=>{const{data:c,pending:p}=Me.value,u=et.value.data,E=u===void 0,v=c===void 0||p,m=be.value.data,w=m===void 0,{defaultValues:F}=It(m==null?void 0:m.defaultCountry),k=Dt({fields:c,preselectedFields:a}),f=Pe(null),{address:L,errors:P,loadAutoFill:N,onBlur:S,dismissError:C,onChange:g,onInvalid:y,onSelection:_,setAddress:W}=Vt({defaultValues:F,formRef:f,onCheckoutDataUpdate:l,preselection:k,saveAddressHandler:s,type:e}),{availableRegions:ae}=St({country:L.country_id,addressType:e});if(dt(h,()=>({triggerSaveAddress:je=>{if(!f.current)return;const qe=bt(f.current);if($e(qe))return s({signal:je,address:L})}})),At({addressType:e,autoFill:t,loadAutoFill:N,dismissError:C}),v||E||w)return o(Lt,{"data-testid":`${e}-skeleton`});const Ge=vt({address:L,addressType:e,availableCountries:u,availableRegions:ae,config:m,dismissError:C,errors:P,fields:c,onBlur:S,onChange:g,onInvalid:y,onSelection:_,setAddress:W}),fe={[B.SHIPPING]:"shipping",[B.BILLING]:"billing"};return o(Mt,{...d,name:i,addressType:e,className:`checkout-${fe[e]}-form`,"data-testid":`${fe[e]}-form`,fields:Ge,formRef:f,headingId:r})}),Nt="DROPIN__CHECKOUT",pe=e=>`${Nt}__${e.toUpperCase()}`,wt=(e,t)=>{window.localStorage.setItem(pe(e),JSON.stringify(t))},Pt=e=>{const t=window.localStorage.getItem(pe(e));return t?JSON.parse(t):null},Rt=e=>{window.localStorage.removeItem(pe(e))};function $t(e){const[t,n]=H(null),r=K(a=>setTimeout(()=>{wt(e,a)},oe),[e]),i=K(()=>{Rt(e)},[e]);return x(()=>{const a=Pt(e);a&&n(a)},[e]),x(()=>{const a=ee.on("checkout/order",()=>{i()});return()=>{a==null||a.off()}},[i]),{addressBackup:t,backupAddress:r,removeAddressBackup:i}}const xt={[B.BILLING]:"billing",[B.SHIPPING]:"shipping"};function Bt({address:e,type:t}){x(()=>{const n=setTimeout(()=>{ee.emit("checkout/address",{type:xt[t],address:e})},oe);return()=>{clearTimeout(n)}},[e,t])}const Ot={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},Ht=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],Tt=e=>{const[t,n]=H({}),r=K(s=>{const{name:l,validity:d,validationMessage:h}=s;let c=d.valid?"":h;Ht.forEach(p=>{if(!d[p])return;const u=e[p];if(!u)return;const E=Ot[p];c=u.replace("{field}",s.getAttribute(E)||"")}),n(p=>({...p,[l]:c}))},[e]);return{errors:t,dismissError:s=>{t[s]&&n(l=>{const{[s]:d,...h}=l;return h})},validateFormElement:r,resetErrors:()=>{n({})}}},zt=e=>{const t=e.current;if(!t)return!1;const n=rt(t);return $e(n)},Vt=({defaultValues:e={},formRef:t,onCheckoutDataUpdate:n,preselection:r={},saveAddressHandler:i,type:a})=>{const s=J({badInput:"Checkout.AddressForm.Validity.badInput",patternMismatch:"Checkout.AddressForm.Validity.patternMismatch",rangeUnderflow:"Checkout.AddressForm.Validity.rangeUnderflow",tooLong:"Checkout.AddressForm.Validity.tooLong",tooShort:"Checkout.AddressForm.Validity.tooShort",typeMismatch:"Checkout.AddressForm.Validity.typeMismatch",valueMissing:"Checkout.AddressForm.Validity.valueMissing"}),l=nt(!1),[d,h]=H({});Bt({address:d,type:a});const{addressBackup:c,backupAddress:p,removeAddressBackup:u}=$t(a),{errors:E,validateFormElement:v,dismissError:m,resetErrors:w}=Tt(s),F=K(C=>{l.current=!1,i(C).then(()=>{u(),n==null||n()}).catch(g=>{l.current=!0,console.error("Saving address form failed:",g)})},[u,i,n]),k=(C,g)=>{h(y=>({...y,[C]:g})),l.current=!0},f=({values:C,triggerAutoSave:g=!1})=>{w(),h(y=>({...y,...C})),g&&(l.current=!0)},L=C=>{const g=C.target,{name:y,value:_}=g;k(y,_),v(g)},P=C=>{const g=C.target;v(g)},N=C=>{const g=C.target,{name:y,value:_}=g;k(y,_),v(g)},S=C=>{C.target.checkValidity()};return x(()=>{h(C=>({...e,...r,...c,...C}))},[e,r,c]),x(()=>{if(!l.current)return;const C=p(d);return()=>{clearTimeout(C)}},[d,p]),x(()=>{if(!l.current||!zt(t))return;const C=new AbortController,g=C.signal,y=setTimeout(()=>{F({signal:g,address:d})},oe);return()=>{clearTimeout(y),C.abort()}},[d,t,F]),{address:d,errors:E,loadAutoFill:f,dismissError:m,onChange:L,onSelection:N,onBlur:S,onInvalid:P,setAddress:h}},Wt={countryCode:b.Country,region:b.Region,postCode:b.PostCode};function Dt({fields:e,preselectedFields:t}){return ot(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((i,a)=>{const s=Wt[a];return!s||!e.some(d=>d.code===s)?i:{...i,[s]:t[a]}},{}),[e,t])}const Gt=({addressType:e,customer:t})=>e===B.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,jt=({addressType:e,cart:t})=>{if(e===B.BILLING)return t.billingAddress;const n=t.shippingAddresses;if(!(!n||n.length===0))return n[0]},Oe=e=>{var E;const t=Pe(null),n=Me.value.data,r=de.value.data,i=r==null?void 0:r.defaultBillingAddress,a=T.value.data,s=a==null?void 0:a.billingAddress,l=(E=a==null?void 0:a.shippingAddresses)==null?void 0:E[0],{checked:d,setByUser:h}=Ie.value,c=!d,p=Re(()=>!n||!c?!1:s?!lt(n,s,l):!!i,[c,n,s,l,i]),u=te(v=>we({signal:v.signal,input:{address:d?void 0:Le(v.address),same_as_shipping:d}}),[d]);return V(()=>{if(!h)return;const v=new AbortController;return d||t.current.triggerSaveAddress(v.signal),()=>{v.abort()}},[d,h]),o(Be,{...e,addressType:B.BILLING,autoFill:p,"data-testid":"billing-form",headingId:"Checkout.BillingAddress.title",name:qt,ref:t,saveAddressHandler:u,style:{display:c?"block":"none"}})};Oe.displayName="BillingFormContainer";const Hn=Y(Oe),qt="billing_address",Ut=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Zt=e=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),He="login-form",Kt=({value:e,error:t,hint:n,onChange:r,onBlur:i,onInvalid:a})=>{const s=J({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return o(re,{size:"medium",error:t,hint:n,children:o(ue,{id:"customer-email",name:"customer-email",type:"email",value:e,autocomplete:"email",placeholder:s.LoginFormPlaceholder,floatingLabel:s.LoginFormFloatingLabel,onChange:r,onBlur:i,onInvalid:a,required:!0,"aria-label":s.LoginFormLabel,"aria-required":!0})})},Xt=({onSignInClick:e,email:t})=>M("div",{className:"checkout-login-form__sign-in",children:[o(j,{id:"Checkout.LoginForm.account"}),o("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:n=>{n.preventDefault(),e==null||e(t)},children:o(j,{id:"Checkout.LoginForm.signIn"})})]}),Jt=({name:e,className:t,currentEmail:n,hint:r,error:i=null,onEmailChange:a,onEmailBlur:s,onEmailInvalid:l,onSignInClick:d,onSignOutClick:h,customer:c,...p})=>{const u=J({Title:"Checkout.LoginForm.title"}),E=!!c;return M("div",{...p,className:R(["checkout-login-form",t]),"data-testid":"checkout-login-form",children:[M("div",{className:"checkout-login-form__heading",children:[o(ne,{level:2,className:"checkout-login-form__title",children:u.Title}),E?o(Yt,{onSignOutClick:h}):o(Xt,{onSignInClick:d,email:n})]}),c?M("div",{className:"checkout-login-form__customer-details",children:[o("div",{className:"checkout-login-form__customer-name",children:`${c==null?void 0:c.firstName} ${c==null?void 0:c.lastName}`}),o("div",{className:"checkout-login-form__customer-email",children:c==null?void 0:c.email})]}):o("div",{className:"checkout-login-form__content",children:M("form",{className:R(["dropin-login-form__form",t]),name:e,noValidate:!0,children:[o("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),o(Kt,{value:n||void 0,error:i||"",hint:r,onChange:a,onBlur:s,onInvalid:l})]})})]})},Yt=({onSignOutClick:e})=>M("p",{className:"checkout-login-form__sign-out",children:[o(j,{id:"Checkout.LoginForm.switch"}),o("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t=>{t.preventDefault(),e==null||e()},children:o(j,{id:"Checkout.LoginForm.signOut"})})]}),Qt=e=>D.email.test(e),en=1e3,Te=({className:e,email:t=null,onSignInClick:n,onSignOutClick:r,...i})=>{const a=J({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),{data:s}=T.value,l=(s==null?void 0:s.id)||"",d=!!s,h=(s==null?void 0:s.email)||"",[c,p]=H(!1),[u,E]=H(t),[v,m]=H(null),[w,F]=H(!0),k=g=>g.valid?null:g.valueMissing?a.LoginFormMissingEmailError:a.LoginFormInvalidEmailError,f=de.value.data,L=g=>{const{value:y}=g.target;E(y),m(null),F(!0)},P=g=>{const{validity:y}=g.target;m(k(y))},N=g=>{const{validity:y}=g.target;m(k(y))};!c&&d&&(p(!0),E((s==null?void 0:s.email)||t)),x(()=>{if(v!==null&&v!==""||u===null||u===""||tt.authenticated)return;const g=setTimeout(()=>{Ze(u).then(y=>{F(y),h!==u&&Ke(u).catch(console.error)}).catch(y=>{console.log(y),m(a.LoginFormInvalidEmailError),F(!0)})},en);return()=>{g&&clearTimeout(g)}},[h,l,u,v,a.LoginFormInvalidEmailError]);const S=w?"":M(X,{children:[a.LoginFormEmailExistsAlreadyHaveAccount," ",o("a",{href:"#",onClick:g=>{g.preventDefault(),n==null||n(u)},children:a.LoginFormEmailExistsSignInButton})," ",a.LoginFormEmailExistsForFasterCheckout]});return o(Jt,{className:e,currentEmail:u,error:v,hint:S,name:He,onEmailBlur:P,onEmailChange:L,onEmailInvalid:N,onSignInClick:g=>{const y=u?Qt(u):!1;n==null||n(y?g:null)},onSignOutClick:r,customer:f,...i})};Te.displayName="LoginFormContainer";const Tn=Y(Te),tn=()=>M(me,{"data-testid":"payment-methods-skeleton",children:[o(A,{variant:"heading",size:"medium"}),o(A,{variant:"empty",size:"medium"}),o(A,{size:"xlarge",fullWidth:!0}),o(A,{size:"xlarge",fullWidth:!0})]}),nn=({code:e,isLoading:t,isSelected:n,onChange:r,title:i})=>o(Fn,{className:"checkout-payment-methods__method",label:i,name:"payment-method",value:e,selected:n,onChange:r,radioButtonProps:{"aria-busy":t}}),on=({className:e,paymentMethodContent:t,isLoading:n,onChange:r=()=>{},options:i,selection:a})=>{const s=J({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return i===void 0?o(tn,{}):M("div",{className:R(["checkout-payment-methods",e]),children:[o(ne,{level:2,className:"checkout-payment-methods__title",children:s.Title}),!n&&i.length===0&&o(Se,{icon:o(Ae,{source:Ut}),message:o("p",{children:s.EmptyState})}),M("div",{className:R(["checkout-payment-methods__wrapper"]),children:[n&&o(he,{className:"checkout-payment-methods__spinner"}),o("div",{className:R(["checkout-payment-methods__methods",["checkout-payment-methods--loading",n],["checkout-payment-methods--full-width",i.length%2!==0]]),children:i==null?void 0:i.map(l=>o(nn,{code:l.code,onChange:r,isSelected:l.code===a,title:l.title},l.code))}),t&&o("div",{className:"checkout-payment-methods__content",children:t})]})]})},ye={free:{render:e=>{const t=document.createElement("div");t.innerText="",e.replaceHTML(t)}},checkmo:{render:e=>{const t=document.createElement("div");t.innerText="",e.replaceHTML(t)}}};function rn(e){var y;const{onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r}=e,[i,a]=G(),[s,l]=G(),[d,h]=G(ye),[c,p]=G(!0),{data:u}=T.value,E=(u==null?void 0:u.id)??"",v=!!u,m=!!((y=u==null?void 0:u.shippingAddresses)!=null&&y[0]),F=!((u==null?void 0:u.isVirtual)??!1),k=u==null?void 0:u.availablePaymentMethods,f=u==null?void 0:u.selectedPaymentMethod,L=te(async _=>{try{if(a(_),!m&&F||_===(f==null?void 0:f.code))return;await Xe(_)}catch(W){console.error("setting payment method failed:",W)}},[m,F,f]);V(()=>{v&&(f!=null&&f.code?(k==null?void 0:k.some(W=>W.code===f.code))?a(f.code):k!=null&&k.length?L(k[0].code):a(void 0):k[0]&&L(s||k[0].code))},[k,v,f,L,s]);const P=async _=>{await L(_),f!=null&&f.code||l(_)},N=te((_,W)=>{if(!_){console.warn("Payment method handler is ignored because it has no code");return}if(!W){console.warn("Payment method handler is ignored because it is empty");return}h(ae=>({...ae,[_]:W}))},[]),S=r?o(Ee,{name:"PaymentMethods",slot:r,context:{addPaymentMethodHandler:N,replaceHTML(_){this.replaceWith(_),p(!1)}}}):null,C=i?d[i]:null,g=C?o(Ee,{name:"PaymentMethodContent",slot:C.render,context:{cartId:E,onPlaceOrder:t,handleServerError:n,replaceHTML(_){this.replaceWith(_)}}},C):void 0;return V(()=>{!c&&d!=ye&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),{availablePaymentMethods:k,selectedPaymentMethod:i,onPaymentMethodChange:P,paymentMethodContent:g,mainSlotContent:S,isDefaultContentUsed:c}}const ze=e=>{const{onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r}=e,{availablePaymentMethods:i,selectedPaymentMethod:a,onPaymentMethodChange:s,paymentMethodContent:l,mainSlotContent:d,isDefaultContentUsed:h}=rn({onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r});return M(X,{children:[d&&o(d.type,{ref:d.ref,...d.props}),h&&o(on,{options:i,selection:a,onChange:s,paymentMethodContent:l,isLoading:T.value.pending})]})};ze.displayName="PaymentMethodsContainer";const zn=Y(ze),sn=({className:e,onClick:t=()=>{},disabled:n=!1})=>o("div",{className:R(["checkout-place-order",e]),children:o(st,{className:R(["checkout-place-order__button",e]),"data-testid":"place-order-button",disabled:n,onClick:t,size:"medium",type:"submit",variant:"primary",children:o(j,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),an=[He,"shipping_address","billing_address"],ln=e=>{const t=e.querySelector(":invalid");t&&(t.scrollIntoView({behavior:"smooth"}),t.focus())},cn=()=>{const t=(Array.from(document.forms)||[]).filter(r=>an.includes(r.name)).filter(r=>r.offsetParent!==null).filter(r=>!r.checkValidity()),n=t.length===0;if(!n){const r=t[0];ln(r)}return n},dn=({onClick:e,handleServerError:t})=>{const[n,r]=G(!1),i=T.value.pending,a=async()=>{if(cn())try{await e()}catch(s){t(s)}};return V(()=>{const s=ee.on("cart/initialized",l=>{const d=(l==null?void 0:l.items)||[];r(d.some(h=>h.outOfStock||h.insufficientQuantity))},{eager:!0});return()=>{s==null||s.off()}},[]),o(sn,{onClick:a,disabled:i||n})},Vn=Y(dn),Ve=({onCheckoutDataUpdate:e,preselectedFields:t,...n})=>{const r=Ie.value.checked,i=te(a=>Je({signal:a.signal,address:Le(a.address)}).then(()=>{if(r)return we({input:{same_as_shipping:!0}})}),[r]);return o(Be,{...n,addressType:B.SHIPPING,headingId:"Checkout.ShippingAddress.title",name:un,onCheckoutDataUpdate:e,preselectedFields:t,saveAddressHandler:i})};Ve.displayName="ShippingFormContainer";const Wn=Y(Ve),un="shipping_address",mn=()=>{const e=()=>window.innerWidth>=1920?"xxlarge":window.innerWidth>=1366?"xlarge":window.innerWidth>=1024?"large":window.innerWidth>=768?"medium":"small",[t,n]=H(e());return x(()=>{let r;const i=()=>{r&&clearTimeout(r),r=setTimeout(()=>n(e()),50)};return window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i),r&&clearTimeout(r)}},[]),t},hn=()=>{const e=K(()=>{document.body.style.overflow="hidden"},[]),t=K(()=>{document.body.style.overflow=""},[]);return{lockScroll:e,unlockScroll:t}},We=()=>M("div",{className:"checkout-heading",children:[o(ne,{level:1,className:"checkout-heading__title",children:o(j,{id:"Checkout.title"})}),o(U,{variant:"primary",className:"checkout-heading__divider-primary"})]}),gn=({billingAddress:e,billToShippingAddress:t,cartSummaryList:n,emptyCart:r,login:i,orderSummary:a,outOfStock:s,paymentMethods:l,placeOrder:d,shippingAddress:h,shippingMethods:c})=>M(X,{children:[o(We,{}),n&&o(I,{node:n}),o(I,{node:r}),o(I,{node:s}),o(I,{node:i}),o(U,{variant:"primary"}),o(I,{node:h}),o(I,{node:t}),o(I,{node:c}),o(U,{variant:"primary"}),o(I,{node:l}),o(I,{node:e}),a&&o(I,{node:a}),o(I,{node:s}),o(I,{node:d})]}),pn=({billingAddress:e,billToShippingAddress:t,cartSummaryList:n,emptyCart:r,login:i,orderSummary:a,outOfStock:s,paymentMethods:l,placeOrder:d,shippingAddress:h,shippingMethods:c})=>M(X,{children:[M("div",{className:"checkout__main",children:[o(We,{}),o(I,{node:r}),o(I,{node:s}),o(I,{node:i}),o(U,{variant:"primary"}),o(I,{node:h}),o(I,{node:t}),o(I,{node:c}),o(U,{variant:"primary"}),o(I,{node:e}),o(I,{node:l}),o(U,{variant:"primary"}),o(I,{node:d})]}),M("div",{className:"checkout__aside",children:[a&&o(I,{node:a}),n&&o(I,{node:n})]})]}),fn=({blocks:e})=>mn()==="small"?o(gn,{...e}):o(pn,{...e}),vn=({children:e,className:t,isLoading:n=!1,...r})=>M("div",{"data-testid":"checkout",className:R(["checkout",t]),...r,children:[n&&o(kn,{}),o(ut,{}),o(mt,{}),o("div",{className:"checkout__content",children:e})]});vn.Main=fn;const ne=({className:e,children:t,level:n=2})=>{const r=n>=1&&n<=6?`h${n}`:"h2";return o(r,{className:e,children:t})},kn=({className:e})=>{const{lockScroll:t,unlockScroll:n}=hn();return x(()=>(t(),n),[t,n]),o("div",{"data-testid":"checkout-overlay-loader",className:R(["checkout-overlay-loader",e]),children:o(he,{})})},Fn=({label:e,name:t,value:n,icon:r,selected:i,onChange:a,className:s,children:l,radioButtonProps:d,...h})=>o("div",{className:R(["checkout-toggle-button",s,["checkout-toggle-button__selected",i]]),...h,children:M("label",{className:"checkout-toggle-button__actionButton",children:[o(Ne,{...d,label:"",name:t,value:n,checked:i,onChange:()=>a(n),"aria-label":e,className:R([s,"checkout-toggle-button__radioButton"])}),M("div",{className:"checkout-toggle-button__content",children:[r&&o(r.type,{...r==null?void 0:r.props,className:"checkout-toggle-button__icon"}),e]})]})}),En=({className:e,isLoading:t=!1,onSelectionChange:n=()=>{},options:r,selection:i,...a})=>{const s=J({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return r===void 0?o(Cn,{}):M("div",{...a,className:R(["checkout-shipping-methods",e]),children:[o(ne,{level:3,className:"checkout-shipping-methods__title",children:s.Title}),!t&&r.length===0&&o(Se,{icon:o(Ae,{source:Zt}),message:o("p",{children:s.EmptyState})}),M("div",{className:R(["checkout-shipping-methods__content"]),children:[t&&o(he,{className:"checkout-shipping-methods__spinner"}),o("div",{className:R(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:r.map(l=>o(Ne,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:l.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:M(X,{children:[o(at,{amount:l.amount.value,currency:l.amount.currency})," ",o("span",{children:l.carrier.title})]}),description:l.title,value:l.value,checked:(i==null?void 0:i.value)===l.value,onChange:()=>n(l)},l.value))})]})]})},Cn=()=>M(me,{"data-testid":"shipping-methods-skeleton",children:[o(A,{variant:"heading",size:"small"}),o(A,{variant:"empty",size:"small"}),o(A,{size:"medium",fullWidth:!0}),o(A,{size:"medium",fullWidth:!0})]});function yn(){var p;const[e,t]=H(),[n,r]=H();x(()=>{ee.on("checkout/address",({address:u,type:E})=>{E==="shipping"&&t(u)})},[]),x(()=>{r(Z.value)},[Z.value]),x(()=>{Q.value.pending?r(void 0):r(Z.value)},[Q.value.pending]);const{country_id:i,region_id:a,region:s,postcode:l}=e||{},d=!!e,h=T.value.data,c=!!((p=h==null?void 0:h.shippingAddresses)!=null&&p[0]);x(()=>{c||!n||!d||ee.emit("shipping/estimate",{address:ht({country_id:i,region_id:a,region:s,postcode:l}),shippingMethod:gt(n)})},[n,i,a,s,l,d,c])}const ce=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function _n({onCheckoutDataUpdate:e,preSelectedMethod:t}){const n=be.value.data,r=!n,i=T.value.data,a=T.value.pending,s=Q.value.data,l=Q.value.pending,d=Z.value,h=i==null?void 0:i.id,c=i==null?void 0:i.shippingAddresses,p=c==null?void 0:c[0],u=!!p,E=p==null?void 0:p.availableShippingMethods,v=p==null?void 0:p.selectedShippingMethod,m=E||s,w=te(f=>{if(!u)return;const L={method_code:f.code,carrier_code:f.carrier.code};Ye([L]).then(()=>{e==null||e()}).catch(P=>{console.error("setting shipping methods on cart failed:",P)})},[u,e]),F=f=>{Z.value=f},k=Re(()=>{if(!(m!=null&&m.length))return;const f=m[0],L=d||v;return L?m.some(N=>ce(N,L))?L:f:m.find(S=>S.carrier.code===(t==null?void 0:t.carrierCode)&&S.code===(t==null?void 0:t.methodCode))||f},[d,v,m,t]);return V(()=>{k&&((!d||!ce(k,d))&&(Z.value=k),(!v||!ce(k,v))&&w(k))},[k,d,v,w]),V(()=>{if(!h||E)return;const{country:f,selectedRegion:L,selectedRegionId:P}=O.value,N=f||(n==null?void 0:n.defaultCountry);N&&_e({criteria:{country_code:N,region_name:L,region_id:P}}).catch(C=>{Q.value={pending:!1,data:[]},console.error("shipping methods estimation failed:",C)})},[h,E,n]),{isLoading:a||r||l,options:m,selection:k,onSelectionChange:F}}const De=({preSelectedMethod:e,onCheckoutDataUpdate:t,...n})=>{const{isLoading:r,options:i,selection:a,onSelectionChange:s}=_n({preSelectedMethod:e,onCheckoutDataUpdate:t});return yn(),o(En,{...n,className:"checkout-shipping-methods",isLoading:r,onSelectionChange:s,options:i,selection:a})};De.displayName="ShippingMethodsContainer";const Dn=Y(De);export{Hn as B,vn as C,Tn as L,Vn as P,Dn as S,Wn as a,un as b,zn as c,He as d,qt as e};
@@ -1,4 +1,18 @@
1
- import{t as a,u as l}from"./fixtures.js";const c=e=>{if(e)return{code:e.code,title:e.title}},d=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:i}=t;return{code:r,title:i}})},u=e=>e?!!e.code&&!!e.label:!1,m=e=>{if(!u(e))return;const{code:t,label:r,region_id:i}=e;return i?{code:t,name:r,id:i}:{code:t,name:r}},_=e=>{const{code:t,label:r}=e;return{value:t,label:r}},p=e=>e?"code"in e&&"value"in e:!1,h=e=>e.filter(p).map(t=>{const{code:r,value:i}=t;return{code:r,value:i}}),o=e=>{const t=e.street.filter(Boolean);return{firstName:e.firstname,lastName:e.lastname,company:e.company||void 0,city:e.city,street:t,postCode:e.postcode||void 0,vatId:e.vat_id||void 0,telephone:e.telephone||void 0,region:m(e.region),country:_(e.country),customAttributes:h(e.custom_attributes)}},y=e=>{if(e)return o(e)},g=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:i,...n}=t;return{...o(n),availableShippingMethods:a(r),selectedShippingMethod:l(i)}}),f=e=>({availablePaymentMethods:d(e.available_payment_methods),billingAddress:y(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:c(e.selected_payment_method),shippingAddresses:g(e.shipping_addresses)}),s=`
1
+ import{events as k}from"@dropins/tools/event-bus.js";import{Component as Y,options as O,isValidElement as J}from"@dropins/tools/preact.js";import{useMemo as $}from"@dropins/tools/preact-hooks.js";import{FetchGraphQL as K}from"@dropins/tools/fetch-graphql.js";class ee extends Error{constructor(t){super(t.map(i=>i.message).join(" ")),this.name="FetchError"}}class b extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class Fe extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class He extends b{constructor(){super("Cart ID is required")}}class Be extends b{constructor(){super("Email is required")}}class We extends b{constructor(){super("Payment method code is required")}}class Qe extends b{constructor(){super("Billing address is required")}}class Ve extends b{constructor(){super("Country Code is required")}}const A=[];function te(e){return new Promise((t,i)=>{A.push(e);const r=()=>{A[0]===e?e().then(t).catch(i).finally(()=>A.shift()):setTimeout(r,100)};r()})}const ie=["sender_email","recipient_email"];function re(e){return e.filter(t=>!t.path||!ie.some(i=>{var r;return((r=t.path)==null?void 0:r.at(-1))===i}))}const R=e=>{throw e instanceof DOMException&&e.name==="AbortError"||k.emit("error",{source:"checkout",type:"network",error:e}),e};var se=Symbol.for("preact-signals");function U(){if(y>1)y--;else{for(var e,t=!1;S!==void 0;){var i=S;for(S=void 0,M++;i!==void 0;){var r=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&F(i))try{i.c()}catch(o){t||(e=o,t=!0)}i=r}}if(M=0,y--,t)throw e}}var n=void 0,S=void 0,y=0,M=0,x=0;function P(e){if(n!==void 0){var t=e.n;if(t===void 0||t.t!==n)return t={i:0,S:e,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:t},n.s!==void 0&&(n.s.n=t),n.s=t,e.n=t,32&n.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=n.s,t.n=void 0,n.s.n=t,n.s=t),t}}function l(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}l.prototype.brand=se;l.prototype.h=function(){return!0};l.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)};l.prototype.U=function(e){if(this.t!==void 0){var t=e.e,i=e.x;t!==void 0&&(t.x=i,e.e=void 0),i!==void 0&&(i.e=t,e.x=void 0),e===this.t&&(this.t=i)}};l.prototype.subscribe=function(e){var t=this;return T(function(){var i=t.value,r=n;n=void 0;try{e(i)}finally{n=r}})};l.prototype.valueOf=function(){return this.value};l.prototype.toString=function(){return this.value+""};l.prototype.toJSON=function(){return this.value};l.prototype.peek=function(){var e=n;n=void 0;try{return this.value}finally{n=e}};Object.defineProperty(l.prototype,"value",{get:function(){var e=P(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(M>100)throw new Error("Cycle detected");this.v=e,this.i++,x++,y++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{U()}}}});function f(e){return new l(e)}function F(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function H(e){for(var t=e.s;t!==void 0;t=t.n){var i=t.S.n;if(i!==void 0&&(t.r=i),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function B(e){for(var t=e.s,i=void 0;t!==void 0;){var r=t.p;t.i===-1?(t.S.U(t),r!==void 0&&(r.n=t.n),t.n!==void 0&&(t.n.p=r)):i=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=r}e.s=i}function g(e){l.call(this,void 0),this.x=e,this.s=void 0,this.g=x-1,this.f=4}(g.prototype=new l).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===x))return!0;if(this.g=x,this.f|=1,this.i>0&&!F(this))return this.f&=-2,!0;var e=n;try{H(this),n=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return n=e,B(this),this.f&=-2,!0};g.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}l.prototype.S.call(this,e)};g.prototype.U=function(e){if(this.t!==void 0&&(l.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}};g.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(g.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=P(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function oe(e){return new g(e)}function W(e){var t=e.u;if(e.u=void 0,typeof t=="function"){y++;var i=n;n=void 0;try{t()}catch(r){throw e.f&=-2,e.f|=8,G(e),r}finally{n=i,U()}}}function G(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,W(e)}function ne(e){if(n!==this)throw new Error("Out-of-order effect");B(this),n=e,this.f&=-2,8&this.f&&G(this),U()}function E(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}E.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}};E.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,W(this),H(this),y++;var e=n;return n=this,ne.bind(this,e)};E.prototype.N=function(){2&this.f||(this.f|=2,this.o=S,S=this)};E.prototype.d=function(){this.f|=8,1&this.f||G(this)};function T(e){var t=new E(e);try{t.c()}catch(i){throw t.d(),i}return t.d.bind(t)}var D;function m(e,t){O[e]=t.bind(null,O[e]||function(){})}function I(e){D&&D(),D=e&&e.S()}function Q(e){var t=this,i=e.data,r=le(i);r.value=i;var o=$(function(){for(var s=t.__v;s=s.__;)if(s.__c){s.__c.__$f|=4;break}return t.__$u.c=function(){var a;!J(o.peek())&&((a=t.base)==null?void 0:a.nodeType)===3?t.base.data=o.peek():(t.__$f|=1,t.setState({}))},oe(function(){var a=r.value.value;return a===0?0:a===!0?"":a||""})},[]);return o.value}Q.displayName="_st";Object.defineProperties(l.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:Q},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});m("__b",function(e,t){if(typeof t.type=="string"){var i,r=t.props;for(var o in r)if(o!=="children"){var s=r[o];s instanceof l&&(i||(t.__np=i={}),i[o]=s,r[o]=s.peek())}}e(t)});m("__r",function(e,t){I();var i,r=t.__c;r&&(r.__$f&=-2,(i=r.__$u)===void 0&&(r.__$u=i=function(o){var s;return T(function(){s=this}),s.c=function(){r.__$f|=1,r.setState({})},s}())),I(i),e(t)});m("__e",function(e,t,i,r){I(),e(t,i,r)});m("diffed",function(e,t){I();var i;if(typeof t.type=="string"&&(i=t.__e)){var r=t.__np,o=t.props;if(r){var s=i.U;if(s)for(var a in s){var u=s[a];u!==void 0&&!(a in r)&&(u.d(),s[a]=void 0)}else i.U=s={};for(var c in r){var p=s[c],v=r[c];p===void 0?(p=ae(i,c,v,o),s[c]=p):p.o(v,o)}}}e(t)});function ae(e,t,i,r){var o=t in e&&e.ownerSVGElement===void 0,s=f(i);return{o:function(a,u){s.value=a,r=u},d:T(function(){var a=s.value.value;r[t]!==a&&(r[t]=a,o?e[t]=a:a?e.setAttribute(t,a):e.removeAttribute(t))})}}m("unmount",function(e,t){if(typeof t.type=="string"){var i=t.__e;if(i){var r=i.U;if(r){i.U=void 0;for(var o in r){var s=r[o];s&&s.d()}}}}else{var a=t.__c;if(a){var u=a.__$u;u&&(a.__$u=void 0,u.d())}}e(t)});m("__h",function(e,t,i,r){(r<3||r===9)&&(t.__$f|=2),e(t,i,r)});Y.prototype.shouldComponentUpdate=function(e,t){var i=this.__$u;if(!(i&&i.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in t)return!0;for(var o in e)if(o!=="__source"&&e[o]!==this.props[o])return!0;for(var s in this.props)if(!(s in e))return!0;return!1};function le(e){return $(function(){return f(e)},[])}const ce=f({data:void 0,pending:!1}),ue=f({checked:!0,setByUser:!1}),N=f({pending:!1,data:void 0});T(()=>{var e;(e=N.value.data)!=null&&e.isVirtual&&(ue.value={checked:!1,setByUser:!1})});T(()=>{N.value.pending||k.emit("checkout/data",N.value.data||null)});const de=f({data:void 0,pending:!1}),fe=f({pending:!1,data:void 0}),he=f({pending:!1,data:void 0}),pe=f({pending:!1,data:void 0}),ve=f({data:void 0,pending:!1}),_e={cart:N,customer:fe,estimateShippingMethods:he,regions:pe,storeConfig:ve,countryList:de,addressFormFields:ce};function ye(e,t){return t.split(".").reduce((i,r)=>i&&i[r]!==void 0?i[r]:void 0,e)}const q={cart:null,customer:null,estimateShippingMethods:null,regions:null,storeConfig:null,countryList:null,addressFormFields:null};async function ge(e){const{defaultValueOnFail:t,query:i,options:r,path:o,signalType:s,type:a,transformer:u}=e,c=_e[s],p=Symbol();q[s]=p,c.value={...c.value,pending:!0};try{const{data:v,errors:w}=await(a==="mutation"?te(()=>X(i,r).catch(R)):X(i,{method:"GET",cache:"no-cache",...r}).catch(R));if(w){const L=re(w);if(L.length>0)throw new ee(L)}let C=ye(v,o);if(C===void 0)throw new Error(`No data found at path: ${o}`);return u&&(C=u(C)),c.value={...c.value,data:C},setTimeout(()=>{c.value={...c.value,pending:q[s]===p?!1:c.value.pending}},0),C}catch(v){if(t)return c.value={pending:!1,data:t},t;if(v.name==="AbortError")return;throw c.value={...c.value,pending:!1},v}}const me={cartId:null,authenticated:!1},je=new Proxy(me,{set(e,t,i){return e[t]=i,!0},get(e,t){return e[t]}}),Ce=e=>{if(e)return{code:e.code,title:e.title}},Se=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:i,title:r}=t;return{code:i,title:r}})},be=e=>e==null,Ee=(e,t)=>e.amount.value-t.amount.value,V=e=>!(!e||!e.method_code||!e.method_title||be(e.amount.value)||!e.amount.currency),j=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),Te=e=>{if(V(e))return j(e)},xe=e=>{if(e)return e.filter(V).map(t=>j(t)).sort(Ee)},Ie=e=>e?!!e.code&&!!e.label:!1,Ne=e=>{if(!Ie(e))return;const{code:t,label:i,region_id:r}=e;return r?{code:t,name:i,id:r}:{code:t,name:i}},Ae=e=>{const{code:t,label:i}=e;return{value:t,label:i}},De=e=>e?"code"in e&&"value"in e:!1,Me=e=>e.filter(De).map(t=>{const{code:i,value:r}=t;return{code:i,value:r}}),Z=e=>{const t=e.street.filter(Boolean);return{firstName:e.firstname,lastName:e.lastname,company:e.company||void 0,city:e.city,street:t,postCode:e.postcode||void 0,vatId:e.vat_id||void 0,telephone:e.telephone||void 0,region:Ne(e.region),country:Ae(e.country),customAttributes:Me(e.custom_attributes)}},Ue=e=>{if(e)return Z(e)},Ge=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:i,selected_shipping_method:r,...o}=t;return{...Z(o),availableShippingMethods:xe(i),selectedShippingMethod:Te(r)}}),Ze=e=>({availablePaymentMethods:Se(e.available_payment_methods),billingAddress:Ue(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:Ce(e.selected_payment_method),shippingAddresses:Ge(e.shipping_addresses)}),we=`
2
+ query getStoreConfig {
3
+ storeConfig {
4
+ countries_with_required_region
5
+ default_country
6
+ display_state_if_optional
7
+ is_guest_checkout_enabled
8
+ is_one_page_checkout_enabled
9
+ locale
10
+ optional_zip_countries
11
+ shopping_cart_display_shipping
12
+ store_code
13
+ }
14
+ }
15
+ `;var _=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(_||{});const Le="US",h={defaultCountry:Le,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:_.EXCLUDING_TAX}},ze=async()=>await ge({type:"query",query:we,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:Re,defaultValueOnFail:h});function Oe(e){switch(e){case 1:return _.EXCLUDING_TAX;case 2:return _.INCLUDING_TAX;case 3:return _.INCLUDING_EXCLUDING_TAX;default:return _.EXCLUDING_TAX}}function Re(e){if(!e)return h;const{default_country:t,countries_with_required_region:i,display_state_if_optional:r,optional_zip_countries:o,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:a,shopping_cart_display_shipping:u}=e;return{defaultCountry:t||h.defaultCountry,countriesWithRequiredRegion:(i==null?void 0:i.split(","))||h.countriesWithRequiredRegion,displayStateIfOptional:r||h.displayStateIfOptional,countriesWithOptionalZipCode:(o==null?void 0:o.split(","))||h.countriesWithOptionalZipCode,isGuestCheckoutEnabled:s||h.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:a||h.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:Oe(u)}}}const{setEndpoint:Ye,setFetchGraphQlHeader:Je,removeFetchGraphQlHeader:Ke,setFetchGraphQlHeaders:et,fetchGraphQl:X,getConfig:tt}=new K().getMethods();var d=(e=>(e.Boolean="BOOLEAN",e.Date="DATE",e.Datetime="DATETIME",e.File="FILE",e.Gallery="GALLERY",e.Hidden="HIDDEN",e.Image="IMAGE",e.MediaImage="MEDIA_IMAGE",e.Multiline="MULTILINE",e.Multiselect="MULTISELECT",e.Price="PRICE",e.Select="SELECT",e.Text="TEXT",e.Textarea="TEXTAREA",e.Undefined="UNDEFINED",e.Weight="WEIGHT",e))(d||{}),qe=(e=>(e.DateRangeMax="DATE_RANGE_MAX",e.DateRangeMin="DATE_RANGE_MIN",e.FileExtensions="FILE_EXTENSIONS",e.InputValidation="INPUT_VALIDATION",e.MaxFileSize="MAX_FILE_SIZE",e.MaxImageHeight="MAX_IMAGE_HEIGHT",e.MaxImageWidth="MAX_IMAGE_WIDTH",e.MaxTextLength="MAX_TEXT_LENGTH",e.MinTextLength="MIN_TEXT_LENGTH",e))(qe||{});const it=[{frontendInput:d.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:d.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:d.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:d.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:d.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:d.Select,code:"country_id",label:"Country",isRequired:!0,isDisabled:!1,options:[{text:"United States",value:"US"},{text:"Spain",value:"ES"},{text:"France",value:"FR"}],validateRules:[],sortOrder:60},{frontendInput:d.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:d.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:d.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:d.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:d.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}],z=`
2
16
  fragment CheckoutData on Cart {
3
17
  is_virtual
4
18
  email
@@ -100,20 +114,20 @@ import{t as a,u as l}from"./fixtures.js";const c=e=>{if(e)return{code:e.code,tit
100
114
  title
101
115
  }
102
116
  }
103
- `,b=`
117
+ `,rt=`
104
118
  query getCart($cartId: String!) {
105
119
  cart(cart_id: $cartId) {
106
120
  id
107
121
  ...CheckoutData
108
122
  }
109
123
  }
110
- ${s}
111
- `,C=`
124
+ ${z}
125
+ `,st=`
112
126
  query getCustomerCart {
113
127
  cart: customerCart {
114
128
  id
115
129
  ...CheckoutData
116
130
  }
117
131
  }
118
- ${s}
119
- `;export{s as C,C as a,b as g,f as t};
132
+ ${z}
133
+ `;export{d as A,de as B,z as C,Le as D,he as E,ee as F,b as I,He as M,h as S,_ as T,Fe as U,qe as V,Be as a,We as b,Qe as c,Ve as d,Je as e,et as f,X as g,tt as h,it as i,ze as j,je as k,ge as l,ve as m,N as n,fe as o,R as p,rt as q,Ke as r,Ye as s,Ze as t,st as u,ue as v,ce as w,xe as x,pe as y,f as z};
@@ -1,4 +1,4 @@
1
- import"@dropins/tools/event-bus.js";import{o,M as l,p as u}from"./fixtures.js";import{t as d,g as f,a as g}from"./getCart.graphql.js";const p=e=>e?"code"in e&&"value"in e:!1,y=e=>e.filter(p).map(t=>{const{code:r,value:s}=t;return{code:r,value:s}}),m=e=>{var n,i,c;const t=e.street.filter(Boolean),r=(n=e.region)==null?void 0:n.region_id,s=r&&r>0;return{id:String(e.id),firstName:e.firstname,lastName:e.lastname,company:e.company||void 0,city:e.city,street:t,postCode:e.postcode||void 0,vatId:e.vat_id||void 0,telephone:e.telephone||void 0,region:{id:s?r:void 0,code:(i=e.region)==null?void 0:i.region_code,name:(c=e.region)==null?void 0:c.region},country:{value:e.country_code,label:e.country_code},customAttributes:y(e.custom_attributesV2)}},h=e=>e?e.filter(Boolean).map(m):[],a=(e,t)=>{if(!t)return;const r=t.find(s=>(s==null?void 0:s[e])===!0);if(r)return m(r)},C=e=>{if(!e)return;const t=e.addresses;return{firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||"",addresses:h(t),defaultBillingAddress:a("default_billing",t),defaultShippingAddress:a("default_shipping",t)}},_=async()=>{const e=o.cartId,t=o.authenticated===!1,r=t?f:g,s=t?{cartId:e}:{};if(t&&!e)throw new l;return await u({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:s},path:"cart",signalType:"cart",transformer:d})},q=async()=>{const e=o.cartId,t=o.authenticated;if(e)try{await _(),t&&await A()}catch(r){console.error(r)}},v=`
1
+ import"@dropins/tools/event-bus.js";import{k as o,M as l,l as u,t as d,q as f,u as g}from"./getCart.graphql.js";const p=e=>e?"code"in e&&"value"in e:!1,y=e=>e.filter(p).map(t=>{const{code:r,value:s}=t;return{code:r,value:s}}),m=e=>{var n,i,c;const t=e.street.filter(Boolean),r=(n=e.region)==null?void 0:n.region_id,s=r&&r>0;return{id:String(e.id),firstName:e.firstname,lastName:e.lastname,company:e.company||void 0,city:e.city,street:t,postCode:e.postcode||void 0,vatId:e.vat_id||void 0,telephone:e.telephone||void 0,region:{id:s?r:void 0,code:(i=e.region)==null?void 0:i.region_code,name:(c=e.region)==null?void 0:c.region},country:{value:e.country_code,label:e.country_code},customAttributes:y(e.custom_attributesV2)}},h=e=>e?e.filter(Boolean).map(m):[],a=(e,t)=>{if(!t)return;const r=t.find(s=>(s==null?void 0:s[e])===!0);if(r)return m(r)},C=e=>{if(!e)return;const t=e.addresses;return{firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||"",addresses:h(t),defaultBillingAddress:a("default_billing",t),defaultShippingAddress:a("default_shipping",t)}},_=async()=>{const e=o.cartId,t=o.authenticated===!1,r=t?f:g,s=t?{cartId:e}:{};if(t&&!e)throw new l;return await u({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:s},path:"cart",signalType:"cart",transformer:d})},q=async()=>{const e=o.cartId,t=o.authenticated;if(e)try{await _(),t&&await A()}catch(r){console.error(r)}},v=`
2
2
  query getCustomer {
3
3
  customer {
4
4
  firstname
@@ -0,0 +1,127 @@
1
+ import{k as T,M as w,g as A,p as k,n as D,F as L,U as R}from"./getCart.graphql.js";import{events as f}from"@dropins/tools/event-bus.js";const V=n=>({id:T.cartId,totalQuantity:n.totalQuantity,possibleOnepageCheckout:!0,items:n.items.map(a=>{var t;return{canApplyMsrp:!0,formattedPrice:"",id:a.id,quantity:a.totalQuantity,product:{canonicalUrl:a.product.canonicalUrl||"",mainImageUrl:a.product.image||"",name:a.product.name,productId:0,productType:a.product.productType,sku:a.product.sku},prices:{price:{value:a.price.value,currency:a.price.currency}},configurableOptions:((t=a.selectedOptions)==null?void 0:t.map(i=>({optionLabel:i.label,valueLabel:i.value})))||[]}})}),q=n=>{var i,c,l;const a=n.coupons[0],t=(i=n.payments)==null?void 0:i[0];return{appliedCouponCode:(a==null?void 0:a.code)||"",email:n.email,grandTotal:n.total,orderId:n.number,orderType:"checkout",otherTax:0,salesTax:n.totalTax,shipping:{shippingMethod:((c=n.shipping)==null?void 0:c.code)||"",shippingAmount:((l=n.shipping)==null?void 0:l.amount)||0},subtotalExcludingTax:n.subtotal,subtotalIncludingTax:0,payments:t?[{paymentMethodCode:(t==null?void 0:t.code)||"",paymentMethodName:(t==null?void 0:t.name)||"",total:n.total}]:[]}},Q=n=>n||0,S=n=>{var a;return{canonicalUrl:(n==null?void 0:n.canonical_url)||"",id:(n==null?void 0:n.uid)||"",name:(n==null?void 0:n.name)||"",sku:(n==null?void 0:n.sku)||"",image:((a=n==null?void 0:n.image)==null?void 0:a.url)||"",productType:(n==null?void 0:n.__typename)||""}};function M(n){if(!n||!("selected_options"in n))return;const a={};for(const t of n.selected_options)a[t.label]=t.value;return a}const P=n=>n?n.map(a=>{var t,i,c,l,u,s,e,p,_,o,y,g,h,v;return{type:a==null?void 0:a.__typename,id:a==null?void 0:a.id,discounted:(a==null?void 0:a.product.price_range.maximum_price.regular_price.value)*(a==null?void 0:a.quantity_ordered)!==(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),total:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},totalInclTax:{value:(a==null?void 0:a.product_sale_price.value)*(a==null?void 0:a.quantity_ordered),currency:a==null?void 0:a.product_sale_price.currency},price:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},priceInclTax:{value:a==null?void 0:a.product_sale_price.value,currency:a==null?void 0:a.product_sale_price.currency},totalQuantity:Q(a==null?void 0:a.quantity_ordered),regularPrice:{value:(c=(i=(t=a==null?void 0:a.product)==null?void 0:t.price_range)==null?void 0:i.maximum_price)==null?void 0:c.regular_price.value,currency:(s=(u=(l=a==null?void 0:a.product)==null?void 0:l.price_range)==null?void 0:u.maximum_price)==null?void 0:s.regular_price.currency},product:S(a==null?void 0:a.product),thumbnail:{label:((p=(e=a==null?void 0:a.product)==null?void 0:e.thumbnail)==null?void 0:p.label)||"",url:((o=(_=a==null?void 0:a.product)==null?void 0:_.thumbnail)==null?void 0:o.url)||""},giftCard:(a==null?void 0:a.__typename)==="GiftCardOrderItem"?{senderName:((y=a.gift_card)==null?void 0:y.sender_name)||"",senderEmail:((g=a.gift_card)==null?void 0:g.sender_email)||"",recipientEmail:((h=a.gift_card)==null?void 0:h.recipient_email)||"",recipientName:((v=a.gift_card)==null?void 0:v.recipient_name)||""}:void 0,configurableOptions:M(a)}}):[];function U(n){return n!==null&&n.value!==void 0}const C=n=>n?{city:n.city,company:n.company||"",country:n.country_code||"",firstName:n.firstname,middleName:n.middlename||"",lastName:n.lastname,postCode:n.postcode||"",regionId:n.region_id||"",region:n.region||"",street:n.street.filter(a=>a!==null),telephone:n.telephone||"",customAttributes:n.custom_attributesV2.filter(U).map(a=>({code:a.code,value:a.value}))}:null,G=n=>{var u,s,e,p,_,o,y,g,h,v;const a=(u=n.payment_methods)==null?void 0:u[0],t=(a==null?void 0:a.type)??"",i=(a==null?void 0:a.name)??"",c=P(n.items),l=c.reduce((b,N)=>b+N.totalQuantity,0);return{status:n.status,isVirtual:n.is_virtual,coupons:((s=n==null?void 0:n.applied_coupons)==null?void 0:s.map(b=>({code:(b==null?void 0:b.code)??""})))||[],email:n.email??"",items:c,number:n.number,token:n.token,grandTotal:{value:((e=n.total)==null?void 0:e.grand_total.value)??0,currency:((p=n.total)==null?void 0:p.grand_total.currency)||""},totalQuantity:l,totalTax:{value:((_=n.total)==null?void 0:_.total_tax.value)??0,currency:((o=n.total)==null?void 0:o.total_tax.currency)||""},subtotal:{value:((y=n.total)==null?void 0:y.subtotal.value)??0,currency:((g=n.total)==null?void 0:g.subtotal.currency)||""},shipping:{amount:((h=n.total)==null?void 0:h.total_shipping.value)??0,currency:((v=n.total)==null?void 0:v.total_shipping.currency)||"",code:n.shipping_method??""},payments:[{code:t,name:i}],shippingAddress:C(n.shipping_address),billingAddress:C(n.billing_address)}},F=`
2
+ mutation placeOrder($cartId: String!) {
3
+ placeOrder(input: { cart_id: $cartId }) {
4
+ orderV2 {
5
+ number
6
+ status
7
+ token
8
+ is_virtual
9
+ applied_coupons {
10
+ code
11
+ }
12
+ email
13
+ id
14
+ total {
15
+ grand_total {
16
+ currency
17
+ value
18
+ }
19
+ subtotal {
20
+ currency
21
+ value
22
+ }
23
+ total_shipping {
24
+ currency
25
+ value
26
+ }
27
+ total_tax {
28
+ currency
29
+ value
30
+ }
31
+ }
32
+ shipping_method
33
+ payment_methods {
34
+ name
35
+ type
36
+ }
37
+ billing_address {
38
+ firstname
39
+ middlename
40
+ lastname
41
+ street
42
+ city
43
+ postcode
44
+ telephone
45
+ country_code
46
+ region
47
+ region_id
48
+ company
49
+ custom_attributesV2 {
50
+ code
51
+ ... on AttributeValue {
52
+ value
53
+ }
54
+ }
55
+ }
56
+ shipping_address {
57
+ firstname
58
+ middlename
59
+ lastname
60
+ street
61
+ city
62
+ postcode
63
+ telephone
64
+ country_code
65
+ region
66
+ region_id
67
+ company
68
+ custom_attributesV2 {
69
+ code
70
+ ... on AttributeValue {
71
+ value
72
+ }
73
+ }
74
+ }
75
+ items {
76
+ __typename
77
+ id
78
+ discounts {
79
+ amount {
80
+ value
81
+ }
82
+ }
83
+ product {
84
+ __typename
85
+ canonical_url
86
+ image {
87
+ url
88
+ }
89
+ thumbnail {
90
+ label
91
+ url
92
+ }
93
+ name
94
+ sku
95
+ uid
96
+ price_range {
97
+ maximum_price {
98
+ regular_price {
99
+ currency
100
+ value
101
+ }
102
+ }
103
+ }
104
+ }
105
+ selected_options {
106
+ label
107
+ value
108
+ }
109
+ product_sale_price {
110
+ value
111
+ currency
112
+ }
113
+ quantity_ordered
114
+ ... on GiftCardOrderItem {
115
+ gift_card {
116
+ recipient_name
117
+ recipient_email
118
+ sender_name
119
+ sender_email
120
+ message
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ `,x={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},X={PLACE_ORDER:"place-order"};function E(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function O(n,a){const t=E();t.push({[n]:null}),t.push({[n]:a})}function $(n,a){E().push(i=>{const c=i.getState?i.getState():{};i.push({event:n,eventInfo:{...c,...a}})})}function H(n){const a=V(n),t=q(n);console.debug({shoppingCartContext:a,orderContext:t}),O(x.SHOPPING_CART_CONTEXT,{...a}),O(x.ORDER_CONTEXT,{...t}),$(X.PLACE_ORDER)}function j(n){throw n.every(t=>{var i;return(i=t.extensions)==null?void 0:i.category})?new L(n):new R(n[0].message)}const J=async()=>{const n=T.cartId;if(!n)throw new w;const{data:a,errors:t}=await A(F,{variables:{cartId:n}}).catch(k);t&&j(t);const i=G(a.placeOrder.orderV2);return H(i),f.emit("checkout/order",i),D.value={pending:!1,data:null},f.emit("cart/reset",void 0),i};export{J as p};
@@ -1,4 +1,4 @@
1
- import{events as n}from"@dropins/tools/event-bus.js";import{p as l,o as a,j as d,n as c,m as f}from"./fixtures.js";import{Initializer as m}from"@dropins/tools/lib.js";import{a as i}from"./getCustomer.js";const _=e=>e?e.filter(Boolean).filter(r=>(r==null?void 0:r.label)&&(r==null?void 0:r.value)).map(r=>({text:r.label,value:r.value})):[],g=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.name)&&(t==null?void 0:t.value)):[],v=e=>e?e.filter(Boolean).map(r=>({code:r.code,defaultValue:r.default_value||void 0,frontendInput:r.frontend_input||void 0,isDisabled:!1,isRequired:r.is_required,label:r.label||void 0,multilineCount:r.multiline_count||void 0,options:_(r.options),sortOrder:r.sort_order||void 0,validateRules:g(r.validate_rules)})):[],p=e=>{if(e)return e.filter(t=>!!t).filter(t=>{const{two_letter_abbreviation:r,full_name_locale:s}=t;return!!r&&!!s}).map(t=>{const{two_letter_abbreviation:r,full_name_locale:s}=t;return{value:r,label:s}})},y=`
1
+ import{events as n}from"@dropins/tools/event-bus.js";import{l,k as a,j as d,n as c,o as f}from"./getCart.graphql.js";import{Initializer as m}from"@dropins/tools/lib.js";import{a as i}from"./getCustomer.js";const _=e=>e?e.filter(Boolean).filter(r=>(r==null?void 0:r.label)&&(r==null?void 0:r.value)).map(r=>({text:r.label,value:r.value})):[],g=e=>e?e.filter(Boolean).filter(t=>(t==null?void 0:t.name)&&(t==null?void 0:t.value)):[],v=e=>e?e.filter(Boolean).map(r=>({code:r.code,defaultValue:r.default_value||void 0,frontendInput:r.frontend_input||void 0,isDisabled:!1,isRequired:r.is_required,label:r.label||void 0,multilineCount:r.multiline_count||void 0,options:_(r.options),sortOrder:r.sort_order||void 0,validateRules:g(r.validate_rules)})):[],p=e=>{if(e)return e.filter(t=>!!t).filter(t=>{const{two_letter_abbreviation:r,full_name_locale:s}=t;return!!r&&!!s}).map(t=>{const{two_letter_abbreviation:r,full_name_locale:s}=t;return{value:r,label:s}})},y=`
2
2
  query fetchAddressFormFields {
3
3
  attributesForm(formCode: "customer_register_address") {
4
4
  items {
@@ -1,4 +1,4 @@
1
- import{o as n,M as e,c as d,p as l}from"./fixtures.js";import{C as o,t as c}from"./getCart.graphql.js";const p=`
1
+ import{C as n,k as e,M as d,c as l,l as o,t as c}from"./getCart.graphql.js";const g=`
2
2
  mutation setBillingAddress($cartId: String!, $input: BillingAddressInput!) {
3
3
  setBillingAddressOnCart(
4
4
  input: { cart_id: $cartId, billing_address: $input }
@@ -9,5 +9,5 @@ import{o as n,M as e,c as d,p as l}from"./fixtures.js";import{C as o,t as c}from
9
9
  }
10
10
  }
11
11
  }
12
- ${o}
13
- `,m=async({signal:a,input:s})=>{const t=n.cartId,{address:i,same_as_shipping:r}=s;if(!t)throw new e;if(!r&&!i)throw new d;return await l({type:"mutation",query:p,options:{signal:a,variables:{cartId:t,input:s}},path:"setBillingAddressOnCart.cart",signalType:"cart",transformer:c})};export{m as s};
12
+ ${n}
13
+ `,A=async({signal:a,input:s})=>{const t=e.cartId,{address:i,same_as_shipping:r}=s;if(!t)throw new d;if(!r&&!i)throw new l;return await o({type:"mutation",query:g,options:{signal:a,variables:{cartId:t,input:s}},path:"setBillingAddressOnCart.cart",signalType:"cart",transformer:c})};export{A as s};
@@ -1,4 +1,86 @@
1
- import{o as a,M as s,p}from"./fixtures.js";import{C as r,t as n}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const o=`
1
+ import{k as h,M as l,d as I,l as u,x as M,y as S,a as v,g as b,p as $,C as g,t as m,b as f}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const E=`
2
+ mutation estimateShippingMethods(
3
+ $cartId: String!
4
+ $address: EstimateAddressInput!
5
+ ) {
6
+ estimateShippingMethods(
7
+ input: {
8
+ cart_id: $cartId
9
+ address: $address
10
+ }
11
+ ) {
12
+ carrier_title
13
+ carrier_code
14
+ method_title
15
+ method_code
16
+ available
17
+ amount {
18
+ currency
19
+ value
20
+ }
21
+ price_excl_tax {
22
+ currency
23
+ value
24
+ }
25
+ price_incl_tax {
26
+ currency
27
+ value
28
+ }
29
+ error_message
30
+ }
31
+ }
32
+ `,w=t=>!!(t!=null&&t.is_email_available),C=t=>t?!!t.id&&!!t.code&&!!t.name:!1,T=t=>{if(t)return t.filter(C).map(a=>{const{id:e,code:i,name:o}=a;return{id:e,code:i,name:o}})};var O=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(O||{}),s=(t=>(t.City="city",t.Company="company",t.Country="country_id",t.FirstName="firstname",t.LastName="lastname",t.PostCode="postcode",t.Region="region",t.RegionId="region_id",t.SaveInAddressBook="save_in_address_book",t.Street="street",t.Telephone="telephone",t.Vat="vat_id",t))(s||{});const V=async t=>{const a=h.cartId,{criteria:e}=t||{},{country_code:i,region_id:o,region_name:c,zip:n}=e||{};if(!a)throw new l;if(!i)throw new I;const r=typeof o=="string"?parseInt(o,10):o,p=o||c?{...r&&{region_id:r},...c&&{region_code:c}}:void 0,d={country_code:i,...n&&{postcode:n},...p&&{region:p}};return await u({type:"mutation",query:E,options:{variables:{cartId:a,address:d}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:M})},R=`
33
+ query getRegions($countryCode: String!) {
34
+ country(id: $countryCode) {
35
+ id
36
+ available_regions {
37
+ id
38
+ code
39
+ name
40
+ }
41
+ }
42
+ }`,Q=async(t,a)=>(S.value.addressType=a,u({type:"query",query:R,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:T})),N=`
43
+ query isEmailAvailable($email: String!) {
44
+ isEmailAvailable(email: $email) {
45
+ is_email_available
46
+ }
47
+ }
48
+ `,A=t=>{if(!(!t||t.length===0))throw Error(t.map(a=>a.message).join(" "))},H=async t=>{if(!t)throw new v;const{data:a,errors:e}=await b(N,{method:"GET",cache:"no-cache",variables:{email:t}}).catch($);return e&&A(e),w(a.isEmailAvailable)},k=`
49
+ mutation setGuestEmail($cartId: String!, $email: String!) {
50
+ setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
51
+ cart {
52
+ id
53
+ ...CheckoutData
54
+ }
55
+ }
56
+ }
57
+ ${g}
58
+ `,W=async t=>{const a=h.cartId;if(!a)throw new l;return await u({type:"mutation",query:k,options:{variables:{cartId:a,email:t}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:m})},G=`
59
+ mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
60
+ setPaymentMethodOnCart(
61
+ input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
62
+ ) {
63
+ cart {
64
+ id
65
+ ...CheckoutData
66
+ }
67
+ }
68
+ }
69
+ ${g}
70
+ `,X=async t=>{const a=h.cartId;if(!a)throw new l;if(!t)throw new f;return await u({type:"mutation",query:G,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m})},y="-",P=`
71
+ `,z=2e3,_=(t,a)=>Object.keys(a).filter(e=>e.startsWith(t)).sort((e,i)=>parseInt(e.replace(`${t}${y}`,""),10)-parseInt(i.replace(`${t}${y}`,""),10)).map(e=>a[e]),D=/^\d+$/,q=t=>{if(D.test(t))return parseInt(t,10)},L=`
72
+ mutation setShippingAddress($cartId: String!, $address: CartAddressInput!) {
73
+ setShippingAddressesOnCart(
74
+ input: { cart_id: $cartId, shipping_addresses: [{ address: $address }] }
75
+ ) {
76
+ cart {
77
+ id
78
+ ...CheckoutData
79
+ }
80
+ }
81
+ }
82
+ ${g}
83
+ `,U=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],K=t=>{const a={city:t[s.City],company:t[s.Company],country_code:t[s.Country],firstname:t[s.FirstName],lastname:t[s.LastName],postcode:t[s.PostCode],save_in_address_book:!0,street:_(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},e=t[s.Region],i=q(e);i?a.region_id=i:a.region=e;const c=Object.keys(t).filter(n=>!n.startsWith("street")).filter(n=>!U.includes(n)).filter(n=>n!=="country_id").map(n=>{const[r,p]=n.split(y);if(!p)return{attribute_code:r,value:t[n]};const d=_(r,t).join(P);return{attribute_code:r,value:d}}).filter((n,r,p)=>r===p.findIndex(d=>d.attribute_code===n.attribute_code));return c.length>0&&(a.custom_attributes=c),a},J=async({signal:t,address:a})=>{const e=h.cartId;if(!e)throw new l;return await u({type:"mutation",query:L,options:{signal:t,variables:{cartId:e,address:a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:m})},x=`
2
84
  mutation setShippingMethods(
3
85
  $cartId: String!
4
86
  $shippingMethods: [ShippingMethodInput]!
@@ -12,5 +94,5 @@ import{o as a,M as s,p}from"./fixtures.js";import{C as r,t as n}from"./getCart.g
12
94
  }
13
95
  }
14
96
  }
15
- ${r}
16
- `,c=async i=>{const t=a.cartId;if(!t)throw new s;return await p({type:"mutation",query:o,options:{variables:{cartId:t,shippingMethods:i}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:n})};export{c as s};
97
+ ${g}
98
+ `,Y=async t=>{const a=h.cartId;if(!a)throw new l;return await u({type:"mutation",query:x,options:{variables:{cartId:a,shippingMethods:t}},path:"setShippingMethodsOnCart.cart",signalType:"cart",transformer:m})};export{s as A,z as D,y as M,U as S,X as a,J as b,Y as c,_ as d,V as e,O as f,Q as g,P as h,H as i,K as p,W as s};
@@ -1,31 +1,27 @@
1
1
  import { FunctionComponent, VNode } from 'preact';
2
2
  import { HTMLAttributes } from 'preact/compat';
3
3
 
4
- export type AsideSections = {
5
- orderSummary?: VNode;
6
- };
7
- declare const Aside: FunctionComponent<{
8
- sections: AsideSections;
9
- }>;
10
- export type MainSections = {
4
+ export type CheckoutBlocks = {
11
5
  billingAddress: VNode;
12
- billToShippingAddress?: VNode;
6
+ billToShippingAddress: VNode;
7
+ cartSummaryList?: VNode;
8
+ emptyCart: VNode;
13
9
  login: VNode;
10
+ orderSummary?: VNode;
14
11
  outOfStock: VNode;
15
12
  paymentMethods: VNode;
16
13
  placeOrder: VNode;
17
- shippingAddress?: VNode;
18
- shippingMethods?: VNode;
14
+ shippingAddress: VNode;
15
+ shippingMethods: VNode;
19
16
  };
20
17
  declare const Main: FunctionComponent<{
21
- sections?: MainSections;
18
+ blocks: CheckoutBlocks;
22
19
  }>;
23
20
  export interface CheckoutProps extends HTMLAttributes<HTMLDivElement> {
24
21
  isLoading?: boolean;
25
22
  }
26
23
  interface CheckoutComponent extends FunctionComponent<CheckoutProps> {
27
24
  Main: typeof Main;
28
- Aside: typeof Aside;
29
25
  }
30
26
  export declare const Checkout: CheckoutComponent;
31
27
  export {};
@@ -1,6 +1,6 @@
1
+ import { ShippingMethod } from '../../data/models';
1
2
  import { FunctionComponent } from 'preact';
2
3
  import { HTMLAttributes } from 'preact/compat';
3
- import { ShippingMethod } from '../../data/models';
4
4
 
5
5
  export interface ShippingMethodsProps extends HTMLAttributes<HTMLDivElement> {
6
6
  isLoading?: boolean;
@@ -1,10 +1,12 @@
1
1
  import { BillingAddress, ShippingAddress } from '../../data/models/address';
2
2
  import { AddressFormField } from '../../data/models/address-form-fields';
3
3
  import { CheckboxProps } from '@dropins/tools/types/elsie/src/components';
4
- import { Container } from '@dropins/tools/types/elsie/src/lib';
5
4
 
6
5
  export declare function compareAddresses(addressFormFields: AddressFormField[], first: BillingAddress | undefined, second: ShippingAddress | undefined): boolean;
7
6
  export interface BillToShippingAddressProps extends Omit<CheckboxProps, 'name' | 'label'> {
8
7
  }
9
- export declare const BillToShippingAddress: Container<BillToShippingAddressProps>;
8
+ export declare const BillToShippingAddress: {
9
+ ({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & BillToShippingAddressProps): import("preact/compat").JSX.Element | null;
10
+ displayName: string;
11
+ };
10
12
  //# sourceMappingURL=BillToShippingAddress.d.ts.map
@@ -1 +1 @@
1
- import{a as f,B as A,c as L,B as P}from"../chunks/BillToShippingAddress2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setBillingAddress.js";import"../chunks/getCart.graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";export{f as BILL_TO_SHIPPING_KEY,A as BillToShippingAddress,L as compareAddresses,P as default};
1
+ import{a as _,B as c,c as f,B as A}from"../chunks/BillToShippingAddress.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import"../chunks/getCart.graphql.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setBillingAddress.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";export{_ as BILL_TO_SHIPPING_KEY,c as BillToShippingAddress,f as compareAddresses,A as default};
@@ -1,7 +1,9 @@
1
- import { Container } from '@dropins/tools/types/elsie/src/lib';
2
1
  import { HTMLAttributes } from 'preact/compat';
3
2
 
4
3
  export interface BillingFormProps extends HTMLAttributes<HTMLDivElement> {
5
4
  }
6
- export declare const BillingForm: Container<BillingFormProps>;
5
+ export declare const BillingForm: {
6
+ ({ hideOnEmptyCart, hideOnVirtualCart, ...props }: import('../../hocs/withConditionalRendering').ConditionalProps & BillingFormProps): import("preact/compat").JSX.Element | null;
7
+ displayName: string;
8
+ };
7
9
  //# sourceMappingURL=BillingForm.d.ts.map
@@ -1 +1 @@
1
- import{B as n,B as u}from"../chunks/BillingForm.js";import{B as E}from"../chunks/constants2.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/event-bus.js";import"../chunks/fixtures.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getMultilineValues.js";import"../chunks/setBillingAddress.js";import"../chunks/getCart.graphql.js";import"../chunks/setShippingAddress.js";import"../chunks/ToggleButton.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";/* empty css */import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";import"../chunks/BillToShippingAddress2.js";export{E as BILLING_FORM_NAME,n as BillingForm,u as default};
1
+ import{e as _,B as d,B as g}from"../chunks/ShippingMethods.js";import"@dropins/tools/preact-jsx-runtime.js";import"../chunks/setShippingMethods.js";import"../chunks/getCart.graphql.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/preact.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"../chunks/BillToShippingAddress.js";import"../chunks/setBillingAddress.js";import"@dropins/tools/preact-compat.js";import"../chunks/ErrorBanner.js";import"../chunks/MergedCartBanner.js";export{_ as BILLING_FORM_NAME,d as BillingForm,g as default};