@adyen/adyen-web 6.5.0 → 6.6.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 (248) hide show
  1. package/dist/cjs/adyen.css +2 -2
  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/cjs/index.d.cts +68 -30
  6. package/dist/es/adyen.css +2 -2
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/ANCV/ANCV.js.map +1 -1
  9. package/dist/es/components/Ach/components/AchInput/defaultProps.js +1 -1
  10. package/dist/es/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  11. package/dist/es/components/ApplePay/components/ApplePayButton.js.map +1 -1
  12. package/dist/es/components/BacsDD/BacsDD.js.map +1 -1
  13. package/dist/es/components/Boleto/Boleto.js.map +1 -1
  14. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  15. package/dist/es/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  16. package/dist/es/components/Card/Card.js.map +1 -1
  17. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  18. package/dist/es/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  19. package/dist/es/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  20. package/dist/es/components/Card/components/CardInput/types.js +1 -1
  21. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  22. package/dist/es/components/CashAppPay/CashAppPay.js.map +1 -1
  23. package/dist/es/components/CashAppPay/services/types.js +1 -1
  24. package/dist/es/components/CashAppPay/services/types.js.map +1 -1
  25. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  26. package/dist/es/components/Donation/components/CampaignContent.js +1 -1
  27. package/dist/es/components/Donation/components/CampaignContent.js.map +1 -1
  28. package/dist/es/components/Donation/components/CampaignInfo.js +2 -0
  29. package/dist/es/components/Donation/components/CampaignInfo.js.map +1 -0
  30. package/dist/es/components/Donation/components/DonationComponent.js +1 -1
  31. package/dist/es/components/Donation/components/DonationComponent.js.map +1 -1
  32. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  33. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  34. package/dist/es/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  35. package/dist/es/components/Giftcard/Giftcard.js.map +1 -1
  36. package/dist/es/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  37. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  38. package/dist/es/components/Klarna/KlarnaPayments.js +1 -1
  39. package/dist/es/components/Klarna/KlarnaPayments.js.map +1 -1
  40. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  41. package/dist/es/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  42. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  43. package/dist/es/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  44. package/dist/es/components/Multibanco/Multibanco.js.map +1 -1
  45. package/dist/es/components/OnlineBankingCZ/index.js +1 -1
  46. package/dist/es/components/OnlineBankingCZ/index.js.map +1 -1
  47. package/dist/es/components/OnlineBankingSK/index.js +1 -1
  48. package/dist/es/components/OnlineBankingSK/index.js.map +1 -1
  49. package/dist/es/components/Oxxo/Oxxo.js.map +1 -1
  50. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  51. package/dist/es/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  52. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  53. package/dist/es/components/Redirect/Redirect.js +1 -1
  54. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  55. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  56. package/dist/es/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  57. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  58. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  59. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  60. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  61. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  62. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  63. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  64. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  65. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  66. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  67. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  68. package/dist/es/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  69. package/dist/es/components/Twint/Twint.js.map +1 -1
  70. package/dist/es/components/UPI/UPI.js.map +1 -1
  71. package/dist/es/components/internal/Address/components/CountryField.js +1 -1
  72. package/dist/es/components/internal/Address/components/CountryField.js.map +1 -1
  73. package/dist/es/components/internal/Address/components/FieldContainer.js +1 -1
  74. package/dist/es/components/internal/Address/components/FieldContainer.js.map +1 -1
  75. package/dist/es/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  76. package/dist/es/components/internal/Address/components/StateField.js +1 -1
  77. package/dist/es/components/internal/Address/components/StateField.js.map +1 -1
  78. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  79. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  80. package/dist/es/components/internal/Button/Button.js.map +1 -1
  81. package/dist/es/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  82. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  83. package/dist/es/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  84. package/dist/es/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  85. package/dist/es/components/internal/FormFields/Select/Select.js +1 -1
  86. package/dist/es/components/internal/FormFields/Select/Select.js.map +1 -1
  87. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  88. package/dist/es/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  89. package/dist/es/components/internal/IFrame/Iframe.js.map +1 -1
  90. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  91. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  92. package/dist/es/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  93. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  94. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  95. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  96. package/dist/es/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  97. package/dist/es/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  98. package/dist/es/components/internal/SecuredFields/lib/constants.js +1 -1
  99. package/dist/es/components/internal/SecuredFields/lib/constants.js.map +1 -1
  100. package/dist/es/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  101. package/dist/es/components/internal/SecuredFields/lib/utilities/logger.js.map +1 -1
  102. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  103. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  104. package/dist/es/components/tx-variants.js +1 -1
  105. package/dist/es/components/tx-variants.js.map +1 -1
  106. package/dist/es/core/Analytics/Analytics.js +1 -1
  107. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  108. package/dist/es/core/Analytics/EventsQueue.js.map +1 -1
  109. package/dist/es/core/Analytics/analyticsPreProcessor.js +1 -1
  110. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +1 -1
  111. package/dist/es/core/Analytics/constants.js +1 -1
  112. package/dist/es/core/Analytics/constants.js.map +1 -1
  113. package/dist/es/core/CheckoutSession/CheckoutSession.js.map +1 -1
  114. package/dist/es/core/Errors/AdyenCheckoutError.js.map +1 -1
  115. package/dist/es/core/Errors/SRPanel.js.map +1 -1
  116. package/dist/es/core/Errors/constants.js +1 -1
  117. package/dist/es/core/Errors/constants.js.map +1 -1
  118. package/dist/es/core/Errors/utils.js +1 -1
  119. package/dist/es/core/RiskModule/RiskModule.js.map +1 -1
  120. package/dist/es/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  121. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  122. package/dist/es/core/core.js +1 -1
  123. package/dist/es/index.d.ts +68 -30
  124. package/dist/es-legacy/adyen.css +2 -2
  125. package/dist/es-legacy/adyen.css.map +1 -1
  126. package/dist/es-legacy/components/ANCV/ANCV.js.map +1 -1
  127. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js +1 -1
  128. package/dist/es-legacy/components/Ach/components/AchInput/defaultProps.js.map +1 -1
  129. package/dist/es-legacy/components/ApplePay/components/ApplePayButton.js.map +1 -1
  130. package/dist/es-legacy/components/BacsDD/BacsDD.js.map +1 -1
  131. package/dist/es-legacy/components/Boleto/Boleto.js.map +1 -1
  132. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js +1 -1
  133. package/dist/es-legacy/components/Boleto/components/BoletoVoucherResult/BoletoVoucherResult.js.map +1 -1
  134. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  135. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js +1 -1
  136. package/dist/es-legacy/components/Card/components/CardInput/components/BrandIcon.js.map +1 -1
  137. package/dist/es-legacy/components/Card/components/CardInput/components/CVCHint.js.map +1 -1
  138. package/dist/es-legacy/components/Card/components/CardInput/types.js +1 -1
  139. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  140. package/dist/es-legacy/components/CashAppPay/CashAppPay.js.map +1 -1
  141. package/dist/es-legacy/components/CashAppPay/services/types.js +1 -1
  142. package/dist/es-legacy/components/CashAppPay/services/types.js.map +1 -1
  143. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  144. package/dist/es-legacy/components/Donation/components/CampaignContent.js +1 -1
  145. package/dist/es-legacy/components/Donation/components/CampaignContent.js.map +1 -1
  146. package/dist/es-legacy/components/Donation/components/CampaignInfo.js +2 -0
  147. package/dist/es-legacy/components/Donation/components/CampaignInfo.js.map +1 -0
  148. package/dist/es-legacy/components/Donation/components/DonationComponent.js +1 -1
  149. package/dist/es-legacy/components/Donation/components/DonationComponent.js.map +1 -1
  150. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  151. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  152. package/dist/es-legacy/components/Dropin/components/PaymentMethod/PaymentMethodItem/PaymentMethodItem.js.map +1 -1
  153. package/dist/es-legacy/components/Giftcard/Giftcard.js.map +1 -1
  154. package/dist/es-legacy/components/Giftcard/components/GiftcardComponent.js.map +1 -1
  155. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  156. package/dist/es-legacy/components/Klarna/KlarnaPayments.js +1 -1
  157. package/dist/es-legacy/components/Klarna/KlarnaPayments.js.map +1 -1
  158. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js +1 -1
  159. package/dist/es-legacy/components/Klarna/components/KlarnaContainer/KlarnaContainer.js.map +1 -1
  160. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js +1 -1
  161. package/dist/es-legacy/components/Klarna/components/KlarnaWidget/KlarnaWidget.js.map +1 -1
  162. package/dist/es-legacy/components/Multibanco/Multibanco.js.map +1 -1
  163. package/dist/es-legacy/components/OnlineBankingCZ/index.js +1 -1
  164. package/dist/es-legacy/components/OnlineBankingCZ/index.js.map +1 -1
  165. package/dist/es-legacy/components/OnlineBankingSK/index.js +1 -1
  166. package/dist/es-legacy/components/OnlineBankingSK/index.js.map +1 -1
  167. package/dist/es-legacy/components/Oxxo/Oxxo.js.map +1 -1
  168. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js +1 -1
  169. package/dist/es-legacy/components/Oxxo/components/OxxoVoucherResult/OxxoVoucherResult.js.map +1 -1
  170. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  171. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  172. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  173. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js +1 -1
  174. package/dist/es-legacy/components/Redirect/components/RedirectShopper/RedirectShopper.js.map +1 -1
  175. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  176. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  177. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  178. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  179. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  180. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  181. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  182. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  183. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.js.map +1 -1
  184. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  185. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  186. package/dist/es-legacy/components/ThreeDS2/components/Form/ThreeDS2Form.js.map +1 -1
  187. package/dist/es-legacy/components/Twint/Twint.js.map +1 -1
  188. package/dist/es-legacy/components/UPI/UPI.js.map +1 -1
  189. package/dist/es-legacy/components/internal/Address/components/CountryField.js +1 -1
  190. package/dist/es-legacy/components/internal/Address/components/CountryField.js.map +1 -1
  191. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js +1 -1
  192. package/dist/es-legacy/components/internal/Address/components/FieldContainer.js.map +1 -1
  193. package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  194. package/dist/es-legacy/components/internal/Address/components/StateField.js +1 -1
  195. package/dist/es-legacy/components/internal/Address/components/StateField.js.map +1 -1
  196. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  197. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  198. package/dist/es-legacy/components/internal/Button/Button.js.map +1 -1
  199. package/dist/es-legacy/components/internal/ClickToPay/components/CtPCards/CtPCards.js.map +1 -1
  200. package/dist/es-legacy/components/internal/ClickToPay/errors/TimeoutError.js.map +1 -1
  201. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js +1 -1
  202. package/dist/es-legacy/components/internal/ClickToPay/services/ClickToPayService.js.map +1 -1
  203. package/dist/es-legacy/components/internal/ClickToPay/services/sdks/SrciError.js.map +1 -1
  204. package/dist/es-legacy/components/internal/FormFields/Select/Select.js +1 -1
  205. package/dist/es-legacy/components/internal/FormFields/Select/Select.js.map +1 -1
  206. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js +1 -1
  207. package/dist/es-legacy/components/internal/FormFields/Select/components/SelectButton.js.map +1 -1
  208. package/dist/es-legacy/components/internal/IFrame/Iframe.js.map +1 -1
  209. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  210. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  211. package/dist/es-legacy/components/internal/PersonalDetails/ReadOnlyPersonalDetails.js.map +1 -1
  212. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  213. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  214. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  215. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/extensions/handleIOSTouchEvents.js.map +1 -1
  216. package/dist/es-legacy/components/internal/SecuredFields/lib/CSF/utils/cardType.js.map +1 -1
  217. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js +1 -1
  218. package/dist/es-legacy/components/internal/SecuredFields/lib/constants.js.map +1 -1
  219. package/dist/es-legacy/components/internal/SecuredFields/lib/securedField/SecuredField.js.map +1 -1
  220. package/dist/es-legacy/components/internal/SecuredFields/lib/utilities/logger.js.map +1 -1
  221. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  222. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  223. package/dist/es-legacy/components/tx-variants.js +1 -1
  224. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  225. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  226. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  227. package/dist/es-legacy/core/Analytics/EventsQueue.js.map +1 -1
  228. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +1 -1
  229. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +1 -1
  230. package/dist/es-legacy/core/Analytics/constants.js +1 -1
  231. package/dist/es-legacy/core/Analytics/constants.js.map +1 -1
  232. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  233. package/dist/es-legacy/core/CheckoutSession/CheckoutSession.js.map +1 -1
  234. package/dist/es-legacy/core/Errors/AdyenCheckoutError.js.map +1 -1
  235. package/dist/es-legacy/core/Errors/SRPanel.js.map +1 -1
  236. package/dist/es-legacy/core/Errors/constants.js +1 -1
  237. package/dist/es-legacy/core/Errors/constants.js.map +1 -1
  238. package/dist/es-legacy/core/Errors/utils.js +1 -1
  239. package/dist/es-legacy/core/RiskModule/RiskModule.js.map +1 -1
  240. package/dist/es-legacy/core/RiskModule/components/DeviceFingerprint/GetDeviceFingerprint.js.map +1 -1
  241. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  242. package/dist/es-legacy/core/core.js +1 -1
  243. package/package.json +15 -12
  244. package/styles/adyen.css +2 -2
  245. package/dist/es/components/Donation/components/CampaignContainer.js +0 -2
  246. package/dist/es/components/Donation/components/CampaignContainer.js.map +0 -1
  247. package/dist/es-legacy/components/Donation/components/CampaignContainer.js +0 -2
  248. package/dist/es-legacy/components/Donation/components/CampaignContainer.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport {\n THREEDS2_CHALLENGE,\n THREEDS2_CHALLENGE_ERROR,\n THREEDS2_FULL,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR\n} from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_API_ERROR, ANALYTICS_NETWORK_ERROR, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.CHALLENGE_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const errorCodeObject: SendAnalyticsObject = {\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_API_ERROR,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n // metadata: { acsURL } // NEW TODO - check acsURL isn't secret\n };\n this.props.onSubmitAnalytics(errorCodeObject);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_API_ERROR,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n } as SendAnalyticsObject);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: errorCode,\n errorType: ANALYTICS_API_ERROR,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_NETWORK_ERROR : ANALYTICS_API_ERROR\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subtype: Analytics3DS2Events.CHALLENGE_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\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 this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_API_ERROR,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","errorCodeObject","type","THREEDS2_ERROR","code","errorType","ANALYTICS_API_ERROR","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","analyticsObject","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","ANALYTICS_NETWORK_ERROR","_object_spread","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"krDAwBA,MAAMA,UAA6BC,EAoC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAA,QAAAD,EAAAC,EAA6BK,WAA7B,IAAAN,SAAAA,EAAkCO,SAAS,2BAK/EC,OAAEA,GAAWZ,KAAKC,MAAMC,cAI9B,IAHuBW,EAAeD,EAAQN,GAGzB,CAEjBN,KAAKc,SACD,CACIC,UAAW,GAAGC,EAAoBC,4BAA4BjB,KAAKO,MAAMW,KAAKC,IAAI,oBAEtF,GAIJ,MAAMC,EAAuC,CACzCC,KAAMC,EACNC,KAAMP,EAAoBC,wBAC1BO,UAAWC,EACXC,QAAS,GAAGC,uDAMhB,OAHA3B,KAAKO,MAAMqB,kBAAkBR,QAE7BS,QAAQC,MAAM,sDAElB,CAEA,MAAMC,WAAEA,EAAUC,eAAEA,EAAcC,qBAAEA,GAA0BjC,KAAKC,MAAMC,cAAgCgC,SAGzG,IAAKH,IAAeC,IAAmBC,EAqBnC,OAnBAjC,KAAKc,SACD,CACIC,UAAW,GAAGC,EAAoBmB,iCAAiCnC,KAAKO,MAAMW,KAAKC,IAAI,oBAG3F,GAIJnB,KAAKO,MAAMqB,kBAAkB,CACzBP,KAAMC,EACNC,KAAMP,EAAoBmB,6BAC1BX,UAAWC,EACXC,QAAS,GAAGC,kIAGhBE,QAAQC,MACJ,4IAMR9B,KAAKoC,SAAS,CAAEC,OAAQ,4BAErB,CACH,MAAMC,EAAmBtC,KAAMC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,"file":"PrepareChallenge3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoChallenge3DS2 from './DoChallenge3DS2';\nimport { createChallengeResolveData, prepareChallengeData, createOldChallengeResolveData, isErrorObject } from '../utils';\nimport { PrepareChallenge3DS2Props, PrepareChallenge3DS2State, StatusErrorInfoObject } from './types';\nimport { ChallengeData, ResultObject, ThreeDS2FlowObject, ErrorCodeObject } from '../../types';\nimport '../../ThreeDS2.scss';\nimport Img from '../../../internal/Img';\nimport './challenge.scss';\nimport { hasOwnProperty } from '../../../../utils/hasOwnProperty';\nimport useImage from '../../../../core/Context/useImage';\nimport AdyenCheckoutError, { ERROR } from '../../../../core/Errors/AdyenCheckoutError';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport {\n THREEDS2_CHALLENGE,\n THREEDS2_CHALLENGE_ERROR,\n THREEDS2_FULL,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR\n} from '../../constants';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\nimport { ErrorObject } from '../../../../core/Errors/types';\n\nclass PrepareChallenge3DS2 extends Component<PrepareChallenge3DS2Props, PrepareChallenge3DS2State> {\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n if (this.props.token) {\n const challengeData: ChallengeData | ErrorObject = prepareChallengeData({\n token: this.props.token,\n size: this.props.challengeWindowSize || this.props.size // TODO confirm that this.props.size is legacy and can be removed\n });\n\n this.state = {\n status: 'init',\n challengeData: challengeData as ChallengeData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { challengeData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_CHALLENGE_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.CHALLENGE_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasChallengeData = !isErrorObject(this.state.challengeData);\n\n if (hasChallengeData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created challengeData\n */\n const { acsURL } = this.state.challengeData as ChallengeData;\n const hasValidAcsURL = isValidHttpUrl(acsURL, shouldAllowHttpDomains);\n\n // Only render component if we have an acsURL.\n if (!hasValidAcsURL) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL}: ${this.props.i18n.get('err.gen.9102')}` //\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n const errorCodeObject: SendAnalyticsObject = {\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_ACSURL,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing a valid acsURL property`\n // metadata: { acsURL } // NEW TODO - check acsURL isn't secret\n };\n this.props.onSubmitAnalytics(errorCodeObject);\n\n console.debug('### PrepareChallenge3DS2::exiting:: no valid acsURL');\n return;\n }\n\n const { acsTransID, messageVersion, threeDSServerTransID } = (this.state.challengeData as ChallengeData).cReqData;\n\n // Only render component if we have a acsTransID, messageVersion & threeDSServerTransID\n if (!acsTransID || !messageVersion || !threeDSServerTransID) {\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo: `${Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if this *ever* happens\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: Decoded token is missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)`\n } as SendAnalyticsObject);\n\n console.debug(\n '### PrepareChallenge3DS2::exiting:: missing one or more of the following properties (acsTransID | messageVersion | threeDSServerTransID)'\n );\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'performingChallenge' });\n //\n } else {\n const errorMsg: string = (this.state.challengeData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n // Set UI error & call onError callback\n this.setError(\n {\n errorInfo:\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? `${Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN}: ${this.props.i18n.get('err.gen.9102')}`\n : `${Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED}: ${this.props.i18n.get('err.gen.9102')}`\n // errorObj: this.state.challengeData // TODO Decide if we want to expose this data\n },\n true\n );\n\n // Send error to analytics endpoint // TODO - check logs to see if the base64 decoding errors *ever* happen\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: errorCode,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n });\n\n console.debug('### PrepareChallenge3DS2::exiting:: no challengeData');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldChallengeResolveData : createChallengeResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj.transStatus, this.props.paymentData);\n\n if (errorCodeObject) {\n console.debug('### PrepareChallenge3DS2::errorCodeObject::', errorCodeObject);\n }\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an \"error\" i.e. timeout or no transStatus, scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === 'timeout' ? Analytics3DS2Errors.THREEDS2_TIMEOUT : Analytics3DS2Errors.NO_TRANSSTATUS,\n errorType: finalResObject.errorCode === 'timeout' ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n // Challenge process has timed out,\n // or, It's an error reported by the backend 'cos no transStatus could be retrieved // TODO - check logs to see if this *ever* happens\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n }\n\n /** Calculate \"result\" for analytics */\n let result: string;\n\n switch (resultObj?.transStatus) {\n case 'Y':\n result = 'success';\n break;\n case 'N':\n result = 'failed';\n break;\n case 'U':\n result = !errorCodeObject ? 'cancelled' : 'timeout';\n break;\n default:\n }\n if (resultObj?.errorCode) {\n result = 'noTransStatus';\n }\n\n /** Create log object - the process is completed, one way or another */\n analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} challenge has completed`,\n subtype: Analytics3DS2Events.CHALLENGE_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\n\n /**\n * Equals call to onAdditionalDetails (except for in 3DS2InMDFlow)\n */\n this.props.onComplete(data);\n });\n }\n\n /**\n * Display error in the UI,\n * and, optionally, decide whether to send any of these errors to the merchant defined onError callback\n *\n * @param errorInfoObj -\n * @param isFatal -\n */\n setError(errorInfoObj: StatusErrorInfoObject, isFatal: boolean) {\n this.setState({ status: 'error', errorInfo: errorInfoObj.errorInfo });\n\n // Decide whether to call this.props.onError\n if (isFatal) {\n this.props.onError(new AdyenCheckoutError(ERROR, errorInfoObj.errorInfo, { cause: errorInfoObj.errorObj }));\n }\n }\n\n render(_, { challengeData }) {\n const getImage = useImage();\n if (this.state.status === 'performingChallenge') {\n return (\n <DoChallenge3DS2\n onCompleteChallenge={(challenge: ThreeDS2FlowObject) => {\n let errorCodeObject: ErrorCodeObject = null;\n\n // Challenge has resulted in an error (no transStatus could be retrieved) - but we still treat this as a valid scenario\n if (hasOwnProperty(challenge.result, 'errorCode') && challenge.result.errorCode.length) {\n // Tell the merchant there's been an error\n errorCodeObject = {\n errorCode: challenge.result.errorCode,\n message: `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription ? challenge.result.errorDescription : 'no transStatus could be retrieved'\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 this.props.onError(\n new AdyenCheckoutError(\n ERROR,\n `${THREEDS2_CHALLENGE_ERROR}: ${\n challenge.result.errorDescription\n ? challenge.result.errorDescription\n : 'no transStatus could be retrieved'\n }`,\n { cause: challenge.result.errorCode }\n )\n );\n }\n }\n\n /**\n * An object has been returned, parsed & accepted as legit (according to the rules in getProcessMessageHandler),\n * but the result prop on that object is missing\n */\n if (!challenge.result) {\n this.setError(\n {\n errorInfo: `${THREEDS2_CHALLENGE_ERROR}: ${this.props.i18n.get('3ds.chal.805', {\n values: { result: '\"result\"' }\n })}`,\n errorObj: challenge as unknown as ErrorObject\n },\n true\n );\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics({\n type: THREEDS2_ERROR,\n code: Analytics3DS2Errors.CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP,\n errorType: ANALYTICS_ERROR_TYPE.apiError,\n message: `${THREEDS2_CHALLENGE_ERROR}: challenge resolved without a \"result\" object`\n });\n\n console.debug('### PrepareChallenge3DS2::exiting:: challenge resolved without a \"result\" object');\n\n return;\n }\n\n // Proceed with call to onAdditionalDetails (except for in 3DS2InMDFlow)\n this.setStatusComplete(challenge.result, errorCodeObject);\n }}\n onErrorChallenge={(challenge: ThreeDS2FlowObject) => {\n /**\n * Called when challenge times-out (which is still a valid scenario)...\n */\n if (hasOwnProperty(challenge, 'errorCode')) {\n const timeoutObject: ErrorCodeObject = {\n errorCode: challenge.errorCode,\n message: `${THREEDS2_CHALLENGE}: ${challenge.errorCode}`\n };\n\n // see comment in onCompleteChallenge code block\n if (this.props.isMDFlow) {\n this.props.onError(\n new AdyenCheckoutError(ERROR, `${THREEDS2_CHALLENGE_ERROR}: '3DS2 challenge timed out'`, {\n cause: challenge.errorCode\n })\n );\n }\n\n this.setStatusComplete(challenge.result, timeoutObject);\n return;\n }\n }}\n {...challengeData}\n onActionHandled={this.props.onActionHandled}\n onFormSubmit={this.onFormSubmit}\n />\n );\n }\n\n if (this.state.status === 'error') {\n return (\n <div className=\"adyen-checkout__threeds2-challenge-error\">\n <Img\n className=\"adyen-checkout__status__icon adyen-checkout__status__icon--error\"\n src={getImage({\n imageFolder: 'components/'\n })('error')}\n alt={''}\n />\n <div className=\"adyen-checkout__status__text\">\n {this.state.errorInfo ? this.state.errorInfo : this.props.i18n.get('error.message.unknown')}\n </div>\n </div>\n );\n }\n\n return null;\n }\n}\n\nexport default PrepareChallenge3DS2;\n"],"names":["PrepareChallenge3DS2","Component","componentDidMount","isErrorObject","this","state","challengeData","process","_this_props__environmentUrls_api","_this_props__environmentUrls","shouldAllowHttpDomains","props","environment","_environmentUrls","api","includes","acsURL","isValidHttpUrl","setError","errorInfo","Analytics3DS2Errors","TOKEN_IS_MISSING_ACSURL","i18n","get","errorCodeObject","type","THREEDS2_ERROR","code","errorType","ANALYTICS_ERROR_TYPE","apiError","message","THREEDS2_CHALLENGE_ERROR","onSubmitAnalytics","console","debug","acsTransID","messageVersion","threeDSServerTransID","cReqData","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","errorCode","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","setStatusComplete","resultObj","data","isMDFlow","createOldChallengeResolveData","createChallengeResolveData","dataKey","transStatus","paymentData","analyticsObject","finalResObject","errorTypeAndCode","THREEDS2_TIMEOUT","NO_TRANSSTATUS","network","_object_spread","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","CHALLENGE_COMPLETED","onComplete","errorInfoObj","isFatal","onError","AdyenCheckoutError","ERROR","cause","errorObj","render","_","getImage","useImage","h","DoChallenge3DS2","onCompleteChallenge","challenge","hasOwnProperty","length","errorDescription","values","CHALLENGE_RESOLVED_WITHOUT_RESULT_PROP","onErrorChallenge","timeoutObject","THREEDS2_CHALLENGE","onActionHandled","onFormSubmit","div","className","Img","src","imageFolder","alt","constructor","super","_define_property","msg","CHALLENGE_DATA_SENT","token","prepareChallengeData","size","challengeWindowSize","success","defaultProps"],"mappings":"spDAwBA,MAAMA,UAA6BC,EAoC/BC,iBAAAA,GAGI,IAF0BC,EAAcC,KAAKC,MAAMC,eAE7B,CAG6BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAX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F,gBAC5BC,aAAc7F,KAAK6F,gBAKL,UAAtB7F,KAAKC,MAAMqC,OAEP0C,EAACc,MAAAA,CAAIC,UAAU,4CACXf,EAACgB,EAAAA,CACGD,UAAU,mEACVE,IAAKnB,EAAS,CACVoB,YAAa,eADZpB,CAEF,SACHqB,IAAK,KAETnB,EAACc,MAAAA,CAAIC,UAAU,gCACV/F,KAAKC,MAAMc,UAAYf,KAAKC,MAAMc,UAAYf,KAAKO,MAAMW,KAAKC,IAAI,2BAM5E,IACX,CAnVAiF,WAAAA,CAAY7F,GAGR,GAFA8F,MAAM9F,GAoBV+F,EAAOT,KAAAA,gBAAgBU,IACnBvG,KAAKO,MAAMsB,kBAAkB,CACzBR,KAAM0C,EACNpC,QAAS4E,EACTtC,QAASC,EAAoBsC,qBACjC,IAvBIxG,KAAKO,MAAMkG,MAAO,CAClB,MAAMvG,EAA6CwG,EAAqB,CACpED,MAAOzG,KAAKO,MAAMkG,MAClBE,KAAM3G,KAAKO,MAAMqG,qBAAuB5G,KAAKO,MAAMoG,OAGvD3G,KAAKC,MAAQ,CACTqC,OAAQ,OACRpC,cAAeA,QAInBF,KAAKC,MAAQ,CAAEC,cAAe,CAAE2G,SAAS,EAAOrE,MAAOG,IAEvDb,QAAQC,MAAM,GAAGH,MAA6Be,IAEtD,EAzBA2D,EADE1G,EACYkH,eAAe,CACzB1C,WAAY,OACZG,QAAS,OACTtB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"DoFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: any;\n public static defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise() {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then(resolveObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch(rejectObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAUA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,UAAWN,KAA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DS2/components/DeviceFingerprint/DoFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Iframe from '../../../internal/IFrame';\nimport Spinner from '../../../internal/Spinner';\nimport ThreeDS2Form from '../Form';\nimport promiseTimeout from '../../../../utils/promiseTimeout';\nimport getProcessMessageHandler from '../../../../utils/get-process-message-handler';\nimport { THREEDS_METHOD_TIMEOUT, FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT, THREEDS2_NUM } from '../../constants';\nimport { encodeBase64URL } from '../utils';\nimport { DoFingerprint3DS2Props, DoFingerprint3DS2State } from './types';\n\nconst iframeName = 'threeDSMethodIframe';\n\n/**\n * Create and Base64URL encode a JSON object containing the serverTransactionID & threeDSMethodNotificationURL.\n * This Base64URL string will be added to the <form> in the ThreeDS2Form component.\n * The ThreeDS2Form component will submit the <form> when it mounts, using the ThreeDS2Iframe as the <form> target.\n * getProcessMessageHandler will listen for the postMessage response from the notificationURL and will settle the\n * promise accordingly causing this component to call the appropriate callback.\n * The callbacks exist in the parent component: ThreeDS2DeviceFingerprint where they ultimately call the onComplete\n * function passed as a prop when checkout.create('threeDS2DeviceFingerprint') is called.\n */\nclass DoFingerprint3DS2 extends Component<DoFingerprint3DS2Props, DoFingerprint3DS2State> {\n private processMessageHandler;\n private fingerPrintPromise: any;\n public static defaultProps = {\n showSpinner: true\n };\n\n constructor(props) {\n super(props);\n\n /**\n * Create and Base64URL encode a JSON object\n */\n const { threeDSServerTransID, threeDSMethodNotificationURL } = this.props;\n\n const jsonStr = JSON.stringify({\n threeDSServerTransID,\n threeDSMethodNotificationURL\n });\n const base64URLencodedData = encodeBase64URL(jsonStr);\n this.state = { base64URLencodedData };\n }\n\n get3DS2MethodPromise() {\n return new Promise((resolve, reject) => {\n /**\n * Listen for postMessage responses from the notification url\n */\n this.processMessageHandler = getProcessMessageHandler(this.props.postMessageDomain, resolve, reject, 'fingerPrintResult');\n\n window.addEventListener('message', this.processMessageHandler);\n });\n }\n\n componentDidMount() {\n // Check 3DS2 Device fingerprint\n this.fingerPrintPromise = promiseTimeout(THREEDS_METHOD_TIMEOUT, this.get3DS2MethodPromise(), FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT);\n this.fingerPrintPromise.promise\n .then(resolveObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onCompleteFingerprint(resolveObject);\n })\n .catch(rejectObject => {\n window.removeEventListener('message', this.processMessageHandler);\n this.props.onErrorFingerprint(rejectObject);\n });\n }\n\n componentWillUnmount() {\n if (this.fingerPrintPromise) this.fingerPrintPromise.cancel();\n window.removeEventListener('message', this.processMessageHandler);\n }\n\n render({ threeDSMethodURL, onActionHandled, onFormSubmit }, { base64URLencodedData }) {\n return (\n <div className=\"adyen-checkout__3ds2-device-fingerprint\">\n {this.props.showSpinner && <Spinner />}\n <div style={{ display: 'none' }}>\n <Iframe\n name={iframeName}\n callback={() => {\n onActionHandled?.({ componentType: '3DS2Fingerprint', actionDescription: `${THREEDS2_NUM} fingerprint iframe loaded` });\n }}\n />\n <ThreeDS2Form\n name={'threeDSMethodForm'}\n action={threeDSMethodURL}\n target={iframeName}\n inputName={'threeDSMethodData'}\n inputValue={base64URLencodedData}\n onFormSubmit={onFormSubmit}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default DoFingerprint3DS2;\n"],"names":["iframeName","DoFingerprint3DS2","Component","get3DS2MethodPromise","Promise","resolve","reject","this","processMessageHandler","getProcessMessageHandler","props","postMessageDomain","window","addEventListener","componentDidMount","fingerPrintPromise","promiseTimeout","THREEDS_METHOD_TIMEOUT","FAILED_METHOD_STATUS_RESOLVE_OBJECT_TIMEOUT","promise","then","resolveObject","removeEventListener","onCompleteFingerprint","catch","rejectObject","onErrorFingerprint","componentWillUnmount","cancel","render","threeDSMethodURL","onActionHandled","onFormSubmit","base64URLencodedData","h","div","className","showSpinner","Spinner","style","display","Iframe","name","callback","componentType","actionDescription","THREEDS2_NUM","ThreeDS2Form","action","target","inputName","inputValue","constructor","super","_define_property","threeDSServerTransID","threeDSMethodNotificationURL","jsonStr","JSON","stringify","encodeBase64URL","state","defaultProps"],"mappings":"+nBAUA,MAAMA,EAAa,sBAWnB,MAAMC,UAA0BC,EAuB5BC,oBAAAA,GACI,OAAO,IAAIC,SAAQ,CAACC,EAASC,KAIzBC,KAAKC,sBAAwBC,EAAyBF,KAAKG,MAAMC,kBAAmBN,EAASC,EAAQ,qBAErGM,OAAOC,iBAAiB,UAAWN,KAAKC,sBAAqB,GAErE,CAEAM,iBAAAA,GAEIP,KAAKQ,mBAAqBC,EAAeC,EAAwBV,KAAKJ,uBAAwBe,GAC9FX,KAAKQ,mBAAmBI,QACnBC,MAAKC,IACFT,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMa,sBAAsBF,EAAAA,IAEpCG,OAAMC,IACHb,OAAOU,oBAAoB,UAAWf,KAAKC,uBAC3CD,KAAKG,MAAMgB,mBAAmBD,EAAAA,GAE1C,CAEAE,oBAAAA,GACQpB,KAAKQ,oBAAoBR,KAAKQ,mBAAmBa,SACrDhB,OAAOU,oBAAoB,UAAWf,KAAKC,sBAC/C,CAEAqB,MAAAA,EAAOC,iBAAEA,EAAgBC,gBAAEA,EAAeC,aAAEA,IAAgBC,qBAAEA,IAC1D,OACIC,EAACC,MAAAA,CAAIC,UAAU,2CACV7B,KAAKG,MAAM2B,aAAeH,EAACI,QAC5BJ,EAACC,MAAAA,CAAII,MAAO,CAAEC,QAAS,SACnBN,EAACO,EAAAA,CACGC,KAAM1C,EACN2C,SAAU,KACNZ,SAAAA,EAAkB,CAAEa,cAAe,kBAAmBC,kBAAmB,GAAGC,+BAAyC,IAG7HZ,EAACa,EAAAA,CACGL,KAAM,oBACNM,OAAQlB,EACRmB,OAAQjD,EACRkD,UAAW,oBACXC,WAAYlB,EACZD,aAAcA,KAKlC,CApEAoB,WAAAA,CAAY1C,GACR2C,MAAM3C,GAPV4C,EAAQ9C,KAAAA,6BAAR,GACA8C,EAAA/C,KAAQQ,0BAAR,GAWI,MAAMwC,qBAAEA,EAAoBC,6BAAEA,GAAiCjD,KAAKG,MAE9D+C,EAAUC,KAAKC,UAAU,CAC3BJ,uBACAC,iCAEEvB,EAAuB2B,EAAgBH,GAC7ClD,KAAKsD,MAAQ,CAAE5B,uBACnB,EAlBAqB,EAHErD,EAGY6D,eAAe,CACzBzB,aAAa"}
@@ -1,2 +1,2 @@
1
- import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as n,prepareFingerPrintData as i}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as c,TIMEOUT as l,THREEDS2_ERROR as d,THREEDS2_FULL as m,THREEDS2_NUM as u,THREEDS2_FINGERPRINT as h}from"../../constants.js";import{Analytics3DS2Errors as S,ANALYTICS_NETWORK_ERROR as g,ANALYTICS_API_ERROR as D,Analytics3DS2Events as f}from"../../../../core/Analytics/constants.js";function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function O(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){b(e,t,r[t])}))}return e}function y(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}class P extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){var e,t;const r="test"===this.props.environment&&(null===(t=this.props._environmentUrls)||void 0===t||null===(e=t.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{threeDSMethodURL:o,threeDSMethodNotificationURL:s,postMessageDomain:n,threeDSServerTransID:i}=this.state.fingerPrintData;if(!a(o,r))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:S.TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const c=a(s,r),l=a(n,r),d=null==i?void 0:i.length;if(!c||!l||!d)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:S.TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.indexOf(c)>-1?S.ACTION_IS_MISSING_TOKEN:S.TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},(()=>{const r=(this.props.isMDFlow?s:n)(this.props.dataKey,e,this.props.paymentData);let o;const i=t||e;if(i.errorCode){const e={code:i.errorCode===l?S.THREEDS2_TIMEOUT:i.errorCode,errorType:i.errorCode===l?g:D};o=O({type:d,message:i.message},e),this.props.onSubmitAnalytics(o)}let a;switch(null==e?void 0:e.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o={type:m,message:`${u} fingerprinting has completed`,subtype:f.FINGERPRINT_COMPLETED,result:a},this.props.onSubmitAnalytics(o),this.props.onComplete(r)}))}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,y(O({onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${h}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):null}constructor(e){super(e),b(this,"onFormSubmit",(e=>{this.props.onSubmitAnalytics({type:m,message:e,subtype:f.FINGERPRINT_DATA_SENT})}));const{token:t,notificationURL:r}=this.props;if(t){const e=i({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:c}},console.debug(`${p}: ${c}`)}}b(P,"type","scheme"),b(P,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{P as default};
1
+ import{Component as e,createElement as t}from"../../../../external/preact/dist/preact.js";import r from"./DoFingerprint3DS2.js";import{isErrorObject as o,createOldFingerprintResolveData as s,createFingerprintResolveData as n,prepareFingerPrintData as i}from"../utils.js";import{isValidHttpUrl as a}from"../../../../utils/isValidURL.js";import{THREEDS2_FINGERPRINT_ERROR as p,MISSING_TOKEN_IN_ACTION_MSG as c,TIMEOUT as l,THREEDS2_ERROR as d,THREEDS2_FULL as m,THREEDS2_NUM as u,THREEDS2_FINGERPRINT as h}from"../../constants.js";import{Analytics3DS2Errors as S,ANALYTICS_ERROR_TYPE as g,Analytics3DS2Events as D}from"../../../../core/Analytics/constants.js";function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function b(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){f(e,t,r[t])}))}return e}function O(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}class y extends e{componentDidMount(){if(!o(this.state.fingerPrintData)){var e,t;const r="test"===this.props.environment&&(null===(t=this.props._environmentUrls)||void 0===t||null===(e=t.api)||void 0===e?void 0:e.includes("http://localhost:8080")),{threeDSMethodURL:o,threeDSMethodNotificationURL:s,postMessageDomain:n,threeDSServerTransID:i}=this.state.fingerPrintData;if(!a(o,r))return this.setStatusComplete({threeDSCompInd:"U"},{errorCode:S.TOKEN_IS_MISSING_THREEDSMETHODURL,message:`${p}: Decoded token is missing a valid threeDSMethodURL property`}),void console.debug("### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL");const c=a(s,r),l=a(n,r),d=null==i?void 0:i.length;if(!c||!l||!d)return this.setStatusComplete({threeDSCompInd:"N"},{errorCode:S.TOKEN_IS_MISSING_OTHER_PROPS,message:`${p}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`}),void console.debug("### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)");this.setState({status:"retrievingFingerPrint"})}else{const e=this.state.fingerPrintData.error,t=e.indexOf(c)>-1?S.ACTION_IS_MISSING_TOKEN:S.TOKEN_DECODE_OR_PARSING_FAILED;this.setStatusComplete({threeDSCompInd:"N"},{errorCode:t,message:`${p}: ${e}`}),console.debug("### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed")}}setStatusComplete(e,t=null){this.setState({status:"complete"},(()=>{const r=(this.props.isMDFlow?s:n)(this.props.dataKey,e,this.props.paymentData);let o;const i=t||e;if(i.errorCode){const e={code:i.errorCode===l?S.THREEDS2_TIMEOUT:i.errorCode,errorType:i.errorCode===l?g.network:g.apiError};o=b({type:d,message:i.message},e),this.props.onSubmitAnalytics(o)}let a;switch(null==e?void 0:e.threeDSCompInd){case"Y":a="success";break;case"N":a=t?t.errorCode===l?l:"failedInternal":"failed";break;case"U":a="noThreeDSMethodURL"}o={type:m,message:`${u} fingerprinting has completed`,subtype:D.FINGERPRINT_COMPLETED,result:a},this.props.onSubmitAnalytics(o),this.props.onComplete(r)}))}render({showSpinner:e},{status:o,fingerPrintData:s}){return"retrievingFingerPrint"===o?t(r,O(b({onCompleteFingerprint:e=>{this.setStatusComplete(e.result)},onErrorFingerprint:e=>{const t={errorCode:e.errorCode,message:`${h}: ${e.errorCode}`};this.setStatusComplete(e.result,t)},showSpinner:e},s),{onActionHandled:this.props.onActionHandled,onFormSubmit:this.onFormSubmit})):null}constructor(e){super(e),f(this,"onFormSubmit",(e=>{this.props.onSubmitAnalytics({type:m,message:e,subtype:D.FINGERPRINT_DATA_SENT})}));const{token:t,notificationURL:r}=this.props;if(t){const e=i({token:t,notificationURL:r});this.state={status:"init",fingerPrintData:e}}else this.state={fingerPrintData:{success:!1,error:c}},console.debug(`${p}: ${c}`)}}f(y,"type","scheme"),f(y,"defaultProps",{onComplete:()=>{},onError:()=>{},paymentData:"",showSpinner:!0,isMDFlow:!1});export{y as default};
2
2
  //# sourceMappingURL=PrepareFingerprint3DS2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_API_ERROR, ANALYTICS_NETWORK_ERROR, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_NETWORK_ERROR : ANALYTICS_API_ERROR\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 analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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 analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_NETWORK_ERROR","ANALYTICS_API_ERROR","_object_spread","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps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oD,kBAAkB,CACzBF,KAAMI,EACNvC,QAAS2D,EACTlB,QAASC,EAAoBkB,uBACjC,IAtBA,MAAMC,MAAEA,EAAKC,gBAAEA,GAAoBpF,KAAKO,MAExC,GAAI4E,EAAO,CACP,MAAMjF,EAAiDmF,EAAuB,CAAEF,QAAOC,oBAEvFpF,KAAKC,MAAQ,CACT+B,OAAQ,OACR9B,gBAAiBA,QAIrBF,KAAKC,MAAQ,CAAEC,gBAAiB,CAAEoF,SAAS,EAAOpD,MAAOE,IAEzDZ,QAAQC,MAAM,GAAGF,MAA+Ba,IAExD,EA5BA4C,EADEpF,EACY6D,OAAO,UAErBuB,EAHEpF,EAGY2F,eAAe,CACzBrB,WAAY,OACZsB,QAAS,OACT1C,YAAa,GACbsB,aAAa,EACb1B,UAAU"}
