@adyen/adyen-web 6.13.1 → 6.15.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 +7 -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 +299 -205
  6. package/dist/es/adyen.css +7 -2
  7. package/dist/es/adyen.css.map +1 -1
  8. package/dist/es/components/AmazonPay/AmazonPay.js +1 -1
  9. package/dist/es/components/AmazonPay/AmazonPay.js.map +1 -1
  10. package/dist/es/components/ApplePay/ApplePay.js +1 -1
  11. package/dist/es/components/ApplePay/ApplePay.js.map +1 -1
  12. package/dist/es/components/Card/Card.js +1 -1
  13. package/dist/es/components/Card/Card.js.map +1 -1
  14. package/dist/es/components/Card/components/CardInput/CardInput.js +1 -1
  15. package/dist/es/components/Card/components/CardInput/CardInput.js.map +1 -1
  16. package/dist/es/components/Card/components/CardInput/types.js.map +1 -1
  17. package/dist/es/components/Card/components/CardInput/utils.js +1 -1
  18. package/dist/es/components/Card/components/CardInput/utils.js.map +1 -1
  19. package/dist/es/components/Card/components/Fastlane/FastlaneSignup.js +1 -1
  20. package/dist/es/components/Card/components/Fastlane/FastlaneSignup.js.map +1 -1
  21. package/dist/es/components/CustomCard/CustomCard.js +1 -1
  22. package/dist/es/components/CustomCard/CustomCard.js.map +1 -1
  23. package/dist/es/components/Dropin/Dropin.js +1 -1
  24. package/dist/es/components/Dropin/Dropin.js.map +1 -1
  25. package/dist/es/components/Dropin/components/DropinComponent.js +1 -1
  26. package/dist/es/components/Dropin/components/DropinComponent.js.map +1 -1
  27. package/dist/es/components/GooglePay/GooglePay.js +1 -1
  28. package/dist/es/components/GooglePay/GooglePay.js.map +1 -1
  29. package/dist/es/components/PayByBankPix/PayByBankPix.js +2 -0
  30. package/dist/es/components/PayByBankPix/PayByBankPix.js.map +1 -0
  31. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js +2 -0
  32. package/dist/es/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -0
  33. package/dist/es/components/PayByBankPix/components/Enrollment/components/AwaitLogoContainer.js +2 -0
  34. package/dist/es/components/PayByBankPix/components/Enrollment/components/AwaitLogoContainer.js.map +1 -0
  35. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +2 -0
  36. package/dist/es/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -0
  37. package/dist/es/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js +2 -0
  38. package/dist/es/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js.map +1 -0
  39. package/dist/es/components/PayByBankPix/components/Enrollment/getEnrollmentStatus.js +2 -0
  40. package/dist/es/components/PayByBankPix/components/Enrollment/getEnrollmentStatus.js.map +1 -0
  41. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +2 -0
  42. package/dist/es/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -0
  43. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js +2 -0
  44. package/dist/es/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -0
  45. package/dist/es/components/PayByBankPix/components/StoredPayment/getAuthorizationStatus.js +2 -0
  46. package/dist/es/components/PayByBankPix/components/StoredPayment/getAuthorizationStatus.js.map +1 -0
  47. package/dist/es/components/PayByBankPix/services/PasskeySdkLoader.js +2 -0
  48. package/dist/es/components/PayByBankPix/services/PasskeySdkLoader.js.map +1 -0
  49. package/dist/es/components/PayByBankPix/services/PasskeyService.js +2 -0
  50. package/dist/es/components/PayByBankPix/services/PasskeyService.js.map +1 -0
  51. package/dist/es/components/PayByBankPix/services/authorizeEnrollment.js +2 -0
  52. package/dist/es/components/PayByBankPix/services/authorizeEnrollment.js.map +1 -0
  53. package/dist/es/components/PayByBankPix/services/authorizePayment.js +2 -0
  54. package/dist/es/components/PayByBankPix/services/authorizePayment.js.map +1 -0
  55. package/dist/es/components/PayByBankPix/services/types.js +2 -0
  56. package/dist/es/components/PayByBankPix/services/types.js.map +1 -0
  57. package/dist/es/components/PayPal/Paypal.js +1 -1
  58. package/dist/es/components/PayPal/Paypal.js.map +1 -1
  59. package/dist/es/components/Redirect/Redirect.js +1 -1
  60. package/dist/es/components/Redirect/Redirect.js.map +1 -1
  61. package/dist/es/components/Riverty/Riverty.js +1 -1
  62. package/dist/es/components/Riverty/Riverty.js.map +1 -1
  63. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  64. package/dist/es/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  65. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  66. package/dist/es/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  67. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  68. package/dist/es/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  69. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  70. package/dist/es/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  71. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  72. package/dist/es/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  73. package/dist/es/components/ThreeDS2/constants.js +1 -1
  74. package/dist/es/components/ThreeDS2/constants.js.map +1 -1
  75. package/dist/es/components/components-name-map.js +1 -1
  76. package/dist/es/components/components-name-map.js.map +1 -1
  77. package/dist/es/components/index.js +1 -1
  78. package/dist/es/components/internal/Address/components/ReadOnlyAddress.js +1 -1
  79. package/dist/es/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  80. package/dist/es/components/internal/Address/constants.js +1 -1
  81. package/dist/es/components/internal/Address/constants.js.map +1 -1
  82. package/dist/es/components/internal/Await/Await.js +1 -1
  83. package/dist/es/components/internal/Await/Await.js.map +1 -1
  84. package/dist/es/components/internal/BaseElement/BaseElement.js +1 -1
  85. package/dist/es/components/internal/BaseElement/BaseElement.js.map +1 -1
  86. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  87. package/dist/es/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  88. package/dist/es/components/internal/IssuerList/IssuerList.js +1 -1
  89. package/dist/es/components/internal/IssuerList/IssuerList.js.map +1 -1
  90. package/dist/es/components/internal/OpenInvoice/utils.js.map +1 -1
  91. package/dist/es/components/internal/QRLoader/QRLoader.js +1 -1
  92. package/dist/es/components/internal/QRLoader/QRLoader.js.map +1 -1
  93. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  94. package/dist/es/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  95. package/dist/es/components/internal/UIElement/UIElement.js +1 -1
  96. package/dist/es/components/internal/UIElement/UIElement.js.map +1 -1
  97. package/dist/es/components/tx-variants.js +1 -1
  98. package/dist/es/components/tx-variants.js.map +1 -1
  99. package/dist/es/core/Analytics/Analytics.js +1 -1
  100. package/dist/es/core/Analytics/Analytics.js.map +1 -1
  101. package/dist/es/core/Analytics/AnalyticsErrorEvent.js +2 -0
  102. package/dist/es/core/Analytics/AnalyticsErrorEvent.js.map +1 -0
  103. package/dist/es/core/Analytics/AnalyticsEvent.js +2 -0
  104. package/dist/es/core/Analytics/AnalyticsEvent.js.map +1 -0
  105. package/dist/es/core/Analytics/AnalyticsInfoEvent.js +2 -0
  106. package/dist/es/core/Analytics/AnalyticsInfoEvent.js.map +1 -0
  107. package/dist/es/core/Analytics/AnalyticsLogEvent.js +2 -0
  108. package/dist/es/core/Analytics/AnalyticsLogEvent.js.map +1 -0
  109. package/dist/es/core/Analytics/utils.js +1 -1
  110. package/dist/es/core/Analytics/utils.js.map +1 -1
  111. package/dist/es/core/Environment/Environment.js +1 -1
  112. package/dist/es/core/Environment/Environment.js.map +1 -1
  113. package/dist/es/core/ProcessResponse/PaymentMethods/filters.js +1 -1
  114. package/dist/es/core/ProcessResponse/PaymentMethods/filters.js.map +1 -1
  115. package/dist/es/core/Services/analytics/collect-id.js +1 -1
  116. package/dist/es/core/core.js +1 -1
  117. package/dist/es/core/core.js.map +1 -1
  118. package/dist/es/core/utils.js +1 -1
  119. package/dist/es/core/utils.js.map +1 -1
  120. package/dist/es/index.d.ts +299 -205
  121. package/dist/es/index.js +1 -1
  122. package/dist/es/utils/base64.js.map +1 -1
  123. package/dist/es-legacy/adyen.css +7 -2
  124. package/dist/es-legacy/adyen.css.map +1 -1
  125. package/dist/es-legacy/components/AmazonPay/AmazonPay.js +1 -1
  126. package/dist/es-legacy/components/AmazonPay/AmazonPay.js.map +1 -1
  127. package/dist/es-legacy/components/ApplePay/ApplePay.js +1 -1
  128. package/dist/es-legacy/components/ApplePay/ApplePay.js.map +1 -1
  129. package/dist/es-legacy/components/Card/Card.js +1 -1
  130. package/dist/es-legacy/components/Card/Card.js.map +1 -1
  131. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js +1 -1
  132. package/dist/es-legacy/components/Card/components/CardInput/CardInput.js.map +1 -1
  133. package/dist/es-legacy/components/Card/components/CardInput/types.js.map +1 -1
  134. package/dist/es-legacy/components/Card/components/CardInput/utils.js +1 -1
  135. package/dist/es-legacy/components/Card/components/CardInput/utils.js.map +1 -1
  136. package/dist/es-legacy/components/Card/components/Fastlane/FastlaneSignup.js +1 -1
  137. package/dist/es-legacy/components/Card/components/Fastlane/FastlaneSignup.js.map +1 -1
  138. package/dist/es-legacy/components/CustomCard/CustomCard.js +1 -1
  139. package/dist/es-legacy/components/CustomCard/CustomCard.js.map +1 -1
  140. package/dist/es-legacy/components/Dropin/Dropin.js +1 -1
  141. package/dist/es-legacy/components/Dropin/Dropin.js.map +1 -1
  142. package/dist/es-legacy/components/Dropin/components/DropinComponent.js +1 -1
  143. package/dist/es-legacy/components/Dropin/components/DropinComponent.js.map +1 -1
  144. package/dist/es-legacy/components/GooglePay/GooglePay.js +1 -1
  145. package/dist/es-legacy/components/GooglePay/GooglePay.js.map +1 -1
  146. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js +2 -0
  147. package/dist/es-legacy/components/PayByBankPix/PayByBankPix.js.map +1 -0
  148. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js +2 -0
  149. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/Enrollment.js.map +1 -0
  150. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/AwaitLogoContainer.js +2 -0
  151. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/AwaitLogoContainer.js.map +1 -0
  152. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js +2 -0
  153. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/IssuerListIntroduction.js.map +1 -0
  154. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js +2 -0
  155. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/components/PayByBankPixAwait.js.map +1 -0
  156. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/getEnrollmentStatus.js +2 -0
  157. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/getEnrollmentStatus.js.map +1 -0
  158. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js +2 -0
  159. package/dist/es-legacy/components/PayByBankPix/components/Enrollment/useIssuerWithLogo.js.map +1 -0
  160. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js +2 -0
  161. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/StoredPayment.js.map +1 -0
  162. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/getAuthorizationStatus.js +2 -0
  163. package/dist/es-legacy/components/PayByBankPix/components/StoredPayment/getAuthorizationStatus.js.map +1 -0
  164. package/dist/es-legacy/components/PayByBankPix/services/PasskeySdkLoader.js +2 -0
  165. package/dist/es-legacy/components/PayByBankPix/services/PasskeySdkLoader.js.map +1 -0
  166. package/dist/es-legacy/components/PayByBankPix/services/PasskeyService.js +2 -0
  167. package/dist/es-legacy/components/PayByBankPix/services/PasskeyService.js.map +1 -0
  168. package/dist/es-legacy/components/PayByBankPix/services/authorizeEnrollment.js +2 -0
  169. package/dist/es-legacy/components/PayByBankPix/services/authorizeEnrollment.js.map +1 -0
  170. package/dist/es-legacy/components/PayByBankPix/services/authorizePayment.js +2 -0
  171. package/dist/es-legacy/components/PayByBankPix/services/authorizePayment.js.map +1 -0
  172. package/dist/es-legacy/components/PayByBankPix/services/types.js +2 -0
  173. package/dist/es-legacy/components/PayByBankPix/services/types.js.map +1 -0
  174. package/dist/es-legacy/components/PayPal/Paypal.js +1 -1
  175. package/dist/es-legacy/components/PayPal/Paypal.js.map +1 -1
  176. package/dist/es-legacy/components/Redirect/Redirect.js +1 -1
  177. package/dist/es-legacy/components/Redirect/Redirect.js.map +1 -1
  178. package/dist/es-legacy/components/Riverty/Riverty.js +1 -1
  179. package/dist/es-legacy/components/Riverty/Riverty.js.map +1 -1
  180. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js +1 -1
  181. package/dist/es-legacy/components/ThreeDS2/ThreeDS2Challenge.js.map +1 -1
  182. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js +1 -1
  183. package/dist/es-legacy/components/ThreeDS2/ThreeDS2DeviceFingerprint.js.map +1 -1
  184. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js +1 -1
  185. package/dist/es-legacy/components/ThreeDS2/callSubmit3DS2Fingerprint.js.map +1 -1
  186. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js +1 -1
  187. package/dist/es-legacy/components/ThreeDS2/components/Challenge/PrepareChallenge3DS2.js.map +1 -1
  188. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js +1 -1
  189. package/dist/es-legacy/components/ThreeDS2/components/DeviceFingerprint/PrepareFingerprint3DS2.js.map +1 -1
  190. package/dist/es-legacy/components/ThreeDS2/constants.js +1 -1
  191. package/dist/es-legacy/components/ThreeDS2/constants.js.map +1 -1
  192. package/dist/es-legacy/components/components-name-map.js +1 -1
  193. package/dist/es-legacy/components/components-name-map.js.map +1 -1
  194. package/dist/es-legacy/components/index.js +1 -1
  195. package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js +1 -1
  196. package/dist/es-legacy/components/internal/Address/components/ReadOnlyAddress.js.map +1 -1
  197. package/dist/es-legacy/components/internal/Address/constants.js +1 -1
  198. package/dist/es-legacy/components/internal/Address/constants.js.map +1 -1
  199. package/dist/es-legacy/components/internal/Await/Await.js +1 -1
  200. package/dist/es-legacy/components/internal/Await/Await.js.map +1 -1
  201. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js +1 -1
  202. package/dist/es-legacy/components/internal/BaseElement/BaseElement.js.map +1 -1
  203. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js +1 -1
  204. package/dist/es-legacy/components/internal/DisclaimerMessage/DisclaimerMessage.js.map +1 -1
  205. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js +1 -1
  206. package/dist/es-legacy/components/internal/IssuerList/IssuerList.js.map +1 -1
  207. package/dist/es-legacy/components/internal/OpenInvoice/utils.js.map +1 -1
  208. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js +1 -1
  209. package/dist/es-legacy/components/internal/QRLoader/QRLoader.js.map +1 -1
  210. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js +1 -1
  211. package/dist/es-legacy/components/internal/SecuredFields/SFP/SecuredFieldsProvider.js.map +1 -1
  212. package/dist/es-legacy/components/internal/UIElement/UIElement.js +1 -1
  213. package/dist/es-legacy/components/internal/UIElement/UIElement.js.map +1 -1
  214. package/dist/es-legacy/components/tx-variants.js +1 -1
  215. package/dist/es-legacy/components/tx-variants.js.map +1 -1
  216. package/dist/es-legacy/core/Analytics/Analytics.js +1 -1
  217. package/dist/es-legacy/core/Analytics/Analytics.js.map +1 -1
  218. package/dist/es-legacy/core/Analytics/AnalyticsErrorEvent.js +2 -0
  219. package/dist/es-legacy/core/Analytics/AnalyticsErrorEvent.js.map +1 -0
  220. package/dist/es-legacy/core/Analytics/AnalyticsEvent.js +2 -0
  221. package/dist/es-legacy/core/Analytics/AnalyticsEvent.js.map +1 -0
  222. package/dist/es-legacy/core/Analytics/AnalyticsInfoEvent.js +2 -0
  223. package/dist/es-legacy/core/Analytics/AnalyticsInfoEvent.js.map +1 -0
  224. package/dist/es-legacy/core/Analytics/AnalyticsLogEvent.js +2 -0
  225. package/dist/es-legacy/core/Analytics/AnalyticsLogEvent.js.map +1 -0
  226. package/dist/es-legacy/core/Analytics/utils.js +1 -1
  227. package/dist/es-legacy/core/Analytics/utils.js.map +1 -1
  228. package/dist/es-legacy/core/Environment/Environment.js +1 -1
  229. package/dist/es-legacy/core/Environment/Environment.js.map +1 -1
  230. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/filters.js +1 -1
  231. package/dist/es-legacy/core/ProcessResponse/PaymentMethods/filters.js.map +1 -1
  232. package/dist/es-legacy/core/Services/analytics/collect-id.js +1 -1
  233. package/dist/es-legacy/core/core.js +1 -1
  234. package/dist/es-legacy/core/core.js.map +1 -1
  235. package/dist/es-legacy/core/utils.js +1 -1
  236. package/dist/es-legacy/core/utils.js.map +1 -1
  237. package/dist/es-legacy/index.js +1 -1
  238. package/dist/es-legacy/utils/base64.js.map +1 -1
  239. package/package.json +6 -7
  240. package/styles/adyen.css +7 -2
  241. package/dist/es/components/Riverty/config.js +0 -2
  242. package/dist/es/components/Riverty/config.js.map +0 -1
  243. package/dist/es/core/Analytics/analyticsPreProcessor.js +0 -2
  244. package/dist/es/core/Analytics/analyticsPreProcessor.js.map +0 -1
  245. package/dist/es-legacy/components/Riverty/config.js +0 -2
  246. package/dist/es-legacy/components/Riverty/config.js.map +0 -1
  247. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js +0 -2
  248. package/dist/es-legacy/core/Analytics/analyticsPreProcessor.js.map +0 -1
