@adyen/adyen-web 6.19.0 → 6.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/adyen.css +5 -5
- package/dist/cjs/adyen.css.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +29 -62
- package/dist/es/adyen.css +5 -5
- package/dist/es/adyen.css.map +1 -1
- package/dist/es/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es/components/Dropin/Dropin.js +1 -1
- package/dist/es/components/Dropin/Dropin.js.map +1 -1
- package/dist/es/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
- package/dist/es/components/PayPal/utils/get-paypal-styles.js.map +1 -1
- package/dist/es/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es/components/UPI/UPI.js +1 -1
- package/dist/es/components/UPI/UPI.js.map +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
- package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
- package/dist/es/components/UPI/constants.js +2 -0
- package/dist/es/components/UPI/constants.js.map +1 -0
- package/dist/es/components/internal/Address/Address.js.map +1 -1
- package/dist/es/components/internal/Alert/Alert.js +1 -1
- package/dist/es/components/internal/Alert/Alert.js.map +1 -1
- package/dist/es/components/internal/ClickToPay/models/ShopperCard.js +1 -1
- package/dist/es/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
- package/dist/es/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es/core/Analytics/utils.js.map +1 -1
- package/dist/es/core/Errors/SRPanel.js.map +1 -1
- package/dist/es/core/Errors/utils.js.map +1 -1
- package/dist/es/core/Services/analytics/collect-id.js +1 -1
- package/dist/es/core/core.js +1 -1
- package/dist/es/core/core.registry.js.map +1 -1
- package/dist/es/core/utils.js.map +1 -1
- package/dist/es/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es/external/preact/dist/preact.js.map +1 -1
- package/dist/es/index.d.ts +29 -62
- package/dist/es/language/utils.js.map +1 -1
- package/dist/es/utils/clipboard.js.map +1 -1
- package/dist/es/utils/setFocus.js.map +1 -1
- package/dist/es/utils/useForm/reducer.js.map +1 -1
- package/dist/es-legacy/adyen.css +5 -5
- package/dist/es-legacy/adyen.css.map +1 -1
- package/dist/es-legacy/components/Ach/components/useSRPanelForACHErrors.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/components/Installments/Installments.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/handlers.js.map +1 -1
- package/dist/es-legacy/components/Card/components/CardInput/useSRPanelForCardInputErrors.js.map +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
- package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
- package/dist/es-legacy/components/Giftcard/components/useSRPanelForGiftcardErrors.js.map +1 -1
- package/dist/es-legacy/components/PayPal/utils/get-paypal-styles.js.map +1 -1
- package/dist/es-legacy/components/PayPalFastlane/FastlaneSDK.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
- package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
- package/dist/es-legacy/components/UPI/UPI.js +1 -1
- package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/UPIComponent.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js +1 -1
- package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppList.js.map +1 -1
- package/dist/es-legacy/components/UPI/constants.js +2 -0
- package/dist/es-legacy/components/UPI/constants.js.map +1 -0
- package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
- package/dist/es-legacy/components/internal/Alert/Alert.js +1 -1
- package/dist/es-legacy/components/internal/Alert/Alert.js.map +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js +1 -1
- package/dist/es-legacy/components/internal/ClickToPay/models/ShopperCard.js.map +1 -1
- package/dist/es-legacy/components/internal/IbanInput/IbanInput.js.map +1 -1
- package/dist/es-legacy/components/internal/OpenInvoice/useSRPanelForOpenInvoiceErrors.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
- package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
- package/dist/es-legacy/components/internal/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
- package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
- package/dist/es-legacy/components/internal/UIElement/utils.js.map +1 -1
- package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
- package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
- package/dist/es-legacy/core/Errors/utils.js.map +1 -1
- package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
- package/dist/es-legacy/core/core.js +1 -1
- package/dist/es-legacy/core/core.registry.js.map +1 -1
- package/dist/es-legacy/core/utils.js.map +1 -1
- package/dist/es-legacy/external/preact/compat/dist/compat.js.map +1 -1
- package/dist/es-legacy/external/preact/dist/preact.js.map +1 -1
- package/dist/es-legacy/language/utils.js.map +1 -1
- package/dist/es-legacy/utils/clipboard.js.map +1 -1
- package/dist/es-legacy/utils/setFocus.js.map +1 -1
- package/dist/es-legacy/utils/useForm/reducer.js.map +1 -1
- package/package.json +159 -159
- package/styles/adyen.css +5 -5
- package/dist/es/components/UPI/components/UPIComponent/constants.js +0 -2
- package/dist/es/components/UPI/components/UPIComponent/constants.js.map +0 -1
- package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
- package/dist/es/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js +0 -2
- package/dist/es-legacy/components/UPI/components/UPIComponent/constants.js.map +0 -1
- package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js +0 -2
- package/dist/es-legacy/components/UPI/components/UPIComponent/useUpiSegmentedControlOptions.js.map +0 -1
package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EA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,GAAGyC,iCACZC,QAASC,EAAoBC,sBAC7BP,WAGJxD,KAAKI,MAAMmD,kBAAkBX,GAK7B5C,KAAKI,MAAM4D,WAAW1B,IAE9B,CAEA2B,MAAAA,EAAOC,YAAEA,IAAerC,OAAEA,EAAM3B,gBAAEA,IAC9B,MAAe,0BAAX2B,EAEIsC,EAACC,EAAAA,CACGC,sBAAuBC,IACnBtE,KAAKc,kBAAkBwD,EAAYd,SAEvCe,mBAAoBD,IAIhB,MAAME,EAAiC,CACnCxD,UAAWsD,EAAYtD,UACvBG,QAAS,GAAGsD,MAAyBH,EAAYtD,aAGrDhB,KAAKc,kBAAkBwD,EAAYd,OAAQgB,IAE/CN,YAAaA,KACThE,EACJwE,gBAAiB1E,KAAKI,MAAMsE,gBAC5BC,aAAc3E,KAAK2E,eAKxB,IACX,CAxOA,WAAAC,CAAYxE,GACRyE,MAAMzE,GAmBV0E,EAAA9E,KAAO2E,eAAgBI,IACnB,MAAMnC,EAAQ,IAAIa,EAAkB,CAChCC,KAAMC,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,wBAGjChF,KAAKI,MAAMmD,kBAAkBX,KAxB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBlF,KAAKI,MAExC,GAAI6E,EAAO,CACP,MAAM/E,EAAiDiF,EAAuB,CAAEF,QAAOC,oBAEvFlF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEkF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADElF,EACY8D,OAAO,UAErBoB,EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
|
|
1
|
+
{"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FULL, THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { AnalyticsLogEvent } from '../../../../core/Analytics/AnalyticsLogEvent';\nimport { AnalyticsEvent } from '../../../../core/Analytics/AnalyticsEvent';\nimport { AnalyticsErrorEvent } from '../../../../core/Analytics/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n const event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: msg,\n subType: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n\n this.props.onSubmitAnalytics(event);\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AnalyticsEvent;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n\n event = new AnalyticsErrorEvent({\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n });\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(event);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.threeDSCompInd) {\n case 'Y':\n result = 'success';\n break;\n case 'N': {\n if (!errorCodeObject) {\n result = 'failed'; // 'failed' is the result returned from the threeDSMethodURL\n } else {\n result = errorCodeObject.errorCode === TIMEOUT ? TIMEOUT : 'failedInternal'; // timed-out; or, 'failed' as a result of internal checks\n }\n break;\n }\n case 'U':\n result = 'noThreeDSMethodURL';\n break;\n default:\n }\n\n /**\n * The fingerprint process is completed, one way or another.\n * The resultObj will be {threeDSCompInd:\"Y\"} in the case of success,\n * else {threeDSCompInd:\"U\"} or {threeDSCompInd:\"N\"} - if we've had some kind of timeout or data parsing problem (as described above)\n */\n\n event = new AnalyticsLogEvent({\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subType: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n });\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(event);\n\n /**\n * Equals call to callSubmit3DS2Fingerprint (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n render({ showSpinner }, { status, fingerPrintData }) {\n if (status === 'retrievingFingerPrint') {\n return (\n <DoFingerprint3DS2\n onCompleteFingerprint={fingerprint => {\n this.setStatusComplete(fingerprint.result);\n }}\n onErrorFingerprint={fingerprint => {\n /**\n * Called when fingerprint times-out (which is still a valid scenario)...\n */\n const timeoutObject: ErrorCodeObject = {\n errorCode: fingerprint.errorCode, // 'timeout'\n message: `${THREEDS2_FINGERPRINT}: ${fingerprint.errorCode}`\n };\n\n this.setStatusComplete(fingerprint.result, timeoutObject); // fingerprint.result = threeDSCompInd: 'N'\n }}\n showSpinner={showSpinner}\n {...fingerPrintData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareFingerprint3DS2;\n"],"names":["PrepareFingerprint3DS2","Component","componentDidMount","isErrorObject","this","state","fingerPrintData","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","AnalyticsErrorEvent","onSubmitAnalytics","result","AnalyticsLogEvent","type","THREEDS2_FULL","THREEDS2_NUM","subType","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"k6BAaA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CACpB,MAAMC,EAO0B,SAA3BH,KAAKI,MAAMC,aAA0BL,KAAKI,MAAME,kBAAkBC,KAAKC,SAAS,0BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBZ,KAAKC,MACpGC,gBAKL,IAH6BW,EAAeJ,EAAkBN,GAoB1D,OAhBAH,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBC,kCAC/BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,GAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZAzB,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAoBU,6BAC/BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORtB,KAAK4B,SAAS,CAAEC,OAAQ,yBAE5B,KAAO,CAGH,MAAMC,EAAmB9B,KAAMC,MAAMC,gBAAgC6B,MAE/Df,EACFc,EAASE,QAAQC,IAA+B,EAC1ChB,EAAoBiB,wBACpBjB,EAAoBkB,+BAE9BnC,KAAKc,kBACD,CAAEC,eAAgB,KAClB,CACIC,YACAG,QAAS,GAAGC,MAA+BU,MAInDT,QAAQC,MAAM,oGAClB,CACJ,CAEAR,iBAA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C,aAAc3E,KAAK2E,eAKxB,IACX,CAxOA,WAAAC,CAAYxE,GACRyE,MAAMzE,GAmBV0E,EAAA9E,KAAO2E,eAAgBI,IACnB,MAAMnC,EAAQ,IAAIa,EAAkB,CAChCC,KAAMC,EACNxC,QAAS4D,EACTlB,QAASC,EAAoBkB,wBAGjChF,KAAKI,MAAMmD,kBAAkBX,KAxB7B,MAAMqC,MAAEA,EAAKC,gBAAEA,GAAoBlF,KAAKI,MAExC,GAAI6E,EAAO,CACP,MAAM/E,EAAiDiF,EAAuB,CAAEF,QAAOC,oBAEvFlF,KAAKC,MAAQ,CACT4B,OAAQ,OACR3B,gBAAiBA,EAEzB,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEkF,SAAS,EAAOrD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA6C,EADElF,EACY8D,OAAO,UAErBoB,EAHElF,EAGYyF,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as
|
|
1
|
+
import{createElement as t}from"../../external/preact/dist/preact.js";import{UIElement as e}from"../internal/UIElement/UIElement.js";import o from"./components/UPIComponent/UPIComponent.js";import{CoreProvider as n}from"../../core/Context/CoreProvider.js";import r from"../internal/Await/Await.js";import s from"../internal/QRLoader/QRLoader.js";import i from"../../core/Errors/SRPanelProvider.js";import{TxVariants as p}from"../tx-variants.js";import a from"../../utils/isMobile.js";import{getQrOption as d,getVpaOption as l,getIntentOption as u}from"./constants.js";function m(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class h extends e{formatProps(t){if(!a())return{...super.formatProps(t),defaultMode:["qrCode","vpa"].includes(t?.defaultMode)?t.defaultMode:"qrCode",apps:[],segmentedControlOptions:[d(t.i18n),l(t.i18n)]};const{i18n:e,apps:o=[]}=t;if(o.length>0){const n=["intent","vpa"].includes(t.defaultMode)?t.defaultMode:"intent";return{...super.formatProps(t),defaultMode:n,apps:o,segmentedControlOptions:[u(e),l(e)]}}return{...super.formatProps(t),defaultMode:"vpa",apps:[],segmentedControlOptions:[]}}get isValid(){return this.state.isValid}formatData(){const{virtualPaymentAddress:t,app:e}=this.state.data||{};return{paymentMethod:{type:this.paymentType,...this.paymentType===p.upi_collect&&t&&{virtualPaymentAddress:t},...this.paymentType===p.upi_intent&&e?.id&&{appId:e.id}}}}get paymentType(){return"qrCode"===this.selectedMode?p.upi_qr:"vpa"===this.selectedMode?p.upi_collect:p.upi_intent}renderContent(e,n,i){switch(e){case"qrCode":return t(s,{ref:t=>{this.componentRef=t},...this.props,qrCodeData:this.props.qrCodeData?encodeURIComponent(this.props.qrCodeData):null,type:p.upi_qr,brandLogo:this.props.brandLogo||this.icon,onComplete:this.onComplete,introduction:this.props.i18n.get("upi.qrCodeWaitingMessage"),countdownTime:5,onActionHandled:this.onActionHandled});case"await":return t(r,{ref:t=>{this.componentRef=t},url:n,type:i,showCountdownTimer:!0,shouldRedirectAutomatically:!0,showAmount:!0,countdownTime:5,clientKey:this.props.clientKey,paymentData:this.props.paymentData,onActionHandled:this.onActionHandled,onError:this.props.onError,messageText:this.props.i18n.get("upi.vpaWaitingMessage"),awaitText:this.props.i18n.get("await.waitForConfirmation"),onComplete:this.onComplete,brandLogo:this.icon,amount:this.props.amount});default:return t(o,{ref:t=>{this.componentRef=t},payButton:this.payButton,onChange:this.setState,onUpdateMode:this.onUpdateMode,apps:this.props.apps,segmentedControlOptions:this.props.segmentedControlOptions,defaultMode:this.props.defaultMode,showPayButton:this.props.showPayButton})}}render(){const{type:e,url:o,paymentMethodType:r}=this.props;return t(n,{i18n:this.props.i18n,loadingContext:this.props.loadingContext,resources:this.resources},t(i,{srPanel:this.props.modules.srPanel},this.renderContent(e,o,r)))}constructor(t,e){super(t,e),m(this,"selectedMode",void 0),m(this,"onUpdateMode",t=>{this.selectedMode=t}),this.selectedMode=this.props.defaultMode}}m(h,"type",p.upi),m(h,"txVariants",[p.upi,p.upi_qr,p.upi_collect,p.upi_intent]);export{h as default};
|
|
2
2
|
//# sourceMappingURL=UPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"2lBAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAaH,GAAOG,aAAe,SAEnCC,KAAM,IAId,MAAMC,EAAgBL,EAAMI,MAAME,OAAS,EACrCC,EAAsBF,EAAgB,SAAW,MACjDG,EAAe,CAACD,EAAqB,UACrCE,EAAqB,CACvBC,GAAI,MACJC,KAAMX,EAAMY,KAAKC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],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\nimport { getIntentOption, getQrOption, getVpaOption } from './constants';\n\n/**\n * For mobile:\n * We should show upi_collect and upi_intent depending on if `apps` are returned in /paymentMethods response.\n * If there is no apps, hide segmented controls.\n * The upi_collect should always be on the second tab.\n * Never show QR code.\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration): UPIConfiguration {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: ['qrCode', 'vpa'].includes(props?.defaultMode) ? props.defaultMode : 'qrCode',\n apps: [], // For desktop, ignore the apps\n segmentedControlOptions: [getQrOption(props.i18n), getVpaOption(props.i18n)]\n };\n }\n\n const { i18n, apps = [] } = props;\n const hasIntentApps = apps.length > 0;\n if (hasIntentApps) {\n // Mobile with UPI apps\n const allowedModes: UpiMode[] = ['intent', 'vpa'];\n const defaultMode = allowedModes.includes(props.defaultMode) ? props.defaultMode : 'intent';\n return {\n ...super.formatProps(props),\n defaultMode,\n apps,\n segmentedControlOptions: [getIntentOption(i18n), getVpaOption(i18n)]\n };\n }\n\n // Mobile, but no UPI apps\n return {\n ...super.formatProps(props),\n defaultMode: 'vpa', // Only VPA is possible\n apps: [],\n segmentedControlOptions: []\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n type: this.paymentType,\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return TxVariants.upi_intent;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n showAmount\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n amount={this.props.amount}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n segmentedControlOptions={this.props.segmentedControlOptions}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","super","defaultMode","includes","apps","segmentedControlOptions","getQrOption","i18n","getVpaOption","length","getIntentOption","isValid","this","state","formatData","virtualPaymentAddress","app","data","paymentMethod","type","paymentType","TxVariants","upi_collect","upi_intent","id","appId","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","get","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","showAmount","clientKey","paymentData","onError","messageText","awaitText","amount","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"+qBAyBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GACR,IAAKC,IACD,MAAO,IACAC,MAAMH,YAAYC,GACrBG,YAAa,CAAC,SAAU,OAAOC,SAASJ,GAAOG,aAAeH,EAAMG,YAAc,SAClFE,KAAM,GACNC,wBAAyB,CAACC,EAAYP,EAAMQ,MAAOC,EAAaT,EAAMQ,QAI9E,MAAMA,KAAEA,EAAIH,KAAEA,EAAO,IAAOL,EAE5B,GADsBK,EAAKK,OAAS,EACjB,CAEf,MACMP,EAD0B,CAAC,SAAU,OACVC,SAASJ,EAAMG,aAAeH,EAAMG,YAAc,SACnF,MAAO,IACAD,MAAMH,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,MAAMmD,QACpBC,YAAavC,KAAKb,MAAMQ,KAAKkC,IAAI,yBACjCW,UAAWxC,KAAKb,MAAMQ,KAAKkC,IAAI,6BAC/BF,WAAY3B,KAAK2B,WACjBF,UAAWzB,KAAK0B,KAChBe,OAAQzC,KAAKb,MAAMsD,SAG/B,QACI,OACItB,EAACuB,EAAAA,CACGrB,IAAMA,IACFrB,KAAKsB,aAAeD,GAExBsB,UAAW3C,KAAK2C,UAChBC,SAAU5C,KAAK6C,SACfC,aAAc9C,KAAK8C,aACnBtD,KAAMQ,KAAKb,MAAMK,KACjBC,wBAAyBO,KAAKb,MAAMM,wBACpCH,YAAaU,KAAKb,MAAMG,YACxByD,cAAe/C,KAAKb,MAAM4D,gBAI9C,CAEOC,MAAAA,GACH,MAAMzC,KAAEA,EAAIU,IAAEA,EAAGC,kBAAEA,GAAsBlB,KAAKb,MAC9C,OACIgC,EAAC8B,EAAAA,CAAatD,KAAMK,KAAKb,MAAMQ,KAAMuD,eAAgBlD,KAAKb,MAAM+D,eAAgBC,UAAWnD,KAAKmD,WAC5FhC,EAACiC,EAAAA,CAAgBC,QAASrD,KAAKb,MAAMmE,QAAQD,SAAUrD,KAAKgB,cAAcT,EAAMU,EAAKC,IAGjG,CAtIA,WAAAqC,CAAYC,EAAiBrE,GACzBE,MAAMmE,EAAUrE,GAHpBsE,EAAAzD,KAAQc,oBAAR,GAkEA2C,EAAAzD,KAAQ8C,eAAgBY,IACpB1D,KAAKc,aAAe4C,IA/DpB1D,KAAKc,aAAed,KAAKb,MAAMG,WACnC,EARAmE,EADEzE,EACYuB,OAAOE,EAAWkD,KAChCF,EAFEzE,EAEY4E,aAAa,CAACnD,EAAWkD,IAAKlD,EAAWM,OAAQN,EAAWC,YAAaD,EAAWE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as o,useEffect as n}from"../../../../external/preact/hooks/dist/hooks.js";import
|
|
1
|
+
import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{useState as a,useCallback as o,useEffect as n}from"../../../../external/preact/hooks/dist/hooks.js";import i from"../VpaInput/VpaInput.js";import r from"../../../../core/Context/useImage.js";import{A11Y as s}from"../../constants.js";import l from"../../../internal/SegmentedControl/SegmentedControl.js";import d from"../UPIIntentAppList/UPIIntentAppList.js";import{useCoreContext as p}from"../../../../core/Context/CoreProvider.js";import c from"../../../internal/Alert/Alert.js";function u({defaultMode:u,onChange:m,onUpdateMode:g=()=>{},payButton:I,showPayButton:b,apps:h=[],segmentedControlOptions:f=[]}){const{i18n:y}=p(),C=r(),[A,N]=a("ready"),[k,j]=a(u),[v,S]=a(null),[V,q]=a(null),[x,P]=a("qrCode"===u);this.setStatus=e=>{N(e)},this.showValidation=()=>{v?.validateInput(),"intent"===k&&M()};const B=o(e=>{S(e)},[]),E=o(e=>{j(e),g(e)},[g]),T=o(e=>{e?.id!==V?.id&&(q(e),P(!0),N("ready"))},[V]),M=o(()=>{V?(N("ready"),P(!0)):(N("error"),P(!1))},[V]);return n(()=>{m("qrCode"!==k?{data:{...V&&{app:V}},isValid:x}:{data:{},valid:{},errors:{},isValid:!0})},[V,x,k,m]),e(t,null,f.length>0&&e("p",{className:"adyen-checkout_upi-mode-selection-text"},y.get("upi.modeSelection")),e(l,{onChange:E,selectedValue:k,disabled:"loading"===A,classNameModifiers:["upi-margin-bottom"],options:f}),"intent"===k&&e("div",{id:s.AreaId.INTENT,"aria-labelledby":s.ButtonId.INTENT,className:"adyen-checkout-upi-area-intent",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.intent.instruction")),"error"===A&&e(c,{icon:"cross"},y.get("upi.error.noAppSelected")),e(d,{disabled:"loading"===A,apps:h,selectedAppId:V?.id,onAppSelect:T}),b&&I({label:y.get("continue"),status:A})),"vpa"===k&&e("div",{id:s.AreaId.VPA,"aria-labelledby":s.ButtonId.VPA,className:"adyen-checkout-upi-area-vpa",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.collect.instruction")),e(i,{disabled:"loading"===A,onChange:m,onSetInputHandlers:B}),b&&I({label:y.get("continue"),status:A})),"qrCode"===k&&e("div",{id:s.AreaId.QR,"aria-labelledby":s.ButtonId.QR,className:"adyen-checkout-upi-area-qr-code",role:"region"},e("span",{className:"adyen-checkout-upi-instruction-label"},y.get("upi.qrCode.instruction")),b&&I({label:y.get("generateQRCode"),icon:C({imageFolder:"components/"})("qr"),status:A})))}export{u as default};
|
|
2
2
|
//# sourceMappingURL=UPIComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h, RefObject } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport { PayButtonFunctionProps, UIElementStatus } from '../../../types';\nimport VpaInput, { VpaInputHandlers } from '../VpaInput/VpaInput';\nimport { App, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport
|
|
1
|
+
{"version":3,"file":"UPIComponent.js","sources":["../../../../../../src/components/UPI/components/UPIComponent/UPIComponent.tsx"],"sourcesContent":["import { Fragment, h, RefObject } from 'preact';\nimport { useCallback, useEffect, useState } from 'preact/hooks';\nimport { PayButtonFunctionProps, UIElementStatus } from '../../../types';\nimport VpaInput, { VpaInputHandlers } from '../VpaInput/VpaInput';\nimport { App, UpiMode } from '../../types';\nimport useImage from '../../../../core/Context/useImage';\nimport { A11Y } from '../../constants';\nimport './UPIComponent.scss';\nimport SegmentedControl from '../../../internal/SegmentedControl';\nimport UPIIntentAppList from '../UPIIntentAppList';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Alert from '../../../internal/Alert';\nimport { SegmentedControlOption } from '../../../internal/SegmentedControl/SegmentedControl';\n\ntype UpiData = { app?: App; virtualPaymentAddress?: string };\n\ntype OnChangeProps = { data: UpiData; valid?: { [key: string]: boolean }; errors?: { [key: string]: any }; isValid: boolean };\n\ninterface UPIComponentProps {\n defaultMode: UpiMode;\n showPayButton: boolean;\n apps?: Array<App>;\n segmentedControlOptions?: Array<SegmentedControlOption<UpiMode>>;\n\n ref?(ref: RefObject<typeof UPIComponent>): void;\n\n payButton?(props: PayButtonFunctionProps): h.JSX.Element;\n\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n\n onUpdateMode?(mode: UpiMode): void;\n}\n\nexport default function UPIComponent({\n defaultMode,\n onChange,\n onUpdateMode = () => {},\n payButton,\n showPayButton,\n apps = [],\n segmentedControlOptions = []\n}: Readonly<UPIComponentProps>): h.JSX.Element {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const [status, setStatus] = useState<UIElementStatus>('ready');\n const [mode, setMode] = useState<UpiMode>(defaultMode);\n const [vpaInputHandlers, setVpaInputHandlers] = useState<VpaInputHandlers>(null);\n const [selectedApp, setSelectedApp] = useState<App>(null);\n const [isValid, setIsValid] = useState<boolean>(defaultMode === 'qrCode');\n\n this.setStatus = (status: UIElementStatus) => {\n setStatus(status);\n };\n\n this.showValidation = () => {\n vpaInputHandlers?.validateInput();\n if (mode === 'intent') {\n validateIntentApp();\n }\n };\n\n const onSetVpaInputHandlers = useCallback((handlers: VpaInputHandlers) => {\n setVpaInputHandlers(handlers);\n }, []);\n\n const onChangeUpiMode = useCallback(\n (newMode: UpiMode) => {\n setMode(newMode);\n onUpdateMode(newMode);\n },\n [onUpdateMode]\n );\n\n const handleAppSelect = useCallback(\n (app: App) => {\n if (app?.id === selectedApp?.id) return;\n\n setSelectedApp(app);\n setIsValid(true);\n setStatus('ready');\n },\n [selectedApp]\n );\n\n const validateIntentApp = useCallback(() => {\n if (!selectedApp) {\n setStatus('error');\n setIsValid(false);\n } else {\n setStatus('ready');\n setIsValid(true);\n }\n }, [selectedApp]);\n\n useEffect(() => {\n if (mode !== 'qrCode') {\n onChange({\n data: { ...(selectedApp && { app: selectedApp }) },\n isValid\n });\n } else {\n /**\n * When selecting QR code mode, we need to clear the state data and trigger the 'onChange'.\n */\n onChange({ data: {}, valid: {}, errors: {}, isValid: true });\n }\n }, [selectedApp, isValid, mode, onChange]);\n\n return (\n <Fragment>\n {segmentedControlOptions.length > 0 && <p className=\"adyen-checkout_upi-mode-selection-text\">{i18n.get('upi.modeSelection')}</p>}\n <SegmentedControl\n onChange={onChangeUpiMode}\n selectedValue={mode}\n disabled={status === 'loading'}\n classNameModifiers={['upi-margin-bottom']}\n options={segmentedControlOptions}\n />\n\n {mode === 'intent' && (\n <div id={A11Y.AreaId.INTENT} aria-labelledby={A11Y.ButtonId.INTENT} className=\"adyen-checkout-upi-area-intent\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.intent.instruction')}</span>\n {status === 'error' && <Alert icon={'cross'}>{i18n.get('upi.error.noAppSelected')}</Alert>}\n <UPIIntentAppList disabled={status === 'loading'} apps={apps} selectedAppId={selectedApp?.id} onAppSelect={handleAppSelect} />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </div>\n )}\n {mode === 'vpa' && (\n <div id={A11Y.AreaId.VPA} aria-labelledby={A11Y.ButtonId.VPA} className=\"adyen-checkout-upi-area-vpa\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.collect.instruction')}</span>\n <VpaInput disabled={status === 'loading'} onChange={onChange} onSetInputHandlers={onSetVpaInputHandlers} />\n\n {showPayButton &&\n payButton({\n label: i18n.get('continue'),\n status\n })}\n </div>\n )}\n {mode === 'qrCode' && (\n <div id={A11Y.AreaId.QR} aria-labelledby={A11Y.ButtonId.QR} className=\"adyen-checkout-upi-area-qr-code\" role=\"region\">\n <span className=\"adyen-checkout-upi-instruction-label\">{i18n.get('upi.qrCode.instruction')}</span>\n {showPayButton &&\n payButton({\n label: i18n.get('generateQRCode'),\n icon: getImage({ imageFolder: 'components/' })('qr'),\n status\n })}\n </div>\n )}\n </Fragment>\n );\n}\n"],"names":["UPIComponent","defaultMode","onChange","onUpdateMode","payButton","showPayButton","apps","segmentedControlOptions","i18n","useCoreContext","getImage","useImage","status","setStatus","useState","mode","setMode","vpaInputHandlers","setVpaInputHandlers","selectedApp","setSelectedApp","isValid","setIsValid","this","showValidation","validateInput","validateIntentApp","onSetVpaInputHandlers","useCallback","handlers","onChangeUpiMode","newMode","handleAppSelect","app","id","useEffect","data","valid","errors","h","Fragment","length","p","className","get","SegmentedControl","selectedValue","disabled","classNameModifiers","options","div","A11Y","AreaId","INTENT","aria-labelledby","ButtonId","role","span","Alert","icon","UPIIntentAppList","selectedAppId","onAppSelect","label","VPA","VpaInput","onSetInputHandlers","QR","imageFolder"],"mappings":"gkBAiCe,SAASA,GAAaC,YACjCA,EAAWC,SACXA,EAAQC,aACRA,EAAe,OAAQC,UACvBA,EAASC,cACTA,EAAaC,KACbA,EAAO,GAAEC,wBACTA,EAA0B,KAE1B,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACVC,EAAQC,GAAaC,EAA0B,UAC/CC,EAAMC,GAAWF,EAAkBb,IACnCgB,EAAkBC,GAAuBJ,EAA2B,OACpEK,EAAaC,GAAkBN,EAAc,OAC7CO,EAASC,GAAcR,EAAkC,WAAhBb,GAEhDsB,KAAKV,UAAaD,IACdC,EAAUD,IAGdW,KAAKC,eAAiB,KAClBP,GAAkBQ,gBACL,WAATV,GACAW,KAIR,MAAMC,EAAwBC,EAAaC,IACvCX,EAAoBW,IACrB,IAEGC,EAAkBF,EACnBG,IACGf,EAAQe,GACR5B,EAAa4B,IAEjB,CAAC5B,IAGC6B,EAAkBJ,EACnBK,IACOA,GAAKC,KAAOf,GAAae,KAE7Bd,EAAea,GACfX,GAAW,GACXT,EAAU,WAEd,CAACM,IAGCO,EAAoBE,EAAY,KAC7BT,GAIDN,EAAU,SACVS,GAAW,KAJXT,EAAU,SACVS,GAAW,KAKhB,CAACH,IAgBJ,OAdAgB,EAAU,KAEFjC,EADS,WAATa,EACS,CACLqB,KAA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CAAkCa,KAAK,UACzGjB,EAACkB,OAAAA,CAAKd,UAAU,wCAAwCnC,EAAKoC,IAAI,2BAChEvC,GACGD,EAAU,CACN2D,MAAOvD,EAAKoC,IAAI,kBAChBe,KAAMjD,EAAS,CAAE0D,YAAa,eAAxB1D,CAAyC,MAC/CE,YAM5B"}
|
package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../Dropin/components/PaymentMethod/PaymentMethodIcon.js";import
|
|
1
|
+
import{createElement as e}from"../../../../../external/preact/dist/preact.js";import t from"../../../../../_virtual/index.js";import a from"../../../../Dropin/components/PaymentMethod/PaymentMethodIcon.js";import p from"../../../../internal/ExpandButton/ExpandButton.js";const c=({app:c,imgSrc:n,isSelected:i,onSelect:o=()=>{}})=>{const m=`adyen-checkout-upi-app-item-button-${c.id}`,s=`adyen-checkout-upi-app-${c.id}`;return e("li",{className:t({"adyen-checkout-upi-app-item":!0,"adyen-checkout-upi-app-item--selected":i}),onClick:()=>(e=>{o(e)})(c)},e("div",{className:"adyen-checkout-upi-app-item-header"},e(p,{classNameModifiers:["upi-app-item"],buttonId:m,isSelected:i,expandContentId:s},e(a,{src:n,altDescription:c.name,type:c.id}),e("label",{className:"adyen-checkout-upi-app-item__label",htmlFor:m},c.name))),i&&e("span",{className:"adyen-checkout-checkmark"}))};export{c as default};
|
|
2
2
|
//# sourceMappingURL=UPIIntentAppItem.js.map
|
package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UPIIntentAppItem.js","sources":["../../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"UPIIntentAppItem.js","sources":["../../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.tsx"],"sourcesContent":["import { h } from 'preact';\nimport cx from 'classnames';\nimport { App } from '../../../types';\nimport PaymentMethodIcon from '../../../../Dropin/components/PaymentMethod/PaymentMethodIcon';\nimport ExpandButton from '../../../../internal/ExpandButton';\nimport './UPIIntentAppItem.scss';\n\ninterface UPIIntentAppItemProps {\n app: App;\n imgSrc: string;\n isSelected: boolean;\n onSelect?: Function;\n}\n\nconst UPIIntentAppItem = ({ app, imgSrc, isSelected, onSelect = () => {} }: UPIIntentAppItemProps): h.JSX.Element => {\n const buttonId = `adyen-checkout-upi-app-item-button-${app.id}`;\n const containerId = `adyen-checkout-upi-app-${app.id}`;\n const handleAppSelected = (app: App) => {\n onSelect(app);\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <li\n className={cx({\n 'adyen-checkout-upi-app-item': true,\n 'adyen-checkout-upi-app-item--selected': isSelected\n })}\n onClick={() => handleAppSelected(app)}\n >\n <div className=\"adyen-checkout-upi-app-item-header\">\n <ExpandButton classNameModifiers={['upi-app-item']} buttonId={buttonId} isSelected={isSelected} expandContentId={containerId}>\n <PaymentMethodIcon src={imgSrc} altDescription={app.name} type={app.id}></PaymentMethodIcon>\n <label className=\"adyen-checkout-upi-app-item__label\" htmlFor={buttonId}>\n {app.name}\n </label>\n </ExpandButton>\n </div>\n {isSelected && <span className=\"adyen-checkout-checkmark\" />}\n </li>\n );\n};\n\nexport default UPIIntentAppItem;\n"],"names":["UPIIntentAppItem","app","imgSrc","isSelected","onSelect","buttonId","id","containerId","h","li","className","cx","onClick","handleAppSelected","div","ExpandButton","classNameModifiers","expandContentId","PaymentMethodIcon","src","altDescription","name","type","label","htmlFor","span"],"mappings":"+QAcA,MAAMA,EAAmB,EAAGC,MAAKC,SAAQC,aAAYC,WAAW,WAC5D,MAAMC,EAAW,sCAAsCJ,EAAIK,KACrDC,EAAc,0BAA0BN,EAAIK,KAKlD,OAEIE,EAACC,KAAAA,CACGC,UAAWC,EAAG,CACV,+BAA+B,EAC/B,wCAAyCR,IAE7CS,QAAS,IAXS,CAACX,IACvBG,EAASH,IAUUY,CAAkBZ,IAEjCO,EAACM,MAAAA,CAAIJ,UAAU,sCACXF,EAACO,EAAAA,CAAaC,mBAAoB,CAAC,gBAAiBX,SAAUA,EAAUF,WAAYA,EAAYc,gBAAiBV,GAC7GC,EAACU,EAAAA,CAAkBC,IAAKjB,EAAQkB,eAAgBnB,EAAIoB,KAAMC,KAAMrB,EAAIK,KACpEE,EAACe,QAAAA,CAAMb,UAAU,qCAAqCc,QAASnB,GAC1DJ,EAAIoB,QAIhBlB,GAAcK,EAACiB,OAAAA,CAAKf,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import
|
|
1
|
+
import{createElement as e}from"../../../../external/preact/dist/preact.js";import t from"../../../../_virtual/index.js";import r from"./UPIIntentAppItem/UPIIntentAppItem.js";import p from"../../../../core/Context/useImage.js";import{useCoreContext as o}from"../../../../core/Context/CoreProvider.js";const a=({apps:a,selectedAppId:i,disabled:s,onAppSelect:n=()=>{}})=>{const{i18n:c}=o(),d=p();return e("ul",{className:t({"adyen-checkout-upi-app-list":!0,"adyen-checkout-upi-app-list--loading":s}),role:"radiogroup","aria-label":c.get("paymentMethodsList.aria.label"),required:!0},a.map(t=>{const p=`adyen-checkout-upi-app-item-${t.id}`,o=i===t.id,a=`upi/${t.id}`,s=d()(a.toLowerCase());return e(r,{key:p,app:t,imgSrc:s,isSelected:o,onSelect:n})}))};export{a as default};
|
|
2
2
|
//# sourceMappingURL=UPIIntentAppList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UPIIntentAppList.js","sources":["../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { App } from '../../types';\nimport UPIIntentAppItem from './UPIIntentAppItem';\nimport
|
|
1
|
+
{"version":3,"file":"UPIIntentAppList.js","sources":["../../../../../../src/components/UPI/components/UPIIntentAppList/UPIIntentAppList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport classNames from 'classnames';\nimport { App } from '../../types';\nimport UPIIntentAppItem from './UPIIntentAppItem';\nimport useImage from '../../../../core/Context/useImage';\nimport './UPIIntentAppList.scss';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\n\ninterface UPIIntentAppListProps {\n apps: Array<App>;\n selectedAppId?: string;\n disabled?: boolean;\n onAppSelect?: (app: App) => void;\n}\n\nconst UPIIntentAppList = ({ apps, selectedAppId, disabled, onAppSelect = () => {} }: UPIIntentAppListProps): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n\n return (\n /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */\n <ul\n className={classNames({\n 'adyen-checkout-upi-app-list': true,\n 'adyen-checkout-upi-app-list--loading': disabled\n })}\n role=\"radiogroup\"\n aria-label={i18n.get('paymentMethodsList.aria.label')}\n required\n >\n {apps.map(app => {\n const key = `adyen-checkout-upi-app-item-${app.id}`;\n const isSelected = selectedAppId === app.id;\n const imgName = `upi/${app.id}`;\n const imgSrc = getImage()(imgName.toLowerCase());\n return <UPIIntentAppItem key={key} app={app} imgSrc={imgSrc} isSelected={isSelected} onSelect={onAppSelect} />;\n })}\n </ul>\n );\n};\n\nexport default UPIIntentAppList;\n"],"names":["UPIIntentAppList","apps","selectedAppId","disabled","onAppSelect","i18n","useCoreContext","getImage","useImage","h","ul","className","classNames","role","aria-label","get","required","map","app","key","id","isSelected","imgName","imgSrc","toLowerCase","UPIIntentAppItem","onSelect"],"mappings":"4SAeA,MAAMA,EAAmB,EAAGC,OAAMC,gBAAeC,WAAUC,cAAc,WACrE,MAAMC,KAAEA,GAASC,IACXC,EAAWC,IAEjB,OAEIC,EAACC,KAAAA,CACGC,UAAWC,EAAW,CAClB,+BAA+B,EAC/B,uCAAwCT,IAE5CU,KAAK,aACLC,aAAYT,EAAKU,IAAI,iCACrBC,UAAAA,GAECf,EAAKgB,IAAIC,IACN,MAAMC,EAAM,+BAA+BD,EAAIE,KACzCC,EAAanB,IAAkBgB,EAAIE,GACnCE,EAAU,OAAOJ,EAAIE,KACrBG,EAAShB,IAAWe,EAAQE,eAClC,OAAOf,EAACgB,EAAAA,CAAiBN,IAAKA,EAAKD,IAAKA,EAAKK,OAAQA,EAAQF,WAAYA,EAAYK,SAAUtB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e={ButtonId:{VPA:"upi-button-vpa",QR:"upi-button-qrCode",INTENT:"upi-button-intent"},AreaId:{VPA:"upi-area-vpa",QR:"upi-area-qrCode",INTENT:"upi-area-intent"}},t=t=>({label:t.get("upi.mode.payByAnyUpi"),value:"intent",id:e.ButtonId.INTENT,controls:e.AreaId.INTENT}),o=t=>({label:t.get("upi.mode.enterUpiId"),value:"vpa",id:e.ButtonId.VPA,controls:e.AreaId.VPA}),a=t=>({label:t.get("upi.mode.qrCode"),value:"qrCode",id:e.ButtonId.QR,controls:e.AreaId.QR});export{e as A11Y,t as getIntentOption,a as getQrOption,o as getVpaOption};
|
|
2
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/UPI/constants.ts"],"sourcesContent":["import { SegmentedControlOption } from '../internal/SegmentedControl/SegmentedControl';\nimport { UpiMode } from './types';\nimport Language from '../../language';\n\nexport const A11Y = {\n ButtonId: {\n VPA: 'upi-button-vpa',\n QR: 'upi-button-qrCode',\n INTENT: 'upi-button-intent'\n },\n AreaId: {\n VPA: 'upi-area-vpa',\n QR: 'upi-area-qrCode',\n INTENT: 'upi-area-intent'\n }\n};\n\nexport const getIntentOption = (i18n: Language): SegmentedControlOption<UpiMode> => ({\n label: i18n.get('upi.mode.payByAnyUpi'),\n value: 'intent',\n id: A11Y.ButtonId.INTENT,\n controls: A11Y.AreaId.INTENT\n});\n\nexport const getVpaOption = (i18n: Language): SegmentedControlOption<UpiMode> => ({\n label: i18n.get('upi.mode.enterUpiId'),\n value: 'vpa',\n id: A11Y.ButtonId.VPA,\n controls: A11Y.AreaId.VPA\n});\n\nexport const getQrOption = (i18n: Language): SegmentedControlOption<UpiMode> => ({\n label: i18n.get('upi.mode.qrCode'),\n value: 'qrCode',\n id: A11Y.ButtonId.QR,\n controls: A11Y.AreaId.QR\n});\n"],"names":["A11Y","ButtonId","VPA","QR","INTENT","AreaId","getIntentOption","i18n","label","get","value","id","controls","getVpaOption","getQrOption"],"mappings":"MAIaA,EAAO,CAChBC,SAAU,CACNC,IAAK,iBACLC,GAAI,oBACJC,OAAQ,qBAEZC,OAAQ,CACJH,IAAK,eACLC,GAAI,kBACJC,OAAQ,oBAIHE,EAAmBC,IAAAA,CAC5BC,MAAOD,EAAKE,IAAI,wBAChBC,MAAO,SACPC,GAAIX,EAAKC,SAASG,OAClBQ,SAAUZ,EAAKK,OAAOD,SAGbS,EAAgBN,IAAAA,CACzBC,MAAOD,EAAKE,IAAI,uBAChBC,MAAO,MACPC,GAAIX,EAAKC,SAASC,IAClBU,SAAUZ,EAAKK,OAAOH,MAGbY,EAAeP,IAAAA,CACxBC,MAAOD,EAAKE,IAAI,mBAChBC,MAAO,SACPC,GAAIX,EAAKC,SAASE,GAClBS,SAAUZ,EAAKK,OAAOF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport default function Address(props: AddressProps) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label || 'address']} label={label}>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","data","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","country","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualBut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BzC,eAAgB,CAAA,EAChByF,sBAAuB,OACvBC,qBAAsB"}
|
|
1
|
+
{"version":3,"file":"Address.js","sources":["../../../../../src/components/internal/Address/Address.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'preact/hooks';\nimport Fieldset from '../FormFields/Fieldset';\nimport ReadOnlyAddress from './components/ReadOnlyAddress';\nimport { getAddressValidationRules } from './validate';\nimport { addressFormatters, countrySpecificFormatters } from './validate.formats';\nimport { AddressProps } from './types';\nimport { AddressData } from '../../../types/global-types';\nimport FieldContainer from './components/FieldContainer';\nimport useForm from '../../../utils/useForm';\nimport Specifications from './Specifications';\nimport { ADDRESS_SCHEMA, FALLBACK_VALUE } from './constants';\nimport { getMaxLengthByFieldAndCountry } from '../../../utils/validator-utils';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport AddressSearch from './components/AddressSearch';\nimport { ComponentMethodsRef } from '../UIElement/types';\n\nexport default function Address(props: AddressProps) {\n const { i18n } = useCoreContext();\n\n const { label = '', requiredFields, visibility, iOSFocusedField = null, showContextualElement } = props;\n\n /** An object by which to expose 'public' members to the parent UIElement */\n const addressRef = useRef<ComponentMethodsRef>({});\n // Just call once\n if (!Object.keys(addressRef.current).length) {\n props.setComponentRef?.(addressRef.current);\n }\n\n const specifications = useMemo(() => new Specifications(props.specifications), [props.specifications]);\n\n const requiredFieldsSchema = specifications.getAddressSchemaForCountryFlat(props.countryCode).filter(field => requiredFields.includes(field));\n\n const [hasSelectedAddress, setHasSelectedAddress] = useState(false);\n\n const [useManualAddress, setUseManualAddress] = useState(false);\n\n const [searchErrorMessage, setSearchErrorMessage] = useState('');\n\n const showAddressSearch = !!props.onAddressLookup;\n\n const [ignoreCountryChange, setIgnoreCountryChange] = useState(false);\n\n const showAddressFields = props.onAddressLookup ? hasSelectedAddress || useManualAddress : true;\n\n const { data, errors, valid, isValid, handleChangeFor, triggerValidation, setData, mergeData } = useForm<AddressData>({\n schema: requiredFieldsSchema,\n defaultData: props.data,\n // Ensure any passed validation rules are merged with the default ones\n rules: { ...getAddressValidationRules(specifications), ...props.validationRules },\n formatters: addressFormatters\n });\n\n const setSearchData = useCallback(\n (selectedAddress: AddressData) => {\n const propsKeysToProcess = ADDRESS_SCHEMA;\n const newStateData = propsKeysToProcess.reduce((acc: AddressData, propKey) => {\n // Make sure the data provided by the merchant is always strings\n const providedValue = selectedAddress[propKey];\n if (providedValue !== null && providedValue !== undefined) {\n // Cast everything to string\n acc[propKey] = String(providedValue);\n }\n return acc;\n }, {});\n mergeData(newStateData);\n setIgnoreCountryChange(true);\n triggerValidation();\n setHasSelectedAddress(true);\n },\n [setHasSelectedAddress, triggerValidation, setData]\n );\n\n const onManualAddress = useCallback(() => {\n setUseManualAddress(true);\n }, []);\n\n // Expose method expected by (parent) Address.tsx\n addressRef.current.showValidation = () => {\n triggerValidation();\n if (showAddressSearch && !showAddressFields && !isValid) {\n setSearchErrorMessage(i18n.get('address.errors.incomplete'));\n } else {\n setSearchErrorMessage('');\n }\n };\n\n /**\n * For iOS: iOSFocusedField is the name of the element calling for other elements to be disabled\n * - so if it is set (meaning we are in iOS *and* an input has been focussed) only enable the field that corresponds to this element\n */\n const enabledFields: string[] = requiredFieldsSchema.filter(item => {\n return !iOSFocusedField ? true : item === iOSFocusedField;\n });\n\n /**\n * Effect that:\n * - Resets validation for all fields by triggering handleChangeFor(fieldName, 'input')\n * - Applies validation on postalCode field in case it has any value\n */\n useEffect((): void => {\n // if the country was set via setSearchData we don't want to trigger this\n if (ignoreCountryChange) {\n setIgnoreCountryChange(false);\n return;\n }\n\n const stateOrProvince = specifications.countryHasDataset(data.country) ? '' : FALLBACK_VALUE;\n const newData = { ...data, stateOrProvince };\n\n requiredFields.forEach(fieldName => {\n handleChangeFor(fieldName, 'input')(newData[fieldName] ?? '');\n });\n\n if (newData.postalCode) {\n handleChangeFor('postalCode', 'blur')(data.postalCode);\n }\n }, [data.country]);\n\n /**\n * Set the value of 'stateOrProvince' during the initial render if\n * property is provided during the creation of the payment method\n */\n useEffect((): void => {\n const stateFieldIsRequired = requiredFields.includes('stateOrProvince');\n const countryHasStatesDataset = data.country && specifications.countryHasDataset(data.country);\n const addressShouldHaveState = stateFieldIsRequired && countryHasStatesDataset;\n const stateOrProvince = data.stateOrProvince || (addressShouldHaveState ? '' : FALLBACK_VALUE);\n\n handleChangeFor('stateOrProvince', 'input')(stateOrProvince);\n }, []);\n\n useEffect((): void => {\n const optionalFields = specifications.getOptionalFieldsForCountry(data.country);\n const processedData = ADDRESS_SCHEMA.reduce((acc, cur) => {\n const isOptional = optionalFields.includes(cur);\n const isRequired = requiredFields.includes(cur);\n const newValue = data[cur];\n const initialValue = props.data[cur];\n // recover default data values which are not requiredFields, or prefill with 'N/A'\n const fallbackValue = !isRequired && !newValue && !!initialValue ? initialValue : FALLBACK_VALUE;\n const value = (isOptional && !newValue) || !isRequired ? fallbackValue : newValue;\n if (value?.length) acc[cur] = value;\n return acc;\n }, {});\n\n props.onChange({ data: processedData, valid, errors, isValid });\n }, [data, valid, errors, isValid]);\n\n if (visibility === 'hidden') return null;\n if (visibility === 'readOnly') return <ReadOnlyAddress data={data} label={label} />;\n\n const getComponent = (fieldName: string, { classNameModifiers = [] }) => {\n if (!requiredFields.includes(fieldName)) return null;\n\n return (\n <FieldContainer\n key={fieldName}\n allowedCountries={props.allowedCountries}\n classNameModifiers={[...classNameModifiers, fieldName]}\n data={data}\n errors={errors}\n valid={valid}\n fieldName={fieldName}\n onInput={handleChangeFor(fieldName, 'input')}\n onBlur={handleChangeFor(fieldName, 'blur')}\n onDropdownChange={handleChangeFor(fieldName, 'blur')}\n specifications={specifications}\n maxLength={getMaxLengthByFieldAndCountry(countrySpecificFormatters, fieldName, data.country, true)}\n trimOnBlur={true}\n disabled={!enabledFields.includes(fieldName)}\n onFieldFocusAnalytics={props.onFieldFocusAnalytics}\n onFieldBlurAnalytics={props.onFieldBlurAnalytics}\n />\n );\n };\n\n const getWrapper = group => (\n <div className=\"adyen-checkout__field-group\">\n {group.map(([field, size]) => getComponent(field, { classNameModifiers: [`col-${size}`] }))}\n </div>\n );\n\n const addressSchema = specifications.getAddressSchemaForCountry(data.country);\n\n return (\n <Fragment>\n <Fieldset classNameModifiers={[label || 'address']} label={label}>\n {showAddressSearch && (\n <AddressSearch\n onAddressLookup={props.onAddressLookup}\n onAddressSelected={props.onAddressSelected}\n onSelect={setSearchData}\n onManualAddress={onManualAddress}\n externalErrorMessage={searchErrorMessage}\n hideManualButton={showAddressFields}\n showContextualElement={showContextualElement}\n contextualText={i18n.get('address.search.contextualText')}\n addressSearchDebounceMs={props.addressSearchDebounceMs}\n />\n )}\n {showAddressFields && (\n <Fragment>{addressSchema.map(field => (field instanceof Array ? getWrapper(field) : getComponent(field, {})))}</Fragment>\n )}\n </Fieldset>\n </Fragment>\n );\n}\n\nAddress.defaultProps = {\n countryCode: null,\n validationRules: null,\n data: {},\n onChange: () => {},\n visibility: 'editable',\n requiredFields: ADDRESS_SCHEMA,\n specifications: {},\n onFieldFocusAnalytics: () => {},\n onFieldBlurAnalytics: () => {}\n};\n"],"names":["Address","props","i18n","useCoreContext","label","requiredFields","visibility","iOSFocusedField","showContextualElement","addressRef","useRef","Object","keys","current","length","setComponentRef","specifications","useMemo","Specifications","requiredFieldsSchema","getAddressSchemaForCountryFlat","countryCode","filter","field","includes","hasSelectedAddress","setHasSelectedAddress","useState","useManualAddress","setUseManualAddress","searchErrorMessage","setSearchErrorMessage","showAddressSearch","onAddressLookup","ignoreCountryChange","setIgnoreCountryChange","showAddressFields","data","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","getAddressValidationRules","validationRules","formatters","addressFormatters","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","country","FALLBACK_VALUE","newData","forEach","fieldName","postalCode","stateFieldIsRequired","countryHasStatesDataset","addressShouldHaveState","optionalFields","getOptionalFieldsForCountry","processedData","cur","isOptional","isRequired","newValue","initialValue","value","onChange","h","ReadOnlyAddress","getComponent","classNameModifiers","FieldContainer","key","allowedCountries","onInput","onBlur","onDropdownChange","maxLength","getMaxLengthByFieldAndCountry","countrySpecificFormatters","trimOnBlur","disabled","onFieldFocusAnalytics","onFieldBlurAnalytics","addressSchema","getAddressSchemaForCountry","Fragment","Fieldset","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"u1BAiBe,SAASA,EAAQC,GAC5B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BP,EAG5FQ,EAAaC,EAA4B,IAE1CC,OAAOC,KAAKH,EAAWI,SAASC,QACjCb,EAAMc,kBAAkBN,EAAWI,SAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAejB,EAAMe,gBAAiB,CAACf,EAAMe,iBAEhFG,EAAuBH,EAAeI,+BAA+BnB,EAAMoB,aAAaC,OAAOC,GAASlB,EAAemB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsB/B,EAAMgC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBnC,EAAMgC,kBAAkBR,GAAsBG,IAElES,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA,GAAcC,EAAqB,CAClHC,OAAQ3B,EACR4B,YAAa9C,EAAMoC,KAEnBW,MAAO,IAAKC,EAA0BjC,MAAoBf,EAAMiD,iBAChEC,WAAYC,IAGVC,EAAgBC,EACjBC,IACG,M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AAUF,EAAcW,IAAI/F,GAAUA,aAAiBgG,MAxBpE7B,EAAC8B,MAAAA,CAAIC,UAAU,+BAwBwElG,EAvB5E+F,IAAI,EAAE/F,EAAOmG,KAAU9B,EAAarE,EAAO,CAAEsE,mBAAoB,CAAC,OAAO6B,SAuBY9B,EAAarE,EAAO,CAAA,MAK5H,CAEAvB,EAAQ2H,aAAe,CACnBtG,YAAa,KACb6B,gBAAiB,KACjBb,KAAM,CAAA,EACNoD,SAAU,OACVnF,WAAY,WACZD,eAAgBoD,EAChBzC,eAAgB,CAAA,EAChByF,sBAAuB,OACvBC,qBAAsB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createElement as e}from"../../../external/preact/dist/preact.js";import
|
|
1
|
+
import{createElement as e}from"../../../external/preact/dist/preact.js";import r from"../../../_virtual/index.js";import a from"../Icon/Icon.js";function t({children:t,classNames:s=[],type:c="error",icon:o}){return e("div",{role:"error"===c||"warning"===c?"alert":"status",className:r("adyen-checkout__alert-message",`adyen-checkout__alert-message--${c}`,s)},o&&e(a,{className:"adyen-checkout__alert-message__icon",type:o}),t)}export{t as default};
|
|
2
2
|
//# sourceMappingURL=Alert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Alert.js","sources":["../../../../../src/components/internal/Alert/Alert.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport cx from 'classnames';\nimport './Alert.scss';\nimport Icon from '../Icon';\n\nconst ALERT_TYPES = ['error', 'warning', 'success'];\n\ninterface AlertProps {\n children: ComponentChildren;\n classNames?: string[];\n icon?: string;\n type?: (typeof ALERT_TYPES)[number];\n}\n\nexport default function Alert({ children, classNames = [], type = 'error', icon }: AlertProps) {\n return (\n <div className={cx('adyen-checkout__alert-message', `adyen-checkout__alert-message--${type}`, classNames)}>\n {icon && <Icon className={'adyen-checkout__alert-message__icon'} type={icon} />}\n {children}\n </div>\n );\n}\n"],"names":["Alert","children","classNames","type","icon","h","div","className","cx","Icon"],"mappings":"iJAce,SAASA,GAAMC,SAAEA,aAAUC,EAAa,GAAEC,KAAEA,EAAO,QAAOC,KAAEA,
|
|
1
|
+
{"version":3,"file":"Alert.js","sources":["../../../../../src/components/internal/Alert/Alert.tsx"],"sourcesContent":["import { ComponentChildren, h } from 'preact';\nimport cx from 'classnames';\nimport './Alert.scss';\nimport Icon from '../Icon';\n\nconst ALERT_TYPES = ['error', 'warning', 'info', 'success'];\n\ninterface AlertProps {\n children: ComponentChildren;\n classNames?: string[];\n icon?: string;\n type?: (typeof ALERT_TYPES)[number];\n}\n\nexport default function Alert({ children, classNames = [], type = 'error', icon }: AlertProps) {\n const role = type === 'error' || type === 'warning' ? 'alert' : 'status';\n\n return (\n <div role={role} className={cx('adyen-checkout__alert-message', `adyen-checkout__alert-message--${type}`, classNames)}>\n {icon && <Icon className={'adyen-checkout__alert-message__icon'} type={icon} />}\n {children}\n </div>\n );\n}\n"],"names":["Alert","children","classNames","type","icon","h","div","role","className","cx","Icon"],"mappings":"iJAce,SAASA,GAAMC,SAAEA,aAAUC,EAAa,GAAEC,KAAEA,EAAO,QAAOC,KAAEA,IAGvE,OACIC,EAACC,MAAAA,CAAIC,KAHa,UAATJ,GAA6B,YAATA,EAAqB,QAAU,SAG3CK,UAAWC,EAAG,gCAAiC,kCAAkCN,IAAQD,IACrGE,GAAQC,EAACK,EAAAA,CAAKF,UAAW,sCAAuCL,KAAMC,IACtEH,EAGb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{SchemeNames as t}from"../services/sdks/utils.js";function i(t,i,a){return i in t?Object.defineProperty(t,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[i]=a,t}class a{get title(){return"visa"===this.scheme?t[this.scheme]:this.descriptorName||t[this.scheme]}get isDcfPopupEmbedded(){return"mc"===this.scheme}confirmCardIsExpired(){if("ACTIVE"
|
|
1
|
+
import{SchemeNames as t}from"../services/sdks/utils.js";function i(t,i,a){return i in t?Object.defineProperty(t,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[i]=a,t}class a{get title(){return"visa"===this.scheme?t[this.scheme]:this.descriptorName||t[this.scheme]}get isDcfPopupEmbedded(){return"mc"===this.scheme}confirmCardIsExpired(){if(!["ACTIVE","PENDING"].includes(this.status))return!0;if(!this.panExpirationYear&&!this.panExpirationMonth)return!1;const[t,i]=[(new Date).getMonth()+1,(new Date).getFullYear()];return!(Number(this.panExpirationYear)>i)&&!(Number(this.panExpirationYear)===i&&Number(this.panExpirationMonth)>=t)}constructor(t,a,r){i(this,"dateOfCardLastUsed",void 0),i(this,"dateOfCardCreated",void 0),i(this,"panLastFour",void 0),i(this,"srcDigitalCardId",void 0),i(this,"scheme",void 0),i(this,"artUri",void 0),i(this,"srcCorrelationId",void 0),i(this,"tokenId",void 0),i(this,"isExpired",void 0),i(this,"panExpirationMonth",void 0),i(this,"panExpirationYear",void 0),i(this,"descriptorName",void 0),i(this,"status",null),this.dateOfCardLastUsed=t.dateOfCardLastUsed,this.dateOfCardCreated=t.dateOfCardCreated,this.panLastFour=t.panLastFour,this.srcDigitalCardId=t.srcDigitalCardId,this.descriptorName=t.digitalCardData.descriptorName,this.tokenId=t.tokenId,this.scheme=a,this.artUri=t.digitalCardData.artUri,this.srcCorrelationId=r,this.panExpirationMonth=t.panExpirationMonth,this.panExpirationYear=t.panExpirationYear,this.status=t.digitalCardData.status,this.isExpired=this.confirmCardIsExpired()}}export{a as default};
|
|
2
2
|
//# sourceMappingURL=ShopperCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShopperCard.js","sources":["../../../../../../src/components/internal/ClickToPay/models/ShopperCard.ts"],"sourcesContent":["import { DigitalCardStatus, SrcCard } from '../services/sdks/types';\nimport { SchemeNames } from '../services/sdks/utils';\nimport { ClickToPayScheme } from '../types';\n\nclass ShopperCard {\n public dateOfCardLastUsed?: string;\n public dateOfCardCreated: string;\n public panLastFour: string;\n public srcDigitalCardId: string;\n public scheme: ClickToPayScheme;\n public artUri: string;\n public srcCorrelationId: string;\n public tokenId?: string;\n public isExpired: boolean;\n\n private readonly panExpirationMonth: string;\n private readonly panExpirationYear: string;\n private readonly descriptorName?: string;\n private readonly status?: DigitalCardStatus = null;\n\n constructor(maskedCard: SrcCard, scheme: ClickToPayScheme, srcCorrelationId: string) {\n this.dateOfCardLastUsed = maskedCard.dateOfCardLastUsed;\n this.dateOfCardCreated = maskedCard.dateOfCardCreated;\n this.panLastFour = maskedCard.panLastFour;\n this.srcDigitalCardId = maskedCard.srcDigitalCardId;\n this.descriptorName = maskedCard.digitalCardData.descriptorName;\n this.tokenId = maskedCard.tokenId;\n this.scheme = scheme;\n this.artUri = maskedCard.digitalCardData.artUri;\n this.srcCorrelationId = srcCorrelationId;\n this.panExpirationMonth = maskedCard.panExpirationMonth;\n this.panExpirationYear = maskedCard.panExpirationYear;\n this.status = maskedCard.digitalCardData.status;\n\n this.isExpired = this.confirmCardIsExpired();\n }\n\n get title() {\n return this.scheme === 'visa' ? SchemeNames[this.scheme] : this.descriptorName || SchemeNames[this.scheme];\n }\n\n get isDcfPopupEmbedded(): boolean {\n return this.scheme === 'mc';\n }\n\n private confirmCardIsExpired(): boolean {\n if (this.status
|
|
1
|
+
{"version":3,"file":"ShopperCard.js","sources":["../../../../../../src/components/internal/ClickToPay/models/ShopperCard.ts"],"sourcesContent":["import { DigitalCardStatus, SrcCard } from '../services/sdks/types';\nimport { SchemeNames } from '../services/sdks/utils';\nimport { ClickToPayScheme } from '../types';\n\nclass ShopperCard {\n public dateOfCardLastUsed?: string;\n public dateOfCardCreated: string;\n public panLastFour: string;\n public srcDigitalCardId: string;\n public scheme: ClickToPayScheme;\n public artUri: string;\n public srcCorrelationId: string;\n public tokenId?: string;\n public isExpired: boolean;\n\n private readonly panExpirationMonth: string;\n private readonly panExpirationYear: string;\n private readonly descriptorName?: string;\n private readonly status?: DigitalCardStatus = null;\n\n constructor(maskedCard: SrcCard, scheme: ClickToPayScheme, srcCorrelationId: string) {\n this.dateOfCardLastUsed = maskedCard.dateOfCardLastUsed;\n this.dateOfCardCreated = maskedCard.dateOfCardCreated;\n this.panLastFour = maskedCard.panLastFour;\n this.srcDigitalCardId = maskedCard.srcDigitalCardId;\n this.descriptorName = maskedCard.digitalCardData.descriptorName;\n this.tokenId = maskedCard.tokenId;\n this.scheme = scheme;\n this.artUri = maskedCard.digitalCardData.artUri;\n this.srcCorrelationId = srcCorrelationId;\n this.panExpirationMonth = maskedCard.panExpirationMonth;\n this.panExpirationYear = maskedCard.panExpirationYear;\n this.status = maskedCard.digitalCardData.status;\n\n this.isExpired = this.confirmCardIsExpired();\n }\n\n get title() {\n return this.scheme === 'visa' ? SchemeNames[this.scheme] : this.descriptorName || SchemeNames[this.scheme];\n }\n\n get isDcfPopupEmbedded(): boolean {\n return this.scheme === 'mc';\n }\n\n private confirmCardIsExpired(): boolean {\n if (!['ACTIVE', 'PENDING'].includes(this.status)) return true;\n\n if (!this.panExpirationYear && !this.panExpirationMonth) return false;\n\n const [currentMonth, currentYear] = [new Date().getMonth() + 1, new Date().getFullYear()];\n if (Number(this.panExpirationYear) > currentYear) return false;\n if (Number(this.panExpirationYear) === currentYear && Number(this.panExpirationMonth) >= currentMonth) return false;\n\n return true;\n }\n}\n\nexport default ShopperCard;\n"],"names":["ShopperCard","title","this","scheme","SchemeNames","descriptorName","isDcfPopupEmbedded","confirmCardIsExpired","includes","status","panExpirationYear","panExpirationMonth","currentMonth","currentYear","Date","getMonth","getFullYear","Number","constructor","maskedCard","srcCorrelationId","_define_property","dateOfCardLastUsed","dateOfCardCreated","panLastFour","srcDigitalCardId","artUri","tokenId","isExpired","digitalCardData"],"mappings":"gLAIA,MAAMA,EAiCF,SAAIC,GACA,MAAuB,SAAhBC,KAAKC,OAAoBC,EAAYF,KAAKC,QAAUD,KAAKG,gBAAkBD,EAAYF,KAAKC,OACvG,CAEA,sBAAIG,GACA,MAAuB,OAAhBJ,KAAKC,MAChB,CAEQI,oBAAAA,GACJ,IAAK,CAAC,SAA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internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: any;\n onChange: (data) => void;\n label: string;\n data: IbanData;\n}\n\ninterface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputState {\n data: any;\n errors: any;\n valid: any;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<IbanInputProps, IbanInputState> {\n private ibanNumber: HTMLInputElement;\n\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : '';\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : '';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setData = (key, value, cb?) => {\n this.setState(prevState => ({ data: { ...prevState.data, [key]: value } }), cb);\n };\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public setValid = (key, value, cb?) => {\n this.setState(prevState => ({ valid: { ...prevState.valid, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr =\n holderStatus != null && !holderStatus // *don't* consider null, i.e. a value that has just been deleted, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null);\n\n const holderErr = !holderStatus // *do* consider null, i.e. an empty field, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n setRef={ref => {\n this.ibanNumber = ref;\n }}\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n />\n </Field>\n\n {this.props.showPayButton && this.props.payButton({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","iban","handleIbanBlur","setRef","ref","ibanNumber","handleIbanInput","autocorrect","spellcheck","showPayButton","payButton","constructor","super","_define_property","setData","key","cb","prevState","setValid","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"8kBAmCA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EA0CpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA1DiB,EAAgBT,KAAKO,MAAMC,KAAK,YA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R,KAAKO,MAAMC,eAAmB,CAC/D,MAAML,EAAkBH,KAAKI,MAAMC,WAAaC,EAAcN,KAAKO,MAAMC,gBAAqB,GAExFhB,GADYQ,KAAKO,MAAMC,gBAA+E,UAA1DC,EAAgBT,KAAKO,MAAMC,iBAAoBT,OAAqB,KACzFI,EACvBK,EAAO,CAAEA,KAAMR,KAAKO,MAAMC,KAAMhB,WAEtCQ,KAAKI,MAAMF,SAASM,EACxB,CACJ,EAEAgD,EAlCE5D,EAkCY+E,eAAe,CACzBzE,SAAU,OACVgE,YAAa,KACb7D,YAAY,EACZY,aAAc,CAAA,EACdO,MAAO"}
|
|
1
|
+
{"version":3,"file":"IbanInput.js","sources":["../../../../../src/components/internal/IbanInput/IbanInput.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport Field from '../FormFields/Field';\nimport { checkIbanStatus, isValidHolder } from './validate';\nimport { electronicFormat, formatIban, getCountryCode, getNextCursorPosition } from './utils';\nimport Fieldset from '../FormFields/Fieldset';\nimport { GenericError } from '../../../core/Errors/types';\nimport InputText from '../FormFields/InputText';\n\ninterface IbanInputProps {\n holderName?: boolean;\n placeholders?: Omit<IbanData, 'countryCode'>;\n countryCode?: string;\n showPayButton?: boolean;\n payButton?: any;\n onChange: (data) => void;\n label: string;\n data: IbanData;\n}\n\ninterface IbanData {\n ownerName?: string;\n ibanNumber?: string;\n countryCode?: string;\n}\n\ninterface IbanInputState {\n data: any;\n errors: any;\n valid: any;\n status: string;\n isValid: boolean;\n cursor: number;\n}\n\nconst ibanHolderNameErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'ach.accountHolderNameField.invalid', // TODO create bespoke translation key\n error: 'ach.accountHolderNameField.invalid'\n};\n\nconst ibanErrorObj: GenericError = {\n isValid: false,\n errorMessage: 'sepaDirectDebit.ibanField.invalid',\n error: 'sepaDirectDebit.ibanField.invalid'\n};\n\nclass IbanInput extends Component<IbanInputProps, IbanInputState> {\n private ibanNumber: HTMLInputElement;\n\n constructor(props) {\n super(props);\n\n this.state = {\n status: 'ready',\n data: {\n ownerName: props?.data?.ownerName || '',\n ibanNumber: props?.data?.ibanNumber || '',\n countryCode: props?.data?.countryCode || ''\n },\n isValid: false,\n cursor: 0,\n errors: {},\n valid: {}\n };\n\n if (this.state.data['ibanNumber']) {\n const electronicFormatIban = electronicFormat(this.state.data['ibanNumber']); // example: NL13TEST0123456789\n this.state.data['ibanNumber'] = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n }\n\n if (this.state.data['ibanNumber'] || this.state.data['ownerName']) {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : '';\n const ibanValid = this.state.data['ibanNumber'] ? checkIbanStatus(this.state.data['ibanNumber']).status === 'valid' : '';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid };\n\n this.props.onChange(data);\n }\n }\n\n public static defaultProps = {\n onChange: () => {},\n countryCode: null,\n holderName: true,\n placeholders: {},\n label: null\n };\n\n setStatus(status) {\n this.setState({ status });\n }\n\n onChange() {\n const holderNameValid = this.props.holderName ? isValidHolder(this.state.data['ownerName']) : true;\n const ibanValid = checkIbanStatus(this.state.data['ibanNumber']).status === 'valid';\n const isValid = ibanValid && holderNameValid;\n const data = { data: this.state.data, isValid, errors: this.state.errors };\n\n this.props.onChange(data);\n }\n\n public setData = (key, value, cb?) => {\n this.setState(prevState => ({ data: { ...prevState.data, [key]: value } }), cb);\n };\n\n public setError = (key, value, cb?) => {\n this.setState(prevState => ({ errors: { ...prevState.errors, [key]: value } }), cb);\n };\n\n public setValid = (key, value, cb?) => {\n this.setState(prevState => ({ valid: { ...prevState.valid, [key]: value } }), cb);\n };\n\n public handleHolderInput = holder => {\n this.setState(\n prevState => ({ data: { ...prevState.data, ownerName: holder } }),\n () => {\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n const holderErr =\n holderStatus != null && !holderStatus // *don't* consider null, i.e. a value that has just been deleted, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange);\n }\n );\n };\n\n public handleIbanInput = e => {\n const inputValue = e.target.value;\n const electronicFormatIban = electronicFormat(inputValue); // example: NL13TEST0123456789\n const iban = formatIban(electronicFormatIban); // example: NL13 TEST 0123 4567 89\n const validationStatus = checkIbanStatus(iban).status;\n\n const countryCode = getCountryCode(electronicFormatIban);\n\n // calculate cursor's new position\n const cursor = e.target.selectionStart;\n const previousIban = this.state.data['ibanNumber'];\n const newCursorPosition = getNextCursorPosition(cursor, iban, previousIban);\n\n this.setState(\n prevState => ({\n data: { ...prevState.data, ibanNumber: iban, countryCode: countryCode },\n errors: {\n ...prevState.errors,\n iban: validationStatus === 'invalid' ? ibanErrorObj : null\n },\n valid: { ...prevState.valid, iban: validationStatus === 'valid' }\n }),\n () => {\n e.target.setSelectionRange(newCursorPosition, newCursorPosition);\n this.onChange();\n }\n );\n };\n\n public handleIbanBlur = e => {\n const currentIban = e.target.value;\n\n if (currentIban.length > 0) {\n const validationStatus = checkIbanStatus(currentIban).status;\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null, this.onChange);\n } else {\n // Empty field is not in error\n this.setError('iban', null, this.onChange);\n }\n };\n\n showValidation() {\n const validationStatus = checkIbanStatus(this.state.data['ibanNumber']).status;\n const holderStatus = isValidHolder(this.state.data['ownerName']);\n this.setError('iban', validationStatus !== 'valid' ? ibanErrorObj : null);\n\n const holderErr = !holderStatus // *do* consider null, i.e. an empty field, to be in error\n ? ibanHolderNameErrorObj\n : null;\n\n this.setError('holder', holderErr, this.onChange); // add callback param to force propagation of state to parent comp\n }\n\n render({ placeholders }: IbanInputProps, { data, errors, valid }) {\n const { i18n } = useCoreContext();\n return (\n <Fieldset classNameModifiers={['iban-input']} label={this.props.label}>\n {this.props.holderName && (\n <Field\n className={'adyen-checkout__field--owner-name'}\n label={i18n.get('sepa.ownerName')}\n filled={data['ownerName'] && data['ownerName'].length}\n errorMessage={errors.holder ? i18n.get(errors.holder.error) : false}\n dir={'ltr'}\n i18n={i18n}\n name={'ownerName'}\n >\n <InputText\n name={'ownerName'}\n className={'adyen-checkout__iban-input__owner-name'}\n placeholder={placeholders?.ownerName}\n value={data['ownerName']}\n aria-invalid={!!this.state.errors.holder}\n aria-label={i18n.get('sepa.ownerName')}\n onInput={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n onBlur={e => this.handleHolderInput((e.target as HTMLInputElement).value)}\n />\n </Field>\n )}\n\n <Field\n className={'adyen-checkout__field--iban-number'}\n label={i18n.get('sepa.ibanNumber')}\n errorMessage={errors.iban ? i18n.get(errors.iban.error) : false}\n filled={data['ibanNumber'] && data['ibanNumber'].length}\n isValid={valid.iban}\n onBlur={this.handleIbanBlur}\n dir={'ltr'}\n i18n={i18n}\n name={'ibanNumber'}\n >\n <InputText\n setRef={ref => {\n this.ibanNumber = ref;\n }}\n name={'ibanNumber'}\n className={'adyen-checkout__iban-input__iban-number'}\n classNameModifiers={['large']}\n placeholder={placeholders?.ibanNumber}\n value={data['ibanNumber']}\n onInput={this.handleIbanInput}\n aria-invalid={!!this.state.errors.iban}\n aria-label={i18n.get('sepa.ibanNumber')}\n autocorrect={'off'}\n spellcheck={false}\n />\n </Field>\n\n {this.props.showPayButton && this.props.payButton({ status: this.state.status })}\n </Fieldset>\n );\n }\n}\n\nexport default IbanInput;\n"],"names":["ibanHolderNameErrorObj","isValid","errorMessage","error","ibanErrorObj","IbanInput","Component","setStatus","status","this","setState","onChange","holderNameValid","props","holderName","isValidHolder","state","data","checkIbanStatus","errors","showValidation","validationStatus","holderStatus","setError","holderErr","render","placeholders","valid","i18n","useCoreContext","h","Fieldset","classNameModifiers","label","Field","className","get","filled","length","holder","dir","name","InputText","placeholder","ownerName","value","aria-invalid","aria-label","onInput","e","handleHolderInput","target","onBlur","iban","handleIbanBlur","setRef","ref","ibanNumber","handleIbanInput","autocorrect","spellcheck","showPayButton","payButton","constructor","super","_define_property","setData","key","cb","prevState","setValid","inputValue","electronicFormatIban","electronicFormat","formatIban","countryCode","getCountryCode","cursor","selectionStart","previousIban","newCursorPosition","getNextCursorPosition","setSelectionRange","currentIban","defaultProps"],"mappings":"8kBAmCA,MAAMA,EAAuC,CACzCC,SAAS,EACTC,aAAc,qCACdC,MAAO,sCAGLC,EAA6B,CAC/BH,SAAS,EACTC,aAAc,oCACdC,MAAO,qCAGX,MAAME,UAAkBC,EA0CpBC,SAAAA,CAAUC,GACNC,KAAKC,SAAS,CAAEF,UACpB,CAEAG,QAAAA,GACI,MAAMC,GAAkBH,KAAKI,MAAMC,YAAaC,EAAcN,KAAKO,MAAMC,gBAEnEhB,EADsE,UAA1DiB,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,QACpCI,EACvBK,EAAO,CAAEA,KAAMR,KAAKO,MAAMC,KAAMhB,UAASkB,OAAQV,KAAKO,MAAMG,QAElEV,KAAKI,MAAMF,SAASM,EACxB,CAsEAG,cAAAA,GACI,MAAMC,EAAmBH,EAAgBT,KAAKO,MAAMC,KAAK,YAAeT,OAClEc,EAAeP,EAAcN,KAAKO,MAAMC,KAAK,WACnDR,KAAKc,SAAS,OAA6B,UAArBF,EAA+BjB,EAAe,MAEpE,MAAMoB,EAAaF,EAEb,KADAtB,EAGNS,KAAKc,SAAS,SAAUC,EAAWf,KAAKE,SAC5C,CAEAc,MAAAA,EAAOC,aAAEA,IAAgCT,KAAEA,EAAIE,OAAEA,EAAMQ,MAAEA,IACrD,MAAMC,KAAEA,GAASC,IACjB,OACIC,EAACC,EAAAA,CAASC,mBAAoB,CAAC,cAAeC,MAAOxB,KAAKI,MAAMoB,OAC3DxB,KAAKI,MAAMC,YACRgB,EAACI,EAAAA,CACGC,UAAW,oCACXF,MAAOL,EAAKQ,IAAI,kBAChBC,OAAQpB,EAAK,WAAgBA,EAAK,UAAaqB,OAC/CpC,eAAciB,EAAOoB,QAASX,EAAKQ,IAAIjB,EAAOoB,OAAOpC,OACrDqC,IAAK,MACLZ,KAAMA,EACNa,KAAM,a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