@dropins/storefront-checkout 2.1.0-alpha1 → 2.1.0-beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,21 @@
1
- import { Cart as CartModel, Customer as CustomerModel } from '../../data/models';
1
+ import { Cart as CartModel, Customer as CustomerModel, ShippingMethod } from '../../data/models';
2
+ import { Filter, Selector } from '../../types/utils';
2
3
  import { Lang } from '@dropins/tools/types/elsie/src/i18n';
3
4
  import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib';
4
5
 
5
6
  export type ConfigProps = {
6
7
  defaults?: {
7
8
  isBillToShipping?: boolean;
9
+ selectedShippingMethod?: Selector<ShippingMethod>;
10
+ };
11
+ shipping?: {
12
+ filterOptions?: Filter<ShippingMethod>;
13
+ };
14
+ features?: {
15
+ b2b?: {
16
+ quotes?: boolean;
17
+ routeLogin?: () => string | void;
18
+ };
8
19
  };
9
20
  langDefinitions?: Lang;
10
21
  models?: {
@@ -1,20 +1,6 @@
1
- /********************************************************************
2
- * ADOBE CONFIDENTIAL
3
- * __________________
4
- *
5
- * Copyright 2024 Adobe
6
- * All Rights Reserved.
7
- *
8
- * NOTICE: All information contained herein is, and remains
9
- * the property of Adobe and its suppliers, if any. The intellectual
10
- * and technical concepts contained herein are proprietary to Adobe
11
- * and its suppliers and are protected by all applicable intellectual
12
- * property laws, including trade secret and copyright laws.
13
- * Dissemination of this information or reproduction of this material
14
- * is strictly forbidden unless prior written permission is obtained
15
- * from Adobe.
16
- *******************************************************************/
17
- export declare const addCheckoutEventListeners: () => ({
1
+ import { ConfigProps } from '..';
2
+
3
+ export declare const addCheckoutEventListeners: (config: ConfigProps | undefined) => ({
18
4
  off(): void;
19
5
  } | undefined)[];
20
6
  //# sourceMappingURL=listeners.d.ts.map
package/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{a as A,c as x,g as G,b as S,i as T,d as k,r as O,s as y}from"./chunks/synchronizeCheckout.js";import{e as M,s as b}from"./chunks/setShippingAddress.js";import{d as s}from"./chunks/fetch-graphql.js";import{D as N,S as Q,f as U,g as R,i as q,j as v,r as z,b as D,c as K,e as L}from"./chunks/fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{A as o}from"./chunks/checkout.js";import{g as w,i as B,s as I}from"./chunks/setGuestEmailOnCart.js";import{s as V}from"./chunks/setBillingAddress.js";import{s as J}from"./chunks/setPaymentMethod.js";import{s as X,s as Z}from"./chunks/setShippingMethods.js";import"./fragments.js";import"./chunks/transform-shipping-methods.js";import"./chunks/values.js";import"./chunks/transform-shipping-estimate.js";import"./chunks/guards.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const r=t=>t?t.filter(e=>!!e).map(e=>({id:e.agreement_id,name:e.name,mode:o[e.mode],text:e.checkbox_text,content:{value:e.content,html:e.is_html,height:e.content_height??null}})):[],a=`
3
+ import{a as A,c as x,g as G,b as S,i as T,d as k,r as O,s as y}from"./chunks/synchronizeCheckout.js";import{e as M,s as b}from"./chunks/setShippingAddress.js";import{d as s}from"./chunks/fetch-graphql.js";import{D as N,S as Q,f as U,g as R,i as q,j as v,r as z,b as D,c as K,e as L}from"./chunks/fetch-graphql.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{A as o}from"./chunks/checkout.js";import{g as w,i as B,s as I}from"./chunks/setGuestEmailOnCart.js";import{s as V}from"./chunks/setBillingAddress.js";import{s as J}from"./chunks/setPaymentMethod.js";import{s as X,s as Z}from"./chunks/setShippingMethods.js";import"./fragments.js";import"./chunks/transform-shipping-methods.js";import"./chunks/transform-shipping-estimate.js";import"./chunks/values.js";import"./chunks/guards.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";const r=t=>t?t.filter(e=>!!e).map(e=>({id:e.agreement_id,name:e.name,mode:o[e.mode],text:e.checkbox_text,content:{value:e.content,html:e.is_html,height:e.content_height??null}})):[],a=`
4
4
  query GET_CHECKOUT_AGREEMENTS {
5
5
  checkoutAgreements {
6
6
  agreement_id
@@ -1,6 +1,6 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import"@dropins/tools/lib.js";import{events as y}from"@dropins/tools/event-bus.js";import{signal as D,computed as m}from"@dropins/tools/signals.js";import{FetchGraphQL as S}from"@dropins/tools/fetch-graphql.js";const U={authenticated:!1,cartId:null,config:null,initialized:!1,quoteId:null},G=new Proxy(U,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class I extends Error{constructor(t){super(t),this.name="InvalidInput"}}class a extends I{constructor(t){super(`${t} is required.`)}}class V extends a{constructor(){super("Cart ID")}}class B extends I{constructor(){super("Either Cart ID or Quote ID is required.")}}class $ extends Error{constructor(){super("User is not authenticated")}}class z extends a{constructor(){super("Negotiable Quote ID")}}class Y extends a{constructor(){super("Email")}}class J extends a{constructor(){super("Payment method code")}}class K extends a{constructor(){super("Shipping address")}}class W extends a{constructor(){super("Shipping method")}}class Z extends a{constructor(){super("Billing address")}}class ee extends a{constructor(){super("Country Code")}}var u=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(u||{}),A=(e=>(e.Updates="updates",e.Default="default",e.ShippingEstimate="shippingEstimate",e))(A||{});const d=new Map,g=new Map,c=D(new Set),E=new Map;E.set("updates",e=>{y.emit("checkout/updated",e)});async function q(e){g.set(e,!0);const t=d.get(e);let s;for(;t.length>0;){const i=t.shift();try{const n=await i.requestFn();i.resolve(n),s=n}catch(n){i.reject(n)}}g.set(e,!1);const r=new Set(c.value);r.delete(e),c.value=r;const o=E.get(e);o&&s&&o(s)}function X(e,t="default"){d.has(t)||d.set(t,[]);const s=d.get(t),r=new Promise((i,n)=>{s.push({requestFn:e,resolve:i,reject:n})}),o=new Set(c.value);return o.add(t),c.value=o,g.get(t)||q(t),r}const te=m(()=>c.value.has("updates")),se=m(()=>c.value.has("shippingEstimate")),v=["sender_email","recipient_email"];function T(e){return e.filter(t=>!t.path||!v.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}function L(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}async function M(e){const{defaultValueOnFail:t,options:s,path:r,query:o,queueName:i,transformer:n,type:p}=e;try{const l=async()=>{const{data:N,errors:_}=await P(o,{method:p==="query"?"GET":"POST",cache:p==="query"?"no-cache":void 0,...s});if(_){const C=T(_);if(C.length>0)throw new w(C)}let h=L(N,r);if(h===void 0)throw new Error(`No data found at path: ${r}`);return n?n(h):h};return p==="mutation"?await X(l,i):await l()}catch(l){if(t!==void 0)return t;throw l}}const x=`
3
+ import"@dropins/tools/lib.js";import{events as y}from"@dropins/tools/event-bus.js";import{signal as D,computed as m}from"@dropins/tools/signals.js";import{FetchGraphQL as S}from"@dropins/tools/fetch-graphql.js";const U={authenticated:!1,cartId:null,config:null,initialized:!1,quoteId:null},G=new Proxy(U,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});var u=(e=>(e.EXCLUDING_TAX="EXCLUDING_TAX",e.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",e.INCLUDING_TAX="INCLUDING_TAX",e))(u||{}),w=(e=>(e.Updates="updates",e.Default="default",e.ShippingEstimate="shippingEstimate",e))(w||{});const d=new Map,g=new Map,c=D(new Set),I=new Map;I.set("updates",e=>{y.emit("checkout/updated",e)});async function A(e){g.set(e,!0);const t=d.get(e);let s;for(;t.length>0;){const i=t.shift();try{const n=await i.requestFn();i.resolve(n),s=n}catch(n){i.reject(n)}}g.set(e,!1);const r=new Set(c.value);r.delete(e),c.value=r;const o=I.get(e);o&&s&&o(s)}function q(e,t="default"){d.has(t)||d.set(t,[]);const s=d.get(t),r=new Promise((i,n)=>{s.push({requestFn:e,resolve:i,reject:n})}),o=new Set(c.value);return o.add(t),c.value=o,g.get(t)||A(t),r}const V=m(()=>c.value.has("updates")),B=m(()=>c.value.has("shippingEstimate")),X=["sender_email","recipient_email"];function v(e){return e.filter(t=>!t.path||!X.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}class T extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class E extends Error{constructor(t){super(t),this.name="InvalidInput"}}class a extends E{constructor(t){super(`${t} is required.`)}}class $ extends a{constructor(){super("Cart ID")}}class z extends E{constructor(){super("Either Cart ID or Quote ID is required.")}}class Y extends Error{constructor(){super("User is not authenticated")}}class J extends a{constructor(){super("Negotiable Quote ID")}}class K extends a{constructor(){super("Email")}}class W extends a{constructor(){super("Payment method code")}}class Z extends a{constructor(){super("Shipping address")}}class ee extends a{constructor(){super("Shipping method")}}class te extends a{constructor(){super("Billing address")}}class se extends a{constructor(){super("Country Code")}}function L(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}async function M(e){const{defaultValueOnFail:t,options:s,path:r,query:o,queueName:i,transformer:n,type:p}=e;try{const l=async()=>{const{data:N,errors:_}=await P(o,{method:p==="query"?"GET":"POST",cache:p==="query"?"no-cache":void 0,...s});if(_){const C=v(_);if(C.length>0)throw new T(C)}let h=L(N,r);if(h===void 0)throw new Error(`No data found at path: ${r}`);return n?n(h):h};return p==="mutation"?await q(l,i):await l()}catch(l){if(t!==void 0)return t;throw l}}const x=`
4
4
  query getStoreConfig {
5
5
  storeConfig {
6
6
  default_country
@@ -10,5 +10,5 @@ import"@dropins/tools/lib.js";import{events as y}from"@dropins/tools/event-bus.j
10
10
  shopping_cart_display_shipping
11
11
  }
12
12
  }
13
- `,F="US",f={defaultCountry:F,agreementsEnabled:!0,shoppingCartDisplaySetting:{shipping:u.EXCLUDING_TAX}},re=async()=>await M({defaultValueOnFail:f,options:{method:"GET",cache:"no-cache"},path:"storeConfig",query:x,transformer:b,type:"query"}),ne=()=>G.config;function Q(e){switch(e){case 1:return u.EXCLUDING_TAX;case 2:return u.INCLUDING_TAX;case 3:return u.INCLUDING_EXCLUDING_TAX;default:return u.EXCLUDING_TAX}}function b(e){if(!e)return f;const{default_country:t,is_checkout_agreements_enabled:s,shopping_cart_display_shipping:r}=e;return{defaultCountry:t||f.defaultCountry,agreementsEnabled:s,shoppingCartDisplaySetting:{shipping:Q(r)}}}const{setEndpoint:ae,setFetchGraphQlHeader:oe,removeFetchGraphQlHeader:ie,setFetchGraphQlHeaders:ue,fetchGraphQl:P,getConfig:ce}=new S().getMethods();export{F as D,I,W as M,A as Q,f as S,u as T,$ as U,se as a,ae as b,oe as c,M as d,ue as e,P as f,ce as g,te as h,re as i,ne as j,J as k,Y as l,V as m,ee as n,K as o,Z as p,B as q,ie as r,G as s,z as t};
13
+ `,F="US",f={defaultCountry:F,agreementsEnabled:!0,shoppingCartDisplaySetting:{shipping:u.EXCLUDING_TAX}},re=async()=>await M({defaultValueOnFail:f,options:{method:"GET",cache:"no-cache"},path:"storeConfig",query:x,transformer:b,type:"query"}),ne=()=>G.config;function Q(e){switch(e){case 1:return u.EXCLUDING_TAX;case 2:return u.INCLUDING_TAX;case 3:return u.INCLUDING_EXCLUDING_TAX;default:return u.EXCLUDING_TAX}}function b(e){if(!e)return f;const{default_country:t,is_checkout_agreements_enabled:s,shopping_cart_display_shipping:r}=e;return{defaultCountry:t||f.defaultCountry,agreementsEnabled:s,shoppingCartDisplaySetting:{shipping:Q(r)}}}const{setEndpoint:ae,setFetchGraphQlHeader:oe,removeFetchGraphQlHeader:ie,setFetchGraphQlHeaders:ue,fetchGraphQl:P,getConfig:ce}=new S().getMethods();export{F as D,E as I,ee as M,w as Q,f as S,u as T,Y as U,B as a,ae as b,oe as c,M as d,ue as e,P as f,ce as g,V as h,re as i,ne as j,W as k,K as l,$ as m,se as n,Z as o,te as p,z as q,ie as r,G as s,J as t};
14
14
  //# sourceMappingURL=fetch-graphql.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-graphql.js","sources":["/@dropins/storefront-checkout/src/lib/state.ts","/@dropins/storefront-checkout/src/lib/errors/customErrors.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/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"],"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 config: StoreConfig | null;\n initialized: boolean;\n quoteId?: string | null;\n};\n\nconst _state: State = (() => ({\n authenticated: false,\n cartId: null,\n config: null,\n initialized: false,\n quoteId: 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 function isQuoteCheckout(): boolean {\n return state.quoteId !== null;\n}\n\nexport function isCartCheckout(): boolean {\n return state.cartId !== null;\n}\n","/********************************************************************\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 { 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 InvalidInput extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidInput';\n }\n}\n\nexport class MissingArgument extends InvalidInput {\n constructor(argumentName: string) {\n super(`${argumentName} is required.`);\n }\n}\n\nexport class MissingCart extends MissingArgument {\n constructor() {\n super('Cart ID');\n }\n}\n\nexport class MissingCartAndQuote extends InvalidInput {\n constructor() {\n super('Either Cart ID or Quote ID is required.');\n }\n}\n\nexport class Unauthenticated extends Error {\n constructor() {\n super('User is not authenticated');\n }\n}\n\nexport class MissingNegotiableQuoteId extends MissingArgument {\n constructor() {\n super('Negotiable Quote ID');\n }\n}\n\nexport class MissingEmail extends MissingArgument {\n constructor() {\n super('Email');\n }\n}\n\nexport class MissingPaymentMethod extends MissingArgument {\n constructor() {\n super('Payment method code');\n }\n}\n\nexport class MissingShippingAddress extends MissingArgument {\n constructor() {\n super('Shipping address');\n }\n}\n\nexport class MissingShippingMethod extends MissingArgument {\n constructor() {\n super('Shipping method');\n }\n}\n\nexport class MissingBillingAddress extends MissingArgument {\n constructor() {\n super('Billing address');\n }\n}\n\nexport class MissingCountry extends MissingArgument {\n constructor() {\n super('Country Code');\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 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, NegotiableQuote } 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 Updates = 'updates',\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(\n QueueName.Updates,\n (latestResult: Cart | NegotiableQuote) => {\n events.emit('checkout/updated', latestResult);\n }\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 hasPendingUpdates: ReadonlySignal<boolean> = computed(() => {\n return pendingRequests.value.has(QueueName.Updates);\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 { fetchGraphQl, FetchOptions, FetchQueryError } from '@/checkout/api';\nimport { enqueueRequest, QueueName } from '@/checkout/lib/enqueueRequest';\nimport { filterControlledErrors } from '@/checkout/lib/filterControlledErrors';\nimport { FetchError } from '@/checkout/lib/errors';\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 });\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, state } 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\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\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"],"names":["_state","state","target","key","value","FetchError","reasons","e","InvalidInput","message","MissingArgument","argumentName","MissingCart","MissingCartAndQuote","Unauthenticated","MissingNegotiableQuoteId","MissingEmail","MissingPaymentMethod","MissingShippingAddress","MissingShippingMethod","MissingBillingAddress","MissingCountry","TaxDisplay","QueueName","queues","processing","pendingRequests","signal","onQueueCompleted","latestResult","events","processQueue","type","queue","latestSuccessResult","request","result","error","pendingSet","handler","enqueueRequest","requestFn","name","promise","resolve","reject","hasPendingUpdates","computed","hasPendingShippingEstimate","controlledErrorProps","filterControlledErrors","errors","controlledErrorProp","_a","getValueAtPath","obj","path","acc","part","dispatchApiCall","params","defaultValueOnFail","options","query","queueName","transformer","processApiCall","data","fetchGraphQl","uncontrolledErrors","getStoreConfigQuery","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","transformStoreConfig","getStoreConfigCache","transformTaxDisplay","default_country","is_checkout_agreements_enabled","shopping_cart_display_shipping","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL"],"mappings":"m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"}
1
+ {"version":3,"file":"fetch-graphql.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/errors/customErrors.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"],"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 config: StoreConfig | null;\n initialized: boolean;\n quoteId?: string | null;\n};\n\nconst _state: State = (() => ({\n authenticated: false,\n cartId: null,\n config: null,\n initialized: false,\n quoteId: 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 function isQuoteCheckout(): boolean {\n return state.quoteId !== null;\n}\n\nexport function isCartCheckout(): boolean {\n return state.cartId !== 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\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, NegotiableQuote } 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 Updates = 'updates',\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(\n QueueName.Updates,\n (latestResult: Cart | NegotiableQuote) => {\n events.emit('checkout/updated', latestResult);\n }\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 hasPendingUpdates: ReadonlySignal<boolean> = computed(() => {\n return pendingRequests.value.has(QueueName.Updates);\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 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 { 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 InvalidInput extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'InvalidInput';\n }\n}\n\nexport class MissingArgument extends InvalidInput {\n constructor(argumentName: string) {\n super(`${argumentName} is required.`);\n }\n}\n\nexport class MissingCart extends MissingArgument {\n constructor() {\n super('Cart ID');\n }\n}\n\nexport class MissingCartAndQuote extends InvalidInput {\n constructor() {\n super('Either Cart ID or Quote ID is required.');\n }\n}\n\nexport class Unauthenticated extends Error {\n constructor() {\n super('User is not authenticated');\n }\n}\n\nexport class MissingNegotiableQuoteId extends MissingArgument {\n constructor() {\n super('Negotiable Quote ID');\n }\n}\n\nexport class MissingEmail extends MissingArgument {\n constructor() {\n super('Email');\n }\n}\n\nexport class MissingPaymentMethod extends MissingArgument {\n constructor() {\n super('Payment method code');\n }\n}\n\nexport class MissingShippingAddress extends MissingArgument {\n constructor() {\n super('Shipping address');\n }\n}\n\nexport class MissingShippingMethod extends MissingArgument {\n constructor() {\n super('Shipping method');\n }\n}\n\nexport class MissingBillingAddress extends MissingArgument {\n constructor() {\n super('Billing address');\n }\n}\n\nexport class MissingCountry extends MissingArgument {\n constructor() {\n super('Country Code');\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, FetchOptions, FetchQueryError } from '@/checkout/api';\nimport { enqueueRequest, QueueName } from '@/checkout/lib/enqueueRequest';\nimport { filterControlledErrors } from '@/checkout/lib/filterControlledErrors';\nimport { FetchError } from '@/checkout/lib/errors';\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 });\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, state } 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\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\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"],"names":["_state","state","target","key","value","TaxDisplay","QueueName","queues","processing","pendingRequests","signal","onQueueCompleted","latestResult","events","processQueue","type","queue","latestSuccessResult","request","result","error","pendingSet","handler","enqueueRequest","requestFn","name","promise","resolve","reject","hasPendingUpdates","computed","hasPendingShippingEstimate","controlledErrorProps","filterControlledErrors","errors","controlledErrorProp","_a","FetchError","reasons","e","InvalidInput","message","MissingArgument","argumentName","MissingCart","MissingCartAndQuote","Unauthenticated","MissingNegotiableQuoteId","MissingEmail","MissingPaymentMethod","MissingShippingAddress","MissingShippingMethod","MissingBillingAddress","MissingCountry","getValueAtPath","obj","path","acc","part","dispatchApiCall","params","defaultValueOnFail","options","query","queueName","transformer","processApiCall","data","fetchGraphQl","uncontrolledErrors","getStoreConfigQuery","DEFAULT_COUNTRY","STORE_CONFIG_DEFAULTS","getStoreConfig","transformStoreConfig","getStoreConfigCache","transformTaxDisplay","default_country","is_checkout_agreements_enabled","shopping_cart_display_shipping","setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getConfig","FetchGraphQL"],"mappings":"mNA2BA,MAAMA,EAAwB,CA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
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import{events as S}from"@dropins/tools/event-bus.js";import{g as T}from"./values.js";import{t as v,a as f}from"./transform-shipping-estimate.js";import{a as U}from"./transform-shipping-methods.js";import{e as G,c as D,d as F}from"./guards.js";import{c as R,t as x,e as H}from"./synchronizeCheckout.js";import{CHECKOUT_DATA_FRAGMENT as q,NEGOTIABLE_QUOTE_FRAGMENT as E}from"../fragments.js";const V=`
3
+ import{s as o,m as G,n as D,d as q,Q as E,I as l,o as Q}from"./fetch-graphql.js";import"@dropins/tools/lib.js";import{t as F,a as O}from"./transform-shipping-estimate.js";import{a as R}from"./transform-shipping-methods.js";import{events as $}from"@dropins/tools/event-bus.js";import{g as N}from"./values.js";import{c as w,t as x,e as H}from"./synchronizeCheckout.js";import{e as V,c as K,d as L}from"./guards.js";import{CHECKOUT_DATA_FRAGMENT as y,NEGOTIABLE_QUOTE_FRAGMENT as B}from"../fragments.js";const k=`
4
4
  mutation estimateShippingMethods(
5
5
  $cartId: String!
6
6
  $address: EstimateAddressInput!
@@ -26,7 +26,7 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
26
26
  error_message
27
27
  }
28
28
  }
29
- `,ne=async e=>{var h,l,A,_;const t=o.cartId,s=((h=e==null?void 0:e.criteria)==null?void 0:h.country_code)??((l=o.config)==null?void 0:l.defaultCountry);if(!t)throw new B;if(!s)throw new b;const{region_id:i,region_name:a,zip:p}=(e==null?void 0:e.criteria)??{},r=i||a?{region_id:typeof i=="string"?parseInt(i,10):i,region_code:a}:void 0,g={country_code:s,...p&&{postcode:p},...r&&{region:{...r.region_id&&{region_id:r.region_id},...r.region_code&&{region_code:r.region_code}}}},u={country_id:s,region:(A=g.region)==null?void 0:A.region_code,region_id:(_=g.region)==null?void 0:_.region_id,postcode:p},Q=f(u);return M({options:{variables:{cartId:t,address:g}},path:"estimateShippingMethods",query:V,queueName:$.ShippingEstimate,transformer:U,type:"mutation"}).then(n=>{const N=n.length>0,w=f(u);let m=null;if(N){const d=T("selectedShippingMethod"),y=n.find(I=>I.code===(d==null?void 0:d.code)&&I.carrier.code===(d==null?void 0:d.carrier.code));m=v(y??n[0])}return S.emit("shipping/estimate",{address:w,availableShippingMethods:n,shippingMethod:m,success:!0}),n}).catch(n=>{throw S.emit("shipping/estimate",{address:Q,shippingMethod:null,availableShippingMethods:[],success:!1}),n})},K=`
29
+ `,ae=async e=>{var _,m,I,S;const s=o.cartId,t=((_=e==null?void 0:e.criteria)==null?void 0:_.country_code)??((m=o.config)==null?void 0:m.defaultCountry);if(!s)throw new G;if(!t)throw new D;const{region_id:i,region_name:a,zip:p}=(e==null?void 0:e.criteria)??{},n=i||a?{region_id:typeof i=="string"?parseInt(i,10):i,region_code:a}:void 0,h={country_code:t,...p&&{postcode:p},...n&&{region:{...n.region_id&&{region_id:n.region_id},...n.region_code&&{region_code:n.region_code}}}},A={country_id:t,region:(I=h.region)==null?void 0:I.region_code,region_id:(S=h.region)==null?void 0:S.region_id,postcode:p},b=O(A);return q({options:{variables:{cartId:s,address:h}},path:"estimateShippingMethods",query:k,queueName:E.ShippingEstimate,transformer:R,type:"mutation"}).then(r=>{const{defaults:c,shipping:u}=w.getConfig(),f=u!=null&&u.filterOptions?r.filter(u.filterOptions):r,v=f.length>0,U=O(A);let M=null;if(v){const d=N("selectedShippingMethod");let g=r.find(C=>C.code===(d==null?void 0:d.code)&&C.carrier.code===(d==null?void 0:d.carrier.code));!g&&(c!=null&&c.selectedShippingMethod)&&(g=c.selectedShippingMethod(r)??void 0),g||(g=r[0]),M=F(g)}return $.emit("shipping/estimate",{address:U,availableShippingMethods:r,shippingMethod:M,success:!0}),f}).catch(r=>{throw $.emit("shipping/estimate",{address:b,shippingMethod:null,availableShippingMethods:[],success:!1}),r})},z=`
30
30
  mutation setShippingAddressOnCartAndUseAsBilling(
31
31
  $cartId: String!
32
32
  $shippingAddress: ShippingAddressInput!
@@ -48,8 +48,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
48
48
  }
49
49
  }
50
50
 
51
- ${q}
52
- `,L=`
51
+ ${y}
52
+ `,P=`
53
53
  mutation setShippingAddressOnCart(
54
54
  $cartId: String!
55
55
  $shippingAddress: ShippingAddressInput!
@@ -63,8 +63,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
63
63
  }
64
64
  }
65
65
 
66
- ${q}
67
- `,k=`
66
+ ${y}
67
+ `,j=`
68
68
  mutation setShippingAddressOnQuote(
69
69
  $quoteId: ID!
70
70
  $shippingAddress: NegotiableQuoteShippingAddressInput!
@@ -78,8 +78,8 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
78
78
  }
79
79
  }
80
80
 
81
- ${E}
82
- `,z=`
81
+ ${B}
82
+ `,J=`
83
83
  mutation setShippingAddressOnQuoteAndUseAsBilling(
84
84
  $quoteId: ID!
85
85
  $shippingAddress: NegotiableQuoteShippingAddressInput!
@@ -104,6 +104,6 @@ import{s as o,m as B,n as b,d as M,Q as $,I as c,o as O}from"./fetch-graphql.js"
104
104
  }
105
105
  }
106
106
 
107
- ${E}
108
- `,P=({address:e,customerAddressId:t,customerAddressUid:s,pickupLocationCode:i})=>{if(!t&&s)throw new c("customerAddressUid is not supported");if(!t&&!i&&!e)throw new O},j=({address:e,customerAddressId:t,customerAddressUid:s,pickupLocationCode:i})=>{if(i)throw new c("pickup location is not supported in quotes");if(!s&&t)throw new c("customerAddressId is not supported in quotes");if(!s&&!e)throw new O},J=e=>{const t=!!o.cartId,s=!!o.quoteId;t?P(e):s&&j(e)},C=(e,t,s,i,a,p)=>async r=>await M({type:"mutation",query:s,options:{variables:{[t]:e,shippingAddress:a(r)}},path:p,queueName:$.Updates,transformer:i}),oe=async e=>{G(),J(e);const{defaults:t}=R.getConfig(),s=T("isBillToShipping")??(t==null?void 0:t.isBillToShipping);return await(!!o.cartId?C(o.cartId,"cartId",s?K:L,x,D,s?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):C(o.quoteId,"quoteId",s?z:k,H,F,s?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)};export{ne as e,oe as s};
107
+ ${B}
108
+ `,W=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(!s&&t)throw new l("customerAddressUid is not supported");if(!s&&!i&&!e)throw new Q},X=({address:e,customerAddressId:s,customerAddressUid:t,pickupLocationCode:i})=>{if(i)throw new l("pickup location is not supported in quotes");if(!t&&s)throw new l("customerAddressId is not supported in quotes");if(!t&&!e)throw new Q},Y=e=>{const s=!!o.cartId,t=!!o.quoteId;s?W(e):t&&X(e)},T=(e,s,t,i,a,p)=>async n=>await q({type:"mutation",query:t,options:{variables:{[s]:e,shippingAddress:a(n)}},path:p,queueName:E.Updates,transformer:i}),pe=async e=>{V(),Y(e);const{defaults:s}=w.getConfig(),t=N("isBillToShipping")??(s==null?void 0:s.isBillToShipping);return await(!!o.cartId?T(o.cartId,"cartId",t?z:P,x,K,t?"setBillingAddressOnCart.cart":"setShippingAddressesOnCart.cart"):T(o.quoteId,"quoteId",t?J:j,H,L,t?"setNegotiableQuoteBillingAddress.quote":"setNegotiableQuoteShippingAddress.quote"))(e)};export{ae as e,pe as s};
109
109
  //# sourceMappingURL=setShippingAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"setShippingAddress.js","sources":["/@dropins/storefront-checkout/src/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.ts","/@dropins/storefront-checkout/src/api/estimateShippingMethods/estimateShippingMethods.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/setShippingAddress.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\nexport const estimateShippingMethodsMutation = /* GraphQL */ `\n mutation estimateShippingMethods(\n $cartId: String!\n $address: EstimateAddressInput!\n ) {\n estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {\n carrier_title\n carrier_code\n method_title\n method_code\n available\n amount {\n currency\n value\n }\n price_excl_tax {\n currency\n value\n }\n price_incl_tax {\n currency\n value\n }\n error_message\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 { MissingCart, MissingCountry } from '@/checkout/lib/errors';\nimport { estimateShippingMethodsMutation } from '@/checkout/api/estimateShippingMethods/graphql';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport {\n transformShippingEstimatePartialAddress,\n transformShippingEstimateShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName, state } from '@/checkout/lib';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface ShippingEstimationCriteria {\n country_code: string;\n region_name?: string;\n region_id?: string | number;\n zip?: string;\n}\n\nexport type EstimateShippingInput = {\n criteria: ShippingEstimationCriteria;\n};\n\nexport const estimateShippingMethods = async (\n input?: EstimateShippingInput\n): Promise<ShippingMethod[] | undefined> => {\n const cartId = state.cartId;\n const countryCode =\n input?.criteria?.country_code ?? state.config?.defaultCountry;\n\n if (!cartId) throw new MissingCart();\n if (!countryCode) throw new MissingCountry();\n\n const { region_id, region_name, zip } = input?.criteria ?? {};\n\n // Process region information\n const region =\n region_id || region_name\n ? {\n region_id:\n typeof region_id === 'string' ? parseInt(region_id, 10) : region_id,\n region_code: region_name,\n }\n : undefined;\n\n // Build address for API call\n const address = {\n country_code: countryCode,\n ...(zip && { postcode: zip }),\n ...(region && {\n region: {\n ...(region.region_id && { region_id: region.region_id }),\n ...(region.region_code && { region_code: region.region_code }),\n },\n }),\n };\n\n // Create address data for transformation\n const estimateShippingAddressData = {\n country_id: countryCode,\n region: address.region?.region_code,\n region_id: address.region?.region_id,\n postcode: zip,\n };\n\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n return dispatchApiCall({\n options: { variables: { cartId, address } },\n path: 'estimateShippingMethods',\n query: estimateShippingMethodsMutation,\n queueName: QueueName.ShippingEstimate,\n transformer: transformShippingMethods,\n type: 'mutation',\n })\n .then((estimation) => {\n const hasAvailableOptions = estimation.length > 0;\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n let shippingMethod = null;\n\n if (hasAvailableOptions) {\n const userSelection = getValue('selectedShippingMethod');\n\n const selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n shippingMethod = transformShippingEstimateShippingMethod(\n selection ?? estimation[0]\n );\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return estimation;\n })\n .catch((error) => {\n events.emit('shipping/estimate', {\n address: partialAddress,\n shippingMethod: null,\n availableShippingMethods: [],\n success: false,\n });\n\n throw error;\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 setShippingAddressOnCartAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnCartAndUseAsBilling(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n id\n }\n }\n\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartMutation = /* GraphQL */ `\n mutation setShippingAddressOnCart(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuote(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuoteAndUseAsBilling(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n uid\n }\n }\n\n setNegotiableQuoteBillingAddress(\n input: {\n quote_uid: $quoteId\n billing_address: { same_as_shipping: true }\n }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_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 { config } from '@/checkout/api';\nimport {\n setShippingAddressOnCartAndUseAsBillingMutation,\n setShippingAddressOnCartMutation,\n setShippingAddressOnQuoteAndUseAsBillingMutation,\n setShippingAddressOnQuoteMutation,\n} from '@/checkout/api/setShippingAddress/graphql';\nimport { ShippingAddressInput as ShippingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingAddressInputModelToCartInput,\n transformShippingAddressInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName } from '@/checkout/lib';\nimport { InvalidInput, MissingShippingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!customerAddressId && !pickupLocationCode && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (pickupLocationCode) {\n throw new InvalidInput('pickup location is not supported in quotes');\n }\n\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported in quotes');\n }\n\n if (!customerAddressUid && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: ShippingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nconst createShippingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: ShippingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: ShippingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nexport const setShippingAddress = async (input: ShippingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const { defaults } = config.getConfig();\n\n const isBillToShipping =\n getValue('isBillToShipping') ?? defaults?.isBillToShipping;\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingAddressSetter(\n state.cartId!,\n 'cartId',\n isBillToShipping\n ? setShippingAddressOnCartAndUseAsBillingMutation\n : setShippingAddressOnCartMutation,\n transformCart,\n transformShippingAddressInputModelToCartInput,\n isBillToShipping\n ? 'setBillingAddressOnCart.cart'\n : 'setShippingAddressesOnCart.cart'\n )\n : createShippingAddressSetter(\n state.quoteId!,\n 'quoteId',\n isBillToShipping\n ? setShippingAddressOnQuoteAndUseAsBillingMutation\n : setShippingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformShippingAddressInputModelToQuoteInput,\n isBillToShipping\n ? 'setNegotiableQuoteBillingAddress.quote'\n : 'setNegotiableQuoteShippingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["estimateShippingMethodsMutation","estimateShippingMethods","input","cartId","state","countryCode","_a","_b","MissingCart","MissingCountry","region_id","region_name","zip","region","address","estimateShippingAddressData","_c","_d","partialAddress","transformShippingEstimatePartialAddress","dispatchApiCall","QueueName","transformShippingMethods","estimation","hasAvailableOptions","shippingMethod","userSelection","getValue","selection","method","transformShippingEstimateShippingMethod","events","error","setShippingAddressOnCartAndUseAsBillingMutation","CHECKOUT_DATA_FRAGMENT","setShippingAddressOnCartMutation","setShippingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","setShippingAddressOnQuoteAndUseAsBillingMutation","ensureIsValidCartInput","customerAddressId","customerAddressUid","pickupLocationCode","InvalidInput","MissingShippingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","isQuote","createShippingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","setShippingAddress","ensureHasCartOrQuoteId","defaults","config","isBillToShipping","transformCart","transformShippingAddressInputModelToCartInput","transformNegotiableQuote","transformShippingAddressInputModelToQuoteInput"],"mappings":"qfAiBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECsBhDC,GAA0B,MACrCC,GAC0C,aAC1C,MAAMC,EAASC,EAAM,OACfC,IACJC,EAAAJ,GAAA,YAAAA,EAAO,WAAP,YAAAI,EAAiB,iBAAgBC,EAAAH,EAAM,SAAN,YAAAG,EAAc,gBAEjD,GAAI,CAACJ,EAAc,MAAA,IAA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AI8B,CAEd,EAEME,EAAsB5C,GAAqC,CACzD,MAAA6C,EAAS,EAAQ3C,EAAM,OACvB4C,EAAU,EAAQ5C,EAAM,QAE1B2C,EACFR,EAAuBrC,CAAK,EACnB8C,GACTH,EAAwB3C,CAAK,CAEjC,EAEM+C,EAA8B,CAClCC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEO,MACLrD,GAEO,MAAMkB,EAAgB,CAC3B,KAAM,WACN,MAAOgC,EACP,QAAS,CACP,UAAW,CACT,CAACD,CAAS,EAAGD,EACb,gBAAiBI,EAAepD,CAAK,CAAA,CAEzC,EACA,KAAAqD,EACA,UAAWlC,EAAU,QACrB,YAAAgC,CAAA,CACD,EAIQG,GAAqB,MAAOtD,GAAqC,CACrDuD,EAAA,EACvBX,EAAmB5C,CAAK,EAExB,KAAM,CAAE,SAAAwD,CAAA,EAAaC,EAAO,UAAU,EAEhCC,EACJjC,EAAS,kBAAkB,IAAK+B,GAAA,YAAAA,EAAU,kBA8BrC,OAAA,MA5BQ,EAAQtD,EAAM,OAGzB6C,EACE7C,EAAM,OACN,SACAwD,EACI3B,EACAE,EACJ0B,EACAC,EACAF,EACI,+BACA,iCAAA,EAENX,EACE7C,EAAM,QACN,UACAwD,EACItB,EACAF,EACJ2B,EACAC,EACAJ,EACI,yCACA,yCACN,GAEgB1D,CAAK,CAC3B"}
1
+ {"version":3,"file":"setShippingAddress.js","sources":["/@dropins/storefront-checkout/src/api/estimateShippingMethods/graphql/estimateShippingMethods.graphql.ts","/@dropins/storefront-checkout/src/api/estimateShippingMethods/estimateShippingMethods.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnCartMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuote.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/graphql/setShippingAddressOnQuoteAndUseAsBillingMutation.graphql.ts","/@dropins/storefront-checkout/src/api/setShippingAddress/setShippingAddress.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\nexport const estimateShippingMethodsMutation = /* GraphQL */ `\n mutation estimateShippingMethods(\n $cartId: String!\n $address: EstimateAddressInput!\n ) {\n estimateShippingMethods(input: { cart_id: $cartId, address: $address }) {\n carrier_title\n carrier_code\n method_title\n method_code\n available\n amount {\n currency\n value\n }\n price_excl_tax {\n currency\n value\n }\n price_incl_tax {\n currency\n value\n }\n error_message\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 { config } from '@/checkout/api';\nimport { estimateShippingMethodsMutation } from '@/checkout/api/estimateShippingMethods/graphql';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport {\n transformShippingEstimatePartialAddress,\n transformShippingEstimateShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName, state } from '@/checkout/lib';\nimport { MissingCart, MissingCountry } from '@/checkout/lib/errors';\nimport { events } from '@adobe-commerce/event-bus';\n\nexport interface ShippingEstimationCriteria {\n country_code: string;\n region_name?: string;\n region_id?: string | number;\n zip?: string;\n}\n\nexport type EstimateShippingInput = {\n criteria: ShippingEstimationCriteria;\n};\n\nexport const estimateShippingMethods = async (\n input?: EstimateShippingInput\n): Promise<ShippingMethod[] | undefined> => {\n const cartId = state.cartId;\n const countryCode =\n input?.criteria?.country_code ?? state.config?.defaultCountry;\n\n if (!cartId) throw new MissingCart();\n if (!countryCode) throw new MissingCountry();\n\n const { region_id, region_name, zip } = input?.criteria ?? {};\n\n // Process region information\n const region =\n region_id || region_name\n ? {\n region_id:\n typeof region_id === 'string' ? parseInt(region_id, 10) : region_id,\n region_code: region_name,\n }\n : undefined;\n\n // Build address for API call\n const address = {\n country_code: countryCode,\n ...(zip && { postcode: zip }),\n ...(region && {\n region: {\n ...(region.region_id && { region_id: region.region_id }),\n ...(region.region_code && { region_code: region.region_code }),\n },\n }),\n };\n\n // Create address data for transformation\n const estimateShippingAddressData = {\n country_id: countryCode,\n region: address.region?.region_code,\n region_id: address.region?.region_id,\n postcode: zip,\n };\n\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n return dispatchApiCall({\n options: { variables: { cartId, address } },\n path: 'estimateShippingMethods',\n query: estimateShippingMethodsMutation,\n queueName: QueueName.ShippingEstimate,\n transformer: transformShippingMethods,\n type: 'mutation',\n })\n .then((estimation) => {\n const { defaults, shipping } = config.getConfig();\n\n const filteredOptions = shipping?.filterOptions\n ? estimation.filter(shipping.filterOptions)\n : estimation;\n\n const hasAvailableOptions = filteredOptions.length > 0;\n const partialAddress = transformShippingEstimatePartialAddress(\n estimateShippingAddressData\n );\n\n let shippingMethod = null;\n\n if (hasAvailableOptions) {\n const userSelection = getValue('selectedShippingMethod');\n\n let selection = estimation.find(\n (method) =>\n method.code === userSelection?.code &&\n method.carrier.code === userSelection?.carrier.code\n );\n\n if (!selection && defaults?.selectedShippingMethod) {\n selection = defaults.selectedShippingMethod(estimation) ?? undefined;\n }\n\n if (!selection) {\n selection = estimation[0];\n }\n\n shippingMethod = transformShippingEstimateShippingMethod(selection);\n }\n\n events.emit('shipping/estimate', {\n address: partialAddress,\n availableShippingMethods: estimation,\n shippingMethod,\n success: true,\n });\n\n return filteredOptions;\n })\n .catch((error) => {\n events.emit('shipping/estimate', {\n address: partialAddress,\n shippingMethod: null,\n availableShippingMethods: [],\n success: false,\n });\n\n throw error;\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 setShippingAddressOnCartAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnCartAndUseAsBilling(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n id\n }\n }\n\n setBillingAddressOnCart(\n input: { cart_id: $cartId, billing_address: { same_as_shipping: true } }\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 { CHECKOUT_DATA_FRAGMENT } from '@/checkout/api/graphql/CheckoutDataFragment.graphql';\n\nexport const setShippingAddressOnCartMutation = /* GraphQL */ `\n mutation setShippingAddressOnCart(\n $cartId: String!\n $shippingAddress: ShippingAddressInput!\n ) {\n setShippingAddressesOnCart(\n input: { cart_id: $cartId, shipping_addresses: [$shippingAddress] }\n ) {\n cart {\n ...CHECKOUT_DATA_FRAGMENT\n }\n }\n }\n\n ${CHECKOUT_DATA_FRAGMENT}\n`;\n","/********************************************************************\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuote(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const setShippingAddressOnQuoteAndUseAsBillingMutation = /* GraphQL */ `\n mutation setShippingAddressOnQuoteAndUseAsBilling(\n $quoteId: ID!\n $shippingAddress: NegotiableQuoteShippingAddressInput!\n ) {\n setNegotiableQuoteShippingAddress(\n input: { quote_uid: $quoteId, shipping_addresses: [$shippingAddress] }\n ) {\n quote {\n uid\n }\n }\n\n setNegotiableQuoteBillingAddress(\n input: {\n quote_uid: $quoteId\n billing_address: { same_as_shipping: true }\n }\n ) {\n quote {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n }\n\n ${NEGOTIABLE_QUOTE_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 { config } from '@/checkout/api';\nimport {\n setShippingAddressOnCartAndUseAsBillingMutation,\n setShippingAddressOnCartMutation,\n setShippingAddressOnQuoteAndUseAsBillingMutation,\n setShippingAddressOnQuoteMutation,\n} from '@/checkout/api/setShippingAddress/graphql';\nimport { ShippingAddressInput as ShippingAddressInputModel } from '@/checkout/data/models';\nimport {\n transformCart,\n transformNegotiableQuote,\n transformShippingAddressInputModelToCartInput,\n transformShippingAddressInputModelToQuoteInput,\n} from '@/checkout/data/transforms';\nimport { dispatchApiCall, getValue, QueueName } from '@/checkout/lib';\nimport { InvalidInput, MissingShippingAddress } from '@/checkout/lib/errors';\nimport { ensureHasCartOrQuoteId } from '@/checkout/lib/guards';\nimport { state } from '@/checkout/lib/state';\n\nconst ensureIsValidCartInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (!customerAddressId && customerAddressUid) {\n throw new InvalidInput('customerAddressUid is not supported');\n }\n\n if (!customerAddressId && !pickupLocationCode && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidQuoteInput = ({\n address,\n customerAddressId,\n customerAddressUid,\n pickupLocationCode,\n}: ShippingAddressInputModel) => {\n if (pickupLocationCode) {\n throw new InvalidInput('pickup location is not supported in quotes');\n }\n\n if (!customerAddressUid && customerAddressId) {\n throw new InvalidInput('customerAddressId is not supported in quotes');\n }\n\n if (!customerAddressUid && !address) {\n throw new MissingShippingAddress();\n }\n};\n\nconst ensureIsValidInput = (input: ShippingAddressInputModel) => {\n const isCart = Boolean(state.cartId);\n const isQuote = Boolean(state.quoteId);\n\n if (isCart) {\n ensureIsValidCartInput(input);\n } else if (isQuote) {\n ensureIsValidQuoteInput(input);\n }\n};\n\nconst createShippingAddressSetter = <TTransformedInput, TTransformedOutput>(\n entityId: string,\n entityKey: string,\n mutation: string,\n transformer: (data: any) => TTransformedOutput,\n transformInput: (input: ShippingAddressInputModel) => TTransformedInput,\n path: string\n) => {\n return async (\n input: ShippingAddressInputModel\n ): Promise<TTransformedOutput> => {\n return await dispatchApiCall({\n type: 'mutation',\n query: mutation,\n options: {\n variables: {\n [entityKey]: entityId,\n shippingAddress: transformInput(input),\n },\n },\n path,\n queueName: QueueName.Updates,\n transformer,\n });\n };\n};\n\nexport const setShippingAddress = async (input: ShippingAddressInputModel) => {\n ensureHasCartOrQuoteId();\n ensureIsValidInput(input);\n\n const { defaults } = config.getConfig();\n\n const isBillToShipping =\n getValue('isBillToShipping') ?? defaults?.isBillToShipping;\n\n const isCart = Boolean(state.cartId);\n\n const setter = isCart\n ? createShippingAddressSetter(\n state.cartId!,\n 'cartId',\n isBillToShipping\n ? setShippingAddressOnCartAndUseAsBillingMutation\n : setShippingAddressOnCartMutation,\n transformCart,\n transformShippingAddressInputModelToCartInput,\n isBillToShipping\n ? 'setBillingAddressOnCart.cart'\n : 'setShippingAddressesOnCart.cart'\n )\n : createShippingAddressSetter(\n state.quoteId!,\n 'quoteId',\n isBillToShipping\n ? setShippingAddressOnQuoteAndUseAsBillingMutation\n : setShippingAddressOnQuoteMutation,\n transformNegotiableQuote,\n transformShippingAddressInputModelToQuoteInput,\n isBillToShipping\n ? 'setNegotiableQuoteBillingAddress.quote'\n : 'setNegotiableQuoteShippingAddress.quote'\n );\n\n return await setter(input);\n};\n"],"names":["estimateShippingMethodsMutation","estimateShippingMethods","input","cartId","state","countryCode","_a","_b","MissingCart","MissingCountry","region_id","region_name","zip","region","address","estimateShippingAddressData","_c","_d","partialAddress","transformShippingEstimatePartialAddress","dispatchApiCall","QueueName","transformShippingMethods","estimation","defaults","shipping","config","filteredOptions","hasAvailableOptions","shippingMethod","userSelection","getValue","selection","method","transformShippingEstimateShippingMethod","events","error","setShippingAddressOnCartAndUseAsBillingMutation","CHECKOUT_DATA_FRAGMENT","setShippingAddressOnCartMutation","setShippingAddressOnQuoteMutation","NEGOTIABLE_QUOTE_FRAGMENT","setShippingAddressOnQuoteAndUseAsBillingMutation","ensureIsValidCartInput","customerAddressId","customerAddressUid","pickupLocationCode","InvalidInput","MissingShippingAddress","ensureIsValidQuoteInput","ensureIsValidInput","isCart","isQuote","createShippingAddressSetter","entityId","entityKey","mutation","transformer","transformInput","path","setShippingAddress","ensureHasCartOrQuoteId","isBillToShipping","transformCart","transformShippingAddressInputModelToCartInput","transformNegotiableQuote","transformShippingAddressInputModelToQuoteInput"],"mappings":"qfAiBa,MAAAA,EAAgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,ECuBhDC,GAA0B,MACrCC,GAC0C,aAC1C,MAAMC,EAASC,EAAM,OACfC,IACJC,EAAAJ,GAAA,YAAAA,E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Reserved. */
3
- import{s as i,m as A,d as l,U as _,t as b,i as v}from"./fetch-graphql.js";import{merge as q,Initializer as w}from"@dropins/tools/lib.js";import{events as n}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as c,NEGOTIABLE_QUOTE_FRAGMENT as E}from"../fragments.js";import{b as M,c as T,d as N,a as Q,e as z,f as S,g as G}from"./transform-shipping-methods.js";const k=async(e=!1)=>{i.authenticated=e},d=e=>{if(e)return{code:e.code,title:e.title}},m=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:s,title:r}=t;return{code:s,title:r}})},D=e=>{var s,r,o;if(!e)return;const t={availablePaymentMethods:m(e.available_payment_methods),billingAddress:T(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:d(e.selected_payment_method),shippingAddresses:M(e.shipping_addresses),isGuest:!i.authenticated};return q(t,(o=(r=(s=H.getConfig().models)==null?void 0:s.CartModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},h=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:G(e.country),customAttributes:S(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:z(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},O=e=>{if(e)return h(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:s,selected_shipping_method:r,...o}=t;return{...h(o),availableShippingMethods:Q(s),selectedShippingMethod:N(r)}}),U=e=>e?{availablePaymentMethods:m(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:d(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),status:e.status,uid:e.uid}:null,x=`
3
+ import{s as i,m as M,d as g,U as T,t as N,i as Q}from"./fetch-graphql.js";import{merge as z,Initializer as S,deepmerge as G}from"@dropins/tools/lib.js";import{events as c}from"@dropins/tools/event-bus.js";import{CHECKOUT_DATA_FRAGMENT as y,NEGOTIABLE_QUOTE_FRAGMENT as k}from"../fragments.js";import{b as L,c as D,d as O,a as P,e as U,f as x,g as B}from"./transform-shipping-methods.js";const R=async(e=!1)=>{i.authenticated=e},b=e=>{if(e)return{code:e.code,title:e.title}},C=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:s,title:r}=t;return{code:s,title:r}})},$=e=>{var s,r,o;if(!e)return;const t={availablePaymentMethods:C(e.available_payment_methods),billingAddress:D(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:b(e.selected_payment_method),shippingAddresses:L(e.shipping_addresses),isGuest:!i.authenticated};return z(t,(o=(r=(s=Z.getConfig().models)==null?void 0:s.CartModel)==null?void 0:r.transformer)==null?void 0:o.call(r,e))},_=e=>{const t=e.street.filter(Boolean);return{city:e.city,company:e.company||void 0,country:B(e.country),customAttributes:x(e.custom_attributes),fax:e.fax||void 0,firstName:e.firstname,lastName:e.lastname,middleName:e.middlename||void 0,postCode:e.postcode||void 0,prefix:e.prefix||void 0,region:U(e.region),street:t,suffix:e.suffix||void 0,telephone:e.telephone||void 0,uid:e.uid,vatId:e.vat_id||void 0}},F=e=>{if(e)return _(e)},H=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:s,selected_shipping_method:r,...o}=t;return{..._(o),availableShippingMethods:P(s),selectedShippingMethod:O(r)}}),K=e=>e?{availablePaymentMethods:C(e.available_payment_methods),billingAddress:F(e.billing_address),email:e.email??"",isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,name:e.name,selectedPaymentMethod:b(e.selected_payment_method),shippingAddresses:H(e.shipping_addresses),status:e.status,uid:e.uid}:null,V=`
4
4
  query getCart($cartId: String!) {
5
5
  cart(cart_id: $cartId) {
6
6
  ...CHECKOUT_DATA_FRAGMENT
7
7
  }
8
8
  }
9
9
 
10
- ${c}
11
- `,R=`
10
+ ${y}
11
+ `,j=`
12
12
  query getCustomerCart {
13
13
  cart: customerCart {
14
14
  ...CHECKOUT_DATA_FRAGMENT
15
15
  }
16
16
  }
17
17
 
18
- ${c}
19
- `,f=async()=>{const e=i.cartId,t=i.authenticated===!1,s=t?x:R,r=t?{cartId:e}:{};if(t&&!e)throw new A;return await l({type:"query",query:s,options:{method:"POST",cache:"no-cache",variables:r},path:"cart",transformer:D})},$=`
18
+ ${y}
19
+ `,A=async()=>{const e=i.cartId,t=i.authenticated===!1,s=t?V:j,r=t?{cartId:e}:{};if(t&&!e)throw new M;return await g({type:"query",query:s,options:{method:"POST",cache:"no-cache",variables:r},path:"cart",transformer:$})},J=`
20
20
  query getNegotiableQuote($quoteId: ID!) {
21
21
  negotiableQuote(uid: $quoteId) {
22
22
  ...NEGOTIABLE_QUOTE_FRAGMENT
23
23
  }
24
24
  }
25
25
 
26
- ${E}
27
- `,p=async(e={})=>{const t=e.uid??i.quoteId;if(i.authenticated===!1)throw new _;if(!t)throw new b;return await l({type:"query",query:$,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:U})},a={eager:!0},B=()=>[n.on("authenticated",k,a),n.on("cart/initialized",u,a),n.on("cart/reset",C),n.on("cart/updated",I),n.on("quote-management/quote-data",u,a)],F=new URL(window.location.href),L=F.searchParams.get("quoteId");i.quoteId=L;const g=new w({init:async e=>{g.config.setConfig({defaults:{isBillToShipping:!0,...e==null?void 0:e.defaults},...e})},listeners:B}),H=g.config,y=e=>"id"in e,K=async e=>{try{return y(e)?(i.cartId=e.id,i.quoteId=null,await f()??null):(i.cartId=null,i.quoteId=e.uid,await p()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},u=async e=>{if(i.initialized){await I(e);return}i.config||(i.config=await v());const t=e?await K(e):null;i.initialized=!0,n.emit("checkout/initialized",t)},C=()=>{i.initialized&&(i.cartId=null,i.quoteId=null,n.emit("checkout/updated",null))},V=async e=>{try{return y(e)?(i.cartId=e.id,i.quoteId=null,await f()??null):(i.cartId=null,i.quoteId=e.uid,await p()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},I=async e=>{if(!i.initialized)return u(e);if(e===null){C();return}const t=await V(e);n.emit("checkout/updated",t)};export{k as a,p as b,H as c,u as d,U as e,f as g,g as i,C as r,I as s,D as t};
26
+ ${k}
27
+ `,I=async(e={})=>{const t=e.uid??i.quoteId;if(i.authenticated===!1)throw new T;if(!t)throw new N;return await g({type:"query",query:J,options:{method:"GET",cache:"no-cache",variables:{quoteId:t}},path:"negotiableQuote",transformer:K})},d={eager:!0},W=e=>{var h,f;const t=((f=(h=e==null?void 0:e.features)==null?void 0:h.b2b)==null?void 0:f.quotes)??!1;return[["authenticated",(n=!1)=>{var u,l,p;if(R(n),!t||n)return;const a=(p=(l=(u=e==null?void 0:e.features)==null?void 0:u.b2b)==null?void 0:l.routeLogin)==null?void 0:p.call(l);a&&window.location.assign(a)},d],...t?[["quote-management/quote-data/initialized",n=>{m(n.quote)},d]]:[["cart/initialized",m,d],["cart/reset",w],["cart/updated",E]]].map(([n,a,u])=>c.on(n,a,u))},X=new URL(window.location.href),Y=X.searchParams.get("quoteId");i.quoteId=Y;const q=new S({init:async(e={})=>{q.config.setConfig(G({defaults:{isBillToShipping:!0,selectedShippingMethod:t=>t.length>0?t[0]:null},features:{b2b:{quotes:!1}}},e))},listeners:W}),Z=q.config,v=e=>"id"in e,ee=async e=>{try{return v(e)?(i.cartId=e.id,i.quoteId=null,await A()??null):(i.cartId=null,i.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout initialization failed:",t),null}},m=async e=>{if(i.initialized){await E(e);return}i.config||(i.config=await Q());const t=e?await ee(e):null;i.initialized=!0,c.emit("checkout/initialized",t)},w=()=>{i.initialized&&(i.cartId=null,i.quoteId=null,c.emit("checkout/updated",null))},te=async e=>{try{return v(e)?(i.cartId=e.id,i.quoteId=null,await A()??null):(i.cartId=null,i.quoteId=e.uid,await I()??null)}catch(t){return console.error("Checkout synchronization failed:",t),null}},E=async e=>{if(!i.initialized)return m(e);if(e===null){w();return}const t=await te(e);c.emit("checkout/updated",t)};export{R as a,I as b,Z as c,m as d,K as e,A as g,q as i,w as r,E as s,$ as t};
28
28
  //# sourceMappingURL=synchronizeCheckout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/data/transforms/transform-quote-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-negotiable-quote.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/getNegotiableQuote.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/types/guards.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 { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\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 { 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 { GetCartQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformCartBillingAddress,\n transformCartShippingAddress,\n} from '@/checkout/data/transforms/transform-cart-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: transformCartBillingAddress(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: transformCartShippingAddress(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 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 {\n Address as AddressModel,\n ShippingAddress as ShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\ntype QuoteShippingAddresses = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['shipping_addresses'];\ntype QuoteShippingAddress = QuoteShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<QuoteShippingAddress>;\n\ntype QuoteBillingAddress = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<QuoteBillingAddress>;\n\nconst transformAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformQuoteBillingAddress = (\n data: QuoteBillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return transformAddress(data);\n};\n\nconst transformQuoteShippingAddress = (\n data: QuoteShippingAddresses\n): ShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n };\n });\n};\n\nexport {\n QuoteBillingAddress,\n QuoteShippingAddress,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n};\n","/********************************************************************\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 { NegotiableQuote as NegotiableQuoteModel } from '@/checkout/data/models/';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\nimport {\n transformAvailablePaymentMethods,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms';\n\ntype NegotiableQuote = GetNegotiableQuoteQuery['negotiableQuote'];\n\nexport const transformNegotiableQuote = (\n data: NegotiableQuote | undefined\n): NegotiableQuoteModel | null => {\n if (!data) return null;\n\n return {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformQuoteBillingAddress(data.billing_address),\n email: data.email ?? '',\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n name: data.name,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformQuoteShippingAddress(data.shipping_addresses),\n status: data.status,\n uid: data.uid,\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 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 { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib';\nimport { MissingCart } from '@/checkout/lib/errors';\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 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const getNegotiableQuoteQuery = /* GraphQL */ `\n query getNegotiableQuote($quoteId: ID!) {\n negotiableQuote(uid: $quoteId) {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\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 { getNegotiableQuoteQuery } from '@/checkout/api/getNegotiableQuote/graphql';\nimport { transformNegotiableQuote as transformer } from '@/checkout/data/transforms';\nimport { state } from '@/checkout/lib';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport {\n MissingNegotiableQuoteId,\n Unauthenticated,\n} from '@/checkout/lib/errors';\n\ntype GetNegotiableQuoteInput = {\n uid?: string;\n};\n\nexport const getNegotiableQuote = async (\n input: GetNegotiableQuoteInput = {}\n) => {\n const quoteId = input.uid ?? state.quoteId;\n const isGuest = state.authenticated === false;\n\n if (isGuest) throw new Unauthenticated();\n if (!quoteId) throw new MissingNegotiableQuoteId();\n\n const variables = { quoteId };\n\n return await dispatchApiCall({\n type: 'query',\n query: getNegotiableQuoteQuery,\n options: { method: 'GET', cache: 'no-cache', variables },\n path: 'negotiableQuote',\n transformer,\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\nconst asEager = { eager: true };\n\nexport const addCheckoutEventListeners = () => {\n return [\n events.on('authenticated', authenticateCustomer, asEager),\n events.on('cart/initialized', initializeCheckout, asEager),\n events.on('cart/reset', resetCheckout),\n events.on('cart/updated', synchronizeCheckout),\n events.on('quote-management/quote-data', initializeCheckout, asEager),\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 { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n} from '@/checkout/data/models';\nimport { state } from '@/checkout/lib';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nconst url = new URL(window.location.href);\nconst quoteId = url.searchParams.get('quoteId');\nstate.quoteId = quoteId;\n\nexport type ConfigProps = {\n defaults?: {\n isBillToShipping?: boolean;\n };\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 initialize.config.setConfig({\n defaults: { isBillToShipping: true, ..._config?.defaults },\n ..._config,\n });\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\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 {\n CartModel,\n InitializeInput,\n NegotiableQuoteModel,\n SynchronizeInput,\n} from '@/checkout/types';\n\nexport const isCartInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is CartModel => {\n return 'id' in input;\n};\n\nexport const isNegotiableQuoteInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is NegotiableQuoteModel => {\n return 'uid' in input;\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 getCart,\n getNegotiableQuote,\n getStoreConfig,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib';\nimport { InitializeInput, isCartInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getInitialData = async (input: NonNullable<InitializeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout initialization failed:', error);\n return null;\n }\n};\n\nexport const initializeCheckout = async (input: InitializeInput) => {\n if (state.initialized) {\n await synchronizeCheckout(input);\n return;\n }\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const initialData = input ? await getInitialData(input) : null;\n\n state.initialized = true;\n events.emit('checkout/initialized', initialData);\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 if (!state.initialized) return;\n state.cartId = null;\n state.quoteId = 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 {\n getCart,\n getNegotiableQuote,\n initializeCheckout,\n resetCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { isCartInput, SynchronizeInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getSynchronizedData = async (input: NonNullable<SynchronizeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout synchronization failed:', error);\n return null;\n }\n};\n\nexport const synchronizeCheckout = async (data: SynchronizeInput) => {\n if (!state.initialized) return initializeCheckout(data);\n\n if (data === null) {\n resetCheckout();\n return;\n }\n\n const update = await getSynchronizedData(data);\n\n events.emit('checkout/updated', update);\n};\n"],"names":["authenticateCustomer","authenticated","state","transformSelectedPaymentMethod","data","transformAvailablePaymentMethods","method","code","title","transformCart","model","transformCartBillingAddress","transformCartShippingAddress","merge","_c","_b","_a","config","transformAddress","street","transformAddressCountry","transformCustomAttributes","transformAddressRegion","transformQuoteBillingAddress","transformQuoteShippingAddress","address","available_shipping_methods","selected_shipping_method","baseData","transformShippingMethods","transformSelectedShippingMethod","transformNegotiableQuote","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","getNegotiableQuoteQuery","NEGOTIABLE_QUOTE_FRAGMENT","getNegotiableQuote","input","quoteId","Unauthenticated","MissingNegotiableQuoteId","transformer","asEager","addCheckoutEventListeners","events","initializeCheckout","resetCheckout","synchronizeCheckout","url","initialize","Initializer","_config","isCartInput","getInitialData","error","getStoreConfig","initialData","getSynchronizedData","update"],"mappings":"oXAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,ECWME,EACJC,GAC8B,CAC9B,GAAKA,EACL,MAAO,CAAE,KAAMA,EAAK,KAAM,MAAOA,EAAK,KAAM,CAC9C,EAEMC,EACJD,GACgC,CAChC,GAAKA,EAEE,OAAAA,EACJ,OAAQE,GAAW,CAAC,CAACA,CAAM,EAC3B,IAAKA,GAAW,CACT,KAAA,CAAE,KAAAC,EAAM,MAAAC,CAAA,EAAUF,EACjB,MAAA,CAAE,KAAAC,EAAM,MAAAC,CAAM,CAAA,CACtB,CACL,EChBMC,EAAiBL,GAAsC,WAC3D,GAAI,CAACA,EAAM,OAEX,MAAMM,EAAQ,CACZ,wBAAyBL,EACvBD,EAAK,yBACP,EACA,eAAgBO,EAA4BP,EAAK,eAAe,EAChE,MAAOA,EAAK,OAAS,OACrB,GAAIA,EAAK,GACT,QAASA,EAAK,iBAAmB,EACjC,UAAWA,EAAK,WAChB,sBAAuBD,EACrBC,EAAK,uBACP,EACA,kBAAmBQ,EAA6BR,EAAK,kBAAkB,EACvE,QA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yB,YAChCkB,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAChD,IAAA,CAEX,EAEaP,EAAsB,MAAOnD,GAA2B,CACnE,GAAI,CAACF,EAAM,YAAa,OAAOmD,EAAmBjD,CAAI,EAEtD,GAAIA,IAAS,KAAM,CACHkD,EAAA,EACd,MAAA,CAGI,MAAAY,EAAS,MAAMD,EAAoB7D,CAAI,EAEtCgD,EAAA,KAAK,mBAAoBc,CAAM,CACxC"}
1
+ {"version":3,"file":"synchronizeCheckout.js","sources":["/@dropins/storefront-checkout/src/api/authenticateCustomer/authenticateCustomer.ts","/@dropins/storefront-checkout/src/data/transforms/transform-payment-methods.ts","/@dropins/storefront-checkout/src/data/transforms/transform-cart.ts","/@dropins/storefront-checkout/src/data/transforms/transform-quote-address.ts","/@dropins/storefront-checkout/src/data/transforms/transform-negotiable-quote.ts","/@dropins/storefront-checkout/src/api/getCart/graphql/getCart.graphql.ts","/@dropins/storefront-checkout/src/api/getCart/getCart.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/graphql/getNegotiableQuote.graphql.ts","/@dropins/storefront-checkout/src/api/getNegotiableQuote/getNegotiableQuote.ts","/@dropins/storefront-checkout/src/api/initialize/listeners.ts","/@dropins/storefront-checkout/src/api/initialize/initialize.ts","/@dropins/storefront-checkout/src/types/guards.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 { PaymentMethod } from '@/checkout/data/models/payment-method';\nimport { GetCartQuery } from '@/checkout/__generated__/types';\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 { 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 { GetCartQuery } from '@/checkout/__generated__/types';\nimport { merge } from '@adobe-commerce/elsie/lib';\n\nimport {\n transformCartBillingAddress,\n transformCartShippingAddress,\n} from '@/checkout/data/transforms/transform-cart-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: transformCartBillingAddress(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: transformCartShippingAddress(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 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 {\n Address as AddressModel,\n ShippingAddress as ShippingAddressModel,\n} from '@/checkout/data/models';\n\nimport {\n transformAddressCountry,\n transformAddressRegion,\n transformCustomAttributes,\n transformSelectedShippingMethod,\n transformShippingMethods,\n} from '@/checkout/data/transforms';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\ntype QuoteShippingAddresses = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['shipping_addresses'];\ntype QuoteShippingAddress = QuoteShippingAddresses[0];\ntype NonNullableShippingAddress = NonNullable<QuoteShippingAddress>;\n\ntype QuoteBillingAddress = NonNullable<\n GetNegotiableQuoteQuery['negotiableQuote']\n>['billing_address'];\ntype NonNullableBillingAddress = NonNullable<QuoteBillingAddress>;\n\nconst transformAddress = (\n data: NonNullableShippingAddress | NonNullableBillingAddress\n): AddressModel => {\n const street = data.street.filter(Boolean) as string[];\n\n return {\n city: data.city,\n company: data.company || undefined,\n country: transformAddressCountry(data.country),\n customAttributes: transformCustomAttributes(data.custom_attributes),\n fax: data.fax || undefined,\n firstName: data.firstname,\n lastName: data.lastname,\n middleName: data.middlename || undefined,\n postCode: data.postcode || undefined,\n prefix: data.prefix || undefined,\n region: transformAddressRegion(data.region),\n street,\n suffix: data.suffix || undefined,\n telephone: data.telephone || undefined,\n uid: data.uid,\n vatId: data.vat_id || undefined,\n };\n};\n\nconst transformQuoteBillingAddress = (\n data: QuoteBillingAddress\n): AddressModel | undefined => {\n if (!data) return;\n return transformAddress(data);\n};\n\nconst transformQuoteShippingAddress = (\n data: QuoteShippingAddresses\n): ShippingAddressModel[] => {\n return data\n .filter((address) => !!address)\n .map((address) => {\n const {\n available_shipping_methods,\n selected_shipping_method,\n ...baseData\n } = address as NonNullableShippingAddress;\n\n return {\n ...transformAddress(baseData as NonNullableShippingAddress),\n availableShippingMethods: transformShippingMethods(\n available_shipping_methods\n ),\n selectedShippingMethod: transformSelectedShippingMethod(\n selected_shipping_method\n ),\n };\n });\n};\n\nexport {\n QuoteBillingAddress,\n QuoteShippingAddress,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n};\n","/********************************************************************\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 { NegotiableQuote as NegotiableQuoteModel } from '@/checkout/data/models/';\nimport { GetNegotiableQuoteQuery } from '@/checkout/__generated__/types';\n\nimport {\n transformAvailablePaymentMethods,\n transformQuoteBillingAddress,\n transformQuoteShippingAddress,\n transformSelectedPaymentMethod,\n} from '@/checkout/data/transforms';\n\ntype NegotiableQuote = GetNegotiableQuoteQuery['negotiableQuote'];\n\nexport const transformNegotiableQuote = (\n data: NegotiableQuote | undefined\n): NegotiableQuoteModel | null => {\n if (!data) return null;\n\n return {\n availablePaymentMethods: transformAvailablePaymentMethods(\n data.available_payment_methods\n ),\n billingAddress: transformQuoteBillingAddress(data.billing_address),\n email: data.email ?? '',\n isEmpty: data.total_quantity === 0,\n isVirtual: data.is_virtual,\n name: data.name,\n selectedPaymentMethod: transformSelectedPaymentMethod(\n data.selected_payment_method\n ),\n shippingAddresses: transformQuoteShippingAddress(data.shipping_addresses),\n status: data.status,\n uid: data.uid,\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 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 { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport { state } from '@/checkout/lib';\nimport { MissingCart } from '@/checkout/lib/errors';\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 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 { NEGOTIABLE_QUOTE_FRAGMENT } from '@/checkout/api/graphql/NegotiableQuoteFragment.graphql';\n\nexport const getNegotiableQuoteQuery = /* GraphQL */ `\n query getNegotiableQuote($quoteId: ID!) {\n negotiableQuote(uid: $quoteId) {\n ...NEGOTIABLE_QUOTE_FRAGMENT\n }\n }\n\n ${NEGOTIABLE_QUOTE_FRAGMENT}\n`;\n","/********************************************************************\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 { getNegotiableQuoteQuery } from '@/checkout/api/getNegotiableQuote/graphql';\nimport { transformNegotiableQuote as transformer } from '@/checkout/data/transforms';\nimport { state } from '@/checkout/lib';\nimport { dispatchApiCall } from '@/checkout/lib/dispatchApiCall';\nimport {\n MissingNegotiableQuoteId,\n Unauthenticated,\n} from '@/checkout/lib/errors';\n\ntype GetNegotiableQuoteInput = {\n uid?: string;\n};\n\nexport const getNegotiableQuote = async (\n input: GetNegotiableQuoteInput = {}\n) => {\n const quoteId = input.uid ?? state.quoteId;\n const isGuest = state.authenticated === false;\n\n if (isGuest) throw new Unauthenticated();\n if (!quoteId) throw new MissingNegotiableQuoteId();\n\n const variables = { quoteId };\n\n return await dispatchApiCall({\n type: 'query',\n query: getNegotiableQuoteQuery,\n options: { method: 'GET', cache: 'no-cache', variables },\n path: 'negotiableQuote',\n transformer,\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 ConfigProps,\n initializeCheckout,\n resetCheckout,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { events, Events } from '@adobe-commerce/event-bus';\n\ntype Listener = [keyof Events, (...args: any[]) => void, { eager: boolean }?];\n\nconst asEager = { eager: true };\n\nexport const addCheckoutEventListeners = (config: ConfigProps | undefined) => {\n const useB2bQuotes = config?.features?.b2b?.quotes ?? false;\n\n const handleAuthenticated = (isAuthenticated = false) => {\n authenticateCustomer(isAuthenticated);\n\n if (!useB2bQuotes) return;\n if (isAuthenticated) return;\n\n const destination = config?.features?.b2b?.routeLogin?.();\n if (destination) {\n window.location.assign(destination);\n }\n };\n\n const cartListeners: Listener[] = [\n ['cart/initialized', initializeCheckout, asEager],\n ['cart/reset', resetCheckout],\n ['cart/updated', synchronizeCheckout],\n ];\n\n const quoteListeners: Listener[] = [\n [\n 'quote-management/quote-data/initialized',\n (data) => {\n initializeCheckout(data.quote);\n },\n asEager,\n ],\n ];\n\n const listeners: Listener[] = [\n ['authenticated', handleAuthenticated, asEager],\n ...(useB2bQuotes ? quoteListeners : cartListeners),\n ];\n\n return listeners.map(([eventName, handler, options]) => {\n return events.on(eventName, handler, options);\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 { addCheckoutEventListeners } from '@/checkout/api/initialize/listeners';\nimport {\n Cart as CartModel,\n Customer as CustomerModel,\n ShippingMethod,\n} from '@/checkout/data/models';\nimport { state } from '@/checkout/lib';\nimport { Filter, Selector } from '@/checkout/types/utils';\nimport { Lang } from '@adobe-commerce/elsie/i18n';\nimport { deepmerge, Initializer, Model } from '@adobe-commerce/elsie/lib';\n\nconst url = new URL(window.location.href);\nconst quoteId = url.searchParams.get('quoteId');\nstate.quoteId = quoteId;\n\nexport type ConfigProps = {\n defaults?: {\n isBillToShipping?: boolean;\n selectedShippingMethod?: Selector<ShippingMethod>;\n };\n shipping?: {\n filterOptions?: Filter<ShippingMethod>;\n };\n features?: {\n b2b?: {\n quotes?: boolean;\n routeLogin?: () => string | void;\n };\n };\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 initialize.config.setConfig(\n deepmerge(\n {\n defaults: {\n isBillToShipping: true,\n selectedShippingMethod: (options) => {\n return options.length > 0 ? options[0] : null;\n },\n },\n features: {\n b2b: { quotes: false },\n },\n },\n _config\n )\n );\n },\n listeners: addCheckoutEventListeners,\n});\n\nexport const config = initialize.config;\n","/********************************************************************\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 {\n CartModel,\n InitializeInput,\n NegotiableQuoteModel,\n SynchronizeInput,\n} from '@/checkout/types';\n\nexport const isCartInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is CartModel => {\n return 'id' in input;\n};\n\nexport const isNegotiableQuoteInput = (\n input: NonNullable<InitializeInput | SynchronizeInput>\n): input is NegotiableQuoteModel => {\n return 'uid' in input;\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 getCart,\n getNegotiableQuote,\n getStoreConfig,\n synchronizeCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib';\nimport { InitializeInput, isCartInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getInitialData = async (input: NonNullable<InitializeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout initialization failed:', error);\n return null;\n }\n};\n\nexport const initializeCheckout = async (input: InitializeInput) => {\n if (state.initialized) {\n await synchronizeCheckout(input);\n return;\n }\n\n if (!state.config) {\n state.config = await getStoreConfig();\n }\n\n const initialData = input ? await getInitialData(input) : null;\n\n state.initialized = true;\n events.emit('checkout/initialized', initialData);\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 if (!state.initialized) return;\n state.cartId = null;\n state.quoteId = 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 {\n getCart,\n getNegotiableQuote,\n initializeCheckout,\n resetCheckout,\n} from '@/checkout/api';\nimport { state } from '@/checkout/lib/state';\nimport { isCartInput, SynchronizeInput } from '@/checkout/types';\nimport { events } from '@adobe-commerce/event-bus';\n\nconst getSynchronizedData = async (input: NonNullable<SynchronizeInput>) => {\n try {\n if (isCartInput(input)) {\n state.cartId = input.id;\n state.quoteId = null;\n return (await getCart()) ?? null;\n }\n state.cartId = null;\n state.quoteId = input.uid;\n return (await getNegotiableQuote()) ?? null;\n } catch (error) {\n console.error('Checkout synchronization failed:', error);\n return null;\n }\n};\n\nexport const synchronizeCheckout = async (data: SynchronizeInput) => {\n if (!state.initialized) return initializeCheckout(data);\n\n if (data === null) {\n resetCheckout();\n return;\n }\n\n const update = await getSynchronizedData(data);\n\n events.emit('checkout/updated', update);\n};\n"],"names":["authenticateCustomer","authenticated","state","transformSelectedPaymentMethod","data","transformAvailablePaymentMethods","method","code","title","transformCart","model","transformCartBillingAddress","transformCartShippingAddress","merge","_c","_b","_a","config","transformAddress","street","transformAddressCountry","transformCustomAttributes","transformAddressRegion","transformQuoteBillingAddress","transformQuoteShippingAddress","address","available_shipping_methods","selected_shipping_method","baseData","transformShippingMethods","transformSelectedShippingMethod","transformNegotiableQuote","getCartQuery","CHECKOUT_DATA_FRAGMENT","getCustomerCartQuery","getCart","cartId","isGuest","query","variables","MissingCart","dispatchApiCall","getNegotiableQuoteQuery","NEGOTIABLE_QUOTE_FRAGMENT","getNegotiableQuote","input","quoteId","Unauthenticated","MissingNegotiableQuoteId","transformer","asEager","addCheckoutEventListeners","useB2bQuotes","isAuthenticated","destination","initializeCheckout","resetCheckout","synchronizeCheckout","eventName","handler","options","events","url","initialize","Initializer","_config","deepmerge","isCartInput","getInitialData","error","getStoreConfig","initialData","getSynchronizedData","update"],"mappings":"mYAmBa,MAAAA,EAAuB,MAAOC,EAAgB,KAAU,CACnEC,EAAM,cAAgBD,CACxB,ECWME,EACJC,GAC8B,CAC9B,GAAKA,EACL,MAAO,CAAE,KAAMA,EAAK,KAAM,MAAOA,EAAK,KAAM,CAC9C,EAEMC,EACJD,GACgC,CAChC,GAAKA,EAEE,OAAAA,EACJ,OAAQE,GAAW,CAAC,CAACA,CAAM,EAC3B,IAAKA,GAAW,CACT,KAAA,CAAE,KAAAC,EAAM,MAAAC,CAAA,EAAUF,EACjB,MAAA,CAAE,KAAAC,EAAM,MAAAC,CAAM,CAAA,CACtB,CACL,EChBMC,EAAiBL,GAAsC,WAC3D,GAAI,CAACA,EAAM,OAEX,MAAMM,EAAQ,CACZ,wBAAyBL,EACvBD,EAAK,yBACP,EACA,eAAgBO,EAA4BP,EAAK,eAAe,EAChE,MAAOA,EAAK,OAAS,OACrB,GAAIA,EAAK,GACT,QAASA,EAAK,iBAAmB,EACjC,UAAWA,EAAK,WAChB,sBAAuBD,EACrBC,EAAK,uBACP,EACA,kBAAmBQ,EAA6BR,EAAK,kBAAkB,EACvE,QAAS,CAACF,EAAM,aAClB,EAGO,OAAAW,EACLH,GACAI,GAAAC,GAAAC,EAAAC,EAAO,UAAU,EAAE,SAAnB,YAAAD,EAA2B,YAA3B,YAAAD,EAAsC,cAAtC,YAAAD,EAAA,KAAAC,EAAoDX,EACtD,CACF,EChBMc,EACJd,GACiB,CACjB,MAAMe,EAASf,EAAK,OAAO,OAAO,OAAO,EAElC,MAAA,CACL,KAAMA,EAAK,KACX,QAASA,EAAK,SAAW,OACzB,QAASgB,EAAwBhB,EAAK,OAAO,EAC7C,iBAAkBiB,EAA0BjB,EAAK,iBAAiB,EAClE,IAAKA,EAAK,KAAO,OACjB,UAAWA,EAAK,UAChB,SAAUA,EAA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AsB,MAAO3B,GAAyC,CACtE,GAAA,CACE,OAAAsB,EAAYtB,CAAK,GACnB3C,EAAM,OAAS2C,EAAM,GACrB3C,EAAM,QAAU,KACR,MAAMiC,KAAc,OAE9BjC,EAAM,OAAS,KACfA,EAAM,QAAU2C,EAAM,IACd,MAAMD,KAAyB,YAChCyB,EAAO,CACN,eAAA,MAAM,mCAAoCA,CAAK,EAChD,IAAA,CAEX,EAEaZ,EAAsB,MAAOrD,GAA2B,CACnE,GAAI,CAACF,EAAM,YAAa,OAAOqD,EAAmBnD,CAAI,EAEtD,GAAIA,IAAS,KAAM,CACHoD,EAAA,EACd,MAAA,CAGI,MAAAiB,EAAS,MAAMD,GAAoBpE,CAAI,EAEtCyD,EAAA,KAAK,mBAAoBY,CAAM,CACxC"}
@@ -6,7 +6,8 @@ export interface ContentSlotContext {
6
6
  }
7
7
  export interface HandlePlaceOrderContext {
8
8
  code: string;
9
- cartId: string;
9
+ cartId?: string | null;
10
+ quoteId?: string | null;
10
11
  }
11
12
  export interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {
12
13
  disabled?: boolean;
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as P,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{W as g}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as b,SkeletonRow as I,Button as A}from"@dropins/tools/components.js";import{classes as x,Slot as z}from"@dropins/tools/lib.js";import{I as W,U as D,h as V,s as K}from"../chunks/fetch-graphql.js";import{events as u}from"@dropins/tools/event-bus.js";import{g as H}from"../chunks/events.js";import{g as U}from"../chunks/values.js";import{useState as k,useCallback as d,useEffect as f}from"@dropins/tools/preact-hooks.js";import{useText as L}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";var p=(e=>(e.INVALID_INPUT="INVALID_INPUT",e.SERVER_ERROR="SERVER_ERROR",e.UNAUTHENTICATED="UNAUTHENTICATED",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e))(p||{});const j=["PlaceOrderError"],v=[{code:"INVALID_INPUT",matches:e=>e instanceof W},{code:"UNAUTHENTICATED",matches:e=>e instanceof D},{code:"SERVER_ERROR",matches:e=>!e||typeof e!="object"||!("name"in e)?!1:j.includes(e.name)}];function B(e){const n=v.find(o=>o.matches(e));return n?n.code:p.UNKNOWN_ERROR}const w=()=>P(b,{"data-testid":"place-order-skeleton",children:[s(I,{size:"small",variant:"empty"}),s(I,{size:"small"})]}),M=({children:e,className:n,disabled:o=!1,onClick:i})=>s("div",{className:x(["checkout-place-order",n]),children:s(A,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:o,size:"medium",type:"button",variant:"primary",onClick:i,children:e},"placeOrder")}),Q=g(M,w),se=({disabled:e=!1,active:n=!0,handleValidation:o,handlePlaceOrder:i,slots:l,...C})=>{var h;const[S,R]=k(!1),[T,E]=k(!1),_=V.value,m=L({CheckoutUnexpectedError:"Checkout.ServerError.unexpected",placeOrderButton:"Checkout.PlaceOrder.button"}),N=d(t=>{const r=B(t),a=r===p.UNKNOWN_ERROR?m.CheckoutUnexpectedError:t.message;u.emit("checkout/error",{message:a,code:r})},[m]),y=d(async()=>{var t;try{if(o&&!o())return;await i({cartId:K.cartId,code:((t=U("selectedPaymentMethod"))==null?void 0:t.code)??""})}catch(r){N(r)}},[o,i,N]),c=d(t=>{(!t||"isEmpty"in t&&t.isEmpty)&&E(!1)},[]);return f(()=>{if(n===!1)return;const t=u.on("cart/initialized",r=>{const a=(r==null?void 0:r.items)||[];E(a.some(O=>O.outOfStock||O.insufficientQuantity))},{eager:!0});return()=>{t==null||t.off()}},[n]),f(()=>{if(!n)return;const t=H();if(t){R(!0),c(t);return}const r=u.on("checkout/initialized",a=>{R(!0),c(a)},{eager:!0});return()=>{r==null||r.off()}},[n,c]),f(()=>{if(!n)return;const t=u.on("checkout/updated",r=>{c(r)},{eager:!1});return()=>{t==null||t.off()}},[n,c]),s(Q,{...C,disabled:e||T||_,initialized:S,visible:n,onClick:y,children:s(z,{context:{code:((h=U("selectedPaymentMethod"))==null?void 0:h.code)??""},name:"Content",slot:l==null?void 0:l.Content,children:m.placeOrderButton})})};export{se as PlaceOrder,se as default};
3
+ import{jsxs as g,jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{W as b}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as A,SkeletonRow as I,Button as x}from"@dropins/tools/components.js";import{classes as z,Slot as W}from"@dropins/tools/lib.js";import{I as D,U as V,h as K,s as U}from"../chunks/fetch-graphql.js";import{events as u}from"@dropins/tools/event-bus.js";import{g as H}from"../chunks/events.js";import{g as k}from"../chunks/values.js";import{useState as C,useCallback as m,useEffect as f}from"@dropins/tools/preact-hooks.js";import{useText as L}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";var p=(e=>(e.INVALID_INPUT="INVALID_INPUT",e.SERVER_ERROR="SERVER_ERROR",e.UNAUTHENTICATED="UNAUTHENTICATED",e.UNKNOWN_ERROR="UNKNOWN_ERROR",e))(p||{});const j=["PlaceOrderError"],v=[{code:"INVALID_INPUT",matches:e=>e instanceof D},{code:"UNAUTHENTICATED",matches:e=>e instanceof V},{code:"SERVER_ERROR",matches:e=>!e||typeof e!="object"||!("name"in e)?!1:j.includes(e.name)}];function B(e){const o=v.find(n=>n.matches(e));return o?o.code:p.UNKNOWN_ERROR}const q=()=>g(A,{"data-testid":"place-order-skeleton",children:[s(I,{size:"small",variant:"empty"}),s(I,{size:"small"})]}),w=({children:e,className:o,disabled:n=!1,onClick:i})=>s("div",{className:z(["checkout-place-order",o]),children:s(x,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:n,size:"medium",type:"button",variant:"primary",onClick:i,children:e},"placeOrder")}),M=b(w,q),se=({disabled:e=!1,active:o=!0,handleValidation:n,handlePlaceOrder:i,slots:l,...S})=>{var h;const[T,R]=C(!1),[_,E]=C(!1),y=K.value,d=L({CheckoutUnexpectedError:"Checkout.ServerError.unexpected",placeOrderButton:"Checkout.PlaceOrder.button"}),N=m(t=>{const r=B(t),a=r===p.UNKNOWN_ERROR?d.CheckoutUnexpectedError:t.message;u.emit("checkout/error",{message:a,code:r})},[d]),P=m(async()=>{var t;try{if(n&&!n())return;await i({cartId:U.cartId,quoteId:U.quoteId,code:((t=k("selectedPaymentMethod"))==null?void 0:t.code)??""})}catch(r){N(r)}},[n,i,N]),c=m(t=>{(!t||"isEmpty"in t&&t.isEmpty)&&E(!1)},[]);return f(()=>{if(o===!1)return;const t=u.on("cart/initialized",r=>{const a=(r==null?void 0:r.items)||[];E(a.some(O=>O.outOfStock||O.insufficientQuantity))},{eager:!0});return()=>{t==null||t.off()}},[o]),f(()=>{if(!o)return;const t=H();if(t){R(!0),c(t);return}const r=u.on("checkout/initialized",a=>{R(!0),c(a)},{eager:!0});return()=>{r==null||r.off()}},[o,c]),f(()=>{if(!o)return;const t=u.on("checkout/updated",r=>{c(r)},{eager:!1});return()=>{t==null||t.off()}},[o,c]),s(M,{...S,disabled:e||_||y,initialized:T,visible:o,onClick:P,children:s(W,{context:{code:((h=k("selectedPaymentMethod"))==null?void 0:h.code)??""},name:"Content",slot:l==null?void 0:l.Content,children:d.placeOrderButton})})};export{se as PlaceOrder,se as default};
4
4
  //# sourceMappingURL=PlaceOrder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlaceOrder.js","sources":["/@dropins/storefront-checkout/src/lib/errors/classifiers.ts","/@dropins/storefront-checkout/src/lib/errors/mapErrorToCode.ts","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrderSkeleton.tsx","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrder.tsx","/@dropins/storefront-checkout/src/containers/PlaceOrder/PlaceOrder.tsx"],"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 { InvalidInput, Unauthenticated } from './customErrors';\n\nexport type ErrorCode = string;\n\nexport enum ErrorCodes {\n INVALID_INPUT = 'INVALID_INPUT',\n SERVER_ERROR = 'SERVER_ERROR',\n UNAUTHENTICATED = 'UNAUTHENTICATED',\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n}\n\nconst KNOWN_SERVER_ERRORS = ['PlaceOrderError'];\n\nexport interface ErrorClassifier {\n /**\n * The specific code to return if this classifier matches.\n */\n code: ErrorCode;\n /**\n * A function that returns `true` if it recognizes the error.\n * It must safely handle `unknown` inputs.\n */\n matches: (error: unknown) => boolean;\n}\n\n// Array of all known error classifiers.\n// The order is important! The first one to match will be used.\nexport const classifiers: ErrorClassifier[] = [\n {\n code: ErrorCodes.INVALID_INPUT,\n matches: (error: unknown): boolean => {\n return error instanceof InvalidInput;\n },\n },\n {\n code: ErrorCodes.UNAUTHENTICATED,\n matches: (error: unknown): boolean => {\n return error instanceof Unauthenticated;\n },\n },\n {\n code: ErrorCodes.SERVER_ERROR,\n matches: (error: unknown): boolean => {\n if (!error || typeof error !== 'object' || !('name' in error)) {\n return false;\n }\n\n return KNOWN_SERVER_ERRORS.includes((error as { name: string }).name);\n },\n },\n];\n","/********************************************************************\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 {\n classifiers,\n ErrorCode,\n ErrorCodes,\n} from '@/checkout/lib/errors/classifiers';\n\nexport function mapErrorToCode(error: unknown): ErrorCode {\n const matchingClassifier = classifiers.find((classifier) =>\n classifier.matches(error)\n );\n\n if (matchingClassifier) {\n return matchingClassifier.code;\n }\n\n return ErrorCodes.UNKNOWN_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 { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const PlaceOrderSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"place-order-skeleton\">\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow size=\"small\" />\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/index';\nimport '@/checkout/components/PlaceOrder/PlaceOrder.css';\nimport { PlaceOrderSkeleton } from '@/checkout/components/PlaceOrder/PlaceOrderSkeleton';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n onClick: (event: Event) => Promise<void>;\n}\n\nconst PlaceOrderComponent: FunctionComponent<PlaceOrderProps> = ({\n children,\n className,\n disabled = false,\n onClick,\n}) => {\n return (\n <div className={classes(['checkout-place-order', className])}>\n <Button\n key=\"placeOrder\"\n className=\"checkout-place-order__button\"\n data-testid=\"place-order-button\"\n disabled={disabled}\n size=\"medium\"\n type=\"button\"\n variant=\"primary\"\n onClick={onClick}\n >\n {children}\n </Button>\n </div>\n );\n};\n\nexport const PlaceOrder = WithConditionals(\n PlaceOrderComponent,\n PlaceOrderSkeleton\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 { PlaceOrder as PlaceOrderComponent } from '@/checkout/components/PlaceOrder/PlaceOrder';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n state,\n} from '@/checkout/lib';\nimport { ErrorCodes, mapErrorToCode } from '@/checkout/lib/errors';\nimport { Item as ItemModel } from '@/checkout/types/cart';\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 { useCallback, useEffect, useState } from 'preact/hooks';\n\nexport interface ContentSlotContext {\n code: string;\n}\n\nexport interface HandlePlaceOrderContext {\n code: string;\n cartId: string;\n}\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n active?: boolean;\n handleValidation?: () => boolean;\n handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;\n slots?: {\n Content?: SlotProps<ContentSlotContext>;\n };\n}\n\nexport const PlaceOrder: Container<PlaceOrderProps> = ({\n disabled: disabledViaProp = false,\n active = true,\n handleValidation,\n handlePlaceOrder,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [hasOutOfStockItems, setHasOutOfStockItems] = useState(false);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n\n const translations = useText({\n CheckoutUnexpectedError: 'Checkout.ServerError.unexpected',\n placeOrderButton: 'Checkout.PlaceOrder.button',\n });\n\n const handlePlaceOrderError = useCallback(\n (error: any) => {\n const code = mapErrorToCode(error);\n\n const message =\n code === ErrorCodes.UNKNOWN_ERROR\n ? translations.CheckoutUnexpectedError\n : error.message;\n\n events.emit('checkout/error', { message, code });\n },\n [translations]\n );\n\n const handleClick = useCallback(async () => {\n try {\n if (handleValidation && !handleValidation()) return;\n\n await handlePlaceOrder({\n cartId: state.cartId!,\n code: getValue('selectedPaymentMethod')?.code ?? '',\n });\n } catch (error: any) {\n handlePlaceOrderError(error);\n }\n }, [handleValidation, handlePlaceOrder, handlePlaceOrderError]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || ('isEmpty' in data && data.isEmpty);\n\n if (isEmptyCart) {\n setHasOutOfStockItems(false);\n }\n },\n []\n );\n\n useEffect(() => {\n if (active === false) return;\n\n const onCartData = events.on(\n 'cart/initialized',\n (data) => {\n const items = (data?.items || []) as ItemModel[];\n setHasOutOfStockItems(\n items.some((item) => item.outOfStock || item.insufficientQuantity)\n );\n },\n { eager: true }\n );\n\n return () => {\n onCartData?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\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 (data) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <PlaceOrderComponent\n {...props}\n disabled={disabledViaProp || hasOutOfStockItems || hasQueuedUpdates}\n initialized={isInitialized}\n visible={active}\n onClick={handleClick}\n >\n <Slot\n context={{ code: getValue('selectedPaymentMethod')?.code ?? '' }}\n name=\"Content\"\n slot={slots?.Content}\n >\n {translations.placeOrderButton}\n </Slot>\n </PlaceOrderComponent>\n );\n};\n"],"names":["ErrorCodes","KNOWN_SERVER_ERRORS","classifiers","error","InvalidInput","Unauthenticated","mapErrorToCode","matchingClassifier","classifier","PlaceOrderSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PlaceOrderComponent","children","className","disabled","onClick","classes","Button","PlaceOrder","WithConditionals","disabledViaProp","active","handleValidation","handlePlaceOrder","slots","props","isInitialized","setIsInitialized","useState","hasOutOfStockItems","setHasOutOfStockItems","hasQueuedUpdates","hasPendingUpdates","translations","useText","handlePlaceOrderError","useCallback","code","message","events","handleClick","state","_a","getValue","handleCheckoutData","data","useEffect","onCartData","items","item","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","Slot"],"mappings":"ssBAqBY,IAAAA,GAAAA,IACVA,EAAA,cAAgB,gBAChBA,EAAA,aAAe,eACfA,EAAA,gBAAkB,kBAClBA,EAAA,cAAgB,gBAJNA,IAAAA,GAAA,CAAA,CAAA,EAOZ,MAAMC,EAAsB,CAAC,iBAAiB,EAgBjCC,EAAiC,CAC5C,CACE,KAAM,gBACN,QAAUC,GACDA,aAAiBC,CAE5B,EACA,CACE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,GAAI,CAACzB,EAAQ,OAEb,MAAMgC,EAAoBd,EAAO,GAC/B,mBACCM,GAAS,CACRD,EAAmBC,CAAI,CACzB,EACA,CAAE,MAAO,EAAM,CACjB,EAEA,MAAO,IAAM,CACXQ,GAAA,MAAAA,EAAmB,KACrB,CAAA,EACC,CAAChC,EAAQuB,CAAkB,CAAC,EAG7BnC,EAACE,EAAA,CACE,GAAGc,EACJ,SAAUL,GAAmBS,GAAsBE,EACnD,YAAaL,EACb,QAASL,EACT,QAASmB,EAET,SAAA/B,EAAC6C,EAAA,CACC,QAAS,CAAE,OAAMZ,EAAAC,EAAS,uBAAuB,IAAhC,YAAAD,EAAmC,OAAQ,EAAG,EAC/D,KAAK,UACL,KAAMlB,GAAA,YAAAA,EAAO,QAEZ,SAAaS,EAAA,gBAAA,CAAA,CAChB,CACF,CAEJ"}
1
+ {"version":3,"file":"PlaceOrder.js","sources":["/@dropins/storefront-checkout/src/lib/errors/classifiers.ts","/@dropins/storefront-checkout/src/lib/errors/mapErrorToCode.ts","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrderSkeleton.tsx","/@dropins/storefront-checkout/src/components/PlaceOrder/PlaceOrder.tsx","/@dropins/storefront-checkout/src/containers/PlaceOrder/PlaceOrder.tsx"],"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 { InvalidInput, Unauthenticated } from './customErrors';\n\nexport type ErrorCode = string;\n\nexport enum ErrorCodes {\n INVALID_INPUT = 'INVALID_INPUT',\n SERVER_ERROR = 'SERVER_ERROR',\n UNAUTHENTICATED = 'UNAUTHENTICATED',\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n}\n\nconst KNOWN_SERVER_ERRORS = ['PlaceOrderError'];\n\nexport interface ErrorClassifier {\n /**\n * The specific code to return if this classifier matches.\n */\n code: ErrorCode;\n /**\n * A function that returns `true` if it recognizes the error.\n * It must safely handle `unknown` inputs.\n */\n matches: (error: unknown) => boolean;\n}\n\n// Array of all known error classifiers.\n// The order is important! The first one to match will be used.\nexport const classifiers: ErrorClassifier[] = [\n {\n code: ErrorCodes.INVALID_INPUT,\n matches: (error: unknown): boolean => {\n return error instanceof InvalidInput;\n },\n },\n {\n code: ErrorCodes.UNAUTHENTICATED,\n matches: (error: unknown): boolean => {\n return error instanceof Unauthenticated;\n },\n },\n {\n code: ErrorCodes.SERVER_ERROR,\n matches: (error: unknown): boolean => {\n if (!error || typeof error !== 'object' || !('name' in error)) {\n return false;\n }\n\n return KNOWN_SERVER_ERRORS.includes((error as { name: string }).name);\n },\n },\n];\n","/********************************************************************\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 {\n classifiers,\n ErrorCode,\n ErrorCodes,\n} from '@/checkout/lib/errors/classifiers';\n\nexport function mapErrorToCode(error: unknown): ErrorCode {\n const matchingClassifier = classifiers.find((classifier) =>\n classifier.matches(error)\n );\n\n if (matchingClassifier) {\n return matchingClassifier.code;\n }\n\n return ErrorCodes.UNKNOWN_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 { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\nimport { FunctionComponent } from 'preact';\n\nexport const PlaceOrderSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"place-order-skeleton\">\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow size=\"small\" />\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/index';\nimport '@/checkout/components/PlaceOrder/PlaceOrder.css';\nimport { PlaceOrderSkeleton } from '@/checkout/components/PlaceOrder/PlaceOrderSkeleton';\nimport { Button } from '@adobe-commerce/elsie/components';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n onClick: (event: Event) => Promise<void>;\n}\n\nconst PlaceOrderComponent: FunctionComponent<PlaceOrderProps> = ({\n children,\n className,\n disabled = false,\n onClick,\n}) => {\n return (\n <div className={classes(['checkout-place-order', className])}>\n <Button\n key=\"placeOrder\"\n className=\"checkout-place-order__button\"\n data-testid=\"place-order-button\"\n disabled={disabled}\n size=\"medium\"\n type=\"button\"\n variant=\"primary\"\n onClick={onClick}\n >\n {children}\n </Button>\n </div>\n );\n};\n\nexport const PlaceOrder = WithConditionals(\n PlaceOrderComponent,\n PlaceOrderSkeleton\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 { PlaceOrder as PlaceOrderComponent } from '@/checkout/components/PlaceOrder/PlaceOrder';\nimport { Cart, NegotiableQuote } from '@/checkout/data/models';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingUpdates,\n state,\n} from '@/checkout/lib';\nimport { ErrorCodes, mapErrorToCode } from '@/checkout/lib/errors';\nimport { Item as ItemModel } from '@/checkout/types';\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 { useCallback, useEffect, useState } from 'preact/hooks';\n\nexport interface ContentSlotContext {\n code: string;\n}\n\nexport interface HandlePlaceOrderContext {\n code: string;\n cartId?: string | null;\n quoteId?: string | null;\n}\n\nexport interface PlaceOrderProps extends HTMLAttributes<HTMLDivElement> {\n disabled?: boolean;\n active?: boolean;\n handleValidation?: () => boolean;\n handlePlaceOrder: (ctx: HandlePlaceOrderContext) => Promise<void>;\n slots?: {\n Content?: SlotProps<ContentSlotContext>;\n };\n}\n\nexport const PlaceOrder: Container<PlaceOrderProps> = ({\n disabled: disabledViaProp = false,\n active = true,\n handleValidation,\n handlePlaceOrder,\n slots,\n ...props\n}) => {\n const [isInitialized, setIsInitialized] = useState(false);\n const [hasOutOfStockItems, setHasOutOfStockItems] = useState(false);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n\n const translations = useText({\n CheckoutUnexpectedError: 'Checkout.ServerError.unexpected',\n placeOrderButton: 'Checkout.PlaceOrder.button',\n });\n\n const handlePlaceOrderError = useCallback(\n (error: any) => {\n const code = mapErrorToCode(error);\n\n const message =\n code === ErrorCodes.UNKNOWN_ERROR\n ? translations.CheckoutUnexpectedError\n : error.message;\n\n events.emit('checkout/error', { message, code });\n },\n [translations]\n );\n\n const handleClick = useCallback(async () => {\n try {\n if (handleValidation && !handleValidation()) return;\n\n await handlePlaceOrder({\n cartId: state.cartId,\n quoteId: state.quoteId,\n code: getValue('selectedPaymentMethod')?.code ?? '',\n });\n } catch (error: any) {\n handlePlaceOrderError(error);\n }\n }, [handleValidation, handlePlaceOrder, handlePlaceOrderError]);\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || ('isEmpty' in data && data.isEmpty);\n\n if (isEmptyCart) {\n setHasOutOfStockItems(false);\n }\n },\n []\n );\n\n useEffect(() => {\n if (active === false) return;\n\n const onCartData = events.on(\n 'cart/initialized',\n (data) => {\n const items = (data?.items || []) as ItemModel[];\n setHasOutOfStockItems(\n items.some((item) => item.outOfStock || item.insufficientQuantity)\n );\n },\n { eager: true }\n );\n\n return () => {\n onCartData?.off();\n };\n }, [active]);\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n setIsInitialized(true);\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 (data) => {\n handleCheckoutData(data);\n },\n { eager: false }\n );\n\n return () => {\n onCheckoutUpdated?.off();\n };\n }, [active, handleCheckoutData]);\n\n return (\n <PlaceOrderComponent\n {...props}\n disabled={disabledViaProp || hasOutOfStockItems || hasQueuedUpdates}\n initialized={isInitialized}\n visible={active}\n onClick={handleClick}\n >\n <Slot\n context={{ code: getValue('selectedPaymentMethod')?.code ?? '' }}\n name=\"Content\"\n slot={slots?.Content}\n >\n {translations.placeOrderButton}\n </Slot>\n </PlaceOrderComponent>\n );\n};\n"],"names":["ErrorCodes","KNOWN_SERVER_ERRORS","classifiers","error","InvalidInput","Unauthenticated","mapErrorToCode","matchingClassifier","classifier","PlaceOrderSkeleton","jsxs","Skeleton","jsx","SkeletonRow","PlaceOrderComponent","children","className","disabled","onClick","classes","Button","PlaceOrder","WithConditionals","disabledViaProp","active","handleValidation","handlePlaceOrder","slots","props","isInitialized","setIsInitialized","useState","hasOutOfStockItems","setHasOutOfStockItems","hasQueuedUpdates","hasPendingUpdates","translations","useText","handlePlaceOrderError","useCallback","code","message","events","handleClick","state","_a","getValue","handleCheckoutData","data","useEffect","onCartData","items","item","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","Slot"],"mappings":"ssBAqBY,IAAAA,GAAAA,IACVA,EAAA,cAAgB,gBAChBA,EAAA,aAAe,eACfA,EAAA,gBAAkB,kBAClBA,EAAA,cAAgB,gBAJNA,IAAAA,GAAA,CAAA,CAAA,EAOZ,MAAMC,EAAsB,CAAC,iBAAiB,EAgBjCC,EAAiC,CAC5C,CACE,KAAM,gBACN,QAAUC,GACDA,aAAiBC,CAE5B,EACA,CACE,KAAM,kBACN,QAAUD,GACDA,aAAiBE,CAE5B,EACA,CACE,KAAM,eACN,QAAUF,GACJ,CAACA,GAAS,OAAOA,GAAU,UAAY,EAAE,SAAUA,GAC9C,GAGFF,EAAoB,SAAUE,EAA2B,IAAI,CACtE,CAEJ,EC5CO,SAASG,EAAeH,EAA2B,CACxD,MAAMI,EAAqBL,EAAY,KAAMM,GAC3CA,EAAW,QAAQL,CAAK,CAC1B,EAEA,OAAII,EACKA,EAAmB,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EACnD,YAAaL,EACb,QAASL,EACT,QAASmB,EAET,SAAA/B,EAAC6C,EAAA,CACC,QAAS,CAAE,OAAMZ,EAAAC,EAAS,uBAAuB,IAAhC,YAAAD,EAAmC,OAAQ,EAAG,EAC/D,KAAK,UACL,KAAMlB,GAAA,YAAAA,EAAO,QAEZ,SAAaS,EAAA,gBAAA,CAAA,CAChB,CACF,CAEJ"}
@@ -1,5 +1,5 @@
1
1
  import { ShippingMethod } from '../../data/models';
2
- import { TitleProps, UIComponentType } from '../../types';
2
+ import { Filter, TitleProps, UIComponentType } from '../../types';
3
3
  import { Container } from '@dropins/tools/types/elsie/src/lib';
4
4
  import { HTMLAttributes } from 'preact/compat';
5
5
 
@@ -7,6 +7,7 @@ interface CartSyncError {
7
7
  method: ShippingMethod;
8
8
  error: Error;
9
9
  }
10
+ export type ShippingOptionsFilter = Filter<ShippingMethod>;
10
11
  export interface ShippingMethodsProps extends HTMLAttributes<HTMLDivElement>, TitleProps {
11
12
  UIComponentType?: UIComponentType;
12
13
  active?: boolean;
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{jsxs as H,jsx as r,Fragment as q}from"@dropins/tools/preact-jsx-runtime.js";import{h as ee,a as te}from"../chunks/fetch-graphql.js";import{classes as z,VComponent as re,Slot as ne}from"@dropins/tools/lib.js";import{t as oe}from"../chunks/transform-shipping-estimate.js";import{h as A,g as ie}from"../chunks/events.js";import{n as se,g as D}from"../chunks/values.js";import{events as W}from"@dropins/tools/event-bus.js";import{s as ce}from"../chunks/setShippingMethods.js";import{W as ae}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as le,SkeletonRow as B,IllustratedMessage as ue,Icon as pe,InLineAlert as de,RadioButton as he,Price as F,ToggleButton as me}from"@dropins/tools/components.js";import{s as fe}from"../chunks/dom.js";import{useRef as ge,useEffect as T,useState as w,useCallback as k,useMemo as ke}from"@dropins/tools/preact-hooks.js";import*as a from"@dropins/tools/preact-compat.js";import{useText as Q}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../chunks/transform-shipping-methods.js";const ve=i=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Ee=()=>H(le,{"data-testid":"shipping-methods-skeleton",children:[r(B,{size:"small",variant:"heading"}),r(B,{size:"small",variant:"empty"}),r(B,{fullWidth:!0,size:"medium"}),r(B,{fullWidth:!0,size:"medium"})]}),Se=({className:i,busy:t=!1,onSelectionChange:u=()=>{},options:v,selection:d,title:l,UIComponentType:p="RadioButton",error:h=null,onDismissError:V=()=>{},...R})=>{const E=Q({EmptyState:"Checkout.ShippingMethods.emptyState"}),S=h!==null,C=ge(null);T(()=>{S&&C.current&&fe(C.current)},[S]);const j=(n,U)=>{const M={busy:t,className:"checkout-shipping-methods__method",key:n.value,name:"shipping-method",value:n.value,onChange:()=>u(n)};return U==="RadioButton"?r(he,{...M,checked:(d==null?void 0:d.value)===n.value,"data-testid":"shipping-method-radioButton",description:n.title,disabled:t,id:n.value,label:H(q,{children:[r(F,{amount:n.amount.value,currency:n.amount.currency})," ",r("span",{children:n.carrier.title})]})}):r(me,{...M,"data-testid":"shipping-method-toggleButton",label:H(q,{children:[r("span",{children:n.carrier.title}),r(F,{amount:n.amount.value,currency:n.amount.currency})]}),selected:(d==null?void 0:d.value)===n.value})};return H("div",{...R,className:z(["checkout-shipping-methods",i]),"data-testid":"checkout-shipping-methods",children:[l&&r(re,{className:"checkout-shipping-methods__title",node:l}),r("div",{className:z(["checkout-shipping-methods__content"]),children:r("div",{className:z(["checkout-shipping-methods__options",["checkout-shipping-methods__options--busy",t],["checkout-shipping-methods__options--toggleButton",p==="ToggleButton"]]),"data-testid":"checkout-shipping-methods-options",children:v.length===0?r(ue,{"data-testid":"checkout-shipping-methods-empty",icon:r(pe,{source:ve}),message:r("p",{children:E.EmptyState})}):v.map(n=>j(n,p))})}),S&&r("div",{ref:C,className:"checkout-shipping-methods__error","data-testid":"checkout-shipping-methods-alert",children:r(de,{heading:h,type:"error",variant:"primary",onDismiss:V})})]})},Ce=ae(Se,Ee);function Me(i,t){return i?t.some(u=>I(u,i)):!1}function I(i,t){return!i||!t||i.amount.value!==t.amount.value?!1:i.code===t.code&&i.carrier.code===t.carrier.code}function Le(i){const t=W.lastPayload("shipping/estimate");t&&W.emit("shipping/estimate",{...t,shippingMethod:oe(i)})}const Ze=({UIComponentType:i="RadioButton",active:t=!0,autoSync:u=!0,displayTitle:v=!0,initialData:d,slots:l,onCartSyncError:p,onSelectionChange:h,...V})=>{const[R,E]=w(null),[S,C]=w(!1),[j,n]=w(),[U,M]=w(null),$=ee.value,G=te.value,{cartSyncError:N,defaultTitle:P}=Q({cartSyncError:"Checkout.ShippingMethods.cartSyncError",defaultTitle:"Checkout.ShippingMethods.title"}),J=k(()=>{E(null)},[]),c=k(e=>{E(null),M(o=>I(o,e)?o:(se({selectedShippingMethod:e}),e))},[]),L=k(async(e,o)=>{if(!u||!A())return;const s={carrierCode:e.carrier.code,methodCode:e.code};ce([s]).catch(m=>{c(o??null),p==null||p({method:e,error:m}),p||E(N)})},[u,c,p,N]),K=k(async e=>{const o=D("selectedShippingMethod");c(e),h==null||h(e),A()||Le(e),await L(e,o)},[h,c,L]),y=k(e=>{var O;const o=!e||e.isEmpty,s=!!(e!=null&&e.isVirtual);if(o||s){C(s),c(null),n([]);return}const m=(O=e.shippingAddresses)==null?void 0:O[0];if(!m)return;const f=m.availableShippingMethods??[];if(n(f),f.length===0){c(null);return}const _=m.selectedShippingMethod??null,g=D("selectedShippingMethod"),x=Me(g,f),Y=I(g,_);if(g&&x&&!Y){L(g,_);return}if((!g||!x)&&_){c(_);return}if((!g||!x)&&!_){const Z=f[0];c(Z),u&&L(Z)}},[L,c,u]),b=k(e=>{if(e===void 0)return;const{shippingMethod:o,availableShippingMethods:s}=e,m=(s==null?void 0:s.find(f=>f.code===(o==null?void 0:o.methodCode)&&f.carrier.code===(o==null?void 0:o.carrierCode)))??null;n(s),c(m)},[c]);T(()=>{if(!t)return;const e=ie();if(e){const s=D("selectedShippingMethod");s&&M(s),y(e);return}const o=W.on("checkout/initialized",y,{eager:!0});return()=>{o==null||o.off()}},[t,y]),T(()=>{if(!t)return;const e=W.on("checkout/updated",y,{eager:!1});return()=>{e==null||e.off()}},[t,y]),T(()=>{if(!t||A())return;const e=W.on("shipping/estimate",b,{eager:!0});return()=>{e==null||e.off()}},[t,b]);const X=ke(()=>{if(v)return r(ne,{name:"checkout-shipping-methods-title",slot:l==null?void 0:l.Title,children:r("h3",{children:P})})},[v,l==null?void 0:l.Title,P]);return r(Ce,{...V,UIComponentType:i,busy:$||G,error:R,initialized:j!==void 0,options:j??[],selection:U,title:X,visible:t&&!S,onDismissError:J,onSelectionChange:K})};export{Ze as ShippingMethods,Ze as default,Le as emitShippingEstimateEvent};
3
+ import{jsxs as V,jsx as n,Fragment as G}from"@dropins/tools/preact-jsx-runtime.js";import{h as ce,a as ae}from"../chunks/fetch-graphql.js";import{classes as z,VComponent as le,Slot as ue}from"@dropins/tools/lib.js";import{t as pe}from"../chunks/transform-shipping-estimate.js";import{h as D,g as de}from"../chunks/events.js";import{n as he,g as I}from"../chunks/values.js";import{events as B}from"@dropins/tools/event-bus.js";import{c as J}from"../chunks/synchronizeCheckout.js";import{s as me}from"../chunks/setShippingMethods.js";import{W as fe}from"../chunks/ConditionalWrapper.js";/* empty css */import{Skeleton as ge,SkeletonRow as O,IllustratedMessage as ke,Icon as ve,InLineAlert as Se,RadioButton as Ee,Price as K,ToggleButton as Ce}from"@dropins/tools/components.js";import{s as Le}from"../chunks/dom.js";import{useRef as Me,useEffect as A,useState as T,useCallback as p,useMemo as X}from"@dropins/tools/preact-hooks.js";import*as a from"@dropins/tools/preact-compat.js";import{useText as Y}from"@dropins/tools/i18n.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/transform-shipping-methods.js";import"../chunks/guards.js";const ye=i=>a.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),a.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),_e=()=>V(ge,{"data-testid":"shipping-methods-skeleton",children:[n(O,{size:"small",variant:"heading"}),n(O,{size:"small",variant:"empty"}),n(O,{fullWidth:!0,size:"medium"}),n(O,{fullWidth:!0,size:"medium"})]}),We=({className:i,busy:r=!1,onSelectionChange:g=()=>{},options:v,selection:d,title:l,UIComponentType:u="RadioButton",error:h=null,onDismissError:R=()=>{},...b})=>{const S=Y({EmptyState:"Checkout.ShippingMethods.emptyState"}),E=h!==null,C=Me(null);A(()=>{E&&C.current&&Le(C.current)},[E]);const L=(o,U)=>{const M={busy:r,className:"checkout-shipping-methods__method",key:o.value,name:"shipping-method",value:o.value,onChange:()=>g(o)};return U==="RadioButton"?n(Ee,{...M,checked:(d==null?void 0:d.value)===o.value,"data-testid":"shipping-method-radioButton",description:o.title,disabled:r,id:o.value,label:V(G,{children:[n(K,{amount:o.amount.value,currency:o.amount.currency})," ",n("span",{children:o.carrier.title})]})}):n(Ce,{...M,"data-testid":"shipping-method-toggleButton",label:V(G,{children:[n("span",{children:o.carrier.title}),n(K,{amount:o.amount.value,currency:o.amount.currency})]}),selected:(d==null?void 0:d.value)===o.value})};return V("div",{...b,className:z(["checkout-shipping-methods",i]),"data-testid":"checkout-shipping-methods",children:[l&&n(le,{className:"checkout-shipping-methods__title",node:l}),n("div",{className:z(["checkout-shipping-methods__content"]),children:n("div",{className:z(["checkout-shipping-methods__options",["checkout-shipping-methods__options--busy",r],["checkout-shipping-methods__options--toggleButton",u==="ToggleButton"]]),"data-testid":"checkout-shipping-methods-options",children:v.length===0?n(ke,{"data-testid":"checkout-shipping-methods-empty",icon:n(ve,{source:ye}),message:n("p",{children:S.EmptyState})}):v.map(o=>L(o,u))})}),E&&n("div",{ref:C,className:"checkout-shipping-methods__error","data-testid":"checkout-shipping-methods-alert",children:n(Se,{heading:h,type:"error",variant:"primary",onDismiss:R})})]})},je=fe(We,_e);function N(i,r){return i?r.some(g=>P(g,i)):!1}function P(i,r){return!i||!r||i.amount.value!==r.amount.value?!1:i.code===r.code&&i.carrier.code===r.carrier.code}function Be(i){const r=B.lastPayload("shipping/estimate");r&&B.emit("shipping/estimate",{...r,shippingMethod:pe(i)})}const Ge=({UIComponentType:i="RadioButton",active:r=!0,autoSync:g=!0,displayTitle:v=!0,initialData:d,slots:l,onCartSyncError:u,onSelectionChange:h,...R})=>{const[b,S]=T(null),[E,C]=T(!1),[L,o]=T(),[U,M]=T(null),ee=ce.value,te=ae.value,{cartSyncError:Z,defaultTitle:q}=Y({cartSyncError:"Checkout.ShippingMethods.cartSyncError",defaultTitle:"Checkout.ShippingMethods.title"}),w=p(e=>{if(!e||e.length===0)return[];const{shipping:t}=J.getConfig();return t!=null&&t.filterOptions?e.filter(t.filterOptions):e},[]),F=p(e=>{if(e.length===0)return null;const{defaults:t}=J.getConfig();return t.selectedShippingMethod(e)},[]),re=X(()=>w(L),[L,w]),ne=p(()=>{S(null)},[]),c=p(e=>{S(null),M(t=>P(t,e)?t:(he({selectedShippingMethod:e}),e))},[]),y=p(async(e,t)=>{if(!g||!D())return;const s={carrierCode:e.carrier.code,methodCode:e.code};me([s]).catch(m=>{c(t??null),u==null||u({method:e,error:m}),u||S(Z)})},[g,c,u,Z]),oe=p(async e=>{const t=I("selectedShippingMethod");c(e),h==null||h(e),D()||Be(e),await y(e,t)},[h,c,y]),_=p(e=>{var $;const t=!e||e.isEmpty,s=!!(e!=null&&e.isVirtual);if(t||s){C(s),c(null),o([]);return}const m=($=e.shippingAddresses)==null?void 0:$[0];if(!m)return;const W=m.availableShippingMethods??[],j=w(W);if(o(W),j.length===0){c(null);return}const f=m.selectedShippingMethod??null,k=I("selectedShippingMethod"),x=N(k,j),se=P(k,f);if(k&&x&&!se){y(k,f);return}if((!k||!x)&&f&&N(f,j)){c(f);return}if((!k||!x)&&(!f||!N(f,j))){const H=F(j);c(H),H&&y(H)}},[w,F,c,y]),Q=p(e=>{if(e===void 0)return;const{shippingMethod:t,availableShippingMethods:s}=e,m=(s==null?void 0:s.find(W=>W.code===(t==null?void 0:t.methodCode)&&W.carrier.code===(t==null?void 0:t.carrierCode)))??null;o(s),c(m)},[c]);A(()=>{if(!r)return;const e=de();if(e){const s=I("selectedShippingMethod");s&&M(s),_(e);return}const t=B.on("checkout/initialized",_,{eager:!0});return()=>{t==null||t.off()}},[r,_]),A(()=>{if(!r)return;const e=B.on("checkout/updated",_,{eager:!1});return()=>{e==null||e.off()}},[r,_]),A(()=>{if(!r||D())return;const e=B.on("shipping/estimate",Q,{eager:!0});return()=>{e==null||e.off()}},[r,Q]);const ie=X(()=>{if(v)return n(ue,{name:"checkout-shipping-methods-title",slot:l==null?void 0:l.Title,children:n("h3",{children:q})})},[v,l==null?void 0:l.Title,q]);return n(je,{...R,UIComponentType:i,busy:ee||te,error:b,initialized:L!==void 0,options:re,selection:U,title:ie,visible:r&&!E,onDismissError:ne,onSelectionChange:oe})};export{Ge as ShippingMethods,Ge as default,Be as emitShippingEstimateEvent};
4
4
  //# sourceMappingURL=ShippingMethods.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ShippingMethods.js","sources":["../../node_modules/@adobe-commerce/elsie/src/icons/Delivery.svg","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethods.tsx","/@dropins/storefront-checkout/src/containers/ShippingMethods/ShippingMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgDelivery = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M15.1758 5.87573H19.0019L21.0394 10.7636\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M8.08792 7.63574H1.69824\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.11229 10.3619H1\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M5.16084 13.0402H1.92773\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76172 16.7611H15.2809\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.38672 16.7611H5.17025\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgDelivery;\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 { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const ShippingMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"shipping-methods-skeleton\">\n <SkeletonRow size=\"small\" variant=\"heading\" />\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\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 { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/ShippingMethods/ShippingMethods.css';\nimport { ShippingMethodsSkeleton } from '@/checkout/components/ShippingMethods/ShippingMethodsSkeleton';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n Price,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Delivery } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useEffect, useRef } from 'preact/hooks';\n\nexport interface ShippingMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n error?: string | null;\n onDismissError?: () => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n options: ShippingMethod[];\n selection: ShippingMethod | null;\n title?: VNode;\n}\n\nconst ShippingMethodsComponent: FunctionComponent<ShippingMethodsProps> = ({\n className,\n busy = false,\n onSelectionChange = () => {},\n options,\n selection,\n title,\n UIComponentType = 'RadioButton',\n error = null,\n onDismissError = () => {},\n ...props\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.ShippingMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n const renderShippingMethod = (\n method: ShippingMethod,\n type: UIComponentType\n ) => {\n const commonProps = {\n busy,\n className: 'checkout-shipping-methods__method',\n key: method.value,\n name: 'shipping-method',\n value: method.value,\n onChange: () => onSelectionChange(method),\n };\n\n if (type === 'RadioButton') {\n return (\n <RadioButton\n {...commonProps}\n checked={selection?.value === method.value}\n data-testid=\"shipping-method-radioButton\"\n description={method.title}\n disabled={busy}\n id={method.value}\n label={\n <>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n &nbsp;\n <span>{method.carrier.title}</span>\n </>\n }\n />\n );\n }\n\n return (\n <ToggleButton\n {...commonProps}\n data-testid=\"shipping-method-toggleButton\"\n label={\n <>\n <span>{method.carrier.title}</span>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n </>\n }\n selected={selection?.value === method.value}\n />\n );\n };\n\n return (\n <div\n {...props}\n className={classes(['checkout-shipping-methods', className])}\n data-testid=\"checkout-shipping-methods\"\n >\n {title && (\n <VComponent className=\"checkout-shipping-methods__title\" node={title} />\n )}\n\n <div className={classes(['checkout-shipping-methods__content'])}>\n <div\n className={classes([\n 'checkout-shipping-methods__options',\n ['checkout-shipping-methods__options--busy', busy],\n [\n 'checkout-shipping-methods__options--toggleButton',\n UIComponentType === 'ToggleButton',\n ],\n ])}\n data-testid=\"checkout-shipping-methods-options\"\n >\n {options.length === 0 ? (\n <IllustratedMessage\n data-testid=\"checkout-shipping-methods-empty\"\n icon={<Icon source={Delivery} />}\n message={<p>{translations.EmptyState}</p>}\n />\n ) : (\n options.map((method: ShippingMethod) =>\n renderShippingMethod(method, UIComponentType)\n )\n )}\n </div>\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-shipping-methods__error\"\n data-testid=\"checkout-shipping-methods-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 ShippingMethods = WithConditionals(\n ShippingMethodsComponent,\n ShippingMethodsSkeleton\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 { setShippingMethods } from '@/checkout/api';\nimport { ShippingMethods as ShippingMethodsComponent } from '@/checkout/components/ShippingMethods';\nimport {\n Cart,\n NegotiableQuote,\n ShippingEstimate,\n ShippingMethod,\n ShippingMethodInput,\n} from '@/checkout/data/models';\nimport { transformShippingEstimateShippingMethod } from '@/checkout/data/transforms';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingShippingEstimate,\n hasPendingUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n method: ShippingMethod;\n error: Error;\n}\n\nexport interface ShippingMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n}\n\nfunction isMethodAvailable(\n method: ShippingMethod | null,\n options: ShippingMethod[]\n) {\n if (!method) return false;\n return options.some((option) => isEqual(option, method));\n}\n\nfunction isEqual(a: ShippingMethod | null, b: ShippingMethod | null) {\n if (!a || !b) return false;\n if (a.amount.value !== b.amount.value) return false;\n return a.code === b.code && a.carrier.code === b.carrier.code;\n}\n\nexport function emitShippingEstimateEvent(selection: ShippingMethod) {\n const shippingEstimatedEvent = events.lastPayload('shipping/estimate');\n\n if (!shippingEstimatedEvent) return;\n\n events.emit('shipping/estimate', {\n ...shippingEstimatedEvent,\n shippingMethod: transformShippingEstimateShippingMethod(selection),\n });\n}\n\nexport const ShippingMethods: Container<ShippingMethodsProps> = ({\n UIComponentType = 'RadioButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n initialData,\n slots,\n onCartSyncError,\n onSelectionChange,\n ...props\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [options, setOptions] = useState<ShippingMethod[] | undefined>();\n const [selection, setSelection] = useState<ShippingMethod | null>(null);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n const hasPendingEstimations = hasPendingShippingEstimate.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.ShippingMethods.cartSyncError',\n defaultTitle: 'Checkout.ShippingMethods.title',\n });\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback(\n (shippingMethod: ShippingMethod | null) => {\n setError(null);\n setSelection((prev) => {\n if (isEqual(prev, shippingMethod)) return prev;\n notifyValues({ selectedShippingMethod: shippingMethod });\n return shippingMethod;\n });\n },\n []\n );\n\n const setUserSelectionOnCart = useCallback(\n async (selection: ShippingMethod, fallback?: ShippingMethod | null) => {\n if (!autoSync || !hasShippingAddress()) return;\n\n const shippingMethodInput: ShippingMethodInput = {\n carrierCode: selection.carrier.code,\n methodCode: selection.code,\n };\n\n setShippingMethods([shippingMethodInput]).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, setUserSelection, onCartSyncError, cartSyncError]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: ShippingMethod) => {\n const prevSelection = getValue('selectedShippingMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n if (!hasShippingAddress()) {\n emitShippingEstimateEvent(selection);\n }\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setIsVirtual(isVirtualCart);\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const primaryAddress = data!.shippingAddresses?.[0];\n\n // If there is no primary address, options are handled by the shipping estimation\n if (!primaryAddress) return;\n\n const availableOptions = primaryAddress.availableShippingMethods ?? [];\n setOptions(availableOptions);\n\n // If there are no available options, reset the user selection\n if (availableOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = primaryAddress.selectedShippingMethod ?? null;\n\n const userSelection = getValue('selectedShippingMethod');\n const isAvailable = isMethodAvailable(userSelection, availableOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // Handle user selection that's available but different from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // If no user selection or not available, decide what to do based on cart and available options\n if ((!userSelection || !isAvailable) && cartSelection) {\n setUserSelection(cartSelection);\n return;\n }\n\n if ((!userSelection || !isAvailable) && !cartSelection) {\n const newSelection = availableOptions[0];\n setUserSelection(newSelection);\n\n // Only sync to cart if autoSync is enabled\n if (autoSync) {\n setUserSelectionOnCart(newSelection);\n }\n }\n },\n [setUserSelectionOnCart, setUserSelection, autoSync]\n );\n\n const handleShippingEstimate = useCallback(\n (estimation: ShippingEstimate | undefined) => {\n if (estimation === undefined) return;\n\n const { shippingMethod, availableShippingMethods } = estimation;\n const selectedShippingMethod =\n availableShippingMethods?.find(\n (method) =>\n method.code === shippingMethod?.methodCode &&\n method.carrier.code === shippingMethod?.carrierCode\n ) ?? null;\n\n setOptions(availableShippingMethods);\n setUserSelection(selectedShippingMethod);\n },\n [setUserSelection]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedShippingMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n\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 useEffect(() => {\n if (!active || hasShippingAddress()) 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 const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-shipping-methods-title\" slot={slots?.Title}>\n <h3>{defaultTitle}</h3>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <ShippingMethodsComponent\n {...props}\n UIComponentType={UIComponentType}\n busy={hasQueuedUpdates || hasPendingEstimations}\n error={error}\n initialized={options !== undefined}\n options={options ?? []}\n selection={selection}\n title={titleContent}\n visible={active && !isVirtual}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgDelivery","props","React","ShippingMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","ShippingMethodsComponent","className","busy","onSelectionChange","options","selection","title","UIComponentType","error","onDismissError","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","renderShippingMethod","method","type","commonProps","RadioButton","Fragment","Price","ToggleButton","classes","VComponent","IllustratedMessage","Icon","Delivery","InLineAlert","ShippingMethods","WithConditionals","isMethodAvailable","option","isEqual","a","b","emitShippingEstimateEvent","shippingEstimatedEvent","events","transformShippingEstimateShippingMethod","active","autoSync","displayTitle","initialData","slots","onCartSyncError","setError","useState","isVirtual","setIsVirtual","setOptions","setSelection","hasQueuedUpdates","hasPendingUpdates","hasPendingEstimations","hasPendingShippingEstimate","cartSyncError","defaultTitle","handleDismissError","useCallback","setUserSelection","shippingMethod","prev","notifyValues","setUserSelectionOnCart","fallback","hasShippingAddress","shippingMethodInput","setShippingMethods","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","isEmptyCart","isVirtualCart","primaryAddress","_a","availableOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastUpdate","getLatestCheckoutUpdate","onCheckoutInit","onCheckoutUpdated","onShippingEstimate","titleContent","useMemo","Slot"],"mappings":"8rCACA,MAAMA,GAAeC,GAA0BC,EAAM,cAAc,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,QAAS,YAAa,KAAM,OAAQ,MAAO,6BAA8B,GAAGD,GAAyBC,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,oEAAqE,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2CAA4C,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,iQAAkQ,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAS,CAAA,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,kNAAmN,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM,cAAc,OAAQ,CAAE,aAAc,qBAAsB,EAAG,2BAA4B,OAAQ,eAAgB,YAAa,EAAG,cAAe,QAAS,eAAgB,OAAO,CAAE,EAAmBA,EAAM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elsie/src/icons/Delivery.svg","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethodsSkeleton.tsx","/@dropins/storefront-checkout/src/components/ShippingMethods/ShippingMethods.tsx","/@dropins/storefront-checkout/src/containers/ShippingMethods/ShippingMethods.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgDelivery = (props) => /* @__PURE__ */ React.createElement(\"svg\", { width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M15.1758 5.87573H19.0019L21.0394 10.7636\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M8.08792 7.63574H1.69824\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M7.11229 10.3619H1\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M5.16084 13.0402H1.92773\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M9.76172 16.7611H15.2809\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M2.38672 16.7611H5.17025\", stroke: \"currentColor\", strokeWidth: 1, strokeLinecap: \"round\", strokeLinejoin: \"round\" }));\nexport default SvgDelivery;\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 { FunctionComponent } from 'preact';\nimport { Skeleton, SkeletonRow } from '@adobe-commerce/elsie/components';\n\nexport const ShippingMethodsSkeleton: FunctionComponent = () => {\n return (\n <Skeleton data-testid=\"shipping-methods-skeleton\">\n <SkeletonRow size=\"small\" variant=\"heading\" />\n <SkeletonRow size=\"small\" variant=\"empty\" />\n <SkeletonRow fullWidth={true} size=\"medium\" />\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 { WithConditionals } from '@/checkout/components/ConditionalWrapper/ConditionalWrapper';\nimport '@/checkout/components/ShippingMethods/ShippingMethods.css';\nimport { ShippingMethodsSkeleton } from '@/checkout/components/ShippingMethods/ShippingMethodsSkeleton';\nimport { ShippingMethod } from '@/checkout/data/models';\nimport { scrollToElement } from '@/checkout/lib';\nimport { UIComponentType } from '@/checkout/types';\nimport {\n Icon,\n IllustratedMessage,\n InLineAlert,\n Price,\n RadioButton,\n ToggleButton,\n} from '@adobe-commerce/elsie/components';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Delivery } from '@adobe-commerce/elsie/icons';\nimport { classes, VComponent } from '@adobe-commerce/elsie/lib';\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useEffect, useRef } from 'preact/hooks';\n\nexport interface ShippingMethodsProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n UIComponentType?: UIComponentType;\n busy?: boolean;\n error?: string | null;\n onDismissError?: () => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n options: ShippingMethod[];\n selection: ShippingMethod | null;\n title?: VNode;\n}\n\nconst ShippingMethodsComponent: FunctionComponent<ShippingMethodsProps> = ({\n className,\n busy = false,\n onSelectionChange = () => {},\n options,\n selection,\n title,\n UIComponentType = 'RadioButton',\n error = null,\n onDismissError = () => {},\n ...props\n}) => {\n const translations = useText({\n EmptyState: 'Checkout.ShippingMethods.emptyState',\n });\n\n const hasError = error !== null;\n const errorRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (hasError && errorRef.current) {\n scrollToElement(errorRef.current);\n }\n }, [hasError]);\n\n const renderShippingMethod = (\n method: ShippingMethod,\n type: UIComponentType\n ) => {\n const commonProps = {\n busy,\n className: 'checkout-shipping-methods__method',\n key: method.value,\n name: 'shipping-method',\n value: method.value,\n onChange: () => onSelectionChange(method),\n };\n\n if (type === 'RadioButton') {\n return (\n <RadioButton\n {...commonProps}\n checked={selection?.value === method.value}\n data-testid=\"shipping-method-radioButton\"\n description={method.title}\n disabled={busy}\n id={method.value}\n label={\n <>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n &nbsp;\n <span>{method.carrier.title}</span>\n </>\n }\n />\n );\n }\n\n return (\n <ToggleButton\n {...commonProps}\n data-testid=\"shipping-method-toggleButton\"\n label={\n <>\n <span>{method.carrier.title}</span>\n <Price\n amount={method.amount.value}\n currency={method.amount.currency}\n />\n </>\n }\n selected={selection?.value === method.value}\n />\n );\n };\n\n return (\n <div\n {...props}\n className={classes(['checkout-shipping-methods', className])}\n data-testid=\"checkout-shipping-methods\"\n >\n {title && (\n <VComponent className=\"checkout-shipping-methods__title\" node={title} />\n )}\n\n <div className={classes(['checkout-shipping-methods__content'])}>\n <div\n className={classes([\n 'checkout-shipping-methods__options',\n ['checkout-shipping-methods__options--busy', busy],\n [\n 'checkout-shipping-methods__options--toggleButton',\n UIComponentType === 'ToggleButton',\n ],\n ])}\n data-testid=\"checkout-shipping-methods-options\"\n >\n {options.length === 0 ? (\n <IllustratedMessage\n data-testid=\"checkout-shipping-methods-empty\"\n icon={<Icon source={Delivery} />}\n message={<p>{translations.EmptyState}</p>}\n />\n ) : (\n options.map((method: ShippingMethod) =>\n renderShippingMethod(method, UIComponentType)\n )\n )}\n </div>\n </div>\n\n {hasError && (\n <div\n ref={errorRef}\n className=\"checkout-shipping-methods__error\"\n data-testid=\"checkout-shipping-methods-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 ShippingMethods = WithConditionals(\n ShippingMethodsComponent,\n ShippingMethodsSkeleton\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 { config, setShippingMethods } from '@/checkout/api';\nimport { ShippingMethods as ShippingMethodsComponent } from '@/checkout/components/ShippingMethods';\nimport {\n Cart,\n NegotiableQuote,\n ShippingEstimate,\n ShippingMethod,\n ShippingMethodInput,\n} from '@/checkout/data/models';\nimport { transformShippingEstimateShippingMethod } from '@/checkout/data/transforms';\nimport {\n getLatestCheckoutUpdate,\n getValue,\n hasPendingShippingEstimate,\n hasPendingUpdates,\n hasShippingAddress,\n notifyValues,\n} from '@/checkout/lib';\nimport { Filter, TitleProps, UIComponentType } from '@/checkout/types';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { Container, Slot } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { HTMLAttributes } from 'preact/compat';\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\n\ninterface CartSyncError {\n method: ShippingMethod;\n error: Error;\n}\n\nexport type ShippingOptionsFilter = Filter<ShippingMethod>;\n\nexport interface ShippingMethodsProps\n extends HTMLAttributes<HTMLDivElement>,\n TitleProps {\n UIComponentType?: UIComponentType;\n active?: boolean;\n autoSync?: boolean;\n onCartSyncError?: (error: CartSyncError) => void;\n onSelectionChange?: (method: ShippingMethod) => void;\n}\n\nfunction isMethodAvailable(\n method: ShippingMethod | null,\n options: ShippingMethod[]\n) {\n if (!method) return false;\n return options.some((option) => isEqual(option, method));\n}\n\nfunction isEqual(a: ShippingMethod | null, b: ShippingMethod | null) {\n if (!a || !b) return false;\n if (a.amount.value !== b.amount.value) return false;\n return a.code === b.code && a.carrier.code === b.carrier.code;\n}\n\nexport function emitShippingEstimateEvent(selection: ShippingMethod) {\n const shippingEstimatedEvent = events.lastPayload('shipping/estimate');\n\n if (!shippingEstimatedEvent) return;\n\n events.emit('shipping/estimate', {\n ...shippingEstimatedEvent,\n shippingMethod: transformShippingEstimateShippingMethod(selection),\n });\n}\n\nexport const ShippingMethods: Container<ShippingMethodsProps> = ({\n UIComponentType = 'RadioButton',\n active = true,\n autoSync = true,\n displayTitle = true,\n initialData,\n slots,\n onCartSyncError,\n onSelectionChange,\n ...props\n}) => {\n const [error, setError] = useState<string | null>(null);\n const [isVirtual, setIsVirtual] = useState(false);\n const [options, setOptions] = useState<ShippingMethod[] | undefined>();\n const [selection, setSelection] = useState<ShippingMethod | null>(null);\n\n const hasQueuedUpdates = hasPendingUpdates.value;\n const hasPendingEstimations = hasPendingShippingEstimate.value;\n\n const { cartSyncError, defaultTitle } = useText({\n cartSyncError: 'Checkout.ShippingMethods.cartSyncError',\n defaultTitle: 'Checkout.ShippingMethods.title',\n });\n\n const filterOptions = useCallback(\n (shippingMethods: ShippingMethod[] | undefined) => {\n if (!shippingMethods || shippingMethods.length === 0) return [];\n const { shipping } = config.getConfig();\n if (!shipping?.filterOptions) return shippingMethods;\n return shippingMethods.filter(shipping.filterOptions);\n },\n []\n );\n\n const preselectOption = useCallback((shippingMethods: ShippingMethod[]) => {\n if (shippingMethods.length === 0) return null;\n const { defaults } = config.getConfig();\n return defaults!.selectedShippingMethod!(shippingMethods);\n }, []);\n\n const filteredOptions = useMemo(() => {\n return filterOptions(options);\n }, [options, filterOptions]);\n\n const handleDismissError = useCallback(() => {\n setError(null);\n }, []);\n\n const setUserSelection = useCallback(\n (shippingMethod: ShippingMethod | null) => {\n setError(null);\n setSelection((prev) => {\n if (isEqual(prev, shippingMethod)) return prev;\n notifyValues({ selectedShippingMethod: shippingMethod });\n return shippingMethod;\n });\n },\n []\n );\n\n const setUserSelectionOnCart = useCallback(\n async (selection: ShippingMethod, fallback?: ShippingMethod | null) => {\n if (!autoSync || !hasShippingAddress()) return;\n\n const shippingMethodInput: ShippingMethodInput = {\n carrierCode: selection.carrier.code,\n methodCode: selection.code,\n };\n\n setShippingMethods([shippingMethodInput]).catch((error) => {\n setUserSelection(fallback ?? null);\n onCartSyncError?.({ method: selection, error });\n\n if (!onCartSyncError) {\n setError(cartSyncError);\n }\n });\n },\n [autoSync, setUserSelection, onCartSyncError, cartSyncError]\n );\n\n const handleSelectionChange = useCallback(\n async (selection: ShippingMethod) => {\n const prevSelection = getValue('selectedShippingMethod');\n\n setUserSelection(selection);\n onSelectionChange?.(selection);\n\n if (!hasShippingAddress()) {\n emitShippingEstimateEvent(selection);\n }\n\n await setUserSelectionOnCart(selection, prevSelection);\n },\n [onSelectionChange, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleCheckoutData = useCallback(\n (data: Cart | NegotiableQuote | null) => {\n const isEmptyCart = !data || data.isEmpty;\n const isVirtualCart = Boolean(data?.isVirtual);\n\n if (isEmptyCart || isVirtualCart) {\n setIsVirtual(isVirtualCart);\n setUserSelection(null);\n setOptions([]);\n return;\n }\n\n const primaryAddress = data!.shippingAddresses?.[0];\n\n // If there is no primary address, options are handled by the shipping estimation\n if (!primaryAddress) return;\n\n const availableOptions = primaryAddress.availableShippingMethods ?? [];\n const filteredOptions = filterOptions(availableOptions);\n setOptions(availableOptions);\n\n // If there are no filtered options, reset the user selection\n if (filteredOptions.length === 0) {\n setUserSelection(null);\n return;\n }\n\n const cartSelection = primaryAddress.selectedShippingMethod ?? null;\n\n const userSelection = getValue('selectedShippingMethod');\n const isAvailable = isMethodAvailable(userSelection, filteredOptions);\n const haveSameSelection = isEqual(userSelection, cartSelection);\n\n // Handle user selection that's available but different from cart\n if (userSelection && isAvailable && !haveSameSelection) {\n setUserSelectionOnCart(userSelection, cartSelection);\n return;\n }\n\n // If no user selection or not available, decide what to do based on cart and filtered options\n if ((!userSelection || !isAvailable) && cartSelection) {\n // Check if cart selection is still available after filtering\n const isCartSelectionAvailable = isMethodAvailable(\n cartSelection,\n filteredOptions\n );\n if (isCartSelectionAvailable) {\n setUserSelection(cartSelection);\n return;\n }\n }\n\n if (\n (!userSelection || !isAvailable) &&\n (!cartSelection || !isMethodAvailable(cartSelection, filteredOptions))\n ) {\n const newSelection = preselectOption(filteredOptions);\n setUserSelection(newSelection);\n if (newSelection) setUserSelectionOnCart(newSelection);\n }\n },\n [filterOptions, preselectOption, setUserSelection, setUserSelectionOnCart]\n );\n\n const handleShippingEstimate = useCallback(\n (estimation: ShippingEstimate | undefined) => {\n if (estimation === undefined) return;\n\n const { shippingMethod, availableShippingMethods } = estimation;\n\n const selectedShippingMethod =\n availableShippingMethods?.find(\n (method) =>\n method.code === shippingMethod?.methodCode &&\n method.carrier.code === shippingMethod?.carrierCode\n ) ?? null;\n\n setOptions(availableShippingMethods);\n setUserSelection(selectedShippingMethod);\n },\n [setUserSelection]\n );\n\n useEffect(() => {\n if (!active) return;\n\n const pastUpdate = getLatestCheckoutUpdate();\n\n if (pastUpdate) {\n // When component becomes active, restore key state so handleCheckoutData can work properly\n const userSelection = getValue('selectedShippingMethod');\n if (userSelection) {\n setSelection(userSelection);\n }\n\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 useEffect(() => {\n if (!active || hasShippingAddress()) 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 const titleContent = useMemo(() => {\n if (!displayTitle) return undefined;\n\n return (\n <Slot name=\"checkout-shipping-methods-title\" slot={slots?.Title}>\n <h3>{defaultTitle}</h3>\n </Slot>\n );\n }, [displayTitle, slots?.Title, defaultTitle]);\n\n return (\n <ShippingMethodsComponent\n {...props}\n UIComponentType={UIComponentType}\n busy={hasQueuedUpdates || hasPendingEstimations}\n error={error}\n initialized={options !== undefined}\n options={filteredOptions}\n selection={selection}\n title={titleContent}\n visible={active && !isVirtual}\n onDismissError={handleDismissError}\n onSelectionChange={handleSelectionChange}\n />\n );\n};\n"],"names":["SvgDelivery","props","React","ShippingMethodsSkeleton","jsxs","Skeleton","jsx","SkeletonRow","ShippingMethodsComponent","className","busy","onSelectionChange","options","selection","title","UIComponentType","error","onDismissError","translations","useText","hasError","errorRef","useRef","useEffect","scrollToElement","renderShippingMethod","method","type","commonProps","RadioButton","Fragment","Price","ToggleButton","classes","VComponent","IllustratedMessage","Icon","Delivery","InLineAlert","ShippingMethods","WithConditionals","isMethodAvailable","option","isEqual","a","b","emitShippingEstimateEvent","shippingEstimatedEvent","events","transformShippingEstimateShippingMethod","active","autoSync","displayTitle","initialData","slots","onCartSyncError","setError","useState","isVirtual","setIsVirtual","setOptions","setSelection","hasQueuedUpdates","hasPendingUpdates","hasPendingEstimations","hasPendingShippingEstimate","cartSyncError","defaultTitle","filterOptions","useCallback","shippingMethods","shipping","config","preselectOption","defaults","filteredOptions","useMemo","handleDismissError","setUserSelection","shippingMethod","prev","notifyValues","setUserSelectionOnCart","fallback","hasShippingAddress","shippingMethodInput","setShippingMethods","handleSelectionChange","prevSelection","getValue","handleCheckoutData","data","isEmptyCart","isVirtualCart","primaryAddress","_a","availableOptions","cartSelection","userSelection","isAvailable","haveSameSelection","newSelection","handleShippingEstimate","estimation","availableShippingMethods","selectedShippingMethod","pastU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AA9D,EACA,MAAOkG,GACP,QAAS7D,GAAU,CAACQ,EACpB,eAAgBmB,GAChB,kBAAmBU,EAAA,CACrB,CAEJ","x_google_ignoreList":[0]}
@@ -1,4 +1,4 @@
1
- import { RenderAPI } from '../../types/storefront-sdk';
1
+ import { RenderAPI } from '../../types';
2
2
 
3
3
  type AddressFormChange = {
4
4
  data: Record<string, any>;
package/lib/utils.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import"../chunks/fetch-graphql.js";import{s as l,e as C}from"../chunks/setShippingAddress.js";import{debounce as f}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{s as y}from"../chunks/setBillingAddress.js";import{b as G,c as H,g as J,a as K,i as L}from"../chunks/events2.js";import{s as W}from"../chunks/dom.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/values.js";import"../chunks/transform-shipping-estimate.js";import"../chunks/transform-shipping-methods.js";import"../chunks/guards.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";import"../chunks/events.js";let p=0;function k({type:e="shipping",debounceMs:i=0,placeOrderBtn:o}){const r=e==="shipping"?l:y,t=f(s=>{p+=1,r(s).catch(console.error).finally(()=>{p-=1,p===0&&(o==null||o.setProps(n=>({...n,disabled:!1})))})},i);return({data:s,isDataValid:n})=>{if(!n)return;o==null||o.setProps(m=>({...m,disabled:!0}));const u=A(s);t(u)}}function P({debounceMs:e=0}){let i={},o=!1;const r=f(t=>{var n,u,m,g;if(o)return;const s={country_code:t.countryCode,region_name:String(((n=t.region)==null?void 0:n.regionCode)||""),region_id:String(((u=t.region)==null?void 0:u.regionId)||""),zip:t.postcode};C({criteria:s}),i={countryCode:t.countryCode,regionCode:((m=t.region)==null?void 0:m.regionCode)||"",regionId:((g=t.region)==null?void 0:g.regionId)||"",postcode:t.postcode}},e);return({data:t,isDataValid:s})=>{var n,u;if(s){o=!0;return}i.countryCode===t.countryCode&&i.regionCode===(((n=t.region)==null?void 0:n.regionCode)||"")&&i.regionId===(((u=t.region)==null?void 0:u.regionId)||"")&&i.postcode===t.postcode||r(t)}}function _(e,i){const o=document.forms.namedItem(e);return!o||!(o&&o.offsetParent!==null)?!0:(o.setAttribute("novalidate",""),i&&i.current?i.current.handleValidationSubmit(!1):o.checkValidity())}function q(e){return document.createRange().createContextualFragment(e)}function D(e){return function(i){return e.querySelector(i)}}function c(e,i,o){if(!e||!o)return;const r=document.head.querySelector(`meta[${o}="${e}"]`);if(!i){r==null||r.remove();return}if(r)r.setAttribute("content",i);else{const t=document.createElement("meta");t.setAttribute(o,e),t.setAttribute("content",i),document.head.appendChild(t)}}function $(e){c("title",e,"name"),c("description",e,"name"),c("keywords",e,"name"),c("og:description",e,"property"),c("og:title",e,"property"),c("og:url",window.location.href,"property")}const A=e=>{var r,t,s;if(!(!(e!=null&&e.id)&&!(e!=null&&e.uid)))return{customerAddressId:e.id,customerAddressUid:e.uid};const o=(r=e.customAttributes)==null?void 0:r.map(({code:n,value:u})=>({code:n,value:String(u)}));return{address:{city:e.city,company:e==null?void 0:e.company,countryCode:e.countryCode,customAttributes:o,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postcode,prefix:e.prefix,region:(t=e==null?void 0:e.region)==null?void 0:t.regionCode,regionId:(s=e==null?void 0:e.region)==null?void 0:s.regionId,street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId,saveInAddressBook:e.saveAddressBook}}},z=e=>{var i,o,r;return{city:e.city,company:e==null?void 0:e.company,countryCode:(i=e.country)==null?void 0:i.code,customAttributes:e.customAttributes,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postCode,prefix:e.prefix,region:{regionCode:(o=e.region)==null?void 0:o.code,regionId:(r=e.region)==null?void 0:r.id},street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId}};export{q as createFragment,c as createMetaTag,D as createScopedSelector,P as estimateShippingCost,G as getCartAddress,H as getCartPaymentMethod,J as getCartShippingMethod,K as isEmptyCart,L as isVirtualCart,W as scrollToElement,k as setAddressOnCart,$ as setMetaTags,A as transformAddressFormValuesToAddressInput,z as transformCartAddressToFormValues,_ as validateForm};
3
+ import"../chunks/fetch-graphql.js";import{s as l,e as C}from"../chunks/setShippingAddress.js";import{debounce as f}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import{s as y}from"../chunks/setBillingAddress.js";import{b as G,c as H,g as J,a as K,i as L}from"../chunks/events2.js";import{s as W}from"../chunks/dom.js";import"@dropins/tools/signals.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/transform-shipping-estimate.js";import"../chunks/transform-shipping-methods.js";import"../chunks/values.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";import"../chunks/guards.js";import"../chunks/events.js";let p=0;function k({type:e="shipping",debounceMs:i=0,placeOrderBtn:o}){const r=e==="shipping"?l:y,t=f(s=>{p+=1,r(s).catch(console.error).finally(()=>{p-=1,p===0&&(o==null||o.setProps(n=>({...n,disabled:!1})))})},i);return({data:s,isDataValid:n})=>{if(!n)return;o==null||o.setProps(m=>({...m,disabled:!0}));const u=A(s);t(u)}}function P({debounceMs:e=0}){let i={},o=!1;const r=f(t=>{var n,u,m,g;if(o)return;const s={country_code:t.countryCode,region_name:String(((n=t.region)==null?void 0:n.regionCode)||""),region_id:String(((u=t.region)==null?void 0:u.regionId)||""),zip:t.postcode};C({criteria:s}),i={countryCode:t.countryCode,regionCode:((m=t.region)==null?void 0:m.regionCode)||"",regionId:((g=t.region)==null?void 0:g.regionId)||"",postcode:t.postcode}},e);return({data:t,isDataValid:s})=>{var n,u;if(s){o=!0;return}i.countryCode===t.countryCode&&i.regionCode===(((n=t.region)==null?void 0:n.regionCode)||"")&&i.regionId===(((u=t.region)==null?void 0:u.regionId)||"")&&i.postcode===t.postcode||r(t)}}function _(e,i){const o=document.forms.namedItem(e);return!o||!(o&&o.offsetParent!==null)?!0:(o.setAttribute("novalidate",""),i&&i.current?i.current.handleValidationSubmit(!1):o.checkValidity())}function q(e){return document.createRange().createContextualFragment(e)}function D(e){return function(i){return e.querySelector(i)}}function c(e,i,o){if(!e||!o)return;const r=document.head.querySelector(`meta[${o}="${e}"]`);if(!i){r==null||r.remove();return}if(r)r.setAttribute("content",i);else{const t=document.createElement("meta");t.setAttribute(o,e),t.setAttribute("content",i),document.head.appendChild(t)}}function $(e){c("title",e,"name"),c("description",e,"name"),c("keywords",e,"name"),c("og:description",e,"property"),c("og:title",e,"property"),c("og:url",window.location.href,"property")}const A=e=>{var r,t,s;if(!(!(e!=null&&e.id)&&!(e!=null&&e.uid)))return{customerAddressId:e.id,customerAddressUid:e.uid};const o=(r=e.customAttributes)==null?void 0:r.map(({code:n,value:u})=>({code:n,value:String(u)}));return{address:{city:e.city,company:e==null?void 0:e.company,countryCode:e.countryCode,customAttributes:o,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postcode,prefix:e.prefix,region:(t=e==null?void 0:e.region)==null?void 0:t.regionCode,regionId:(s=e==null?void 0:e.region)==null?void 0:s.regionId,street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId,saveInAddressBook:e.saveAddressBook}}},z=e=>{var i,o,r;return{city:e.city,company:e==null?void 0:e.company,countryCode:(i=e.country)==null?void 0:i.code,customAttributes:e.customAttributes,fax:e.fax,firstName:e.firstName,lastName:e.lastName,middleName:e.middleName,postcode:e.postCode,prefix:e.prefix,region:{regionCode:(o=e.region)==null?void 0:o.code,regionId:(r=e.region)==null?void 0:r.id},street:e.street,suffix:e.suffix,telephone:e.telephone,vatId:e.vatId}};export{q as createFragment,c as createMetaTag,D as createScopedSelector,P as estimateShippingCost,G as getCartAddress,H as getCartPaymentMethod,J as getCartShippingMethod,K as isEmptyCart,L as isVirtualCart,W as scrollToElement,k as setAddressOnCart,$ as setMetaTags,A as transformAddressFormValuesToAddressInput,z as transformCartAddressToFormValues,_ as validateForm};
4
4
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["/@dropins/storefront-checkout/src/lib/utils/api.ts","/@dropins/storefront-checkout/src/lib/utils/forms.ts","/@dropins/storefront-checkout/src/lib/utils/fragments.ts","/@dropins/storefront-checkout/src/lib/utils/meta.ts","/@dropins/storefront-checkout/src/lib/utils/transformers.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 {\n estimateShippingMethods,\n setBillingAddress,\n setShippingAddress,\n} from '@/checkout/api';\nimport {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { transformAddressFormValuesToAddressInput } from '@/checkout/lib/utils';\nimport { RenderAPI } from '@/checkout/types/storefront-sdk';\nimport { debounce } from '@adobe-commerce/elsie/lib';\n\ntype AddressFormChange = {\n data: Record<string, any>;\n isDataValid: boolean;\n};\n\nlet ongoingSetAddressCalls = 0;\n\nexport function setAddressOnCart({\n type = 'shipping',\n debounceMs = 0,\n placeOrderBtn,\n}: {\n type?: 'shipping' | 'billing';\n debounceMs?: number;\n placeOrderBtn?: RenderAPI;\n}) {\n const api = type === 'shipping' ? setShippingAddress : setBillingAddress;\n\n const debouncedApi = debounce(\n (address: ShippingAddressInput | BillingAddressInput) => {\n ongoingSetAddressCalls += 1;\n api(address)\n .catch(console.error)\n .finally(() => {\n ongoingSetAddressCalls -= 1;\n if (ongoingSetAddressCalls === 0) {\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: false }));\n }\n });\n },\n debounceMs\n );\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (!isDataValid) return;\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: true }));\n const address = transformAddressFormValuesToAddressInput(data);\n debouncedApi(address);\n };\n}\n\nexport function estimateShippingCost({ debounceMs = 0 }) {\n let prevEstimateShippingData: {\n countryCode?: string;\n regionCode?: string;\n regionId?: string;\n postcode?: string;\n } = {};\n\n let shouldCancelDebounce = false;\n\n const debouncedApi = debounce((data: Record<string, any>) => {\n if (shouldCancelDebounce) return;\n\n const estimateShippingInputCriteria = {\n country_code: data.countryCode,\n region_name: String(data.region?.regionCode || ''),\n region_id: String(data.region?.regionId || ''),\n zip: data.postcode,\n };\n\n estimateShippingMethods({ criteria: estimateShippingInputCriteria });\n\n prevEstimateShippingData = {\n countryCode: data.countryCode,\n regionCode: data.region?.regionCode || '',\n regionId: data.region?.regionId || '',\n postcode: data.postcode,\n };\n }, debounceMs);\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (isDataValid) {\n shouldCancelDebounce = true;\n return;\n }\n\n if (\n prevEstimateShippingData.countryCode === data.countryCode &&\n prevEstimateShippingData.regionCode === (data.region?.regionCode || '') &&\n prevEstimateShippingData.regionId === (data.region?.regionId || '') &&\n prevEstimateShippingData.postcode === data.postcode\n )\n return;\n\n debouncedApi(data);\n };\n}\n","/********************************************************************\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 { FormRef } from '@/checkout/types/storefront-account';\nimport { RefObject } from 'preact';\n\nexport function validateForm(\n formName: string,\n formRef: RefObject<FormRef>\n): boolean {\n const formElement = document.forms.namedItem(formName);\n\n if (!formElement) {\n return true;\n }\n\n const isVisible = formElement && formElement.offsetParent !== null;\n if (!isVisible) {\n return true;\n }\n\n formElement.setAttribute('novalidate', '');\n\n if (formRef && formRef.current) {\n return formRef.current.handleValidationSubmit(false);\n }\n\n return formElement.checkValidity();\n}\n","/********************************************************************\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\nexport function createFragment(html: string): DocumentFragment {\n return document.createRange().createContextualFragment(html);\n}\n\nexport function createScopedSelector(\n fragment: DocumentFragment\n): (selector: string) => HTMLElement | null {\n return function (selector: string): HTMLElement | null {\n return fragment.querySelector(selector);\n };\n}\n","/********************************************************************\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\nexport function createMetaTag(property: string, content: string, type: string) {\n if (!property || !type) {\n return;\n }\n\n const meta = document.head.querySelector<HTMLMetaElement>(\n `meta[${type}=\"${property}\"]`\n );\n\n if (!content) {\n meta?.remove();\n return;\n }\n\n if (meta) {\n meta.setAttribute('content', content);\n } else {\n const newMeta = document.createElement('meta');\n newMeta.setAttribute(type, property);\n newMeta.setAttribute('content', content);\n document.head.appendChild(newMeta);\n }\n}\n\nexport function setMetaTags(dropin: string) {\n createMetaTag('title', dropin, 'name');\n createMetaTag('description', dropin, 'name');\n createMetaTag('keywords', dropin, 'name');\n createMetaTag('og:description', dropin, 'property');\n createMetaTag('og:title', dropin, 'property');\n createMetaTag('og:url', window.location.href, 'property');\n}\n","/********************************************************************\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 {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { CartAddress } from '@/checkout/data/models/cart';\n\nexport const transformAddressFormValuesToAddressInput = (\n data: Record<string, any>\n): ShippingAddressInput | BillingAddressInput => {\n const isNewAddress = !data?.id && !data?.uid;\n\n if (!isNewAddress) {\n return {\n customerAddressId: data.id,\n customerAddressUid: data.uid,\n };\n }\n\n const customAttributes = data.customAttributes?.map(\n ({ code, value }: { code: string; value: unknown }) => ({\n code,\n value: String(value),\n })\n );\n\n return {\n address: {\n city: data.city,\n company: data?.company,\n countryCode: data.countryCode,\n customAttributes,\n fax: data.fax,\n firstName: data.firstName,\n lastName: data.lastName,\n middleName: data.middleName,\n postcode: data.postcode,\n prefix: data.prefix,\n region: data?.region?.regionCode,\n regionId: data?.region?.regionId,\n street: data.street,\n suffix: data.suffix,\n telephone: data.telephone,\n vatId: data.vatId,\n saveInAddressBook: data.saveAddressBook,\n },\n };\n};\n\nexport const transformCartAddressToFormValues = (\n address: CartAddress\n): Record<string, any> => {\n return {\n city: address.city,\n company: address?.company,\n countryCode: address.country?.code,\n customAttributes: address.customAttributes,\n fax: address.fax,\n firstName: address.firstName,\n lastName: address.lastName,\n middleName: address.middleName,\n postcode: address.postCode,\n prefix: address.prefix,\n region: {\n regionCode: address.region?.code,\n regionId: address.region?.id,\n },\n street: address.street,\n suffix: address.suffix,\n telephone: address.telephone,\n vatId: address.vatId,\n };\n};\n"],"names":["ongoingSetAddressCalls","setAddressOnCart","type","debounceMs","placeOrderBtn","api","setShippingAddress","setBillingAddress","debouncedApi","debounce","address","prev","data","isDataValid","transformAddressFormValuesToAddressInput","estimateShippingCost","prevEstimateShippingData","shouldCancelDebounce","estimateShippingInputCriteria","_a","_b","estimateShippingMethods","_c","_d","validateForm","formName","formRef","formElement","createFragment","html","createScopedSelector","fragment","selector","createMetaTag","property","content","meta","newMeta","setMetaTags","dropin","customAttributes","code","value","transformCartAddressToFormValues"],"mappings":"gpBAmCA,IAAIA,EAAyB,EAEtB,SAASC,EAAiB,CAC/B,KAAAC,EAAO,WACP,WAAAC,EAAa,EACb,cAAAC,CACF,EAIG,CACK,MAAAC,EAAMH,IAAS,WAAaI,EAAqBC,EAEjDC,EAAeC,EAClBC,GAAwD,CAC7BV,GAAA,EAC1BK,EAAIK,CAAO,EACR,MAAM,QAAQ,KAAK,EACnB,QAAQ,IAAM,CACaV,GAAA,EACtBA,IAA2B,IACdI,GAAA,MAAAA,EAAA,SAAUO,IAAU,CAAE,GAAGA,EAAM,SAAU,MAC1D,CACD,CACL,EACAR,CACF,EAEA,MAAO,CAAC,CAAE,KAAAS,EAAM,YAAAC,KAAqC,CACnD,GAAI,CAACA,EAAa,OACHT,GAAA,MAAAA,EAAA,SAAUO,IAAU,CAAE,GAAGA,EAAM,SAAU,MAClD,MAAAD,EAAUI,EAAyCF,CAAI,EAC7DJ,EAAaE,CAAO,CACtB,CACF,CAEO,SAASK,EAAqB,CAAE,WAAAZ,EAAa,GAAK,CACvD,IAAIa,EAKA,CAAC,EAEDC,EAAuB,GAErB,MAAAT,EAAeC,EAAUG,GAA8B,aAC3D,GAAIK,EAAsB,OAE1B,MAAMC,EAAgC,CACpC,aAAcN,EAAK,YACnB,YAAa,SAAOO,EAAAP,EAAK,SAAL,YAAAO,EAAa,aAAc,EAAE,EACjD,UAAW,SAAOC,EAAAR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EACXjC,GACwB,WACjB,MAAA,CACL,KAAMA,EAAQ,KACd,QAASA,GAAA,YAAAA,EAAS,QAClB,aAAaS,EAAAT,EAAQ,UAAR,YAAAS,EAAiB,KAC9B,iBAAkBT,EAAQ,iBAC1B,IAAKA,EAAQ,IACb,UAAWA,EAAQ,UACnB,SAAUA,EAAQ,SAClB,WAAYA,EAAQ,WACpB,SAAUA,EAAQ,SAClB,OAAQA,EAAQ,OAChB,OAAQ,CACN,YAAYU,EAAAV,EAAQ,SAAR,YAAAU,EAAgB,KAC5B,UAAUE,EAAAZ,EAAQ,SAAR,YAAAY,EAAgB,EAC5B,EACA,OAAQZ,EAAQ,OAChB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,MAAOA,EAAQ,KACjB,CACF"}
1
+ {"version":3,"file":"utils.js","sources":["/@dropins/storefront-checkout/src/lib/utils/api.ts","/@dropins/storefront-checkout/src/lib/utils/forms.ts","/@dropins/storefront-checkout/src/lib/utils/fragments.ts","/@dropins/storefront-checkout/src/lib/utils/meta.ts","/@dropins/storefront-checkout/src/lib/utils/transformers.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 {\n estimateShippingMethods,\n setBillingAddress,\n setShippingAddress,\n} from '@/checkout/api';\nimport {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { transformAddressFormValuesToAddressInput } from '@/checkout/lib/utils';\nimport { RenderAPI } from '@/checkout/types';\nimport { debounce } from '@adobe-commerce/elsie/lib';\n\ntype AddressFormChange = {\n data: Record<string, any>;\n isDataValid: boolean;\n};\n\nlet ongoingSetAddressCalls = 0;\n\nexport function setAddressOnCart({\n type = 'shipping',\n debounceMs = 0,\n placeOrderBtn,\n}: {\n type?: 'shipping' | 'billing';\n debounceMs?: number;\n placeOrderBtn?: RenderAPI;\n}) {\n const api = type === 'shipping' ? setShippingAddress : setBillingAddress;\n\n const debouncedApi = debounce(\n (address: ShippingAddressInput | BillingAddressInput) => {\n ongoingSetAddressCalls += 1;\n api(address)\n .catch(console.error)\n .finally(() => {\n ongoingSetAddressCalls -= 1;\n if (ongoingSetAddressCalls === 0) {\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: false }));\n }\n });\n },\n debounceMs\n );\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (!isDataValid) return;\n placeOrderBtn?.setProps((prev) => ({ ...prev, disabled: true }));\n const address = transformAddressFormValuesToAddressInput(data);\n debouncedApi(address);\n };\n}\n\nexport function estimateShippingCost({ debounceMs = 0 }) {\n let prevEstimateShippingData: {\n countryCode?: string;\n regionCode?: string;\n regionId?: string;\n postcode?: string;\n } = {};\n\n let shouldCancelDebounce = false;\n\n const debouncedApi = debounce((data: Record<string, any>) => {\n if (shouldCancelDebounce) return;\n\n const estimateShippingInputCriteria = {\n country_code: data.countryCode,\n region_name: String(data.region?.regionCode || ''),\n region_id: String(data.region?.regionId || ''),\n zip: data.postcode,\n };\n\n estimateShippingMethods({ criteria: estimateShippingInputCriteria });\n\n prevEstimateShippingData = {\n countryCode: data.countryCode,\n regionCode: data.region?.regionCode || '',\n regionId: data.region?.regionId || '',\n postcode: data.postcode,\n };\n }, debounceMs);\n\n return ({ data, isDataValid }: AddressFormChange) => {\n if (isDataValid) {\n shouldCancelDebounce = true;\n return;\n }\n\n if (\n prevEstimateShippingData.countryCode === data.countryCode &&\n prevEstimateShippingData.regionCode === (data.region?.regionCode || '') &&\n prevEstimateShippingData.regionId === (data.region?.regionId || '') &&\n prevEstimateShippingData.postcode === data.postcode\n )\n return;\n\n debouncedApi(data);\n };\n}\n","/********************************************************************\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 { FormRef } from '@/checkout/types/storefront-account';\nimport { RefObject } from 'preact';\n\nexport function validateForm(\n formName: string,\n formRef: RefObject<FormRef>\n): boolean {\n const formElement = document.forms.namedItem(formName);\n\n if (!formElement) {\n return true;\n }\n\n const isVisible = formElement && formElement.offsetParent !== null;\n if (!isVisible) {\n return true;\n }\n\n formElement.setAttribute('novalidate', '');\n\n if (formRef && formRef.current) {\n return formRef.current.handleValidationSubmit(false);\n }\n\n return formElement.checkValidity();\n}\n","/********************************************************************\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\nexport function createFragment(html: string): DocumentFragment {\n return document.createRange().createContextualFragment(html);\n}\n\nexport function createScopedSelector(\n fragment: DocumentFragment\n): (selector: string) => HTMLElement | null {\n return function (selector: string): HTMLElement | null {\n return fragment.querySelector(selector);\n };\n}\n","/********************************************************************\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\nexport function createMetaTag(property: string, content: string, type: string) {\n if (!property || !type) {\n return;\n }\n\n const meta = document.head.querySelector<HTMLMetaElement>(\n `meta[${type}=\"${property}\"]`\n );\n\n if (!content) {\n meta?.remove();\n return;\n }\n\n if (meta) {\n meta.setAttribute('content', content);\n } else {\n const newMeta = document.createElement('meta');\n newMeta.setAttribute(type, property);\n newMeta.setAttribute('content', content);\n document.head.appendChild(newMeta);\n }\n}\n\nexport function setMetaTags(dropin: string) {\n createMetaTag('title', dropin, 'name');\n createMetaTag('description', dropin, 'name');\n createMetaTag('keywords', dropin, 'name');\n createMetaTag('og:description', dropin, 'property');\n createMetaTag('og:title', dropin, 'property');\n createMetaTag('og:url', window.location.href, 'property');\n}\n","/********************************************************************\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 {\n BillingAddressInput,\n ShippingAddressInput,\n} from '@/checkout/data/models/api';\nimport { CartAddress } from '@/checkout/data/models/cart';\n\nexport const transformAddressFormValuesToAddressInput = (\n data: Record<string, any>\n): ShippingAddressInput | BillingAddressInput => {\n const isNewAddress = !data?.id && !data?.uid;\n\n if (!isNewAddress) {\n return {\n customerAddressId: data.id,\n customerAddressUid: data.uid,\n };\n }\n\n const customAttributes = data.customAttributes?.map(\n ({ code, value }: { code: string; value: unknown }) => ({\n code,\n value: String(value),\n })\n );\n\n return {\n address: {\n city: data.city,\n company: data?.company,\n countryCode: data.countryCode,\n customAttributes,\n fax: data.fax,\n firstName: data.firstName,\n lastName: data.lastName,\n middleName: data.middleName,\n postcode: data.postcode,\n prefix: data.prefix,\n region: data?.region?.regionCode,\n regionId: data?.region?.regionId,\n street: data.street,\n suffix: data.suffix,\n telephone: data.telephone,\n vatId: data.vatId,\n saveInAddressBook: data.saveAddressBook,\n },\n };\n};\n\nexport const transformCartAddressToFormValues = (\n address: CartAddress\n): Record<string, any> => {\n return {\n city: address.city,\n company: address?.company,\n countryCode: address.country?.code,\n customAttributes: address.customAttributes,\n fax: address.fax,\n firstName: address.firstName,\n lastName: address.lastName,\n middleName: address.middleName,\n postcode: address.postCode,\n prefix: address.prefix,\n region: {\n regionCode: address.region?.code,\n regionId: address.region?.id,\n },\n street: address.street,\n suffix: address.suffix,\n telephone: address.telephone,\n vatId: address.vatId,\n };\n};\n"],"names":["ongoingSetAddressCalls","setAddressOnCart","type","debounceMs","placeOrderBtn","api","setShippingAddress","setBillingAddress","debouncedApi","debounce","address","prev","data","isDataValid","transformAddressFormValuesToAddressInput","estimateShippingCost","prevEstimateShippingData","shouldCancelDebounce","estimateShippingInputCriteria","_a","_b","estimateShippingMethods","_c","_d","validateForm","formName","formRef","formElement","createFragment","html","createScopedSelector","fragment","selector","createMetaTag","property","content","meta","newMeta","setMetaTags","dropin","customAttributes","code","value","transformCartAddressToFormValues"],"mappings":"gpBAmCA,IAAIA,EAAyB,EAEtB,SAASC,EAAiB,CAC/B,KAAAC,EAAO,WACP,WAAAC,EAAa,EACb,cAAAC,CACF,EAIG,CACK,MAAAC,EAAMH,IAAS,WAAaI,EAAqBC,EAEjDC,EAAeC,EAClBC,GAAwD,CAC7BV,GAAA,EAC1BK,EAAIK,CAAO,EACR,MAAM,QAAQ,KAAK,EACnB,QAAQ,IAAM,CACaV,GAAA,EACtBA,IAA2B,IACdI,GAAA,MAAAA,EAAA,SAAUO,IAAU,CAAE,GAAGA,EAAM,SAAU,MAC1D,CACD,CACL,EACAR,CACF,EAEA,MAAO,CAAC,CAAE,KAAAS,EAAM,YAAAC,KAAq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AAM9B,EAAK,KACX,QAASA,GAAA,YAAAA,EAAM,QACf,YAAaA,EAAK,YAClB,iBAAA4B,EACA,IAAK5B,EAAK,IACV,UAAWA,EAAK,UAChB,SAAUA,EAAK,SACf,WAAYA,EAAK,WACjB,SAAUA,EAAK,SACf,OAAQA,EAAK,OACb,QAAQQ,EAAAR,GAAA,YAAAA,EAAM,SAAN,YAAAQ,EAAc,WACtB,UAAUE,EAAAV,GAAA,YAAAA,EAAM,SAAN,YAAAU,EAAc,SACxB,OAAQV,EAAK,OACb,OAAQA,EAAK,OACb,UAAWA,EAAK,UAChB,MAAOA,EAAK,MACZ,kBAAmBA,EAAK,eAAA,CAE5B,CACF,EAEa+B,EACXjC,GACwB,WACjB,MAAA,CACL,KAAMA,EAAQ,KACd,QAASA,GAAA,YAAAA,EAAS,QAClB,aAAaS,EAAAT,EAAQ,UAAR,YAAAS,EAAiB,KAC9B,iBAAkBT,EAAQ,iBAC1B,IAAKA,EAAQ,IACb,UAAWA,EAAQ,UACnB,SAAUA,EAAQ,SAClB,WAAYA,EAAQ,WACpB,SAAUA,EAAQ,SAClB,OAAQA,EAAQ,OAChB,OAAQ,CACN,YAAYU,EAAAV,EAAQ,SAAR,YAAAU,EAAgB,KAC5B,UAAUE,EAAAZ,EAAQ,SAAR,YAAAY,EAAgB,EAC5B,EACA,OAAQZ,EAAQ,OAChB,OAAQA,EAAQ,OAChB,UAAWA,EAAQ,UACnB,MAAOA,EAAQ,KACjB,CACF"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/storefront-checkout", "version": "2.1.0-alpha1", "@dropins/tools": "^1.5.0-beta2", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/storefront-checkout", "version": "2.1.0-beta3", "@dropins/tools": "^1.5.0-beta2", "license": "SEE LICENSE IN LICENSE.md"}
package/types/index.d.ts CHANGED
@@ -17,5 +17,6 @@
17
17
  export type { InitializeInput, Nullable, SynchronizeInput } from './api';
18
18
  export type { TitleProps, UIComponentType } from './components';
19
19
  export * from './guards';
20
- export type { CartModel, FormRef, NegotiableQuoteModel, RenderAPI, } from './storefront';
20
+ export type { CartModel, FormRef, Item, NegotiableQuoteModel, RenderAPI, } from './storefront';
21
+ export type { Filter, Selector } from './utils';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -56,7 +56,7 @@ interface TotalPriceModifier {
56
56
  amount: Price;
57
57
  label: string;
58
58
  }
59
- interface Item {
59
+ export interface Item {
60
60
  taxedPrice: Price;
61
61
  rowTotal: Price;
62
62
  rowTotalIncludingTax: Price;
@@ -0,0 +1,19 @@
1
+ /********************************************************************
2
+ * ADOBE CONFIDENTIAL
3
+ * __________________
4
+ *
5
+ * Copyright 2025 Adobe
6
+ * All Rights Reserved.
7
+ *
8
+ * NOTICE: All information contained herein is, and remains
9
+ * the property of Adobe and its suppliers, if any. The intellectual
10
+ * and technical concepts contained herein are proprietary to Adobe
11
+ * and its suppliers and are protected by all applicable intellectual
12
+ * property laws, including trade secret and copyright laws.
13
+ * Dissemination of this information or reproduction of this material
14
+ * is strictly forbidden unless prior written permission is obtained
15
+ * from Adobe.
16
+ *******************************************************************/
17
+ export type Selector<T> = (options: Array<T>) => T | null;
18
+ export type Filter<T> = (option: T) => boolean;
19
+ //# sourceMappingURL=utils.d.ts.map