@@ -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=c.billingAddress,{firstName:e,lastName:r}=t,o=l(t,["firstName","lastName"]);c.billingAddress=a({},o)}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};
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";import{AnalyticsInfoEvent as p}from"../../../core/Analytics/AnalyticsInfoEvent.js";function a(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(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){a(t,e,r[e])}))}return t}function h(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}class l{buildElementProps(t){this.props=this.formatProps(u({},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=u({},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();return c.paymentMethod&&s&&(c.paymentMethod.checkoutAttemptId=s),h(u({},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((()=>{if(!this.props.isDropin){const t=new p({type:s});this.submitAnalytics(t)}})));return this}update(t){return this.props=this.formatProps(u({},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){a(this,"_id",`${this.constructor.type}-${r()}`),a(this,"core",void 0),a(this,"props",void 0),a(this,"state",{}),a(this,"_component",void 0),a(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)}}a(l,"defaultProps",{});export{l as default};
2
2
  //# sourceMappingURL=BaseElement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport type { AnalyticsInitialEvent, SendAnalyticsObject } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: SendAnalyticsObject) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n // Workaround, to be fixed properly\n // Remove the firstName & lastName in the billingAddress for non Riverty components\n // @ts-ignore type exists\n if (this.props.type !== 'riverty' && componentData.billingAddress) {\n const { firstName, lastName, ...rest } = componentData.billingAddress;\n componentData.billingAddress = { ...rest };\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n this.submitAnalytics({ type: ANALYTICS_RENDERED_STR });\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","getProp","clientData","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","type","billingAddress","firstName","lastName","rest","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"qhDAuBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,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,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuCpE,KAAKI,YAAmB,6DAIvEJ,KAAK2D,KAAOC,EACZ5D,KAAKF,kBAAkBG,GAEvBD,KAAKU,eAAiBV,KAAKU,eAAe2D,KAAKrE,KACnD,EAhBA6D,EAVWhE,EAUMyE,eAAe"}
