@dropins/storefront-checkout 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/api.js +1 -0
  2. package/api.js.map +1 -0
  3. package/chunks/ConditionalWrapper.js +2 -1
  4. package/chunks/ConditionalWrapper.js.map +1 -0
  5. package/chunks/OrderError.js +1 -0
  6. package/chunks/OrderError.js.map +1 -0
  7. package/chunks/ServerErrorSignal.js +1 -0
  8. package/chunks/ServerErrorSignal.js.map +1 -0
  9. package/chunks/TermsAndConditions.js +3 -2
  10. package/chunks/TermsAndConditions.js.map +1 -0
  11. package/chunks/checkout.js +1 -0
  12. package/chunks/checkout.js.map +1 -0
  13. package/chunks/classes.js +1 -0
  14. package/chunks/classes.js.map +1 -0
  15. package/chunks/dom.js +1 -0
  16. package/chunks/dom.js.map +1 -0
  17. package/chunks/errors.js +1 -0
  18. package/chunks/errors.js.map +1 -0
  19. package/chunks/setBillingAddress.js +1 -0
  20. package/chunks/setBillingAddress.js.map +1 -0
  21. package/chunks/setGuestEmailOnCart.js +1 -0
  22. package/chunks/setGuestEmailOnCart.js.map +1 -0
  23. package/chunks/setPaymentMethod.js +1 -0
  24. package/chunks/setPaymentMethod.js.map +1 -0
  25. package/chunks/setShippingMethods.js +1 -0
  26. package/chunks/setShippingMethods.js.map +1 -0
  27. package/chunks/synchronizeCheckout.js +1 -0
  28. package/chunks/synchronizeCheckout.js.map +1 -0
  29. package/chunks/values.js +1 -0
  30. package/chunks/values.js.map +1 -0
  31. package/components/PaymentMethods/PaymentMethods.d.ts +2 -2
  32. package/components/ShippingMethods/ShippingMethods.d.ts +2 -2
  33. package/components/index.d.ts +0 -4
  34. package/containers/BillToShippingAddress.js +2 -1
  35. package/containers/BillToShippingAddress.js.map +1 -0
  36. package/containers/EstimateShipping.js +2 -1
  37. package/containers/EstimateShipping.js.map +1 -0
  38. package/containers/LoginForm.js +2 -1
  39. package/containers/LoginForm.js.map +1 -0
  40. package/containers/MergedCartBanner.js +2 -1
  41. package/containers/MergedCartBanner.js.map +1 -0
  42. package/containers/OutOfStock.js +1 -0
  43. package/containers/OutOfStock.js.map +1 -0
  44. package/containers/PaymentMethods.js +2 -1
  45. package/containers/PaymentMethods.js.map +1 -0
  46. package/containers/PlaceOrder.js +2 -1
  47. package/containers/PlaceOrder.js.map +1 -0
  48. package/containers/ServerError.js +1 -0
  49. package/containers/ServerError.js.map +1 -0
  50. package/containers/ShippingMethods.js +2 -1
  51. package/containers/ShippingMethods.js.map +1 -0
  52. package/containers/TermsAndConditions.js +2 -1
  53. package/containers/TermsAndConditions.js.map +1 -0
  54. package/containers/index.d.ts +0 -2
  55. package/fragments.js +1 -0
  56. package/fragments.js.map +1 -0
  57. package/package.json +1 -1
  58. package/render.js +4 -3
  59. package/render.js.map +1 -0
  60. package/chunks/Summary.js +0 -3
  61. package/chunks/events.js +0 -3
  62. package/components/LoginFormSummary/LoginFormSummary.d.ts +0 -10
  63. package/components/LoginFormSummary/index.d.ts +0 -18
  64. package/components/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +0 -11
  65. package/components/PaymentMethodsSummary/index.d.ts +0 -19
  66. package/components/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +0 -14
  67. package/components/ShippingMethodsSummary/index.d.ts +0 -19
  68. package/components/Summary/Summary.d.ts +0 -10
  69. package/components/Summary/index.d.ts +0 -19
  70. package/containers/LoginFormSummary/LoginFormSummary.d.ts +0 -14
  71. package/containers/LoginFormSummary/index.d.ts +0 -19
  72. package/containers/LoginFormSummary.d.ts +0 -3
  73. package/containers/LoginFormSummary.js +0 -3
  74. package/containers/PaymentMethodsSummary/PaymentMethodsSummary.d.ts +0 -18
  75. package/containers/PaymentMethodsSummary/index.d.ts +0 -19
  76. package/containers/PaymentMethodsSummary.d.ts +0 -3
  77. package/containers/PaymentMethodsSummary.js +0 -3
  78. package/containers/ShippingMethodsSummary/ShippingMethodsSummary.d.ts +0 -15
  79. package/containers/ShippingMethodsSummary/index.d.ts +0 -19
  80. package/containers/ShippingMethodsSummary.d.ts +0 -3
  81. package/containers/ShippingMethodsSummary.js +0 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sources":["/@dropins/storefront-checkout/src/lib/state.ts","/@dropins/storefront-checkout/src/data/models/store-config.ts","/@dropins/storefront-checkout/src/lib/enqueueRequest.ts","/@dropins/storefront-checkout/src/lib/filterControlledErrors.ts","/@dropins/storefront-checkout/src/lib/network-error.ts","/@dropins/storefront-checkout/src/lib/dispatchApiCall.ts","/@dropins/storefront-checkout/src/api/getStoreConfig/graphql/getStoreConfig.graphql.ts","/@dropins/storefront-checkout/src/api/getStoreConfig/getStoreConfig.ts","/@dropins/storefront-checkout/src/data/transforms/transform-store-config.ts","/@dropins/storefront-checkout/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-checkout/src/errors/errors.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfig } from '@/checkout/data/models';\n\ntype State = {\n authenticated: boolean;\n cartId: string | null;\n initialized: boolean;\n config: StoreConfig | null;\n};\n\nconst _state: State = (() => ({\n authenticated: false,\n cartId: null,\n initialized: false,\n config: null,\n}))();\n\n// Proxy state to allow reactivity\nexport const state = new Proxy(_state, {\n set(target, key, value) {\n // @ts-ignore\n target[key] = value;\n return true;\n },\n get(target, key) {\n return target[key as keyof State];\n },\n});\n\nexport const getStoreConfigCache = () => state.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport enum TaxDisplay {\n EXCLUDING_TAX = 'EXCLUDING_TAX',\n INCLUDING_EXCLUDING_TAX = 'INCLUDING_AND_EXCLUDING_TAX',\n INCLUDING_TAX = 'INCLUDING_TAX',\n}\n\nexport interface StoreConfig {\n defaultCountry: string;\n agreementsEnabled: boolean;\n shoppingCartDisplaySetting: {\n shipping: TaxDisplay;\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Cart } from '@/checkout/data/models';\nimport {\n computed,\n ReadonlySignal,\n signal,\n} from '@adobe-commerce/elsie/lib/signals';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport enum QueueName {\n CartUpdate = 'cartUpdate',\n Default = 'default',\n ShippingEstimate = 'shippingEstimate',\n}\n\ntype Request<T> = () => Promise<T>;\ntype QueueCompletedHandler<T> = (result: T) => void;\n\ninterface QueuedRequest<T> {\n requestFn: Request<T>;\n resolve: (value: T) => void;\n reject: (error: any) => void;\n}\n\nconst queues = new Map<QueueName, QueuedRequest<any>[]>();\nconst processing = new Map<QueueName, boolean>();\nconst pendingRequests = signal<Set<QueueName>>(new Set());\nconst onQueueCompleted = new Map<QueueName, QueueCompletedHandler<any>>();\n\nonQueueCompleted.set(QueueName.CartUpdate, (latestResult: Cart) => {\n events.emit('checkout/updated', latestResult);\n});\n\nasync function processQueue(type: QueueName): Promise<void> {\n processing.set(type, true);\n\n const queue = queues.get(type)!;\n let latestSuccessResult: any;\n\n while (queue.length > 0) {\n const request = queue.shift()!;\n\n try {\n const result = await request.requestFn();\n request.resolve(result);\n latestSuccessResult = result;\n } catch (error) {\n request.reject(error);\n }\n }\n\n processing.set(type, false);\n\n const pendingSet = new Set(pendingRequests.value);\n pendingSet.delete(type);\n pendingRequests.value = pendingSet;\n\n const handler = onQueueCompleted.get(type);\n\n if (handler && latestSuccessResult) {\n handler(latestSuccessResult);\n }\n}\n\nexport function enqueueRequest<T>(\n requestFn: Request<T>,\n name: QueueName = QueueName.Default\n): Promise<T> {\n if (!queues.has(name)) {\n queues.set(name, []);\n }\n\n const queue = queues.get(name)!;\n\n const promise = new Promise<T>((resolve, reject) => {\n queue.push({ requestFn, resolve, reject });\n });\n\n const pendingSet = new Set(pendingRequests.value);\n pendingSet.add(name);\n pendingRequests.value = pendingSet;\n\n if (!processing.get(name)) {\n processQueue(name);\n }\n\n return promise;\n}\n\nexport const hasPendingCartUpdates: ReadonlySignal<boolean> = computed(() => {\n return pendingRequests.value.has(QueueName.CartUpdate);\n});\n\nexport const hasPendingShippingEstimate: ReadonlySignal<boolean> = computed(\n () => {\n return pendingRequests.value.has(QueueName.ShippingEstimate);\n }\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchQueryError } from '@/checkout/api/fetch-graphql';\n\ntype ErrorPath = (string | number)[];\n\nexport type ErrorWithPath = FetchQueryError[number] & {\n path?: ErrorPath;\n};\n\nconst controlledErrorProps: string[] = ['sender_email', 'recipient_email'];\n\n/**\n * Filters out errors with known paths from a list of errors generated by a GraphQL query.\n *\n * Known issue: The query does not differentiate between physical and virtual gift cards, leading\n * to errors for physical ones as they don't have 'sender_email' and 'recipient_email' properties.\n *\n * @param {ErrorWithPath[]} errors - Array of errors to be filtered.\n * @return {ErrorWithPath[]} Uncontrolled (unexpected) errors not matching predefined paths.\n */\n\nexport function filterControlledErrors(errors: ErrorWithPath[]) {\n return errors.filter(\n (error) =>\n !error.path ||\n !controlledErrorProps.some((controlledErrorProp) => {\n return error.path?.at(-1) === controlledErrorProp;\n })\n );\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { events } from '@adobe-commerce/event-bus';\n\n/**\n * A function which can be attached to fetchGraphQL to handle thrown errors in\n * a generic way.\n */\nexport const handleNetworkError = (error: Error) => {\n const isAbortError =\n error instanceof DOMException && error.name === 'AbortError';\n\n if (!isAbortError) {\n events.emit('error', {\n source: 'checkout',\n type: 'network',\n error,\n });\n }\n\n throw error;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n FetchError,\n fetchGraphQl,\n FetchOptions,\n FetchQueryError,\n} from '@/checkout/api';\nimport { enqueueRequest, QueueName } from '@/checkout/lib/enqueueRequest';\nimport { filterControlledErrors } from '@/checkout/lib/filterControlledErrors';\nimport { handleNetworkError } from '@/checkout/lib/network-error';\n\ntype DispatchApiCallParams<T> = {\n defaultValueOnFail?: T;\n options?: FetchOptions;\n path: string;\n query: string;\n queueName?: QueueName;\n transformer?: (data: any) => T;\n type: 'query' | 'mutation';\n};\n\nexport function getValueAtPath(obj: any, path: string) {\n return path\n .split('.')\n .reduce(\n (acc, part) => (acc && acc[part] !== undefined ? acc[part] : undefined),\n obj\n );\n}\n\nasync function dispatchApiCall<T>(\n params: DispatchApiCallParams<T>\n): Promise<T> {\n const {\n defaultValueOnFail,\n options,\n path,\n query,\n queueName,\n transformer,\n type,\n } = params;\n\n try {\n const processApiCall = async () => {\n const { data, errors } = await fetchGraphQl<T>(query, {\n method: type === 'query' ? 'GET' : 'POST',\n cache: type === 'query' ? 'no-cache' : undefined,\n ...options,\n }).catch(handleNetworkError);\n\n if (errors) {\n const uncontrolledErrors = filterControlledErrors(errors);\n\n if (uncontrolledErrors.length > 0) {\n throw new FetchError(uncontrolledErrors as FetchQueryError);\n }\n }\n\n let result = getValueAtPath(data, path);\n\n if (result === undefined) {\n throw new Error(`No data found at path: ${path}`);\n }\n\n return transformer ? transformer(result) : result;\n };\n\n // Execute the API call, either directly or through the queue\n const result =\n type === 'mutation'\n ? await enqueueRequest<T>(processApiCall, queueName)\n : await processApiCall();\n\n return result;\n } catch (error: any) {\n if (defaultValueOnFail !== undefined) return defaultValueOnFail;\n throw error;\n }\n}\n\nexport { dispatchApiCall };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const getStoreConfigQuery = /* GraphQL */ `\n query getStoreConfig {\n storeConfig {\n default_country\n is_checkout_agreements_enabled\n is_guest_checkout_enabled\n is_one_page_checkout_enabled\n shopping_cart_display_shipping\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { StoreConfig, TaxDisplay } from '@/checkout/data/models';\nimport { transformStoreConfig } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib';\nimport { getStoreConfigQuery } from './graphql/getStoreConfig.graphql';\n\nexport const DEFAULT_COUNTRY = 'US';\n\nexport const STORE_CONFIG_DEFAULTS: StoreConfig = {\n defaultCountry: DEFAULT_COUNTRY,\n agreementsEnabled: true,\n shoppingCartDisplaySetting: {\n shipping: TaxDisplay.EXCLUDING_TAX,\n },\n};\n\nexport const getStoreConfig = async () => {\n return await dispatchApiCall({\n defaultValueOnFail: STORE_CONFIG_DEFAULTS,\n options: { method: 'GET', cache: 'no-cache' },\n path: 'storeConfig',\n query: getStoreConfigQuery,\n transformer: transformStoreConfig,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetStoreConfigQuery } from '@/checkout/__generated__/types';\nimport { STORE_CONFIG_DEFAULTS } from '@/checkout/api/getStoreConfig';\nimport { StoreConfig, TaxDisplay } from '@/checkout/data/models';\n\nexport function transformTaxDisplay(data: number | null | undefined) {\n switch (data) {\n case 1:\n return TaxDisplay.EXCLUDING_TAX;\n case 2:\n return TaxDisplay.INCLUDING_TAX;\n case 3:\n return TaxDisplay.INCLUDING_EXCLUDING_TAX;\n default:\n return TaxDisplay.EXCLUDING_TAX;\n }\n}\n\nexport function transformStoreConfig(\n data: GetStoreConfigQuery['storeConfig']\n): StoreConfig {\n if (!data) return STORE_CONFIG_DEFAULTS;\n\n const {\n default_country,\n is_checkout_agreements_enabled,\n shopping_cart_display_shipping,\n } = data;\n\n return {\n defaultCountry: default_country || STORE_CONFIG_DEFAULTS.defaultCountry,\n agreementsEnabled: is_checkout_agreements_enabled,\n shoppingCartDisplaySetting: {\n shipping: transformTaxDisplay(shopping_cart_display_shipping),\n },\n };\n}\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n\nexport type {\n FetchOptions,\n FetchQueryError,\n} from '@adobe-commerce/fetch-graphql';\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { FetchQueryError } from '@/checkout/api/fetch-graphql';\n\nexport class FetchError extends Error {\n constructor(reasons: FetchQueryError) {\n super(reasons.map((e: any) => e.message).join(' '));\n this.name = 'FetchError';\n }\n}\n\nexport class InvalidArgument extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidArgument';\n }\n}\n\nexport class UnexpectedError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'UnexpectedError';\n }\n}\n\nexport class MissingCart extends InvalidArgument {\n constructor() {\n super('Cart ID is required');\n }\n}\nexport class MissingEmail extends InvalidArgument {\n constructor() {\n super('Email is required');\n }\n}\n\nexport class MissingPaymentMethod extends InvalidArgument {\n constructor() {\n super('Payment method code is required');\n }\n}\n\nexport class MissingShippinghAddress extends InvalidArgument {\n constructor() {\n super('Shipping address is required');\n }\n}\n\nexport class MissingBillingAddress extends InvalidArgument {\n constructor() {\n super('Billing address is required');\n }\n}\n\nexport class MissingCountry extends InvalidArgument {\n constructor() {\n super('Country Code is required');\n }\n}\n"],"names":["_state","state","target","key","value","getStoreConfigCache","TaxDisplay","QueueName","queues","processing","pendingRequests","signal","onQueueCompleted","latestResult","events","processQueue","type","queue","latestSuccessResult","request","result","error","pendingSet","handler","enqueueRequest","requestFn","name","promise","resolve","reject","hasPendingCartUpdates","computed","hasPendingShippingEstimate","controlledErrorProps","filterControlledErrors","errors","controlledErrorProp","_a","handleNetworkError","getValueAtPath","obj","path","acc","part","dispatchApiCall","params","defaultValueOnFail","options","query","queueName","transformer","processApiCall","data","fetchGraphQl","uncontrolledErrors","FetchError","getStoreConfigQuery","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","transformStoreConfig","transformTaxDisplay","default_country","is_checkout_agreements_enabled","shopping_cart_display_shipping","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL","reasons","e","InvalidArgument","message","UnexpectedError","MissingCart","MissingEmail","MissingPaymentMethod","MissingShippinghAddress","MissingBillingAddress","MissingCountry"],"mappings":"mNA0BA,MAAMA,EAAwB,CAC5B,cAAe,GACf,OAAQ,KACR,YAAa,GACb,OAAQ,IACV,EAGaC,EAAQ,IAAI,MAAMD,EAAQ,CACrC,IAAIE,EAAQC,EAAKC,EAAO,CAEtB,OAAAF,EAAOC,CAAG,EAAIC,EACP,EACT,EACA,IAAIF,EAAQC,EAAK,CACf,OAAOD,EAAOC,CAAkB,CAAA,CAEpC,CAAC,EAEYE,EAAsB,IAAMJ,EAAM,OC5BnC,IAAAK,GAAAA,IACVA,EAAA,cAAgB,gBAChBA,EAAA,wBAA0B,8BAC1BA,EAAA,cAAgB,gBAHNA,IAAAA,GAAA,CAAA,CAAA,ECQAC,GAAAA,IACVA,EAAA,WAAa,aACbA,EAAA,QAAU,UACVA,EAAA,iBAAmB,mBAHTA,IAAAA,GAAA,CAAA,CAAA,EAeZ,MAAMC,MAAa,IACbC,MAAiB,IACjBC,EAAkBC,EAA2B,IAAA,GAAK,EAClDC,MAAuB,IAE7BA,EAAiB,IAAI,aAAuBC,GAAuB,CAC1DC,EAAA,KAAK,mBAAoBD,CAAY,CAC9C,CAAC,EAED,eAAeE,EAAaC,EAAgC,CAC/CP,EAAA,IAAIO,EAAM,EAAI,EAEnB,MAAAC,EAAQT,EAAO,IAAIQ,CAAI,EACzB,IAAAE,EAEG,KAAAD,EAAM,OAAS,GAAG,CACjB,MAAAE,EAAUF,EAAM,MAAM,EAExB,GAAA,CACI,MAAAG,EAAS,MAAMD,EAAQ,UAAU,EACvCA,EAAQ,QAAQC,CAAM,EACAF,EAAAE,QACfC,EAAO,CACdF,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AExC,CAEO,MAAMO,WAA8BP,CAAgB,CACzD,aAAc,CACZ,MAAM,6BAA6B,CAAA,CAEvC,CAEO,MAAMQ,WAAuBR,CAAgB,CAClD,aAAc,CACZ,MAAM,0BAA0B,CAAA,CAEpC"}
