@adyen/kyc-components 3.85.0 → 3.86.0-beta.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 (398) hide show
  1. package/dist/{AcceptTermsOfServiceComponent-DWt6MA7A.js → AcceptTermsOfServiceComponent-DzMlzUjz.js} +16 -17
  2. package/dist/{Accordion-DQSd9JrF.js → Accordion-ZHPTn2Gl.js} +2 -2
  3. package/dist/{AccountSetupRejected-Y2jV7DOd.js → AccountSetupRejected-DON-7H74.js} +4 -4
  4. package/dist/{Address-CN31gTRW.js → Address-ChPj2pfR.js} +337 -22
  5. package/dist/{Alert-B2qwr9au.js → Alert-CeZqoFeT.js} +3 -3
  6. package/dist/{Avatar-CrL6cVDB.js → Avatar-zXT7v3KF.js} +2 -2
  7. package/dist/{BusinessDetailsMultiformDropin-BB1mTi0Z.js → BusinessDetailsMultiformDropin-DKiYg8gJ.js} +89 -3112
  8. package/dist/{BusinessFinancingComponent-BevBrUTE.js → BusinessFinancingComponent-BRziB5i-.js} +6 -6
  9. package/dist/{BusinessFinancingDropin-BgU5hfv0.js → BusinessFinancingDropin-CUmKL5bO.js} +21 -38
  10. package/dist/{BusinessFinancingPage-u2Xu42u-.js → BusinessFinancingPage-DhhnCxFQ.js} +4 -4
  11. package/dist/{BusinessTypeSelectionPage-BNxEzkjO.js → BusinessTypeSelectionPage-B_dVM7cC.js} +9 -8
  12. package/dist/Card-Bz2B4J0v.js +82 -0
  13. package/dist/ConstitutionalDocument-Dt9O9bVo.js +143 -0
  14. package/dist/{CountryField-CFppUh42.js → CountryField-Bv9P8dRJ.js} +110 -78
  15. package/dist/CreateIndividualComponent-Mw4AiW_M.js +71 -0
  16. package/dist/CreateTransferInstrumentComponent-usUQlcH_.js +66 -0
  17. package/dist/{Currency-Zz8j3LFf.js → Currency-SzvigNNo.js} +8 -63
  18. package/dist/{CustomerSupport-CkqG00fn.js → CustomerSupport-C_KLB51k.js} +21 -9
  19. package/dist/{DebugModal-Cxp_Lbjk.js → DebugModal-DYolUZQS.js} +9 -9
  20. package/dist/{DecisionMakerDetailsPage-kpoxsSYP.js → DecisionMakerDetailsPage-C2BzKLSi.js} +7 -7
  21. package/dist/{DecisionMakers-DMboYynJ.js → DecisionMakers-DTYzQWdY.js} +18 -20
  22. package/dist/{EmbeddedStatus-DdZv9Kwp.js → EmbeddedStatus-jepajhAF.js} +3 -3
  23. package/dist/{EndStateLayout-Cswr0wiZ.js → EndStateLayout-DQm7Xrqx.js} +2 -2
  24. package/dist/{useFormContext-DrrsFJH7.js → FormFlow-A9b0QEcM.js} +10 -16
  25. package/dist/{FormNavigation-DrejHtXO.js → FormNavigation-DEdNWaAc.js} +5 -5
  26. package/dist/{useGlobalData-rR_jnTzW.js → FormWrapper-DjWyqVD2.js} +12 -79
  27. package/dist/{IndividualOnfidoDropin-CydUe7_6.js → IndividualOnfido-BMIkKHvJ.js} +8187 -6328
  28. package/dist/IndividualOnfidoDropin-DBQF0Onh.js +2502 -0
  29. package/dist/{InputText-EX5kyD9L.js → InputText-BG-TiSNN.js} +4 -4
  30. package/dist/{Introduction-DncY2r7T.js → Introduction-BgoEJd8o.js} +4 -4
  31. package/dist/{JpAddress-BTfvrykR.js → JpAddress-Jxj9u4D5.js} +8 -8
  32. package/dist/{LegalRepresentativeDetailsPage-DxqaU2W7.js → LegalRepresentativeDetailsPage-BH5AnQhk.js} +5 -5
  33. package/dist/{ListItem-pn0XFAz_.js → ListItem-DIDj0vuO.js} +3 -3
  34. package/dist/{ManageIndividualComponent-CKRuUS0t.js → ManageIndividualComponent-CJKXW8rK.js} +5 -5
  35. package/dist/{ManageTermsOfServiceComponent-DDgriC3w.js → ManageTermsOfServiceComponent-DNf00D1s.js} +5 -5
  36. package/dist/{ManageTransferInstrumentComponent-BoQn6JaV.js → ManageTransferInstrumentComponent-gVWN389q.js} +14 -13
  37. package/dist/{MaybeModal-B1X7K4z1.js → MaybeModal-D51ALTH6.js} +3 -3
  38. package/dist/{Modal-ConNvgj4.js → Modal-C9aImxis.js} +2 -2
  39. package/dist/OnboardingDropinComponent-D-tQ12Sy.js +9791 -0
  40. package/dist/{PayoutDetailsDropin-CHOa81Ot.js → PayoutDetailsDropin-CxWPXV7j.js} +288 -158
  41. package/dist/{Review-BAuL4AQ-.js → Review-CRhM6n_P.js} +8 -8
  42. package/dist/RootBusinessDetailsPage-DZrT_e0g.js +61 -0
  43. package/dist/{RootBusinessLinesPage-D-YRRyIW.js → RootBusinessLinesPage-CJUpoVy5.js} +267 -144
  44. package/dist/RootIndividualDetailsPage-pqVuzOoJ.js +80 -0
  45. package/dist/{SignPCIComponent-B6FQiV5E.js → SignPCIComponent-BNbx3OzX.js} +11 -11
  46. package/dist/{SingpassSelection-DxGUYazk.js → SingpassSelection-BAa3S705.js} +4 -5
  47. package/dist/SoleProprietorshipPage-Bhw3GBKP.js +60 -0
  48. package/dist/{SourceOfFundsPage-Ce-Mim_H.js → SourceOfFundsPage-CJXpHSgo.js} +24 -29
  49. package/dist/{StepProgressIndicator-BymtNCPV.js → StepProgressIndicator-Dncrs7ra.js} +2 -2
  50. package/dist/{StoreProvider-BYjTSjnX.js → StoreProvider-CWnZNw9D.js} +427 -305
  51. package/dist/{TaskItemStatus-BholBQ7C.js → TaskItemStatus-D3ri_-L2.js} +3 -3
  52. package/dist/{TaxReportingDropin-CSa5vto5.js → TaxReportingDropin-Du7KU--L.js} +15 -17
  53. package/dist/{TrustDetailsPage-CYMeuEyr.js → TrustDetailsPage-SGmHwgzj.js} +24 -32
  54. package/dist/{TrustMemberCompanyPage-DICY9KDR.js → TrustMemberCompanyPage-BkQ9q4_T.js} +6 -6
  55. package/dist/{TrustMemberIndividualPage-DUGmI852.js → TrustMemberIndividualPage-CIr73hS-.js} +5 -5
  56. package/dist/UnincorporatedPartnershipIndividualPage-DQxHTyUp.js +65 -0
  57. package/dist/{UnincorporatedPartnershipMemberCompanyPage-CuvkBZ2N.js → UnincorporatedPartnershipMemberCompanyPage-DOWqNUHn.js} +6 -6
  58. package/dist/VerificationErrorAlert-DDsMxj76.js +79 -0
  59. package/dist/{ViewVerificationStatusComponent-zXuO8CY1.js → ViewVerificationStatusComponent-Hqp0gnec.js} +4 -4
  60. package/dist/adyen-business-financing.js +3 -3
  61. package/dist/adyen-individual-configuration.js +3 -3
  62. package/dist/adyen-individual-status.js +3 -3
  63. package/dist/adyen-kyc-components.js +20 -20
  64. package/dist/adyen-onboarding.js +2 -2
  65. package/dist/adyen-terms-of-service-management.js +3 -3
  66. package/dist/adyen-terms-of-service-status.js +3 -3
  67. package/dist/adyen-transfer-instrument-configuration.js +3 -3
  68. package/dist/adyen-transfer-instrument-management.js +3 -3
  69. package/dist/adyen-verification-status.js +3 -3
  70. package/dist/{bg-BG-fr-xfUBV.js → bg-BG-B1GR6lKu.js} +3 -1
  71. package/dist/{bg-BG-BIOMFPaW.js → bg-BG-BC1dwNN2.js} +2 -5
  72. package/dist/bg-BG-BJo9yIYj.js +13 -0
  73. package/dist/bg-BG-D8qq7TQJ.js +94 -0
  74. package/dist/bg-BG-a6CQ0hKw.js +13 -0
  75. package/dist/{bg-BG-Cs_1PU3v.js → bg-BG-e6Rs6yz_.js} +4 -1
  76. package/dist/{cs-CZ-DNWTRefA.js → cs-CZ-2foXfkBk.js} +2 -5
  77. package/dist/cs-CZ-BAr1-JAS.js +13 -0
  78. package/dist/cs-CZ-ChGeQ9s0.js +94 -0
  79. package/dist/{cs-CZ-C0sNB1Fm.js → cs-CZ-DBQXByj7.js} +3 -1
  80. package/dist/cs-CZ-LGBI1w0Z.js +13 -0
  81. package/dist/{cs-CZ-B2WAqmaW.js → cs-CZ-Q6NVYK-k.js} +4 -1
  82. package/dist/da-DK-914Viqia.js +13 -0
  83. package/dist/{da-DK-8dk9Q_Wk.js → da-DK-CjjWmhN6.js} +3 -1
  84. package/dist/da-DK-CyHH8kX3.js +94 -0
  85. package/dist/{da-DK-D-eeokQn.js → da-DK-DSYEF7Q1.js} +4 -1
  86. package/dist/{da-DK-D-PlwKvZ.js → da-DK-DU3_xdWg.js} +2 -5
  87. package/dist/da-DK-DoHb4ssx.js +13 -0
  88. package/dist/{de-DE-Dcs3W1fT.js → de-DE-B9-ILIdw.js} +4 -1
  89. package/dist/{de-DE-4GAd_srm.js → de-DE-BODG29hR.js} +2 -5
  90. package/dist/de-DE-BXKZNAA1.js +13 -0
  91. package/dist/de-DE-DL6SrIBE.js +94 -0
  92. package/dist/{de-DE-CCyKie8B.js → de-DE-DoQHxDRp.js} +3 -1
  93. package/dist/de-DE-R6YgDOo5.js +13 -0
  94. package/dist/{analytics-DkXXx2b6.js → debouncedInputEvent-B3Lwtvx_.js} +7 -21
  95. package/dist/{validate-DzaSMOa2.js → documentUtils-C2iCagu9.js} +3 -167
  96. package/dist/{dropinUtils-CCEDaAJW.js → dropinUtils-L9qJuAw0.js} +4 -20
  97. package/dist/el-GR-BnMw4HQ7.js +13 -0
  98. package/dist/{el-GR-D7zMcBtK.js → el-GR-CnoZeZlX.js} +3 -1
  99. package/dist/{el-GR-DBum-QDu.js → el-GR-DYjcbiSc.js} +4 -1
  100. package/dist/{el-GR-Ddnh0NhQ.js → el-GR-DcIdm3iK.js} +2 -5
  101. package/dist/el-GR-DgaUGjyJ.js +13 -0
  102. package/dist/el-GR-l0JeDNPy.js +94 -0
  103. package/dist/{en-US-DjF6iC7G.js → en-US-BxEW5N6f.js} +44 -5
  104. package/dist/{en-US-BwDZ0WHW.js → en-US-C5WyUweF.js} +3 -1
  105. package/dist/en-US-CTZwL084.js +13 -0
  106. package/dist/{en-US-BCFNoF5y.js → en-US-DYo4OF-P.js} +8 -7
  107. package/dist/{en-US-DdeSoN_2.js → en-US-gsp7CD_E.js} +5 -1
  108. package/dist/{es-ES-JvAvmB2A.js → es-ES-BMrse1nQ.js} +3 -1
  109. package/dist/es-ES-BWAlCq7R.js +13 -0
  110. package/dist/{es-ES-C7XjLOHi.js → es-ES-C-tTuMLH.js} +4 -1
  111. package/dist/es-ES-C1ClJ2XE.js +94 -0
  112. package/dist/{es-ES-C4lENXHH.js → es-ES-CMQqgMEJ.js} +2 -5
  113. package/dist/es-ES-dMSfTLXF.js +13 -0
  114. package/dist/{et-EE-SJf3_Ega.js → et-EE-BE8bHZns.js} +3 -1
  115. package/dist/et-EE-BG_Y29oV.js +94 -0
  116. package/dist/{et-EE-BUG05EDz.js → et-EE-BzLAp08F.js} +4 -1
  117. package/dist/et-EE-D9SV0taO.js +13 -0
  118. package/dist/{et-EE-3EQr-1cj.js → et-EE-DcpuYQwB.js} +2 -5
  119. package/dist/et-EE-l977xCZ_.js +13 -0
  120. package/dist/fi-FI-0ScajGUB.js +13 -0
  121. package/dist/{fi-FI-Byvvcxxq.js → fi-FI-4GTHkwOL.js} +2 -5
  122. package/dist/{fi-FI-Cy2hAl0B.js → fi-FI-Bmu7sndb.js} +3 -1
  123. package/dist/fi-FI-C7GrKbXx.js +13 -0
  124. package/dist/fi-FI-bIhXiQPL.js +94 -0
  125. package/dist/{fi-FI-CEzjKgiz.js → fi-FI-pyHLbmel.js} +4 -1
  126. package/dist/{MaskedInput-DB6EYmfa.js → fieldConfigurations-DVV23oeM.js} +616 -14
  127. package/dist/{fr-FR-E_UubsZ-.js → fr-FR-Ba-HRBQ7.js} +2 -5
  128. package/dist/fr-FR-Bj275MRb.js +94 -0
  129. package/dist/fr-FR-CqCcxkgA.js +13 -0
  130. package/dist/{fr-FR-DNJiLv9b.js → fr-FR-DG3tEkdN.js} +4 -1
  131. package/dist/fr-FR-o45TzYMp.js +13 -0
  132. package/dist/{fr-FR-BmW46mYd.js → fr-FR-ufKVxWpT.js} +3 -1
  133. package/dist/getFieldsWithExistingData-C6JBh3D6.js +22 -0
  134. package/dist/{getName-Dc03c4n_.js → getName-k5oRc0oZ.js} +9 -2
  135. package/dist/{hasDataChanged-CUdKM92N.js → hasDataChanged-CogwJI1I.js} +2 -2
  136. package/dist/{hr-HR-TVOgDkBf.js → hr-HR-BFx1T11G.js} +2 -5
  137. package/dist/{hr-HR-WMnlxMEY.js → hr-HR-BRFErTkv.js} +4 -1
  138. package/dist/{hr-HR-c1Si_0s4.js → hr-HR-BYXLJcPZ.js} +3 -1
  139. package/dist/hr-HR-CL0q_D2U.js +94 -0
  140. package/dist/hr-HR-CoCrArfg.js +13 -0
  141. package/dist/hr-HR-YG9hvMMj.js +13 -0
  142. package/dist/hu-HU-BrxUJuJh.js +13 -0
  143. package/dist/{hu-HU-B2nrl0pw.js → hu-HU-CJA8w351.js} +4 -1
  144. package/dist/hu-HU-DIurnBC3.js +13 -0
  145. package/dist/{hu-HU-DRONW_47.js → hu-HU-GXvzHwu9.js} +2 -5
  146. package/dist/{hu-HU-CibGC8KY.js → hu-HU-J4qBifyy.js} +3 -1
  147. package/dist/hu-HU-cLqGFTTR.js +94 -0
  148. package/dist/{iframeWidget-BWwxgbNs.js → iframeWidget-D2CKFlJk.js} +4 -4
  149. package/dist/{it-IT-BMjuva_2.js → it-IT-B_5GkLBx.js} +3 -1
  150. package/dist/{it-IT-DuBLJIdz.js → it-IT-Bw3VIHJB.js} +2 -5
  151. package/dist/it-IT-C0Qk47kh.js +94 -0
  152. package/dist/it-IT-CNS4NmYX.js +13 -0
  153. package/dist/it-IT-Cztl5jRY.js +13 -0
  154. package/dist/{it-IT-BRmX2jEi.js → it-IT-mhNjrQZn.js} +4 -1
  155. package/dist/{ja-JP-Cr_qjpZ2.js → ja-JP-BUrknIDB.js} +3 -1
  156. package/dist/{ja-JP-CCnzjx-u.js → ja-JP-BxEWI56P.js} +9 -1
  157. package/dist/{ja-JP-gRRH8Eph.js → ja-JP-CfrHlRGC.js} +4 -1
  158. package/dist/{ja-JP-CJ_j_HAA.js → ja-JP-DI7lRfpI.js} +2 -5
  159. package/dist/ja-JP-DSdZj-it.js +94 -0
  160. package/dist/ja-JP-DXkV1ta4.js +13 -0
  161. package/dist/{localizeDateString-rfEOu5f7.js → localizeDateString-ZCoTLjs1.js} +2 -2
  162. package/dist/lt-LT-BJTBEa5D.js +13 -0
  163. package/dist/lt-LT-C-dKiExL.js +94 -0
  164. package/dist/{lt-LT-BJQDUanx.js → lt-LT-C0Acftnm.js} +4 -1
  165. package/dist/lt-LT-D1viSP-v.js +13 -0
  166. package/dist/{lt-LT-DjNjg3Pl.js → lt-LT-L0wG5Pd2.js} +3 -1
  167. package/dist/{lt-LT-CBBDNCnp.js → lt-LT-ewVNPhQN.js} +2 -5
  168. package/dist/lv-LV-AkiOewnL.js +13 -0
  169. package/dist/{lv-LV-h3nTokkM.js → lv-LV-Bnq61WAt.js} +4 -1
  170. package/dist/{lv-LV-BpRfRfMz.js → lv-LV-DFvpmmGg.js} +3 -1
  171. package/dist/lv-LV-GI-ZDM0K.js +13 -0
  172. package/dist/{lv-LV-CtIe38WU.js → lv-LV-JqXvRt4T.js} +2 -5
  173. package/dist/lv-LV-UkEOuqFz.js +94 -0
  174. package/dist/{mapExistingFile-D_HVWRXe.js → mapExistingFile-txzqej6F.js} +5 -80
  175. package/dist/mapFinancialReportsToFinancialInformation-DoTIj0Q-.js +67 -0
  176. package/dist/mapJpAddressSchemaToAddressLocalizations-pPCQCgRx.js +63 -0
  177. package/dist/{mapLegalEntityToIndividualOnfidoSchema-DsQrqqP5.js → mapLegalEntityToIndividualOnfidoSchema-B8NxtO2j.js} +3 -63
  178. package/dist/{mapTransferInstrumentToPayoutAccount-MugvfqfK.js → mapTransferInstrumentToPayoutAccount-D9lyD7nx.js} +2 -2
  179. package/dist/nl-NL-B6B4Z_tr.js +13 -0
  180. package/dist/nl-NL-Cfr5hMtI.js +94 -0
  181. package/dist/{nl-NL-CE4l8R5l.js → nl-NL-DR1wVqQC.js} +2 -5
  182. package/dist/{nl-NL-oaBDOlm6.js → nl-NL-UhpFianh.js} +3 -1
  183. package/dist/nl-NL-VneIcgWO.js +13 -0
  184. package/dist/{nl-NL-YzDSCWLL.js → nl-NL-donw5yvS.js} +4 -1
  185. package/dist/no-NO-ASO8Je2l.js +94 -0
  186. package/dist/{no-NO-B1_YJlMP.js → no-NO-BZmigu6-.js} +2 -5
  187. package/dist/{no-NO-BTrfxWS7.js → no-NO-DRF-gOWI.js} +3 -1
  188. package/dist/{no-NO-Big2B13b.js → no-NO-Dev7r3VA.js} +4 -1
  189. package/dist/no-NO-Dn1LUbDp.js +13 -0
  190. package/dist/no-NO-Dqp598Ox.js +13 -0
  191. package/dist/payout-verification-instant-5u-wvFKv.js +41 -0
  192. package/dist/payout-verification-manual-BJsf7QPE.js +90 -0
  193. package/dist/{pl-PL-DGYFY42P.js → pl-PL-BKxhMICw.js} +2 -5
  194. package/dist/pl-PL-C1cP4Qpn.js +13 -0
  195. package/dist/pl-PL-CG4rvgUo.js +94 -0
  196. package/dist/{pl-PL-C72GTDxW.js → pl-PL-CHyLS1B7.js} +3 -1
  197. package/dist/{pl-PL-CL483jMb.js → pl-PL-DU_Xulyu.js} +4 -1
  198. package/dist/pl-PL-Zdh_Xu43.js +13 -0
  199. package/dist/{process-field-configurations-CiECrUSj.js → process-field-configurations-D2EUZow3.js} +3 -3
  200. package/dist/{pt-BR-CtFCi7U4.js → pt-BR-CFZE5Nop.js} +3 -1
  201. package/dist/{pt-BR-DJOzf0y2.js → pt-BR-DeXo4rsi.js} +4 -1
  202. package/dist/pt-BR-DkzLiK7Y.js +13 -0
  203. package/dist/pt-BR-DqLaaG4L.js +13 -0
  204. package/dist/pt-BR-IWTcYKu9.js +94 -0
  205. package/dist/{pt-BR-Co8OqKh-.js → pt-BR-wAIdhUru.js} +2 -5
  206. package/dist/{pt-PT-XAn7WGle.js → pt-PT-Bc9JI4eu.js} +3 -1
  207. package/dist/{pt-PT-pKLoM66X.js → pt-PT-C1qHVe7L.js} +2 -5
  208. package/dist/pt-PT-CoTUf3zo.js +13 -0
  209. package/dist/{pt-PT-B3qoJ3Fr.js → pt-PT-DkJdR6SS.js} +4 -1
  210. package/dist/pt-PT-LZZYQKaC.js +94 -0
  211. package/dist/pt-PT-uiREjC_e.js +13 -0
  212. package/dist/{resolveEnvironment-DTYC79J1.js → resolveEnvironment-CU4TOfg6.js} +3 -3
  213. package/dist/{ro-RO-Ct_BJvsc.js → ro-RO-BDjHimxe.js} +4 -1
  214. package/dist/{ro-RO-qX8X1Q1m.js → ro-RO-BFzooIri.js} +3 -1
  215. package/dist/ro-RO-C835aMET.js +13 -0
  216. package/dist/ro-RO-_HSYnLLu.js +13 -0
  217. package/dist/{ro-RO-D3rQ93wa.js → ro-RO-juw6hKRk.js} +2 -5
  218. package/dist/ro-RO-nVSeNtIQ.js +94 -0
  219. package/dist/{rules-BfrH23mO.js → rules-LaFMJfnA.js} +4 -5
  220. package/dist/{sk-SK-CmH1I1tp.js → sk-SK-BM57awWi.js} +2 -5
  221. package/dist/sk-SK-BX0wsQH4.js +94 -0
  222. package/dist/sk-SK-D6KtBU3q.js +13 -0
  223. package/dist/{sk-SK-CjdK4BKW.js → sk-SK-DRuiKuEp.js} +3 -1
  224. package/dist/sk-SK-K03EHmJF.js +13 -0
  225. package/dist/{sk-SK-FGK1FMMO.js → sk-SK-atqQJid1.js} +4 -1
  226. package/dist/{sl-SI-lPxRRPsh.js → sl-SI-CmYmQ6nG.js} +3 -1
  227. package/dist/{sl-SI-Cz28AFTz.js → sl-SI-CwKpXVCh.js} +4 -1
  228. package/dist/sl-SI-Dt7rovIT.js +94 -0
  229. package/dist/{sl-SI-hnlbW1OT.js → sl-SI-g2WSP0Tj.js} +2 -5
  230. package/dist/sl-SI-gM40Ay3W.js +13 -0
  231. package/dist/sl-SI-wYYQibM-.js +13 -0
  232. package/dist/style.css +931 -892
  233. package/dist/styles-CLV89_hH.js +931 -892
  234. package/dist/sv-SE-Bnhsdw8c.js +13 -0
  235. package/dist/{sv-SE-DLl7OGxl.js → sv-SE-CGCP_6VE.js} +4 -1
  236. package/dist/{sv-SE-BPpQ-05i.js → sv-SE-CHomf31L.js} +3 -1
  237. package/dist/{sv-SE-7Cbo1oic.js → sv-SE-Cfs0NHgG.js} +2 -5
  238. package/dist/sv-SE-DqzH809e.js +94 -0
  239. package/dist/sv-SE-uisfAT9L.js +13 -0
  240. package/dist/{useForm-CNi1k1NR.js → trackNavigation-gyYoCNvj.js} +25 -8
  241. package/dist/types/api/businessLines/businessLines.types.d.ts +7 -2
  242. package/dist/types/api/businessLines/useDeleteBusinessLine.d.ts +5 -0
  243. package/dist/types/api/businessLines/useUpdateBusinessLines.d.ts +7 -0
  244. package/dist/types/api/businessLines/useUpdateSourceOfFunds.d.ts +1 -0
  245. package/dist/types/components/BankAccount/forms/BankDocument/types.d.ts +2 -2
  246. package/dist/types/components/BankAccount/forms/PayoutDetails/PayoutDetails.d.ts +0 -1
  247. package/dist/types/components/BankAccount/forms/PayoutVerificationMethod/PayoutVerificationMethod.d.ts +1 -2
  248. package/dist/types/components/BankAccount/forms/PayoutVerificationMethod/payoutVerificationMethodMetadata.d.ts +1 -1
  249. package/dist/types/components/BankAccount/mapping/payoutKeyMappings.d.ts +51 -51
  250. package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/PayoutDetailsDropin.d.ts +1 -0
  251. package/dist/types/components/BankAccount/tasks/PayoutDetailsDropin/utils.d.ts +3 -3
  252. package/dist/types/components/BankAccount/utils/payoutAccountUtil.d.ts +2 -2
  253. package/dist/types/components/Business/tasks/BusinessDetailsDropin/types.d.ts +1 -3
  254. package/dist/types/components/Business/tasks/BusinessDetailsDropin/utils.d.ts +1 -1
  255. package/dist/types/components/BusinessLines/fields/WebDataField/types.d.ts +2 -4
  256. package/dist/types/components/BusinessLines/forms/rules.d.ts +5 -0
  257. package/dist/types/components/BusinessLines/tasks/BusinessLines/BusinessLinesStore.d.ts +2 -0
  258. package/dist/types/components/BusinessLines/tasks/BusinessLines/ExistingBusinessLines/BusinessLineModal.d.ts +3 -2
  259. package/dist/types/components/BusinessLines/tasks/utils.d.ts +11 -2
  260. package/dist/types/components/EFP/mapping/businessFinancingKeyMappings.d.ts +124 -124
  261. package/dist/types/components/Shared/FormNavigation/FormNavigation.d.ts +1 -1
  262. package/dist/types/components/Shared/FormNavigation/types.d.ts +0 -2
  263. package/dist/types/components/Shared/FormWrapper/FormWrapper.d.ts +1 -3
  264. package/dist/types/components/Shared/Summary/Summary.d.ts +1 -1
  265. package/dist/types/components/Shared/Summary/types.d.ts +0 -2
  266. package/dist/types/components/Shared/forms/Address/utils.d.ts +1 -1
  267. package/dist/types/components/Shared/tasks/CustomerSupport/mapping/customerSupportKeyMapping.d.ts +4 -0
  268. package/dist/types/context/ExperimentContext/types.d.ts +12 -0
  269. package/dist/types/core/errorMapping.d.ts +4 -1
  270. package/dist/types/core/user-events.d.ts +7 -9
  271. package/dist/types/hooks/{useAnalytics.d.ts → useAnalytics/useAnalytics.d.ts} +1 -7
  272. package/dist/types/utils/analytics/convertToEmbeddedEvent.d.ts +9 -0
  273. package/dist/types/utils/analytics/debouncedInputEvent.d.ts +19 -0
  274. package/dist/types/utils/analytics/getAnalyticsAssociatedEntityDetails.d.ts +13 -0
  275. package/dist/types/utils/{trackNavigation.d.ts → analytics/trackNavigation.d.ts} +1 -1
  276. package/dist/types/utils/entityStatusUtil.d.ts +1 -1
  277. package/dist/types/utils/filterProblemsByTaskForms.d.ts +12 -0
  278. package/dist/types/utils/getName.d.ts +1 -1
  279. package/dist/{types-DNH7oNbA.js → types-C1FJZQd1.js} +2 -2
  280. package/dist/{types-SBNit_kK.js → types-D0aacEF5.js} +27 -3
  281. package/dist/{types-DHmyPbAn.js → types-DQVZ5BSQ.js} +14 -2
  282. package/dist/{useAssociatedLegalEntity-CmhNWabq.js → useAssociatedLegalEntity-CuTN8T5x.js} +2 -2
  283. package/dist/{useDataset-C0A9qR_N.js → useDataset-C4vcroxo.js} +3 -3
  284. package/dist/{useMultiForm-CU58VvHX.js → useMultiForm-GpoMvhwU.js} +4 -4
  285. package/dist/{useOnboardingStatus-DuIJSnGH.js → useOnboardingStatus-Cifcsbcr.js} +1 -1
  286. package/dist/{useScenarios-T0NF0gUi.js → useScenarios-AyvycExm.js} +2 -2
  287. package/dist/{useTermsOfServiceStatus-1oGd6y18.js → useTermsOfServiceStatus-yhwwFpfh.js} +1 -1
  288. package/dist/{useToastContext-DHgUoF6x.js → useToastContext-CCxuinr_.js} +2 -2
  289. package/dist/{useUnincorporatedPartnershipMembers-57G1Bu4k.js → useUnincorporatedPartnershipMembers-D_N_aPNq.js} +62 -7
  290. package/dist/{utils-DZz9bCID.js → utils-U0nEMoML.js} +6 -46
  291. package/dist/validate-BRRbVwma.js +41 -0
  292. package/dist/{validate-Bz6-McmI.js → validate-Bqbj3vVS.js} +2 -2
  293. package/dist/{validationError-Ci4nlmhZ.js → validationError-DhRqgFgA.js} +2 -2
  294. package/package.json +1 -1
  295. package/dist/Card-N9psV2kP.js +0 -147
  296. package/dist/CreateIndividualComponent-BL3dK960.js +0 -71
  297. package/dist/CreateTransferInstrumentComponent-kxMU_XVD.js +0 -66
  298. package/dist/Divider-DiS12D_i.js +0 -239
  299. package/dist/Dropzone-DSyKXnbD.js +0 -218
  300. package/dist/Image-BhBefhke.js +0 -22
  301. package/dist/InputDate-C2j7qA_b.js +0 -43
  302. package/dist/InputGroup-WBfGDV5F.js +0 -32
  303. package/dist/LandingLayout-Ca68Z9DA.js +0 -60
  304. package/dist/Link-BS6Zpegg.js +0 -35
  305. package/dist/OnboardingDropinComponent-IKzrTT3r.js +0 -4274
  306. package/dist/RadioGroup-DhwjhH0X.js +0 -144
  307. package/dist/RegistrationAddress-BnyrwF-X.js +0 -2337
  308. package/dist/RootBusinessDetailsPage-BFR4Sxfp.js +0 -61
  309. package/dist/RootIndividualDetailsPage-D6lLtamt.js +0 -76
  310. package/dist/SoleProprietorshipPage-BKlAFmwp.js +0 -60
  311. package/dist/Spacer-BK3jDget.js +0 -18
  312. package/dist/TaxInformationField-DCjcBMwQ.js +0 -3094
  313. package/dist/TileGroup-BkTpSpVX.js +0 -174
  314. package/dist/UnincorporatedPartnershipIndividualPage-DZZc7sEn.js +0 -65
  315. package/dist/bafinUtils-DkP3ZoN4.js +0 -366
  316. package/dist/bg-BG-BLe6BCNz.js +0 -13
  317. package/dist/bg-BG-BPsOhDfg.js +0 -13
  318. package/dist/bg-BG-z3gZQvGq.js +0 -42
  319. package/dist/commonValidators-BLvtzPWZ.js +0 -24
  320. package/dist/cs-CZ-C5lyVYlZ.js +0 -42
  321. package/dist/cs-CZ-CHzJM-ii.js +0 -13
  322. package/dist/cs-CZ-xoLsda7i.js +0 -13
  323. package/dist/currency-BGwQyxBo.js +0 -36
  324. package/dist/da-DK-CYl2jko-.js +0 -42
  325. package/dist/da-DK-D-TJghBi.js +0 -13
  326. package/dist/da-DK-XNMYSp7w.js +0 -13
  327. package/dist/de-DE-BI7AAdOv.js +0 -13
  328. package/dist/de-DE-CCmlaL2F.js +0 -13
  329. package/dist/de-DE-DlUEkik0.js +0 -42
  330. package/dist/el-GR-DZ8GheJK.js +0 -42
  331. package/dist/el-GR-DoCIcce-.js +0 -13
  332. package/dist/el-GR-kYiInIQ9.js +0 -13
  333. package/dist/en-US-DYpvuCLO.js +0 -13
  334. package/dist/es-ES-CJMsyMAc.js +0 -13
  335. package/dist/es-ES-CnNU6AJv.js +0 -13
  336. package/dist/es-ES-D0c0MoqK.js +0 -42
  337. package/dist/et-EE-BR4OXRfV.js +0 -13
  338. package/dist/et-EE-C4Fwyr7-.js +0 -42
  339. package/dist/et-EE-sB7wkSA3.js +0 -13
  340. package/dist/fi-FI-BbqwYcLI.js +0 -13
  341. package/dist/fi-FI-bRXb-Q_i.js +0 -42
  342. package/dist/fi-FI-u5GxMZsq.js +0 -13
  343. package/dist/fieldConfigurations-BsOQ678Q.js +0 -448
  344. package/dist/form-rules-DhbF2mY4.js +0 -13
  345. package/dist/fr-FR-CMjrAkKl.js +0 -13
  346. package/dist/fr-FR-Cr-Y1vIy.js +0 -13
  347. package/dist/fr-FR-JLPKgufm.js +0 -42
  348. package/dist/hr-HR-Bhsop3CT.js +0 -13
  349. package/dist/hr-HR-D26Gz-HL.js +0 -42
  350. package/dist/hr-HR-D8cBxUFa.js +0 -13
  351. package/dist/hu-HU-BVfkOdJe.js +0 -13
  352. package/dist/hu-HU-BZCFneWx.js +0 -42
  353. package/dist/hu-HU-D2j1ISVk.js +0 -13
  354. package/dist/isEmpty-B0GMAw4K.js +0 -23
  355. package/dist/it-IT-C7Sg1k4p.js +0 -13
  356. package/dist/it-IT-CwA8megO.js +0 -13
  357. package/dist/it-IT-mScKLwBR.js +0 -42
  358. package/dist/ja-JP-DyELKS9Q.js +0 -42
  359. package/dist/ja-JP-GSbqID7o.js +0 -13
  360. package/dist/jpAddressSchema-ULGNNt5U.js +0 -27
  361. package/dist/lt-LT-C5nNCk4_.js +0 -13
  362. package/dist/lt-LT-CLPQVRpJ.js +0 -42
  363. package/dist/lt-LT-DSiutpRl.js +0 -13
  364. package/dist/lv-LV-C62XiDE5.js +0 -13
  365. package/dist/lv-LV-CEK8Re4d.js +0 -13
  366. package/dist/lv-LV-Cu-MJMVO.js +0 -42
  367. package/dist/mapJpAddressSchemaToAddressLocalizations-D7YGYa9S.js +0 -147
  368. package/dist/nl-NL-BOJ6zuBr.js +0 -13
  369. package/dist/nl-NL-DOQPxTX-.js +0 -13
  370. package/dist/nl-NL-pVdpCCOx.js +0 -42
  371. package/dist/no-NO-CRULNwNn.js +0 -42
  372. package/dist/no-NO-Cp3-tDMw.js +0 -13
  373. package/dist/no-NO-CuwTDFSf.js +0 -13
  374. package/dist/pl-PL-1-MrLPXu.js +0 -13
  375. package/dist/pl-PL-CtDHmbhp.js +0 -13
  376. package/dist/pl-PL-CxCiWdAF.js +0 -42
  377. package/dist/pt-BR-Br_cHzGx.js +0 -13
  378. package/dist/pt-BR-DnKEuslh.js +0 -13
  379. package/dist/pt-BR-apPtB2cK.js +0 -42
  380. package/dist/pt-PT-CLwCij2I.js +0 -13
  381. package/dist/pt-PT-Coa6J7SM.js +0 -42
  382. package/dist/pt-PT-cjbtYBUX.js +0 -13
  383. package/dist/ro-RO-BTqq5BPM.js +0 -42
  384. package/dist/ro-RO-CGhIjlpU.js +0 -13
  385. package/dist/ro-RO-Cmk-sVDr.js +0 -13
  386. package/dist/sk-SK-Bo5nvxWQ.js +0 -13
  387. package/dist/sk-SK-Do6CKNU4.js +0 -13
  388. package/dist/sk-SK-welR06By.js +0 -42
  389. package/dist/sl-SI-B9N6vA08.js +0 -42
  390. package/dist/sl-SI-CrTRlNnN.js +0 -13
  391. package/dist/sl-SI-cY-L2ma-.js +0 -13
  392. package/dist/sv-SE-BtwPrLEA.js +0 -13
  393. package/dist/sv-SE-D6al0j6W.js +0 -42
  394. package/dist/sv-SE-WPziDPQa.js +0 -13
  395. package/dist/types/utils/analytics.d.ts +0 -31
  396. package/dist/utils-AieP90ex.js +0 -29
  397. package/dist/utils-Bd79Y_6k.js +0 -165
  398. package/dist/validate-WO7yAOk4.js +0 -382