1
+ {"version":3,"file":"BaseElement.js","sources":["../../../../../src/components/internal/BaseElement/BaseElement.ts"],"sourcesContent":["import { ComponentChild, h, render } from 'preact';\nimport getProp from '../../../utils/getProp';\nimport uuid from '../../../utils/uuid';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { ANALYTICS_RENDERED_STR, NO_CHECKOUT_ATTEMPT_ID } from '../../../core/Analytics/constants';\n\nimport type { ICore } from '../../../core/types';\nimport type { BaseElementProps, IBaseElement } from './types';\nimport type { PaymentData } from '../../../types/global-types';\nimport { AnalyticsInitialEvent } from '../../../core/Analytics/types';\nimport { off, on } from '../../../utils/listenerUtils';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\nimport { AnalyticsEvent } from '../../../core/Analytics/AnalyticsEvent';\n\n/**\n * Verify if the first parameter is instance of Core.\n * We do not use 'instanceof' to avoid importing the Core class directly into this class.\n * @param checkout\n */\nfunction assertIsCoreInstance(checkout: ICore): checkout is ICore {\n if (!checkout) return false;\n const isCoreObject = typeof checkout.initialize === 'function' && typeof checkout.createFromAction === 'function';\n return isCoreObject;\n}\n\nabstract class BaseElement<P extends BaseElementProps> implements IBaseElement {\n public readonly _id = `${this.constructor['type']}-${uuid()}`;\n public readonly core: ICore;\n\n public props: P;\n public state: any = {};\n public _component;\n\n protected _node: HTMLElement = null;\n\n protected static defaultProps = {};\n\n constructor(checkout: ICore, props?: P) {\n const isCoreInstance = assertIsCoreInstance(checkout);\n\n if (!isCoreInstance) {\n throw new AdyenCheckoutError(\n 'IMPLEMENTATION_ERROR',\n `Trying to initialise the component '${this.constructor['type']}' without a reference to an instance of AdyenCheckout`\n );\n }\n\n this.core = checkout;\n this.buildElementProps(props);\n\n this.handleKeyPress = this.handleKeyPress.bind(this);\n }\n\n protected buildElementProps(componentProps?: P) {\n this.props = this.formatProps({ ...this.constructor['defaultProps'], ...componentProps });\n }\n\n /**\n * Executed during creation of any payment element.\n * Gives a chance to any paymentMethod to format the props we're receiving.\n */\n protected formatProps(props: P) {\n return props;\n }\n\n /**\n * Executed on the `data` getter.\n * Returns the component data necessary for the /payments request\n */\n protected formatData(): any {\n return {};\n }\n\n /* eslint-disable-next-line */\n protected setUpAnalytics(setUpAnalyticsObj: AnalyticsInitialEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected submitAnalytics(analyticsObj?: AnalyticsEvent) {\n return null;\n }\n\n /* eslint-disable-next-line */\n protected handleKeyPress(e: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) {\n return null;\n }\n\n protected setState(newState: object): void {\n this.state = { ...this.state, ...newState };\n }\n\n /**\n * Returns the component payment data ready to submit to the Checkout API\n * Note: this does not ensure validity, check isValid first\n */\n public get data(): PaymentData {\n const clientData = getProp(this.props, 'modules.risk.data');\n const checkoutAttemptId = getProp(this.props, 'modules.analytics.getCheckoutAttemptId')?.() ?? NO_CHECKOUT_ATTEMPT_ID; // NOTE: we never expect to see this \"failed\" value, but, just in case...\n const order = this.state.order || this.props.order;\n const componentData = this.formatData();\n\n if (componentData.paymentMethod && checkoutAttemptId) {\n componentData.paymentMethod.checkoutAttemptId = checkoutAttemptId;\n }\n\n return {\n ...(clientData && { riskData: { clientData } }),\n ...(order && { order: { orderData: order.orderData, pspReference: order.pspReference } }),\n ...componentData,\n clientStateDataIndicator: true\n };\n }\n\n /**\n * Method used to make the payment method active\n * (Useful when there are different payment methods available and activating one PM must trigger a specific task)\n */\n public activate(): void {\n return;\n }\n\n public render(): ComponentChild | Error {\n // render() not implemented in the element\n throw new Error('Payment method cannot be rendered.');\n }\n\n /**\n * Mounts an element into the dom\n * @param domNode - Node (or selector) where we will mount the payment element\n * @returns this - the payment element instance we mounted\n */\n public mount(domNode: HTMLElement | string): this {\n const node = typeof domNode === 'string' ? document.querySelector<HTMLElement>(domNode) : domNode;\n\n if (!node) {\n throw new Error('Component could not mount. Root node was not found.');\n }\n\n const setupAnalytics = !this._node;\n\n if (this._node) {\n this.unmount(); // new, if this._node exists then we are \"remounting\" so we first need to unmount if it's not already been done\n }\n\n this._node = node;\n\n // Add listener for key press events, notably 'Enter' key presses\n on(this._node, 'keypress', this.handleKeyPress, false);\n\n this._component = this.render();\n\n render(this._component, node);\n\n // Set up analytics (once, since this._node is currently undefined) now that we have mounted and rendered\n if (setupAnalytics) {\n if (this.props.modules && this.props.modules.analytics) {\n this.setUpAnalytics({\n containerWidth: node && node.offsetWidth,\n component: !this.props.isDropin ? (this.constructor['analyticsType'] ?? this.constructor['type']) : 'dropin',\n flavor: !this.props.isDropin ? 'components' : 'dropin'\n }).then(() => {\n // Once the initial analytics set up call has been made...\n // ...create an analytics event declaring that the component has been rendered\n // (The dropin will do this itself from DropinComponent once the PM list has rendered)\n if (!this.props.isDropin) {\n const event = new AnalyticsInfoEvent({ type: ANALYTICS_RENDERED_STR });\n this.submitAnalytics(event);\n }\n });\n }\n }\n\n return this;\n }\n\n /**\n * Updates props, resets the internal state and remounts the element.\n *\n * @param props - props to update\n * @returns this - the element instance\n */\n public update(props: Partial<P>): this {\n this.props = this.formatProps({ ...this.props, ...props });\n this.state = {};\n\n return this.unmount().mount(this._node); // for new mount fny\n }\n\n /**\n * Unmounts a payment element from the DOM\n */\n public unmount(): this {\n // Remove listener\n off(this._node, 'keypress', this.handleKeyPress);\n\n if (this._node) {\n render(null, this._node);\n }\n\n return this;\n }\n\n /**\n * Unmounts an element and removes it from the parent instance\n * For \"destroy\" type cleanup - when you don't intend to use the component again\n */\n public remove() {\n this.unmount();\n\n if (this.core) {\n this.core.remove(this);\n }\n }\n}\n\nexport default BaseElement;\n"],"names":["BaseElement","buildElementProps","componentProps","this","props","formatProps","_object_spread","constructor","formatData","setUpAnalytics","setUpAnalyticsObj","submitAnalytics","analyticsObj","handleKeyPress","e","setState","newState","state","data","getProp","clientData","checkoutAttemptId","NO_CHECKOUT_ATTEMPT_ID","order","componentData","paymentMethod","_object_spread_props","riskData","orderData","pspReference","clientStateDataIndicator","activate","render","Error","mount","domNode","node","document","querySelector","setupAnalytics","_node","_this_constructor_analyticsType","unmount","on","_component","modules","analytics","containerWidth","offsetWidth","component","isDropin","flavor","then","event","AnalyticsInfoEvent","type","ANALYTICS_RENDERED_STR","update","off","remove","core","checkout","_define_property","_id","uuid","isCoreInstance","initialize","createFromAction","assertIsCoreInstance","AdyenCheckoutError","bind","defaultProps"],"mappings":"ovCAyBA,MAAeA,EA4BDC,iBAAAA,CAAkBC,GACxBC,KAAKC,MAAQD,KAAKE,YAAYC,EAAA,GAAKH,KAAKI,yBAAgCL,GAC5E,CAMUG,WAAAA,CAAYD,GAClB,OAAOA,CACX,CAMA,UAAAI,GACI,MAAO,CAAC,CACZ,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAGUC,eAAAA,CAAgBC,GACtB,OAAO,IACX,CAGUC,cAAAA,CAAeC,GACrB,OAAO,IACX,CAEUC,QAAAA,CAASC,GACfb,KAAKc,MAAQX,KAAKH,KAAKc,MAAUD,EACrC,CAMA,QAAWE,GAEmBC,IAAAA,EAD1B,MAAMC,EAAaD,EAAQhB,KAAKC,MAAO,qBACbe,IAAAA,EAA1B,MAAME,EAAoBF,QAAAA,UAAAA,EAAAA,EAAQhB,KAAKC,MAAO,iDAApBe,IAAAA,OAAAA,EAAAA,WAAAA,IAAAA,EAAAA,EAAqEG,EACzFC,EAAQpB,KAAKc,MAAMM,OAASpB,KAAKC,MAAMmB,MACvCC,EAAgBrB,KAAKK,aAM3B,OAJIgB,EAAcC,eAAiBJ,IAC/BG,EAAcC,cAAcJ,kBAAoBA,GAG7CK,OACCN,GAAc,CAA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AO,KAAM7B,KAAKqC,OAGfrC,IACX,CAMA,MAAAwD,GACIxD,KAAKuC,UAEDvC,KAAKyD,MACLzD,KAAKyD,KAAKD,OAAOxD,KAEzB,CAhLAI,WAAAA,CAAYsD,EAAiBzD,GAX7B0D,EAAgBC,KAAAA,MAAM,GAAG5D,KAAKI,YAAmB,QAAIyD,OACrDF,EAAA3D,KAAgByD,YAAhB,GAEAE,EAAA3D,KAAOC,aAAP,GACA0D,EAAA3D,KAAOc,QAAa,IACpB6C,EAAA3D,KAAOyC,kBAAP,GAEAkB,EAAA3D,KAAUqC,QAAqB,MAK3B,MAAMyB,EAnBd,SAA8BJ,GAC1B,QAAKA,IAC+C,mBAAxBA,EAASK,YAAkE,mBAA9BL,EAASM,iBAEtF,CAe+BC,CAAqBP,GAE5C,IAAKI,EACD,MAAM,IAAII,EACN,uBACA,uCAAuClE,KAAKI,YAAmB,6DAIvEJ,KAAKyD,KAAOC,EACZ1D,KAAKF,kBAAkBG,GAEvBD,KAAKU,eAAiBV,KAAKU,eAAeyD,KAAKnE,KACnD,EAhBA2D,EAVW9D,EAUMuE,eAAe"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import a from"../Link/Link.js";function n({message:t,urls:r}){return e("span",{className:"adyen-checkout-disclaimer__label"},e(i,{message:t,urls:r}))}function i({message:n,urls:i}){const l="string"==typeof n,o=i.every((e=>"string"==typeof e&&r(e)));return l&&o?e(t,null,s(n,i.map((t=>function(r){return e(a,{to:t},r)})))):null}export{i as LabelOnlyDisclaimerMessage,n as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{isValidHttpUrl as r}from"../../../utils/isValidURL.js";import{interpolateElement as s}from"../../../language/utils.js";import a from"../Link/Link.js";function n({message:t,urls:r=[]}){return e("span",{className:"adyen-checkout-disclaimer__label"},e(i,{message:t,urls:r}))}function i({message:n,urls:i}){const l="string"==typeof n,o=i.every((e=>"string"==typeof e&&r(e)));return l&&o?e(t,null,s(n,i.map((t=>function(r){return e(a,{to:t},r)})))):null}export{i as LabelOnlyDisclaimerMessage,n as default};
2
2
  //# sourceMappingURL=DisclaimerMessage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText: string;\n link: string;\n}\n\ninterface InternalDisclaimerMsgObject {\n message: string;\n urls: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n */\n\nexport default function DisclaimerMessage({ message, urls }: InternalDisclaimerMsgObject) {\n return (\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls }: InternalDisclaimerMsgObject) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n return (\n <Fragment>\n {interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n )}\n </Fragment>\n );\n}\n"],"names":["DisclaimerMessage","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","Fragment","interpolateElement","map","translation","Link","to"],"mappings":"mPAyBe,SAASA,GAAkBC,QAAEA,EAAOC,KAAEA,IACjD,OACIC,EAACC,OAAAA,CAAKC,UAAU,oCACZF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,IAClD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,OAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,KAC9E,OAAKH,GAAiBC,EAGlBL,EAACS,EACIC,KAAAA,EACGZ,EACAC,EAAKY,KAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,MAXoB,IAgB5C"}
1
+ {"version":3,"file":"DisclaimerMessage.js","sources":["../../../../../src/components/internal/DisclaimerMessage/DisclaimerMessage.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { isValidHttpUrl } from '../../../utils/isValidURL';\nimport './DisclaimerMessage.scss';\nimport { interpolateElement } from '../../../language/utils';\nimport Link from '../Link';\n\nexport interface DisclaimerMsgObject {\n message: string;\n linkText: string;\n link: string;\n}\n\ninterface InternalDisclaimerMsgObject {\n message: string;\n urls?: Array<string>;\n}\n\n/**\n * props: {\n * message: 'By continuing you agree with the %#terms and conditions%#',\n * urls: ['https://www.adyen.com']\n * }\n * String inside the '%#' token pair will be rendered as an anchor element.\n */\n\nexport default function DisclaimerMessage({ message, urls = [] }: InternalDisclaimerMsgObject) {\n return (\n <span className=\"adyen-checkout-disclaimer__label\">\n <LabelOnlyDisclaimerMessage message={message} urls={urls} />\n </span>\n );\n}\n\nexport function LabelOnlyDisclaimerMessage({ message, urls }: InternalDisclaimerMsgObject) {\n const messageIsStr = typeof message === 'string';\n const validUrls = urls.every(url => typeof url === 'string' && isValidHttpUrl(url));\n if (!messageIsStr || !validUrls) return null;\n\n return (\n <Fragment>\n {interpolateElement(\n message,\n urls.map(\n // for each URL in the URLs array, return a createLink function\n url =>\n function createLink(translation) {\n return <Link to={url}>{translation}</Link>;\n }\n )\n )}\n </Fragment>\n );\n}\n"],"names":["DisclaimerMessage","message","urls","h","span","className","LabelOnlyDisclaimerMessage","messageIsStr","validUrls","every","url","isValidHttpUrl","Fragment","interpolateElement","map","translation","Link","to"],"mappings":"mPAyBe,SAASA,GAAkBC,QAAEA,EAAOC,KAAEA,EAAO,KACxD,OACIC,EAACC,OAAAA,CAAKC,UAAU,oCACZF,EAACG,EAAAA,CAA2BL,QAASA,EAASC,KAAMA,IAGhE,CAEO,SAASI,GAA2BL,QAAEA,EAAOC,KAAEA,IAClD,MAAMK,EAAkC,iBAAZN,EACtBO,EAAYN,EAAKO,OAAMC,GAAsB,iBAARA,GAAoBC,EAAeD,KAC9E,OAAKH,GAAiBC,EAGlBL,EAACS,EACIC,KAAAA,EACGZ,EACAC,EAAKY,KAEDJ,GACI,SAAoBK,GAChB,OAAOZ,EAACa,EAAAA,CAAKC,GAAIP,GAAMK,EAC3B,MAXoB,IAgB5C"}
@@ -1,2 +1,2 @@
1
- import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useCallback as r,useRef as o,useEffect as i}from"../../../external/preact/hooks/dist/hooks.js";import n from"../../../utils/useForm/useForm.js";import a from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import h from"../DisclaimerMessage/DisclaimerMessage.js";import p from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as f,ANALYTICS_FEATURED_ISSUER as y,ANALYTICS_SELECTED_STR as b,ANALYTICS_DISPLAYED_STR as j,ANALYTICS_SEARCH_DEBOUNCE_TIME as v,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as C}from"../../../core/Analytics/constants.js";import{debounce as O}from"../../../utils/debounce.js";function S(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function F(e,t){if(null==e)return{};var s,r,o=function(e,t){if(null==e)return{};var s,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||(o[s]=e[s]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)s=i[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s])}return o}const w=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find((t=>t.id===e)))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},_=["issuer"],I={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function P(P){var{items:k,placeholder:E,issuer:M,highlightedIds:A=[],showContextualElement:T,contextualText:V}=P,B=F(P,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText"]);const{i18n:D}=c(),{handleChangeFor:N,triggerValidation:R,data:L,valid:G,errors:$,isValid:K}=n({schema:_,defaultData:{issuer:M},rules:I}),[q,z]=s("ready"),[H,J]=s(1),{setSRMessagesFromObjects:Q,shouldMoveFocusSR:U}=m(),W=null==Q?void 0:Q({});this.setStatus=e=>{z(e)};const X=r((e=>t=>{const s=1===e?f:y,r=k.find((e=>e.id===t.target.value));B.onSubmitAnalytics({type:b,target:s,issuer:r.name}),J(e),N("issuer")(t)}),[N]),Y=r((e=>{e&&B.onSubmitAnalytics({type:j,target:f})}),[]),Z=o(O(B.onSubmitAnalytics,v)),ee=r((()=>{Z.current({type:C,target:x})}),[]);i((()=>{B.onChange({data:L,valid:G,errors:$,isValid:K});const e=null==W?void 0:W({errors:$,isValidating:!0});(null==e?void 0:e.action)===d&&U&&g(".adyen-checkout__issuer-list","issuer-list")}),[L,G,$,K]),this.showValidation=()=>{R()};const{highlightedItems:te}=k.reduce(((e,t)=>(A.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})))),r.forEach((function(t){S(e,t,s[t])}))}return e}({},t)),e)),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!te.length&&e(t,null,e(l,{selectedIssuerId:0===H?L.issuer:null,items:te,onChange:X(0)}),e(u,null)),e(a,{label:D.get("issuerList.selectField.label"),errorMessage:(se=$.issuer,se&&se.errorMessage?D.get(se.errorMessage):!!se),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:T,contextualText:V},e(p,{items:k,selectedValue:1===H?L.issuer:null,placeholder:E,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:X(1),onListToggle:Y,onInput:ee})),B.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(h,{message:D.get(B.termsAndConditions.translationKey),urls:B.termsAndConditions.urls})),B.showPayButton&&B.payButton({status:q,label:w({issuer:L.issuer,items:[...k,...te]},D)}));var se}P.defaultProps={onChange:()=>{}};export{P as default};
1
+ import{createElement as e,Fragment as t}from"../../../external/preact/dist/preact.js";import{useState as s,useCallback as r,useRef as o,useEffect as n}from"../../../external/preact/hooks/dist/hooks.js";import i from"../../../utils/useForm/useForm.js";import a from"../FormFields/Field/Field.js";import l from"./IssuerButtonGroup/IssuerButtonGroup.js";import u from"../ContentSeparator/ContentSeparator.js";import{useCoreContext as c}from"../../../core/Context/CoreProvider.js";import m from"../../../core/Errors/useSRPanelContext.js";import{ERROR_ACTION_FOCUS_FIELD as d}from"../../../core/Errors/constants.js";import{setFocusOnField as g}from"../../../utils/setFocus.js";import f from"../DisclaimerMessage/DisclaimerMessage.js";import h from"../FormFields/Select/Select.js";import{ANALYTICS_LIST as p,ANALYTICS_FEATURED_ISSUER as y,ANALYTICS_SELECTED_STR as b,ANALYTICS_DISPLAYED_STR as j,ANALYTICS_SEARCH_DEBOUNCE_TIME as v,ANALYTICS_LIST_SEARCH as x,ANALYTICS_INPUT_STR as C}from"../../../core/Analytics/constants.js";import{debounce as O}from"../../../utils/debounce.js";import{AnalyticsInfoEvent as S}from"../../../core/Analytics/AnalyticsInfoEvent.js";function F(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function w(e,t){if(null==e)return{};var s,r,o=function(e,t){if(null==e)return{};var s,r,o={},n=Object.keys(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||(o[s]=e[s]);return o}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)s=n[r],t.indexOf(s)>=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(o[s]=e[s])}return o}const I=({issuer:e,items:t},s)=>{var r;const o=null===(r=t.find((t=>t.id===e)))||void 0===r?void 0:r.name;return e&&o?`${s.get("continueTo")} ${o}`:s.get("continue")},_=["issuer"],A={issuer:{validate:e=>!!e&&e.length>0,errorMessage:"issuerList.selectField.contextualText",modes:["blur"]}};function E(E){var{items:P,placeholder:k,issuer:M,highlightedIds:T=[],showContextualElement:V,contextualText:B}=E,D=w(E,["items","placeholder","issuer","highlightedIds","showContextualElement","contextualText"]);const{i18n:N}=c(),{handleChangeFor:R,triggerValidation:L,data:G,valid:$,errors:K,isValid:q}=i({schema:_,defaultData:{issuer:M},rules:A}),[z,H]=s("ready"),[J,Q]=s(1),{setSRMessagesFromObjects:U,shouldMoveFocusSR:W}=m(),X=null==U?void 0:U({});this.setStatus=e=>{H(e)};const Y=r((e=>t=>{const s=1===e?p:y,r=P.find((e=>e.id===t.target.value)),o=new S({type:b,target:s,issuer:r.name});D.onSubmitAnalytics(o),Q(e),R("issuer")(t)}),[R]),Z=r((e=>{if(e){const e=new S({type:j,target:p});D.onSubmitAnalytics(e)}}),[]),ee=o(O(D.onSubmitAnalytics,v)),te=r((()=>{ee.current({type:C,target:x})}),[]);n((()=>{D.onChange({data:G,valid:$,errors:K,isValid:q});const e=null==X?void 0:X({errors:K,isValidating:!0});(null==e?void 0:e.action)===d&&W&&g(".adyen-checkout__issuer-list","issuer-list")}),[G,$,K,q]),this.showValidation=()=>{L()};const{highlightedItems:se}=P.reduce(((e,t)=>(T.includes(t.id)&&e.highlightedItems.push(function(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},r=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(s).filter((function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})))),r.forEach((function(t){F(e,t,s[t])}))}return e}({},t)),e)),{highlightedItems:[]});return e("div",{className:"adyen-checkout__issuer-list"},!!se.length&&e(t,null,e(l,{selectedIssuerId:0===J?G.issuer:null,items:se,onChange:Y(0)}),e(u,null)),e(a,{label:N.get("issuerList.selectField.label"),errorMessage:(re=K.issuer,re&&re.errorMessage?N.get(re.errorMessage):!!re),classNameModifiers:["issuer-list"],name:"issuer",showContextualElement:V,contextualText:B},e(h,{items:P,selectedValue:1===J?G.issuer:null,placeholder:k,name:"issuer",className:"adyen-checkout__issuer-list__dropdown",onChange:Y(1),onListToggle:Z,onInput:te})),D.termsAndConditions&&e("div",{className:"adyen-checkout__issuer-list__termsAndConditions"},e(f,{message:N.get(D.termsAndConditions.translationKey),urls:D.termsAndConditions.urls})),D.showPayButton&&D.payButton({status:z,label:I({issuer:G.issuer,items:[...P,...se]},N)}));var re}E.defaultProps={onChange:()=>{}};export{E as default};
2
2
  //# sourceMappingURL=IssuerList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n props.onSubmitAnalytics({ type: ANALYTICS_SELECTED_STR, target, issuer: issuerObj.name });\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n props.onSubmitAnalytics({ type: ANALYTICS_DISPLAYED_STR, target: ANALYTICS_LIST });\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","onSubmitAnalytics","ANALYTICS_SELECTED_STR","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"+hDA6BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC,wBAAuBC,mBAC1F,MAAMlB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,MAAOtB,KAEJuB,EAAQC,GAAaC,EAAS,UAC9BC,EAAWC,GAAgBF,EAAAA,IAE5BG,yBAAEA,EAAwBC,kBAAEA,GAAsBC,IAClDC,EAAuCH,aAAAA,EAAAA,EAA2B,IAIxEI,KAAKR,UAAYS,IACbT,EAAUS,EAAAA,EAGd,MAAMC,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EY6E,GAmEkB9D,EAAO5B,OAnEf0F,IAASA,GAAM7E,aAAeX,EAAKM,IAAIkF,GAAM7E,gBAAkB6E,IAoErFC,mBAAoB,CAAC,eACrBpF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB6D,EAACW,EAAAA,CACG3F,MAAOA,EACP4F,cAA6DnE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN4E,UAAW,wCACXhB,SAAUvB,EAAAA,GACVkD,aAAcvC,EACdwC,QAASjC,MAIhBzC,EAAM2E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAAShG,EAAKM,IAAIa,EAAM2E,mBAAmBG,gBAAiBC,KAAM/E,EAAM2E,mBAAmBI,QAIrH/E,EAAMgF,eACHhF,EAAMiF,UAAU,CACZrE,SACAwD,MAAO1F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAUyE,KAAqBxE,MA9FlFwF,IAAAA,EAkG5B,CAEA3E,EAAWwF,aAAe,CACtBpC,SAAU"}
