@adyen/kyc-components 4.0.0-beta.5 → 4.0.0-compact.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 (457) hide show
  1. package/dist/{AcceptTermsOfServiceComponent-Bjj3cdYk.js → AcceptTermsOfServiceComponent-BF24NWVw.js} +43 -15
  2. package/dist/{AccountSetupRejected-CSQTnRkO.js → AccountSetupRejected-2t22lJUo.js} +6 -4
  3. package/dist/Address-DSwfzWFu.js +1076 -0
  4. package/dist/Alert-C24s_Ygs.js +231 -0
  5. package/dist/{Avatar-DL_WbHEO.js → Avatar-DQjt5Lk2.js} +2 -2
  6. package/dist/BusinessDetailsDropin-CRFPvWuD.js +5088 -0
  7. package/dist/BusinessFinancingComponent-y2_kC8bx.js +45 -0
  8. package/dist/{BusinessFinancingDropin-MrOVSlPu.js → BusinessFinancingDropin-C-xm14b8.js} +51 -26
  9. package/dist/BusinessFinancingPage-BOG7yrw6.js +40 -0
  10. package/dist/{BusinessTypeSelectionPage-DJ5bfr8m.js → BusinessTypeSelectionPage-ujY2jj6B.js} +9 -5
  11. package/dist/Card-BMuquALf.js +145 -0
  12. package/dist/Confirm-DwutojkY.js +64 -0
  13. package/dist/{ContractViewer-z3KbE1Vf.js → ContractViewer-Byp71k2e.js} +34 -46
  14. package/dist/CountryField-D0YZrov9.js +864 -0
  15. package/dist/CreateIndividualComponent-VZWLAo0l.js +72 -0
  16. package/dist/CreateTransferInstrumentComponent-OtReN6Cy.js +67 -0
  17. package/dist/Currency-BECbMsi5.js +238 -0
  18. package/dist/{CustomerSupport-CUPUElh7.js → CustomerSupport-B8zC_huY.js} +10 -6
  19. package/dist/{DebugModal-BC-xS3Y1.js → DebugModal-CshTHx0o.js} +8 -5
  20. package/dist/DecisionMakerDetailsPage-BJUwR4R7.js +100 -0
  21. package/dist/{DecisionMakers-5m_hI3ko.js → DecisionMakers-BDNa3HcC.js} +247 -134
  22. package/dist/DetailViewLayout-Z9cuUp4X.js +65 -0
  23. package/dist/Dropzone-D6dXhmL4.js +218 -0
  24. package/dist/{EmbeddedStatus-8yA_zZvi.js → EmbeddedStatus-BHTZcjUN.js} +4 -4
  25. package/dist/EndStateLayout-CyGtLyvf.js +71 -0
  26. package/dist/{FormFlow-6j8qCSuK.js → FormFlow-CZ9f5X0C.js} +8 -2
  27. package/dist/FormNavigation-ezxkIqdb.js +162 -0
  28. package/dist/{IndividualOnfidoDropin-B0G_nHXY.js → IndividualOnfidoDropin-vuHu-O_C.js} +3240 -258
  29. package/dist/InputDate-CHygOGiS.js +43 -0
  30. package/dist/InputGroup-WBfGDV5F.js +32 -0
  31. package/dist/InputText-BX5sG9WJ.js +161 -0
  32. package/dist/{Introduction-aPZmTW68.js → Introduction-BsKwELuc.js} +58 -4
  33. package/dist/{LegalRepresentativeDetailsPage-Beh9_16w.js → LegalRepresentativeDetailsPage-DtMHe1Nq.js} +9 -3
  34. package/dist/Link-BFdxU8qh.js +35 -0
  35. package/dist/ManageIndividualComponent-By_fCmN1.js +47 -0
  36. package/dist/ManageTermsOfServiceComponent-D7F44OPD.js +47 -0
  37. package/dist/{ManageTransferInstrumentComponent-Ds1QZxxR.js → ManageTransferInstrumentComponent-DywpP5PK.js} +37 -42
  38. package/dist/MaskedInput-BZ7t98eu.js +799 -0
  39. package/dist/MaybeModal-CE9kYOrU.js +25 -0
  40. package/dist/Modal-nMRQDTF7.js +136 -0
  41. package/dist/{OnboardingDropinComponent-DLvTQVTE.js → OnboardingDropinComponent-B0GrJ_pR.js} +235 -90
  42. package/dist/PayoutDetailsDropin-BJIqXmPn.js +3694 -0
  43. package/dist/RadioGroup-CYDXrtrO.js +143 -0
  44. package/dist/RegistrationAddress-qtMZa31b.js +2334 -0
  45. package/dist/{Review-DEeOefPe.js → Review-D7NEYFoT.js} +8 -4
  46. package/dist/{RootBusinessDetailsPage-B2VBJ6x2.js → RootBusinessDetailsPage-rCbGLBEv.js} +66 -44
  47. package/dist/{RootIndividualDetailsPage-Bi7xeUYJ.js → RootIndividualDetailsPage-B3TkB6Xj.js} +9 -3
  48. package/dist/SignPCIComponent-C0iYfSl6.js +294 -0
  49. package/dist/{SingpassSelection--f8TDTJH.js → SingpassSelection-ClMlwfoj.js} +19 -11
  50. package/dist/SoleProprietorshipPage-JKNrAy74.js +50 -0
  51. package/dist/{SourceOfFundsPage-avNGxkCP.js → SourceOfFundsPage-D-pN33-9.js} +49 -32
  52. package/dist/Spacer-BK3jDget.js +18 -0
  53. package/dist/StepProgressIndicator-BWCQmDeV.js +78 -0
  54. package/dist/StoreProvider-BlaJzXSZ.js +7072 -0
  55. package/dist/StructuredList-DaepaiVE.js +38 -0
  56. package/dist/{TaskItemStatus-DMPUHtWU.js → TaskItemStatus-B38keERo.js} +4 -3
  57. package/dist/{TaskStatusIndicator-Bfc4X_jG.js → TaskStatusIndicator-BIvTrQtf.js} +3 -3
  58. package/dist/TaxInformationField-DS0m73if.js +3062 -0
  59. package/dist/{TaxReportingDropin-B7FXPbLq.js → TaxReportingDropin-CVbVkFhv.js} +28 -17
  60. package/dist/{TileGroup-DUoq3Lh4.js → TileGroup-CztY53P9.js} +4 -2
  61. package/dist/{TrustDetailsPage-J4MShc8J.js → TrustDetailsPage-C791Wu5u.js} +506 -19
  62. package/dist/TrustMemberCompanyPage-BOQ5D3y4.js +60 -0
  63. package/dist/{TrustMemberIndividualPage-CFo3Is4F.js → TrustMemberIndividualPage-BPIXX2Mh.js} +9 -3
  64. package/dist/{UnincorporatedPartnershipIndividualPage-CfllAxUK.js → UnincorporatedPartnershipIndividualPage-vzn0R02z.js} +9 -3
  65. package/dist/{UnincorporatedPartnershipMemberCompanyPage-779IUOW2.js → UnincorporatedPartnershipMemberCompanyPage-C-kGU5Sh.js} +10 -3
  66. package/dist/{ViewVerificationStatusComponent-ZtYIqtnO.js → ViewVerificationStatusComponent-BTW-Vw9I.js} +4 -3
  67. package/dist/adyen-business-financing.js +33 -22
  68. package/dist/adyen-individual-configuration.js +59 -0
  69. package/dist/adyen-individual-status.js +47 -0
  70. package/dist/adyen-kyc-components.js +28 -15
  71. package/dist/adyen-onboarding.js +3 -3
  72. package/dist/adyen-terms-of-service-management.js +63 -0
  73. package/dist/adyen-terms-of-service-status.js +47 -0
  74. package/dist/adyen-transfer-instrument-configuration.js +73 -0
  75. package/dist/adyen-transfer-instrument-management.js +61 -0
  76. package/dist/adyen-verification-status.js +44 -36
  77. package/dist/analytics-3-a-Od7Z.js +61 -0
  78. package/dist/{LandingLayout-Xi3iuRMx.js → bafinUtils-Bar3qiJA.js} +218 -8
  79. package/dist/basePatterns-BwdnMQxI.js +15 -0
  80. package/dist/commonValidators-Bk0SSjsH.js +24 -0
  81. package/dist/currency-BGwQyxBo.js +36 -0
  82. package/dist/{da-DK-Adj8R5Qn.js → da-DK-B45X2VaJ.js} +9 -2
  83. package/dist/da-DK-BJ7aTPir.js +13 -0
  84. package/dist/{da-DK-Dm8o1giq.js → da-DK-BoQic3Gy.js} +2 -4
  85. package/dist/{da-DK-4QAKic_C.js → da-DK-D0N1TVVU.js} +4 -1
  86. package/dist/da-DK-D4H69PX3.js +30 -0
  87. package/dist/da-DK-DStNe471.js +22 -0
  88. package/dist/de-DE-C78RLE2G.js +13 -0
  89. package/dist/de-DE-CGoBPCPv.js +22 -0
  90. package/dist/{de-DE-BG0tKqvi.js → de-DE-CWvgMDqU.js} +9 -2
  91. package/dist/{de-DE-BzumFI3T.js → de-DE-Dtuu-nE7.js} +4 -1
  92. package/dist/{de-DE-DMFaycio.js → de-DE-Dwagawx1.js} +2 -4
  93. package/dist/de-DE-wp5-H-ov.js +30 -0
  94. package/dist/{digital-wallet-with-local-currencies-POeLD54e.js → digital-wallet-D_IpxnkN.js} +3 -3
  95. package/dist/dropinUtils-DHp5v5jB.js +192 -0
  96. package/dist/emitEvent-CzZf80Am.js +28 -0
  97. package/dist/{en-US-DLm6gy6T.js → en-US-546hB2Wn.js} +3 -1
  98. package/dist/{en-US-CkZcSKGh.js → en-US-BbAzROHT.js} +5 -4
  99. package/dist/en-US-CAm3meB1.js +30 -0
  100. package/dist/{en-US-SbE0c1gn.js → en-US-DIdQJky-.js} +1 -2
  101. package/dist/en-US.instructions-Ddr7AO05.js +22 -0
  102. package/dist/{es-ES-BhQOdKge.js → es-ES-BsQpwaPN.js} +4 -1
  103. package/dist/{es-ES-pXHx3ODy.js → es-ES-Bsoco8Fj.js} +2 -4
  104. package/dist/es-ES-BtUSEzkE.js +13 -0
  105. package/dist/es-ES-CKMfS8Yy.js +22 -0
  106. package/dist/{es-ES-BM4U0hT3.js → es-ES-DKCCgVF8.js} +9 -2
  107. package/dist/es-ES-Ds3-DtqZ.js +30 -0
  108. package/dist/{fi-FI-Djollt2G.js → fi-FI-BJ9RzrL3.js} +4 -1
  109. package/dist/{fi-FI-DT351N-G.js → fi-FI-ClnsYt3L.js} +2 -4
  110. package/dist/fi-FI-Cvar63RH.js +13 -0
  111. package/dist/fi-FI-DPNeTsJS.js +30 -0
  112. package/dist/{fi-FI-BJ2l42Pj.js → fi-FI-Hhku9Lmc.js} +9 -2
  113. package/dist/fi-FI-REYOX46I.js +22 -0
  114. package/dist/fieldConfigurations-B8bDFQ53.js +458 -0
  115. package/dist/{hr-HR-CNzbyo9r.js → form-rules-DhbF2mY4.js} +3 -5
  116. package/dist/fr-FR-B5543Fe-.js +13 -0
  117. package/dist/{fr-FR-g7lmxEsI.js → fr-FR-BYuKsZIb.js} +9 -2
  118. package/dist/{fr-FR-BNXXNUX_.js → fr-FR-CJI0bIig.js} +2 -4
  119. package/dist/{fr-FR-l36qBV3a.js → fr-FR-CNR5-s9g.js} +4 -1
  120. package/dist/fr-FR-ChmNQciP.js +30 -0
  121. package/dist/fr-FR-D9qaP6nx.js +22 -0
  122. package/dist/getName-DJlhsDj_.js +41 -0
  123. package/dist/{hasDataChanged-CTE9vdfO.js → hasDataChanged-BgvxL-Hx.js} +2 -2
  124. package/dist/iframeWidget-Bftkd3v_.js +234 -0
  125. package/dist/{payout-verification-instant-BIcnFP-p.js → instant-verification-Dvvkyfmp.js} +3 -3
  126. package/dist/isEmpty-CuQFhMf0.js +23 -0
  127. package/dist/{it-IT-BEWyAQUU.js → it-IT-BV9K87FK.js} +4 -1
  128. package/dist/{it-IT-BeYbInCQ.js → it-IT-BeC2Y1F8.js} +2 -4
  129. package/dist/it-IT-Biduphjt.js +22 -0
  130. package/dist/it-IT-Dd6xGSe-.js +13 -0
  131. package/dist/{it-IT-DYIx7myn.js → it-IT-Nl57jui-.js} +9 -2
  132. package/dist/it-IT-eCrTB65E.js +30 -0
  133. package/dist/keys-BpNgnAsD.js +23 -0
  134. package/dist/{localizeDateString-DaAGYSWR.js → localizeDateString-DHsivjy2.js} +2 -2
  135. package/dist/{payout-verification-manual-DH9-DdlZ.js → manual-verification-BvZWqA00.js} +3 -3
  136. package/dist/mapExistingFile-DW5ktJzM.js +231 -0
  137. package/dist/mapScriptLocalization-CI-Ydp2z.js +72 -0
  138. package/dist/mapTransferInstrumentToPayoutAccount-CAoOlPMA.js +30 -0
  139. package/dist/{nl-NL-Cht7cSwD.js → nl-NL-BHkRnVrj.js} +9 -2
  140. package/dist/{nl-NL-Dbx0ZmI7.js → nl-NL-Cysslsh2.js} +2 -4
  141. package/dist/nl-NL-D2QKudfh.js +30 -0
  142. package/dist/nl-NL-DVENFpd5.js +13 -0
  143. package/dist/{nl-NL-lZcJhRsP.js → nl-NL-DywVQ9km.js} +4 -1
  144. package/dist/nl-NL-G1wVnmzT.js +22 -0
  145. package/dist/{no-NO-BEIyAMmZ.js → no-NO-B8oxqfNI.js} +4 -1
  146. package/dist/no-NO-BTtAuqCb.js +22 -0
  147. package/dist/no-NO-C_snYWBc.js +30 -0
  148. package/dist/no-NO-Dn2UkdoI.js +13 -0
  149. package/dist/{no-NO-BQAqVzF4.js → no-NO-kaAdT9B8.js} +9 -2
  150. package/dist/{no-NO-C0sfkp82.js → no-NO-zSnPtrDi.js} +2 -4
  151. package/dist/{pt-PT-BsDCHbWN.js → pt-PT-BvK00TeI.js} +4 -1
  152. package/dist/pt-PT-C-hbNnsB.js +30 -0
  153. package/dist/{pt-PT-BY9rcwcF.js → pt-PT-CjsyP_OK.js} +2 -4
  154. package/dist/pt-PT-Dk48OVtf.js +22 -0
  155. package/dist/{pt-PT-CBbmkr_J.js → pt-PT-Xm-pm3mb.js} +9 -2
  156. package/dist/pt-PT-_o5xgnxS.js +13 -0
  157. package/dist/{resolveEnvironment-D0tYcn_s.js → resolveEnvironment-BGYn6Ls_.js} +3 -3
  158. package/dist/{rules-DXnRkeBJ.js → rules-DP3jxPzq.js} +5 -2
  159. package/dist/sl-SI-BB7iVcFI.js +22 -0
  160. package/dist/sl-SI-BhVTSmhQ.js +30 -0
  161. package/dist/{sl-SI-C8CMAkD0.js → sl-SI-Br0UEUPL.js} +2 -4
  162. package/dist/{sl-SI-BB0suyr1.js → sl-SI-D_rqR0D7.js} +9 -2
  163. package/dist/{sl-SI-BE_ndzZ2.js → sl-SI-NI2OJAvm.js} +4 -1
  164. package/dist/style.css +3226 -2972
  165. package/dist/styles-CLV89_hH.js +3226 -2972
  166. package/dist/sv-SE-66rqYTxi.js +30 -0
  167. package/dist/{sv-SE-DYruQSzt.js → sv-SE-B3zoXMuH.js} +9 -2
  168. package/dist/sv-SE-BUfESAQK.js +13 -0
  169. package/dist/{sv-SE-Bwh0wKFk.js → sv-SE-BtXmvxx4.js} +2 -4
  170. package/dist/{sv-SE-BryiIPVv.js → sv-SE-CAZpDX9G.js} +4 -1
  171. package/dist/sv-SE-DbI-1JqN.js +22 -0
  172. package/dist/translation-DJHWTow9.js +472 -0
  173. package/dist/types/api/configurations/useScenarios.d.ts +8 -7
  174. package/dist/types/api/idNowProvider/idNowProvider.types.d.ts +1 -1
  175. package/dist/types/api/idNowProvider/useIdNowProvider.d.ts +9 -5
  176. package/dist/types/api/industryCodes/industryCodes.types.d.ts +2 -0
  177. package/dist/types/api/industryCodes/useIndustryCodes.d.ts +6 -0
  178. package/dist/types/api/queryKeys.d.ts +2 -1
  179. package/dist/types/components/BankAccount/forms/PayoutDetails/PayoutDetails.d.ts +1 -0
  180. package/dist/types/components/BankAccount/forms/PayoutVerificationMethod/payoutVerificationMethodMetadata.d.ts +3 -3
  181. package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/payoutDetailsFormConfig.d.ts +0 -9
  182. package/dist/types/components/Business/forms/BasicInformation/BasicInformationMultiform.d.ts +0 -1
  183. package/dist/types/components/Business/forms/BusinessDetails/forms.d.ts +7 -1
  184. package/dist/types/components/Business/forms/rules.d.ts +1 -3
  185. package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +1 -2
  186. package/dist/types/components/Business/tasks/BusinessDetailsMultiformDropin/BusinessDetailsMultiform.d.ts +1 -1
  187. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/ServiceAgreementDropin.d.ts +1 -1
  188. package/dist/types/components/Contract/tasks/ServiceAgreementDropin/types.d.ts +1 -0
  189. package/dist/types/components/EFP/mapping/businessFinancingKeyMappings.d.ts +0 -3
  190. package/dist/types/components/EFP/tasks/SourceOfFundsDropin/utils.d.ts +0 -1
  191. package/dist/types/components/EmbeddedDropins/AcceptTermsOfServiceComponent/AcceptTermsOfServiceComponent.d.ts +4 -3
  192. package/dist/types/components/EmbeddedDropins/ManageTransferInstrumentComponent/ManageTransferInstrumentOverviewItemModal/ManageTransferInstrumentOverviewItemModal.d.ts +0 -1
  193. package/dist/types/components/Individual/fields/NameFields/types.d.ts +4 -18
  194. package/dist/types/components/Individual/forms/Individual/IdVerificationMethod/idVerificationMethodMetadata.d.ts +3 -3
  195. package/dist/types/components/Individual/forms/Individual/Individual.d.ts +4 -0
  196. package/dist/types/components/Individual/forms/Individual/ProofOfRelationship/types.d.ts +0 -5
  197. package/dist/types/components/Individual/forms/IndividualOnfido/AdditionalPersonalDetails/AdditionalPersonalDetails.types.d.ts +1 -1
  198. package/dist/types/components/Individual/forms/IndividualOnfido/BasicDetails/BasicDetails.types.d.ts +1 -1
  199. package/dist/types/components/Individual/forms/IndividualOnfido/IdNowVerificationModal/IdNowVerificationModal.d.ts +4 -0
  200. package/dist/types/components/Individual/forms/IndividualOnfido/IdNowVerificationModal/isIdNowModalOpen.d.ts +17 -0
  201. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/IdVerificationMethod.types.d.ts +2 -0
  202. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/mapExtractionResultToSchema.d.ts +2 -1
  203. package/dist/types/components/Individual/forms/IndividualOnfido/IdVerificationMethod/validateExtractionResult.d.ts +12 -0
  204. package/dist/types/components/Individual/forms/IndividualOnfido/IndividualOnfido.types.d.ts +5 -3
  205. package/dist/types/components/Individual/helpers/bafinUtils.d.ts +35 -0
  206. package/dist/types/components/Individual/helpers/isDecisionMakerTask.d.ts +2 -0
  207. package/dist/types/components/Individual/helpers/shouldShowMotionCapture.d.ts +2 -2
  208. package/dist/types/components/Individual/pages/DecisionMakerDetailsPage.d.ts +2 -1
  209. package/dist/types/components/Shared/SingpassBanner/ProviderButton/ProviderButton.d.ts +7 -0
  210. package/dist/types/components/Shared/fields/IdFieldTypeSelector/countryIdNumberTypes.d.ts +1 -1
  211. package/dist/types/components/Shared/fields/LocalizedLegalCompanyNameField/fieldConfig.d.ts +4 -5
  212. package/dist/types/components/Shared/fields/LocalizedLegalCompanyNameField/types.d.ts +4 -5
  213. package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
  214. package/dist/types/components/Trust/forms/Trust/Trust.d.ts +1 -0
  215. package/dist/types/components/Trust/forms/TrustRegistrationDetails/types.d.ts +1 -2
  216. package/dist/types/components/Trust/tasks/TrustMembers/TrustMembersOverview.d.ts +2 -1
  217. package/dist/types/components/UnincorporatedPartnership/pages/UnincorporatedPartnershipMemberCompanyPage.d.ts +2 -1
  218. package/dist/types/components/ui/atoms/ActionsMenu/ActionsMenu.d.ts +2 -1
  219. package/dist/types/components/ui/atoms/Button/Button.types.d.ts +4 -5
  220. package/dist/types/components/ui/atoms/Image/Image.d.ts +18 -0
  221. package/dist/types/components/ui/atoms/ListItem/ListItem.d.ts +2 -1
  222. package/dist/types/components/ui/atoms/Modal/MaybeModal.d.ts +1 -1
  223. package/dist/types/components/ui/atoms/RadioGroupCard/RadioGroupCard.types.d.ts +0 -14
  224. package/dist/types/components/ui/atoms/RadioWithLabel/RadioWithLabel.d.ts +2 -1
  225. package/dist/types/components/ui/atoms/Remove/Remove.d.ts +1 -1
  226. package/dist/types/components/ui/atoms/SelectList/SelectList.d.ts +1 -0
  227. package/dist/types/components/ui/atoms/StepProgressIndicator/StepProgressIndicator.d.ts +2 -1
  228. package/dist/types/components/ui/atoms/StructuredList/StructuredList.d.ts +2 -1
  229. package/dist/types/components/ui/atoms/Svg/svgs.d.ts +0 -76
  230. package/dist/types/components/ui/atoms/TaskStatusIndicator/TaskStatusIndicator.d.ts +4 -4
  231. package/dist/types/components/ui/layout/DetailViewLayout/DetailViewLayout.d.ts +12 -0
  232. package/dist/types/components/ui/layout/EndStateLayout/EndStateLayout.d.ts +13 -0
  233. package/dist/types/components/ui/layout/LandingLayout/LandingLayout.d.ts +8 -3
  234. package/dist/types/components/ui/layout/StackLayout/StackLayout.d.ts +2 -1
  235. package/dist/types/components/ui/molecules/DocumentGuidance/DocumentGuidance.types.d.ts +2 -3
  236. package/dist/types/components/ui/molecules/InputCurrency/InputCurrency.d.ts +2 -1
  237. package/dist/types/components/ui/molecules/InputEmail/InputEmail.d.ts +2 -1
  238. package/dist/types/components/ui/molecules/InputGroup/InputGroup.d.ts +2 -1
  239. package/dist/types/components/ui/molecules/InputTelephone/InputTelephone.d.ts +2 -1
  240. package/dist/types/components/ui/molecules/InputText/InputText.d.ts +2 -0
  241. package/dist/types/components/ui/molecules/MaskedInput/MaskedInput.d.ts +0 -1
  242. package/dist/types/components/ui/molecules/Tabs/Tabs.d.ts +1 -1
  243. package/dist/types/context/StateContext/types.d.ts +1 -1
  244. package/dist/types/core/models/api/accountIdentification.d.ts +5 -4
  245. package/dist/types/core/models/api/contracts.d.ts +1 -1
  246. package/dist/types/core/models/api/get-scenarios.d.ts +11 -5
  247. package/dist/types/core/models/api/individual.d.ts +5 -10
  248. package/dist/types/core/models/api/legal-arrangement.d.ts +0 -8
  249. package/dist/types/core/models/api/organization.d.ts +4 -8
  250. package/dist/types/core/models/api/scriptLocalization.d.ts +9 -0
  251. package/dist/types/core/process-field-configurations.d.ts +14 -3
  252. package/dist/types/embeds/business-financing/AdyenBusinessFinancing.d.ts +1 -1
  253. package/dist/types/embeds/business-financing/adyen-business-financing.types.d.ts +1 -5
  254. package/dist/types/embeds/emitEvent.d.ts +14 -0
  255. package/dist/types/embeds/{individual → individual-configuration}/AdyenIndividual.d.ts +2 -2
  256. package/dist/types/embeds/{individual/adyen-individual.types.d.ts → individual-configuration/adyen-individual-configuration.types.d.ts} +2 -2
  257. package/dist/types/embeds/{manage-individual → individual-status}/AdyenManageIndividual.d.ts +3 -3
  258. package/dist/types/embeds/{manage-individual/adyen-manage-individual.types.d.ts → individual-status/adyen-individual-status.types.d.ts} +1 -1
  259. package/dist/types/embeds/{terms-of-service → terms-of-service-management}/AdyenTermsOfService.d.ts +2 -2
  260. package/dist/types/embeds/{terms-of-service/adyen-terms-of-service.types.d.ts → terms-of-service-management/adyen-terms-of-service-management.types.d.ts} +4 -3
  261. package/dist/types/embeds/{manage-terms-of-service → terms-of-service-status}/AdyenManageTermsOfService.d.ts +2 -2
  262. package/dist/types/embeds/{manage-terms-of-service → terms-of-service-status}/adyen-manage-terms-of-service.types.d.ts +1 -1
  263. package/dist/types/embeds/{transfer-instrument → transfer-instrument-configuration}/AdyenTransferInstrument.d.ts +2 -2
  264. package/dist/types/embeds/{transfer-instrument/adyen-transfer-instrument.types.d.ts → transfer-instrument-configuration/adyen-transfer-instrument-configuration.types.d.ts} +2 -2
  265. package/dist/types/embeds/{manage-transfer-instruments → transfer-instrument-management}/AdyenManageTransferInstrument.d.ts +5 -6
  266. package/dist/types/embeds/{manage-transfer-instruments/adyen-manage-transfer-instruments.types.d.ts → transfer-instrument-management/adyen-transfer-instrument-management.types.d.ts} +3 -4
  267. package/dist/types/embeds/verification-status/adyen-verification-status.types.d.ts +3 -3
  268. package/dist/types/hooks/introduction/useIntroductionScreens.d.ts +2 -1
  269. package/dist/types/hooks/introduction/useShouldShowIntroduction.d.ts +2 -1
  270. package/dist/types/hooks/useMultiForm/types.d.ts +4 -4
  271. package/dist/types/language/utils.d.ts +1 -1
  272. package/dist/types/types/localizedScriptSchema.d.ts +22 -0
  273. package/dist/types/utils/addLinkedFields.d.ts +7 -1
  274. package/dist/types/utils/entityStatusUtil.d.ts +1 -1
  275. package/dist/types/utils/formUtils.d.ts +1 -1
  276. package/dist/types/utils/getDisplayErrorMessage.d.ts +1 -1
  277. package/dist/types/utils/getName.d.ts +2 -1
  278. package/dist/types/utils/makeSelectItemForRole.d.ts +1 -1
  279. package/dist/types/utils/mapScriptLocalization.d.ts +55 -0
  280. package/dist/types/utils/masking/masks/businessRegistrationNumberMasks.d.ts +5 -0
  281. package/dist/types/utils/translation.d.ts +6 -0
  282. package/dist/types-CAznNNSI.js +160 -0
  283. package/dist/types-CP1NRoE8.js +74 -0
  284. package/dist/types-K58FM7k4.js +64 -0
  285. package/dist/useAssociatedLegalEntity-G30FPhOX.js +33 -0
  286. package/dist/useDataset-BgvQQEKd.js +120 -0
  287. package/dist/useForm-C1DW3mPC.js +1694 -0
  288. package/dist/useFormContext-beqGS11A.js +23 -0
  289. package/dist/useGlobalData-jb7ua9I6.js +205 -0
  290. package/dist/{useMultiForm-CuBrV4Tk.js → useMultiForm-BucfLW49.js} +8 -3
  291. package/dist/{useOnboardingStatus-DUB9BH7M.js → useOnboardingStatus-CTgWLZxC.js} +2 -2
  292. package/dist/useScenarios-B7IWZ3xW.js +46 -0
  293. package/dist/{useTermsOfServiceStatus-BblV2n-A.js → useTermsOfServiceStatus-B0dIrYTA.js} +2 -2
  294. package/dist/useToastContext-DGMeMy5R.js +51 -0
  295. package/dist/useUnincorporatedPartnershipMembers-BCvmGMOX.js +99 -0
  296. package/dist/{utils-CoNP20Mi.js → utils-Bwnj33y_.js} +46 -4
  297. package/dist/utils-CXtNbmpA.js +29 -0
  298. package/dist/utils-CgOzbb9O.js +159 -0
  299. package/dist/utils-DNSfZiio.js +70 -0
  300. package/dist/{validate-BPEF-9EC.js → validate-B5PwC1oL.js} +2 -2
  301. package/dist/validate-BRz0LPdo.js +382 -0
  302. package/dist/validate-CvtamBXH.js +605 -0
  303. package/dist/validationError-DOCbfk7K.js +86 -0
  304. package/package.json +66 -69
  305. package/dist/BusinessDetailsDropin-JZ29P1pI.js +0 -2163
  306. package/dist/BusinessFinancingComponent-AAD0wzc0.js +0 -38
  307. package/dist/BusinessFinancingPage-DWvnRK3f.js +0 -35
  308. package/dist/CreateIndividualComponent-CO0NnimV.js +0 -64
  309. package/dist/CreateTransferInstrumentComponent-CpUB63yl.js +0 -55
  310. package/dist/DecisionMakerDetailsPage-DBsCSIAU.js +0 -80
  311. package/dist/FormEndState-s8NUp0x5.js +0 -59
  312. package/dist/ManageIndividualComponent-C5ll1EKq.js +0 -42
  313. package/dist/ManageTermsOfServiceComponent-BYgWiamd.js +0 -40
  314. package/dist/SignPCIComponent-Dgnvmjbr.js +0 -279
  315. package/dist/SoleProprietorshipPage-DMYrwSK2.js +0 -44
  316. package/dist/StoreProvider-QThALSrj.js +0 -31918
  317. package/dist/TrustMemberCompanyPage-DKNQ_vHF.js +0 -54
  318. package/dist/VerificationErrorAlert-BtsLa_Ty.js +0 -77
  319. package/dist/adyen-a-filled-czhSM_bc.js +0 -14
  320. package/dist/adyen-individual.js +0 -50
  321. package/dist/adyen-manage-individual.js +0 -48
  322. package/dist/adyen-manage-terms-of-service.js +0 -48
  323. package/dist/adyen-manage-transfer-instruments.js +0 -63
  324. package/dist/adyen-terms-of-service.js +0 -60
  325. package/dist/adyen-transfer-instrument.js +0 -64
  326. package/dist/arrow-left-Dtc2gya1.js +0 -14
  327. package/dist/bg-BG-9uVrFuHv.js +0 -23
  328. package/dist/bg-BG-BY3Wa361.js +0 -54
  329. package/dist/bg-BG-BiYtb1Tz.js +0 -55
  330. package/dist/bg-BG-BvSUDgGF.js +0 -13
  331. package/dist/bg-BG-CMomhopf.js +0 -35
  332. package/dist/bg-BG-Dy6-IwuZ.js +0 -28
  333. package/dist/bg-BG-NMIts2sa.js +0 -35
  334. package/dist/bg-BG-hFblesn-.js +0 -15
  335. package/dist/cs-CZ-B8IPRc47.js +0 -15
  336. package/dist/cs-CZ-BEFeaKsV.js +0 -54
  337. package/dist/cs-CZ-Csr_35T-.js +0 -35
  338. package/dist/cs-CZ-DMzortvO.js +0 -35
  339. package/dist/cs-CZ-Dbow28-o.js +0 -28
  340. package/dist/cs-CZ-Wzc382q6.js +0 -23
  341. package/dist/cs-CZ-wdftovLe.js +0 -55
  342. package/dist/cs-CZ-y4mvq4Lv.js +0 -13
  343. package/dist/da-DK-qgQOVjDp.js +0 -13
  344. package/dist/de-DE-pSdsxBpQ.js +0 -13
  345. package/dist/document-plus-NwgAdjyB.js +0 -17
  346. package/dist/el-GR-B5j7VZ3E.js +0 -54
  347. package/dist/el-GR-Bvjk5Sw8.js +0 -13
  348. package/dist/el-GR-CGeBAkDN.js +0 -35
  349. package/dist/el-GR-CXmTklMq.js +0 -55
  350. package/dist/el-GR-Cu9HwD-f.js +0 -15
  351. package/dist/el-GR-DGW388LZ.js +0 -35
  352. package/dist/el-GR-DerT143K.js +0 -28
  353. package/dist/el-GR-DfNOPkLq.js +0 -23
  354. package/dist/en-US-Bq2Twy6x.js +0 -54
  355. package/dist/es-ES-Dy1uR2H_.js +0 -13
  356. package/dist/et-EE-BJIsPOnh.js +0 -23
  357. package/dist/et-EE-CFlzRBEx.js +0 -55
  358. package/dist/et-EE-D5lRJbMZ.js +0 -35
  359. package/dist/et-EE-DUWZ2Vqm.js +0 -54
  360. package/dist/et-EE-Dor3enPS.js +0 -15
  361. package/dist/et-EE-OJg_PSHf.js +0 -28
  362. package/dist/et-EE-QLVnr6Vl.js +0 -35
  363. package/dist/et-EE-d9V24rcf.js +0 -13
  364. package/dist/fi-FI-B0fnAFV2.js +0 -13
  365. package/dist/fr-FR-BoKzVp2q.js +0 -13
  366. package/dist/getFieldsWithExistingData-CUMH8N-C.js +0 -22
  367. package/dist/hide-CigAXbWC.js +0 -18
  368. package/dist/hr-HR-B8AZ4eHJ.js +0 -35
  369. package/dist/hr-HR-CDUE36Dg.js +0 -28
  370. package/dist/hr-HR-CF0AHQzi.js +0 -13
  371. package/dist/hr-HR-CnP5sqih.js +0 -54
  372. package/dist/hr-HR-CzSrqEFA.js +0 -35
  373. package/dist/hr-HR-DTCY4iL8.js +0 -55
  374. package/dist/hr-HR-DzS44Gpv.js +0 -23
  375. package/dist/hu-HU-BSOiZA7a.js +0 -15
  376. package/dist/hu-HU-BTlpbCpc.js +0 -54
  377. package/dist/hu-HU-Bmf13NMf.js +0 -28
  378. package/dist/hu-HU-BznXPoc2.js +0 -55
  379. package/dist/hu-HU-CSPhOvLC.js +0 -13
  380. package/dist/hu-HU-DRi6Dz9U.js +0 -35
  381. package/dist/hu-HU-xCvNM5TU.js +0 -23
  382. package/dist/hu-HU-zK6nUqWr.js +0 -35
  383. package/dist/idea-DwJIwJHR.js +0 -18
  384. package/dist/instant-verification-method-BGfknV9x.js +0 -28
  385. package/dist/it-IT-BH-eqIKH.js +0 -13
  386. package/dist/ja-JP-B3yqM_FM.js +0 -13
  387. package/dist/ja-JP-BUz3qN-V.js +0 -23
  388. package/dist/ja-JP-BhS-_dIx.js +0 -54
  389. package/dist/ja-JP-C1OQ16fo.js +0 -35
  390. package/dist/ja-JP-D7oL6xGY.js +0 -55
  391. package/dist/ja-JP-GXkLvnQ4.js +0 -15
  392. package/dist/ja-JP-tx1DbZYD.js +0 -28
  393. package/dist/ja-JP-weDU8GLW.js +0 -35
  394. package/dist/lt-LT-B6CJ4ULI.js +0 -23
  395. package/dist/lt-LT-BUYY0LaT.js +0 -35
  396. package/dist/lt-LT-BxScCodJ.js +0 -28
  397. package/dist/lt-LT-DNjXmQPv.js +0 -15
  398. package/dist/lt-LT-DTQGR9M0.js +0 -54
  399. package/dist/lt-LT-De7dLXxI.js +0 -55
  400. package/dist/lt-LT-Lzl_Cbw-.js +0 -13
  401. package/dist/lt-LT-_MzAcXJo.js +0 -35
  402. package/dist/lv-LV-B9js9VoA.js +0 -35
  403. package/dist/lv-LV-BQ4F1GrV.js +0 -54
  404. package/dist/lv-LV-CRhXAjn6.js +0 -35
  405. package/dist/lv-LV-ChOoZuhc.js +0 -15
  406. package/dist/lv-LV-DTtuyfHS.js +0 -23
  407. package/dist/lv-LV-De9rdme0.js +0 -55
  408. package/dist/lv-LV-F9_Fiu3w.js +0 -28
  409. package/dist/lv-LV-y00wN1pj.js +0 -13
  410. package/dist/mapFinancialReportsToFinancialInformation-Bo2uW3j7.js +0 -66
  411. package/dist/nl-NL-DmnFXAQC.js +0 -13
  412. package/dist/no-NO-DbvFfP96.js +0 -13
  413. package/dist/pl-PL--mmxopYA.js +0 -13
  414. package/dist/pl-PL-1ylK-_FE.js +0 -35
  415. package/dist/pl-PL-CqxMKpBm.js +0 -28
  416. package/dist/pl-PL-D6heiKsH.js +0 -15
  417. package/dist/pl-PL-DAPGaxWi.js +0 -35
  418. package/dist/pl-PL-DD3wVcKc.js +0 -55
  419. package/dist/pl-PL-T6uD5--R.js +0 -23
  420. package/dist/pl-PL-kGaeUP-w.js +0 -54
  421. package/dist/plus-small-Dj1WRyFM.js +0 -14
  422. package/dist/pt-PT-BVzXBFp7.js +0 -13
  423. package/dist/ro-RO-C83h2zHZ.js +0 -54
  424. package/dist/ro-RO-CUg8-CQ8.js +0 -55
  425. package/dist/ro-RO-Cdmevo9A.js +0 -13
  426. package/dist/ro-RO-DJLWmWZ4.js +0 -35
  427. package/dist/ro-RO-DL9V1CMj.js +0 -15
  428. package/dist/ro-RO-Dfx0g3bU.js +0 -35
  429. package/dist/ro-RO-IY3AMhwm.js +0 -28
  430. package/dist/ro-RO-Ic1SzBgx.js +0 -23
  431. package/dist/ru-RU-FZb2upqh.js +0 -13
  432. package/dist/sk-SK-B7o3L57C.js +0 -35
  433. package/dist/sk-SK-BDKRZ2mM.js +0 -28
  434. package/dist/sk-SK-BSioQTMW.js +0 -15
  435. package/dist/sk-SK-CgLJIuJw.js +0 -54
  436. package/dist/sk-SK-CiD0FeLN.js +0 -23
  437. package/dist/sk-SK-Cjrkrb85.js +0 -55
  438. package/dist/sk-SK-iO863_t2.js +0 -35
  439. package/dist/sk-SK-nfeuTcY5.js +0 -13
  440. package/dist/sl-SI-DUTZDqkP.js +0 -13
  441. package/dist/sv-SE-BTx2XKAp.js +0 -13
  442. package/dist/types/components/Individual/mapping/mapLocalization.d.ts +0 -3
  443. package/dist/types/components/ui/atoms/OutlinedIcon/OutlinedIcon.d.ts +0 -5
  444. package/dist/types/components/ui/atoms/ProviderButton/ProviderButton.d.ts +0 -3
  445. package/dist/types/components/ui/atoms/ProviderButton/ProviderButton.types.d.ts +0 -5
  446. package/dist/types/components/ui/molecules/FormEndState/FormEndState.d.ts +0 -2
  447. package/dist/types/components/ui/molecules/FormEndState/types.d.ts +0 -8
  448. package/dist/useUpdateLegalEntity-56mDjaQA.js +0 -57
  449. package/dist/validate-Bgc1XuQl.js +0 -40
  450. package/dist/zh-CN-wUb4MmTZ.js +0 -13
  451. package/dist/zh-TW-DNTXHLKa.js +0 -13
  452. /package/dist/types/embeds/{individual/adyen-individual.d.ts → individual-configuration/adyen-individual-configuration.d.ts} +0 -0
  453. /package/dist/types/embeds/{manage-individual/adyen-manage-individual.d.ts → individual-status/adyen-individual-status.d.ts} +0 -0
  454. /package/dist/types/embeds/{manage-terms-of-service/adyen-manage-terms-of-service.d.ts → terms-of-service-management/adyen-terms-of-service-management.d.ts} +0 -0
  455. /package/dist/types/embeds/{manage-transfer-instruments/adyen-manage-transfer-instruments.d.ts → terms-of-service-status/adyen-terms-of-service-status.d.ts} +0 -0
  456. /package/dist/types/embeds/{terms-of-service/adyen-terms-of-service.d.ts → transfer-instrument-configuration/adyen-transfer-instrument-configuration.d.ts} +0 -0
  457. /package/dist/types/embeds/{transfer-instrument/adyen-transfer-instrument.d.ts → transfer-instrument-management/adyen-transfer-instrument-management.d.ts} +0 -0