1
+ {"version":3,"file":"PrepareFingerprint3DS2.js","sources":["../../../../../../src/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport DoFingerprint3DS2 from './DoFingerprint3DS2';\nimport { createFingerprintResolveData, createOldFingerprintResolveData, isErrorObject, prepareFingerPrintData } from '../utils';\nimport { PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State } from './types';\nimport { FingerPrintData, ResultObject, ErrorCodeObject } from '../../types';\nimport { ErrorObject } from '../../../../core/Errors/types';\nimport { SendAnalyticsObject } from '../../../../core/Analytics/types';\nimport { isValidHttpUrl } from '../../../../utils/isValidURL';\nimport {\n THREEDS2_FULL,\n THREEDS2_FINGERPRINT,\n THREEDS2_FINGERPRINT_ERROR,\n THREEDS2_NUM,\n MISSING_TOKEN_IN_ACTION_MSG,\n THREEDS2_ERROR,\n TIMEOUT\n} from '../../constants';\nimport { ANALYTICS_ERROR_TYPE, Analytics3DS2Errors, Analytics3DS2Events } from '../../../../core/Analytics/constants';\n\nclass PrepareFingerprint3DS2 extends Component<PrepareFingerprint3DS2Props, PrepareFingerprint3DS2State> {\n public static type = 'scheme';\n\n public static defaultProps = {\n onComplete: () => {},\n onError: () => {},\n paymentData: '',\n showSpinner: true,\n isMDFlow: false\n };\n\n constructor(props) {\n super(props);\n\n const { token, notificationURL } = this.props; // See comments on prepareFingerPrintData regarding notificationURL\n\n if (token) {\n const fingerPrintData: FingerPrintData | ErrorObject = prepareFingerPrintData({ token, notificationURL });\n\n this.state = {\n status: 'init',\n fingerPrintData: fingerPrintData as FingerPrintData\n };\n } else {\n // Will be picked up in componentDidMount\n this.state = { fingerPrintData: { success: false, error: MISSING_TOKEN_IN_ACTION_MSG } };\n\n console.debug(`${THREEDS2_FINGERPRINT_ERROR}: ${MISSING_TOKEN_IN_ACTION_MSG}`);\n }\n }\n\n public onFormSubmit = (msg: string) => {\n this.props.onSubmitAnalytics({\n type: THREEDS2_FULL,\n message: msg,\n subtype: Analytics3DS2Events.FINGERPRINT_DATA_SENT\n });\n };\n\n componentDidMount() {\n const hasFingerPrintData = !isErrorObject(this.state.fingerPrintData);\n\n if (hasFingerPrintData) {\n const shouldAllowHttpDomains =\n /** Allow http urls if in development and testing against localhost:8080 */\n (process.env.NODE_ENV === 'development' && process.env.__CLIENT_ENV__?.indexOf('localhost:8080') > -1) ||\n /**\n * Allows the checkoutshopper demo on localhost:8080 to work -\n * requires a configuration in localhost of environment: 'test', _environmentUrls: {api: 'http://localhost:8080/'}\n */\n (this.props.environment === 'test' && this.props._environmentUrls?.api?.includes('http://localhost:8080'));\n\n /**\n * Check the structure of the created fingerPrintData\n */\n const { threeDSMethodURL, threeDSMethodNotificationURL, postMessageDomain, threeDSServerTransID } = this.state\n .fingerPrintData as FingerPrintData;\n\n const hasValid3DSMethodURL = isValidHttpUrl(threeDSMethodURL, shouldAllowHttpDomains);\n\n // Only render component if we have a threeDSMethodURL. Otherwise, exit with threeDSCompInd: 'U'\n if (!hasValid3DSMethodURL) {\n this.setStatusComplete(\n { threeDSCompInd: 'U' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_THREEDSMETHODURL,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing a valid threeDSMethodURL property`\n }\n );\n\n /**\n * NOTE: we can now use this.props.isMDFlow to decide if we want to send any of these errors to the onError handler\n * - this is problematic in the regular flow since merchants tend to treat any calls to their onError handler as 'fatal',\n * but in the MDFlow we control what the onError handler does.\n */\n // if (this.props.isMDFlow) {}\n\n console.debug('### PrepareFingerprint3DS2::exiting:: no valid threeDSMethodURL');\n return;\n }\n\n const hasValid3DSMethodNotificationURL = isValidHttpUrl(threeDSMethodNotificationURL, shouldAllowHttpDomains);\n const hasValidPostMessageDomain = isValidHttpUrl(postMessageDomain, shouldAllowHttpDomains);\n const hasTransServerID = threeDSServerTransID?.length;\n\n if (!hasValid3DSMethodNotificationURL || !hasValidPostMessageDomain || !hasTransServerID) {\n /**\n * NOTE: EMVCo_3DS_CoreSpec_v2.3.1_20220831.pdf states that we should return: threeDSCompInd: 'N'\n * when the fingerprinting process \"Did not run or did not successfully complete\"\n */\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode: Analytics3DS2Errors.TOKEN_IS_MISSING_OTHER_PROPS,\n message: `${THREEDS2_FINGERPRINT_ERROR}: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)`\n }\n );\n\n console.debug(\n '### PrepareFingerprint3DS2::exiting:: Decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)'\n );\n\n return;\n }\n\n // Proceed to allow component to render\n this.setState({ status: 'retrievingFingerPrint' });\n //\n } else {\n // Only render component if we have fingerPrintData. Otherwise, complete with threeDSCompInd: 'N'\n\n const errorMsg: string = (this.state.fingerPrintData as ErrorObject).error;\n\n const errorCode =\n errorMsg.indexOf(MISSING_TOKEN_IN_ACTION_MSG) > -1\n ? Analytics3DS2Errors.ACTION_IS_MISSING_TOKEN\n : Analytics3DS2Errors.TOKEN_DECODE_OR_PARSING_FAILED;\n\n this.setStatusComplete(\n { threeDSCompInd: 'N' },\n {\n errorCode,\n message: `${THREEDS2_FINGERPRINT_ERROR}: ${errorMsg}` // can be: 'Missing \"token\" property from threeDS2 action', 'not base64', 'malformed URI sequence' or 'Could not JSON parse token'\n }\n );\n\n console.debug('### PrepareFingerprint3DS2:: token does not exist or could not be base64 decoded &/or JSON.parsed');\n }\n }\n\n setStatusComplete(resultObj: ResultObject, errorCodeObject: ErrorCodeObject = null) {\n this.setState({ status: 'complete' }, () => {\n /**\n * Create the data in the way that the /details endpoint expects.\n * This is different for the flow triggered by the threeds2InMDFlow process than for the new, v67, 'threeDS2' action\n */\n const resolveDataFunction = this.props.isMDFlow ? createOldFingerprintResolveData : createFingerprintResolveData;\n const data = resolveDataFunction(this.props.dataKey, resultObj, this.props.paymentData);\n\n let analyticsObject: SendAnalyticsObject;\n\n /** Are we in an error scenario? If so, submit analytics about it */\n const finalResObject = errorCodeObject ? errorCodeObject : resultObj;\n if (finalResObject.errorCode) {\n const errorTypeAndCode = {\n code: finalResObject.errorCode === TIMEOUT ? Analytics3DS2Errors.THREEDS2_TIMEOUT : finalResObject.errorCode,\n errorType: finalResObject.errorCode === TIMEOUT ? ANALYTICS_ERROR_TYPE.network : ANALYTICS_ERROR_TYPE.apiError\n };\n\n /**\n * Timeout or data parsing problems:\n *\n * (threeDSCompInd:\"U\"):\n * - Decoded token is missing a valid threeDSMethodURL property,\n * or, (threeDSCompInd:\"N\"):\n * - Fingerprint process has timed out,\n * also, (threeDSCompInd:\"N\"):\n * - Missing \"token\" property from threeDS2 action\n * - or, decoded token is missing one or more of the following properties (threeDSMethodNotificationURL | postMessageDomain | threeDSServerTransID)\n * - or, token could not be base64 decoded &/or JSON.parsed\n */\n analyticsObject = {\n type: THREEDS2_ERROR,\n message: (finalResObject as ErrorCodeObject).message,\n ...errorTypeAndCode\n };\n\n // Send error to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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 analyticsObject = {\n type: THREEDS2_FULL,\n message: `${THREEDS2_NUM} fingerprinting has completed`,\n subtype: Analytics3DS2Events.FINGERPRINT_COMPLETED,\n result\n };\n\n // Send log to analytics endpoint\n this.props.onSubmitAnalytics(analyticsObject);\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","Analytics3DS2Errors","TOKEN_IS_MISSING_THREEDSMETHODURL","message","THREEDS2_FINGERPRINT_ERROR","console","debug","hasValid3DSMethodNotificationURL","hasValidPostMessageDomain","hasTransServerID","length","TOKEN_IS_MISSING_OTHER_PROPS","setState","status","errorMsg","error","indexOf","MISSING_TOKEN_IN_ACTION_MSG","ACTION_IS_MISSING_TOKEN","TOKEN_DECODE_OR_PARSING_FAILED","resultObj","errorCodeObject","data","isMDFlow","createOldFingerprintResolveData","createFingerprintResolveData","dataKey","paymentData","analyticsObject","finalResObject","errorTypeAndCode","code","TIMEOUT","THREEDS2_TIMEOUT","errorType","ANALYTICS_ERROR_TYPE","network","apiError","_object_spread","type","THREEDS2_ERROR","onSubmitAnalytics","result","THREEDS2_FULL","THREEDS2_NUM","subtype","Analytics3DS2Events","FINGERPRINT_COMPLETED","onComplete","render","showSpinner","h","DoFingerprint3DS2","onCompleteFingerprint","fingerprint","onErrorFingerprint","timeoutObject","THREEDS2_FINGERPRINT","onActionHandled","onFormSubmit","constructor","super","_define_property","msg","FINGERPRINT_DATA_SENT","token","notificationURL","prepareFingerPrintData","success","defaultProps","onError"],"mappings":"i8CAmBA,MAAMA,UAA+BC,EAuCjCC,iBAAAA,GAGI,IAF4BC,EAAcC,KAAKC,MAAMC,iBAE7B,CAG2BC,IAKLC,EAAAC,EAP1C,MAAMC,EAO0B,SAA3BN,KAAKO,MAAMC,cAAqD,QAA3BH,EAAAL,KAAKO,MAAME,4BAAXJ,GAAA,QAAAD,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,CA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BrB,WAAY,OACZsB,QAAS,OACT3C,YAAa,GACbuB,aAAa,EACb3B,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDS2Form.js","sources":["../../../../../../src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\ninterface ThreeDS2FormProps {\n name: string;\n action: string;\n target: string;\n inputName: string;\n inputValue: string;\n onFormSubmit: (msg: string) => void;\n}\n\nexport default class ThreeDS2Form extends Component<ThreeDS2FormProps> {\n protected formEl;\n\n componentDidMount() {\n this.formEl.submit();\n this.props.onFormSubmit(`${this.props.inputName} sent`);\n }\n\n render({ name, action, target, inputName, inputValue }) {\n return (\n <form\n ref={ref => {\n this.formEl = ref;\n }}\n method=\"POST\"\n className={classNames(['adyen-checkout__threeds2__form', `adyen-checkout__threeds2__form--${name}`])}\n name={name}\n action={action}\n target={target}\n style={{ display: 'none' }}\n >\n <input name={inputName} value={inputValue} />\n </form>\n );\n }\n}\n"],"names":["ThreeDS2Form","Component","componentDidMount","this","formEl","submit","props","onFormSubmit","inputName","render","name","action","target","inputValue","h","form","ref","method","className","classNames","style","display","input","value"],"mappings":"kJAYe,MAAMA,UAAqBC,EAGtCC,iBAAAA,GACIC,KAAKC,OAAOC,SACZF,KAAKG,MAAMC,aAAa,GAAGJ,KAAKG,MAAME,iBAC1C,CAEAC,MAAAA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,OAAEA,EAAMJ,UAAEA,EAASK,WAAEA,IACtC,OACIC,EAACC,OAAAA,CACGC,IAAKA,IACDb,KAAKC,OAASY,CAAAA,EAElBC,OAAO,OACPC,UAAWC,EAAW,CAAC,iCAAkC,mCAAmCT,MAC5FA,KAAMA,EACNC,OAAQA,EACRC,OAAQA,EACRQ,MAAO,CAAEC,QAAS,SAElBP,EAACQ,QAAAA,CAAMZ,KAAMF,EAAWe,MAAOV,IAG3C,gDAvBA,KAAUT,cAAVD"}
1
+ {"version":3,"file":"ThreeDS2Form.js","sources":["../../../../../../src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport classNames from 'classnames';\n\ninterface ThreeDS2FormProps {\n name: string;\n action: string;\n target: string;\n inputName: string;\n inputValue: string;\n onFormSubmit: (msg: string) => void;\n}\n\nexport default class ThreeDS2Form extends Component<ThreeDS2FormProps> {\n protected formEl;\n\n componentDidMount() {\n this.formEl.submit();\n this.props.onFormSubmit(`${this.props.inputName} sent`);\n }\n\n render({ name, action, target, inputName, inputValue }) {\n return (\n <form\n ref={ref => {\n this.formEl = ref;\n }}\n method=\"POST\"\n className={classNames(['adyen-checkout__threeds2__form', `adyen-checkout__threeds2__form--${name}`])}\n name={name}\n action={action}\n target={target}\n style={{ display: 'none' }}\n >\n <input name={inputName} value={inputValue} />\n </form>\n );\n }\n}\n"],"names":["ThreeDS2Form","Component","componentDidMount","this","formEl","submit","props","onFormSubmit","inputName","render","name","action","target","inputValue","h","form","ref","method","className","classNames","style","display","input","value","super","args"],"mappings":"kJAYe,MAAMA,UAAqBC,EAGtCC,iBAAAA,GACIC,KAAKC,OAAOC,SACZF,KAAKG,MAAMC,aAAa,GAAGJ,KAAKG,MAAME,iBAC1C,CAEAC,MAAAA,EAAOC,KAAEA,EAAIC,OAAEA,EAAMC,OAAEA,EAAMJ,UAAEA,EAASK,WAAEA,IACtC,OACIC,EAACC,OAAAA,CACGC,IAAKA,IACDb,KAAKC,OAASY,CAAAA,EAElBC,OAAO,OACPC,UAAWC,EAAW,CAAC,iCAAkC,mCAAmCT,MAC5FA,KAAMA,EACNC,OAAQA,EACRC,OAAQA,EACRQ,MAAO,CAAEC,QAAS,SAElBP,EAACQ,QAAAA,CAAMZ,KAAMF,EAAWe,MAAOV,IAG3C,6BAvBAW,SAAAC,UAAA,KAAUrB,cAAVD"}
@@ -1 +1 @@
1
- {"version":3,"file":"Twint.js","sources":["../../../../src/components/Twint/Twint.tsx"],"sourcesContent":["import RedirectElement from '../Redirect';\nimport PayButton, { payAmountLabel } from '../internal/PayButton';\nimport { h } from 'preact';\nimport { TxVariants } from '../tx-variants';\n\nclass TwintElement extends RedirectElement {\n public static type = TxVariants.twint;\n\n public static defaultProps = {\n type: TwintElement.type,\n name: 'Twint'\n };\n /**\n * Get the element displayable name\n */\n get displayName(): string {\n const { i18n, name, isStoredPaymentMethod } = this.props;\n return isStoredPaymentMethod ? `${name} ${i18n.get('twint.saved')}` : name || this.constructor['type'];\n }\n\n public payButtonLabel() {\n const { i18n, amount, isStoredPaymentMethod, name } = this.props;\n if (isStoredPaymentMethod) return payAmountLabel(i18n, amount);\n return `${i18n.get('continueTo')} ${name}`;\n }\n\n /**\n * Overrides RedirectElement default payButton behaviour to use label\n * @param props - props\n */\n public payButton = props => {\n return <PayButton {...props} label={this.payButtonLabel()} onClick={this.submit} />;\n };\n}\n\nexport default TwintElement;\n"],"names":["TwintElement","RedirectElement","displayName","i18n","name","isStoredPaymentMethod","this","props","get","constructor","payButtonLabel","amount","payAmountLabel","_define_property","payButton","h","PayButton","label","onClick","submit","type","TxVariants","twint","defaultProps"],"mappings":"ovBAKA,MAAMA,UAAqBC,EAUvB,eAAIC,GACA,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,sBAAEA,GAA0BC,KAAKC,MACnD,OAAOF,EAAwB,GAAGD,KAAQD,EAAKK,IAAI,iBAAmBJ,GAAQE,KAAKG,YAAmB,IAC1G,CAEOC,cAAAA,GACH,MAAMP,KAAEA,EAAIQ,OAAEA,EAAMN,sBAAEA,EAAqBD,KAAEA,GAASE,KAAKC,MAC3D,OAAIF,EAA8BO,EAAeT,EAAMQ,GAChD,GAAGR,EAAKK,IAAI,iBAAiBJ,GACxC,+BAMAS,EAAAP,KAAOQ,aAAYP,GACRQ,EAACC,EAAcT,wUAAAA,CAAAA,CAAAA,EAAAA,GAAAA,CAAOU,MAAOX,KAAKI,iBAAkBQ,QAASZ,KAAKa,aAzB7EN,EADEb,EACYoB,OAAOC,EAAWC,OAEhCT,EAHEb,EAGYuB,eAAe,CACzBH,KAAMpB,EAAaoB,KACnBhB,KAAM"}
1
+ {"version":3,"file":"Twint.js","sources":["../../../../src/components/Twint/Twint.tsx"],"sourcesContent":["import RedirectElement from '../Redirect';\nimport PayButton, { payAmountLabel } from '../internal/PayButton';\nimport { h } from 'preact';\nimport { TxVariants } from '../tx-variants';\n\nclass TwintElement extends RedirectElement {\n public static type = TxVariants.twint;\n\n public static defaultProps = {\n type: TwintElement.type,\n name: 'Twint'\n };\n /**\n * Get the element displayable name\n */\n get displayName(): string {\n const { i18n, name, isStoredPaymentMethod } = this.props;\n return isStoredPaymentMethod ? `${name} ${i18n.get('twint.saved')}` : name || this.constructor['type'];\n }\n\n public payButtonLabel() {\n const { i18n, amount, isStoredPaymentMethod, name } = this.props;\n if (isStoredPaymentMethod) return payAmountLabel(i18n, amount);\n return `${i18n.get('continueTo')} ${name}`;\n }\n\n /**\n * Overrides RedirectElement default payButton behaviour to use label\n * @param props - props\n */\n public payButton = props => {\n return <PayButton {...props} label={this.payButtonLabel()} onClick={this.submit} />;\n };\n}\n\nexport default TwintElement;\n"],"names":["TwintElement","RedirectElement","displayName","i18n","name","isStoredPaymentMethod","this","props","get","constructor","payButtonLabel","amount","payAmountLabel","super","args","_define_property","payButton","h","PayButton","label","onClick","submit","type","TxVariants","twint","defaultProps"],"mappings":"ovBAKA,MAAMA,UAAqBC,EAUvB,eAAIC,GACA,MAAMC,KAAEA,EAAIC,KAAEA,EAAIC,sBAAEA,GAA0BC,KAAKC,MACnD,OAAOF,EAAwB,GAAGD,KAAQD,EAAKK,IAAI,iBAAmBJ,GAAQE,KAAKG,YAAmB,IAC1G,CAEOC,cAAAA,GACH,MAAMP,KAAEA,EAAIQ,OAAEA,EAAMN,sBAAEA,EAAqBD,KAAEA,GAASE,KAAKC,MAC3D,OAAIF,EAA8BO,EAAeT,EAAMQ,GAChD,GAAGR,EAAKK,IAAI,iBAAiBJ,GACxC,mBAEAS,SAAAC,GAIAC,EAAAT,KAAOU,aAAYT,GACRU,EAACC,EAAcX,wUAAAA,CAAAA,CAAAA,EAAAA,GAAAA,CAAOY,MAAOb,KAAKI,iBAAkBU,QAASd,KAAKe,aAzB7EN,EADEf,EACYsB,OAAOC,EAAWC,OAEhCT,EAHEf,EAGYyB,eAAe,CACzBH,KAAMtB,EAAasB,KACnBlB,KAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAAlBL,EAAAA,aAAAA,EAAAA,EAAOK,uBAAPL,EAAAA,EAAsB,SAEnCM,KAAM,KAId,MAAMC,GAAgBP,QAAA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,IAGjG,CA5HAkC,WAAAA,CAAYC,EAAiBzE,GACzBI,MAAMqE,EAAUzE,GAHpB0E,EAAAlD,KAAQU,oBAAR,GA2DAwC,EAAAlD,KAAQuC,gBAAgBY,IACpBnD,KAAKU,aAAeyC,CAAAA,IAxDpBnD,KAAKU,aAAeV,KAAKxB,MAAMK,WACnC,EARAqE,EADE7E,EACYmB,OAAOC,EAAW2D,KAChCF,EAFE7E,EAEYgF,aAAa,CAAC5D,EAAW2D,IAAK3D,EAAWkB,OAAQlB,EAAWC,YAAaD,EAAWI"}
1
+ {"version":3,"file":"UPI.js","sources":["../../../../src/components/UPI/UPI.tsx"],"sourcesContent":["import { h, RefObject } from 'preact';\nimport UIElement from '../internal/UIElement/UIElement';\nimport UPIComponent from './components/UPIComponent';\nimport { CoreProvider } from '../../core/Context/CoreProvider';\nimport Await from '../internal/Await';\nimport QRLoader from '../internal/QRLoader';\nimport { App, UPIConfiguration, UpiMode, UpiPaymentData, UpiType } from './types';\nimport SRPanelProvider from '../../core/Errors/SRPanelProvider';\nimport { TxVariants } from '../tx-variants';\nimport isMobile from '../../utils/isMobile';\nimport type { ICore } from '../../core/types';\n\n/**\n * For mobile:\n * We should show upi_collect or upi_intent depending on if `apps` are returned in /paymentMethods response\n * The upi_qr should always be on the second tab\n *\n * For non-mobile:\n * We should never show the upi_intent (ignore `apps` in /paymentMethods response)\n * The upi_qr should be on the first tab and the upi_collect should be on second tab\n */\n\nclass UPI extends UIElement<UPIConfiguration> {\n public static type = TxVariants.upi;\n public static txVariants = [TxVariants.upi, TxVariants.upi_qr, TxVariants.upi_collect, TxVariants.upi_intent];\n\n private selectedMode: UpiMode;\n\n constructor(checkout: ICore, props: UPIConfiguration) {\n super(checkout, props);\n this.selectedMode = this.props.defaultMode;\n }\n\n formatProps(props: UPIConfiguration) {\n if (!isMobile()) {\n return {\n ...super.formatProps(props),\n defaultMode: props?.defaultMode ?? 'qrCode',\n // For large screen, ignore the apps\n apps: []\n };\n }\n\n const hasIntentApps = props.apps?.length > 0;\n const fallbackDefaultMode = hasIntentApps ? 'intent' : 'vpa';\n const allowedModes = [fallbackDefaultMode, 'qrCode'];\n const upiCollectApp: App = {\n id: 'vpa',\n name: props.i18n.get('upi.collect.dropdown.label'),\n type: TxVariants.upi_collect as UpiType\n };\n const apps = hasIntentApps ? [...props.apps.map(app => ({ ...app, type: TxVariants.upi_intent as UpiType })), upiCollectApp] : [];\n return {\n ...super.formatProps(props),\n defaultMode: allowedModes.includes(props?.defaultMode) ? props.defaultMode : fallbackDefaultMode,\n apps\n };\n }\n\n public get isValid(): boolean {\n return this.state.isValid;\n }\n\n public formatData(): UpiPaymentData {\n const { virtualPaymentAddress, app } = this.state.data || {};\n\n return {\n paymentMethod: {\n ...(this.paymentType && { type: this.paymentType }),\n ...(this.paymentType === TxVariants.upi_collect && virtualPaymentAddress && { virtualPaymentAddress }),\n ...(this.paymentType === TxVariants.upi_intent && app?.id && { appId: app.id })\n }\n };\n }\n\n get paymentType(): UpiType {\n if (this.selectedMode === 'qrCode') {\n return TxVariants.upi_qr;\n }\n if (this.selectedMode === 'vpa') {\n return TxVariants.upi_collect;\n }\n return this.state.data?.app?.type;\n }\n\n private onUpdateMode = (mode: UpiMode): void => {\n this.selectedMode = mode;\n };\n\n private renderContent(type: string, url: string, paymentMethodType: string): h.JSX.Element {\n switch (type) {\n case 'qrCode':\n return (\n <QRLoader\n ref={ref => {\n this.componentRef = ref;\n }}\n {...this.props}\n qrCodeData={this.props.qrCodeData ? encodeURIComponent(this.props.qrCodeData) : null}\n type={TxVariants.upi_qr}\n brandLogo={this.props.brandLogo || this.icon}\n onComplete={this.onComplete}\n introduction={this.props.i18n.get('upi.qrCodeWaitingMessage')}\n countdownTime={5}\n onActionHandled={this.onActionHandled}\n />\n );\n case 'await':\n return (\n <Await\n ref={ref => {\n this.componentRef = ref;\n }}\n url={url}\n type={paymentMethodType}\n showCountdownTimer\n shouldRedirectAutomatically\n countdownTime={5}\n clientKey={this.props.clientKey}\n paymentData={this.props.paymentData}\n onActionHandled={this.onActionHandled}\n onError={this.props.onError}\n messageText={this.props.i18n.get('upi.vpaWaitingMessage')}\n awaitText={this.props.i18n.get('await.waitForConfirmation')}\n onComplete={this.onComplete}\n brandLogo={this.icon}\n />\n );\n default:\n return (\n <UPIComponent\n ref={(ref: RefObject<typeof UPIComponent>) => {\n this.componentRef = ref;\n }}\n payButton={this.payButton}\n onChange={this.setState}\n onUpdateMode={this.onUpdateMode}\n apps={this.props.apps}\n defaultMode={this.props.defaultMode}\n showPayButton={this.props.showPayButton}\n />\n );\n }\n }\n\n public render(): h.JSX.Element {\n const { type, url, paymentMethodType } = this.props;\n return (\n <CoreProvider i18n={this.props.i18n} loadingContext={this.props.loadingContext} resources={this.resources}>\n <SRPanelProvider srPanel={this.props.modules.srPanel}>{this.renderContent(type, url, paymentMethodType)}</SRPanelProvider>\n </CoreProvider>\n );\n }\n}\n\nexport default UPI;\n"],"names":["UPI","UIElement","formatProps","props","isMobile","_object_spread_props","_object_spread","super","defaultMode","apps","hasIntentApps","length","fallbackDefaultMode","allowedModes","upiCollectApp","id","name","i18n","get","type","TxVariants","upi_collect","map","app","upi_intent","includes","isValid","this","state","formatData","virtualPaymentAddress","data","paymentMethod","paymentType","appId","_this_state_data_app","_this_state_data","selectedMode","upi_qr","renderContent","url","paymentMethodType","h","QRLoader","ref","componentRef","qrCodeData","encodeURIComponent","brandLogo","icon","onComplete","introduction","countdownTime","onActionHandled","Await","showCountdownTimer","shouldRedirectAutomatically","clientKey","paymentData","onError","messageText","awaitText","UPIComponent","payButton","onChange","setState","onUpdateMode","showPayButton","render","CoreProvider","loadingContext","resources","SRPanelProvider","srPanel","modules","constructor","checkout","_define_property","mode","upi","txVariants"],"mappings":"kxCAsBA,MAAMA,UAAYC,EAWdC,WAAAA,CAAYC,GAUcA,IAAAA,EANDA,EAHrB,IAAKC,IACD,OAAOC,EAAAC,EAAA,CAAA,EACAC,MAAML,YAAYC,IAAAA,CACrBK,YAA+B,QAA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,EAAC8B,EAAAA,CAAgBC,QAAS9C,KAAKxB,MAAMuE,QAAQD,SAAU9C,KAAKY,cAAcpB,EAAMqB,EAAKC,IAGjG,CA5HAkC,WAAAA,CAAYC,EAAiBzE,GACzBI,MAAMqE,EAAUzE,GAHpB0E,EAAAlD,KAAQU,oBAAR,GA2DAwC,EAAQX,KAAAA,gBAAgBY,IACpBnD,KAAKU,aAAeyC,CAAAA,IAxDpBnD,KAAKU,aAAeV,KAAKxB,MAAMK,WACnC,EARAqE,EADE7E,EACYmB,OAAOC,EAAW2D,KAChCF,EAFE7E,EAEYgF,aAAa,CAAC5D,EAAW2D,IAAK3D,EAAWkB,OAAQlB,EAAWC,YAAaD,EAAWI"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import c from"../../../../core/Services/get-dataset.js";import s from"../../FormFields/Select/Select.js";function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(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}const l=(e,t)=>{const r=e=>i(function(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){a(e,t,r[t])}))}return e}({},e),{name:e.name,selectedOptionName:e.name});return t.length?e.filter((e=>t.includes(e.id))).map(r):e.map(r)};function u(a){const{allowedCountries:i=[],classNameModifiers:u=[],errorMessage:p,onDropdownChange:m,value:f}=a,{i18n:d,loadingContext:y}=n(),[O,b]=t([]),[j,g]=t(!1),[h,w]=t(a.readOnly);return r((()=>{c("countries",y,d.locale).then((e=>{const t=l(e,i);b(t||[]),w(1===t.length||h),g(!0)})).catch((e=>{console.error(e),b([]),g(!0)}))}),[]),j?e(o,{name:"country",label:d.get("country"),errorMessage:p,classNameModifiers:u,isValid:!!f,showValidIcon:!1,i18n:d,readOnly:h&&!!f},e(s,{onChange:m,name:"country",selectedValue:f,items:O,readonly:h&&!!f})):null}export{u as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as r,useLayoutEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import c from"../../../../core/Services/get-dataset.js";import s from"../../FormFields/Select/Select.js";function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):function(e){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r.push.apply(r,t)}return r}(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})),e}const l=(e,r)=>{const t=e=>i(function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(r){a(e,r,t[r])}))}return e}({},e),{name:e.name,selectedOptionName:e.name});return r.length?e.filter((e=>r.includes(e.id))).map(t):e.map(t)};function u(a){const{allowedCountries:i=[],classNameModifiers:u=[],errorMessage:p,onDropdownChange:m,value:f,required:d}=a,{i18n:y,loadingContext:O}=n(),[b,j]=r([]),[g,h]=r(!1),[w,P]=r(a.readOnly);return t((()=>{c("countries",O,y.locale).then((e=>{const r=l(e,i);j(r||[]),P(1===r.length||w),h(!0)})).catch((e=>{console.error(e),j([]),h(!0)}))}),[]),g?e(o,{name:"country",label:y.get("country"),errorMessage:p,classNameModifiers:u,isValid:!!f,showValidIcon:!1,i18n:y,readOnly:w&&!!f},e(s,{onChange:m,name:"country",selectedValue:f,items:b,readonly:w&&!!f,required:d})):null}export{u as default};
2
2
  //# sourceMappingURL=CountryField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select onChange={onDropdownChange} name={'country'} selectedValue={value} items={countries} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["formatCountries","countries","allowedCountries","applyMapper","country","_object_spread_props","name","selectedOptionName","length","filter","includes","id","map","CountryField","props","classNameModifiers","errorMessage","onDropdownChange","value","i18n","loadingContext","useCoreContext","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"o3BAQA,MAAMA,EAAkB,CAACC,EAAoCC,KACzD,MACMC,EAAeC,GACVC,wUACAD,CAAAA,CAAAA,EAAAA,GAAAA,CACHE,KAAMF,EAAQE,KACdC,mBAAoBH,EAAQE,OAGpC,OAAOJ,EAAiBM,OAASP,EAAUQ,QARtBL,GAA8BF,EAAiBQ,SAASN,EAAQO,MAQtBC,IAAIT,GAAeF,EAAUW,IAAIT,EAAAA,EAGrF,SAASU,EAAaC,GACjC,MAAMZ,iBAAEA,EAAmB,GAAEa,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,GAAUJ,GAC5FK,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BpB,EAAWqB,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAAST,EAAMY,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaT,EAAgBD,EAAKW,QACxCC,MAAKC,IACF,MAAMC,EAAejC,EAAgBgC,EAAU9B,GAC/CoB,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAazB,QAAgBkB,GACzCD,GAAU,EAAA,IAEbS,OAAMC,IACHC,QAAQD,MAAMA,GACdb,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDa,EAACC,EAAAA,CACGhC,KAAM,UACNiC,MAAOpB,EAAKqB,IAAI,WAChBxB,aAAcA,EACdD,mBAAoBA,EACpB0B,UAAWvB,EACXwB,eAAe,EACfvB,KAAMA,EACNO,SAAUA,KAAcR,GAExBmB,EAACM,EAAAA,CAAOC,SAAU3B,EAAkBX,KAAM,UAAWuC,cAAe3B,EAAO4B,MAAO7C,EAAW8C,SAAUrB,KAAcR,KAbzG,IAgBxB"}