@@ -0,0 +1,2502 @@
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] = "b507bc0a-1bef-4c2c-b7d4-cff7bd738076", e._sentryDebugIdIdentifier = "sentry-dbid-b507bc0a-1bef-4c2c-b7d4-cff7bd738076");
6
+ } catch (e) {
7
+ }
8
+ }
9
+ ;
10
+ import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
11
+ import { useMemo, useState, useEffect, useCallback, useRef } from "preact/hooks";
12
+ import { u as useScenarios } from "./useScenarios-AyvycExm.js";
13
+ import { l as useProviderStatus, r as addressValidators, s as addressFormatters, j as useCreateLegalEntity, k as useUpdateLegalEntity, t as mapAddressLabels } from "./Address-ChPj2pfR.js";
14
+ import { c as contactDetailsValidationRules, u as useValidatePhoneNumberImperatively } from "./validate-BRRbVwma.js";
15
+ import { b as useApiContext, a2 as useMutation, k as httpPost, aJ as matchesRegex, aV as trimValWithOneSpace, aK as NO_ALPHABET_REGEX, aL as EMOJI_REGEX, aM as hasRepeatedCharacters, aN as isInvalidName, aW as INDIVIDUAL_VALID_CHAR_REGEX, aT as getFormattingRegEx, aU as SPECIAL_CHARS, aQ as standardKatakanaValidator, aR as standardKanjiValidator, V as CountryCodes, X as isEmpty, O as TaskTypes, z as LegalEntityTypes, b5 as getAgeToday, b6 as euCountries, b7 as individualApiKeyMapping, aq as individualComponentsKeyMapping, b3 as reverseMapping, b8 as getNomineeFromAssociation, b9 as drop, P as createLogger, K as useAccountHolder, W as useI18nContext, a1 as useAnalyticsContext, $ as useExperimentsContext, m as useSettingsContext, g as getLegalEntityCountry, ba as getAllowedDecisionMakerRoles, bb as filterOutUnwantedAssociationsIfRootLE, aG as cloneObject, bc as individualDocumentMapping, bd as individualObscuredFields, ag as getOwnEntityAssociations, be as hasNomineesChanged, bf as attachNomineeToRole, a_ as doArraysMatch, j as useQuery, r as skipToken, o as httpGet, u as useTranslation, a3 as useQueryClient, B as Button, L as Loader, bg as individualOnfidoApiKeyMapping, as as Scenarios, at as DecisionMakerTypes, bh as individualOnfidoDocumentMapping, bi as individualOnfidoObscuredFields } from "./StoreProvider-CWnZNw9D.js";
16
+ import { F as FormContextProvider, a as FormFlow } from "./FormFlow-A9b0QEcM.js";
17
+ import { u as useToastContext } from "./useToastContext-CCxuinr_.js";
18
+ import { g as getPropsFromConfigurations, c as composePerScenarioFormConfigurations } from "./process-field-configurations-D2EUZow3.js";
19
+ import { A as getSSNType, B as defaultFieldMetadata, D as defaultFieldConfig, E as defaultFieldMetadata$1, F as fieldConfig, t as taxInformationDefaultFieldMetadata, h as taxInformationDefaultFieldConfig, G as isEmpty$1, x as useSingpassMyInfoLogin, H as getAsyncIdNumberValidationRule, I as getAsyncPhoneValidationRules, J as setHasMotionCaptureScenario, K as showIndividualMotionCapture, p as individualForms, L as Individual, O as individualDocumentForms, P as idVerificationProviderId, Q as idNowModalChildEntityId, R as LandingLayout, z as showIdNowModal, U as check4DigitSsnFailed, V as individualOnfidoRules, o as individualOnfidoForms, W as isNextStepDisabled, X as shouldShowIdNowModal, Y as IndividualOnfido, Z as JP_ADDRESS_REQUIRED_FIELDS, _ as GuidanceQuestionValues, $ as DECISION_MAKER_TYPES_WITH_JOBTITLE$1 } from "./IndividualOnfido-BMIkKHvJ.js";
20
+ import { g as getRequiredForms, a as addValidityToForms, u as useFormComposer } from "./dropinUtils-L9qJuAw0.js";
21
+ import { u as useMultiForm } from "./useMultiForm-GpoMvhwU.js";
22
+ import { m as mapExistingFile, g as getPageName, a as getPage, u as useScenarioConfiguration } from "./mapExistingFile-txzqej6F.js";
23
+ import { i as isValidationError, p as processValidationErrors, a as isMaintenanceModeError } from "./validationError-DhRqgFgA.js";
24
+ import { g as getIdDocument, a as getDocument, c as createDocumentRequest, d as documentApiUtils, m as mergeAttachments, b as getFileExtention } from "./documentUtils-C2iCagu9.js";
25
+ import { a as datasetUtilities, C as Confirm } from "./useDataset-C4vcroxo.js";
26
+ import { g as getFieldsWithExistingData } from "./getFieldsWithExistingData-C6JBh3D6.js";
27
+ import { l as localizeDateString } from "./localizeDateString-ZCoTLjs1.js";
28
+ import { o as omitObscuredFieldsIfUnchanged, I as IFrameWidget } from "./iframeWidget-D2CKFlJk.js";
29
+ import { r as resolveFieldMetadata, w as getLocalizedIdDocumentTypeOptions, I as Image } from "./fieldConfigurations-DVV23oeM.js";
30
+ import { r as rules, D as DECISION_MAKER_TYPES_WITH_JOBTITLE } from "./rules-LaFMJfnA.js";
31
+ import { f as formatObject } from "./utils-DNSfZiio.js";
32
+ import { m as mapSchemaFieldsToApiScriptLocalization, a as mapApiScriptLocalizationToSchemaFields } from "./mapAddressLocalizationToJpAddressSchema-vJWbpAyq.js";
33
+ import { computed } from "@preact/signals";
34
+ import { Show } from "@preact/signals/utils";
35
+ import { m as mapJpAddressSchemaToAddressLocalizations, a as mapJpAddressSummary } from "./mapJpAddressSchemaToAddressLocalizations-pPCQCgRx.js";
36
+ import { lazy } from "preact/compat";
37
+ import { M as Modal } from "./Modal-C9aImxis.js";
38
+ import { a as Alert } from "./Alert-CeZqoFeT.js";
39
+ import { a as getIndividualLegalEntityName } from "./getName-k5oRc0oZ.js";
40
+ import { g as getOnfidoIdentityTypeToApiIdentityTypeMap, m as mapLegalEntityToIndividualOnfidoSchema } from "./mapLegalEntityToIndividualOnfidoSchema-B8NxtO2j.js";
41
+ const verifyIdNumber = async (legalEntityId, baseUrl, data) => {
42
+ return await httpPost(
43
+ {
44
+ baseUrl,
45
+ path: `legalEntities/${legalEntityId}/verifications/idNumber`,
46
+ // Handler for unhappy flows, i.e. status != 200, in the idNumber verification process
47
+ errorHandler: async (response) => {
48
+ const responseData = await response;
49
+ if (responseData.status === 422) {
50
+ return { status: 422, message: responseData.detail, errorCode: responseData.errorCode };
51
+ }
52
+ if (responseData.status === 500) {
53
+ return { status: 500, message: "Service did not respond, do not block verification" };
54
+ }
55
+ }
56
+ },
57
+ data
58
+ );
59
+ };
60
+ const useVerifyIdNumber = (options) => {
61
+ const { rootLegalEntityId, baseUrl } = useApiContext();
62
+ return useMutation({
63
+ mutationFn: (data) => verifyIdNumber(rootLegalEntityId.value, baseUrl.value, data),
64
+ ...options
65
+ });
66
+ };
67
+ const startVerificationCheck = async (rootLegalEntityId, baseUrl, data) => {
68
+ return httpPost(
69
+ {
70
+ baseUrl,
71
+ path: `legalEntities/${rootLegalEntityId}/providers/idVerification/process`
72
+ },
73
+ data
74
+ );
75
+ };
76
+ const useIdVerificationStartCheck = (options) => {
77
+ const { rootLegalEntityId, baseUrl } = useApiContext();
78
+ return useMutation({
79
+ mutationFn: (data) => startVerificationCheck(rootLegalEntityId.value, baseUrl.value, data),
80
+ ...options
81
+ });
82
+ };
83
+ const nameValidationRulesV4 = {
84
+ firstName: [
85
+ {
86
+ modes: ["blur"],
87
+ validate: (input) => !matchesRegex(NO_ALPHABET_REGEX, input),
88
+ errorMessage: "nameMustContainLetters"
89
+ },
90
+ {
91
+ modes: ["blur"],
92
+ validate: (input) => !matchesRegex(EMOJI_REGEX, input) && !hasRepeatedCharacters(input) && !isInvalidName(input) && matchesRegex(INDIVIDUAL_VALID_CHAR_REGEX, input),
93
+ errorMessage: "checkForTypos"
94
+ }
95
+ ],
96
+ lastName: [
97
+ {
98
+ modes: ["blur"],
99
+ validate: (input) => !matchesRegex(NO_ALPHABET_REGEX, input),
100
+ errorMessage: "nameMustContainLetters"
101
+ },
102
+ {
103
+ modes: ["blur"],
104
+ validate: (input) => !matchesRegex(EMOJI_REGEX, input) && !hasRepeatedCharacters(input) && !isInvalidName(input) && matchesRegex(INDIVIDUAL_VALID_CHAR_REGEX, input),
105
+ errorMessage: "checkForTypos"
106
+ }
107
+ ]
108
+ };
109
+ const specialCharsRegEx = getFormattingRegEx(SPECIAL_CHARS.replace("-", ""));
110
+ const nameFormatters = {
111
+ firstName: {
112
+ // formatter: trimValWithOneSpace // just trim
113
+ // Example - removing disallowed chars as they are input: then they don't end up in state
114
+ formatter: (val) => val ? trimValWithOneSpace(val).replace(specialCharsRegEx, "") : void 0
115
+ // trim & replace
116
+ },
117
+ lastName: {
118
+ formatter: (val) => val ? trimValWithOneSpace(val).replace(specialCharsRegEx, "") : void 0
119
+ }
120
+ };
121
+ const onfidoDocumentTypeMapping = [
122
+ { id: "driversLicense", name: "driversLicense", hasBackPage: true },
123
+ { id: "identityCard", name: "identityCard", hasBackPage: true },
124
+ { id: "passport", name: "passport", hasBackPage: false }
125
+ ];
126
+ const jaHaniNameValidationRules = {
127
+ jaHaniFirstName: [
128
+ {
129
+ modes: ["blur"],
130
+ validate: (input) => standardKanjiValidator(input),
131
+ errorMessage: "nameMustContainLetters"
132
+ }
133
+ ],
134
+ jaHaniLastName: [
135
+ {
136
+ modes: ["blur"],
137
+ validate: (input) => standardKanjiValidator(input),
138
+ errorMessage: "nameMustContainLetters"
139
+ }
140
+ ]
141
+ };
142
+ const jaKanaNameValidationRules = {
143
+ jaKanaFirstName: [
144
+ {
145
+ modes: ["blur"],
146
+ validate: (input) => standardKatakanaValidator(input),
147
+ errorMessage: "nameMustContainLetters"
148
+ }
149
+ ],
150
+ jaKanaLastName: [
151
+ {
152
+ modes: ["blur"],
153
+ validate: (input) => standardKatakanaValidator(input),
154
+ errorMessage: "nameMustContainLetters"
155
+ }
156
+ ]
157
+ };
158
+ const isNotOutOfRangeBirthDateValidatorRule$1 = {
159
+ modes: ["blur"],
160
+ validate: (birthDate) => !isEmpty(birthDate) && new Date(birthDate) < /* @__PURE__ */ new Date(),
161
+ errorMessage: "invalidDateOfBirth"
162
+ };
163
+ const buildMinimumAgeValidationRule$1 = (minimumAge) => ({
164
+ modes: ["blur"],
165
+ validate: (birthDate) => !!birthDate && getAgeToday(birthDate) >= minimumAge,
166
+ errorMessage: {
167
+ key: "youMustXYearsOldToContinue",
168
+ values: { minimumAge: minimumAge.toString() }
169
+ }
170
+ });
171
+ const getCountrySpecificMinimumAgeValidationRule$1 = (country) => {
172
+ if (!country) {
173
+ return buildMinimumAgeValidationRule$1(13);
174
+ }
175
+ if ([...euCountries, CountryCodes.UnitedKingdom, CountryCodes.Switzerland].some(
176
+ (c) => c === country
177
+ )) {
178
+ return buildMinimumAgeValidationRule$1(16);
179
+ }
180
+ switch (country) {
181
+ case CountryCodes.HongKong:
182
+ case CountryCodes.Singapore:
183
+ return buildMinimumAgeValidationRule$1(18);
184
+ default:
185
+ return buildMinimumAgeValidationRule$1(13);
186
+ }
187
+ };
188
+ const personalDetailsValidators = ({
189
+ country,
190
+ isExperimentEnabled = () => false,
191
+ isSettingEnabled = () => false,
192
+ taskType,
193
+ idNumberType,
194
+ phonePrefix,
195
+ idNumberExempt,
196
+ idNumber,
197
+ existingIdNumber,
198
+ formVerificationErrors,
199
+ taxIdNumberType
200
+ }) => ({
201
+ taxInformation: resolveFieldMetadata(
202
+ taxInformationDefaultFieldConfig[country],
203
+ {
204
+ taxIdNumberType,
205
+ companyType: LegalEntityTypes.INDIVIDUAL
206
+ },
207
+ taxInformationDefaultFieldMetadata
208
+ )?.validators,
209
+ birthDate: (() => {
210
+ const baseValidators = [isNotOutOfRangeBirthDateValidatorRule$1];
211
+ if (isSettingEnabled("enforceLegalAge")) {
212
+ return [...baseValidators, buildMinimumAgeValidationRule$1(18)];
213
+ }
214
+ if (isExperimentEnabled("EnableAgeVerification")) {
215
+ if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS) {
216
+ return [...baseValidators, buildMinimumAgeValidationRule$1(18)];
217
+ }
218
+ return [...baseValidators, getCountrySpecificMinimumAgeValidationRule$1(country)];
219
+ }
220
+ return baseValidators;
221
+ })(),
222
+ ...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0,
223
+ ...contactDetailsValidationRules,
224
+ phoneNumber: resolveFieldMetadata(
225
+ fieldConfig[phonePrefix ?? country],
226
+ {},
227
+ defaultFieldMetadata$1
228
+ )?.validators,
229
+ idNumber: (() => {
230
+ const derivedIdNumberType = country === CountryCodes.UnitedStates ? getSSNType(formVerificationErrors, existingIdNumber) : idNumberType;
231
+ return idNumberExempt ? {
232
+ validate: () => {
233
+ return idNumberExempt || !isEmpty(idNumber);
234
+ },
235
+ modes: ["blur"]
236
+ } : resolveFieldMetadata(
237
+ defaultFieldConfig[country],
238
+ { idNumberType: derivedIdNumberType },
239
+ defaultFieldMetadata
240
+ )?.validators;
241
+ })(),
242
+ ...jaHaniNameValidationRules,
243
+ ...jaKanaNameValidationRules
244
+ });
245
+ const mandateIdVerificationForMotionCapture = (showMotionCapture, derivedProps) => {
246
+ if (!derivedProps) {
247
+ return void 0;
248
+ }
249
+ const copiedDerivedProps = { ...derivedProps };
250
+ if (showMotionCapture) {
251
+ const idVerificationFields = [
252
+ ...derivedProps.requiredFields.idVerificationMethod ?? [],
253
+ "idVerificationMethod"
254
+ ];
255
+ copiedDerivedProps.allFields.idVerificationMethod = idVerificationFields;
256
+ copiedDerivedProps.requiredFields.idVerificationMethod = idVerificationFields;
257
+ }
258
+ return copiedDerivedProps;
259
+ };
260
+ const mapApiDocumentToIndividualDocuments = (entityId) => {
261
+ const idDocument2 = getIdDocument(entityId);
262
+ const proofOfResidency = getDocument(entityId, "proofOfResidency");
263
+ const proofOfNationalId = getDocument(entityId, "proofOfNationalIdNumber");
264
+ const proofOfRelationship = getDocument(entityId, "proofOfRelationship");
265
+ return {
266
+ idDocument: idDocument2 ? mapApiIdDocumentToSchema(idDocument2) : void 0,
267
+ proofOfResidency: proofOfResidency ? { proofOfResidency: [mapExistingFile(getPageName(proofOfResidency))] } : void 0,
268
+ proofOfNationalId: proofOfNationalId ? { proofOfNationalId: [mapExistingFile(getPageName(proofOfNationalId))] } : void 0,
269
+ proofOfRelationship: proofOfRelationship ? { proofOfRelationship: [mapExistingFile(getPageName(proofOfRelationship))] } : void 0
270
+ };
271
+ };
272
+ const mapApiIdDocumentToSchema = (idDocument2) => {
273
+ const { type, attachments, modificationDate } = idDocument2;
274
+ const { hasBackPage } = getLocalizedIdDocumentTypeOptions().find(({ id }) => id === type);
275
+ let frontPage;
276
+ let backPage;
277
+ if (attachments?.length === 1) {
278
+ frontPage = getPage(idDocument2);
279
+ } else {
280
+ frontPage = hasBackPage ? getPage(idDocument2, "front") : getPage(idDocument2);
281
+ backPage = hasBackPage ? getPage(idDocument2, "back") : void 0;
282
+ }
283
+ return {
284
+ ...frontPage ? { idFrontPage: [mapExistingFile(frontPage.pageName ?? "")] } : {},
285
+ ...backPage ? { idBackPage: [mapExistingFile(backPage.pageName ?? "")] } : {},
286
+ idDocumentType: type,
287
+ modificationDate
288
+ };
289
+ };
290
+ const mapIndividualDocumentToApiDocument = async (data, entityId) => {
291
+ if (!data) return void 0;
292
+ const { proofOfNationalId, proofOfResidency, proofOfRelationship } = data;
293
+ const idDocument2 = "idDocument" in data ? data.idDocument : data.manualIdUpload;
294
+ const entityType = "legalEntity";
295
+ const documents = await Promise.all([
296
+ idDocument2?.idFrontPage ? createDocumentRequest({
297
+ entityId,
298
+ entityType,
299
+ documentType: idDocument2.idDocumentType,
300
+ page1: idDocument2.idFrontPage?.[0],
301
+ page2: idDocument2.idBackPage?.[0]
302
+ }) : void 0,
303
+ proofOfNationalId?.proofOfNationalId ? createDocumentRequest({
304
+ entityId,
305
+ entityType,
306
+ documentType: "proofOfNationalIdNumber",
307
+ page1: proofOfNationalId.proofOfNationalId[0]
308
+ }) : void 0,
309
+ proofOfResidency?.proofOfResidency ? createDocumentRequest({
310
+ entityId,
311
+ entityType,
312
+ documentType: "proofOfResidency",
313
+ page1: proofOfResidency.proofOfResidency[0]
314
+ }) : void 0,
315
+ proofOfRelationship?.proofOfRelationship ? createDocumentRequest({
316
+ entityId,
317
+ entityType,
318
+ documentType: "proofOfRelationship",
319
+ page1: proofOfRelationship.proofOfRelationship[0]
320
+ }) : void 0
321
+ ]);
322
+ return documents.filter(Boolean);
323
+ };
324
+ const getIdentityTypeToApiIdentityTypeMap = (data) => {
325
+ const { residencyCountry } = data;
326
+ switch (residencyCountry) {
327
+ case CountryCodes.HongKong:
328
+ return {
329
+ passport: "passport",
330
+ driversLicense: "driversLicense",
331
+ proofOfIdentityCard: "nationalIdNumber"
332
+ };
333
+ default:
334
+ return {
335
+ nationalIdNumber: "nationalIdNumber",
336
+ passport: "passport",
337
+ driversLicense: "driversLicense",
338
+ proofOfIdentityCard: "identityCard"
339
+ };
340
+ }
341
+ };
342
+ const adjustIdentificationData = (data, apiData) => {
343
+ const { typeOfIdentity, idNumber, idNumberExempt } = data;
344
+ const identificationData = {
345
+ ...apiData,
346
+ number: idNumber,
347
+ type: getIdentityTypeToApiIdentityTypeMap(data)[typeOfIdentity] ?? "nationalIdNumber"
348
+ };
349
+ switch (typeOfIdentity) {
350
+ case "passport":
351
+ return {
352
+ ...identificationData,
353
+ cardNumber: ""
354
+ };
355
+ case "driversLicense":
356
+ return {
357
+ ...identificationData,
358
+ expiryDate: ""
359
+ };
360
+ default:
361
+ return idNumber === void 0 && idNumberExempt === void 0 ? void 0 : {
362
+ ...identificationData,
363
+ expiryDate: "",
364
+ cardNumber: "",
365
+ nationalIdExempt: apiData?.nationalIdExempt ?? !idNumber
366
+ };
367
+ }
368
+ };
369
+ const mapIndividualToLegalEntity = (data) => {
370
+ const requestObj = {
371
+ ...formatObject(data, individualApiKeyMapping)
372
+ };
373
+ requestObj.type = LegalEntityTypes.INDIVIDUAL;
374
+ const { personalDetails } = data;
375
+ if (!personalDetails) return requestObj;
376
+ requestObj.individual.identificationData = adjustIdentificationData(
377
+ personalDetails,
378
+ requestObj.individual.identificationData
379
+ );
380
+ const localization = [
381
+ mapSchemaFieldsToApiScriptLocalization(personalDetails, "jaHani"),
382
+ mapSchemaFieldsToApiScriptLocalization(personalDetails, "jaKana")
383
+ ].filter(({ fields }) => !isEmpty$1(fields));
384
+ if (localization.length) {
385
+ requestObj.individual.name.localization = localization;
386
+ }
387
+ if (personalDetails.phoneNumber?.number) {
388
+ requestObj.individual.phone = {
389
+ number: personalDetails.phoneNumber.number,
390
+ type: "mobile"
391
+ };
392
+ } else {
393
+ delete requestObj.individual.phone;
394
+ }
395
+ return requestObj;
396
+ };
397
+ const mapLegalEntityToIndividual = (legalEntity, isChangingType, isRoleFieldNeeded, parentLegalEntity, isLegalRepresentative) => {
398
+ let individualData = formatObject(
399
+ legalEntity,
400
+ individualComponentsKeyMapping
401
+ );
402
+ individualData = {
403
+ ...individualData,
404
+ personalDetails: {
405
+ ...individualData?.personalDetails,
406
+ ...isChangingType && {
407
+ firstName: "",
408
+ lastName: ""
409
+ }
410
+ }
411
+ };
412
+ if (!individualData.personalDetails?.idNumberExempt) {
413
+ individualData.personalDetails.idNumberExempt = false;
414
+ }
415
+ const apiIdentityTypeToIdentityTypeMap = reverseMapping(
416
+ getIdentityTypeToApiIdentityTypeMap(individualData.personalDetails)
417
+ );
418
+ if (legalEntity?.individual?.identificationData?.type) {
419
+ individualData.personalDetails.typeOfIdentity = apiIdentityTypeToIdentityTypeMap[legalEntity.individual.identificationData.type];
420
+ }
421
+ if (legalEntity?.documentDetails?.length) {
422
+ individualData = {
423
+ ...individualData,
424
+ ...mapApiDocumentToIndividualDocuments(legalEntity?.id)
425
+ };
426
+ }
427
+ if (legalEntity?.individual?.residentialAddress.country === "JP" && legalEntity.individual?.name?.localization) {
428
+ for (const scriptLoc of legalEntity.individual.name.localization) {
429
+ individualData.personalDetails = {
430
+ ...individualData.personalDetails,
431
+ ...mapApiScriptLocalizationToSchemaFields(scriptLoc)
432
+ };
433
+ }
434
+ }
435
+ if (!parentLegalEntity?.entityAssociations) {
436
+ return individualData;
437
+ }
438
+ const associations = parentLegalEntity?.entityAssociations?.filter((ea) => ea.legalEntityId === legalEntity?.id) ?? [];
439
+ if (isRoleFieldNeeded) {
440
+ individualData.personalDetails.role = associations.map((ea) => ea.type);
441
+ individualData.personalDetails.jobTitle = associations.find(
442
+ ({ jobTitle }) => Boolean(jobTitle)
443
+ )?.jobTitle;
444
+ }
445
+ individualData.personalDetails = getNomineeFromAssociation(
446
+ associations,
447
+ individualData.personalDetails
448
+ );
449
+ if (isLegalRepresentative) {
450
+ individualData.personalDetails.relationship = associations.find(
451
+ ({ relationship }) => Boolean(relationship)
452
+ )?.relationship;
453
+ }
454
+ return individualData;
455
+ };
456
+ const identityBase = {
457
+ role: {
458
+ rule: "requiredIfDecisionMakerTask"
459
+ },
460
+ firstName: {
461
+ rule: "REQUIRED"
462
+ },
463
+ lastName: {
464
+ rule: "REQUIRED"
465
+ },
466
+ birthDate: {
467
+ rule: "REQUIRED"
468
+ },
469
+ phoneNumber: {
470
+ rules: ["requiredIfPhoneScenarioDisabled", "contactsIfRequiredForRole"]
471
+ },
472
+ email: {
473
+ rule: "contactsIfRequiredForRole"
474
+ },
475
+ jobTitle: {
476
+ rule: "jobTitleIfRequiredForRole"
477
+ },
478
+ nationality: {
479
+ rule: "nationalityIfRequiredForRole"
480
+ },
481
+ address: {
482
+ rule: "addressIfRequiredForCountry"
483
+ },
484
+ otherAddressInformation: {
485
+ rule: "otherAddressInfoIfRequiredForCountry"
486
+ },
487
+ country: {
488
+ rule: "REQUIRED"
489
+ },
490
+ postalCode: {
491
+ rule: "postalCodeIfRequiredForCountry"
492
+ },
493
+ city: {
494
+ rule: "cityIfRequiredForCountry"
495
+ },
496
+ stateOrProvince: {
497
+ rule: "stateOrProvinceIfRequiredForCountry"
498
+ },
499
+ residencyCountry: {
500
+ rule: "REQUIRED"
501
+ },
502
+ proofOfResidency: {
503
+ rule: "isProofOfResidencyRequired"
504
+ },
505
+ proofOfNationalId: {
506
+ rule: "isProofOfNationalIdRequired"
507
+ },
508
+ relationship: {
509
+ rule: "legalRepresentativeRelationshipRequired"
510
+ },
511
+ proofOfRelationship: {
512
+ rule: "isProofOfRelationshipRequired"
513
+ },
514
+ nomineeDirector: {
515
+ rule: "nomineeDirectorRequiredForCountry"
516
+ },
517
+ nomineeShareholder: {
518
+ rule: "nomineeShareHolderRequiredForCountry"
519
+ },
520
+ jaHaniFirstName: {
521
+ rule: "japaneseFirstAndLastNames"
522
+ },
523
+ jaHaniLastName: {
524
+ rule: "japaneseFirstAndLastNames"
525
+ },
526
+ jaKanaFirstName: {
527
+ rule: "japaneseFirstAndLastNames"
528
+ },
529
+ jaKanaLastName: {
530
+ rule: "japaneseFirstAndLastNames"
531
+ },
532
+ idDocumentType: {
533
+ // If the user has a missing ID error and chooses manual flow
534
+ rule: "isManualIdFlowAndHasMissingData"
535
+ }
536
+ };
537
+ const identityNumber$1 = {
538
+ idNumber: {
539
+ rule: "idNumberRules",
540
+ obscured: true
541
+ },
542
+ idNumberExempt: {
543
+ rules: ["idNumberExemptIfApplicableCountry", "isDirectorIdNumberRequiredForCountry"]
544
+ },
545
+ idDocumentType: {
546
+ rule: "manualIdDocumentRequired"
547
+ },
548
+ idFrontPage: {
549
+ rule: "idFrontPageIfManualUpload"
550
+ },
551
+ idBackPage: {
552
+ rule: "backPageIfRequiredForDocumentType"
553
+ },
554
+ idVerificationMethod: {
555
+ rule: "idVerificationRequired"
556
+ },
557
+ instantIdVerificationData: {
558
+ rule: "instantVerificationDataRule"
559
+ }
560
+ };
561
+ const additionalIdentityInfo$1 = {
562
+ typeOfIdentity: {
563
+ rules: ["requiredIfCountryUsesMultipleTypesOfIdentity", "isDirectorIdNumberRequiredForCountry"]
564
+ },
565
+ issuerState: {
566
+ rule: "issuerStateRequired"
567
+ },
568
+ licenseCardNumber: {
569
+ rule: "licenseCardNumberRules"
570
+ },
571
+ expiryDate: {
572
+ rule: "expiryDateRequired"
573
+ }
574
+ };
575
+ const idDocument = {
576
+ idVerificationMethod: {
577
+ rule: "REQUIRED"
578
+ },
579
+ idDocumentType: {
580
+ rule: "REQUIRED"
581
+ },
582
+ idFrontPage: {
583
+ rule: "idFrontPageIfManualUpload"
584
+ },
585
+ idBackPage: {
586
+ rule: "backPageIfRequiredForDocumentType"
587
+ }
588
+ };
589
+ const nationality$1 = {
590
+ nationality: {
591
+ rule: "REQUIRED"
592
+ }
593
+ };
594
+ const phoneNumberBase$1 = {
595
+ phoneNumber: {
596
+ rule: "contactsIfRequiredForRole"
597
+ }
598
+ };
599
+ const taxInformationBase$1 = {
600
+ taxInformation: { rule: "countryUsesTaxId" }
601
+ };
602
+ const fieldsPerScenario = {
603
+ L0: drop("address", "birthDate").from(identityBase),
604
+ L1: identityBase,
605
+ L_TAXINFO: { ...identityBase, ...taxInformationBase$1 },
606
+ L1_ID: {
607
+ ...identityBase,
608
+ ...identityNumber$1,
609
+ ...additionalIdentityInfo$1
610
+ },
611
+ L1_IDO: {
612
+ // TODO: change idNumber rule to optional once optional fields are implemented
613
+ ...identityBase,
614
+ ...identityNumber$1,
615
+ ...additionalIdentityInfo$1
616
+ },
617
+ L1_NAT: {
618
+ ...identityBase,
619
+ ...identityNumber$1,
620
+ ...additionalIdentityInfo$1,
621
+ ...nationality$1
622
+ },
623
+ L1_IDDOC: idDocument,
624
+ L_PH: phoneNumberBase$1
625
+ };
626
+ const parseIndividualScenarios = (scenarios) => composePerScenarioFormConfigurations(scenarios, fieldsPerScenario);
627
+ const parseConfiguration$1 = ({ scenarios }) => parseIndividualScenarios(scenarios);
628
+ const logger$1 = createLogger();
629
+ function IndividualDropin({
630
+ taskType = TaskTypes.INDIVIDUAL,
631
+ parentLegalEntity,
632
+ legalEntityResponse,
633
+ handleHomeClick,
634
+ isTargetLegalEntityType,
635
+ country: parentCountry,
636
+ problems: propProblems,
637
+ trustMember,
638
+ onSubmit: externalOnSubmit,
639
+ asModal = false,
640
+ handleBackClick: externalBackClick,
641
+ trustedFields,
642
+ trustedFieldsProvider,
643
+ trustedRoles
644
+ }) {
645
+ const { baseUrl, rootLegalEntityId } = useApiContext();
646
+ const { accountHolder, setAccountHolder } = useAccountHolder();
647
+ const { i18n } = useI18nContext();
648
+ const userEvents = useAnalyticsContext();
649
+ const { showToast, clearToasts } = useToastContext();
650
+ const { isExperimentEnabled } = useExperimentsContext();
651
+ const { isSettingEnabled } = useSettingsContext();
652
+ const isRoleFieldNeeded = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER;
653
+ const isLegalRepresentative = taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS;
654
+ const dataFromResponse = useMemo(() => {
655
+ if (legalEntityResponse) {
656
+ return mapLegalEntityToIndividual(
657
+ legalEntityResponse,
658
+ isTargetLegalEntityType,
659
+ isRoleFieldNeeded,
660
+ parentLegalEntity,
661
+ isLegalRepresentative
662
+ );
663
+ }
664
+ return {
665
+ personalDetails: {
666
+ residencyCountry: parentCountry
667
+ },
668
+ address: {
669
+ country: parentCountry
670
+ }
671
+ };
672
+ }, [
673
+ legalEntityResponse,
674
+ parentCountry,
675
+ isTargetLegalEntityType,
676
+ parentLegalEntity,
677
+ isRoleFieldNeeded,
678
+ isLegalRepresentative
679
+ ]);
680
+ const documentUtils = documentApiUtils({
681
+ baseUrl: baseUrl.value,
682
+ rootLegalEntityId: rootLegalEntityId.value
683
+ });
684
+ let roleTypes = [];
685
+ const [newDecisionMaker] = useState();
686
+ const [matchingScenario, setMatchingScenario] = useState();
687
+ const [validationErrors, setValidationErrors] = useState();
688
+ const [loadingStatus, setLoadingStatus] = useState("success");
689
+ const [documents, setDocuments] = useState();
690
+ const [existingAttachments, setExistingAttachments] = useState();
691
+ const [country, setCountry] = useState(
692
+ dataFromResponse?.personalDetails?.residencyCountry ?? parentCountry
693
+ );
694
+ const [hideFooter, setHideFooter] = useState(false);
695
+ const [derivedProps, setDerivedProps] = useState();
696
+ const { trustedFields: associatedLegalEntityTrustedFields } = useSingpassMyInfoLogin({
697
+ legalEntity: legalEntityResponse,
698
+ accountHolder
699
+ });
700
+ const { data: providerStatus } = useProviderStatus({
701
+ providers: ["address", "idDocument"],
702
+ country: legalEntityResponse ? getLegalEntityCountry(legalEntityResponse) : country
703
+ });
704
+ const problems = useMemo(
705
+ () => ({
706
+ ...propProblems,
707
+ validationErrors
708
+ }),
709
+ [propProblems, validationErrors]
710
+ );
711
+ useEffect(() => {
712
+ userEvents.updateBaseTrackingPayload({ task: taskType });
713
+ userEvents.addTaskEvent("Landed on page", {
714
+ actionType: "start"
715
+ });
716
+ }, []);
717
+ const individualFieldValidations = useCallback(
718
+ (data2) => ({
719
+ personalDetails: personalDetailsValidators({
720
+ country: data2?.personalDetails?.residencyCountry ?? country,
721
+ isExperimentEnabled,
722
+ isSettingEnabled,
723
+ taskType,
724
+ idNumberType: data2?.personalDetails?.typeOfIdentity,
725
+ phonePrefix: data2?.personalDetails?.phoneNumber?.phoneCountryCode,
726
+ idNumberExempt: data2?.personalDetails?.idNumberExempt,
727
+ idNumber: data2?.personalDetails?.idNumber,
728
+ existingIdNumber: dataFromResponse.personalDetails?.idNumber,
729
+ formVerificationErrors: propProblems?.verificationErrors?.personalDetails,
730
+ taxIdNumberType: data2?.personalDetails?.taxInformation?.length ? data2?.personalDetails?.taxInformation[0]?.type : void 0
731
+ }),
732
+ address: addressValidators({
733
+ isExperimentEnabled,
734
+ country: data2?.personalDetails?.residencyCountry ?? country,
735
+ i18n
736
+ })
737
+ }),
738
+ [isExperimentEnabled, isSettingEnabled, taskType]
739
+ );
740
+ const validatePhoneNumber = useValidatePhoneNumberImperatively();
741
+ const { mutateAsync: verifyIdNumber2 } = useVerifyIdNumber();
742
+ const individualFieldAsyncValidations = useCallback(
743
+ (data2) => ({
744
+ personalDetails: {
745
+ phoneNumber: getAsyncPhoneValidationRules(validatePhoneNumber).phoneNumber,
746
+ idNumber: getAsyncIdNumberValidationRule(verifyIdNumber2, data2?.personalDetails).idNumber
747
+ }
748
+ }),
749
+ [getAsyncPhoneValidationRules, getAsyncIdNumberValidationRule]
750
+ );
751
+ const defaultData = useMemo(
752
+ () => ({
753
+ ...dataFromResponse,
754
+ ...documents,
755
+ idVerificationMethod: {
756
+ idVerificationMethod: "instantVerification"
757
+ }
758
+ }),
759
+ [legalEntityResponse, documents, isTargetLegalEntityType, dataFromResponse]
760
+ );
761
+ const formatters = useMemo(
762
+ () => ({
763
+ personalDetails: {
764
+ ...nameFormatters
765
+ },
766
+ address: addressFormatters
767
+ }),
768
+ []
769
+ );
770
+ const form = useMultiForm({
771
+ requiredFields: derivedProps?.requiredFields,
772
+ defaultData,
773
+ rules: individualFieldValidations,
774
+ asyncRules: individualFieldAsyncValidations,
775
+ optionalFields: derivedProps?.optionalFields,
776
+ formatters,
777
+ obscuredFields: {
778
+ personalDetails: ["idNumber"]
779
+ }
780
+ });
781
+ const { data = dataFromResponse } = form;
782
+ useEffect(() => {
783
+ setCountry(data?.personalDetails?.residencyCountry ?? parentCountry);
784
+ }, [data?.personalDetails?.residencyCountry, parentCountry]);
785
+ const { data: scenarios } = useScenarios(country, LegalEntityTypes.INDIVIDUAL);
786
+ useEffect(() => {
787
+ if (!scenarios) return;
788
+ setHasMotionCaptureScenario(scenarios);
789
+ setMatchingScenario(scenarios);
790
+ }, [scenarios]);
791
+ const { fieldConfigurations } = useScenarioConfiguration({
792
+ parseConfiguration: parseConfiguration$1,
793
+ legalEntityType: LegalEntityTypes.INDIVIDUAL,
794
+ setLoadingStatus,
795
+ country
796
+ });
797
+ const fieldsFromCustomRules = useMemo(
798
+ () => rules({
799
+ matchingScenario,
800
+ data,
801
+ country: data?.personalDetails?.residencyCountry ?? country,
802
+ taskType,
803
+ isExperimentEnabled,
804
+ rootLegalEntity: parentLegalEntity,
805
+ problems
806
+ }),
807
+ [country, matchingScenario, data, taskType, problems]
808
+ );
809
+ useEffect(() => {
810
+ const derivedProps2 = getPropsFromConfigurations({
811
+ scenarioConfiguration: fieldConfigurations,
812
+ forms: individualForms,
813
+ remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
814
+ dataMissingErrors: problems?.missingData ?? [],
815
+ fieldsWithExistingData: legalEntityResponse ? getFieldsWithExistingData(
816
+ legalEntityResponse,
817
+ individualApiKeyMapping,
818
+ individualDocumentMapping,
819
+ // We ignore these fields for the purposes of this rule because we know them to be problematic
820
+ [
821
+ "personalDetails.typeOfIdentity",
822
+ "personalDetails.idNumber",
823
+ "address.stateOrProvince",
824
+ "personalDetails.issuerState"
825
+ ]
826
+ ) : [],
827
+ customRules: fieldsFromCustomRules,
828
+ legalEntityType: legalEntityResponse?.type,
829
+ legalEntityTrustedFields: [],
830
+ remediationFieldAsOptional: true
831
+ });
832
+ const updatedDerivedProps = mandateIdVerificationForMotionCapture(
833
+ showIndividualMotionCapture?.value,
834
+ derivedProps2
835
+ );
836
+ setDerivedProps(updatedDerivedProps);
837
+ }, [
838
+ fieldConfigurations,
839
+ legalEntityResponse,
840
+ fieldsFromCustomRules,
841
+ problems?.remediationActions,
842
+ problems?.missingData
843
+ ]);
844
+ const forms = useMemo(() => {
845
+ const formsWithUpdatedName = {
846
+ ...individualForms,
847
+ idDocument: {
848
+ ...individualForms.idDocument,
849
+ formName: data.idVerificationMethod?.idVerificationMethod === "instantVerification" ? "instantVerification" : "idDocument"
850
+ }
851
+ };
852
+ const requiredForms = getRequiredForms(
853
+ formsWithUpdatedName,
854
+ derivedProps?.requiredFields,
855
+ derivedProps?.optionalFields
856
+ ).filter(
857
+ // Prevent showing the ID verification method step when onfido is not enabled
858
+ (form2) => form2.formId !== "idVerificationMethod" || providerStatus?.statuses?.idDocument?.enabled
859
+ );
860
+ return addValidityToForms(requiredForms, form.isValid, problems);
861
+ }, [
862
+ derivedProps,
863
+ form.isValid,
864
+ problems,
865
+ providerStatus?.statuses?.idDocument?.enabled,
866
+ data.idVerificationMethod?.idVerificationMethod
867
+ ]);
868
+ if (isRoleFieldNeeded && parentLegalEntity) {
869
+ roleTypes = getAllowedDecisionMakerRoles(parentLegalEntity, taskType);
870
+ }
871
+ useEffect(() => {
872
+ if (!legalEntityResponse?.documentDetails?.length) return;
873
+ documentUtils.fetchDocuments(legalEntityResponse.documentDetails, legalEntityResponse?.id).then((res) => {
874
+ setExistingAttachments(res[0].attachments);
875
+ setDocuments(mapApiDocumentToIndividualDocuments(legalEntityResponse?.id));
876
+ }).catch(() => {
877
+ showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
878
+ });
879
+ }, [legalEntityResponse]);
880
+ const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
881
+ const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
882
+ const idDocumentTypeOptions = getLocalizedIdDocumentTypeOptions(country);
883
+ const submitLegalEntity = async ({
884
+ dataSubmitted,
885
+ legalEntity,
886
+ idDocumentType
887
+ }) => {
888
+ let updatedLegalEntity;
889
+ const leId = legalEntityResponse?.id || newDecisionMaker?.id;
890
+ if (!leId) {
891
+ updatedLegalEntity = await createLegalEntity(legalEntity);
892
+ userEvents.addTaskEvent("Success", {
893
+ actionType: "submit",
894
+ legalEntityId: updatedLegalEntity.id,
895
+ entityType: updatedLegalEntity.type,
896
+ countryOfRegistration: dataSubmitted.personalDetails?.residencyCountry || null,
897
+ roles: dataSubmitted.personalDetails?.role || null
898
+ });
899
+ } else {
900
+ const patchLegalEntity = { ...drop("type").from(legalEntity), id: leId };
901
+ updatedLegalEntity = await updateLegalEntity(patchLegalEntity);
902
+ userEvents.addTaskEvent("Success", {
903
+ actionType: "submit",
904
+ legalEntityId: updatedLegalEntity.id,
905
+ entityType: updatedLegalEntity.type,
906
+ countryOfRegistration: dataSubmitted.personalDetails?.residencyCountry || null,
907
+ documentType: idDocumentType || null
908
+ });
909
+ }
910
+ return updatedLegalEntity;
911
+ };
912
+ const { mutateAsync: getIdVerificationStartCheck } = useIdVerificationStartCheck();
913
+ const handleInstantIdVerificationStartCheck = async (onfidoResponse, legalEntityId) => {
914
+ const providerId = idVerificationProviderId.value;
915
+ if (!providerId) throw Error("idVerificationProviderId not yet set");
916
+ const data2 = {
917
+ providerId,
918
+ legalEntityId,
919
+ captureMetadata: onfidoResponse
920
+ };
921
+ await getIdVerificationStartCheck(data2);
922
+ };
923
+ const submitDocuments = async ({
924
+ forms: forms2,
925
+ legalEntity,
926
+ dataSubmitted
927
+ }) => {
928
+ if (!isDocumentsRequired(forms2)) return;
929
+ if (dataSubmitted.idDocument?.instantIdVerificationData) {
930
+ if (providerStatus?.statuses?.idDocument?.enabled === false) {
931
+ throw new Error("Provider unexpectedly disabled instant verification flow");
932
+ }
933
+ await handleInstantIdVerificationStartCheck(
934
+ dataSubmitted.idDocument.instantIdVerificationData,
935
+ legalEntity.id
936
+ );
937
+ } else {
938
+ const formattedDocuments = await mapIndividualDocumentToApiDocument(
939
+ dataSubmitted,
940
+ legalEntity.id
941
+ );
942
+ if (!formattedDocuments || formattedDocuments.length === 0) {
943
+ if (existingAttachments?.length)
944
+ logger$1.log(
945
+ "User has already uploaded documents and is not changing them, nothing needs to be done"
946
+ );
947
+ else
948
+ logger$1.error(
949
+ `formattedDocuments is empty, but there are no existing documents. Something has gone wrong`
950
+ );
951
+ return;
952
+ }
953
+ formattedDocuments[0].attachments = mergeAttachments(
954
+ existingAttachments ?? [],
955
+ formattedDocuments[0]?.attachments ?? []
956
+ ).filter((attachment) => attachment.content);
957
+ const uploadedDocuments = await documentUtils.uploadDocuments(
958
+ formattedDocuments,
959
+ legalEntity.id
960
+ );
961
+ uploadedDocuments?.forEach((doc) => {
962
+ userEvents.addTaskEvent("Success", {
963
+ actionType: "upload",
964
+ documentType: doc.type,
965
+ fileExtention: doc?.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? null
966
+ });
967
+ });
968
+ }
969
+ };
970
+ const hasRolesChanged = (legalEntity, existingEntityAssociations, newRoles) => {
971
+ const existingRoles = existingEntityAssociations?.filter((ea) => ea.legalEntityId === legalEntity.id)?.map(({ type }) => type);
972
+ return !doArraysMatch(existingRoles, newRoles);
973
+ };
974
+ const attachAssociationToParentLegalEntity = async ({
975
+ legalEntity,
976
+ parentLE,
977
+ dataSubmitted
978
+ }) => {
979
+ const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER ? dataSubmitted?.personalDetails?.role : taskType === TaskTypes.TRUST_MEMBER_INDIVIDUAL || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_INDIVIDUAL ? trustMember?.roles : null;
980
+ const existingEntityAssociations = getOwnEntityAssociations(parentLE);
981
+ if (newRoles && (hasRolesChanged(legalEntity, existingEntityAssociations, newRoles) || dataFromResponse.personalDetails?.jobTitle !== dataSubmitted?.personalDetails?.jobTitle || hasNomineesChanged(dataFromResponse.personalDetails, dataSubmitted.personalDetails))) {
982
+ const updatedParentLegalEntity = {
983
+ entityAssociations: [
984
+ ...newRoles.map((role) => ({
985
+ type: role,
986
+ legalEntityId: legalEntity.id,
987
+ ...DECISION_MAKER_TYPES_WITH_JOBTITLE.some((type) => type === role) && {
988
+ jobTitle: dataSubmitted?.personalDetails?.jobTitle
989
+ }
990
+ })) || [],
991
+ ...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
992
+ ]
993
+ };
994
+ if (updatedParentLegalEntity.entityAssociations) {
995
+ updatedParentLegalEntity.entityAssociations = updatedParentLegalEntity.entityAssociations.map(
996
+ (ea) => attachNomineeToRole(ea, country, dataSubmitted.personalDetails)
997
+ );
998
+ }
999
+ await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
1000
+ }
1001
+ if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS && (existingEntityAssociations.every((ea) => ea.legalEntityId !== legalEntity.id) || dataFromResponse?.personalDetails?.relationship !== dataSubmitted?.personalDetails?.relationship)) {
1002
+ const newEntityAssociation = {
1003
+ type: "legalRepresentative",
1004
+ legalEntityId: legalEntity.id,
1005
+ relationship: dataSubmitted?.personalDetails?.relationship
1006
+ };
1007
+ const updatedParentLegalEntity = {
1008
+ entityAssociations: [newEntityAssociation, ...existingEntityAssociations]
1009
+ };
1010
+ await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
1011
+ }
1012
+ };
1013
+ const onSubmit = async () => {
1014
+ setLoadingStatus("loading");
1015
+ const dataSubmitted = omitObscuredFieldsIfUnchanged(
1016
+ individualObscuredFields,
1017
+ data,
1018
+ dataFromResponse
1019
+ );
1020
+ if (!dataSubmitted) {
1021
+ return;
1022
+ }
1023
+ try {
1024
+ const legalEntity = mapIndividualToLegalEntity(dataSubmitted);
1025
+ const idDocumentType = idDocumentTypeOptions.find(
1026
+ ({ id }) => dataSubmitted?.idDocument?.idDocumentType === id
1027
+ )?.id;
1028
+ legalEntity.entityAssociations = filterOutUnwantedAssociationsIfRootLE(
1029
+ taskType,
1030
+ legalEntityResponse,
1031
+ accountHolder || void 0
1032
+ );
1033
+ const createdLegalEntity = await submitLegalEntity({
1034
+ dataSubmitted,
1035
+ legalEntity,
1036
+ idDocumentType
1037
+ });
1038
+ setAccountHolder(accountHolder);
1039
+ await submitDocuments({ forms, legalEntity: createdLegalEntity, dataSubmitted });
1040
+ if (parentLegalEntity) {
1041
+ await attachAssociationToParentLegalEntity({
1042
+ legalEntity: createdLegalEntity,
1043
+ parentLE: parentLegalEntity,
1044
+ dataSubmitted
1045
+ });
1046
+ }
1047
+ setLoadingStatus("success");
1048
+ clearToasts();
1049
+ externalOnSubmit?.(dataSubmitted);
1050
+ } catch (e) {
1051
+ logger$1.error("Failed to update individual", e);
1052
+ if (isValidationError(e)) {
1053
+ setValidationErrors(processValidationErrors(e, TaskTypes.INDIVIDUAL));
1054
+ } else if (isMaintenanceModeError(e)) {
1055
+ showToast({
1056
+ label: i18n.get("maintenanceModeMessage"),
1057
+ variant: "error",
1058
+ duration: "indefinite"
1059
+ });
1060
+ } else {
1061
+ showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
1062
+ }
1063
+ setLoadingStatus("success");
1064
+ userEvents.addTaskEvent("Encountered error", {
1065
+ actionType: "submit",
1066
+ returnType: e.errorCode,
1067
+ returnValue: e.title
1068
+ });
1069
+ }
1070
+ };
1071
+ const isDocumentsRequired = (forms2) => forms2.some((form2) => individualDocumentForms.includes(form2.formId));
1072
+ const datasetUtils = datasetUtilities(i18n.locale);
1073
+ const formatIdDocument = (idDocument2) => {
1074
+ if (!idDocument2) return void 0;
1075
+ const documentType = idDocument2?.instantIdVerificationData ? onfidoDocumentTypeMapping.find(
1076
+ (document2) => idDocument2.instantIdVerificationData?.document_front.type === document2.id
1077
+ ) : idDocumentTypeOptions.find(({ id }) => idDocument2.idDocumentType === id);
1078
+ if (!documentType) return void 0;
1079
+ const frontPage = idDocument2.idFrontPage?.[0];
1080
+ const backPage = idDocument2.idBackPage?.[0];
1081
+ if (!frontPage) return void 0;
1082
+ return {
1083
+ documentType: i18n.get(documentType.name),
1084
+ ...backPage && documentType.hasBackPage ? {
1085
+ frontPage: frontPage.name,
1086
+ backPage: backPage.name
1087
+ } : {
1088
+ fileName: frontPage.name
1089
+ }
1090
+ };
1091
+ };
1092
+ const formatFileSummaryData = ({
1093
+ idDocument: idDocument2,
1094
+ proofOfNationalId,
1095
+ proofOfResidency,
1096
+ proofOfRelationship
1097
+ }) => {
1098
+ const proofOfNationalIdFile = proofOfNationalId?.proofOfNationalId?.[0];
1099
+ const proofOfResidencyFile = proofOfResidency?.proofOfResidency?.[0];
1100
+ const proofOfRelationshipFile = proofOfRelationship?.proofOfRelationship?.[0];
1101
+ return {
1102
+ ...(idDocument2?.idDocumentType || idDocument2?.instantIdVerificationData) && {
1103
+ idDocument: formatIdDocument(idDocument2)
1104
+ },
1105
+ ...proofOfNationalIdFile && {
1106
+ proofOfNationalId: {
1107
+ fileName: proofOfNationalIdFile.name
1108
+ }
1109
+ },
1110
+ ...proofOfResidencyFile && {
1111
+ proofOfResidency: {
1112
+ fileName: proofOfResidencyFile.name
1113
+ }
1114
+ },
1115
+ ...proofOfRelationshipFile && {
1116
+ proofOfRelationship: {
1117
+ fileName: proofOfRelationshipFile.name
1118
+ }
1119
+ }
1120
+ };
1121
+ };
1122
+ const formatDataForSummary = () => {
1123
+ let summaryData = cloneObject(data);
1124
+ if (summaryData.personalDetails?.residencyCountry) {
1125
+ summaryData.personalDetails.residencyCountry = datasetUtils.getCountryName(
1126
+ summaryData.personalDetails.residencyCountry
1127
+ );
1128
+ }
1129
+ if (summaryData.personalDetails?.nationality) {
1130
+ summaryData.personalDetails.nationality = datasetUtils.getCountryName(
1131
+ summaryData.personalDetails.nationality
1132
+ );
1133
+ }
1134
+ if (summaryData.address) {
1135
+ summaryData.address = mapAddressLabels(summaryData.address, datasetUtils);
1136
+ }
1137
+ if (isDocumentsRequired(forms)) {
1138
+ individualDocumentForms.forEach((formId) => delete summaryData[formId]);
1139
+ summaryData = { ...summaryData, ...formatFileSummaryData(data) };
1140
+ }
1141
+ if (summaryData.personalDetails?.accountHolder) {
1142
+ summaryData.personalDetails.accountHolder = i18n.get(
1143
+ summaryData.personalDetails.accountHolder
1144
+ );
1145
+ }
1146
+ if (summaryData.personalDetails?.birthDate) {
1147
+ summaryData.personalDetails.birthDate = localizeDateString(
1148
+ summaryData.personalDetails.birthDate,
1149
+ i18n.locale
1150
+ );
1151
+ }
1152
+ if (summaryData.personalDetails?.phoneNumber) {
1153
+ delete summaryData.personalDetails.phoneNumber;
1154
+ summaryData.personalDetails.phoneNumber = data.personalDetails?.phoneNumber?.number;
1155
+ }
1156
+ if (summaryData.personalDetails?.taxInformation) {
1157
+ const taxInformation = summaryData.personalDetails.taxInformation.find(
1158
+ (taxId) => taxId.country === data.personalDetails?.nationality
1159
+ );
1160
+ if (taxInformation) {
1161
+ delete summaryData.personalDetails.taxInformation;
1162
+ summaryData.personalDetails[taxInformation.type] = taxInformation.number;
1163
+ }
1164
+ }
1165
+ return summaryData;
1166
+ };
1167
+ const summaryOmittedKeys = [
1168
+ ...taskType === TaskTypes.DECISION_MAKER ? ["role"] : [],
1169
+ ...data?.personalDetails?.idNumberExempt ? ["idNumber"] : []
1170
+ ];
1171
+ const {
1172
+ handleNextClick,
1173
+ handleBackClick,
1174
+ activeForm,
1175
+ shouldValidate,
1176
+ gotoFormByFormIndex,
1177
+ steps
1178
+ } = useFormComposer({
1179
+ problems,
1180
+ externalBackClick,
1181
+ forms,
1182
+ onSubmit,
1183
+ triggerValidation: form.triggerValidation
1184
+ // TODO: figure out type of nested keys
1185
+ });
1186
+ return /* @__PURE__ */ jsx(FormContextProvider, { form, children: /* @__PURE__ */ jsx(
1187
+ FormFlow,
1188
+ {
1189
+ summary: {
1190
+ data: formatDataForSummary(),
1191
+ omitted: {
1192
+ keys: summaryOmittedKeys
1193
+ },
1194
+ problems
1195
+ },
1196
+ asModal,
1197
+ currentStep: steps.current,
1198
+ disableNextButton: hideFooter,
1199
+ forms,
1200
+ gotoFormByFormIndex,
1201
+ handleBackClick,
1202
+ handleCancelClick: handleHomeClick,
1203
+ handleNextClick,
1204
+ loadingStatus,
1205
+ totalSteps: steps.total,
1206
+ children: /* @__PURE__ */ jsx(
1207
+ Individual,
1208
+ {
1209
+ ...derivedProps,
1210
+ data,
1211
+ country,
1212
+ activeForm,
1213
+ forms,
1214
+ taskType,
1215
+ problems,
1216
+ onNext: handleNextClick,
1217
+ onBack: handleBackClick,
1218
+ setHideFooter,
1219
+ legalEntityId: legalEntityResponse?.id,
1220
+ allowedRoles: roleTypes,
1221
+ shouldValidate,
1222
+ accountHolder,
1223
+ parentLegalEntity,
1224
+ trustedFields: !parentLegalEntity ? trustedFields : associatedLegalEntityTrustedFields,
1225
+ trustedFieldsProvider,
1226
+ trustedRoles
1227
+ }
1228
+ )
1229
+ }
1230
+ ) });
1231
+ }
1232
+ const isNotOutOfRangeBirthDateValidatorRule = {
1233
+ modes: ["blur"],
1234
+ validate: (birthDate) => !isEmpty(birthDate) && new Date(birthDate) < /* @__PURE__ */ new Date(),
1235
+ errorMessage: "invalidDateOfBirth"
1236
+ };
1237
+ const buildMinimumAgeValidationRule = (minimumAge) => ({
1238
+ modes: ["blur"],
1239
+ validate: (birthDate) => !!birthDate && getAgeToday(birthDate) >= minimumAge,
1240
+ errorMessage: {
1241
+ key: "youMustXYearsOldToContinue",
1242
+ values: { minimumAge: minimumAge.toString() }
1243
+ }
1244
+ });
1245
+ const getCountrySpecificMinimumAgeValidationRule = (country) => {
1246
+ if (!country) {
1247
+ return buildMinimumAgeValidationRule(13);
1248
+ }
1249
+ if ([...euCountries, CountryCodes.UnitedKingdom, CountryCodes.Switzerland].some(
1250
+ (c) => c === country
1251
+ )) {
1252
+ return buildMinimumAgeValidationRule(16);
1253
+ }
1254
+ switch (country) {
1255
+ case CountryCodes.HongKong:
1256
+ case CountryCodes.Singapore:
1257
+ return buildMinimumAgeValidationRule(18);
1258
+ default:
1259
+ return buildMinimumAgeValidationRule(13);
1260
+ }
1261
+ };
1262
+ const additionalPersonalDetailsValidators = ({
1263
+ country,
1264
+ isExperimentEnabled = () => false,
1265
+ isSettingEnabled = () => false,
1266
+ taskType,
1267
+ idNumberType,
1268
+ idNumberExempt,
1269
+ idNumber,
1270
+ existingIdNumber,
1271
+ formVerificationErrors,
1272
+ i18n,
1273
+ taxIdNumberType
1274
+ }) => ({
1275
+ taxInformation: resolveFieldMetadata(
1276
+ taxInformationDefaultFieldConfig[country],
1277
+ {
1278
+ taxIdNumberType,
1279
+ companyType: LegalEntityTypes.INDIVIDUAL
1280
+ },
1281
+ taxInformationDefaultFieldMetadata
1282
+ )?.validators,
1283
+ birthDate: (() => {
1284
+ const baseValidators = [isNotOutOfRangeBirthDateValidatorRule];
1285
+ if (isSettingEnabled("enforceLegalAge")) {
1286
+ return [...baseValidators, buildMinimumAgeValidationRule(18)];
1287
+ }
1288
+ if (isExperimentEnabled("EnableAgeVerification")) {
1289
+ if (taskType === TaskTypes.LEGAL_REPRESENTATIVE_DETAILS) {
1290
+ return [...baseValidators, buildMinimumAgeValidationRule(18)];
1291
+ }
1292
+ return [...baseValidators, getCountrySpecificMinimumAgeValidationRule(country)];
1293
+ }
1294
+ return baseValidators;
1295
+ })(),
1296
+ ...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0,
1297
+ ...contactDetailsValidationRules,
1298
+ idNumber: (() => {
1299
+ const derivedIdNumberType = country === CountryCodes.UnitedStates ? getSSNType(formVerificationErrors, existingIdNumber) : idNumberType;
1300
+ return idNumberExempt ? {
1301
+ validate: () => {
1302
+ return idNumberExempt || !isEmpty(idNumber);
1303
+ },
1304
+ modes: ["blur"]
1305
+ } : resolveFieldMetadata(
1306
+ defaultFieldConfig[country],
1307
+ { idNumberType: derivedIdNumberType },
1308
+ defaultFieldMetadata
1309
+ )?.validators;
1310
+ })(),
1311
+ ...addressValidators({
1312
+ isExperimentEnabled,
1313
+ country,
1314
+ i18n
1315
+ })
1316
+ });
1317
+ const basicDetailsValidators = ({
1318
+ isExperimentEnabled = () => false
1319
+ }) => ({
1320
+ ...contactDetailsValidationRules,
1321
+ ...isExperimentEnabled("StrictNameAndAddressValidationV4") ? nameValidationRulesV4 : void 0
1322
+ });
1323
+ const getIdNowProviderIdentificationStatus = async (rootLegalEntityId, baseUrl, legalEntityId) => {
1324
+ return httpGet({
1325
+ baseUrl,
1326
+ path: `legalEntities/${rootLegalEntityId}/child/${legalEntityId}/provider/idnow/identification/status`,
1327
+ errorHandler: async (response) => {
1328
+ const responseData = await response;
1329
+ if (responseData.status === 404) {
1330
+ return { status: 404, message: responseData.detail, errorCode: responseData.errorCode };
1331
+ }
1332
+ }
1333
+ });
1334
+ };
1335
+ const useIdNowIdentificationStatus = (legalEntityId, options) => {
1336
+ const { rootLegalEntityId, baseUrl } = useApiContext();
1337
+ return useQuery({
1338
+ queryKey: legalEntityId === skipToken ? [] : ["idNowProviderIdentificationStatus", legalEntityId],
1339
+ queryFn: legalEntityId === skipToken ? skipToken : () => getIdNowProviderIdentificationStatus(
1340
+ rootLegalEntityId.value,
1341
+ baseUrl.value,
1342
+ legalEntityId
1343
+ ),
1344
+ ...options
1345
+ });
1346
+ };
1347
+ const idNowProviderStartIdentification = async (rootLegalEntityId, baseUrl, legalEntityId) => {
1348
+ return httpPost({
1349
+ baseUrl,
1350
+ path: `legalEntities/${rootLegalEntityId}/child/${legalEntityId}/provider/idnow/identification/start`
1351
+ });
1352
+ };
1353
+ const useIdNowStartIdentification = (legalEntityId, options) => {
1354
+ const { rootLegalEntityId, baseUrl } = useApiContext();
1355
+ return useQuery({
1356
+ queryKey: legalEntityId === skipToken ? [] : ["idNowProviderStartIdentification", legalEntityId],
1357
+ queryFn: legalEntityId === skipToken ? skipToken : () => idNowProviderStartIdentification(rootLegalEntityId.value, baseUrl.value, legalEntityId),
1358
+ ...options
1359
+ });
1360
+ };
1361
+ const idnowHeader = "adyen-kyc-idnow-header";
1362
+ const idnowVerificationHeaderIframeContainer = "adyen-kyc-idnow-verification-header-iframe-container";
1363
+ const idnowVerificationHeaderIframe = "adyen-kyc-idnow-verification-header-iframe";
1364
+ const idnowVerificationHeaderImage = "adyen-kyc-idnow-verification-header-image";
1365
+ const styles = {
1366
+ idnowHeader,
1367
+ idnowVerificationHeaderIframeContainer,
1368
+ idnowVerificationHeaderIframe,
1369
+ idnowVerificationHeaderImage
1370
+ };
1371
+ const passportFrontGreenImage = lazy(
1372
+ () => import("./passport-front-green-BL4HmtsB.js")
1373
+ );
1374
+ const isIdNowSuccessful = (status) => {
1375
+ const providerStatus = status?.providerStatus;
1376
+ return providerStatus === "SUCCESS" || providerStatus === "SUCCESS_DATA_CHANGED" || providerStatus === "REVIEW_PENDING";
1377
+ };
1378
+ const IdNowVerificationModal = ({ handleFinish }) => {
1379
+ const { t } = useTranslation(["individual", "common"]);
1380
+ const [isConfirmPresented, setIsConfirmPresented] = useState(false);
1381
+ const [genericError, setGenericError] = useState(false);
1382
+ const widgetContainerRef = useRef(null);
1383
+ const iFrameRef = useRef(null);
1384
+ const iFrameWidgetRef = useRef(null);
1385
+ const [page, setPage] = useState(1);
1386
+ const queryClient = useQueryClient();
1387
+ const { showToast } = useToastContext();
1388
+ const {
1389
+ data: idNowStatus,
1390
+ isLoading: isStatusLoading,
1391
+ refetch: refetchIdNowIdentificationStatus
1392
+ } = useIdNowIdentificationStatus(idNowModalChildEntityId.value?.id ?? skipToken, {
1393
+ enabled: !!idNowModalChildEntityId.value?.id,
1394
+ refetchOnMount: "always",
1395
+ refetchInterval: 1e4,
1396
+ // poll every 10 seconds
1397
+ retry: (failureCount, error) => {
1398
+ if ("status" in error && error.status === 404) return false;
1399
+ return failureCount < 3;
1400
+ }
1401
+ });
1402
+ const {
1403
+ data: idNowStart,
1404
+ isLoading,
1405
+ isError: idNowStartError,
1406
+ refetch: refetchIdNowStartIdentification
1407
+ } = useIdNowStartIdentification(idNowModalChildEntityId.value?.id ?? skipToken, {
1408
+ enabled: !!idNowModalChildEntityId.value?.id && page === 2
1409
+ });
1410
+ const handleDismiss = () => {
1411
+ setIsConfirmPresented(true);
1412
+ };
1413
+ const handleCancelDismiss = () => {
1414
+ setIsConfirmPresented(false);
1415
+ };
1416
+ const handleConfirmDismiss = () => {
1417
+ setPage(1);
1418
+ setGenericError(false);
1419
+ setIsConfirmPresented(false);
1420
+ showIdNowModal.value = false;
1421
+ if (idNowStartError && idNowModalChildEntityId.value?.id) {
1422
+ queryClient.resetQueries({
1423
+ queryKey: ["idNowProviderStartIdentification", idNowModalChildEntityId.value?.id]
1424
+ });
1425
+ }
1426
+ idNowModalChildEntityId.value = void 0;
1427
+ iFrameWidgetRef.current?.unmount();
1428
+ iFrameRef.current?.remove();
1429
+ handleFinish?.();
1430
+ };
1431
+ if (idNowStatus?.status === "finished") {
1432
+ if (isIdNowSuccessful(idNowStatus)) {
1433
+ showToast({
1434
+ label: t(($) => $["successfullyUpdatedDetails"], { ns: "common" }),
1435
+ variant: "success"
1436
+ });
1437
+ handleConfirmDismiss();
1438
+ } else {
1439
+ if (page === 2) {
1440
+ handleConfirmDismiss();
1441
+ }
1442
+ }
1443
+ }
1444
+ if (!isLoading && idNowStartError) {
1445
+ setGenericError(true);
1446
+ setPage(1);
1447
+ }
1448
+ const initializeIdNowWidget = useCallback(async (url) => {
1449
+ const container = widgetContainerRef.current;
1450
+ if (!container) {
1451
+ return;
1452
+ }
1453
+ const iFrame = document.createElement("iframe");
1454
+ iFrameRef.current = iFrame;
1455
+ iFrame.setAttribute("allowFullscreen", "true");
1456
+ iFrame.classList.add(styles.idnowVerificationHeaderIframe);
1457
+ iFrame.setAttribute("height", "800");
1458
+ iFrame.setAttribute(
1459
+ "allow",
1460
+ "camera *;microphone *;geolocation *;clipboard-read *;clipboard-write *"
1461
+ );
1462
+ container.appendChild(iFrame);
1463
+ try {
1464
+ iFrameWidgetRef.current = new IFrameWidget(iFrame, url, "idnow", "");
1465
+ await iFrameWidgetRef.current.mountAndWaitForResponse();
1466
+ } catch (err) {
1467
+ console.error("Error occurred:", err);
1468
+ setGenericError(true);
1469
+ setPage(1);
1470
+ }
1471
+ }, []);
1472
+ useEffect(() => {
1473
+ if (page === 2 && !isLoading && idNowStart && idNowStart?.url) {
1474
+ (async () => {
1475
+ await refetchIdNowIdentificationStatus();
1476
+ await initializeIdNowWidget(idNowStart.url);
1477
+ })();
1478
+ }
1479
+ return () => {
1480
+ iFrameWidgetRef.current?.unmount();
1481
+ iFrameRef.current?.remove();
1482
+ };
1483
+ }, [isLoading, page, initializeIdNowWidget, refetchIdNowIdentificationStatus, idNowStart]);
1484
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1485
+ !isStatusLoading && /* @__PURE__ */ jsxs(
1486
+ Modal,
1487
+ {
1488
+ size: page === 2 ? "large" : "medium",
1489
+ showCloseButton: !isLoading && !isStatusLoading,
1490
+ onClose: handleDismiss,
1491
+ ariaLabel: t(($) => $["identityVerification"], { ns: "common" }),
1492
+ children: [
1493
+ page === 1 && /* @__PURE__ */ jsx("div", { className: styles.idnowHeader, children: /* @__PURE__ */ jsx(
1494
+ LandingLayout,
1495
+ {
1496
+ media: /* @__PURE__ */ jsx(
1497
+ Image,
1498
+ {
1499
+ className: styles.idnowVerificationHeaderImage,
1500
+ lazyLoadedImage: passportFrontGreenImage
1501
+ }
1502
+ ),
1503
+ title: t(($) => $["identityVerification"], { ns: "common" }),
1504
+ description: /* @__PURE__ */ jsxs(Fragment, { children: [
1505
+ t(($) => $["idNowDescription"], { ns: "individual" }),
1506
+ /* @__PURE__ */ jsx("br", {}),
1507
+ /* @__PURE__ */ jsx("br", {}),
1508
+ getIndividualLegalEntityName(idNowModalChildEntityId.value) && t(($) => $["idNowDescriptionName"], {
1509
+ ns: "individual",
1510
+ name: getIndividualLegalEntityName(idNowModalChildEntityId.value)
1511
+ })
1512
+ ] }),
1513
+ error: !isLoading && genericError ? /* @__PURE__ */ jsx(
1514
+ Alert,
1515
+ {
1516
+ variant: "error",
1517
+ title: t(($) => $["thereWasAnErrorTryAgain"], { ns: "common" })
1518
+ }
1519
+ ) : void 0,
1520
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
1521
+ /* @__PURE__ */ jsx(
1522
+ Button,
1523
+ {
1524
+ onClick: async () => {
1525
+ setGenericError(false);
1526
+ setPage(2);
1527
+ await refetchIdNowStartIdentification();
1528
+ },
1529
+ disabled: isLoading || isStatusLoading || idNowStatus?.status === "finished" && isIdNowSuccessful(idNowStatus),
1530
+ fullWidth: true,
1531
+ children: idNowStatus?.status === "pending" ? t(($) => $["continueVerification"], { ns: "common" }) : t(($) => $["startVerification"], { ns: "common" })
1532
+ }
1533
+ ),
1534
+ /* @__PURE__ */ jsx(
1535
+ Button,
1536
+ {
1537
+ disabled: isLoading || isStatusLoading,
1538
+ variant: "tertiary",
1539
+ onClick: handleConfirmDismiss,
1540
+ fullWidth: true,
1541
+ children: t(($) => $["finishLater"], { ns: "common" })
1542
+ }
1543
+ )
1544
+ ] })
1545
+ }
1546
+ ) }),
1547
+ page === 2 && (isLoading ? /* @__PURE__ */ jsx(Loader, {}) : /* @__PURE__ */ jsx(
1548
+ "div",
1549
+ {
1550
+ ref: widgetContainerRef,
1551
+ className: styles.idnowVerificationHeaderIframeContainer
1552
+ }
1553
+ ))
1554
+ ]
1555
+ }
1556
+ ),
1557
+ isConfirmPresented && /* @__PURE__ */ jsx(
1558
+ Confirm,
1559
+ {
1560
+ confirmText: t(($) => $["leave"], { ns: "common" }),
1561
+ onCancel: handleCancelDismiss,
1562
+ onConfirm: handleConfirmDismiss,
1563
+ title: t(($) => $["unsavedChanges"], { ns: "common" })
1564
+ }
1565
+ )
1566
+ ] });
1567
+ };
1568
+ const adjustOnfidoIdentificationData = (data, apiData) => {
1569
+ const { typeOfIdentity, idNumber, idNumberExempt } = data;
1570
+ const identificationData = {
1571
+ ...apiData,
1572
+ number: idNumber,
1573
+ type: getOnfidoIdentityTypeToApiIdentityTypeMap(data)[typeOfIdentity] ?? "nationalIdNumber"
1574
+ };
1575
+ switch (typeOfIdentity) {
1576
+ case "passport":
1577
+ return {
1578
+ ...identificationData,
1579
+ cardNumber: ""
1580
+ };
1581
+ case "driversLicense":
1582
+ return {
1583
+ ...identificationData,
1584
+ expiryDate: ""
1585
+ };
1586
+ default:
1587
+ return idNumber === void 0 && idNumberExempt === void 0 ? void 0 : {
1588
+ ...identificationData,
1589
+ expiryDate: "",
1590
+ cardNumber: "",
1591
+ nationalIdExempt: apiData?.nationalIdExempt ?? !idNumber
1592
+ };
1593
+ }
1594
+ };
1595
+ const mapIndividualOnfidoSchemaToLegalEntity = (individualOnfido, isExperimentEnabled, matchingScenario) => {
1596
+ const legalEntity = {
1597
+ ...formatObject(individualOnfido, individualOnfidoApiKeyMapping),
1598
+ type: LegalEntityTypes.INDIVIDUAL
1599
+ };
1600
+ if (individualOnfido.additionalPersonalDetails) {
1601
+ if (isExperimentEnabled("EnableTaxIdRequiredForBusinessAccountsScenarios") && matchingScenario?.includes(Scenarios.L_TAXINFO) && individualOnfido.additionalPersonalDetails?.idNumber && individualOnfido.additionalPersonalDetails?.typeOfIdentity && individualOnfido.additionalPersonalDetails?.country === CountryCodes.Spain) {
1602
+ legalEntity.individual.taxInformation = [
1603
+ {
1604
+ country: individualOnfido.additionalPersonalDetails.country,
1605
+ number: individualOnfido.additionalPersonalDetails.idNumber,
1606
+ type: individualOnfido.additionalPersonalDetails.typeOfIdentity.toUpperCase()
1607
+ }
1608
+ ];
1609
+ }
1610
+ legalEntity.individual.identificationData = adjustOnfidoIdentificationData(
1611
+ individualOnfido.additionalPersonalDetails,
1612
+ legalEntity.individual.identificationData
1613
+ );
1614
+ }
1615
+ const nameLocalization = [
1616
+ mapSchemaFieldsToApiScriptLocalization(individualOnfido.basicDetails ?? {}, "jaHani"),
1617
+ mapSchemaFieldsToApiScriptLocalization(individualOnfido.basicDetails ?? {}, "jaKana")
1618
+ ].filter(({ fields }) => !isEmpty$1(fields));
1619
+ if (nameLocalization.length) {
1620
+ legalEntity.individual.name.localization = nameLocalization;
1621
+ }
1622
+ const addressLocalizations = mapJpAddressSchemaToAddressLocalizations(
1623
+ individualOnfido.additionalPersonalDetails
1624
+ );
1625
+ if (addressLocalizations.length > 0)
1626
+ legalEntity.individual.residentialAddress.localization = addressLocalizations;
1627
+ if (individualOnfido.basicDetails?.phoneNumber) {
1628
+ const phone = {
1629
+ number: individualOnfido.basicDetails.phoneNumber.number,
1630
+ type: "mobile"
1631
+ };
1632
+ if (phone.number && legalEntity.individual) {
1633
+ legalEntity.individual.phone = phone;
1634
+ } else {
1635
+ delete legalEntity?.individual?.phone;
1636
+ }
1637
+ }
1638
+ return legalEntity;
1639
+ };
1640
+ const identityOnfidoBase = {
1641
+ role: {
1642
+ rule: "requiredIfDecisionMakerTask"
1643
+ },
1644
+ firstName: {
1645
+ rule: "REQUIRED"
1646
+ },
1647
+ lastName: {
1648
+ rule: "REQUIRED"
1649
+ },
1650
+ birthDate: {
1651
+ rule: "REQUIRED"
1652
+ },
1653
+ phoneNumber: {
1654
+ rules: ["requiredIfPhoneScenarioDisabled", "contactsIfRequiredForRole"]
1655
+ },
1656
+ email: {
1657
+ rule: "contactsIfRequiredForRole"
1658
+ },
1659
+ jobTitle: {
1660
+ rule: "jobTitleIfRequiredForRole"
1661
+ },
1662
+ placeOfBirth: {
1663
+ rule: "isPlaceOfBirthRequired"
1664
+ },
1665
+ nationality: {
1666
+ rule: "nationalityIfRequiredForRole"
1667
+ },
1668
+ address: {
1669
+ rule: "addressIfRequiredForCountry"
1670
+ },
1671
+ otherAddressInformation: {
1672
+ rule: "otherAddressInfoIfRequiredForCountry"
1673
+ },
1674
+ country: {
1675
+ rule: "REQUIRED"
1676
+ },
1677
+ postalCode: {
1678
+ rule: "postalCodeIfRequiredForCountry"
1679
+ },
1680
+ city: {
1681
+ rule: "cityIfRequiredForCountry"
1682
+ },
1683
+ stateOrProvince: {
1684
+ rule: "stateOrProvinceIfRequiredForCountry"
1685
+ },
1686
+ proofOfResidency: {
1687
+ rule: "isProofOfResidencyRequired"
1688
+ },
1689
+ proofOfNationalId: {
1690
+ rule: "isProofOfNationalIdRequired"
1691
+ },
1692
+ relationship: {
1693
+ rule: "legalRepresentativeRelationshipRequired"
1694
+ },
1695
+ proofOfRelationship: {
1696
+ rule: "isProofOfRelationshipRequired"
1697
+ },
1698
+ nomineeDirector: {
1699
+ rules: ["isGuidedDecisionMakersFlowDisabled", "nomineeDirectorRequiredForCountry"]
1700
+ },
1701
+ nomineeShareholder: {
1702
+ rules: ["isGuidedDecisionMakersFlowDisabled", "nomineeShareHolderRequiredForCountry"]
1703
+ },
1704
+ idVerificationMethod: {
1705
+ rule: "isIdVerificationMethodRequired"
1706
+ },
1707
+ idDocument: {
1708
+ // (either from Onfido or previously-uploaded document)
1709
+ rule: "isUsingInstantVerificationOrHasExistingDocument"
1710
+ },
1711
+ idDocumentType: {
1712
+ // If the user has a missing ID error and chooses manual flow
1713
+ rule: "isManualIdFlowAndHasMissingData"
1714
+ },
1715
+ /**
1716
+ * Below fields only relevant if manual ID is needed
1717
+ * @see identityNumber
1718
+ * @see idDocRequired
1719
+ */
1720
+ idFrontPage: {
1721
+ rule: "hasChosenIdType"
1722
+ },
1723
+ idBackPage: {
1724
+ rule: "backPageIfRequiredForIdType"
1725
+ },
1726
+ // Fields required for Guided decision makers flow
1727
+ isSignatory: {
1728
+ rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
1729
+ },
1730
+ isOwner: {
1731
+ rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
1732
+ },
1733
+ isControllingPerson: {
1734
+ rules: ["isGuidedDecisionMakersFlowEnabled", "requiredIfDecisionMakerTask"]
1735
+ },
1736
+ isDirector: {
1737
+ rules: [
1738
+ "isGuidedDecisionMakersFlowEnabled",
1739
+ "requiredIfDecisionMakerTask",
1740
+ "isDirectorRequiredForCountry"
1741
+ ]
1742
+ },
1743
+ isNomineeDirector: {
1744
+ rules: [
1745
+ "isGuidedDecisionMakersFlowEnabled",
1746
+ "requiredIfDecisionMakerTask",
1747
+ "nomineeDirectorRequiredForCountry"
1748
+ ]
1749
+ },
1750
+ isNomineeShareholder: {
1751
+ rules: [
1752
+ "isGuidedDecisionMakersFlowEnabled",
1753
+ "requiredIfDecisionMakerTask",
1754
+ "nomineeShareHolderRequiredForCountry"
1755
+ ]
1756
+ },
1757
+ // Japanese name fields
1758
+ jaHaniFirstName: {
1759
+ rule: "japanSpecificField"
1760
+ },
1761
+ jaHaniLastName: {
1762
+ rule: "japanSpecificField"
1763
+ },
1764
+ jaKanaFirstName: {
1765
+ rule: "japanSpecificField"
1766
+ },
1767
+ jaKanaLastName: {
1768
+ rule: "japanSpecificField"
1769
+ },
1770
+ // Japanese address fields
1771
+ jaHaniAddress: {
1772
+ rule: "japanSpecificField"
1773
+ },
1774
+ jaHaniCity: {
1775
+ rule: "japanSpecificField"
1776
+ },
1777
+ jaHaniStateOrProvince: {
1778
+ rule: "japanSpecificField"
1779
+ },
1780
+ jaKanaCity: {
1781
+ rule: "japanSpecificField"
1782
+ },
1783
+ jaKanaStateOrProvince: {
1784
+ rule: "japanSpecificField"
1785
+ }
1786
+ };
1787
+ const identityNumber = {
1788
+ idNumber: {
1789
+ rule: "idNumberRules",
1790
+ obscured: true
1791
+ },
1792
+ idNumberExempt: {
1793
+ rules: ["idNumberExemptIfApplicableCountry", "isDirectorIdNumberRequiredForCountry"]
1794
+ },
1795
+ idDocumentType: {
1796
+ // If the user chooses to not provide an ID number, we'll need an ID from them
1797
+ rule: "isManualIdFlowAndNotProvidingIdNumber"
1798
+ }
1799
+ };
1800
+ const additionalIdentityInfo = {
1801
+ typeOfIdentity: {
1802
+ rules: ["requiredIfCountryUsesMultipleTypesOfIdentity", "isDirectorIdNumberRequiredForCountry"]
1803
+ },
1804
+ issuerState: {
1805
+ rule: "issuerStateRequired"
1806
+ },
1807
+ licenseCardNumber: {
1808
+ rule: "licenseCardNumberRules"
1809
+ },
1810
+ expiryDate: {
1811
+ rule: "expiryDateRequired"
1812
+ }
1813
+ };
1814
+ const idDocRequired = {
1815
+ // These fields are relevant for the manual ID flow only.
1816
+ // If we get `L1_IDDOC` then we know we need to require a manual ID upload when the manual flow is used
1817
+ idDocumentType: {
1818
+ rule: "isManualIdFlow"
1819
+ }
1820
+ };
1821
+ const nationality = {
1822
+ nationality: {
1823
+ rule: "REQUIRED"
1824
+ }
1825
+ };
1826
+ const phoneNumberBase = {
1827
+ phoneNumber: {
1828
+ rule: "contactsIfRequiredForRole"
1829
+ }
1830
+ };
1831
+ const taxInformationBase = {
1832
+ taxInformation: { rule: "countryUsesTaxId" }
1833
+ };
1834
+ const individualOnfidoFieldsPerScenario = {
1835
+ L0: drop("address", "birthDate").from(identityOnfidoBase),
1836
+ L1: identityOnfidoBase,
1837
+ L1_ID: {
1838
+ ...identityOnfidoBase,
1839
+ ...identityNumber,
1840
+ ...additionalIdentityInfo
1841
+ },
1842
+ L1_IDO: {
1843
+ // TODO: change idNumber rule to optional once optional fields are implemented
1844
+ ...identityOnfidoBase,
1845
+ ...identityNumber,
1846
+ ...additionalIdentityInfo
1847
+ },
1848
+ L1_NAT: {
1849
+ ...identityOnfidoBase,
1850
+ ...identityNumber,
1851
+ ...additionalIdentityInfo,
1852
+ ...nationality
1853
+ },
1854
+ L_TAXINFO: { ...identityOnfidoBase, ...taxInformationBase },
1855
+ L1_IDDOC: idDocRequired,
1856
+ L_PH: phoneNumberBase
1857
+ };
1858
+ const parseIndividualOnfidoScenarios = (scenarios) => composePerScenarioFormConfigurations(scenarios, individualOnfidoFieldsPerScenario);
1859
+ const parseConfiguration = ({ scenarios }) => parseIndividualOnfidoScenarios(scenarios);
1860
+ const logger = createLogger();
1861
+ function IndividualOnfidoDropin({
1862
+ taskType = TaskTypes.INDIVIDUAL,
1863
+ parentLegalEntity,
1864
+ legalEntityResponse,
1865
+ handleHomeClick,
1866
+ isTargetLegalEntityType,
1867
+ country: parentCountry,
1868
+ problems: propProblems,
1869
+ onSubmit: externalOnSubmit,
1870
+ asModal = false,
1871
+ handleBackClick: externalBackClick,
1872
+ trustedFields,
1873
+ trustedFieldsProvider,
1874
+ trustedRoles
1875
+ }) {
1876
+ const { baseUrl, rootLegalEntityId } = useApiContext();
1877
+ const { accountHolder, setAccountHolder } = useAccountHolder();
1878
+ const { i18n } = useI18nContext();
1879
+ const { t } = useTranslation("individual");
1880
+ const userEvents = useAnalyticsContext();
1881
+ const { showToast, clearToasts } = useToastContext();
1882
+ const { isExperimentEnabled } = useExperimentsContext();
1883
+ const { isSettingEnabled } = useSettingsContext();
1884
+ const queryClient = useQueryClient();
1885
+ const isGuidedDecisionMakersFlowEnabled = isExperimentEnabled("EnableGuidedDecisionMakersFlow") || isExperimentEnabled("DecisionMakersFlowOptimization_GuidedDecisionMakersFlow");
1886
+ const isGuidedDecisionMakersFlowDisabled = isExperimentEnabled("DisableGuidedDecisionMakersFlow");
1887
+ const defaultCountry = "NL";
1888
+ const { data: providerStatus } = useProviderStatus({
1889
+ providers: ["idDocument"],
1890
+ country: legalEntityResponse ? getLegalEntityCountry(legalEntityResponse) : defaultCountry
1891
+ });
1892
+ const isInstantVerificationEnabled = providerStatus?.statuses?.idDocument?.enabled ?? true;
1893
+ const { mutateAsync: updateLegalEntity } = useUpdateLegalEntity();
1894
+ const isRoleFieldNeeded = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER;
1895
+ const dataFromResponse = useMemo(() => {
1896
+ if (legalEntityResponse) {
1897
+ return mapLegalEntityToIndividualOnfidoSchema(
1898
+ legalEntityResponse,
1899
+ isTargetLegalEntityType,
1900
+ isRoleFieldNeeded,
1901
+ parentLegalEntity
1902
+ );
1903
+ }
1904
+ return {
1905
+ additionalPersonalDetails: {
1906
+ country: parentCountry
1907
+ }
1908
+ };
1909
+ }, [
1910
+ legalEntityResponse,
1911
+ parentCountry,
1912
+ isTargetLegalEntityType,
1913
+ isRoleFieldNeeded,
1914
+ parentLegalEntity
1915
+ ]);
1916
+ const [newDecisionMaker] = useState();
1917
+ const [matchingScenario, setMatchingScenario] = useState();
1918
+ const [validationErrors, setValidationErrors] = useState();
1919
+ const [loadingStatus, setLoadingStatus] = useState("success");
1920
+ const [existingAttachments, setExistingAttachments] = useState();
1921
+ const [documents, setDocuments] = useState();
1922
+ const [country, setCountry] = useState(
1923
+ dataFromResponse?.additionalPersonalDetails?.country ?? parentCountry
1924
+ );
1925
+ const [derivedProps, setDerivedProps] = useState();
1926
+ const [nextHandler, setNextHandler] = useState();
1927
+ const problems = useMemo(
1928
+ () => ({
1929
+ ...propProblems,
1930
+ validationErrors
1931
+ }),
1932
+ [propProblems, validationErrors]
1933
+ );
1934
+ const hasVerificationErrors = propProblems?.verificationErrors && Object.keys(propProblems.verificationErrors).length > 0;
1935
+ useEffect(() => {
1936
+ userEvents.updateBaseTrackingPayload({ task: taskType });
1937
+ userEvents.addTaskEvent("Landed on page", {
1938
+ actionType: "start"
1939
+ });
1940
+ }, []);
1941
+ const individualFieldValidations = useCallback(
1942
+ (data2) => ({
1943
+ basicDetails: basicDetailsValidators({
1944
+ isExperimentEnabled
1945
+ }),
1946
+ additionalPersonalDetails: additionalPersonalDetailsValidators({
1947
+ country: data2?.additionalPersonalDetails?.country ?? country,
1948
+ isExperimentEnabled,
1949
+ isSettingEnabled,
1950
+ taskType,
1951
+ idNumberType: data2?.additionalPersonalDetails?.typeOfIdentity,
1952
+ idNumberExempt: data2?.additionalPersonalDetails?.idNumberExempt,
1953
+ idNumber: data2?.additionalPersonalDetails?.idNumber,
1954
+ existingIdNumber: dataFromResponse.additionalPersonalDetails?.idNumber,
1955
+ formVerificationErrors: problems?.verificationErrors?.additionalPersonalDetails,
1956
+ i18n,
1957
+ taxIdNumberType: data2?.additionalPersonalDetails?.taxInformation?.length ? data2?.additionalPersonalDetails?.taxInformation[0]?.type : void 0
1958
+ })
1959
+ }),
1960
+ [
1961
+ country,
1962
+ dataFromResponse.additionalPersonalDetails?.idNumber,
1963
+ i18n,
1964
+ isExperimentEnabled,
1965
+ isSettingEnabled,
1966
+ problems?.verificationErrors?.additionalPersonalDetails,
1967
+ taskType
1968
+ ]
1969
+ );
1970
+ const validatePhoneNumber = useValidatePhoneNumberImperatively();
1971
+ const { mutateAsync: verifyIdNumber2 } = useVerifyIdNumber();
1972
+ const individualFieldAsyncValidations = useCallback(
1973
+ (data2) => ({
1974
+ basicDetails: {
1975
+ phoneNumber: getAsyncPhoneValidationRules(validatePhoneNumber).phoneNumber
1976
+ },
1977
+ additionalPersonalDetails: {
1978
+ idNumber: getAsyncIdNumberValidationRule(verifyIdNumber2, data2?.additionalPersonalDetails).idNumber
1979
+ }
1980
+ }),
1981
+ [verifyIdNumber2, validatePhoneNumber]
1982
+ );
1983
+ const defaultData = useMemo(() => {
1984
+ if (!documents) return dataFromResponse;
1985
+ return {
1986
+ ...dataFromResponse,
1987
+ ...drop("idDocument").from(documents),
1988
+ idVerificationMethod: {
1989
+ idDocument: documents.idDocument,
1990
+ idVerificationMethod: "existingDocument"
1991
+ }
1992
+ };
1993
+ }, [documents, dataFromResponse]);
1994
+ const form = useMultiForm({
1995
+ requiredFields: derivedProps?.requiredFields,
1996
+ defaultData,
1997
+ rules: individualFieldValidations,
1998
+ asyncRules: individualFieldAsyncValidations,
1999
+ optionalFields: derivedProps?.optionalFields,
2000
+ obscuredFields: {
2001
+ /**takes care of scenario when the 4 digit provided is wrong based on verification errors and
2002
+ * we need to show validation error for defaultData which is already saved
2003
+ **/
2004
+ additionalPersonalDetails: check4DigitSsnFailed(
2005
+ problems?.verificationErrors?.additionalPersonalDetails
2006
+ ) ? [] : ["idNumber"]
2007
+ }
2008
+ });
2009
+ const documentUtils = documentApiUtils({
2010
+ baseUrl: baseUrl.value,
2011
+ rootLegalEntityId: rootLegalEntityId.value
2012
+ });
2013
+ const { data, requiredFields } = form;
2014
+ useEffect(() => {
2015
+ setCountry(data?.additionalPersonalDetails?.country ?? parentCountry);
2016
+ }, [data?.additionalPersonalDetails?.country, parentCountry]);
2017
+ const { data: scenarios } = useScenarios(country, LegalEntityTypes.INDIVIDUAL);
2018
+ useEffect(() => {
2019
+ if (!scenarios) return;
2020
+ setHasMotionCaptureScenario(scenarios);
2021
+ setMatchingScenario(scenarios);
2022
+ }, [scenarios]);
2023
+ const { fieldConfigurations } = useScenarioConfiguration({
2024
+ parseConfiguration,
2025
+ legalEntityType: LegalEntityTypes.INDIVIDUAL,
2026
+ setLoadingStatus,
2027
+ country
2028
+ });
2029
+ const fieldsFromCustomRules = useMemo(
2030
+ () => individualOnfidoRules({
2031
+ matchingScenario,
2032
+ data,
2033
+ country: data?.additionalPersonalDetails?.country ?? country,
2034
+ taskType,
2035
+ isExperimentEnabled,
2036
+ rootLegalEntity: parentLegalEntity,
2037
+ problems
2038
+ }),
2039
+ [country, matchingScenario, data, isExperimentEnabled, parentLegalEntity, taskType, problems]
2040
+ );
2041
+ useEffect(() => {
2042
+ const derivedProps2 = getPropsFromConfigurations({
2043
+ scenarioConfiguration: fieldConfigurations,
2044
+ forms: individualOnfidoForms,
2045
+ remediationActions: problems?.remediationActions ? Object.values(problems?.remediationActions) : [],
2046
+ dataMissingErrors: problems?.missingData ?? [],
2047
+ fieldsWithExistingData: legalEntityResponse ? getFieldsWithExistingData(
2048
+ legalEntityResponse,
2049
+ individualOnfidoApiKeyMapping,
2050
+ individualOnfidoDocumentMapping,
2051
+ [
2052
+ "additionalPersonalDetails.typeOfIdentity",
2053
+ "additionalPersonalDetails.idNumber",
2054
+ "additionalPersonalDetails.stateOrProvince",
2055
+ "additionalPersonalDetails.issuerState"
2056
+ ]
2057
+ ) : [],
2058
+ customRules: fieldsFromCustomRules,
2059
+ legalEntityType: legalEntityResponse?.type,
2060
+ legalEntityTrustedFields: [],
2061
+ remediationFieldAsOptional: true
2062
+ });
2063
+ const updatedDerivedProps = mandateIdVerificationForMotionCapture(
2064
+ showIndividualMotionCapture?.value,
2065
+ derivedProps2
2066
+ );
2067
+ if (updatedDerivedProps) {
2068
+ setDerivedProps(updatedDerivedProps);
2069
+ }
2070
+ }, [
2071
+ fieldConfigurations,
2072
+ legalEntityResponse,
2073
+ fieldsFromCustomRules,
2074
+ problems?.remediationActions,
2075
+ problems?.missingData
2076
+ ]);
2077
+ useEffect(() => {
2078
+ if (!legalEntityResponse?.documentDetails?.length) return;
2079
+ documentUtils.fetchDocuments(legalEntityResponse.documentDetails, legalEntityResponse?.id).then((res) => {
2080
+ setExistingAttachments(res[0].attachments);
2081
+ setDocuments(mapApiDocumentToIndividualDocuments(legalEntityResponse?.id));
2082
+ }).catch(() => {
2083
+ showToast({ label: i18n.get("failedToFetchRelevantDocuments"), variant: "error" });
2084
+ });
2085
+ }, []);
2086
+ const forms = useMemo(() => {
2087
+ const requiredForms = getRequiredForms(
2088
+ individualOnfidoForms,
2089
+ derivedProps?.requiredFields,
2090
+ derivedProps?.optionalFields
2091
+ );
2092
+ const filteredForms = !isInstantVerificationEnabled ? requiredForms.filter((f) => f.formId !== "idVerificationMethod") : requiredForms;
2093
+ return addValidityToForms(filteredForms, form.isValid, problems);
2094
+ }, [derivedProps, form.isValid, isInstantVerificationEnabled, problems]);
2095
+ const { mutateAsync: getIdVerificationStartCheck } = useIdVerificationStartCheck();
2096
+ const handleInstantIdVerificationStartCheck = async (onfidoResponse, legalEntityId) => {
2097
+ const providerId = idVerificationProviderId.value;
2098
+ if (!providerId) throw Error("idVerificationProviderId not yet set");
2099
+ const data2 = {
2100
+ providerId,
2101
+ legalEntityId,
2102
+ captureMetadata: onfidoResponse
2103
+ };
2104
+ await getIdVerificationStartCheck(data2);
2105
+ };
2106
+ const roleTypes = isRoleFieldNeeded && parentLegalEntity ? getAllowedDecisionMakerRoles(parentLegalEntity, taskType, matchingScenario) : [];
2107
+ const { mutateAsync: createLegalEntity } = useCreateLegalEntity();
2108
+ const idDocumentTypeOptions = getLocalizedIdDocumentTypeOptions(country);
2109
+ const submitLegalEntity = async ({
2110
+ dataSubmitted,
2111
+ legalEntity,
2112
+ idDocumentType
2113
+ }) => {
2114
+ let updatedLegalEntity;
2115
+ const leId = legalEntityResponse?.id || newDecisionMaker?.id;
2116
+ if (!leId) {
2117
+ updatedLegalEntity = await createLegalEntity(legalEntity);
2118
+ userEvents.addTaskEvent("Success", {
2119
+ actionType: "submit",
2120
+ legalEntityId: updatedLegalEntity.id,
2121
+ entityType: updatedLegalEntity.type,
2122
+ countryOfRegistration: dataSubmitted.additionalPersonalDetails?.country || null,
2123
+ roles: dataSubmitted.basicDetails?.role || null
2124
+ });
2125
+ } else {
2126
+ updatedLegalEntity = await updateLegalEntity({ ...drop("type").from(legalEntity), id: leId });
2127
+ userEvents.addTaskEvent("Success", {
2128
+ actionType: "submit",
2129
+ legalEntityId: updatedLegalEntity.id,
2130
+ entityType: updatedLegalEntity.type,
2131
+ countryOfRegistration: dataSubmitted.additionalPersonalDetails?.country || null,
2132
+ documentType: idDocumentType || null
2133
+ });
2134
+ }
2135
+ return updatedLegalEntity;
2136
+ };
2137
+ const submitDocuments = async ({
2138
+ legalEntity,
2139
+ dataSubmitted
2140
+ }) => {
2141
+ const idDocument2 = dataSubmitted.idVerificationMethod?.idDocument;
2142
+ if (idDocument2?.instantIdVerificationData) {
2143
+ if (providerStatus?.statuses?.idDocument?.enabled === false) {
2144
+ throw new Error("Provider unexpectedly disabled instant verification flow");
2145
+ }
2146
+ await handleInstantIdVerificationStartCheck(
2147
+ idDocument2.instantIdVerificationData,
2148
+ legalEntity.id
2149
+ );
2150
+ } else {
2151
+ const formattedDocuments = await mapIndividualDocumentToApiDocument(
2152
+ dataSubmitted,
2153
+ legalEntity.id
2154
+ );
2155
+ if (!formattedDocuments || formattedDocuments?.length === 0) {
2156
+ if (existingAttachments?.length)
2157
+ logger.log(
2158
+ "User has already uploaded documents and is not changing them, nothing needs to be done"
2159
+ );
2160
+ else
2161
+ logger.error(
2162
+ `formattedDocuments is empty, but there are no existing documents. Something has gone wrong`
2163
+ );
2164
+ return;
2165
+ }
2166
+ formattedDocuments[0].attachments = mergeAttachments(
2167
+ existingAttachments ?? [],
2168
+ formattedDocuments[0]?.attachments ?? []
2169
+ ).filter((attachment) => attachment.content);
2170
+ const uploadedDocuments = await documentUtils.uploadDocuments(
2171
+ formattedDocuments,
2172
+ legalEntity.id
2173
+ );
2174
+ uploadedDocuments?.forEach((doc) => {
2175
+ userEvents.addTaskEvent("Success", {
2176
+ actionType: "upload",
2177
+ documentType: doc.type,
2178
+ fileExtention: doc?.attachments?.map((item) => getFileExtention(item.pageName ?? "")).filter((item) => item !== void 0) ?? null
2179
+ });
2180
+ });
2181
+ }
2182
+ };
2183
+ const hasRolesChanged = (legalEntityId, existingEntityAssociations, newRoles) => {
2184
+ const existingRoles = existingEntityAssociations?.filter((association) => association.legalEntityId === legalEntityId).map(({ type }) => type);
2185
+ return !doArraysMatch(existingRoles, newRoles);
2186
+ };
2187
+ const attachAssociationToParentLegalEntity = async ({
2188
+ legalEntity,
2189
+ parentLE,
2190
+ dataSubmitted
2191
+ }) => {
2192
+ const newRoles = taskType === TaskTypes.DECISION_MAKER || taskType === TaskTypes.TRUST_MEMBER_COMPANY_OWNER || taskType === TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER ? dataSubmitted?.basicDetails?.role : null;
2193
+ const existingEntityAssociations = getOwnEntityAssociations(parentLE);
2194
+ if (newRoles && (hasRolesChanged(legalEntity?.id, existingEntityAssociations, newRoles) || dataFromResponse.basicDetails?.jobTitle !== dataSubmitted?.basicDetails?.jobTitle || hasNomineesChanged(dataFromResponse.basicDetails, dataSubmitted.basicDetails))) {
2195
+ const updatedParentLegalEntity = {
2196
+ entityAssociations: [
2197
+ ...newRoles.map((role) => ({
2198
+ type: role,
2199
+ legalEntityId: legalEntity.id,
2200
+ ...DECISION_MAKER_TYPES_WITH_JOBTITLE$1.some((type) => type === role) && {
2201
+ jobTitle: dataSubmitted?.basicDetails?.jobTitle
2202
+ }
2203
+ })) || [],
2204
+ ...existingEntityAssociations.filter((ea) => ea.legalEntityId !== legalEntity.id) || []
2205
+ ]
2206
+ };
2207
+ const nomineeDataSource = !isGuidedDecisionMakersFlowDisabled && isGuidedDecisionMakersFlowEnabled ? dataSubmitted?.uboQuestionnaire : dataSubmitted.basicDetails;
2208
+ if (nomineeDataSource && updatedParentLegalEntity.entityAssociations) {
2209
+ updatedParentLegalEntity.entityAssociations = updatedParentLegalEntity.entityAssociations.map(
2210
+ (ea) => attachNomineeToRole(ea, country, nomineeDataSource)
2211
+ );
2212
+ }
2213
+ await updateLegalEntity({ ...updatedParentLegalEntity, id: parentLE.id });
2214
+ }
2215
+ };
2216
+ const onSubmit = async () => {
2217
+ setLoadingStatus("loading");
2218
+ const dataSubmitted = omitObscuredFieldsIfUnchanged(
2219
+ individualOnfidoObscuredFields,
2220
+ data,
2221
+ dataFromResponse
2222
+ );
2223
+ if (!dataSubmitted) {
2224
+ return;
2225
+ }
2226
+ try {
2227
+ const legalEntity = mapIndividualOnfidoSchemaToLegalEntity(
2228
+ dataSubmitted,
2229
+ isExperimentEnabled,
2230
+ matchingScenario
2231
+ );
2232
+ const idDocumentType = idDocumentTypeOptions.find(
2233
+ ({ id }) => dataSubmitted?.idVerificationMethod?.idDocument?.idDocumentType === id
2234
+ )?.id;
2235
+ legalEntity.entityAssociations = filterOutUnwantedAssociationsIfRootLE(
2236
+ taskType,
2237
+ legalEntityResponse,
2238
+ accountHolder || void 0
2239
+ );
2240
+ const submittedLegalEntity = await submitLegalEntity({
2241
+ dataSubmitted,
2242
+ legalEntity,
2243
+ idDocumentType
2244
+ });
2245
+ setAccountHolder(accountHolder);
2246
+ if (dataSubmitted.idVerificationMethod && dataSubmitted.idVerificationMethod?.idVerificationMethod !== "existingDocument" || hasVerificationErrors) {
2247
+ const isBafinSignatory = dataSubmitted?.basicDetails?.role?.includes(DecisionMakerTypes.SIGNATORY) && matchingScenario?.includes(Scenarios.L_BAFIN);
2248
+ if (!isBafinSignatory) {
2249
+ await submitDocuments({ legalEntity: submittedLegalEntity, dataSubmitted });
2250
+ }
2251
+ }
2252
+ if (parentLegalEntity) {
2253
+ await attachAssociationToParentLegalEntity({
2254
+ legalEntity: submittedLegalEntity,
2255
+ parentLE: parentLegalEntity,
2256
+ dataSubmitted
2257
+ });
2258
+ queryClient.invalidateQueries({
2259
+ queryKey: ["legalEntity", parentLegalEntity.id],
2260
+ refetchType: "all"
2261
+ });
2262
+ }
2263
+ idNowModalChildEntityId.value = submittedLegalEntity;
2264
+ setLoadingStatus("success");
2265
+ clearToasts();
2266
+ externalOnSubmit?.(dataSubmitted, matchingScenario);
2267
+ } catch (e) {
2268
+ const eventsAdditionalData = {};
2269
+ logger.error("Failed to update individual", e);
2270
+ if (isValidationError(e)) {
2271
+ const getErrors = processValidationErrors(e, TaskTypes.INDIVIDUAL);
2272
+ if (getErrors && !Object.keys(getErrors).length) {
2273
+ showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
2274
+ eventsAdditionalData.unmappedErrorNames = e.invalidFields?.map((field) => field.name).filter(Boolean);
2275
+ } else {
2276
+ setValidationErrors(getErrors);
2277
+ }
2278
+ } else if (isMaintenanceModeError(e)) {
2279
+ showToast({
2280
+ label: i18n.get("maintenanceModeMessage"),
2281
+ variant: "error",
2282
+ duration: "indefinite"
2283
+ });
2284
+ } else {
2285
+ showToast({ label: i18n.get("failedToUpdateDetails"), variant: "error" });
2286
+ }
2287
+ setLoadingStatus("success");
2288
+ userEvents.addTaskEvent("Encountered error", {
2289
+ actionType: "submit",
2290
+ additionalData: eventsAdditionalData,
2291
+ returnType: e?.errorCode,
2292
+ returnValue: e?.title || "backend"
2293
+ });
2294
+ }
2295
+ };
2296
+ const datasetUtils = datasetUtilities(i18n.locale);
2297
+ const formatIdDocument = (idDocument2) => {
2298
+ if (!idDocument2) return void 0;
2299
+ const documentType = idDocument2?.instantIdVerificationData ? onfidoDocumentTypeMapping.find(
2300
+ (document2) => idDocument2.instantIdVerificationData?.document_front.type === document2.id
2301
+ ) : idDocumentTypeOptions.find(({ id }) => idDocument2.idDocumentType === id);
2302
+ if (!documentType) return void 0;
2303
+ const frontPage = idDocument2.idFrontPage?.[0];
2304
+ const backPage = idDocument2.idBackPage?.[0];
2305
+ if (!frontPage) return void 0;
2306
+ return {
2307
+ documentType: i18n.get(documentType.name),
2308
+ ...backPage && documentType.hasBackPage ? {
2309
+ frontPage: frontPage.name,
2310
+ backPage: backPage.name
2311
+ } : {
2312
+ fileName: frontPage.name
2313
+ }
2314
+ };
2315
+ };
2316
+ const formatFileSummaryData = ({
2317
+ idVerificationMethod,
2318
+ manualIdUpload,
2319
+ proofOfNationalId,
2320
+ proofOfResidency,
2321
+ proofOfRelationship
2322
+ }) => {
2323
+ const proofOfNationalIdFile = proofOfNationalId?.proofOfNationalId?.[0];
2324
+ const proofOfResidencyFile = proofOfResidency?.proofOfResidency?.[0];
2325
+ const proofOfRelationshipFile = proofOfRelationship?.proofOfRelationship?.[0];
2326
+ const idDocument2 = idVerificationMethod?.idVerificationMethod === "manualVerification" ? manualIdUpload : idVerificationMethod?.idDocument;
2327
+ return {
2328
+ ...(idDocument2?.idDocumentType || idDocument2?.instantIdVerificationData) && {
2329
+ idDocument: formatIdDocument(idDocument2)
2330
+ },
2331
+ ...proofOfNationalIdFile && {
2332
+ proofOfNationalId: {
2333
+ fileName: proofOfNationalIdFile.name
2334
+ }
2335
+ },
2336
+ ...proofOfResidencyFile && {
2337
+ proofOfResidency: {
2338
+ fileName: proofOfResidencyFile.name
2339
+ }
2340
+ },
2341
+ ...proofOfRelationshipFile && {
2342
+ proofOfRelationship: {
2343
+ fileName: proofOfRelationshipFile.name
2344
+ }
2345
+ }
2346
+ };
2347
+ };
2348
+ const isManualVerificationOrExistingDoc = (idVerificationMethod) => idVerificationMethod === "manualVerification" || idVerificationMethod === "existingDocument";
2349
+ const formatDataForSummary = () => {
2350
+ let summaryData = cloneObject(data);
2351
+ if (summaryData?.basicDetails?.phoneNumber) {
2352
+ summaryData.basicDetails.phoneNumber = summaryData.basicDetails.phoneNumber.number;
2353
+ }
2354
+ if (summaryData.additionalPersonalDetails?.nationality) {
2355
+ summaryData.additionalPersonalDetails.nationality = datasetUtils.getCountryName(
2356
+ summaryData.additionalPersonalDetails.nationality
2357
+ );
2358
+ }
2359
+ if (data.additionalPersonalDetails) {
2360
+ if (country === CountryCodes.Japan) {
2361
+ summaryData.additionalPersonalDetails = {
2362
+ ...drop(...JP_ADDRESS_REQUIRED_FIELDS).from(summaryData.additionalPersonalDetails),
2363
+ ...mapJpAddressSummary(data.additionalPersonalDetails, datasetUtils)
2364
+ };
2365
+ } else {
2366
+ summaryData.additionalPersonalDetails = {
2367
+ ...summaryData.additionalPersonalDetails,
2368
+ ...mapAddressLabels(data.additionalPersonalDetails, datasetUtils)
2369
+ };
2370
+ }
2371
+ }
2372
+ if (summaryData.basicDetails?.accountHolder) {
2373
+ summaryData.basicDetails.accountHolder = i18n.get(summaryData.basicDetails.accountHolder);
2374
+ }
2375
+ if (summaryData.additionalPersonalDetails?.birthDate) {
2376
+ summaryData.additionalPersonalDetails.birthDate = localizeDateString(
2377
+ summaryData.additionalPersonalDetails.birthDate,
2378
+ i18n.locale
2379
+ );
2380
+ }
2381
+ if (isManualVerificationOrExistingDoc(summaryData.idVerificationMethod?.idVerificationMethod) || summaryData.proofOfResidency) {
2382
+ const fileSummaryData = formatFileSummaryData(data);
2383
+ summaryData = { ...summaryData, ...fileSummaryData };
2384
+ summaryData.manualIdUpload = { ...summaryData.idDocument };
2385
+ summaryData.idVerificationMethod.idDocument = { ...summaryData.idDocument };
2386
+ }
2387
+ if (summaryData.additionalPersonalDetails?.taxInformation) {
2388
+ const taxInformation = summaryData.additionalPersonalDetails.taxInformation.find(
2389
+ (taxId) => taxId.country === data.additionalPersonalDetails?.nationality
2390
+ );
2391
+ if (taxInformation) {
2392
+ delete summaryData.additionalPersonalDetails.taxInformation;
2393
+ summaryData.additionalPersonalDetails[taxInformation.type] = taxInformation.number;
2394
+ }
2395
+ }
2396
+ if (summaryData?.signatoryQuestionnaire) {
2397
+ summaryData.signatoryQuestionnaire = data?.signatoryQuestionnaire?.isSignatory === GuidanceQuestionValues.YES ? [i18n.get("signatorySummaryLabel")] : [];
2398
+ }
2399
+ if (summaryData?.uboQuestionnaire) {
2400
+ const roleFieldToLabelMap = {
2401
+ isOwner: "ownerSummaryLabel",
2402
+ isControllingPerson: "controllingPersonSummaryLabel",
2403
+ isDirector: "directorSummaryLabel"
2404
+ };
2405
+ summaryData.uboQuestionnaire = Object.keys(roleFieldToLabelMap).flatMap(
2406
+ (field) => data?.uboQuestionnaire?.[field] === GuidanceQuestionValues.YES ? [t(($) => $[roleFieldToLabelMap[field]])] : []
2407
+ );
2408
+ }
2409
+ return summaryData;
2410
+ };
2411
+ const omittedKeysForSummary = [
2412
+ ...taskType === TaskTypes.DECISION_MAKER ? ["role"] : [],
2413
+ ...data?.additionalPersonalDetails?.idNumberExempt ? ["idNumber"] : [],
2414
+ ...isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) ? ["idVerificationMethod", "modificationDate"] : []
2415
+ ];
2416
+ const isUploadEmpty = !data?.manualIdUpload || Object.keys(data?.manualIdUpload).length === 0;
2417
+ const omittedFormsForSummary = [
2418
+ // 1. Omit idDocument if instant OR (manual/existing AND upload is empty)
2419
+ ...data?.idVerificationMethod?.idVerificationMethod === "instantVerification" || isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) && isUploadEmpty ? ["idDocument"] : [],
2420
+ // 2. Omit idVerificationMethod if manual or existing
2421
+ ...isManualVerificationOrExistingDoc(data?.idVerificationMethod?.idVerificationMethod) ? ["idVerificationMethod"] : []
2422
+ ];
2423
+ const customLabelsForSummary = {
2424
+ idVerificationMethod: data?.idVerificationMethod?.idVerificationMethod === "instantVerification" ? "idVerificationMethod" : "idDocument"
2425
+ };
2426
+ const {
2427
+ handleNextClick,
2428
+ handleBackClick,
2429
+ activeForm,
2430
+ shouldValidate,
2431
+ gotoFormByFormIndex,
2432
+ steps
2433
+ } = useFormComposer({
2434
+ problems,
2435
+ externalBackClick,
2436
+ forms,
2437
+ onSubmit,
2438
+ triggerValidation: form.triggerValidation
2439
+ // TODO: figure out type of nested keys
2440
+ });
2441
+ const disableNextButton = computed(() => {
2442
+ const isVerificationMethod = activeForm?.formId === "idVerificationMethod";
2443
+ return isVerificationMethod && !activeForm?.isValid || isNextStepDisabled.value;
2444
+ });
2445
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2446
+ /* @__PURE__ */ jsx(Show, { when: shouldShowIdNowModal, children: /* @__PURE__ */ jsx(IdNowVerificationModal, { handleFinish: handleHomeClick }) }),
2447
+ /* @__PURE__ */ jsx(FormContextProvider, { form, children: /* @__PURE__ */ jsx(
2448
+ FormFlow,
2449
+ {
2450
+ summary: {
2451
+ data: formatDataForSummary(),
2452
+ omitted: {
2453
+ keys: omittedKeysForSummary,
2454
+ forms: omittedFormsForSummary
2455
+ },
2456
+ problems,
2457
+ labels: customLabelsForSummary
2458
+ },
2459
+ asModal,
2460
+ currentStep: steps.current,
2461
+ disableNextButton: disableNextButton.value,
2462
+ forms,
2463
+ gotoFormByFormIndex,
2464
+ handleBackClick,
2465
+ handleCancelClick: handleHomeClick,
2466
+ handleNextClick: nextHandler || handleNextClick,
2467
+ loadingStatus,
2468
+ totalSteps: steps.total,
2469
+ children: /* @__PURE__ */ jsx(
2470
+ IndividualOnfido,
2471
+ {
2472
+ ...derivedProps,
2473
+ requiredFields,
2474
+ data,
2475
+ defaultCountry: country,
2476
+ activeForm,
2477
+ forms,
2478
+ scenarios,
2479
+ taskType,
2480
+ problems,
2481
+ onNext: handleNextClick,
2482
+ onBack: handleBackClick,
2483
+ legalEntityId: legalEntityResponse?.id,
2484
+ allowedRoles: roleTypes,
2485
+ shouldValidate,
2486
+ accountHolder,
2487
+ parentLegalEntity,
2488
+ trustedFields,
2489
+ trustedFieldsProvider,
2490
+ trustedRoles,
2491
+ setNextHandler,
2492
+ handleHomeClick
2493
+ }
2494
+ )
2495
+ }
2496
+ ) })
2497
+ ] });
2498
+ }
2499
+ export {
2500
+ IndividualOnfidoDropin as I,
2501
+ IndividualDropin as a
2502
+ };