@adyen/adyen-web 6.37.0 → 6.38.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.
Files changed (194) hide show
  1. package/dist/cjs/adyen.css +9 -9
  2. package/dist/cjs/adyen.css.map +1 -1
  3. package/dist/cjs/index.cjs +2 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/es/adyen.css +9 -9
  6. package/dist/es/adyen.css.map +1 -1
  7. package/dist/es/components/ANCV/components/ANCVInput.js +1 -1
  8. package/dist/es/components/ANCV/components/ANCVInput.js.map +1 -1
  9. package/dist/es/components/Ach/components/AchComponent.js +1 -1
  10. package/dist/es/components/Ach/components/AchComponent.js.map +1 -1
  11. package/dist/es/components/BacsDD/components/BacsInput.js +1 -1
  12. package/dist/es/components/BacsDD/components/BacsInput.js.map +1 -1
  13. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  14. package/dist/es/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  15. package/dist/es/components/Blik/components/BlikInput.js +1 -1
  16. package/dist/es/components/Blik/components/BlikInput.js.map +1 -1
  17. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  18. package/dist/es/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  20. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  21. package/dist/es/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js +1 -1
  22. package/dist/es/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js.map +1 -1
  23. package/dist/es/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  24. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  25. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js +1 -1
  26. package/dist/es/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -1
  27. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  28. package/dist/es/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  29. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  30. package/dist/es/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  31. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
  32. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
  33. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js +1 -1
  34. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js.map +1 -1
  35. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  36. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  37. package/dist/es/components/PayTo/components/BSBInput.js +1 -1
  38. package/dist/es/components/PayTo/components/BSBInput.js.map +1 -1
  39. package/dist/es/components/PayTo/components/PayIDInput.js +1 -1
  40. package/dist/es/components/PayTo/components/PayIDInput.js.map +1 -1
  41. package/dist/es/components/PayTo/components/PayToNameFields.js +1 -1
  42. package/dist/es/components/PayTo/components/PayToNameFields.js.map +1 -1
  43. package/dist/es/components/PayTo/components/PayToPhone.js +1 -1
  44. package/dist/es/components/PayTo/components/PayToPhone.js.map +1 -1
  45. package/dist/es/components/Pix/components/PixInput/PixInput.js +1 -1
  46. package/dist/es/components/Pix/components/PixInput/PixInput.js.map +1 -1
  47. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  48. package/dist/es/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  49. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  50. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  51. package/dist/es/components/ThreeDS2/components/utils.js +1 -1
  52. package/dist/es/components/ThreeDS2/components/utils.js.map +1 -1
  53. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  54. package/dist/es/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  55. package/dist/es/components/internal/Address/Address.js +1 -1
  56. package/dist/es/components/internal/Address/Address.js.map +1 -1
  57. package/dist/es/components/internal/Await/Await.js +1 -1
  58. package/dist/es/components/internal/Await/Await.js.map +1 -1
  59. package/dist/es/components/internal/BrandIcons/BrandIcons.js +1 -1
  60. package/dist/es/components/internal/BrandIcons/BrandIcons.js.map +1 -1
  61. package/dist/es/components/internal/BrandImage/BrandImage.js +1 -1
  62. package/dist/es/components/internal/BrandImage/BrandImage.js.map +1 -1
  63. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js +1 -1
  64. package/dist/es/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js.map +1 -1
  65. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  66. package/dist/es/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  67. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  68. package/dist/es/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  69. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  70. package/dist/es/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  71. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  72. package/dist/es/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  73. package/dist/es/components/internal/FormFields/Field/Field.js +1 -1
  74. package/dist/es/components/internal/FormFields/Field/Field.js.map +1 -1
  75. package/dist/es/components/internal/Img/Img.js.map +1 -1
  76. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  77. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  78. package/dist/es/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  79. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  80. package/dist/es/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  81. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  82. package/dist/es/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  83. package/dist/es/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  84. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  85. package/dist/es/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  86. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  87. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  88. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  89. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  90. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  91. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  92. package/dist/es/core/config.js +1 -1
  93. package/dist/es/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  94. package/dist/es/language/LanguageService.js.map +1 -1
  95. package/dist/es/utils/useForm/useErrorFocus.js +2 -0
  96. package/dist/es/utils/useForm/useErrorFocus.js.map +1 -0
  97. package/dist/es/utils/useForm/useFormWithA11y.js +2 -0
  98. package/dist/es/utils/useForm/useFormWithA11y.js.map +1 -0
  99. package/dist/es-legacy/adyen.css +9 -9
  100. package/dist/es-legacy/adyen.css.map +1 -1
  101. package/dist/es-legacy/components/ANCV/components/ANCVInput.js +1 -1
  102. package/dist/es-legacy/components/ANCV/components/ANCVInput.js.map +1 -1
  103. package/dist/es-legacy/components/Ach/components/AchComponent.js +1 -1
  104. package/dist/es-legacy/components/Ach/components/AchComponent.js.map +1 -1
  105. package/dist/es-legacy/components/BacsDD/components/BacsInput.js +1 -1
  106. package/dist/es-legacy/components/BacsDD/components/BacsInput.js.map +1 -1
  107. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js +1 -1
  108. package/dist/es-legacy/components/BankTransfer/components/BankTransferInput/BankTransferInput.js.map +1 -1
  109. package/dist/es-legacy/components/Blik/components/BlikInput.js +1 -1
  110. package/dist/es-legacy/components/Blik/components/BlikInput.js.map +1 -1
  111. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js +1 -1
  112. package/dist/es-legacy/components/Boleto/components/BoletoInput/BoletoInput.js.map +1 -1
  113. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  114. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  115. package/dist/es-legacy/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js +1 -1
  116. package/dist/es-legacy/components/Card/components/CardInput/components/AvailableBrands/AvailableBrands.js.map +1 -1
  117. package/dist/es-legacy/components/Card/components/CardInput/components/CardNumber.js.map +1 -1
  118. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  119. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js +1 -1
  120. package/dist/es-legacy/components/Card/components/Fastlane/USOnlyPhoneInput.js.map +1 -1
  121. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js +1 -1
  122. package/dist/es-legacy/components/Dragonpay/components/DragonpayInput/DragonpayInput.js.map +1 -1
  123. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js +1 -1
  124. package/dist/es-legacy/components/Dropin/components/PaymentMethod/OrderPaymentMethods.js.map +1 -1
  125. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js +1 -1
  126. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodBrands/PaymentMethodBrands.js.map +1 -1
  127. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js +1 -1
  128. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodIcon.js.map +1 -1
  129. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js +1 -1
  130. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  131. package/dist/es-legacy/components/PayTo/components/BSBInput.js +1 -1
  132. package/dist/es-legacy/components/PayTo/components/BSBInput.js.map +1 -1
  133. package/dist/es-legacy/components/PayTo/components/PayIDInput.js +1 -1
  134. package/dist/es-legacy/components/PayTo/components/PayIDInput.js.map +1 -1
  135. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js +1 -1
  136. package/dist/es-legacy/components/PayTo/components/PayToNameFields.js.map +1 -1
  137. package/dist/es-legacy/components/PayTo/components/PayToPhone.js +1 -1
  138. package/dist/es-legacy/components/PayTo/components/PayToPhone.js.map +1 -1
  139. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js +1 -1
  140. package/dist/es-legacy/components/Pix/components/PixInput/PixInput.js.map +1 -1
  141. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js +1 -1
  142. package/dist/es-legacy/components/PreAuthorizedDebitCanada/components/PreAuthorizedDebitCanadaComponent.js.map +1 -1
  143. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  144. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  145. package/dist/es-legacy/components/ThreeDS2/components/utils.js +1 -1
  146. package/dist/es-legacy/components/ThreeDS2/components/utils.js.map +1 -1
  147. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js +1 -1
  148. package/dist/es-legacy/components/UPI/components/UPIIntentAppList/UPIIntentAppItem/UPIIntentAppItem.js.map +1 -1
  149. package/dist/es-legacy/components/internal/Address/Address.js +1 -1
  150. package/dist/es-legacy/components/internal/Address/Address.js.map +1 -1
  151. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  152. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  153. package/dist/es-legacy/components/internal/BrandIcons/BrandIcons.js +1 -1
  154. package/dist/es-legacy/components/internal/BrandIcons/BrandIcons.js.map +1 -1
  155. package/dist/es-legacy/components/internal/BrandImage/BrandImage.js +1 -1
  156. package/dist/es-legacy/components/internal/BrandImage/BrandImage.js.map +1 -1
  157. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js +1 -1
  158. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.js.map +1 -1
  159. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js +1 -1
  160. package/dist/es-legacy/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.js.map +1 -1
  161. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js +1 -1
  162. package/dist/es-legacy/components/internal/ClickToPay/components/CtPOneTimePassword/CtPOneTimePasswordInput/CtPOneTimePasswordInput.js.map +1 -1
  163. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js +1 -1
  164. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/VisaSdk.js.map +1 -1
  165. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js +1 -1
  166. package/dist/es-legacy/components/internal/CompanyDetails/CompanyDetails.js.map +1 -1
  167. package/dist/es-legacy/components/internal/FormFields/Field/Field.js +1 -1
  168. package/dist/es-legacy/components/internal/FormFields/Field/Field.js.map +1 -1
  169. package/dist/es-legacy/components/internal/Img/Img.js.map +1 -1
  170. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  171. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js +1 -1
  172. package/dist/es-legacy/components/internal/PersonalDetails/PersonalDetails.js.map +1 -1
  173. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js +1 -1
  174. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputFields.js.map +1 -1
  175. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js +1 -1
  176. package/dist/es-legacy/components/internal/PhoneInput/PhoneInputForm.js.map +1 -1
  177. package/dist/es-legacy/components/internal/SecuredFields/binLookup/extensions.js.map +1 -1
  178. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js +1 -1
  179. package/dist/es-legacy/components/internal/SecuredFields/binLookup/triggerBinLookUp.js.map +1 -1
  180. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/createSecuredFields.js.map +1 -1
  181. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleBrandFromBinLookup.js.map +1 -1
  182. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/callbackUtils.js.map +1 -1
  183. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  184. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  185. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  186. package/dist/es-legacy/core/config.js +1 -1
  187. package/dist/es-legacy/hooks/usePaymentStatusTimer/usePaymentStatusTimer.js.map +1 -1
  188. package/dist/es-legacy/language/LanguageService.js.map +1 -1
  189. package/dist/es-legacy/utils/useForm/useErrorFocus.js +2 -0
  190. package/dist/es-legacy/utils/useForm/useErrorFocus.js.map +1 -0
  191. package/dist/es-legacy/utils/useForm/useFormWithA11y.js +2 -0
  192. package/dist/es-legacy/utils/useForm/useFormWithA11y.js.map +1 -0
  193. package/package.json +16 -16
  194. package/styles/adyen.css +9 -9