@@ -11,3 +11,4 @@ import{CHECKOUT_DATA_FRAGMENT as e}from"../fragments.js";import{a as d,b as l}fr
11
11
 
12
12
  ${e}
13
13
  `,M=async({address:a,customerAddressId:s,sameAsShipping:t=!1,useForShipping:n=!1})=>{const r=o.cartId;if(!r)throw new p;const i={cart_id:r,billing_address:{same_as_shipping:t,use_for_shipping:n}};if(!t&&s&&(i.billing_address.customer_address_id=s),!t&&!s){if(!a)throw new u;i.billing_address.address=d(a)}return await _({options:{variables:{input:i}},path:"setBillingAddressOnCart.cart",query:m,queueName:f.CartUpdate,transformer:l,type:"mutation"})};export{M as s};
14
+ //# sourceMappingURL=setBillingAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setBillingAddress.js","sources":["/@dropins/storefront-checkout/src/api/setBillingAddress/graphql/setBillingAddress.graphql.ts","/@dropins/storefront-checkout/src/api/setBillingAddress/setBillingAddress.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setBillingAddressMutation = /* GraphQL */ `\n mutation setBillingAddress($input: SetBillingAddressOnCartInput!) {\n setBillingAddressOnCart(input: $input) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setBillingAddressMutation } from '@/checkout/api/setBillingAddress/graphql/setBillingAddress.graphql';\nimport { BillingAddressInput } from '@/checkout/data/models';\nimport {\n transformCart,\n transformCartAddressModelToInput,\n} from '@/checkout/data/transforms';\nimport { MissingBillingAddress, MissingCart } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { state } from '@/checkout/lib/state';\nimport { SetBillingAddressOnCartInput } from '@/checkout/__generated__/types';\n\nexport const setBillingAddress = async ({\n address,\n customerAddressId,\n sameAsShipping = false,\n useForShipping = false,\n}: BillingAddressInput) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n const input: SetBillingAddressOnCartInput = {\n cart_id: cartId,\n billing_address: {\n same_as_shipping: sameAsShipping,\n use_for_shipping: useForShipping,\n },\n };\n\n if (!sameAsShipping && customerAddressId) {\n input.billing_address.customer_address_id = customerAddressId;\n }\n\n if (!sameAsShipping && !customerAddressId) {\n if (!address) throw new MissingBillingAddress();\n input.billing_address.address = transformCartAddressModelToInput(address);\n }\n\n return await dispatchApiCall({\n options: { variables: { input } },\n path: 'setBillingAddressOnCart.cart',\n query: setBillingAddressMutation,\n queueName: QueueName.CartUpdate,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["setBillingAddressMutation","CHECKOUT_DATA_FRAGMENT","setBillingAddress","address","customerAddressId","sameAsShipping","useForShipping","cartId","state","MissingCart","input","MissingBillingAddress","transformCartAddressModelToInput","dispatchApiCall","QueueName","transformCart"],"mappings":"2OAmBa,MAAAA,EAA0C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASnDC,CAAsB;AAAA,ECCbC,EAAoB,MAAO,CACtC,QAAAC,EACA,kBAAAC,EACA,eAAAC,EAAiB,GACjB,eAAAC,EAAiB,EACnB,IAA2B,CACzB,MAAMC,EAASC,EAAM,OAErB,GAAI,CAACD,EAAc,MAAA,IAAIE,EAEvB,MAAMC,EAAsC,CAC1C,QAASH,EACT,gBAAiB,CACf,iBAAkBF,EAClB,iBAAkBC,CAAA,CAEtB,EAMI,GAJA,CAACD,GAAkBD,IACrBM,EAAM,gBAAgB,oBAAsBN,GAG1C,CAACC,GAAkB,CAACD,EAAmB,CACzC,GAAI,CAACD,EAAe,MAAA,IAAIQ,EAClBD,EAAA,gBAAgB,QAAUE,EAAiCT,CAAO,CAAA,CAG1E,OAAO,MAAMU,EAAgB,CAC3B,QAAS,CAAE,UAAW,CAAE,MAAAH,EAAQ,EAChC,KAAM,+BACN,MAAOV,EACP,UAAWc,EAAU,WACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
@@ -25,3 +25,4 @@ import{CUSTOMER_FRAGMENT as o,CHECKOUT_DATA_FRAGMENT as n}from"../fragments.js";
25
25
 
26
26
  ${n}
27
27
  `,N=async t=>{const a=m.cartId;if(!a)throw new u;return await r({options:{variables:{cartId:a,email:t}},path:"setGuestEmailOnCart.cart",query:h,queueName:c.CartUpdate,transformer:p,type:"mutation"})};export{v as g,q as i,N as s};
28
+ //# sourceMappingURL=setGuestEmailOnCart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setGuestEmailOnCart.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-customer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-email-availability.ts","/@dropins/storefront-checkout/src/api/getCustomer/graphql/getCustomer.graphql.ts","/@dropins/storefront-checkout/src/api/getCustomer/getCustomer.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/graphql/isEmailAvailable.graphql.ts","/@dropins/storefront-checkout/src/api/isEmailAvailable/isEmailAvailable.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setGuestEmailOnCart/setGuestEmailOnCart.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { config } from '@/checkout/api';\nimport { Customer as CustomerModel } from '@/checkout/data/models';\nimport { GetCustomerQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\ntype Customer = GetCustomerQuery['customer'];\n\nconst transformCustomer = (data: Customer): CustomerModel | null => {\n if (!data) return null;\n\n const model = {\n firstName: data.firstname || '',\n lastName: data.lastname || '',\n email: data.email || '',\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CustomerModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Customer, transformCustomer };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { IsEmailAvailableQuery } from '@/checkout/__generated__/types';\nimport { EmailAvailability } from '@/checkout/data/models';\n\nconst transformEmailAvailability = (\n data: IsEmailAvailableQuery['isEmailAvailable']\n): EmailAvailability => {\n return Boolean(data?.is_email_available);\n};\n\nexport { transformEmailAvailability };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CUSTOMER_FRAGMENT } from '@/checkout/api/graphql/CustomerFragment.graphql';\n\nexport const getCustomerQuery = /* GraphQL */ `\n query getCustomer {\n customer {\n ...CUSTOMER_FRAGMENT\n }\n }\n\n ${CUSTOMER_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCustomerQuery } from '@/checkout/api/getCustomer/graphql/getCustomer.graphql';\nimport { Customer } from '@/checkout/data/models';\nimport { transformCustomer } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCustomer = async (): Promise<Customer | null> => {\n if (!state.authenticated) return null;\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache' },\n path: 'customer',\n query: getCustomerQuery,\n transformer: transformCustomer,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nexport const isEmailAvailableQuery = /* GraphQL */ `\n query isEmailAvailable($email: String!) {\n isEmailAvailable(email: $email) {\n is_email_available\n }\n }\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { isEmailAvailableQuery } from '@/checkout/api/isEmailAvailable/graphql/isEmailAvailable.graphql';\nimport { EmailAvailability } from '@/checkout/data/models/email-availability';\nimport { transformEmailAvailability } from '@/checkout/data/transforms';\nimport { MissingEmail } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\n\nexport const isEmailAvailable = async (\n email: string\n): Promise<EmailAvailability> => {\n if (!email) throw new MissingEmail();\n\n return await dispatchApiCall({\n options: { method: 'GET', cache: 'no-cache', variables: { email } },\n path: 'isEmailAvailable',\n query: isEmailAvailableQuery,\n transformer: transformEmailAvailability,\n type: 'query',\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setGuestEmailMutation = /* GraphQL */ `\n mutation setGuestEmail($cartId: String!, $email: String!) {\n setGuestEmailOnCart(input: { cart_id: $cartId, email: $email }) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setGuestEmailMutation } from '@/checkout/api/setGuestEmailOnCart/graphql/setGuestEmailOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { MissingCart } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { state } from '@/checkout/lib/state';\n\nexport const setGuestEmailOnCart = async (email: string) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n options: { variables: { cartId, email } },\n path: 'setGuestEmailOnCart.cart',\n query: setGuestEmailMutation,\n queueName: QueueName.CartUpdate,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["transformCustomer","data","model","merge","_c","_b","_a","config","transformEmailAvailability","getCustomerQuery","CUSTOMER_FRAGMENT","getCustomer","state","dispatchApiCall","isEmailAvailableQuery","isEmailAvailable","email","MissingEmail","setGuestEmailMutation","CHECKOUT_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ACxC,KAAM,2BACN,MAAOE,EACP,UAAWK,EAAU,WACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
@@ -16,3 +16,4 @@ import{CHECKOUT_DATA_FRAGMENT as e}from"../fragments.js";import{b as r}from"./sy
16
16
 
17
17
  ${e}
18
18
  `,u=async t=>{const a=n.cartId;if(!a)throw new o;if(!t)throw new s;return await m({options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",query:d,queueName:i.CartUpdate,transformer:r,type:"mutation"})};export{u as s};
19
+ //# sourceMappingURL=setPaymentMethod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setPaymentMethod.js","sources":["/@dropins/storefront-checkout/src/api/setPaymentMethod/graphql/setPaymentMethod.graphql.ts","/@dropins/storefront-checkout/src/api/setPaymentMethod/setPaymentMethod.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setPaymentMethodMutation = /* GraphQL */ `\n mutation setPaymentMethod(\n $cartId: String!\n $paymentMethod: PaymentMethodInput!\n ) {\n setPaymentMethodOnCart(\n input: { cart_id: $cartId, payment_method: $paymentMethod }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setPaymentMethodMutation } from '@/checkout/api/setPaymentMethod/graphql/setPaymentMethod.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { MissingCart, MissingPaymentMethod } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { state } from '@/checkout/lib/state';\nimport { SetPaymentMethodOnCartInput } from '@/checkout/__generated__/types';\n\nexport const setPaymentMethod = async (\n paymentMethod: SetPaymentMethodOnCartInput['payment_method']\n) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n if (!paymentMethod) throw new MissingPaymentMethod();\n\n return await dispatchApiCall({\n options: { variables: { cartId, paymentMethod } },\n path: 'setPaymentMethodOnCart.cart',\n query: setPaymentMethodMutation,\n queueName: QueueName.CartUpdate,\n transformer: transformCart,\n type: 'mutation',\n });\n};\n"],"names":["setPaymentMethodMutation","CHECKOUT_DATA_FRAGMENT","setPaymentMethod","paymentMethod","cartId","state","MissingCart","MissingPaymentMethod","dispatchApiCall","QueueName","transformCart"],"mappings":"oOAmBa,MAAAA,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAclDC,CAAsB;AAAA,ECRbC,EAAmB,MAC9BC,GACG,CACH,MAAMC,EAASC,EAAM,OAErB,GAAI,CAACD,EAAc,MAAA,IAAIE,EACvB,GAAI,CAACH,EAAqB,MAAA,IAAII,EAE9B,OAAO,MAAMC,EAAgB,CAC3B,QAAS,CAAE,UAAW,CAAE,OAAAJ,EAAQ,cAAAD,EAAgB,EAChD,KAAM,8BACN,MAAOH,EACP,UAAWS,EAAU,WACrB,YAAaC,EACb,KAAM,UAAA,CACP,CACH"}
@@ -16,3 +16,4 @@ import{s as r,M as i,d as n,Q as e}from"./errors.js";import{b as s}from"./synchr
16
16
 
17
17
  ${p}
18
18
  `,M=async t=>{const o=r.cartId;if(!o)throw new i;return await n({type:"mutation",query:a,queueName:e.CartUpdate,options:{variables:{cartId:o,shippingMethods:t}},path:"setShippingMethodsOnCart.cart",transformer:s})};export{g as a,M as s,C as t};
19
+ //# sourceMappingURL=setShippingMethods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setShippingMethods.js","sources":["/@dropins/storefront-checkout/src/data/transforms/transform-shipping-estimate.ts","/@dropins/storefront-checkout/src/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingMethods/setShippingMethods.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n PartialShippingAddress,\n ShippingEstimateShippingMethod,\n ShippingMethod,\n} from '@/checkout/data/models';\n\ntype TransformShippingEstimatePartialAddressInput = {\n country_id: string;\n postcode?: string;\n region_id?: number;\n region?: string;\n};\n\nexport const transformShippingEstimatePartialAddress = (\n data: TransformShippingEstimatePartialAddressInput\n): PartialShippingAddress => {\n return {\n countryCode: data.country_id,\n postCode: data.postcode || '',\n ...(data.region_id\n ? { regionId: Number(data.region_id) }\n : { ...(data.region ? { region: data.region } : {}) }),\n };\n};\n\nexport const transformShippingEstimateShippingMethod = (\n data: ShippingMethod\n): ShippingEstimateShippingMethod => {\n return {\n carrierCode: data.carrier.code || '',\n methodCode: data.code || '',\n amount: data.amount,\n amountExclTax: data.amountExclTax,\n amountInclTax: data.amountInclTax,\n };\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingMethodsMutation = /* GraphQL */ `\n mutation setShippingMethods(\n $cartId: String!\n $shippingMethods: [ShippingMethodInput]!\n ) {\n setShippingMethodsOnCart(\n input: { cart_id: $cartId, shipping_methods: $shippingMethods }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { MissingCart } from '@/checkout/api';\nimport { setShippingMethodsMutation } from '@/checkout/api/setShippingMethods/graphql/setShippingMethodsOnCart.graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { QueueName } from '@/checkout/lib/enqueueRequest';\nimport { state } from '@/checkout/lib/state';\nimport { SetShippingMethodsOnCartInput } from '@/checkout/__generated__/types';\n\ntype ShippingMethodsOnCart = SetShippingMethodsOnCartInput['shipping_methods'];\n\nexport const setShippingMethodsOnCart = async (\n shippingMethods: ShippingMethodsOnCart\n) => {\n const cartId = state.cartId;\n\n if (!cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'mutation',\n query: setShippingMethodsMutation,\n queueName: QueueName.CartUpdate,\n options: { variables: { cartId, shippingMethods } },\n path: 'setShippingMethodsOnCart.cart',\n transformer: transformCart,\n });\n};\n"],"names":["transformShippingEstimatePartialAddress","data","transformShippingEstimateShippingMethod","setShippingMethodsMutation","CHECKOUT_DATA_FRAGMENT","setShippingMethodsOnCart","shippingMethods","cartId","state","MissingCart","dispatchApiCall","QueueName","transformCart"],"mappings":"6NA8Ba,MAAAA,EACXC,IAEO,CACL,YAAaA,EAAK,WAClB,SAAUA,EAAK,UAAY,GAC3B,GAAIA,EAAK,UACL,CAAE,SAAU,OAAOA,EAAK,SAAS,CAAE,EACnC,CAAE,GAAIA,EAAK,OAAS,CAAE,OAAQA,EAAK,MAAO,EAAI,CAAI,CAAA,CACxD,GAGWC,EACXD,IAEO,CACL,YAAaA,EAAK,QAAQ,MAAQ,GAClC,WAAYA,EAAK,MAAQ,GACzB,OAAQA,EAAK,OACb,cAAeA,EAAK,cACpB,cAAeA,EAAK,aACtB,GChCWE,EAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcpDC,CAAsB;AAAA,ECNbC,EAA2B,MACtCC,GACG,CACH,MAAMC,EAASC,EAAM,OAErB,GAAI,CAACD,EAAc,MAAA,IAAIE,EAEvB,OAAO,MAAMC,EAAgB,CAC3B,KAAM,WACN,MAAOP,EACP,UAAWQ,EAAU,WACrB,QAAS,CAAE,UAAW,CAAE,OAAAJ,EAAQ,gBAAAD,EAAkB,EAClD,KAAM,gCACN,YAAaM,CAAA,CACd,CACH"}
@@ -17,3 +17,4 @@ import{s as r,M as h,d as g,l as y}from"./errors.js";import{merge as v,Initializ
17
17
 
18
18
  ${c}
19
19
  `,m=async()=>{const e=r.cartId,t=r.authenticated===!1,i=t?B:D,n=t?{cartId:e}:{};if(t&&!e)throw new h;return await g({type:"query",query:i,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",transformer:q})},G=()=>[o.on("authenticated",A,{eager:!0}),o.on("cart/initialized",p,{eager:!0}),o.on("cart/reset",O),o.on("cart/updated",d)],f=new C({init:async e=>{const t={...e};f.config.setConfig(t)},listeners:G}),R=f.config,p=async e=>{if(r.initialized)return d(e);r.config||(r.config=await y());const t=e?e.id:null;r.cartId=t;const i=t?await m():null;r.initialized=!0,o.emit("checkout/initialized",i||null)},O=()=>{r.cartId=null,o.emit("checkout/updated",null)},d=async e=>{if(!r.initialized)return p(e);const t=e?e.id:null;r.cartId=t;const i=t?await m():null;o.emit("checkout/updated",i||null)};export{U as a,q as b,R as c,A as d,p as e,m as g,f as i,O as r,d as s,M as t};
20
+ //# sourceMappingURL=synchronizeCheckout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-shipping-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/api/initializeCheckout/initializeCheckout.ts","/@dropins/storefront-checkout/src/api/resetCheckout/resetCheckout.ts","/@dropins/storefront-checkout/src/api/synchronizeCheckout/synchronizeCheckout.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\n\nexport const authenticateCustomer = async (authenticated = false) => {\n state.authenticated = authenticated;\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ShippingMethod } from '@/checkout/data/models/shipping-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\n\ntype Cart = NonNullable<GetCartQuery['cart']>;\ntype ShippingAddresses = Cart['shipping_addresses'];\ntype ShippingAddress = NonNullable<NonNullable<ShippingAddresses>[number]>;\ntype AvailableShippingMethods = ShippingAddress['available_shipping_methods'];\ntype AvailableShippingMethod = NonNullable<AvailableShippingMethods>[number];\ntype SelectedShippingMethod = ShippingAddress['selected_shipping_method'];\n\ntype FilteredShippingMethod = Omit<\n NonNullable<AvailableShippingMethod>,\n | 'method_code'\n | 'method_title'\n | 'amount'\n | 'price_excl_tax'\n | 'price_incl_tax'\n> & {\n method_code: string;\n method_title: string;\n amount: {\n value: number;\n currency: string;\n };\n price_excl_tax: {\n value: number;\n currency: string;\n };\n price_incl_tax: {\n value: number;\n currency: string;\n };\n};\n\nconst byPrice = (a: ShippingMethod, b: ShippingMethod) =>\n a.amount.value - b.amount.value;\n\nexport const isNullish = (value: any): boolean =>\n value === null || value === undefined;\n\nconst isValid = (method: AvailableShippingMethod | SelectedShippingMethod) => {\n if (!method) return false;\n if (!method.method_code || !method.method_title) return false;\n if (isNullish(method.amount.value) || !method.amount.currency) return false;\n return true;\n};\n\nconst buildShippingMethod = (data: FilteredShippingMethod): ShippingMethod => {\n return {\n amount: {\n value: data.amount.value,\n currency: data.amount.currency,\n },\n title: data.method_title,\n code: data.method_code,\n carrier: {\n code: data.carrier_code,\n title: data.carrier_title,\n },\n value: `${data.carrier_code} - ${data.method_code}`,\n ...(data.price_excl_tax && {\n amountExclTax: {\n value: data.price_excl_tax.value,\n currency: data.price_excl_tax.currency,\n },\n }),\n ...(data.price_incl_tax && {\n amountInclTax: {\n value: data.price_incl_tax.value,\n currency: data.price_incl_tax.currency,\n },\n }),\n };\n};\n\nexport const transformSelectedShippingMethod = (\n data: SelectedShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformAvailableShippingMethod = (\n data: AvailableShippingMethod\n): ShippingMethod | undefined => {\n if (!isValid(data)) return;\n return buildShippingMethod(data as FilteredShippingMethod);\n};\n\nexport const transformShippingMethods = (\n data: AvailableShippingMethods\n): ShippingMethod[] => {\n if (!data) return [];\n\n return data\n .filter(isValid)\n .map((method) => buildShippingMethod(method as FilteredShippingMethod))\n .sort(byPrice);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CartAddressInput, GetCartQuery } from '@/checkout/__generated__/types';\nimport {\n Address as AddressModel,\n Country as CountryModel,\n CustomAttribute as CustomAttributeModel,\n Region as RegionModel,\n ShippingAddress as ShippingAddressModel,\n CartAddress as CartAddressModel,\n} from '@/checkout/data/models';\nimport {\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms/transform-shipping-methods';\n\ntype ShippingAddresses = NonNullable<\n GetCartQuery['cart']\n>['shipping_addresses'];\ntype ShippingAddress = ShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<ShippingAddress>;\n\ntype AddressRegion = NonNullableShippingAddress['region'];\ntype NonNullableAddressRegion = NonNullable<AddressRegion>;\ntype ValidatedAddressRegion = {\n code: NonNullable<NonNullableAddressRegion['code']>;\n label: NonNullable<NonNullableAddressRegion['label']>;\n region_id: NonNullableAddressRegion['region_id'];\n};\n\ntype AddressCountry = NonNullableShippingAddress['country'];\ntype NonNullableAddressCountry = NonNullable<AddressCountry>;\ntype ValidatedAddressCountry = {\n code: NonNullable<NonNullableAddressCountry['code']>;\n label: NonNullable<NonNullableAddressCountry['label']>;\n};\n\ntype BillingAddress = NonNullable<GetCartQuery['cart']>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<BillingAddress>;\n\ntype CustomAttributes =\n | NonNullableShippingAddress['custom_attributes']\n | NonNullableBillingAddress['custom_attributes'];\n\nconst isValidAddressRegion = (region: AddressRegion): boolean => {\n if (!region) return false;\n return !!region.code && !!region.label;\n};\n\nconst transformAddressRegion = (\n data: AddressRegion\n): RegionModel | undefined => {\n if (!isValidAddressRegion(data)) return;\n const { code, label, region_id } = data as ValidatedAddressRegion;\n if (!region_id) return { code, name: label };\n return { code, name: label, id: region_id };\n};\n\nconst transformAddressCountry = (data: AddressCountry): CountryModel => {\n const { code, label } = data as ValidatedAddressCountry;\n return { value: code, label };\n};\n\nconst isValidCustomAttribute = (attribute: any): boolean => {\n if (!attribute) return false;\n return 'code' in attribute && 'value' in attribute;\n};\n\nexport const transformCustomAttributes = (\n data: CustomAttributes\n): CustomAttributeModel[] => {\n return data.filter(isValidCustomAttribute).map((attribute) => {\n const { code, value } = attribute as { code: string; value: string };\n return { code, value };\n });\n};\n\nconst buildBaseAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n id: data?.id || undefined,\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n firstName: data.firstname,\n lastName: data.lastname,\n postCode: data.postcode || undefined,\n region: transformAddressRegion(data.region),\n street,\n telephone: data.telephone || undefined,\n vatId: data.vat_id || undefined,\n prefix: data.prefix || undefined,\n suffix: data.suffix || undefined,\n middleName: data.middlename || undefined,\n fax: data.fax || undefined,\n };\n};\n\nconst transformBillingAddress = (\n data: BillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return buildBaseAddress(data);\n};\n\nconst transformShippingAddresses = (\n data: ShippingAddresses\n): ShippingAddressModel[] | undefined => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n same_as_billing,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...buildBaseAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n sameAsBilling: same_as_billing,\n };\n });\n};\n\nconst transformCartAddressModelToInput = (\n address: CartAddressModel\n): CartAddressInput => {\n return {\n city: address.city,\n company: address.company,\n country_code: address.countryCode,\n custom_attributes: address.customAttributes.map((attribute) => ({\n attribute_code: attribute.code,\n value: attribute.value,\n })),\n firstname: address.firstName,\n lastname: address.lastName,\n postcode: address.postcode,\n region: address.region,\n region_id: address.regionId,\n save_in_address_book: address.saveInAddressBook ?? true,\n street: address.street,\n telephone: address.telephone,\n vat_id: address.vatId,\n prefix: address.prefix,\n suffix: address.suffix,\n middlename: address.middleName,\n fax: address.fax,\n };\n};\n\nexport {\n BillingAddress,\n ShippingAddress,\n transformCartAddressModelToInput,\n transformBillingAddress,\n transformShippingAddresses,\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetCartQuery } from '@/checkout/__generated__/types';\nimport { PaymentMethod } from '@/checkout/data/models/payment-method';\n\ntype SelectedPaymentMethod = NonNullable<\n GetCartQuery['cart']\n>['selected_payment_method'];\n\ntype AvailablePaymentMethods = NonNullable<\n GetCartQuery['cart']\n>['available_payment_methods'];\n\ntype AvailablePaymentMethod = NonNullable<AvailablePaymentMethods>[number];\n\ntype NonNullabePaymentMethod = NonNullable<AvailablePaymentMethod>;\n\nconst transformSelectedPaymentMethod = (\n data: SelectedPaymentMethod\n): PaymentMethod | undefined => {\n if (!data) return;\n return { code: data.code, title: data.title };\n};\n\nconst transformAvailablePaymentMethods = (\n data: AvailablePaymentMethods\n): PaymentMethod[] | undefined => {\n if (!data) return;\n\n return data\n .filter((method) => !!method)\n .map((method) => {\n const { code, title } = method as NonNullabePaymentMethod;\n return { code, title };\n });\n};\n\nexport { transformAvailablePaymentMethods, transformSelectedPaymentMethod };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { GetCartQuery } from '@/checkout/__generated__/types';\nimport { config } from '@/checkout/api';\nimport { Cart as CartModel } from '@/checkout/data/models';\nimport {\n transformAvailablePaymentMethods,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms/transform-payment-methods';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformBillingAddress,\n transformShippingAddresses,\n} from '@/checkout/data/transforms/transform-address';\nimport { state } from '@/checkout/lib/state';\n\ntype Cart = GetCartQuery['cart'];\n\nconst transformCart = (data: Cart): CartModel | undefined => {\n if (!data) return;\n\n const model = {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformBillingAddress(data.billing_address),\n email: data.email ?? undefined,\n id: data.id,\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformShippingAddresses(data.shipping_addresses),\n isGuest: !state.authenticated,\n };\n\n // Extend the model merging custom transformer, if provided\n return merge(\n model, // default transformer\n config.getConfig().models?.CartModel?.transformer?.(data) // custom transformer\n );\n};\n\nexport { Cart, transformCart };\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const getCartQuery = /* GraphQL */ `\n query getCart($cartId: String!) {\n cart(cart_id: $cartId) {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n\nexport const getCustomerCartQuery = /* GraphQL */ `\n query getCustomerCart {\n cart: customerCart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCartQuery,\n getCustomerCartQuery,\n} from '@/checkout/api/getCart/graphql';\nimport { transformCart } from '@/checkout/data/transforms';\nimport { MissingCart } from '@/checkout/errors';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib/state';\n\nexport const getCart = async () => {\n const cartId = state.cartId;\n const isGuest = state.authenticated === false;\n const query = isGuest ? getCartQuery : getCustomerCartQuery;\n const variables = isGuest ? { cartId } : {};\n\n if (isGuest && !cartId) throw new MissingCart();\n\n return await dispatchApiCall({\n type: 'query',\n query,\n options: { method: 'POST', cache: 'no-cache', variables },\n path: 'cart',\n transformer: transformCart,\n });\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n authenticateCustomer,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const addCheckoutEventListeners = () => [\n events.on('authenticated', authenticateCustomer, { eager: true }),\n events.on('cart/initialized', initializeCheckout, { eager: true }),\n events.on('cart/reset', resetCheckout),\n events.on('cart/updated', synchronizeCheckout),\n];\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n} from '@/checkout/data/models';\n\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nexport type ConfigProps = {\n langDefinitions?: Lang;\n models?: {\n CartModel?: Model<CartModel>;\n CustomerModel?: Model<CustomerModel>;\n };\n};\n\nexport const initialize = new Initializer<ConfigProps>({\n init: async (_config) => {\n const config = { ..._config };\n initialize.config.setConfig(config);\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCart, getStoreConfig, synchronizeCheckout } from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { Cart, events } from '@adobe-commerce/event-bus';\n\nexport const initializeCheckout = async (cart: Cart | null): Promise<void> => {\n if (state.initialized) return synchronizeCheckout(cart);\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const cartId = cart ? cart.id : null;\n state.cartId = cartId;\n\n const initialData = cartId ? await getCart() : null;\n state.initialized = true;\n\n events.emit('checkout/initialized', initialData || null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { state } from '@/checkout/lib/state';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const resetCheckout = () => {\n state.cartId = null;\n events.emit('checkout/updated', null);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { getCart, initializeCheckout } from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { Cart, events } from '@adobe-commerce/event-bus';\n\nexport const synchronizeCheckout = async (cart: Cart | null) => {\n if (!state.initialized) return initializeCheckout(cart);\n const cartId = cart ? cart.id : null;\n state.cartId = cartId;\n const data = cartId ? await getCart() : null;\n events.emit('checkout/updated', data || null);\n};\n"],"names":["authenticateCustomer","authenticated","state","byPrice","a","b","isNullish","value","isValid","method","buildShippingMethod","data","transformSelectedShippingMethod","transformShippingMethods","isValidAddressRegion","region","transformAddressRegion","code","label","region_id","transformAddressCountry","isValidCustomAttribute","attribute","transformCustomAttributes","buildBaseAddress","street","transformBillingAddress","transformShippingAddresses","address","available_shipping_methods","selected_shipping_method","same_as_billing","baseData","transformCartAddressModelToInput","transformSelectedPaymentMethod","transformAvailablePaymentMethods","title","transformCart","model","merge","_c","_b","_a","config","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","addCheckoutEventListeners","events","initializeCheckout","resetCheckout","synchronizeCheckout","initialize","Initializer","_config","cart","getStoreConfig","initialData"],"mappings":"kOAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,EC8BME,EAAU,CAACC,EAAmBC,IAClCD,EAAE,OAAO,MAAQC,EAAE,OAAO,MAEfC,EAAaC,GACxBA,GAAU,KAENC,EAAWC,GACX,GAACA,GACD,CAACA,EAAO,aAAe,CAACA,EAAO,cAC/BH,EAAUG,EAAO,OAAO,KAAK,GAAK,CAACA,EAAO,OAAO,UAIjDC,EAAuBC,IACpB,CACL,OAAQ,CACN,MAAOA,EAAK,OAAO,MACnB,SAAUA,EAAK,OAAO,QACxB,EACA,MAAOA,EAAK,aACZ,KAAMA,EAAK,YACX,QAAS,CACP,KAAMA,EAAK,aACX,MAAOA,EAAK,aACd,EACA,MAAO,GAAGA,EAAK,YAAY,MAAMA,EAAK,WAAW,GACjD,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAElC,EACA,GAAIA,EAAK,gBAAkB,CACzB,cAAe,CACb,MAAOA,EAAK,eAAe,MAC3B,SAAUA,EAAK,eAAe,QAAA,CAChC,CAEJ,GAGWC,EACXD,GAC+B,CAC3B,GAACH,EAAQG,CAAI,EACjB,OAAOD,EAAoBC,CAA8B,CAC3D,EASaE,EACXF,GAEKA,EAEEA,EACJ,OAAOH,CAAO,EACd,IAAKC,GAAWC,EAAoBD,CAAgC,CAAC,EACrE,KAAKN,CAAO,EALG,CAAC,EClDfW,EAAwBC,GACvBA,EACE,CAAC,CAACA,EAAO,MAAQ,CAAC,CA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EAAoBI,CAAI,EAEjD5D,EAAM,SACHA,EAAA,OAAS,MAAM6D,EAAe,GAGhC,MAAAf,EAASc,EAAOA,EAAK,GAAK,KAChC5D,EAAM,OAAS8C,EAEf,MAAMgB,EAAchB,EAAS,MAAMD,EAAY,EAAA,KAC/C7C,EAAM,YAAc,GAEbqD,EAAA,KAAK,uBAAwBS,GAAe,IAAI,CACzD,ECfaP,EAAgB,IAAM,CACjCvD,EAAM,OAAS,KACRqD,EAAA,KAAK,mBAAoB,IAAI,CACtC,ECFaG,EAAsB,MAAOI,GAAsB,CAC9D,GAAI,CAAC5D,EAAM,YAAa,OAAOsD,EAAmBM,CAAI,EAChD,MAAAd,EAASc,EAAOA,EAAK,GAAK,KAChC5D,EAAM,OAAS8C,EACf,MAAMrC,EAAOqC,EAAS,MAAMD,EAAY,EAAA,KACjCQ,EAAA,KAAK,mBAAoB5C,GAAQ,IAAI,CAC9C"}
package/chunks/values.js CHANGED
@@ -1,3 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
3
  import{events as l}from"@dropins/tools/event-bus.js";const a={email:"",isBillToShipping:!0,selectedPaymentMethod:null,selectedShippingMethod:null};function s(e){const n={...l.lastPayload("checkout/values")??a,...e};l.emit("checkout/values",n)}function u(e){const t=l.lastPayload("checkout/values");return t&&e in t?t[e]:null}export{u as g,s as n};
4
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"values.js","sources":["/@dropins/storefront-checkout/src/lib/values.ts"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { ValuesModel } from '@/checkout/data/models';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport const initialValues: ValuesModel = {\n email: '',\n isBillToShipping: true,\n selectedPaymentMethod: null,\n selectedShippingMethod: null,\n};\n\n/**\n * Emits a checkout/values event with the provided values\n * Merges with previous values if they exist\n *\n * @param values - Partial values to be emitted or merged with existing values\n */\nexport function notifyValues(values: Partial<ValuesModel>): void {\n const prev = events.lastPayload('checkout/values') ?? initialValues;\n const next = { ...prev, ...values };\n events.emit('checkout/values', next);\n}\n\n/**\n * Retrieves a specific value from the ValuesModel by key\n * @param key - The key of the ValuesModel to retrieve\n * @returns The value for the specified key or null if not defined/found\n */\nexport function getValue<K extends keyof ValuesModel>(\n key: K\n): ValuesModel[K] | null {\n const values = events.lastPayload('checkout/values');\n return values && key in values ? values[key] : null;\n}\n"],"names":["initialValues","notifyValues","values","next","events","getValue","key"],"mappings":"qDAoBO,MAAMA,EAA6B,CACxC,MAAO,GACP,iBAAkB,GAClB,sBAAuB,KACvB,uBAAwB,IAC1B,EAQO,SAASC,EAAaC,EAAoC,CAE/D,MAAMC,EAAO,CAAE,GADFC,EAAO,YAAY,iBAAiB,GAAKJ,EAC9B,GAAGE,CAAO,EAC3BE,EAAA,KAAK,kBAAmBD,CAAI,CACrC,CAOO,SAASE,EACdC,EACuB,CACjB,MAAAJ,EAASE,EAAO,YAAY,iBAAiB,EACnD,OAAOF,GAAUI,KAAOJ,EAASA,EAAOI,CAAG,EAAI,IACjD"}
@@ -6,9 +6,9 @@ import { HTMLAttributes } from 'preact/compat';
6
6
 
7
7
  interface ExtendedPaymentMethod extends PaymentMethodConfig, PaymentMethod {
8
8
  }
9
- export interface PaymentMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'loading' | 'title'> {
9
+ export interface PaymentMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
10
10
  error?: string | null;
11
- loading?: boolean;
11
+ busy?: boolean;
12
12
  onDismissError?: () => void;
13
13
  onSelectionChange?: (value: PaymentMethod) => void;
14
14
  options?: ExtendedPaymentMethod[];
@@ -4,14 +4,14 @@ import { FunctionComponent, VNode } from 'preact';
4
4
  import { HTMLAttributes } from 'preact/compat';
5
5
 
6
6
  export interface ShippingMethodsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
7
+ UIComponentType?: UIComponentType;
8
+ busy?: boolean;
7
9
  error?: string | null;
8
- isLoading?: boolean;
9
10
  onDismissError?: () => void;
10
11
  onSelectionChange?: (method: ShippingMethod) => void;
11
12
  options: ShippingMethod[];
12
13
  selection: ShippingMethod | null;
13
14
  title?: VNode;
14
- UIComponentType?: UIComponentType;
15
15
  }
16
16
  export declare const ShippingMethods: FunctionComponent<ShippingMethodsProps & import('../ConditionalWrapper/ConditionalWrapper').ConditionalProps>;
17
17
  //# sourceMappingURL=ShippingMethods.d.ts.map
@@ -18,15 +18,11 @@ export * from './BillToShippingAddress';
18
18
  export * from './ConditionalWrapper/index';
19
19
  export * from './EstimateShipping';
20
20
  export * from './LoginForm';
21
- export * from './LoginFormSummary';
22
21
  export * from './Markup';
23
22
  export * from './OutOfStock';
24
23
  export * from './PaymentMethods';
25
- export * from './PaymentMethodsSummary';
26
24
  export * from './PlaceOrder';
27
25
  export * from './ServerError';
28
26
  export * from './ShippingMethods';
29
- export * from './ShippingMethodsSummary';
30
- export * from './Summary';
31
27
  export * from './TermsAndConditions';
32
28
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as p,jsxs as V}from"@dropins/tools/preact-jsx-runtime.js";import{h as E}from"../chunks/errors.js";import"@dropins/tools/lib.js";import{events as S}from"@dropins/tools/event-bus.js";import{h as N,g as U}from"../chunks/events.js";import{n as j}from"../chunks/values.js";import{s as w}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as L,SkeletonRow as P,Checkbox as R,InLineAlert as W}from"@dropins/tools/components.js";import{W as y}from"../chunks/ConditionalWrapper.js";import{c as C}from"../chunks/classes.js";import{useText as x}from"@dropins/tools/i18n.js";import{useState as u,useRef as $,useCallback as m,useEffect as T}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const q=()=>p(L,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:p(P,{size:"small",variant:"row"})}),F=({className:e,checked:r,disabled:t,error:l=null,onChange:o=()=>{},onDismissError:a=()=>{}})=>{const f=x({title:"Checkout.BillToShippingAddress.title"}),h=l!==null,g=k=>{const b=k.target;o==null||o(b.checked)};return V("div",{className:"checkout-bill-to-shipping-address",children:[p(R,{checked:r,className:C(["checkout-bill-to-shipping-address__checkbox",e]),"data-testid":"bill-to-shipping-checkbox",disabled:t,label:f.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:g}),h&&p("div",{className:"checkout-bill-to-shipping-address__error","data-testid":"checkout-bill-to-shipping-address-alert",children:p(W,{heading:l,type:"error",variant:"primary",onDismiss:a})})]})},G=y(F,q);function H(e){var o;const r=(o=e.shippingAddresses)==null?void 0:o[0],t=!!e.billingAddress;return(r==null?void 0:r.sameAsBilling)??!t}const cs=({active:e=!0,autoSync:r=!0,onCartSyncError:t,onChange:l})=>{const[o,a]=u(null),[f,h]=u(!1),[g,k]=u(!1),[b,_]=u(!0),A=$(!1),I=E.value,{cartSyncError:B}=x({cartSyncError:"Checkout.BillToShippingAddress.cartSyncError"}),z=m(()=>{a(null)},[]),n=m(s=>{a(null),_(i=>i===s?i:(l==null||l(s),s)),j({isBillToShipping:s})},[l]),D=m(s=>{const i=s;n(i),!(!r||!i||!N())&&w({sameAsShipping:!0}).catch(c=>{n(!1),t==null||t({error:c}),t||a(B)})},[n,r,t,B]),d=m(s=>{const i=!s||(s==null?void 0:s.isEmpty),c=!!(s!=null&&s.isVirtual);if(i||c){k(c),n(!1),A.current=!1;return}A.current||(n(H(s)),A.current=!0)},[n]);return T(()=>{if(!e)return;const s=U();if(s){h(!0),d(s);return}const i=S.on("checkout/initialized",c=>{h(!0),d(c)},{eager:!0});return()=>{i==null||i.off()}},[e,d]),T(()=>{if(!e)return;const s=S.on("checkout/updated",d,{eager:!1});return()=>{s==null||s.off()}},[e,d]),p(G,{checked:b,disabled:I,error:o,initialized:f,visible:e&&!g,onChange:D,onDismissError:z})};export{cs as BillToShippingAddress,cs as default};
3
+ import{jsx as c,jsxs as E}from"@dropins/tools/preact-jsx-runtime.js";import{h as N}from"../chunks/errors.js";import"@dropins/tools/lib.js";import{events as T}from"@dropins/tools/event-bus.js";import{W as U,h as j,g as v}from"../chunks/ConditionalWrapper.js";import{n as w,g as L}from"../chunks/values.js";import{s as P}from"../chunks/setBillingAddress.js";/* empty css */import{Skeleton as R,SkeletonRow as W,Checkbox as y,InLineAlert as C}from"@dropins/tools/components.js";import{c as $}from"../chunks/classes.js";import{useText as _}from"@dropins/tools/i18n.js";import{useState as u,useRef as q,useCallback as m,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const F=()=>c(R,{className:"bill-to-shipping-address__skeleton","data-testid":"bill-to-shipping-skeleton",children:c(W,{size:"small",variant:"row"})}),G=({className:i,checked:r,disabled:e,error:o=null,onChange:n=()=>{},onDismissError:a=()=>{}})=>{const f=_({title:"Checkout.BillToShippingAddress.title"}),h=o!==null,g=k=>{const b=k.target;n==null||n(b.checked)};return E("div",{className:"checkout-bill-to-shipping-address",children:[c(y,{checked:r,className:$(["checkout-bill-to-shipping-address__checkbox",i]),"data-testid":"bill-to-shipping-checkbox",disabled:e,label:f.title,name:"checkout-bill-to-shipping-address__checkbox",onChange:g}),h&&c("div",{className:"checkout-bill-to-shipping-address__error","data-testid":"checkout-bill-to-shipping-address-alert",children:c(C,{heading:o,type:"error",variant:"primary",onDismiss:a})})]})},H=U(G,F);function J(i){var n;const r=(n=i.shippingAddresses)==null?void 0:n[0],e=!!i.billingAddress;return(r==null?void 0:r.sameAsBilling)??!e}const cs=({active:i=!0,autoSync:r=!0,onCartSyncError:e,onChange:o})=>{const[n,a]=u(null),[f,h]=u(!1),[g,k]=u(!1),[b,A]=u(!0),B=q(!1),V=N.value,{cartSyncError:S}=_({cartSyncError:"Checkout.BillToShippingAddress.cartSyncError"}),I=m(()=>{a(null)},[]),p=m(s=>{a(null),A(s),w({isBillToShipping:s})},[]),z=m(s=>{const t=s;p(t),o==null||o(t),!(!r||!t||!j())&&P({sameAsShipping:!0}).catch(l=>{p(!1),e==null||e({error:l}),e||a(S)})},[r,S,e,o,p]),d=m(s=>{const t=!s||(s==null?void 0:s.isEmpty),l=!!(s!=null&&s.isVirtual);if(t||l){k(l),p(!1),B.current=!1;return}if(!B.current){const D=J(s);p(D),B.current=!0}},[p]);return x(()=>{if(!i)return;const s=v();if(s){h(!0);const l=L("isBillToShipping");l!=null&&A(l),d(s);return}const t=T.on("checkout/initialized",l=>{h(!0),d(l)},{eager:!0});return()=>{t==null||t.off()}},[i,d]),x(()=>{if(!i)return;const s=T.on("checkout/updated",d,{eager:!1});return()=>{s==null||s.off()}},[i,d]),c(H,{checked:b,disabled:V,error:n,initialized:f,visible:i&&!g,onChange:z,onDismissError:I})};export{cs as BillToShippingAddress,cs as default};
4
+ //# sourceMappingURL=BillToShippingAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BillToShippingAddress.js","sources":["/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddressSkeleton.tsx","/@dropins/storefront-checkout/src/components/BillToShippingAddress/BillToShippingAddress.tsx","/@dropins/storefront-checkout/src/containers/BillToShippingAddress/BillToShippingAddress.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const BillToShippingAddressSkeleton: FunctionComponent = () => {\n return (\n <Skeleton\n className=\"bill-to-shipping-address__skeleton\"\n data-testid=\"bill-to-shipping-skeleton\"\n >\n <SkeletonRow size=\"small\" variant=\"row\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport '@/checkout/components/BillToShippingAddress/BillToShippingAddress.css';\nimport { BillToShippingAddressSkeleton } from '@/checkout/components/BillToShippingAddress/BillToShippingAddressSkeleton';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport { Checkbox, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { classes } from '@adobe-commerce/elsie/lib/classes';\nimport { FunctionComponent } from 'preact';\nimport { ChangeEvent, HTMLAttributes } from 'preact/compat';\n\nexport interface BillToShippingAddressProps\n extends Omit<\n HTMLAttributes<HTMLInputElement>,\n 'loading' | 'disabled' | 'onChange'\n > {\n disabled?: boolean;\n error?: string | null;\n onChange?: (checked: boolean) => void;\n onDismissError?: () => void;\n}\n\nconst BillToShippingAddressComponent: FunctionComponent<\n BillToShippingAddressProps\n> = ({\n className,\n checked,\n disabled,\n error = null,\n onChange = () => {},\n onDismissError = () => {},\n}) => {\n const translations = useText({\n title: 'Checkout.BillToShippingAddress.title',\n });\n\n const hasError = error !== null;\n\n const handleChange = (event: Event | ChangeEvent<HTMLInputElement>) => {\n const checkbox = event.target as HTMLInputElement;\n onChange?.(checkbox.checked);\n };\n\n return (\n <div className=\"checkout-bill-to-shipping-address\">\n <Checkbox\n checked={checked}\n className={classes([\n 'checkout-bill-to-shipping-address__checkbox',\n className,\n ])}\n data-testid=\"bill-to-shipping-checkbox\"\n disabled={disabled}\n label={translations.title}\n name=\"checkout-bill-to-shipping-address__checkbox\"\n onChange={handleChange}\n />\n\n {hasError && (\n <div\n className=\"checkout-bill-to-shipping-address__error\"\n data-testid=\"checkout-bill-to-shipping-address-alert\"\n >\n <InLineAlert\n heading={error}\n type=\"error\"\n variant=\"primary\"\n onDismiss={onDismissError}\n />\n </div>\n )}\n </div>\n );\n};\n\nexport const BillToShippingAddress = WithConditionals(\n BillToShippingAddressComponent,\n BillToShippingAddressSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { setBillingAddress } from '@/checkout/api';\nimport { BillToShippingAddress as BillToShippingAddressComponent } from '@/checkout/components/BillToShippingAddress';\nimport { Cart } from '@/checkout/data/models/cart';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingCartUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n error: Error;\n}\n\nexport interface BillToShippingAddressProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onChange?: (checked: boolean) => void;\n}\n\nfunction isBillToShippingAddress(cart: Cart) {\n const shippingAddress = cart.shippingAddresses?.[0];\n const hasBillingAddress = !!cart.billingAddress;\n const sameAsBilling = shippingAddress?.sameAsBilling;\n return sameAsBilling ?? !hasBillingAddress;\n}\n\nexport const BillToShippingAddress: Container<BillToShippingAddressProps> = ({\n active = true,\n autoSync = true,\n onCartSyncError,\n onChange,\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isInitialized, setIsInitialized] = useState(false);\n const [isVirtual, setIsVirtual] = useState(false);\n const [isChecked, setIsChecked] = useState(true);\n\n const hasInitialCartData = useRef(false);\n\n const hasPendingUpdates = hasPendingCartUpdates.value;\n\n const { cartSyncError } = useText({\n cartSyncError: 'Checkout.BillToShippingAddress.cartSyncError',\n });\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setBillToShipping = useCallback(\n (value: boolean) => {\n setError(null);\n setIsChecked(value);\n notifyValues({ isBillToShipping: value });\n },\n []\n );\n\n const handleChange = useCallback(\n (checked: boolean) => {\n const isBillToShipping = checked;\n\n setBillToShipping(isBillToShipping);\n\n onChange?.(isBillToShipping);\n\n if (!autoSync || !isBillToShipping || !hasShippingAddress()) {\n return;\n }\n\n setBillingAddress({ sameAsShipping: true }).catch((error: any) => {\n setBillToShipping(false);\n onCartSyncError?.({ error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, cartSyncError, onCartSyncError, onChange, setBillToShipping]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | null) => {\n const isEmptyCart = !data || data?.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setIsVirtual(isVirtualCart);\n setBillToShipping(false);\n hasInitialCartData.current = false;\n return;\n }\n\n if (!hasInitialCartData.current) {\n const billToShippingValue = isBillToShippingAddress(data);\n setBillToShipping(billToShippingValue);\n hasInitialCartData.current = true;\n }\n },\n [setBillToShipping]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userBillToShipping = getValue('isBillToShipping');\n if (userBillToShipping != null) {\n setIsChecked(userBillToShipping);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n {\n eager: false,\n }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <BillToShippingAddressComponent\n checked={isChecked}\n disabled={hasPendingUpdates}\n error={error}\n initialized={isInitialized}\n visible={active && !isVirtual}\n onChange={handleChange}\n onDismissError={handleDismissError}\n />\n );\n};\n"],"names":["BillToShippingAddressSkeleton","jsx","Skeleton","SkeletonRow","BillToShippingAddressComponent","className","checked","disabled","error","onChange","onDismissError","translations","useText","hasError","handleChange","event","checkbox","jsxs","Checkbox","classes","InLineAlert","BillToShippingAddress","WithConditionals","isBillToShippingAddress","cart","shippingAddress","_a","hasBillingAddress","active","autoSync","onCartSyncError","setError","useState","isInitialized","setIsInitialized","isVirtual","setIsVirtual","isChecked","setIsChecked","hasInitialCartData","useRef","hasPendingUpdates","hasPendingCartUpdates","cartSyncError","handleDismissError","useCallback","setBillToShipping","value","notifyValues","isBillToShipping","hasShippingAddress","setBillingAddress","handleCheckoutData","data","isEmptyCart","isVirtualCart","billToShippingValue","useEffect","pastUpdate","getLatestCheckoutUpdate","userBillToShipping","getValue","onCheckoutInit","events","onCheckoutUpdated"],"mappings":"k0BAoBO,MAAMA,EAAmD,IAE5DC,EAACC,EAAA,CACC,UAAU,qCACV,cAAY,4BAEZ,SAACD,EAAAE,EAAA,CAAY,KAAK,QAAQ,QAAQ,KAAM,CAAA,CAAA,CAC1C,ECUEC,EAEF,CAAC,CACH,UAAAC,EACA,QAAAC,EACA,SAAAC,EACA,MAAAC,EAAQ,KACR,SAAAC,EAAW,IAAM,CAAC,EAClB,eAAAC,EAAiB,IAAM,CAAA,CACzB,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,MAAO,sCAAA,CACR,EAEKC,EAAWL,IAAU,KAErBM,EAAgBC,GAAiD,CACrE,MAAMC,EAAWD,EAAM,OACvBN,GAAA,MAAAA,EAAWO,EAAS,QACtB,EAGE,OAAAC,EAAC,MAAI,CAAA,UAAU,oCACb,SAAA,CAAAhB,EAACiB,EAAA,CACC,QAAAZ,EACA,UAAWa,EAAQ,CACjB,8CACAd,CAAA,CACD,EACD,cAAY,4BACZ,SAAAE,EACA,MAAOI,EAAa,MACpB,KAAK,8CACL,SAAUG,CAAA,CACZ,EAECD,GACCZ,EAAC,MAAA,CACC,UAAU,2CACV,cAAY,0CAEZ,SAAAA,EAACmB,EAAA,CACC,QAASZ,EACT,KAAK,QACL,QAAQ,UACR,UAAWE,CAAA,CAAA,CACb,CAAA,CACF,EAEJ,CAEJ,EAEaW,EAAwBC,EACnClB,EACAJ,CACF,EChDA,SAASuB,EAAwBC,EAAY,OACrC,MAAAC,GAAkBC,EAAAF,EAAK,oBAAL,YAAAE,EAAyB,GAC3CC,EAAoB,CAAC,CAACH,EAAK,eAEjC,OADsBC,GAAA,YAAAA,EAAiB,gBACf,CAACE,CAC3B,CAEO,MAAMN,GAA+D,CAAC,CAC3E,OAAAO,EAAS,GACT,SAAAC,EAAW,GACX,g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ACrCjB,EAAmB,QAAU,EAAA,CAEjC,EACA,CAACO,CAAiB,CACpB,EAEA,OAAAW,EAAU,IAAM,CACd,GAAI,CAAC7B,EAAQ,OAEb,MAAM8B,EAAaC,EAAwB,EAE3C,GAAID,EAAY,CACdxB,EAAiB,EAAI,EAEf,MAAA0B,EAAqBC,EAAS,kBAAkB,EAClDD,GAAsB,MACxBtB,EAAasB,CAAkB,EAEjCR,EAAmBM,CAAU,EAC7B,MAAA,CAGF,MAAMI,EAAiBC,EAAO,GAC5B,uBACCV,GAAS,CACRnB,EAAiB,EAAI,EACrBkB,EAAmBC,CAAI,CACzB,EACA,CAAE,MAAO,EAAK,CAChB,EAEA,MAAO,IAAM,CACXS,GAAA,MAAAA,EAAgB,KAClB,CAAA,EACC,CAAClC,EAAQwB,CAAkB,CAAC,EAE/BK,EAAU,IAAM,CACd,GAAI,CAAC7B,EAAQ,OAEb,MAAMoC,EAAoBD,EAAO,GAC/B,mBACAX,EACA,CACE,MAAO,EAAA,CAEX,EAEA,MAAO,IAAM,CACXY,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAACpC,EAAQwB,CAAkB,CAAC,EAG7BnD,EAACG,EAAA,CACC,QAASiC,EACT,SAAUI,EACV,MAAAjC,EACA,YAAayB,EACb,QAASL,GAAU,CAACO,EACpB,SAAUrB,EACV,eAAgB8B,CAAA,CAClB,CAEJ"}
@@ -1,3 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";import{W as z}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{useText as _}from"@dropins/tools/i18n.js";/* empty css */import{s as G,T as I}from"../chunks/errors.js";import{events as d}from"@dropins/tools/event-bus.js";import{g as P}from"../chunks/events.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),at=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=G.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=P();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{at as EstimateShipping,at as default};
3
+ import{jsx as i,jsxs as k}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Skeleton as B,SkeletonRow as U,Price as h}from"@dropins/tools/components.js";import{W as z,g as G}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";import{VComponent as C,classes as D}from"@dropins/tools/lib.js";import{useText as _}from"@dropins/tools/i18n.js";/* empty css */import{s as P,T as I}from"../chunks/errors.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as V,useCallback as b,useEffect as x}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const X=()=>i(B,{"data-testid":"estimate-shipping-skeleton",children:i(U,{size:"xsmall"})}),j=({label:n,price:t,priceExclTax:a,taxExcluded:o=!1,taxIncluded:c=!1})=>{const l=_({withTaxes:"Checkout.EstimateShipping.withTaxes",withoutTaxes:"Checkout.EstimateShipping.withoutTaxes"});return k("div",{className:"checkout-estimate-shipping","data-testid":"estimate-shipping",children:[i(C,{className:"checkout-estimate-shipping__label",node:n}),i(C,{className:"checkout-estimate-shipping__price",node:t}),c&&i("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included",children:l.withTaxes}),o&&k("span",{className:D(["checkout-estimate-shipping__caption"]),"data-testid":"shipping-tax-included-excluded",children:[a," ",l.withoutTaxes]})]})},v=z(j,X),st=({active:n=!0})=>{var T;const[t,a]=V(),o=(t==null?void 0:t.amount.value)===0,c=(T=P.config)==null?void 0:T.shoppingCartDisplaySetting.shipping,l=c===I.INCLUDING_EXCLUDING_TAX,g=c===I.INCLUDING_TAX,u=_({freeShipping:"Checkout.EstimateShipping.freeShipping",taxToBeDetermined:"Checkout.EstimateShipping.taxToBeDetermined",label:"Checkout.EstimateShipping.label",estimated:"Checkout.EstimateShipping.estimated"}),r=b(e=>{var S;const s=!e||e.isEmpty,p=!!(e!=null&&e.isVirtual);if(s||p){a(null);return}const m=(S=e.shippingAddresses)==null?void 0:S[0];if(!m)return;const E=m==null?void 0:m.selectedShippingMethod;if(!E){a(null);return}const{amount:w,amountExclTax:L,amountInclTax:M}=E;a({estimated:!1,amount:w,amountExclTax:L,amountInclTax:M})},[]),f=b(e=>{let s=null;if(e.shippingMethod){const p=e.shippingMethod;s={estimated:!0,amount:p.amount,amountExclTax:p.amountExclTax,amountInclTax:p.amountInclTax}}a(s)},[]);x(()=>{if(!n)return;const e=d.on("shipping/estimate",f,{eager:!0});return()=>{e==null||e.off()}},[n,f]),x(()=>{if(!n)return;const e=G();if(e){r(e);return}const s=d.on("checkout/initialized",r,{eager:!0});return()=>{s==null||s.off()}},[n,r]),x(()=>{if(!n)return;const e=d.on("checkout/updated",r,{eager:!1});return()=>{e==null||e.off()}},[n,r]);const y=()=>o?i("span",{"data-testid":"free-shipping",children:u.freeShipping}):g&&(t!=null&&t.amountInclTax)?i(h,{amount:t.amountInclTax.value,currency:t.amountInclTax.currency,"data-testid":"shipping"}):i(h,{amount:t==null?void 0:t.amount.value,currency:t==null?void 0:t.amount.currency,"data-testid":"shipping"}),N=()=>t!=null&&t.amountExclTax?i(h,{amount:t.amountExclTax.value,currency:t.amountExclTax.currency,"data-testid":"shipping-excluding-tax"}):i("span",{children:u.taxToBeDetermined});return i(v,{initialized:t!==void 0,label:(()=>{const e=t!=null&&t.estimated?u.estimated:u.label;return i("span",{"data-testid":"estimate-shipping-label",children:e})})(),price:y(),priceExclTax:N(),taxExcluded:l&&!o,taxIncluded:g&&!o,visible:n&&t!==null})};export{st as EstimateShipping,st as default};
4
+ //# sourceMappingURL=EstimateShipping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EstimateShipping.js","sources":["/@dropins/storefront-checkout/src/components/EstimateShipping/EstimateShippingSkeleton.tsx","/@dropins/storefront-checkout/src/components/EstimateShipping/EstimateShipping.tsx","/@dropins/storefront-checkout/src/containers/EstimateShipping/EstimateShipping.tsx"],"sourcesContent":["/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const EstimateShippingSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"estimate-shipping-skeleton\">\n <SkeletonRow size=\"xsmall\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper';\nimport '@/checkout/components/EstimateShipping/EstimateShipping.css';\nimport { EstimateShippingSkeleton } from '@/checkout/components/EstimateShipping/EstimateShippingSkeleton';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { VComponent, classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface EstimateShippingProps {\n label: VNode<HTMLAttributes<HTMLSpanElement>>;\n price: VNode<HTMLAttributes<HTMLSpanElement>>;\n priceExclTax?: VNode<HTMLAttributes<HTMLSpanElement>>;\n taxExcluded?: boolean;\n taxIncluded?: boolean;\n}\n\nconst EstimateShippingComponent: FunctionComponent<EstimateShippingProps> = ({\n label,\n price,\n priceExclTax,\n taxExcluded = false,\n taxIncluded = false,\n}) => {\n const translations = useText({\n withTaxes: 'Checkout.EstimateShipping.withTaxes',\n withoutTaxes: 'Checkout.EstimateShipping.withoutTaxes',\n });\n\n return (\n <div className=\"checkout-estimate-shipping\" data-testid=\"estimate-shipping\">\n <VComponent className=\"checkout-estimate-shipping__label\" node={label} />\n <VComponent className=\"checkout-estimate-shipping__price\" node={price} />\n\n {taxIncluded && (\n <span\n className={classes(['checkout-estimate-shipping__caption'])}\n data-testid=\"shipping-tax-included\"\n >\n {translations.withTaxes}\n </span>\n )}\n\n {taxExcluded && (\n <span\n className={classes(['checkout-estimate-shipping__caption'])}\n data-testid=\"shipping-tax-included-excluded\"\n >\n {priceExclTax}&nbsp;\n {translations.withoutTaxes}\n </span>\n )}\n </div>\n );\n};\n\nexport const EstimateShipping = WithConditionals(\n EstimateShippingComponent,\n EstimateShippingSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { EstimateShipping as EstimateShippingComponent } from '@/checkout/components';\nimport {\n Cart,\n Price as PriceModel,\n ShippingEstimate,\n TaxDisplay,\n} from '@/checkout/data/models';\nimport { getLatestCheckoutUpdate } from '@/checkout/lib';\nimport { state } from '@/checkout/lib/state';\nimport { Price } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\n\ninterface ShippingData {\n estimated?: boolean;\n amount: PriceModel;\n amountExclTax?: PriceModel;\n amountInclTax?: PriceModel;\n}\n\nexport interface EstimateShippingProps {\n active?: boolean;\n}\n\nexport const EstimateShipping: Container<EstimateShippingProps> = ({\n active = true,\n}) => {\n const [data, setData] = useState<ShippingData | null | undefined>();\n\n const isFreeShipping = data?.amount.value === 0;\n const shippingDisplay = state.config?.shoppingCartDisplaySetting.shipping;\n const taxExcluded = shippingDisplay === TaxDisplay.INCLUDING_EXCLUDING_TAX;\n const taxIncluded = shippingDisplay === TaxDisplay.INCLUDING_TAX;\n\n const translations = useText({\n freeShipping: 'Checkout.EstimateShipping.freeShipping',\n taxToBeDetermined: 'Checkout.EstimateShipping.taxToBeDetermined',\n label: 'Checkout.EstimateShipping.label',\n estimated: 'Checkout.EstimateShipping.estimated',\n });\n\n const handleCheckoutData = useCallback((data: Cart | null) => {\n const isEmptyCart = !data || data.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setData(null);\n return;\n }\n\n const primaryAddress = data.shippingAddresses?.[0];\n\n if (!primaryAddress) {\n return;\n }\n\n const shippingMethod = primaryAddress?.selectedShippingMethod;\n\n if (!shippingMethod) {\n setData(null);\n return;\n }\n\n const { amount, amountExclTax, amountInclTax } = shippingMethod;\n setData({ estimated: false, amount, amountExclTax, amountInclTax });\n }, []);\n\n const handleShippingEstimate = useCallback((estimation: ShippingEstimate) => {\n let shippingData: ShippingData | null = null;\n\n if (estimation.shippingMethod) {\n const shippingMethod = estimation.shippingMethod;\n\n shippingData = {\n estimated: true,\n amount: shippingMethod.amount,\n amountExclTax: shippingMethod.amountExclTax,\n amountInclTax: shippingMethod.amountInclTax,\n };\n }\n\n setData(shippingData);\n }, []);\n\n useEffect(() => {\n if (!active) return;\n\n const onShippingEstimate = events.on(\n 'shipping/estimate',\n handleShippingEstimate,\n { eager: true }\n );\n\n return () => {\n onShippingEstimate?.off();\n };\n }, [active, handleShippingEstimate]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n handleCheckoutData,\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n const renderPrice = () => {\n if (isFreeShipping) {\n return (\n <span data-testid=\"free-shipping\">{translations.freeShipping}</span>\n );\n }\n\n if (taxIncluded && data?.amountInclTax) {\n return (\n <Price\n amount={data.amountInclTax.value}\n currency={data.amountInclTax.currency}\n data-testid=\"shipping\"\n />\n );\n }\n\n return (\n <Price\n amount={data?.amount.value}\n currency={data?.amount.currency}\n data-testid=\"shipping\"\n />\n );\n };\n\n const renderPriceExclTax = () => {\n if (!data?.amountExclTax)\n return <span>{translations.taxToBeDetermined}</span>;\n\n return (\n <Price\n amount={data.amountExclTax.value}\n currency={data.amountExclTax.currency}\n data-testid=\"shipping-excluding-tax\"\n />\n );\n };\n\n const renderLabel = () => {\n const label = data?.estimated ? translations.estimated : translations.label;\n return <span data-testid=\"estimate-shipping-label\">{label}</span>;\n };\n\n return (\n <EstimateShippingComponent\n initialized={data !== undefined}\n label={renderLabel()}\n price={renderPrice()}\n priceExclTax={renderPriceExclTax()}\n taxExcluded={taxExcluded && !isFreeShipping}\n taxIncluded={taxIncluded && !isFreeShipping}\n visible={active && data !== null}\n />\n );\n};\n"],"names":["EstimateShippingSkeleton","jsx","Skeleton","SkeletonRow","EstimateShippingComponent","label","price","priceExclTax","taxExcluded","taxIncluded","translations","useText","jsxs","VComponent","classes","EstimateShipping","WithConditionals","active","data","setData","useState","isFreeShipping","shippingDisplay","_a","state","TaxDisplay","handleCheckoutData","useCallback","isEmptyCart","isVirtualCart","primaryAddress","shippingMethod","amount","amountExclTax","amountInclTax","handleShippingEstimate","estimation","shippingData","useEffect","onShippingEstimate","events","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","renderPrice","Price","renderPriceExclTax"],"mappings":"izBAoBO,MAAMA,EAA8C,IAEvDC,EAACC,GAAS,cAAY,6BACpB,WAACC,EAAY,CAAA,KAAK,SAAS,CAC7B,CAAA,ECSEC,EAAsE,CAAC,CAC3E,MAAAC,EACA,MAAAC,EACA,aAAAC,EACA,YAAAC,EAAc,GACd,YAAAC,EAAc,EAChB,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,UAAW,sCACX,aAAc,wCAAA,CACf,EAED,OACGC,EAAA,MAAA,CAAI,UAAU,6BAA6B,cAAY,oBACtD,SAAA,CAAAX,EAACY,EAAW,CAAA,UAAU,oCAAoC,KAAMR,EAAO,EACtEJ,EAAAY,EAAA,CAAW,UAAU,oCAAoC,KA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CACd,EAIE6B,EAAqB,IACpB7B,GAAA,MAAAA,EAAM,cAITjB,EAAC6C,EAAA,CACC,OAAQ5B,EAAK,cAAc,MAC3B,SAAUA,EAAK,cAAc,SAC7B,cAAY,wBAAA,CACd,EAPOjB,EAAC,OAAM,CAAA,SAAAS,EAAa,iBAAkB,CAAA,EAiB/C,OAAAT,EAACG,EAAA,CACC,YAAac,IAAS,OACtB,OARgB,IAAM,CACxB,MAAMb,EAAQa,GAAA,MAAAA,EAAM,UAAYR,EAAa,UAAYA,EAAa,MACtE,OAAQT,EAAA,OAAA,CAAK,cAAY,0BAA2B,SAAMI,EAAA,CAC5D,GAKuB,EACnB,MAAOwC,EAAY,EACnB,aAAcE,EAAmB,EACjC,YAAavC,GAAe,CAACa,EAC7B,YAAaZ,GAAe,CAACY,EAC7B,QAASJ,GAAUC,IAAS,IAAA,CAC9B,CAEJ"}
@@ -1,3 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsx as r,jsxs as u,Fragment as le}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/errors.js";import{VComponent as G,classes as se,Slot as J}from"@dropins/tools/lib.js";import{events as T}from"@dropins/tools/event-bus.js";import{b as ce,g as me}from"../chunks/events.js";import{n as H,g as K}from"../chunks/values.js";import{i as ue,s as he,g as de}from"../chunks/setGuestEmailOnCart.js";import{Field as ge,Input as fe,Skeleton as pe,SkeletonRow as Q}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";/* empty css */import{W as ke}from"../chunks/ConditionalWrapper.js";import"../chunks/TermsAndConditions.js";/* empty css */import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as k,useRef as Le,useCallback as d,useEffect as M,useMemo as $}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const ve={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},B=n=>ve.EMAIL.test(n),Fe=({value:n,error:o,hint:a,onChange:g,onBlur:L,onInvalid:c})=>{const l=I({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(ge,{error:o,hint:a,children:r(fe,{"aria-label":l.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:l.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",placeholder:l.LoginFormPlaceholder,required:!0,type:"email",value:n,onBlur:L,onChange:g,onInvalid:c})})},_e=({onClick:n})=>{const o=I({account:"Checkout.LoginForm.account",signIn:"Checkout.LoginForm.signIn"});return u("div",{className:"checkout-login-form__sign-in",children:[o.account,r("a",{className:"checkout-login-form__link","data-testid":"sign-in-link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),n(a)},children:o.signIn})]})},be=()=>u(pe,{"data-testid":"login-form-skeleton",children:[r(Q,{fullWidth:!0,variant:"heading"}),r(Q,{fullWidth:!0,size:"medium"})]}),Ee=({className:n,customer:o,email:a,error:g,headingContent:L,hint:c,name:l,onEmailBlur:f,onEmailChange:m,onEmailInvalid:s,title:F,...A})=>u("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[u("div",{className:"checkout-login-form__heading",children:[F&&r(G,{className:"checkout-login-form__title",node:F}),L&&r(G,{className:"checkout-login-form__heading-label",node:L})]}),o?u("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${o.firstName} ${o.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:o.email})]}):r("div",{className:"checkout-login-form__content",children:u("form",{...A,noValidate:!0,className:se(["dropin-login-form__form",n]),name:l,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(Fe,{error:g,hint:c,value:a,onBlur:f,onChange:m,onInvalid:s})]})})]}),Ce=ke(Ee,be),Ne=({onClick:n})=>{const o=I({switch:"Checkout.LoginForm.switch",signOut:"Checkout.LoginForm.signOut"});return u("p",{className:"checkout-login-form__sign-out",children:[o.switch,r("a",{className:"checkout-login-form__link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),n==null||n(a)},children:o.signOut})]})},Ie=1e3,Ke=({active:n=!0,autoSync:o=!0,displayHeadingContent:a=!0,displayTitle:g=!0,initialData:L,onCartSyncError:c,onSignInClick:l,onSignOutClick:f,onValidationError:m,slots:s,...F})=>{const[A,X]=k(null),[Y,D]=k(""),[Z,p]=k(""),[y,S]=k(!1),[w,_]=k(!0),[ee,V]=k(!1),h=Le(null),{alreadyHaveAccountHint:W,cartSyncError:P,defaultTitle:j,fasterCheckoutHint:q,invalidEmailError:b,missingEmailError:E,signInLabel:O}=I({alreadyHaveAccountHint:"Checkout.LoginForm.emailExists.alreadyHaveAccount",cartSyncError:"Checkout.LoginForm.cartSyncError",defaultTitle:"Checkout.LoginForm.title",fasterCheckoutHint:"Checkout.LoginForm.emailExists.forFasterCheckout",invalidEmailError:"Checkout.LoginForm.invalidEmailError",missingEmailError:"Checkout.LoginForm.missingEmailError",signInLabel:"Checkout.LoginForm.emailExists.signInButton"}),C=d(e=>{!B(e)||e===ce()||(ue(e).then(t=>{_(t)}).catch(t=>{console.error(t),_(!0)}),o&&he(e).catch(t=>{c==null||c({email:e,error:t}),c||p(P)}))},[o,c,P]),te=d(e=>{const i=e.target.value;D(i),_(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{C(i),H({email:i}),h.current=null},Ie)},[C]),ie=d(e=>{const t=e.target,i=t.value.trim();if(B(i)){if(p(""),t.setCustomValidity(""),!h.current)return;clearTimeout(h.current),h.current=null,C(i),H({email:i});return}const U=i===""?"missing":"invalid",x=U==="missing"?E:b;if(m){m({email:i,message:x,type:U});return}p(x),t.setCustomValidity(x)},[b,E,m,C]),re=d(e=>{const t=e.target,i=t.validity,z=i.valueMissing?E:b;if(!m){p(z);return}m({email:t.value,message:z,type:i.valueMissing?"missing":"invalid"})},[E,b,m]),N=d(()=>{const e=K("email")??"",t=B(e);l==null||l(t?e:"")},[l]),R=d(()=>{f==null||f()},[f]),v=d(e=>{const t=K("email")??"",i=(e==null?void 0:e.email)??"";i!==t&&(D(i),p(""),_(!0),H({email:i}))},[]);M(()=>{if(!n)return;const e=T.on("authenticated",t=>{S(t),de().then(i=>{X(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[n]),M(()=>{if(!n)return;const e=me();if(e){V(!0),v(e);return}const t=T.on("checkout/initialized",i=>{V(!0),v(i)},{eager:!0});return()=>{t==null||t.off()}},[n,v]),M(()=>{if(!n)return;const e=T.on("checkout/updated",v,{eager:!1});return()=>{e==null||e.off()}},[n,v]);const ne=$(()=>{if(g)return r(J,{name:"checkout-login-form-title",slot:s==null?void 0:s.Title,children:r("h2",{children:j})})},[g,s,j]),oe=$(()=>{if(a)return r(J,{context:{authenticated:y},name:"checkout-login-form-heading-label",slot:s==null?void 0:s.Heading,children:y?r(Ne,{onClick:R}):r(_e,{onClick:N})})},[a,y,s,N,R]),ae=$(()=>w?"":u(le,{children:[W," ",r("a",{href:"#",onClick:N,children:O})," ",q]}),[w,W,O,q,N]);return r(Ce,{...F,customer:A,email:Y,error:Z,headingContent:oe,hint:ae,initialized:ee,title:ne,visible:n,onEmailBlur:ie,onEmailChange:te,onEmailInvalid:re})};export{Ke as LoginForm,Ke as default};
3
+ import{jsx as r,jsxs as u,Fragment as le}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/errors.js";import{VComponent as G,classes as se,Slot as J}from"@dropins/tools/lib.js";import{events as H}from"@dropins/tools/event-bus.js";import{W as ce,a as me,g as ue}from"../chunks/ConditionalWrapper.js";import{n as M,g as K}from"../chunks/values.js";import{i as he,s as de,g as ge}from"../chunks/setGuestEmailOnCart.js";import{Field as fe,Input as pe,Skeleton as ke,SkeletonRow as Q}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";/* empty css */import"../chunks/TermsAndConditions.js";/* empty css */import"@dropins/tools/preact-compat.js";/* empty css *//* empty css */import{useState as k,useRef as Le,useCallback as d,useEffect as $,useMemo as B}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const ve={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},D=n=>ve.EMAIL.test(n),Fe=({value:n,error:o,hint:a,onChange:g,onBlur:L,onInvalid:c})=>{const l=I({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(fe,{error:o,hint:a,children:r(pe,{"aria-label":l.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:l.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",placeholder:l.LoginFormPlaceholder,required:!0,type:"email",value:n,onBlur:L,onChange:g,onInvalid:c})})},_e=({onClick:n})=>{const o=I({account:"Checkout.LoginForm.account",signIn:"Checkout.LoginForm.signIn"});return u("div",{className:"checkout-login-form__sign-in",children:[o.account,r("a",{className:"checkout-login-form__link","data-testid":"sign-in-link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),n(a)},children:o.signIn})]})},Ee=()=>u(ke,{"data-testid":"login-form-skeleton",children:[r(Q,{fullWidth:!0,variant:"heading"}),r(Q,{fullWidth:!0,size:"medium"})]}),be=({className:n,customer:o,email:a,error:g,headingContent:L,hint:c,name:l,onEmailBlur:f,onEmailChange:m,onEmailInvalid:s,title:F,...A})=>u("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[u("div",{className:"checkout-login-form__heading",children:[F&&r(G,{className:"checkout-login-form__title",node:F}),L&&r(G,{className:"checkout-login-form__heading-label",node:L})]}),o?u("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${o.firstName} ${o.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:o.email})]}):r("div",{className:"checkout-login-form__content",children:u("form",{...A,noValidate:!0,className:se(["dropin-login-form__form",n]),name:l,children:[r("button",{disabled:!0,"aria-hidden":"true",style:"display: none",type:"submit"}),r(Fe,{error:g,hint:c,value:a,onBlur:f,onChange:m,onInvalid:s})]})})]}),Ce=ce(be,Ee),Ne=({onClick:n})=>{const o=I({switch:"Checkout.LoginForm.switch",signOut:"Checkout.LoginForm.signOut"});return u("p",{className:"checkout-login-form__sign-out",children:[o.switch,r("a",{className:"checkout-login-form__link",href:"#",rel:"noreferrer",target:"_blank",onClick:a=>{a.preventDefault(),n==null||n(a)},children:o.signOut})]})},Ie=1e3,Je=({active:n=!0,autoSync:o=!0,displayHeadingContent:a=!0,displayTitle:g=!0,initialData:L,onCartSyncError:c,onSignInClick:l,onSignOutClick:f,onValidationError:m,slots:s,...F})=>{const[A,X]=k(null),[Y,y]=k(""),[Z,p]=k(""),[z,S]=k(!1),[w,_]=k(!0),[ee,V]=k(!1),h=Le(null),{alreadyHaveAccountHint:W,cartSyncError:P,defaultTitle:j,fasterCheckoutHint:q,invalidEmailError:E,missingEmailError:b,signInLabel:O}=I({alreadyHaveAccountHint:"Checkout.LoginForm.emailExists.alreadyHaveAccount",cartSyncError:"Checkout.LoginForm.cartSyncError",defaultTitle:"Checkout.LoginForm.title",fasterCheckoutHint:"Checkout.LoginForm.emailExists.forFasterCheckout",invalidEmailError:"Checkout.LoginForm.invalidEmailError",missingEmailError:"Checkout.LoginForm.missingEmailError",signInLabel:"Checkout.LoginForm.emailExists.signInButton"}),C=d(e=>{!D(e)||e===me()||(he(e).then(t=>{_(t)}).catch(t=>{console.error(t),_(!0)}),o&&de(e).catch(t=>{c==null||c({email:e,error:t}),c||p(P)}))},[o,c,P]),te=d(e=>{const i=e.target.value;y(i),_(!0),p(""),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{C(i),M({email:i}),h.current=null},Ie)},[C]),ie=d(e=>{const t=e.target,i=t.value.trim();if(D(i)){if(p(""),t.setCustomValidity(""),!h.current)return;clearTimeout(h.current),h.current=null,C(i),M({email:i});return}const U=i===""?"missing":"invalid",T=U==="missing"?b:E;if(m){m({email:i,message:T,type:U});return}p(T),t.setCustomValidity(T)},[E,b,m,C]),re=d(e=>{const t=e.target,i=t.validity,x=i.valueMissing?b:E;if(!m){p(x);return}m({email:t.value,message:x,type:i.valueMissing?"missing":"invalid"})},[b,E,m]),N=d(()=>{const e=K("email")??"",t=D(e);l==null||l(t?e:"")},[l]),R=d(()=>{f==null||f()},[f]),v=d(e=>{const t=K("email")??"",i=(e==null?void 0:e.email)??"";i!==t&&(y(i),p(""),_(!0),M({email:i}))},[]);$(()=>{if(!n)return;const e=H.on("authenticated",t=>{S(t),ge().then(i=>{X(i)}).catch(console.error)},{eager:!0});return()=>{e==null||e.off()}},[n]),$(()=>{if(!n)return;const e=ue();if(e){V(!0);const i=e.email??"";i&&y(i),v(e);return}const t=H.on("checkout/initialized",i=>{V(!0),v(i)},{eager:!0});return()=>{t==null||t.off()}},[n,v]),$(()=>{if(!n)return;const e=H.on("checkout/updated",v,{eager:!1});return()=>{e==null||e.off()}},[n,v]);const ne=B(()=>{if(g)return r(J,{name:"checkout-login-form-title",slot:s==null?void 0:s.Title,children:r("h2",{children:j})})},[g,s,j]),oe=B(()=>{if(a)return r(J,{context:{authenticated:z},name:"checkout-login-form-heading-label",slot:s==null?void 0:s.Heading,children:z?r(Ne,{onClick:R}):r(_e,{onClick:N})})},[a,z,s,N,R]),ae=B(()=>w?"":u(le,{children:[W," ",r("a",{href:"#",onClick:N,children:O})," ",q]}),[w,W,O,q,N]);return r(Ce,{...F,customer:A,email:Y,error:Z,headingContent:oe,hint:ae,initialized:ee,title:ne,visible:n,onEmailBlur:ie,onEmailChange:te,onEmailInvalid:re})};export{Je as LoginForm,Je as default};
4
+ //# sourceMappingURL=LoginForm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginForm.js","sources":["/@dropins/storefront-checkout/src/lib/validation.ts","/@dropins/storefront-checkout/src/components/LoginForm/Email.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignIn.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginFormSkeleton.tsx","/@dropins/storefront-checkout/src/components/LoginForm/LoginForm.tsx","/@dropins/storefront-checkout/src/components/LoginForm/SignOut.tsx","/@dropins/storefront-checkout/src/containers/LoginForm/LoginForm.tsx"],"sourcesContent":["export const validationPatterns = {\n EMAIL:\n /^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\\.)+[a-z]{2,}$/i,\n};\n\nexport const validateEmail = (email: string): boolean => {\n return validationPatterns.EMAIL.test(email);\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Field, Input } from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginEmailProps extends HTMLAttributes<HTMLInputElement> {\n value: string;\n error: string;\n hint: string;\n onChange: (event: Event) => void;\n onBlur: (event: Event) => void;\n onInvalid: (event: Event) => void;\n}\n\nexport const Email: FunctionComponent<LoginEmailProps> = ({\n value,\n error,\n hint,\n onChange,\n onBlur,\n onInvalid,\n}) => {\n const translations = useText({\n LoginFormLabel: 'Checkout.LoginForm.ariaLabel',\n LoginFormFloatingLabel: 'Checkout.LoginForm.floatingLabel',\n LoginFormPlaceholder: 'Checkout.LoginForm.placeholder',\n });\n\n return (\n <Field error={error} hint={hint}>\n <Input\n aria-label={translations.LoginFormLabel}\n aria-required={true}\n autocomplete=\"email\"\n floatingLabel={translations.LoginFormFloatingLabel}\n id=\"customer-email\"\n name=\"customer-email\"\n placeholder={translations.LoginFormPlaceholder}\n required={true}\n type=\"email\"\n value={value}\n onBlur={onBlur}\n onChange={onChange}\n onInvalid={onInvalid}\n />\n </Field>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignInProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignIn: FunctionComponent<SignInProps> = ({ onClick }) => {\n const translations = useText({\n account: 'Checkout.LoginForm.account',\n signIn: 'Checkout.LoginForm.signIn'\n });\n\n return (\n <div className=\"checkout-login-form__sign-in\">\n {translations.account}\n\n <a\n className=\"checkout-login-form__link\"\n data-testid=\"sign-in-link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick(event);\n }}\n >\n {translations.signIn}\n </a>\n </div>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const LoginFormSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"login-form-skeleton\">\n <SkeletonRow fullWidth={true} variant=\"heading\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\n </Skeleton>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { Email } from '@/checkout/components';\nimport { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/LoginForm/LoginForm.css';\nimport { LoginFormSkeleton } from '@/checkout/components/LoginForm/LoginFormSkeleton';\nimport { Customer } from '@/checkout/data/models';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface LoginFormProps\n extends Omit<HTMLAttributes<HTMLFormElement>, 'title'> {\n customer: Customer | null;\n email: string;\n error: string;\n headingContent?: VNode;\n hint: string | VNode;\n onEmailBlur: (event: Event) => void;\n onEmailChange: (event: Event) => void;\n onEmailInvalid: (event: Event) => void;\n title?: VNode;\n}\n\nconst LoginFormComponent: FunctionComponent<LoginFormProps> = ({\n className,\n customer,\n email,\n error,\n headingContent,\n hint,\n name,\n onEmailBlur,\n onEmailChange,\n onEmailInvalid,\n title,\n ...props\n}) => {\n return (\n <div className=\"checkout-login-form\" data-testid=\"checkout-login-form\">\n <div className=\"checkout-login-form__heading\">\n {title && (\n <VComponent className=\"checkout-login-form__title\" node={title} />\n )}\n\n {headingContent && (\n <VComponent\n className=\"checkout-login-form__heading-label\"\n node={headingContent}\n />\n )}\n </div>\n\n {customer ? (\n <div className=\"checkout-login-form__customer-details\">\n <div className=\"checkout-login-form__customer-name\">\n {`${customer.firstName} ${customer.lastName}`}\n </div>\n\n <div className=\"checkout-login-form__customer-email\">\n {customer.email}\n </div>\n </div>\n ) : (\n <div className=\"checkout-login-form__content\">\n <form\n {...props}\n noValidate\n className={classes(['dropin-login-form__form', className])}\n name={name}\n >\n {/* Prevent 'Enter' key press from submitting this form. */}\n <button\n disabled\n aria-hidden=\"true\"\n style=\"display: none\"\n type=\"submit\"\n />\n <Email\n error={error}\n hint={hint as any}\n value={email}\n onBlur={onEmailBlur}\n onChange={onEmailChange}\n onInvalid={onEmailInvalid}\n />\n </form>\n </div>\n )}\n </div>\n );\n};\n\nexport const LoginForm = WithConditionals(\n LoginFormComponent,\n LoginFormSkeleton\n);\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { FunctionComponent } from 'preact';\n\ninterface SignOutProps {\n onClick: (event: Event) => void;\n}\n\nexport const SignOut: FunctionComponent<SignOutProps> = ({ onClick }) => {\n const translations = useText({\n switch: 'Checkout.LoginForm.switch',\n signOut: 'Checkout.LoginForm.signOut'\n });\n\n return (\n <p className=\"checkout-login-form__sign-out\">\n {translations.switch}\n\n <a\n className=\"checkout-login-form__link\"\n href=\"#\"\n rel=\"noreferrer\"\n target=\"_blank\"\n onClick={(event) => {\n event.preventDefault();\n onClick?.(event);\n }}\n >\n {translations.signOut}\n </a>\n </p>\n );\n};\n","/********************************************************************\n * ADOBE CONFIDENTIAL\n * __________________\n *\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: All information contained herein is, and remains\n * the property of Adobe and its suppliers, if any. The intellectual\n * and technical concepts contained herein are proprietary to Adobe\n * and its suppliers and are protected by all applicable intellectual\n * property laws, including trade secret and copyright laws.\n * Dissemination of this information or reproduction of this material\n * is strictly forbidden unless prior written permission is obtained\n * from Adobe.\n *******************************************************************/\n\nimport {\n getCustomer,\n isEmailAvailable,\n setGuestEmailOnCart,\n} from '@/checkout/api';\nimport {\n LoginForm as LoginFormComponent,\n SignIn,\n SignOut,\n} from '@/checkout/components/LoginForm';\nimport { Cart, Customer } from '@/checkout/data/models';\nimport {\n getCartEmail,\n getLatestCheckoutUpdate,\n getValue,\n notifyValues,\n validateEmail,\n} from '@/checkout/lib';\nimport { TitleProps } from '@/checkout/types/TitleProps';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'preact/hooks';\n\ninterface ValidationError {\n email: string;\n message: string;\n type: 'missing' | 'invalid';\n}\n\ninterface CartSyncError {\n email: string;\n error: Error;\n}\n\nexport interface LoginFormProps\n extends HTMLAttributes<HTMLFormElement>,\n TitleProps {\n active?: boolean;\n autoSync?: boolean;\n displayHeadingContent?: boolean;\n onSignInClick?: (email: string) => void;\n onSignOutClick?: () => void;\n onCartSyncError?: (error: CartSyncError) => void;\n onValidationError?: (error: ValidationError) => void;\n slots?: {\n Heading?: SlotProps<{\n authenticated: boolean;\n }>;\n } & TitleProps['slots'];\n}\n\nconst DEBOUNCE_TIME = 1000;\n\nexport const LoginForm: Container<LoginFormProps> = ({\n active = true,\n autoSync = true,\n displayHeadingContent = true,\n displayTitle = true,\n initialData,\n onCartSyncError,\n onSignInClick,\n onSignOutClick,\n onValidationError,\n slots,\n ...props\n}) => {\n const [customer, setCustomer] = useState<Customer | null>(null);\n const [email, setEmail] = useState<string>('');\n const [error, setError] = useState<string>('');\n const [isAuthenticated, setIsAuthenticated] = useState(false);\n const [isAvailable, setIsAvailable] = useState<boolean>(true);\n const [isInitialized, setIsInitialized] = useState<boolean>(false);\n\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const {\n alreadyHaveAccountHint,\n cartSyncError,\n defaultTitle,\n fasterCheckoutHint,\n invalidEmailError,\n missingEmailError,\n signInLabel,\n } = useText({\n alreadyHaveAccountHint: 'Checkout.LoginForm.emailExists.alreadyHaveAccount',\n cartSyncError: 'Checkout.LoginForm.cartSyncError',\n defaultTitle: 'Checkout.LoginForm.title',\n fasterCheckoutHint: 'Checkout.LoginForm.emailExists.forFasterCheckout',\n invalidEmailError: 'Checkout.LoginForm.invalidEmailError',\n missingEmailError: 'Checkout.LoginForm.missingEmailError',\n signInLabel: 'Checkout.LoginForm.emailExists.signInButton',\n });\n\n const setEmailAndCheckAvailability = useCallback(\n (email: string) => {\n if (!validateEmail(email) || email === getCartEmail()) return;\n\n isEmailAvailable(email)\n .then((availability) => {\n setIsAvailable(availability);\n })\n .catch((error) => {\n console.error(error);\n setIsAvailable(true);\n });\n\n if (!autoSync) return;\n\n setGuestEmailOnCart(email).catch((error) => {\n onCartSyncError?.({ email, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, onCartSyncError, cartSyncError]\n );\n\n const handleChange = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value;\n\n setEmail(email);\n setIsAvailable(true);\n setError('');\n\n if (debounceTimer.current) {\n clearTimeout(debounceTimer.current);\n }\n\n debounceTimer.current = setTimeout(() => {\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n debounceTimer.current = null;\n }, DEBOUNCE_TIME);\n },\n [setEmailAndCheckAvailability]\n );\n\n const handleBlur = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const email = target.value.trim();\n const isValid = validateEmail(email);\n\n if (isValid) {\n setError('');\n target.setCustomValidity('');\n\n if (!debounceTimer.current) return;\n\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n setEmailAndCheckAvailability(email);\n notifyValues({ email });\n return;\n }\n\n const type = email === '' ? 'missing' : 'invalid';\n const message =\n type === 'missing' ? missingEmailError : invalidEmailError;\n\n if (onValidationError) {\n onValidationError({ email, message, type });\n return;\n }\n\n setError(message);\n target.setCustomValidity(message);\n },\n [\n invalidEmailError,\n missingEmailError,\n onValidationError,\n setEmailAndCheckAvailability,\n ]\n );\n\n const handleInvalid = useCallback(\n (event: Event) => {\n const target = event.target as HTMLInputElement;\n const validity = target.validity;\n\n const message = validity.valueMissing\n ? missingEmailError\n : invalidEmailError;\n\n if (!onValidationError) {\n setError(message);\n return;\n }\n\n onValidationError({\n email: target.value,\n message,\n type: validity.valueMissing ? 'missing' : 'invalid',\n });\n },\n [missingEmailError, invalidEmailError, onValidationError]\n );\n\n const handleSignIn = useCallback(() => {\n const email = getValue('email') ?? '';\n const isValid = validateEmail(email);\n onSignInClick?.(isValid ? email : '');\n }, [onSignInClick]);\n\n const handleSignOut = useCallback(() => {\n onSignOutClick?.();\n }, [onSignOutClick]);\n\n const handleCheckoutData = useCallback((data: Cart | null) => {\n const prevEmail = getValue('email') ?? '';\n const email = data?.email ?? '';\n\n if (email !== prevEmail) {\n setEmail(email);\n setError('');\n setIsAvailable(true);\n notifyValues({ email });\n }\n }, []);\n\n useEffect(() => {\n if (!active) return;\n\n const onAuthenticated = events.on(\n 'authenticated',\n (authenticated) => {\n setIsAuthenticated(authenticated);\n\n getCustomer()\n .then((customer) => {\n setCustomer(customer);\n })\n .catch(console.error);\n },\n { eager: true }\n );\n\n return () => {\n onAuthenticated?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\n // When component becomes active, restore local state from checkout data\n const checkoutEmail = pastUpdate.email ?? '';\n if (checkoutEmail) {\n setEmail(checkoutEmail);\n }\n handleCheckoutData(pastUpdate);\n return;\n }\n\n const onCheckoutInit = events.on(\n 'checkout/initialized',\n (data) => {\n setIsInitialized(true);\n handleCheckoutData(data);\n },\n { eager: true }\n );\n\n return () => {\n onCheckoutInit?.off();\n };\n }, [active, handleCheckoutData]);\n\n useEffect(() => {\n if (!active) return;\n\n const onCheckoutUpdated = events.on(\n 'checkout/updated',\n handleCheckoutData,\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-login-form-title\" slot={slots?.Title}>\n <h2>{defaultTitle}</h2>\n </Slot>\n );\n }, [displayTitle, slots, defaultTitle]);\n\n const headingContent = useMemo(() => {\n if (!displayHeadingContent) return undefined;\n\n return (\n <Slot\n context={{ authenticated: isAuthenticated }}\n name=\"checkout-login-form-heading-label\"\n slot={slots?.Heading}\n >\n {isAuthenticated ? (\n <SignOut onClick={handleSignOut} />\n ) : (\n <SignIn onClick={handleSignIn} />\n )}\n </Slot>\n );\n }, [\n displayHeadingContent,\n isAuthenticated,\n slots,\n handleSignIn,\n handleSignOut,\n ]);\n\n const hintContent = useMemo(() => {\n if (isAvailable) return '';\n\n return (\n <>\n {alreadyHaveAccountHint}{' '}\n <a href=\"#\" onClick={handleSignIn}>\n {signInLabel}\n </a>{' '}\n {fasterCheckoutHint}\n </>\n );\n }, [\n isAvailable,\n alreadyHaveAccountHint,\n signInLabel,\n fasterCheckoutHint,\n handleSignIn,\n ]);\n\n return (\n <LoginFormComponent\n {...props}\n customer={customer}\n email={email}\n error={error}\n headingContent={headingContent}\n hint={hintContent}\n initialized={isInitialized}\n title={titleContent}\n visible={active}\n onEmailBlur={handleBlur}\n onEmailChange={handleChange}\n onEmailInvalid={handleInvalid}\n />\n );\n};\n"],"names":["validationPatterns","validateEmail","email","Email","value","error","hint","onChange","onBlur","onInvalid","translations","useText","jsx","Field","Input","SignIn","onClick","jsxs","event","LoginFormSkeleton","Skeleton","SkeletonRow","LoginFormComponent","className","customer","headingContent","name","onEmailBlur","onEmailChange","onEmailInvalid","title","props","VComponent","classes","LoginForm","WithConditionals","SignOut","DEBOUNCE_TIME","active","autoSync","displayHeadingContent","displayTitle","initialData","onCartSyncError","onSignInClick","onSignOutClick","onValidationError","slots","setCustomer","useState","setEmail","setError","isAuthenticated","setIsAuthenticated","isAvailable","setIsAvailable","isInitialized","setIsInitialized","debounceTimer","useRef","alreadyHaveAccountHint","cartSyncError","defaultTitle","fasterCheckoutHint","invalidEmailError","missingEmailError","signInLabel","setEmailAndCheckAvailability","useCallback","getCartEmail","isEmailAvailable","availability","setGuestEmailOnCart","handleChange","notifyValues","handleBlur","target","type","message","handleInvalid","validity","handleSignIn","getValue","isValid","handleSignOut","handleCheckoutData","data","prevEmail","useEffect","onAuthenticated","events","authenticated","getCustomer","pastUpdate","getLatestCheckoutUpdate","checkoutEmail","onCheckoutInit","onCheckoutUpdated","titleContent","useMemo","Slot","hintContent","Fragment"],"mappings":"giCAAO,MAAMA,GAAqB,CAChC,MACE,6FACJ,EAEaC,EAAiBC,GACrBF,GAAmB,MAAM,KAAKE,CAAK,ECyB/BC,GAA4C,CAAC,CACxD,MAAAC,EACA,MAAAC,EACA,KAAAC,EACA,SAAAC,EACA,OAAAC,EACA,UAAAC,CACF,IAAM,CACJ,MAAMC,EAAeC,EAAQ,CAC3B,eAAgB,+BAChB,uBAAwB,mCACxB,qBAAsB,gCAAA,CACvB,EAGC,OAAAC,EAACC,GAAM,CAAA,MAAAR,EA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