1
+ {"version":3,"file":"CountryField.js","sources":["../../../../../../src/components/internal/Address/components/CountryField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useLayoutEffect, useState } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { CountryFieldProps, CountryFieldItem } from '../types';\nimport Select from '../../FormFields/Select';\n\nconst formatCountries = (countries: Array<CountryFieldItem>, allowedCountries: string[]) => {\n const applyFilter = (country: CountryFieldItem) => allowedCountries.includes(country.id);\n const applyMapper = (country: CountryFieldItem) => {\n return {\n ...country,\n name: country.name,\n selectedOptionName: country.name\n };\n };\n return allowedCountries.length ? countries.filter(applyFilter).map(applyMapper) : countries.map(applyMapper);\n};\n\nexport default function CountryField(props: CountryFieldProps) {\n const { allowedCountries = [], classNameModifiers = [], errorMessage, onDropdownChange, value, required } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [countries, setCountries] = useState<CountryFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n const [readOnly, setReadOnly] = useState(props.readOnly);\n\n useLayoutEffect(() => {\n getDataset('countries', loadingContext, i18n.locale)\n .then(response => {\n const newCountries = formatCountries(response, allowedCountries);\n setCountries(newCountries || []);\n setReadOnly(newCountries.length === 1 || readOnly);\n setLoaded(true);\n })\n .catch(error => {\n console.error(error);\n setCountries([]);\n setLoaded(true);\n });\n }, []);\n\n if (!loaded) return null;\n\n return (\n <Field\n name={'country'}\n label={i18n.get('country')}\n errorMessage={errorMessage}\n classNameModifiers={classNameModifiers}\n isValid={!!value}\n showValidIcon={false}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select\n onChange={onDropdownChange}\n name={'country'}\n selectedValue={value}\n items={countries}\n readonly={readOnly && !!value}\n required={required}\n />\n </Field>\n );\n}\n"],"names":["formatCountries","countries","allowedCountries","applyMapper","country","_object_spread_props","name","selectedOptionName","length","filter","includes","id","map","CountryField","props","classNameModifiers","errorMessage","onDropdownChange","value","required","i18n","loadingContext","useCoreContext","setCountries","useState","loaded","setLoaded","readOnly","setReadOnly","useLayoutEffect","getDataset","locale","then","response","newCountries","catch","error","console","h","Field","label","get","isValid","showValidIcon","Select","onChange","selectedValue","items","readonly"],"mappings":"o3BAQA,MAAMA,EAAkB,CAACC,EAAoCC,KACzD,MACMC,EAAeC,GACVC,wUACAD,CAAAA,CAAAA,EAAAA,GAAAA,CACHE,KAAMF,EAAQE,KACdC,mBAAoBH,EAAQE,OAGpC,OAAOJ,EAAiBM,OAASP,EAAUQ,QARtBL,GAA8BF,EAAiBQ,SAASN,EAAQO,MAQtBC,IAAIT,GAAeF,EAAUW,IAAIT,EAAAA,EAGrF,SAASU,EAAaC,GACjC,MAAMZ,iBAAEA,EAAmB,GAAEa,mBAAEA,EAAqB,GAAEC,aAAEA,EAAYC,iBAAEA,EAAgBC,MAAEA,EAAKC,SAAEA,GAAaL,GACtGM,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BrB,EAAWsB,GAAgBC,EAA6B,KACxDC,EAAQC,GAAaF,GAAkB,IACvCG,EAAUC,GAAeJ,EAASV,EAAMa,UAiB/C,OAfAE,GAAgB,KACZC,EAAW,YAAaT,EAAgBD,EAAKW,QACxCC,MAAKC,IACF,MAAMC,EAAelC,EAAgBiC,EAAU/B,GAC/CqB,EAAaW,GAAgB,IAC7BN,EAAoC,IAAxBM,EAAa1B,QAAgBmB,GACzCD,GAAU,EAAA,IAEbS,OAAMC,IACHC,QAAQD,MAAMA,GACdb,EAAa,IACbG,GAAU,EAAA,GACd,GACL,IAEED,EAGDa,EAACC,EAAAA,CACGjC,KAAM,UACNkC,MAAOpB,EAAKqB,IAAI,WAChBzB,aAAcA,EACdD,mBAAoBA,EACpB2B,UAAWxB,EACXyB,eAAe,EACfvB,KAAMA,EACNO,SAAUA,KAAcT,GAExBoB,EAACM,EAAAA,CACGC,SAAU5B,EACVX,KAAM,UACNwC,cAAe5B,EACf6B,MAAO9C,EACP+C,SAAUrB,KAAcT,EACxBC,SAAUA,KAnBF,IAuBxB"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import t from"./CountryField.js";import{useCoreContext as i}from"../../../../core/Context/CoreProvider.js";import a from"../../FormFields/InputText.js";function s(s){const{i18n:n}=i(),{classNameModifiers:l=[],data:d,errors:c,valid:u,fieldName:m,onInput:f,onBlur:p,trimOnBlur:g,maxLength:F,disabled:v}=s,C=d[m],M=d.country,y=s.specifications.countryHasOptionalField(M,m),b=s.specifications.getKeyForField(m,M),j=y?` ${n.get("field.title.optional")}`:"",w=`${n.get(b)}${j}`,h=function(e,r,o,t){var i,a;if("object"==typeof(null===(i=e[r])||void 0===i?void 0:i.errorMessage)){const{translationKey:t,translationObject:i}=e[r].errorMessage;return o.get(t,i)}return o.get(null===(a=e[r])||void 0===a?void 0:a.errorMessage,{values:{label:t.toLowerCase()}})||!!e[r]}(c,m,n,w);switch(m){case"country":return e(t,{allowedCountries:s.allowedCountries,classNameModifiers:l,label:w,errorMessage:h,onDropdownChange:s.onDropdownChange,value:C});case"stateOrProvince":return e(o,{classNameModifiers:l,label:w,errorMessage:h,onDropdownChange:s.onDropdownChange,selectedCountry:M,specifications:s.specifications,value:C});default:return e(r,{label:w,classNameModifiers:l,errorMessage:h,isValid:u[m],name:m,i18n:n,onFocus:e=>s.onFieldFocusAnalytics(m,e),onBlur:e=>s.onFieldBlurAnalytics(m,e)},e(a,{name:m,classNameModifiers:l,value:C,onInput:f,onBlur:p,maxlength:F,trimOnBlur:g,disabled:v,required:!y}))}}export{s as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import r from"../../FormFields/Field/Field.js";import o from"./StateField.js";import i from"./CountryField.js";import{useCoreContext as t}from"../../../../core/Context/CoreProvider.js";import a from"../../FormFields/InputText.js";function s(s){const{i18n:n}=t(),{classNameModifiers:l=[],data:d,errors:u,valid:c,fieldName:m,onInput:f,onBlur:p,trimOnBlur:g,maxLength:F,disabled:v}=s,C=d[m],M=d.country,y=s.specifications.countryHasOptionalField(M,m),b=s.specifications.getKeyForField(m,M),j=y?` ${n.get("field.title.optional")}`:"",w=`${n.get(b)}${j}`,h=function(e,r,o,i){var t,a;if("object"==typeof(null===(t=e[r])||void 0===t?void 0:t.errorMessage)){const{translationKey:i,translationObject:t}=e[r].errorMessage;return o.get(i,t)}return o.get(null===(a=e[r])||void 0===a?void 0:a.errorMessage,{values:{label:i.toLowerCase()}})||!!e[r]}(u,m,n,w);switch(m){case"country":return e(i,{allowedCountries:s.allowedCountries,classNameModifiers:l,label:w,errorMessage:h,onDropdownChange:s.onDropdownChange,value:C,required:!y});case"stateOrProvince":return e(o,{classNameModifiers:l,label:w,errorMessage:h,onDropdownChange:s.onDropdownChange,selectedCountry:M,specifications:s.specifications,value:C,required:!y});default:return e(r,{label:w,classNameModifiers:l,errorMessage:h,isValid:c[m],name:m,i18n:n,onFocus:e=>s.onFieldFocusAnalytics(m,e),onBlur:e=>s.onFieldBlurAnalytics(m,e)},e(a,{name:m,classNameModifiers:l,value:C,onInput:f,onBlur:p,maxlength:F,trimOnBlur:g,disabled:v,required:!y}))}}export{s as default};
2
2
  //# sourceMappingURL=FieldContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction FieldContainer(props: FieldContainerProps) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName);\n const labelKey: string = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n switch (fieldName) {\n case 'country':\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n />\n );\n case 'stateOrProvince':\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n />\n );\n default:\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n />\n </Field>\n );\n }\n}\n\nexport default FieldContainer;\n"],"names":["FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","fieldName","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength","required"],"mappings":"iTAyBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,GAAaZ,EAEhHa,EAAgBT,EAAKG,GACrBO,EAA0BV,EAAKW,QAC/BC,EAAsBhB,EAAMiB,eAAeC,wBAAwBJ,EAAiBP,GACpFY,EAAmBnB,EAAMiB,eAAeG,eAAeb,EAAWO,GAClEO,EAAgBL,EAAa,IAAIf,EAAKqB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGtB,EAAKqB,IAAIH,KAAYE,IAChCG,EA1BV,SAAyBnB,EAA2BE,EAAmBN,EAAgBsB,OACxElB,EAKeA,EAL1B,GAA+C,yBAApCA,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,cAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBrB,EAAOE,GAAWiB,aAChE,OAAOvB,EAAKqB,IAAIG,EAAgBC,EACpC,CAGA,OADiBzB,EAAKqB,IAAIjB,QAAAA,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DvB,EAAOE,EAChC,CAkByBsB,CAAgBxB,EAAQE,EAAWN,EAAMsB,GAE9D,OAAQhB,GACJ,IAAK,UACD,OACIuB,EAACC,EAAAA,CACGC,iBAAkBhC,EAAMgC,iBACxB7B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBpB,MAAOA,IAGnB,IAAK,kBACD,OACIiB,EAACI,EAAAA,CACG/B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBnB,gBAAiBA,EACjBG,eAAgBjB,EAAMiB,eACtBJ,MAAOA,IAGnB,QACI,OACIiB,EAACK,EAAAA,CACGZ,MAAOA,EACPpB,mBAAoBA,EACpBqB,aAAcA,EACdY,QAAS9B,EAAMC,GACf8B,KAAM9B,EACNN,KAAMA,EACNqC,QAASC,GAAKvC,EAAMwC,sBAAsBjC,EAAWgC,GACrD9B,OAAQ8B,GAAKvC,EAAMyC,qBAAqBlC,EAAWgC,IAEnDT,EAACY,EAAAA,CACGL,KAAM9B,EACNJ,mBAAoBA,EACpBU,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRkC,UAAWhC,EACXD,WAAYA,EACZE,SAAUA,EACVgC,UAAW5B,KAKnC"}
1
+ {"version":3,"file":"FieldContainer.js","sources":["../../../../../../src/components/internal/Address/components/FieldContainer.tsx"],"sourcesContent":["import { h } from 'preact';\nimport Field from '../../FormFields/Field';\nimport StateField from './StateField';\nimport CountryField from './CountryField';\nimport { AddressStateError, FieldContainerProps } from '../types';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport Language from '../../../../language/Language';\nimport InputText from '../../FormFields/InputText';\n\nfunction getErrorMessage(errors: AddressStateError, fieldName: string, i18n: Language, label: string): string | boolean {\n if (typeof errors[fieldName]?.errorMessage === 'object') {\n const { translationKey, translationObject } = errors[fieldName].errorMessage;\n return i18n.get(translationKey, translationObject);\n }\n // Default error msg: Enter the [label name]\n const errorMsg = i18n.get(errors[fieldName]?.errorMessage, { values: { label: label.toLowerCase() } });\n return errorMsg || !!errors[fieldName];\n}\n\n/**\n * USAGE: Specifically defined as a util to provide a wrapper for fields created within the Address component\n *\n * NOT TO BE USED: if you just want to add a Country or State dropdown outside of an Address component\n * - then you should implement <CountryField> or <StateField> directly\n */\nfunction FieldContainer(props: FieldContainerProps) {\n const { i18n } = useCoreContext();\n const { classNameModifiers = [], data, errors, valid, fieldName, onInput, onBlur, trimOnBlur, maxLength, disabled } = props;\n\n const value: string = data[fieldName];\n const selectedCountry: string = data.country;\n const isOptional: boolean = props.specifications.countryHasOptionalField(selectedCountry, fieldName);\n const labelKey: string = props.specifications.getKeyForField(fieldName, selectedCountry);\n const optionalLabel = isOptional ? ` ${i18n.get('field.title.optional')}` : '';\n const label = `${i18n.get(labelKey)}${optionalLabel}`;\n const errorMessage = getErrorMessage(errors, fieldName, i18n, label);\n\n switch (fieldName) {\n case 'country':\n return (\n <CountryField\n allowedCountries={props.allowedCountries}\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n value={value}\n required={!isOptional}\n />\n );\n case 'stateOrProvince':\n return (\n <StateField\n classNameModifiers={classNameModifiers}\n label={label}\n errorMessage={errorMessage}\n onDropdownChange={props.onDropdownChange}\n selectedCountry={selectedCountry}\n specifications={props.specifications}\n value={value}\n required={!isOptional}\n />\n );\n default:\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={errorMessage}\n isValid={valid[fieldName]}\n name={fieldName}\n i18n={i18n}\n onFocus={e => props.onFieldFocusAnalytics(fieldName, e)}\n onBlur={e => props.onFieldBlurAnalytics(fieldName, e)}\n >\n <InputText\n name={fieldName}\n classNameModifiers={classNameModifiers}\n value={value}\n onInput={onInput}\n onBlur={onBlur}\n maxlength={maxLength}\n trimOnBlur={trimOnBlur}\n disabled={disabled}\n required={!isOptional}\n />\n </Field>\n );\n }\n}\n\nexport default FieldContainer;\n"],"names":["FieldContainer","props","i18n","useCoreContext","classNameModifiers","data","errors","valid","fieldName","onInput","onBlur","trimOnBlur","maxLength","disabled","value","selectedCountry","country","isOptional","specifications","countryHasOptionalField","labelKey","getKeyForField","optionalLabel","get","label","errorMessage","translationKey","translationObject","values","toLowerCase","getErrorMessage","h","CountryField","allowedCountries","onDropdownChange","required","StateField","Field","isValid","name","onFocus","e","onFieldFocusAnalytics","onFieldBlurAnalytics","InputText","maxlength"],"mappings":"iTAyBA,SAASA,EAAeC,GACpB,MAAMC,KAAEA,GAASC,KACXC,mBAAEA,EAAqB,GAAEC,KAAEA,EAAIC,OAAEA,EAAMC,MAAEA,EAAKC,UAAEA,EAASC,QAAEA,EAAOC,OAAEA,EAAMC,WAAEA,EAAUC,UAAEA,EAASC,SAAEA,GAAaZ,EAEhHa,EAAgBT,EAAKG,GACrBO,EAA0BV,EAAKW,QAC/BC,EAAsBhB,EAAMiB,eAAeC,wBAAwBJ,EAAiBP,GACpFY,EAAmBnB,EAAMiB,eAAeG,eAAeb,EAAWO,GAClEO,EAAgBL,EAAa,IAAIf,EAAKqB,IAAI,0BAA4B,GACtEC,EAAQ,GAAGtB,EAAKqB,IAAIH,KAAYE,IAChCG,EA1BV,SAAyBnB,EAA2BE,EAAmBN,EAAgBsB,OACxElB,EAKeA,EAL1B,GAA+C,yBAApCA,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,cAA2B,CACrD,MAAMC,eAAEA,EAAcC,kBAAEA,GAAsBrB,EAAOE,GAAWiB,aAChE,OAAOvB,EAAKqB,IAAIG,EAAgBC,EACpC,CAGA,OADiBzB,EAAKqB,IAAIjB,QAAAA,EAAAA,EAAOE,UAAPF,IAAAA,OAAAA,EAAAA,EAAmBmB,aAAc,CAAEG,OAAQ,CAAEJ,MAAOA,EAAMK,oBAC/DvB,EAAOE,EAChC,CAkByBsB,CAAgBxB,EAAQE,EAAWN,EAAMsB,GAE9D,OAAQhB,GACJ,IAAK,UACD,OACIuB,EAACC,EAAAA,CACGC,iBAAkBhC,EAAMgC,iBACxB7B,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBpB,MAAOA,EACPqB,UAAWlB,IAGvB,IAAK,kBACD,OACIc,EAACK,EAAAA,CACGhC,mBAAoBA,EACpBoB,MAAOA,EACPC,aAAcA,EACdS,iBAAkBjC,EAAMiC,iBACxBnB,gBAAiBA,EACjBG,eAAgBjB,EAAMiB,eACtBJ,MAAOA,EACPqB,UAAWlB,IAGvB,QACI,OACIc,EAACM,EAAAA,CACGb,MAAOA,EACPpB,mBAAoBA,EACpBqB,aAAcA,EACda,QAAS/B,EAAMC,GACf+B,KAAM/B,EACNN,KAAMA,EACNsC,QAASC,GAAKxC,EAAMyC,sBAAsBlC,EAAWiC,GACrD/B,OAAQ+B,GAAKxC,EAAM0C,qBAAqBnC,EAAWiC,IAEnDV,EAACa,EAAAA,CACGL,KAAM/B,EACNJ,mBAAoBA,EACpBU,MAAOA,EACPL,QAASA,EACTC,OAAQA,EACRmC,UAAWjC,EACXD,WAAYA,EACZE,SAAUA,EACVsB,UAAWlB,KAKnC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ReadOnlyAddress.js","sources":["../../../../../../src/components/internal/Address/components/ReadOnlyAddress.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport Fieldset from '../../FormFields/Fieldset';\nimport { ReadOnlyAddressProps } from '../types';\nimport { FALLBACK_VALUE } from '../constants';\n\nconst FullName = ({ firstName, lastName }) => {\n return (\n <Fragment>\n {firstName && `${firstName} `}\n {lastName && `${lastName}`}\n <br />\n </Fragment>\n );\n};\n\nconst ReadOnlyAddress = ({ data, label }: ReadOnlyAddressProps) => {\n const { street, houseNumberOrName, city, postalCode, stateOrProvince, country, firstName, lastName } = data;\n const hasName = firstName || lastName;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label} readonly>\n <Fragment>\n {hasName && <FullName firstName={firstName} lastName={lastName}></FullName>}\n {!!street && street}\n {houseNumberOrName && `, ${houseNumberOrName},`}\n <br />\n {postalCode && `${postalCode}`}\n {city && `, ${city}`}\n {stateOrProvince && stateOrProvince !== FALLBACK_VALUE && `, ${stateOrProvince}`}\n {country && `, ${country} `}\n </Fragment>\n </Fieldset>\n );\n};\n\nexport default ReadOnlyAddress;\n"],"names":["FullName","firstName","lastName","h","Fragment","br","ReadOnlyAddress","data","label","street","houseNumberOrName","city","postalCode","stateOrProvince","country","Fieldset","classNameModifiers","readonly","FALLBACK_VALUE"],"mappings":"+LAKA,MAAMA,EAAW,EAAGC,YAAWC,cAEvBC,EAACC,EAAAA,KACIH,GAAa,GAAGA,KAChBC,GAAY,GAAGA,IAChBC,EAACE,KAAAA,OAKPC,EAAkB,EAAGC,OAAMC,YAC7B,MAAMC,OAAEA,EAAMC,kBAAEA,EAAiBC,KAAEA,EAAIC,WAAEA,EAAUC,gBAAEA,EAAeC,QAAEA,EAAOb,UAAEA,EAASC,SAAEA,GAAaK,EAGvG,OACIJ,EAACY,EAAAA,CAASC,mBAAoB,CAACR,GAAQA,MAAOA,EAAOS,UAAAA,GACjDd,EAACC,EAAAA,MAJOH,GAAaC,IAKLC,EAACH,EAAAA,CAASC,UAAWA,EAAWC,SAAUA,MACnDO,GAAUA,EACZC,GAAqB,KAAKA,KAC3BP,EAACE,KACAO,MAAAA,GAAc,GAAGA,IACjBD,GAAQ,KAAKA,IACbE,GAAmBA,IAAoBK,GAAkB,KAAKL,IAC9DC,GAAW,KAAKA,MAAU"}
1
+ {"version":3,"file":"ReadOnlyAddress.js","sources":["../../../../../../src/components/internal/Address/components/ReadOnlyAddress.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport Fieldset from '../../FormFields/Fieldset';\nimport { ReadOnlyAddressProps } from '../types';\nimport { FALLBACK_VALUE } from '../constants';\n\nconst FullName = ({ firstName, lastName }) => {\n return (\n <Fragment>\n {firstName && `${firstName} `}\n {lastName && `${lastName}`}\n <br />\n </Fragment>\n );\n};\n\nconst ReadOnlyAddress = ({ data, label }: ReadOnlyAddressProps) => {\n const { street, houseNumberOrName, city, postalCode, stateOrProvince, country, firstName, lastName } = data;\n const hasName = firstName || lastName;\n\n return (\n <Fieldset classNameModifiers={[label]} label={label} readonly>\n <Fragment>\n {hasName && <FullName firstName={firstName} lastName={lastName}></FullName>}\n {!!street && street}\n {houseNumberOrName && `, ${houseNumberOrName},`}\n <br />\n {postalCode && `${postalCode}`}\n {city && `, ${city}`}\n {stateOrProvince && stateOrProvince !== FALLBACK_VALUE && `, ${stateOrProvince}`}\n {country && `, ${country} `}\n </Fragment>\n </Fieldset>\n );\n};\n\nexport default ReadOnlyAddress;\n"],"names":["FullName","firstName","lastName","h","Fragment","br","ReadOnlyAddress","data","label","street","houseNumberOrName","city","postalCode","stateOrProvince","country","Fieldset","classNameModifiers","readonly","FALLBACK_VALUE"],"mappings":"+LAKA,MAAMA,EAAW,EAAGC,YAAWC,cAEvBC,EAACC,EAAAA,KACIH,GAAa,GAAGA,KAChBC,GAAY,GAAGA,IAChBC,EAACE,KAAAA,OAKPC,EAAkB,EAAGC,OAAMC,YAC7B,MAAMC,OAAEA,EAAMC,kBAAEA,EAAiBC,KAAEA,EAAIC,WAAEA,EAAUC,gBAAEA,EAAeC,QAAEA,EAAOb,UAAEA,EAASC,SAAEA,GAAaK,EAGvG,OACIJ,EAACY,EAAAA,CAASC,mBAAoB,CAACR,GAAQA,MAAOA,EAAOS,UAAAA,GACjDd,EAACC,EAAAA,MAJOH,GAAaC,IAKLC,EAACH,EAAAA,CAASC,UAAWA,EAAWC,SAAUA,MACnDO,GAAUA,EACZC,GAAqB,KAAKA,KAC3BP,EAACE,KAAAA,MACAO,GAAc,GAAGA,IACjBD,GAAQ,KAAKA,IACbE,GAAmBA,IAAoBK,GAAkB,KAAKL,IAC9DC,GAAW,KAAKA,MAAU"}
@@ -1,2 +1,2 @@
1
- import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as t,useLayoutEffect as r}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import a from"../../../../core/Services/get-dataset.js";import n from"../../FormFields/Select/Select.js";function i(i){const{classNameModifiers:l,label:c,onDropdownChange:d,readOnly:m,selectedCountry:f,specifications:p,value:u}=i,{i18n:h,loadingContext:g}=s(),[j,v]=t([]),[y,C]=t(!1);return r((()=>{if(!f||!p.countryHasDataset(f))return v([]),void C(!0);a(`states/${f}`,g,h.locale).then((e=>{const t=e&&e.length?e:[];v(t),C(!0)})).catch((()=>{v([]),C(!0)}))}),[f]),y&&j.length?e(o,{label:c,classNameModifiers:l,errorMessage:i.errorMessage,isValid:!!u,showValidIcon:!1,name:"stateOrProvince",i18n:h,readOnly:m&&!!u},e(n,{name:"stateOrProvince",onChange:d,selectedValue:u,items:j,readonly:m&&!!u})):null}export{i as default};
1
+ import{createElement as e}from"../../../../external/preact/dist/preact.js";import{useState as r,useLayoutEffect as t}from"../../../../external/preact/hooks/dist/hooks.js";import o from"../../FormFields/Field/Field.js";import{useCoreContext as s}from"../../../../core/Context/CoreProvider.js";import a from"../../../../core/Services/get-dataset.js";import i from"../../FormFields/Select/Select.js";function n(n){const{classNameModifiers:l,label:c,onDropdownChange:d,readOnly:m,selectedCountry:f,specifications:u,value:p,required:h}=n,{i18n:g,loadingContext:j}=s(),[v,y]=r([]),[C,F]=r(!1);return t((()=>{if(!f||!u.countryHasDataset(f))return y([]),void F(!0);a(`states/${f}`,j,g.locale).then((e=>{const r=e&&e.length?e:[];y(r),F(!0)})).catch((()=>{y([]),F(!0)}))}),[f]),C&&v.length?e(o,{label:c,classNameModifiers:l,errorMessage:n.errorMessage,isValid:!!p,showValidIcon:!1,name:"stateOrProvince",i18n:g,readOnly:m&&!!p},e(i,{name:"stateOrProvince",onChange:d,selectedValue:p,items:v,required:h,readonly:m&&!!p})):null}export{n as default};
2
2
  //# sourceMappingURL=StateField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateField.js","sources":["../../../../../../src/components/internal/Address/components/StateField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useLayoutEffect } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { StateFieldItem, StateFieldProps } from '../types';\nimport Select from '../../FormFields/Select';\n\nexport default function StateField(props: StateFieldProps) {\n const { classNameModifiers, label, onDropdownChange, readOnly, selectedCountry, specifications, value } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [states, setStates] = useState<StateFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n\n useLayoutEffect(() => {\n if (!selectedCountry || !specifications.countryHasDataset(selectedCountry)) {\n setStates([]);\n setLoaded(true);\n return;\n }\n\n getDataset(`states/${selectedCountry}`, loadingContext, i18n.locale)\n .then(response => {\n const newStates = response && response.length ? response : [];\n setStates(newStates);\n setLoaded(true);\n })\n .catch(() => {\n setStates([]);\n setLoaded(true);\n });\n }, [selectedCountry]);\n\n if (!loaded || !states.length) return null;\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={props.errorMessage}\n isValid={!!value}\n showValidIcon={false}\n name={'stateOrProvince'}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select name={'stateOrProvince'} onChange={onDropdownChange} selectedValue={value} items={states} readonly={readOnly && !!value} />\n </Field>\n );\n}\n"],"names":["StateField","props","classNameModifiers","label","onDropdownChange","readOnly","selectedCountry","specifications","value","i18n","loadingContext","useCoreContext","states","setStates","useState","loaded","setLoaded","useLayoutEffect","countryHasDataset","getDataset","locale","then","response","newStates","length","catch","h","Field","errorMessage","isValid","showValidIcon","name","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAQe,SAASA,EAAWC,GAC/B,MAAMC,mBAAEA,EAAkBC,MAAEA,EAAKC,iBAAEA,EAAgBC,SAAEA,EAAQC,gBAAEA,EAAeC,eAAEA,EAAcC,MAAEA,GAAUP,GACpGQ,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAQC,GAAaC,EAA2B,KAChDC,EAAQC,GAAaF,GAAkB,GAqB9C,OAnBAG,GAAgB,KACZ,IAAKX,IAAoBC,EAAeW,kBAAkBZ,GAGtD,OAFAO,EAAU,SACVG,GAAU,GAIdG,EAAW,UAAUb,IAAmBI,EAAgBD,EAAKW,QACxDC,MAAKC,IACF,MAAMC,EAAYD,GAAYA,EAASE,OAASF,EAAW,GAC3DT,EAAUU,GACVP,GAAU,EAAA,IAEbS,OAAM,KACHZ,EAAU,IACVG,GAAU,EAAA,GACd,GACL,CAACV,IAECS,GAAWH,EAAOY,OAGnBE,EAACC,EAAAA,CACGxB,MAAOA,EACPD,mBAAoBA,EACpB0B,aAAc3B,EAAM2B,aACpBC,UAAWrB,EACXsB,eAAe,EACfC,KAAM,kBACNtB,KAAMA,EACNJ,SAAUA,KAAcG,GAExBkB,EAACM,EAAAA,CAAOD,KAAM,kBAAmBE,SAAU7B,EAAkB8B,cAAe1B,EAAO2B,MAAOvB,EAAQwB,SAAU/B,KAAcG,KAb5F,IAgB1C"}
1
+ {"version":3,"file":"StateField.js","sources":["../../../../../../src/components/internal/Address/components/StateField.tsx"],"sourcesContent":["import { h } from 'preact';\nimport { useState, useLayoutEffect } from 'preact/hooks';\nimport Field from '../../FormFields/Field';\nimport { useCoreContext } from '../../../../core/Context/CoreProvider';\nimport getDataset from '../../../../core/Services/get-dataset';\nimport { StateFieldItem, StateFieldProps } from '../types';\nimport Select from '../../FormFields/Select';\n\nexport default function StateField(props: StateFieldProps) {\n const { classNameModifiers, label, onDropdownChange, readOnly, selectedCountry, specifications, value, required } = props;\n const { i18n, loadingContext } = useCoreContext();\n const [states, setStates] = useState<StateFieldItem[]>([]);\n const [loaded, setLoaded] = useState<boolean>(false);\n\n useLayoutEffect(() => {\n if (!selectedCountry || !specifications.countryHasDataset(selectedCountry)) {\n setStates([]);\n setLoaded(true);\n return;\n }\n\n getDataset(`states/${selectedCountry}`, loadingContext, i18n.locale)\n .then(response => {\n const newStates = response && response.length ? response : [];\n setStates(newStates);\n setLoaded(true);\n })\n .catch(() => {\n setStates([]);\n setLoaded(true);\n });\n }, [selectedCountry]);\n\n if (!loaded || !states.length) return null;\n\n return (\n <Field\n label={label}\n classNameModifiers={classNameModifiers}\n errorMessage={props.errorMessage}\n isValid={!!value}\n showValidIcon={false}\n name={'stateOrProvince'}\n i18n={i18n}\n readOnly={readOnly && !!value}\n >\n <Select\n name={'stateOrProvince'}\n onChange={onDropdownChange}\n selectedValue={value}\n items={states}\n required={required}\n readonly={readOnly && !!value}\n />\n </Field>\n );\n}\n"],"names":["StateField","props","classNameModifiers","label","onDropdownChange","readOnly","selectedCountry","specifications","value","required","i18n","loadingContext","useCoreContext","states","setStates","useState","loaded","setLoaded","useLayoutEffect","countryHasDataset","getDataset","locale","then","response","newStates","length","catch","h","Field","errorMessage","isValid","showValidIcon","name","Select","onChange","selectedValue","items","readonly"],"mappings":"6YAQe,SAASA,EAAWC,GAC/B,MAAMC,mBAAEA,EAAkBC,MAAEA,EAAKC,iBAAEA,EAAgBC,SAAEA,EAAQC,gBAAEA,EAAeC,eAAEA,EAAcC,MAAEA,EAAKC,SAAEA,GAAaR,GAC9GS,KAAEA,EAAIC,eAAEA,GAAmBC,KAC1BC,EAAQC,GAAaC,EAA2B,KAChDC,EAAQC,GAAaF,GAAkB,GAqB9C,OAnBAG,GAAgB,KACZ,IAAKZ,IAAoBC,EAAeY,kBAAkBb,GAGtD,OAFAQ,EAAU,SACVG,GAAU,GAIdG,EAAW,UAAUd,IAAmBK,EAAgBD,EAAKW,QACxDC,MAAKC,IACF,MAAMC,EAAYD,GAAYA,EAASE,OAASF,EAAW,GAC3DT,EAAUU,GACVP,GAAU,EAAA,IAEbS,OAAM,KACHZ,EAAU,IACVG,GAAU,EAAA,GACd,GACL,CAACX,IAECU,GAAWH,EAAOY,OAGnBE,EAACC,EAAAA,CACGzB,MAAOA,EACPD,mBAAoBA,EACpB2B,aAAc5B,EAAM4B,aACpBC,UAAWtB,EACXuB,eAAe,EACfC,KAAM,kBACNtB,KAAMA,EACNL,SAAUA,KAAcG,GAExBmB,EAACM,EAAAA,CACGD,KAAM,kBACNE,SAAU9B,EACV+B,cAAe3B,EACf4B,MAAOvB,EACPJ,SAAUA,EACV4B,SAAUhC,KAAcG,KAnBE,IAuB1C"}
@@ -1,2 +1,2 @@
1
- import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as n,ANALYTICS_RENDERED_STR as s}from"../../../core/Analytics/constants.js";import{on as i,off as c}from"../../../utils/listenerUtils.js";function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){p(t,e,r[e])}))}return t}function u(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function l(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class h{buildElementProps(t){this.props=this.formatProps(a({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=a({},this.state,t)}get data(){var t;const r=e(this.props,"modules.risk.data");var o;const s=null!==(o=null===(t=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===t?void 0:t())&&void 0!==o?o:n,i=this.state.order||this.props.order,c=this.formatData();if(c.paymentMethod&&s&&(c.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&c.billingAddress){const t=l(c.billingAddress,["firstName","lastName"]);c.billingAddress=a({},t)}return u(a({},r&&{riskData:{clientData:r}},i&&{order:{orderData:i.orderData,pspReference:i.pspReference}},c),{clientStateDataIndicator:!0})}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var n;(this._node&&this.unmount(),this._node=r,i(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(n=this.constructor.analyticsType)&&void 0!==n?n:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:s})})));return this}update(t){return this.props=this.formatProps(a({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return c(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){p(this,"_id",`${this.constructor.type}-${r()}`),p(this,"core",void 0),p(this,"props",void 0),p(this,"state",{}),p(this,"_component",void 0),p(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e),this.handleKeyPress=this.handleKeyPress.bind(this)}}p(h,"defaultProps",{});export{h as default};
1
+ import{render as t}from"../../../external/preact/dist/preact.js";import e from"../../../utils/getProp.js";import r from"../../../utils/uuid.js";import o from"../../../core/Errors/AdyenCheckoutError.js";import{NO_CHECKOUT_ATTEMPT_ID as n,ANALYTICS_RENDERED_STR as s}from"../../../core/Analytics/constants.js";import{on as i,off as c}from"../../../utils/listenerUtils.js";function p(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){p(t,e,r[e])}))}return t}function u(t,e){return e=null!=e?e:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):function(t){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e.push.apply(e,r)}return e}(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})),t}function l(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r,o,n={},s=Object.keys(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(o=0;o<s.length;o++)r=s[o],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}class h{buildElementProps(t){this.props=this.formatProps(a({},this.constructor.defaultProps,t))}formatProps(t){return t}formatData(){return{}}setUpAnalytics(t){return null}submitAnalytics(t){return null}handleKeyPress(t){return null}setState(t){this.state=a({},this.state,t)}get data(){var t;const r=e(this.props,"modules.risk.data");var o;const s=null!==(o=null===(t=e(this.props,"modules.analytics.getCheckoutAttemptId"))||void 0===t?void 0:t())&&void 0!==o?o:n,i=this.state.order||this.props.order,c=this.formatData();if(c.paymentMethod&&s&&(c.paymentMethod.checkoutAttemptId=s),"riverty"!==this.props.type&&c.billingAddress){const t=l(c.billingAddress,["firstName","lastName"]);c.billingAddress=a({},t)}return u(a({},r&&{riskData:{clientData:r}},i&&{order:{orderData:i.orderData,pspReference:i.pspReference}},c),{clientStateDataIndicator:!0})}activate(){}render(){throw new Error("Payment method cannot be rendered.")}mount(e){const r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error("Component could not mount. Root node was not found.");const o=!this._node;var n;(this._node&&this.unmount(),this._node=r,i(this._node,"keypress",this.handleKeyPress,!1),this._component=this.render(),t(this._component,r),o)&&(this.props.modules&&this.props.modules.analytics&&this.setUpAnalytics({containerWidth:r&&r.offsetWidth,component:this.props.isDropin?"dropin":null!==(n=this.constructor.analyticsType)&&void 0!==n?n:this.constructor.type,flavor:this.props.isDropin?"dropin":"components"}).then((()=>{this.props.isDropin||this.submitAnalytics({type:s})})));return this}update(t){return this.props=this.formatProps(a({},this.props,t)),this.state={},this.unmount().mount(this._node)}unmount(){return c(this._node,"keypress",this.handleKeyPress),this._node&&t(null,this._node),this}remove(){this.unmount(),this.core&&this.core.remove(this)}constructor(t,e){p(this,"_id",`${this.constructor.type}-${r()}`),p(this,"core",void 0),p(this,"props",void 0),p(this,"state",{}),p(this,"_component",void 0),p(this,"_node",null);const n=function(t){return!!t&&("function"==typeof t.initialize&&"function"==typeof t.createFromAction)}(t);if(!n)throw new o("IMPLEMENTATION_ERROR",`Trying to initialise the component '${this.constructor.type}' without a reference to an instance of AdyenCheckout`);this.core=t,this.buildElementProps(e),this.handleKeyPress=this.handleKeyPress.bind(this)}}p(h,"defaultProps",{});export{h as default};
2
2
  //# sourceMappingURL=BaseElement.js.map