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AASoN,OAAOpN,GAAS,E,2DCiBnC,IAdA,SAA6BA,GAC3B,MAAMkO,GAAMjK,EAAAA,EAAAA,QAAUjE,GAEtB,OAAa,MAATA,GAAiB,SAASmO,YAAYnO,GACjCA,GAGJoO,IAAQF,EAAIlT,QAASgF,KACxBkO,EAAIlT,QAAUgF,GAGTkO,EAAIlT,QACb,C","sources":["webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/apiHelpers.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/sortShippingOptions.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/SessionHandlers/BaseApplePayHandler.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/constants.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/getLineItems.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/getSupportedNetworks.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/useApplePay.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/ApplePayButton/utils.ts","webpack://nocodenodeweb/./src/client/components/ButtonsStack/JSSDKButton.tsx","webpack://nocodenodeweb/./src/client/components/ButtonsStack/styles.ts","webpack://nocodenodeweb/./src/client/components/payment/validation/index.ts","webpack://nocodenodeweb/./src/client/components/payment/validation/rules.ts","webpack://nocodenodeweb/./src/client/helpers/isNonZeroStr.ts","webpack://nocodenodeweb/./src/client/hooks/useDeepEqualMemo.ts"],"sourcesContent":["import { MutableRefObject } from 'react';\nimport fetchWrapper from '@client/helpers/fetchWrapper';\nimport { logErrorClient } from '@client/utils/beaverLogger';\nimport type { UserInputsType, OrderDetails, ServerError } from '@client/typings/Common';\nimport { startCPLTracking, endCPLTracking, recordImpression, PageName } from '@common/analytics';\nimport { CartDetails } from '@client/typings/Cart';\nimport { getViewCartTags } from '../PaywallHostedButtons/utils';\n\nconst APPLE_PAY_FUNDING_SOURCE = 'APPLE_PAY';\nconst FUNDING_TYPE = 'APPLEPAY';\n\ntype ApplePayOrderDetails = Pick;\n\nexport type ApplePayCreateOrder = ApplePayOrderDetails & { session: string };\ntype ApplePayCaptureOrder = ApplePayOrderDetails & Pick;\ntype KnownErrorCaptureOrder = {\n status: 422;\n name: 'DUPLICATE_INVOICE_ID' | 'INSTRUMENT_DECLINED';\n error: true;\n details: Record[];\n};\nexport type ApplePayCreateOrderInput = {\n csrfToken: string;\n hostedButtonId: string;\n merchantId: string;\n buttonType: string;\n userInputs: UserInputsType;\n fptiAdditionalTags: Record;\n pageName: PageName;\n cartDetailsRef?: MutableRefObject;\n};\n\nexport const createOrder = async ({\n csrfToken,\n hostedButtonId,\n merchantId,\n buttonType,\n userInputs,\n fptiAdditionalTags,\n pageName,\n cartDetailsRef\n}: ApplePayCreateOrderInput): Promise => {\n const cplImpressEvent = {\n pageName,\n eventName: 'create_order',\n event: 'im'\n };\n\n try {\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'create_order_start'\n },\n {\n funding_type: FUNDING_TYPE\n }\n );\n\n startCPLTracking(cplImpressEvent);\n const tStart = Date.now();\n const { responseData, response } = await fetchWrapper(\n '/ncp/api/apple-pay/create-order',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-csrf-token': csrfToken\n },\n body: JSON.stringify({\n link_id: hostedButtonId,\n merchant_id: merchantId,\n ...userInputs,\n funding_source: APPLE_PAY_FUNDING_SOURCE,\n button_type: buttonType,\n cart_details: cartDetailsRef?.current\n })\n },\n true\n );\n const apiDuration = Date.now() - tStart;\n const body = responseData as ApplePayCreateOrder;\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'create_order_end'\n },\n {\n funding_type: FUNDING_TYPE,\n order_id: body?.context_id,\n api_response_code: response.status,\n api_duration: apiDuration\n }\n );\n if (response.status !== 200) {\n throw body;\n }\n return body;\n } catch (err) {\n logErrorClient('ApplePay createOrder', err);\n return err;\n } finally {\n endCPLTracking(cplImpressEvent);\n }\n};\n\nexport const captureOrder = async ({\n csrfToken,\n hostedButtonId,\n merchantId,\n buttonType,\n userInputs,\n contextId,\n applePayPayment,\n fptiAdditionalTags,\n pageName,\n cartDetailsRef\n}: {\n csrfToken: string;\n hostedButtonId: string;\n merchantId: string;\n buttonType: string;\n userInputs: UserInputsType;\n contextId: string;\n applePayPayment: ApplePayJS.ApplePayPaymentAuthorizedEvent['payment'];\n fptiAdditionalTags: Record;\n pageName: PageName;\n cartDetailsRef?: MutableRefObject;\n}): Promise => {\n const cplImpressEvent = {\n pageName,\n eventName: 'capture_order',\n event: 'im'\n };\n\n try {\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'capture_order_start'\n },\n {\n funding_type: FUNDING_TYPE,\n order_id: contextId\n }\n );\n\n startCPLTracking(cplImpressEvent);\n const tStart = Date.now();\n const { responseData, response } = await fetchWrapper(\n '/ncp/api/apple-pay/capture-order',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-csrf-token': csrfToken\n },\n body: JSON.stringify({\n context_id: contextId,\n orderId: contextId,\n applePay: applePayPayment,\n link_id: hostedButtonId,\n merchant_id: merchantId,\n ...userInputs,\n funding_source: { paymentSource: 'applepay' },\n button_type: buttonType\n })\n },\n true\n );\n const apiDuration = Date.now() - tStart;\n recordImpression(\n {\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'capture_order_end'\n },\n {\n funding_type: FUNDING_TYPE,\n order_id: contextId,\n api_response_code: response.status,\n api_duration: apiDuration\n }\n );\n\n const body = responseData as ApplePayCaptureOrder | KnownErrorCaptureOrder;\n\n if (response.status !== 200 && response.status !== 422) {\n throw Error('CaptureOrder error');\n }\n return body;\n } catch (err) {\n logErrorClient('ApplePay captureOrder', err);\n return null;\n } finally {\n endCPLTracking(cplImpressEvent);\n }\n};\n\ninterface IMerchantSession {\n displayName: string;\n domainName: string;\n epochTimestamp: number;\n expiresAt: number;\n merchantIdentifier: string;\n merchantSessionIdentifier: string;\n nonce: string;\n operationalAnalyticsIdentifier: string;\n pspId: string;\n signature: string;\n}\nexport const getMerchantSession = (\n session: ApplePayCreateOrder['session']\n): IMerchantSession | null => {\n try {\n const merchantSession = JSON.parse(window.atob(session));\n return merchantSession;\n } catch (err) {\n logErrorClient('ApplePay parse merchant session', err);\n return null;\n }\n};\n","import { OrderShipping } from '@client/typings/Common';\n\n/**\n * Apple Pay selects the first element by default.\n * Re-order the selected shipping option to the first index\n */\nconst sortShippingOptions = (shippingOptions: OrderShipping['shipping_options']) => {\n if (!shippingOptions || !shippingOptions.length) return shippingOptions;\n const selectedIndex = shippingOptions.findIndex((option) => option.selected);\n\n if (selectedIndex !== -1) {\n const selectedOption = shippingOptions[selectedIndex];\n shippingOptions.splice(selectedIndex, 1);\n shippingOptions.unshift(selectedOption);\n }\n return shippingOptions;\n};\n\nexport default sortShippingOptions;\n","import {\n OrderDetails,\n OrderShipping,\n ServerError,\n TotalFields,\n UserInputsType\n} from '@client/typings/Common';\nimport { useAppContext } from '@client/contexts/AppContext';\nimport { logErrorClient, logWarnClient } from '@client/utils/beaverLogger';\nimport { CaptureStatus } from '@client/utils/constants';\nimport { getLocalizedString, WorldReadyProps } from '@client/utils/localeHelper';\nimport { PaymentContextType } from '@client/contexts/PaymentContext';\nimport { CartContextType } from '@client/contexts/CartContext';\nimport { updateOrderShippingOptions } from '../../ordersHelper';\nimport {\n createOrder,\n captureOrder,\n getMerchantSession,\n ApplePayCreateOrderInput\n} from '../apiHelpers';\nimport { UseApplePay } from '../useApplePay';\nimport sortShippingOptions from '../sortShippingOptions';\nimport { notApplicable } from '../constants';\nimport { ApplePayButtonContainerProps } from '../types';\n\nexport interface BaseApplePayHandlerProps {\n appContext: ReturnType;\n sessionContext: UseApplePay;\n paymentContext: PaymentContextType;\n cartContext?: CartContextType;\n button: T;\n buttonProps: ApplePayButtonContainerProps;\n worldReady: WorldReadyProps;\n}\n\nexport abstract class BaseApplePayHandler {\n protected appContext: ReturnType;\n\n protected sessionContext: UseApplePay;\n\n protected paymentContext: PaymentContextType;\n\n protected cartContext?: CartContextType;\n\n protected button: T;\n\n protected buttonProps: ApplePayButtonContainerProps;\n\n protected worldReady: WorldReadyProps;\n\n constructor(props: BaseApplePayHandlerProps) {\n this.appContext = props.appContext;\n this.sessionContext = props.sessionContext;\n this.paymentContext = props.paymentContext;\n this.cartContext = props.cartContext;\n this.button = props.button;\n this.buttonProps = props.buttonProps;\n this.worldReady = props.worldReady;\n }\n\n // Abstract functions\n protected abstract getButtonType(): string | undefined;\n\n protected abstract isShippingFromProfile(button: T): boolean;\n\n protected abstract getPaymentRequest(\n button: T,\n userInputs?: UserInputsType\n ): ApplePayJS.ApplePayPaymentRequest | undefined;\n\n protected abstract getLineItems(orderShipping?: OrderShipping): ApplePayJS.ApplePayLineItem[];\n\n protected abstract getTotals(\n button: T,\n userInputs?: UserInputsType\n ): TotalsType;\n\n protected abstract getCreateOrderInput(): ApplePayCreateOrderInput;\n\n protected abstract handleCreateOrderError(error: ServerError): void;\n\n // Protected functions\n protected onValidateMerchant = async (event: ApplePayJS.ApplePayValidateMerchantEvent) => {\n const { getSession, updateOrder, getIsInProgress } = this.sessionContext;\n\n const applePaySession = getSession() as ApplePaySession;\n try {\n const createOrderInput = this.getCreateOrderInput();\n\n const response = await createOrder(createOrderInput);\n\n if ('error' in response) {\n throw response;\n }\n\n const { context_id, session: orderSession } = response;\n if (!context_id || !orderSession) {\n throw Error('Missing order context_id or session');\n }\n updateOrder({ context_id });\n const merchantSession = getMerchantSession(orderSession);\n if (!merchantSession) {\n throw Error('Missing merchantSession');\n }\n\n if (!getIsInProgress()) {\n /**\n * In case ApplePay is cancelled during createOrder call.\n * Either user clicks the cancel button or createOrder takes\n * more than 30 seconds.\n */\n return logErrorClient('onValidateMerchant', 'Apple Pay not in progress');\n }\n applePaySession.completeMerchantValidation(merchantSession);\n } catch (err) {\n logErrorClient('onValidateMerchant', err.message);\n // Close the ApplePay modal\n applePaySession.completeMerchantValidation({});\n this.handleCreateOrderError(err);\n }\n };\n\n protected onPaymentAuthorized = async (event: ApplePayJS.ApplePayPaymentAuthorizedEvent) => {\n const { getSession, getIsInProgress, getOrder } = this.sessionContext;\n const { fptiAdditionalTags, setCaptureStatus, setIsLoading, setOrderData } =\n this.paymentContext;\n const { hostedButtonId, merchantId, userInputsRef, pageName, cartDetailsRef } =\n this.buttonProps;\n const buttonType = this.getButtonType();\n\n const applePaySession = getSession() as ApplePaySession;\n\n try {\n const csrfToken = this.appContext?.app.csrfToken;\n if (!csrfToken) {\n throw Error('Missing csrfToken');\n }\n\n if (!buttonType) {\n throw Error('Missing button_type');\n }\n\n if (!merchantId) {\n throw Error('Missing merchantId');\n }\n\n const { context_id } = getOrder();\n if (!context_id) {\n throw Error('Missing order context_id');\n }\n\n /**\n * We don't need to setIsLoading false when capture order complete in this function\n * setIsLoading false will be called in useOrderStatus when thank you page redirection\n * is not required\n */\n setIsLoading(true);\n const order = await captureOrder({\n csrfToken,\n hostedButtonId,\n merchantId,\n buttonType,\n userInputs: userInputsRef.current,\n contextId: context_id,\n applePayPayment: event.payment,\n pageName,\n fptiAdditionalTags,\n cartDetailsRef\n });\n\n if (!order) {\n throw Error('Capture order error');\n }\n\n /**\n * Edge case: ApplePay modal would only stay active for ~30 seconds\n * If captureOrder takes longer than that, ApplePay modal\n * would cancel and close. We don't expect captureOrder to\n * take longer than 30 seconds.\n *\n * At this moment, paywall should still be loading.\n */\n if (!getIsInProgress()) {\n logErrorClient('onPaymentAuthorized', 'ApplePay closed before captureOrder completed');\n\n /**\n * Since the ApplePay modal has already error'd out, we should not\n * contradict it in thank you page. Hence, we will redirect\n * to thank you page with unknown status to display \"We can't show your transaction status\"\n * even when order status is completed\n */\n if (order.status === 'COMPLETED') {\n setOrderData({\n ...order,\n name: 'UNKNOWN'\n } as OrderDetails);\n } else {\n setOrderData(order as OrderDetails);\n }\n return;\n }\n\n setOrderData(order as OrderDetails);\n\n if (order.status !== 'COMPLETED') {\n throw Error('Incomplete payment');\n }\n applePaySession.completePayment({\n status: ApplePaySession.STATUS_SUCCESS\n });\n } catch (err) {\n logErrorClient('onPaymentAuthorized', err.message);\n setIsLoading(false);\n applePaySession.completePayment({\n status: ApplePaySession.STATUS_FAILURE\n });\n setCaptureStatus(CaptureStatus.FAILED);\n }\n };\n\n protected onShippingContactSelected = async (\n event: ApplePayJS.ApplePayShippingContactSelectedEvent\n ) => {\n const { getSession, getOrder, getInitialPaymentRequest, setOrderShipping } =\n this.sessionContext;\n const { fptiAdditionalTags, setCaptureStatus } = this.paymentContext;\n const { hostedButtonId, pageName } = this.buttonProps;\n const { worldReady } = this;\n\n const applePaySession = getSession() as ApplePaySession;\n const initialPaymentRequest = getInitialPaymentRequest() as ApplePayJS.ApplePayPaymentRequest;\n\n const isShippingFromProfile = this.isShippingFromProfile(this.button);\n\n try {\n const csrfToken = this.appContext?.app.csrfToken;\n if (!csrfToken) {\n throw Error('Missing csrfToken');\n }\n\n const { context_id } = getOrder();\n if (!context_id) {\n throw Error('Missing order context_id');\n }\n\n const {\n locality = '',\n administrativeArea = '',\n countryCode = '',\n postalCode = ''\n } = event.shippingContact;\n\n const orderShipping = await updateOrderShippingOptions({\n csrfToken,\n contextId: context_id,\n hostedButtonId,\n shippingAddress: {\n city: locality,\n state: administrativeArea,\n countryCode,\n postalCode\n },\n fptiAdditionalTags,\n pageName\n });\n\n if (!orderShipping) {\n throw Error('Invalid order shipping');\n }\n\n setOrderShipping(orderShipping);\n\n const shippingOptions = sortShippingOptions(orderShipping.shipping_options);\n\n const newShippingMethodsForProfileShippingButton = shippingOptions\n ? {\n newShippingMethods: shippingOptions.map((option) => ({\n label: option.label,\n detail: '',\n amount: option.amount.value,\n identifier: option.id\n }))\n }\n : {\n newShippingMethods: [\n {\n label: getLocalizedString(worldReady, 'payment.text.applePay.noShippingOptions'),\n detail: '',\n amount: '0',\n identifier: notApplicable\n }\n ]\n };\n\n applePaySession.completeShippingContactSelection({\n newTotal: {\n amount: orderShipping.amount.value.toString(),\n label: initialPaymentRequest.total.label\n },\n newLineItems: this.getLineItems(orderShipping),\n ...(isShippingFromProfile ? newShippingMethodsForProfileShippingButton : {})\n });\n } catch (err) {\n logErrorClient('onShippingContactSelected', err.message);\n applePaySession.completeShippingContactSelection({\n newTotal: initialPaymentRequest.total,\n errors: [new window.ApplePayError!('shippingContactInvalid')]\n });\n setCaptureStatus(CaptureStatus.FAILED);\n }\n };\n\n protected onShippingMethodsSelected = async (\n event: ApplePayJS.ApplePayShippingMethodSelectedEvent\n ) => {\n const { getSession, getOrder, getInitialPaymentRequest, setOrderShipping, getOrderShipping } =\n this.sessionContext;\n const { fptiAdditionalTags, setCaptureStatus } = this.paymentContext;\n const { hostedButtonId, pageName } = this.buttonProps;\n\n const applePaySession = getSession() as ApplePaySession;\n const initialPaymentRequest = getInitialPaymentRequest() as ApplePayJS.ApplePayPaymentRequest;\n\n try {\n const csrfToken = this.appContext?.app.csrfToken;\n if (!csrfToken) {\n throw Error('Missing csrfToken');\n }\n\n const { context_id } = getOrder();\n if (!context_id) {\n throw Error('Missing order context_id');\n }\n\n const { identifier } = event.shippingMethod;\n\n // If the identifier is notApplicable then there are no shipping\n // methods associated with the merchant profile shipping configuration\n // When this happens, we will invoke the shipping method selection\n // from the Apple Pay SDK with the initial payment information\n if (identifier === notApplicable) {\n const orderShipping = getOrderShipping() as OrderShipping;\n\n applePaySession.completeShippingMethodSelection({\n newTotal: {\n amount: orderShipping.amount.value.toString(),\n label: initialPaymentRequest.total.label\n },\n newLineItems: this.getLineItems(orderShipping)\n });\n return;\n }\n\n const orderShipping = await updateOrderShippingOptions({\n csrfToken,\n contextId: context_id,\n hostedButtonId,\n optionId: identifier,\n fptiAdditionalTags,\n pageName\n });\n\n if (!orderShipping) {\n throw Error('Invalid order shipping');\n }\n\n // If shipping method is selected, shipping_options cannot be empty\n if (!orderShipping.shipping_options || !orderShipping.shipping_options.length) {\n throw Error('Invalid shipping options');\n }\n\n if (\n !orderShipping.shipping_options.some(\n (option) => option.id === identifier && option.selected\n )\n ) {\n throw Error('Order shipping not updated');\n }\n\n setOrderShipping(orderShipping);\n\n applePaySession.completeShippingMethodSelection({\n newTotal: {\n amount: orderShipping.amount.value.toString(),\n label: initialPaymentRequest.total.label\n },\n newLineItems: this.getLineItems(orderShipping)\n });\n } catch (err) {\n logErrorClient('onShippingMethodsSelected', err.message);\n // ApplePay API completeShippingMethodSelection doesn't support error\n applePaySession.abort();\n setCaptureStatus(CaptureStatus.FAILED);\n }\n };\n\n protected onCancel = (event: ApplePayJS.Event) => {\n const { setIsCancelled } = this.sessionContext;\n setIsCancelled();\n logWarnClient('onCancel', 'ApplePay cancelled');\n };\n\n // Public functions\n public createApplePaySession = (): ApplePaySession | undefined => {\n const { ApplePaySession } = window;\n if (!ApplePaySession) {\n logWarnClient('createApplePaySession-Missing ApplePaySession');\n return;\n }\n\n const paymentRequest = this.getPaymentRequest(this.button, this.paymentContext?.userInputs);\n\n if (!paymentRequest) {\n return;\n }\n\n const { setSession } = this.sessionContext;\n const { shouldUpdateOrderShipping } = this.buttonProps;\n const applePaySession = new ApplePaySession(7, paymentRequest);\n\n setSession(applePaySession, paymentRequest);\n\n applePaySession.onvalidatemerchant = this.onValidateMerchant;\n applePaySession.onpaymentauthorized = this.onPaymentAuthorized;\n applePaySession.oncancel = this.onCancel;\n\n if (shouldUpdateOrderShipping) {\n applePaySession.onshippingcontactselected = this.onShippingContactSelected;\n applePaySession.onshippingmethodselected = this.onShippingMethodsSelected;\n }\n\n return applePaySession;\n };\n}\n","export const amexSupportedCurrencyCodes = [\n 'AUD',\n 'CAD',\n 'CHF',\n 'CZK',\n 'DKK',\n 'EUR',\n 'GBP',\n 'HKD',\n 'HUF',\n 'JPY',\n 'NOK',\n 'NZD',\n 'PLN',\n 'SEK',\n 'SGD',\n 'USD'\n];\n\nexport const notApplicable = 'notApplicable';\n","import type { WorldReadyProps } from '@client/contexts/WorldReadyContext';\nimport { OrderShipping, FieldValueContent, TotalFields } from '@client/typings/Common';\nimport { getLocalizedString } from '@client/utils/localeHelper';\nimport isNonZeroStr from '@client/helpers/isNonZeroStr';\n\nenum ContentKey {\n Shipping = 'payment.text.shipping',\n Tax = 'payment.text.tax',\n Subtotal = 'payment.text.subtotal',\n FreeShipping = 'editor.shippingPreference.value.free'\n}\n\nexport const getTotalFieldLineItems = (\n worldReady: WorldReadyProps,\n totalFields: T\n) => {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [];\n\n const { shipping, tax, subtotal } = totalFields;\n if (shipping.showField) {\n if (typeof shipping.value === 'number') {\n lineItems.push({\n label: getLocalizedString(worldReady, ContentKey.Shipping),\n amount: shipping.value.toString()\n });\n } else if (shipping.value === FieldValueContent.Free) {\n lineItems.push({\n label: getLocalizedString(worldReady, ContentKey.FreeShipping),\n amount: '0'\n });\n }\n }\n\n if (tax.showField && typeof tax.value === 'number') {\n lineItems.push({\n label: getLocalizedString(worldReady, ContentKey.Tax),\n amount: tax.value.toString()\n });\n }\n\n if (subtotal.showField) {\n lineItems.unshift({\n label: getLocalizedString(worldReady, ContentKey.Subtotal),\n amount: subtotal.value.toString()\n });\n }\n\n return lineItems;\n};\n\nexport const getOrderShippingLineItems = (\n worldReady: WorldReadyProps,\n orderShipping: OrderShipping,\n addSubtotal?: boolean\n) => {\n const lineItems: ApplePayJS.ApplePayLineItem[] = [];\n\n const { shipping, tax_total, item_total } = orderShipping.amount.breakdown;\n if (isNonZeroStr(shipping?.value)) {\n lineItems.push({\n label: getLocalizedString(worldReady, ContentKey.Shipping),\n amount: shipping.value\n });\n }\n\n if (isNonZeroStr(tax_total?.value)) {\n lineItems.push({\n label: getLocalizedString(worldReady, ContentKey.Tax),\n amount: tax_total.value\n });\n }\n\n if (lineItems.length || addSubtotal) {\n lineItems.unshift({\n label: getLocalizedString(worldReady, ContentKey.Subtotal),\n amount: item_total.value\n });\n }\n\n return lineItems;\n};\n","import { amexSupportedCurrencyCodes } from './constants';\n\ntype SupportedNetworks = 'visa' | 'masterCard' | 'discover' | 'cartesBancaires' | 'amex';\nconst getSupportedNetworks = (currencyCode: string): SupportedNetworks[] => {\n // At this point, we will have determined merchant country eligibility.\n const supportedNetworks: SupportedNetworks[] = ['visa', 'masterCard'];\n if (currencyCode === 'USD') {\n supportedNetworks.push('discover');\n }\n\n // cartesBancaires only available on Apple Pay JS API version 4 and later.\n if (currencyCode === 'EUR' && window.ApplePaySession?.supportsVersion?.(4)) {\n supportedNetworks.push('cartesBancaires');\n }\n\n if (amexSupportedCurrencyCodes.includes(currencyCode)) {\n supportedNetworks.push('amex');\n }\n\n return supportedNetworks;\n};\n\nexport default getSupportedNetworks;\n","import { useRef, useMemo } from 'react';\nimport { OrderShipping } from '@client/typings/Common';\nimport type { ApplePayCreateOrder } from './apiHelpers';\n\nenum Status {\n cancelled = 'cancelled',\n inProgress = 'inProgress',\n notStarted = 'notStarted'\n}\n\nexport interface UseApplePay {\n getOrder: () => Partial;\n updateOrder: (order: Partial) => void;\n getSession: () => ApplePaySession | null;\n setSession: (\n applePaySession: ApplePaySession,\n paymentRequest: ApplePayJS.ApplePayPaymentRequest\n ) => void;\n getIsInProgress: () => boolean;\n setIsCancelled: () => void;\n getInitialPaymentRequest: () => ApplePayJS.ApplePayPaymentRequest | null;\n setOrderShipping: (orderShipping: OrderShipping) => void;\n getOrderShipping: () => OrderShipping | undefined;\n}\n\nconst useApplePay = (): UseApplePay => {\n const applePaySessionRef = useRef(null);\n const orderRef = useRef>({});\n const statusRef = useRef<`${Status}`>(Status.notStarted);\n const paymentRequest = useRef(null);\n const orderShippingRef = useRef();\n\n const methods = useMemo(\n () => ({\n getOrder: () => orderRef.current,\n updateOrder: (order: Partial) => {\n orderRef.current = { ...orderRef.current, ...order };\n },\n getSession: () => applePaySessionRef.current,\n setSession: (\n applePaySession: ApplePaySession,\n _paymentRequest: ApplePayJS.ApplePayPaymentRequest\n ) => {\n applePaySessionRef.current = applePaySession;\n paymentRequest.current = _paymentRequest;\n statusRef.current = Status.inProgress;\n },\n getIsInProgress: () => statusRef.current === Status.inProgress,\n setIsCancelled: () => {\n statusRef.current = Status.cancelled;\n },\n getInitialPaymentRequest: () => paymentRequest.current,\n setOrderShipping: (orderShipping: OrderShipping) => {\n orderShippingRef.current = orderShipping;\n },\n getOrderShipping: () => orderShippingRef.current\n }),\n []\n );\n return methods;\n};\n\nexport default useApplePay;\n","// eslint-disable-next-line import/prefer-default-export\nexport const mapC2ToCN = (countryCode: string) => {\n return countryCode === 'C2' ? 'CN' : countryCode;\n};\n","import React, {\n Dispatch,\n MutableRefObject,\n SetStateAction,\n useContext,\n useState,\n useEffect,\n useMemo\n} from 'react';\nimport cx from 'classnames';\nimport { PayPalButtons, FUNDING } from '@paypal/react-paypal-js';\nimport { Shimmer } from '@paypalcorp/pp-react';\nimport type {\n FUNDING_SOURCE,\n CreateOrderData,\n CreateOrderActions,\n PayPalButtonsComponentOptions\n} from '@paypal/paypal-js';\nimport { Context as WorldReadyContext } from '@paypalcorp/worldready-react';\nimport type {\n ServerError,\n FormErrorMessageType,\n SDKButtonStyle,\n UserInputsType\n} from '@client/typings/Common';\nimport { ButtonVariation } from '@client/typings/Common';\nimport { CaptureStatus } from '@client/utils/constants';\nimport { recordClick, recordActivity, PageName } from '@common/analytics';\nimport { validateForm } from '@components/payment/validation';\nimport _ from 'lodash';\nimport validateCart from '@components/ViewCart/validation';\nimport { WorldReadyProps, getCurrencyConfig } from '@client/utils/localeHelper';\nimport { useAppContext } from '@client/contexts/AppContext';\nimport { usePreviewContext } from '@client/contexts/PreviewContext';\nimport useDeepEqualMemo from '@client/hooks/useDeepEqualMemo';\nimport { PaymentContextType, usePaymentContext } from '@client/contexts/PaymentContext';\nimport type { CartDetails } from '@client/typings/Cart';\nimport { useCartContext } from '@client/contexts/CartContext';\nimport styles, { shimmerHeight } from '@components/ButtonsStack/styles';\nimport { getViewCartTags } from './PaywallHostedButtons/utils';\nimport { handleCreateOrderCartError } from './ordersHelper';\n\nexport interface JSSDKButtonProps {\n buttonType: string | undefined;\n currencyCode: string | undefined;\n fundingSource: FUNDING_SOURCE | undefined;\n createOrder: PayPalButtonsComponentOptions['createOrder'];\n onApprove: PayPalButtonsComponentOptions['onApprove'];\n setInitComplete?: Dispatch>;\n setCaptureStatus: PaymentContextType['setCaptureStatus'];\n userInputsRef: MutableRefObject;\n userInputs: UserInputsType;\n formErrorMessageRef: MutableRefObject;\n pageName: PageName;\n onShippingAddressChange?: PayPalButtonsComponentOptions['onShippingAddressChange'];\n onShippingOptionsChange?: PayPalButtonsComponentOptions['onShippingOptionsChange'];\n onCancel?: PayPalButtonsComponentOptions['onCancel'];\n buttonStyle?: SDKButtonStyle;\n notCollectShippingAddr?: boolean;\n buttonVariables: Record;\n amount?: number;\n paypalButtonMessagingEnabled?: boolean;\n cartDetailsRef?: MutableRefObject;\n isUpdating?: boolean;\n}\n\ninterface BCDCState {\n showPaymentForm: string | null | undefined;\n showShimmer: boolean;\n forceButtonReRender: string;\n}\n\nconst JSSDKButton = ({\n buttonType,\n currencyCode,\n fundingSource,\n createOrder,\n onApprove,\n setInitComplete,\n setCaptureStatus,\n userInputsRef,\n userInputs,\n formErrorMessageRef,\n pageName,\n onShippingAddressChange,\n onShippingOptionsChange,\n onCancel,\n buttonStyle,\n notCollectShippingAddr,\n buttonVariables,\n amount,\n paypalButtonMessagingEnabled,\n cartDetailsRef,\n isUpdating = false\n}: JSSDKButtonProps) => {\n const [isLoading, setIsLoading] = useState(true);\n const [bcdcState, setBcdcState] = useState({\n showPaymentForm: null,\n showShimmer: false,\n forceButtonReRender: ''\n });\n\n const appContext = useAppContext();\n const enablePaywallButtons = appContext?.enablePaywallButtons;\n const { setFormErrorMessage, fptiAdditionalTags, setErrorMessage } = usePaymentContext();\n const { createOrderInPreview, onClickButtonInPreview, isPreview, onApproveInPreview } =\n usePreviewContext();\n const { setStaleCartItems, setCartDetails } = useCartContext();\n const worldReady = useContext(WorldReadyContext);\n const currencyConfig = getCurrencyConfig(worldReady, currencyCode);\n const memorizedButtonStyle = useDeepEqualMemo(buttonStyle);\n const [amountState, setAmountState] = useState(amount || 0);\n\n const debounce = useMemo(\n () =>\n _.debounce((_newAmount: number) => {\n setAmountState(_newAmount);\n }, 500),\n []\n );\n useEffect(() => {\n debounce(amount || 0);\n }, [amount, debounce]);\n const isPaypalButton = fundingSource === FUNDING?.PAYPAL;\n const shouldShowMessaging = isPaypalButton && paypalButtonMessagingEnabled;\n\n // if there is a change in user input and an order id exists during card funding method flow\n // render the shimmer and set the context id back to null\n useEffect(() => {\n if (bcdcState.showPaymentForm && fundingSource === 'card') {\n recordActivity({\n ...fptiAdditionalTags,\n order_id: bcdcState.showPaymentForm,\n eventName: 'bcdc_order_id_cleared'\n });\n setBcdcState({\n showPaymentForm: null,\n showShimmer: true,\n forceButtonReRender: Date.now().toString()\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [userInputs]);\n\n const createOrderWrapper = createOrder\n ? async (data: CreateOrderData, actions: CreateOrderActions) => {\n try {\n const id = await createOrder(data, actions);\n setBcdcState({ ...bcdcState, showPaymentForm: id, showShimmer: false });\n return Promise.resolve(id);\n } catch (e) {\n return Promise.reject(e);\n }\n }\n : undefined;\n\n const showShimmer =\n (enablePaywallButtons && isLoading) ||\n (bcdcState.showShimmer && fundingSource === 'card') ||\n isUpdating;\n\n const getForceReRenderList = () => {\n const list: (SDKButtonStyle | boolean | undefined | string)[] = [\n memorizedButtonStyle,\n notCollectShippingAddr\n ];\n\n if (fundingSource === 'card') {\n list.push(bcdcState.forceButtonReRender);\n }\n return list;\n };\n\n return (\n <>\n {showShimmer && (\n \n )}\n
\n {\n const formValidation =\n buttonType === ButtonVariation.Cart\n ? validateCart(cartDetailsRef?.current, userInputsRef.current)\n : validateForm(\n userInputsRef.current,\n buttonType,\n currencyConfig,\n formErrorMessageRef.current,\n buttonVariables\n );\n setErrorMessage('');\n if (setStaleCartItems) {\n setStaleCartItems(null);\n }\n setFormErrorMessage(formValidation);\n recordClick({\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: `${data.fundingSource}_button_clicked`,\n int_error_desc: formValidation.isFormValid ? {} : formValidation\n });\n\n const isEmptyCart = cartDetailsRef?.current?.total_purchase_quantity === '0';\n if (isEmptyCart) {\n setCaptureStatus(CaptureStatus.CART_EMPTY);\n return actions.reject();\n }\n if (!formValidation.isFormValid) {\n return actions.reject();\n }\n setCaptureStatus('');\n return actions.resolve();\n }\n }\n createOrder={isPreview ? createOrderInPreview : createOrderWrapper}\n onApprove={isPreview ? onApproveInPreview : onApprove}\n onInit={() => {\n if (fundingSource === 'card') {\n setBcdcState({ ...bcdcState, showPaymentForm: null, showShimmer: false });\n }\n\n setIsLoading(false);\n return setInitComplete?.(true);\n }}\n onError={(error) => {\n if (cartDetailsRef?.current && setStaleCartItems && setCartDetails && setErrorMessage) {\n const handled = handleCreateOrderCartError(\n error as ServerError,\n cartDetailsRef.current,\n worldReady,\n setStaleCartItems,\n setCartDetails,\n setErrorMessage\n );\n if (handled) {\n return;\n }\n }\n if (error.status === 403) {\n setCaptureStatus(CaptureStatus.AUTH_FAILED);\n return;\n }\n setCaptureStatus(CaptureStatus.FAILED);\n }}\n onCancel={\n isPreview\n ? undefined\n : (data, actions) => {\n setBcdcState({ ...bcdcState, showPaymentForm: null, showShimmer: false });\n recordClick({\n ...fptiAdditionalTags,\n ...getViewCartTags(cartDetailsRef),\n pageName,\n eventName: 'popup_close_clicked',\n order_id: data.orderID\n });\n\n if (onCancel) {\n onCancel(data, actions);\n }\n }\n }\n onShippingAddressChange={isPreview ? undefined : onShippingAddressChange}\n onShippingOptionsChange={isPreview ? undefined : onShippingOptionsChange}\n style={buttonStyle}\n forceReRender={getForceReRenderList()}\n />\n
\n \n );\n};\n\nJSSDKButton.defaultProps = {\n setInitComplete: undefined,\n onShippingAddressChange: undefined,\n onShippingOptionsChange: undefined\n};\n\nexport default JSSDKButton;\n","import { css } from '@emotion/react';\nimport { checkoutColorMapping } from '@client/utils/constants';\n\nconst styles = {\n paypalButtonsContainer: css`\n &.hide {\n display: none;\n }\n `,\n checkoutButton: css`\n padding: 0 2rem;\n overflow-wrap: anywhere;\n width: 100%;\n line-height: 1.15;\n\n &.black {\n &:hover {\n filter: brightness(${checkoutColorMapping.black.hoverBrightness});\n }\n }\n\n &.white {\n &:hover {\n filter: brightness(${checkoutColorMapping.white.hoverBrightness});\n }\n }\n\n &:hover {\n filter: brightness(${checkoutColorMapping.default.hoverBrightness});\n }\n\n &:focus {\n outline-offset: ${checkoutColorMapping.default.focus.offset};\n outline: ${checkoutColorMapping.default.focus.outline};\n }\n `\n};\n\nexport const shimmerHeight = (height?: number) => css`\n height: ${height ? `${height}px` : '2.813rem'};\n`;\n\nexport default styles;\n","import { ButtonType, INVALID_OPTION_CONTENT_KEY } from '@client/utils/constants';\nimport { FormErrorMessageType, UserInputsType } from '@client/typings/Common';\nimport { CurrencyConfigType } from '@client/utils/localeHelper';\nimport getValidationRules, { getPriceRange } from './rules';\n\ntype ValidationRule = {\n isInvalid: (val: string | undefined) => boolean;\n getMessageVars: () => Record;\n messageId: string;\n};\n\nconst focusOnError = (isFocused: boolean, field: string, useId: boolean = false) => {\n if (isFocused) {\n return;\n }\n // focus on first error\n const queryKey = useId ? `[id=\"${field}\"]` : `[name=\"${field}\"]`;\n const element = document.querySelector(queryKey);\n setTimeout(() => {\n element?.focus();\n }, 450);\n};\n\nconst hasPrefillError = (field: string, formErrorMessage: FormErrorMessageType) =>\n formErrorMessage[field] === INVALID_OPTION_CONTENT_KEY;\n\nconst FIELD_FOCUS_ID_MAP = {\n quantity: 'dropdownMenuButton_quantity-dropdown',\n item: 'dropdownMenuButton_item-dropdown'\n};\n\nexport const validateField = (\n field: string,\n rules: Array,\n value: string | undefined,\n invalidItems: FormErrorMessageType\n): FormErrorMessageType => {\n for (const fieldSpecificRule of rules) {\n if (fieldSpecificRule.isInvalid(value)) {\n focusOnError(invalidItems.isFocused, field);\n invalidItems.isFocused = true;\n invalidItems.isFormValid = false;\n invalidItems[field] = fieldSpecificRule.messageId;\n invalidItems.msgVariables = {\n ...invalidItems.msgVariables,\n ...fieldSpecificRule.getMessageVars()\n };\n }\n }\n\n return invalidItems;\n};\n\nconst getFixedPriceInvalidItems = (\n buttonVariables: Record,\n userInputs: UserInputsType,\n rules: Record>,\n formErrorMessage: FormErrorMessageType,\n invalidItems: FormErrorMessageType\n): FormErrorMessageType => {\n if (hasPrefillError('quantity', formErrorMessage)) {\n focusOnError(invalidItems.isFocused, FIELD_FOCUS_ID_MAP.quantity, true);\n invalidItems.isFocused = true;\n invalidItems.isFormValid = false;\n invalidItems.quantity = INVALID_OPTION_CONTENT_KEY;\n }\n\n [buttonVariables?.memo_label && 'memo'].filter(Boolean).forEach((field: string) => {\n validateField(field, rules[field], userInputs[field], invalidItems);\n });\n\n return invalidItems;\n};\n\nconst getSingleSelectInvalidItems = (\n buttonVariables: Record,\n userInputs: UserInputsType,\n rules: Record>,\n formErrorMessage: FormErrorMessageType,\n invalidItems: FormErrorMessageType\n): FormErrorMessageType => {\n ['item', 'quantity'].forEach((field) => {\n if (hasPrefillError(field, formErrorMessage)) {\n focusOnError(invalidItems.isFocused, FIELD_FOCUS_ID_MAP[field], true);\n invalidItems.isFocused = true;\n invalidItems.isFormValid = false;\n invalidItems[field] = INVALID_OPTION_CONTENT_KEY;\n }\n });\n\n [buttonVariables?.memo_label && 'memo'].filter(Boolean).forEach((field: string) => {\n validateField(field, rules[field], userInputs[field], invalidItems);\n });\n\n return invalidItems;\n};\n\nexport const validateForm = (\n userInputs: UserInputsType,\n btnType: string | undefined,\n currencyConfig: CurrencyConfigType,\n formErrorMessage: FormErrorMessageType,\n buttonVariables: Record\n): FormErrorMessageType => {\n if (!btnType) {\n return { isFormValid: false, isFocused: false, msgVariables: {} };\n }\n\n const invalidItems: FormErrorMessageType = {\n isFormValid: true,\n isFocused: false,\n msgVariables: {}\n };\n const maxTextLength = 127;\n const { min, max } = getPriceRange(currencyConfig.currencyCode);\n const rules = getValidationRules({ maxTextLength, min, max, symbol: currencyConfig.symbol });\n\n switch (btnType) {\n case ButtonType.FIXED_PRICE:\n getFixedPriceInvalidItems(buttonVariables, userInputs, rules, formErrorMessage, invalidItems);\n break;\n case ButtonType.SINGLE_SELECT_LIST:\n getSingleSelectInvalidItems(\n buttonVariables,\n userInputs,\n rules,\n formErrorMessage,\n invalidItems\n );\n break;\n case ButtonType.VARIABLE_PRICE:\n [buttonVariables?.memo_label && 'memo', 'amount', 'invoice']\n .filter(Boolean)\n .forEach((field: string) => {\n validateField(field, rules[field], userInputs[field], invalidItems);\n });\n break;\n default:\n break;\n }\n\n return invalidItems;\n};\n","import currencyRules from './currencyRules.json';\n\nexport const getPriceRange = (currency: string) => {\n const priceRange = currencyRules[currency] ?? currencyRules.default;\n const min = priceRange.min ?? currencyRules.default.min;\n return { min, max: priceRange.max };\n};\n\ntype Restrictions = {\n maxTextLength: number;\n min: number;\n max: number;\n symbol: string;\n};\n\nexport default (restrictions: Restrictions) => ({\n memo: [\n {\n isInvalid: (val) => !val,\n getMessageVars: () => ({}),\n messageId: 'error.text.blank'\n },\n {\n isInvalid: (val) => val && val.length > restrictions.maxTextLength,\n getMessageVars: () => ({}),\n messageId: 'error.text.max'\n }\n ],\n amount: [\n {\n isInvalid: (val) => !val,\n getMessageVars: () => ({}),\n messageId: 'error.text.amount'\n },\n {\n isInvalid: (val) => val && Number(val) < restrictions.min,\n getMessageVars: () => ({\n min: restrictions.min,\n currencySymbol: restrictions.symbol\n }),\n messageId: 'error.text.amountmin'\n },\n {\n isInvalid: (val) => val && Number(val) > restrictions.max,\n getMessageVars: () => ({\n max: restrictions.max\n }),\n messageId: 'error.text.amountmax'\n }\n ],\n invoice: [\n {\n isInvalid: (val) => val && val.length > restrictions.maxTextLength,\n getMessageVars: () => ({}),\n messageId: 'error.text.max'\n }\n ]\n});\n","/**\n * Return true when value is not undefined or not stringified zero. E.g '0', '0.0'\n */\nconst isNonZeroStr = (value: string | undefined): value is string =>\n Boolean(value && Number(value) > 0);\n\nexport const isZeroStr = (value: string | undefined): value is string => Number(value) === 0;\n\nexport default isNonZeroStr;\n","import { useRef } from 'react';\nimport isEqual from 'lodash/isEqual';\n/**\n * This hook is for and only for non-primitive value to keep a memorized version as long as it remains deeply equal.\n * Since React uses Object.is to compare deps, which is a shallow comparison in normal useMemo.\n * Not recommended for primitive use case. Returns original value if value is primitive.\n */\nfunction useDeepEqualMemo(value: T) {\n const ref = useRef(value);\n\n if (value == null || /^[sbn]/.test(typeof value)) {\n return value;\n }\n\n if (!isEqual(ref.current, value)) {\n ref.current = value;\n }\n\n return ref.current;\n}\n\nexport default useDeepEqualMemo;\n"],"names":["FUNDING_TYPE","BaseApplePayHandler","constructor","props","_defineProperty","async","getSession","updateOrder","getIsInProgress","this","sessionContext","applePaySession","createOrderInput","getCreateOrderInput","response","csrfToken","hostedButtonId","merchantId","buttonType","userInputs","fptiAdditionalTags","pageName","cartDetailsRef","cplImpressEvent","eventName","event","recordImpression","getViewCartTags","funding_type","startCPLTracking","tStart","Date","now","responseData","fetchWrapper","method","headers","body","JSON","stringify","link_id","merchant_id","funding_source","button_type","cart_details","current","apiDuration","order_id","context_id","api_response_code","status","api_duration","err","logErrorClient","endCPLTracking","createOrder","session","orderSession","Error","merchantSession","parse","window","atob","getMerchantSession","completeMerchantValidation","message","handleCreateOrderError","getOrder","setCaptureStatus","setIsLoading","setOrderData","paymentContext","userInputsRef","buttonProps","getButtonType","appContext","app","order","contextId","applePayPayment","orderId","applePay","paymentSource","captureOrder","payment","name","completePayment","ApplePaySession","STATUS_SUCCESS","STATUS_FAILURE","CaptureStatus","FAILED","getInitialPaymentRequest","setOrderShipping","worldReady","initialPaymentRequest","isShippingFromProfile","button","locality","administrativeArea","countryCode","postalCode","shippingContact","orderShipping","updateOrderShippingOptions","shippingAddress","city","state","shippingOptions","length","selectedIndex","findIndex","option","selected","selectedOption","splice","unshift","sortShippingOptions","shipping_options","newShippingMethodsForProfileShippingButton","newShippingMethods","map","label","detail","amount","value","identifier","id","getLocalizedString","notApplicable","completeShippingContactSelection","newTotal","toString","total","newLineItems","getLineItems","errors","ApplePayError","getOrderShipping","shippingMethod","completeShippingMethodSelection","optionId","some","abort","setIsCancelled","logWarnClient","paymentRequest","getPaymentRequest","setSession","shouldUpdateOrderShipping","onvalidatemerchant","onValidateMerchant","onpaymentauthorized","onPaymentAuthorized","oncancel","onCancel","onshippingcontactselected","onShippingContactSelected","onshippingmethodselected","onShippingMethodsSelected","cartContext","amexSupportedCurrencyCodes","ContentKey","getTotalFieldLineItems","totalFields","lineItems","shipping","tax","subtotal","showField","push","Shipping","FieldValueContent","Free","FreeShipping","Tax","Subtotal","getOrderShippingLineItems","addSubtotal","tax_total","item_total","breakdown","isNonZeroStr","currencyCode","supportedNetworks","supportsVersion","includes","Status","useApplePay","applePaySessionRef","useRef","orderRef","statusRef","notStarted","orderShippingRef","useMemo","_paymentRequest","inProgress","cancelled","mapC2ToCN","JSSDKButton","fundingSource","onApprove","setInitComplete","formErrorMessageRef","onShippingAddressChange","onShippingOptionsChange","buttonStyle","notCollectShippingAddr","buttonVariables","paypalButtonMessagingEnabled","isUpdating","isLoading","useState","bcdcState","setBcdcState","showPaymentForm","showShimmer","forceButtonReRender","useAppContext","enablePaywallButtons","setFormErrorMessage","setErrorMessage","usePaymentContext","createOrderInPreview","onClickButtonInPreview","isPreview","onApproveInPreview","usePreviewContext","setStaleCartItems","setCartDetails","useCartContext","useContext","WorldReadyContext","currencyConfig","getCurrencyConfig","memorizedButtonStyle","useDeepEqualMemo","amountState","setAmountState","debounce","_debounce","_newAmount","useEffect","shouldShowMessaging","FUNDING","PAYPAL","recordActivity","createOrderWrapper","data","actions","Promise","resolve","e","reject","undefined","_jsxs","_Fragment","children","_jsx","_Shimmer","css","shimmerHeight","height","styles","paypalButtonsContainer","className","cx","PayPalButtons","disabled","position","onClick","formValidation","ButtonVariation","Cart","validateCart","validateForm","recordClick","int_error_desc","isFormValid","total_purchase_quantity","CART_EMPTY","onInit","onError","error","handleCreateOrderCartError","AUTH_FAILED","orderID","style","forceReRender","getForceReRenderList","list","defaultProps","checkoutButton","checkoutColorMapping","black","hoverBrightness","white","default","focus","offset","outline","focusOnError","isFocused","field","useId","queryKey","element","document","querySelector","setTimeout","hasPrefillError","formErrorMessage","INVALID_OPTION_CONTENT_KEY","FIELD_FOCUS_ID_MAP","quantity","item","validateField","rules","invalidItems","fieldSpecificRule","isInvalid","messageId","msgVariables","getMessageVars","btnType","min","max","currency","priceRange","currencyRules","getPriceRange","restrictions","maxTextLength","symbol","memo","val","Number","currencySymbol","invoice","ButtonType","FIXED_PRICE","getFixedPriceInvalidItems","memo_label","filter","Boolean","forEach","SINGLE_SELECT_LIST","getSingleSelectInvalidItems","VARIABLE_PRICE","isZeroStr","ref","test","isEqual"],"sourceRoot":""}