@@ -0,0 +1,3694 @@
1
+ ;
2
+ {
3
+ try {
4
+ let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "743cc952-87a2-4737-8336-8e437ec1e02e", e._sentryDebugIdIdentifier = "sentry-dbid-743cc952-87a2-4737-8336-8e437ec1e02e");
6
+ } catch (e) {
7
+ }
8
+ }
9
+ ;
10
+ import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
11
+ import { useState, useEffect, useRef, useMemo, useCallback, useContext } from "preact/hooks";
12
+ import { b as useApiContext, j as useQuery, k as httpPost, o as httpGet, aA as useMutation, aC as useQueryClient, N as createLogger, a8 as CountryCodes, a as useTranslation, c as useLegalEntity, R as ROOT_LE, y as LegalEntityTypes, L as Loader, J as EntityTypes, U as useAnalyticsContext, V as Icon, x as Typography, B as Button, u as useI18nContext, af as objectsDeepEqual, aG as doArraysMatch, a9 as isEmpty, bj as getSdkToken, G as hasOwnEntityAssociationOfType, m as useSettingsContext, bk as EEA_Countries, X as useExperimentsContext, bl as isAccountIdentifierObscured, bm as hasEmptyFields, bn as extractFieldName, bo as concatenateFieldNames, aD as keysOf, g as getLegalEntityCountry, am as getCapabilityProblems, M as TaskTypes, ay as cloneObject, q as skipToken } from "./StoreProvider-BlaJzXSZ.js";
13
+ import { u as useTransferInstrument, m as mapTransferInstrumentToPayoutAccount } from "./mapTransferInstrumentToPayoutAccount-CAoOlPMA.js";
14
+ import { a as useForm, F as Field, c as Select, L as LoaderWrapper } from "./useForm-C1DW3mPC.js";
15
+ import { E as ExperimentNames } from "./types-CAznNNSI.js";
16
+ import { I as InputText, S as SettingNames } from "./InputText-BX5sG9WJ.js";
17
+ import { u as useGlobalDataSlice, a as useGlobalData, b as useResetGlobalData, c as useStateContext, F as FormWrapper } from "./useGlobalData-jb7ua9I6.js";
18
+ import { a as useInvalidateRootLegalEntity, u as useToastContext } from "./useToastContext-DGMeMy5R.js";
19
+ import { D as DropzoneFile, h as bytesToSize, i as defaultFileValidationOptions, j as fileValidationRules, S as StateContextSetter, a as getDocument, c as createDocumentRequest, k as augmentWithCountryConfigs, d as documentApiUtils, b as getPropsFromConfigurations, f as getFileExtention } from "./validate-CvtamBXH.js";
20
+ import { g as getRequiredForms, a as addValidityToForms, u as useFormComposer } from "./dropinUtils-DHp5v5jB.js";
21
+ import { D as DocumentGuidance, A as AdyenKycSdkError, u as uppercase, p as payoutAccountFormat, m as mapExistingFile, g as getPageName, b as useScenarioConfiguration, c as useUnifyLoadingStatus } from "./mapExistingFile-DW5ktJzM.js";
22
+ import { C as Confirm } from "./Confirm-DwutojkY.js";
23
+ import { c as currencyByCountry } from "./types-K58FM7k4.js";
24
+ import { i as isValidationError, p as processValidationErrors, b as isIdDocumentUploadError, c as isBankStatementUploadError, a as isMaintenanceModeError, m as mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable } from "./validationError-DOCbfk7K.js";
25
+ import { u as useDataset, d as datasetIdentifier, a as datasetUtilities } from "./useDataset-BgvQQEKd.js";
26
+ import { g as getLegalEntityNameBasedOnType, b as getPayoutAccountHolderName } from "./getName-DJlhsDj_.js";
27
+ import { I as IFrameWidget, o as omitObscuredFieldsIfUnchanged } from "./iframeWidget-Bftkd3v_.js";
28
+ import { Show } from "@preact/signals/utils";
29
+ import { c as createFormUtils, F as FormHeader, E as ErrorPanel, m as mergeFieldMetadataIntoProps, g as getFieldProps, C as CountryField, f as getFormProps, d as summaryStep, s as summaryItem } from "./CountryField-D0YZrov9.js";
30
+ import { a as addResourceBundles, _ as __variableDynamicImportRuntimeHelper, T as Trans } from "./translation-DJHWTow9.js";
31
+ import { signal } from "@preact/signals";
32
+ import { u as useAssociatedLegalEntity } from "./useAssociatedLegalEntity-G30FPhOX.js";
33
+ import { b as useCapabilityProblems, g as getProblemsForEntity, T as TextArea, f as validatePatternOnBlur, r as resolveFieldMetadata, a as useAccountHolder, I as Image, R as RadioGroupCard, C as ContextGuidance } from "./fieldConfigurations-B8bDFQ53.js";
34
+ import { c as createFormRules } from "./form-rules-DhbF2mY4.js";
35
+ import { memo, lazy } from "preact/compat";
36
+ import { u as useUnincorporatedPartnershipMembers } from "./useUnincorporatedPartnershipMembers-BCvmGMOX.js";
37
+ import cx from "classnames";
38
+ import { b as bankStatementDescriptionPattern } from "./basePatterns-BwdnMQxI.js";
39
+ import { createContext } from "preact";
40
+ import { a as Alert } from "./Alert-C24s_Ygs.js";
41
+ import { A as ActionBar } from "./FormNavigation-ezxkIqdb.js";
42
+ import OpenBankingSDK from "@adyen/openbankingsdk";
43
+ import { m as makeMask, n as numericInputs, a as nonInputs, s as spacer, c as customInputs, M as MaskedInput, d as alphanumericInputs, b as alphaInputs } from "./MaskedInput-BZ7t98eu.js";
44
+ import { a as isNotEmptyValidator } from "./commonValidators-Bk0SSjsH.js";
45
+ import { C as Currencies } from "./currency-BGwQyxBo.js";
46
+ import { L as Link } from "./Link-BFdxU8qh.js";
47
+ const getCheck = async (legalEntityId, baseUrl, data) => {
48
+ return httpPost(
49
+ {
50
+ baseUrl,
51
+ path: `legalEntities/${legalEntityId}/checks/bankAccount`
52
+ },
53
+ data
54
+ );
55
+ };
56
+ const useCheck = (data, options) => {
57
+ const { rootLegalEntityId, baseUrl: url } = useApiContext();
58
+ return useQuery({
59
+ queryKey: ["checkAsAService", data],
60
+ queryFn: () => getCheck(rootLegalEntityId.value, url.value, data),
61
+ ...options
62
+ });
63
+ };
64
+ const getBankVerificationProviders = async (legalEntityId, baseUrl, queryParams) => {
65
+ const { country, locale, configId } = queryParams;
66
+ const providerParams = new URLSearchParams({
67
+ country,
68
+ locale,
69
+ ...configId && { configId }
70
+ });
71
+ return httpGet({
72
+ baseUrl,
73
+ path: `legalEntities/${legalEntityId}/transferInstruments/trusted/providers?${providerParams}`
74
+ });
75
+ };
76
+ const useBankVerificationProviders = (queryParams, options) => {
77
+ const { rootLegalEntityId, baseUrl } = useApiContext();
78
+ return useQuery({
79
+ queryKey: ["bankVerificationProviders", queryParams],
80
+ queryFn: () => getBankVerificationProviders(rootLegalEntityId.value, baseUrl.value, queryParams),
81
+ ...options
82
+ });
83
+ };
84
+ const createTransferInstrument = async (rootLegalEntityId, baseUrl, transferInstrument) => {
85
+ return httpPost(
86
+ {
87
+ baseUrl,
88
+ path: `legalEntities/${rootLegalEntityId}/transferInstruments`
89
+ },
90
+ transferInstrument
91
+ );
92
+ };
93
+ const createTrustedTransferInstrument = async (legalEntityId, baseUrl, data) => {
94
+ return httpPost(
95
+ {
96
+ baseUrl,
97
+ path: `legalEntities/${legalEntityId}/transferInstruments/trusted`
98
+ },
99
+ data
100
+ );
101
+ };
102
+ const useCreateTrustedTransferInstrument = (options) => {
103
+ const { rootLegalEntityId, baseUrl } = useApiContext();
104
+ return useMutation({
105
+ mutationFn: (data) => createTrustedTransferInstrument(rootLegalEntityId.value, baseUrl.value, data),
106
+ ...options
107
+ });
108
+ };
109
+ const updateTransferInstrument = async (legalEntityId, baseUrl, transferInstrument, transferInstrumentId) => {
110
+ return httpPost(
111
+ {
112
+ baseUrl,
113
+ path: `legalEntities/${legalEntityId}/transferInstruments/${transferInstrumentId}`
114
+ },
115
+ transferInstrument
116
+ );
117
+ };
118
+ const useUpdateTransferInstrument = (options) => {
119
+ const { rootLegalEntityId, baseUrl } = useApiContext();
120
+ const queryClient = useQueryClient();
121
+ return useMutation({
122
+ mutationFn: ({ transferInstrument, transferInstrumentId }) => updateTransferInstrument(
123
+ rootLegalEntityId.value,
124
+ baseUrl.value,
125
+ transferInstrument,
126
+ transferInstrumentId
127
+ ),
128
+ onSuccess: async (transferInstrument) => {
129
+ queryClient.setQueryData(["transferInstrument", transferInstrument.id], transferInstrument);
130
+ await queryClient.invalidateQueries({
131
+ // Invalidate transfer instruments on root LE
132
+ queryKey: ["transferInstruments"]
133
+ });
134
+ },
135
+ ...options
136
+ });
137
+ };
138
+ const accountFormatsImports = /* @__PURE__ */ Object.assign({ "../accountFormats/AD.json": () => import("./AD-CyP5INSp.js"), "../accountFormats/AE.json": () => import("./AE-mIZ12t47.js"), "../accountFormats/AI.json": () => import("./AI-CYOqGKk2.js"), "../accountFormats/AL.json": () => import("./AL-BX1fEo1A.js"), "../accountFormats/AR.json": () => import("./AR-C9kMRnHG.js"), "../accountFormats/AS.json": () => import("./AS-B0TMZQ6o.js"), "../accountFormats/AT.json": () => import("./AT-DJLlevck.js"), "../accountFormats/AU.json": () => import("./AU-B5LSe4bo.js"), "../accountFormats/AX.json": () => import("./AX-Z6f6EnJc.js"), "../accountFormats/AZ.json": () => import("./AZ-BqrKjWMH.js"), "../accountFormats/BA.json": () => import("./BA-BbP72Tn6.js"), "../accountFormats/BE.json": () => import("./BE-B-m_4F41.js"), "../accountFormats/BG.json": () => import("./BG-BVR5ytc-.js"), "../accountFormats/BH.json": () => import("./BH-Ded1Eyrc.js"), "../accountFormats/BM.json": () => import("./BM-CBl-UQUl.js"), "../accountFormats/BR.json": () => import("./BR-DsY9PZVZ.js"), "../accountFormats/BS.json": () => import("./BS-dBfArxRw.js"), "../accountFormats/BV.json": () => import("./BV-D0QBsH7-.js"), "../accountFormats/BY.json": () => import("./BY-BsQUo3fM.js"), "../accountFormats/CA.json": () => import("./CA-DT4cmOOe.js"), "../accountFormats/CH.json": () => import("./CH-CesIKOYy.js"), "../accountFormats/CN.json": () => import("./CN-BV-5PSpq.js"), "../accountFormats/CR.json": () => import("./CR-Dtv-rXg9.js"), "../accountFormats/CY.json": () => import("./CY-BnJ7k_mN.js"), "../accountFormats/CZ.json": () => import("./CZ-BiPeoA9G.js"), "../accountFormats/DE.json": () => import("./DE-DdcbG-CC.js"), "../accountFormats/DK.json": () => import("./DK-DA8qRrzq.js"), "../accountFormats/DO.json": () => import("./DO-B1BWc3Iy.js"), "../accountFormats/EC.json": () => import("./EC-DbNXe71-.js"), "../accountFormats/EE.json": () => import("./EE-CaXoPgZz.js"), "../accountFormats/ES.json": () => import("./ES-Bt_oaIaf.js"), "../accountFormats/FI.json": () => import("./FI-C5V3lLuN.js"), "../accountFormats/FJ.json": () => import("./FJ-CBdbPf5l.js"), "../accountFormats/FO.json": () => import("./FO-1pD1p939.js"), "../accountFormats/FR.json": () => import("./FR-Bc1tLIC4.js"), "../accountFormats/GB.json": () => import("./GB-CCYHTagl.js"), "../accountFormats/GE.json": () => import("./GE-Deog1a3Z.js"), "../accountFormats/GF.json": () => import("./GF-Cda8N7A4.js"), "../accountFormats/GG.json": () => import("./GG-BGuqxplU.js"), "../accountFormats/GI.json": () => import("./GI-CROkpYrU.js"), "../accountFormats/GL.json": () => import("./GL-0vO9Of9c.js"), "../accountFormats/GP.json": () => import("./GP-za-3opp-.js"), "../accountFormats/GR.json": () => import("./GR-B9c2boG8.js"), "../accountFormats/GT.json": () => import("./GT-C1jhs-Dx.js"), "../accountFormats/GU.json": () => import("./GU-CALV5vh1.js"), "../accountFormats/HK.json": () => import("./HK-BB3PIq-Z.js"), "../accountFormats/HR.json": () => import("./HR-p4luVYpu.js"), "../accountFormats/HU.json": () => import("./HU-D8vJYkDH.js"), "../accountFormats/ID.json": () => import("./ID-BcOv4SXj.js"), "../accountFormats/IE.json": () => import("./IE-Cli_j7Al.js"), "../accountFormats/IL.json": () => import("./IL-CQ0yHRRe.js"), "../accountFormats/IM.json": () => import("./IM-mpIyBn16.js"), "../accountFormats/IN.json": () => import("./IN-BhEI9o7G.js"), "../accountFormats/IS.json": () => import("./IS-02zCAdvq.js"), "../accountFormats/IT.json": () => import("./IT-CzURFhrK.js"), "../accountFormats/JE.json": () => import("./JE-MFwIYti7.js"), "../accountFormats/JM.json": () => import("./JM-BMGgBK6y.js"), "../accountFormats/JO.json": () => import("./JO-rY8A8f9C.js"), "../accountFormats/JP.json": () => import("./JP-BQG5dF1Y.js"), "../accountFormats/KR.json": () => import("./KR-74SwXHka.js"), "../accountFormats/KW.json": () => import("./KW-CcVPOJ8B.js"), "../accountFormats/KY.json": () => import("./KY-DXCeltYA.js"), "../accountFormats/KZ.json": () => import("./KZ-CZNjdp22.js"), "../accountFormats/LB.json": () => import("./LB-DZ5YfAsO.js"), "../accountFormats/LI.json": () => import("./LI-DA06W10W.js"), "../accountFormats/LT.json": () => import("./LT-DuU6E2Ct.js"), "../accountFormats/LU.json": () => import("./LU-BQHhNpDy.js"), "../accountFormats/LV.json": () => import("./LV-DN7wckbP.js"), "../accountFormats/MC.json": () => import("./MC-DtSWC4jS.js"), "../accountFormats/MD.json": () => import("./MD-DVc0183a.js"), "../accountFormats/ME.json": () => import("./ME-DiJhSuli.js"), "../accountFormats/MK.json": () => import("./MK-BZxslBTS.js"), "../accountFormats/MP.json": () => import("./MP-7IpnbfCj.js"), "../accountFormats/MQ.json": () => import("./MQ-DusG_no1.js"), "../accountFormats/MR.json": () => import("./MR-DaBVNHqN.js"), "../accountFormats/MT.json": () => import("./MT-DeDMQ1f_.js"), "../accountFormats/MU.json": () => import("./MU-D3gGVu1R.js"), "../accountFormats/MX.json": () => import("./MX-CZVOFg3D.js"), "../accountFormats/MY.json": () => import("./MY-ym71svTa.js"), "../accountFormats/NC.json": () => import("./NC-xzMvjp9-.js"), "../accountFormats/NL.json": () => import("./NL-aVL0NAp-.js"), "../accountFormats/NO.json": () => import("./NO-D7EOiQA1.js"), "../accountFormats/NZ.json": () => import("./NZ-BP7_Q9Om.js"), "../accountFormats/PE.json": () => import("./PE-CdxgPh3v.js"), "../accountFormats/PF.json": () => import("./PF-CstaOd9Z.js"), "../accountFormats/PH.json": () => import("./PH-BYgMDYIH.js"), "../accountFormats/PK.json": () => import("./PK-bLhtgsEk.js"), "../accountFormats/PL.json": () => import("./PL-Bg7axKQA.js"), "../accountFormats/PM.json": () => import("./PM-BWbxAh4u.js"), "../accountFormats/PR.json": () => import("./PR-CFPKXEXp.js"), "../accountFormats/PS.json": () => import("./PS-B8obOOWY.js"), "../accountFormats/PT.json": () => import("./PT-hB1HnBM2.js"), "../accountFormats/QA.json": () => import("./QA-CSfx-mvb.js"), "../accountFormats/RE.json": () => import("./RE-BApq1FJ6.js"), "../accountFormats/RO.json": () => import("./RO-BLlC4CKq.js"), "../accountFormats/RS.json": () => import("./RS-BCenke-W.js"), "../accountFormats/RU.json": () => import("./RU-D27RC7dq.js"), "../accountFormats/SA.json": () => import("./SA-C9VgxCgm.js"), "../accountFormats/SE.json": () => import("./SE-q25Qt85B.js"), "../accountFormats/SG.json": () => import("./SG-DoCqjlFi.js"), "../accountFormats/SI.json": () => import("./SI-BzA-ozn6.js"), "../accountFormats/SJ.json": () => import("./SJ-Z9jwQQlz.js"), "../accountFormats/SK.json": () => import("./SK-DOTdLJPw.js"), "../accountFormats/SM.json": () => import("./SM-B4BIgmhk.js"), "../accountFormats/TF.json": () => import("./TF-BOWng-Dz.js"), "../accountFormats/TH.json": () => import("./TH-CvyXLcZK.js"), "../accountFormats/TL.json": () => import("./TL-BWslydRz.js"), "../accountFormats/TN.json": () => import("./TN-Cjd3bM_V.js"), "../accountFormats/TR.json": () => import("./TR-BBx5CuWS.js"), "../accountFormats/TT.json": () => import("./TT-D4-z5BA-.js"), "../accountFormats/TW.json": () => import("./TW-BC8YpnMr.js"), "../accountFormats/UA.json": () => import("./UA-DrXUnAe6.js"), "../accountFormats/US.json": () => import("./US-D8dI5_i1.js"), "../accountFormats/UY.json": () => import("./UY-DEHqLXhX.js"), "../accountFormats/VA.json": () => import("./VA-bPXdCnwD.js"), "../accountFormats/VG.json": () => import("./VG-DnKAVCsi.js"), "../accountFormats/VI.json": () => import("./VI-CU9MA9ux.js"), "../accountFormats/VN.json": () => import("./VN-CTSqsmB6.js"), "../accountFormats/WF.json": () => import("./WF-CwHbsjtJ.js"), "../accountFormats/YT.json": () => import("./YT-BCyAAbo7.js"), "../accountFormats/ZA.json": () => import("./ZA-NU7slima.js") });
139
+ const getAccountFormatsForCountry = async (country) => {
140
+ const importForCountry = accountFormatsImports[`../accountFormats/${country}.json`];
141
+ if (!importForCountry) {
142
+ throw Error(`No account formats available for ${country}`);
143
+ }
144
+ return (await importForCountry()).default;
145
+ };
146
+ const validateAccountIdentification = async (baseUrl, data) => {
147
+ return httpPost(
148
+ {
149
+ baseUrl,
150
+ path: `validations/accountidentification`
151
+ },
152
+ {
153
+ accountIdentification: {
154
+ ...data
155
+ }
156
+ }
157
+ );
158
+ };
159
+ const useValidateAccountIdentification = (options) => {
160
+ const { baseUrl } = useApiContext();
161
+ return useMutation({
162
+ mutationFn: (data) => validateAccountIdentification(baseUrl.value, data),
163
+ ...options
164
+ });
165
+ };
166
+ const useAsyncAccountDetailsValidationRules = (payload, hasEmptyFields2, isAccountNumberMasked) => {
167
+ const [timeoutId, setTimeoutId] = useState(null);
168
+ const [accountValidationData, setAccountValidationData] = useState({
169
+ invalidFields: [],
170
+ valid: false
171
+ });
172
+ const { mutateAsync } = useValidateAccountIdentification();
173
+ useEffect(() => {
174
+ const fetchAccountDetails = async (accountIdentificationPayload) => {
175
+ try {
176
+ const accountIdentificationResponse = await mutateAsync(accountIdentificationPayload);
177
+ setAccountValidationData(accountIdentificationResponse);
178
+ } catch (error) {
179
+ console.error("Error fetching account details:", error);
180
+ }
181
+ };
182
+ if (payload && !hasEmptyFields2 && !isAccountNumberMasked) {
183
+ if (timeoutId !== null) {
184
+ clearTimeout(timeoutId);
185
+ }
186
+ setTimeoutId(
187
+ setTimeout(() => {
188
+ fetchAccountDetails(payload);
189
+ setTimeoutId(null);
190
+ }, 500)
191
+ );
192
+ }
193
+ }, [mutateAsync, hasEmptyFields2, payload]);
194
+ return accountValidationData;
195
+ };
196
+ const logger = createLogger();
197
+ const getAccountIdentificationFromPayoutAccountSchema = (payoutAccount, bankCountry) => {
198
+ if ("iban" in payoutAccount && payoutAccount.iban)
199
+ return {
200
+ type: "iban",
201
+ iban: payoutAccount.iban
202
+ };
203
+ switch (bankCountry) {
204
+ case CountryCodes.Australia:
205
+ return {
206
+ type: "auLocal",
207
+ accountNumber: payoutAccount.bankAccountNumber,
208
+ bsbCode: payoutAccount.branchCode
209
+ };
210
+ case CountryCodes.Brazil:
211
+ return {
212
+ type: "brLocal",
213
+ accountNumber: payoutAccount.bankAccountNumber,
214
+ ispb: payoutAccount.bankCode,
215
+ bankCode: payoutAccount.bankName,
216
+ branchNumber: payoutAccount.branchCode
217
+ };
218
+ case CountryCodes.Canada:
219
+ return {
220
+ type: "caLocal",
221
+ accountNumber: payoutAccount.bankAccountNumber,
222
+ institutionNumber: payoutAccount.bankCode,
223
+ transitNumber: payoutAccount.branchCode
224
+ };
225
+ case CountryCodes.CzechRepublic:
226
+ return {
227
+ type: "czLocal",
228
+ accountNumber: payoutAccount.bankAccountNumber,
229
+ bankCode: payoutAccount.bankCode
230
+ };
231
+ case CountryCodes.Denmark:
232
+ return {
233
+ type: "dkLocal",
234
+ accountNumber: payoutAccount.bankAccountNumber,
235
+ bankCode: payoutAccount.bankCode
236
+ };
237
+ case CountryCodes.HongKong:
238
+ return {
239
+ type: "hkLocal",
240
+ accountNumber: payoutAccount.bankAccountNumber,
241
+ clearingCode: payoutAccount.bankCode
242
+ };
243
+ case CountryCodes.NewZealand:
244
+ return {
245
+ type: "nzLocal",
246
+ accountNumber: payoutAccount.bankAccountNumber?.replaceAll("-", "")
247
+ };
248
+ case CountryCodes.Sweden:
249
+ return {
250
+ type: "seLocal",
251
+ accountNumber: payoutAccount.bankAccountNumber,
252
+ clearingNumber: payoutAccount.branchCode
253
+ };
254
+ case CountryCodes.Singapore:
255
+ return {
256
+ type: "sgLocal",
257
+ accountNumber: payoutAccount.bankAccountNumber,
258
+ bic: payoutAccount.swiftCode
259
+ };
260
+ case CountryCodes.IsleOfMan:
261
+ case CountryCodes.Guernsey:
262
+ case CountryCodes.Gibraltar:
263
+ case CountryCodes.Jersey:
264
+ case CountryCodes.UnitedKingdom:
265
+ return {
266
+ type: "ukLocal",
267
+ // for some reason GB's account identification is called `ukLocalAccountIdentification`
268
+ accountNumber: payoutAccount.bankAccountNumber,
269
+ sortCode: payoutAccount.branchCode
270
+ };
271
+ case CountryCodes.NorthernMarianaIslands:
272
+ case CountryCodes.Guam:
273
+ case CountryCodes.VirginIslandsUS:
274
+ case CountryCodes.AmericanSamoa:
275
+ case CountryCodes.PuertoRico:
276
+ case CountryCodes.UnitedStates:
277
+ return {
278
+ type: "usLocal",
279
+ accountNumber: payoutAccount.bankAccountNumber,
280
+ routingNumber: payoutAccount.branchCode
281
+ };
282
+ default:
283
+ logger.log(`${bankCountry.toLowerCase()}Local is not a configured region`);
284
+ return {
285
+ type: `${bankCountry.toLowerCase()}Local`,
286
+ accountNumber: payoutAccount.bankAccountNumber
287
+ };
288
+ }
289
+ };
290
+ const mapPayoutAccountSchemaToApiBankAccount = (payoutAccount, bankCountry) => ({
291
+ accountIdentification: getAccountIdentificationFromPayoutAccountSchema(
292
+ payoutAccount,
293
+ bankCountry
294
+ ),
295
+ countryCode: bankCountry,
296
+ bankName: payoutAccount.bankName
297
+ });
298
+ const showPayoutVerificationMethodError = signal(false);
299
+ function PayoutDetailsPage({
300
+ transferInstrumentId,
301
+ setTransferInstrumentId,
302
+ taskType,
303
+ openBankingPartnerConfigId,
304
+ onSubmit,
305
+ handleHomeClick
306
+ }) {
307
+ const { i18n } = useTranslation();
308
+ const { data: rootLe } = useLegalEntity(ROOT_LE);
309
+ const { data: associatedLe, isLoading: associatedLeIsLoading } = useAssociatedLegalEntity(
310
+ rootLe,
311
+ [
312
+ LegalEntityTypes.SOLE_PROPRIETORSHIP,
313
+ LegalEntityTypes.TRUST,
314
+ LegalEntityTypes.UNINCORPORATED_PARTNERSHIP
315
+ ]
316
+ );
317
+ const capabilityProblems = useCapabilityProblems();
318
+ addResourceBundles(i18n, i18n.language, [
319
+ { ns: "banking", importFn: () => __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "../language/da-DK.json": () => import("./da-DK-q2b_1elr.js"), "../language/de-DE.json": () => import("./de-DE-D2ByeIZs.js"), "../language/en-US.json": () => import("./en-US-BQpgt41j.js"), "../language/es-ES.json": () => import("./es-ES-WWftn3JX.js"), "../language/fi-FI.json": () => import("./fi-FI-D9E_KaJi.js"), "../language/fr-FR.json": () => import("./fr-FR-Cv0k-3Xc.js"), "../language/it-IT.json": () => import("./it-IT-C_fNHhjE.js"), "../language/nl-NL.json": () => import("./nl-NL-DLedC3mO.js"), "../language/no-NO.json": () => import("./no-NO-CpVal4cV.js"), "../language/pt-PT.json": () => import("./pt-PT-BkvMsoK4.js"), "../language/sl-SI.json": () => import("./sl-SI-Cth2Qa5T.js"), "../language/sv-SE.json": () => import("./sv-SE-OPOHtqtP.js") }), `../language/${i18n.language}.json`, 3) }
320
+ ]);
321
+ if (!rootLe || associatedLeIsLoading) {
322
+ return /* @__PURE__ */ jsx(Loader, {});
323
+ }
324
+ const problems = capabilityProblems && transferInstrumentId ? getProblemsForEntity(capabilityProblems, EntityTypes.BANK_ACCOUNT, transferInstrumentId) : void 0;
325
+ return /* @__PURE__ */ jsx(
326
+ PayoutDetailsDropin,
327
+ {
328
+ taskType,
329
+ currentTransferInstrumentId: transferInstrumentId,
330
+ setCurrentTransferInstrumentId: setTransferInstrumentId,
331
+ legalEntityResponse: rootLe,
332
+ associatedLegalArrangement: associatedLe,
333
+ problems,
334
+ onSubmit,
335
+ handleHomeClick,
336
+ navigateBackToTaskList: handleHomeClick,
337
+ openBankingPartnerConfigId
338
+ }
339
+ );
340
+ }
341
+ const PayoutDetailsPage$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
342
+ __proto__: null,
343
+ PayoutDetailsPage,
344
+ showPayoutVerificationMethodError
345
+ }, Symbol.toStringTag, { value: "Module" }));
346
+ function FilePicker({
347
+ files,
348
+ setFiles,
349
+ isValid,
350
+ errorMessage,
351
+ multiple = false,
352
+ label,
353
+ name,
354
+ iconPrefix = "generic-document",
355
+ enableTracking = false,
356
+ id,
357
+ // file validation options
358
+ allowedFileTypes,
359
+ maxSize,
360
+ isOptional,
361
+ maxNumberOfFiles,
362
+ // a11y
363
+ "aria-describedby": ariaDescribedBy,
364
+ "aria-labelledby": ariaLabelledBy
365
+ }) {
366
+ const { t } = useTranslation("common");
367
+ const userEvents = useAnalyticsContext();
368
+ const fileInput = useRef(null);
369
+ const [dragged, setDragged] = useState(false);
370
+ const hasRequiredError = errorMessage === "fieldIsRequired";
371
+ const showDropzone = files.length < maxNumberOfFiles;
372
+ const openFilePicker = () => fileInput.current?.click();
373
+ const handleFileDelete = (fileToDelete) => setFiles(files.filter((file) => file !== fileToDelete));
374
+ const handleDragEnter = (e) => {
375
+ e.preventDefault();
376
+ e.stopPropagation();
377
+ };
378
+ const handleDragLeave = (e) => {
379
+ e.preventDefault();
380
+ e.stopPropagation();
381
+ setDragged(false);
382
+ };
383
+ const handleDragOver = (e) => {
384
+ e.preventDefault();
385
+ e.stopPropagation();
386
+ setDragged(true);
387
+ };
388
+ const handleDrop = (e) => {
389
+ e.preventDefault();
390
+ e.stopPropagation();
391
+ if (e.dataTransfer) addFiles(e.dataTransfer.files);
392
+ setDragged(false);
393
+ };
394
+ const handleFilesChosen = (e) => {
395
+ const fileInput2 = e.target;
396
+ if (fileInput2.files) addFiles(fileInput2.files);
397
+ };
398
+ const addFiles = (newFiles) => {
399
+ if (enableTracking) {
400
+ userEvents.addFieldEvent("Interacted with form field", {
401
+ actionType: "change",
402
+ field: name || "dropzone"
403
+ });
404
+ }
405
+ setFiles([...newFiles, ...files]);
406
+ };
407
+ const allowedFileTypesString = allowedFileTypes.join(", ");
408
+ return /* @__PURE__ */ jsxs("div", { children: [
409
+ label && /* @__PURE__ */ jsx(
410
+ "div",
411
+ {
412
+ className: cx("adyen-kyc-label__text", {
413
+ "adyen-kyc-label__text--error": hasRequiredError
414
+ }),
415
+ children: label
416
+ }
417
+ ),
418
+ files.map((file) => /* @__PURE__ */ jsx(
419
+ DropzoneFile,
420
+ {
421
+ file,
422
+ onDelete: () => handleFileDelete(file),
423
+ errorMessage,
424
+ iconPrefix
425
+ },
426
+ file
427
+ )),
428
+ showDropzone && /* @__PURE__ */ jsxs(
429
+ "div",
430
+ {
431
+ role: "region",
432
+ className: cx("adyen-kyc-dropzone", {
433
+ "adyen-kyc-dropzone--dragged": dragged,
434
+ "adyen-kyc-dropzone--error": !dragged && hasRequiredError
435
+ }),
436
+ onDrop: handleDrop,
437
+ onDragOver: handleDragOver,
438
+ onDragEnter: handleDragEnter,
439
+ onDragLeave: handleDragLeave,
440
+ children: [
441
+ /* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropzone__icon", children: /* @__PURE__ */ jsx(Icon, { name: "upload" }) }),
442
+ /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-dropzone__labels", children: [
443
+ /* @__PURE__ */ jsx(Typography, { el: "h4", variant: "body-strongest", children: t(($) => $["dropFileToUpload"]) }),
444
+ /* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["supportedFileTypes"], { fileTypes: allowedFileTypesString }) }),
445
+ /* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["maxFileSize"], { maxSize: bytesToSize(maxSize) }) }),
446
+ /* @__PURE__ */ jsx(Typography, { color: "secondary", children: t(($) => $["upToFiles"], { maxFiles: maxNumberOfFiles }) })
447
+ ] }),
448
+ /* @__PURE__ */ jsx("div", { className: "adyen-kyc-dropzone__button", children: /* @__PURE__ */ jsx(Button, { onClick: openFilePicker, variant: "secondary", children: t(($) => $["browseFiles"]) }) }),
449
+ /* @__PURE__ */ jsx(
450
+ "input",
451
+ {
452
+ id,
453
+ className: "adyen-kyc-dropzone__input",
454
+ ref: fileInput,
455
+ multiple,
456
+ accept: allowedFileTypesString,
457
+ onChange: handleFilesChosen,
458
+ type: "file",
459
+ "aria-required": !isOptional,
460
+ "aria-describedby": ariaDescribedBy,
461
+ "aria-labelledby": ariaLabelledBy,
462
+ "data-testid": "hidden-file-input",
463
+ "aria-invalid": !isValid
464
+ }
465
+ )
466
+ ]
467
+ }
468
+ ),
469
+ hasRequiredError && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-error-text", children: t(($) => $["fieldIsRequired"]) })
470
+ ] });
471
+ }
472
+ const bankDocument = "adyen-kyc-bank-document";
473
+ const styles$2 = {
474
+ bankDocument
475
+ };
476
+ const documentRequirements = "adyen-kyc-document-requirements";
477
+ const documentRequirementsSubtitle = "adyen-kyc-document-requirements-subtitle";
478
+ const styles$1 = {
479
+ documentRequirements,
480
+ documentRequirementsSubtitle
481
+ };
482
+ const BankDocumentTypes = {
483
+ BANK_STATEMENT: "bankStatement",
484
+ DEPOSIT_SLIP: "depositSlip",
485
+ SCREENSHOT_OF_BANK: "screenshotOfOnlineBankingEnviroment",
486
+ A_LETTER_FROM_YOUR_BANK: "aLetterFromYourBank",
487
+ CHECK: "check"
488
+ };
489
+ const bankDocumentOptions = [
490
+ { id: BankDocumentTypes.BANK_STATEMENT, name: "bankStatementDocument" },
491
+ { id: BankDocumentTypes.DEPOSIT_SLIP, name: "depositSlip" },
492
+ { id: BankDocumentTypes.SCREENSHOT_OF_BANK, name: "screenshotOfOnlineBankingEnviroment" },
493
+ { id: BankDocumentTypes.A_LETTER_FROM_YOUR_BANK, name: "aLetterFromYourBank" },
494
+ { id: BankDocumentTypes.CHECK, name: "check" }
495
+ ];
496
+ const BankDocumentRequirement = {
497
+ ACCOUNT_NAME_INDIVIDUAL: "bankAccountNameIndividual",
498
+ ACCOUNT_NAME_ORGANIZATION: "bankAccountNameOrganization",
499
+ ACCOUNT_NAME_WITH_SOLE_PROP: "bankAccountNameWithSoleProprietor",
500
+ ACCOUNT_NAME_WITH_TRUST: "bankAccountNameWithTrust",
501
+ ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP: "accountMustBeInTheNameOfUnincorporatedPartnership",
502
+ ACCOUNT_NUMBER_OR_IBAN: "accountNumberOrIbanVisible",
503
+ ACCOUNT_NUMBER: "accountNumberVisible",
504
+ ACCOUNT_NUMBER_FULL_OR_PARTIAL: "accountNumberFullOrPartialVisible",
505
+ DATE_ON_DOCUMENT: "datedInTheLastXMonths",
506
+ COUNTRY_OF_BANK: "showsCountryOfBankAccount",
507
+ OFFICIAL_DOCUMENT: "hasToBeOfficialDocumentFromBank",
508
+ STAMP_OR_SIGNATURE: "hasBankStampOrBankSignature",
509
+ HIGH_RESOLUTION_CHECK: "highResolutionCheck"
510
+ };
511
+ const accountNameRequirement = {
512
+ [LegalEntityTypes.INDIVIDUAL]: {
513
+ default: BankDocumentRequirement.ACCOUNT_NAME_INDIVIDUAL
514
+ },
515
+ [LegalEntityTypes.ORGANIZATION]: {
516
+ default: BankDocumentRequirement.ACCOUNT_NAME_ORGANIZATION
517
+ }
518
+ };
519
+ const accountNameRequirementWithLegalArrangement = {
520
+ [LegalEntityTypes.INDIVIDUAL]: {
521
+ [LegalEntityTypes.SOLE_PROPRIETORSHIP]: {
522
+ default: BankDocumentRequirement.ACCOUNT_NAME_WITH_SOLE_PROP
523
+ },
524
+ [LegalEntityTypes.TRUST]: {
525
+ [CountryCodes.UnitedStates]: "bankAccountNameWithTrust_US",
526
+ default: BankDocumentRequirement.ACCOUNT_NAME_WITH_TRUST
527
+ },
528
+ [LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: {
529
+ default: BankDocumentRequirement.ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP
530
+ }
531
+ },
532
+ [LegalEntityTypes.ORGANIZATION]: {
533
+ [LegalEntityTypes.TRUST]: {
534
+ [CountryCodes.UnitedStates]: "bankAccountNameWithTrust_US",
535
+ default: BankDocumentRequirement.ACCOUNT_NAME_WITH_TRUST
536
+ },
537
+ [LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]: {
538
+ default: BankDocumentRequirement.ACCOUNT_NAME_WITH_UNINCORPORATED_PARTNERSHIP
539
+ }
540
+ }
541
+ };
542
+ const applyNamedModifiers = (country, documentModifiers) => {
543
+ if (!documentModifiers.associatedEntityType || !documentModifiers.associatedEntityLegalName) {
544
+ switch (documentModifiers.rootEntityType) {
545
+ case LegalEntityTypes.INDIVIDUAL:
546
+ return {
547
+ key: accountNameRequirement[LegalEntityTypes.INDIVIDUAL].default,
548
+ options: { values: { individualLegalName: documentModifiers.rootEntityLegalName } }
549
+ };
550
+ case LegalEntityTypes.ORGANIZATION:
551
+ default:
552
+ return {
553
+ key: accountNameRequirement[LegalEntityTypes.ORGANIZATION].default,
554
+ options: { values: { companyLegalName: documentModifiers.rootEntityLegalName } }
555
+ };
556
+ }
557
+ }
558
+ switch (documentModifiers.rootEntityType) {
559
+ case LegalEntityTypes.INDIVIDUAL:
560
+ switch (documentModifiers.associatedEntityType) {
561
+ case LegalEntityTypes.TRUST:
562
+ return {
563
+ key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.TRUST]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.TRUST]?.default,
564
+ options: {
565
+ values: {
566
+ trusteeName: documentModifiers.rootEntityLegalName,
567
+ trustLegalName: documentModifiers.associatedEntityLegalName,
568
+ trustTradingName: documentModifiers.associatedEntityTradingName ?? documentModifiers.associatedEntityLegalName
569
+ }
570
+ }
571
+ };
572
+ case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
573
+ return {
574
+ key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.default,
575
+ options: {
576
+ values: {
577
+ partnerNames: documentModifiers.unincorporatedPartnershipMembers || "",
578
+ partnershipName: documentModifiers.associatedEntityLegalName
579
+ }
580
+ }
581
+ };
582
+ case LegalEntityTypes.SOLE_PROPRIETORSHIP:
583
+ default:
584
+ return {
585
+ key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.INDIVIDUAL][LegalEntityTypes.SOLE_PROPRIETORSHIP]?.default,
586
+ options: {
587
+ values: {
588
+ individualLegalName: documentModifiers.rootEntityLegalName,
589
+ soleProprietorshipName: documentModifiers.associatedEntityLegalName
590
+ }
591
+ }
592
+ };
593
+ }
594
+ case LegalEntityTypes.ORGANIZATION:
595
+ default:
596
+ switch (documentModifiers.associatedEntityType) {
597
+ case LegalEntityTypes.TRUST:
598
+ return {
599
+ key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.TRUST]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.TRUST]?.default,
600
+ options: {
601
+ values: {
602
+ trusteeName: documentModifiers.rootEntityLegalName,
603
+ trustLegalName: documentModifiers.associatedEntityLegalName,
604
+ trustTradingName: documentModifiers.associatedEntityTradingName ?? documentModifiers.associatedEntityLegalName
605
+ }
606
+ }
607
+ };
608
+ case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
609
+ return {
610
+ key: accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.[country] ?? accountNameRequirementWithLegalArrangement[LegalEntityTypes.ORGANIZATION][LegalEntityTypes.UNINCORPORATED_PARTNERSHIP]?.default,
611
+ options: {
612
+ values: {
613
+ partnerNames: documentModifiers.unincorporatedPartnershipMembers || "",
614
+ partnershipName: documentModifiers.associatedEntityLegalName
615
+ }
616
+ }
617
+ };
618
+ default:
619
+ return { key: accountNameRequirement[LegalEntityTypes.ORGANIZATION].default };
620
+ }
621
+ }
622
+ };
623
+ const getBankDocumentRequirements = (country, documentType, documentModifiers) => {
624
+ const isBasedInUS = country === "US";
625
+ const baseRequirements = isBasedInUS ? [{ key: BankDocumentRequirement.OFFICIAL_DOCUMENT }] : [
626
+ { key: BankDocumentRequirement.OFFICIAL_DOCUMENT },
627
+ { key: BankDocumentRequirement.COUNTRY_OF_BANK }
628
+ ];
629
+ const accountNumberRequirement = isBasedInUS ? documentType === BankDocumentTypes.CHECK || documentType === BankDocumentTypes.DEPOSIT_SLIP ? [{ key: BankDocumentRequirement.ACCOUNT_NUMBER }] : [{ key: BankDocumentRequirement.ACCOUNT_NUMBER_FULL_OR_PARTIAL }] : [{ key: BankDocumentRequirement.ACCOUNT_NUMBER_OR_IBAN }];
630
+ const requireLast12Months = isBasedInUS ? documentType === BankDocumentTypes.A_LETTER_FROM_YOUR_BANK || documentType === BankDocumentTypes.BANK_STATEMENT : documentType !== BankDocumentTypes.SCREENSHOT_OF_BANK;
631
+ const requireStampOrSignature = !isBasedInUS && (documentType === BankDocumentTypes.DEPOSIT_SLIP || documentType === BankDocumentTypes.A_LETTER_FROM_YOUR_BANK);
632
+ const requirements = [
633
+ applyNamedModifiers(country, documentModifiers),
634
+ ...accountNumberRequirement,
635
+ ...baseRequirements
636
+ ];
637
+ if (requireLast12Months) {
638
+ requirements.push({
639
+ key: BankDocumentRequirement.DATE_ON_DOCUMENT,
640
+ options: { values: { number: 12 } }
641
+ });
642
+ }
643
+ if (requireStampOrSignature) {
644
+ requirements.push({ key: BankDocumentRequirement.STAMP_OR_SIGNATURE });
645
+ }
646
+ if (isBasedInUS && documentType === BankDocumentTypes.CHECK) {
647
+ requirements.push({ key: BankDocumentRequirement.HIGH_RESOLUTION_CHECK });
648
+ }
649
+ return requirements;
650
+ };
651
+ const BankDocumentRequirements = ({
652
+ country,
653
+ documentType,
654
+ documentModifiers
655
+ }) => {
656
+ const { i18n } = useI18nContext();
657
+ const documentRequirements2 = getBankDocumentRequirements(
658
+ country,
659
+ documentType,
660
+ documentModifiers
661
+ );
662
+ return /* @__PURE__ */ jsxs("div", { className: styles$1.documentRequirements, children: [
663
+ /* @__PURE__ */ jsx("strong", { className: styles$1.documentRequirementsSubtitle, children: i18n.get("documentRequirements") }),
664
+ /* @__PURE__ */ jsx("ul", { children: documentRequirements2.map(({ key, options }, i) => /* @__PURE__ */ jsx("li", { "data-testid": key, children: i18n.get(key, options) }, i)) })
665
+ ] });
666
+ };
667
+ const bankDocumentValidationRules = {
668
+ description: {
669
+ modes: ["blur"],
670
+ validate: (description) => description ? bankStatementDescriptionPattern.test(description) : true,
671
+ errorMessage: "invalidFormatBankStatementDescription"
672
+ }
673
+ };
674
+ const CHARACTERS_LIMIT = 200;
675
+ const bankDocumentFields = [
676
+ "documentType",
677
+ "bankStatementDocument",
678
+ "description"
679
+ ];
680
+ function BankDocument(props) {
681
+ const {
682
+ legalEntity,
683
+ associatedLegalArrangement,
684
+ country,
685
+ optionalFields,
686
+ validators,
687
+ data: bankData,
688
+ id,
689
+ description,
690
+ heading,
691
+ formIsActive,
692
+ fieldValidationErrors,
693
+ shouldValidate
694
+ } = props;
695
+ const { t } = useTranslation("common");
696
+ const stateRef = useRef({ setState: null });
697
+ const isBankStatementOptional = optionalFields?.includes("bankStatementDocument") ?? false;
698
+ const formUtils = createFormUtils(props, t);
699
+ const bankStatementValidationOptions = useMemo(
700
+ () => ({
701
+ ...defaultFileValidationOptions,
702
+ isOptional: isBankStatementOptional
703
+ }),
704
+ [isBankStatementOptional]
705
+ );
706
+ const rules2 = useMemo(
707
+ () => ({
708
+ ...validators || bankDocumentValidationRules,
709
+ bankStatementDocument: fileValidationRules(bankStatementValidationOptions)
710
+ }),
711
+ [bankStatementValidationOptions, validators]
712
+ );
713
+ const { handleChangeFor, data, setData, valid, fieldProblems, errors, triggerValidation } = useForm({
714
+ ...props,
715
+ schema: bankDocumentFields,
716
+ defaultData: bankData,
717
+ rules: rules2,
718
+ fieldProblems: fieldValidationErrors,
719
+ shouldValidate
720
+ });
721
+ useEffect(() => {
722
+ if (formIsActive) {
723
+ triggerValidation();
724
+ }
725
+ }, [formIsActive, triggerValidation]);
726
+ const alreadyUploadedDocuments = useMemo(
727
+ () => bankData?.bankStatementDocument ?? [],
728
+ [bankData?.bankStatementDocument]
729
+ );
730
+ const hasAlreadyUploadedDocuments = alreadyUploadedDocuments.length > 0;
731
+ const usingExistingUploadedDocuments = data.bankStatementDocument && doArraysMatch(alreadyUploadedDocuments, data.bankStatementDocument);
732
+ useEffect(() => {
733
+ if (hasAlreadyUploadedDocuments) {
734
+ setData("bankStatementDocument", alreadyUploadedDocuments);
735
+ if (bankData?.description) setData("description", bankData.description);
736
+ triggerValidation();
737
+ }
738
+ }, [
739
+ alreadyUploadedDocuments,
740
+ hasAlreadyUploadedDocuments,
741
+ bankData?.description,
742
+ setData,
743
+ triggerValidation
744
+ ]);
745
+ useEffect(() => {
746
+ stateRef.current?.setState?.({
747
+ type: "addToState",
748
+ value: {
749
+ data,
750
+ valid,
751
+ errors,
752
+ fieldProblems,
753
+ dataStoreId: id,
754
+ schema: bankDocumentFields
755
+ }
756
+ });
757
+ }, [data, valid, errors, fieldProblems, id]);
758
+ const getBankDocumentOptions = () => bankDocumentOptions.map(({ id: id2, name }) => ({ id: id2, name: t(($) => $[name]) }));
759
+ const unincorporatedPartnershipMembers = useUnincorporatedPartnershipMembers();
760
+ const documentsModifiers = useMemo(
761
+ () => ({
762
+ rootEntityType: legalEntity.type,
763
+ rootEntityLegalName: getLegalEntityNameBasedOnType(legalEntity),
764
+ associatedEntityType: associatedLegalArrangement?.type,
765
+ associatedEntityLegalName: associatedLegalArrangement?.[associatedLegalArrangement?.type]?.name,
766
+ associatedEntityTradingName: associatedLegalArrangement?.[associatedLegalArrangement?.type]?.doingBusinessAs,
767
+ unincorporatedPartnershipMembers: unincorporatedPartnershipMembers?.map((member) => member?.name)?.join(", ")
768
+ }),
769
+ [legalEntity, associatedLegalArrangement, unincorporatedPartnershipMembers]
770
+ );
771
+ return /* @__PURE__ */ jsxs("form", { className: styles$2.bankDocument, children: [
772
+ /* @__PURE__ */ jsx(StateContextSetter, { owner: id, stateRef }),
773
+ /* @__PURE__ */ jsx(FormHeader, { heading, description }),
774
+ /* @__PURE__ */ jsx(
775
+ ErrorPanel,
776
+ {
777
+ verificationErrors: props?.formVerificationErrors,
778
+ validationErrors: props?.fieldValidationErrors,
779
+ formUtils,
780
+ id: "ariaErrorField"
781
+ }
782
+ ),
783
+ formUtils.isVisibleField("bankStatementDocument") && /* @__PURE__ */ jsxs(Fragment, { children: [
784
+ !usingExistingUploadedDocuments && /* @__PURE__ */ jsx(
785
+ Field,
786
+ {
787
+ name: "documentType",
788
+ label: formUtils.getLabel("bankStatementDocument", "selectDocumentType"),
789
+ className: "adyen-kyc-bank-document__document-type",
790
+ children: (childProps) => /* @__PURE__ */ jsx(
791
+ Select,
792
+ {
793
+ ...childProps,
794
+ onChange: handleChangeFor("documentType"),
795
+ name: "documentType",
796
+ placeholder: t(($) => $["selectDocument"]),
797
+ isInvalid: false,
798
+ items: getBankDocumentOptions(),
799
+ selected: data.documentType
800
+ }
801
+ )
802
+ }
803
+ ),
804
+ data.documentType ? /* @__PURE__ */ jsxs(Fragment, { children: [
805
+ country ? /* @__PURE__ */ jsx(
806
+ BankDocumentRequirements,
807
+ {
808
+ country,
809
+ documentType: data.documentType,
810
+ documentModifiers: documentsModifiers
811
+ }
812
+ ) : void 0,
813
+ /* @__PURE__ */ jsx(DocumentGuidance, { type: "bankStatement", className: "adyen-kyc-u-margin-y-24" })
814
+ ] }) : null,
815
+ data.documentType || usingExistingUploadedDocuments ? /* @__PURE__ */ jsx(
816
+ Field,
817
+ {
818
+ className: "adyen-kyc-bank-document__document-upload adyen-kyc-upload-field",
819
+ name: "bankStatementDocument",
820
+ isValid: valid.bankStatementDocument,
821
+ children: (childProps) => /* @__PURE__ */ jsx(
822
+ FilePicker,
823
+ {
824
+ ...childProps,
825
+ name: "bankStatementDocument",
826
+ files: data.bankStatementDocument ?? [],
827
+ setFiles: handleChangeFor("bankStatementDocument"),
828
+ isValid: valid.bankStatementDocument ?? isBankStatementOptional,
829
+ errorMessage: errors.bankStatementDocument?.errorMessage,
830
+ ...bankStatementValidationOptions
831
+ }
832
+ )
833
+ }
834
+ ) : null
835
+ ] }),
836
+ data.documentType || usingExistingUploadedDocuments ? /* @__PURE__ */ jsx(
837
+ Field,
838
+ {
839
+ className: "adyen-kyc-bank-document__document-description",
840
+ name: "description",
841
+ label: formUtils.getLabel("bankDocumentFileDescription"),
842
+ errorMessage: formUtils.getErrorMessage("description", errors, fieldProblems),
843
+ isValid: valid.description,
844
+ children: (childProps) => /* @__PURE__ */ jsx(
845
+ TextArea,
846
+ {
847
+ ...childProps,
848
+ name: "description",
849
+ value: data.description,
850
+ maxLength: CHARACTERS_LIMIT,
851
+ onInput: handleChangeFor("description"),
852
+ "aria-invalid": !valid.description
853
+ }
854
+ )
855
+ }
856
+ ) : null
857
+ ] });
858
+ }
859
+ const MemoizedBankDocument = memo(
860
+ BankDocument,
861
+ (prevProps, nextProps) => objectsDeepEqual(prevProps.requiredFields, nextProps.requiredFields) && objectsDeepEqual(prevProps.optionalFields, nextProps.optionalFields) && objectsDeepEqual(prevProps.data, nextProps.data) && objectsDeepEqual(prevProps.formVerificationErrors, nextProps.formVerificationErrors) && objectsDeepEqual(prevProps.fieldValidationErrors, nextProps.fieldValidationErrors) && prevProps.country === nextProps.country && prevProps.shouldValidate === nextProps.shouldValidate && prevProps.heading === nextProps.heading && prevProps.formIsActive === nextProps.formIsActive
862
+ );
863
+ const bankVerificationValidationRules = {
864
+ verifiedAccountHolder: {
865
+ modes: ["blur"],
866
+ validate: (verifiedAccountHolder) => !isEmpty(verifiedAccountHolder),
867
+ errorMessage: "fieldIsRequired"
868
+ },
869
+ verifiedBankCountry: {
870
+ modes: ["blur"],
871
+ validate: (verifiedBankCountry) => !isEmpty(verifiedBankCountry),
872
+ errorMessage: "fieldIsRequired"
873
+ },
874
+ verifiedBankName: {
875
+ modes: ["blur"],
876
+ validate: (verifiedBankName) => !isEmpty(verifiedBankName),
877
+ errorMessage: "fieldIsRequired"
878
+ },
879
+ verifiedCurrencyCode: {
880
+ modes: ["blur"],
881
+ validate: (verifiedCurrencyCode) => !isEmpty(verifiedCurrencyCode),
882
+ errorMessage: "fieldIsRequired"
883
+ },
884
+ verifiedBankAccountNumber: {
885
+ modes: ["blur"],
886
+ validate: (verifiedBankAccountNumber) => !isEmpty(verifiedBankAccountNumber),
887
+ errorMessage: "fieldIsRequired"
888
+ }
889
+ };
890
+ const handleBankVerificationError = async (legalEntityId, baseUrl, bankVerificationErrorParams) => {
891
+ return httpPost(
892
+ {
893
+ baseUrl,
894
+ path: `legalEntities/${legalEntityId}/transferInstruments/trusted/error`
895
+ },
896
+ bankVerificationErrorParams
897
+ );
898
+ };
899
+ const useHandleBankVerificationError = (options) => {
900
+ const { rootLegalEntityId, baseUrl } = useApiContext();
901
+ return useMutation({
902
+ mutationFn: (params) => handleBankVerificationError(rootLegalEntityId.value, baseUrl.value, params),
903
+ ...options
904
+ });
905
+ };
906
+ const addAnimationStartListener = (element, listener) => {
907
+ element.addEventListener("animationstart", listener, false);
908
+ };
909
+ const removeAnimationStartListener = (element, listener) => {
910
+ element.removeEventListener("animationstart", listener, false);
911
+ };
912
+ const VerificationWidgetCallbackActions = {
913
+ HANDLE_EXCEPTION: "handle_exception",
914
+ VERIFICATION_SUCCESS: "verification_success",
915
+ RETRY_VERIFICATION: "retry_verification",
916
+ HANDLE_EVENT: "handle_event"
917
+ };
918
+ const WIDGET_IFRAME_CLASS = "adyen-kyc-bank-verification-widget";
919
+ const WIDGET_CONTAINER_CLASS = `${WIDGET_IFRAME_CLASS}-container`;
920
+ const EMPTY_WIDGET_CONTAINER_ANIMATION = "adyen-kyc-empty-bank-verification-widget-container";
921
+ function BankVerificationWidget({
922
+ url,
923
+ vendor,
924
+ setBankVerificationError,
925
+ setHideVerificationWidget,
926
+ onBack,
927
+ retrieveBankAccountInfo,
928
+ createTrustedTransferInstrument: createTrustedTransferInstrument2,
929
+ fullscreen
930
+ }) {
931
+ const { i18n } = useI18nContext();
932
+ const userEvents = useAnalyticsContext();
933
+ const widgetContainerRef = useRef(null);
934
+ const sdkToken = getSdkToken();
935
+ const { mutateAsync: handleBankVerificationError2 } = useHandleBankVerificationError();
936
+ const trackVerificationError = (returnValue) => {
937
+ userEvents.addPageEvent("Encountered error", {
938
+ actionType: "add",
939
+ returnType: "sdk error",
940
+ returnValue
941
+ });
942
+ };
943
+ const DEFAULT_ERROR = {
944
+ error: "UNKNOWN_ERROR",
945
+ message: i18n.get("weCouldntCompleteTheAccountCheck")
946
+ };
947
+ setBankVerificationError(null);
948
+ const widgetCallback = useCallback(
949
+ (payload) => {
950
+ const errorContent = i18n.get("tryAgainOrManualAccountDetails");
951
+ switch (payload.action) {
952
+ case VerificationWidgetCallbackActions.HANDLE_EXCEPTION: {
953
+ let errorTitle;
954
+ const { err } = payload;
955
+ switch (!(err instanceof Error) && err?.error) {
956
+ case "USER_CANCELLED":
957
+ errorTitle = "";
958
+ break;
959
+ case "CONNECTION_ERROR":
960
+ errorTitle = i18n.get("couldNotEstablishBankConnection");
961
+ break;
962
+ case "GENERIC_ERROR":
963
+ errorTitle = i18n.get("ranIntoTechnicalError");
964
+ break;
965
+ case "UNKNOWN_ERROR":
966
+ default: {
967
+ errorTitle = i18n.get("couldNotCompleteAccountCheck");
968
+ break;
969
+ }
970
+ }
971
+ if (errorTitle) {
972
+ setBankVerificationError({ title: errorTitle, content: errorContent });
973
+ }
974
+ setHideVerificationWidget(true);
975
+ onBack?.();
976
+ break;
977
+ }
978
+ case VerificationWidgetCallbackActions.RETRY_VERIFICATION:
979
+ setBankVerificationError({
980
+ title: i18n.get("failedInitializeInstantVerification"),
981
+ content: errorContent
982
+ });
983
+ setHideVerificationWidget(true);
984
+ onBack?.();
985
+ break;
986
+ case VerificationWidgetCallbackActions.HANDLE_EVENT: {
987
+ const { name, provider } = payload.event;
988
+ if (name === "institution_selected" && provider === "plaid") {
989
+ widgetContainerRef.current?.classList.add(`${WIDGET_CONTAINER_CLASS}--plaid-modal`);
990
+ }
991
+ break;
992
+ }
993
+ case VerificationWidgetCallbackActions.VERIFICATION_SUCCESS: {
994
+ const { accounts } = payload.result;
995
+ if (accounts) retrieveBankAccountInfo(accounts[0]);
996
+ setHideVerificationWidget(true);
997
+ }
998
+ }
999
+ },
1000
+ [i18n, retrieveBankAccountInfo, onBack, setBankVerificationError, setHideVerificationWidget]
1001
+ );
1002
+ useEffect(
1003
+ () => {
1004
+ const container = widgetContainerRef.current;
1005
+ if (!container) {
1006
+ return;
1007
+ }
1008
+ let iFrame;
1009
+ let iFrameWidget;
1010
+ let openBanking;
1011
+ addAnimationStartListener(container, function refreshWidgetIframe(evt) {
1012
+ if (evt.animationName !== EMPTY_WIDGET_CONTAINER_ANIMATION) return;
1013
+ requestAnimationFrame(async () => {
1014
+ if (createTrustedTransferInstrument2) {
1015
+ openBanking = OpenBankingSDK.create({
1016
+ divElement: container,
1017
+ link: url,
1018
+ successHandler: (code, state) => {
1019
+ createTrustedTransferInstrument2(code, state).then((res) => {
1020
+ userEvents.addPageEvent("Success", { actionType: "add" });
1021
+ if (res) {
1022
+ widgetCallback({
1023
+ action: VerificationWidgetCallbackActions.VERIFICATION_SUCCESS,
1024
+ result: res
1025
+ });
1026
+ }
1027
+ }).catch(() => {
1028
+ trackVerificationError(DEFAULT_ERROR.error);
1029
+ widgetCallback({
1030
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1031
+ err: DEFAULT_ERROR
1032
+ });
1033
+ });
1034
+ },
1035
+ errorHandler: (errorCode, errorMessage, state, metadata) => {
1036
+ trackVerificationError(errorCode);
1037
+ handleBankVerificationError2?.({
1038
+ errorCode,
1039
+ errorMessage,
1040
+ state,
1041
+ metadata: metadata && Object.fromEntries(metadata)
1042
+ }).then(
1043
+ (error) => widgetCallback({
1044
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1045
+ err: error
1046
+ })
1047
+ ).catch(
1048
+ () => widgetCallback({
1049
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1050
+ err: DEFAULT_ERROR
1051
+ })
1052
+ );
1053
+ },
1054
+ eventHandler: (eventName, provider) => {
1055
+ widgetCallback({
1056
+ action: VerificationWidgetCallbackActions.HANDLE_EVENT,
1057
+ event: { name: eventName, provider }
1058
+ });
1059
+ }
1060
+ });
1061
+ openBanking.open();
1062
+ } else {
1063
+ removeAnimationStartListener(container, refreshWidgetIframe);
1064
+ iFrame = document.createElement("iframe");
1065
+ iFrame.setAttribute("allowFullscreen", "true");
1066
+ iFrame.classList.add(WIDGET_IFRAME_CLASS);
1067
+ evt.target.appendChild(iFrame);
1068
+ requestAnimationFrame(async () => {
1069
+ try {
1070
+ iFrameWidget = new IFrameWidget(iFrame, url, vendor, sdkToken);
1071
+ const result = await iFrameWidget.mountAndWaitForResponse();
1072
+ widgetCallback({
1073
+ action: VerificationWidgetCallbackActions.VERIFICATION_SUCCESS,
1074
+ result
1075
+ });
1076
+ userEvents.addPageEvent("Success", { actionType: "add" });
1077
+ } catch (err) {
1078
+ if (err instanceof AdyenKycSdkError) {
1079
+ switch (err.message) {
1080
+ case "WIDGET_ACCOUNT_COMMIT_FAILURE":
1081
+ return widgetCallback({
1082
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1083
+ err: err.sourceError
1084
+ });
1085
+ case "WIDGET_LAUNCH_FAILED":
1086
+ case "WIDGET_URL_MALFORMED":
1087
+ case "WIDGET_TIMEOUT":
1088
+ return widgetCallback({
1089
+ action: VerificationWidgetCallbackActions.RETRY_VERIFICATION
1090
+ });
1091
+ default:
1092
+ return widgetCallback({
1093
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1094
+ err: {
1095
+ error: err?.name ?? VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1096
+ message: err.sourceError?.message ?? VerificationWidgetCallbackActions.HANDLE_EXCEPTION
1097
+ }
1098
+ });
1099
+ }
1100
+ }
1101
+ trackVerificationError(err instanceof AdyenKycSdkError ? err.message : "sdk error");
1102
+ return widgetCallback({
1103
+ action: VerificationWidgetCallbackActions.HANDLE_EXCEPTION,
1104
+ err
1105
+ });
1106
+ }
1107
+ });
1108
+ }
1109
+ });
1110
+ });
1111
+ container.classList.add(WIDGET_CONTAINER_CLASS);
1112
+ if (fullscreen) {
1113
+ container.classList.add(`${WIDGET_CONTAINER_CLASS}--fullscreen`);
1114
+ }
1115
+ return () => {
1116
+ iFrameWidget?.unmount();
1117
+ iFrame?.remove();
1118
+ openBanking?.destroy();
1119
+ };
1120
+ },
1121
+ // Effect dependencies have been omitted here, which isn't intended. However, there seems to be
1122
+ // some problematic behaviour in the overall flow with the dependencies present, which requires
1123
+ // further debugging and tracing to resolve (totally out of the scope of this component).
1124
+ // [url, vendor, widgetCallback]
1125
+ []
1126
+ );
1127
+ return /* @__PURE__ */ jsx("div", { ref: widgetContainerRef });
1128
+ }
1129
+ const accountVerificationFields = [
1130
+ "verifiedAccountHolder",
1131
+ "verifiedBankCountry",
1132
+ "verifiedBankName",
1133
+ "verifiedCurrencyCode",
1134
+ "verifiedBankAccountNumber"
1135
+ ];
1136
+ const InstantVerificationErrorContext = createContext(null);
1137
+ const useInstantVerificationErrorNotification = (notificationVisibilityDuration) => {
1138
+ const [errorNotification, setErrorNotification] = useState(null);
1139
+ const dismissNotificationTimeoutRef = useRef();
1140
+ const clearNotificationTimeout = useCallback(() => {
1141
+ if (dismissNotificationTimeoutRef.current) {
1142
+ clearTimeout(dismissNotificationTimeoutRef.current);
1143
+ dismissNotificationTimeoutRef.current = void 0;
1144
+ }
1145
+ }, []);
1146
+ useEffect(() => {
1147
+ clearNotificationTimeout();
1148
+ if (errorNotification && notificationVisibilityDuration > 0) {
1149
+ dismissNotificationTimeoutRef.current = setTimeout(() => {
1150
+ setErrorNotification(null);
1151
+ clearNotificationTimeout();
1152
+ }, notificationVisibilityDuration);
1153
+ }
1154
+ return () => clearNotificationTimeout();
1155
+ }, [errorNotification, clearNotificationTimeout, notificationVisibilityDuration]);
1156
+ return [errorNotification, setErrorNotification];
1157
+ };
1158
+ function BankVerification(props) {
1159
+ const {
1160
+ heading,
1161
+ setBankVerificationError,
1162
+ onBack,
1163
+ hideSidebar,
1164
+ setBankInfoValidated,
1165
+ bankInfoValidated,
1166
+ formIsActive,
1167
+ createTrustedTransferInstrument: createTrustedTransferInstrument2,
1168
+ country,
1169
+ data: propData,
1170
+ provider,
1171
+ id,
1172
+ fieldValidationErrors
1173
+ } = props;
1174
+ const { i18n } = useI18nContext();
1175
+ const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
1176
+ const schema = accountVerificationFields;
1177
+ const stateRef = useRef({ setState: null });
1178
+ const [hideVerificationWidget, setHideVerificationWidget] = useState(false);
1179
+ const { handleChangeFor, data, valid, errors, isValid, triggerValidation, fieldProblems } = useForm({
1180
+ ...props,
1181
+ schema,
1182
+ defaultData: propData,
1183
+ rules: bankVerificationValidationRules,
1184
+ fieldProblems: fieldValidationErrors
1185
+ });
1186
+ const retrieveBankAccountInfo = async ({
1187
+ realLastFour,
1188
+ number,
1189
+ bankName
1190
+ }) => {
1191
+ handleChangeFor("verifiedBankAccountNumber")(realLastFour ? `*******${realLastFour}` : number);
1192
+ handleChangeFor("verifiedBankName")(bankName);
1193
+ handleChangeFor("verifiedBankCountry")(country);
1194
+ handleChangeFor("verifiedAccountHolder")(propData?.verifiedAccountHolder);
1195
+ handleChangeFor("verifiedCurrencyCode")(
1196
+ propData?.verifiedCurrencyCode ?? currencyByCountry[country]?.[0]
1197
+ );
1198
+ setBankInfoValidated?.(true);
1199
+ hideSidebar?.(false);
1200
+ triggerValidation();
1201
+ await invalidateRootLegalEntity();
1202
+ };
1203
+ const handleOnBack = () => {
1204
+ setHideVerificationWidget(false);
1205
+ onBack?.();
1206
+ };
1207
+ useEffect(() => {
1208
+ stateRef.current.setState?.({
1209
+ type: "addToState",
1210
+ value: {
1211
+ data,
1212
+ valid,
1213
+ errors,
1214
+ fieldProblems,
1215
+ dataStoreId: id,
1216
+ schema
1217
+ }
1218
+ });
1219
+ }, [data, valid, errors, isValid]);
1220
+ useEffect(() => {
1221
+ hideSidebar?.(formIsActive && !bankInfoValidated);
1222
+ return () => hideSidebar?.(false);
1223
+ }, [bankInfoValidated, formIsActive]);
1224
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1225
+ /* @__PURE__ */ jsx(StateContextSetter, { owner: id, stateRef }),
1226
+ bankInfoValidated && /* @__PURE__ */ jsxs(Fragment, { children: [
1227
+ /* @__PURE__ */ jsx(FormHeader, { heading }),
1228
+ /* @__PURE__ */ jsx(Alert, { title: i18n.get("youSuccessfullyVerifiedAccount"), variant: "success" })
1229
+ ] }),
1230
+ provider && formIsActive && !bankInfoValidated && /* @__PURE__ */ jsx("div", { className: "adyen-kyc-bank-verification-container", children: /* @__PURE__ */ jsx("form", { className: "adyen-kyc-bank-verification", children: !hideVerificationWidget ? /* @__PURE__ */ jsxs(Fragment, { children: [
1231
+ /* @__PURE__ */ jsx(
1232
+ BankVerificationWidget,
1233
+ {
1234
+ url: provider.redirectUrl,
1235
+ vendor: provider.name,
1236
+ setBankVerificationError,
1237
+ setHideVerificationWidget,
1238
+ onBack: handleOnBack,
1239
+ retrieveBankAccountInfo,
1240
+ createTrustedTransferInstrument: createTrustedTransferInstrument2
1241
+ }
1242
+ ),
1243
+ /* @__PURE__ */ jsx(ActionBar, { onBack: handleOnBack, backButtonLabel: i18n.get("goBack") })
1244
+ ] }) : void 0 }) })
1245
+ ] });
1246
+ }
1247
+ function BankAccountFormat(props) {
1248
+ const { i18n } = useI18nContext();
1249
+ const { bankAccountFormat, handleAccountFormatChange } = props;
1250
+ const bankFormatOptions = [
1251
+ {
1252
+ id: "iban",
1253
+ name: i18n.get("ibanFormat")
1254
+ },
1255
+ {
1256
+ id: "local",
1257
+ name: i18n.get("localFormat")
1258
+ }
1259
+ ];
1260
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Field, { name: "bankAccountFormat", label: i18n.get("bankAccountFormat"), children: (childProps) => /* @__PURE__ */ jsx(
1261
+ Select,
1262
+ {
1263
+ ...childProps,
1264
+ onChange: (e) => handleAccountFormatChange?.(e?.target?.value),
1265
+ name: "bankAccountFormat",
1266
+ placeholder: i18n.get("localFormat"),
1267
+ selected: bankAccountFormat,
1268
+ items: bankFormatOptions
1269
+ }
1270
+ ) }) });
1271
+ }
1272
+ const simpleBankAccountNumberMetadata = (example, length, maxLength) => {
1273
+ if (maxLength) {
1274
+ return {
1275
+ label: "bankAccountNumber",
1276
+ validators: validatePatternOnBlur(new RegExp(`^\\d{${length},${maxLength}}$`)),
1277
+ mask: {
1278
+ mask: makeMask(...numericInputs(length), ...numericInputs(maxLength - length, true))
1279
+ },
1280
+ guidanceText: {
1281
+ key: "enterAMaximumOfNDigitsForExample",
1282
+ values: {
1283
+ maxDigits: `${maxLength}`,
1284
+ example
1285
+ }
1286
+ }
1287
+ };
1288
+ }
1289
+ return {
1290
+ label: "bankAccountNumber",
1291
+ validators: validatePatternOnBlur(new RegExp(`^\\d{${length}}$`)),
1292
+ mask: { mask: makeMask(...numericInputs(length)) },
1293
+ guidanceText: {
1294
+ key: "enterNDigitsForExample",
1295
+ values: {
1296
+ numDigits: `${length}`,
1297
+ example
1298
+ }
1299
+ }
1300
+ };
1301
+ };
1302
+ const defaultFieldMetadata$3 = {
1303
+ label: "bankAccountNumber",
1304
+ validators: isNotEmptyValidator
1305
+ };
1306
+ const defaultFieldConfig$3 = {
1307
+ [CountryCodes.CzechRepublic]: {
1308
+ // Validators & masks pulled from https://docs.adyen.com/api-explorer/legalentity/4/post/transferInstruments#request-bankAccount-accountIdentification-CZLocalAccountIdentification
1309
+ label: "bankAccountNumber",
1310
+ validators: validatePatternOnBlur(/^((\d{2}|\d{6})-)?\d*\d{2}$/),
1311
+ mask: {
1312
+ mask: makeMask(
1313
+ ...numericInputs(2),
1314
+ ...customInputs(1, /-|\d/),
1315
+ ...numericInputs(3),
1316
+ ...customInputs(1, /-|\d/),
1317
+ ...numericInputs(10)
1318
+ )
1319
+ },
1320
+ guidanceText: {
1321
+ key: "enterXToYDigitsWithOrWithoutPrefixForExample",
1322
+ values: {
1323
+ minDigits: "2",
1324
+ maxDigits: "16",
1325
+ firstExample: "19-123457",
1326
+ secondExample: "123457"
1327
+ }
1328
+ }
1329
+ },
1330
+ [CountryCodes.Denmark]: simpleBankAccountNumberMetadata("2621955959", 10),
1331
+ [CountryCodes.Norway]: simpleBankAccountNumberMetadata("86011117947", 11),
1332
+ [CountryCodes.UnitedKingdom]: simpleBankAccountNumberMetadata("10000003", 8),
1333
+ [CountryCodes.Australia]: simpleBankAccountNumberMetadata("0001234", 5, 10),
1334
+ [CountryCodes.Brazil]: simpleBankAccountNumberMetadata("0009795493", 4, 12),
1335
+ [CountryCodes.Canada]: simpleBankAccountNumberMetadata("10220001111", 5, 12),
1336
+ [CountryCodes.HongKong]: {
1337
+ label: "bankAccountNumber",
1338
+ validators: validatePatternOnBlur(new RegExp(`^\\d{${6},${18}}$`)),
1339
+ mask: {
1340
+ mask: makeMask(...numericInputs(6), ...numericInputs(12, true))
1341
+ },
1342
+ guidanceText: {
1343
+ key: "enterAccountNumberWithBranchCodeForExample",
1344
+ values: {
1345
+ minDigits: "9",
1346
+ maxDigits: "15",
1347
+ example: "790000000"
1348
+ }
1349
+ }
1350
+ },
1351
+ [CountryCodes.Hungary]: simpleBankAccountNumberMetadata("117730161111101800000000", 24),
1352
+ [CountryCodes.Singapore]: simpleBankAccountNumberMetadata("0052312891876", 4, 19),
1353
+ [CountryCodes.Sweden]: simpleBankAccountNumberMetadata("123456789", 7, 10),
1354
+ [CountryCodes.UnitedStates]: simpleBankAccountNumberMetadata("10220001111", 3, 17),
1355
+ [CountryCodes.Poland]: {
1356
+ label: "bankAccountNumber",
1357
+ validators: validatePatternOnBlur(/^\d{26}$/),
1358
+ mask: {
1359
+ mask: makeMask(
1360
+ ...numericInputs(2),
1361
+ spacer,
1362
+ ...numericInputs(4),
1363
+ spacer,
1364
+ ...numericInputs(4),
1365
+ spacer,
1366
+ ...numericInputs(4),
1367
+ spacer,
1368
+ ...numericInputs(4),
1369
+ spacer,
1370
+ ...numericInputs(4),
1371
+ spacer,
1372
+ ...numericInputs(4)
1373
+ )
1374
+ },
1375
+ guidanceText: {
1376
+ key: "enterNDigitsForExample",
1377
+ values: {
1378
+ numDigits: "26",
1379
+ example: "98 1090 2402 7474 4662 2173 1624"
1380
+ }
1381
+ }
1382
+ },
1383
+ [CountryCodes.NewZealand]: {
1384
+ label: "bankAccountNumber",
1385
+ validators: validatePatternOnBlur(/^\d{15,16}$/),
1386
+ mask: {
1387
+ mask: makeMask(
1388
+ ...numericInputs(2),
1389
+ ...nonInputs(" - "),
1390
+ ...numericInputs(4),
1391
+ ...nonInputs(" - "),
1392
+ ...numericInputs(7),
1393
+ ...nonInputs(" - "),
1394
+ ...numericInputs(2),
1395
+ ...numericInputs(1, true)
1396
+ )
1397
+ },
1398
+ guidanceText: {
1399
+ key: "enterXToYDigitsForExample",
1400
+ values: {
1401
+ minDigits: "15",
1402
+ maxDigits: "16",
1403
+ example: "12-8765-9876543-043"
1404
+ }
1405
+ }
1406
+ }
1407
+ };
1408
+ const bankAccountNumberFields = ["bankAccountNumber"];
1409
+ function BankAccountNumber(props) {
1410
+ const { t } = useTranslation("common");
1411
+ const { country, fieldConfig = defaultFieldConfig$3, onFocus, onBlur } = props;
1412
+ const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$3);
1413
+ const mergedProps = mergeFieldMetadataIntoProps("bankAccountNumber", metadata, props);
1414
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
1415
+ ...mergedProps,
1416
+ schema: bankAccountNumberFields,
1417
+ rules: mergedProps.validators,
1418
+ defaultData: mergedProps.data,
1419
+ fieldProblems: mergedProps?.fieldValidationErrors,
1420
+ obscuredFields: mergedProps.obscuredFields
1421
+ });
1422
+ const handleBlur = () => {
1423
+ onBlur?.();
1424
+ handleChangeFor("bankAccountNumber", "blur");
1425
+ };
1426
+ const { updateStateSlice } = useGlobalDataSlice(
1427
+ "payoutAccountDetails"
1428
+ );
1429
+ useEffect(() => {
1430
+ updateStateSlice({ data, valid, errors, fieldProblems });
1431
+ }, [data, valid, errors]);
1432
+ const formUtils = createFormUtils(mergedProps, t);
1433
+ return /* @__PURE__ */ jsx(
1434
+ MaskedInput,
1435
+ {
1436
+ name: "bankAccountNumber",
1437
+ type: "text",
1438
+ label: formUtils.getLabel("bankAccountNumber"),
1439
+ formatGuidance: formUtils.getGuidanceText("bankAccountNumber"),
1440
+ ...formUtils.getMask("bankAccountNumber"),
1441
+ isValid: valid.bankAccountNumber,
1442
+ errorMessage: formUtils.getErrorMessage("bankAccountNumber", errors, fieldProblems),
1443
+ "aria-required": true,
1444
+ "aria-invalid": !valid.bankAccountNumber,
1445
+ onBlur: handleBlur,
1446
+ onInput: handleChangeFor("bankAccountNumber", "input"),
1447
+ onFocus,
1448
+ readonly: formUtils.isReadOnly("bankAccountNumber"),
1449
+ value: data.bankAccountNumber ?? "",
1450
+ acceptObscuredValue: formUtils.isObscured("bankAccountNumber")
1451
+ }
1452
+ );
1453
+ }
1454
+ const bankCityFields = ["bankCity"];
1455
+ function BankCity(props) {
1456
+ const { t } = useTranslation("common");
1457
+ const { validators, data: bankCityData, fieldValidationErrors } = props;
1458
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
1459
+ ...props,
1460
+ schema: bankCityFields,
1461
+ rules: validators,
1462
+ defaultData: bankCityData,
1463
+ fieldProblems: fieldValidationErrors
1464
+ });
1465
+ const { updateStateSlice } = useGlobalDataSlice(
1466
+ "payoutAccountDetails"
1467
+ );
1468
+ useEffect(() => {
1469
+ updateStateSlice({ data, valid, errors, fieldProblems });
1470
+ }, [data, valid, errors]);
1471
+ const formUtils = createFormUtils(props, t);
1472
+ return /* @__PURE__ */ jsx(
1473
+ Field,
1474
+ {
1475
+ name: "bankCity",
1476
+ label: formUtils.getLabel("bankCity"),
1477
+ errorMessage: formUtils.getErrorMessage("bankCity", errors, fieldProblems),
1478
+ isValid: valid.bankCity,
1479
+ children: (childProps) => /* @__PURE__ */ jsx(
1480
+ InputText,
1481
+ {
1482
+ ...childProps,
1483
+ name: "bankCity",
1484
+ value: data.bankCity,
1485
+ readonly: formUtils.isReadOnly("bankCity"),
1486
+ onInput: handleChangeFor("bankCity", "input"),
1487
+ onBlur: handleChangeFor("bankCity", "blur"),
1488
+ "aria-required": true,
1489
+ "aria-invalid": !valid.bankCity
1490
+ }
1491
+ )
1492
+ }
1493
+ );
1494
+ }
1495
+ const defaultFieldMetadata$2 = {
1496
+ label: "bankCode",
1497
+ validators: isNotEmptyValidator
1498
+ };
1499
+ const simpleBankCodeMetadata = (length, example, label) => ({
1500
+ label: label ?? "bankCode",
1501
+ validators: validatePatternOnBlur(new RegExp(`^\\d{${length}}$`)),
1502
+ mask: {
1503
+ mask: makeMask(...numericInputs(length))
1504
+ },
1505
+ guidanceText: {
1506
+ key: "enterNDigitsForExample",
1507
+ values: {
1508
+ numDigits: `${length}`,
1509
+ example
1510
+ }
1511
+ }
1512
+ });
1513
+ const defaultFieldConfig$2 = {
1514
+ [CountryCodes.Brazil]: simpleBankCodeMetadata(3, "123"),
1515
+ [CountryCodes.Canada]: simpleBankCodeMetadata(3, "100", "institutionNumber"),
1516
+ [CountryCodes.CzechRepublic]: simpleBankCodeMetadata(4, "0800"),
1517
+ [CountryCodes.Denmark]: simpleBankCodeMetadata(4, "5051"),
1518
+ [CountryCodes.HongKong]: simpleBankCodeMetadata(3, "250", "bankCode"),
1519
+ [CountryCodes.Norway]: simpleBankCodeMetadata(4, "8601"),
1520
+ // Not yet implemented
1521
+ [CountryCodes.Ecuador]: simpleBankCodeMetadata(4, "1234"),
1522
+ [CountryCodes.Japan]: simpleBankCodeMetadata(4, "1234"),
1523
+ [CountryCodes.Taiwan]: simpleBankCodeMetadata(3, "123")
1524
+ };
1525
+ const bankCodeFields = ["bankCode"];
1526
+ function BankCode(props) {
1527
+ const { t } = useTranslation("common");
1528
+ const { country, fieldConfig = defaultFieldConfig$2 } = props;
1529
+ const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$2);
1530
+ const mergedProps = mergeFieldMetadataIntoProps("bankCode", metadata, props);
1531
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
1532
+ ...mergedProps,
1533
+ schema: bankCodeFields,
1534
+ rules: mergedProps.validators,
1535
+ defaultData: mergedProps.data,
1536
+ fieldProblems: mergedProps.fieldValidationErrors
1537
+ });
1538
+ const { updateStateSlice } = useGlobalDataSlice(
1539
+ "payoutAccountDetails"
1540
+ );
1541
+ useEffect(() => {
1542
+ updateStateSlice({ data, valid, errors, fieldProblems });
1543
+ }, [data, valid, errors]);
1544
+ const formUtils = createFormUtils(mergedProps, t);
1545
+ return /* @__PURE__ */ jsx(
1546
+ MaskedInput,
1547
+ {
1548
+ name: "bankCode",
1549
+ type: "text",
1550
+ label: formUtils.getLabel("bankCode"),
1551
+ errorMessage: formUtils.getErrorMessage("bankCode", errors, fieldProblems),
1552
+ formatGuidance: formUtils.getGuidanceText("bankCode"),
1553
+ ...formUtils.getMask("bankCode"),
1554
+ isValid: valid.bankCode,
1555
+ value: data.bankCode ?? "",
1556
+ readonly: formUtils.isReadOnly("bankCode"),
1557
+ onInput: handleChangeFor("bankCode", "input"),
1558
+ onBlur: handleChangeFor("bankCode", "blur"),
1559
+ "aria-required": true,
1560
+ "aria-invalid": !valid.bankCode
1561
+ }
1562
+ );
1563
+ }
1564
+ const bankNameFields = ["bankName"];
1565
+ function BankName(props) {
1566
+ const { t } = useTranslation("common");
1567
+ const { validators, data: bankNameData, fieldValidationErrors } = props;
1568
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
1569
+ ...props,
1570
+ schema: bankNameFields,
1571
+ rules: validators,
1572
+ defaultData: bankNameData,
1573
+ fieldProblems: fieldValidationErrors
1574
+ });
1575
+ const { updateStateSlice } = useGlobalDataSlice(
1576
+ "payoutAccountDetails"
1577
+ );
1578
+ useEffect(() => {
1579
+ updateStateSlice({ data, valid, errors, fieldProblems });
1580
+ }, [data, valid, errors]);
1581
+ const formUtils = createFormUtils(props, t);
1582
+ return /* @__PURE__ */ jsx(
1583
+ Field,
1584
+ {
1585
+ name: "bankName",
1586
+ label: formUtils.getLabel("bankName"),
1587
+ errorMessage: formUtils.getErrorMessage("bankName", errors, fieldProblems),
1588
+ isValid: valid.bankName,
1589
+ children: (childProps) => /* @__PURE__ */ jsx(
1590
+ InputText,
1591
+ {
1592
+ ...childProps,
1593
+ name: "bankName",
1594
+ value: data.bankName,
1595
+ readonly: formUtils.isReadOnly("bankName"),
1596
+ onInput: handleChangeFor("bankName", "input"),
1597
+ onBlur: handleChangeFor("bankName", "blur"),
1598
+ "aria-required": true,
1599
+ "aria-invalid": !valid.bankName
1600
+ }
1601
+ )
1602
+ }
1603
+ );
1604
+ }
1605
+ const defaultFieldMetadata$1 = {
1606
+ label: "branchCode",
1607
+ validators: isNotEmptyValidator
1608
+ };
1609
+ const defaultFieldConfig$1 = {
1610
+ [CountryCodes.UnitedKingdom]: {
1611
+ label: "sortCode",
1612
+ validators: validatePatternOnBlur(/^\d{6}$/),
1613
+ mask: { mask: makeMask(...numericInputs(6)) },
1614
+ guidanceText: {
1615
+ key: "enterNDigitsForExample",
1616
+ values: {
1617
+ numDigits: "6",
1618
+ example: "401199"
1619
+ }
1620
+ }
1621
+ },
1622
+ [CountryCodes.Australia]: {
1623
+ label: "bsbNumber",
1624
+ validators: validatePatternOnBlur(/^\d{6}$/),
1625
+ mask: { mask: makeMask(...numericInputs(3), ...nonInputs(" - "), ...numericInputs(3)) },
1626
+ guidanceText: {
1627
+ key: "enterNDigitsForExample",
1628
+ values: {
1629
+ numDigits: "6",
1630
+ example: "033-547"
1631
+ }
1632
+ }
1633
+ },
1634
+ [CountryCodes.Brazil]: {
1635
+ label: "branchCode",
1636
+ validators: validatePatternOnBlur(/^\d{1,5}$/),
1637
+ mask: { mask: makeMask(...numericInputs(1), ...numericInputs(4, true)) },
1638
+ guidanceText: {
1639
+ key: "enterAMaximumOfNDigitsForExample",
1640
+ values: {
1641
+ maxDigits: "5",
1642
+ example: "36257"
1643
+ }
1644
+ }
1645
+ },
1646
+ [CountryCodes.Canada]: {
1647
+ label: "transitNumber",
1648
+ validators: validatePatternOnBlur(/^\d{5}$/),
1649
+ mask: { mask: makeMask(...numericInputs(5)) },
1650
+ guidanceText: {
1651
+ key: "enterNDigitsForExample",
1652
+ values: {
1653
+ numDigits: "5",
1654
+ example: "27601"
1655
+ }
1656
+ }
1657
+ },
1658
+ [CountryCodes.UnitedStates]: {
1659
+ label: "routingNumber",
1660
+ validators: validatePatternOnBlur(/^\d{9}$/),
1661
+ mask: { mask: makeMask(...numericInputs(9)) },
1662
+ guidanceText: {
1663
+ key: "enterNDigitsForExample",
1664
+ values: {
1665
+ numDigits: "9",
1666
+ example: "107005432"
1667
+ }
1668
+ }
1669
+ },
1670
+ [CountryCodes.Sweden]: {
1671
+ label: "branchCode",
1672
+ validators: validatePatternOnBlur(/^\d{4,5}$/),
1673
+ mask: {
1674
+ mask: makeMask(
1675
+ ...numericInputs(4),
1676
+ ...nonInputs(" - ", { displayEagerly: false }),
1677
+ ...numericInputs(1, true)
1678
+ )
1679
+ },
1680
+ guidanceText: {
1681
+ key: "enterXToYDigitsForExample",
1682
+ values: {
1683
+ minDigits: "4",
1684
+ maxDigits: "5",
1685
+ example: "5678 or 7635-2"
1686
+ }
1687
+ }
1688
+ },
1689
+ // Not yet implemented
1690
+ [CountryCodes.Indonesia]: {
1691
+ label: "clearingCode",
1692
+ validators: isNotEmptyValidator
1693
+ }
1694
+ };
1695
+ const branchCodeFields = ["branchCode"];
1696
+ function BranchCode(props) {
1697
+ const { t } = useTranslation("common");
1698
+ const { country, fieldConfig = defaultFieldConfig$1, onFocus, onBlur } = props;
1699
+ const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata$1);
1700
+ const mergedProps = mergeFieldMetadataIntoProps("branchCode", metadata, props);
1701
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
1702
+ ...mergedProps,
1703
+ schema: branchCodeFields,
1704
+ rules: mergedProps.validators,
1705
+ defaultData: mergedProps.data,
1706
+ fieldProblems: mergedProps?.fieldValidationErrors
1707
+ });
1708
+ const { updateStateSlice } = useGlobalDataSlice(
1709
+ "payoutAccountDetails"
1710
+ );
1711
+ const handleBlur = () => {
1712
+ onBlur?.();
1713
+ handleChangeFor("branchCode", "blur");
1714
+ };
1715
+ useEffect(() => {
1716
+ updateStateSlice({ data, valid, errors, fieldProblems });
1717
+ }, [data, valid, errors]);
1718
+ const formUtils = createFormUtils(mergedProps, t);
1719
+ return /* @__PURE__ */ jsx(
1720
+ MaskedInput,
1721
+ {
1722
+ name: "branchCode",
1723
+ type: "text",
1724
+ label: formUtils.getLabel("branchCode"),
1725
+ formatGuidance: formUtils.getGuidanceText("branchCode"),
1726
+ ...formUtils.getMask("branchCode"),
1727
+ errorMessage: formUtils.getErrorMessage("branchCode", errors, fieldProblems),
1728
+ isValid: valid.branchCode,
1729
+ value: data.branchCode ?? "",
1730
+ readonly: formUtils.isReadOnly("branchCode"),
1731
+ onInput: handleChangeFor("branchCode", "input"),
1732
+ onBlur: handleBlur,
1733
+ onFocus,
1734
+ "aria-required": true,
1735
+ "aria-invalid": !valid.branchCode
1736
+ }
1737
+ );
1738
+ }
1739
+ const bbanPatternsByCountry = {
1740
+ [CountryCodes.Albania]: /\d{8}[\dA-Z]{16}/,
1741
+ [CountryCodes.Andorra]: /\d{8}[\dA-Z]{12}/,
1742
+ [CountryCodes.Austria]: /\d{16}/,
1743
+ [CountryCodes.Azerbaijan]: /[\dA-Z]{4}\d{20}/,
1744
+ [CountryCodes.Belgium]: /\d{12}/,
1745
+ [CountryCodes.Bahrain]: /[A-Z]{4}[\dA-Z]{14}/,
1746
+ [CountryCodes.BosniaAndHerzegovina]: /\d{16}/,
1747
+ [CountryCodes.Brazil]: /\d{23}[A-Z][\dA-Z]/,
1748
+ [CountryCodes.Bulgaria]: /[A-Z]{4}\d{6}[\dA-Z]{8}/,
1749
+ [CountryCodes.CostaRica]: /\d{17}/,
1750
+ [CountryCodes.Croatia]: /\d{17}/,
1751
+ [CountryCodes.Cyprus]: /\d{8}[\dA-Z]{16}/,
1752
+ [CountryCodes.CzechRepublic]: /\d{20}/,
1753
+ [CountryCodes.Denmark]: /\d{14}/,
1754
+ [CountryCodes.DominicanRepublic]: /[A-Z]{4}\d{20}/,
1755
+ [CountryCodes.Estonia]: /\d{16}/,
1756
+ [CountryCodes.FaroeIslands]: /\d{14}/,
1757
+ [CountryCodes.Finland]: /\d{14}/,
1758
+ [CountryCodes.France]: /\d{10}[\dA-Z]{11}\d{2}/,
1759
+ [CountryCodes.Georgia]: /[\dA-Z]{2}\d{16}/,
1760
+ [CountryCodes.Germany]: /\d{18}/,
1761
+ [CountryCodes.Gibraltar]: /[A-Z]{4}[\dA-Z]{15}/,
1762
+ [CountryCodes.Greece]: /\d{7}[\dA-Z]{16}/,
1763
+ [CountryCodes.Greenland]: /\d{14}/,
1764
+ [CountryCodes.Guatemala]: /[\dA-Z]{4}[\dA-Z]{20}/,
1765
+ [CountryCodes.Hungary]: /\d{24}/,
1766
+ [CountryCodes.Iceland]: /\d{22}/,
1767
+ [CountryCodes.Ireland]: /[\dA-Z]{4}\d{14}/,
1768
+ [CountryCodes.Israel]: /\d{19}/,
1769
+ [CountryCodes.Italy]: /[A-Z]\d{10}[\dA-Z]{12}/,
1770
+ [CountryCodes.Kazakhstan]: /\d{3}[\dA-Z]{13}/,
1771
+ [CountryCodes.Kuwait]: /[A-Z]{4}[\dA-Z]{22}/,
1772
+ [CountryCodes.Latvia]: /[A-Z]{4}[\dA-Z]{13}/,
1773
+ [CountryCodes.Lebanon]: /\d{4}[\dA-Z]{20}/,
1774
+ [CountryCodes.Liechtenstein]: /\d{5}[\dA-Z]{12}/,
1775
+ [CountryCodes.Lithuania]: /\d{16}/,
1776
+ [CountryCodes.Luxembourg]: /\d{3}[\dA-Z]{13}/,
1777
+ [CountryCodes.Macedonia]: /\d{3}[\dA-Z]{10}\d{2}/,
1778
+ [CountryCodes.Malta]: /[A-Z]{4}\d{5}[\dA-Z]{18}/,
1779
+ [CountryCodes.Mauritania]: /\d{23}/,
1780
+ [CountryCodes.Mauritius]: /[A-Z]{4}\d{19}[A-Z]{3}/,
1781
+ [CountryCodes.Monaco]: /\d{10}[\dA-Z]{11}\d{2}/,
1782
+ [CountryCodes.Moldova]: /[\dA-Z]{2}\d{18}/,
1783
+ [CountryCodes.Montenegro]: /\d{18}/,
1784
+ [CountryCodes.Netherlands]: /[A-Z]{4}\d{10}/,
1785
+ [CountryCodes.Norway]: /\d{11}/,
1786
+ [CountryCodes.Pakistan]: /[\dA-Z]{4}\d{16}/,
1787
+ [CountryCodes.PalestinianTerritory]: /[\dA-Z]{4}\d{21}/,
1788
+ [CountryCodes.Poland]: /\d{24}/,
1789
+ [CountryCodes.Portugal]: /\d{21}/,
1790
+ [CountryCodes.Romania]: /[A-Z]{4}[\dA-Z]{16}/,
1791
+ [CountryCodes.SanMarino]: /[A-Z]\d{10}[\dA-Z]{12}/,
1792
+ [CountryCodes.SaudiArabia]: /\d{2}[\dA-Z]{18}/,
1793
+ [CountryCodes.Serbia]: /\d{18}/,
1794
+ [CountryCodes.Slovakia]: /\d{20}/,
1795
+ [CountryCodes.Slovenia]: /\d{15}/,
1796
+ [CountryCodes.Spain]: /\d{20}/,
1797
+ [CountryCodes.Sweden]: /\d{20}/,
1798
+ [CountryCodes.Switzerland]: /\d{5}[\dA-Z]{12}/,
1799
+ [CountryCodes.Tunisia]: /\d{20}/,
1800
+ [CountryCodes.Turkey]: /\d{5}[\dA-Z]{17}/,
1801
+ [CountryCodes.UnitedArabEmirates]: /\d{3}\d{16}/,
1802
+ [CountryCodes.UnitedKingdom]: /[A-Z]{4}\d{14}/,
1803
+ [CountryCodes.VirginIslandsBritish]: /[\dA-Z]{4}\d{16}/
1804
+ };
1805
+ const customPrefixByCountry = {
1806
+ [CountryCodes.Guernsey]: "GB",
1807
+ [CountryCodes.Jersey]: "GB",
1808
+ [CountryCodes.IsleOfMan]: "GB"
1809
+ };
1810
+ function ibanValidator(input, bankCountry) {
1811
+ if (isEmpty(input)) return false;
1812
+ const ibanInput = input.replace(/ /g, "").toUpperCase();
1813
+ if (!/^([a-zA-Z0-9]{4} ){2,8}[a-zA-Z0-9]{1,4}|[a-zA-Z0-9]{12,34}$/.test(ibanInput)) {
1814
+ return false;
1815
+ }
1816
+ const countryCode = ibanInput.substring(0, 2);
1817
+ const allowedPrefix = customPrefixByCountry[bankCountry] ?? bankCountry;
1818
+ if (countryCode !== allowedPrefix) {
1819
+ return {
1820
+ key: "yourIbanShouldBeginWith_",
1821
+ values: {
1822
+ countryCode: allowedPrefix
1823
+ }
1824
+ };
1825
+ }
1826
+ const bbanPattern = bbanPatternsByCountry[countryCode];
1827
+ if (bbanPattern) {
1828
+ const ibanPattern = new RegExp(`^[A-Z]{2}\\d{2}${bbanPattern.source}$`, "");
1829
+ if (!ibanPattern.test(ibanInput)) {
1830
+ return false;
1831
+ }
1832
+ }
1833
+ const ibanCheck = ibanInput.substring(4, ibanInput.length) + ibanInput.substring(0, 4);
1834
+ let leadingZeroes = true;
1835
+ let ibanCheckDigits = "";
1836
+ for (let i = 0; i < ibanCheck.length; i += 1) {
1837
+ const charAt = ibanCheck.charAt(i);
1838
+ if (charAt !== "0") {
1839
+ leadingZeroes = false;
1840
+ }
1841
+ if (!leadingZeroes) {
1842
+ ibanCheckDigits += "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(charAt);
1843
+ }
1844
+ }
1845
+ let cRest = 0;
1846
+ for (let p = 0; p < ibanCheckDigits.length; p += 1) {
1847
+ const cChar = ibanCheckDigits.charAt(p);
1848
+ const cOperator = +`${cRest}${cChar}`;
1849
+ cRest = cOperator % 97;
1850
+ }
1851
+ return cRest === 1;
1852
+ }
1853
+ const validateIbanOnBlurAndInput = (country) => ({
1854
+ modes: ["blur", "input"],
1855
+ validate: (iban) => ibanValidator(iban, country) === true,
1856
+ errorMessage: (iban) => {
1857
+ const result = ibanValidator(iban, country);
1858
+ return typeof result === "boolean" ? void 0 : result;
1859
+ }
1860
+ });
1861
+ const ibanMask = (country, inputLength, allowLettersInBban) => {
1862
+ const tokens = [];
1863
+ tokens.push(...nonInputs(country, { includeInValue: true }), ...numericInputs(2));
1864
+ inputLength -= 2;
1865
+ const inputToken = allowLettersInBban ? alphanumericInputs : numericInputs;
1866
+ const numGroups = Math.floor(inputLength / 4);
1867
+ const remainder = inputLength % 4;
1868
+ for (let i = 0; i < numGroups; i += 1) {
1869
+ tokens.push(spacer, ...inputToken(4));
1870
+ }
1871
+ if (remainder > 0) {
1872
+ tokens.push(spacer, ...inputToken(remainder));
1873
+ }
1874
+ return {
1875
+ mask: makeMask(...tokens),
1876
+ transformOnType: allowLettersInBban ? uppercase : void 0
1877
+ };
1878
+ };
1879
+ const ibanGuidance = (type, numDigitsOrChars, example) => type === "digits" ? {
1880
+ key: "enterTheRemainingNDigitsForExample",
1881
+ values: {
1882
+ numDigits: `${numDigitsOrChars}`,
1883
+ example
1884
+ }
1885
+ } : {
1886
+ key: "enterTheRemainingNCharactersForExample",
1887
+ values: {
1888
+ numChars: `${numDigitsOrChars}`,
1889
+ example
1890
+ }
1891
+ };
1892
+ const ibanMetadata = (country, inputLength, example, allowLettersInBban) => ({
1893
+ label: "iban",
1894
+ validators: validateIbanOnBlurAndInput(country),
1895
+ mask: ibanMask(country, inputLength, allowLettersInBban),
1896
+ guidanceText: ibanGuidance(allowLettersInBban ? "characters" : "digits", inputLength, example)
1897
+ });
1898
+ const gbIbanMetadata = ibanMetadata(
1899
+ CountryCodes.UnitedKingdom,
1900
+ 20,
1901
+ "GB09 BARC 2003 9554 8297 59",
1902
+ true
1903
+ );
1904
+ const defaultFieldMetadata = {
1905
+ label: "iban",
1906
+ validators: isNotEmptyValidator
1907
+ };
1908
+ const defaultFieldConfig = {
1909
+ [CountryCodes.Austria]: ibanMetadata(CountryCodes.Austria, 18, "AT88 5400 0746 7265 9747"),
1910
+ [CountryCodes.Belgium]: ibanMetadata(CountryCodes.Belgium, 14, "BE59 9788 6743 2226"),
1911
+ [CountryCodes.Croatia]: ibanMetadata(CountryCodes.Croatia, 19, "HR51 2484 0083 5929 6973 8"),
1912
+ [CountryCodes.Cyprus]: ibanMetadata(
1913
+ CountryCodes.Cyprus,
1914
+ 26,
1915
+ "CY16 5183 1221 8756 5858 5388 7678"
1916
+ ),
1917
+ [CountryCodes.CzechRepublic]: ibanMetadata(
1918
+ CountryCodes.CzechRepublic,
1919
+ 22,
1920
+ "CZ23 5051 3674 5924 5233 3465"
1921
+ ),
1922
+ [CountryCodes.Denmark]: ibanMetadata(CountryCodes.Denmark, 16, "DK95 2000 0123 4567 89"),
1923
+ [CountryCodes.Estonia]: ibanMetadata(CountryCodes.Estonia, 18, "EE26 1291 5123 1542 6371"),
1924
+ [CountryCodes.Finland]: ibanMetadata(CountryCodes.Finland, 16, "FI03 9319 8995 3742 51"),
1925
+ [CountryCodes.Germany]: ibanMetadata(CountryCodes.Germany, 20, "DE91 1000 0000 0123 4567 89"),
1926
+ [CountryCodes.Greece]: ibanMetadata(CountryCodes.Greece, 25, "GR57 0107 7142 7681 6687 9575 217"),
1927
+ [CountryCodes.Hungary]: ibanMetadata(
1928
+ CountryCodes.Hungary,
1929
+ 26,
1930
+ "HU68 1070 0024 3428 4128 3192 4812"
1931
+ ),
1932
+ [CountryCodes.Lithuania]: ibanMetadata(CountryCodes.Lithuania, 18, "LT59 9244 6228 2176 2762"),
1933
+ [CountryCodes.Luxembourg]: ibanMetadata(CountryCodes.Luxembourg, 18, "LU71 0106 9242 5365 8562"),
1934
+ [CountryCodes.Norway]: ibanMetadata(CountryCodes.Norway, 13, "NO83 3000 1234 567"),
1935
+ [CountryCodes.Poland]: ibanMetadata(
1936
+ CountryCodes.Poland,
1937
+ 26,
1938
+ "PL98 1090 2402 7474 4662 2173 1624"
1939
+ ),
1940
+ [CountryCodes.Portugal]: ibanMetadata(
1941
+ CountryCodes.Portugal,
1942
+ 23,
1943
+ "PT42 0035 0651 8646 9119 5263 5"
1944
+ ),
1945
+ [CountryCodes.Slovakia]: ibanMetadata(CountryCodes.Slovakia, 22, "SK25 5173 1333 4916 3219 3521"),
1946
+ [CountryCodes.Slovenia]: ibanMetadata(CountryCodes.Slovenia, 17, "SI56 1920 0123 4567 892"),
1947
+ [CountryCodes.Spain]: ibanMetadata(CountryCodes.Spain, 22, "ES76 1465 5599 9226 7623 2635"),
1948
+ [CountryCodes.Sweden]: ibanMetadata(CountryCodes.Sweden, 22, "SE72 8000 0810 3400 0978 3242"),
1949
+ // These include letters in the BBAN (bank account number)
1950
+ [CountryCodes.Bulgaria]: ibanMetadata(
1951
+ CountryCodes.Bulgaria,
1952
+ 20,
1953
+ "BG17 BNPA 9440 4432 7749 93",
1954
+ true
1955
+ ),
1956
+ [CountryCodes.France]: ibanMetadata(
1957
+ CountryCodes.France,
1958
+ 25,
1959
+ "FR64 1009 6000 4035 3425 9742 Y90",
1960
+ true
1961
+ ),
1962
+ [CountryCodes.Gibraltar]: ibanMetadata(
1963
+ CountryCodes.Gibraltar,
1964
+ 21,
1965
+ "GI96 JYJT 9899 9587 8655 898",
1966
+ true
1967
+ ),
1968
+ [CountryCodes.Ireland]: ibanMetadata(
1969
+ CountryCodes.Ireland,
1970
+ 20,
1971
+ "IE64 IRCE 9205 0112 3456 78",
1972
+ true
1973
+ ),
1974
+ [CountryCodes.Italy]: ibanMetadata(
1975
+ CountryCodes.Italy,
1976
+ 25,
1977
+ "IT06 L030 0203 2809 8485 8934 882",
1978
+ true
1979
+ ),
1980
+ [CountryCodes.Latvia]: ibanMetadata(CountryCodes.Latvia, 19, "LV80 BANK 0000 4351 9500 1", true),
1981
+ [CountryCodes.Liechtenstein]: ibanMetadata(
1982
+ CountryCodes.Liechtenstein,
1983
+ 19,
1984
+ "LI21 0881 0000 2324 013A A",
1985
+ true
1986
+ ),
1987
+ [CountryCodes.Malta]: ibanMetadata(
1988
+ CountryCodes.Malta,
1989
+ 29,
1990
+ "MT03 VIXW 2487 8926 8575 8586 8929 858",
1991
+ true
1992
+ ),
1993
+ [CountryCodes.Monaco]: ibanMetadata(
1994
+ CountryCodes.Monaco,
1995
+ 25,
1996
+ "MC58 1122 2000 0101 2345 6789 030",
1997
+ true
1998
+ ),
1999
+ [CountryCodes.Netherlands]: ibanMetadata(
2000
+ CountryCodes.Netherlands,
2001
+ 16,
2002
+ "NL50 ABNA 4452 7591 49",
2003
+ true
2004
+ ),
2005
+ [CountryCodes.Romania]: ibanMetadata(
2006
+ CountryCodes.Romania,
2007
+ 22,
2008
+ "RO36 PORL 9596 9966 4965 4284",
2009
+ true
2010
+ ),
2011
+ [CountryCodes.Switzerland]: ibanMetadata(
2012
+ CountryCodes.Switzerland,
2013
+ 19,
2014
+ "CH56 0483 5012 3456 7800 9",
2015
+ true
2016
+ ),
2017
+ [CountryCodes.UnitedKingdom]: gbIbanMetadata,
2018
+ // IBANs for Guernsey, Jersey, and Isle of Man also use United Kingdom's format (starting with `GB`)
2019
+ [CountryCodes.Guernsey]: gbIbanMetadata,
2020
+ [CountryCodes.Jersey]: gbIbanMetadata,
2021
+ [CountryCodes.IsleOfMan]: gbIbanMetadata
2022
+ };
2023
+ const ibanFields = ["iban"];
2024
+ function Iban(props) {
2025
+ const { t } = useTranslation("common");
2026
+ const {
2027
+ country,
2028
+ fieldConfig = defaultFieldConfig,
2029
+ data: ibanData,
2030
+ obscuredFields,
2031
+ fieldValidationErrors
2032
+ } = props;
2033
+ const metadata = resolveFieldMetadata(fieldConfig[country], {}, defaultFieldMetadata);
2034
+ const mergedProps = mergeFieldMetadataIntoProps("iban", metadata, props);
2035
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
2036
+ ...mergedProps,
2037
+ schema: ibanFields,
2038
+ rules: mergedProps.validators,
2039
+ defaultData: ibanData,
2040
+ fieldProblems: fieldValidationErrors,
2041
+ obscuredFields
2042
+ });
2043
+ const { updateStateSlice } = useGlobalDataSlice(
2044
+ "payoutAccountDetails"
2045
+ );
2046
+ useEffect(() => {
2047
+ updateStateSlice({ data, valid, errors, fieldProblems });
2048
+ }, [data, errors, valid]);
2049
+ const formUtils = createFormUtils(mergedProps, t);
2050
+ return /* @__PURE__ */ jsx(
2051
+ MaskedInput,
2052
+ {
2053
+ name: "iban",
2054
+ type: "text",
2055
+ label: formUtils.getLabel("iban"),
2056
+ formatGuidance: formUtils.getGuidanceText("iban"),
2057
+ ...formUtils.getMask("iban"),
2058
+ errorMessage: formUtils.getErrorMessage("iban", errors, fieldProblems),
2059
+ isValid: valid.iban,
2060
+ value: data.iban ?? "",
2061
+ readonly: formUtils.isReadOnly("iban"),
2062
+ onInput: handleChangeFor("iban", "blur"),
2063
+ onBlur: handleChangeFor("iban", "blur"),
2064
+ "aria-required": true,
2065
+ "aria-invalid": !valid.iban,
2066
+ acceptObscuredValue: formUtils.isObscured("iban")
2067
+ }
2068
+ );
2069
+ }
2070
+ const swiftCodeFieldMetadata = {
2071
+ label: "bicSwift",
2072
+ validators: validatePatternOnBlur(/^([a-zA-Z0-9]{8}|[a-zA-Z0-9]{11})$/),
2073
+ mask: {
2074
+ mask: makeMask(...alphaInputs(6), ...alphanumericInputs(2), ...alphanumericInputs(3, true)),
2075
+ transformOnType: uppercase
2076
+ },
2077
+ guidanceText: {
2078
+ key: "enterXOrYCharactersForExample",
2079
+ values: {
2080
+ xChars: "8",
2081
+ yChars: "11",
2082
+ example: "BANKDE65287"
2083
+ }
2084
+ }
2085
+ };
2086
+ const swiftCodeFields = ["swiftCode"];
2087
+ function SwiftCode(props) {
2088
+ const { t } = useTranslation("common");
2089
+ const mergedProps = mergeFieldMetadataIntoProps("swiftCode", swiftCodeFieldMetadata, props);
2090
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
2091
+ ...mergedProps,
2092
+ schema: swiftCodeFields,
2093
+ rules: mergedProps.validators,
2094
+ defaultData: mergedProps.data,
2095
+ fieldProblems: mergedProps?.fieldValidationErrors
2096
+ });
2097
+ const { updateStateSlice } = useGlobalDataSlice(
2098
+ "payoutAccountDetails"
2099
+ );
2100
+ useEffect(() => {
2101
+ updateStateSlice({ data, valid, errors, fieldProblems });
2102
+ }, [data, valid, errors]);
2103
+ const formUtils = createFormUtils(mergedProps, t);
2104
+ return /* @__PURE__ */ jsx(
2105
+ MaskedInput,
2106
+ {
2107
+ name: "swiftCode",
2108
+ type: "text",
2109
+ label: formUtils.getLabel("swiftCode"),
2110
+ formatGuidance: formUtils.getGuidanceText("swiftCode"),
2111
+ ...formUtils.getMask("swiftCode"),
2112
+ errorMessage: formUtils.getErrorMessage("swiftCode", errors, fieldProblems),
2113
+ isValid: valid.swiftCode,
2114
+ value: data.swiftCode ?? "",
2115
+ readonly: formUtils.isReadOnly("swiftCode"),
2116
+ onInput: handleChangeFor("swiftCode", "input"),
2117
+ onBlur: handleChangeFor("swiftCode", "blur"),
2118
+ "aria-required": true,
2119
+ "aria-invalid": !valid.swiftCode
2120
+ }
2121
+ );
2122
+ }
2123
+ const countriesWithMultipleCurrencies = /* @__PURE__ */ new Set([
2124
+ CountryCodes.Bulgaria,
2125
+ CountryCodes.Canada,
2126
+ CountryCodes.Croatia,
2127
+ CountryCodes.CzechRepublic,
2128
+ CountryCodes.Hungary,
2129
+ CountryCodes.Romania,
2130
+ CountryCodes.Switzerland
2131
+ ]);
2132
+ const countriesWithLocalFormat = /* @__PURE__ */ new Set([
2133
+ CountryCodes.CzechRepublic,
2134
+ CountryCodes.Denmark,
2135
+ CountryCodes.Hungary,
2136
+ CountryCodes.Norway,
2137
+ CountryCodes.Poland,
2138
+ CountryCodes.Sweden,
2139
+ CountryCodes.UnitedKingdom
2140
+ ]);
2141
+ const payoutCurrencySupport = {
2142
+ [CountryCodes.Sweden]: {
2143
+ local: [Currencies.SEK],
2144
+ iban: [Currencies.EUR, Currencies.SEK]
2145
+ },
2146
+ [CountryCodes.Canada]: {
2147
+ local: [Currencies.CAD, Currencies.USD],
2148
+ iban: [Currencies.CAD, Currencies.USD]
2149
+ }
2150
+ };
2151
+ const shouldShowCheckGuidance = (country) => country === "US";
2152
+ const shouldShowPayoutAccountFormatSelector = (country) => countriesWithLocalFormat.has(country);
2153
+ const shouldShowPayoutAlert = (country) => shouldShowPayoutAccountFormatSelector(country) || countriesWithMultipleCurrencies.has(country);
2154
+ const getSupportedCurrencyGuidance = (i18n, country, requiredFields) => {
2155
+ const format = requiredFields.includes("iban") ? "iban" : "local";
2156
+ if (!shouldShowPayoutAlert(country)) {
2157
+ return;
2158
+ }
2159
+ const supportedCurrencies = getSupportedCurrenciesPerFormat(country, format);
2160
+ if (!supportedCurrencies) {
2161
+ return;
2162
+ }
2163
+ return supportedCurrencies.length > 1 ? i18n.get("payoutIn_Or_", {
2164
+ values: { currencyOne: supportedCurrencies[0], currencyTwo: supportedCurrencies[1] }
2165
+ }) : i18n.get("payoutInOnly_", {
2166
+ values: { currency: supportedCurrencies[0] }
2167
+ });
2168
+ };
2169
+ const getSupportedCurrenciesPerFormat = (country, format) => {
2170
+ const supportedCurrencies = payoutCurrencySupport[country];
2171
+ if (!supportedCurrencies) {
2172
+ const defaultCurrency = currencyByCountry[country]?.[0];
2173
+ if (!defaultCurrency) {
2174
+ return;
2175
+ }
2176
+ return format === "iban" ? [Currencies.EUR, defaultCurrency] : [defaultCurrency];
2177
+ }
2178
+ return supportedCurrencies[format];
2179
+ };
2180
+ const AccountHolderDescriptionFragment = ({
2181
+ legalEntityResponse
2182
+ }) => {
2183
+ const { i18n } = useI18nContext();
2184
+ const hasSolePropEntityAssociations = hasOwnEntityAssociationOfType(
2185
+ LegalEntityTypes.SOLE_PROPRIETORSHIP,
2186
+ legalEntityResponse.entityAssociations,
2187
+ legalEntityResponse.id
2188
+ );
2189
+ const { accountHolder } = useAccountHolder();
2190
+ const unincorporatedPartnershipMembers = useUnincorporatedPartnershipMembers();
2191
+ if (accountHolder === "mySoleProprietorName" || hasSolePropEntityAssociations) {
2192
+ const soleProp = legalEntityResponse.entityAssociations?.find(
2193
+ (ea) => ea.entityType === "soleProprietorship"
2194
+ );
2195
+ const { individual: individual2 } = legalEntityResponse;
2196
+ return /* @__PURE__ */ jsxs(Typography, { children: [
2197
+ `${i18n.get("bankAccountHasToBeInYourName")} `,
2198
+ /* @__PURE__ */ jsx(
2199
+ Typography,
2200
+ {
2201
+ el: "span",
2202
+ variant: "body-stronger",
2203
+ children: `${individual2?.name.firstName} ${individual2?.name.lastName}`
2204
+ }
2205
+ ),
2206
+ ` ${i18n.get("orSoleProprietorshipName")} `,
2207
+ " ",
2208
+ /* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: `${soleProp?.name ?? ""}` })
2209
+ ] });
2210
+ }
2211
+ const hasTrustsEntityAssociations = hasOwnEntityAssociationOfType(
2212
+ LegalEntityTypes.TRUST,
2213
+ legalEntityResponse.entityAssociations,
2214
+ legalEntityResponse.id
2215
+ );
2216
+ if (accountHolder === "aTrust" || hasTrustsEntityAssociations) {
2217
+ const trust = legalEntityResponse.entityAssociations?.find((ea) => ea.entityType === "trust");
2218
+ if (legalEntityResponse.type === LegalEntityTypes.INDIVIDUAL) {
2219
+ return /* @__PURE__ */ jsxs(Typography, { children: [
2220
+ `${i18n.get("bankAccountToHaveSameNameAsTrust")} `,
2221
+ /* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: i18n.get("trusteeAsTrusteeForTrust", {
2222
+ values: {
2223
+ trusteeName: `${legalEntityResponse?.individual?.name.firstName} ${legalEntityResponse?.individual?.name.lastName}`,
2224
+ trustName: trust?.name ?? ""
2225
+ }
2226
+ }) })
2227
+ ] });
2228
+ }
2229
+ const companyTrusteeBankAccountName = legalEntityResponse?.organization?.legalName !== legalEntityResponse?.organization?.doingBusinessAs ? i18n.get("trusteeAsTrusteeForTrustDoingBusinessAs", {
2230
+ values: {
2231
+ trusteeName: legalEntityResponse?.organization?.legalName ?? "",
2232
+ trustName: trust?.name ?? "",
2233
+ tradingName: legalEntityResponse?.organization?.doingBusinessAs
2234
+ }
2235
+ }) : i18n.get("trusteeAsTrusteeForTrust", {
2236
+ values: {
2237
+ trusteeName: legalEntityResponse?.organization?.legalName ?? "",
2238
+ trustName: trust?.name ?? ""
2239
+ }
2240
+ });
2241
+ return /* @__PURE__ */ jsxs(Typography, { children: [
2242
+ `${i18n.get("bankAccountToHaveSameNameAsTrust")} `,
2243
+ /* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: companyTrusteeBankAccountName })
2244
+ ] });
2245
+ }
2246
+ const hasUnincorporatedPartnershipEntityAssociations = hasOwnEntityAssociationOfType(
2247
+ LegalEntityTypes.UNINCORPORATED_PARTNERSHIP,
2248
+ legalEntityResponse.entityAssociations,
2249
+ legalEntityResponse.id
2250
+ );
2251
+ if (accountHolder === "anUnincorporatedPartnership" || hasUnincorporatedPartnershipEntityAssociations) {
2252
+ const unincorporatedPartnership = legalEntityResponse?.entityAssociations?.find(
2253
+ (ea) => ea.entityType === "unincorporatedPartnership"
2254
+ );
2255
+ const partnerNames = unincorporatedPartnershipMembers?.map((member) => member?.name)?.sort();
2256
+ return /* @__PURE__ */ jsx(Typography, { children: `${i18n.get("bankAccountToHaveSameNameAsUnincorporatedPartnership", {
2257
+ values: {
2258
+ partnerNames: `${partnerNames?.join(", ")}`,
2259
+ partnershipName: unincorporatedPartnership?.name ?? ""
2260
+ }
2261
+ })} ` });
2262
+ }
2263
+ if (legalEntityResponse.type === LegalEntityTypes.ORGANIZATION) {
2264
+ return /* @__PURE__ */ jsxs(Typography, { children: [
2265
+ `${i18n.get("bankAccountHasToBeInYourCompanyName")} `,
2266
+ /* @__PURE__ */ jsx(Typography, { el: "span", variant: "body-stronger", children: legalEntityResponse?.organization?.legalName })
2267
+ ] });
2268
+ }
2269
+ const { individual } = legalEntityResponse;
2270
+ return /* @__PURE__ */ jsxs(Typography, { children: [
2271
+ `${i18n.get("bankAccountHasToBeInYourName")} `,
2272
+ /* @__PURE__ */ jsx(
2273
+ Typography,
2274
+ {
2275
+ el: "span",
2276
+ variant: "body-stronger",
2277
+ children: `${individual?.name.firstName} ${individual?.name.lastName}`
2278
+ }
2279
+ )
2280
+ ] });
2281
+ };
2282
+ const checkGuidance = "adyen-kyc-check-guidance";
2283
+ const checkGuidanceImage = "adyen-kyc-check-guidance-image";
2284
+ const checkGuidanceAnnotated = "adyen-kyc-check-guidance-annotated";
2285
+ const checkGuidanceInactive = "adyen-kyc-check-guidance-inactive";
2286
+ const styles = {
2287
+ checkGuidance,
2288
+ checkGuidanceImage,
2289
+ checkGuidanceAnnotated,
2290
+ checkGuidanceInactive
2291
+ };
2292
+ const usCheckAccount = lazy(() => import("./us-check-account-number-C7KE5YzX.js"));
2293
+ const usCheckRouting = lazy(() => import("./us-check-routing-number-DUbhsYAR.js"));
2294
+ const usCheck = lazy(() => import("./us-check-CYY6Crhr.js"));
2295
+ const CheckGuidance = ({ annotated }) => {
2296
+ return /* @__PURE__ */ jsxs("div", { className: styles.checkGuidance, children: [
2297
+ /* @__PURE__ */ jsx(
2298
+ Image,
2299
+ {
2300
+ lazyLoadedImage: usCheckAccount,
2301
+ className: cx(styles.checkGuidanceImage, styles.checkGuidanceAnnotated, {
2302
+ [styles.checkGuidanceInactive]: annotated !== "account"
2303
+ })
2304
+ }
2305
+ ),
2306
+ /* @__PURE__ */ jsx(
2307
+ Image,
2308
+ {
2309
+ lazyLoadedImage: usCheckRouting,
2310
+ className: cx(styles.checkGuidanceImage, styles.checkGuidanceAnnotated, {
2311
+ [styles.checkGuidanceInactive]: annotated !== "routing"
2312
+ })
2313
+ }
2314
+ ),
2315
+ /* @__PURE__ */ jsx(Image, { lazyLoadedImage: usCheck, className: styles.checkGuidanceImage })
2316
+ ] });
2317
+ };
2318
+ const payoutAccountFields = [
2319
+ "accountHolder",
2320
+ ...ibanFields,
2321
+ ...branchCodeFields,
2322
+ ...swiftCodeFields,
2323
+ ...bankAccountNumberFields,
2324
+ ...bankNameFields,
2325
+ ...bankCodeFields
2326
+ ];
2327
+ const defaultArray = [];
2328
+ function PayoutAccount(props) {
2329
+ const accountFormat = payoutAccountFormat.value;
2330
+ const { t } = useTranslation("banking");
2331
+ const { t: commonT } = useTranslation("common");
2332
+ const { i18n } = useI18nContext();
2333
+ const [checkAnnotation, setCheckAnnotation] = useState();
2334
+ const { isSettingEnabled } = useSettingsContext();
2335
+ const bankAccountFormatSelectionAllowed = isSettingEnabled(
2336
+ SettingNames.AllowBankAccountFormatSelection
2337
+ );
2338
+ const {
2339
+ heading,
2340
+ country,
2341
+ id,
2342
+ legalEntityResponse,
2343
+ requiredFields = defaultArray,
2344
+ arePayoutAccountDetailsInvalid,
2345
+ invalidFieldNames,
2346
+ formVerificationErrors,
2347
+ fieldValidationErrors
2348
+ } = props;
2349
+ const showCheckGuidance = shouldShowCheckGuidance(country);
2350
+ const formUtils = createFormUtils({ ...props, requiredFields }, commonT);
2351
+ const bankAccountNumberProps = getFieldProps(props, bankAccountNumberFields);
2352
+ const swiftCodeProps = getFieldProps(props, swiftCodeFields);
2353
+ const ibanProps = getFieldProps(
2354
+ props,
2355
+ ibanFields
2356
+ );
2357
+ const branchCodeProps = getFieldProps(props, branchCodeFields);
2358
+ const bankNameProps = getFieldProps(props, bankNameFields);
2359
+ const bankCodeProps = getFieldProps(props, bankCodeFields);
2360
+ const bankCityProps = getFieldProps(props, bankCityFields);
2361
+ const { clearStateSlice } = useGlobalDataSlice(
2362
+ "payoutAccountDetails"
2363
+ );
2364
+ const handleAccountFormatChange = (accountFormat2) => {
2365
+ clearStateSlice();
2366
+ payoutAccountFormat.value = accountFormat2;
2367
+ };
2368
+ return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
2369
+ /* @__PURE__ */ jsx(FormHeader, { heading, children: /* @__PURE__ */ jsx(
2370
+ AccountHolderDescriptionFragment,
2371
+ {
2372
+ slot: "description",
2373
+ legalEntityResponse
2374
+ }
2375
+ ) }),
2376
+ /* @__PURE__ */ jsx(
2377
+ ErrorPanel,
2378
+ {
2379
+ verificationErrors: formVerificationErrors,
2380
+ validationErrors: fieldValidationErrors,
2381
+ formUtils,
2382
+ id: "ariaErrorField"
2383
+ }
2384
+ ),
2385
+ showCheckGuidance ? /* @__PURE__ */ jsx(CheckGuidance, { annotated: checkAnnotation }) : void 0,
2386
+ bankAccountFormatSelectionAllowed && shouldShowPayoutAccountFormatSelector(country) && accountFormat && /* @__PURE__ */ jsx(
2387
+ BankAccountFormat,
2388
+ {
2389
+ bankAccountFormat: accountFormat,
2390
+ handleAccountFormatChange
2391
+ }
2392
+ ),
2393
+ formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
2394
+ BranchCode,
2395
+ {
2396
+ ...branchCodeProps,
2397
+ country,
2398
+ dataStoreId: id,
2399
+ onFocus: showCheckGuidance ? () => setCheckAnnotation("routing") : void 0,
2400
+ onBlur: showCheckGuidance ? () => setCheckAnnotation(void 0) : void 0
2401
+ }
2402
+ ),
2403
+ formUtils.isRequiredField("bankAccountNumber") && /* @__PURE__ */ jsx(
2404
+ BankAccountNumber,
2405
+ {
2406
+ ...bankAccountNumberProps,
2407
+ country,
2408
+ dataStoreId: id,
2409
+ onFocus: showCheckGuidance ? () => setCheckAnnotation("account") : void 0,
2410
+ onBlur: showCheckGuidance ? () => setCheckAnnotation(void 0) : void 0
2411
+ }
2412
+ ),
2413
+ formUtils.isRequiredField("iban") && /* @__PURE__ */ jsx(Iban, { ...ibanProps, dataStoreId: id, country }),
2414
+ formUtils.isRequiredField("swiftCode") && /* @__PURE__ */ jsx(SwiftCode, { ...swiftCodeProps, dataStoreId: id }),
2415
+ formUtils.isRequiredField("bankName") && /* @__PURE__ */ jsx(BankName, { ...bankNameProps, dataStoreId: id }),
2416
+ formUtils.isRequiredField("bankCode") && /* @__PURE__ */ jsx(BankCode, { ...bankCodeProps, country, dataStoreId: id }),
2417
+ formUtils.isRequiredField("bankCity") && /* @__PURE__ */ jsx(BankCity, { ...bankCityProps, dataStoreId: id }),
2418
+ shouldShowPayoutAlert(country) && /* @__PURE__ */ jsx(
2419
+ Alert,
2420
+ {
2421
+ title: getSupportedCurrencyGuidance(i18n, country, requiredFields),
2422
+ className: "adyen-kyc-u-margin-bottom-8"
2423
+ }
2424
+ ),
2425
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "tertiary", children: t(($) => $["thisAccountWillBeVerifiedToPrevent"]) }),
2426
+ arePayoutAccountDetailsInvalid && /* @__PURE__ */ jsx(
2427
+ Alert,
2428
+ {
2429
+ className: "adyen-kyc-u-margin-top-16",
2430
+ variant: "error",
2431
+ title: invalidFieldNames ? t(($) => $["pleaseEnterValidField"], {
2432
+ fieldNames: invalidFieldNames
2433
+ }) : t(($) => $["pleaseEnterValidAccountDetails"])
2434
+ }
2435
+ )
2436
+ ] });
2437
+ }
2438
+ const regions = {
2439
+ europe: [
2440
+ ...EEA_Countries,
2441
+ CountryCodes.Switzerland,
2442
+ CountryCodes.UnitedKingdom,
2443
+ CountryCodes.Gibraltar
2444
+ ],
2445
+ apac: [CountryCodes.NewZealand, CountryCodes.Australia]
2446
+ };
2447
+ const getAllowedBankCountries = (country) => Object.values(regions).find((countriesInARegion) => countriesInARegion.includes(country)) ?? [
2448
+ country
2449
+ ];
2450
+ const tinkLogo = lazy(() => import("./tink-logo-BcIv93ND.js"));
2451
+ const plaidLogo = lazy(() => import("./plaid-logo-CtActXTN.js"));
2452
+ const yapilyLogo = lazy(() => import("./yapily-logo-CZ4ywjwA.js"));
2453
+ const instantVerificationImage = lazy(
2454
+ () => import("./instant-verification-Dvvkyfmp.js")
2455
+ );
2456
+ const manualVerificationImage = lazy(
2457
+ () => import("./manual-verification-BvZWqA00.js")
2458
+ );
2459
+ const getProviderIconName = (providerName) => {
2460
+ switch (providerName?.toLowerCase()) {
2461
+ case "tink":
2462
+ return tinkLogo;
2463
+ case "plaid":
2464
+ return plaidLogo;
2465
+ case "yapily":
2466
+ return yapilyLogo;
2467
+ default:
2468
+ return void 0;
2469
+ }
2470
+ };
2471
+ const makePayoutVerificationMethodsMetadata = (instantVerificationProviderName) => ({
2472
+ instantVerification: {
2473
+ name: "verifyViaMobileBankingAppOrWebsite",
2474
+ subtitle: "instant",
2475
+ description: "instantVerificationDescription",
2476
+ svgImport: instantVerificationImage,
2477
+ provider: instantVerificationProviderName ? {
2478
+ name: instantVerificationProviderName,
2479
+ svgImport: getProviderIconName(instantVerificationProviderName)
2480
+ } : void 0
2481
+ },
2482
+ manualVerification: {
2483
+ name: "uploadABankStatement",
2484
+ subtitle: "mayTakeAFewDays",
2485
+ description: "manualVerificationDescription",
2486
+ svgImport: manualVerificationImage
2487
+ }
2488
+ });
2489
+ const payoutVerificationMethods = ["instantVerification", "manualVerification"];
2490
+ const PayoutVerificationMethodOptionFooter = ({
2491
+ method,
2492
+ methodsMetadata
2493
+ }) => {
2494
+ const { i18n } = useI18nContext();
2495
+ const { provider } = methodsMetadata[method];
2496
+ return provider ? /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "adyen-kyc-field-verification-methods__footer", children: [
2497
+ i18n.get("poweredBy"),
2498
+ provider.svgImport ? /* @__PURE__ */ jsx(
2499
+ Image,
2500
+ {
2501
+ className: "adyen-kyc-field-verification-methods__logo",
2502
+ lazyLoadedImage: provider.svgImport
2503
+ }
2504
+ ) : ` ${provider.name}`
2505
+ ] }) : null;
2506
+ };
2507
+ const payoutVerificationMethodFields = ["payoutVerificationMethod", "bankCountry", ...accountVerificationFields];
2508
+ const getMustHaveSameAccountHolderNameTransKey = (legalEntityType) => {
2509
+ switch (legalEntityType) {
2510
+ case LegalEntityTypes.INDIVIDUAL:
2511
+ case LegalEntityTypes.SOLE_PROPRIETORSHIP:
2512
+ return "theBankAccountHolderMustBeInYourName";
2513
+ case LegalEntityTypes.ORGANIZATION:
2514
+ case LegalEntityTypes.TRUST:
2515
+ case LegalEntityTypes.UNINCORPORATED_PARTNERSHIP:
2516
+ return "theBankAccountHolderMustHaveTheSameNameAsYourCompany";
2517
+ }
2518
+ };
2519
+ function PayoutVerificationMethod(props) {
2520
+ const {
2521
+ heading,
2522
+ country,
2523
+ accountHolder,
2524
+ provider,
2525
+ bankVendorsLoadingStatus,
2526
+ instantVerificationAvailable,
2527
+ legalEntityResponse,
2528
+ validators,
2529
+ bankInfoValidated,
2530
+ data: payoutVerificationMethodData,
2531
+ fieldValidationErrors,
2532
+ formVerificationErrors
2533
+ } = props;
2534
+ const { type: legalEntityType } = legalEntityResponse;
2535
+ const { t } = useTranslation("banking");
2536
+ const { t: commonT } = useTranslation("common");
2537
+ const instantVerificationError = useContext(InstantVerificationErrorContext);
2538
+ const { isSettingEnabled } = useSettingsContext();
2539
+ const { isExperimentEnabled } = useExperimentsContext();
2540
+ const canChangeEntityType = isSettingEnabled(SettingNames.AllowLegalEntityTypeChange);
2541
+ const intraRegionCrossBorderPayoutsAllowed = isSettingEnabled(
2542
+ SettingNames.AllowIntraRegionCrossBorderPayout
2543
+ );
2544
+ const enabledUnbiasedVerificationMethod = isExperimentEnabled(
2545
+ "BankVerificationMethodAutonomy_UnbiasedSelection"
2546
+ );
2547
+ const [hasSelectedMethod, setHasSelectedMethod] = useState(false);
2548
+ const { handleChangeFor, data, valid, errors, fieldProblems } = useForm({
2549
+ ...props,
2550
+ schema: payoutVerificationMethodFields,
2551
+ defaultData: {
2552
+ verifiedAccountHolder: accountHolder,
2553
+ verifiedCurrencyCode: currencyByCountry[country]?.[0],
2554
+ bankCountry: country,
2555
+ ...payoutVerificationMethodData
2556
+ },
2557
+ rules: validators || {
2558
+ payoutVerificationMethod: {
2559
+ modes: ["blur"],
2560
+ validate: (payoutVerificationMethod) => !enabledUnbiasedVerificationMethod || !!payoutVerificationMethod
2561
+ }
2562
+ },
2563
+ fieldProblems: fieldValidationErrors
2564
+ });
2565
+ const formUtils = createFormUtils(props, commonT);
2566
+ const { sliceData, updateStateSlice } = useGlobalDataSlice("payoutVerificationMethod");
2567
+ const { clearStateSlice: clearPayoutAccountDetails } = useGlobalDataSlice("payoutAccountDetails");
2568
+ useEffect(
2569
+ () => updateStateSlice({ data: { ...sliceData, ...data }, errors, valid, fieldProblems }),
2570
+ [data, errors, fieldProblems, valid]
2571
+ );
2572
+ const methodsMetadata = makePayoutVerificationMethodsMetadata(provider?.name);
2573
+ const selectVerificationMethod = (method) => {
2574
+ setHasSelectedMethod(true);
2575
+ handleChangeFor("payoutVerificationMethod")(method);
2576
+ };
2577
+ useEffect(() => {
2578
+ if (bankInfoValidated || enabledUnbiasedVerificationMethod) return;
2579
+ if (!hasSelectedMethod && instantVerificationAvailable && data.payoutVerificationMethod !== "instantVerification") {
2580
+ handleChangeFor("payoutVerificationMethod")("instantVerification");
2581
+ }
2582
+ if (!instantVerificationAvailable && data.payoutVerificationMethod !== "manualVerification") {
2583
+ handleChangeFor("payoutVerificationMethod")("manualVerification");
2584
+ }
2585
+ }, [
2586
+ data.payoutVerificationMethod,
2587
+ handleChangeFor,
2588
+ instantVerificationAvailable,
2589
+ hasSelectedMethod,
2590
+ bankInfoValidated
2591
+ ]);
2592
+ const { dataset: countries } = useDataset(datasetIdentifier.country);
2593
+ const bankCountryName = countries.find((country2) => country2.id === data.bankCountry)?.name ?? data.bankCountry;
2594
+ const allowedBankCountries = getAllowedBankCountries(country);
2595
+ const countryField = /* @__PURE__ */ jsx(
2596
+ CountryField,
2597
+ {
2598
+ data: { country: data.bankCountry },
2599
+ valid: { country: valid?.bankCountry },
2600
+ errors: { country: formUtils.getErrorMessage("bankCountry", errors, fieldProblems) },
2601
+ labels: { country: formUtils.getLabel("bankCountry", "bankAccountCountryRegion") },
2602
+ readonly: !intraRegionCrossBorderPayoutsAllowed || allowedBankCountries.length === 1 || bankInfoValidated,
2603
+ allowedCountries: allowedBankCountries,
2604
+ handleChangeFor: () => (e) => {
2605
+ clearPayoutAccountDetails();
2606
+ return handleChangeFor("bankCountry", "input")(e);
2607
+ },
2608
+ helperText: {
2609
+ country: intraRegionCrossBorderPayoutsAllowed ? void 0 : t(
2610
+ ($) => $[legalEntityType === LegalEntityTypes.INDIVIDUAL ? "youCanOnlyUseABankAccountInTheCountryRegionWhereYouLive" : "youCanOnlyUseABankAccountInTheCountryRegionWhereYourCompanyIsRegistered"]
2611
+ )
2612
+ }
2613
+ }
2614
+ );
2615
+ const description = canChangeEntityType ? /* @__PURE__ */ jsx(AccountHolderDescriptionFragment, { legalEntityResponse }) : /* @__PURE__ */ jsxs(Typography, { children: [
2616
+ t(($) => $["forYouToReceiveYourPayouts"]),
2617
+ " ",
2618
+ /* @__PURE__ */ jsx(
2619
+ Trans,
2620
+ {
2621
+ t,
2622
+ ns: "banking",
2623
+ i18nKey: ($) => $[getMustHaveSameAccountHolderNameTransKey(legalEntityType)],
2624
+ values: { name: accountHolder, companyName: accountHolder }
2625
+ }
2626
+ )
2627
+ ] });
2628
+ return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-payout-verification-method", children: [
2629
+ /* @__PURE__ */ jsx(FormHeader, { heading, children: /* @__PURE__ */ jsx("div", { slot: "description", className: "adyen-kyc-u-margin-bottom-12", children: description }) }),
2630
+ instantVerificationError && /* @__PURE__ */ jsx(
2631
+ Alert,
2632
+ {
2633
+ variant: "error",
2634
+ className: "adyen-kyc-instant-verification-error",
2635
+ title: instantVerificationError.title,
2636
+ children: instantVerificationError.content && /* @__PURE__ */ jsx("p", { className: "adyen-kyc-u-margin-0", children: instantVerificationError.content })
2637
+ }
2638
+ ),
2639
+ countryField,
2640
+ /* @__PURE__ */ jsx(
2641
+ Field,
2642
+ {
2643
+ el: "fieldset",
2644
+ name: "verificationMethods",
2645
+ label: formUtils.getLabel("payoutVerificationMethod", "verificationMethod"),
2646
+ errorMessage: formUtils.getErrorMessage("payoutVerificationMethod", errors, fieldProblems),
2647
+ helper: instantVerificationAvailable ? void 0 : t(($) => $["weDoNotYetSupportInstantVerificationForBankAccountsIn"], {
2648
+ countryName: bankCountryName
2649
+ }),
2650
+ children: (childProps) => /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2651
+ RadioGroupCard,
2652
+ {
2653
+ ...childProps,
2654
+ name: "verificationMethod",
2655
+ options: payoutVerificationMethods,
2656
+ onSelect: selectVerificationMethod,
2657
+ selected: data.payoutVerificationMethod,
2658
+ optionId: (method) => method,
2659
+ optionName: (method) => methodsMetadata[method].name,
2660
+ optionDescription: (method) => methodsMetadata[method].description,
2661
+ optionSubtitle: (method) => methodsMetadata[method].subtitle,
2662
+ className: "adyen-kyc-field-verification-methods",
2663
+ optionClassNames: () => ({
2664
+ label: "adyen-kyc-field-verification-methods__card"
2665
+ }),
2666
+ isOptionDisabled: (option) => bankInfoValidated || option === "instantVerification" && !instantVerificationAvailable,
2667
+ renderOptionIcon: (method) => /* @__PURE__ */ jsx("div", { className: "adyen-kyc-radio-group-card__illustration", children: methodsMetadata[method]?.svgImport && /* @__PURE__ */ jsx(Image, { lazyLoadedImage: methodsMetadata[method].svgImport }) }),
2668
+ renderOptionFooter: (method) => /* @__PURE__ */ jsx(
2669
+ PayoutVerificationMethodOptionFooter,
2670
+ {
2671
+ method,
2672
+ methodsMetadata
2673
+ }
2674
+ ),
2675
+ floatingRadio: true
2676
+ }
2677
+ ) })
2678
+ }
2679
+ ),
2680
+ /* @__PURE__ */ jsx(
2681
+ ErrorPanel,
2682
+ {
2683
+ verificationErrors: formVerificationErrors,
2684
+ validationErrors: fieldValidationErrors,
2685
+ formUtils,
2686
+ id: "ariaErrorField"
2687
+ }
2688
+ ),
2689
+ provider && bankVendorsLoadingStatus === "success" ? /* @__PURE__ */ jsx(
2690
+ ContextGuidance,
2691
+ {
2692
+ titleId: "howDoesVerificationWithOurPartnerWorks",
2693
+ contentId: "bankVerificationWithPartnerSteps",
2694
+ title: t(($) => $["howDoesVerificationWithOurPartnerWork"], {
2695
+ provider: provider.name
2696
+ }),
2697
+ content: /* @__PURE__ */ jsxs(Fragment, { children: [
2698
+ /* @__PURE__ */ jsx(Typography, { children: t(($) => $["isOurTrustedPartnerHelpingSpeedUpSetup"], {
2699
+ provider: provider.name
2700
+ }) }),
2701
+ /* @__PURE__ */ jsxs("ul", { children: [
2702
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["selectTheBankToReceivePayouts"]) }),
2703
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["loginIntoYourBankingEnvironment"]) }),
2704
+ /* @__PURE__ */ jsx("li", { children: t(($) => $["yourBankWillConfirmYourAccountDetails"]) })
2705
+ ] }),
2706
+ /* @__PURE__ */ jsx(Typography, { children: t(($) => $["adyenWillOnlyGetTemporaryAccess"]) }),
2707
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", children: /* @__PURE__ */ jsx(Link, { href: "https://www.adyen.com/policies-and-disclaimer/privacy-policy", external: true, children: commonT(($) => $["adyenPrivacyPolicy"]) }) })
2708
+ ] })
2709
+ }
2710
+ ) : void 0
2711
+ ] });
2712
+ }
2713
+ const payoutSteps = {
2714
+ payoutVerificationMethod: {
2715
+ formId: "payoutVerificationMethod",
2716
+ formName: "verificationMethod",
2717
+ fields: payoutVerificationMethodFields
2718
+ },
2719
+ payoutAccountDetails: {
2720
+ formId: "payoutAccountDetails",
2721
+ formName: "bankAccount",
2722
+ fields: payoutAccountFields
2723
+ },
2724
+ payoutAccountDocuments: {
2725
+ formId: "payoutAccountDocuments",
2726
+ formName: "bankDocument",
2727
+ formHeader: "bankDocumentHeader",
2728
+ formDescription: "bankDocumentDescription",
2729
+ fields: bankDocumentFields
2730
+ },
2731
+ payoutAccountVerification: {
2732
+ formId: "payoutAccountVerification",
2733
+ formName: "instantVerification",
2734
+ fields: accountVerificationFields
2735
+ }
2736
+ };
2737
+ const PayoutVerificationMethodFormID = payoutSteps.payoutVerificationMethod.formId;
2738
+ const PayoutAccountDocumentsFormID = payoutSteps.payoutAccountDocuments.formId;
2739
+ const PayoutAccountVerificationFormID = payoutSteps.payoutAccountVerification.formId;
2740
+ function PayoutDetails(props) {
2741
+ const { t } = useTranslation("banking");
2742
+ const { t: commonT } = useTranslation("common");
2743
+ const {
2744
+ activeForm,
2745
+ legalEntityResponse,
2746
+ associatedLegalArrangement,
2747
+ provider,
2748
+ bankVendorsLoadingStatus,
2749
+ instantVerificationAvailable,
2750
+ setHideSidebar,
2751
+ setSkipSubmit,
2752
+ createTrustedTransferInstrument: createTrustedTransferInstrument2,
2753
+ accountDetailsFromInput,
2754
+ country,
2755
+ accountHolder,
2756
+ data: propData,
2757
+ onBack,
2758
+ trustedTransferInstrumentId
2759
+ } = props;
2760
+ const [instantVerificationError, setInstantVerificationError] = useInstantVerificationErrorNotification(1e4);
2761
+ const verificationMethodFormProps = getFormProps(props, PayoutVerificationMethodFormID);
2762
+ const accountVerificationFormProps = getFormProps(props, PayoutAccountVerificationFormID);
2763
+ const payoutAccountFormProps = getFormProps(props, payoutSteps.payoutAccountDetails.formId);
2764
+ const bankDocumentFormProps = getFormProps(props, PayoutAccountDocumentsFormID);
2765
+ const taskHeading = t(($) => $["addABankAccountForPayouts"]);
2766
+ const isBankStatementDocumentOptional = createFormUtils(
2767
+ bankDocumentFormProps ?? {},
2768
+ commonT
2769
+ ).isOptionalField("bankStatementDocument");
2770
+ const globalData = useGlobalData();
2771
+ const data = isEmpty(globalData) || propData?.payoutAccountDetails?.transferInstrumentId ? propData : globalData;
2772
+ const resetData = useResetGlobalData();
2773
+ const verifyInstantly = data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification";
2774
+ const bankCountry = data?.payoutVerificationMethod?.bankCountry ?? country;
2775
+ const bankDocumentDescription = t(
2776
+ ($) => $[legalEntityResponse.type === "individual" ? "toHelpVerifyYourBankDetailsIndividual" : "toHelpVerifyYourBankDetailsBusiness"]
2777
+ );
2778
+ useEffect(() => resetData(), [resetData]);
2779
+ useEffect(() => {
2780
+ if (activeForm?.formId === summaryStep.formId && verifyInstantly && trustedTransferInstrumentId) {
2781
+ setSkipSubmit?.(true);
2782
+ }
2783
+ }, [activeForm, trustedTransferInstrumentId]);
2784
+ const [bankInfoValidated, setBankInfoValidated] = useState(false);
2785
+ const [arePayoutAccountDetailsInvalid, setArePayoutAccountDetailsInvalid] = useState(false);
2786
+ const [invalidFieldNames, setInvalidFieldNames] = useState("");
2787
+ const payload = useMemo(
2788
+ () => bankCountry && accountDetailsFromInput ? getAccountIdentificationFromPayoutAccountSchema(accountDetailsFromInput, bankCountry) : {},
2789
+ [accountDetailsFromInput, bankCountry]
2790
+ );
2791
+ const validateAccountDetails = useAsyncAccountDetailsValidationRules(
2792
+ payload,
2793
+ hasEmptyFields(payload),
2794
+ isAccountIdentifierObscured(payload)
2795
+ );
2796
+ const resetInvalidFieldState = () => {
2797
+ setInvalidFieldNames("");
2798
+ setArePayoutAccountDetailsInvalid(false);
2799
+ };
2800
+ useEffect(() => {
2801
+ if (validateAccountDetails?.invalidFields && validateAccountDetails.invalidFields.length > 0) {
2802
+ const fieldNames = validateAccountDetails.invalidFields.map((field) => extractFieldName(field.name)).map((key) => commonT(($) => $[key]));
2803
+ const invalidFieldsString = concatenateFieldNames(fieldNames);
2804
+ setInvalidFieldNames(invalidFieldsString);
2805
+ setArePayoutAccountDetailsInvalid(true);
2806
+ } else {
2807
+ resetInvalidFieldState();
2808
+ }
2809
+ }, [t, validateAccountDetails]);
2810
+ return /* @__PURE__ */ jsxs("div", { className: "adyen-kyc-payout", children: [
2811
+ /* @__PURE__ */ jsx(
2812
+ "div",
2813
+ {
2814
+ className: activeForm?.formId !== PayoutVerificationMethodFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
2815
+ children: /* @__PURE__ */ jsx(InstantVerificationErrorContext.Provider, { value: instantVerificationError, children: /* @__PURE__ */ jsx(
2816
+ PayoutVerificationMethod,
2817
+ {
2818
+ ...verificationMethodFormProps,
2819
+ id: PayoutVerificationMethodFormID,
2820
+ heading: taskHeading,
2821
+ country,
2822
+ accountHolder,
2823
+ legalEntityResponse,
2824
+ provider,
2825
+ bankVendorsLoadingStatus,
2826
+ bankInfoValidated,
2827
+ instantVerificationAvailable
2828
+ }
2829
+ ) })
2830
+ }
2831
+ ),
2832
+ verifyInstantly ? /* @__PURE__ */ jsx(
2833
+ "div",
2834
+ {
2835
+ className: activeForm?.formId !== PayoutAccountVerificationFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
2836
+ children: /* @__PURE__ */ jsx(
2837
+ BankVerification,
2838
+ {
2839
+ ...accountVerificationFormProps,
2840
+ heading: t(($) => $["bankAccountVerification"]),
2841
+ id: PayoutAccountVerificationFormID,
2842
+ provider,
2843
+ country: bankCountry,
2844
+ onBack,
2845
+ hideSidebar: setHideSidebar,
2846
+ setBankVerificationError: setInstantVerificationError,
2847
+ bankInfoValidated,
2848
+ setBankInfoValidated,
2849
+ formIsActive: activeForm?.formId === PayoutAccountVerificationFormID,
2850
+ createTrustedTransferInstrument: createTrustedTransferInstrument2
2851
+ }
2852
+ )
2853
+ }
2854
+ ) : /* @__PURE__ */ jsxs(Fragment, { children: [
2855
+ /* @__PURE__ */ jsx(
2856
+ "div",
2857
+ {
2858
+ className: activeForm?.formId !== payoutSteps.payoutAccountDetails.formId ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
2859
+ children: /* @__PURE__ */ jsx(
2860
+ PayoutAccount,
2861
+ {
2862
+ ...payoutAccountFormProps,
2863
+ heading: taskHeading,
2864
+ id: payoutSteps.payoutAccountDetails.formId,
2865
+ country: bankCountry,
2866
+ legalEntityResponse,
2867
+ arePayoutAccountDetailsInvalid,
2868
+ invalidFieldNames
2869
+ }
2870
+ )
2871
+ }
2872
+ ),
2873
+ /* @__PURE__ */ jsx(
2874
+ "div",
2875
+ {
2876
+ className: activeForm?.formId !== PayoutAccountDocumentsFormID ? "adyen-kyc-form-wrapper adyen-kyc-form-wrapper--hidden" : "adyen-kyc-form-wrapper",
2877
+ children: /* @__PURE__ */ jsx(
2878
+ MemoizedBankDocument,
2879
+ {
2880
+ ...bankDocumentFormProps,
2881
+ heading: t(
2882
+ ($) => $[isBankStatementDocumentOptional ? "uploadABankDocumentOptional" : "uploadABankDocument"]
2883
+ ),
2884
+ description: bankDocumentDescription,
2885
+ id: PayoutAccountDocumentsFormID,
2886
+ legalEntity: legalEntityResponse,
2887
+ associatedLegalArrangement,
2888
+ country: bankCountry,
2889
+ formIsActive: activeForm?.formId === PayoutAccountDocumentsFormID
2890
+ }
2891
+ )
2892
+ }
2893
+ )
2894
+ ] }),
2895
+ /* @__PURE__ */ jsx(Show, { when: showPayoutVerificationMethodError, children: /* @__PURE__ */ jsx(
2896
+ Confirm,
2897
+ {
2898
+ analyticsEventLabel: "payoutVerificationMethodError",
2899
+ title: t(($) => $["toContinuePleaseChooseAVerificationMethod"]),
2900
+ confirmText: commonT(($) => $["ok"]),
2901
+ onConfirm: () => {
2902
+ showPayoutVerificationMethodError.value = false;
2903
+ }
2904
+ }
2905
+ ) })
2906
+ ] });
2907
+ }
2908
+ const rules = ({
2909
+ data,
2910
+ requiredFields,
2911
+ isExperimentEnabled
2912
+ }) => createFormRules({
2913
+ whenUsingManualVerification: () => {
2914
+ if (!data.payoutVerificationMethod) return;
2915
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification") {
2916
+ return "REQUIRED";
2917
+ }
2918
+ },
2919
+ whenUsingInstantVerification: () => {
2920
+ if (!data.payoutVerificationMethod) {
2921
+ return "REQUIRED";
2922
+ }
2923
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
2924
+ return "REQUIRED";
2925
+ }
2926
+ },
2927
+ verifiedBankAccountNumber: () => {
2928
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
2929
+ return "REQUIRED";
2930
+ }
2931
+ },
2932
+ bankStatementRequirement: () => {
2933
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod !== "instantVerification" && (isExperimentEnabled?.("EnableCheckOnCreateBankAccount") || isExperimentEnabled?.("BankVerificationFlowOptimization_CAASIntegration"))) {
2934
+ return "REQUIRED";
2935
+ }
2936
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification") {
2937
+ return requiredFields?.bankStatementRequirement;
2938
+ }
2939
+ },
2940
+ // "bankStatement description" field is always "optional" and it's coupled with bank statement document.
2941
+ bankStatementDescription: () => {
2942
+ if (data?.payoutVerificationMethod?.payoutVerificationMethod === "manualVerification" && !!requiredFields?.bankStatementRequirement) {
2943
+ return "OPTIONAL";
2944
+ }
2945
+ }
2946
+ });
2947
+ const mapApiDocumentToPayoutDocuments = (entityId) => {
2948
+ const bankStatement = getDocument(entityId, "bankStatement");
2949
+ if (!bankStatement) throw new Error(`bankStatement with id ${entityId} not found`);
2950
+ return {
2951
+ bankStatementDocument: [mapExistingFile(getPageName(bankStatement))],
2952
+ description: bankStatement.description
2953
+ };
2954
+ };
2955
+ const mapPayoutDetailsToTransferInstrument = ({
2956
+ data,
2957
+ legalEntity
2958
+ }) => {
2959
+ if (!data.payoutAccountDetails || !data.payoutVerificationMethod) {
2960
+ throw new Error("Missing payout details data");
2961
+ }
2962
+ return {
2963
+ bankAccount: mapPayoutAccountSchemaToApiBankAccount(
2964
+ data.payoutAccountDetails,
2965
+ data.payoutVerificationMethod.bankCountry
2966
+ ),
2967
+ legalEntityId: legalEntity.id,
2968
+ type: "bankAccount"
2969
+ };
2970
+ };
2971
+ const mapPayoutDocumentsToApiDocuments = async (data, entityId) => {
2972
+ const { bankStatementDocument, description } = data.payoutAccountDocuments ?? {};
2973
+ if (!bankStatementDocument) {
2974
+ throw new Error("Bank statement document missing");
2975
+ }
2976
+ const page1 = bankStatementDocument[0];
2977
+ if (!page1) {
2978
+ throw new Error("Document needs at least one page");
2979
+ }
2980
+ const existingDocument = getDocument(entityId, "bankStatement");
2981
+ return await createDocumentRequest({
2982
+ entityId,
2983
+ entityType: "bankAccount",
2984
+ documentType: "bankStatement",
2985
+ page1,
2986
+ description,
2987
+ existingDocument
2988
+ });
2989
+ };
2990
+ const CUSTOM_LABELS = {
2991
+ verifiedAccountHolder: "accountHolder",
2992
+ verifiedBankCountry: "bankCountry",
2993
+ verifiedBankName: "bankName",
2994
+ verifiedCurrencyCode: "currencyCode",
2995
+ verifiedBankAccountNumber: "bankAccountNumber"
2996
+ };
2997
+ const formatAccountVerificationSummary = (data) => {
2998
+ if (!data) return {};
2999
+ const summary = {};
3000
+ keysOf(CUSTOM_LABELS).forEach((key) => {
3001
+ if (!data[key]) return;
3002
+ summary[key] = summaryItem(CUSTOM_LABELS[key], data[key]);
3003
+ });
3004
+ return summary;
3005
+ };
3006
+ const obscuredPayoutFields = ["bankAccountNumber", "iban"];
3007
+ const payoutDetailsCountryConfig = {
3008
+ [CountryCodes.Canada]: {
3009
+ bankStatementDocument: {
3010
+ label: "listitemVoidedChequeBankLetterBankStatementOnline"
3011
+ }
3012
+ },
3013
+ [CountryCodes.UnitedKingdom]: {
3014
+ bankCity: {
3015
+ label: "bankCityTown"
3016
+ },
3017
+ bankStatementDocument: {
3018
+ label: "listitemVoidedChequeBankLetterBankStatementOnline"
3019
+ }
3020
+ }
3021
+ };
3022
+ const parseConfiguration = ({
3023
+ requiredFields,
3024
+ country,
3025
+ bankVerificationAvailable
3026
+ }) => parsePayoutScenarios({
3027
+ requiredFields: requiredFields?.fields,
3028
+ country,
3029
+ bankVerificationAvailable
3030
+ });
3031
+ function parsePayoutScenarios({
3032
+ requiredFields,
3033
+ country,
3034
+ bankVerificationAvailable
3035
+ }) {
3036
+ if (!requiredFields) return {};
3037
+ let formConfig = {
3038
+ payoutVerificationMethod: {
3039
+ rule: "REQUIRED"
3040
+ },
3041
+ bankCountry: {
3042
+ rule: "REQUIRED"
3043
+ },
3044
+ bankStatementDocument: {
3045
+ rule: "bankStatementRequirement"
3046
+ },
3047
+ description: {
3048
+ rule: "bankStatementDescription"
3049
+ }
3050
+ };
3051
+ requiredFields.forEach((fieldName) => {
3052
+ formConfig[fieldName] = {
3053
+ rule: bankVerificationAvailable ? "whenUsingManualVerification" : "REQUIRED",
3054
+ obscured: obscuredPayoutFields.includes(fieldName)
3055
+ };
3056
+ });
3057
+ if (bankVerificationAvailable) {
3058
+ formConfig = {
3059
+ ...formConfig,
3060
+ verifiedAccountHolder: {
3061
+ rule: "whenUsingInstantVerification"
3062
+ },
3063
+ verifiedBankCountry: {
3064
+ rule: "whenUsingInstantVerification"
3065
+ },
3066
+ verifiedBankName: {
3067
+ rule: "whenUsingInstantVerification"
3068
+ },
3069
+ verifiedCurrencyCode: {
3070
+ rule: "whenUsingInstantVerification"
3071
+ },
3072
+ verifiedBankAccountNumber: {
3073
+ rule: "whenUsingInstantVerification"
3074
+ }
3075
+ };
3076
+ }
3077
+ return augmentWithCountryConfigs(payoutDetailsCountryConfig[country], formConfig);
3078
+ }
3079
+ const getAppropriatePayoutDetailsSteps = (isEditing, instantVerificationAvailable, canChangeCountry) => {
3080
+ const dependentSteps = {
3081
+ payoutAccountDetails: payoutSteps.payoutAccountDetails,
3082
+ payoutAccountDocuments: payoutSteps.payoutAccountDocuments,
3083
+ payoutAccountVerification: payoutSteps.payoutAccountVerification
3084
+ };
3085
+ if (!isEditing && (instantVerificationAvailable || canChangeCountry)) {
3086
+ return {
3087
+ payoutVerificationMethod: payoutSteps.payoutVerificationMethod,
3088
+ ...dependentSteps
3089
+ };
3090
+ }
3091
+ return dependentSteps;
3092
+ };
3093
+ const getInvalidFieldsErrorHeader = (invalidField) => {
3094
+ switch (invalidField) {
3095
+ case "LEGAL_BUSINESS_NAME":
3096
+ case "FIRST_NAME":
3097
+ case "LAST_NAME":
3098
+ return "caasBankAccountHolderDoesNotMatch";
3099
+ default:
3100
+ return "weCouldntCompleteTheAccountCheck";
3101
+ }
3102
+ };
3103
+ const getInvalidFieldsErrorContent = (invalidField) => {
3104
+ switch (invalidField) {
3105
+ case "LEGAL_BUSINESS_NAME":
3106
+ return "caasBankAccountMustBeInYourNameYourBusinessLegalNameOrDoingBusinessAs";
3107
+ case "FIRST_NAME":
3108
+ case "LAST_NAME":
3109
+ return "caasBankAccountMustBeInYourName";
3110
+ default:
3111
+ return "weCouldntCompleteTheAccountCheck";
3112
+ }
3113
+ };
3114
+ const defaultInvalidErrorMessage = {
3115
+ header: "weCouldntCompleteTheAccountCheck",
3116
+ content: "weCouldntCompleteTheAccountCheck"
3117
+ };
3118
+ const getInvalidFieldsErrorMessage = (errors) => {
3119
+ if (!errors || errors.length === 0) {
3120
+ return defaultInvalidErrorMessage;
3121
+ }
3122
+ const [firstError] = errors;
3123
+ const { invalidFields } = firstError;
3124
+ if (!invalidFields || invalidFields.length === 0) {
3125
+ return defaultInvalidErrorMessage;
3126
+ }
3127
+ const [firstInvalidField] = invalidFields;
3128
+ return {
3129
+ header: getInvalidFieldsErrorHeader(firstInvalidField),
3130
+ content: getInvalidFieldsErrorContent(firstInvalidField)
3131
+ };
3132
+ };
3133
+ const getPayoutVerificationMethod = (transferInstrument, instantVerificationEnabled, enabledUnbiasedVerificationMethod) => {
3134
+ if (transferInstrument) {
3135
+ return "manualVerification";
3136
+ } else {
3137
+ return enabledUnbiasedVerificationMethod || !instantVerificationEnabled ? void 0 : "instantVerification";
3138
+ }
3139
+ };
3140
+ function PayoutDetailsDropin({
3141
+ legalEntityResponse,
3142
+ associatedLegalArrangement,
3143
+ problems: propProblems,
3144
+ onSubmit: externalOnSubmit,
3145
+ onChange,
3146
+ asModal = false,
3147
+ handleCloseClick,
3148
+ taskType: propTaskType,
3149
+ handleHomeClick,
3150
+ currentTransferInstrumentId,
3151
+ setCurrentTransferInstrumentId,
3152
+ navigateBackToTaskList,
3153
+ handleBackClick: externalBackClick,
3154
+ hideSidebar,
3155
+ openBankingPartnerConfigId
3156
+ }) {
3157
+ const { baseUrl, rootLegalEntityId } = useApiContext();
3158
+ const {
3159
+ data: transferInstrument,
3160
+ refetch: refetchTransferInstrument,
3161
+ isLoading: isTransferInstrumentLoading
3162
+ } = useTransferInstrument(currentTransferInstrumentId ?? skipToken);
3163
+ const { mutateAsync: handleUpdateTransferInstrument } = useUpdateTransferInstrument();
3164
+ const {
3165
+ mutateAsync: handleCreateTrustedTransferInstrument,
3166
+ status: createTrustedTransferInstrumentStatus
3167
+ } = useCreateTrustedTransferInstrument();
3168
+ const [previousTrustedInstrumentStatus, setPreviousTrustedInstrumentStatus] = useState(
3169
+ createTrustedTransferInstrumentStatus
3170
+ );
3171
+ const { t, i18n: i18next } = useTranslation("common");
3172
+ const { i18n } = useI18nContext();
3173
+ const userEvents = useAnalyticsContext();
3174
+ const { showToast, clearToasts } = useToastContext();
3175
+ const { isExperimentEnabled } = useExperimentsContext();
3176
+ const { isSettingEnabled } = useSettingsContext();
3177
+ const defaultPayoutCountry = getLegalEntityCountry(legalEntityResponse);
3178
+ const existingPayoutDetails = useMemo(
3179
+ () => transferInstrument ? mapTransferInstrumentToPayoutAccount(transferInstrument) : void 0,
3180
+ [transferInstrument]
3181
+ );
3182
+ const [documents, setDocuments] = useState();
3183
+ const [isCaasCalled, setIsCaasCalled] = useState(false);
3184
+ const enableCheckOnCreateBankAccount = isExperimentEnabled("EnableCheckOnCreateBankAccount") || isExperimentEnabled("BankVerificationFlowOptimization_CAASIntegration");
3185
+ const enabledUnbiasedVerificationMethod = isExperimentEnabled(
3186
+ "BankVerificationMethodAutonomy_UnbiasedSelection"
3187
+ );
3188
+ const accountHolder = getPayoutAccountHolderName(legalEntityResponse, t);
3189
+ const fallbackCurrency = currencyByCountry[defaultPayoutCountry]?.[0];
3190
+ const accountHolderName = accountHolder || getLegalEntityNameBasedOnType(legalEntityResponse);
3191
+ const instantVerificationEnabled = Boolean(
3192
+ !isTransferInstrumentLoading && !transferInstrument && isSettingEnabled("instantBankVerification")
3193
+ );
3194
+ const taskType = propTaskType ?? TaskTypes.PAYOUT;
3195
+ const [trustedTransferInstrumentId, setTrustedTransferInstrumentId] = useState();
3196
+ const prefilledData = {
3197
+ payoutAccountDetails: {
3198
+ accountHolder: accountHolderName,
3199
+ currency: fallbackCurrency,
3200
+ ...existingPayoutDetails?.payoutAccountDetails
3201
+ },
3202
+ payoutVerificationMethod: {
3203
+ payoutVerificationMethod: getPayoutVerificationMethod(
3204
+ transferInstrument,
3205
+ instantVerificationEnabled,
3206
+ enabledUnbiasedVerificationMethod
3207
+ ),
3208
+ bankCountry: defaultPayoutCountry,
3209
+ ...existingPayoutDetails?.payoutVerificationMethod
3210
+ },
3211
+ payoutAccountVerification: {
3212
+ verifiedAccountHolder: accountHolderName,
3213
+ verifiedBankCountry: defaultPayoutCountry,
3214
+ ...existingPayoutDetails?.payoutAccountVerification
3215
+ }
3216
+ };
3217
+ const documentUtils = documentApiUtils({
3218
+ baseUrl: baseUrl.value,
3219
+ rootLegalEntityId: rootLegalEntityId.value
3220
+ });
3221
+ const {
3222
+ state: { currentState }
3223
+ } = useStateContext();
3224
+ const formValidity = currentState.validityByForm;
3225
+ const bankAccountCountry = currentState?.data?.payoutVerificationMethod?.bankCountry ?? defaultPayoutCountry;
3226
+ const [hideFooterAndSidebar, setHideFooterAndSidebar] = useState(false);
3227
+ const [skipSubmit, setSkipSubmit] = useState(false);
3228
+ const [loadingStatus, setLoadingStatus] = useState("loading");
3229
+ const [isSubmitting, setIsSubmitting] = useState(false);
3230
+ const [configurationLoadingStatus, setConfigurationLoadingStatus] = useState("loading");
3231
+ const [data, setData] = useState(prefilledData);
3232
+ const [problems, setProblems] = useState(
3233
+ propProblems || (transferInstrument?.id ? getCapabilityProblems(legalEntityResponse, bankAccountCountry)?.BankAccount?.[transferInstrument.id] : void 0)
3234
+ );
3235
+ const [accountDetailsFromInput, setAccountDetailsFromInput] = useState(
3236
+ prefilledData.payoutAccountDetails
3237
+ );
3238
+ const isMaskedBankAccountNumber = data.payoutAccountDetails?.bankAccountNumber?.includes("*") || data.payoutAccountDetails?.iban?.includes("*");
3239
+ const existingBankAccountFormat = transferInstrument ? existingPayoutDetails?.payoutAccountDetails?.iban ? "iban" : "local" : void 0;
3240
+ const checkAsAServiceAnalyticsProps = {
3241
+ "Experiment name": ExperimentNames.BankVerificationFlowOptimization_CAASIntegration,
3242
+ "Experiment value": enableCheckOnCreateBankAccount ? "TREATMENT" : "CONTROL"
3243
+ };
3244
+ useEffect(() => {
3245
+ userEvents.updateBaseTrackingPayload({ task: taskType });
3246
+ userEvents.addTaskEvent("Landed on page", {
3247
+ actionType: "start",
3248
+ ...checkAsAServiceAnalyticsProps
3249
+ });
3250
+ }, []);
3251
+ useEffect(() => {
3252
+ setData({
3253
+ ...currentState.data,
3254
+ payoutAccountDetails: {
3255
+ ...currentState.data?.payoutAccountDetails,
3256
+ currency: currencyByCountry[bankAccountCountry]?.[0]
3257
+ }
3258
+ });
3259
+ onChange?.(currentState);
3260
+ }, [bankAccountCountry, currentState, onChange]);
3261
+ const {
3262
+ data: providers,
3263
+ refetch: refetchBankVerificationProviders,
3264
+ status: bankVendorsLoadingStatus
3265
+ } = useBankVerificationProviders(
3266
+ {
3267
+ country: bankAccountCountry,
3268
+ configId: openBankingPartnerConfigId,
3269
+ locale: i18next.language
3270
+ },
3271
+ {
3272
+ enabled: instantVerificationEnabled
3273
+ }
3274
+ );
3275
+ const instantVerificationAvailable = useMemo(
3276
+ () => Boolean(instantVerificationEnabled && providers?.[0]?.redirectUrl),
3277
+ [instantVerificationEnabled, providers]
3278
+ );
3279
+ const getPayoutAccountFormatData = useCallback(
3280
+ async () => getAccountFormatsForCountry(bankAccountCountry),
3281
+ [bankAccountCountry]
3282
+ );
3283
+ const { fieldConfigurations, requiredFields } = useScenarioConfiguration({
3284
+ parseConfiguration,
3285
+ legalEntityType: legalEntityResponse.type,
3286
+ getPayoutAccountFormatData,
3287
+ instantVerificationAvailable,
3288
+ setLoadingStatus: setConfigurationLoadingStatus,
3289
+ country: bankAccountCountry,
3290
+ existingBankAccountFormat
3291
+ });
3292
+ const fieldsFromCustomRules = useMemo(
3293
+ () => rules({
3294
+ data,
3295
+ requiredFields,
3296
+ isExperimentEnabled
3297
+ }),
3298
+ [bankAccountCountry, data, taskType, isExperimentEnabled]
3299
+ );
3300
+ const apiBankAccount = useMemo(() => {
3301
+ const payoutAccountDetails = data.payoutAccountDetails ?? { bankAccountNumber: "" };
3302
+ return mapPayoutAccountSchemaToApiBankAccount(payoutAccountDetails, bankAccountCountry);
3303
+ }, [data, bankAccountCountry]);
3304
+ const {
3305
+ data: checkAsAServiceData,
3306
+ refetch: refetchCheckAsAService,
3307
+ isLoading: isCheckAsAServiceLoading,
3308
+ isError: isCheckAsAServiceError
3309
+ } = useCheck(apiBankAccount.accountIdentification, {
3310
+ enabled: false
3311
+ });
3312
+ const checkAsAServiceResultStatus = checkAsAServiceData?.status;
3313
+ const checkAsAServiceResultErrors = checkAsAServiceData?.errors;
3314
+ const [isModalOpen, setIsModalOpen] = useState(false);
3315
+ const payoutDetailsSteps = useMemo(() => {
3316
+ const appropriatePayoutDetailsSteps = getAppropriatePayoutDetailsSteps(
3317
+ Boolean(prefilledData?.payoutAccountDetails?.transferInstrumentId),
3318
+ instantVerificationAvailable,
3319
+ isSettingEnabled(SettingNames.AllowIntraRegionCrossBorderPayout)
3320
+ );
3321
+ const { payoutAccountDocuments: _, ...restOfAppropriatePayoutDetailsSteps } = appropriatePayoutDetailsSteps;
3322
+ if (enableCheckOnCreateBankAccount && !isCheckAsAServiceError && (checkAsAServiceResultStatus === "VALID" || checkAsAServiceResultStatus === void 0) && !isMaskedBankAccountNumber) {
3323
+ return restOfAppropriatePayoutDetailsSteps;
3324
+ }
3325
+ return appropriatePayoutDetailsSteps;
3326
+ }, [
3327
+ providers,
3328
+ enableCheckOnCreateBankAccount,
3329
+ checkAsAServiceResultStatus,
3330
+ isCheckAsAServiceError,
3331
+ isMaskedBankAccountNumber
3332
+ ]);
3333
+ const derivedProps = useMemo(() => {
3334
+ return getPropsFromConfigurations({
3335
+ scenarioConfiguration: fieldConfigurations,
3336
+ forms: payoutDetailsSteps,
3337
+ remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
3338
+ dataMissingErrors: problems?.missingData ?? [],
3339
+ fieldsWithExistingData: [],
3340
+ customRules: fieldsFromCustomRules,
3341
+ legalEntityType: legalEntityResponse.type
3342
+ });
3343
+ }, [
3344
+ fieldConfigurations,
3345
+ payoutDetailsSteps,
3346
+ problems?.remediationActions,
3347
+ problems?.missingData,
3348
+ fieldsFromCustomRules,
3349
+ legalEntityResponse.type
3350
+ ]);
3351
+ useUnifyLoadingStatus(
3352
+ setLoadingStatus,
3353
+ configurationLoadingStatus,
3354
+ // bank vendor loading status only matters when we fetch bank vendors
3355
+ instantVerificationEnabled ? bankVendorsLoadingStatus : "success",
3356
+ isSubmitting ? "loading" : "success"
3357
+ );
3358
+ const forms = useMemo(() => {
3359
+ const requiredForms = getRequiredForms(
3360
+ payoutDetailsSteps,
3361
+ derivedProps?.requiredFields,
3362
+ derivedProps?.optionalFields
3363
+ );
3364
+ return addValidityToForms(requiredForms, formValidity, problems);
3365
+ }, [derivedProps, formValidity, problems, payoutDetailsSteps]);
3366
+ useEffect(() => {
3367
+ if (!transferInstrument?.documentDetails?.length) return;
3368
+ if (transferInstrument.id) {
3369
+ documentUtils.fetchDocuments(transferInstrument.documentDetails, transferInstrument.id).then(() => {
3370
+ setDocuments(mapApiDocumentToPayoutDocuments(transferInstrument.id));
3371
+ }).catch(() => {
3372
+ showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
3373
+ });
3374
+ }
3375
+ }, [transferInstrument?.documentDetails]);
3376
+ const submitDocuments = async ({
3377
+ forms: forms2,
3378
+ transferInstrument: transferInstrument2,
3379
+ dataSubmitted
3380
+ }) => {
3381
+ const isRequiredDocuments = isDocumentsRequired(forms2);
3382
+ if (isRequiredDocuments) {
3383
+ const documentToUpload = await mapPayoutDocumentsToApiDocuments(
3384
+ dataSubmitted,
3385
+ transferInstrument2.id
3386
+ );
3387
+ if (documentToUpload) {
3388
+ try {
3389
+ const documents2 = await documentUtils.uploadDocuments(
3390
+ [documentToUpload],
3391
+ transferInstrument2.id
3392
+ );
3393
+ documents2.forEach((document2) => {
3394
+ userEvents.addTaskEvent("Success", {
3395
+ actionType: "upload",
3396
+ documentType: dataSubmitted.payoutAccountDocuments?.documentType ?? document2.type,
3397
+ // tracks BankDocumentTypes
3398
+ fileExtention: document2.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? null
3399
+ });
3400
+ });
3401
+ } catch {
3402
+ setProblems({
3403
+ ...problems,
3404
+ validationErrors: {
3405
+ payoutAccountDocuments: { bankStatementDocument: true }
3406
+ }
3407
+ });
3408
+ throw new Error(i18n.get("remediationMessage_1_704"));
3409
+ } finally {
3410
+ await refetchTransferInstrument?.();
3411
+ }
3412
+ }
3413
+ }
3414
+ };
3415
+ useEffect(() => {
3416
+ const payoutAccountData = cloneObject(data)?.payoutAccountDetails;
3417
+ if (payoutAccountData) setAccountDetailsFromInput(payoutAccountData);
3418
+ }, [data]);
3419
+ const onSubmit = async () => {
3420
+ setIsSubmitting(true);
3421
+ const dataSubmitted = cloneObject(data);
3422
+ const { payoutAccountDetails, payoutVerificationMethod } = dataSubmitted;
3423
+ const baseTracking = {
3424
+ actionType: "submit",
3425
+ documentType: "bankStatement",
3426
+ bankCountry: payoutVerificationMethod?.bankCountry ?? defaultPayoutCountry,
3427
+ bankCurrency: payoutAccountDetails?.currency ?? null
3428
+ };
3429
+ let transferInstrumentFromInput = mapPayoutDetailsToTransferInstrument({
3430
+ data: dataSubmitted,
3431
+ legalEntity: legalEntityResponse
3432
+ });
3433
+ transferInstrumentFromInput = omitObscuredFieldsIfUnchanged(
3434
+ ["bankAccount.accountIdentification.accountNumber", "bankAccount.accountIdentification.iban"],
3435
+ transferInstrumentFromInput,
3436
+ transferInstrument
3437
+ );
3438
+ try {
3439
+ if (!transferInstrumentFromInput) return;
3440
+ const response = await (transferInstrument ? handleUpdateTransferInstrument({
3441
+ transferInstrument: transferInstrumentFromInput,
3442
+ transferInstrumentId: transferInstrument.id
3443
+ }) : createTransferInstrument(
3444
+ rootLegalEntityId.value,
3445
+ baseUrl.value,
3446
+ transferInstrumentFromInput
3447
+ ));
3448
+ setCurrentTransferInstrumentId?.(response?.id);
3449
+ userEvents.addTaskEvent("Success", {
3450
+ ...baseTracking,
3451
+ ...checkAsAServiceAnalyticsProps
3452
+ });
3453
+ try {
3454
+ await submitDocuments({ forms, transferInstrument: response, dataSubmitted });
3455
+ clearToasts();
3456
+ externalOnSubmit?.({ ...dataSubmitted, id: response?.id });
3457
+ } catch (e) {
3458
+ showToast({ label: e.message, variant: "error" });
3459
+ } finally {
3460
+ setIsSubmitting(false);
3461
+ }
3462
+ } catch (e) {
3463
+ if (isValidationError(e)) {
3464
+ const validationErrors = processValidationErrors(e, taskType);
3465
+ setProblems({ ...problems, validationErrors });
3466
+ } else if (isIdDocumentUploadError(e)) {
3467
+ showToast({ label: i18n.get("idDocumentAlreadyUploaded"), variant: "error" });
3468
+ } else if (isBankStatementUploadError(e)) {
3469
+ showToast({ label: i18n.get("bankStatementAlreadyUploaded"), variant: "error" });
3470
+ } else if (isMaintenanceModeError(e)) {
3471
+ showToast({
3472
+ label: i18n.get("maintenanceModeMessage"),
3473
+ variant: "error",
3474
+ duration: "indefinite"
3475
+ });
3476
+ } else {
3477
+ const errorTranslatable = mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable(e);
3478
+ showToast({ label: i18n.get(errorTranslatable), variant: "error" });
3479
+ }
3480
+ setIsSubmitting(false);
3481
+ userEvents.addTaskEvent("Encountered error", {
3482
+ ...baseTracking,
3483
+ returnType: e?.errorCode || "backend",
3484
+ returnValue: e?.title || e?.message,
3485
+ ...checkAsAServiceAnalyticsProps
3486
+ });
3487
+ }
3488
+ };
3489
+ const isDocumentsRequired = (forms2) => forms2.some((form) => form.formId === payoutSteps.payoutAccountDocuments.formId);
3490
+ const formatFileSummaryData = (bankDocuments) => {
3491
+ const bankStatementDocument = bankDocuments?.bankStatementDocument?.[0];
3492
+ return {
3493
+ ...bankStatementDocument && {
3494
+ fileName: bankStatementDocument.name
3495
+ }
3496
+ };
3497
+ };
3498
+ const canSubmit = () => {
3499
+ if (data.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification") {
3500
+ return false;
3501
+ }
3502
+ const bankDetails = data.payoutAccountDetails;
3503
+ return !isEmpty(bankDetails) && Object.values(bankDetails).every(Boolean);
3504
+ };
3505
+ const datasetUtils = datasetUtilities(i18next.language);
3506
+ const formatDataForSummary = () => {
3507
+ const summaryData = cloneObject(data);
3508
+ summaryData.payoutAccountDetails.accountHolder = accountHolderName;
3509
+ if (summaryData.payoutVerificationMethod?.bankCountry && summaryData.payoutAccountDetails) {
3510
+ summaryData.payoutAccountDetails.bankCountry = datasetUtils.getCountryName(
3511
+ summaryData.payoutVerificationMethod.bankCountry
3512
+ );
3513
+ }
3514
+ if (summaryData.payoutAccountDocuments) {
3515
+ summaryData.payoutAccountDocuments.bankStatementDocument = formatFileSummaryData(
3516
+ data?.payoutAccountDocuments
3517
+ );
3518
+ }
3519
+ summaryData.payoutAccountVerification = formatAccountVerificationSummary(
3520
+ data.payoutAccountVerification
3521
+ );
3522
+ return summaryData;
3523
+ };
3524
+ const createTrustedTransferInstrumentHandler = async (code, state) => {
3525
+ try {
3526
+ const trustedTransferInstrument = await handleCreateTrustedTransferInstrument({
3527
+ code,
3528
+ state
3529
+ });
3530
+ if (trustedTransferInstrument) {
3531
+ setTrustedTransferInstrumentId(trustedTransferInstrument.verificationReference);
3532
+ return trustedTransferInstrument;
3533
+ }
3534
+ } catch (e) {
3535
+ refetchBankVerificationProviders();
3536
+ const errorTranslatable = mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable(e);
3537
+ if (errorTranslatable === "transferInstrumentLimitHasAlreadyBeenMet") {
3538
+ showToast({ label: i18n.get(errorTranslatable), variant: "error" });
3539
+ }
3540
+ throw e;
3541
+ }
3542
+ };
3543
+ const {
3544
+ handleNextClick,
3545
+ handleBackClick,
3546
+ activeForm,
3547
+ setShouldValidate,
3548
+ gotoFormByFormIndex,
3549
+ steps
3550
+ } = useFormComposer({
3551
+ problems,
3552
+ forms,
3553
+ externalBackClick,
3554
+ navigationTrackingParams: {
3555
+ ...checkAsAServiceAnalyticsProps
3556
+ },
3557
+ onSubmit: skipSubmit ? () => {
3558
+ if (trustedTransferInstrumentId) {
3559
+ externalOnSubmit?.({ ...data, id: trustedTransferInstrumentId });
3560
+ }
3561
+ userEvents.addTaskEvent("Success", {
3562
+ actionType: "submit"
3563
+ });
3564
+ navigateBackToTaskList?.();
3565
+ } : onSubmit
3566
+ });
3567
+ useEffect(() => {
3568
+ if (isCaasCalled && forms) {
3569
+ if (checkAsAServiceResultStatus !== "VALID") {
3570
+ const formIndex = forms.findIndex((f) => f.formId === "payoutAccountDocuments");
3571
+ if (formIndex > -1) {
3572
+ gotoFormByFormIndex(formIndex);
3573
+ }
3574
+ }
3575
+ if (checkAsAServiceResultStatus === "VALID") {
3576
+ handleNextClick();
3577
+ }
3578
+ }
3579
+ setIsCaasCalled(false);
3580
+ }, [forms, checkAsAServiceResultStatus, isCaasCalled]);
3581
+ const handleFormNextClick = async () => {
3582
+ if (!data?.payoutVerificationMethod?.payoutVerificationMethod) {
3583
+ showPayoutVerificationMethodError.value = true;
3584
+ return;
3585
+ }
3586
+ if (enableCheckOnCreateBankAccount && activeForm.formId === "payoutAccountDetails" && activeForm.isValid && data.payoutAccountDetails && !isMaskedBankAccountNumber) {
3587
+ try {
3588
+ const { data: response } = await refetchCheckAsAService();
3589
+ setIsCaasCalled(true);
3590
+ if (response?.status === "INCOMPLETE_INPUT") {
3591
+ setIsModalOpen(true);
3592
+ } else {
3593
+ handleNextClick();
3594
+ }
3595
+ } catch {
3596
+ handleNextClick();
3597
+ }
3598
+ } else {
3599
+ handleNextClick();
3600
+ }
3601
+ };
3602
+ if (previousTrustedInstrumentStatus !== createTrustedTransferInstrumentStatus) {
3603
+ if (activeForm.formId === "payoutAccountVerification" && activeForm.isValid && createTrustedTransferInstrumentStatus === "success" && data.payoutAccountVerification?.verifiedBankAccountNumber) {
3604
+ handleNextClick();
3605
+ setPreviousTrustedInstrumentStatus(createTrustedTransferInstrumentStatus);
3606
+ }
3607
+ }
3608
+ const omittedForms = data?.payoutVerificationMethod?.payoutVerificationMethod === "instantVerification" ? [] : [payoutSteps.payoutVerificationMethod.formId];
3609
+ const { header: invalidFieldHeader, content: invalidFieldContent } = getInvalidFieldsErrorMessage(
3610
+ checkAsAServiceResultErrors ?? []
3611
+ );
3612
+ return /* @__PURE__ */ jsxs(
3613
+ LoaderWrapper,
3614
+ {
3615
+ showSpinner: true,
3616
+ status: isCheckAsAServiceLoading || isModalOpen ? "loading" : "success",
3617
+ formOpacityWhenLoading: 0.3,
3618
+ children: [
3619
+ isModalOpen && /* @__PURE__ */ jsx(
3620
+ Confirm,
3621
+ {
3622
+ title: i18n.get(invalidFieldHeader),
3623
+ description: i18n.get(invalidFieldContent),
3624
+ cancelText: i18n.get("editDetails"),
3625
+ confirmText: i18n.get("continueAnyway"),
3626
+ onConfirm: () => {
3627
+ handleNextClick();
3628
+ setIsModalOpen(false);
3629
+ },
3630
+ onCancel: () => {
3631
+ gotoFormByFormIndex(0);
3632
+ setIsModalOpen(false);
3633
+ }
3634
+ }
3635
+ ),
3636
+ /* @__PURE__ */ jsx(
3637
+ FormWrapper,
3638
+ {
3639
+ taskName: taskType === TaskTypes.PAYIN ? "payinDetails" : "payoutDetails",
3640
+ activeForm,
3641
+ summary: {
3642
+ data: formatDataForSummary(),
3643
+ omitted: {
3644
+ keys: ["transferInstrumentId", "payoutVerificationMethod"],
3645
+ forms: omittedForms,
3646
+ summaryEditButton: ["payoutVerificationMethod"]
3647
+ }
3648
+ },
3649
+ handleBackClick,
3650
+ handleNextClick: handleFormNextClick,
3651
+ handleHomeClick,
3652
+ handleCloseClick,
3653
+ hideSidebar: hideSidebar || hideFooterAndSidebar,
3654
+ hideFooter: hideFooterAndSidebar,
3655
+ loadingStatus: isTransferInstrumentLoading ? "loading" : loadingStatus,
3656
+ asModal,
3657
+ forms,
3658
+ onSubmit,
3659
+ gotoFormByFormIndex,
3660
+ validateForm: () => setShouldValidate(true),
3661
+ canSubmit: canSubmit(),
3662
+ problems,
3663
+ steps,
3664
+ children: (!isTransferInstrumentLoading || isSubmitting) && /* @__PURE__ */ jsx(
3665
+ PayoutDetails,
3666
+ {
3667
+ ...derivedProps,
3668
+ data: { ...prefilledData, payoutAccountDocuments: documents },
3669
+ country: defaultPayoutCountry,
3670
+ activeForm,
3671
+ onBack: handleBackClick,
3672
+ accountHolder: accountHolder ?? getLegalEntityNameBasedOnType(legalEntityResponse),
3673
+ setHideSidebar: setHideFooterAndSidebar,
3674
+ setSkipSubmit,
3675
+ legalEntityResponse,
3676
+ associatedLegalArrangement,
3677
+ provider: providers?.[0],
3678
+ bankVendorsLoadingStatus,
3679
+ instantVerificationAvailable,
3680
+ createTrustedTransferInstrument: createTrustedTransferInstrumentHandler,
3681
+ accountDetailsFromInput,
3682
+ trustedTransferInstrumentId
3683
+ }
3684
+ )
3685
+ }
3686
+ )
3687
+ ]
3688
+ }
3689
+ );
3690
+ }
3691
+ export {
3692
+ PayoutDetailsDropin as P,
3693
+ PayoutDetailsPage$1 as a
3694
+ };