@@ -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, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject, FingerprintResolveData } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static readonly type = 'scheme';\n\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\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 component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintDataSentWeb,\n message: msg\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__?.includes('localhost:8080')) ||\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: ErrorEventCode.THREEDS2_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: ErrorEventCode.THREEDS2_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 = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_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 const data: FingerprintResolveData = createFingerprintResolveData(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AbstractAnalyticsEvent;\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 ? ErrorEventCode.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: ErrorEventType.threeDS2\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 component: this.props.type,\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 component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintCompleted,\n message: `${THREEDS2_NUM} fingerprinting has 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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ErrorEventType","threeDS2","AnalyticsErrorEvent","_object_spread","component","type","onSubmitAnalytics","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintCompleted","THREEDS2_NUM","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","fingerprintDataSentWeb","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError","isMDFlow"],"mappings":"u/CAYA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CAG2BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,iBAAEA,EAAgBC,6BAAEA,EAA4BC,kBAAEA,EAAiBC,qBAAEA,GAAyBf,KAAKC,MACpGC,gBAKL,IAH6Bc,EAAeJ,EAAkBN,GAoB1D,OAhBAN,KAAKiB,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAeC,2CAC1BC,QAAS,GAAGC,uEAWpBC,QAAQC,MAAM,mEAIlB,MAAMC,EAAmCV,EAAeH,EAA8BP,GAChFqB,EAA4BX,EAAeF,EAAmBR,GAC9DsB,EAAmBb,aAAAA,EAAAA,EAAsBc,OAE/C,IAAKH,IAAqCC,IAA8BC,EAiBpE,OAZA5B,KAAKiB,kBACD,CAAEC,eAAgB,KAClB,CACIC,UAAWC,EAAeU,sCAC1BR,QAAS,GAAGC,uJAIpBC,QAAQC,MACJ,oLAORzB,KAAK+B,SAAS,CAAEC,OAAQ,yBAE5B,KAAO,CAGH,MAAMC,EAAmBjC,KAAMC,MAAMC,gBAAgCgC,MAE/Df,EAAYc,EAAStB,SAASwB,GAC9Bf,EAAegB,iCACfhB,EAAeiB,wCAErBrC,KAAKiB,kBACD,CAAEC,eAAgB,KAClB,CACIC,YACAG,QAAS,GAAGC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AKiB,kBAAkBsD,EAAYb,OAAQe,IAE/CN,YAAaA,GACTjE,GAAAA,CACJyE,gBAAiB3E,KAAKO,MAAMoE,gBAC5BC,aAAc5E,KAAK4E,gBAKxB,IACX,CApOA,WAAAC,CAAYtE,GACRuE,MAAMvE,GAkBVwE,EAAA/E,KAAO4E,eAAgBI,IACnB,MAAMpC,EAAQ,IAAIe,EAAkB,CAChCJ,UAAWvD,KAAKO,MAAMiD,KACtBA,KAAMI,EAAaR,SACnBS,QAASC,EAAgBmB,uBACzB3D,QAAS0D,IAGbhF,KAAKO,MAAMkD,kBAAkBb,KAzB7B,MAAMsC,MAAEA,EAAKC,gBAAEA,GAAoBnF,KAAKO,MAExC,GAAI2E,EAAO,CACP,MAAMhF,EAAiDkF,EAAuB,CAAEF,QAAOC,oBAEvFnF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,gBAAiBA,EAEzB,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEmF,SAAS,EAAOnD,MAAOC,IAEzDX,QAAQC,MAAM,GAAGF,MAA+BY,IAExD,EA3BA4C,EADEnF,EACqB4D,OAAO,UAE9BuB,EAHEnF,EAGqB0F,eAAe,CAClCrB,WAAY,OACZsB,QAAS,OACT5C,YAAa,GACbwB,aAAa,EACbqB,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, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject, FingerprintResolveData } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { THREEDS2_FINGERPRINT, THREEDS2_FINGERPRINT_ERROR, THREEDS2_NUM, MISSING_TOKEN_IN_ACTION_MSG, TIMEOUT } from '../../constants';\nimport { AnalyticsLogEvent, LogEventSubtype, LogEventType } from '../../../../core/Analytics/events/AnalyticsLogEvent';\nimport { AbstractAnalyticsEvent } from '../../../../core/Analytics/events/AbstractAnalyticsEvent';\nimport { AnalyticsErrorEvent, ErrorEventCode, ErrorEventType } from '../../../../core/Analytics/events/AnalyticsErrorEvent';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static readonly type = 'scheme';\n\n public static readonly defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\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\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 component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintDataSentWeb,\n message: msg\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__?.includes('localhost:8080')) ||\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: ErrorEventCode.THREEDS2_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: ErrorEventCode.THREEDS2_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 = errorMsg.includes(MISSING_TOKEN_IN_ACTION_MSG)\n ? ErrorEventCode.THREEDS2_ACTION_IS_MISSING_TOKEN\n : ErrorEventCode.THREEDS2_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 const data: FingerprintResolveData = createFingerprintResolveData(this.props.dataKey, resultObj, this.props.paymentData);\n\n let event: AbstractAnalyticsEvent;\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 ? ErrorEventCode.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: ErrorEventType.threeDS2\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 component: this.props.type,\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 component: this.props.type,\n type: LogEventType.threeDS2,\n subType: LogEventSubtype.fingerprintCompleted,\n message: `${THREEDS2_NUM} fingerprinting has 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","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","threeDSMethodURL","threeDSMethodNotificationURL","postMessageDomain","threeDSServerTransID","isValidHttpUrl","setStatusComplete","threeDSCompInd","errorCode","ErrorEventCode","THREEDS2_TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","THREEDS2_TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","MISSING_TOKEN_IN_ACTION_MSG","THREEDS2_ACTION_IS_MISSING_TOKEN","THREEDS2_TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","createFingerprintResolveData","dataKey","paymentData","event","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ErrorEventType","threeDS2","AnalyticsErrorEvent","_object_spread","component","type","onSubmitAnalytics","result","AnalyticsLogEvent","LogEventType","subType","LogEventSubtype","fingerprintCompleted","THREEDS2_NUM","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","fingerprintDataSentWeb","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError","isMDFlow"],"mappings":"u/CAYA,MAAMA,UAA+BC,EAyCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CAG2BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAgC,QAAhCD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,E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AEF,QAAOC,oBAEvFnF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,kBAER,MAEIF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEmF,SAAS,EAAOnD,MAAOC,IAEzDX,QAAQC,MAAM,GAAGF,MAA+BY,IAExD,EA3BA4C,EADEnF,EACqB4D,OAAO,UAE9BuB,EAHEnF,EAGqB0F,eAAe,CAClCrB,WAAY,OACZsB,QAAS,OACT5C,YAAa,GACbwB,aAAa,EACbqB,UAAU"}
@@ -1,2 +1,2 @@
1
- import{CHALLENGE_WINDOW_SIZES as e,DEFAULT_CHALLENGE_WINDOW_SIZE as t}from"../constants.js";import{getOrigin as r}from"../../../utils/getOrigin.js";import n from"../../../utils/base64.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const s=e=>"success"in e&&!e.success,a=e=>{const t=n.decode(e);if(t.success)try{return JSON.parse(t.data)}catch(e){return{success:!1,error:"Could not JSON parse token"}}return t},i=e=>{if(!e||!Object.keys(e).length)throw new Error("No (populated) data object to encode");return n.encode(JSON.stringify(e))},c=r=>{const n=1===r.length?`0${r}`:r;return Object.prototype.hasOwnProperty.call(e,n)?n:t},u=t=>e[c(t)],l=({token:e,size:t})=>{const n=a(e);if(s(n))return n;const{acsTransID:o,acsURL:i,messageVersion:l,threeDSNotificationURL:p,threeDSServerTransID:f}=n,h=r(p);return{acsURL:i,cReqData:{acsTransID:o,messageVersion:l,threeDSServerTransID:f,messageType:"CReq",challengeWindowSize:c(t)},iframeSizeArr:u(t),postMessageDomain:h}},p=({token:e,notificationURL:t})=>{const n=a(e);if(s(n))return n;const{threeDSMethodNotificationURL:o,threeDSMethodUrl:i,threeDSServerTransID:c}=n,u=t||o;return{threeDSServerTransID:c,threeDSMethodURL:i,threeDSMethodNotificationURL:u,postMessageDomain:r(u)}},f=(e,t,r)=>({data:{[e]:i({threeDSCompInd:t.threeDSCompInd}),paymentData:r}}),h=(e,t,r)=>({data:{details:{[e]:i({transStatus:t,authorisationToken:r})}}}),m=e=>{let t=window.btoa(e).split("=")[0];return t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t},S=(e,t)=>"fingerprint"===e?function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){o(e,t,r[t])})}return e}({showSpinner:!t.isDropin,statusType:"loading"},t.elementRef&&{elementRef:t.elementRef}):{statusType:"custom",i18n:t.i18n,elementRef:t.elementRef};export{h as createChallengeResolveData,f as createFingerprintResolveData,a as decodeAndParseToken,m as encodeBase64URL,i as encodeObject,S as get3DS2FlowProps,u as getChallengeWindowSize,s as isErrorObject,l as prepareChallengeData,p as prepareFingerPrintData,c as validateChallengeWindowSize};
1
+ import{CHALLENGE_WINDOW_SIZES as e,DEFAULT_CHALLENGE_WINDOW_SIZE as t}from"../constants.js";import{getOrigin as r}from"../../../utils/getOrigin.js";import n from"../../../utils/base64.js";function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const s=e=>"success"in e&&!e.success,a=e=>{const t=n.decode(e);if(t.success&&t.data)try{return JSON.parse(t.data)}catch(e){return{success:!1,error:"Could not JSON parse token"}}return t},i=e=>{if(!e||!Object.keys(e).length)throw new Error("No (populated) data object to encode");return n.encode(JSON.stringify(e))},c=r=>{const n=1===r.length?`0${r}`:r;return Object.prototype.hasOwnProperty.call(e,n)?n:t},l=t=>e[c(t)],u=({token:e,size:t})=>{const n=a(e);if(s(n))return n;const{acsTransID:o,acsURL:i,messageVersion:u,threeDSNotificationURL:p,threeDSServerTransID:f}=n,h=r(null!=p?p:"");return{acsURL:null!=i?i:"",cReqData:{acsTransID:null!=o?o:"",messageVersion:null!=u?u:"",threeDSServerTransID:null!=f?f:"",messageType:"CReq",challengeWindowSize:c(t)},iframeSizeArr:l(t),postMessageDomain:h}},p=({token:e,notificationURL:t})=>{var n;const o=a(e);if(s(o))return o;const{threeDSMethodNotificationURL:i,threeDSMethodUrl:c,threeDSServerTransID:l}=o,u=null!==(n=null!=t?t:i)&&void 0!==n?n:"";return{threeDSServerTransID:null!=l?l:"",threeDSMethodURL:null!=c?c:"",threeDSMethodNotificationURL:u,postMessageDomain:r(u)}},f=(e,t,r)=>({data:{[e]:i({threeDSCompInd:t.threeDSCompInd}),paymentData:r}}),h=(e,t,r)=>({data:{details:{[e]:i({transStatus:t,authorisationToken:r})}}}),m=e=>{let t=window.btoa(e).split("=")[0];return t=t.replace(/\+/g,"-"),t=t.replace(/\//g,"_"),t},S=(e,t)=>"fingerprint"===e?function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){o(e,t,r[t])})}return e}({showSpinner:!t.isDropin,statusType:"loading"},t.elementRef&&{elementRef:t.elementRef}):{statusType:"custom",i18n:t.i18n,elementRef:t.elementRef};export{h as createChallengeResolveData,f as createFingerprintResolveData,a as decodeAndParseToken,m as encodeBase64URL,i as encodeObject,S as get3DS2FlowProps,l as getChallengeWindowSize,s as isErrorObject,u as prepareChallengeData,p as prepareFingerPrintData,c as validateChallengeWindowSize};
2
2
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/ThreeDS2/components/utils.ts"],"sourcesContent":["import { CHALLENGE_WINDOW_SIZES, DEFAULT_CHALLENGE_WINDOW_SIZE } from '../constants';\nimport { getOrigin } from '../../../utils/getOrigin';\nimport base64 from '../../../utils/base64';\nimport type {\n ChallengeData,\n ThreeDS2Token,\n FingerPrintData,\n ResultObject,\n FingerprintResolveData,\n ChallengeResolveData,\n ThreeDS2FlowProps,\n ThreeDS2ActionProps\n} from '../types';\nimport type { DecodeObject } from '../../../types/global-types';\nimport type { ErrorObject } from '../../../core/Errors/types';\n\n/**\n * Check if we have been passed an ErrorObject because either base64 decoding or JSON.parse failed\n * @param obj -\n */\nexport const isErrorObject = (obj: ErrorObject | ThreeDS2Token): boolean => {\n return 'success' in obj && !obj.success;\n};\n\nexport const decodeAndParseToken = (token: string): ThreeDS2Token | ErrorObject => {\n const decodedToken: DecodeObject = base64.decode(token);\n if (decodedToken.success) {\n try {\n return JSON.parse(decodedToken.data) as ThreeDS2Token;\n } catch (e) {\n return {\n success: false,\n error: 'Could not JSON parse token'\n };\n }\n }\n\n // base64.decode failed - object will contain error msg: 'not base64' or 'malformed URI sequence'\n return decodedToken as ErrorObject;\n};\n\n/**\n * Performs JSON.stringify on passed object & and base64 encodes result\n * @param obj -\n * @returns encoded result\n */\nexport const encodeObject = obj => {\n if (!obj || !Object.keys(obj).length) {\n throw new Error('No (populated) data object to encode');\n }\n return base64.encode(JSON.stringify(obj));\n};\n\n/**\n * Accepts a size string for the challenge window & returns it if it is valid else returns a default value\n * @param sizeStr - the size string to check the validity of\n * @returns a valid size string\n */\nexport const validateChallengeWindowSize = (sizeStr: string): string => {\n const sizeString = sizeStr.length === 1 ? `0${sizeStr}` : sizeStr;\n const hasSize = Object.prototype.hasOwnProperty.call(CHALLENGE_WINDOW_SIZES, sizeString);\n return hasSize ? sizeString : DEFAULT_CHALLENGE_WINDOW_SIZE;\n};\n\n/**\n * Accepts a size string for the challenge window & returns the corresponding array of w/h values\n * @param sizeStr -\n */\nexport const getChallengeWindowSize = (sizeStr: string): string[] => CHALLENGE_WINDOW_SIZES[validateChallengeWindowSize(sizeStr)];\n\n/**\n * prepareChallengeData\n *\n * Requires an object containing the challenge parameters:\n * @param token - challengeToken string received from /submitThreeDS2Fingerprint, /details or /payments call: contains acsTransID, acsURL, messageVersion,\n * threeDSNotificationURL and threeDSServerTransID\n * @param size - one of five possible challenge window sizes\n */\nexport const prepareChallengeData = ({ token, size }): ChallengeData | ErrorObject => {\n const decodedChallengeToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedChallengeToken)) {\n return decodedChallengeToken as ErrorObject;\n }\n\n const { acsTransID, acsURL, messageVersion, threeDSNotificationURL, threeDSServerTransID } = decodedChallengeToken as ThreeDS2Token;\n const notificationURLOrigin = getOrigin(threeDSNotificationURL);\n\n return {\n acsURL,\n cReqData: {\n acsTransID,\n messageVersion,\n threeDSServerTransID,\n messageType: 'CReq',\n challengeWindowSize: validateChallengeWindowSize(size)\n },\n iframeSizeArr: getChallengeWindowSize(size),\n postMessageDomain: notificationURLOrigin\n } as ChallengeData;\n};\n\n/**\n * prepareFingerPrintData\n *\n * Requires an object containing the fingerprint parameters:\n * @param token - fingerprintToken string received from /payments call: contains threeDSMethodNotificationURL, threeDSMethodUrl and\n * threeDSServerTransID\n * @param notificationURL - the URL that the final notification is expected to be postMessaged from.\n *\n * NOTE: we don't expect merchants to alter the default by passing in a notificationURL of their own via props;\n * and if 3DS2 is being done via createFromAction or handleAction we won't accept it.\n * But if the merchant is using checkout.create('threeDS2DeviceFingerprint') we still support the fact that they might want to set their own\n * notificationURL (aka threeDSMethodNotificationURL)\n */\nexport const prepareFingerPrintData = ({ token, notificationURL }): FingerPrintData | ErrorObject => {\n const decodedFingerPrintToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedFingerPrintToken)) {\n return decodedFingerPrintToken as ErrorObject;\n }\n\n const { threeDSMethodNotificationURL, threeDSMethodUrl: threeDSMethodURL, threeDSServerTransID } = decodedFingerPrintToken as ThreeDS2Token;\n const receivedNotificationURL = notificationURL || threeDSMethodNotificationURL;\n const notificationURLOrigin = getOrigin(receivedNotificationURL);\n\n return {\n threeDSServerTransID,\n threeDSMethodURL,\n threeDSMethodNotificationURL: receivedNotificationURL,\n postMessageDomain: notificationURLOrigin\n } as FingerPrintData;\n};\n\nexport const createFingerprintResolveData = (dataKey: string, resultObj: ResultObject, paymentData: string): FingerprintResolveData => ({\n data: {\n [dataKey]: encodeObject({ threeDSCompInd: resultObj.threeDSCompInd }),\n paymentData\n }\n});\n\nexport const createChallengeResolveData = (dataKey: string, transStatus: string, authorisationToken: string): ChallengeResolveData => ({\n data: {\n details: { [dataKey]: encodeObject({ transStatus, authorisationToken }) }\n }\n});\n\n/**\n *\n * Takes a string and encodes it as a base64url string\n * (https://en.wikipedia.org/wiki/Base64#URL_applications)\n * (See also https://tools.ietf.org/html/rfc7515)\n *\n * @example\n * ```\n * const jsonStr = JSON.stringify( {name:'john', surname:'smith'} );\n * const base64url = encodeBase64URL(jsonStr);\n * ```\n *\n * @param dataStr - data, as a string, to be encoded\n *\n * @returns base64URL - a base64url encoded string\n */\nexport const encodeBase64URL = (dataStr: string): string => {\n const base64Data = window.btoa(dataStr);\n let base64url = base64Data.split('=')[0]; // Remove any trailing '='s\n\n base64url = base64url.replace(/\\+/g, '-'); // 62nd char of encoding\n base64url = base64url.replace(/\\//g, '_'); // 63rd char of encoding\n\n return base64url;\n};\n\n/**\n * Add props specifically needed for the type of 3DS2 flow: fingerprint or challenge\n *\n * @param actionSubtype - 3DS2 flow type: fingerprint or challenge\n * @param props - object from which to extract particular properties\n */\nexport const get3DS2FlowProps = (actionSubtype: string, props: ThreeDS2ActionProps): ThreeDS2FlowProps => {\n if (actionSubtype === 'fingerprint') {\n return {\n showSpinner: !props.isDropin,\n statusType: 'loading',\n // elementRef exists when the fingerprint component is created from the Dropin\n ...(props.elementRef && { elementRef: props.elementRef })\n };\n }\n\n // Challenge\n return {\n statusType: 'custom',\n i18n: props.i18n,\n elementRef: props.elementRef\n };\n};\n"],"names":["isErrorObject","obj","success","decodeAndParseToken","token","decodedToken","base64","decode","JSON","parse","data","e","error","encodeObject","Object","keys","length","Error","encode","stringify","validateChallengeWindowSize","sizeStr","sizeString","prototype","hasOwnProperty","call","CHALLENGE_WINDOW_SIZES","DEFAULT_CHALLENGE_WINDOW_SIZE","getChallengeWindowSize","prepareChallengeData","size","decodedChallengeToken","acsTransID","acsURL","messageVersion","threeDSNotificationURL","threeDSServerTransID","notificationURLOrigin","getOrigin","cReqData","messageType","challengeWindowSize","iframeSizeArr","postMessageDomain","prepareFingerPrintData","notificationURL","decodedFingerPrintToken","threeDSMethodNotificationURL","threeDSMethodUrl","threeDSMethodURL","receivedNotificationURL","createFingerprintResolveData","dataKey","resultObj","paymentData","threeDSCompInd","createChallengeResolveData","transStatus","authorisationToken","details","encodeBase64URL","dataStr","base64url","window","btoa","split","replace","get3DS2FlowProps","actionSubtype","props","_object_spread","showSpinner","isDropin","statusType","elementRef","i18n"],"mappings":"oTAoBO,MAAMA,EAAiBC,GACnB,YAAaA,IAAQA,EAAIC,QAGvBC,EAAuBC,IAChC,MAAMC,EAA6BC,EAAOC,OAAOH,GACjD,GAAIC,EAAaH,QACb,IACI,OAAOM,KAAKC,MAAMJ,EAAaK,KACnC,CAAE,MAAOC,GACL,MAAO,CACHT,SAAS,EACTU,MAAO,6BAEf,CAIJ,OAAOP,GAQEQ,EAAeZ,IACxB,IAAKA,IAAQa,OAAOC,KAAKd,GAAKe,OAC1B,MAAM,IAAIC,MAAM,wCAEpB,OAAOX,EAAOY,OAAOV,KAAKW,UAAUlB,KAQ3BmB,EAA+BC,IACxC,MAAMC,EAAgC,IAAnBD,EAAQL,OAAe,IAAIK,IAAYA,EAE1D,OADgBP,OAAOS,UAAUC,eAAeC,KAAKC,EAAwBJ,GAC5DA,EAAaK,GAOrBC,EAA0BP,GAA8BK,EAAuBN,EAA4BC,IAU3GQ,EAAuB,EAAGzB,QAAO0B,WAC1C,MAAMC,EAAwB5B,EAAoBC,GAElD,GAAIJ,EAAc+B,GACd,OAAOA,EAGX,MAAMC,WAAEA,EAAUC,OAAEA,EAAMC,eAAEA,EAAcC,uBAAEA,EAAsBC,qBAAEA,GAAyBL,EACvFM,EAAwBC,EAAUH,GAExC,MAAO,CACHF,SACAM,SAAU,CACNP,aACAE,iBACAE,uBACAI,YAAa,OACbC,oBAAqBrB,EAA4BU,IAErDY,cAAed,EAAuBE,GACtCa,kBAAmBN,IAiBdO,EAAyB,EAAGxC,QAAOyC,sBAC5C,MAAMC,EAA0B3C,EAAoBC,GAEpD,GAAIJ,EAAc8C,GACd,OAAOA,EAGX,MAAMC,6BAAEA,EAA8BC,iBAAkBC,EAAgBb,qBAAEA,GAAyBU,EAC7FI,EAA0BL,GAAmBE,EAGnD,MAAO,CACHX,uBACAa,mBACAF,6BAA8BG,EAC9BP,kBAN0BL,EAAUY,KAU/BC,EAA+B,CAACC,EAAiBC,EAAyBC,MACnF5C,KAAM,CACF0C,CAACA,GAAUvC,EAAa,CAAE0C,eAAgBF,EAAUE,iBACpDD,iBAIKE,EAA6B,CAACJ,EAAiBK,EAAqBC,MAC7EhD,KAAM,CACFiD,QAAS,CAAEP,CAACA,GAAUvC,EAAa,CAAE4C,cAAaC,2BAoB7CE,EAAmBC,IAE5B,IAAIC,EADeC,OAAOC,KAAKH,GACJI,MAAM,KAAK,GAKtC,OAHAH,EAAYA,EAAUI,QAAQ,MAAO,KACrCJ,EAAYA,EAAUI,QAAQ,MAAO,KAE9BJ,GASEK,EAAmB,CAACC,EAAuBC,IAC9B,gBAAlBD,oUACOE,CAAA,CACHC,aAAcF,EAAMG,SACpBC,WAAY,WAERJ,EAAMK,YAAc,CAAEA,WAAYL,EAAMK,aAK7C,CACHD,WAAY,SACZE,KAAMN,EAAMM,KACZD,WAAYL,EAAMK"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/ThreeDS2/components/utils.ts"],"sourcesContent":["import { CHALLENGE_WINDOW_SIZES, DEFAULT_CHALLENGE_WINDOW_SIZE } from '../constants';\nimport { getOrigin } from '../../../utils/getOrigin';\nimport base64 from '../../../utils/base64';\nimport type {\n ChallengeData,\n ThreeDS2Token,\n FingerPrintData,\n ResultObject,\n FingerprintResolveData,\n ChallengeResolveData,\n ThreeDS2FlowProps,\n ThreeDS2ActionProps\n} from '../types';\nimport type { DecodeObject } from '../../../types/global-types';\nimport type { ErrorObject } from '../../../core/Errors/types';\n\n/**\n * Check if we have been passed an ErrorObject because either base64 decoding or JSON.parse failed\n * @param obj -\n */\nexport const isErrorObject = (obj: ErrorObject | ThreeDS2Token): boolean => {\n return 'success' in obj && !obj.success;\n};\n\nexport const decodeAndParseToken = (token: string): ThreeDS2Token | ErrorObject => {\n const decodedToken: DecodeObject = base64.decode(token);\n if (decodedToken.success && decodedToken.data) {\n try {\n return JSON.parse(decodedToken.data) as ThreeDS2Token;\n } catch (e) {\n return {\n success: false,\n error: 'Could not JSON parse token'\n };\n }\n }\n\n // base64.decode failed - object will contain error msg: 'not base64' or 'malformed URI sequence'\n return decodedToken as ErrorObject;\n};\n\n/**\n * Performs JSON.stringify on passed object & and base64 encodes result\n * @param obj -\n * @returns encoded result\n */\nexport const encodeObject = obj => {\n if (!obj || !Object.keys(obj).length) {\n throw new Error('No (populated) data object to encode');\n }\n return base64.encode(JSON.stringify(obj));\n};\n\n/**\n * Accepts a size string for the challenge window & returns it if it is valid else returns a default value\n * @param sizeStr - the size string to check the validity of\n * @returns a valid size string\n */\nexport const validateChallengeWindowSize = (sizeStr: string): string => {\n const sizeString = sizeStr.length === 1 ? `0${sizeStr}` : sizeStr;\n const hasSize = Object.prototype.hasOwnProperty.call(CHALLENGE_WINDOW_SIZES, sizeString);\n return hasSize ? sizeString : DEFAULT_CHALLENGE_WINDOW_SIZE;\n};\n\n/**\n * Accepts a size string for the challenge window & returns the corresponding array of w/h values\n * @param sizeStr -\n */\nexport const getChallengeWindowSize = (sizeStr: string): string[] => CHALLENGE_WINDOW_SIZES[validateChallengeWindowSize(sizeStr)];\n\n/**\n * prepareChallengeData\n *\n * Requires an object containing the challenge parameters:\n * @param token - challengeToken string received from /submitThreeDS2Fingerprint, /details or /payments call: contains acsTransID, acsURL, messageVersion,\n * threeDSNotificationURL and threeDSServerTransID\n * @param size - one of five possible challenge window sizes\n */\nexport const prepareChallengeData = ({ token, size }: { token: string; size: string }): ChallengeData | ErrorObject => {\n const decodedChallengeToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedChallengeToken)) {\n return decodedChallengeToken as ErrorObject;\n }\n\n const { acsTransID, acsURL, messageVersion, threeDSNotificationURL, threeDSServerTransID } = decodedChallengeToken as ThreeDS2Token;\n const notificationURLOrigin = getOrigin(threeDSNotificationURL ?? '');\n\n return {\n acsURL: acsURL ?? '',\n cReqData: {\n acsTransID: acsTransID ?? '',\n messageVersion: messageVersion ?? '',\n threeDSServerTransID: threeDSServerTransID ?? '',\n messageType: 'CReq',\n challengeWindowSize: validateChallengeWindowSize(size)\n },\n iframeSizeArr: getChallengeWindowSize(size),\n postMessageDomain: notificationURLOrigin\n };\n};\n\n/**\n * prepareFingerPrintData\n *\n * Requires an object containing the fingerprint parameters:\n * @param token - fingerprintToken string received from /payments call: contains threeDSMethodNotificationURL, threeDSMethodUrl and\n * threeDSServerTransID\n * @param notificationURL - the URL that the final notification is expected to be postMessaged from.\n *\n * NOTE: we don't expect merchants to alter the default by passing in a notificationURL of their own via props;\n * and if 3DS2 is being done via createFromAction or handleAction we won't accept it.\n * But if the merchant is using checkout.create('threeDS2DeviceFingerprint') we still support the fact that they might want to set their own\n * notificationURL (aka threeDSMethodNotificationURL)\n */\nexport const prepareFingerPrintData = ({ token, notificationURL }: { token: string; notificationURL?: string }): FingerPrintData | ErrorObject => {\n const decodedFingerPrintToken = decodeAndParseToken(token);\n\n if (isErrorObject(decodedFingerPrintToken)) {\n return decodedFingerPrintToken as ErrorObject;\n }\n\n const { threeDSMethodNotificationURL, threeDSMethodUrl: threeDSMethodURL, threeDSServerTransID } = decodedFingerPrintToken as ThreeDS2Token;\n const receivedNotificationURL = notificationURL ?? threeDSMethodNotificationURL ?? '';\n const notificationURLOrigin = getOrigin(receivedNotificationURL);\n\n return {\n threeDSServerTransID: threeDSServerTransID ?? '',\n threeDSMethodURL: threeDSMethodURL ?? '',\n threeDSMethodNotificationURL: receivedNotificationURL,\n postMessageDomain: notificationURLOrigin\n };\n};\n\nexport const createFingerprintResolveData = (dataKey: string, resultObj: ResultObject, paymentData: string): FingerprintResolveData => ({\n data: {\n [dataKey]: encodeObject({ threeDSCompInd: resultObj.threeDSCompInd }),\n paymentData\n }\n});\n\nexport const createChallengeResolveData = (dataKey: string, transStatus: string, authorisationToken: string): ChallengeResolveData => ({\n data: {\n details: { [dataKey]: encodeObject({ transStatus, authorisationToken }) }\n }\n});\n\n/**\n *\n * Takes a string and encodes it as a base64url string\n * (https://en.wikipedia.org/wiki/Base64#URL_applications)\n * (See also https://tools.ietf.org/html/rfc7515)\n *\n * @example\n * ```\n * const jsonStr = JSON.stringify( {name:'john', surname:'smith'} );\n * const base64url = encodeBase64URL(jsonStr);\n * ```\n *\n * @param dataStr - data, as a string, to be encoded\n *\n * @returns base64URL - a base64url encoded string\n */\nexport const encodeBase64URL = (dataStr: string): string => {\n const base64Data = window.btoa(dataStr);\n let base64url = base64Data.split('=')[0]; // Remove any trailing '='s\n\n base64url = base64url.replace(/\\+/g, '-'); // 62nd char of encoding\n base64url = base64url.replace(/\\//g, '_'); // 63rd char of encoding\n\n return base64url;\n};\n\n/**\n * Add props specifically needed for the type of 3DS2 flow: fingerprint or challenge\n *\n * @param actionSubtype - 3DS2 flow type: fingerprint or challenge\n * @param props - object from which to extract particular properties\n */\nexport const get3DS2FlowProps = (actionSubtype: string, props: ThreeDS2ActionProps): ThreeDS2FlowProps => {\n if (actionSubtype === 'fingerprint') {\n return {\n showSpinner: !props.isDropin,\n statusType: 'loading',\n // elementRef exists when the fingerprint component is created from the Dropin\n ...(props.elementRef && { elementRef: props.elementRef })\n };\n }\n\n // Challenge\n return {\n statusType: 'custom',\n i18n: props.i18n,\n elementRef: props.elementRef\n };\n};\n"],"names":["isErrorObject","obj","success","decodeAndParseToken","token","decodedToken","base64","decode","data","JSON","parse","e","error","encodeObject","Object","keys","length","Error","encode","stringify","validateChallengeWindowSize","sizeStr","sizeString","prototype","hasOwnProperty","call","CHALLENGE_WINDOW_SIZES","DEFAULT_CHALLENGE_WINDOW_SIZE","getChallengeWindowSize","prepareChallengeData","size","decodedChallengeToken","acsTransID","acsURL","messageVersion","threeDSNotificationURL","threeDSServerTransID","notificationURLOrigin","getOrigin","cReqData","messageType","challengeWindowSize","iframeSizeArr","postMessageDomain","prepareFingerPrintData","notificationURL","decodedFingerPrintToken","threeDSMethodNotificationURL","threeDSMethodUrl","threeDSMethodURL","receivedNotificationURL","createFingerprintResolveData","dataKey","resultObj","paymentData","threeDSCompInd","createChallengeResolveData","transStatus","authorisationToken","details","encodeBase64URL","dataStr","base64url","window","btoa","split","replace","get3DS2FlowProps","actionSubtype","props","_object_spread","showSpinner","isDropin","statusType","elementRef","i18n"],"mappings":"oTAoBO,MAAMA,EAAiBC,GACnB,YAAaA,IAAQA,EAAIC,QAGvBC,EAAuBC,IAChC,MAAMC,EAA6BC,EAAOC,OAAOH,GACjD,GAAIC,EAAaH,SAAWG,EAAaG,KACrC,IACI,OAAOC,KAAKC,MAAML,EAAaG,KACnC,CAAE,MAAOG,GACL,MAAO,CACHT,SAAS,EACTU,MAAO,6BAEf,CAIJ,OAAOP,GAQEQ,EAAeZ,IACxB,IAAKA,IAAQa,OAAOC,KAAKd,GAAKe,OAC1B,MAAM,IAAIC,MAAM,wCAEpB,OAAOX,EAAOY,OAAOT,KAAKU,UAAUlB,KAQ3BmB,EAA+BC,IACxC,MAAMC,EAAgC,IAAnBD,EAAQL,OAAe,IAAIK,IAAYA,EAE1D,OADgBP,OAAOS,UAAUC,eAAeC,KAAKC,EAAwBJ,GAC5DA,EAAaK,GAOrBC,EAA0BP,GAA8BK,EAAuBN,EAA4BC,IAU3GQ,EAAuB,EAAGzB,QAAO0B,WAC1C,MAAMC,EAAwB5B,EAAoBC,GAElD,GAAIJ,EAAc+B,GACd,OAAOA,EAGX,MAAMC,WAAEA,EAAUC,OAAEA,EAAMC,eAAEA,EAAcC,uBAAEA,EAAsBC,qBAAEA,GAAyBL,EAC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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 i=({app:i,imgSrc:c,isSelected:n,onSelect:o})=>{const m=`adyen-checkout-upi-app-item-button-${i.id}`,s=`adyen-checkout-upi-app-${i.id}`;return e("li",{className:t({"adyen-checkout-upi-app-item":!0,"adyen-checkout-upi-app-item--selected":n}),onClick:()=>(e=>{o(e)})(i)},e("div",{className:"adyen-checkout-upi-app-item-header"},e(p,{classNameModifiers:["upi-app-item"],buttonId:m,isSelected:n,expandContentId:s},e(a,{src:c,altDescription:i.name,type:i.id}),e("label",{className:"adyen-checkout-upi-app-item__label",htmlFor:m},i.name))),n&&e("span",{className:"adyen-checkout-upi-app-item__checkmark"}))};export{i as default};
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:i,isSelected:n,onSelect:o})=>{const m=`adyen-checkout-upi-app-item-button-${c.id}`,d=`adyen-checkout-upi-app-${c.id}`;return e("li",{className:t({"adyen-checkout-upi-app-item":!0,"adyen-checkout-upi-app-item--selected":n}),onClick:()=>(e=>{o(e)})(c)},e("div",{className:"adyen-checkout-upi-app-item-header"},e(p,{classNameModifiers:["upi-app-item"],buttonId:m,isSelected:n,expandContentId:d},e(a,{src:i,alt:c.name,type:c.id}),e("label",{className:"adyen-checkout-upi-app-item__label",htmlFor:m},c.name))),n&&e("span",{className:"adyen-checkout-upi-app-item__checkmark"}))};export{c as default};
2
2
  //# sourceMappingURL=UPIIntentAppItem.js.map
@@ -1 +1 @@
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: (app: App) => void;\n}\n\nconst UPIIntentAppItem = ({ app, imgSrc, isSelected, onSelect }: Readonly<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-upi-app-item__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,eACjD,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
+ {"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: (app: App) => void;\n}\n\nconst UPIIntentAppItem = ({ app, imgSrc, isSelected, onSelect }: Readonly<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} alt={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-upi-app-item__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","alt","name","type","label","htmlFor","span"],"mappings":"+QAcA,MAAMA,EAAmB,EAAGC,MAAKC,SAAQC,aAAYC,eACjD,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,IAAKnB,EAAIoB,KAAMC,KAAMrB,EAAIK,KACzDE,EAACe,QAAAA,CAAMb,UAAU,qCAAqCc,QAASnB,GAC1DJ,EAAIoB,QAIhBlB,GAAcK,EAACiB,OAAAA,CAAKf,UAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as d,countrySpecificFormatters as u}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as v}from"../../../utils/validator-utils.js";import{useCoreContext as O}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){h(e,t,r[t])})}return e}function F(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function C(h){var C,A;const{i18n:P}=O(),{label:S="",requiredFields:w,visibility:k,iOSFocusedField:x=null,showContextualElement:D}=h,M=r({});var E;Object.keys(M.current).length||(null===(E=h.setComponentRef)||void 0===E||E.call(h,M.current));const B=o(()=>new f(h.specifications),[h.specifications]),L=B.getAddressSchemaForCountryFlat(h.countryCode).filter(e=>w.includes(e)),[N,R]=n(!1),[V,H]=n(!1),[q,T]=n(""),_=!!h.onAddressLookup,[I,U]=n(!1),$=!h.onAddressLookup||(N||V),{data:z,errors:G,valid:J,isValid:K,handleChangeFor:Q,triggerValidation:W,setData:X,mergeData:Y}=m({schema:L,defaultData:h.data,rules:j({},c(B),h.validationRules),formatters:d}),Z=r(null===(C=h.data)||void 0===C?void 0:C.country),ee=null===(A=z.country||Z.current)||void 0===A?void 0:A.toUpperCase(),te=o(()=>F(j({},z),{country:ee}),[z,ee]),re=s(e=>{const t=y.reduce((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t},{});Y(t),U(!0),W(),R(!0)},[R,W,X]),oe=s(()=>{H(!0)},[]);M.current.showValidation=()=>{W(),T(!_||$||K?"":P.get("address.errors.incomplete"))};const ne=L.filter(e=>!x||e===x);if(a(()=>{if(I)return void U(!1);const e=B.countryHasDataset(z.country)?"":b,t=F(j({},z),{stateOrProvince:e});w.forEach(e=>{var r;Q(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")}),t.postalCode&&Q("postalCode","blur")(z.postalCode)},[z.country]),a(()=>{const e=w.includes("stateOrProvince"),t=z.country&&B.countryHasDataset(z.country),r=e&&t,o=z.stateOrProvince||(r?"":b);Q("stateOrProvince","input")(o)},[]),a(()=>{const e=B.getOptionalFieldsForCountry(z.country),t=y.reduce((t,r)=>{const o=e.includes(r),n=w.includes(r),s=z[r],a=h.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t},{});!t.country&&Z.current&&(t.country=Z.current),h.onChange({data:t,valid:J,errors:G,isValid:K})},[z,J,G,K]),"hidden"===k)return null;if("readOnly"===k)return e(l,{data:z,label:S});const se=(t,{classNameModifiers:r=[]})=>w.includes(t)?e(p,{key:t,allowedCountries:h.allowedCountries,classNameModifiers:[...r,t],data:te,errors:G,valid:J,fieldName:t,onInput:Q(t,"input"),onBlur:Q(t,"blur"),onDropdownChange:Q(t,"blur"),specifications:B,maxLength:v(u,t,ee),trimOnBlur:!0,disabled:!ne.includes(t),onFieldFocusAnalytics:h.onFieldFocusAnalytics,onFieldBlurAnalytics:h.onFieldBlurAnalytics}):null,ae=B.getAddressSchemaForCountry(z.country);return e(t,null,e(i,{classNameModifiers:[S,"address"],label:S,renderLabelAsSectionHeading:!0},_&&e(g,{onAddressLookup:h.onAddressLookup,onAddressSelected:h.onAddressSelected,onSelect:re,onManualAddress:oe,externalErrorMessage:q,hideManualButton:$,showContextualElement:D,contextualText:P.get("address.search.contextualText"),addressSearchDebounceMs:h.addressSearchDebounceMs}),$&&e(t,null,ae.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>se(e,{classNameModifiers:[`col-${t}`]}))):se(t,{})))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useRef as r,useMemo as o,useState as n,useCallback as s,useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import i from"../FormFields/Fieldset/Fieldset.js";import l from"./components/ReadOnlyAddress.js";import{getAddressValidationRules as c}from"./validate.js";import{addressFormatters as u,countrySpecificFormatters as d}from"./validate.formats.js";import p from"./components/FieldContainer.js";import m from"../../../utils/useForm/useForm.js";import"../SecuredFields/lib/CSF/utils/userAgent.js";import f from"./Specifications.js";import{ADDRESS_SCHEMA as y,FALLBACK_VALUE as b}from"./constants.js";import{getMaxLengthByFieldAndCountry as v}from"../../../utils/validator-utils.js";import{useCoreContext as O}from"../../../core/Context/CoreProvider.js";import g from"./components/AddressSearch.js";function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function F(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){j(e,t,r[t])})}return e}function h(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t}(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function C(j){var C,A;const{i18n:S}=O(),{label:P="",requiredFields:w,visibility:k,iOSFocusedField:x=null,showContextualElement:D}=j,M=r({});var E;Object.keys(M.current).length||(null===(E=j.setComponentRef)||void 0===E||E.call(j,M.current));const B=o(()=>new f(j.specifications),[j.specifications]),L=B.getAddressSchemaForCountryFlat(j.countryCode).filter(e=>w.includes(e)),[N,R]=n(!1),[V,H]=n(!1),[q,T]=n(""),_=!!j.onAddressLookup,[I,U]=n(!1),$=!j.onAddressLookup||(N||V),{data:z,errors:G,valid:J,isValid:K,handleChangeFor:Q,triggerValidation:W,setData:X,mergeData:Y}=m({schema:L,defaultData:j.data,rules:F({},c(B),j.validationRules),formatters:u}),Z=r(null===(C=j.data)||void 0===C?void 0:C.country),ee=null===(A=z.country||Z.current)||void 0===A?void 0:A.toUpperCase(),te=o(()=>h(F({},z),{country:ee}),[z,ee]),re=s(e=>{const t=y.reduce((t,r)=>{const o=e[r];return null!=o&&(t[r]=String(o)),t},{});Y(t),U(!0),W(),R(!0)},[R,W,X]),oe=s(()=>{H(!0)},[]);M.current.showValidation=()=>{W(),T(!_||$||K?"":S.get("address.errors.incomplete"))};const ne=L.filter(e=>!x||e===x);if(a(()=>{if(I)return void U(!1);const e=B.countryHasDataset(z.country)?"":b,t=h(F({},z),{stateOrProvince:e});w.forEach(e=>{var r;Q(e,"input")(null!==(r=t[e])&&void 0!==r?r:"")}),t.postalCode&&Q("postalCode","blur")(z.postalCode)},[z.country]),a(()=>{const e=w.includes("stateOrProvince"),t=z.country&&B.countryHasDataset(z.country),r=e&&t,o=z.stateOrProvince||(r?"":b);Q("stateOrProvince","input")(o)},[]),a(()=>{const e=B.getOptionalFieldsForCountry(z.country),t=y.reduce((t,r)=>{const o=e.includes(r),n=w.includes(r),s=z[r],a=j.data[r],i=o&&!s||!n?n||s||!a?b:a:s;return(null==i?void 0:i.length)&&(t[r]=i),t},{});!t.country&&Z.current&&(t.country=Z.current),j.onChange({data:t,valid:J,errors:G,isValid:K})},[z,J,G,K]),"hidden"===k)return null;if("readOnly"===k)return e(l,{data:z,label:P});const se=(t,{classNameModifiers:r=[]})=>w.includes(t)?e(p,{key:t,allowedCountries:j.allowedCountries,classNameModifiers:[...r,t],data:te,errors:G,valid:J,fieldName:t,onInput:Q(t,"input"),onBlur:Q(t,"blur"),onDropdownChange:Q(t,"blur"),specifications:B,maxLength:v(d,t,ee),trimOnBlur:!0,disabled:!ne.includes(t),onFieldFocusAnalytics:j.onFieldFocusAnalytics,onFieldBlurAnalytics:j.onFieldBlurAnalytics}):null,ae=B.getAddressSchemaForCountry(z.country);return e(t,null,e(i,{classNameModifiers:[P,"address"],label:P,renderLabelAsSectionHeading:!0},_&&e(g,{onAddressLookup:j.onAddressLookup,onAddressSelected:j.onAddressSelected,onSelect:re,onManualAddress:oe,externalErrorMessage:q,hideManualButton:$,showContextualElement:D,contextualText:S.get("address.search.contextualText"),addressSearchDebounceMs:j.addressSearchDebounceMs}),$&&e(t,null,ae.map(t=>t instanceof Array?e("div",{className:"adyen-checkout__field-group"},t.map(([e,t])=>se(e,{classNameModifiers:[`col-${t}`]}))):se(t,{})))))}C.defaultProps={countryCode:null,validationRules:null,data:{},onChange:()=>{},visibility:"editable",requiredFields:y,specifications:{},onFieldFocusAnalytics:()=>{},onFieldBlurAnalytics:()=>{}};export{C as default};
2
2
  //# sourceMappingURL=Address.js.map
@@ -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';\nimport './Address.scss';\n\nexport default function Address(props: Readonly<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 // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\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 // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\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={dataWithCountry}\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, effectiveCountry, 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} renderLabelAsSectionHeading>\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","data","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","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","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","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"goDAkBe,SAASA,EAAQC,OAsC0BA,EAC5BC,EAtC1B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BR,EAG5FS,EAAaC,EAA4B,IAG3CV,IAAAA,EADCW,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBd,EAAAA,EAAMe,2BAANf,GAAAA,EAAAA,KAAAA,EAAwBS,EAAWI,UAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAelB,EAAMgB,gBAAiB,CAAChB,EAAMgB,iBAEhFG,EAAuBH,EAAeI,+BAA+BpB,EAAMqB,aAAaC,OAAOC,GAASlB,EAAemB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBhC,EAAMiC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBpC,EAAMiC,kBAAkBR,GAAsBG,IAElE3B,KAAEA,EAAIoC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA,GAAcC,EAAqB,CAClHC,OAAQ1B,EACR2B,YAAa9C,EAAMC,KAEnB8C,MAAOC,EAAA,GAA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/EsD,YAAY,EACZC,UAAWrC,GAAclD,SAAS0D,GAClC8B,sBAAuBhH,EAAMgH,sBAC7BC,qBAAsBjH,EAAMiH,uBAnBY,KA8B9CC,GAAgBlG,EAAemG,2BAA2BlH,EAAKsD,SAErE,OACI0C,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAAChG,EAAO,WAAYA,MAAOA,EAAOkH,6BAAAA,GAC3DtF,GACGiE,EAACsB,EAAAA,CACGtF,gBAAiBjC,EAAMiC,gBACvBuF,kBAAmBxH,EAAMwH,kBACzBC,SAAU5D,GACVU,gBAAiBA,GACjBmD,qBAAsB5F,EACtB6F,iBAAkBvF,EAClB5B,sBAAuBA,EACvBoH,eAAgB1H,EAAKuE,IAAI,iCACzBoD,wBAAyB7H,EAAM6H,0BAGtCzF,GACG6D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIvG,GAAUA,aAAiBwG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwE1G,EAvB5EuG,IAAI,EAAEvG,EAAO2G,KAAU/B,GAAa5E,EAAO,CAAE6E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa5E,EAAO,CAAA,MAK5H,CAEAxB,EAAQoI,aAAe,CACnB9G,YAAa,KACb6B,gBAAiB,KACjBjD,KAAM,CAAA,EACN+F,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChBjD,eAAgB,CAAA,EAChBgG,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';\nimport './Address.scss';\n\nexport default function Address(props: Readonly<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 // In partial address mode, country is not in the form schema but we need it for regionalized labels.\n // Store the merchant's country config once at mount, then use it if form data doesn't have country.\n const initialCountryRef = useRef<string | undefined>((props.data as AddressData)?.country);\n const effectiveCountry = (data.country || initialCountryRef.current)?.toUpperCase();\n const dataWithCountry = useMemo(() => ({ ...data, country: effectiveCountry }), [data, effectiveCountry]);\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 // In partial address mode, ensure country is included in output for regionalized labels/validation.\n if (!(processedData as AddressData).country && initialCountryRef.current) {\n (processedData as AddressData).country = initialCountryRef.current;\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={dataWithCountry}\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, effectiveCountry, 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} renderLabelAsSectionHeading>\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","data","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","errors","valid","isValid","handleChangeFor","triggerValidation","setData","mergeData","useForm","schema","defaultData","rules","_object_spread","getAddressValidationRules","validationRules","formatters","addressFormatters","initialCountryRef","_props_data","country","effectiveCountry","_this","toUpperCase","dataWithCountry","_object_spread_props","setSearchData","useCallback","selectedAddress","newStateData","ADDRESS_SCHEMA","reduce","acc","propKey","providedValue","String","onManualAddress","showValidation","get","enabledFields","item","useEffect","stateOrProvince","countryHasDataset","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","renderLabelAsSectionHeading","AddressSearch","onAddressSelected","onSelect","externalErrorMessage","hideManualButton","contextualText","addressSearchDebounceMs","map","Array","div","className","size","defaultProps"],"mappings":"orDAkBe,SAASA,EAAQC,OAsC0BA,EAC5BC,EAtC1B,MAAMC,KAAEA,GAASC,KAEXC,MAAEA,EAAQ,GAAEC,eAAEA,EAAcC,WAAEA,EAAUC,gBAAEA,EAAkB,KAAIC,sBAAEA,GAA0BR,EAG5FS,EAAaC,EAA4B,IAG3CV,IAAAA,EADCW,OAAOC,KAAKH,EAAWI,SAASC,SACZ,QAArBd,EAAAA,EAAMe,2BAANf,GAAAA,EAAAA,KAAAA,EAAwBS,EAAWI,UAGvC,MAAMG,EAAiBC,EAAQ,IAAM,IAAIC,EAAelB,EAAMgB,gBAAiB,CAAChB,EAAMgB,iBAEhFG,EAAuBH,EAAeI,+BAA+BpB,EAAMqB,aAAaC,OAAOC,GAASlB,EAAemB,SAASD,KAE/HE,EAAoBC,GAAyBC,GAAS,IAEtDC,EAAkBC,GAAuBF,GAAS,IAElDG,EAAoBC,GAAyBJ,EAAS,IAEvDK,IAAsBhC,EAAMiC,iBAE3BC,EAAqBC,GAA0BR,GAAS,GAEzDS,GAAoBpC,EAAMiC,kBAAkBR,GAAsBG,IAElE3B,KAAEA,EAAIoC,OAAEA,EAAMC,MAAEA,EAAKC,QAAEA,EAAOC,gBAAEA,EAAeC,kBAAEA,EAAiBC,QAAEA,EAAOC,UAAEA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E,EAAgB0C,EAAW,QAC7ClE,eAAgBA,EAChB2F,UAAWC,EAA8BC,EAA2B3B,EAAW1B,IAC/EsD,YAAY,EACZC,UAAWrC,GAAclD,SAAS0D,GAClC8B,sBAAuBhH,EAAMgH,sBAC7BC,qBAAsBjH,EAAMiH,uBAnBY,KA8B9CC,GAAgBlG,EAAemG,2BAA2BlH,EAAKsD,SAErE,OACI0C,EAACmB,OACGnB,EAACoB,EAAAA,CAASjB,mBAAoB,CAAChG,EAAO,WAAYA,MAAOA,EAAOkH,6BAAAA,GAC3DtF,GACGiE,EAACsB,EAAAA,CACGtF,gBAAiBjC,EAAMiC,gBACvBuF,kBAAmBxH,EAAMwH,kBACzBC,SAAU5D,GACVU,gBAAiBA,GACjBmD,qBAAsB5F,EACtB6F,iBAAkBvF,EAClB5B,sBAAuBA,EACvBoH,eAAgB1H,EAAKuE,IAAI,iCACzBoD,wBAAyB7H,EAAM6H,0BAGtCzF,GACG6D,EAACmB,EAAAA,KAAUF,GAAcY,IAAIvG,GAAUA,aAAiBwG,MAxBpE9B,EAAC+B,MAAAA,CAAIC,UAAU,+BAwBwE1G,EAvB5EuG,IAAI,EAAEvG,EAAO2G,KAAU/B,GAAa5E,EAAO,CAAE6E,mBAAoB,CAAC,OAAO8B,SAuBY/B,GAAa5E,EAAO,CAAA,MAK5H,CAEAxB,EAAQoI,aAAe,CACnB9G,YAAa,KACb6B,gBAAiB,KACjBjD,KAAM,CAAA,EACN+F,SAAU,OACV1F,WAAY,WACZD,eAAgB4D,EAChBjD,eAAgB,CAAA,EAChBgG,sBAAuB,OACvBC,qBAAsB"}
@@ -1,2 +1,2 @@
1
- import t from"../../../_virtual/index.js";import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{usePaymentStatusTimer as n}from"../../../hooks/usePaymentStatusTimer/usePaymentStatusTimer.js";import{DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS as i,DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS as r,DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS as s,DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN as c}from"../../../hooks/usePaymentStatusTimer/constants.js";import l from"../Spinner/Spinner.js";import m from"../Button/Button.js";import d from"../ContentSeparator/ContentSeparator.js";import u from"../Countdown/index.js";import{AwaitFinalState as _}from"./components/AwaitFinalState.js";import{redirectToApp as p}from"../../../utils/urls.js";import{useAmount as y}from"../../../core/Context/AmountProvider.js";function h(i){var r;const{i18n:s,loadingContext:c}=o(),{state:h,actions:w}=n({loadingContext:c,paymentData:i.paymentData,clientKey:i.clientKey,delay:i.delay,throttleTime:i.throttleTime,throttleInterval:i.throttleInterval,type:i.type,onError:i.onError,onComplete:i.onComplete,pollStatus:i.pollStatus,onActionHandled:i.onActionHandled}),{completed:g,expired:k,loading:v,percentage:f}=h,{onTick:N,onTimeUp:C}=w,{amount:T}=y();if(a(()=>{i.shouldRedirectAutomatically&&i.url&&p(i.url)},[i.shouldRedirectAutomatically,i.url]),k)return e(_,{image:"error",message:s.get("error.subtitle.payment")});if(g)return e(_,{image:"success",message:s.get("creditCard.success")});if(v)return e("div",{className:"adyen-checkout__await"},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),e(l,{inline:!1,size:"large"}));const x=s.get("wechatpay.timetopay").split("%@");return e("div",{className:t("adyen-checkout__await",`adyen-checkout__await--${i.type}`,i.classNameModifiers.map(t=>`adyen-checkout__await--${t}`))},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),!(!i.showAmount||null===(null==T?void 0:T.value)||!(null==T?void 0:T.currency))&&e("div",{className:"adyen-checkout__await__amount"},s.amount(T.value,T.currency)),null!=i.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},i.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(l,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},i.awaitText)),i.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${f}%`}})),e("div",{className:"adyen-checkout__await__countdown"},x[0]," ",e(u,{minutesFromNow:i.countdownTime,onTick:N,onCompleted:C})," ",x[1])),i.url&&!i.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(m,{classNameModifiers:["await"],onClick:()=>p(i.url),label:s.get("openApp")})),i.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof i.instructions?s.get(i.instructions):null===(r=i.instructions)||void 0===r?void 0:r.call(i)),i.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},i.endSlot()))}h.defaultProps={countdownTime:c,delay:s,throttleTime:r,throttleInterval:i,onError:()=>{},onComplete:()=>{},showCountdownTimer:!0,classNameModifiers:[],url:null};export{h as Await};
1
+ import t from"../../../_virtual/index.js";import{createElement as e}from"../../../external/preact/dist/preact.js";import{useEffect as a}from"../../../external/preact/hooks/dist/hooks.js";import{useCoreContext as o}from"../../../core/Context/CoreProvider.js";import{usePaymentStatusTimer as n}from"../../../hooks/usePaymentStatusTimer/usePaymentStatusTimer.js";import{DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS as i,DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS as r,DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS as s,DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN as c}from"../../../hooks/usePaymentStatusTimer/constants.js";import l from"../Spinner/Spinner.js";import m from"../Button/Button.js";import d from"../ContentSeparator/ContentSeparator.js";import u from"../Countdown/index.js";import{AwaitFinalState as _}from"./components/AwaitFinalState.js";import{redirectToApp as p}from"../../../utils/urls.js";import{useAmount as y}from"../../../core/Context/AmountProvider.js";import{useA11yReporter as h}from"../../../core/Errors/useA11yReporter.js";function w(i){var r;const{i18n:s,loadingContext:c}=o();h(i.awaitText);const{state:w,actions:g}=n({loadingContext:c,paymentData:i.paymentData,clientKey:i.clientKey,delay:i.delay,throttleTime:i.throttleTime,throttleInterval:i.throttleInterval,type:i.type,onError:i.onError,onComplete:i.onComplete,pollStatus:i.pollStatus,onActionHandled:i.onActionHandled}),{completed:k,expired:v,loading:f,percentage:N}=w,{onTick:T,onTimeUp:C}=g,{amount:x}=y();if(a(()=>{i.shouldRedirectAutomatically&&i.url&&p(i.url)},[i.shouldRedirectAutomatically,i.url]),v)return e(_,{image:"error",message:s.get("error.subtitle.payment")});if(k)return e(_,{image:"success",message:s.get("creditCard.success")});if(f)return e("div",{className:"adyen-checkout__await"},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),e(l,{inline:!1,size:"large"}));const j=s.get("wechatpay.timetopay").split("%@");return e("div",{className:t("adyen-checkout__await",`adyen-checkout__await--${i.type}`,i.classNameModifiers.map(t=>`adyen-checkout__await--${t}`))},i.brandLogo&&e("img",{src:i.brandLogo,alt:i.type,className:"adyen-checkout__await__brand-logo"}),!(!i.showAmount||null===(null==x?void 0:x.value)||!(null==x?void 0:x.currency))&&e("div",{className:"adyen-checkout__await__amount"},s.amount(x.value,x.currency)),null!=i.messageText&&e("div",{className:"adyen-checkout__await__subtitle"},i.messageText),e("div",{className:"adyen-checkout__await__indicator-holder"},e("div",{className:"adyen-checkout__await__indicator-spinner"},e(l,{inline:!1,size:"medium"})),e("div",{className:"adyen-checkout__await__indicator-text"},i.awaitText)),i.showCountdownTimer&&e("div",{className:"adyen-checkout__await__countdown-holder"},e("div",{className:"adyen-checkout__await__progress"},e("span",{className:"adyen-checkout__await__percentage",style:{width:`${N}%`}})),e("div",{className:"adyen-checkout__await__countdown"},j[0]," ",e(u,{minutesFromNow:i.countdownTime,onTick:T,onCompleted:C})," ",j[1])),i.url&&!i.shouldRedirectAutomatically&&e("div",{className:"adyen-checkout__await__app-link"},e(d,null),e(m,{classNameModifiers:["await"],onClick:()=>p(i.url),label:s.get("openApp")})),i.instructions&&e("div",{className:"adyen-checkout__await__instructions"},"string"==typeof i.instructions?s.get(i.instructions):null===(r=i.instructions)||void 0===r?void 0:r.call(i)),i.endSlot&&e("div",{className:"adyen-checkout__await__end-slot"},i.endSlot()))}w.defaultProps={countdownTime:c,delay:s,throttleTime:r,throttleInterval:i,onError:()=>{},onComplete:()=>{},showCountdownTimer:!0,classNameModifiers:[],url:null};export{w as Await};
2
2
  //# sourceMappingURL=Await.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\nimport { useAmount } from '../../../core/Context/AmountProvider';\n\nexport function Await(props: Readonly<AwaitComponentProps>) {\n const { i18n, loadingContext } = useCoreContext();\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n const { amount } = useAmount();\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n if (expired) {\n return <AwaitFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <AwaitFinalState image=\"success\" message={i18n.get('creditCard.success')} />;\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n delay: DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n throttleTime: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS,\n throttleInterval: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n onError: () => {},\n onComplete: () => {},\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","state","timerState","actions","timerActions","usePaymentStatusTimer","paymentData","clientKey","delay","throttleTime","throttleInterval","type","onError","onComplete","pollStatus","onActionHandled","completed","expired","loading","percentage","onTick","onTimeUp","amount","useAmount","useEffect","shouldRedirectAutomatically","url","redirectToApp","h","AwaitFinalState","image","message","get","div","className","brandLogo","img","src","alt","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","awaitText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps","DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN","DEFAULT_PAYMENT_STATUS_TIMER_DELAY_M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A,EAAAA,EAAAA,KAAAA,IAIhFA,EAAMqE,SAAWtC,EAACK,MAAAA,CAAIC,UAAU,mCAAmCrC,EAAMqE,WAGtF,CAEAtE,EAAMuE,aAAe,CACjBR,cAAeS,EACf5D,MAAO6D,EACP5D,aAAc6D,EACd5D,iBAAkB6D,EAClB3D,QAAS,OACTC,WAAY,OACZwC,oBAAoB,EACpBR,mBAAoB,GACpBnB,IAAK"}
1
+ {"version":3,"file":"Await.js","sources":["../../../../../src/components/internal/Await/Await.tsx"],"sourcesContent":["import classnames from 'classnames';\nimport { h } from 'preact';\nimport { useEffect } from 'preact/hooks';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport {\n usePaymentStatusTimer,\n DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS\n} from '../../../hooks/usePaymentStatusTimer';\nimport Spinner from '../../internal/Spinner';\nimport Button from '../Button';\nimport ContentSeparator from '../ContentSeparator';\nimport Countdown from '../Countdown';\nimport { AwaitFinalState } from './components/AwaitFinalState';\nimport { AwaitComponentProps } from './types';\nimport { redirectToApp } from '../../../utils/urls';\nimport './Await.scss';\nimport { useAmount } from '../../../core/Context/AmountProvider';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\n\nexport function Await(props: Readonly<AwaitComponentProps>) {\n const { i18n, loadingContext } = useCoreContext();\n useA11yReporter(props.awaitText);\n\n const { state: timerState, actions: timerActions } = usePaymentStatusTimer({\n loadingContext,\n paymentData: props.paymentData,\n clientKey: props.clientKey,\n delay: props.delay,\n throttleTime: props.throttleTime,\n throttleInterval: props.throttleInterval,\n type: props.type,\n onError: props.onError,\n onComplete: props.onComplete,\n pollStatus: props.pollStatus,\n onActionHandled: props.onActionHandled\n });\n\n const { completed, expired, loading, percentage } = timerState;\n const { onTick, onTimeUp } = timerActions;\n const { amount } = useAmount();\n\n useEffect(() => {\n if (props.shouldRedirectAutomatically && props.url) {\n redirectToApp(props.url);\n }\n }, [props.shouldRedirectAutomatically, props.url]);\n\n if (expired) {\n return <AwaitFinalState image=\"error\" message={i18n.get('error.subtitle.payment')} />;\n }\n\n if (completed) {\n return <AwaitFinalState image=\"success\" message={i18n.get('creditCard.success')} />;\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__await\">\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n <Spinner inline={false} size=\"large\" />\n </div>\n );\n }\n\n const timeToPayString = i18n.get('wechatpay.timetopay').split('%@');\n\n return (\n <div\n className={classnames(\n 'adyen-checkout__await',\n `adyen-checkout__await--${props.type}`,\n props.classNameModifiers.map(m => `adyen-checkout__await--${m}`)\n )}\n >\n {props.brandLogo && <img src={props.brandLogo} alt={props.type} className=\"adyen-checkout__await__brand-logo\" />}\n\n {/* Everything is wrapped in !! so we evaluate the result as boolean,\n otherwise we might just print the value or object as mistake */}\n {!!(props.showAmount && amount?.value !== null && amount?.currency) && (\n <div className=\"adyen-checkout__await__amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {props.messageText != null && <div className=\"adyen-checkout__await__subtitle\">{props.messageText}</div>}\n\n <div className=\"adyen-checkout__await__indicator-holder\">\n <div className=\"adyen-checkout__await__indicator-spinner\">\n <Spinner inline={false} size=\"medium\" />\n </div>\n <div className=\"adyen-checkout__await__indicator-text\">{props.awaitText}</div>\n </div>\n\n {props.showCountdownTimer && (\n <div className=\"adyen-checkout__await__countdown-holder\">\n <div className=\"adyen-checkout__await__progress\">\n <span className=\"adyen-checkout__await__percentage\" style={{ width: `${percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__await__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={props.countdownTime} onTick={onTick} onCompleted={onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n </div>\n )}\n\n {props.url && !props.shouldRedirectAutomatically && (\n <div className=\"adyen-checkout__await__app-link\">\n <ContentSeparator />\n <Button classNameModifiers={['await']} onClick={() => redirectToApp(props.url)} label={i18n.get('openApp')} />\n </div>\n )}\n\n {props.instructions && (\n <div className=\"adyen-checkout__await__instructions\">\n {typeof props.instructions === 'string' ? i18n.get(props.instructions) : props.instructions?.()}\n </div>\n )}\n\n {props.endSlot && <div className=\"adyen-checkout__await__end-slot\">{props.endSlot()}</div>}\n </div>\n );\n}\n\nAwait.defaultProps = {\n countdownTime: DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN,\n delay: DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS,\n throttleTime: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS,\n throttleInterval: DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS,\n onError: () => {},\n onComplete: () => {},\n showCountdownTimer: true,\n classNameModifiers: [],\n url: null\n};\n"],"names":["Await","props","i18n","loadingContext","useCoreContext","useA11yReporter","awaitText","state","timerState","actions","timerActions","usePaymentStatusTimer","paymentData","clientKey","delay","throttleTime","throttleInterval","type","onError","onComplete","pollStatus","onActionHandled","completed","expired","loading","percentage","onTick","onTimeUp","amount","useAmount","useEffect","shouldRedirectAutomatically","url","redirectToApp","h","AwaitFinalState","image","message","get","div","className","brandLogo","img","src","alt","Spinner","inline","size","timeToPayString","split","classnames","classNameModifiers","map","m","showAmount","value","currency","messageText","showCountdownTimer","span","style","width","Countdown","minutesFromNow","countdownTime","onCompleted","ContentSeparator","Button","onClick","label","instructions","endSlot","defaultProps","DEFAULT_PAYMENT_STATUS_TIMER_COUNTDOWN_TIME_MIN","DEFAULT_PAYMENT_STATUS_TIMER_DELAY_MS","DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_TIME_MS","DEFAULT_PAYMENT_STATUS_TIMER_THROTTLE_INTERVAL_MS"],"mappings":"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AU,mCAAmCvC,EAAMsE,WAGtF,CAEAvE,EAAMwE,aAAe,CACjBR,cAAeS,EACf3D,MAAO4D,EACP3D,aAAc4D,EACd3D,iBAAkB4D,EAClB1D,QAAS,OACTC,WAAY,OACZuC,oBAAoB,EACpBP,mBAAoB,GACpBnB,IAAK"}
@@ -1,2 +1,2 @@
1
- import{createElement as a}from"../../../external/preact/dist/preact.js";import{useMemo as r}from"../../../external/preact/hooks/dist/hooks.js";import e from"../../../_virtual/index.js";import{BrandImage as s}from"../BrandImage/BrandImage.js";import n from"./BrandIcons.module.scss.js";const m=({brandIcons:m,maxBrandsToShow:o=m.length,remainingBrandsLabel:l,className:t,containerType:i="flex",remainingBrandsLabelClassName:c,brandImageClassName:d,brandImageWrapperClassName:g,showIconOnError:p,smallIcons:I,renderBrandIcon:B})=>{const h=r(()=>m.slice(0,o),[m,o]),N=r(()=>m.slice(o),[m,o]),b=Boolean(l)||N.length>0;return a("div",{className:e(n.container,{[n.grid]:"grid"===i,[n.smallImgGrid]:I&&"grid"===i},t)},h.map(r=>B?B(r):a(s,{key:r.alt,src:r.src,alt:r.alt,wrapperClassName:g,imgClassName:e(n.img,{[n.smallImg]:I},d),showOnError:p})),b&&a("span",{className:e(n.remainingBrandsLabel,c)},l||`+ ${N.length}`))};export{m as BrandIcons};
1
+ import{createElement as a}from"../../../external/preact/dist/preact.js";import{useMemo as r}from"../../../external/preact/hooks/dist/hooks.js";import e from"../../../_virtual/index.js";import{BrandImage as s}from"../BrandImage/BrandImage.js";import n from"./BrandIcons.module.scss.js";const m=({brandIcons:m,maxBrandsToShow:l=m.length,remainingBrandsLabel:o,className:i,containerType:t="flex",remainingBrandsLabelClassName:d,brandImageClassName:c,brandImageWrapperClassName:g,showIconOnError:p,smallIcons:I,renderBrandIcon:h,ariaHidden:B})=>{const N=r(()=>m.slice(0,l),[m,l]),b=r(()=>m.slice(l),[m,l]),f=Boolean(o)||b.length>0;return a("ul",{className:e(n.container,{[n.grid]:"grid"===t,[n.smallImgGrid]:I&&"grid"===t},i),"aria-hidden":B},N.map(r=>h?h(r):a(s,{as:"li",key:r.alt,src:r.src,alt:r.alt,wrapperClassName:g,imgClassName:e(n.img,{[n.smallImg]:I},c),showOnError:p})),f&&a("li",{className:e(n.remainingBrandsLabel,d)},o||`+ ${b.length}`))};export{m as BrandIcons};
2
2
  //# sourceMappingURL=BrandIcons.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrandIcons.js","sources":["../../../../../src/components/internal/BrandIcons/BrandIcons.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useMemo } from 'preact/hooks';\nimport cn from 'classnames';\n\nimport { BrandIcon } from './types';\nimport { BrandImage } from '../BrandImage';\n\nimport styles from './BrandIcons.module.scss';\n\nexport type BrandIconsProp = {\n brandIcons: BrandIcon[];\n suffix?: string;\n maxBrandsToShow?: number;\n remainingBrandsLabel?: string;\n className?: string;\n containerType?: 'flex' | 'grid';\n remainingBrandsLabelClassName?: string;\n brandImageWrapperClassName?: string;\n brandImageClassName?: string;\n showIconOnError?: boolean;\n smallIcons?: boolean;\n renderBrandIcon?: (brandIcon: BrandIcon) => h.JSX.Element;\n};\n\nexport const BrandIcons = ({\n brandIcons,\n maxBrandsToShow = brandIcons.length,\n remainingBrandsLabel,\n className,\n containerType = 'flex',\n remainingBrandsLabelClassName,\n brandImageClassName,\n brandImageWrapperClassName,\n showIconOnError,\n smallIcons,\n renderBrandIcon\n}: Readonly<BrandIconsProp>) => {\n const visibleBrands = useMemo(() => brandIcons.slice(0, maxBrandsToShow), [brandIcons, maxBrandsToShow]);\n const remainingBrands = useMemo(() => brandIcons.slice(maxBrandsToShow), [brandIcons, maxBrandsToShow]);\n\n const hasRemainingBrands = Boolean(remainingBrandsLabel) || remainingBrands.length > 0;\n\n return (\n <div\n className={cn(\n styles.container,\n { [styles.grid]: containerType === 'grid', [styles.smallImgGrid]: smallIcons && containerType === 'grid' },\n className\n )}\n >\n {visibleBrands.map(brandIcon =>\n renderBrandIcon ? (\n renderBrandIcon(brandIcon)\n ) : (\n <BrandImage\n key={brandIcon.alt}\n src={brandIcon.src}\n alt={brandIcon.alt}\n wrapperClassName={brandImageWrapperClassName}\n imgClassName={cn(styles.img, { [styles.smallImg]: smallIcons }, brandImageClassName)}\n showOnError={showIconOnError}\n />\n )\n )}\n {hasRemainingBrands && (\n <span className={cn(styles.remainingBrandsLabel, remainingBrandsLabelClassName)}>\n {remainingBrandsLabel || `+ ${remainingBrands.length}`}\n </span>\n )}\n </div>\n );\n};\n"],"names":["BrandIcons","brandIcons","maxBrandsToShow","length","remainingBrandsLabel","className","containerType","remainingBrandsLabelClassName","brandImageClassName","brandImageWrapperClassName","showIconOnError","smallIcons","renderBrandIcon","visibleBrands","useMemo","slice","remainingBrands","hasRemainingBrands","Boolean","h","div","cn","styles","container","grid","smallImgGrid","map","brandIcon","BrandImage","key","alt","src","wrapperClassName","imgClassName","img","smallImg","showOnError","span"],"mappings":"6RAwBO,MAAMA,EAAa,EACtBC,aACAC,kBAAkBD,EAAWE,OAC7BC,uBACAC,YACAC,gBAAgB,OAChBC,gCACAC,sBACAC,6BACAC,kBACAC,aACAC,sBAEA,MAAMC,EAAgBC,EAAQ,IAAMb,EAAWc,MAAM,EAAGb,GAAkB,CAACD,EAAYC,IACjFc,EAAkBF,EAAQ,IAAMb,EAAWc,MAAMb,GAAkB,CAACD,EAAYC,IAEhFe,EAAqBC,QAAQd,IAAyBY,EAAgBb,OAAS,EAErF,OACIgB,EAACC,MAAAA,CACGf,UAAWgB,EACPC,EAAOC,UACP,CAAE,CAACD,EAAOE,MAAyB,SAAlBlB,EAA0B,CAACgB,EAAOG,cAAed,GAAgC,SAAlBL,GAChFD,IAGHQ,EAAca,IAAIC,GACff,EACIA,EAAgBe,GAEhBR,EAACS,EAAAA,CACGC,IAAKF,EAAUG,IACfC,IAAKJ,EAAUI,IACfD,IAAKH,EAAUG,IACfE,iBAAkBvB,EAClBwB,aAAcZ,EAAGC,EAAOY,IAAK,CAAE,CAACZ,EAAOa,UAAWxB,GAAcH,GAChE4B,YAAa1B,KAIxBO,GACGE,EAACkB,OAAAA,CAAKhC,UAAWgB,EAAGC,EAAOlB,qBAAsBG,IAC5CH,GAAwB,KAAKY,EAAgBb"}
