@dropins/storefront-checkout 0.1.0-alpha45 → 0.1.0-alpha47
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.
- package/__generated__/types.d.ts +22 -20
- package/api/errors/index.d.ts +16 -0
- package/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.d.ts +16 -0
- package/api/estimateShippingMethods/graphql/index.d.ts +16 -0
- package/api/estimateShippingMethods/index.d.ts +16 -0
- package/api/fetch-graphql/fetch-graphql.d.ts +16 -0
- package/api/fetch-graphql/index.d.ts +16 -0
- package/api/fetchAddressFormFields/fetchAddressFormFields.d.ts +16 -0
- package/api/fetchAddressFormFields/graphql/fetchAddressFormFields.graphql.d.ts +16 -0
- package/api/fetchAddressFormFields/index.d.ts +16 -0
- package/api/getCart/getCart.d.ts +16 -0
- package/api/getCart/graphql/getCart.graphql.d.ts +16 -0
- package/api/getCart/graphql/index.d.ts +16 -0
- package/api/getCart/index.d.ts +16 -0
- package/api/getCheckoutData/getCheckoutData.d.ts +16 -0
- package/api/getCheckoutData/index.d.ts +16 -0
- package/api/getCountries/getCountries.d.ts +16 -0
- package/api/getCountries/graphql/getCountries.graphql.d.ts +16 -0
- package/api/getCountries/index.d.ts +16 -0
- package/api/getCustomer/graphql/getCustomer.graphql.d.ts +16 -0
- package/api/getCustomer/graphql/index.d.ts +16 -0
- package/api/getCustomer/index.d.ts +16 -0
- package/api/getRegions/graphql/getRegions.graphql.d.ts +16 -0
- package/api/getRegions/index.d.ts +16 -0
- package/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +16 -0
- package/api/getStoreConfig/index.d.ts +16 -0
- package/api/index.d.ts +16 -0
- package/api/initialize/index.d.ts +16 -0
- package/api/initialize/listeners.d.ts +16 -0
- package/api/initializeCheckout/index.d.ts +16 -0
- package/api/initializeCheckout/initializeCheckout.d.ts +16 -0
- package/api/isEmailAvailable/graphql/isEmailAvailable.graphql.d.ts +16 -0
- package/api/isEmailAvailable/index.d.ts +16 -0
- package/api/placeOrder/graphql/index.d.ts +16 -0
- package/api/placeOrder/graphql/placeOrder.graphql.d.ts +17 -1
- package/api/placeOrder/index.d.ts +16 -0
- package/api/placeOrder/placeOrder.d.ts +16 -0
- package/api/redirect/index.d.ts +16 -0
- package/api/redirect/redirect.d.ts +16 -0
- package/api/resetCheckout/index.d.ts +16 -0
- package/api/resetCheckout/resetCheckout.d.ts +16 -0
- package/api/resetCustomer/index.d.ts +16 -0
- package/api/resetCustomer/resetCustomer.d.ts +16 -0
- package/api/setBillingAddress/graphql/setBillingAddress.graphql.d.ts +16 -0
- package/api/setBillingAddress/index.d.ts +16 -0
- package/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.d.ts +16 -0
- package/api/setGuestEmailOnCart/index.d.ts +16 -0
- package/api/setGuestEmailOnCart/setGuestEmailOnCart.d.ts +16 -0
- package/api/setPaymentMethod/graphql/setPaymentMethod.graphql.d.ts +16 -0
- package/api/setPaymentMethod/index.d.ts +16 -0
- package/api/setPaymentMethod/setPaymentMethod.d.ts +16 -0
- package/api/setShippingAddress/graphql/setShippingAddress.graphql.d.ts +16 -0
- package/api/setShippingAddress/index.d.ts +16 -0
- package/api/setShippingAddress/setShippingAddress.d.ts +17 -1
- package/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.d.ts +16 -0
- package/api/setShippingMethods/index.d.ts +16 -0
- package/api/setShippingMethods/setShippingMethods.d.ts +16 -0
- package/api/utils/enqueueRequest.d.ts +16 -0
- package/api.js +1 -1
- package/chunks/BillToShippingAddress.js +1 -1
- package/chunks/OrderError.js +1 -0
- package/chunks/ShippingMethods.js +1 -1
- package/chunks/fixtures.js +15 -0
- package/chunks/getCart.graphql.js +6 -20
- package/chunks/getCustomer.js +1 -1
- package/chunks/getMultilineValues.js +43 -0
- package/chunks/placeOrder.js +6 -2
- package/chunks/resetCustomer.js +1 -1
- package/chunks/setBillingAddress.js +3 -3
- package/chunks/setGuestEmailOnCart.js +17 -0
- package/chunks/setPaymentMethod.js +13 -0
- package/chunks/setShippingAddress.js +16 -0
- package/chunks/setShippingMethods.js +3 -85
- package/chunks/transform-shipping-methods.js +1 -0
- package/chunks/withConditionalRendering.js +1 -0
- package/components/AddressForm/constants.d.ts +16 -0
- package/components/AddressForm/index.d.ts +16 -0
- package/components/BillToShippingAddress/index.d.ts +16 -0
- package/components/EstimateShipping/index.d.ts +16 -0
- package/components/FieldsForm/index.d.ts +16 -0
- package/components/Heading/index.d.ts +16 -0
- package/components/LoginForm/index.d.ts +16 -0
- package/components/OutOfStock/index.d.ts +16 -0
- package/components/OverlayLoader/index.d.ts +16 -0
- package/components/PaymentMethods/index.d.ts +16 -0
- package/components/PlaceOrder/PlaceOrder.d.ts +1 -1
- package/components/PlaceOrder/index.d.ts +16 -0
- package/components/ServerError/index.d.ts +16 -0
- package/components/ShippingMethods/index.d.ts +16 -0
- package/components/ToggleButton/assets/icons/index.d.ts +16 -0
- package/components/ToggleButton/assets/images/index.d.ts +16 -0
- package/components/ToggleButton/index.d.ts +16 -0
- package/components/index.d.ts +16 -2
- package/containers/BillToShippingAddress/BillToShippingAddress.d.ts +1 -1
- package/containers/BillToShippingAddress/constants.d.ts +16 -0
- package/containers/BillToShippingAddress/index.d.ts +16 -0
- package/containers/BillToShippingAddress.js +1 -1
- package/containers/BillingForm/BillingForm.d.ts +1 -1
- package/containers/BillingForm/constants.d.ts +16 -0
- package/containers/BillingForm/index.d.ts +16 -0
- package/containers/BillingForm.js +1 -1
- package/containers/ErrorBanner/index.d.ts +16 -0
- package/containers/ErrorBanner.js +1 -1
- package/containers/EstimateShipping/index.d.ts +16 -0
- package/containers/EstimateShipping.js +1 -1
- package/containers/LoginForm/LoginForm.d.ts +1 -1
- package/containers/LoginForm/constants.d.ts +16 -0
- package/containers/LoginForm/index.d.ts +16 -0
- package/containers/LoginForm.js +1 -1
- package/containers/MergedCartBanner/index.d.ts +16 -0
- package/containers/MergedCartBanner.js +1 -1
- package/containers/OutOfStock/index.d.ts +16 -0
- package/containers/OutOfStock.js +1 -1
- package/containers/PaymentMethods/PaymentMethods.d.ts +10 -11
- package/containers/PaymentMethods/defaultHandlers.d.ts +2 -9
- package/containers/PaymentMethods/index.d.ts +16 -0
- package/containers/PaymentMethods.js +1 -1
- package/containers/PlaceOrder/PlaceOrder.d.ts +10 -3
- package/containers/PlaceOrder/index.d.ts +16 -0
- package/containers/PlaceOrder.js +1 -1
- package/containers/ServerError/ServerError.d.ts +8 -0
- package/containers/ServerError/index.d.ts +19 -0
- package/containers/ServerError.d.ts +3 -0
- package/containers/ServerError.js +1 -0
- package/containers/ShippingForm/ShippingForm.d.ts +1 -1
- package/containers/ShippingForm/constants.d.ts +16 -0
- package/containers/ShippingForm/index.d.ts +17 -1
- package/containers/ShippingForm.js +1 -1
- package/containers/ShippingMethods/ShippingMethods.d.ts +7 -3
- package/containers/ShippingMethods/hooks/useShippingEstimateEventEmitter.d.ts +16 -0
- package/containers/ShippingMethods/index.d.ts +16 -0
- package/containers/ShippingMethods.js +1 -1
- package/containers/index.d.ts +17 -2
- package/data/models/acdl.d.ts +16 -0
- package/data/models/country.d.ts +16 -0
- package/data/models/custom-attribute.d.ts +16 -0
- package/data/models/email-availability.d.ts +16 -0
- package/data/models/index.d.ts +16 -0
- package/data/models/payment-method.d.ts +16 -0
- package/data/models/price.d.ts +16 -0
- package/data/models/region.d.ts +16 -0
- package/data/models/store-config.d.ts +16 -0
- package/data/transforms/index.d.ts +16 -0
- package/hocs/index.d.ts +16 -0
- package/hocs/withConditionalRendering.d.ts +1 -1
- package/hooks/index.d.ts +16 -0
- package/hooks/useBreakpoint/index.d.ts +16 -0
- package/hooks/useBreakpoint/useBreakpoint.d.ts +16 -0
- package/hooks/useLockScroll/index.d.ts +16 -0
- package/hooks/useLockScroll/useLockScroll.d.ts +16 -0
- package/hooks/useValidity/index.d.ts +16 -0
- package/hooks/useValidity/useValidity.d.ts +16 -0
- package/i18n/en_US.json.d.ts +0 -8
- package/lib/backup-data.d.ts +16 -0
- package/lib/fetch-error.d.ts +16 -0
- package/lib/index.d.ts +16 -0
- package/lib/network-error.d.ts +16 -0
- package/lib/redirect.d.ts +16 -0
- package/lib/state.d.ts +16 -0
- package/msw/browser.d.ts +16 -0
- package/msw/fixtures/fragments/billing-address.d.ts +16 -0
- package/msw/fixtures/fragments/cart.d.ts +16 -0
- package/msw/fixtures/fragments/index.d.ts +16 -0
- package/msw/fixtures/fragments/shipping-address.d.ts +16 -0
- package/msw/fixtures/index.d.ts +16 -0
- package/msw/fixtures/mutations/index.d.ts +16 -0
- package/msw/fixtures/queries/index.d.ts +16 -0
- package/msw/server.d.ts +16 -0
- package/package.json +1 -1
- package/render/index.d.ts +16 -0
- package/render.js +4 -3
- package/signals/IsBillToShippingSignal.d.ts +16 -0
- package/signals/ServerErrorSignal.d.ts +18 -0
- package/signals/index.d.ts +17 -0
- package/tests/constants.d.ts +16 -0
- package/tests/integration/utils/index.d.ts +16 -0
- package/tests/integration/utils/setup.d.ts +6 -4
- package/tests/integration/utils/user-actions.d.ts +16 -0
- package/tests/mocks/svg.d.ts +16 -0
- package/tests/utils/expectError.d.ts +16 -0
- package/tests/utils/index.d.ts +16 -0
- package/tests/utils/mockEvents.d.ts +16 -0
- package/utils/autocompleteFieldCodes/autocompleteFieldCodes.d.ts +16 -0
- package/utils/autocompleteFieldCodes/index.d.ts +16 -0
- package/utils/getDisplayName/index.d.ts +16 -0
- package/utils/getMultilineValues/getMultilineValues.d.ts +16 -0
- package/utils/getMultilineValues/index.d.ts +16 -0
- package/utils/index.d.ts +19 -0
- package/utils/isEmpty/index.d.ts +16 -0
- package/utils/isEmpty/isEmpty.d.ts +16 -0
- package/utils/isNullish/index.d.ts +16 -0
- package/utils/isNullish/isNullish.d.ts +16 -0
- package/utils/isUnexpectedError/index.d.ts +18 -0
- package/utils/isUnexpectedError/isUnexpectedError.d.ts +18 -0
- package/utils/parseRegionId/index.d.ts +16 -0
- package/utils/parseRegionId/parseRegionId.d.ts +16 -0
- package/utils/processFormFields/index.d.ts +16 -0
- package/utils/refetchEstimatedShippingMethods/index.d.ts +16 -0
- package/utils/scrollToElement/index.d.ts +18 -0
- package/utils/scrollToElement/scrollToElement.d.ts +18 -0
- package/utils/shippingMethods/index.d.ts +16 -0
- package/utils/validateForms/index.d.ts +18 -0
- package/utils/validateForms/validateForms.d.ts +18 -0
- package/chunks/EmptyCart.js +0 -1
- package/chunks/ErrorBanner.js +0 -1
- package/chunks/MergedCartBanner.js +0 -1
- package/chunks/OutOfStock.js +0 -1
- package/components/Checkout/Checkout.d.ts +0 -28
- package/components/Checkout/index.d.ts +0 -3
- package/components/EmptyCart/EmptyCart.d.ts +0 -9
- package/components/EmptyCart/index.d.ts +0 -3
- package/containers/Checkout/Checkout.d.ts +0 -35
- package/containers/Checkout/constants.d.ts +0 -2
- package/containers/Checkout/index.d.ts +0 -4
- package/containers/Checkout.d.ts +0 -3
- package/containers/Checkout.js +0 -1
- package/containers/EmptyCart/EmptyCart.d.ts +0 -8
- package/containers/EmptyCart/index.d.ts +0 -3
- package/containers/EmptyCart.d.ts +0 -3
- package/containers/EmptyCart.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,Fragment as U,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{d as ke,A as b,f as B,e as Le,D as oe,g as Ze,M as Fe,h as Ee,p as Me,i as Ke,s as Xe,a as Je,b as Ye,c as Qe}from"./setShippingMethods.js";import{events as ee}from"@dropins/tools/event-bus.js";import{A as Z,y as O,n as T,V as z,w as be,z as et,m as Ie,o as ue,v as Se,k as tt,B as K,E as Q}from"./getCart.graphql.js";import{useState as H,useCallback as j,useEffect as R,useRef as nt,useMemo as ot}from"@dropins/tools/preact-hooks.js";import{classes as $,getFormErrors as rt,Slot as de,VComponent as I}from"@dropins/tools/lib.js";import{Text as q,useText as J}from"@dropins/tools/i18n.js";import{Field as re,Input as me,Picker as it,Skeleton as he,SkeletonRow as A,IllustratedMessage as Ae,Icon as Ne,ProgressSpinner as ge,Button as st,Divider as X,RadioButton as we,Price as at}from"@dropins/tools/components.js";import{w as Y,c as lt}from"./BillToShippingAddress.js";import{s as Pe}from"./setBillingAddress.js";import*as x from"@dropins/tools/preact-compat.js";import{forwardRef as ct,useRef as $e,useImperativeHandle as dt,useState as G,useEffect as V,useMemo as xe,useCallback as te}from"@dropins/tools/preact-compat.js";import{E as ut}from"./ErrorBanner.js";import{M as mt}from"./MergedCartBanner.js";const 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}),pe={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 Re(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)},f=m=>{u(w=>({...w,[b.RegionId]:m}))};return l.map(m=>{var C;let w,F=m.frontendInput,k=p,v=h,M=m.isDisabled,P=m.isRequired,N=[],S;return F===Z.Multiline?(S=ke(m.code,e),w=ke(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&&(M=O.value.pending),P=i.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),N=pt(r),!P&&!i.displayStateIfOptional&&(F=Z.Undefined),F=N.length>0?Z.Select:Z.Text,F===Z.Select?t===B.SHIPPING?(O.value.selectedRegion=S,k=g=>{const _=g.target.value;le({country_code:O.value.country,region_id:_}),p(g),f(_)}):k=g=>{p(g);const _=g.target.value;f(_)}:F===Z.Text&&t===B.SHIPPING&&(O.value.selectedRegion=S,v=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:M,isRequired:P,onBlur:d,onChange:v,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(()=>{Le({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=Be(h);return o(re,{disabled:i,error:r,children:o(me,{"aria-label":a,autocomplete:pe[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,f=Be(p);return o(U,{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(me,{id:ie({addressType:e,code:n,index:m}),className:se(n),floatingLabel:`${s} ${m!=0?m:""} ${a&&m===0?"*":""}`,autocomplete:m===0?pe[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,...f})},`${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:pe[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}},Be=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=>L(he,{...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})=>L("div",{...s,className:$(["checkout-fields-form",t]),children:[o(ne,{level:2,children:o(q,{id:i}),className:"checkout-fields-form__title"}),o("form",{name:a,ref:r,className:$(["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}Ze(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=ue.value.data,l=!!s,d=T.value.data,h=!!d;V(()=>{var w;if(!e||!h||i)return;let c,p=!1;c=Gt({addressType:t,cart:d}),!c&&l&&(c=Dt({addressType:t,customer:s}),p=!0);const u=F=>F?F.split(Ee).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||""},f=c.region;if(f){const F=(w=f==null?void 0:f.id)==null?void 0:w.toString();F?(E[b.Region]=F,E[b.RegionId]=F):E[b.Region]=f.code}c!=null&&c.street&&c.street.length>0&&c.street.forEach((F,k)=>{E[`${b.Street}${Fe}${k}`]=F}),((c==null?void 0:c.customAttributes)||[]).forEach(F=>{u(F.code)?F.value.split(Ee).forEach((v,M)=>{E[`${F.code}${Fe}${M}`]=v}):E[F.code]=F.value}),r({values:E,triggerAutoSave:p})},[t,e,d,s,i,h,l,r,n])}const Oe=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}=be.value,u=et.value.data,E=u===void 0,f=c===void 0||p,m=Ie.value.data,w=m===void 0,{defaultValues:F}=It(m==null?void 0:m.defaultCountry),k=Wt({fields:c,preselectedFields:a}),v=$e(null),{address:M,errors:P,loadAutoFill:N,onBlur:S,dismissError:C,onChange:g,onInvalid:y,onSelection:_,setAddress:W}=zt({defaultValues:F,formRef:v,onCheckoutDataUpdate:l,preselection:k,saveAddressHandler:s,type:e}),{availableRegions:ae}=St({country:M.country_id,addressType:e});if(dt(h,()=>({triggerSaveAddress:qe=>{if(!v.current)return;const Ue=bt(v.current);if(Re(Ue))return s({signal:qe,address:M})}})),At({addressType:e,autoFill:t,loadAutoFill:N,dismissError:C}),f||E||w)return o(Lt,{"data-testid":`${e}-skeleton`});const je=vt({address:M,addressType:e,availableCountries:u,availableRegions:ae,config:m,dismissError:C,errors:P,fields:c,onBlur:S,onChange:g,onInvalid:y,onSelection:_,setAddress:W}),ve={[B.SHIPPING]:"shipping",[B.BILLING]:"billing"};return o(Mt,{...d,name:i,addressType:e,className:`checkout-${ve[e]}-form`,"data-testid":`${ve[e]}-form`,fields:je,formRef:v,headingId:r})}),Nt="DROPIN__CHECKOUT",fe=e=>`${Nt}__${e.toUpperCase()}`,wt=(e,t)=>{window.localStorage.setItem(fe(e),JSON.stringify(t))},Pt=e=>{const t=window.localStorage.getItem(fe(e));return t?JSON.parse(t):null},$t=e=>{window.localStorage.removeItem(fe(e))};function xt(e){const[t,n]=H(null),r=j(a=>setTimeout(()=>{wt(e,a)},oe),[e]),i=j(()=>{$t(e)},[e]);return R(()=>{const a=Pt(e);a&&n(a)},[e]),R(()=>{const a=ee.on("checkout/order",()=>{i()});return()=>{a==null||a.off()}},[i]),{addressBackup:t,backupAddress:r,removeAddressBackup:i}}const Rt={[B.BILLING]:"billing",[B.SHIPPING]:"shipping"};function Bt({address:e,type:t,isValid:n}){R(()=>{const r=setTimeout(()=>{ee.emit("checkout/address",{type:Rt[t],address:e,isValid:n()})},oe);return()=>{clearTimeout(r)}},[e,n,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=j(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({})}}},ye=e=>{const t=e.current;if(!t)return!1;const n=rt(t);return Re(n)},zt=({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,isValid:j(()=>ye(t),[t])});const{addressBackup:c,backupAddress:p,removeAddressBackup:u}=xt(a),{errors:E,validateFormElement:f,dismissError:m,resetErrors:w}=Tt(s),F=j(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},v=({values:C,triggerAutoSave:g=!1})=>{w(),h(y=>({...y,...C})),g&&(l.current=!0)},M=C=>{const g=C.target,{name:y,value:_}=g;k(y,_),f(g)},P=C=>{const g=C.target;f(g)},N=C=>{const g=C.target,{name:y,value:_}=g;k(y,_),f(g)},S=C=>{C.target.checkValidity()};return R(()=>{h(C=>({...e,...r,...c,...C}))},[e,r,c]),R(()=>{if(!l.current)return;const C=p(d);return()=>{clearTimeout(C)}},[d,p]),R(()=>{if(!l.current||!ye(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:v,dismissError:m,onChange:M,onSelection:N,onBlur:S,onInvalid:P,setAddress:h}},Vt={countryCode:b.Country,region:b.Region,postCode:b.PostCode};function Wt({fields:e,preselectedFields:t}){return ot(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((i,a)=>{const s=Vt[a];return!s||!e.some(d=>d.code===s)?i:{...i,[s]:t[a]}},{}),[e,t])}const Dt=({addressType:e,customer:t})=>e===B.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,Gt=({addressType:e,cart:t})=>{if(e===B.BILLING)return t.billingAddress;const n=t.shippingAddresses;if(!(!n||n.length===0))return n[0]},He=e=>{var E;const t=$e(null),n=be.value.data,r=ue.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}=Se.value,c=!d,p=xe(()=>!n||!c?!1:s?!lt(n,s,l):!!i,[c,n,s,l,i]),u=te(f=>Pe({signal:f.signal,input:{address:d?void 0:Me(f.address),same_as_shipping:d}}),[d]);return V(()=>{if(!h)return;const f=new AbortController;return d||t.current.triggerSaveAddress(f.signal),()=>{f.abort()}},[d,h]),o(Oe,{...e,addressType:B.BILLING,autoFill:p,"data-testid":"billing-form",headingId:"Checkout.BillingAddress.title",name:jt,ref:t,saveAddressHandler:u,style:{display:c?"block":"none"}})};He.displayName="BillingFormContainer";const On=Y(He),jt="billing_address",qt=e=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.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"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Ut=e=>x.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},x.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"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.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"}),x.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"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),x.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Te="login-form",Zt=({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(me,{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})})},Kt=({onSignInClick:e,email:t})=>L("div",{className:"checkout-login-form__sign-in",children:[o(q,{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(q,{id:"Checkout.LoginForm.signIn"})})]}),Xt=({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 L("div",{...p,className:$(["checkout-login-form",t]),"data-testid":"checkout-login-form",children:[L("div",{className:"checkout-login-form__heading",children:[o(ne,{level:2,className:"checkout-login-form__title",children:u.Title}),E?o(Jt,{onSignOutClick:h}):o(Kt,{onSignInClick:d,email:n})]}),c?L("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:L("form",{className:$(["dropin-login-form__form",t]),name:e,noValidate:!0,children:[o("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),o(Zt,{value:n||void 0,error:i||"",hint:r,onChange:a,onBlur:s,onInvalid:l})]})})]})},Jt=({onSignOutClick:e})=>L("p",{className:"checkout-login-form__sign-out",children:[o(q,{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(q,{id:"Checkout.LoginForm.signOut"})})]}),Yt=e=>D.email.test(e),Qt=1e3,ze=({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),[f,m]=H(null),[w,F]=H(!0),k=g=>g.valid?null:g.valueMissing?a.LoginFormMissingEmailError:a.LoginFormInvalidEmailError,v=ue.value.data,M=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)),R(()=>{if(f!==null&&f!==""||u===null||u===""||tt.authenticated)return;const g=setTimeout(()=>{Ke(u).then(y=>{F(y),h!==u&&Xe(u).catch(console.error)}).catch(y=>{console.log(y),m(a.LoginFormInvalidEmailError),F(!0)})},Qt);return()=>{g&&clearTimeout(g)}},[h,l,u,f,a.LoginFormInvalidEmailError]);const S=w?"":L(U,{children:[a.LoginFormEmailExistsAlreadyHaveAccount," ",o("a",{href:"#",onClick:g=>{g.preventDefault(),n==null||n(u)},children:a.LoginFormEmailExistsSignInButton})," ",a.LoginFormEmailExistsForFasterCheckout]});return o(Xt,{className:e,currentEmail:u,error:f,hint:S,name:Te,onEmailBlur:P,onEmailChange:M,onEmailInvalid:N,onSignInClick:g=>{const y=u?Yt(u):!1;n==null||n(y?g:null)},onSignOutClick:r,customer:v,...i})};ze.displayName="LoginFormContainer";const Hn=Y(ze),en=()=>L(he,{"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})]}),tn=({code:e,isLoading:t,isSelected:n,onChange:r,title:i})=>o(kn,{className:"checkout-payment-methods__method",label:i,name:"payment-method",value:e,selected:n,onChange:r,radioButtonProps:{"aria-busy":t}}),nn=({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(en,{}):L("div",{className:$(["checkout-payment-methods",e]),children:[o(ne,{level:2,className:"checkout-payment-methods__title",children:s.Title}),!n&&i.length===0&&o(Ae,{icon:o(Ne,{source:qt}),message:o("p",{children:s.EmptyState})}),L("div",{className:$(["checkout-payment-methods__wrapper"]),children:[n&&o(ge,{className:"checkout-payment-methods__spinner"}),o("div",{className:$(["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(tn,{code:l.code,onChange:r,isSelected:l.code===a,title:l.title},l.code))}),t&&o("div",{className:"checkout-payment-methods__content",children:t})]})]})},_e={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 on(e){var y;const{onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r}=e,[i,a]=G(),[s,l]=G(),[d,h]=G(_e),[c,p]=G(!0),{data:u}=T.value,E=(u==null?void 0:u.id)??"",f=!!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,v=u==null?void 0:u.selectedPaymentMethod,M=te(async _=>{try{if(a(_),!m&&F||_===(v==null?void 0:v.code))return;await Je(_)}catch(W){console.error("setting payment method failed:",W)}},[m,F,v]);V(()=>{f&&(v!=null&&v.code?(k==null?void 0:k.some(W=>W.code===v.code))?a(v.code):k!=null&&k.length?M(k[0].code):a(void 0):k[0]&&M(s||k[0].code))},[k,f,v,M,s]);const P=async _=>{t(),await M(_),v!=null&&v.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(de,{name:"PaymentMethods",slot:r,context:{addPaymentMethodHandler:N,replaceHTML(_){this.replaceWith(_),p(!1)}}}):null,C=i?d[i]:null,g=C?o(de,{name:"PaymentMethodContent",slot:C.render,context:{cartId:E,onPlaceOrder:t,handleServerError:n,replaceHTML(_){this.replaceWith(_)}}},C):void 0;return V(()=>{!c&&d!=_e&&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 Ve=e=>{const{onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r}=e,{availablePaymentMethods:i,selectedPaymentMethod:a,onPaymentMethodChange:s,paymentMethodContent:l,mainSlotContent:d,isDefaultContentUsed:h}=on({onPlaceOrder:t,handleServerError:n,paymentMethodsSlot:r});return L(U,{children:[d&&o(d.type,{ref:d.ref,...d.props}),h&&o(nn,{options:i,selection:a,onChange:s,paymentMethodContent:l,isLoading:T.value.pending})]})};Ve.displayName="PaymentMethodsContainer";const Tn=Y(Ve),rn=({className:e,onClick:t=()=>{},disabled:n=!1})=>o("div",{className:$(["checkout-place-order",e]),children:o(st,{className:$(["checkout-place-order__button",e]),"data-testid":"place-order-button",disabled:n,onClick:t,size:"medium",type:"submit",variant:"primary",children:o(q,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),sn=[Te,"shipping_address","billing_address"],an=e=>{const t=e.querySelector(":invalid");t&&(t.scrollIntoView({behavior:"smooth"}),t.focus())},ln=()=>{const t=(Array.from(document.forms)||[]).filter(r=>sn.includes(r.name)).filter(r=>r.offsetParent!==null).filter(r=>!r.checkValidity()),n=t.length===0;if(!n){const r=t[0];an(r)}return n},cn=({onClick:e,handleServerError:t})=>{const[n,r]=G(!1),i=T.value.pending,a=async()=>{if(ln())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(rn,{onClick:a,disabled:i||n})},zn=Y(cn),We=({onCheckoutDataUpdate:e,preselectedFields:t,...n})=>{const r=Se.value.checked,i=te(a=>Ye({signal:a.signal,address:Me(a.address)}).then(()=>{if(r)return Pe({input:{same_as_shipping:!0}})}),[r]);return o(Oe,{...n,addressType:B.SHIPPING,headingId:"Checkout.ShippingAddress.title",name:dn,onCheckoutDataUpdate:e,preselectedFields:t,saveAddressHandler:i})};We.displayName="ShippingFormContainer";const Vn=Y(We),dn="shipping_address",un=()=>{const e=()=>window.innerWidth>=1920?"xxlarge":window.innerWidth>=1366?"xlarge":window.innerWidth>=1024?"large":window.innerWidth>=768?"medium":"small",[t,n]=H(e());return R(()=>{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},mn=()=>{const e=j(()=>{document.body.style.overflow="hidden"},[]),t=j(()=>{document.body.style.overflow=""},[]);return{lockScroll:e,unlockScroll:t}},De=()=>L("div",{className:"checkout-heading",children:[o(ne,{level:1,className:"checkout-heading__title",children:o(q,{id:"Checkout.title"})}),o(X,{variant:"primary",className:"checkout-heading__divider-primary"})]}),hn=({billingAddress:e,billToShippingAddress:t,cartSummaryList:n,emptyCart:r,login:i,orderSummary:a,outOfStock:s,paymentMethods:l,placeOrder:d,shippingAddress:h,shippingMethods:c})=>L(U,{children:[o(De,{}),n&&o(I,{node:n}),o(I,{node:r}),o(I,{node:s}),o(I,{node:i}),o(X,{variant:"primary"}),o(I,{node:h}),o(I,{node:t}),c&&o(I,{node:c}),o(X,{variant:"primary"}),o(I,{node:l}),o(I,{node:e}),a&&o(I,{node:a}),o(I,{node:s}),o(I,{node:d})]}),gn=({billingAddress:e,billToShippingAddress:t,cartSummaryList:n,emptyCart:r,login:i,orderSummary:a,outOfStock:s,paymentMethods:l,placeOrder:d,shippingAddress:h,shippingMethods:c})=>L(U,{children:[L("div",{className:"checkout__main",children:[o(De,{}),o(I,{node:r}),o(I,{node:s}),o(I,{node:i}),o(X,{variant:"primary"}),o(I,{node:h}),o(I,{node:t}),c&&o(I,{node:c}),o(X,{variant:"primary"}),o(I,{node:e}),o(I,{node:l}),o(X,{variant:"primary"}),o(I,{node:d})]}),L("div",{className:"checkout__aside",children:[a&&o(I,{node:a}),n&&o(I,{node:n})]})]}),pn=({blocks:e})=>un()==="small"?o(hn,{...e}):o(gn,{...e}),fn=({children:e,className:t,isLoading:n=!1,...r})=>L("div",{"data-testid":"checkout",className:$(["checkout",t]),...r,children:[n&&o(vn,{}),o(ut,{}),o(mt,{}),o("div",{className:"checkout__content",children:e})]});fn.Main=pn;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})},vn=({className:e})=>{const{lockScroll:t,unlockScroll:n}=mn();return R(()=>(t(),n),[t,n]),o("div",{"data-testid":"checkout-overlay-loader",className:$(["checkout-overlay-loader",e]),children:o(ge,{})})},kn=({label:e,name:t,value:n,icon:r,selected:i,onChange:a,className:s,children:l,radioButtonProps:d,...h})=>o("div",{className:$(["checkout-toggle-button",s,["checkout-toggle-button__selected",i]]),...h,children:L("label",{className:"checkout-toggle-button__actionButton",children:[o(we,{...d,label:"",name:t,value:n,checked:i,onChange:()=>a(n),"aria-label":e,className:$([s,"checkout-toggle-button__radioButton"])}),L("div",{className:"checkout-toggle-button__content",children:[r&&o(r.type,{...r==null?void 0:r.props,className:"checkout-toggle-button__icon"}),e]})]})}),Fn=({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(En,{}):L("div",{...a,className:$(["checkout-shipping-methods",e]),children:[o(ne,{level:3,className:"checkout-shipping-methods__title",children:s.Title}),!t&&r.length===0&&o(Ae,{icon:o(Ne,{source:Ut}),message:o("p",{children:s.EmptyState})}),L("div",{className:$(["checkout-shipping-methods__content"]),children:[t&&o(ge,{className:"checkout-shipping-methods__spinner"}),o("div",{className:$(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:r.map(l=>o(we,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:l.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:L(U,{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))})]})]})},En=()=>L(he,{"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 Cn(){var u;const[e,t]=H(),[n,r]=H();R(()=>{ee.on("checkout/address",({address:E,type:f,isValid:m})=>{f==="shipping"&&t({address:E,isValid:m})})},[]),R(()=>{r(K.value)},[K.value]),R(()=>{Q.value.pending?r(void 0):r(K.value)},[Q.value.pending]);const{country_id:i,region_id:a,region:s,postcode:l}=(e==null?void 0:e.address)||{},d=!!e,h=T.value.data,c=!!((u=h==null?void 0:h.shippingAddresses)!=null&&u[0]),p=e==null?void 0:e.isValid;R(()=>{c||p||!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,p])}const ce=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code;function yn({onCheckoutDataUpdate:e,preSelectedMethod:t}){const n=Ie.value.data,r=!n,i=T.value.data,a=T.value.pending,s=Q.value.data,l=Q.value.pending,d=K.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,f=p==null?void 0:p.selectedShippingMethod,m=E||s,w=te(v=>{if(!u)return;const M={method_code:v.code,carrier_code:v.carrier.code};Qe([M]).then(()=>{e==null||e()}).catch(P=>{console.error("setting shipping methods on cart failed:",P)})},[u,e]),F=v=>{K.value=v},k=xe(()=>{if(!(m!=null&&m.length))return;const v=m[0],M=d||f;return M?m.some(N=>ce(N,M))?M:v:m.find(S=>S.carrier.code===(t==null?void 0:t.carrierCode)&&S.code===(t==null?void 0:t.methodCode))||v},[d,f,m,t]);return V(()=>{k&&((!d||!ce(k,d))&&(K.value=k),(!f||!ce(k,f))&&w(k))},[k,d,f,w]),V(()=>{if(!h||E)return;const{country:v,selectedRegion:M,selectedRegionId:P}=O.value,N=v||(n==null?void 0:n.defaultCountry);N&&Le({criteria:{country_code:N,region_name:M,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 Ge=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:n,...r})=>{const{isLoading:i,options:a,selection:s,onSelectionChange:l}=yn({preSelectedMethod:e,onCheckoutDataUpdate:t});return Cn(),L(U,{children:[o(Fn,{...r,className:"checkout-shipping-methods",isLoading:i,onSelectionChange:l,options:a,selection:s}),!i&&o(de,{name:"ShippingMethods",slot:n})]})};Ge.displayName="ShippingMethodsContainer";const Wn=Y(Ge);export{On as B,fn as C,Hn as L,zn as P,Wn as S,Vn as a,dn as b,Tn as c,Te as d,jt as e};
|
|
1
|
+
import{jsx as m,Fragment as me,jsxs as te}from"@dropins/tools/preact-jsx-runtime.js";import{events as re}from"@dropins/tools/event-bus.js";import{A as x,x as y,q as ne,V as k,o as ge,y as fe,t as he,p as pe}from"./fixtures.js";import{b as X,a as p,A as N,e as Fe,D as O,g as ve,M as J,c as K}from"./getMultilineValues.js";import{classes as Y,getFormErrors as Ie}from"@dropins/tools/lib.js";import{useState as G,useCallback as P,useEffect as z,useRef as Ee,useMemo as Ae}from"@dropins/tools/preact-hooks.js";import{Text as Ce,useText as Se}from"@dropins/tools/i18n.js";import{Field as H,Input as se,Picker as be,Skeleton as $e,SkeletonRow as $}from"@dropins/tools/components.js";/* empty css *//* empty css */import{forwardRef as Me,useRef as Re,useImperativeHandle as Le,useState as U,useEffect as q}from"@dropins/tools/preact-compat.js";const Z={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 ae(e){return Object.keys(e).length===0&&e.constructor===Object}const we=e=>e.map(t=>{var n;const r=((n=t==null?void 0:t.id)==null?void 0:n.toString())||t.code;return{text:t.name,value:r}}),Ne=e=>e?e.map(t=>({text:t.label,value:t.value})):[];function ye({address:e,addressType:t,availableCountries:r,availableRegions:n,config:s,dismissError:o,errors:c,fields:u,onBlur:d,onChange:F,onInvalid:a,onSelection:h,setAddress:v}){const I=()=>{v(i=>({...i,[p.Region]:"",[p.RegionId]:""})),o(p.Region)},A=i=>{v(M=>({...M,[p.RegionId]:i}))};return u.map(i=>{var f;let M,g=i.frontendInput,b=h,R=F,L=i.isDisabled,D=i.isRequired,w=[],S;return g===x.Multiline?(S=X(i.code,e),M=X(i.code,c)):(S=e[i.code],M=c[i.code]||""),i.code===p.Country&&(w=Ne(r),t===N.SHIPPING&&(y.value.country=S,b=l=>{const E=l.target,{value:C}=E;C&&T({country_code:C}),h(l),I()})),i.code===p.RegionId&&t===N.SHIPPING&&(y.value.selectedRegionId=S),i.code===p.Region&&(t===y.value.addressType&&(L=y.value.pending),D=s.countriesWithRequiredRegion.includes(e==null?void 0:e.country_id),w=we(n),!D&&!s.displayStateIfOptional&&(g=x.Undefined),g=w.length>0?x.Select:x.Text,g===x.Select?t===N.SHIPPING?(y.value.selectedRegion=S,b=l=>{const C=l.target.value;T({country_code:y.value.country,region_id:C}),h(l),A(C)}):b=l=>{h(l);const C=l.target.value;A(C)}:g===x.Text&&t===N.SHIPPING&&(y.value.selectedRegion=S,R=l=>{const E=l.target,{value:C}=E;y.value.country&&T({country_code:y.value.country,region_name:C}),F(l)}),S=w.length>0?((f=w.find(l=>l.value===S))==null?void 0:f.value)||"":S),i.code===p.PostCode&&(D=!s.countriesWithOptionalZipCode.includes(e==null?void 0:e.country_id)),{...i,error:M,frontendInput:g,handleSelect:b,isDisabled:L,isRequired:D,onBlur:d,onChange:R,onInvalid:a,options:w,value:S}})}let Q;function T(e){var o;const t=ne.value.data,r=!!t,n=(o=t==null?void 0:t.shippingAddresses)==null?void 0:o[0],s=n==null?void 0:n.availableShippingMethods;r&&!s&&(clearTimeout(Q),Q=setTimeout(()=>{Fe({criteria:e})},O))}const V=({addressType:e,code:t,index:r})=>r?`${e}-${t}-${r}`:`${e}-${t}`,B=e=>`checkout-address-form__${e}`,ke=({addressType:e,element:t})=>{const{code:r,value:n,defaultValue:s}=t;return m("input",{className:B(r),id:V({addressType:e,code:r}),name:r,type:"hidden",value:n||s},r)},De=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,label:o,onBlur:c,onChange:u,onInvalid:d,validateRules:F,value:a}=t,h=oe(F);return m(H,{disabled:s,error:n,children:m(se,{"aria-label":o,autocomplete:Z[r]||"off",className:B(r),floatingLabel:`${o} ${t.isRequired?"*":""}`,id:V({addressType:e,code:r}),onBlur:c,onChange:u,onInvalid:d,placeholder:o,required:t.isRequired||!1,type:"text",name:r,value:a??void 0,...h})})},_e=({addressType:e,element:t})=>{const{code:r,error:n,isDisabled:s,isRequired:o,label:c,multilineCount:u,onBlur:d,onChange:F,onInvalid:a,validateRules:h,value:v}=t,I=u??0,A=oe(h);return m(me,{children:Array.from(Array(I).keys()).map(i=>m(H,{disabled:s,error:(n==null?void 0:n[i])||"",className:"dropin-field--multiline",children:m(se,{id:V({addressType:e,code:r,index:i}),className:B(r),floatingLabel:`${c} ${i!=0?i:""} ${o&&i===0?"*":""}`,autocomplete:i===0?Z[r]:"off","aria-label":c,placeholder:`${c} ${i!=0?i:""}`,type:"text",required:o&&i===0,onChange:F,onBlur:d,onInvalid:a,name:`${r}-${i}`,value:(v==null?void 0:v[i])||void 0,...A})},`${r}-${i}`))})},xe=({addressType:e,element:t})=>{const{code:r,error:n,handleSelect:s,isDisabled:o,isRequired:c,label:u,onBlur:d,onInvalid:F,options:a,value:h}=t,v=s?{handleSelect:s}:{};return m(H,{disabled:o,error:n,children:m(be,{id:V({addressType:e,code:r}),className:B(r),name:r,floatingLabel:`${u} ${c?"*":""}`,required:c,placeholder:u,"aria-label":u,options:a,value:h,autocomplete:Z[r]||"off",onBlur:d,onInvalid:F,...v},r)})},ze=({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 ke({addressType:e,element:t});case"TEXT":return De({addressType:e,element:t});case"MULTILINE":return _e({addressType:e,element:t});case"SELECT":return xe({addressType:e,element:t});default:return null}},oe=e=>e?e.reduce((t,r)=>{switch(r.name){case k.DateRangeMax:return{...t,max:r.value};case k.DateRangeMin:return{...t,min:r.value};case k.FileExtensions:return{...t,accept:r.value};case k.InputValidation:return{...t,pattern:Pe(r.value)};case k.MaxFileSize:case k.MaxImageHeight:case k.MaxImageWidth:return t;case k.MaxTextLength:return{...t,maxLength:r.value};case k.MinTextLength:return{...t,minLength:r.value};default:throw new Error(`Unknown rule: ${r.name}`)}},{}):{},_={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]*))?)$/},Pe=e=>{switch(e){case"alpha":return _.alpha.source;case"alphanumeric":return _.alphanumeric.source;case"alphanumeric-w-space":return _["alphanumeric-w-space"].source;case"alphanum-with-spaces":return _["alphanum-with-spaces"].source;case"url":return _.url.source;case"numeric":return _.numeric.source;case"email":return _.email.source;default:throw new Error(`Unknown validation type: ${e}`)}},Oe=e=>te($e,{...e,children:[m($,{variant:"heading",size:"medium"}),m($,{variant:"empty",size:"medium"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large",fullWidth:!0}),m($,{size:"large",fullWidth:!0,lines:3}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"}),m($,{size:"large"})]}),Ve=({addressType:e,className:t,fields:r,formRef:n,headingId:s,name:o,...c})=>te("div",{...c,className:Y(["checkout-fields-form",t]),children:[m(at,{level:2,children:m(Ce,{id:s}),className:"checkout-fields-form__title"}),m("form",{name:o,ref:n,className:Y(["checkout-fields-form__form",t]),noValidate:!0,children:r.sort((u,d)=>!u.sortOrder||!d.sortOrder?u.code<d.code?-1:1:u.sortOrder-d.sortOrder).map(u=>ze({element:u,addressType:e}))})]}),Be=e=>{const t=new FormData(e),r=Object.fromEntries(t);return Object.entries(r).reduce((s,[o])=>{const c=e.elements[o];return c!=null&&c.validationMessage?{...s,[o]:c.validationMessage}:{...s}},{})};function Te(e){const[t,r]=U({});return q(()=>{e&&r(n=>({...n,country_id:e}))},[e]),{defaultValues:t}}function Ge({country:e,addressType:t}){const[r,n]=U([]);return q(()=>{if(!e){n([]);return}ve(e,t).then(s=>{n(s||[])}).catch(s=>{console.error(s)})},[n,e,t]),{availableRegions:r}}function He({autoFill:e,addressType:t,dismissError:r,loadAutoFill:n}){const[s,o]=U(!1),c=pe.value.data,u=!!c,d=ne.value.data,F=!!d;q(()=>{var M;if(!e||!F||s)return;let a,h=!1;a=st({addressType:t,cart:d}),!a&&u&&(a=nt({addressType:t,customer:c}),h=!0);const v=g=>g?g.split(K).length>1:!1;if(!a)return;o(!0);const I={[p.City]:a.city,[p.Company]:a.company||"",[p.Country]:a.country.value,[p.FirstName]:a.firstName,[p.LastName]:a.lastName,[p.PostCode]:a.postCode||"",[p.Telephone]:a.telephone||"",[p.Vat]:a.vatId||""},A=a.region;if(A){const g=(M=A==null?void 0:A.id)==null?void 0:M.toString();g?(I[p.Region]=g,I[p.RegionId]=g):I[p.Region]=A.code}a!=null&&a.street&&a.street.length>0&&a.street.forEach((g,b)=>{I[`${p.Street}${J}${b}`]=g}),((a==null?void 0:a.customAttributes)||[]).forEach(g=>{v(g.code)?g.value.split(K).forEach((R,L)=>{I[`${g.code}${J}${L}`]=R}):I[g.code]=g.value}),n({values:I,triggerAutoSave:h})},[t,e,d,c,s,F,u,n,r])}const vt=Me(({addressType:e,autoFill:t=!0,children:r,headingId:n,name:s,preselectedFields:o,saveAddressHandler:c,onCheckoutDataUpdate:u,...d},F)=>{const{data:a,pending:h}=ge.value,v=fe.value.data,I=v===void 0,A=a===void 0||h,i=he.value.data,M=i===void 0,{defaultValues:g}=Te(i==null?void 0:i.defaultCountry),b=rt({fields:a,preselectedFields:o}),R=Re(null),{address:L,errors:D,loadAutoFill:w,onBlur:S,dismissError:f,onChange:l,onInvalid:E,onSelection:C,setAddress:ie}=et({defaultValues:g,formRef:R,onCheckoutDataUpdate:u,preselection:b,saveAddressHandler:c,type:e}),{availableRegions:ce}=Ge({country:L.country_id,addressType:e});if(Le(F,()=>({triggerSaveAddress:le=>{if(!R.current)return;const de=Be(R.current);if(ae(de))return c({signal:le,address:L})}})),He({addressType:e,autoFill:t,loadAutoFill:w,dismissError:f}),A||I||M)return m(Oe,{"data-testid":`${e}-skeleton`});const ue=ye({address:L,addressType:e,availableCountries:v,availableRegions:ce,config:i,dismissError:f,errors:D,fields:a,onBlur:S,onChange:l,onInvalid:E,onSelection:C,setAddress:ie}),W={[N.SHIPPING]:"shipping",[N.BILLING]:"billing"};return m(Ve,{...d,name:s,addressType:e,className:`checkout-${W[e]}-form`,"data-testid":`${W[e]}-form`,fields:ue,formRef:R,headingId:n})}),Ue="DROPIN__CHECKOUT",j=e=>`${Ue}__${e.toUpperCase()}`,qe=(e,t)=>{window.localStorage.setItem(j(e),JSON.stringify(t))},Ze=e=>{const t=window.localStorage.getItem(j(e));return t?JSON.parse(t):null},je=e=>{window.localStorage.removeItem(j(e))};function We(e){const[t,r]=G(null),n=P(o=>setTimeout(()=>{qe(e,o)},O),[e]),s=P(()=>{je(e)},[e]);return z(()=>{const o=Ze(e);o&&r(o)},[e]),z(()=>{const o=re.on("checkout/order",()=>{s()});return()=>{o==null||o.off()}},[s]),{addressBackup:t,backupAddress:n,removeAddressBackup:s}}const Xe={[N.BILLING]:"billing",[N.SHIPPING]:"shipping"};function Je({address:e,type:t,isValid:r}){z(()=>{const n=setTimeout(()=>{re.emit("checkout/address",{type:Xe[t],address:e,isValid:r()})},O);return()=>{clearTimeout(n)}},[e,r,t])}const Ke={badInput:"aria-label",patternMismatch:"aria-label",rangeOverflow:"max",rangeUnderflow:"min",tooLong:"maxlength",tooShort:"minlength",typeMismatch:"aria-label",valueMissing:"aria-label"},Ye=["badInput","patternMismatch","rangeOverflow","rangeUnderflow","tooLong","tooShort","typeMismatch","valueMissing"],Qe=e=>{const[t,r]=G({}),n=P(c=>{const{name:u,validity:d,validationMessage:F}=c;let a=d.valid?"":F;Ye.forEach(h=>{if(!d[h])return;const v=e[h];if(!v)return;const I=Ke[h];a=v.replace("{field}",c.getAttribute(I)||"")}),r(h=>({...h,[u]:a}))},[e]);return{errors:t,dismissError:c=>{t[c]&&r(u=>{const{[c]:d,...F}=u;return F})},validateFormElement:n,resetErrors:()=>{r({})}}},ee=e=>{const t=e.current;if(!t)return!1;const r=Ie(t);return ae(r)},et=({defaultValues:e={},formRef:t,onCheckoutDataUpdate:r,preselection:n={},saveAddressHandler:s,type:o})=>{const c=Se({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"}),u=Ee(!1),[d,F]=G({});Je({address:d,type:o,isValid:P(()=>ee(t),[t])});const{addressBackup:a,backupAddress:h,removeAddressBackup:v}=We(o),{errors:I,validateFormElement:A,dismissError:i,resetErrors:M}=Qe(c),g=P(f=>{u.current=!1,s(f).then(()=>{v(),r==null||r()}).catch(l=>{u.current=!0,console.error("Saving address form failed:",l)})},[v,s,r]),b=(f,l)=>{F(E=>({...E,[f]:l})),u.current=!0},R=({values:f,triggerAutoSave:l=!1})=>{M(),F(E=>({...E,...f})),l&&(u.current=!0)},L=f=>{const l=f.target,{name:E,value:C}=l;b(E,C),A(l)},D=f=>{const l=f.target;A(l)},w=f=>{const l=f.target,{name:E,value:C}=l;b(E,C),A(l)},S=f=>{f.target.checkValidity()};return z(()=>{F(f=>({...e,...n,...a,...f}))},[e,n,a]),z(()=>{if(!u.current)return;const f=h(d);return()=>{clearTimeout(f)}},[d,h]),z(()=>{if(!u.current||!ee(t))return;const f=new AbortController,l=f.signal,E=setTimeout(()=>{g({signal:l,address:d})},O);return()=>{clearTimeout(E),f.abort()}},[d,t,g]),{address:d,errors:I,loadAutoFill:R,dismissError:i,onChange:L,onSelection:w,onBlur:S,onInvalid:D,setAddress:F}},tt={countryCode:p.Country,region:p.Region,postCode:p.PostCode};function rt({fields:e,preselectedFields:t}){return Ae(()=>!(!!e&&e.length>0)||!!!t?{}:Object.keys(t).reduce((s,o)=>{const c=tt[o];return!c||!e.some(d=>d.code===c)?s:{...s,[c]:t[o]}},{}),[e,t])}const nt=({addressType:e,customer:t})=>e===N.BILLING?t.defaultBillingAddress:t.defaultShippingAddress,st=({addressType:e,cart:t})=>{if(e===N.BILLING)return t.billingAddress;const r=t.shippingAddresses;if(!(!r||r.length===0))return r[0]},at=({className:e,children:t,level:r=2})=>{const n=r>=1&&r<=6?`h${r}`:"h2";return m(n,{className:e,children:t})};export{vt as A,at as H,_ as p};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{events as E}from"@dropins/tools/event-bus.js";import{signal as o,effect as I}from"@dropins/tools/signals.js";import{FetchGraphQL as M}from"@dropins/tools/fetch-graphql.js";class G extends Error{constructor(s){super(s.map(t=>t.message).join(" ")),this.name="FetchError"}}class p extends Error{constructor(s){super(s),this.name="InvalidArgument"}}class $ extends Error{constructor(s){super(s),this.name="UnexpectedError"}}class J extends p{constructor(){super("Cart ID is required")}}class K extends p{constructor(){super("Email is required")}}class V extends p{constructor(){super("Payment method code is required")}}class ee extends p{constructor(){super("Billing address is required")}}class se extends p{constructor(){super("Country Code is required")}}const C=[];function L(e){return new Promise((s,t)=>{C.push(e);const a=()=>{C[0]===e?e().then(s).catch(t).finally(()=>C.shift()):setTimeout(a,100)};a()})}const x=["sender_email","recipient_email"];function A(e){return e.filter(s=>!s.path||!x.some(t=>{var a;return((a=s.path)==null?void 0:a.at(-1))===t}))}const S=e=>{throw e instanceof DOMException&&e.name==="AbortError"||E.emit("error",{source:"checkout",type:"network",error:e}),e},R=o({data:void 0,pending:!1}),O=o({checked:!0,setByUser:!1}),_=o({pending:!1,data:void 0});I(()=>{var e;(e=_.value.data)!=null&&e.isVirtual&&(O.value={checked:!1,setByUser:!1})});I(()=>{_.value.pending||E.emit("checkout/data",_.value.data||null)});const U=o({data:void 0,pending:!1}),h=o({pending:!1,data:void 0});I(()=>{h.value.pending||h.value.data&&E.emit("checkout/customer",h.value.data)});const X=o({pending:!1,data:void 0}),q=o({pending:!1,data:void 0}),te=o(void 0),ae=o(),b=o({data:void 0,pending:!1}),k={cart:_,customer:h,estimateShippingMethods:X,regions:q,storeConfig:b,countryList:U,addressFormFields:R};function w(e,s){return s.split(".").reduce((t,a)=>t&&t[a]!==void 0?t[a]:void 0,e)}const N={cart:null,customer:null,estimateShippingMethods:null,regions:null,storeConfig:null,countryList:null,addressFormFields:null};async function P(e){const{defaultValueOnFail:s,query:t,options:a,path:l,signalType:c,type:T,transformer:f}=e,r=k[c],v=Symbol();N[c]=v,r.value={...r.value,pending:!0};try{const{data:g,errors:y}=await(T==="mutation"?L(()=>m(t,a).catch(S)):m(t,{method:"GET",cache:"no-cache",...a}).catch(S));if(y){const D=A(y);if(D.length>0)throw new G(D)}let u=w(g,l);if(u===void 0)throw new Error(`No data found at path: ${l}`);return f&&(u=f(u)),r.value={...r.value,data:u},setTimeout(()=>{r.value={...r.value,pending:N[c]===v?!1:r.value.pending}},0),u}catch(g){if(s)return r.value={pending:!1,data:s},s;if(g.name==="AbortError")return;throw r.value={...r.value,pending:!1},g}}const F={cartId:null,authenticated:!1},ie=new Proxy(F,{set(e,s,t){return e[s]=t,!0},get(e,s){return e[s]}}),H=`
|
|
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 d=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(d||{});const W="US",n={defaultCountry:W,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:d.EXCLUDING_TAX}},re=async()=>await P({type:"query",query:H,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:Q,defaultValueOnFail:n});function B(e){switch(e){case 1:return d.EXCLUDING_TAX;case 2:return d.INCLUDING_TAX;case 3:return d.INCLUDING_EXCLUDING_TAX;default:return d.EXCLUDING_TAX}}function Q(e){if(!e)return n;const{default_country:s,countries_with_required_region:t,display_state_if_optional:a,optional_zip_countries:l,is_guest_checkout_enabled:c,is_one_page_checkout_enabled:T,shopping_cart_display_shipping:f}=e;return{defaultCountry:s||n.defaultCountry,countriesWithRequiredRegion:(t==null?void 0:t.split(","))||n.countriesWithRequiredRegion,displayStateIfOptional:a||n.displayStateIfOptional,countriesWithOptionalZipCode:(l==null?void 0:l.split(","))||n.countriesWithOptionalZipCode,isGuestCheckoutEnabled:c||n.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:T||n.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:B(f)}}}const{setEndpoint:oe,setFetchGraphQlHeader:ne,removeFetchGraphQlHeader:le,setFetchGraphQlHeaders:de,fetchGraphQl:m,getConfig:ce}=new M().getMethods();var i=(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))(i||{}),Z=(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))(Z||{});const ue=[{frontendInput:i.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:i.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:i.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:i.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:i.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:i.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:i.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:i.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:i.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:i.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:i.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}];export{i as A,W as D,G as F,p as I,J as M,n as S,d as T,$ as U,Z as V,K as a,V as b,ee as c,se as d,ne as e,de as f,m as g,ce as h,ue as i,re as j,ie as k,P as l,O as m,ae as n,R as o,h as p,_ as q,le as r,oe as s,b as t,S as u,te as v,X as w,q as x,U as y};
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import{
|
|
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 c=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(c||{});const oe="US",l={defaultCountry:oe,countriesWithRequiredRegion:[],displayStateIfOptional:!1,countriesWithOptionalZipCode:[],isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:c.EXCLUDING_TAX}},Ee=async()=>await W({type:"query",query:ae,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:le,defaultValueOnFail:l});function ne(e){switch(e){case 1:return c.EXCLUDING_TAX;case 2:return c.INCLUDING_TAX;case 3:return c.INCLUDING_EXCLUDING_TAX;default:return c.EXCLUDING_TAX}}function le(e){if(!e)return l;const{default_country:t,countries_with_required_region:s,display_state_if_optional:r,optional_zip_countries:n,is_guest_checkout_enabled:d,is_one_page_checkout_enabled:g,shopping_cart_display_shipping:_}=e;return{defaultCountry:t||l.defaultCountry,countriesWithRequiredRegion:(s==null?void 0:s.split(","))||l.countriesWithRequiredRegion,displayStateIfOptional:r||l.displayStateIfOptional,countriesWithOptionalZipCode:(n==null?void 0:n.split(","))||l.countriesWithOptionalZipCode,isGuestCheckoutEnabled:d||l.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:g||l.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:ne(_)}}}const{setEndpoint:Ie,setFetchGraphQlHeader:be,removeFetchGraphQlHeader:Se,setFetchGraphQlHeaders:xe,fetchGraphQl:I,getConfig:De}=new N().getMethods();var i=(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))(i||{}),ce=(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))(ce||{});const Ae=[{frontendInput:i.Text,code:"firstname",label:"First Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:10},{frontendInput:i.Text,code:"lastname",label:"Last Name",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:20},{frontendInput:i.Text,code:"company",label:"Company",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:30},{frontendInput:i.Multiline,code:"street",label:"Street Address",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:40},{frontendInput:i.Text,code:"city",label:"City",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:50},{frontendInput:i.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:i.Text,code:"region",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:70},{frontendInput:i.Hidden,code:"region_id",label:"State/Province",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:80},{frontendInput:i.Text,code:"postcode",label:"Zip/Postal Code",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:90},{frontendInput:i.Text,code:"telephone",label:"Phone Number",isRequired:!0,isDisabled:!1,options:[],validateRules:[],sortOrder:100},{frontendInput:i.Text,code:"vat_id",label:"VAT Number",isRequired:!1,isDisabled:!1,options:[],validateRules:[],sortOrder:110}],M=`
|
|
1
|
+
import{t as a,a as l}from"./transform-shipping-methods.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=`
|
|
16
2
|
fragment CheckoutData on Cart {
|
|
17
3
|
is_virtual
|
|
18
4
|
email
|
|
@@ -114,20 +100,20 @@ import{events as b}from"@dropins/tools/event-bus.js";import{signal as o,effect a
|
|
|
114
100
|
title
|
|
115
101
|
}
|
|
116
102
|
}
|
|
117
|
-
`,
|
|
103
|
+
`,b=`
|
|
118
104
|
query getCart($cartId: String!) {
|
|
119
105
|
cart(cart_id: $cartId) {
|
|
120
106
|
id
|
|
121
107
|
...CheckoutData
|
|
122
108
|
}
|
|
123
109
|
}
|
|
124
|
-
${
|
|
125
|
-
`,
|
|
110
|
+
${s}
|
|
111
|
+
`,C=`
|
|
126
112
|
query getCustomerCart {
|
|
127
113
|
cart: customerCart {
|
|
128
114
|
id
|
|
129
115
|
...CheckoutData
|
|
130
116
|
}
|
|
131
117
|
}
|
|
132
|
-
${
|
|
133
|
-
`;export{
|
|
118
|
+
${s}
|
|
119
|
+
`;export{s as C,C as a,b as g,f as t};
|
package/chunks/getCustomer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"@dropins/tools/event-bus.js";import{k as o,M as l,l as u
|
|
1
|
+
import"@dropins/tools/event-bus.js";import{k as o,M as l,l 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=`
|
|
2
2
|
query getCustomer {
|
|
3
3
|
customer {
|
|
4
4
|
firstname
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import{k as _,M as y,d as h,l as g,x as l}from"./fixtures.js";import{t as m}from"./transform-shipping-methods.js";import"@dropins/tools/event-bus.js";const I=`
|
|
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
|
+
`,M=t=>t?!!t.id&&!!t.code&&!!t.name:!1,S=t=>{if(t)return t.filter(M).map(e=>{const{id:a,code:n,name:i}=e;return{id:a,code:n,name:i}})};var f=(t=>(t.SHIPPING="shipping_addresses",t.BILLING="billing_address",t))(f||{}),v=(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))(v||{});const L=async t=>{const e=_.cartId,{criteria:a}=t||{},{country_code:n,region_id:i,region_name:s,zip:r}=a||{};if(!e)throw new y;if(!n)throw new h;const o=typeof i=="string"?parseInt(i,10):i,c=i||s?{...o&&{region_id:o},...s&&{region_code:s}}:void 0,u={country_code:n,...r&&{postcode:r},...c&&{region:c}};return await g({type:"mutation",query:I,options:{variables:{cartId:e,address:u}},path:"estimateShippingMethods",signalType:"estimateShippingMethods",transformer:m})},d=`
|
|
33
|
+
query getRegions($countryCode: String!) {
|
|
34
|
+
country(id: $countryCode) {
|
|
35
|
+
id
|
|
36
|
+
available_regions {
|
|
37
|
+
id
|
|
38
|
+
code
|
|
39
|
+
name
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}`,N=async(t,e)=>(l.value.addressType=e,g({type:"query",query:d,options:{variables:{countryCode:t}},path:"country.available_regions",signalType:"regions",transformer:S})),p="-",R=`
|
|
43
|
+
`,E=2e3,w=(t,e)=>Object.keys(e).filter(a=>a.startsWith(t)).sort((a,n)=>parseInt(a.replace(`${t}${p}`,""),10)-parseInt(n.replace(`${t}${p}`,""),10)).map(a=>e[a]);export{f as A,E as D,p as M,v as a,w as b,R as c,L as e,N as g};
|
package/chunks/placeOrder.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import{k as T,M as w,g as A,
|
|
1
|
+
import{k as T,M as w,g as A,u as k,F as D,U as L}from"./fixtures.js";import{events as f}from"@dropins/tools/event-bus.js";const R=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})))||[]}})}),V=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,Q=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:Q(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 S(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(S).map(a=>({code:a.code,value:a.value}))}:null,U=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)}},G=`
|
|
2
2
|
mutation placeOrder($cartId: String!) {
|
|
3
3
|
placeOrder(input: { cart_id: $cartId }) {
|
|
4
|
+
errors {
|
|
5
|
+
code
|
|
6
|
+
message
|
|
7
|
+
}
|
|
4
8
|
orderV2 {
|
|
5
9
|
number
|
|
6
10
|
status
|
|
@@ -124,4 +128,4 @@ 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.j
|
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
|
-
`,x={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},
|
|
131
|
+
`,x={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},F={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 X(n,a){E().push(i=>{const c=i.getState?i.getState():{};i.push({event:n,eventInfo:{...c,...a}})})}function $(n){const a=R(n),t=V(n);console.debug({shoppingCartContext:a,orderContext:t}),O(x.SHOPPING_CART_CONTEXT,{...a}),O(x.ORDER_CONTEXT,{...t}),X(F.PLACE_ORDER)}function H(n){throw n.every(t=>{var i;return(i=t.extensions)==null?void 0:i.category})?new D(n):new L(n[0].message)}const B=async()=>{const n=T.cartId;if(!n)throw new w;const{data:a,errors:t}=await A(G,{variables:{cartId:n}}).catch(k);t&&H(t);const i=U(a.placeOrder.orderV2);return $(i),f.emit("checkout/order",i),f.emit("cart/reset",void 0),i};export{B as p};
|
package/chunks/resetCustomer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{events as n}from"@dropins/tools/event-bus.js";import{l,k as a,j as d,
|
|
1
|
+
import{events as n}from"@dropins/tools/event-bus.js";import{l,k as a,j as d,q as c,p 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=`
|
|
2
2
|
query fetchAddressFormFields {
|
|
3
3
|
attributesForm(formCode: "customer_register_address") {
|
|
4
4
|
items {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{k as n,M as e,c as d,l}from"./fixtures.js";import{C as o,t as c}from"./getCart.graphql.js";const p=`
|
|
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{C as n,k as e,M as d,c as l,l as o,t as c}from"./getCart.graphql.js";cons
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
${
|
|
13
|
-
`,
|
|
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};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{a as r,g as s,u as e,k as l,M as n,l as o}from"./fixtures.js";import"@dropins/tools/event-bus.js";import{C as m,t as c}from"./getCart.graphql.js";const u=a=>!!(a!=null&&a.is_email_available),E=`
|
|
2
|
+
query isEmailAvailable($email: String!) {
|
|
3
|
+
isEmailAvailable(email: $email) {
|
|
4
|
+
is_email_available
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
`,h=a=>{if(!(!a||a.length===0))throw Error(a.map(t=>t.message).join(" "))},A=async a=>{if(!a)throw new r;const{data:t,errors:i}=await s(E,{method:"GET",cache:"no-cache",variables:{email:a}}).catch(e);return i&&h(i),u(t.isEmailAvailable)},p=`
|
|
8
|
+
mutation setGuestEmail($cartId: String!, $email: String!) {
|
|
9
|
+
setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {
|
|
10
|
+
cart {
|
|
11
|
+
id
|
|
12
|
+
...CheckoutData
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
${m}
|
|
17
|
+
`,C=async a=>{const t=l.cartId;if(!t)throw new n;return await o({type:"mutation",query:p,options:{variables:{cartId:t,email:a}},path:"setGuestEmailOnCart.cart",signalType:"cart",transformer:c})};export{A as i,C as s};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{k as e,M as r,b as n,l as s}from"./fixtures.js";import{C as o,t as i}from"./getCart.graphql.js";const m=`
|
|
2
|
+
mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) {
|
|
3
|
+
setPaymentMethodOnCart(
|
|
4
|
+
input: { cart_id: $cartId, payment_method: { code: $paymentMethod } }
|
|
5
|
+
) {
|
|
6
|
+
cart {
|
|
7
|
+
id
|
|
8
|
+
...CheckoutData
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
${o}
|
|
13
|
+
`,h=async t=>{const a=e.cartId;if(!a)throw new r;if(!t)throw new n;return await s({type:"mutation",query:m,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:i})};export{h as s};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{a as s,b as p,M as u,c as _}from"./getMultilineValues.js";import{k as g,M as I,l}from"./fixtures.js";import{C,t as h}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const A=/^\d+$/,T=t=>{if(A.test(t))return parseInt(t,10)},m=`
|
|
2
|
+
mutation setShippingAddress($cartId: String!, $address: CartAddressInput!, $pickup_location_code: String) {
|
|
3
|
+
setShippingAddressesOnCart(
|
|
4
|
+
input: {
|
|
5
|
+
cart_id: $cartId,
|
|
6
|
+
shipping_addresses: [{ address: $address, pickup_location_code: $pickup_location_code }]
|
|
7
|
+
}
|
|
8
|
+
) {
|
|
9
|
+
cart {
|
|
10
|
+
id
|
|
11
|
+
...CheckoutData
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
${C}
|
|
16
|
+
`,y=["city","company","country_code","firstname","lastname","postcode","region","region_id","save_in_address_book","street","telephone","vat_id"],$=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:p(s.Street,t),telephone:t[s.Telephone],vat_id:t[s.Vat]},r=t[s.Region],c=T(r);c?a.region_id=c:a.region=r;const d=Object.keys(t).filter(e=>!e.startsWith("street")).filter(e=>!y.includes(e)).filter(e=>e!=="country_id").map(e=>{const[n,i]=e.split(u);if(!i)return{attribute_code:n,value:t[e]};const o=p(n,t).join(_);return{attribute_code:n,value:o}}).filter((e,n,i)=>n===i.findIndex(o=>o.attribute_code===e.attribute_code));return d.length>0&&(a.custom_attributes=d),a},k=async({signal:t,...a})=>{const r=g.cartId;if(!r)throw new I;return await l({type:"mutation",query:m,options:{signal:t,variables:{cartId:r,...a}},path:"setShippingAddressesOnCart.cart",signalType:"cart",transformer:h})};export{y as S,$ as p,k as s};
|
|
@@ -1,86 +1,4 @@
|
|
|
1
|
-
import{k as
|
|
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=`
|
|
1
|
+
import{k as a,M as s,l as p}from"./fixtures.js";import{C as r,t as n}from"./getCart.graphql.js";import"@dropins/tools/event-bus.js";const o=`
|
|
84
2
|
mutation setShippingMethods(
|
|
85
3
|
$cartId: String!
|
|
86
4
|
$shippingMethods: [ShippingMethodInput]!
|
|
@@ -94,5 +12,5 @@ query getRegions($countryCode: String!) {
|
|
|
94
12
|
}
|
|
95
13
|
}
|
|
96
14
|
}
|
|
97
|
-
${
|
|
98
|
-
`,
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const u=e=>e==null,i=(e,r)=>e.amount.value-r.amount.value,c=e=>!(!e||!e.method_code||!e.method_title||u(e.amount.value)||!e.amount.currency),n=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}}}),t=e=>{if(c(e))return n(e)},l=e=>{if(e)return e.filter(c).map(r=>n(r)).sort(i)};export{t as a,l as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{q as c}from"./fixtures.js";import"@dropins/tools/event-bus.js";function d(t){return t.displayName||t.name||"Component"}const f=t=>{const a=d(t),n=({hideOnEmptyCart:s=!0,hideOnVirtualCart:r=!1,...e})=>{const i=c.value.data,l=i!==void 0&&(i===null||i.isEmpty),m=!!(i!=null&&i.isVirtual);return o("div",{children:!(s&&l||r&&m)&&o(t,{...e})})};return n.displayName=`Conditional(${a})`,n};export{f as w};
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
export declare const MULTILINE_SUFFIX = "-";
|
|
2
18
|
export declare const MULTILINE_CUSTOM_ATTR_SPLIT = "\n";
|
|
3
19
|
export declare const DEBOUNCE_TIME = 2000;
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
export * from './AddressForm';
|
|
2
18
|
export * from './constants';
|
|
3
19
|
export * from './useAddressForm';
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
export * from './BillToShippingAddress';
|
|
2
18
|
export * from './BillToShippingAddressSkeleton';
|
|
3
19
|
export { BillToShippingAddress as default } from './BillToShippingAddress';
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/********************************************************************
|
|
2
|
+
* ADOBE CONFIDENTIAL
|
|
3
|
+
* __________________
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2024 Adobe
|
|
6
|
+
* All Rights Reserved.
|
|
7
|
+
*
|
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
|
12
|
+
* property laws, including trade secret and copyright laws.
|
|
13
|
+
* Dissemination of this information or reproduction of this material
|
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
|
15
|
+
* from Adobe.
|
|
16
|
+
*******************************************************************/
|
|
1
17
|
export * from './EstimateShipping';
|
|
2
18
|
export { EstimateShipping as default } from './EstimateShipping';
|
|
3
19
|
export * from './EstimateShippingSkeleton';
|