1
+ {"version":3,"file":"IssuerList.js","sources":["../../../../../src/components/internal/IssuerList/IssuerList.tsx"],"sourcesContent":["import { Fragment, h } from 'preact';\nimport { useState, useEffect, useCallback, useRef } from 'preact/hooks';\nimport useForm from '../../../utils/useForm';\nimport Field from '../FormFields/Field';\nimport IssuerButtonGroup from './IssuerButtonGroup';\nimport ContentSeparator from '../ContentSeparator';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport { ValidatorRules } from '../../../utils/Validator/types';\nimport { IssuerListProps } from './types';\nimport './IssuerList.scss';\nimport useSRPanelContext from '../../../core/Errors/useSRPanelContext';\nimport { SetSRMessagesReturnFn } from '../../../core/Errors/SRPanelProvider';\nimport { SetSRMessagesReturnObject } from '../../../core/Errors/types';\nimport { ERROR_ACTION_FOCUS_FIELD } from '../../../core/Errors/constants';\nimport { setFocusOnField } from '../../../utils/setFocus';\nimport DisclaimerMessage from '../DisclaimerMessage';\nimport Select from '../FormFields/Select';\nimport { SelectTargetObject } from '../FormFields/Select/types';\nimport {\n ANALYTICS_DISPLAYED_STR,\n ANALYTICS_FEATURED_ISSUER,\n ANALYTICS_INPUT_STR,\n ANALYTICS_LIST,\n ANALYTICS_LIST_SEARCH,\n ANALYTICS_SEARCH_DEBOUNCE_TIME,\n ANALYTICS_SELECTED_STR\n} from '../../../core/Analytics/constants';\nimport { debounce } from '../../../utils/debounce';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst payButtonLabel = ({ issuer, items }, i18n): string => {\n const issuerName = items.find(i => i.id === issuer)?.name;\n if (!issuer || !issuerName) return i18n.get('continue');\n return `${i18n.get('continueTo')} ${issuerName}`;\n};\n\nconst schema = ['issuer'];\nconst validationRules: ValidatorRules = {\n issuer: {\n validate: issuer => !!issuer && issuer.length > 0,\n errorMessage: 'issuerList.selectField.contextualText',\n modes: ['blur']\n }\n};\n\nenum IssuerListInputTypes {\n ButtonGroup,\n Dropdown\n}\n\nfunction IssuerList({ items, placeholder, issuer, highlightedIds = [], showContextualElement, contextualText, ...props }: IssuerListProps) {\n const { i18n } = useCoreContext();\n const { handleChangeFor, triggerValidation, data, valid, errors, isValid } = useForm({\n schema,\n defaultData: { issuer },\n rules: validationRules\n });\n const [status, setStatus] = useState('ready');\n const [inputType, setInputType] = useState<IssuerListInputTypes>(IssuerListInputTypes.Dropdown);\n\n const { setSRMessagesFromObjects, shouldMoveFocusSR } = useSRPanelContext();\n const setSRMessages: SetSRMessagesReturnFn = setSRMessagesFromObjects?.({});\n\n const getErrorMessage = error => (error && error.errorMessage ? i18n.get(error.errorMessage) : !!error);\n\n this.setStatus = newStatus => {\n setStatus(newStatus);\n };\n\n const handleInputChange = useCallback(\n (type: IssuerListInputTypes) => (event: h.JSX.TargetedKeyboardEvent<HTMLInputElement>) => {\n const target = type === IssuerListInputTypes.Dropdown ? ANALYTICS_LIST : ANALYTICS_FEATURED_ISSUER;\n const issuerObj = items.find(issuer => issuer.id === (event.target as SelectTargetObject).value);\n\n const analyticsEvent = new AnalyticsInfoEvent({\n type: ANALYTICS_SELECTED_STR,\n target,\n issuer: issuerObj.name\n });\n props.onSubmitAnalytics(analyticsEvent);\n\n setInputType(type);\n handleChangeFor('issuer')(event);\n },\n [handleChangeFor]\n );\n\n const handleListToggle = useCallback((isOpen: boolean) => {\n if (isOpen) {\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DISPLAYED_STR,\n target: ANALYTICS_LIST\n });\n props.onSubmitAnalytics(event);\n }\n }, []);\n\n const debounceSearchAnalytics = useRef(debounce(props.onSubmitAnalytics, ANALYTICS_SEARCH_DEBOUNCE_TIME));\n\n const handleSearch = useCallback(() => {\n debounceSearchAnalytics.current({ type: ANALYTICS_INPUT_STR, target: ANALYTICS_LIST_SEARCH });\n }, []);\n\n useEffect(() => {\n props.onChange({ data, valid, errors, isValid });\n\n const srPanelResp: SetSRMessagesReturnObject = setSRMessages?.({ errors, isValidating: true });\n if (srPanelResp?.action === ERROR_ACTION_FOCUS_FIELD) {\n // Focus field in error, if required\n if (shouldMoveFocusSR) setFocusOnField('.adyen-checkout__issuer-list', 'issuer-list');\n }\n }, [data, valid, errors, isValid]);\n\n this.showValidation = () => {\n triggerValidation();\n };\n\n const { highlightedItems } = items.reduce(\n (memo, item) => {\n if (highlightedIds.includes(item.id)) memo.highlightedItems.push({ ...item });\n return memo;\n },\n { highlightedItems: [] }\n );\n\n return (\n <div className=\"adyen-checkout__issuer-list\">\n {!!highlightedItems.length && (\n <Fragment>\n <IssuerButtonGroup\n selectedIssuerId={inputType === IssuerListInputTypes.ButtonGroup ? data['issuer'] : null}\n items={highlightedItems}\n onChange={handleInputChange(IssuerListInputTypes.ButtonGroup)}\n />\n <ContentSeparator />\n </Fragment>\n )}\n\n <Field\n label={i18n.get('issuerList.selectField.label')}\n errorMessage={getErrorMessage(errors.issuer)}\n classNameModifiers={['issuer-list']}\n name={'issuer'}\n showContextualElement={showContextualElement}\n contextualText={contextualText}\n >\n <Select\n items={items}\n selectedValue={inputType === IssuerListInputTypes.Dropdown ? data['issuer'] : null}\n placeholder={placeholder}\n name={'issuer'}\n className={'adyen-checkout__issuer-list__dropdown'}\n onChange={handleInputChange(IssuerListInputTypes.Dropdown)}\n onListToggle={handleListToggle}\n onInput={handleSearch}\n />\n </Field>\n\n {props.termsAndConditions && (\n <div className=\"adyen-checkout__issuer-list__termsAndConditions\">\n <DisclaimerMessage message={i18n.get(props.termsAndConditions.translationKey)} urls={props.termsAndConditions.urls} />\n </div>\n )}\n\n {props.showPayButton &&\n props.payButton({\n status,\n label: payButtonLabel({ issuer: data['issuer'], items: [...items, ...highlightedItems] }, i18n)\n })}\n </div>\n );\n}\n\nIssuerList.defaultProps = {\n onChange: () => {}\n};\n\nexport default IssuerList;\n"],"names":["payButtonLabel","issuer","items","i18n","issuerName","find","i","id","name","get","schema","validationRules","validate","length","errorMessage","modes","IssuerList","_param","placeholder","highlightedIds","showContextualElement","contextualText","props","_object_without_properties","useCoreContext","handleChangeFor","triggerValidation","data","valid","errors","isValid","useForm","defaultData","rules","status","setStatus","useState","inputType","setInputType","setSRMessagesFromObjects","shouldMoveFocusSR","useSRPanelContext","setSRMessages","this","newStatus","handleInputChange","useCallback","type","event","target","ANALYTICS_LIST","ANALYTICS_FEATURED_ISSUER","issuerObj","value","analyticsEvent","AnalyticsInfoEvent","ANALYTICS_SELECTED_STR","onSubmitAnalytics","handleListToggle","isOpen","ANALYTICS_DISPLAYED_STR","debounceSearchAnalytics","useRef","debounce","ANALYTICS_SEARCH_DEBOUNCE_TIME","handleSearch","current","ANALYTICS_INPUT_STR","ANALYTICS_LIST_SEARCH","useEffect","onChange","srPanelResp","isValidating","action","ERROR_ACTION_FOCUS_FIELD","setFocusOnField","showValidation","highlightedItems","reduce","memo","item","includes","push","_object_spread","h","div","className","Fragment","IssuerButtonGroup","selectedIssuerId","ContentSeparator","Field","label","error","classNameModifiers","Select","selectedValue","onListToggle","onInput","termsAndConditions","DisclaimerMessage","message","translationKey","urls","showPayButton","payButton","defaultProps"],"mappings":"knDA8BA,MAAMA,EAAiB,EAAGC,SAAQC,SAASC,KACpBD,IAAAA,EAAnB,MAAME,EAAaF,QAAAA,EAAAA,EAAMG,MAAKC,GAAKA,EAAEC,KAAON,WAAzBC,IAAAA,OAAAA,EAAAA,EAAkCM,KACrD,OAAKP,GAAWG,EACT,GAAGD,EAAKM,IAAI,iBAAiBL,IADDD,EAAKM,IAAI,WACI,EAG9CC,EAAS,CAAC,UACVC,EAAkC,CACpCV,OAAQ,CACJW,SAAUX,KAAYA,GAAUA,EAAOY,OAAS,EAChDC,aAAc,wCACdC,MAAO,CAAC,UAShB,SAASC,EAAWC,GAAA,IAAAf,MAAEA,EAAKgB,YAAEA,EAAWjB,OAAEA,EAAMkB,eAAEA,EAAiB,GAAEC,sBAAEA,EAAqBC,eAAEA,GAA1EJ,EAA6FK,EAA7FC,EAAAN,EAAA,CAAEf,QAAOgB,cAAajB,SAAQkB,iBAAqBC,wBAAuBC,mBAC1F,MAAMlB,KAAEA,GAASqB,KACXC,gBAAEA,EAAeC,kBAAEA,EAAiBC,KAAEA,EAAIC,MAAEA,EAAKC,OAAEA,EAAMC,QAAEA,GAAYC,EAAQ,CACjFrB,SACAsB,YAAa,CAAE/B,UACfgC,MAAOtB,KAEJuB,EAAQC,GAAaC,EAAS,UAC9BC,EAAWC,GAAgBF,EAAAA,IAE5BG,yBAAEA,EAAwBC,kBAAEA,GAAsBC,IAClDC,EAAuCH,aAAAA,EAAAA,EAA2B,IAIxEI,KAAKR,UAAYS,IACbT,EAAUS,EAAAA,EAGd,MAAMC,EAAoBC,GACrBC,GAAgCC,IAC7B,MAAMC,MAASF,EAAyCG,EAAiBC,EACnEC,EAAYlD,EAAMG,MAAKJ,GAAUA,EAAOM,KAAQyC,EAAMC,OAA8BI,QAEpFC,EAAiB,IAAIC,EAAmB,CAC1CR,KAAMS,EAC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oB,CAAC,eACrBtF,KAAM,SACNY,sBAAuBA,EACvBC,eAAgBA,GAEhB+D,EAACW,EAAAA,CACG7F,MAAOA,EACP8F,cAA6DrE,IAA9CU,EAA8CV,EAAK,OAAY,KAC9ET,YAAaA,EACbV,KAAM,SACN8E,UAAW,wCACXhB,SAAUzB,EAAAA,GACVoD,aAAcvC,EACdwC,QAASjC,MAIhB3C,EAAM6E,oBACHf,EAACC,MAAAA,CAAIC,UAAU,mDACXF,EAACgB,EAAAA,CAAkBC,QAASlG,EAAKM,IAAIa,EAAM6E,mBAAmBG,gBAAiBC,KAAMjF,EAAM6E,mBAAmBI,QAIrHjF,EAAMkF,eACHlF,EAAMmF,UAAU,CACZvE,SACA0D,MAAO5F,EAAe,CAAEC,OAAQ0B,EAAc,OAAEzB,MAAO,IAAIA,KAAU2E,KAAqB1E,MAxGlF0F,IAAAA,EA4G5B,CAEA7E,EAAW0F,aAAe,CACtBpC,SAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/OpenInvoice/utils.ts"],"sourcesContent":["import { OpenInvoiceActiveFieldsets, OpenInvoiceStateData, OpenInvoiceVisibility } from './types';\nimport Language from '../../../language';\nimport { mapFieldKey as mapFieldKeyAddress } from '../Address/utils';\nimport { StringObject } from '../Address/types';\n\nexport const fieldsetsSchema: Array<keyof OpenInvoiceStateData> = [\n 'companyDetails',\n 'personalDetails',\n 'billingAddress',\n 'deliveryAddress',\n 'bankAccount'\n];\n\nconst isPrefilled = (fieldsetData: object = {}): boolean => Object.keys(fieldsetData).length > 1;\n\nexport const getActiveFieldsData = (activeFieldsets: OpenInvoiceActiveFieldsets, data: OpenInvoiceStateData): OpenInvoiceStateData =>\n Object.keys(data)\n .filter(fieldset => activeFieldsets[fieldset])\n .reduce((acc, cur) => {\n acc[cur] = data[cur];\n return acc;\n }, {});\n\nexport const getInitialActiveFieldsets = (visibility: OpenInvoiceVisibility, data: OpenInvoiceStateData = {}): OpenInvoiceActiveFieldsets =>\n fieldsetsSchema.reduce((acc, fieldset) => {\n const isVisible = visibility[fieldset] !== 'hidden';\n const isDeliveryAddress = fieldset === 'deliveryAddress';\n const billingAddressIsHidden = visibility?.billingAddress === 'hidden';\n\n // The delivery address will be active not only when set as visible\n // but also when the billing address is hidden or when it has prefilled data\n acc[fieldset] = isVisible && (!isDeliveryAddress || billingAddressIsHidden || isPrefilled(data[fieldset]));\n return acc;\n }, {} as OpenInvoiceActiveFieldsets);\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to add the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to add the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n let refKey = key;\n let label;\n\n // Differentiate between address types (billing and delivery)\n const splitKey = refKey.split(':');\n const hasSplitKey = splitKey.length > 1;\n if (hasSplitKey) {\n label = splitKey[0];\n refKey = splitKey[1];\n }\n\n const addressKey = mapFieldKeyAddress(refKey, i18n, countrySpecificLabels);\n // Also use the presence of a label to know that we are dealing with address related fields. (This matters now that addresses can contain first & last name fields.)\n if (addressKey && label) return hasSplitKey ? `${i18n.get(label)} ${addressKey}` : addressKey;\n\n switch (refKey) {\n case 'dateOfBirth':\n case 'shopperEmail':\n case 'telephoneNumber':\n return i18n.get(refKey);\n default:\n break;\n }\n\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them\n return null;\n};\n"],"names":["fieldsetsSchema","getActiveFieldsData","activeFieldsets","data","Object","keys","filter","fieldset","reduce","acc","cur","getInitialActiveFieldsets","visibility","isVisible","isDeliveryAddress","billingAddressIsHidden","billingAddress","fieldsetData","length","isPrefilled","mapFieldKey","key","i18n","countrySpecificLabels","label","refKey","splitKey","split","hasSplitKey","addressKey","mapFieldKeyAddress","get"],"mappings":"wDAKaA,EAAqD,CAC9D,iBACA,kBACA,iBACA,kBACA,eAKSC,EAAsB,CAACC,EAA6CC,IAC7EC,OAAOC,KAAKF,GACPG,QAAOC,GAAYL,EAAgBK,KACnCC,QAAO,CAACC,EAAKC,KACVD,EAAIC,GAAOP,EAAKO,GACTD,IACR,CAAI,GAEFE,EAA4B,CAACC,EAAmCT,EAA6B,CAAA,IACtGH,EAAgBQ,QAAO,CAACC,EAAKF,KACzB,MAAMM,EAAqC,WAAzBD,EAAWL,GACvBO,EAAiC,oBAAbP,EACpBQ,EAAwD,YAA/BH,aAAAA,EAAAA,EAAYI,gBAK3C,OADAP,EAAIF,GAAYM,KAAeC,GAAqBC,GAlBxC,EAACE,EAAuB,KAAgBb,OAAOC,KAAKY,GAAcC,OAAS,EAkBTC,CAAYhB,EAAKI,KACxFE,CAAAA,GACR,CAAkC,GAO5BW,EAAc,CAACC,EAAaC,EAAgBC,KACrD,IACIC,EADAC,EAASJ,EAIb,MAAMK,EAAWD,EAAOE,MAAM,KACxBC,EAAcF,EAASR,OAAS,EAClCU,IACAJ,EAAQE,EAAS,GACjBD,EAASC,EAAS,IAGtB,MAAMG,EAAaC,EAAmBL,EAAQH,EAAMC,GAEpD,GAAIM,GAAcL,EAAO,OAAOI,EAAc,GAAGN,EAAKS,IAAIP,MAAUK,IAAeA,EAEnF,OAAQJ,GACJ,IAAK,cACL,IAAK,eACL,IAAK,kBACD,OAAOH,EAAKS,IAAIN,GAMxB,OAAO,IAAA"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../../src/components/internal/OpenInvoice/utils.ts"],"sourcesContent":["import { OpenInvoiceActiveFieldsets, OpenInvoiceStateData, OpenInvoiceVisibility } from './types';\nimport Language from '../../../language';\nimport { mapFieldKey as mapFieldKeyAddress } from '../Address/utils';\nimport { StringObject } from '../Address/types';\n\nexport const fieldsetsSchema: Array<keyof OpenInvoiceStateData> = [\n 'companyDetails',\n 'personalDetails',\n 'billingAddress',\n 'deliveryAddress',\n 'bankAccount'\n];\n\nconst isPrefilled = (fieldsetData: object = {}): boolean => Object.keys(fieldsetData).length > 1;\n\nexport const getActiveFieldsData = (activeFieldsets: OpenInvoiceActiveFieldsets, data: OpenInvoiceStateData): OpenInvoiceStateData =>\n Object.keys(data)\n .filter(fieldset => activeFieldsets[fieldset])\n .reduce((acc, cur) => {\n acc[cur] = data[cur];\n return acc;\n }, {});\n\nexport const getInitialActiveFieldsets = (visibility: OpenInvoiceVisibility, data: OpenInvoiceStateData = {}): OpenInvoiceActiveFieldsets =>\n fieldsetsSchema.reduce((acc, fieldset) => {\n const isVisible = visibility[fieldset] !== 'hidden';\n const isDeliveryAddress = fieldset === 'deliveryAddress';\n const billingAddressIsHidden = visibility?.billingAddress === 'hidden';\n\n // The delivery address will be active not only when set as visible\n // but also when the billing address is hidden or when it has prefilled data\n acc[fieldset] = isVisible && (!isDeliveryAddress || billingAddressIsHidden || isPrefilled(data[fieldset]));\n return acc;\n }, {} as OpenInvoiceActiveFieldsets);\n\n/**\n * Used by the SRPanel sorting function to tell it whether we need to add the field type to the SR panel message, and, if so, we retrieve the correct translation for the field type.\n * (Whether we need to add the field type depends on whether we know that the error message correctly reflects the label of the field. Ultimately all error messages should do this\n * and this mapping fn will become redundant)\n */\nexport const mapFieldKey = (key: string, i18n: Language, countrySpecificLabels: StringObject): string => {\n let refKey = key;\n let label;\n\n // Differentiate between address types (billing and delivery)\n const splitKey = refKey.split(':');\n const hasSplitKey = splitKey.length > 1;\n\n if (hasSplitKey) {\n label = splitKey[0];\n refKey = splitKey[1];\n }\n\n const addressKey = mapFieldKeyAddress(refKey, i18n, countrySpecificLabels);\n // Also use the presence of a label to know that we are dealing with address related fields. (This matters now that addresses can contain first & last name fields.)\n if (addressKey && label) return hasSplitKey ? `${i18n.get(label)} ${addressKey}` : addressKey;\n\n switch (refKey) {\n case 'dateOfBirth':\n case 'shopperEmail':\n case 'telephoneNumber':\n return i18n.get(refKey);\n default:\n break;\n }\n\n // We know that the translated error messages do contain a reference to the field they refer to, so we won't need to map them\n return null;\n};\n"],"names":["fieldsetsSchema","getActiveFieldsData","activeFieldsets","data","Object","keys","filter","fieldset","reduce","acc","cur","getInitialActiveFieldsets","visibility","isVisible","isDeliveryAddress","billingAddressIsHidden","billingAddress","fieldsetData","length","isPrefilled","mapFieldKey","key","i18n","countrySpecificLabels","label","refKey","splitKey","split","hasSplitKey","addressKey","mapFieldKeyAddress","get"],"mappings":"wDAKaA,EAAqD,CAC9D,iBACA,kBACA,iBACA,kBACA,eAKSC,EAAsB,CAACC,EAA6CC,IAC7EC,OAAOC,KAAKF,GACPG,QAAOC,GAAYL,EAAgBK,KACnCC,QAAO,CAACC,EAAKC,KACVD,EAAIC,GAAOP,EAAKO,GACTD,IACR,CAAI,GAEFE,EAA4B,CAACC,EAAmCT,EAA6B,CAAA,IACtGH,EAAgBQ,QAAO,CAACC,EAAKF,KACzB,MAAMM,EAAqC,WAAzBD,EAAWL,GACvBO,EAAiC,oBAAbP,EACpBQ,EAAwD,YAA/BH,aAAAA,EAAAA,EAAYI,gBAK3C,OADAP,EAAIF,GAAYM,KAAeC,GAAqBC,GAlBxC,EAACE,EAAuB,KAAgBb,OAAOC,KAAKY,GAAcC,OAAS,EAkBTC,CAAYhB,EAAKI,KACxFE,CAAAA,GACR,CAAkC,GAO5BW,EAAc,CAACC,EAAaC,EAAgBC,KACrD,IACIC,EADAC,EAASJ,EAIb,MAAMK,EAAWD,EAAOE,MAAM,KACxBC,EAAcF,EAASR,OAAS,EAElCU,IACAJ,EAAQE,EAAS,GACjBD,EAASC,EAAS,IAGtB,MAAMG,EAAaC,EAAmBL,EAAQH,EAAMC,GAEpD,GAAIM,GAAcL,EAAO,OAAOI,EAAc,GAAGN,EAAKS,IAAIP,MAAUK,IAAeA,EAEnF,OAAQJ,GACJ,IAAK,cACL,IAAK,eACL,IAAK,kBACD,OAAOH,EAAKS,IAAIN,GAMxB,OAAO,IAAA"}
@@ -1,2 +1,2 @@
1
- import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_QR_CODE_DOWNLOAD as h,ANALYTICS_DOWNLOAD_STR as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";function g(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class f extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:g,type:f,onActionHandled:k},{expired:v,completed:q,loading:b}){var C,N,w,T;const{i18n:I,loadingContext:j}=p(),S=l(),x=this.props.qrCodeData?`${j}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,E=(t,o)=>{const r=I.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:S({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(v)return E("error","error.subtitle.payment");if(q)return E("success","creditCard.success");if(b)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=I.get(this.props.timeToPay).split("%@"),D=u(),A=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${f} ${A.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},I.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},I.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:I.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?I.get(this.props.introduction):null===(C=(N=this.props).introduction)||void 0===C?void 0:C.call(N)),e("img",{src:x,alt:I.get("wechatpay.scanqrcode"),onLoad:()=>{null==k||k({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},P[0]," ",e(o,{minutesFromNow:g,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?I.get(this.props.instructions):null===(w=(T=this.props).instructions)||void 0===w?void 0:w.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData),this.props.onSubmitAnalytics({type:_,target:h}),e()},icon:S({imageFolder:"components/"})(`${y}copy`),label:I.get("button.copy")})))}constructor(t){super(t),g(this,"timeoutId",void 0),g(this,"redirectToApp",(t=>{window.location.assign(t)})),g(this,"statusInterval",((t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)})),g(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),g(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),g(this,"onComplete",(t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)})),g(this,"onError",(t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)})),g(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}g(f,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{f as default};
1
+ import{Component as t,createElement as e}from"../../../external/preact/dist/preact.js";import o from"../Countdown/index.js";import r from"../Button/Button.js";import s from"../Spinner/Spinner.js";import a from"../../../core/Services/payment-status.js";import{processResponse as i}from"../../../core/ProcessResponse/process-response.js";import{copyToClipboard as n}from"../../../utils/clipboard.js";import c from"../../../core/Errors/AdyenCheckoutError.js";import{useCoreContext as p}from"../../../core/Context/CoreProvider.js";import d from"../ContentSeparator/ContentSeparator.js";import l from"../../../core/Context/useImage.js";import{useA11yReporter as m}from"../../../core/Errors/useA11yReporter.js";import u from"../../../utils/useAutoFocus.js";import{ANALYTICS_QR_CODE_DOWNLOAD as h,ANALYTICS_DOWNLOAD_STR as _}from"../../../core/Analytics/constants.js";import{PREFIX as y}from"../Icon/constants.js";import{AnalyticsInfoEvent as g}from"../../../core/Analytics/AnalyticsInfoEvent.js";function f(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}class k extends t{componentDidMount(){this.statusInterval()}componentWillUnmount(){clearTimeout(this.timeoutId)}pollStatus(t){clearTimeout(this.timeoutId),this.timeoutId=setTimeout((async()=>{const t=performance.now();await this.checkStatus();const e=performance.now();this.statusInterval(Math.round(e-t))}),t)}render({amount:t,url:a,brandLogo:i,brandName:c,countdownTime:f,type:k,onActionHandled:v},{expired:q,completed:b,loading:C}){var w,N,I,T;const{i18n:j,loadingContext:S}=p(),x=l(),E=this.props.qrCodeData?`${S}utility/v1/barcode.png?type=qrCode&data=${this.props.qrCodeData}&clientKey=${this.props.clientKey}`:this.props.qrCodeImage,A=(t,o)=>{const r=j.get(o);return m(r),e("div",{className:"adyen-checkout__qr-loader adyen-checkout__qr-loader--result"},e("img",{className:"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result",src:x({imageFolder:"components/"})(t),alt:r}),e("div",{className:"adyen-checkout__qr-loader__subtitle"},r))};if(q)return A("error","error.subtitle.payment");if(b)return A("success","creditCard.success");if(C)return e("div",{className:"adyen-checkout__qr-loader"},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{alt:c,src:i,className:"adyen-checkout__qr-loader__brand-logo"})),e(s,null));const P=j.get(this.props.timeToPay).split("%@"),D=u(),R=this.props.classNameModifiers.map((t=>`adyen-checkout__qr-loader--${t}`));return e("div",{className:`adyen-checkout__qr-loader adyen-checkout__qr-loader--${k} ${R.join(" ")}`},i&&e("div",{className:"adyen-checkout__qr-loader__brand-logo-wrapper"},e("img",{src:i,alt:c,className:"adyen-checkout__qr-loader__brand-logo"})),t&&t.value&&t.currency&&e("div",{className:"adyen-checkout__qr-loader__payment_amount"},j.amount(t.value,t.currency)),a&&e("div",{className:"adyen-checkout__qr-loader__app-link"},this.props.redirectIntroduction&&e("div",{className:"adyen-checkout__qr-loader__subtitle"},j.get(this.props.redirectIntroduction)),e(r,{classNameModifiers:["qr-loader"],onClick:()=>this.redirectToApp(a),label:j.get(this.props.buttonLabel)}),e(d,null)),e("div",{ref:D,tabIndex:0,className:"adyen-checkout__qr-loader__subtitle"},"string"==typeof this.props.introduction?j.get(this.props.introduction):null===(w=(N=this.props).introduction)||void 0===w?void 0:w.call(N)),e("img",{src:E,alt:j.get("wechatpay.scanqrcode"),onLoad:()=>{null==v||v({componentType:this.props.type,actionDescription:"qr-code-loaded"})}}),e("div",{className:"adyen-checkout__qr-loader__progress"},e("span",{className:"adyen-checkout__qr-loader__percentage",style:{width:`${this.state.percentage}%`}})),e("div",{className:"adyen-checkout__qr-loader__countdown"},P[0]," ",e(o,{minutesFromNow:f,onTick:this.onTick,onCompleted:this.onTimeUp})," ",P[1]),this.props.instructions&&e("div",{className:"adyen-checkout__qr-loader__instructions"},"string"==typeof this.props.instructions?j.get(this.props.instructions):null===(I=(T=this.props).instructions)||void 0===I?void 0:I.call(T)),this.props.copyBtn&&e("div",{className:"adyen-checkout__qr-loader__actions"},e(r,{inline:!0,variant:"action",onClick:(t,{complete:e})=>{n(this.props.qrCodeData);const o=new g({type:_,target:h});this.props.onSubmitAnalytics(o),e()},icon:x({imageFolder:"components/"})(`${y}copy`),label:j.get("button.copy")})))}constructor(t){super(t),f(this,"timeoutId",void 0),f(this,"redirectToApp",(t=>{window.location.assign(t)})),f(this,"statusInterval",((t=0)=>{if(this.state.expired||this.state.completed)return;this.setState((e=>({timePassed:e.timePassed+this.props.delay+t})));const e=this.state.timePassed>=this.props.throttleTime?this.props.throttledInterval:this.state.delay;this.pollStatus(e)})),f(this,"onTick",(t=>{this.setState({percentage:t.percentage})})),f(this,"onTimeUp",(()=>{this.setState({expired:!0}),clearTimeout(this.timeoutId),this.props.onError(new c("ERROR","Payment Expired"))})),f(this,"onComplete",(t=>{clearTimeout(this.timeoutId),this.setState({completed:!0,loading:!1});const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)})),f(this,"onError",(t=>{if(clearTimeout(this.timeoutId),this.setState({expired:!0,loading:!1}),t.props.payload){const e={data:{details:{payload:t.props.payload},paymentData:this.props.paymentData}};this.props.onComplete(e,this)}const e=new c("ERROR","error result with no payload in response");return this.props.onError(e)})),f(this,"checkStatus",(()=>{const{paymentData:t,clientKey:e,loadingContext:o,throttledInterval:r}=this.props;return a(t,e,o,r).then(i).catch((t=>({type:"network-error",props:t}))).then((t=>{switch(t.type){case"success":this.onComplete(t);break;case"error":this.onError(t);break;default:this.setState({loading:!1})}return t}))})),this.state={buttonStatus:"default",completed:!1,delay:t.delay,expired:!1,loading:!0,percentage:100,timePassed:0}}}f(k,"defaultProps",{delay:2e3,countdownTime:15,onError:()=>{},onComplete:()=>{},throttleTime:6e4,classNameModifiers:[],throttledInterval:1e4,introduction:"wechatpay.scanqrcode",timeToPay:"wechatpay.timetopay",buttonLabel:"openApp"});export{k as default};
2
2
  //# sourceMappingURL=QRLoader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n this.props.onSubmitAnalytics({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","onSubmitAnalytics","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processResponse","catch","response","buttonStatus","defaultProps"],"mappings":"mgCAsBA,MAAMA,UAAiBC,EA8BnBC,iBAAAA,GACIC,KAAKC,gBACT,CAEAC,oBAAAA,GACIC,aAAaH,KAAKI,UACtB,CAiBQC,UAAAA,CAAWC,GACfH,aAAaH,KAAKI,WAGlBJ,KAAKI,UAAYG,YAAWC,UAGxB,MAAMC,EAAQC,YAAYC,YACpBX,KAAKY,cACX,MAAMC,EAAMH,YAAYC,MACxBX,KAAKC,eAAea,KAAKC,MAAMF,EAAMJ,GAAAA,GACtCH,EACP,CAiEAU,MAAAA,EAAOC,OAAEA,EAAMC,IAAEA,EAAGC,UAAEA,EAASC,UAAEA,EAASC,cAAEA,EAAaC,KAAEA,EAAIC,gBAAEA,IAAkCC,QAAEA,EAAOC,UAAEA,EAASC,QAAEA,IAyEtB,IAAAC,EAAAC,EA0BIC,EAAAC,EAlGnG,MAAMC,KAAEA,EAAIC,eAAEA,GAAmBC,IAC3BC,EAAWC,IAEXC,EAAcpC,KAAKqC,MAAMC,WACzB,GAAGN,4CAA8BhC,KAAKqC,MAAMC,wBAAwBtC,KAAKqC,MAAME,YAC/EvC,KAAKqC,MAAMD,YAEXI,EAAa,CAACC,EAAOC,KACvB,MAAMC,EAASZ,EAAKa,IAAIF,GAExB,OADAG,EAAgBF,GAEZG,EAACC,MAAAA,CAAIC,UAAU,+DACXF,EAACG,MAAAA,CACGD,UAAU,0EACVE,IAAKhB,EAAS,CAAEiB,YAAa,eAAxBjB,CAAyCO,GAC9CW,IAAKT,IAETG,EAACC,MAAAA,CAAIC,UAAU,uCAAuCL,GAAAA,EAKlE,GAAInB,EACA,OAAOgB,EAAW,QAAS,0BAG/B,GAAIf,EACA,OAAOe,EAAW,UAAW,sBAGjC,GAAId,E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OwF,EAAmBF,EAAapF,EAAWP,EAAgBmF,GAC7DW,KAAKC,GACLC,OAAMC,IAAa,CAAE3G,KAAM,gBAAiBe,MAAO4F,MACnDH,MAAMnF,IACH,OAAQA,EAAOrB,MACX,IAAK,UACDtB,KAAKuH,WAAW5E,GAChB,MACJ,IAAK,QACD3C,KAAKqH,QAAQ1E,GACb,MACJ,QACI3C,KAAK8G,SAAS,CAAEpF,SAAS,IAEjC,OAAOiB,CAAAA,GACX,IAzHJ3C,KAAKmF,MAAQ,CACT+C,aAAc,UACdzG,WAAW,EACXnB,MAAO+B,EAAM/B,MACbkB,SAAS,EACTE,SAAS,EACT0D,WAAY,IACZ4B,WAAY,EAEpB,EAEAP,EAjBE5G,EAiBYsI,eAAe,CACzB7H,MAAO,IACPe,cAAe,GACfgG,QAAS,OACTE,WAAY,OACZL,aAAc,IACdtD,mBAAoB,GACpBuD,kBAAmB,IACnBxC,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