1
+ {"version":3,"file":"BrandIcons.js","sources":["../../../../../src/components/internal/BrandIcons/BrandIcons.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useMemo } from 'preact/hooks';\nimport cn from 'classnames';\n\nimport { BrandIcon } from './types';\nimport { BrandImage } from '../BrandImage';\n\nimport styles from './BrandIcons.module.scss';\n\nexport type BrandIconsProp = {\n brandIcons: BrandIcon[];\n suffix?: string;\n maxBrandsToShow?: number;\n remainingBrandsLabel?: string;\n className?: string;\n containerType?: 'flex' | 'grid';\n remainingBrandsLabelClassName?: string;\n brandImageWrapperClassName?: string;\n brandImageClassName?: string;\n showIconOnError?: boolean;\n smallIcons?: boolean;\n ariaHidden?: boolean;\n renderBrandIcon?: (brandIcon: BrandIcon) => h.JSX.Element;\n};\n\nexport const BrandIcons = ({\n brandIcons,\n maxBrandsToShow = brandIcons.length,\n remainingBrandsLabel,\n className,\n containerType = 'flex',\n remainingBrandsLabelClassName,\n brandImageClassName,\n brandImageWrapperClassName,\n showIconOnError,\n smallIcons,\n renderBrandIcon,\n ariaHidden\n}: Readonly<BrandIconsProp>) => {\n const visibleBrands = useMemo(() => brandIcons.slice(0, maxBrandsToShow), [brandIcons, maxBrandsToShow]);\n const remainingBrands = useMemo(() => brandIcons.slice(maxBrandsToShow), [brandIcons, maxBrandsToShow]);\n\n const hasRemainingBrands = Boolean(remainingBrandsLabel) || remainingBrands.length > 0;\n\n return (\n <ul\n className={cn(\n styles.container,\n { [styles.grid]: containerType === 'grid', [styles.smallImgGrid]: smallIcons && containerType === 'grid' },\n className\n )}\n aria-hidden={ariaHidden}\n >\n {visibleBrands.map(brandIcon =>\n renderBrandIcon ? (\n renderBrandIcon(brandIcon)\n ) : (\n <BrandImage\n as=\"li\"\n key={brandIcon.alt}\n src={brandIcon.src}\n alt={brandIcon.alt}\n wrapperClassName={brandImageWrapperClassName}\n imgClassName={cn(styles.img, { [styles.smallImg]: smallIcons }, brandImageClassName)}\n showOnError={showIconOnError}\n />\n )\n )}\n {hasRemainingBrands && (\n <li className={cn(styles.remainingBrandsLabel, remainingBrandsLabelClassName)}>\n {remainingBrandsLabel || `+ ${remainingBrands.length}`}\n </li>\n )}\n </ul>\n );\n};\n"],"names":["BrandIcons","brandIcons","maxBrandsToShow","length","remainingBrandsLabel","className","containerType","remainingBrandsLabelClassName","brandImageClassName","brandImageWrapperClassName","showIconOnError","smallIcons","renderBrandIcon","ariaHidden","visibleBrands","useMemo","slice","remainingBrands","hasRemainingBrands","Boolean","h","ul","cn","styles","container","grid","smallImgGrid","aria-hidden","map","brandIcon","BrandImage","as","key","alt","src","wrapperClassName","imgClassName","img","smallImg","showOnError","li"],"mappings":"6RAyBO,MAAMA,EAAa,EACtBC,aACAC,kBAAkBD,EAAWE,OAC7BC,uBACAC,YACAC,gBAAgB,OAChBC,gCACAC,sBACAC,6BACAC,kBACAC,aACAC,kBACAC,iBAEA,MAAMC,EAAgBC,EAAQ,IAAMd,EAAWe,MAAM,EAAGd,GAAkB,CAACD,EAAYC,IACjFe,EAAkBF,EAAQ,IAAMd,EAAWe,MAAMd,GAAkB,CAACD,EAAYC,IAEhFgB,EAAqBC,QAAQf,IAAyBa,EAAgBd,OAAS,EAErF,OACIiB,EAACC,KAAAA,CACGhB,UAAWiB,EACPC,EAAOC,UACP,CAAE,CAACD,EAAOE,MAAyB,SAAlBnB,EAA0B,CAACiB,EAAOG,cAAef,GAAgC,SAAlBL,GAChFD,GAEJsB,cAAad,GAEZC,EAAcc,IAAIC,GACfjB,EACIA,EAAgBiB,GAEhBT,EAACU,EAAAA,CACGC,GAAG,KACHC,IAAKH,EAAUI,IACfC,IAAKL,EAAUK,IACfD,IAAKJ,EAAUI,IACfE,iBAAkB1B,EAClB2B,aAAcd,EAAGC,EAAOc,IAAK,CAAE,CAACd,EAAOe,UAAW3B,GAAcH,GAChE+B,YAAa7B,KAIxBQ,GACGE,EAACoB,KAAAA,CAAGnC,UAAWiB,EAAGC,EAAOnB,qBAAsBG,IAC1CH,GAAwB,KAAKa,EAAgBd"}
@@ -1,2 +1,2 @@
1
- import{createElement as r}from"../../../external/preact/dist/preact.js";import{useState as a}from"../../../external/preact/hooks/dist/hooks.js";import e from"../../../_virtual/index.js";import t from"../Img/Img.js";const s=({src:s,alt:o,wrapperClassName:m="",imgClassName:p="",showOnError:n})=>{const[c,i]=a(!1),d=e("adyen-checkout-brand-wrapper",m,n?{}:{"adyen-checkout-brand-wrapper--error":c});return r("span",{className:d,"data-testid":"brand-image-wrapper"},r(t,{className:p,src:s,alt:o,onError:()=>i(!0)}))};export{s as BrandImage};
1
+ import{createElement as r}from"../../../external/preact/dist/preact.js";import{useState as a}from"../../../external/preact/hooks/dist/hooks.js";import e from"../../../_virtual/index.js";import s from"../Img/Img.js";const t=({src:t,alt:o,wrapperClassName:m="",imgClassName:p="",showOnError:n,as:c})=>{const[l,i]=a(!1),d=e("adyen-checkout-brand-wrapper",m,n?{}:{"adyen-checkout-brand-wrapper--error":l});return r(null!=c?c:"span",{className:d,"data-testid":"brand-image-wrapper"},r(s,{className:p,src:t,alt:o,onError:()=>i(!0)}))};export{t as BrandImage};
2
2
  //# sourceMappingURL=BrandImage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BrandImage.js","sources":["../../../../../src/components/internal/BrandImage/BrandImage.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport Img from '../Img';\nimport './BrandImage.scss';\n\ninterface BrandImageProps {\n src: string;\n alt: string;\n wrapperClassName?: string;\n imgClassName?: string;\n showOnError?: boolean;\n}\n\nexport const BrandImage = ({ src, alt, wrapperClassName = '', imgClassName = '', showOnError }: Readonly<BrandImageProps>) => {\n const [hasError, setHasError] = useState(false);\n const classesOnError = showOnError ? {} : { 'adyen-checkout-brand-wrapper--error': hasError };\n const classes = cx('adyen-checkout-brand-wrapper', wrapperClassName, classesOnError);\n\n return (\n <span className={classes} data-testid=\"brand-image-wrapper\">\n <Img className={imgClassName} src={src} alt={alt} onError={() => setHasError(true)} />\n </span>\n );\n};\n"],"names":["BrandImage","src","alt","wrapperClassName","imgClassName","showOnError","hasError","setHasError","useState","classes","cx","h","span","className","data-testid","Img","onError"],"mappings":"uNAcO,MAAMA,EAAa,EAAGC,MAAKC,MAAKC,mBAAmB,GAAIC,eAAe,GAAIC,kBAC7E,MAAOC,EAAUC,GAAeC,GAAS,GAEnCC,EAAUC,EAAG,+BAAgCP,EAD5BE,EAAc,GAAK,CAAE,sCAAuCC,IAGnF,OACIK,EAACC,OAAAA,CAAKC,UAAWJ,EAASK,cAAY,uBAClCH,EAACI,EAAAA,CAAIF,UAAWT,EAAcH,IAAKA,EAAKC,IAAKA,EAAKc,QAAS,IAAMT,GAAY"}
1
+ {"version":3,"file":"BrandImage.js","sources":["../../../../../src/components/internal/BrandImage/BrandImage.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState } from 'preact/hooks';\nimport cx from 'classnames';\nimport Img from '../Img';\nimport './BrandImage.scss';\nimport { ElementType } from 'preact/compat';\n\ninterface BrandImageProps {\n src: string;\n alt: string;\n wrapperClassName?: string;\n imgClassName?: string;\n showOnError?: boolean;\n as?: ElementType;\n}\n\nexport const BrandImage = ({ src, alt, wrapperClassName = '', imgClassName = '', showOnError, as }: Readonly<BrandImageProps>) => {\n const [hasError, setHasError] = useState(false);\n const classesOnError = showOnError ? {} : { 'adyen-checkout-brand-wrapper--error': hasError };\n const classes = cx('adyen-checkout-brand-wrapper', wrapperClassName, classesOnError);\n\n const Component = as ?? 'span';\n\n return (\n <Component className={classes} data-testid=\"brand-image-wrapper\">\n <Img className={imgClassName} src={src} alt={alt} onError={() => setHasError(true)} />\n </Component>\n );\n};\n"],"names":["BrandImage","src","alt","wrapperClassName","imgClassName","showOnError","as","hasError","setHasError","useState","classes","cx","h","Component","className","data-testid","Img","onError"],"mappings":"6NAgBaA,EAAa,EAAGC,MAAKC,MAAKC,mBAAmB,GAAIC,eAAe,GAAIC,cAAaC,SAC1F,MAAOC,EAAUC,GAAeC,GAAS,GAEnCC,EAAUC,EAAG,+BAAgCR,EAD5BE,EAAc,GAAK,CAAE,sCAAuCE,IAKnF,OACIK,EAHcN,QAAAA,EAAM,OAGnBO,CAAUC,UAAWJ,EAASK,cAAY,uBACvCH,EAACI,EAAAA,CAAIF,UAAWV,EAAcH,IAAKA,EAAKC,IAAKA,EAAKe,QAAS,IAAMT,GAAY"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useMemo as r,useEffect as a}from"../../../../../../external/preact/hooks/dist/hooks.js";import t from"../../../context/useClickToPayContext.js";import{useCoreContext as s}from"../../../../../../core/Context/CoreProvider.js";import i from"../../../../../../core/Context/useImage.js";import o from"../../../../../../utils/useForm/useForm.js";import d from"../../../../../../utils/isMobile.js";import c from"../../../../FormFields/Field/Field.js";import l from"../../../../FormFields/Select/Select.js";const m=["srcDigitalCardId"],n=({cardSelected:n,cards:p,errorMessage:C,onChangeCard:g})=>{const{i18n:u}=s(),f=i(),{status:x}=t(),{handleChangeFor:h,data:F}=o({schema:m,defaultData:{srcDigitalCardId:n.srcDigitalCardId}}),j=r(()=>p.map(e=>({icon:e.artUri||f()(e.scheme),name:`${d()?"":e.title} •••• ${e.panLastFour} `,secondaryText:e.isExpired&&u.get("ctp.cards.expiredCard"),id:e.srcDigitalCardId,disabled:e.isExpired})),[p]);return a(()=>{const{srcDigitalCardId:e}=F,r=p.find(r=>r.srcDigitalCardId===e);g(r)},[F,g]),e(c,{name:"clickToPayCards",className:"adyen-checkout-ctp__cards-list-field",errorMessage:C,readOnly:"loading"===x,label:u.get("ctp.cards.subtitle")},e(l,{items:j,selectedValue:F.srcDigitalCardId,name:"clickToPayCards",filterable:!1,className:"adyen-checkout-ctp__cards-list-dropdown",readonly:"loading"===x,onChange:h("srcDigitalCardId")}))};export{n as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useMemo as r,useEffect as a}from"../../../../../../external/preact/hooks/dist/hooks.js";import t from"../../../context/useClickToPayContext.js";import{useCoreContext as s}from"../../../../../../core/Context/CoreProvider.js";import i from"../../../../../../core/Context/useImage.js";import o from"../../../../../../utils/useForm/useForm.js";import"../../../../SecuredFields/lib/CSF/utils/userAgent.js";import d from"../../../../../../utils/isMobile.js";import c from"../../../../FormFields/Field/Field.js";import l from"../../../../FormFields/Select/Select.js";const m=["srcDigitalCardId"],n=({cardSelected:n,cards:p,errorMessage:C,onChangeCard:u})=>{const{i18n:g}=s(),f=i(),{status:F}=t(),{handleChangeFor:x,data:h}=o({schema:m,defaultData:{srcDigitalCardId:n.srcDigitalCardId}}),j=r(()=>p.map(e=>({icon:e.artUri||f()(e.scheme),name:`${d()?"":e.title} •••• ${e.panLastFour} `,secondaryText:e.isExpired&&g.get("ctp.cards.expiredCard"),id:e.srcDigitalCardId,disabled:e.isExpired})),[p]);return a(()=>{const{srcDigitalCardId:e}=h,r=p.find(r=>r.srcDigitalCardId===e);u(r)},[h,u]),e(c,{name:"clickToPayCards",className:"adyen-checkout-ctp__cards-list-field",errorMessage:C,readOnly:"loading"===F,label:g.get("ctp.cards.subtitle")},e(l,{items:j,selectedValue:h.srcDigitalCardId,name:"clickToPayCards",filterable:!1,className:"adyen-checkout-ctp__cards-list-dropdown",readonly:"loading"===F,onChange:x("srcDigitalCardId")}))};export{n as default};
2
2
  //# sourceMappingURL=CtPCardsList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPCardsList.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useMemo } from 'preact/hooks';\nimport ShopperCard from '../../../models/ShopperCard';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport useForm from '../../../../../../utils/useForm';\nimport isMobile from '../../../../../../utils/isMobile';\nimport Field from '../../../../FormFields/Field';\nimport './CtPCardsList.scss';\nimport Select from '../../../../FormFields/Select';\n\ntype CtPCardsListProps = {\n cards: ShopperCard[];\n cardSelected: ShopperCard;\n errorMessage?: string;\n onChangeCard(card: ShopperCard): void;\n};\n\ntype CardsSelectorDataState = {\n srcDigitalCardId: string;\n};\n\nconst schema = ['srcDigitalCardId'];\n\nconst CtPCardsList = ({ cardSelected, cards, errorMessage, onChangeCard }: Readonly<CtPCardsListProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { status } = useClickToPayContext();\n const { handleChangeFor, data } = useForm<CardsSelectorDataState>({\n schema,\n defaultData: { srcDigitalCardId: cardSelected.srcDigitalCardId }\n });\n\n const items = useMemo(() => {\n return cards.map(card => ({\n icon: card.artUri || getImage()(card.scheme),\n name: `${isMobile() ? '' : card.title} •••• ${card.panLastFour} `,\n secondaryText: card.isExpired && i18n.get('ctp.cards.expiredCard'),\n id: card.srcDigitalCardId,\n disabled: card.isExpired\n }));\n }, [cards]);\n\n useEffect(() => {\n const { srcDigitalCardId } = data;\n const card = cards.find(card => card.srcDigitalCardId === srcDigitalCardId);\n onChangeCard(card);\n }, [data, onChangeCard]);\n\n return (\n <Field\n name=\"clickToPayCards\"\n className=\"adyen-checkout-ctp__cards-list-field\"\n errorMessage={errorMessage}\n readOnly={status === 'loading'}\n label={i18n.get('ctp.cards.subtitle')}\n >\n <Select\n items={items}\n selectedValue={data['srcDigitalCardId']}\n name={'clickToPayCards'}\n filterable={false}\n className={'adyen-checkout-ctp__cards-list-dropdown'}\n readonly={status === 'loading'}\n onChange={handleChangeFor('srcDigitalCardId')}\n />\n </Field>\n );\n};\n\nexport default CtPCardsList;\n"],"names":["schema","CtPCardsList","cardSelected","cards","errorMessage","onChangeCard","i18n","useCoreContext","getImage","useImage","status","useClickToPayContext","handleChangeFor","data","useForm","defaultData","srcDigitalCardId","items","useMemo","map","card","icon","artUri","scheme","name","isMobile","title","panLastFour","secondaryText","isExpired","get","id","disabled","useEffect","find","h","Field","className","readOnly","label","Select","selectedValue","filterable","readonly","onChange"],"mappings":"2kBAuBA,MAAMA,EAAS,CAAC,oBAEVC,EAAe,EAAGC,eAAcC,QAAOC,eAAcC,mBACvD,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACXC,OAAEA,GAAWC,KACbC,gBAAEA,EAAeC,KAAEA,GAASC,EAAgC,CAC9Dd,SACAe,YAAa,CAAEC,iBAAkBd,EAAac,oBAG5CC,EAAQC,EAAQ,IACXf,EAAMgB,IAAIC,KACbC,KAAMD,EAAKE,QAAUd,IAAWY,EAAKG,QACrCC,KAAM,GAAGC,IAAa,GAAKL,EAAKM,cAAcN,EAAKO,eACnDC,cAAeR,EAAKS,WAAavB,EAAKwB,IAAI,yBAC1CC,GAAIX,EAAKJ,iBACTgB,SAAUZ,EAAKS,aAEpB,CAAC1B,IAQJ,OANA8B,EAAU,KACN,MAAMjB,iBAAEA,GAAqBH,EACvBO,EAAOjB,EAAM+B,KAAKd,GAAQA,EAAKJ,mBAAqBA,GAC1DX,EAAae,IACd,CAACP,EAAMR,IAGN8B,EAACC,EAAAA,CACGZ,KAAK,kBACLa,UAAU,uCACVjC,aAAcA,EACdkC,SAAqB,YAAX5B,EACV6B,MAAOjC,EAAKwB,IAAI,uBAEhBK,EAACK,EAAAA,CACGvB,MAAOA,EACPwB,cAAe5B,EAAK,iBACpBW,KAAM,kBACNkB,YAAY,EACZL,UAAW,0CACXM,SAAqB,YAAXjC,EACVkC,SAAUhC,EAAgB"}