1
+ {"version":3,"file":"QRLoader.js","sources":["../../../../../src/components/internal/QRLoader/QRLoader.tsx"],"sourcesContent":["import { Component, h } from 'preact';\nimport Countdown from '../Countdown';\nimport Button from '../Button';\nimport Spinner from '../Spinner';\nimport checkPaymentStatus from '../../../core/Services/payment-status';\nimport processResponse from '../../../core/ProcessResponse';\n\nimport './QRLoader.scss';\nimport { QRLoaderProps, QRLoaderState } from './types';\nimport copyToClipboard from '../../../utils/clipboard';\nimport AdyenCheckoutError from '../../../core/Errors/AdyenCheckoutError';\nimport { useCoreContext } from '../../../core/Context/CoreProvider';\nimport ContentSeparator from '../ContentSeparator';\nimport { StatusObject } from '../Await/types';\nimport useImage from '../../../core/Context/useImage';\nimport { useA11yReporter } from '../../../core/Errors/useA11yReporter';\nimport useAutoFocus from '../../../utils/useAutoFocus';\nimport { ANALYTICS_DOWNLOAD_STR, ANALYTICS_QR_CODE_DOWNLOAD } from '../../../core/Analytics/constants';\nimport { PREFIX } from '../Icon/constants';\nimport { AnalyticsInfoEvent } from '../../../core/Analytics/AnalyticsInfoEvent';\n\nconst QRCODE_URL = 'utility/v1/barcode.png?type=qrCode&data=';\n\nclass QRLoader extends Component<QRLoaderProps, QRLoaderState> {\n private timeoutId;\n\n constructor(props) {\n super(props);\n\n this.state = {\n buttonStatus: 'default',\n completed: false,\n delay: props.delay,\n expired: false,\n loading: true,\n percentage: 100,\n timePassed: 0\n };\n }\n\n public static defaultProps = {\n delay: 2000,\n countdownTime: 15,\n onError: () => {},\n onComplete: () => {},\n throttleTime: 60000,\n classNameModifiers: [],\n throttledInterval: 10000,\n introduction: 'wechatpay.scanqrcode',\n timeToPay: 'wechatpay.timetopay',\n buttonLabel: 'openApp'\n };\n\n componentDidMount() {\n this.statusInterval();\n }\n\n componentWillUnmount() {\n clearTimeout(this.timeoutId);\n }\n\n public redirectToApp = (url: string | URL) => {\n window.location.assign(url);\n };\n\n // Retry until getting a complete response from the server, or it times out\n public statusInterval = (responseTime = 0) => {\n // If we are already in the final statuses, do not poll!\n if (this.state.expired || this.state.completed) return;\n\n this.setState(previous => ({ timePassed: previous.timePassed + this.props.delay + responseTime }));\n // Changes interval time to 10 seconds after 1 minute (60 seconds)\n const newDelay = this.state.timePassed >= this.props.throttleTime ? this.props.throttledInterval : this.state.delay;\n this.pollStatus(newDelay);\n };\n\n private pollStatus(delay: number) {\n clearTimeout(this.timeoutId);\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n this.timeoutId = setTimeout(async () => {\n // Wait for previous status call to finish.\n // Also taking the server response time into the consideration to calculate timePassed.\n const start = performance.now();\n await this.checkStatus();\n const end = performance.now();\n this.statusInterval(Math.round(end - start));\n }, delay);\n }\n\n private onTick = (time): void => {\n this.setState({ percentage: time.percentage });\n };\n\n private onTimeUp = (): void => {\n this.setState({ expired: true });\n clearTimeout(this.timeoutId);\n this.props.onError(new AdyenCheckoutError('ERROR', 'Payment Expired'));\n };\n\n private onComplete = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ completed: true, loading: false });\n\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n\n this.props.onComplete(state, this);\n };\n\n private onError = (status: StatusObject): void => {\n clearTimeout(this.timeoutId);\n this.setState({ expired: true, loading: false });\n\n if (status.props.payload) {\n const state = {\n data: {\n details: { payload: status.props.payload },\n paymentData: this.props.paymentData\n }\n };\n this.props.onComplete(state, this);\n }\n\n const error = new AdyenCheckoutError('ERROR', 'error result with no payload in response');\n return this.props.onError(error);\n };\n\n private checkStatus = () => {\n const { paymentData, clientKey, loadingContext, throttledInterval } = this.props;\n\n return checkPaymentStatus(paymentData, clientKey, loadingContext, throttledInterval)\n .then(processResponse)\n .catch(response => ({ type: 'network-error', props: response }))\n .then((status: StatusObject) => {\n switch (status.type) {\n case 'success':\n this.onComplete(status);\n break;\n case 'error':\n this.onError(status);\n break;\n default:\n this.setState({ loading: false });\n }\n return status;\n });\n };\n\n render({ amount, url, brandLogo, brandName, countdownTime, type, onActionHandled }: QRLoaderProps, { expired, completed, loading }) {\n const { i18n, loadingContext } = useCoreContext();\n const getImage = useImage();\n\n const qrCodeImage = this.props.qrCodeData\n ? `${loadingContext}${QRCODE_URL}${this.props.qrCodeData}&clientKey=${this.props.clientKey}`\n : this.props.qrCodeImage;\n\n const finalState = (image, message) => {\n const status = i18n.get(message);\n useA11yReporter(status);\n return (\n <div className=\"adyen-checkout__qr-loader adyen-checkout__qr-loader--result\">\n <img\n className=\"adyen-checkout__qr-loader__icon adyen-checkout__qr-loader__icon--result\"\n src={getImage({ imageFolder: 'components/' })(image)}\n alt={status}\n />\n <div className=\"adyen-checkout__qr-loader__subtitle\">{status}</div>\n </div>\n );\n };\n\n if (expired) {\n return finalState('error', 'error.subtitle.payment');\n }\n\n if (completed) {\n return finalState('success', 'creditCard.success');\n }\n\n if (loading) {\n return (\n <div className=\"adyen-checkout__qr-loader\">\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img alt={brandName} src={brandLogo} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n <Spinner />\n </div>\n );\n }\n\n const timeToPayString = i18n.get(this.props.timeToPay).split('%@');\n\n const qrSubtitleRef = useAutoFocus();\n const classnames = this.props.classNameModifiers.map(m => `adyen-checkout__qr-loader--${m}`);\n\n return (\n <div className={`adyen-checkout__qr-loader adyen-checkout__qr-loader--${type} ${classnames.join(' ')}`}>\n {brandLogo && (\n <div className=\"adyen-checkout__qr-loader__brand-logo-wrapper\">\n <img src={brandLogo} alt={brandName} className=\"adyen-checkout__qr-loader__brand-logo\" />\n </div>\n )}\n\n {amount && amount.value && amount.currency && (\n <div className=\"adyen-checkout__qr-loader__payment_amount\">{i18n.amount(amount.value, amount.currency)}</div>\n )}\n\n {url && (\n <div className=\"adyen-checkout__qr-loader__app-link\">\n {this.props.redirectIntroduction && (\n <div className=\"adyen-checkout__qr-loader__subtitle\">{i18n.get(this.props.redirectIntroduction)}</div>\n )}\n <Button classNameModifiers={['qr-loader']} onClick={() => this.redirectToApp(url)} label={i18n.get(this.props.buttonLabel)} />\n <ContentSeparator />\n </div>\n )}\n\n {/* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */}\n <div ref={qrSubtitleRef} tabIndex={0} className=\"adyen-checkout__qr-loader__subtitle\">\n {typeof this.props.introduction === 'string' ? i18n.get(this.props.introduction) : this.props.introduction?.()}\n </div>\n\n <img\n src={qrCodeImage}\n alt={i18n.get('wechatpay.scanqrcode')}\n onLoad={() => {\n onActionHandled?.({\n componentType: this.props.type,\n actionDescription: 'qr-code-loaded'\n });\n }}\n />\n\n <div className=\"adyen-checkout__qr-loader__progress\">\n <span className=\"adyen-checkout__qr-loader__percentage\" style={{ width: `${this.state.percentage}%` }} />\n </div>\n\n <div className=\"adyen-checkout__qr-loader__countdown\">\n {timeToPayString[0]}&nbsp;\n <Countdown minutesFromNow={countdownTime} onTick={this.onTick} onCompleted={this.onTimeUp} />\n &nbsp;{timeToPayString[1]}\n </div>\n\n {this.props.instructions && (\n <div className=\"adyen-checkout__qr-loader__instructions\">\n {typeof this.props.instructions === 'string' ? i18n.get(this.props.instructions) : this.props.instructions?.()}\n </div>\n )}\n\n {this.props.copyBtn && (\n <div className=\"adyen-checkout__qr-loader__actions\">\n <Button\n inline\n variant=\"action\"\n onClick={(e, { complete }) => {\n copyToClipboard(this.props.qrCodeData);\n\n const event = new AnalyticsInfoEvent({\n type: ANALYTICS_DOWNLOAD_STR,\n target: ANALYTICS_QR_CODE_DOWNLOAD\n });\n this.props.onSubmitAnalytics(event);\n\n complete();\n }}\n icon={getImage({ imageFolder: 'components/' })(`${PREFIX}copy`)}\n label={i18n.get('button.copy')}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default QRLoader;\n"],"names":["QRLoader","Component","componentDidMount","this","statusInterval","componentWillUnmount","clearTimeout","timeoutId","pollStatus","delay","setTimeout","async","start","performance","now","checkStatus","end","Math","round","render","amount","url","brandLogo","brandName","countdownTime","type","onActionHandled","expired","completed","loading","_this_props_introduction","_this_props","_this_props_instructions","_this_props1","i18n","loadingContext","useCoreContext","getImage","useImage","qrCodeImage","props","qrCodeData","clientKey","finalState","image","message","status","get","useA11yReporter","h","div","className","img","src","imageFolder","alt","Spinner","timeToPayString","timeToPay","split","qrSubtitleRef","useAutoFocus","classnames","classNameModifiers","map","m","join","value","currency","redirectIntroduction","Button","onClick","redirectToApp","label","buttonLabel","ContentSeparator","ref","tabIndex","introduction","call","onLoad","componentType","actionDescription","span","style","width","state","percentage","Countdown","minutesFromNow","onTick","onCompleted","onTimeUp","instructions","copyBtn","inline","variant","e","complete","copyToClipboard","event","AnalyticsInfoEvent","ANALYTICS_DOWNLOAD_STR","target","ANALYTICS_QR_CODE_DOWNLOAD","onSubmitAnalytics","icon","PREFIX","constructor","super","_define_property","window","location","assign","responseTime","setState","previous","timePassed","newDelay","throttleTime","throttledInterval","time","onError","AdyenCheckoutError","onComplete","data","details","payload","paymentData","error","checkPaymentStatus","then","processRespon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,MAAMrF,IACH,OAAQA,EAAOrB,MACX,IAAK,UACDtB,KAAKyH,WAAW9E,GAChB,MACJ,IAAK,QACD3C,KAAKuH,QAAQ5E,GACb,MACJ,QACI3C,KAAKgH,SAAS,CAAEtF,SAAS,IAEjC,OAAOiB,CAAAA,GACX,IAzHJ3C,KAAKmF,MAAQ,CACTiD,aAAc,UACd3G,WAAW,EACXnB,MAAO+B,EAAM/B,MACbkB,SAAS,EACTE,SAAS,EACT0D,WAAY,IACZ8B,WAAY,EAEpB,EAEAP,EAjBE9G,EAiBYwI,eAAe,CACzB/H,MAAO,IACPe,cAAe,GACfkG,QAAS,OACTE,WAAY,OACZL,aAAc,IACdxD,mBAAoB,GACpByD,kBAAmB,IACnB1C,aAAc,uBACdpB,UAAW,sBACXgB,YAAa"}
@@ -1,2 +1,2 @@
1
- import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import r from"../lib/CSF/initCSF.js";import n from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as m}from"../../../../core/Errors/constants.js";function O(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}function y(t){for(var s=1;s<arguments.length;s++){var e=null!=arguments[s]?arguments[s]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),i.forEach((function(s){O(t,s,e[s])}))}return t}function F(t,s){return s=null!=s?s:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):function(t){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);s.push.apply(s,e)}return s}(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})),t}class C extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=s(this.rootNode),i=t.reduce(e,{});this.setState({valid:i}),t.forEach((t=>{this.numCharsInField[t]=0})),this.numDateFields=t.filter((t=>t.match(/Expiry/))).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):this.handleOnNoDataRequired()}componentDidUpdate(){this.checkForKCPFields()}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){let s=this.props.loadingContext;var e;const i={rootNode:t,type:this.props.type,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:null!==(e=this.props.placeholders)&&void 0!==e?e:{},showContextualElement:this.props.showContextualElement};this.csf=r(i),this.csfLoadFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))}),this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:F(y({},t.data),{[a]:void 0}),valid:F(y({},t.valid),{[a]:!1}),errors:F(y({},t.errors),{[a]:!1}),hasKoreanFields:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:F(y({},t.valid),{[a]:!1}),hasKoreanFields:!0,isSfpValid:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const s=!!t.error;return s&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,s),this.csf&&this.csf.hasUnsupportedCard(h,t.error),s}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}showValidation(){const{numDateFields:t,state:s}=this;Object.keys(s.valid).reduce(i(t,s),[]).forEach((t=>{const e=o(t,this.rootNode,s);this.handleOnError(e,!!s.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,e.error)}))}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce(((t,s)=>{const e=this.state.errors[s];return t[s]=e?y({isValid:!1,errorMessage:f(e,m),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode},this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}):null,t}),{})}processBinLookupResponse(t,s){var e;if(this.state.detectedUnsupportedBrands&&(this.setState((t=>({errors:F(y({},t.errors),{[h]:!1}),detectedUnsupportedBrands:null}))),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=null==t||null===(e=t.issuingCountryCode)||void 0===e?void 0:e.toLowerCase();const i=(null==s?void 0:s.brand)&&l.includes(s.brand);i&&this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf&&this.csf.brandsFromBinLookup(t,i?s:null)}render(t,s){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},s)}constructor(t){super(t),O(this,"csfLoadFailTimeout",void 0),O(this,"csfLoadFailTimeoutMS",void 0),O(this,"csfConfigFailTimeout",void 0),O(this,"csfConfigFailTimeoutMS",void 0),O(this,"numCharsInField",void 0),O(this,"rootNode",void 0),O(this,"numDateFields",void 0),O(this,"csf",void 0),O(this,"handleOnLoad",void 0),O(this,"handleOnConfigSuccess",void 0),O(this,"handleOnFieldValid",void 0),O(this,"handleOnAllValid",void 0),O(this,"handleOnBrand",void 0),O(this,"handleFocus",void 0),O(this,"handleOnError",void 0),O(this,"handleOnAutoComplete",void 0),O(this,"handleOnNoDataRequired",void 0),O(this,"handleOnTouchstartIOS",void 0),O(this,"handleKeyPressed",void 0),O(this,"state",void 0),O(this,"props",void 0),O(this,"issuingCountryCode",void 0),O(this,"setRootNode",(t=>{this.rootNode=t}));const s={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=s,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=n.handleOnLoad.bind(this),this.handleOnConfigSuccess=n.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=n.handleOnFieldValid.bind(this),this.handleOnAllValid=n.handleOnAllValid.bind(this),this.handleOnBrand=n.handleOnBrand.bind(this),this.handleFocus=n.handleFocus.bind(this),this.handleOnError=n.handleOnError.bind(this),this.handleOnNoDataRequired=n.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=n.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=n.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=n.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}O(C,"defaultProps",d);export{C as default};
1
+ import{Component as t}from"../../../../external/preact/dist/preact.js";import{getFields as s,validFieldsReducer as e,getErrorReducer as i,getErrorObject as o}from"./SFPUtils.js";import r from"../lib/CSF/initCSF.js";import n from"./SecuredFieldsProviderHandlers.js";import d from"./defaultProps.js";import{ENCRYPTED_PWD_FIELD as a,ENCRYPTED_CARD_NUMBER as h,DEDICATED_CARD_COMPONENTS as l,DATE_POLICY_REQUIRED as p,CVC_POLICY_REQUIRED as c}from"../lib/constants.js";import u from"../../../../core/Errors/AdyenCheckoutError.js";import{getErrorMessageFromCode as f}from"../../../../core/Errors/utils.js";import{SF_ErrorCodes as m}from"../../../../core/Errors/constants.js";function O(t,s,e){return s in t?Object.defineProperty(t,s,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[s]=e,t}function y(t){for(var s=1;s<arguments.length;s++){var e=null!=arguments[s]?arguments[s]:{},i=Object.keys(e);"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(e).filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})))),i.forEach((function(s){O(t,s,e[s])}))}return t}function F(t,s){return s=null!=s?s:{},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):function(t){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);s.push.apply(s,e)}return s}(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})),t}class C extends t{componentDidMount(){this.props.rootNode&&this.setRootNode(this.props.rootNode);const t=s(this.rootNode),i=t.reduce(e,{});this.setState({valid:i}),t.forEach((t=>{this.numCharsInField[t]=0})),this.numDateFields=t.filter((t=>t.match(/Expiry/))).length,t.length?(this.destroy(),this.initializeCSF(this.rootNode)):this.handleOnNoDataRequired()}componentDidUpdate(){var t,s;this.checkForKCPFields(),null===(t=(s=this.props).onStateUpdate)||void 0===t||t.call(s,this.state)}componentWillUnmount(){this.csf=null,clearTimeout(this.csfLoadFailTimeout),clearTimeout(this.csfConfigFailTimeout)}initializeCSF(t){let s=this.props.loadingContext;var e;const i={rootNode:t,type:this.props.type,clientKey:this.props.clientKey,cardGroupTypes:this.props.brands,autoFocus:this.props.autoFocus,trimTrailingSeparator:this.props.trimTrailingSeparator,loadingContext:s,keypadFix:this.props.keypadFix,showWarnings:this.props.showWarnings,iframeUIConfig:{sfStyles:this.props.styles},i18n:this.props.i18n,callbacks:{onLoad:this.handleOnLoad,onConfigSuccess:this.handleOnConfigSuccess,onFieldValid:this.handleOnFieldValid,onAllValid:this.handleOnAllValid,onBrand:this.handleOnBrand,onError:this.handleOnError,onFocus:this.handleFocus,onBinValue:this.props.onBinValue,onAutoComplete:this.handleOnAutoComplete,onAdditionalSFConfig:this.props.onAdditionalSFConfig,onAdditionalSFRemoved:this.props.onAdditionalSFRemoved,onTouchstartIOS:this.handleOnTouchstartIOS,onKeyPressed:this.handleKeyPressed},isKCP:this.state.hasKoreanFields,legacyInputMode:this.props.legacyInputMode,minimumExpiryDate:this.props.minimumExpiryDate,implementationType:this.props.implementationType||"components",forceCompat:this.props.forceCompat,maskSecurityCode:this.props.maskSecurityCode,exposeExpiryDate:this.props.exposeExpiryDate,shouldDisableIOSArrowKeys:!!this.props.disableIOSArrowKeys,placeholders:null!==(e=this.props.placeholders)&&void 0!==e?e:{},showContextualElement:this.props.showContextualElement};this.csf=r(i),this.csfLoadFailTimeout=setTimeout((()=>{"ready"!==this.state.status&&(this.setState({status:"csfLoadFailure"}),this.props.onError(new u("ERROR","secured field iframes have failed to load")))}),this.csfLoadFailTimeoutMS)}checkForKCPFields(){let t=!1;if(this.props.koreanAuthenticationRequired&&(t=this.issuingCountryCode?"kr"===this.issuingCountryCode:"kr"===this.props.countryCode),this.state.hasKoreanFields&&!t){const t=t=>({data:F(y({},t.data),{[a]:void 0}),valid:F(y({},t.valid),{[a]:!1}),errors:F(y({},t.errors),{[a]:!1}),hasKoreanFields:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.removeSecuredField(a),this.csf.setKCPStatus(!1)}if(!this.state.hasKoreanFields&&t){const t=t=>({valid:F(y({},t.valid),{[a]:!1}),hasKoreanFields:!0,isSfpValid:!1});this.setState(t,(()=>{this.props.onChange(this.state)})),this.csf.addSecuredField(a),this.csf.setKCPStatus(!0)}}getChildContext(){return{i18n:this.props.i18n}}handleUnsupportedCard(t){const s=!!t.error;return s&&this.setState({detectedUnsupportedBrands:t.detectedBrands}),t.rootNode=this.rootNode,this.handleOnError(t,s),this.csf&&this.csf.hasUnsupportedCard(h,t.error),s}setFocusOn(t){this.csf&&this.csf.setFocusOnFrame(t)}updateStyles(t){this.csf&&this.csf.updateStyles(t)}sfIsOptionalOrHidden(t){return this.csf.sfIsOptionalOrHidden(t)}destroy(){this.csf&&this.csf.destroy()}showValidation(){const{numDateFields:t,state:s}=this;Object.keys(s.valid).reduce(i(t,s),[]).forEach((t=>{const e=o(t,this.rootNode,s);this.handleOnError(e,!!s.detectedUnsupportedBrands),this.csf&&this.csf.isValidated&&this.csf.isValidated(t,e.error)}))}mapErrorsToValidationRuleResult(){return Object.keys(this.state.errors).reduce(((t,s)=>{const e=this.state.errors[s];return t[s]=e?y({isValid:!1,errorMessage:f(e,m),errorI18n:this.props.i18n.get(e),error:e,rootNode:this.rootNode},this.state.detectedUnsupportedBrands&&{detectedBrands:this.state.detectedUnsupportedBrands}):null,t}),{})}processBinLookupResponse(t,s){var e;if(this.state.detectedUnsupportedBrands&&(this.setState((t=>({errors:F(y({},t.errors),{[h]:!1}),detectedUnsupportedBrands:null}))),this.csf&&t)){const t={type:"card",fieldType:"encryptedCardNumber",error:""};this.handleUnsupportedCard(t)}this.issuingCountryCode=null==t||null===(e=t.issuingCountryCode)||void 0===e?void 0:e.toLowerCase();const i=(null==s?void 0:s.brand)&&l.includes(s.brand);i&&this.setState(s,(()=>{this.props.onChange(this.state)})),this.csf&&this.csf.brandsFromBinLookup(t,i?s:null)}render(t,s){return t.render({setRootNode:this.setRootNode,setFocusOn:this.setFocusOn},s)}constructor(t){super(t),O(this,"csfLoadFailTimeout",void 0),O(this,"csfLoadFailTimeoutMS",void 0),O(this,"csfConfigFailTimeout",void 0),O(this,"csfConfigFailTimeoutMS",void 0),O(this,"numCharsInField",void 0),O(this,"rootNode",void 0),O(this,"numDateFields",void 0),O(this,"csf",void 0),O(this,"handleOnLoad",void 0),O(this,"handleOnConfigSuccess",void 0),O(this,"handleOnFieldValid",void 0),O(this,"handleOnAllValid",void 0),O(this,"handleOnBrand",void 0),O(this,"handleFocus",void 0),O(this,"handleOnError",void 0),O(this,"handleOnAutoComplete",void 0),O(this,"handleOnNoDataRequired",void 0),O(this,"handleOnTouchstartIOS",void 0),O(this,"handleKeyPressed",void 0),O(this,"state",void 0),O(this,"props",void 0),O(this,"issuingCountryCode",void 0),O(this,"setRootNode",(t=>{this.rootNode=t}));const s={status:"loading",brand:t.type,errors:{},valid:{},data:{},cvcPolicy:c,expiryDatePolicy:p,isSfpValid:!1,hasKoreanFields:t.hasKoreanFields};this.state=s,this.csfLoadFailTimeout=null,this.csfLoadFailTimeoutMS=3e4,this.csfConfigFailTimeout=null,this.csfConfigFailTimeoutMS=15e3,this.numCharsInField={},this.handleOnLoad=n.handleOnLoad.bind(this),this.handleOnConfigSuccess=n.handleOnConfigSuccess.bind(this),this.handleOnFieldValid=n.handleOnFieldValid.bind(this),this.handleOnAllValid=n.handleOnAllValid.bind(this),this.handleOnBrand=n.handleOnBrand.bind(this),this.handleFocus=n.handleFocus.bind(this),this.handleOnError=n.handleOnError.bind(this),this.handleOnNoDataRequired=n.handleOnNoDataRequired.bind(this),this.handleOnAutoComplete=n.handleOnAutoComplete.bind(this),this.handleOnTouchstartIOS=n.handleOnTouchstartIOS.bind(this),this.handleKeyPressed=n.handleKeyPressed.bind(this),this.processBinLookupResponse=this.processBinLookupResponse.bind(this),this.setFocusOn=this.setFocusOn.bind(this),this.updateStyles=this.updateStyles.bind(this),this.handleUnsupportedCard=this.handleUnsupportedCard.bind(this),this.showValidation=this.showValidation.bind(this),this.destroy=this.destroy.bind(this)}}O(C,"defaultProps",d);export{C as default};
2
2
  //# sourceMappingURL=SecuredFieldsProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SecuredFieldsProvider.js","sources":["../../../../../../src/components/internal/SecuredFields/SFP/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n // TODO\n // if(!this.props.keypadFix){\n // send analytics action because to know if anyone *ever* sets this config prop\n // }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","checkForKCPFields","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","state","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,GACHrB,KAAKsB,mBACT,CAEOC,oBAAAA,GACHvB,KAAKwB,IAAM,KACXC,aAAazB,KAAK0B,oBAClBD,aAAazB,KAAK2B,qBACtB,CAEQR,aAAAA,CAAcS,GAClB,IAAIC,EAAiB7B,KAAKC,MAAM4B,eAiDd,IAAAC,EArClB,MAAMC,EAA8B,CAChC7B,SAAU0B,EACVI,KAAMhC,KAAKC,MAAM+B,KACjBC,UAAWjC,KAAKC,MAAMgC,UACtBC,eAAgBlC,KAAKC,MAAMkC,OAC3BC,UAAWpC,KAAKC,MAAMmC,UACtBC,sBAAuBrC,KAAKC,MAAMoC,sBAClCR,iBACAS,UAAWtC,KAAKC,MAAMqC,UACtBC,aAAcvC,KAAKC,MAAMsC,aACzBC,eAAgB,CACZC,SAAUzC,KAAKC,MAAMyC,QAEzBC,KAAM3C,KAAKC,MAAM0C,KACjBC,UAAW,CACPC,OAAQ7C,KAAK8C,aACbC,gBAAiB/C,KAAK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/SecuredFieldsProvider.ts"],"sourcesContent":["import { Component } from 'preact';\nimport { getErrorObject, getFields, getErrorReducer, validFieldsReducer } from './SFPUtils';\nimport initCSF from '../lib/CSF';\nimport handlers from './SecuredFieldsProviderHandlers';\nimport defaultProps from './defaultProps';\nimport { SFPProps, SFPState, SingleBrandResetObject } from './types';\nimport {\n StylesObject,\n CardErrorData,\n CardFocusData,\n CardBrandData,\n CardAllValidData,\n CardFieldValidData,\n CardAutoCompleteData,\n CardConfigSuccessData,\n CardLoadData,\n SFKeyPressObj\n} from '../lib/types';\nimport { CSFReturnObject, CSFSetupObject } from '../lib/CSF/types';\nimport { CVC_POLICY_REQUIRED, DATE_POLICY_REQUIRED, DEDICATED_CARD_COMPONENTS, ENCRYPTED_CARD_NUMBER, ENCRYPTED_PWD_FIELD } from '../lib/constants';\nimport { BinLookupResponse } from '../../../Card/types';\nimport AdyenCheckoutError from '../../../../core/Errors/AdyenCheckoutError';\nimport { SFStateErrorObj } from '../../../Card/components/CardInput/types';\nimport { getErrorMessageFromCode } from '../../../../core/Errors/utils';\nimport { SF_ErrorCodes } from '../../../../core/Errors/constants';\n\n/**\n * SecuredFieldsProvider:\n * Initialises & handles the client-side part of SecuredFields\n */\nclass SecuredFieldsProvider extends Component<SFPProps, SFPState> {\n private csfLoadFailTimeout: number;\n private csfLoadFailTimeoutMS: number;\n private csfConfigFailTimeout: number;\n private csfConfigFailTimeoutMS: number;\n private numCharsInField: object;\n private rootNode;\n private numDateFields: number;\n private csf: CSFReturnObject;\n private handleOnLoad: (obj: CardLoadData) => void;\n private handleOnConfigSuccess: (obj: CardConfigSuccessData) => void;\n private handleOnFieldValid: (obj: CardFieldValidData) => void;\n private handleOnAllValid: (obj: CardAllValidData) => void;\n private handleOnBrand: (obj: CardBrandData) => void;\n private handleFocus: (obj: CardFocusData) => void;\n private handleOnError: (obj: CardErrorData, hasUnsupportedCard?: boolean) => void;\n private handleOnAutoComplete: (obj: CardAutoCompleteData) => void;\n private handleOnNoDataRequired: () => void;\n private handleOnTouchstartIOS: (obj) => void;\n private handleKeyPressed: (obj: SFKeyPressObj) => void;\n public state: SFPState;\n public props;\n private issuingCountryCode;\n\n constructor(props: SFPProps) {\n super(props);\n\n const stateObj: SFPState = {\n status: 'loading',\n brand: props.type,\n errors: {},\n valid: {},\n data: {},\n cvcPolicy: CVC_POLICY_REQUIRED,\n expiryDatePolicy: DATE_POLICY_REQUIRED,\n isSfpValid: false,\n hasKoreanFields: props.hasKoreanFields\n };\n this.state = stateObj;\n\n this.csfLoadFailTimeout = null;\n this.csfLoadFailTimeoutMS = 30000;\n\n this.csfConfigFailTimeout = null;\n this.csfConfigFailTimeoutMS = 15000;\n\n this.numCharsInField = {};\n\n // Handlers\n this.handleOnLoad = handlers.handleOnLoad.bind(this);\n this.handleOnConfigSuccess = handlers.handleOnConfigSuccess.bind(this);\n this.handleOnFieldValid = handlers.handleOnFieldValid.bind(this);\n this.handleOnAllValid = handlers.handleOnAllValid.bind(this);\n this.handleOnBrand = handlers.handleOnBrand.bind(this);\n this.handleFocus = handlers.handleFocus.bind(this);\n this.handleOnError = handlers.handleOnError.bind(this);\n this.handleOnNoDataRequired = handlers.handleOnNoDataRequired.bind(this);\n this.handleOnAutoComplete = handlers.handleOnAutoComplete.bind(this);\n this.handleOnTouchstartIOS = handlers.handleOnTouchstartIOS.bind(this); // Only called when iOS detected\n this.handleKeyPressed = handlers.handleKeyPressed.bind(this);\n\n this.processBinLookupResponse = this.processBinLookupResponse.bind(this);\n\n // Bindings for functions exposed to users of this component: SecuredFields & CardInput\n this.setFocusOn = this.setFocusOn.bind(this);\n this.updateStyles = this.updateStyles.bind(this);\n this.handleUnsupportedCard = this.handleUnsupportedCard.bind(this);\n this.showValidation = this.showValidation.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n\n public static defaultProps = defaultProps;\n\n public componentDidMount(): void {\n // When SFP instantiated through SecuredFieldsInput c.f. CardInput\n if (this.props.rootNode) {\n this.setRootNode(this.props.rootNode);\n }\n\n // Find encryptedFields and map them to the values we use to store valid states\n const fields = getFields(this.rootNode);\n const valid = fields.reduce(validFieldsReducer, {});\n\n this.setState({ valid });\n\n // Populate numCharsInField object\n fields.forEach(field => {\n this.numCharsInField[field] = 0;\n });\n\n // Store how many dateFields we are dealing with visually\n this.numDateFields = fields.filter(f => f.match(/Expiry/)).length;\n\n if (fields.length) {\n this.destroy(); // TODO test if this solves the React double render problem.\n this.initializeCSF(this.rootNode);\n } else {\n this.handleOnNoDataRequired();\n }\n }\n\n public componentDidUpdate() {\n this.checkForKCPFields();\n // Pass all the state data up - Used right now for loading status\n this.props.onStateUpdate?.(this.state);\n }\n\n public componentWillUnmount(): void {\n this.csf = null;\n clearTimeout(this.csfLoadFailTimeout);\n clearTimeout(this.csfConfigFailTimeout);\n }\n\n private initializeCSF(root: HTMLElement): void {\n let loadingContext = this.props.loadingContext;\n\n // For loading securedFields from local server during development\n if (process.env.NODE_ENV === 'development' && process.env.__SF_ENV__ !== 'build') {\n loadingContext = process.env.__SF_ENV__;\n }\n\n const csfSetupObj: CSFSetupObject = {\n rootNode: root,\n type: this.props.type,\n clientKey: this.props.clientKey,\n cardGroupTypes: this.props.brands,\n autoFocus: this.props.autoFocus,\n trimTrailingSeparator: this.props.trimTrailingSeparator,\n loadingContext,\n keypadFix: this.props.keypadFix,\n showWarnings: this.props.showWarnings,\n iframeUIConfig: {\n sfStyles: this.props.styles\n },\n i18n: this.props.i18n,\n callbacks: {\n onLoad: this.handleOnLoad,\n onConfigSuccess: this.handleOnConfigSuccess,\n onFieldValid: this.handleOnFieldValid,\n onAllValid: this.handleOnAllValid,\n onBrand: this.handleOnBrand,\n onError: this.handleOnError,\n onFocus: this.handleFocus,\n onBinValue: this.props.onBinValue,\n onAutoComplete: this.handleOnAutoComplete,\n onAdditionalSFConfig: this.props.onAdditionalSFConfig,\n onAdditionalSFRemoved: this.props.onAdditionalSFRemoved,\n onTouchstartIOS: this.handleOnTouchstartIOS,\n onKeyPressed: this.handleKeyPressed\n },\n isKCP: this.state.hasKoreanFields,\n legacyInputMode: this.props.legacyInputMode,\n minimumExpiryDate: this.props.minimumExpiryDate,\n implementationType: this.props.implementationType || 'components', // to distinguish between 'regular' and 'custom' card component\n forceCompat: this.props.forceCompat,\n maskSecurityCode: this.props.maskSecurityCode,\n exposeExpiryDate: this.props.exposeExpiryDate,\n shouldDisableIOSArrowKeys: !!this.props.disableIOSArrowKeys, // convert whether function has been defined into a boolean\n placeholders: this.props.placeholders ?? {},\n showContextualElement: this.props.showContextualElement\n };\n\n this.csf = initCSF(csfSetupObj);\n\n /**\n * Expect to at least have had the handleOnLoad callback called within this time\n * - if this hasn't happened then something has happened to interrupt the loading of the securedFields\n * So we need to clear the loading spinner to see if the securedFields are reporting anything\n */\n // @ts-ignore - timout 'type' is a number\n this.csfLoadFailTimeout = setTimeout(() => {\n if (this.state.status !== 'ready') {\n // Hide the spinner\n this.setState({ status: 'csfLoadFailure' });\n // Report the error\n this.props.onError(new AdyenCheckoutError('ERROR', 'secured field iframes have failed to load'));\n }\n }, this.csfLoadFailTimeoutMS);\n }\n\n private checkForKCPFields() {\n let needsKoreanFields = false;\n if (this.props.koreanAuthenticationRequired) {\n needsKoreanFields = this.issuingCountryCode ? this.issuingCountryCode === 'kr' : this.props.countryCode === 'kr';\n }\n\n // Was korean, now isn't - hide password field\n if (this.state.hasKoreanFields && !needsKoreanFields) {\n // Clear any stored data\n const setRemovedFieldState = prevState => ({\n data: { ...prevState.data, [ENCRYPTED_PWD_FIELD]: undefined },\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n errors: { ...prevState.errors, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: false\n });\n\n this.setState(setRemovedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.removeSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(false);\n }\n\n // Wasn't korean, now is - show password field\n if (!this.state.hasKoreanFields && needsKoreanFields) {\n const setAddedFieldState = prevState => ({\n valid: { ...prevState.valid, [ENCRYPTED_PWD_FIELD]: false },\n hasKoreanFields: true,\n isSfpValid: false\n });\n\n this.setState(setAddedFieldState, () => {\n this.props.onChange(this.state);\n });\n\n this.csf.addSecuredField(ENCRYPTED_PWD_FIELD);\n this.csf.setKCPStatus(true);\n }\n }\n\n public getChildContext(): object {\n return { i18n: this.props.i18n };\n }\n\n public handleUnsupportedCard(errObj: CardErrorData): boolean {\n const hasUnsupportedCard = !!errObj.error;\n\n // Store the brand(s) we detected and which we don't support\n if (hasUnsupportedCard) {\n this.setState({ detectedUnsupportedBrands: errObj.detectedBrands });\n }\n\n errObj.rootNode = this.rootNode; // Needed for CustomCard\n this.handleOnError(errObj, hasUnsupportedCard);\n // Inform CSF that the number field has an unsupportedCard error (or that it has been cleared)\n if (this.csf) {\n this.csf.hasUnsupportedCard(ENCRYPTED_CARD_NUMBER, errObj.error);\n }\n return hasUnsupportedCard;\n }\n\n public setFocusOn(frame: string): void {\n if (this.csf) this.csf.setFocusOnFrame(frame);\n }\n\n public updateStyles(stylesObj: StylesObject): void {\n if (this.csf) this.csf.updateStyles(stylesObj);\n }\n\n public sfIsOptionalOrHidden(fieldType: string): boolean {\n return this.csf.sfIsOptionalOrHidden(fieldType);\n }\n\n public destroy(): void {\n if (this.csf) this.csf.destroy();\n }\n\n public showValidation(): void {\n const { numDateFields, state }: SecuredFieldsProvider = this;\n\n Object.keys(state.valid)\n .reduce(getErrorReducer(numDateFields, state), [])\n .forEach(field => {\n // For each detected error pass an error object to the handler (calls error callback & sets state)\n const errorObj: CardErrorData = getErrorObject(field, this.rootNode, state);\n this.handleOnError(errorObj, !!state.detectedUnsupportedBrands);\n // Inform the secured-fields instance of which fields have been found to have errors\n if (this.csf && this.csf.isValidated) {\n this.csf.isValidated(field, errorObj.error);\n }\n });\n }\n\n /**\n * Map SF errors to ValidationRuleResult-like objects, for CardInput component\n */\n public mapErrorsToValidationRuleResult(): SFStateErrorObj {\n const fieldNames: string[] = Object.keys(this.state.errors);\n\n const sfStateErrorsObj = fieldNames.reduce((acc, fieldName) => {\n const errorCode = this.state.errors[fieldName];\n if (errorCode) {\n acc[fieldName] = {\n isValid: false,\n errorMessage: getErrorMessageFromCode(errorCode, SF_ErrorCodes), // this is the human-readable, untranslated, explanation of the error that will exist on the error object in card.state.errors\n // For v5 the object found in state.errors should also contain the additional properties that used to be sent to the onError callback\n // namely: translation, errorCode, a ref to rootNode &, in the case of failed binLookup, an array of the detectedBrands\n errorI18n: this.props.i18n.get(errorCode),\n error: errorCode,\n rootNode: this.rootNode,\n ...(this.state.detectedUnsupportedBrands && { detectedBrands: this.state.detectedUnsupportedBrands })\n };\n } else {\n acc[fieldName] = null;\n }\n return acc;\n }, {});\n return sfStateErrorsObj;\n }\n\n public processBinLookupResponse(binLookupResponse: BinLookupResponse, resetObject: SingleBrandResetObject): void {\n // If we were dealing with an unsupported card & now we have a valid /binLookup response (or a response triggering a reset of the UI),\n // - reset state to clear the error & the stored unsupportedBrands and, in the case of a valid /binLookup response, inform CSF (via handleUnsupportedCard)\n // (Scenario: from an unsupportedCard state the shopper has pasted another number long enough to trigger a /binLookup)\n if (this.state.detectedUnsupportedBrands) {\n this.setState(prevState => ({\n errors: { ...prevState.errors, [ENCRYPTED_CARD_NUMBER]: false },\n detectedUnsupportedBrands: null\n }));\n\n // If we have some sort of binLookupResponse object then this isn't the reset caused by digits dropping below a threshold\n // - so call handleUnsupportedCard to clear the error\n if (this.csf && binLookupResponse) {\n const errObj: CardErrorData = {\n type: 'card',\n fieldType: 'encryptedCardNumber',\n error: ''\n };\n this.handleUnsupportedCard(errObj);\n }\n }\n\n this.issuingCountryCode = binLookupResponse?.issuingCountryCode?.toLowerCase();\n\n const hasBrandedResetObj = resetObject?.brand;\n\n /**\n * Are we dealing with a \"dedicated\" card scenario i.e a card component created as: checkout.create('bcmc') but which can accept multiple brands\n * - in which case we will need to reset brand and pass on the resetObj to CSF\n */\n const mustResetDedicatedBrand = hasBrandedResetObj && DEDICATED_CARD_COMPONENTS.includes(resetObject.brand);\n\n if (mustResetDedicatedBrand) {\n // resetObject.brand will be the value of the brand whose logo we want to reshow in the UI\n this.setState(resetObject, () => {\n this.props.onChange(this.state);\n });\n }\n\n /**\n * Scenarios:\n *\n * - RESET (binLookupResponse === null): The number of digits in number field has dropped below threshold for BIN lookup\n * - RESULT (binLookupResponse.supportedBrands.length === 1): binLookup has found a result so inform CSF\n *\n * In the RESET scenario, for \"dedicated\" card components we also need to pass on the resetObject since this contains information about\n * the brand that CSF needs to reset to, internally.\n */\n if (this.csf) this.csf.brandsFromBinLookup(binLookupResponse, mustResetDedicatedBrand ? resetObject : null);\n }\n\n private setRootNode = (input: HTMLElement): void => {\n this.rootNode = input;\n };\n\n public render(props, state) {\n return props.render({ setRootNode: this.setRootNode, setFocusOn: this.setFocusOn }, state);\n }\n}\n\nexport default SecuredFieldsProvider;\n"],"names":["SecuredFieldsProvider","Component","componentDidMount","this","props","rootNode","setRootNode","fields","getFields","valid","reduce","validFieldsReducer","setState","forEach","field","numCharsInField","numDateFields","filter","f","match","length","destroy","initializeCSF","handleOnNoDataRequired","componentDidUpdate","_this_props_onStateUpdate","_this_props","checkForKCPFields","onStateUpdate","call","state","componentWillUnmount","csf","clearTimeout","csfLoadFailTimeout","csfConfigFailTimeout","root","loadingContext","_this_props_placeholders","csfSetupObj","type","clientKey","cardGroupTypes","brands","autoFocus","trimTrailingSeparator","keypadFix","showWarnings","iframeUIConfig","sfStyles","styles","i18n","callbacks","onLoad","handleOnLoad","onConfigSuccess","handleOnConfigSuccess","onFieldValid","handleOnFieldValid","onAllValid","handleOnAllValid","onBrand","handleOnBrand","onError","handleOnError","onFocus","handleFocus","onBinValue","onAutoComplete","handleOnAutoComplete","onAdditionalSFConfig","onAdditionalSFRemoved","onTouchstartIOS","handleOnTouchstartIOS","onKeyPressed","handleKeyPressed","isKCP","hasKoreanFields","legacyInputMode","minimumExpiryDate","implementationType","forceCompat","maskSecurityCode","exposeExpiryDate","shouldDisableIOSArrowKeys","disableIOSArrowKeys","placeholders","showContextualElement","initCSF","setTimeout","status","AdyenCheckoutError","csfLoadFailTimeoutMS","needsKoreanFields","koreanAuthenticationRequired","issuingCountryCode","countryCode","setRemovedFieldState","prevState","data","_object_spread_props","_object_spread","ENCRYPTED_PWD_FIELD","undefined","errors","onChange","removeSecuredField","setKCPStatus","setAddedFieldState","isSfpValid","addSecuredField","getChildContext","handleUnsupportedCard","errObj","hasUnsupportedCard","error","detectedUnsupportedBrands","detectedBrands","ENCRYPTED_CARD_NUMBER","setFocusOn","frame","setFocusOnFrame","updateStyles","stylesObj","sfIsOptionalOrHidden","fieldType","showValidation","Object","keys","getErrorReducer","errorObj","getErrorObject","isValidated","mapErrorsToValidationRuleResult","acc","fieldName","errorCode","isValid","errorMessage","getErrorMessageFromCode","SF_ErrorCodes","errorI18n","get","processBinLookupResponse","binLookupResponse","resetObject","toLowerCase","mustResetDedicatedBrand","brand","DEDICATED_CARD_COMPONENTS","includes","brandsFromBinLookup","render","constructor","super","_define_property","csfConfigFailTimeoutMS","input","stateObj","cvcPolicy","CVC_POLICY_REQUIRED","expiryDatePolicy","DATE_POLICY_REQUIRED","handlers","bind","defaultProps"],"mappings":"68CA8BA,MAAMA,UAA8BC,EAyEzBC,iBAAAA,GAECC,KAAKC,MAAMC,UACXF,KAAKG,YAAYH,KAAKC,MAAMC,UAIhC,MAAME,EAASC,EAAUL,KAAKE,UACxBI,EAAQF,EAAOG,OAAOC,EAAoB,CAAA,GAEhDR,KAAKS,SAAS,CAAEH,UAGhBF,EAAOM,SAAQC,IACXX,KAAKY,gBAAgBD,GAAS,CAAA,IAIlCX,KAAKa,cAAgBT,EAAOU,QAAOC,GAAKA,EAAEC,MAAM,YAAWC,OAEvDb,EAAOa,QACPjB,KAAKkB,UACLlB,KAAKmB,cAAcnB,KAAKE,WAExBF,KAAKoB,wBAEb,CAEOC,kBAAAA,OAGHC,EAAAC,EAFAvB,KAAKwB,oBAEmB,QAAxBF,GAAAC,EAAA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