1
+ {"version":3,"file":"CtPCardsList.js","sources":["../../../../../../../../src/components/internal/ClickToPay/components/CtPCards/CtPCardsList/CtPCardsList.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useEffect, useMemo } from 'preact/hooks';\nimport ShopperCard from '../../../models/ShopperCard';\nimport useClickToPayContext from '../../../context/useClickToPayContext';\nimport { useCoreContext } from '../../../../../../core/Context/CoreProvider';\nimport useImage from '../../../../../../core/Context/useImage';\nimport useForm from '../../../../../../utils/useForm';\nimport isMobile from '../../../../../../utils/isMobile';\nimport Field from '../../../../FormFields/Field';\nimport './CtPCardsList.scss';\nimport Select from '../../../../FormFields/Select';\n\ntype CtPCardsListProps = {\n cards: ShopperCard[];\n cardSelected: ShopperCard;\n errorMessage?: string;\n onChangeCard(card: ShopperCard): void;\n};\n\ntype CardsSelectorDataState = {\n srcDigitalCardId: string;\n};\n\nconst schema = ['srcDigitalCardId'];\n\nconst CtPCardsList = ({ cardSelected, cards, errorMessage, onChangeCard }: Readonly<CtPCardsListProps>) => {\n const { i18n } = useCoreContext();\n const getImage = useImage();\n const { status } = useClickToPayContext();\n const { handleChangeFor, data } = useForm<CardsSelectorDataState>({\n schema,\n defaultData: { srcDigitalCardId: cardSelected.srcDigitalCardId }\n });\n\n const items = useMemo(() => {\n return cards.map(card => ({\n icon: card.artUri || getImage()(card.scheme),\n name: `${isMobile() ? '' : card.title} •••• ${card.panLastFour} `,\n secondaryText: card.isExpired && i18n.get('ctp.cards.expiredCard'),\n id: card.srcDigitalCardId,\n disabled: card.isExpired\n }));\n }, [cards]);\n\n useEffect(() => {\n const { srcDigitalCardId } = data;\n const card = cards.find(card => card.srcDigitalCardId === srcDigitalCardId);\n onChangeCard(card);\n }, [data, onChangeCard]);\n\n return (\n <Field\n name=\"clickToPayCards\"\n className=\"adyen-checkout-ctp__cards-list-field\"\n errorMessage={errorMessage}\n readOnly={status === 'loading'}\n label={i18n.get('ctp.cards.subtitle')}\n >\n <Select\n items={items}\n selectedValue={data['srcDigitalCardId']}\n name={'clickToPayCards'}\n filterable={false}\n className={'adyen-checkout-ctp__cards-list-dropdown'}\n readonly={status === 'loading'}\n onChange={handleChangeFor('srcDigitalCardId')}\n />\n </Field>\n );\n};\n\nexport default CtPCardsList;\n"],"names":["schema","CtPCardsList","cardSelected","cards","errorMessage","onChangeCard","i18n","useCoreContext","getImage","useImage","status","useClickToPayContext","handleChangeFor","data","useForm","defaultData","srcDigitalCardId","items","useMemo","map","card","icon","artUri","scheme","name","isMobile","title","panLastFour","secondaryText","isExpired","get","id","disabled","useEffect","find","h","Field","className","readOnly","label","Select","selectedValue","filterable","readonly","onChange"],"mappings":"woBAuBA,MAAMA,EAAS,CAAC,oBAEVC,EAAe,EAAGC,eAAcC,QAAOC,eAAcC,mBACvD,MAAMC,KAAEA,GAASC,IACXC,EAAWC,KACXC,OAAEA,GAAWC,KACbC,gBAAEA,EAAeC,KAAEA,GAASC,EAAgC,CAC9Dd,SACAe,YAAa,CAAEC,iBAAkBd,EAAac,oBAG5CC,EAAQC,EAAQ,IACXf,EAAMgB,IAAIC,KACbC,KAAMD,EAAKE,QAAUd,IAAWY,EAAKG,QACrCC,KAAM,GAAGC,IAAa,GAAKL,EAAKM,cAAcN,EAAKO,eACnDC,cAAeR,EAAKS,WAAavB,EAAKwB,IAAI,yBAC1CC,GAAIX,EAAKJ,iBACTgB,SAAUZ,EAAKS,aAEpB,CAAC1B,IAQJ,OANA8B,EAAU,KACN,MAAMjB,iBAAEA,GAAqBH,EACvBO,EAAOjB,EAAM+B,KAAKd,GAAQA,EAAKJ,mBAAqBA,GAC1DX,EAAae,IACd,CAACP,EAAMR,IAGN8B,EAACC,EAAAA,CACGZ,KAAK,kBACLa,UAAU,uCACVjC,aAAcA,EACdkC,SAAqB,YAAX5B,EACV6B,MAAOjC,EAAKwB,IAAI,uBAEhBK,EAACK,EAAAA,CACGvB,MAAOA,EACPwB,cAAe5B,EAAK,iBACpBW,KAAM,kBACNkB,YAAY,EACZL,UAAW,0CACXM,SAAqB,YAAXjC,EACVkC,SAAUhC,EAAgB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as a}from"./validate.js";import{useCoreContext as n}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useForm.js";import p from"../../../FormFields/Field/Field.js";import l from"../../../FormFields/InputEmail.js";const d=d=>{const{i18n:u}=n(),{handleChangeFor:m,data:c,triggerValidation:g,valid:h,errors:f,isValid:L}=i({schema:["shopperLogin"],rules:a}),F=r({validateInput:null}),[j,v]=o(!1),b=s(()=>{v(!0),g()},[g]);t(()=>{c.shopperLogin&&v(!0)},[c.shopperLogin]),t(()=>{F.current.validateInput=b,d.onSetInputHandlers(F.current)},[b,d.onSetInputHandlers]);const E=s(e=>{"Enter"===e.key&&d.onPressEnter()},[d.onPressEnter]);return t(()=>{d.onChange({data:c,valid:h,errors:f,isValid:L})},[c,h,f]),e(p,{name:"shopperLogin",label:u.get("ctp.login.inputLabel"),errorMessage:j?d.errorMessage||!!f.shopperLogin:null,classNameModifiers:["shopperLogin"]},e(l,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:c.shopperLogin,disabled:d.disabled,onInput:m("shopperLogin","input"),onBlur:m("shopperLogin","blur"),onKeyPress:E}))};export{d as default};
1
+ import{createElement as e}from"../../../../../external/preact/dist/preact.js";import{useRef as r,useState as o,useCallback as s,useEffect as t}from"../../../../../external/preact/hooks/dist/hooks.js";import{loginValidationRules as n}from"./validate.js";import{useCoreContext as a}from"../../../../../core/Context/CoreProvider.js";import i from"../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as l}from"../../../../../utils/setFocus.js";import p from"../../../FormFields/Field/Field.js";import u from"../../../FormFields/InputEmail.js";const d=d=>{const{i18n:m}=a(),c=r(null),{handleChangeFor:g,data:h,triggerValidation:f,valid:L,errors:F,isValid:v}=i({schema:["shopperLogin"],rules:n,formHolder:c}),j=r({validateInput:null,focusInput:null}),[I,b]=o(!1),E=s(()=>{b(!0),f()},[f]);t(()=>{c.current&&d.errorMessage&&l(c.current,"shopperLogin")},[d.errorMessage]),t(()=>{h.shopperLogin&&b(!0)},[h.shopperLogin]),t(()=>{j.current.validateInput=E,d.onSetInputHandlers(j.current)},[E,d.onSetInputHandlers]);const k=s(e=>{"Enter"===e.key&&d.onPressEnter()},[d.onPressEnter]);return t(()=>{d.onChange({data:h,valid:L,errors:F,isValid:v})},[h,L,F]),e("div",{ref:c},e(p,{name:"shopperLogin",label:m.get("ctp.login.inputLabel"),errorMessage:I?d.errorMessage||!!F.shopperLogin:null,classNameModifiers:["shopperLogin"],errorLive:!0},e(u,{name:"shopperLogin",autocorrect:"off",spellcheck:!1,value:h.shopperLogin,disabled:d.disabled,onInput:g("shopperLogin","input"),onBlur:g("shopperLogin","blur"),onKeyPress:k})))};export{d as default};
2
2
  //# sourceMappingURL=CtPLoginInput.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport useForm from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useForm<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","handleChangeFor","data","triggerValidation","valid","errors","isValid","useForm","schema","rules","loginValidationRules","loginInputHandlersRef","useRef","validateInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","shopperLogin","current","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","Field","name","label","get","errorMessage","classNameModifiers","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"oeA0BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,KAEXC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAgC,CACzGC,OAFe,CAAC,gBAGhBC,MAAOC,IAELC,EAAwBC,EAA8B,CAAEC,cAAe,QACtEC,EAAmBC,GAAwBC,GAAkB,GAE9DH,EAAgBI,EAAY,KAC9BF,GAAqB,GACrBZ,KACD,CAACA,IAEJe,EAAU,KACFhB,EAAKiB,cAAcJ,GAAqB,IAC7C,CAACb,EAAKiB,eAETD,EAAU,KACNP,EAAsBS,QAAQP,cAAgBA,EAC9Cf,EAAMuB,mBAAmBV,EAAsBS,UAChD,CAACP,EAAef,EAAMuB,qBAEzB,MAAMC,EAAmBL,EACpBM,IACqB,UAAdA,EAAMC,KACD1B,EAAM2B,gBAGnB,CAAC3B,EAAM2B,eAOX,OAJAP,EAAU,KACNpB,EAAM4B,SAAS,CAAExB,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbsB,EAACC,EAAAA,CACGC,KAAK,eACLC,MAAO/B,EAAKgC,IAAI,wBAChBC,aAAclB,EAAoBhB,EAAMkC,gBAAkB3B,EAAOc,aAAe,KAChFc,mBAAoB,CAAC,iBAErBN,EAACO,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOnC,EAAKiB,aACZmB,SAAUxC,EAAMwC,SAChBC,QAAStC,EAAgB,eAAgB,SACzCuC,OAAQvC,EAAgB,eAAgB,QACxCwC,WAAYnB"}
1
+ {"version":3,"file":"CtPLoginInput.js","sources":["../../../../../../../src/components/internal/ClickToPay/components/CtPLogin/CtPLoginInput.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\nimport { loginValidationRules } from './validate';\nimport { useCoreContext } from '../../../../../core/Context/CoreProvider';\nimport { useFormWithA11y } from '../../../../../utils/useForm';\nimport Field from '../../../FormFields/Field';\nimport InputEmail from '../../../FormFields/InputEmail';\nimport { setFocusOnField } from '../../../../../utils/setFocus';\n\ntype OnChangeProps = { data: CtPLoginInputDataState; valid; errors; isValid: boolean };\n\ninterface CtPLoginInputProps {\n disabled: boolean;\n errorMessage?: string;\n onPressEnter(): Promise<void>;\n onChange({ data, valid, errors, isValid }: OnChangeProps): void;\n onSetInputHandlers(handlers: CtPLoginInputHandlers): void;\n}\n\ninterface CtPLoginInputDataState {\n shopperLogin?: string;\n}\n\nexport type CtPLoginInputHandlers = {\n validateInput(): void;\n focusInput(): void;\n};\n\nconst CtPLoginInput = (props: Readonly<CtPLoginInputProps>): h.JSX.Element => {\n const { i18n } = useCoreContext();\n const formSchema = ['shopperLogin'];\n const containerRef = useRef<HTMLDivElement>(null);\n const { handleChangeFor, data, triggerValidation, valid, errors, isValid } = useFormWithA11y<CtPLoginInputDataState>({\n schema: formSchema,\n rules: loginValidationRules,\n formHolder: containerRef\n });\n const loginInputHandlersRef = useRef<CtPLoginInputHandlers>({ validateInput: null, focusInput: null });\n const [isLoginInputDirty, setIsLoginInputDirty] = useState<boolean>(false);\n\n const validateInput = useCallback(() => {\n setIsLoginInputDirty(true);\n triggerValidation();\n }, [triggerValidation]);\n\n useEffect(() => {\n if (containerRef.current && props.errorMessage) {\n setFocusOnField(containerRef.current, 'shopperLogin');\n }\n }, [props.errorMessage]);\n\n useEffect(() => {\n if (data.shopperLogin) setIsLoginInputDirty(true);\n }, [data.shopperLogin]);\n\n useEffect(() => {\n loginInputHandlersRef.current.validateInput = validateInput;\n props.onSetInputHandlers(loginInputHandlersRef.current);\n }, [validateInput, props.onSetInputHandlers]);\n\n const handleOnKeyPress = useCallback(\n (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n void props.onPressEnter();\n }\n },\n [props.onPressEnter]\n );\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n }, [data, valid, errors]);\n\n return (\n <div ref={containerRef}>\n <Field\n name=\"shopperLogin\"\n label={i18n.get('ctp.login.inputLabel')}\n errorMessage={isLoginInputDirty ? props.errorMessage || !!errors.shopperLogin : null}\n classNameModifiers={['shopperLogin']}\n errorLive={true}\n >\n <InputEmail\n name={'shopperLogin'}\n autocorrect={'off'}\n spellcheck={false}\n value={data.shopperLogin}\n disabled={props.disabled}\n onInput={handleChangeFor('shopperLogin', 'input')}\n onBlur={handleChangeFor('shopperLogin', 'blur')}\n onKeyPress={handleOnKeyPress}\n />\n </Field>\n </div>\n );\n};\n\nexport default CtPLoginInput;\n"],"names":["CtPLoginInput","props","i18n","useCoreContext","containerRef","useRef","handleChangeFor","data","triggerValidation","valid","errors","isValid","useFormWithA11y","schema","rules","loginValidationRules","formHolder","loginInputHandlersRef","validateInput","focusInput","isLoginInputDirty","setIsLoginInputDirty","useState","useCallback","useEffect","current","errorMessage","setFocusOnField","shopperLogin","onSetInputHandlers","handleOnKeyPress","event","key","onPressEnter","onChange","h","div","ref","Field","name","label","get","classNameModifiers","errorLive","InputEmail","autocorrect","spellcheck","value","disabled","onInput","onBlur","onKeyPress"],"mappings":"+iBA4BA,MAAMA,EAAiBC,IACnB,MAAMC,KAAEA,GAASC,IAEXC,EAAeC,EAAuB,OACtCC,gBAAEA,EAAeC,KAAEA,EAAIC,kBAAEA,EAAiBC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAwC,CACjHC,OAHe,CAAC,gBAIhBC,MAAOC,EACPC,WAAYZ,IAEVa,EAAwBZ,EAA8B,CAAEa,cAAe,KAAMC,WAAY,QACxFC,EAAmBC,GAAwBC,GAAkB,GAE9DJ,EAAgBK,EAAY,KAC9BF,GAAqB,GACrBb,KACD,CAACA,IAEJgB,EAAU,KACFpB,EAAaqB,SAAWxB,EAAMyB,cAC9BC,EAAgBvB,EAAaqB,QAAS,iBAE3C,CAACxB,EAAMyB,eAEVF,EAAU,KACFjB,EAAKqB,cAAcP,GAAqB,IAC7C,CAACd,EAAKqB,eAETJ,EAAU,KACNP,EAAsBQ,QAAQP,cAAgBA,EAC9CjB,EAAM4B,mBAAmBZ,EAAsBQ,UAChD,CAACP,EAAejB,EAAM4B,qBAEzB,MAAMC,EAAmBP,EACpBQ,IACqB,UAAdA,EAAMC,KACD/B,EAAMgC,gBAGnB,CAAChC,EAAMgC,eAOX,OAJAT,EAAU,KACNvB,EAAMiC,SAAS,CAAE3B,OAAME,QAAOC,SAAQC,aACvC,CAACJ,EAAME,EAAOC,IAGbyB,EAACC,MAAAA,CAAIC,IAAKjC,GACN+B,EAACG,EAAAA,CACGC,KAAK,eACLC,MAAOtC,EAAKuC,IAAI,wBAChBf,aAAcN,EAAoBnB,EAAMyB,gBAAkBhB,EAAOkB,aAAe,KAChFc,mBAAoB,CAAC,gBACrBC,WAAW,GAEXR,EAACS,EAAAA,CACGL,KAAM,eACNM,YAAa,MACbC,YAAY,EACZC,MAAOxC,EAAKqB,aACZoB,SAAU/C,EAAM+C,SAChBC,QAAS3C,EAAgB,eAAgB,SACzC4C,OAAQ5C,EAAgB,eAAgB,QACxC6C,WAAYrB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as t,useRef as r,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useForm.js";import d from"../../../../FormFields/Field/Field.js";import c from"../../../../FormFields/InputText.js";import{getErrorMessage as u}from"../../../../../../utils/getErrorMessage.js";const m=m=>{const{i18n:f}=i(),{configuration:{disableOtpAutoFocus:g}}=l(),[C,j]=t(null),{handleChangeFor:F,data:b,triggerValidation:h,valid:k,errors:v,isValid:x,setData:E}=p({schema:["otp"],rules:a}),P=r({validateInput:null}),I=r(null),[R,y]=t(!1),M=o(()=>{y(!0),h()},[h]);s(()=>{b.otp&&y(!0)},[b.otp]),s(()=>{!g&&I.current&&I.current.focus()},[I.current,g]),s(()=>{P.current.validateInput=M,m.onSetInputHandlers(P.current)},[M,m.onSetInputHandlers]);const V=o(()=>{E("otp",""),j(null),g||I.current.focus(),m.onResendCode()},[m.onResendCode,I.current,g]),_=o(e=>{const t=f.get(`ctp.errors.${e}`);t&&j(t)},[f]),w=o(e=>{"Enter"===e.key&&m.onPressEnter()},[m.onPressEnter]);s(()=>{m.onChange({data:b,valid:k,errors:v,isValid:x})},[b,k,v]);const L=o(()=>R?C||m.errorMessage||u(f,v.otp,f.get("ctp.otp.fieldLabel")):null,[R,C,m.errorMessage,v.otp,f]);return e("div",{className:"adyen-checkout-ctp__otp-field-wrapper"},e(d,{name:"oneTimePassword",label:f.get("ctp.otp.fieldLabel"),errorMessage:L(),classNameModifiers:["otp"]},e(c,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:m.disabled,onInput:F("otp","input"),onBlur:F("otp","blur"),onKeyPress:w,setRef:e=>{I.current=e}})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:m.isValidatingOtp,onError:_,onResendCode:V})))};export{m as default};
1
+ import{createElement as e}from"../../../../../../external/preact/dist/preact.js";import{useState as r,useRef as t,useCallback as o,useEffect as s}from"../../../../../../external/preact/hooks/dist/hooks.js";import{otpValidationRules as a}from"./validate.js";import n from"./CtPResendOtpLink.js";import l from"../../../context/useClickToPayContext.js";import{useCoreContext as i}from"../../../../../../core/Context/CoreProvider.js";import p from"../../../../../../utils/useForm/useFormWithA11y.js";import{setFocusOnField as d}from"../../../../../../utils/setFocus.js";import u from"../../../../FormFields/Field/Field.js";import c from"../../../../FormFields/InputText.js";import{getErrorMessage as m}from"../../../../../../utils/getErrorMessage.js";const f=f=>{const{i18n:g}=i(),{configuration:{disableOtpAutoFocus:j}}=l(),[C,F]=r(null),h=t(null),{handleChangeFor:v,data:b,triggerValidation:k,valid:x,errors:E,isValid:M,setData:P}=p({schema:["otp"],rules:a,formHolder:h}),y=t({validateInput:null}),I=t(null),[R,L]=r(!1),V=o(()=>{L(!0),k()},[k]);s(()=>{b.otp&&L(!0)},[b.otp]),s(()=>{!j&&I.current&&I.current.focus()},[I.current,j]),s(()=>{h.current&&f.errorMessage&&d(h.current,"otp")},[f.errorMessage]),s(()=>{y.current.validateInput=V,f.onSetInputHandlers(y.current)},[V,f.onSetInputHandlers]);const _=o(()=>{P("otp",""),F(null),j||I.current.focus(),f.onResendCode()},[f.onResendCode,I.current,j]),w=o(e=>{const r=g.get(`ctp.errors.${e}`);r&&F(r)},[g]),H=o(e=>{"Enter"===e.key&&f.onPressEnter()},[f.onPressEnter]);s(()=>{f.onChange({data:b,valid:x,errors:E,isValid:M})},[b,x,E]);const N=o(()=>R?C||f.errorMessage||m(g,E.otp,g.get("ctp.otp.fieldLabel")):null,[R,C,f.errorMessage,E.otp,g]);return e("div",{ref:h,className:"adyen-checkout-ctp__otp-field-wrapper"},e(u,{name:"oneTimePassword",label:g.get("ctp.otp.fieldLabel"),errorMessage:N(),classNameModifiers:["otp"],errorLive:!0},e(c,{name:"otp",autocorrect:"off",spellcheck:!1,value:b.otp,disabled:f.disabled,onInput:v("otp","input"),onBlur:v("otp","blur"),onKeyPress:H,setRef:e=>{I.current=e}})),e("div",{className:"adyen-checkout-ctp__otp-resend-code-wrapper"},e(n,{disabled:f.isValidatingOtp,onError:w,onResendCode:_})))};export{f as default};
2
2
  //# sourceMappingURL=CtPOneTimePasswordInput.js.map