@hhgtech/hhg-components 1.29.371-beta-3 → 1.29.372

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 (545) hide show
  1. package/build/{InputDate-61e9c5a1.js → InputDate-084af3b7.js} +20 -20
  2. package/build/{LastPeriod-37f9ad03.js → LastPeriod-7920d16e.js} +1 -1
  3. package/build/{Locale-7ef9bbac.js → Locale-a034e717.js} +0 -1
  4. package/build/{MobileBottomNavigationIcon-2504f04b.js → MobileBottomNavigationIcon-ae480710.js} +3 -3
  5. package/build/{Spinner-4a73038c.js → Spinner-9bf08d65.js} +1 -1
  6. package/build/{WhatsApp-48e231e9.js → WhatsApp-73c563dc.js} +1 -1
  7. package/build/adapters.js +19 -19
  8. package/build/atoms.js +48 -48
  9. package/build/babyGrowth.js +83 -83
  10. package/build/cache.js +2 -2
  11. package/build/care.js +17 -17
  12. package/build/careBookingSearchBar.js +14 -14
  13. package/build/careBookingSearchBarV2.js +15 -15
  14. package/build/components/atoms/logo/index.d.ts +1 -1
  15. package/build/components/mantine/phone/index.d.ts +0 -2
  16. package/build/components.js +96 -96
  17. package/build/{constants-0773fc84.js → constants-3c232ac7.js} +1 -1
  18. package/build/{constants-ef70697a.js → constants-f0954264.js} +0 -1
  19. package/build/constants.js +3 -3
  20. package/build/constantsDomainLocales.js +1 -3
  21. package/build/constantsRiskScreener.js +2 -2
  22. package/build/constantsSite.js +2 -2
  23. package/build/{core-b94eb05a.js → core-35ae537b.js} +1 -1
  24. package/build/{dataTransform-866f83fb.js → dataTransform-90facc7b.js} +1 -1
  25. package/build/ecom.js +4 -4
  26. package/build/{editor-67f37f06.js → editor-b1b9b19c.js} +11 -11
  27. package/build/embeddedHeathToolCards_babyGrowth.js +23 -23
  28. package/build/embeddedHeathToolCards_babyPoop.js +19 -19
  29. package/build/embeddedHeathToolCards_babyVaccine.js +22 -22
  30. package/build/embeddedHeathToolCards_bmi_bmi.js +25 -25
  31. package/build/embeddedHeathToolCards_bmrBmr.js +25 -25
  32. package/build/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  33. package/build/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  34. package/build/embeddedHeathToolCards_pwg_pwg.js +26 -26
  35. package/build/embeddedHeathToolCards_targetHeartRate.js +27 -27
  36. package/build/esm/{InputDate-7205d5bf.js → InputDate-544d7517.js} +20 -20
  37. package/build/esm/{LastPeriod-8fb1da89.js → LastPeriod-64debefd.js} +1 -1
  38. package/build/esm/{Locale-08f0c7dd.js → Locale-3e2786ee.js} +0 -1
  39. package/build/esm/{MobileBottomNavigationIcon-46d840d7.js → MobileBottomNavigationIcon-57dcd2d5.js} +3 -3
  40. package/build/esm/{Spinner-90f339db.js → Spinner-a2b03942.js} +1 -1
  41. package/build/esm/{WhatsApp-60d6e215.js → WhatsApp-4bd22594.js} +1 -1
  42. package/build/esm/adapters.js +19 -19
  43. package/build/esm/atoms.js +48 -48
  44. package/build/esm/babyGrowth.js +83 -83
  45. package/build/esm/cache.js +2 -2
  46. package/build/esm/care.js +17 -17
  47. package/build/esm/careBookingSearchBar.js +14 -14
  48. package/build/esm/careBookingSearchBarV2.js +15 -15
  49. package/build/esm/components/atoms/logo/index.d.ts +1 -1
  50. package/build/esm/components/mantine/phone/index.d.ts +0 -2
  51. package/build/esm/components.js +96 -96
  52. package/build/esm/{constants-5c8f80dc.js → constants-46a13b0b.js} +1 -1
  53. package/build/esm/{constants-39b9db20.js → constants-5e4d9287.js} +0 -1
  54. package/build/esm/constants.js +3 -3
  55. package/build/esm/constantsDomainLocales.js +1 -3
  56. package/build/esm/constantsRiskScreener.js +2 -2
  57. package/build/esm/constantsSite.js +2 -2
  58. package/build/esm/{core-e470839e.js → core-b8fa3e33.js} +1 -1
  59. package/build/esm/{dataTransform-bf484109.js → dataTransform-1ad95d27.js} +1 -1
  60. package/build/esm/ecom.js +4 -4
  61. package/build/esm/{editor-0f2f16c6.js → editor-8213370a.js} +11 -11
  62. package/build/esm/embeddedHeathToolCards_babyGrowth.js +23 -23
  63. package/build/esm/embeddedHeathToolCards_babyPoop.js +19 -19
  64. package/build/esm/embeddedHeathToolCards_babyVaccine.js +22 -22
  65. package/build/esm/embeddedHeathToolCards_bmi_bmi.js +25 -25
  66. package/build/esm/embeddedHeathToolCards_bmrBmr.js +25 -25
  67. package/build/esm/embeddedHeathToolCards_dueDate_dueDate.js +22 -22
  68. package/build/esm/embeddedHeathToolCards_ovulation_ovulation.js +22 -22
  69. package/build/esm/embeddedHeathToolCards_pwg_pwg.js +26 -26
  70. package/build/esm/embeddedHeathToolCards_targetHeartRate.js +27 -27
  71. package/build/esm/footer.js +21 -21
  72. package/build/esm/gAssets.js +2 -2
  73. package/build/esm/{healthTools-3f8017a5.js → healthTools-84758186.js} +1 -1
  74. package/build/esm/healthToolsCardWrapper.js +18 -18
  75. package/build/esm/healthToolsForm.js +33 -33
  76. package/build/esm/hooks.js +13 -13
  77. package/build/esm/i18n.js +55 -14
  78. package/build/esm/i18nV2.js +2 -2
  79. package/build/esm/{index-631ed8f0.js → index-008fb6f5.js} +13 -13
  80. package/build/esm/{index-48aacda8.js → index-02c659dd.js} +1 -1
  81. package/build/esm/{index-f8b4f0b3.js → index-08134aa1.js} +18 -18
  82. package/build/esm/{index-22f4a880.js → index-0823f05f.js} +2 -2
  83. package/build/esm/{index-c0789666.js → index-0b7e5368.js} +17 -17
  84. package/build/esm/{index-ab6306df.js → index-0ece29aa.js} +2 -2
  85. package/build/esm/{index-fcfb5e03.js → index-15dc7ed3.js} +32 -32
  86. package/build/esm/{index-dba3c9f8.js → index-1992432a.js} +1 -1
  87. package/build/esm/{index-0042746f.js → index-2050b8fa.js} +17 -17
  88. package/build/esm/{index-463a4ac6.js → index-22e09b92.js} +16 -16
  89. package/build/esm/{index-462f2716.js → index-260a6cef.js} +16 -16
  90. package/build/esm/{index-c2757163.js → index-3283d034.js} +8 -8
  91. package/build/esm/{index-b448c622.js → index-34f81557.js} +2 -2
  92. package/build/esm/{index-ed5e4009.js → index-371d0a77.js} +2 -2
  93. package/build/esm/{index-5bfbb25e.js → index-37f46909.js} +17 -17
  94. package/build/esm/{index-a88963d3.js → index-3c7bade1.js} +2 -2
  95. package/build/esm/{index-64e7b9c3.js → index-3e33fe3d.js} +10 -10
  96. package/build/esm/{index-dc733b8a.js → index-3fe07695.js} +27 -36
  97. package/build/esm/{index-cc9c8870.js → index-40542814.js} +5 -5
  98. package/build/esm/{index-b194318f.js → index-4320a963.js} +15 -15
  99. package/build/esm/{index-5094d18a.js → index-49767cf6.js} +5 -5
  100. package/build/esm/{index-234cb2cc.js → index-49c4b81e.js} +2 -2
  101. package/build/esm/{index-2ea81f95.js → index-59b7c65e.js} +2 -2
  102. package/build/esm/{index-1f4d454e.js → index-5b5f2d0c.js} +22 -22
  103. package/build/esm/{index-e0adcb3b.js → index-6223f41c.js} +3 -3
  104. package/build/esm/{index-3a3f8652.js → index-6491bd17.js} +1 -1
  105. package/build/esm/{index-2cbac092.js → index-6e796974.js} +1 -1
  106. package/build/esm/{index-34ba8787.js → index-722df7e6.js} +4 -4
  107. package/build/esm/{index-e6c329bb.js → index-773c6e02.js} +6 -6
  108. package/build/esm/{index-2413498d.js → index-799ebe61.js} +13 -13
  109. package/build/esm/{index-c9594e55.js → index-7cdf73e7.js} +6 -6
  110. package/build/esm/{index-77220ada.js → index-83afe17a.js} +17 -17
  111. package/build/esm/{index-56ec762e.js → index-84fabe77.js} +16 -16
  112. package/build/esm/{index-e5173b05.js → index-8590aa43.js} +1 -1
  113. package/build/esm/{index-9ebcb339.js → index-87283fad.js} +13 -13
  114. package/build/esm/{index-9865e182.js → index-88a60434.js} +13 -13
  115. package/build/esm/{index-b51ea106.js → index-8a062d3b.js} +3 -3
  116. package/build/esm/{index-d854a351.js → index-9792c9b6.js} +18 -18
  117. package/build/esm/{index-857de40f.js → index-b0a09330.js} +2 -2
  118. package/build/esm/{index-603469cf.js → index-b0f6139c.js} +31 -31
  119. package/build/esm/{index-3b4d798b.js → index-b1702546.js} +2 -39
  120. package/build/esm/{index-1ad4b807.js → index-b41d6d8a.js} +21 -21
  121. package/build/esm/{index-40ab3b03.js → index-b42c9f25.js} +32 -32
  122. package/build/esm/{index-e3789b8b.js → index-b52e228a.js} +16 -16
  123. package/build/esm/{index-6eed224f.js → index-c07eed8e.js} +24 -24
  124. package/build/esm/{index-864f7b5b.js → index-c229b5b7.js} +1 -1
  125. package/build/esm/{index-e3c73f61.js → index-c85f2927.js} +2 -2
  126. package/build/esm/{index-27e79f70.js → index-cc5dd802.js} +7 -7
  127. package/build/esm/{index-7b648cab.js → index-d2bdab8c.js} +6 -6
  128. package/build/esm/{index-cfd3b8dd.js → index-d303f24d.js} +7 -7
  129. package/build/esm/{index-0978cfdd.js → index-d46d72e5.js} +2 -2
  130. package/build/esm/{index-f74a8323.js → index-d6b1760f.js} +25 -25
  131. package/build/esm/{index-c2617513.js → index-ddb8b5f9.js} +3 -3
  132. package/build/esm/{index-6cbb85ce.js → index-e00ea5ce.js} +1 -1
  133. package/build/esm/{index-652d6c84.js → index-e2f4897f.js} +3 -3
  134. package/build/esm/{index-a8c524a9.js → index-e3522239.js} +1 -1
  135. package/build/esm/{index-d77e0c23.js → index-e3abcd93.js} +1 -1
  136. package/build/esm/{index-64a61d3e.js → index-e5ebf355.js} +6 -6
  137. package/build/esm/{index-cfe7c4a6.js → index-eb34db89.js} +2 -2
  138. package/build/esm/{index-8f0d901b.js → index-f12cf95a.js} +6 -6
  139. package/build/esm/{index-07beb988.js → index-f18301b6.js} +3 -3
  140. package/build/esm/{index-44404be2.js → index-f1dfe73b.js} +3 -3
  141. package/build/esm/{index-49cbae4a.js → index-f20e08f2.js} +2 -2
  142. package/build/esm/{index-fcbbfa4b.js → index-febe5b0b.js} +2 -2
  143. package/build/esm/index.js +117 -117
  144. package/build/esm/interfaces/constants/domainLocales.d.ts +0 -2
  145. package/build/esm/interfaces/constants/index.d.ts +1 -1
  146. package/build/esm/interfaces/types/Locale.d.ts +1 -2
  147. package/build/esm/interfaces/types/index.d.ts +1 -2
  148. package/build/esm/{labelSorting-9cf83f21.js → labelSorting-4590af02.js} +4 -4
  149. package/build/esm/lead/helpers.d.ts +1 -56
  150. package/build/esm/lead/index.d.ts +2 -2
  151. package/build/esm/lead/layouts/lightbox/formContext.d.ts +1 -2
  152. package/build/esm/lead/leadGenContext.d.ts +1 -0
  153. package/build/esm/lead/services/index.d.ts +0 -19
  154. package/build/esm/lead/store/index.d.ts +0 -1
  155. package/build/esm/lead.css +1 -1
  156. package/build/esm/lead.js +1037 -2234
  157. package/build/esm/{logoIcon-cb8e0653.js → logoIcon-8a63b46b.js} +2 -8
  158. package/build/esm/mantine.js +25 -25
  159. package/build/esm/misc.js +17 -17
  160. package/build/esm/miscGetDynamicHealthTool.js +4 -4
  161. package/build/esm/miscGetSocialList.js +8 -8
  162. package/build/esm/miscScreenSizeContext.js +1 -1
  163. package/build/esm/mobileBottomNavigation.js +5 -5
  164. package/build/esm/mobileBottomNavigationIcon.js +5 -5
  165. package/build/esm/molecules.js +73 -73
  166. package/build/esm/moleculesArticleCard.js +6 -6
  167. package/build/esm/moleculesArticleCardV2.js +16 -16
  168. package/build/esm/navigation.js +45 -45
  169. package/build/esm/navigationLogoutPopup.js +9 -9
  170. package/build/esm/navigationProfileButton.js +23 -23
  171. package/build/esm/onboardingV2.js +29 -29
  172. package/build/esm/organisms.js +49 -49
  173. package/build/esm/{post-ed72f334.js → post-a4e3b00b.js} +2 -2
  174. package/build/esm/profileNavigation.js +19 -19
  175. package/build/esm/progressBar.js +1 -1
  176. package/build/esm/pwg.js +22 -22
  177. package/build/esm/ssoV2/api/featureFlag.d.ts +1 -2
  178. package/build/esm/ssoV2.js +39 -51
  179. package/build/esm/{store-8c2e40e8.js → store-a9c2a3c4.js} +4 -4
  180. package/build/esm/subot.js +35 -35
  181. package/build/esm/surveyOrPremiumBanner.js +32 -32
  182. package/build/esm/surveyQuestionCard.js +10 -10
  183. package/build/esm/{surveyThankyouCard-df288b5b.js → surveyThankyouCard-f1e71ef9.js} +5 -5
  184. package/build/esm/together.js +55 -55
  185. package/build/esm/togetherApiUtils.js +4 -4
  186. package/build/esm/togetherAtoms.js +30 -30
  187. package/build/esm/togetherComponentGlobalContext.js +4 -4
  188. package/build/esm/togetherMolecules.js +50 -50
  189. package/build/esm/togetherMoleculesCardAuthor.js +28 -28
  190. package/build/esm/togetherMoleculesPostImagePreview.js +11 -11
  191. package/build/esm/togetherMoleculesProfileDetail.js +38 -38
  192. package/build/esm/togetherOrganisms.js +49 -49
  193. package/build/esm/togetherRichTextEditor.js +17 -17
  194. package/build/esm/togetherShareBox.js +10 -10
  195. package/build/esm/{treePopoverMenu-f55ffb06.js → treePopoverMenu-2b4a0ce7.js} +19 -19
  196. package/build/esm/{types-fe17cb13.js → types-00647e82.js} +2 -2
  197. package/build/esm/types.js +2 -2
  198. package/build/esm/{useCategory-485df8ce.js → useCategory-b156220e.js} +5 -18
  199. package/build/esm/{useHealthToolCache-21c2c43e.js → useHealthToolCache-83bc2007.js} +1 -1
  200. package/build/esm/{useMantineLocale-6f10e30e.js → useMantineLocale-75d3a92b.js} +6 -8
  201. package/build/esm/{usePlacesAutocomplete-1043aded.js → usePlacesAutocomplete-be5196d7.js} +1 -1
  202. package/build/esm/{useScreenSize-caf0dd66.js → useScreenSize-9091e971.js} +2 -2
  203. package/build/esm/useTogetherAuthRequiredAction.js +9 -9
  204. package/build/esm/{utils-608e1033.js → utils-0d32cd95.js} +4 -4
  205. package/build/esm/{utils-0cb064a5.js → utils-654cc220.js} +2 -2
  206. package/build/esm/{utils-4d4e79bb.js → utils-c6d483d6.js} +3 -3
  207. package/build/esm/{utils-be2c60b0.js → utils-d3607ebf.js} +2 -2
  208. package/build/esm/vaccination.js +21 -21
  209. package/build/footer.js +21 -21
  210. package/build/gAssets.js +2 -2
  211. package/build/{healthTools-6a9f073b.js → healthTools-5d43fdba.js} +1 -1
  212. package/build/healthToolsCardWrapper.js +18 -18
  213. package/build/healthToolsForm.js +33 -33
  214. package/build/hooks.js +13 -13
  215. package/build/i18n.js +56 -16
  216. package/build/i18nV2.js +1 -1
  217. package/build/{index-a3e1ea36.js → index-015decac.js} +13 -13
  218. package/build/{index-05aa2361.js → index-022360ea.js} +2 -2
  219. package/build/{index-2c675ca4.js → index-04336ab9.js} +1 -1
  220. package/build/{index-3be634dd.js → index-04fded65.js} +1 -1
  221. package/build/{index-d4eecf33.js → index-064c06f3.js} +5 -5
  222. package/build/{index-f40aef22.js → index-0b1b3404.js} +3 -3
  223. package/build/{index-07842b92.js → index-0ccd6ab4.js} +18 -18
  224. package/build/{index-2c5ea2c0.js → index-109bc0ba.js} +16 -16
  225. package/build/{index-0c52d734.js → index-153b215b.js} +16 -16
  226. package/build/{index-4de45eec.js → index-1832c923.js} +1 -1
  227. package/build/{index-d3e5cfef.js → index-1dca06d3.js} +31 -31
  228. package/build/{index-6748439e.js → index-1e3ef673.js} +8 -8
  229. package/build/{index-9df0ac34.js → index-1e5869a0.js} +1 -1
  230. package/build/{index-770e2eb7.js → index-1ffd87e6.js} +6 -6
  231. package/build/{index-6d5de17c.js → index-2aa39a80.js} +15 -15
  232. package/build/{index-4c0627ae.js → index-312f141b.js} +3 -3
  233. package/build/{index-347b5bb1.js → index-32d56013.js} +2 -2
  234. package/build/{index-c2596ec2.js → index-33c24fd1.js} +13 -13
  235. package/build/{index-81637606.js → index-349d4ad5.js} +3 -3
  236. package/build/{index-54b96999.js → index-3acf4291.js} +1 -1
  237. package/build/{index-bfa8f8e1.js → index-3b559014.js} +6 -6
  238. package/build/{index-080b0aaf.js → index-3c9b6c14.js} +1 -1
  239. package/build/{index-b0be7fa8.js → index-3d0f0804.js} +2 -2
  240. package/build/{index-fdc1ccc3.js → index-3d49b533.js} +17 -17
  241. package/build/{index-2dde1f98.js → index-4f50c9a6.js} +4 -4
  242. package/build/{index-f651a751.js → index-576a7b83.js} +32 -32
  243. package/build/{index-ebd7b720.js → index-578b7adc.js} +2 -2
  244. package/build/{index-cd6ddf39.js → index-5874eb30.js} +7 -7
  245. package/build/{index-c5c2105e.js → index-6427efb3.js} +32 -32
  246. package/build/{index-5f6ebc77.js → index-6433425b.js} +6 -6
  247. package/build/{index-81a96c8d.js → index-669549a2.js} +2 -2
  248. package/build/{index-87d3b911.js → index-6e1d6d78.js} +2 -2
  249. package/build/{index-2e482c2e.js → index-73816dbf.js} +16 -16
  250. package/build/{index-79296333.js → index-7a0bbb05.js} +2 -39
  251. package/build/{index-b3c66e75.js → index-7d70d6d9.js} +2 -2
  252. package/build/{index-61cd7af4.js → index-7fc6a742.js} +3 -3
  253. package/build/{index-5b0db148.js → index-86e1489b.js} +3 -3
  254. package/build/{index-13879fc8.js → index-892e05e3.js} +13 -13
  255. package/build/{index-78e2cb65.js → index-8a505064.js} +17 -17
  256. package/build/{index-e0bdefdd.js → index-90c3bd51.js} +2 -2
  257. package/build/{index-7013062e.js → index-95d0866e.js} +22 -22
  258. package/build/{index-93bc0075.js → index-964bebd5.js} +2 -2
  259. package/build/{index-696ae54c.js → index-9e545145.js} +17 -17
  260. package/build/{index-9f0bcaee.js → index-9ed8f15e.js} +6 -6
  261. package/build/{index-47c560a5.js → index-a67e5b8c.js} +2 -2
  262. package/build/{index-a90113f4.js → index-b15cd09e.js} +2 -2
  263. package/build/{index-ffaf8d8a.js → index-b7e2e5d7.js} +2 -2
  264. package/build/{index-565a5e20.js → index-b98ed131.js} +13 -13
  265. package/build/{index-9cf6031b.js → index-bcf83833.js} +17 -17
  266. package/build/{index-178544eb.js → index-bcffdc4e.js} +3 -3
  267. package/build/{index-56f422b6.js → index-c234311f.js} +16 -16
  268. package/build/{index-0e998580.js → index-c349ac59.js} +18 -18
  269. package/build/{index-6ec9d3b4.js → index-c4fdcb5d.js} +25 -25
  270. package/build/{index-4dda9970.js → index-c6c79524.js} +5 -5
  271. package/build/{index-1ec480a4.js → index-d59daad9.js} +21 -21
  272. package/build/{index-00e0387f.js → index-d93867ea.js} +1 -1
  273. package/build/{index-f6fe92be.js → index-dc9d63cb.js} +10 -10
  274. package/build/{index-c721c3c3.js → index-e6d89d93.js} +7 -7
  275. package/build/{index-8860da28.js → index-e7f91600.js} +1 -1
  276. package/build/{index-0739a213.js → index-f0871b13.js} +2 -2
  277. package/build/{index-56dd9661.js → index-f1240784.js} +6 -6
  278. package/build/{index-686b3e59.js → index-fa0f1dec.js} +1 -1
  279. package/build/{index-caea14e2.js → index-ff7f8fd0.js} +24 -24
  280. package/build/{index-125f65cd.js → index-ffa29b44.js} +27 -36
  281. package/build/index.js +117 -117
  282. package/build/interfaces/constants/domainLocales.d.ts +0 -2
  283. package/build/interfaces/constants/index.d.ts +1 -1
  284. package/build/interfaces/types/Locale.d.ts +1 -2
  285. package/build/interfaces/types/index.d.ts +1 -2
  286. package/build/{labelSorting-ddd1f2ce.js → labelSorting-7570276e.js} +4 -4
  287. package/build/lead/helpers.d.ts +1 -56
  288. package/build/lead/index.d.ts +2 -2
  289. package/build/lead/layouts/lightbox/formContext.d.ts +1 -2
  290. package/build/lead/leadGenContext.d.ts +1 -0
  291. package/build/lead/services/index.d.ts +0 -19
  292. package/build/lead/store/index.d.ts +0 -1
  293. package/build/lead.css +1 -1
  294. package/build/lead.js +1033 -2231
  295. package/build/{logoIcon-10d4c2c7.js → logoIcon-a0093830.js} +2 -8
  296. package/build/mantine.js +22 -22
  297. package/build/misc.js +17 -17
  298. package/build/miscGetDynamicHealthTool.js +4 -4
  299. package/build/miscGetSocialList.js +8 -8
  300. package/build/miscScreenSizeContext.js +1 -1
  301. package/build/mobileBottomNavigation.js +5 -5
  302. package/build/mobileBottomNavigationIcon.js +5 -5
  303. package/build/molecules.js +73 -73
  304. package/build/moleculesArticleCard.js +6 -6
  305. package/build/moleculesArticleCardV2.js +16 -16
  306. package/build/navigation.js +45 -45
  307. package/build/navigationLogoutPopup.js +9 -9
  308. package/build/navigationProfileButton.js +23 -23
  309. package/build/onboardingV2.js +28 -28
  310. package/build/organisms.js +49 -49
  311. package/build/{post-71dba53e.js → post-8b3ec323.js} +2 -2
  312. package/build/profileNavigation.js +19 -19
  313. package/build/progressBar.js +1 -1
  314. package/build/pwg.js +22 -22
  315. package/build/ssoV2/api/featureFlag.d.ts +1 -2
  316. package/build/ssoV2.js +37 -49
  317. package/build/{store-162831bf.js → store-3bb34d08.js} +4 -4
  318. package/build/subot.js +34 -34
  319. package/build/surveyOrPremiumBanner.js +32 -32
  320. package/build/surveyQuestionCard.js +10 -10
  321. package/build/{surveyThankyouCard-04e30b65.js → surveyThankyouCard-40fde7aa.js} +5 -5
  322. package/build/together.js +55 -55
  323. package/build/togetherApiUtils.js +4 -4
  324. package/build/togetherAtoms.js +30 -30
  325. package/build/togetherComponentGlobalContext.js +4 -4
  326. package/build/togetherMolecules.js +50 -50
  327. package/build/togetherMoleculesCardAuthor.js +28 -28
  328. package/build/togetherMoleculesPostImagePreview.js +11 -11
  329. package/build/togetherMoleculesProfileDetail.js +38 -38
  330. package/build/togetherOrganisms.js +49 -49
  331. package/build/togetherRichTextEditor.js +17 -17
  332. package/build/togetherShareBox.js +10 -10
  333. package/build/{treePopoverMenu-102e209a.js → treePopoverMenu-9f4d0f7d.js} +19 -19
  334. package/build/{types-8648a9f6.js → types-709ee706.js} +2 -2
  335. package/build/types.js +2 -2
  336. package/build/{useCategory-edc47b24.js → useCategory-889d8b9e.js} +5 -18
  337. package/build/{useHealthToolCache-7ac7bc8b.js → useHealthToolCache-dd27ba92.js} +1 -1
  338. package/build/{useMantineLocale-cbfcee76.js → useMantineLocale-aa4e4cdc.js} +6 -8
  339. package/build/{usePlacesAutocomplete-d9c9d190.js → usePlacesAutocomplete-60f0a6d0.js} +1 -1
  340. package/build/{useScreenSize-5edbf21b.js → useScreenSize-013494cb.js} +2 -2
  341. package/build/useTogetherAuthRequiredAction.js +9 -9
  342. package/build/{utils-b86dfeef.js → utils-0a036093.js} +3 -3
  343. package/build/{utils-55566c6a.js → utils-bb4ffbb8.js} +2 -2
  344. package/build/{utils-b9463401.js → utils-c3214203.js} +4 -4
  345. package/build/{utils-ed4bc922.js → utils-cfbfcd70.js} +2 -2
  346. package/build/vaccination.js +21 -21
  347. package/package.json +3 -3
  348. package/build/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  349. package/build/components/mantine/phoneInput/index.d.ts +0 -1
  350. package/build/esm/components/mantine/phoneInput/PhoneInput.d.ts +0 -17
  351. package/build/esm/components/mantine/phoneInput/index.d.ts +0 -1
  352. package/build/esm/i18n-values/zh-CN.js +0 -855
  353. package/build/esm/lead/LeadGen.type.d.ts +0 -31
  354. package/build/esm/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  355. package/build/esm/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  356. package/build/esm/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  357. package/build/esm/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  358. package/build/esm/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  359. package/build/esm/lead/LeadGenForm/index.d.ts +0 -3
  360. package/build/esm/lead/LeadGenForm/textField/index.d.ts +0 -13
  361. package/build/esm/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  362. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  363. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  364. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  365. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  366. package/build/esm/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  367. package/build/esm/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  368. package/build/esm/lead/LeadGenTranslationContext.d.ts +0 -6
  369. package/build/esm/translationsProvider-598fb4c6.js +0 -55
  370. package/build/i18n-values/zh-CN.js +0 -866
  371. package/build/lead/LeadGen.type.d.ts +0 -31
  372. package/build/lead/LeadGenForm/LeadGenForm.d.ts +0 -41
  373. package/build/lead/LeadGenForm/LeadGenForm.helpers.d.ts +0 -2
  374. package/build/lead/LeadGenForm/LeadGenForm.styled.d.ts +0 -5
  375. package/build/lead/LeadGenForm/LeadGenFormPhone.d.ts +0 -17
  376. package/build/lead/LeadGenForm/LeadGenThankYou.d.ts +0 -20
  377. package/build/lead/LeadGenForm/index.d.ts +0 -3
  378. package/build/lead/LeadGenForm/textField/index.d.ts +0 -13
  379. package/build/lead/LeadGenForm/textField/index.styled.d.ts +0 -11
  380. package/build/lead/LeadGenSubscriptionBox/LeadGenContext.d.ts +0 -63
  381. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.d.ts +0 -4
  382. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBox.styled.d.ts +0 -21
  383. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxA.d.ts +0 -3
  384. package/build/lead/LeadGenSubscriptionBox/LeadGenSubscriptionBoxContainer.d.ts +0 -23
  385. package/build/lead/LeadGenSubscriptionBox/index.d.ts +0 -1
  386. package/build/lead/LeadGenTranslationContext.d.ts +0 -6
  387. package/build/translationsProvider-b383e3b6.js +0 -62
  388. /package/build/{BMI_BOYS.percentile.monthly-35aa5ebe.js → BMI_BOYS.percentile.monthly-f5295f7f.js} +0 -0
  389. /package/build/{BMI_BOYS.percentile.weekly-06d286f6.js → BMI_BOYS.percentile.weekly-e89f6859.js} +0 -0
  390. /package/build/{BMI_BOYS.percentile.yearly-d68cbaef.js → BMI_BOYS.percentile.yearly-206f392e.js} +0 -0
  391. /package/build/{BMI_BOYS.zscore.monthly-d778ca5f.js → BMI_BOYS.zscore.monthly-62cfeba2.js} +0 -0
  392. /package/build/{BMI_BOYS.zscore.weekly-d40d219b.js → BMI_BOYS.zscore.weekly-aa9c8d30.js} +0 -0
  393. /package/build/{BMI_BOYS.zscore.yearly-b6efcc79.js → BMI_BOYS.zscore.yearly-40a612b4.js} +0 -0
  394. /package/build/{BMI_GIRLS.percentile.monthly-0d426264.js → BMI_GIRLS.percentile.monthly-81b1a5b7.js} +0 -0
  395. /package/build/{BMI_GIRLS.percentile.weekly-936b386f.js → BMI_GIRLS.percentile.weekly-b90e7d68.js} +0 -0
  396. /package/build/{BMI_GIRLS.percentile.yearly-af29294d.js → BMI_GIRLS.percentile.yearly-78565dff.js} +0 -0
  397. /package/build/{BMI_GIRLS.zscore.monthly-d9f1c7b0.js → BMI_GIRLS.zscore.monthly-bf3313da.js} +0 -0
  398. /package/build/{BMI_GIRLS.zscore.weekly-23490287.js → BMI_GIRLS.zscore.weekly-76c59850.js} +0 -0
  399. /package/build/{BMI_GIRLS.zscore.yearly-a846aa7d.js → BMI_GIRLS.zscore.yearly-b45db558.js} +0 -0
  400. /package/build/{ChevronDown-5961731d.js → ChevronDown-4d7e527c.js} +0 -0
  401. /package/build/{Close-74cf47e8.js → Close-88109e78.js} +0 -0
  402. /package/build/{Google-d0c35b20.js → Google-18b395b8.js} +0 -0
  403. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-77226b6c.js → HEAD CIRCUM_BOYS.percentile.monthly-c5365f78.js} +0 -0
  404. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-72e7afe1.js → HEAD CIRCUM_BOYS.percentile.weekly-ba1be07f.js} +0 -0
  405. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-98efbbf7.js → HEAD CIRCUM_BOYS.percentile.yearly-0d9ff7de.js} +0 -0
  406. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-3af2a621.js → HEAD CIRCUM_BOYS.zscore.monthly-293579ed.js} +0 -0
  407. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-747e6068.js → HEAD CIRCUM_BOYS.zscore.weekly-d4476f55.js} +0 -0
  408. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-c0e7f52b.js → HEAD CIRCUM_BOYS.zscore.yearly-b7f64416.js} +0 -0
  409. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-d7461423.js → HEAD CIRCUM_GIRLS.percentile.monthly-30829c3b.js} +0 -0
  410. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-efc23b48.js → HEAD CIRCUM_GIRLS.percentile.weekly-2f227a0a.js} +0 -0
  411. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-eed57f44.js → HEAD CIRCUM_GIRLS.percentile.yearly-ab05fba4.js} +0 -0
  412. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-46108e64.js → HEAD CIRCUM_GIRLS.zscore.monthly-9e41bb48.js} +0 -0
  413. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-c8b69243.js → HEAD CIRCUM_GIRLS.zscore.weekly-07fdf8b4.js} +0 -0
  414. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-aa19583f.js → HEAD CIRCUM_GIRLS.zscore.yearly-3d09a791.js} +0 -0
  415. /package/build/{HEIGHT_BOYS.percentile.monthly-1ce70df3.js → HEIGHT_BOYS.percentile.monthly-58875bdd.js} +0 -0
  416. /package/build/{HEIGHT_BOYS.percentile.weekly-f2bb70b7.js → HEIGHT_BOYS.percentile.weekly-0614ac80.js} +0 -0
  417. /package/build/{HEIGHT_BOYS.percentile.yearly-e4d04b02.js → HEIGHT_BOYS.percentile.yearly-b992897c.js} +0 -0
  418. /package/build/{HEIGHT_BOYS.zscore.monthly-c2bbcded.js → HEIGHT_BOYS.zscore.monthly-4b1bcf27.js} +0 -0
  419. /package/build/{HEIGHT_BOYS.zscore.weekly-0f41d68c.js → HEIGHT_BOYS.zscore.weekly-77c0776c.js} +0 -0
  420. /package/build/{HEIGHT_BOYS.zscore.yearly-a99fec6a.js → HEIGHT_BOYS.zscore.yearly-5dc8e6a1.js} +0 -0
  421. /package/build/{HEIGHT_GIRLS.percentile.monthly-ebbb538b.js → HEIGHT_GIRLS.percentile.monthly-cc99017e.js} +0 -0
  422. /package/build/{HEIGHT_GIRLS.percentile.weekly-1fd31eca.js → HEIGHT_GIRLS.percentile.weekly-fae4e9f9.js} +0 -0
  423. /package/build/{HEIGHT_GIRLS.percentile.yearly-f732d518.js → HEIGHT_GIRLS.percentile.yearly-bc7c5e30.js} +0 -0
  424. /package/build/{HEIGHT_GIRLS.zscore.monthly-a9088cff.js → HEIGHT_GIRLS.zscore.monthly-2a6220ef.js} +0 -0
  425. /package/build/{HEIGHT_GIRLS.zscore.weekly-3af9512e.js → HEIGHT_GIRLS.zscore.weekly-c676eacf.js} +0 -0
  426. /package/build/{HEIGHT_GIRLS.zscore.yearly-60b3eab0.js → HEIGHT_GIRLS.zscore.yearly-eec4124e.js} +0 -0
  427. /package/build/{Visible-24f4ae37.js → Visible-49e0cc9d.js} +0 -0
  428. /package/build/{WEIGHT_BOYS.percentile.monthly-937f229b.js → WEIGHT_BOYS.percentile.monthly-14105231.js} +0 -0
  429. /package/build/{WEIGHT_BOYS.percentile.weekly-573412d4.js → WEIGHT_BOYS.percentile.weekly-7bb55772.js} +0 -0
  430. /package/build/{WEIGHT_BOYS.percentile.yearly-8b8ad9fe.js → WEIGHT_BOYS.percentile.yearly-d5d911a6.js} +0 -0
  431. /package/build/{WEIGHT_BOYS.zscore.monthly-c20b7ddc.js → WEIGHT_BOYS.zscore.monthly-67f28812.js} +0 -0
  432. /package/build/{WEIGHT_BOYS.zscore.weekly-17ff91ca.js → WEIGHT_BOYS.zscore.weekly-c5749492.js} +0 -0
  433. /package/build/{WEIGHT_BOYS.zscore.yearly-bf2e850b.js → WEIGHT_BOYS.zscore.yearly-f9dfc214.js} +0 -0
  434. /package/build/{WEIGHT_GIRLS.percentile.monthly-6deb23bc.js → WEIGHT_GIRLS.percentile.monthly-863b5e58.js} +0 -0
  435. /package/build/{WEIGHT_GIRLS.percentile.weekly-603d00e9.js → WEIGHT_GIRLS.percentile.weekly-97e5da17.js} +0 -0
  436. /package/build/{WEIGHT_GIRLS.percentile.yearly-60cdc8d1.js → WEIGHT_GIRLS.percentile.yearly-540af1d1.js} +0 -0
  437. /package/build/{WEIGHT_GIRLS.zscore.monthly-14c20f6f.js → WEIGHT_GIRLS.zscore.monthly-79fe6b74.js} +0 -0
  438. /package/build/{WEIGHT_GIRLS.zscore.weekly-394bbf62.js → WEIGHT_GIRLS.zscore.weekly-0ec74845.js} +0 -0
  439. /package/build/{WEIGHT_GIRLS.zscore.yearly-04c5803f.js → WEIGHT_GIRLS.zscore.yearly-7e811cf4.js} +0 -0
  440. /package/build/{animation-98f0f673.js → animation-13c1efd7.js} +0 -0
  441. /package/build/{constants-c84c0a84.js → constants-0dc7ef32.js} +0 -0
  442. /package/build/{constants-15fd8e3c.js → constants-4b2fea40.js} +0 -0
  443. /package/build/{dataTransform-466b2cef.js → dataTransform-ed106647.js} +0 -0
  444. /package/build/{doctor-e368b391.js → doctor-b018f684.js} +0 -0
  445. /package/build/esm/{BMI_BOYS.percentile.monthly-d847cb51.js → BMI_BOYS.percentile.monthly-eca08d1b.js} +0 -0
  446. /package/build/esm/{BMI_BOYS.percentile.weekly-28f99e79.js → BMI_BOYS.percentile.weekly-0f36c0a5.js} +0 -0
  447. /package/build/esm/{BMI_BOYS.percentile.yearly-e17cdcd7.js → BMI_BOYS.percentile.yearly-de605740.js} +0 -0
  448. /package/build/esm/{BMI_BOYS.zscore.monthly-c1bcc29a.js → BMI_BOYS.zscore.monthly-871240d7.js} +0 -0
  449. /package/build/esm/{BMI_BOYS.zscore.weekly-87c39d2a.js → BMI_BOYS.zscore.weekly-53e9361f.js} +0 -0
  450. /package/build/esm/{BMI_BOYS.zscore.yearly-c34d70cd.js → BMI_BOYS.zscore.yearly-693c5ba7.js} +0 -0
  451. /package/build/esm/{BMI_GIRLS.percentile.monthly-9b3d44a4.js → BMI_GIRLS.percentile.monthly-af445923.js} +0 -0
  452. /package/build/esm/{BMI_GIRLS.percentile.weekly-1bd0fd46.js → BMI_GIRLS.percentile.weekly-038c1d84.js} +0 -0
  453. /package/build/esm/{BMI_GIRLS.percentile.yearly-914d5a00.js → BMI_GIRLS.percentile.yearly-ad96c33e.js} +0 -0
  454. /package/build/esm/{BMI_GIRLS.zscore.monthly-ec794401.js → BMI_GIRLS.zscore.monthly-d1463624.js} +0 -0
  455. /package/build/esm/{BMI_GIRLS.zscore.weekly-97f06d42.js → BMI_GIRLS.zscore.weekly-7d60db22.js} +0 -0
  456. /package/build/esm/{BMI_GIRLS.zscore.yearly-54289d04.js → BMI_GIRLS.zscore.yearly-df88448a.js} +0 -0
  457. /package/build/esm/{ChevronDown-a4cf7631.js → ChevronDown-47446788.js} +0 -0
  458. /package/build/esm/{Close-a61d81c6.js → Close-c3a49880.js} +0 -0
  459. /package/build/esm/{Google-658e601e.js → Google-4613f559.js} +0 -0
  460. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-2504b72e.js → HEAD CIRCUM_BOYS.percentile.monthly-60e25ec5.js} +0 -0
  461. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-945555ab.js → HEAD CIRCUM_BOYS.percentile.weekly-3c3343ae.js} +0 -0
  462. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-0ecdf4fa.js → HEAD CIRCUM_BOYS.percentile.yearly-be196089.js} +0 -0
  463. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-a415c706.js → HEAD CIRCUM_BOYS.zscore.monthly-29ff8370.js} +0 -0
  464. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-4301d02a.js → HEAD CIRCUM_BOYS.zscore.weekly-92e4b27a.js} +0 -0
  465. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-db5d50e4.js → HEAD CIRCUM_BOYS.zscore.yearly-2e6a5016.js} +0 -0
  466. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-20107e97.js → HEAD CIRCUM_GIRLS.percentile.monthly-b9290e16.js} +0 -0
  467. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-f7dc82dd.js → HEAD CIRCUM_GIRLS.percentile.weekly-8062ea4d.js} +0 -0
  468. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-1593553b.js → HEAD CIRCUM_GIRLS.percentile.yearly-b164ccc6.js} +0 -0
  469. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-bc248172.js → HEAD CIRCUM_GIRLS.zscore.monthly-d9e6f3eb.js} +0 -0
  470. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-307991f7.js → HEAD CIRCUM_GIRLS.zscore.weekly-4fd80615.js} +0 -0
  471. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-61b0290d.js → HEAD CIRCUM_GIRLS.zscore.yearly-f28609a2.js} +0 -0
  472. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-9113922c.js → HEIGHT_BOYS.percentile.monthly-15a0bc4d.js} +0 -0
  473. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-1f3bcc5f.js → HEIGHT_BOYS.percentile.weekly-102b50e3.js} +0 -0
  474. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-267121e2.js → HEIGHT_BOYS.percentile.yearly-cf42e15a.js} +0 -0
  475. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-48d404ae.js → HEIGHT_BOYS.zscore.monthly-8f455cc9.js} +0 -0
  476. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-6993438a.js → HEIGHT_BOYS.zscore.weekly-f2c852bd.js} +0 -0
  477. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-4bf4d1e6.js → HEIGHT_BOYS.zscore.yearly-0ebca637.js} +0 -0
  478. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-daa0663f.js → HEIGHT_GIRLS.percentile.monthly-790caf2c.js} +0 -0
  479. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-813f5fd7.js → HEIGHT_GIRLS.percentile.weekly-18f018dd.js} +0 -0
  480. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-eff8bf30.js → HEIGHT_GIRLS.percentile.yearly-5b3a5c7e.js} +0 -0
  481. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-30a32b50.js → HEIGHT_GIRLS.zscore.monthly-5a259243.js} +0 -0
  482. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-694139b8.js → HEIGHT_GIRLS.zscore.weekly-7dcf65e7.js} +0 -0
  483. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-fd93c8ea.js → HEIGHT_GIRLS.zscore.yearly-1f427d14.js} +0 -0
  484. /package/build/esm/{Visible-2bab58e1.js → Visible-c0ca5ff5.js} +0 -0
  485. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-ff9ff248.js → WEIGHT_BOYS.percentile.monthly-1cb736bc.js} +0 -0
  486. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-329cab06.js → WEIGHT_BOYS.percentile.weekly-cd49dbad.js} +0 -0
  487. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-7febf596.js → WEIGHT_BOYS.percentile.yearly-73dbe0a9.js} +0 -0
  488. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-45594801.js → WEIGHT_BOYS.zscore.monthly-cf13f60b.js} +0 -0
  489. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-9530978c.js → WEIGHT_BOYS.zscore.weekly-5cb0f54e.js} +0 -0
  490. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-eb72e975.js → WEIGHT_BOYS.zscore.yearly-f8920ebb.js} +0 -0
  491. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-05775d79.js → WEIGHT_GIRLS.percentile.monthly-d05adf8a.js} +0 -0
  492. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-8d9f769e.js → WEIGHT_GIRLS.percentile.weekly-8bfcc146.js} +0 -0
  493. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-30144bae.js → WEIGHT_GIRLS.percentile.yearly-b8972989.js} +0 -0
  494. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-cf07d175.js → WEIGHT_GIRLS.zscore.monthly-fb98e36d.js} +0 -0
  495. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-33e0d835.js → WEIGHT_GIRLS.zscore.weekly-69079f9a.js} +0 -0
  496. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-d608073f.js → WEIGHT_GIRLS.zscore.yearly-22e982d8.js} +0 -0
  497. /package/build/esm/{animation-936439f3.js → animation-8f44fc6c.js} +0 -0
  498. /package/build/esm/{constants-dec93ad8.js → constants-6d3e6bd2.js} +0 -0
  499. /package/build/esm/{constants-3525e3f2.js → constants-dbb68f45.js} +0 -0
  500. /package/build/esm/{dataTransform-3d760b9f.js → dataTransform-0688712b.js} +0 -0
  501. /package/build/esm/{doctor-76b1e3a5.js → doctor-23714c67.js} +0 -0
  502. /package/build/esm/{index-f99e0243.js → index-388c355e.js} +0 -0
  503. /package/build/esm/{index-b9fd9fcf.js → index-530d9459.js} +0 -0
  504. /package/build/esm/{index-b0b1e4dc.js → index-577a8f9b.js} +0 -0
  505. /package/build/esm/{index-649372bd.js → index-658ef77b.js} +0 -0
  506. /package/build/esm/{index-5a380bf2.js → index-72875897.js} +0 -0
  507. /package/build/esm/{index-b2f2ef05.js → index-a96ad622.js} +0 -0
  508. /package/build/esm/{index-037ec766.js → index-d1e7bea2.js} +0 -0
  509. /package/build/esm/{index-8227d187.js → index-f6ae34df.js} +0 -0
  510. /package/build/esm/{index.styles-24493eed.js → index.styles-e7a84f91.js} +0 -0
  511. /package/build/esm/{localizeNumberFormat-5ee70bdb.js → localizeNumberFormat-e8ce7c0c.js} +0 -0
  512. /package/build/esm/{normalizeLink-70222b22.js → normalizeLink-a6fff3b6.js} +0 -0
  513. /package/build/esm/{number-6c0361f0.js → number-9db85954.js} +0 -0
  514. /package/build/esm/{other-04096300.js → other-39c7ba92.js} +0 -0
  515. /package/build/esm/{paths-50ad35fc.js → paths-73406cfb.js} +0 -0
  516. /package/build/esm/{translationsContext-1d64cf04.js → translationsContext-db44a804.js} +0 -0
  517. /package/build/esm/{tslib.es6-b06892b6.js → tslib.es6-def645e9.js} +0 -0
  518. /package/build/esm/{types-6b50d489.js → types-d2b218e1.js} +0 -0
  519. /package/build/esm/{useIsInit-09563c77.js → useIsInit-e1c4cbbb.js} +0 -0
  520. /package/build/esm/{useOutsideClick-461af3f1.js → useOutsideClick-c5c0416e.js} +0 -0
  521. /package/build/esm/{useScrollbarSize-ea155b73.js → useScrollbarSize-cdca65c3.js} +0 -0
  522. /package/build/esm/{useUniqueId-879e70af.js → useUniqueId-5ba39dd0.js} +0 -0
  523. /package/build/esm/{utils-f4fc54ed.js → utils-ad366429.js} +0 -0
  524. /package/build/{index-2e09584a.js → index-020412a7.js} +0 -0
  525. /package/build/{index-af135972.js → index-0630bc54.js} +0 -0
  526. /package/build/{index-312d7d65.js → index-439ed166.js} +0 -0
  527. /package/build/{index-1262dfcb.js → index-5ecc8dcf.js} +0 -0
  528. /package/build/{index-cc3c4d6d.js → index-6d25977a.js} +0 -0
  529. /package/build/{index-69afccff.js → index-71123b1e.js} +0 -0
  530. /package/build/{index-8b8d709b.js → index-a18c5ff1.js} +0 -0
  531. /package/build/{index-5aac0dc2.js → index-ec78675c.js} +0 -0
  532. /package/build/{index.styles-33ccc931.js → index.styles-1c27538c.js} +0 -0
  533. /package/build/{localizeNumberFormat-cf37a5eb.js → localizeNumberFormat-3fa00932.js} +0 -0
  534. /package/build/{normalizeLink-79d4e277.js → normalizeLink-cdde0b93.js} +0 -0
  535. /package/build/{number-87c5f3a1.js → number-d95061a1.js} +0 -0
  536. /package/build/{other-81af4989.js → other-4710bd77.js} +0 -0
  537. /package/build/{paths-31b6c759.js → paths-264a6504.js} +0 -0
  538. /package/build/{translationsContext-32ff79c3.js → translationsContext-02291cc2.js} +0 -0
  539. /package/build/{tslib.es6-a8bff8b8.js → tslib.es6-0c296361.js} +0 -0
  540. /package/build/{types-40d5f385.js → types-124cdc28.js} +0 -0
  541. /package/build/{useIsInit-1dd7e2ba.js → useIsInit-1962c185.js} +0 -0
  542. /package/build/{useOutsideClick-009d5b2b.js → useOutsideClick-99f10750.js} +0 -0
  543. /package/build/{useScrollbarSize-499a8e08.js → useScrollbarSize-3663cbc4.js} +0 -0
  544. /package/build/{useUniqueId-cf03a9e2.js → useUniqueId-5d17e7af.js} +0 -0
  545. /package/build/{utils-77ed117f.js → utils-e42c732c.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,71 +1,51 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-b06892b6.js';
2
- import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback, forwardRef, useImperativeHandle, memo } from 'react';
3
- import { createStyles, Box, Button as Button$2, Input as Input$1, clsx, Autocomplete, Checkbox as Checkbox$1, Radio as Radio$1, Select as Select$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-def645e9.js';
2
+ import React__default, { createContext, useMemo, useEffect, useRef, useState, useContext, useCallback } from 'react';
3
+ import { createStyles, Box, Button as Button$1, Autocomplete, clsx, Input as Input$1, TextInput, NumberInput as NumberInput$1, Portal, Transition, Overlay } from '@mantine/core';
4
4
  import dayjs from 'dayjs';
5
5
  import debounce from 'lodash/debounce';
6
- import { createFormContext, useForm } from '@mantine/form';
7
- import { u as useTranslations } from './index-a8c524a9.js';
8
- import { T as TranslationsContext } from './translationsContext-1d64cf04.js';
6
+ import { createFormContext } from '@mantine/form';
7
+ import { u as useTranslations } from './index-e3522239.js';
8
+ import { T as TranslationsContext } from './translationsContext-db44a804.js';
9
9
  import { getCookie, setCookie } from './miscCookieHelper.js';
10
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-f4fc54ed.js';
11
- import { T as Text } from './index-0978cfdd.js';
12
- import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-dc733b8a.js';
13
- import { D as DatePicker } from './index-e6c329bb.js';
14
- import { M as MAPPED_LOCALE } from './utils-0cb064a5.js';
15
- import { DateInput } from '@mantine/dates';
16
- import { Z as ZINDEX_SSO, I as ISO_FORMAT } from './index-3b4d798b.js';
17
- import { C as COMMON_DATE_TRANSLATE_KEY } from './index-2cbac092.js';
18
- import './index-8227d187.js';
19
- import './useMantineLocale-6f10e30e.js';
20
- import { B as Button$1 } from './index-48aacda8.js';
21
- import './index.styles-24493eed.js';
10
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-ad366429.js';
11
+ import { T as Text } from './index-d46d72e5.js';
12
+ import { S as Select, d as Checkbox, I as Input, R as Radio, P as Phone, N as NumberInput, O as OTP } from './index-3fe07695.js';
13
+ import { D as DatePicker } from './index-773c6e02.js';
14
+ import { B as Button } from './index-02c659dd.js';
15
+ import './index.styles-e7a84f91.js';
22
16
  import { useClickOutside } from '@mantine/hooks';
23
- import './other-04096300.js';
24
- import './index-07beb988.js';
25
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-1043aded.js';
26
- import { B as Button } from './index-22f4a880.js';
27
- import { H as Heading$1 } from './index-e3c73f61.js';
28
- import { t as translationsMap$1 } from './translationsProvider-598fb4c6.js';
29
- import { L as LOCALE } from './Locale-08f0c7dd.js';
17
+ import './useMantineLocale-75d3a92b.js';
18
+ import './index-6e796974.js';
19
+ import './index-f6ae34df.js';
20
+ import { Z as ZINDEX_SSO } from './index-b1702546.js';
21
+ import './other-39c7ba92.js';
22
+ import './index-f18301b6.js';
23
+ import { M as MAPPED_LOCALE } from './utils-654cc220.js';
24
+ import '@mantine/dates';
25
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-be5196d7.js';
26
+ import { H as Heading$1 } from './index-c85f2927.js';
30
27
  import { v1 } from 'uuid';
31
- import { parsePhoneNumber } from 'react-phone-number-input';
28
+ import { i as isVideo } from './index-72875897.js';
29
+ import { D as DrawerComponent } from './index-3c7bade1.js';
30
+ import { u as useScreenSize } from './useScreenSize-9091e971.js';
31
+ import { createPortal } from 'react-dom';
32
+ import { css } from '@emotion/react';
32
33
  import styled from '@emotion/styled';
33
34
  import { theme } from './miscTheme.js';
34
- import { css } from '@emotion/react';
35
- import { T as TogetherComponentGlobalContext } from './utils-4d4e79bb.js';
36
- import { i as isVideo } from './index-5a380bf2.js';
37
- import { D as DrawerComponent } from './index-a88963d3.js';
38
- import { u as useScreenSize } from './useScreenSize-caf0dd66.js';
39
- import { createPortal } from 'react-dom';
40
- import { I as InputDate } from './InputDate-7205d5bf.js';
41
- import { C as Close } from './Close-a61d81c6.js';
35
+ import { B as Button$2 } from './index-0823f05f.js';
36
+ import { C as Close } from './Close-c3a49880.js';
42
37
  import '@hhgtech/icons/other';
43
38
  import '@mantine/carousel';
39
+ import './Locale-3e2786ee.js';
44
40
  import 'classnames';
45
- import './useUniqueId-879e70af.js';
41
+ import './useUniqueId-5ba39dd0.js';
46
42
  import './constantsSite.js';
47
43
  import '@hhgtech/icons/core';
48
- import 'date-fns/locale';
44
+ import '@mantine/notifications';
49
45
  import './constantsDomainLocales.js';
50
- import './constantsRiskScreener.js';
51
46
  import './constantsIsProduction.js';
52
- import '@mantine/notifications';
53
- import './i18n-values/en-PH.js';
54
- import './i18n-values/hi-IN.js';
55
- import './i18n-values/id-ID.js';
56
- import './i18n-values/km-KH.js';
57
- import './i18n-values/ms-MY.js';
58
- import './i18n-values/my-MM.js';
59
- import './i18n-values/th-TH.js';
60
- import './i18n-values/tl-PH.js';
61
- import './i18n-values/vi-VN.js';
62
- import './i18n-values/vi-VN_MB.js';
63
- import './i18n-values/zh-TW.js';
64
- import './index-037ec766.js';
65
- import 'slugify';
66
- import 'string-format';
67
- import './togetherApiPaths.js';
68
- import './constants-dec93ad8.js';
47
+ import 'date-fns/locale';
48
+ import './constantsRiskScreener.js';
69
49
  import 'vaul';
70
50
 
71
51
  const LeadGenComponentContext = createContext({});
@@ -92,7 +72,7 @@ if (sessionStorage.getItem('insider_object')) {
92
72
  }
93
73
  const docLang = document.documentElement.lang;
94
74
  // TODO: country code
95
- const LEAD_LOCALE_DATA$1 = {
75
+ const LEAD_LOCALE_DATA = {
96
76
  'vi-VN': {
97
77
  popupLang: 'vi',
98
78
  countryCode: 'vn',
@@ -134,7 +114,7 @@ const LEAD_LOCALE_DATA$1 = {
134
114
  countryCodeNumber: 91,
135
115
  },
136
116
  };
137
- const LEAD_LOCALE = LEAD_LOCALE_DATA$1[docLang] || LEAD_LOCALE_DATA$1['vi-VN'];
117
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
138
118
  function LEAD_RESET_VAR() {
139
119
  // LEAD_CURRENT_URL = location.href.toLowerCase();
140
120
  LEAD_CURRENT_URL =
@@ -155,11 +135,6 @@ const LEAD_TIMEZONE_DATA = {
155
135
  9: 'Asia/Manila', // Philippines / Filipinos Site
156
136
  };
157
137
 
158
- const LEADGEN_ACTIONS = {
159
- SHOW: 'SHOW',
160
- SCROLL: 'SCROLL',
161
- TIME: 'TIME',
162
- };
163
138
  const LEADGEN_LAYOUT = {
164
139
  LightBoxA: 'LightBoxA',
165
140
  LightBoxB: 'LightBoxB',
@@ -189,10 +164,8 @@ const LEADGEN_BLOCK = {
189
164
  DropdownBlock: 'DropdownBlock',
190
165
  CheckboxBlock: 'CheckboxBlock',
191
166
  TncBlock: 'TncBlock',
192
- TitleBlock: 'TitleBlock',
193
- SubtitleBlock: 'SubtitleBlock',
194
167
  };
195
- const LEADGEN_BLOCK_INPUT = [
168
+ const LEADGEN_BLOCK_IN_FORM = [
196
169
  LEADGEN_BLOCK.TextBlock,
197
170
  LEADGEN_BLOCK.NumberBlock,
198
171
  LEADGEN_BLOCK.DateBlock,
@@ -207,59 +180,7 @@ const LEADGEN_BLOCK_INPUT = [
207
180
  LEADGEN_BLOCK.CheckboxBlock,
208
181
  LEADGEN_BLOCK.TncBlock,
209
182
  ];
210
- const leadGenFieldNamePhone = (listBlockAdded) => {
211
- return listBlockAdded
212
- .filter(({ name }) => [
213
- LEADGEN_BLOCK.PhoneBlock,
214
- LEADGEN_BLOCK.PhoneOtpBlock,
215
- LEADGEN_BLOCK.WhatsappOtpBlock,
216
- LEADGEN_BLOCK.ZaloOtpBlock,
217
- ].includes(name))
218
- .map(({ data }) => data.value);
219
- };
220
183
  const SSO_MAP_LEAD = ['name', 'email', 'birthday', 'phone', 'gender'];
221
- const LEAD_LOCALE_DATA = {
222
- 'vi-VN': {
223
- popupLang: 'vi',
224
- countryCode: 'vn',
225
- countryCodeNumber: 84,
226
- },
227
- 'id-ID': {
228
- popupLang: 'id',
229
- countryCode: 'id',
230
- countryCodeNumber: 62,
231
- },
232
- 'th-TH': {
233
- popupLang: 'th',
234
- countryCode: 'th',
235
- countryCodeNumber: 66,
236
- },
237
- 'ms-MY': {
238
- popupLang: 'ms',
239
- countryCode: 'my',
240
- countryCodeNumber: 60,
241
- },
242
- 'zh-TW': {
243
- popupLang: 'zh',
244
- countryCode: 'tw',
245
- countryCodeNumber: 886,
246
- },
247
- 'km-KH': {
248
- popupLang: 'km',
249
- countryCode: 'kh',
250
- countryCodeNumber: 855,
251
- },
252
- 'my-MM': {
253
- popupLang: 'my',
254
- countryCode: 'mm',
255
- countryCodeNumber: 95,
256
- },
257
- 'hi-IN': {
258
- popupLang: 'hi',
259
- countryCode: 'in',
260
- countryCodeNumber: 91,
261
- },
262
- };
263
184
  const mappingSSOToLead = (userInfoProps) => {
264
185
  var _a, _b;
265
186
  try {
@@ -275,7 +196,7 @@ const mappingSSOToLead = (userInfoProps) => {
275
196
  if (ssoKey === 'birthday') {
276
197
  const dob = dayjs(initValue, 'YYYY-MM-DD', true);
277
198
  if (dob.isValid()) {
278
- user.birthday = dob.toDate();
199
+ user.birthday = dob;
279
200
  }
280
201
  }
281
202
  else if (ssoKey === 'gender') {
@@ -298,66 +219,16 @@ const mappingSSOToLead = (userInfoProps) => {
298
219
  catch (error) {
299
220
  return;
300
221
  }
301
- };
302
- const formatCampaignDetail = (campaign) => {
303
- if (!campaign) {
304
- return {};
305
- }
306
- try {
307
- const { extra_fields, thank_you_image } = campaign || {};
308
- const { textBlocks: exTextBlocks, imageBlocks: exImageBlocks, listBlockAdded: exListBlockAdded, listBlockThankyou: exListBlockThankyou, actionBlocks: exActionBlocks, } = extra_fields;
309
- const textBlocks = JSON.parse(exTextBlocks);
310
- const imageBlocks = JSON.parse(exImageBlocks);
311
- const listBlockAdded = JSON.parse(exListBlockAdded);
312
- const listBlockThankyou = JSON.parse(exListBlockThankyou);
313
- const actionBlocks = JSON.parse(exActionBlocks);
314
- const ThankYouBlock = {
315
- image: { src: thank_you_image },
316
- };
317
- listBlockThankyou.forEach((block) => {
318
- const { name, data } = block || {};
319
- const { value: htmlText, align, newtab, url } = data || {};
320
- switch (name) {
321
- case LEADGEN_BLOCK.TitleBlock: {
322
- ThankYouBlock.title = { htmlText, align };
323
- }
324
- case LEADGEN_BLOCK.SubtitleBlock: {
325
- ThankYouBlock.description = { htmlText, align };
326
- }
327
- case LEADGEN_BLOCK.LinkButtonBlock: {
328
- ThankYouBlock.button = { htmlText, newtab, url };
329
- }
330
- }
331
- });
332
- return Object.assign(Object.assign({}, campaign), { extra_fields: Object.assign(Object.assign({}, extra_fields), { textBlocks,
333
- imageBlocks,
334
- listBlockAdded,
335
- listBlockThankyou,
336
- actionBlocks }), ThankYouBlock });
337
- }
338
- catch (error) {
339
- return {};
340
- }
341
222
  };
342
223
 
343
224
  class Store {
344
225
  constructor() {
345
- this.apiSsoUrl = 'https://staging-id.hellobacsi.com/';
346
226
  this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
347
227
  this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
348
228
  }
349
229
  }
350
230
  const leadStore = new Store();
351
231
 
352
- const LEADGEN_API_METHOD = {
353
- GET: 'get',
354
- POST: 'POST',
355
- };
356
- const LEADGEN_API_PATH = {
357
- V2_CAMPAIGN: 'api/v2/campaign',
358
- V2_SUBSCRIPTION_LEAD: 'api/v2/subscription-box',
359
- V2_SUBSCRIPTION_INFO: 'api/campaign/get-title',
360
- };
361
232
  const leadApi = {
362
233
  call(_a) {
363
234
  var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
@@ -461,50 +332,8 @@ const verifyOtpLead = ({ phone, otp, type, }) => {
461
332
  },
462
333
  });
463
334
  };
464
- const getCampaignByCode = (campaign_code) => {
465
- return leadApi.call({
466
- url: `${LEADGEN_API_PATH.V2_CAMPAIGN}/${campaign_code}`,
467
- method: LEADGEN_API_METHOD.GET,
468
- });
469
- };
470
- const getSubscriptionBoxInfo = ({ category, site, }) => {
471
- return leadApi.call({
472
- url: `${LEADGEN_API_PATH.V2_SUBSCRIPTION_INFO}?category=${category}&site=${site}`,
473
- method: LEADGEN_API_METHOD.GET,
474
- });
475
- };
476
- const postSubscriptionBoxLead = ({ data }) => {
477
- return leadApi.call({
478
- url: LEADGEN_API_PATH.V2_SUBSCRIPTION_LEAD,
479
- method: LEADGEN_API_METHOD.POST,
480
- data,
481
- });
482
- };
483
- const postUserInfoFromLeadGen = ({}) => {
484
- return;
485
- };
486
- const campaignPostImpression = ({ code, action, title_article, ga_client_id, cookie_id, extra, url, referrer, }) => {
487
- return leadApi.call({
488
- url: `api/campaign/${code}/impression`,
489
- method: LEADGEN_API_METHOD.POST,
490
- data: {
491
- action,
492
- title_article,
493
- cookie_id,
494
- ga_client_id,
495
- url,
496
- extra,
497
- referrer,
498
- },
499
- });
500
- };
501
335
  const Service = {
502
336
  campaignGetById,
503
- getCampaignByCode,
504
- getSubscriptionBoxInfo,
505
- postSubscriptionBoxLead,
506
- postUserInfoFromLeadGen,
507
- campaignPostImpression,
508
337
  validateEmailOrPhoneOnSubot,
509
338
  validateEmailOrPhoneOnLeadGen,
510
339
  validatePhoneNumberOnLeadGen,
@@ -844,6 +673,8 @@ const Description = (_a) => {
844
673
  return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
845
674
  };
846
675
 
676
+ const LeadGenContext = createContext({});
677
+
847
678
  var useStyles$2 = createStyles(() => {
848
679
  return {
849
680
  control: {},
@@ -906,6 +737,7 @@ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement(
906
737
  const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
907
738
 
908
739
  const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, popoverProps, }) => {
740
+ const { primaryColor } = useContext(LeadGenContext);
909
741
  const { classes, cx } = useStyles$2(undefined, {
910
742
  name: 'LeadGen__Field',
911
743
  styles,
@@ -960,7 +792,7 @@ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, style
960
792
  case 'LinkButtonBlock':
961
793
  return (React__default.createElement("div", { key: index },
962
794
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
963
- React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
795
+ React__default.createElement(Button, { type: "button", size: "md", color: primaryColor, className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
964
796
  onClose === null || onClose === void 0 ? void 0 : onClose();
965
797
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
966
798
  } }, value))));
@@ -1020,6 +852,7 @@ const Heading = (_a) => {
1020
852
 
1021
853
  const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps, submitProps, }) => {
1022
854
  var _a;
855
+ const { primaryColor } = useContext(LeadGenContext);
1023
856
  const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, setFormRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
1024
857
  const { classes, cx } = useStyles$1(undefined, {
1025
858
  name: 'LeadGen__FormComponent',
@@ -1108,7 +941,7 @@ const FormComponent = ({ styles, className, classNames, fillInfo, popoverProps,
1108
941
  control: classes.control,
1109
942
  }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit, popoverProps: popoverProps })),
1110
943
  ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default.createElement("div", { className: classes.submitBtnWrapper },
1111
- React__default.createElement(Button$1, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading }, submitProps), popUpSubmitText))))));
944
+ React__default.createElement(Button, Object.assign({ size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, loading: isSubmitLoading, color: primaryColor }, submitProps), popUpSubmitText))))));
1112
945
  };
1113
946
  const Form = (props) => {
1114
947
  const { showOtpPhone, showThankyou } = useContext(LeadGenComponentContext);
@@ -1250,10 +1083,10 @@ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, st
1250
1083
  setErrorMsg(undefined);
1251
1084
  }, error: isDirty ? errorMsg : undefined }),
1252
1085
  React__default.createElement("div", { className: classes.actions },
1253
- React__default.createElement(Button$1, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1086
+ React__default.createElement(Button, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
1254
1087
  // onClick={() => submitOtp()}
1255
1088
  disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
1256
- React__default.createElement(Button$1, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1089
+ React__default.createElement(Button, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
1257
1090
  sendOtp();
1258
1091
  }, disabled: !!resendTimer }, t('lead.otp.resend', {
1259
1092
  timer: resendTimer ? ` (${resendTimer}s)` : '',
@@ -1296,7 +1129,6 @@ var enPH = {
1296
1129
  "validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
1297
1130
  "validator.emailUsed": "Email already in use for this campaign.",
1298
1131
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1299
- "validator.dateInvalid": "This date is not valid, please update.",
1300
1132
  "lead.otp.title": "Enter OTP",
1301
1133
  "lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
1302
1134
  "lead.otp.verify": "Verify",
@@ -1305,10 +1137,7 @@ var enPH = {
1305
1137
  "lead.otp.phonePlaceholder": "Enter OTP",
1306
1138
  "lead.empty.title": "Oops, seem your information is empty, do you want to submit the information again?",
1307
1139
  "lead.empty.cancel": "Cancel",
1308
- "lead.empty.submitAgain": "Submit again",
1309
- "common.day": "Day",
1310
- "common.month": "Month",
1311
- "common.year": "Year"
1140
+ "lead.empty.submitAgain": "Submit again"
1312
1141
  };
1313
1142
 
1314
1143
  var hiIN = {
@@ -1319,7 +1148,6 @@ var hiIN = {
1319
1148
  "validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
1320
1149
  "validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
1321
1150
  "validator.phone": "कृपया एक वैध संख्या दर्ज करें",
1322
- "validator.dateInvalid": "यह तिथि मान्य नहीं है, कृपया अपडेट करें।",
1323
1151
  "validator.emailUsed": "Email already in use for this campaign.",
1324
1152
  "validator.phoneUsed": "Your phone number already in use for this campaign.",
1325
1153
  "lead.otp.title": "Enter OTP",
@@ -1328,10 +1156,7 @@ var hiIN = {
1328
1156
  "lead.otp.resend": "Resend OTP{timer}",
1329
1157
  "lead.empty.title": "ऊप्स! लगता है आपकी जानकारी खाली है। क्या आप जानकारी फिर से सबमिट करना चाहते हैं?",
1330
1158
  "lead.empty.cancel": "रद्द करें",
1331
- "lead.empty.submitAgain": "फिर से सबमिट करें",
1332
- "common.day": "साल",
1333
- "common.month": "महीना",
1334
- "common.year": ""
1159
+ "lead.empty.submitAgain": "फिर से सबमिट करें"
1335
1160
  };
1336
1161
 
1337
1162
  var idID = {
@@ -1344,7 +1169,6 @@ var idID = {
1344
1169
  "validator.phone": "Tolong daftarkan nomor telepon yang valid",
1345
1170
  "validator.emailUsed": "Email sudah digunakan untuk kampanye ini.",
1346
1171
  "validator.phoneUsed": "Nomor telepon Anda sudah digunakan untuk kampanye ini.",
1347
- "validator.dateInvalid": "Tanggal ini tidak valid, silakan perbarui",
1348
1172
  "lead.otp.title": "Masukkan OTP",
1349
1173
  "lead.otp.desc": "Kami telah mengirimkan OTP ke nomor ponsel Anda {phone}",
1350
1174
  "lead.otp.verify": "Verifikasi",
@@ -1353,10 +1177,7 @@ var idID = {
1353
1177
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1354
1178
  "lead.empty.title": "Oops, sepertinya informasi Anda kosong. Apakah Anda ingin mengirimkan informasi lagi?",
1355
1179
  "lead.empty.cancel": "Batal",
1356
- "lead.empty.submitAgain": "Kirim lagi",
1357
- "common.day": "Hari",
1358
- "common.month": "Bulan",
1359
- "common.year": "Tahun"
1180
+ "lead.empty.submitAgain": "Kirim lagi"
1360
1181
  };
1361
1182
 
1362
1183
  var kmKH = {
@@ -1369,7 +1190,6 @@ var kmKH = {
1369
1190
  "validator.phone": "សូម​វាយបញ្ចូល​លេខ​ឲ្យ​បាន​ត្រឹមត្រូវ",
1370
1191
  "validator.emailUsed": "អ៊ីមែលត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1371
1192
  "validator.phoneUsed": "លេខទូរស័ព្ទរបស់អ្នកត្រូវបានប្រើប្រាស់សម្រាប់យុទ្ធនាការនេះរួចហើយ។",
1372
- "validator.dateInvalid": "កាលបរិច្ឆេទនេះមិនត្រឹមត្រូវទេ សូមធ្វើបច្ចុប្បន្នភាព។",
1373
1193
  "lead.otp.title": "បញ្ចូល OTP",
1374
1194
  "lead.otp.desc": "យើងបានផ្ញើ OTP ទៅកាន់លេខទូរសព្ទរបស់អ្នក {phone}",
1375
1195
  "lead.otp.verify": "ផ្ទៀងផ្ទាត់",
@@ -1378,10 +1198,7 @@ var kmKH = {
1378
1198
  "lead.otp.phonePlaceholder": "បញ្ចូល OTP",
1379
1199
  "lead.empty.title": "អូុបស! ហាក់ដូចជាព័ត៌មានរបស់អ្នកទទេ។ តើអ្នកចង់ដាក់ស្នើព័ត៌មានម្តងទៀតទេ?",
1380
1200
  "lead.empty.cancel": "លុប​ចោល",
1381
- "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត",
1382
- "common.day": "ឆ្នាំ",
1383
- "common.month": "ខែ",
1384
- "common.year": "ថ្ងៃ"
1201
+ "lead.empty.submitAgain": "ដាក់ស្នើម្ដងទៀត"
1385
1202
  };
1386
1203
 
1387
1204
  var msMY = {
@@ -1394,7 +1211,6 @@ var msMY = {
1394
1211
  "validator.phone": "Sila masukkan no telefon yang sah.",
1395
1212
  "validator.emailUsed": "Emel sudah digunakan untuk kempen ini.",
1396
1213
  "validator.phoneUsed": "Nombor telefon anda sudah digunakan untuk kempen ini.",
1397
- "validator.dateInvalid": "Tarikh ini tidak sah, sila kemas kini",
1398
1214
  "lead.otp.title": "Masukkan OTP",
1399
1215
  "lead.otp.desc": "Kami telah menghantar OTP ke nombor telefon bimbit anda {phone}",
1400
1216
  "lead.otp.verify": "Sahkan",
@@ -1403,10 +1219,7 @@ var msMY = {
1403
1219
  "lead.otp.phonePlaceholder": "Masukkan OTP",
1404
1220
  "lead.empty.title": "Oops, nampaknya maklumat anda kosong. Adakah anda ingin menghantar maklumat semula?",
1405
1221
  "lead.empty.cancel": "Batal",
1406
- "lead.empty.submitAgain": "Hantar semula",
1407
- "common.day": "Hari",
1408
- "common.month": "Bulan",
1409
- "common.year": "Tahun"
1222
+ "lead.empty.submitAgain": "Hantar semula"
1410
1223
  };
1411
1224
 
1412
1225
  var myMM = {
@@ -1419,7 +1232,6 @@ var myMM = {
1419
1232
  "validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
1420
1233
  "validator.emailUsed": "ဤအေကာင့်အတွက် အီးမေးလ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1421
1234
  "validator.phoneUsed": "ဤအေကာင့်အတွက် သင့်ဖုန်းနံပါတ်ကို အသုံးပြုပြီးဖြစ်ပါသည်။",
1422
- "validator.dateInvalid": "ယနေ့စွဲမှားနေသည်၊ ကျေးဇူးပြု၍ ပြင်ဆင်ပါ။",
1423
1235
  "lead.otp.title": "OTP ကိုထည့်ပါ",
1424
1236
  "lead.otp.desc": "ကျွန်ုပ်တို့သည် OTP ကိုသင့်ဖုန်းနံပါတ် {phone} သို့ပို့ခဲ့သည်",
1425
1237
  "lead.otp.verify": "အတည်ပြုပါ",
@@ -1428,10 +1240,7 @@ var myMM = {
1428
1240
  "lead.otp.phonePlaceholder": "OTP ကိုထည့်ပါ",
1429
1241
  "lead.empty.title": "အုပ်စ်! သင့်အချက်အလက်သည် ဗလာဖြစ်နေသလိုဖြစ်သည်။ ထပ်မံတင်သွင်းလိုပါသလား?",
1430
1242
  "lead.empty.cancel": "မလုပ်ဆောင်ပါ",
1431
- "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ",
1432
- "common.day": "ရက်",
1433
- "common.month": "လ",
1434
- "common.year": "နှစ်"
1243
+ "lead.empty.submitAgain": "ထပ်မံတင်သွင်းပါ"
1435
1244
  };
1436
1245
 
1437
1246
  var thTH = {
@@ -1444,7 +1253,6 @@ var thTH = {
1444
1253
  "validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
1445
1254
  "validator.emailUsed": "อีเมลนี้ถูกใช้สำหรับแคมเปญนี้แล้ว",
1446
1255
  "validator.phoneUsed": "หมายเลขโทรศัพท์ของคุณถูกใช้สำหรับแคมเปญนี้แล้ว",
1447
- "validator.dateInvalid": "วันที่นี้ไม่ถูกต้อง โปรดอัปเดต",
1448
1256
  "lead.otp.title": "ป้อน OTP",
1449
1257
  "lead.otp.desc": "เราได้ส่ง OTP ไปยังหมายเลขโทรศัพท์มือถือของคุณ {phone}",
1450
1258
  "lead.otp.verify": "ยืนยัน",
@@ -1453,10 +1261,7 @@ var thTH = {
1453
1261
  "lead.otp.phonePlaceholder": "ป้อน OTP",
1454
1262
  "lead.empty.title": "อุ๊ปส์! ดูเหมือนว่าข้อมูลของคุณว่างเปล่า คุณต้องการส่งข้อมูลอีกครั้งหรือไม่?",
1455
1263
  "lead.empty.cancel": "ยกเลิก",
1456
- "lead.empty.submitAgain": "ส่งอีกครั้ง",
1457
- "common.day": "วัน",
1458
- "common.month": "เดือน",
1459
- "common.year": "ปี"
1264
+ "lead.empty.submitAgain": "ส่งอีกครั้ง"
1460
1265
  };
1461
1266
 
1462
1267
  var viVN = {
@@ -1480,7 +1285,6 @@ var viVN = {
1480
1285
  "validator.phone": "Nhập đúng định dạng số điện thoại",
1481
1286
  "validator.emailUsed": "Email này đã được sử dụng.",
1482
1287
  "validator.phoneUsed": "Số điện thoại này đã được sử dụng.",
1483
- "validator.dateInvalid": "Ngày này không hợp lệ, vui lòng cập nhật.",
1484
1288
  "lead.otp.title": "Nhập OTP",
1485
1289
  "lead.otp.desc": "Chúng tôi đã gửi OTP đến số điện thoại của bạn {phone}",
1486
1290
  "lead.otp.verify": "Xác minh",
@@ -1489,10 +1293,7 @@ var viVN = {
1489
1293
  "lead.otp.phonePlaceholder": "Nhập OTP",
1490
1294
  "lead.empty.title": "Oops, có vẻ như thông tin của bạn đang trống. Bạn có muốn gửi lại thông tin không?",
1491
1295
  "lead.empty.cancel": "Hủy",
1492
- "lead.empty.submitAgain": "Gửi lại",
1493
- "common.day": "Ngày",
1494
- "common.month": "Tháng",
1495
- "common.year": "Năm"
1296
+ "lead.empty.submitAgain": "Gửi lại"
1496
1297
  };
1497
1298
 
1498
1299
  var zhTW = {
@@ -1505,7 +1306,6 @@ var zhTW = {
1505
1306
  "validator.phone": "請填入有效的電話號碼",
1506
1307
  "validator.emailUsed": "此電子郵件已被使用於此活動。",
1507
1308
  "validator.phoneUsed": "您的手機號碼已被使用於此活動。",
1508
- "validator.dateInvalid": "此日期無效,請更新.",
1509
1309
  "lead.otp.title": "輸入 OTP",
1510
1310
  "lead.otp.desc": "我們已將 OTP 發送到您的手機號碼 {phone}",
1511
1311
  "lead.otp.verify": "驗證",
@@ -1514,10 +1314,7 @@ var zhTW = {
1514
1314
  "lead.otp.phonePlaceholder": "輸入 OTP",
1515
1315
  "lead.empty.title": "哎呀,您的資訊似乎是空的,您想要重新提交資訊嗎?",
1516
1316
  "lead.empty.cancel": "取消",
1517
- "lead.empty.submitAgain": "重新提交",
1518
- "common.day": "日",
1519
- "common.month": "月",
1520
- "common.year": "年"
1317
+ "lead.empty.submitAgain": "重新提交"
1521
1318
  };
1522
1319
 
1523
1320
  const translationsMap = {
@@ -1529,1618 +1326,92 @@ const translationsMap = {
1529
1326
  'my-MM': myMM,
1530
1327
  'km-KH': kmKH,
1531
1328
  'zh-TW': zhTW,
1532
- 'zh-CN': zhTW,
1533
1329
  'th-TH': thTH,
1534
1330
  'tl-PH': enPH,
1535
1331
  };
1536
1332
  const getTranslations = (locale) => {
1537
- const translations = Object.assign(Object.assign({}, translationsMap$1[locale]), translationsMap[locale]);
1333
+ const translations = translationsMap[locale];
1538
1334
  if (translations) {
1539
1335
  return translations;
1540
1336
  }
1541
1337
  return translationsMap['en-PH'];
1542
1338
  };
1543
1339
 
1544
- const LeadGenContext$1 = createContext({});
1340
+ const useImageSize = (src) => {
1341
+ const [width, setWidth] = useState(16);
1342
+ const [height, setHeight] = useState(9);
1343
+ const [loaded, setLoaded] = useState(false);
1344
+ // load src image to get its width and height
1345
+ useEffect(() => {
1346
+ setLoaded(false);
1347
+ if (src) {
1348
+ const img = new Image();
1349
+ img.addEventListener('load', () => {
1350
+ setWidth(img.naturalWidth);
1351
+ setHeight(img.naturalHeight);
1352
+ setLoaded(true);
1353
+ });
1354
+ img.addEventListener('error', () => {
1355
+ setWidth(16);
1356
+ setHeight(9);
1357
+ setLoaded(true);
1358
+ });
1359
+ img.src = src;
1360
+ }
1361
+ else {
1362
+ setWidth(16);
1363
+ setHeight(9);
1364
+ setLoaded(true);
1365
+ }
1366
+ }, [src]);
1367
+ return {
1368
+ loaded,
1369
+ width,
1370
+ height,
1371
+ };
1372
+ };
1373
+
1374
+ const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
1375
+ React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
1376
+ React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
1545
1377
 
1546
- const LeadGenTranslationProvider = (props) => {
1547
- const { locale, children } = props;
1548
- const translationContextValue = useMemo(() => ({ locale, values: getTranslations(locale) }), [locale]);
1549
- return (React__default.createElement(TranslationsContext.Provider, { value: translationContextValue }, children));
1378
+ // url: imageBlocks.imageMobile.data.url
1379
+ // newTab: imageBlocks.imageMobile.data.newtab
1380
+ // imageMobile: campaignShow.image
1381
+ // imageDestkop: campaignShow.image_desktop
1382
+ const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
1383
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1384
+ const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
1385
+ if (!imageMobileLoaded || !imageDestkopLoaded)
1386
+ return null;
1387
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
1388
+ React__default.createElement("div", { className: "le-center-tab-popup" },
1389
+ React__default.createElement("div", { style: { position: 'relative' } },
1390
+ React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
1391
+ isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
1392
+ React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
1393
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
1394
+ } })),
1395
+ isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
1396
+ React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
1397
+ aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
1398
+ } }))),
1399
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
1550
1400
  };
1551
1401
 
1552
- // import mockLeadData from './mockLeadData'
1553
- const listCampaignScheduled = [];
1554
- const listCampaignScheduledToActivated = [];
1555
- const listCampaignActiveButExpired = [];
1556
- const listCampaignExcludeSonsored = [];
1557
- const listCampaignDifferentSponsor = [];
1558
- const listCampaignNotDisplayInRangeOfTime = [];
1559
- function isMobile() {
1560
- return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
1561
- }
1562
- const getShuffleArray = (array) => {
1563
- const newArray = [...array];
1564
- for (let i = newArray.length - 1; i > 0; i--) {
1565
- const j = Math.floor(Math.random() * (i + 1));
1566
- const temp = newArray[i];
1567
- newArray[i] = newArray[j];
1568
- newArray[j] = temp;
1569
- }
1570
- return newArray;
1571
- };
1572
- const getTimeByTimezone = (timeZone = 'UTC') => {
1573
- const date = new Date();
1574
- return new Date(date.toLocaleString('en-US', { timeZone }));
1575
- };
1576
- const parseDateByCampaignTime = (dateStr) => {
1577
- // Format like this: 2023-04-04 00:00:00
1578
- try {
1579
- const [datePart, timePart] = dateStr.split(' ');
1580
- const [year, month, day] = datePart.split('-').map(Number);
1581
- const [hours, minutes, seconds] = timePart.split(':').map(Number);
1582
- /** JavaScript counts months from 0 to 11 */
1583
- return new Date(year, month - 1, day, hours, minutes, seconds);
1584
- }
1585
- catch (err) {
1586
- return null;
1587
- }
1588
- };
1589
- const checkCampaignNowInTimeframe = (c) => {
1590
- var _a;
1591
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1592
- const startedAtStr = c.started_at;
1593
- const endedAtStr = c.ended_at;
1594
- const startedDate = parseDateByCampaignTime(startedAtStr);
1595
- const endedDate = parseDateByCampaignTime(endedAtStr);
1596
- if (!startedDate || !endedDate) {
1597
- return false;
1598
- }
1599
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1600
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1601
- if (nowWithTimezoneMs <= endedDate.getTime() &&
1602
- nowWithTimezoneMs >= startedDate.getTime()) {
1603
- listCampaignScheduledToActivated.push(c);
1604
- return true;
1605
- }
1606
- return false;
1607
- };
1608
- function checkCampaignActiveButExpireAlready(c) {
1609
- var _a;
1610
- /** Do not setup timeframe for this campaign. No need to check */
1611
- if (c.forever === 1) {
1612
- return true;
1613
- }
1614
- const startedAtStr = c.started_at;
1615
- const endedAtStr = c.ended_at;
1616
- const startedDate = parseDateByCampaignTime(startedAtStr);
1617
- const endedDate = parseDateByCampaignTime(endedAtStr);
1618
- /** Do not setup timeframe for this campaign. No need to check */
1619
- if (!startedDate || !endedDate) {
1620
- return true;
1621
- }
1622
- const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
1623
- const timeZone = LEAD_TIMEZONE_DATA[siteId];
1624
- const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
1625
- /** Check if this expire already, do not show */
1626
- if (nowWithTimezoneMs > endedDate.getTime()) {
1627
- listCampaignActiveButExpired.push(c);
1628
- return false;
1629
- }
1630
- return true;
1631
- }
1632
- function shouldNotDisplayIfExcludeAllSponsors(c) {
1633
- var _a;
1634
- const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
1635
- const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
1636
- if (isSponsored && excludeSponsored) {
1637
- listCampaignExcludeSonsored.push(c);
1638
- return true;
1639
- }
1640
- return false;
1641
- }
1642
- function shouldDisplayWithCurrentSponsor(c) {
1643
- var _a, _b;
1644
- try {
1645
- // TODO: BE will rename `exclude_sponsored_list` later
1646
- const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
1647
- const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
1648
- const dataSponsoredId = Number((_b = document
1649
- .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
1650
- // There is no config for sponsor id and white list, should show as default
1651
- if (!dataSponsoredId ||
1652
- dataSponsoredId <= 0 ||
1653
- whiteListSponsors.length === 0) {
1654
- return true;
1655
- }
1656
- // Check the dataSponsoredId exists in the white list or not.
1657
- const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
1658
- if (isExist) {
1659
- return true;
1660
- }
1661
- listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
1662
- return false;
1663
- }
1664
- catch (err) {
1665
- // Default is show
1666
- return true;
1667
- }
1668
- }
1669
- const filterFnCampaign = (c) => {
1670
- if (shouldNotDisplayIfExcludeAllSponsors(c)) {
1671
- return false;
1672
- }
1673
- else if (!shouldDisplayWithCurrentSponsor(c)) {
1674
- return false;
1675
- }
1676
- /** Active */
1677
- if (c.formatted_status === 1) {
1678
- return checkCampaignActiveButExpireAlready(c);
1679
- }
1680
- /** Schedule */
1681
- if (c.formatted_status === 0) {
1682
- listCampaignScheduled.push(c);
1683
- return checkCampaignNowInTimeframe(c);
1684
- }
1685
- return false;
1686
- };
1687
- const fillterApprearanceTimeCampaign = (c) => {
1688
- var _a;
1689
- try {
1690
- const isTimeInRange = (currentTime, startTime, endTime) => {
1691
- const startParts = startTime.split(':');
1692
- const endParts = endTime.split(':');
1693
- const startDate = new Date();
1694
- startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
1695
- const endDate = new Date();
1696
- endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
1697
- return currentTime >= startDate && currentTime <= endDate;
1698
- };
1699
- const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
1700
- const startTime = rulesApprValue.startTime;
1701
- const endTime = rulesApprValue.endTime || '23:59';
1702
- if (!startTime) {
1703
- return true;
1704
- }
1705
- if (isTimeInRange(new Date(), startTime, endTime)) {
1706
- return true;
1707
- }
1708
- listCampaignNotDisplayInRangeOfTime.push(c);
1709
- return false;
1710
- }
1711
- catch (err) {
1712
- return true;
1713
- }
1714
- };
1715
- let timeoutRef = null;
1716
- let LEAD_SCROLL_EVENT = null;
1717
- function clearPassiveEvent() {
1718
- if (timeoutRef) {
1719
- clearTimeout(timeoutRef);
1720
- timeoutRef = null;
1721
- }
1722
- if (LEAD_SCROLL_EVENT) {
1723
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1724
- LEAD_SCROLL_EVENT = null;
1725
- }
1726
- }
1727
- function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
1728
- // clear previous passive event, check for new condition
1729
- clearPassiveEvent();
1730
- const leadCurrentUrl = DEBUG_URL ||
1731
- ('https://' +
1732
- location.hostname +
1733
- location.pathname +
1734
- location.search).toLowerCase();
1735
- fetch(leadApi + 'api/campaign/' + leadSiteId, {
1736
- method: 'POST',
1737
- headers: {
1738
- 'Content-Type': 'application/json',
1739
- },
1740
- body: JSON.stringify({
1741
- url: leadCurrentUrl,
1742
- ga_client_id: getCookie('_ga') || null,
1743
- }),
1744
- })
1745
- .then((response) => {
1746
- return response.json();
1747
- // return mockLeadData || response.json()
1748
- })
1749
- .then((data) => {
1750
- var _a, _b, _c, _d;
1751
- LeadLog('List campagin: ', data);
1752
- LEAD_RESET_VAR();
1753
- if (data._status == 1) {
1754
- const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
1755
- if (!getCookie('hhg-id')) {
1756
- setCookie('hhg-id', v1(), {
1757
- domain: '.' + leadDomain,
1758
- path: '/',
1759
- });
1760
- LeadLog('😍 Set HHG ID cookie');
1761
- }
1762
- // getCookie('hhg-id')
1763
- // TODO: HP-534 Filter desktop
1764
- let campaignsDevice = [];
1765
- if (isMobile()) {
1766
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
1767
- }
1768
- else {
1769
- campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
1770
- }
1771
- LeadLog(`👓 campaignsDevice`, campaignsDevice);
1772
- LeadLog('--listCampaignScheduled', listCampaignScheduled);
1773
- LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
1774
- LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
1775
- LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
1776
- LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
1777
- LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
1778
- // Check links
1779
- let listLinksObj = campaignsDevice
1780
- .map((i, index) => i.targets
1781
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
1782
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1783
- .flat(1);
1784
- // Check list link match current href
1785
- listLinksObj = listLinksObj.filter((i) => {
1786
- var _a;
1787
- const target = new URL(String(i.target).toLowerCase());
1788
- if (i.option == 'exact_match')
1789
- // FOR TEST LOCAL:
1790
- // return Boolean(location.pathname === target.pathname)
1791
- return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
1792
- if (i.option == 'start_with') {
1793
- // FOR TEST LOCAL:
1794
- // if (location.pathname.includes(target.pathname)) {
1795
- if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
1796
- const listExcluding = i.sub_target
1797
- .filter((i) => i.option == 'excluding')
1798
- .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
1799
- return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
1800
- }
1801
- else {
1802
- return false;
1803
- }
1804
- }
1805
- });
1806
- // Check tags
1807
- const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
1808
- const listTags = listMetaTag.map((i) => i.content);
1809
- let listCampaignHasTag = [];
1810
- let listTagsObj = [];
1811
- if (listTags && listTags.length) {
1812
- listCampaignHasTag = campaignsDevice
1813
- .map((i, index) => i.targets
1814
- .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
1815
- .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
1816
- .flat(1);
1817
- listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
1818
- }
1819
- const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
1820
- const cookieKeys = document.cookie
1821
- .split('; ')
1822
- .map((i) => i.split('=')[0]);
1823
- const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
1824
- LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
1825
- const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
1826
- LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
1827
- const listCampaignSubmitedClosed = [
1828
- ...listCampaignCodeSubmited,
1829
- ...listCampaignCodeClosed,
1830
- ];
1831
- const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
1832
- const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
1833
- return !hasSubmited;
1834
- });
1835
- const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
1836
- // .sort(
1837
- // (a, b) =>
1838
- // (listCampaignValid[a.campaignIndex]?.score || 0) -
1839
- // (listCampaignValid[b.campaignIndex]?.score || 0),
1840
- // )
1841
- LeadLog('--listCampaignValid : ', listCampaignValid);
1842
- if (listCampaignValid && listCampaignValid.length) {
1843
- const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
1844
- LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
1845
- const { rules } = CAMPAIGN_SHOW;
1846
- // CHECK RULE TRIGGER POPUP
1847
- const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
1848
- LeadLog(`timeoutRule`, timeoutRule);
1849
- const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
1850
- LeadLog(`scrollRule`, scrollRule);
1851
- let impressionAction = 'TIME';
1852
- if (Number.isInteger(timeoutRule)) {
1853
- impressionAction = 'TIME';
1854
- LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
1855
- timeoutRef = setTimeout(() => {
1856
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1857
- }, timeoutRule * 1000);
1858
- }
1859
- if (Number.isInteger(scrollRule)) {
1860
- impressionAction = 'SCROLL';
1861
- LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
1862
- const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
1863
- document.querySelector('body');
1864
- const pct = $p.getBoundingClientRect().top;
1865
- const pb = $p.offsetHeight;
1866
- LeadLog(`👓 Element check scroll: `, $p);
1867
- LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
1868
- const wt = window.pageYOffset || document.documentElement.scrollTop;
1869
- let percent = 0;
1870
- if (wt >= pct) {
1871
- percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
1872
- }
1873
- LeadLog('---Scroll', percent, scrollRule);
1874
- // TODO: CHECK FOOTER HEIGHT
1875
- if (percent >= scrollRule) {
1876
- window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
1877
- onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
1878
- }
1879
- };
1880
- window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
1881
- passive: true,
1882
- });
1883
- }
1884
- }
1885
- else {
1886
- LeadLog('🚧 No lead campaigns on current URL, tags');
1887
- }
1888
- }
1889
- })
1890
- .catch((err) => {
1891
- LeadLog(`Lead error: `, err);
1892
- });
1893
- }
1894
- const LeadLog = (...params) => {
1895
- if (process.env.NODE_ENV !== 'production' ||
1896
- (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
1897
- process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
1898
- (typeof localStorage !== 'undefined' &&
1899
- localStorage.getItem('hhg_debug') === 'true')) {
1900
- console.log(...params);
1901
- }
1902
- };
1903
-
1904
- const LeadGenContext = createContext({
1905
- submit(value) {
1906
- /** Init for FAKING function */
1907
- LeadLog('** LeadGen Submit : ', value);
1908
- return Promise.reject(value);
1909
- },
1910
- submitSubscriptionBox(value) {
1911
- /** Init for FAKING function */
1912
- LeadLog('** LeadGen SubmitSubscriptionBox : ', value);
1913
- return Promise.reject(value);
1914
- },
1915
- impression(value) {
1916
- /** Init for FAKING function */
1917
- LeadLog('** LeadGen Impression : ', value);
1918
- return Promise.reject(value);
1919
- },
1920
- /** For Subscription Box */
1921
- subscriptionIcon: '',
1922
- subscriptionTitle: '',
1923
- });
1924
- const LeadGenContextProvider = (props) => {
1925
- const { campaign_code: campaignCodeProps, apiSsoUrl, apiLeadUrl, apiSubotUrl, locale: localeProps, forceCampaign: forceCampaignProps, extraValues, articleId = 1, categoryId = 1, siteDomain: site_domain, children, } = props;
1926
- const [forceCampaign, setForceCampaign] = useState(forceCampaignProps);
1927
- const [subscriptionInfo, setSubscriptionInfo] = useState({
1928
- subscriptionIcon: '',
1929
- subscriptionTitle: '',
1930
- });
1931
- const locale = useMemo(() => {
1932
- return localeProps || LOCALE['PhilippinesEnglish'];
1933
- }, [localeProps]);
1934
- const leadGenContextValue = useMemo(() => (Object.assign(Object.assign({}, props), { forceCampaign })), [...Object.values(props), forceCampaign]);
1935
- const { url, campaign_id, campaign_code, cookie_id, ga_client_id, category_id, article_id, article_title, } = useMemo(() => ({
1936
- url: location.href.toLowerCase() || '',
1937
- cookie_id: getCookie('hhg-id') || null,
1938
- ga_client_id: getCookie('_ga'),
1939
- campaign_id: forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id,
1940
- campaign_code: campaignCodeProps || (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code),
1941
- category_id: categoryId,
1942
- article_id: articleId,
1943
- article_title: document.title || '',
1944
- }), [campaignCodeProps, articleId, categoryId, forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id]);
1945
- const fetchCampaign = useCallback((campaign_code) => {
1946
- Service.getCampaignByCode(campaign_code).then((res) => {
1947
- const { _data } = res || {};
1948
- const { campaigns } = _data || {};
1949
- LeadLog('** LeadGen Campaign : ', campaigns);
1950
- setForceCampaign(formatCampaignDetail(campaigns));
1951
- });
1952
- }, [campaignCodeProps]);
1953
- // TODO : Update form for LeadGen
1954
- const submit = useCallback((data) => {
1955
- return Service.postSubscriptionBoxLead({ data });
1956
- }, []);
1957
- const submitSubscriptionBox = useCallback((value) => {
1958
- const data = Object.assign(Object.assign(Object.assign(Object.assign({}, value), { campaign_id,
1959
- site_domain, url: (value === null || value === void 0 ? void 0 : value.url) || url, ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id }), extraValues), { article_id,
1960
- category_id, article_title: (extraValues === null || extraValues === void 0 ? void 0 : extraValues.article_title) || article_title });
1961
- return Service.postSubscriptionBoxLead({ data });
1962
- }, [
1963
- extraValues,
1964
- site_domain,
1965
- campaign_id,
1966
- article_id,
1967
- article_title,
1968
- category_id,
1969
- url,
1970
- ga_client_id,
1971
- ]);
1972
- const impression = useCallback((value) => {
1973
- return Service.campaignPostImpression({
1974
- url: (value === null || value === void 0 ? void 0 : value.url) || url,
1975
- action: (value === null || value === void 0 ? void 0 : value.action) || LEADGEN_ACTIONS.SCROLL,
1976
- code: (value === null || value === void 0 ? void 0 : value.code) || campaign_code,
1977
- title_article: (value === null || value === void 0 ? void 0 : value.title_article) || article_title,
1978
- cookie_id: (value === null || value === void 0 ? void 0 : value.cookie_id) || cookie_id,
1979
- ga_client_id: (value === null || value === void 0 ? void 0 : value.ga_client_id) || ga_client_id,
1980
- extra: (value === null || value === void 0 ? void 0 : value.extra) || Object.assign({ cookie_id,
1981
- article_id, subscription_title: subscriptionInfo.subscriptionTitle }, extraValues),
1982
- referrer: value === null || value === void 0 ? void 0 : value.referrer,
1983
- });
1984
- }, [
1985
- extraValues,
1986
- campaign_id,
1987
- url,
1988
- campaign_code,
1989
- article_title,
1990
- cookie_id,
1991
- ga_client_id,
1992
- article_id,
1993
- subscriptionInfo.subscriptionTitle,
1994
- ]);
1995
- useEffect(() => {
1996
- if (forceCampaignProps) {
1997
- setForceCampaign(forceCampaignProps);
1998
- return;
1999
- }
2000
- /** For Subscription Box */
2001
- if (categoryId) {
2002
- Service.getSubscriptionBoxInfo({
2003
- category: categoryId,
2004
- site: site_domain,
2005
- }).then((res) => {
2006
- const { _data } = res || {};
2007
- const { item, campaign_code } = _data || {};
2008
- const { icon, content } = item;
2009
- LeadLog('** LeadGen SubscriptionBox campaign_code : ', campaign_code);
2010
- LeadLog('** LeadGen SubscriptionBox subscription_icon : ', icon);
2011
- LeadLog('** LeadGen SubscriptionBox subscription_title : ', content);
2012
- if (icon && content) {
2013
- setSubscriptionInfo({
2014
- subscriptionIcon: icon,
2015
- subscriptionTitle: content,
2016
- });
2017
- }
2018
- fetchCampaign(campaign_code);
2019
- });
2020
- return;
2021
- }
2022
- if (campaignCodeProps) {
2023
- fetchCampaign(campaignCodeProps);
2024
- }
2025
- }, [campaignCodeProps, categoryId]);
2026
- useEffect(() => {
2027
- leadStore.apiSsoUrl = apiSsoUrl;
2028
- leadStore.apiLeadUrl = apiLeadUrl;
2029
- leadStore.apiSubotUrl = apiSubotUrl;
2030
- }, [apiLeadUrl, apiSubotUrl, apiSsoUrl]);
2031
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
2032
- return null;
2033
- }
2034
- return (React__default.createElement(LeadGenContext.Provider, { value: Object.assign(Object.assign(Object.assign({}, leadGenContextValue), subscriptionInfo), { submit,
2035
- submitSubscriptionBox,
2036
- impression }) },
2037
- React__default.createElement(LeadGenTranslationProvider, { locale: locale }, children)));
2038
- };
2039
- const useLeadGenContext = () => {
2040
- const context = useContext(LeadGenContext);
2041
- return Object.assign(Object.assign({}, context), { apiLeadUrl: context.apiLeadUrl || leadStore.apiLeadUrl, apiSubotUrl: context.apiSubotUrl || leadStore.apiSubotUrl });
2042
- };
2043
-
2044
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2045
- const customParseFormat = require('dayjs/plugin/customParseFormat');
2046
- dayjs.extend(customParseFormat);
2047
- // You can give context variables any name
2048
- const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
2049
- const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, format, }) => {
2050
- var _a;
2051
- const { t } = useTranslations();
2052
- const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
2053
- const LEAD_LOCALE = LEAD_LOCALE_DATA[(_a = document === null || document === void 0 ? void 0 : document.documentElement) === null || _a === void 0 ? void 0 : _a.lang] ||
2054
- LEAD_LOCALE_DATA['vi-VN'];
2055
- const validateObj = useMemo(() => {
2056
- const InputBlocks = [
2057
- 'TextBlock',
2058
- 'NumberBlock',
2059
- 'EmailBlock',
2060
- 'PhoneBlock',
2061
- 'DateBlock',
2062
- 'CheckboxBlock',
2063
- 'RadioBlock',
2064
- 'DropdownBlock',
2065
- 'PhoneOtpBlock',
2066
- 'WhatsappOtpBlock',
2067
- 'ZaloOtpBlock',
2068
- 'LocationBlock',
2069
- 'TncBlock',
2070
- ];
2071
- // ALL are required and can skip if not touched yet
2072
- const withSharedCheck = (name, cb,
2073
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2074
- block) => {
2075
- return (value) => {
2076
- var _a;
2077
- const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
2078
- if (!formRef.current.isTouched(name))
2079
- return;
2080
- if ((typeof value === 'string' && value.trim() === '') ||
2081
- typeof value === 'undefined' ||
2082
- (Array.isArray(value) && value.length === 0)) {
2083
- return isBLockRequired
2084
- ? t('validator.required')
2085
- : cb === null || cb === void 0 ? void 0 : cb(value);
2086
- }
2087
- return cb === null || cb === void 0 ? void 0 : cb(value);
2088
- };
2089
- };
2090
- return listBlockAdded
2091
- .filter((b) => InputBlocks.includes(b.name))
2092
- .reduce((r, b) => {
2093
- const { name: fieldType, data } = b || {};
2094
- const { value: fieldName, required } = data || {};
2095
- const isRequired = required !== null && required !== void 0 ? required : true;
2096
- if (fieldType === 'NumberBlock') {
2097
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2098
- if (value && isNaN(Number(value))) {
2099
- return t('validator.number');
2100
- }
2101
- }, b) });
2102
- }
2103
- else if (fieldType === 'EmailBlock') {
2104
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2105
- if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
2106
- return t('validator.email');
2107
- }
2108
- if (!value)
2109
- return;
2110
- validatingEmailRef.current = true;
2111
- setTimeout(() => {
2112
- formRef.current.setFieldError(fieldName, 'Validating...');
2113
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2114
- email: value,
2115
- })
2116
- .then((tKey) => {
2117
- if (tKey) {
2118
- formRef.current.setFieldError(fieldName, t(tKey));
2119
- }
2120
- else {
2121
- formRef.current.clearFieldError(fieldName);
2122
- }
2123
- validatingEmailRef.current = false;
2124
- })
2125
- .catch((e) => {
2126
- console.error(e);
2127
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2128
- validatingEmailRef.current = false;
2129
- });
2130
- }, 200);
2131
- }, b) });
2132
- }
2133
- else if (fieldType === 'PhoneBlock' ||
2134
- fieldType === 'PhoneOtpBlock' ||
2135
- fieldType === 'ZaloOtpBlock' ||
2136
- fieldType === 'WhatsappOtpBlock') {
2137
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2138
- if (value &&
2139
- window.intlTelInputUtils &&
2140
- !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
2141
- return t('validator.phone');
2142
- }
2143
- if (!value)
2144
- return;
2145
- validatingPhoneRef.current = true;
2146
- setTimeout(() => {
2147
- formRef.current.setFieldError(fieldName, 'Validating...');
2148
- if (b.data.singleSubmission) {
2149
- checkUsedPhoneOnlyWithCache(campaignId, value)
2150
- .then((tKey) => {
2151
- if (tKey) {
2152
- formRef.current.setFieldError(fieldName, t(tKey));
2153
- }
2154
- else {
2155
- formRef.current.clearFieldError(fieldName);
2156
- }
2157
- validatingPhoneRef.current = false;
2158
- })
2159
- .catch((err) => {
2160
- console.error(err);
2161
- formRef.current.setFieldError(fieldName, err.message || 'Something went wrong');
2162
- validatingPhoneRef.current = false;
2163
- });
2164
- }
2165
- else {
2166
- checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
2167
- phone: value,
2168
- })
2169
- .then((tKey) => {
2170
- if (tKey) {
2171
- formRef.current.setFieldError(fieldName, t(tKey));
2172
- }
2173
- else {
2174
- formRef.current.clearFieldError(fieldName);
2175
- }
2176
- validatingPhoneRef.current = false;
2177
- })
2178
- .catch((e) => {
2179
- console.error(e);
2180
- formRef.current.setFieldError(fieldName, e.message || 'Something went wrong');
2181
- validatingPhoneRef.current = false;
2182
- });
2183
- }
2184
- }, 200);
2185
- }, b) });
2186
- }
2187
- else if (fieldType === 'DateBlock') {
2188
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, (value) => {
2189
- if (!isRequired && !value) {
2190
- return;
2191
- }
2192
- const errMsg = t('validator.dateInvalid');
2193
- const dayInJS = typeof value === 'string'
2194
- ? dayjs(value, format, true)
2195
- : dayjs(value);
2196
- if (!dayInJS.isValid()) {
2197
- return errMsg;
2198
- }
2199
- }, b) });
2200
- }
2201
- else if (fieldType === 'TncBlock') {
2202
- return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
2203
- if (isRequired && !value) {
2204
- return t('validator.required');
2205
- }
2206
- }, b) });
2207
- }
2208
- else {
2209
- return Object.assign(Object.assign({}, r), { [fieldName]: withSharedCheck(fieldName, undefined, b) });
2210
- }
2211
- }, {});
2212
- }, [listBlockAdded.map((b) => b.name).join(','), format]);
2213
- const form = useLeadForm({
2214
- validateInputOnChange: true,
2215
- validateInputOnBlur: true,
2216
- clearInputErrorOnChange: true,
2217
- validate: validateObj,
2218
- initialValues,
2219
- });
2220
- const formRef = useRef(form);
2221
- formRef.current = form;
2222
- return { form, validateObj };
2223
- };
2224
-
2225
- const StyledLeadGenThankYou = styled.div `
2226
- display: flex;
2227
- gap: 8px;
2228
- flex-direction: column;
2229
- padding-block: 24px;
2230
-
2231
- .leadgen-image {
2232
- width: 120px;
2233
- height: 120px;
2234
- margin-inline: auto;
2235
- object-fit: contain;
2236
- object-position: center;
2237
- text-align: center;
2238
- }
2239
-
2240
- .leadgen-title {
2241
- margin-block: 0;
2242
- color: ${theme.colors.gray900};
2243
- font-weight: 700;
2244
- font-size: 18px;
2245
- line-height: 28px;
2246
- letter-spacing: -0.2px;
2247
- }
2248
-
2249
- .leadgen-description {
2250
- margin-block: 0;
2251
- color: ${theme.colors.gray600};
2252
- font-weight: 400;
2253
- font-size: 14px;
2254
- line-height: 22px;
2255
- letter-spacing: -0.2px;
2256
- text-align: center;
2257
- }
2258
-
2259
- > [data-align] {
2260
- &[data-align='right'] {
2261
- text-align: right;
2262
- }
2263
- &[data-align='center'] {
2264
- text-align: center;
2265
- }
2266
- }
2267
- `;
2268
- const LeadGenThankYou = ({ image, title, description, showButton = false, button, className, style, }) => {
2269
- const { src } = image;
2270
- const { htmlText: titleText, align: titleAlign } = title;
2271
- const { htmlText: descriptionText, align: descriptionAlign } = description;
2272
- const { htmlText: buttonText, newtab, url, onClick } = button;
2273
- return (React__default.createElement(StyledLeadGenThankYou, { className: className, style: style },
2274
- React__default.createElement("img", { src: src, alt: "", className: "leadgen-thankyou_image leadgen-image" }),
2275
- React__default.createElement("p", { className: "leadgen-thankyou_title leadgen-title", "data-align": titleAlign }, titleText),
2276
- React__default.createElement("p", { className: "leadgen-thankyou_description leadgen-description", "data-align": descriptionAlign }, descriptionText),
2277
- !!buttonText && showButton && (React__default.createElement(Button$2, { component: url ? 'a' : 'button', target: newtab ? '_blank' : undefined, href: url, size: "lg", variant: "filled", className: "leadgen-thankyoue_btn leadgen-btn", onClick: onClick }, buttonText))));
2278
- };
2279
-
2280
- const StyledLeadGenSubscriptionBoxBody = styled.div `
2281
- margin-top: 16px;
2282
- .leadgen-btn {
2283
- margin-top: 16px;
2284
- }
2285
- `;
2286
- const StyledLeadGenSubscriptionBoxHeaderImage = styled.div `
2287
- margin-top: 3px;
2288
- margin-right: 20px;
2289
- width: 44px;
2290
- height: 44px;
2291
-
2292
- img {
2293
- width: 100%;
2294
- height: 100%;
2295
- object-fix: contain;
2296
- onject-position: center;
2297
- }
2298
-
2299
- :has(img[src='']) {
2300
- display: none;
2301
- }
2302
- `;
2303
- const StyledLeadGenSubscriptionBoxHeader = styled.div `
2304
- display: flex;
2305
- align-items: center;
2306
- margin-bottom: 16px;
2307
- .leadgen-title {
2308
- margin-bottom: 0;
2309
- flex: 1;
2310
- min-width: 0;
2311
- color: ${theme.colors.gray900};
2312
- font-size: 18px;
2313
- font-weight: 400;
2314
- line-height: 1.4;
2315
- letter-spacing: -0.8px;
2316
- }
2317
- `;
2318
- const StyledLeadGenSubscriptionBox = styled.div `
2319
- padding: 16px;
2320
- border: 1px solid ${theme.colors.neutral100};
2321
- border-radius: 12px;
2322
- margin-inline: auto;
2323
- .leadgen-form_inputs {
2324
- .leadgen-form_input {
2325
- width: 100%;
2326
- }
2327
- }
2328
-
2329
- .leadgen-form_input {
2330
- .mantine-Input-wrapper {
2331
- max-height: 56px;
2332
- }
2333
- }
2334
-
2335
- @media screen and (min-width: 768px) {
2336
- .leadgen-subscription_box_body {
2337
- display: flex;
2338
- > form {
2339
- flex: 1;
2340
- min-width: 0;
2341
-
2342
- .leadgen-form_inputs {
2343
- .leadgen-form_input {
2344
- width: calc(50% - 4px);
2345
- }
2346
- }
2347
- }
2348
-
2349
- .leadgen-btn {
2350
- margin-top: 0;
2351
- margin-left: 8px;
2352
- width: auto;
2353
- min-height: 56px;
2354
- }
2355
- }
2356
- }
2357
- `;
2358
- const StyledLeadGenSubscriptionBoxA = styled.div `
2359
- .leadgen-form_input {
2360
- --phone-select: 45px;
2361
- .PhoneInput {
2362
- --phone-select: 45px;
2363
- .PhoneInputCountry {
2364
- margin-top: 1px;
2365
- pointer-events: none;
2366
- .PhoneInputCountryIconImg,
2367
- .PhoneInputArrowContainer {
2368
- display: none;
2369
- }
2370
- }
2371
- }
2372
- }
2373
- `;
2374
-
2375
- const PhoneInput = forwardRef((props, ref) => {
2376
- const { defaultCountry, id: idProps, name, placeholder, label, labelElement, labelProps, description, descriptionProps, withAsterisk, inputMode, inputContainer, inputWrapperOrder, error, className, classNames, style, styles } = props, restProps = __rest(props, ["defaultCountry", "id", "name", "placeholder", "label", "labelElement", "labelProps", "description", "descriptionProps", "withAsterisk", "inputMode", "inputContainer", "inputWrapperOrder", "error", "className", "classNames", "style", "styles"]);
2377
- const id = idProps || v1() + name;
2378
- return (React__default.createElement(Input$1.Wrapper, { size: "md", label: label, labelElement: labelElement, labelProps: Object.assign({ htmlFor: id }, labelProps), description: description, descriptionProps: descriptionProps, withAsterisk: withAsterisk, inputMode: inputMode, inputContainer: inputContainer, inputWrapperOrder: inputWrapperOrder, error: error, "data-invalid": !!error, className: className, classNames: classNames, style: style, styles: styles },
2379
- React__default.createElement("div", { className: "mantine-Input-wrapper" },
2380
- React__default.createElement(Phone, Object.assign({}, restProps, { id: id, ref: ref, name: name, spellCheck: false, placeholder: placeholder, defaultCountry: defaultCountry, className: "mantine-Input-input", type: "tel", "data-control": "tel" })))));
2381
- });
2382
-
2383
- const formatLeadGenFormValue = (values, blocks) => {
2384
- const newValues = {};
2385
- for (const block of blocks) {
2386
- const { data } = block || {};
2387
- const { value: fieldName } = data || {};
2388
- if (fieldName in values) {
2389
- newValues[fieldName] = values[fieldName];
2390
- }
2391
- }
2392
- return newValues;
2393
- };
2394
-
2395
- const StyledLeadGenFormInner = styled.div `
2396
- display: flex;
2397
- flex-wrap: wrap;
2398
- gap: 8px;
2399
- .leadgen-form_input {
2400
- width: calc(50% - 4px);
2401
- }
2402
-
2403
- .leadgen-form_input_checkbox {
2404
- width: 100%;
2405
- }
2406
- `;
2407
-
2408
- const cssInputNotShrink$1 = css `
2409
- height: 100% !important;
2410
- min-height: calc(var(--container-height, 56px) * 22 / 56);
2411
- color: ${theme.colors.gray800};
2412
- font-size: var(--input, 16px);
2413
- line-height: calc(var(--container-height, 56px) * 22 / 56);
2414
- border: none !important;
2415
- border-radius: 0 !important;
2416
- outline: none !important;
2417
- box-shadow: none !important;
2418
- padding: 0;
2419
- cursor: pointer;
2420
- opacity: 0;
2421
-
2422
- ::placeholder {
2423
- color: ${theme.colors.gray400};
2424
- }
2425
- `;
2426
- const cssInputShrink$1 = css `
2427
- height: auto !important;
2428
- cursor: text;
2429
- opacity: 1;
2430
- transition: 0.1s ease-in-out all;
2431
- `;
2432
- const cssLabelNotShrink$1 = css `
2433
- position: absolute;
2434
- top: calc(var(--container-height) / 2);
2435
- left: var(--space-x, 16px);
2436
- color: ${theme.colors.gray400};
2437
- font-size: var(--label-not-shrink, 16px);
2438
- font-weight: 400;
2439
- line-height: calc(var(--container-height, 56px) * 18 / 56);
2440
- margin: 0;
2441
- z-index: 1;
2442
- cursor: pointer;
2443
- transform: translateY(-50%);
2444
- transition: 0.125s ease-in all;
2445
- `;
2446
- const cssLabelShrink$1 = css `
2447
- color: ${theme.colors.gray600};
2448
- font-weight: 600;
2449
- font-size: var(--label-shrink, 12px);
2450
- top: calc(var(--container-height) * 7 / 56);
2451
- transform: none;
2452
- transition: 0.125s ease-out all;
2453
- `;
2454
- const cssWrapperInputNotShrink$1 = css `
2455
- min-height: var(--container-height, 56px);
2456
- display: flex;
2457
- align-items: flex-end;
2458
- border: 1px solid ${theme.colors.gray200};
2459
- border-radius: 8px;
2460
- background-color: #fff;
2461
- padding-inline: var(--space-x, 16px);
2462
- padding-block: var(--space-y-not-shrink, 16px);
2463
- cursor: pointer;
2464
- pointer-events: none;
2465
-
2466
- &:has(.mantine-Input-rightSection) {
2467
- padding-right: var(--container-height, 56px);
2468
- }
2469
-
2470
- .mantine-Input-icon {
2471
- display: none;
2472
- }
2473
-
2474
- .mantine-NumberInput-control {
2475
- border-color: ${theme.colors.gray200};
2476
- }
2477
- `;
2478
- const cssWrapperInputShrink$1 = css `
2479
- height: auto;
2480
- min-height: var(--container-height, 56px);
2481
- padding-block: var(--space-y-shrink, 7px);
2482
- cursor: text;
2483
- pointer-events: auto;
2484
- `;
2485
- const cssInputWrapperError$1 = css `
2486
- color: ${theme.colors.red800};
2487
- font-size: 12px;
2488
- line-height: 1.5;
2489
- `;
2490
- const StyledTextFieldContainer$1 = styled.div `
2491
- --space-x: 16px;
2492
- --space-y-not-shrink: 16px;
2493
- --space-y-shrink: 7px;
2494
- --container-height: 56px;
2495
- --label-not-shrink: 16px;
2496
- --label-shrink: 12px;
2497
- --input: 16px;
2498
-
2499
- position: relative;
2500
- min-width: 100px;
2501
- max-width: 100%;
2502
- display: inline-block;
2503
-
2504
- .textField_wrapper {
2505
- display: inline-block;
2506
- width: 100%;
2507
- cursor: pointer;
2508
- }
2509
-
2510
- .mantine-InputWrapper-root {
2511
- &[data-invalid='true'] {
2512
- .mantine-Input-wrapper {
2513
- border-color: ${theme.colors.red400};
2514
- }
2515
- }
2516
-
2517
- .mantine-Input-wrapper {
2518
- &:has([data-invalid]) {
2519
- border-color: ${theme.colors.red400};
2520
- }
2521
- }
2522
-
2523
- .mantine-InputWrapper-error {
2524
- font-size: 12px !important;
2525
- }
2526
- }
2527
-
2528
- .mantine-InputWrapper-label {
2529
- ${cssLabelNotShrink$1}
2530
- }
2531
-
2532
- .mantine-Input-wrapper {
2533
- ${cssWrapperInputNotShrink$1}
2534
-
2535
- + .mantine-Popover-dropdown[data-position="bottom-start"] {
2536
- left: 0 !important;
2537
- }
2538
- + .mantine-Popover-dropdown[data-position='top-start'] {
2539
- top: unset !important;
2540
- left: 0 !important;
2541
- bottom: 100% !important;
2542
- }
2543
- }
2544
-
2545
- .mantine-Input-input {
2546
- ${cssInputNotShrink$1}
2547
- }
2548
-
2549
- &.textField_shrink,
2550
- &:focus-within {
2551
- .mantine-InputWrapper-label {
2552
- ${cssLabelShrink$1}
2553
- }
2554
-
2555
- .mantine-Input-wrapper {
2556
- ${cssWrapperInputShrink$1}
2557
- &.mantine-Select-wrapper {
2558
- .mantine-Select-rightSection {
2559
- pointer-events: auto !important;
2560
- }
2561
- }
2562
- }
2563
-
2564
- .mantine-Input-input {
2565
- ${cssInputShrink$1}
2566
- }
2567
-
2568
- &:has(.PhoneInput) {
2569
- .mantine-InputWrapper-label {
2570
- left: var(--space-x, 16px);
2571
- }
2572
- .PhoneInput {
2573
- .PhoneInputInput {
2574
- opacity: 1;
2575
- }
2576
- }
2577
- }
2578
- }
2579
-
2580
- .PhoneInput {
2581
- --phone-select: 75px;
2582
- --phone-input-space-x: 8px;
2583
- width: 100%;
2584
- opacity: 1;
2585
- border: none;
2586
- .PhoneInputCountry {
2587
- background-color: transparent;
2588
- border: none;
2589
- padding: 0;
2590
- width: var(--phone-select, 75px);
2591
- }
2592
- .PhoneInputInput {
2593
- flex: 1;
2594
- min-width: 0;
2595
- line-height: 1.5;
2596
- outline: none !important;
2597
- border: none;
2598
- box-shadow: none;
2599
- padding: 0 var(--phone-input-space-x, 8px);
2600
- opacity: 0;
2601
- color: ${theme.colors.gray800} !important;
2602
- :focus {
2603
- color: ${theme.colors.gray800} !important;
2604
- }
2605
- }
2606
- }
2607
-
2608
- &:has(.PhoneInput) {
2609
- .mantine-InputWrapper-label {
2610
- left: calc(
2611
- var(--space-x, 16px) + var(--phone-select, 75px) +
2612
- var(--phone-input-space-x, 8px)
2613
- );
2614
- }
2615
- }
2616
- `;
2617
- const StyledChoiceFieldContainer$1 = styled.div `
2618
- &.leadgen-form_checkbox,
2619
- &.leadgen-form_radio {
2620
- width: 100%;
2621
- }
2622
-
2623
- &.leadgen-form_dropdown {
2624
- width: calc(50% - 12px);
2625
- }
2626
-
2627
- .mantine-InputWrapper-root {
2628
- display: block;
2629
- .mantine-InputWrapper-error {
2630
- font-size: 12px !important;
2631
- }
2632
- }
2633
-
2634
- .mantine-InputWrapper-label {
2635
- margin-bottom: 0.5rem;
2636
- color: ${theme.colors.gray800};
2637
- font-size: 16px;
2638
- font-weight: 400;
2639
- line-height: 1.5;
2640
- }
2641
-
2642
- .mantine-Radio-root,
2643
- .mantine-Checkbox-root {
2644
- gap: 8px;
2645
- min-width: calc(50% - 4px);
2646
-
2647
- input[type='radio'],
2648
- input[type='checkbox'] {
2649
- border-color: ${theme.colors.gray600};
2650
- width: 18px;
2651
- height: 18px;
2652
- }
2653
- input[type='checkbox'] {
2654
- border-radius: 4px;
2655
- }
2656
-
2657
- &[data-checked='true'] {
2658
- input[type='radio'],
2659
- input[type='checkbox'] {
2660
- border-color: ${theme.colors.primary600};
2661
- + svg {
2662
- color: ${theme.colors.primary600};
2663
- }
2664
- }
2665
-
2666
- input[type='radio'] {
2667
- background-color: white;
2668
- }
2669
- }
2670
-
2671
- .mantine-Checkbox-input {
2672
- &:checked {
2673
- border-color: ${theme.colors.primary600};
2674
- }
2675
- }
2676
- }
2677
-
2678
- .mantine-Radio-inner,
2679
- .mantine-Checkbox-inner {
2680
- width: 24px;
2681
- height: 24px;
2682
- display: flex;
2683
- align-items: center;
2684
- justify-content: center;
2685
- }
2686
-
2687
- .mantine-Radio-body,
2688
- .mantine-Checkbox-body {
2689
- display: flex;
2690
- align-items: center;
2691
- }
2692
-
2693
- .mantine-Radio-label,
2694
- .mantine-Checkbox-label {
2695
- padding-left: 8px;
2696
- color: ${theme.colors.gray800};
2697
- font-size: 14px;
2698
- line-height: 1.4;
2699
- letter-spacing: -0.2px;
2700
- }
2701
-
2702
- .leadgen-choiceContainer {
2703
- display: flex;
2704
- flex-wrap: wrap;
2705
- align-items: flex-start;
2706
- gap: 8px;
2707
- }
2708
-
2709
- .mantine-InputWrapper-error {
2710
- ${cssInputWrapperError$1}
2711
- }
2712
- `;
2713
-
2714
- const TextField$1 = (props) => {
2715
- const { shrink: shrinkProps, onChangeShrink, className, children } = props, restProps = __rest(props, ["shrink", "onChangeShrink", "className", "children"]);
2716
- const containerRef = useClickOutside(() => {
2717
- if (shrinkProps) {
2718
- return;
2719
- }
2720
- setShrink(false);
2721
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(false);
2722
- });
2723
- const [shrink, setShrink] = useState(shrinkProps);
2724
- const onClick = useCallback((e) => {
2725
- setShrink(true);
2726
- onChangeShrink === null || onChangeShrink === void 0 ? void 0 : onChangeShrink(true);
2727
- if (shrink) {
2728
- return;
2729
- }
2730
- const $textEl = e.currentTarget.querySelectorAll('input:not([disabled]):not([type="submit"]),select:not([disabled]),textarea:not([disabled])');
2731
- const $focusEl = $textEl.item($textEl.length - 1);
2732
- if ($focusEl) {
2733
- $focusEl.focus();
2734
- setTimeout(() => {
2735
- $focusEl.scrollIntoView({
2736
- behavior: 'auto',
2737
- block: 'center',
2738
- inline: 'start',
2739
- });
2740
- }, 100);
2741
- }
2742
- }, [shrink]);
2743
- useEffect(() => {
2744
- setShrink(shrinkProps);
2745
- }, [shrinkProps]);
2746
- return (React__default.createElement(StyledTextFieldContainer$1, Object.assign({ shrink: shrink, className: clsx(className, 'textField', { textField_shrink: !!shrink }) }, restProps),
2747
- React__default.createElement("div", { ref: containerRef, onClick: onClick, className: "textField_wrapper" }, children)));
2748
- };
2749
- const ChoiceField$1 = (props) => {
2750
- const { children, className } = props, restProps = __rest(props, ["children", "className"]);
2751
- return (React__default.createElement(StyledChoiceFieldContainer$1, Object.assign({ className: clsx(className, 'choiceField') }, restProps), children));
2752
- };
2753
-
2754
- const libraries = ['places'];
2755
- const GoogleLocationBlock = (props) => {
2756
- var _a;
2757
- const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
2758
- const [LoadScript, setLoadScript] = useState(null);
2759
- const [value, setValue] = useState(defaultValue || valueProps);
2760
- const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
2761
- const onChangeAutocomplete = useCallback((s) => {
2762
- setValue(s);
2763
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
2764
- }, []);
2765
- const onClickItem = useCallback((item) => {
2766
- /** For sure get value */
2767
- setValue(item.value);
2768
- const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
2769
- onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
2770
- }, [onChangeProps, predictions]);
2771
- useEffect(() => {
2772
- setValue(valueProps);
2773
- }, [valueProps]);
2774
- useEffect(() => {
2775
- var _a, _b, _c;
2776
- // only load extra google script when not yet loaded
2777
- if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
2778
- import('@react-google-maps/api').then((m) => {
2779
- setLoadScript(() => m.LoadScript);
2780
- });
2781
- }
2782
- }, []);
2783
- return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
2784
- return { value: pred.description, label: pred.description };
2785
- }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
2786
- return (React__default.createElement(React__default.Fragment, null,
2787
- LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
2788
- children));
2789
- } }, restProps)));
2790
- };
2791
-
2792
- const LeadGenForm = forwardRef((props, ref) => {
2793
- const { locale, blocks, scrollToErrorField = true, form: formProps, rules: validate, initialValues, onFinish, onFinishFailed, className, style, } = props;
2794
- const formRef = useRef(null);
2795
- const form = formProps || useForm({ initialValues, validate });
2796
- const middlewareFinish = useCallback((values, event) => {
2797
- /** Set `touched` all values for validation when submiting */
2798
- form.setTouched(blocks.reduce((touched, { data }) => {
2799
- touched[data.value] = true;
2800
- return touched;
2801
- }, {}));
2802
- /** Wait for `touched` state and then submit */
2803
- setTimeout(() => {
2804
- const { hasErrors } = form.validate();
2805
- if (hasErrors) {
2806
- return;
2807
- }
2808
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(formatLeadGenFormValue(values, blocks), event);
2809
- }, 100);
2810
- }, [form, blocks]);
2811
- const middlewareFinishFailed = useCallback((errors, values, events) => {
2812
- if (scrollToErrorField && errors) {
2813
- const firstErrorKey = Object.keys(errors)[0];
2814
- const firstErrorElement = document.querySelector(`[name="${firstErrorKey}"]`);
2815
- if (firstErrorElement && (firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus)) {
2816
- setTimeout(() => {
2817
- firstErrorElement === null || firstErrorElement === void 0 ? void 0 : firstErrorElement.focus();
2818
- firstErrorElement.scrollIntoView({
2819
- behavior: 'auto',
2820
- block: 'center',
2821
- inline: 'center',
2822
- });
2823
- }, 100);
2824
- }
2825
- }
2826
- onFinishFailed === null || onFinishFailed === void 0 ? void 0 : onFinishFailed(errors, values, events);
2827
- }, [scrollToErrorField]);
2828
- useEffect(() => {
2829
- (() => __awaiter(void 0, void 0, void 0, function* () {
2830
- if (!window.intlTelInputUtils) {
2831
- yield require('intl-tel-input/build/js/utils');
2832
- }
2833
- }))();
2834
- }, []);
2835
- useImperativeHandle(ref, () => (Object.assign(Object.assign({}, form), { submit: () => {
2836
- formRef.current.requestSubmit();
2837
- } })), [form, formRef]);
2838
- if (!blocks || !blocks.length) {
2839
- return null;
2840
- }
2841
- return (React__default.createElement("form", { ref: formRef, onSubmit: form.onSubmit(middlewareFinish, middlewareFinishFailed), className: className, style: style },
2842
- React__default.createElement(StyledLeadGenFormInner, { className: "leadgen-form_inputs" }, blocks.map((block, idx) => {
2843
- const { id, name: blockName, data } = block;
2844
- const { placeholder, value: name, required, listQuestion, valueHTML, isSendMailChimp = false, } = data;
2845
- const formInputProps = form.getInputProps(name);
2846
- const { value, error } = formInputProps;
2847
- const reactKey = `${id}-${idx}`;
2848
- switch (blockName) {
2849
- case LEADGEN_BLOCK.TextBlock: {
2850
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2851
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "text", "data-control": "text" }, formInputProps))));
2852
- }
2853
- case LEADGEN_BLOCK.NumberBlock: {
2854
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2855
- React__default.createElement(NumberInput$1, Object.assign({ name: value, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "number", "data-control": "number" }, formInputProps))));
2856
- }
2857
- case LEADGEN_BLOCK.EmailBlock: {
2858
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2859
- React__default.createElement(TextInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, "data-control": "email" }, formInputProps))));
2860
- }
2861
- case LEADGEN_BLOCK.PhoneOtpBlock:
2862
- case LEADGEN_BLOCK.WhatsappOtpBlock:
2863
- case LEADGEN_BLOCK.ZaloOtpBlock:
2864
- case LEADGEN_BLOCK.PhoneBlock: {
2865
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2866
- React__default.createElement(PhoneInput, Object.assign({ name: name, spellCheck: false, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), type: "text", "data-control": "text" }, formInputProps))));
2867
- }
2868
- case LEADGEN_BLOCK.LocationBlock: {
2869
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2870
- React__default.createElement(GoogleLocationBlock, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, locale: locale, "data-control": "text" }, formInputProps))));
2871
- }
2872
- case LEADGEN_BLOCK.DateBlock: {
2873
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2874
- React__default.createElement(DateInput, Object.assign({ locale: (MAPPED_LOCALE === null || MAPPED_LOCALE === void 0 ? void 0 : MAPPED_LOCALE[locale]) || MAPPED_LOCALE['vi-VN'], valueFormat: "DD/MM/YYYY", name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, type: "default", "data-control": "date" }, formInputProps))));
2875
- }
2876
- case LEADGEN_BLOCK.DropdownBlock:
2877
- return (React__default.createElement(TextField$1, { key: reactKey, shrink: !!value, className: "leadgen-form_input" },
2878
- React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
2879
- React__default.createElement(Select$1, Object.assign({ name: name, withAsterisk: required, label: placeholder, placeholder: placeholder, data: listQuestion.map((l) => ({
2880
- value: l.value,
2881
- label: l.placeholder,
2882
- })) }, formInputProps))));
2883
- case LEADGEN_BLOCK.CheckboxBlock: {
2884
- const formInputCheckboxProps = form.getInputProps(name, {
2885
- type: 'checkbox',
2886
- });
2887
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2888
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2889
- React__default.createElement(Checkbox$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, sx: {
2890
- display: 'flex',
2891
- flexDirection: 'column',
2892
- flexWrap: 'wrap',
2893
- gap: 8,
2894
- }, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2895
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2896
- } }, formInputCheckboxProps), listQuestion.map((l, _idx) => (React__default.createElement(Checkbox$1, { name: name, key: _idx, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
2897
- }
2898
- case LEADGEN_BLOCK.RadioBlock: {
2899
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2900
- isSendMailChimp && (React__default.createElement("div", { style: { display: 'none' }, "data-name": name + '-mailchimp' })),
2901
- React__default.createElement(Radio$1.Group, Object.assign({ size: "md", withAsterisk: required, label: placeholder, value: value, spellCheck: true, inputWrapperOrder: LEADGEN_ORDER_INPUT_WRAPPER, inputContainer: (children) => {
2902
- return (React__default.createElement("div", { className: "leadgen-choiceContainer" }, children));
2903
- } }, formInputProps), listQuestion.map((l, _index) => (React__default.createElement(Radio$1, { name: name, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
2904
- }
2905
- case LEADGEN_BLOCK.TncBlock:
2906
- return (React__default.createElement(ChoiceField$1, { className: "leadgen-form_input leadgen-form_input_checkbox", key: reactKey },
2907
- React__default.createElement(Input$1.Wrapper, { error: error },
2908
- React__default.createElement(Checkbox$1, Object.assign({ value: value, name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, formInputProps)))));
2909
- default: {
2910
- return null;
2911
- }
2912
- }
2913
- }))));
2914
- });
2915
-
2916
- const LEADGEN_ORDER_INPUT_WRAPPER = ['label', 'input', 'description', 'error'];
2917
-
2918
- const LeadGenSubscriptionBoxA = (props) => {
2919
- const { loading, image, title, submitText, locale, blocks, form, rules, onFinish, } = props;
2920
- const formRef = useRef();
2921
- const imageComp = useMemo(() => {
2922
- if (!image) {
2923
- return null;
2924
- }
2925
- return (React__default.createElement(StyledLeadGenSubscriptionBoxHeaderImage, null,
2926
- React__default.createElement("img", { src: image, alt: "" })));
2927
- }, [image]);
2928
- const titleComp = useMemo(() => {
2929
- if (typeof title === 'string') {
2930
- return (React__default.createElement("p", { className: "leadgen-title", dangerouslySetInnerHTML: { __html: title } }));
2931
- }
2932
- return React__default.createElement("p", { className: "leadgen-title" }, title);
2933
- }, [title]);
2934
- return (React__default.createElement(StyledLeadGenSubscriptionBoxA, { className: "subcription_box_A" },
2935
- React__default.createElement(StyledLeadGenSubscriptionBoxHeader, { className: "leadgen-subscription_box_header" },
2936
- imageComp,
2937
- titleComp),
2938
- React__default.createElement(StyledLeadGenSubscriptionBoxBody, { className: "leadgen-subscription_box_body" },
2939
- React__default.createElement(LeadGenForm, { ref: formRef, form: form, rules: rules, blocks: blocks, locale: locale, onFinish: onFinish, className: "leadgen-subscription_box_form" }),
2940
- React__default.createElement(Button$2, { disabled: loading, loading: loading, variant: "filled", size: "lg", onClick: () => {
2941
- formRef.current.submit();
2942
- }, className: "leadgen-btn leadgen-btn_action", fullWidth: true }, submitText))));
2943
- };
2944
-
2945
- const LeadGenSubscriptionBoxWithoutMemo = ({ locale, userInfo, forceCampaign, categoryId, }) => {
2946
- var _a, _b, _c;
2947
- const { image, extra_fields, id: campaign_id, bot_id: campaign_subot_id = [], ThankYouBlock, } = forceCampaign || {};
2948
- const { textBlocks, listBlockAdded, actionBlocks } = extra_fields || {};
2949
- const { submitBlock } = actionBlocks || {};
2950
- const { apiLeadUrl, subscriptionIcon, subscriptionTitle, submitSubscriptionBox, impression, onFinish, } = useLeadGenContext();
2951
- const { t } = useTranslations();
2952
- const { action: { pushNotifications }, } = useContext(TogetherComponentGlobalContext);
2953
- const refContainer = useRef(null);
2954
- const [loading, setLoading] = useState(false);
2955
- const [showThankyou, setShowThankyou] = useState(false);
2956
- const validatingEmailRef = useRef(false);
2957
- const validatingPhoneRef = useRef(false);
2958
- const { form, validateObj } = useLeadFormConfig({
2959
- listBlockAdded,
2960
- campaignId: campaign_id,
2961
- campaign_subot_id,
2962
- validatingEmailRef,
2963
- validatingPhoneRef,
2964
- userInfo,
2965
- });
2966
- const subscription_title = useMemo(() => {
2967
- var _a, _b;
2968
- return subscriptionTitle ||
2969
- ((_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value) ||
2970
- t('leadgen.message.title.default');
2971
- }, [subscriptionTitle, (_b = (_a = textBlocks === null || textBlocks === void 0 ? void 0 : textBlocks.titleBlock) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value]);
2972
- const { image: thankyouImage, title: thankyouTitle, description: thankyouDescription, button: thankyouButton, } = ThankYouBlock || {};
2973
- const intersectionObserverCallback = useCallback((entries) => {
2974
- entries.forEach((entry) => {
2975
- const { isIntersecting, target } = entry;
2976
- if (!showThankyou &&
2977
- isIntersecting &&
2978
- target === refContainer.current) {
2979
- impression();
2980
- }
2981
- });
2982
- }, [impression, showThankyou]);
2983
- const IObserver = new IntersectionObserver(intersectionObserverCallback);
2984
- const middlewareOnSubmit = useCallback((values) => __awaiter(void 0, void 0, void 0, function* () {
2985
- const newValues = {
2986
- subscription_title,
2987
- };
2988
- const ssoValues = {
2989
- sso_user_id: undefined,
2990
- sso_uuid: undefined,
2991
- sso_verified_profile: undefined,
2992
- };
2993
- const valueKeys = Object.keys(values);
2994
- for (const key of valueKeys) {
2995
- const isPhoneField = leadGenFieldNamePhone(listBlockAdded).some((k) => k === key);
2996
- if (isPhoneField) {
2997
- const phone = parsePhoneNumber(values[key]);
2998
- if (phone.isValid()) {
2999
- /** Seperate `area_code` and `phone_number` for BE */
3000
- newValues['area_code'] = `+${phone.countryCallingCode}`;
3001
- newValues['phone_number'] = phone.nationalNumber;
3002
- /** Only case login has this update */
3003
- if ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) && (userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid)) {
3004
- ssoValues['sso_verified_profile'] =
3005
- phone.number === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone) ? 1 : 0;
3006
- ssoValues['sso_user_id'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.id;
3007
- ssoValues['sso_uuid'] = userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid;
3008
- }
3009
- }
3010
- continue;
3011
- }
3012
- newValues[key] = values[key];
3013
- }
3014
- setLoading(true);
3015
- try {
3016
- const { _data } = (yield submitSubscriptionBox(Object.assign(Object.assign({}, newValues), ssoValues))) || {};
3017
- const { model } = _data || {};
3018
- if (model && (model === null || model === void 0 ? void 0 : model.id)) {
3019
- setShowThankyou(true);
3020
- onFinish === null || onFinish === void 0 ? void 0 : onFinish(Object.assign(Object.assign({}, newValues), ssoValues), listBlockAdded || []);
3021
- }
3022
- }
3023
- catch (error) {
3024
- LeadLog('** LeadGen SubscriptionBox error : ', error);
3025
- pushNotifications({
3026
- message: t('leadgen.message.error.default'),
3027
- type: 'danger',
3028
- });
3029
- }
3030
- setLoading(false);
3031
- }), [
3032
- subscription_title,
3033
- listBlockAdded,
3034
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.id,
3035
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.uid,
3036
- userInfo === null || userInfo === void 0 ? void 0 : userInfo.phone,
3037
- ]);
3038
- useEffect(() => {
3039
- if (refContainer.current) {
3040
- IObserver.observe(refContainer.current);
3041
- }
3042
- return () => {
3043
- IObserver.disconnect();
3044
- };
3045
- }, [categoryId]);
3046
- return (React__default.createElement("div", { ref: refContainer },
3047
- React__default.createElement(StyledLeadGenSubscriptionBox, null,
3048
- showThankyou && (React__default.createElement(LeadGenThankYou, { image: Object.assign(Object.assign({}, thankyouImage), { src: thankyouImage.src || `${apiLeadUrl}admin/img/thanksyou.png` }), title: thankyouTitle, description: thankyouDescription, button: thankyouButton })),
3049
- !showThankyou && (React__default.createElement(LeadGenSubscriptionBoxA, { loading: loading, image: subscriptionIcon || image, title: subscription_title, submitText: (_c = submitBlock === null || submitBlock === void 0 ? void 0 : submitBlock.data) === null || _c === void 0 ? void 0 : _c.value, blocks: listBlockAdded, locale: locale, form: form, rules: validateObj, onFinish: middlewareOnSubmit })))));
3050
- };
3051
- const LeadGenSubscriptionBox$1 = memo(LeadGenSubscriptionBoxWithoutMemo);
3052
-
3053
- const Container = () => {
3054
- const context = useContext(LeadGenContext);
3055
- const { campaign_code, locale, siteId, siteDomain, userInfo, forceCampaign } = context;
3056
- if (!forceCampaign || !(forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.id)) {
3057
- return null;
3058
- }
3059
- return (React__default.createElement(LeadGenSubscriptionBox$1, { locale: locale, siteId: siteId, siteDomain: siteDomain, userInfo: userInfo, forceCampaign: forceCampaign, campaign_code: campaign_code }));
3060
- };
3061
- Container.displayName = 'LeadGenSubscriptionBox';
3062
- const LeadGenSubscriptionBoxContainer = (props) => {
3063
- const { apiUrl, apiSubotUrl } = props;
3064
- return (React__default.createElement(LeadGenContextProvider, Object.assign({}, props, { apiLeadUrl: apiUrl, apiSubotUrl: apiSubotUrl }),
3065
- React__default.createElement(Container, null)));
3066
- };
3067
- const LeadGenSubscriptionBox = LeadGenSubscriptionBoxContainer;
3068
-
3069
- const useImageSize = (src) => {
3070
- const [width, setWidth] = useState(16);
3071
- const [height, setHeight] = useState(9);
3072
- const [loaded, setLoaded] = useState(false);
3073
- // load src image to get its width and height
3074
- useEffect(() => {
3075
- setLoaded(false);
3076
- if (src) {
3077
- const img = new Image();
3078
- img.addEventListener('load', () => {
3079
- setWidth(img.naturalWidth);
3080
- setHeight(img.naturalHeight);
3081
- setLoaded(true);
3082
- });
3083
- img.addEventListener('error', () => {
3084
- setWidth(16);
3085
- setHeight(9);
3086
- setLoaded(true);
3087
- });
3088
- img.src = src;
3089
- }
3090
- else {
3091
- setWidth(16);
3092
- setHeight(9);
3093
- setLoaded(true);
3094
- }
3095
- }, [src]);
3096
- return {
3097
- loaded,
3098
- width,
3099
- height,
3100
- };
3101
- };
3102
-
3103
- const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
3104
- React__default.createElement("svg", { width: "1em", height: "1em", viewBox: "0 0 20 20", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", className: svgClassName },
3105
- React__default.createElement("path", { d: "M9.99981 10.8432L14.0583 14.9017C14.1691 15.0125 14.3083 15.0691 14.476 15.0717C14.6437 15.0743 14.7854 15.0176 14.9013 14.9017C15.0172 14.7858 15.0752 14.6453 15.0752 14.4802C15.0752 14.3151 15.0172 14.1746 14.9013 14.0587L10.8429 10.0002L14.9013 5.9417C15.0121 5.83094 15.0688 5.69172 15.0713 5.52402C15.0739 5.35634 15.0172 5.21456 14.9013 5.09866C14.7854 4.98276 14.6449 4.9248 14.4798 4.9248C14.3147 4.9248 14.1742 4.98276 14.0583 5.09866L9.99981 9.15712L5.94133 5.09866C5.83057 4.98789 5.69135 4.93122 5.52365 4.92866C5.35598 4.92609 5.21419 4.98276 5.09829 5.09866C4.98239 5.21456 4.92444 5.35506 4.92444 5.52018C4.92444 5.6853 4.98239 5.82581 5.09829 5.9417L9.15675 10.0002L5.09829 14.0587C4.98752 14.1694 4.93085 14.3087 4.9283 14.4763C4.92572 14.644 4.98239 14.7858 5.09829 14.9017C5.21419 15.0176 5.3547 15.0756 5.51982 15.0756C5.68493 15.0756 5.82544 15.0176 5.94133 14.9017L9.99981 10.8432Z" }))));
3106
-
3107
- // url: imageBlocks.imageMobile.data.url
3108
- // newTab: imageBlocks.imageMobile.data.newtab
3109
- // imageMobile: campaignShow.image
3110
- // imageDestkop: campaignShow.image_desktop
3111
- const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
3112
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3113
- const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
3114
- if (!imageMobileLoaded || !imageDestkopLoaded)
3115
- return null;
3116
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
3117
- React__default.createElement("div", { className: "le-center-tab-popup" },
3118
- React__default.createElement("div", { style: { position: 'relative' } },
3119
- React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
3120
- isVideo(imageMobile) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-mobile" },
3121
- React__default.createElement("source", { src: imageMobile }))) : (React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
3122
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
3123
- } })),
3124
- isVideo(imageDestkop) ? (React__default.createElement("video", { loop: true, muted: true, autoPlay: true, className: "le-only-desktop" },
3125
- React__default.createElement("source", { src: imageDestkop }))) : (React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
3126
- aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
3127
- } }))),
3128
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
3129
- };
3130
-
3131
- // title: titleText
3132
- // titleAlign: textBlocks.titleBlock.data.align
3133
- // subtitle: textBlocks.subtitleBlock.data.value
3134
- // subtitleAlign: textBlocks.subtitleBlock.data.align
3135
- // url: actionBlocks.linkButtonBlock.data.url
3136
- // urlText: actionBlocks.linkButtonBlock.data.value
3137
- // newTab: actionBlocks.linkButtonBlock.data.newtab
3138
- // imageMobile: campaignShow.image
3139
- // imageDesktop: campaignShow.image_desktop
3140
- const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
3141
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
3142
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
3143
- if (!imageMobileLoaded || !imageDesktopLoaded)
1402
+ // title: titleText
1403
+ // titleAlign: textBlocks.titleBlock.data.align
1404
+ // subtitle: textBlocks.subtitleBlock.data.value
1405
+ // subtitleAlign: textBlocks.subtitleBlock.data.align
1406
+ // url: actionBlocks.linkButtonBlock.data.url
1407
+ // urlText: actionBlocks.linkButtonBlock.data.value
1408
+ // newTab: actionBlocks.linkButtonBlock.data.newtab
1409
+ // imageMobile: campaignShow.image
1410
+ // imageDesktop: campaignShow.image_desktop
1411
+ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
1412
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
1413
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
1414
+ if (!imageMobileLoaded || !imageDesktopLoaded)
3144
1415
  return null;
3145
1416
  return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
3146
1417
  React__default.createElement("aside", { className: "le-only-desktop" },
@@ -3180,6 +1451,7 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
3180
1451
  };
3181
1452
 
3182
1453
  const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
1454
+ const { primaryColor } = useContext(LeadGenContext);
3183
1455
  const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
3184
1456
  if (!imageLoaded)
3185
1457
  return null;
@@ -3199,7 +1471,7 @@ const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkN
3199
1471
  }))),
3200
1472
  linkText && (React__default.createElement("div", null,
3201
1473
  React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
3202
- React__default.createElement("button", { className: `lead-modal__btn ${LEAD_CLASS}` }, linkText)))))));
1474
+ React__default.createElement(Button, { className: `lead-modal__btn ${LEAD_CLASS}`, color: primaryColor }, linkText)))))));
3203
1475
  };
3204
1476
 
3205
1477
  const InlineLayout = ({ content, inlinePosition, }) => {
@@ -3343,8 +1615,213 @@ const EmptyComponent = ({ onClose, onContinue, }) => {
3343
1615
  React__default.createElement(EmptyIcon, { className: "leadgen-empty_image" }),
3344
1616
  React__default.createElement("h5", { className: "leadgen-empty_title" }, t('lead.empty.title')))),
3345
1617
  React__default.createElement("div", { className: "leadgen-empty_footer" },
3346
- React__default.createElement(Button$2, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
3347
- React__default.createElement(Button$2, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1618
+ React__default.createElement(Button$1, { onClick: onClose, size: "lg", variant: "default", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_cancel" }, t('lead.empty.cancel')),
1619
+ React__default.createElement(Button$1, { onClick: onContinue, size: "lg", variant: "filled", fullWidth: false, className: "leadgen-btn leadgen-btn_empty_again" }, t('lead.empty.submitAgain')))));
1620
+ };
1621
+
1622
+ const libraries = ['places'];
1623
+ const GoogleLocationBlock = (props) => {
1624
+ var _a;
1625
+ const { inputWrapperOrder = ['label', 'input', 'description', 'error'], defaultValue, value: valueProps, onChange: onChangeProps, locale } = props, restProps = __rest(props, ["inputWrapperOrder", "defaultValue", "value", "onChange", "locale"]);
1626
+ const [LoadScript, setLoadScript] = useState(null);
1627
+ const [value, setValue] = useState(defaultValue || valueProps);
1628
+ const { predictions } = usePlacesAutocomplete(value, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
1629
+ const onChangeAutocomplete = useCallback((s) => {
1630
+ setValue(s);
1631
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(s);
1632
+ }, []);
1633
+ const onClickItem = useCallback((item) => {
1634
+ /** For sure get value */
1635
+ setValue(item.value);
1636
+ const predCur = predictions === null || predictions === void 0 ? void 0 : predictions.find(({ description }) => description === item.value);
1637
+ onChangeProps === null || onChangeProps === void 0 ? void 0 : onChangeProps(item.value, predCur === null || predCur === void 0 ? void 0 : predCur.rawData);
1638
+ }, [onChangeProps, predictions]);
1639
+ useEffect(() => {
1640
+ setValue(valueProps);
1641
+ }, [valueProps]);
1642
+ useEffect(() => {
1643
+ var _a, _b, _c;
1644
+ // only load extra google script when not yet loaded
1645
+ if (!((_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places) === null || _c === void 0 ? void 0 : _c.AutocompleteService) && !LoadScript) {
1646
+ import('@react-google-maps/api').then((m) => {
1647
+ setLoadScript(() => m.LoadScript);
1648
+ });
1649
+ }
1650
+ }, []);
1651
+ return (React__default.createElement(Autocomplete, Object.assign({ defaultValue: defaultValue, value: value, onChange: onChangeAutocomplete, data: predictions.map((pred) => {
1652
+ return { value: pred.description, label: pred.description };
1653
+ }), filter: () => true, onItemSubmit: onClickItem, inputWrapperOrder: inputWrapperOrder, zIndex: ZINDEX_SSO - 9e6 + 2, withinPortal: true, styles: { dropdown: { pointerEvents: 'auto' } }, inputContainer: (children) => {
1654
+ return (React__default.createElement(React__default.Fragment, null,
1655
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null), style: { width: '100%' } })),
1656
+ children));
1657
+ } }, restProps)));
1658
+ };
1659
+
1660
+ // You can give context variables any name
1661
+ const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
1662
+ const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], userInfo, }) => {
1663
+ const { t } = useTranslations();
1664
+ const initialValues = useMemo(() => mappingSSOToLead(userInfo), [userInfo === null || userInfo === void 0 ? void 0 : userInfo.id]);
1665
+ const validateObj = useMemo(() => {
1666
+ const InputBlocks = [
1667
+ 'TextBlock',
1668
+ 'NumberBlock',
1669
+ 'EmailBlock',
1670
+ 'PhoneBlock',
1671
+ 'DateBlock',
1672
+ 'CheckboxBlock',
1673
+ 'RadioBlock',
1674
+ 'DropdownBlock',
1675
+ 'PhoneOtpBlock',
1676
+ 'WhatsappOtpBlock',
1677
+ 'ZaloOtpBlock',
1678
+ 'LocationBlock',
1679
+ 'TncBlock',
1680
+ ];
1681
+ // ALL are required and can skip if not touched yet
1682
+ const withSharedCheck = (name, cb,
1683
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1684
+ block) => {
1685
+ return (value) => {
1686
+ var _a;
1687
+ const isBLockRequired = (_a = block === null || block === void 0 ? void 0 : block.data) === null || _a === void 0 ? void 0 : _a.required;
1688
+ if (!formRef.current.isTouched(name))
1689
+ return;
1690
+ if ((typeof value === 'string' && value.replace(' ', '') === '') ||
1691
+ typeof value === 'undefined' ||
1692
+ value === '' ||
1693
+ (Array.isArray(value) && value.length === 0)) {
1694
+ return isBLockRequired
1695
+ ? t('validator.required')
1696
+ : cb === null || cb === void 0 ? void 0 : cb(value);
1697
+ }
1698
+ return cb === null || cb === void 0 ? void 0 : cb(value);
1699
+ };
1700
+ };
1701
+ return listBlockAdded
1702
+ .filter((b) => InputBlocks.includes(b.name))
1703
+ .reduce((r, b) => {
1704
+ var _a;
1705
+ const isRequired = (_a = b.data.required) !== null && _a !== void 0 ? _a : true;
1706
+ if (b.name === 'NumberBlock') {
1707
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1708
+ if (value && isNaN(Number(value))) {
1709
+ return t('validator.number');
1710
+ }
1711
+ }, b) });
1712
+ }
1713
+ else if (b.name === 'EmailBlock') {
1714
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1715
+ if (value && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
1716
+ return t('validator.email');
1717
+ }
1718
+ if (!value)
1719
+ return;
1720
+ validatingEmailRef.current = true;
1721
+ setTimeout(() => {
1722
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1723
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1724
+ email: value,
1725
+ })
1726
+ .then((tKey) => {
1727
+ if (tKey) {
1728
+ formRef.current.setFieldError(b.data.value, t(tKey));
1729
+ }
1730
+ else {
1731
+ formRef.current.clearFieldError(b.data.value);
1732
+ }
1733
+ validatingEmailRef.current = false;
1734
+ })
1735
+ .catch((e) => {
1736
+ console.error(e);
1737
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1738
+ validatingEmailRef.current = false;
1739
+ });
1740
+ }, 200);
1741
+ }, b) });
1742
+ }
1743
+ else if (b.name === 'PhoneBlock' ||
1744
+ b.name === 'PhoneOtpBlock' ||
1745
+ b.name === 'ZaloOtpBlock' ||
1746
+ b.name === 'WhatsappOtpBlock') {
1747
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1748
+ if (value &&
1749
+ window.intlTelInputUtils &&
1750
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
1751
+ return t('validator.phone');
1752
+ }
1753
+ if (!value)
1754
+ return;
1755
+ validatingPhoneRef.current = true;
1756
+ setTimeout(() => {
1757
+ formRef.current.setFieldError(b.data.value, 'Validating...');
1758
+ if (b.data.singleSubmission) {
1759
+ checkUsedPhoneOnlyWithCache(campaignId, value)
1760
+ .then((tKey) => {
1761
+ if (tKey) {
1762
+ formRef.current.setFieldError(b.data.value, t(tKey));
1763
+ }
1764
+ else {
1765
+ formRef.current.clearFieldError(b.data.value);
1766
+ }
1767
+ validatingPhoneRef.current = false;
1768
+ })
1769
+ .catch((err) => {
1770
+ console.error(err);
1771
+ formRef.current.setFieldError(b.data.value, err.message || 'Something went wrong');
1772
+ validatingPhoneRef.current = false;
1773
+ });
1774
+ }
1775
+ else {
1776
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
1777
+ phone: value,
1778
+ })
1779
+ .then((tKey) => {
1780
+ if (tKey) {
1781
+ formRef.current.setFieldError(b.data.value, t(tKey));
1782
+ }
1783
+ else {
1784
+ formRef.current.clearFieldError(b.data.value);
1785
+ }
1786
+ validatingPhoneRef.current = false;
1787
+ })
1788
+ .catch((e) => {
1789
+ console.error(e);
1790
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
1791
+ validatingPhoneRef.current = false;
1792
+ });
1793
+ }
1794
+ }, 200);
1795
+ }, b) });
1796
+ }
1797
+ else if (b.name === 'DateBlock') {
1798
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
1799
+ if (value && isNaN(Date.parse(value))) {
1800
+ return t('validator.date');
1801
+ }
1802
+ }, b) });
1803
+ }
1804
+ else if (b.name === 'TncBlock') {
1805
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id, (value) => {
1806
+ if (isRequired && !value) {
1807
+ return t('validator.required');
1808
+ }
1809
+ }, b) });
1810
+ }
1811
+ else {
1812
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, undefined, b) });
1813
+ }
1814
+ }, {});
1815
+ }, [listBlockAdded.map((b) => b.name).join(',')]);
1816
+ const form = useLeadForm({
1817
+ validateInputOnChange: true,
1818
+ clearInputErrorOnChange: true,
1819
+ validate: validateObj,
1820
+ initialValues,
1821
+ });
1822
+ const formRef = useRef(form);
1823
+ formRef.current = form;
1824
+ return { form, validateObj };
3348
1825
  };
3349
1826
 
3350
1827
  const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
@@ -3517,14 +1994,6 @@ const StyledTextFieldContainer = styled.div `
3517
1994
  }
3518
1995
  }
3519
1996
 
3520
- &:focus-within {
3521
- .mantine-Input-wrapper {
3522
- transition: 0.25s linear border;
3523
- border-color: ${theme.colors.primary600};
3524
- box-shadow: 0 0 4px ${theme.colors.primary200};
3525
- }
3526
- }
3527
-
3528
1997
  .PhoneInput {
3529
1998
  --phone-select: 75px;
3530
1999
  --phone-input-space-x: 8px;
@@ -3673,13 +2142,11 @@ const TextField = (props) => {
3673
2142
  const $focusEl = $textEl.item($textEl.length - 1);
3674
2143
  if ($focusEl) {
3675
2144
  $focusEl.focus();
3676
- setTimeout(() => {
3677
- $focusEl.scrollIntoView({
3678
- behavior: 'auto',
3679
- block: 'center',
3680
- inline: 'start',
3681
- });
3682
- }, 100);
2145
+ $focusEl.scrollIntoView({
2146
+ behavior: 'auto',
2147
+ block: 'center',
2148
+ inline: 'start',
2149
+ });
3683
2150
  }
3684
2151
  }, [shrink]);
3685
2152
  useEffect(() => {
@@ -3696,14 +2163,8 @@ const ChoiceField = (props) => {
3696
2163
  const TitleBlock = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
3697
2164
 
3698
2165
  const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
3699
- const { t } = useTranslations();
3700
2166
  const form = useLeadFormContext();
3701
2167
  const formValues = form.values;
3702
- const labelTuples = useMemo(() => {
3703
- return ((ISO_FORMAT === null || ISO_FORMAT === void 0 ? void 0 : ISO_FORMAT[locale]) || ISO_FORMAT['vi-VN']).dateFormat
3704
- .split('/')
3705
- .map((key) => { var _a; return t((_a = COMMON_DATE_TRANSLATE_KEY === null || COMMON_DATE_TRANSLATE_KEY === void 0 ? void 0 : COMMON_DATE_TRANSLATE_KEY[key]) === null || _a === void 0 ? void 0 : _a.id); });
3706
- }, [locale]);
3707
2168
  return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
3708
2169
  var _a;
3709
2170
  const { name = '', data = {}, id } = b || {};
@@ -3753,15 +2214,17 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3753
2214
  return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
3754
2215
  React__default.createElement(GoogleLocationBlock, Object.assign({ withAsterisk: required, name: value, placeholder: placeholder, label: placeholder, "data-control": "text", locale: locale, inputWrapperOrder: ['label', 'input', 'description', 'error'] }, form.getInputProps(value)))));
3755
2216
  }
3756
- case 'DateBlock': {
3757
- const _c = form.getInputProps(value), { error } = _c, formInputProps = __rest(_c, ["error"]);
3758
- return (React__default.createElement(Input$1.Wrapper, { key: index, size: "md", withAsterisk: required, label: placeholder, "data-invalid": !!error, inputWrapperOrder: ['label', 'input', 'description', 'error'], error: error, className: "lead-modal__form-control leadgen-form_field" },
3759
- React__default.createElement(InputDate, Object.assign({ name: value, error: Boolean(error), locale: locale, "data-extra": true, "data-name": value, "data-control": "date", className: "leadgen-form_field_date", labelTuples: labelTuples }, formInputProps))));
3760
- }
2217
+ case 'DateBlock':
2218
+ return (React__default.createElement(TextField, { key: index, shrink: !!formValue, className: "lead-modal__form-control leadgen-form_field" },
2219
+ React__default.createElement(DatePicker, Object.assign({ clearable: true, withAsterisk: required, type: "default", name: value, placeholder: placeholder, label: placeholder, inputWrapperOrder: ['label', 'input', 'description', 'error'], inputContainer: (children) => {
2220
+ return (React__default.createElement(React__default.Fragment, null,
2221
+ children,
2222
+ React__default.createElement("input", { type: "hidden", "data-control": "date", name: value, value: formValue })));
2223
+ } }, form.getInputProps(value)))));
3761
2224
  case 'LinkButtonBlock':
3762
2225
  return (React__default.createElement("div", { key: index },
3763
2226
  React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
3764
- React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
2227
+ React__default.createElement(Button$2, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
3765
2228
  onClose === null || onClose === void 0 ? void 0 : onClose();
3766
2229
  onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
3767
2230
  } }, value))));
@@ -3800,7 +2263,7 @@ const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmi
3800
2263
  label: l.placeholder,
3801
2264
  })) }, form.getInputProps(value)))));
3802
2265
  case 'TncBlock':
3803
- const _d = form.getInputProps(`TNC-${id}`), { error } = _d, tncInputProps = __rest(_d, ["error"]);
2266
+ const _c = form.getInputProps(`TNC-${id}`), { error } = _c, tncInputProps = __rest(_c, ["error"]);
3804
2267
  return (React__default.createElement(ChoiceField, { className: "leadgen-form_checkbox", key: id },
3805
2268
  React__default.createElement(Input$1.Wrapper, { error: error },
3806
2269
  React__default.createElement(Checkbox, Object.assign({ name: 'TNC-' + id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps)))));
@@ -3910,6 +2373,7 @@ const HeaderImage = ({ src, ratio = 3 / 2, className, style, }) => {
3910
2373
  };
3911
2374
 
3912
2375
  const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
2376
+ const { primaryColor } = useContext(LeadGenContext);
3913
2377
  const { t } = useTranslations();
3914
2378
  const phone = otpData.phone;
3915
2379
  const otpType = otpData.type;
@@ -3995,370 +2459,709 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
3995
2459
  // type: 'danger',
3996
2460
  // })
3997
2461
  }
3998
- setIsSubmitLoading(false);
3999
- });
4000
- useEffect(() => {
4001
- setTimeout(() => {
4002
- if (resendTimer > 0) {
4003
- setResendTimer((r) => r - 1);
4004
- }
4005
- }, 1000);
4006
- }, [resendTimer]);
4007
- useEffect(() => {
4008
- if (autoSendWhenOpen && !resendTimer) {
4009
- sendOtp();
2462
+ setIsSubmitLoading(false);
2463
+ });
2464
+ useEffect(() => {
2465
+ setTimeout(() => {
2466
+ if (resendTimer > 0) {
2467
+ setResendTimer((r) => r - 1);
2468
+ }
2469
+ }, 1000);
2470
+ }, [resendTimer]);
2471
+ useEffect(() => {
2472
+ if (autoSendWhenOpen && !resendTimer) {
2473
+ sendOtp();
2474
+ }
2475
+ }, []);
2476
+ return (React__default.createElement("form", { onSubmit: (e) => {
2477
+ e.preventDefault();
2478
+ submitOtp();
2479
+ }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
2480
+ React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
2481
+ phone: `<strong>${displayPhone}</strong>`,
2482
+ }), footer: React__default.createElement(React__default.Fragment, null,
2483
+ React__default.createElement(Button$1, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
2484
+ React__default.createElement(Button$1, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, color: primaryColor, onClick: () => {
2485
+ sendOtp();
2486
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
2487
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
2488
+ }))) },
2489
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2490
+ React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
2491
+ React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
2492
+ setIsDirty(true);
2493
+ setOtp(v.toString());
2494
+ if (isDirty && !v)
2495
+ setErrorMsg('OTP is required');
2496
+ else
2497
+ setErrorMsg(undefined);
2498
+ } }))))));
2499
+ };
2500
+
2501
+ // url: imageBlocks.imageMobile.data.url
2502
+ // newTab: imageBlocks.imageMobile.data.newtab
2503
+ // image: campaignShow.image
2504
+ // imageDestkop: campaignShow.image_desktop
2505
+ const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
2506
+ LEADGEN_LAYOUT.Fullscreen,
2507
+ LEADGEN_LAYOUT.Slider,
2508
+ ];
2509
+ const LEADGEN_LIMIT_LIGHTBOXB = 6;
2510
+ const LEADGEN_SHOW_HEADER = [
2511
+ 'LightBoxA',
2512
+ 'InlineA',
2513
+ LEADGEN_LAYOUT.Sidebar,
2514
+ LEADGEN_LAYOUT.Slider,
2515
+ ];
2516
+ const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
2517
+ var _a;
2518
+ const { primaryColor } = useContext(LeadGenContext);
2519
+ const { isMobile } = useScreenSize();
2520
+ const [open, setOpen] = useState(!!campaignId);
2521
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
2522
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
2523
+ const [snap, setSnap] = useState(0.8);
2524
+ const formRef = useRef();
2525
+ const onClose = () => {
2526
+ if (showOtpPhone) {
2527
+ setShowOtpPhone(null);
2528
+ }
2529
+ else {
2530
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2531
+ }
2532
+ };
2533
+ const textBlocks = JSON.parse(extraFields.textBlocks);
2534
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
2535
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
2536
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
2537
+ const currentPath = location.pathname;
2538
+ const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
2539
+ const { align: titleAlign } = textBlocks.titleBlock.data || {};
2540
+ const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
2541
+ const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
2542
+ const isLightBox = currentLayout.includes('LightBox');
2543
+ const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
2544
+ const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
2545
+ const isInline = currentLayout.includes('Inline');
2546
+ const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
2547
+ const isInPage = isInline || isSidebar;
2548
+ const isDrawer = isLightBoxB && isMobile;
2549
+ const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
2550
+ const hasForm = isLightBoxA
2551
+ ? listBlockAdded.some((item) => LEADGEN_BLOCK_IN_FORM.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
2552
+ : true;
2553
+ const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
2554
+ const showHeader = !!imageMobile || !!imageDesktop;
2555
+ const onlyHeader = !title && !description;
2556
+ const showButtonClose = !isInline;
2557
+ if (window.innerWidth < 769 &&
2558
+ LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
2559
+ console.log('😎 Not show fullscreen, slider on mobile ');
2560
+ return null;
2561
+ }
2562
+ useEffect(() => {
2563
+ if (isLightBox || isFullscreen) {
2564
+ document.body.classList.add('noscroll');
2565
+ }
2566
+ if (!window.intlTelInputUtils) {
2567
+ require('intl-tel-input/build/js/utils');
2568
+ }
2569
+ clearCacheUsedEmailOrPhone();
2570
+ }, []);
2571
+ const validatingPhoneRef = useRef(false);
2572
+ const validatingEmailRef = useRef(false);
2573
+ const { form, validateObj } = useLeadFormConfig({
2574
+ listBlockAdded,
2575
+ validatingPhoneRef,
2576
+ validatingEmailRef,
2577
+ campaignId,
2578
+ campaign_subot_id,
2579
+ userInfo,
2580
+ });
2581
+ const middlewareOnSubmit = (e) => {
2582
+ e.preventDefault();
2583
+ // mark all as touched to allow validation
2584
+ form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
2585
+ acc[cur] = true;
2586
+ return acc;
2587
+ }, {}));
2588
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
2589
+ return;
2590
+ }
2591
+ setTimeout(() => {
2592
+ form.onSubmit((v) => {
2593
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
2594
+ if (Object.keys(form.errors).length)
2595
+ return;
2596
+ let newShowOtpPhone = null;
2597
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
2598
+ // not submit yet, open otp
2599
+ const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
2600
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
2601
+ newShowOtpPhone = {
2602
+ phone: v[fieldName],
2603
+ type: 'phone',
2604
+ };
2605
+ }
2606
+ }
2607
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
2608
+ // not submit yet, open otp
2609
+ const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
2610
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
2611
+ newShowOtpPhone = {
2612
+ phone: v[fieldName],
2613
+ type: 'whatsapp',
2614
+ };
2615
+ }
2616
+ }
2617
+ if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
2618
+ // not submit yet, open otp
2619
+ const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
2620
+ if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
2621
+ newShowOtpPhone = {
2622
+ phone: v[fieldName],
2623
+ type: 'zalo',
2624
+ };
2625
+ }
2626
+ }
2627
+ if (newShowOtpPhone) {
2628
+ setIsSubmitLoading(true);
2629
+ Service.sendSMSOtpLead(newShowOtpPhone)
2630
+ .then((res) => {
2631
+ var _a;
2632
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
2633
+ if (respMessage === 'This phone number was verified') {
2634
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2635
+ return;
2636
+ }
2637
+ setShowOtpPhone(newShowOtpPhone);
2638
+ })
2639
+ .finally(() => {
2640
+ setIsSubmitLoading(false);
2641
+ });
2642
+ return;
2643
+ }
2644
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
2645
+ })(e);
2646
+ }, 100);
2647
+ };
2648
+ const onOpenChange = (_open) => {
2649
+ setOpen(_open);
2650
+ if (!_open) {
2651
+ setTimeout(() => {
2652
+ onClose();
2653
+ }, 250);
2654
+ }
2655
+ };
2656
+ const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
2657
+ const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
2658
+ const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
2659
+ const renderAfterImageSizes = imageMobileLoaded &&
2660
+ imageDesktopLoaded &&
2661
+ (isFullscreen ? imageBackgroundLoaded : true);
2662
+ const ButtonSubmit = !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$1, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, loading: isSubmitLoading }, popUpSubmitText));
2663
+ const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
2664
+ const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
2665
+ var _a, _b, _c;
2666
+ return (React__default.createElement(Button$1, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", color: primaryColor, onClick: () => {
2667
+ onClose === null || onClose === void 0 ? void 0 : onClose();
2668
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
2669
+ } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
2670
+ })));
2671
+ const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
2672
+ React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
2673
+ React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
2674
+ const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
2675
+ const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
2676
+ React__default.createElement("form", { ref: formRef, className: "leadgen-form", onSubmit: middlewareOnSubmit },
2677
+ React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
2678
+ React__default.createElement("div", { className: "leadgen-form_inner" },
2679
+ React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
2680
+ const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
2681
+ setShowOtpPhone(null);
2682
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
2683
+ } }));
2684
+ const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
2685
+ const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
2686
+ 'leadgen-content_small': limitFieldsLightBoxB,
2687
+ }) },
2688
+ !headerInsideFormContainer && PopupHeader,
2689
+ !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
2690
+ PopupThankYou,
2691
+ !showThankyou && (React__default.createElement(React__default.Fragment, null,
2692
+ PopupOtp,
2693
+ PopupEmpty,
2694
+ !(showOtpPhone || showEmpty) && PopupForm))))));
2695
+ const styleOverlay = useMemo(() => {
2696
+ let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
2697
+ if (isMobile && imageOverlayMobile) {
2698
+ styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
2699
+ }
2700
+ if (!isMobile && imageOverlayDesktop) {
2701
+ styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
4010
2702
  }
4011
- }, []);
4012
- return (React__default.createElement("form", { onSubmit: (e) => {
4013
- e.preventDefault();
4014
- submitOtp();
4015
- }, className: "lead-phone-otp-form leadgen-form leadgen-form_otp" },
4016
- React__default.createElement(FormContainer, { title: t('lead.otp.title'), description: t('lead.otp.desc', {
4017
- phone: `<strong>${displayPhone}</strong>`,
4018
- }), footer: React__default.createElement(React__default.Fragment, null,
4019
- React__default.createElement(Button$2, { type: "submit", size: "lg", variant: "filled", className: `lead-modal__btn leadgen-btn_action ${LEAD_CLASS}`, disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
4020
- React__default.createElement(Button$2, { type: "button", size: "lg", variant: "light", className: `lead-modal__btn lead-phone-otp-button leadgen-btn_action ${LEAD_CLASS}`, onClick: () => {
4021
- sendOtp();
4022
- }, disabled: !!resendTimer }, t('lead.otp.resend', {
4023
- timer: resendTimer ? ` (${resendTimer}s)` : '',
4024
- }))) },
4025
- React__default.createElement("div", { className: "leadgen-form_inner" },
4026
- React__default.createElement(Input.Wrapper, { error: isDirty ? errorMsg : undefined, className: "leadgen-form_field" },
4027
- React__default.createElement(OTP, { ref: inputRef, name: '_' + name + '-otp', value: otp, onChange: (v) => {
4028
- setIsDirty(true);
4029
- setOtp(v.toString());
4030
- if (isDirty && !v)
4031
- setErrorMsg('OTP is required');
4032
- else
4033
- setErrorMsg(undefined);
4034
- } }))))));
2703
+ return styleContent;
2704
+ }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
2705
+ const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
2706
+ React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
2707
+ React__default.createElement("div", { className: clsx('leadgen-wrapper', {
2708
+ 'leadgen-wrapper_small': limitFieldsLightBoxB,
2709
+ }) },
2710
+ showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
2711
+ PopupContent)));
2712
+ const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
2713
+ 'leadgen-lightbox': isLightBox,
2714
+ 'leadgen-inline': isInPage,
2715
+ 'leadgen-slider': isSlider,
2716
+ });
2717
+ const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
2718
+ PopupWrapper,
2719
+ React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
2720
+ isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
2721
+ aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
2722
+ } })) : null,
2723
+ PopupWrapper));
2724
+ if (!renderAfterImageSizes)
2725
+ return null;
2726
+ if (isLightBox || isFullscreen || isSlider) {
2727
+ return PopupContainer;
2728
+ }
2729
+ else if (isSidebar) {
2730
+ return React__default.createElement(SideBarLayout, { content: PopupContainer });
2731
+ }
2732
+ else if (isInline) {
2733
+ return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
2734
+ }
2735
+ return null;
2736
+ };
2737
+
2738
+ const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
2739
+ const currentPath = location.pathname;
2740
+ const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
2741
+ const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
2742
+ if (!imageMobileLoaded || !imageDesktopLoaded)
2743
+ return null;
2744
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
2745
+ currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2746
+ React__default.createElement("div", { className: "le-skin-a-desktop" },
2747
+ React__default.createElement("div", { style: { position: 'relative' } },
2748
+ React__default.createElement("img", { src: imageDesktop, style: {
2749
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2750
+ } }),
2751
+ React__default.createElement("a", { style: {
2752
+ position: 'absolute',
2753
+ top: '75%',
2754
+ left: '50%',
2755
+ transform: 'translate(-50%, -50%)',
2756
+ textAlign: 'center',
2757
+ width: 'calc(100% - 15px)',
2758
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2759
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
2760
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
2761
+ React__default.createElement("div", { className: "" },
2762
+ React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
2763
+ React__default.createElement("img", { src: imageDesktop, style: {
2764
+ width: '100%',
2765
+ aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
2766
+ } }),
2767
+ React__default.createElement("a", { style: {
2768
+ position: 'absolute',
2769
+ top: '75%',
2770
+ left: '50%',
2771
+ transform: 'translate(-50%, -50%)',
2772
+ textAlign: 'center',
2773
+ width: '100%',
2774
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2775
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2776
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
2777
+ React__default.createElement("aside", { className: "le-only-mobile" },
2778
+ React__default.createElement("div", { className: "le-skin-mobile" },
2779
+ React__default.createElement("div", { style: { position: 'relative' } },
2780
+ isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
2781
+ React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
2782
+ width: '100%',
2783
+ aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
2784
+ } })),
2785
+ React__default.createElement("a", { style: {
2786
+ position: 'absolute',
2787
+ top: '82%',
2788
+ left: '50%',
2789
+ transform: 'translate(-50%, -50%)',
2790
+ textAlign: 'center',
2791
+ maxWidth: 'calc(100% - 15px)',
2792
+ }, href: link, target: linkNewTab ? 'blank' : '_parent' },
2793
+ React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
2794
+ React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4035
2795
  };
4036
2796
 
4037
2797
  // url: imageBlocks.imageMobile.data.url
4038
2798
  // newTab: imageBlocks.imageMobile.data.newtab
4039
2799
  // image: campaignShow.image
4040
2800
  // imageDestkop: campaignShow.image_desktop
4041
- const LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE = [
4042
- LEADGEN_LAYOUT.Fullscreen,
4043
- LEADGEN_LAYOUT.Slider,
4044
- ];
4045
- const LEADGEN_LIMIT_LIGHTBOXB = 6;
4046
- const LEADGEN_SHOW_HEADER = [
4047
- 'LightBoxA',
4048
- 'InlineA',
4049
- LEADGEN_LAYOUT.Sidebar,
4050
- LEADGEN_LAYOUT.Slider,
4051
- ];
4052
- const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, showEmpty, setShowEmpty, userInfo, }) => {
4053
- var _a, _b;
4054
- const { isMobile } = useScreenSize();
4055
- const [open, setOpen] = useState(!!campaignId);
4056
- const [showOtpPhone, setShowOtpPhone] = useState(null);
4057
- const [isSubmitLoading, setIsSubmitLoading] = useState(false);
4058
- const [snap, setSnap] = useState(0.8);
4059
- const formRef = useRef();
4060
- const onClose = () => {
4061
- if (showOtpPhone) {
4062
- setShowOtpPhone(null);
2801
+ const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
2802
+ const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
2803
+ if (!imageLoaded)
2804
+ return null;
2805
+ return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
2806
+ React__default.createElement("div", { className: "le-tab-popup" },
2807
+ React__default.createElement("div", { style: { position: 'relative' } },
2808
+ React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
2809
+ React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
2810
+ aspectRatio: `${imageWidth}/${imageHeight}`,
2811
+ } })),
2812
+ React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
2813
+ };
2814
+
2815
+ // import mockLeadData from './mockLeadData'
2816
+ const listCampaignScheduled = [];
2817
+ const listCampaignScheduledToActivated = [];
2818
+ const listCampaignActiveButExpired = [];
2819
+ const listCampaignExcludeSonsored = [];
2820
+ const listCampaignDifferentSponsor = [];
2821
+ const listCampaignNotDisplayInRangeOfTime = [];
2822
+ function isMobile() {
2823
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
2824
+ }
2825
+ const getShuffleArray = (array) => {
2826
+ const newArray = [...array];
2827
+ for (let i = newArray.length - 1; i > 0; i--) {
2828
+ const j = Math.floor(Math.random() * (i + 1));
2829
+ const temp = newArray[i];
2830
+ newArray[i] = newArray[j];
2831
+ newArray[j] = temp;
2832
+ }
2833
+ return newArray;
2834
+ };
2835
+ const getTimeByTimezone = (timeZone = 'UTC') => {
2836
+ const date = new Date();
2837
+ return new Date(date.toLocaleString('en-US', { timeZone }));
2838
+ };
2839
+ const parseDateByCampaignTime = (dateStr) => {
2840
+ // Format like this: 2023-04-04 00:00:00
2841
+ try {
2842
+ const [datePart, timePart] = dateStr.split(' ');
2843
+ const [year, month, day] = datePart.split('-').map(Number);
2844
+ const [hours, minutes, seconds] = timePart.split(':').map(Number);
2845
+ /** JavaScript counts months from 0 to 11 */
2846
+ return new Date(year, month - 1, day, hours, minutes, seconds);
2847
+ }
2848
+ catch (err) {
2849
+ return null;
2850
+ }
2851
+ };
2852
+ const checkCampaignNowInTimeframe = (c) => {
2853
+ var _a;
2854
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2855
+ const startedAtStr = c.started_at;
2856
+ const endedAtStr = c.ended_at;
2857
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2858
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2859
+ if (!startedDate || !endedDate) {
2860
+ return false;
2861
+ }
2862
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2863
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2864
+ if (nowWithTimezoneMs <= endedDate.getTime() &&
2865
+ nowWithTimezoneMs >= startedDate.getTime()) {
2866
+ listCampaignScheduledToActivated.push(c);
2867
+ return true;
2868
+ }
2869
+ return false;
2870
+ };
2871
+ function checkCampaignActiveButExpireAlready(c) {
2872
+ var _a;
2873
+ /** Do not setup timeframe for this campaign. No need to check */
2874
+ if (c.forever === 1) {
2875
+ return true;
2876
+ }
2877
+ const startedAtStr = c.started_at;
2878
+ const endedAtStr = c.ended_at;
2879
+ const startedDate = parseDateByCampaignTime(startedAtStr);
2880
+ const endedDate = parseDateByCampaignTime(endedAtStr);
2881
+ /** Do not setup timeframe for this campaign. No need to check */
2882
+ if (!startedDate || !endedDate) {
2883
+ return true;
2884
+ }
2885
+ const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
2886
+ const timeZone = LEAD_TIMEZONE_DATA[siteId];
2887
+ const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
2888
+ /** Check if this expire already, do not show */
2889
+ if (nowWithTimezoneMs > endedDate.getTime()) {
2890
+ listCampaignActiveButExpired.push(c);
2891
+ return false;
2892
+ }
2893
+ return true;
2894
+ }
2895
+ function shouldNotDisplayIfExcludeAllSponsors(c) {
2896
+ var _a;
2897
+ const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
2898
+ const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
2899
+ if (isSponsored && excludeSponsored) {
2900
+ listCampaignExcludeSonsored.push(c);
2901
+ return true;
2902
+ }
2903
+ return false;
2904
+ }
2905
+ function shouldDisplayWithCurrentSponsor(c) {
2906
+ var _a, _b;
2907
+ try {
2908
+ // TODO: BE will rename `exclude_sponsored_list` later
2909
+ const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
2910
+ const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
2911
+ const dataSponsoredId = Number((_b = document
2912
+ .querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
2913
+ // There is no config for sponsor id and white list, should show as default
2914
+ if (!dataSponsoredId ||
2915
+ dataSponsoredId <= 0 ||
2916
+ whiteListSponsors.length === 0) {
2917
+ return true;
4063
2918
  }
4064
- else {
4065
- onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
2919
+ // Check the dataSponsoredId exists in the white list or not.
2920
+ const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
2921
+ if (isExist) {
2922
+ return true;
4066
2923
  }
4067
- };
4068
- const textBlocks = JSON.parse(extraFields.textBlocks);
4069
- const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
4070
- const actionBlocks = JSON.parse(extraFields.actionBlocks);
4071
- const popUpSubmitText = actionBlocks.submitBlock.data.value;
4072
- const currentPath = location.pathname;
4073
- const { align: descriptionAlign, value: description } = textBlocks.subtitleBlock.data || {};
4074
- const { align: titleAlign } = textBlocks.titleBlock.data || {};
4075
- const isSlider = currentLayout === LEADGEN_LAYOUT.Slider;
4076
- const isSidebar = currentLayout === LEADGEN_LAYOUT.Sidebar;
4077
- const isLightBox = currentLayout.includes('LightBox');
4078
- const isLightBoxA = currentLayout === LEADGEN_LAYOUT.LightBoxA;
4079
- const isLightBoxB = currentLayout === LEADGEN_LAYOUT.LightBoxB;
4080
- const isInline = currentLayout.includes('Inline');
4081
- const isFullscreen = currentLayout === LEADGEN_LAYOUT.Fullscreen;
4082
- const isInPage = isInline || isSidebar;
4083
- const isDrawer = isLightBoxB && isMobile;
4084
- const limitFieldsLightBoxB = isLightBoxB && listBlockAdded.length <= LEADGEN_LIMIT_LIGHTBOXB;
4085
- const hasForm = isLightBoxA
4086
- ? listBlockAdded.some((item) => LEADGEN_BLOCK_INPUT.some((k) => k === (item === null || item === void 0 ? void 0 : item.name)))
4087
- : true;
4088
- const headerInsideFormContainer = isSlider || isLightBoxA || isFullscreen;
4089
- const showHeader = !!imageMobile || !!imageDesktop;
4090
- const onlyHeader = !title && !description;
4091
- const showButtonClose = !isInline;
4092
- if (window.innerWidth < 769 &&
4093
- LEADGEN_LAYOUT_NOT_SHOW_IN_MOBILE.includes(currentLayout)) {
4094
- console.log('😎 Not show fullscreen, slider on mobile ');
4095
- return null;
2924
+ listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
2925
+ return false;
4096
2926
  }
4097
- useEffect(() => {
4098
- if (isLightBox || isFullscreen) {
4099
- document.body.classList.add('noscroll');
4100
- }
4101
- if (!window.intlTelInputUtils) {
4102
- require('intl-tel-input/build/js/utils');
2927
+ catch (err) {
2928
+ // Default is show
2929
+ return true;
2930
+ }
2931
+ }
2932
+ const filterFnCampaign = (c) => {
2933
+ if (shouldNotDisplayIfExcludeAllSponsors(c)) {
2934
+ return false;
2935
+ }
2936
+ else if (!shouldDisplayWithCurrentSponsor(c)) {
2937
+ return false;
2938
+ }
2939
+ /** Active */
2940
+ if (c.formatted_status === 1) {
2941
+ return checkCampaignActiveButExpireAlready(c);
2942
+ }
2943
+ /** Schedule */
2944
+ if (c.formatted_status === 0) {
2945
+ listCampaignScheduled.push(c);
2946
+ return checkCampaignNowInTimeframe(c);
2947
+ }
2948
+ return false;
2949
+ };
2950
+ const fillterApprearanceTimeCampaign = (c) => {
2951
+ var _a;
2952
+ try {
2953
+ const isTimeInRange = (currentTime, startTime, endTime) => {
2954
+ const startParts = startTime.split(':');
2955
+ const endParts = endTime.split(':');
2956
+ const startDate = new Date();
2957
+ startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
2958
+ const endDate = new Date();
2959
+ endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
2960
+ return currentTime >= startDate && currentTime <= endDate;
2961
+ };
2962
+ const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
2963
+ const startTime = rulesApprValue.startTime;
2964
+ const endTime = rulesApprValue.endTime || '23:59';
2965
+ if (!startTime) {
2966
+ return true;
4103
2967
  }
4104
- clearCacheUsedEmailOrPhone();
4105
- }, []);
4106
- const validatingPhoneRef = useRef(false);
4107
- const validatingEmailRef = useRef(false);
4108
- const { form, validateObj } = useLeadFormConfig({
4109
- listBlockAdded,
4110
- validatingPhoneRef,
4111
- validatingEmailRef,
4112
- campaignId,
4113
- campaign_subot_id,
4114
- userInfo,
4115
- format: (_a = (ISO_FORMAT[locale] || ISO_FORMAT['vi-VN'])) === null || _a === void 0 ? void 0 : _a.dateFormat,
4116
- });
4117
- const onFocus = (e) => {
4118
- const target = e.target;
4119
- target.scrollIntoView({
4120
- block: 'center',
4121
- inline: 'nearest',
4122
- behavior: 'auto',
4123
- });
4124
- };
4125
- const middlewareOnSubmit = (e) => {
4126
- e.preventDefault();
4127
- // mark all as touched to allow validation
4128
- const fields = Object.keys(validateObj);
4129
- const fieldStatus = fields.reduce((acc, cur) => {
4130
- acc[cur] = true;
4131
- return acc;
4132
- }, {});
4133
- form.setTouched(fieldStatus);
4134
- if (validatingEmailRef.current || validatingPhoneRef.current) {
4135
- return;
2968
+ if (isTimeInRange(new Date(), startTime, endTime)) {
2969
+ return true;
4136
2970
  }
4137
- setTimeout(() => {
4138
- form.onSubmit((v) => {
4139
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
4140
- if (Object.keys(form.errors).length)
4141
- return;
4142
- let newShowOtpPhone = null;
4143
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock) > -1) {
4144
- // not submit yet, open otp
4145
- const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.PhoneOtpBlock)) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
4146
- if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
4147
- newShowOtpPhone = {
4148
- phone: v[fieldName],
4149
- type: 'phone',
4150
- };
2971
+ listCampaignNotDisplayInRangeOfTime.push(c);
2972
+ return false;
2973
+ }
2974
+ catch (err) {
2975
+ return true;
2976
+ }
2977
+ };
2978
+ let timeoutRef = null;
2979
+ let LEAD_SCROLL_EVENT = null;
2980
+ function clearPassiveEvent() {
2981
+ if (timeoutRef) {
2982
+ clearTimeout(timeoutRef);
2983
+ timeoutRef = null;
2984
+ }
2985
+ if (LEAD_SCROLL_EVENT) {
2986
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
2987
+ LEAD_SCROLL_EVENT = null;
2988
+ }
2989
+ }
2990
+ function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
2991
+ // clear previous passive event, check for new condition
2992
+ clearPassiveEvent();
2993
+ const leadCurrentUrl = DEBUG_URL ||
2994
+ ('https://' +
2995
+ location.hostname +
2996
+ location.pathname +
2997
+ location.search).toLowerCase();
2998
+ fetch(leadApi + 'api/campaign/' + leadSiteId, {
2999
+ method: 'POST',
3000
+ headers: {
3001
+ 'Content-Type': 'application/json',
3002
+ },
3003
+ body: JSON.stringify({
3004
+ url: leadCurrentUrl,
3005
+ ga_client_id: getCookie('_ga') || null,
3006
+ }),
3007
+ })
3008
+ .then((response) => {
3009
+ return response.json();
3010
+ // return mockLeadData || response.json()
3011
+ })
3012
+ .then((data) => {
3013
+ var _a, _b, _c, _d;
3014
+ LeadLog('List campagin: ', data);
3015
+ LEAD_RESET_VAR();
3016
+ if (data._status == 1) {
3017
+ const campaigns = (((_b = (_a = data._data) === null || _a === void 0 ? void 0 : _a.campaigns) === null || _b === void 0 ? void 0 : _b.filter(filterFnCampaign)) || []).filter(fillterApprearanceTimeCampaign);
3018
+ if (!getCookie('hhg-id')) {
3019
+ setCookie('hhg-id', v1(), {
3020
+ domain: '.' + leadDomain,
3021
+ path: '/',
3022
+ });
3023
+ LeadLog('😍 Set HHG ID cookie');
3024
+ }
3025
+ // getCookie('hhg-id')
3026
+ // TODO: HP-534 Filter desktop
3027
+ let campaignsDevice = [];
3028
+ if (isMobile()) {
3029
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
3030
+ }
3031
+ else {
3032
+ campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
3033
+ }
3034
+ LeadLog(`👓 campaignsDevice`, campaignsDevice);
3035
+ LeadLog('--listCampaignScheduled', listCampaignScheduled);
3036
+ LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
3037
+ LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
3038
+ LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
3039
+ LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
3040
+ LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
3041
+ // Check links
3042
+ let listLinksObj = campaignsDevice
3043
+ .map((i, index) => i.targets
3044
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
3045
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3046
+ .flat(1);
3047
+ // Check list link match current href
3048
+ listLinksObj = listLinksObj.filter((i) => {
3049
+ var _a;
3050
+ const target = new URL(String(i.target).toLowerCase());
3051
+ if (i.option == 'exact_match')
3052
+ // FOR TEST LOCAL:
3053
+ // return Boolean(location.pathname === target.pathname)
3054
+ return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
3055
+ if (i.option == 'start_with') {
3056
+ // FOR TEST LOCAL:
3057
+ // if (location.pathname.includes(target.pathname)) {
3058
+ if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
3059
+ const listExcluding = i.sub_target
3060
+ .filter((i) => i.option == 'excluding')
3061
+ .map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
3062
+ return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
4151
3063
  }
4152
- }
4153
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock) > -1) {
4154
- // not submit yet, open otp
4155
- const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.WhatsappOtpBlock)) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
4156
- if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
4157
- newShowOtpPhone = {
4158
- phone: v[fieldName],
4159
- type: 'whatsapp',
4160
- };
3064
+ else {
3065
+ return false;
4161
3066
  }
4162
3067
  }
4163
- if (listBlockAdded.findIndex((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock) > -1) {
4164
- // not submit yet, open otp
4165
- const fieldName = (_h = (_g = listBlockAdded.find((x) => x.name === LEADGEN_BLOCK.ZaloOtpBlock)) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.value;
4166
- if ((_j = v[fieldName]) === null || _j === void 0 ? void 0 : _j.startsWith('+')) {
4167
- newShowOtpPhone = {
4168
- phone: v[fieldName],
4169
- type: 'zalo',
4170
- };
4171
- }
3068
+ });
3069
+ // Check tags
3070
+ const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
3071
+ const listTags = listMetaTag.map((i) => i.content);
3072
+ let listCampaignHasTag = [];
3073
+ let listTagsObj = [];
3074
+ if (listTags && listTags.length) {
3075
+ listCampaignHasTag = campaignsDevice
3076
+ .map((i, index) => i.targets
3077
+ .filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
3078
+ .map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
3079
+ .flat(1);
3080
+ listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
3081
+ }
3082
+ const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
3083
+ const cookieKeys = document.cookie
3084
+ .split('; ')
3085
+ .map((i) => i.split('=')[0]);
3086
+ const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
3087
+ LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
3088
+ const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
3089
+ LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
3090
+ const listCampaignSubmitedClosed = [
3091
+ ...listCampaignCodeSubmited,
3092
+ ...listCampaignCodeClosed,
3093
+ ];
3094
+ const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
3095
+ const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
3096
+ return !hasSubmited;
3097
+ });
3098
+ const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
3099
+ // .sort(
3100
+ // (a, b) =>
3101
+ // (listCampaignValid[a.campaignIndex]?.score || 0) -
3102
+ // (listCampaignValid[b.campaignIndex]?.score || 0),
3103
+ // )
3104
+ LeadLog('--listCampaignValid : ', listCampaignValid);
3105
+ if (listCampaignValid && listCampaignValid.length) {
3106
+ const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
3107
+ LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
3108
+ const { rules } = CAMPAIGN_SHOW;
3109
+ // CHECK RULE TRIGGER POPUP
3110
+ const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
3111
+ LeadLog(`timeoutRule`, timeoutRule);
3112
+ const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
3113
+ LeadLog(`scrollRule`, scrollRule);
3114
+ let impressionAction = 'TIME';
3115
+ if (Number.isInteger(timeoutRule)) {
3116
+ impressionAction = 'TIME';
3117
+ LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
3118
+ timeoutRef = setTimeout(() => {
3119
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3120
+ }, timeoutRule * 1000);
4172
3121
  }
4173
- if (newShowOtpPhone) {
4174
- setIsSubmitLoading(true);
4175
- Service.sendSMSOtpLead(newShowOtpPhone)
4176
- .then((res) => {
4177
- var _a;
4178
- const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
4179
- if (respMessage === 'This phone number was verified') {
4180
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4181
- return;
3122
+ if (Number.isInteger(scrollRule)) {
3123
+ impressionAction = 'SCROLL';
3124
+ LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
3125
+ const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
3126
+ document.querySelector('body');
3127
+ const pct = $p.getBoundingClientRect().top;
3128
+ const pb = $p.offsetHeight;
3129
+ LeadLog(`👓 Element check scroll: `, $p);
3130
+ LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
3131
+ const wt = window.pageYOffset || document.documentElement.scrollTop;
3132
+ let percent = 0;
3133
+ if (wt >= pct) {
3134
+ percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
4182
3135
  }
4183
- setShowOtpPhone(newShowOtpPhone);
4184
- })
4185
- .finally(() => {
4186
- setIsSubmitLoading(false);
3136
+ LeadLog('---Scroll', percent, scrollRule);
3137
+ // TODO: CHECK FOOTER HEIGHT
3138
+ if (percent >= scrollRule) {
3139
+ window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
3140
+ onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
3141
+ }
3142
+ };
3143
+ window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
3144
+ passive: true,
4187
3145
  });
4188
- return;
4189
3146
  }
4190
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
4191
- })(e);
4192
- }, 100);
4193
- };
4194
- const onOpenChange = (_open) => {
4195
- setOpen(_open);
4196
- if (!_open) {
4197
- setTimeout(() => {
4198
- onClose();
4199
- }, 250);
4200
- }
4201
- };
4202
- const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
4203
- const { loaded: imageMobileLoaded } = useImageSize(imageMobile);
4204
- const { loaded: imageDesktopLoaded } = useImageSize(imageDesktop);
4205
- const renderAfterImageSizes = imageMobileLoaded &&
4206
- imageDesktopLoaded &&
4207
- (isFullscreen ? imageBackgroundLoaded : true);
4208
- const ButtonSubmit = useMemo(() => {
4209
- var _a;
4210
- return !((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) && (React__default.createElement(Button$2, { size: "lg", id: "lead-submit", type: "submit", variant: "filled", className: "leadgen-btn leadgen-btn_action", loading: isSubmitLoading }, popUpSubmitText));
4211
- }, [popUpSubmitText, isSubmitLoading, (_b = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _b === void 0 ? void 0 : _b.isHide]);
4212
- const LinkButtonBlock = listBlockAdded.filter(({ name }) => name == LEADGEN_BLOCK.LinkButtonBlock);
4213
- const ButtonLink = !!(LinkButtonBlock === null || LinkButtonBlock === void 0 ? void 0 : LinkButtonBlock.length) && (React__default.createElement(React__default.Fragment, null, LinkButtonBlock.map((item, index) => {
4214
- var _a, _b, _c;
4215
- return (React__default.createElement(Button$2, { key: `${item.name}-${index}`, component: "a", href: (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a.url, target: ((_b = item === null || item === void 0 ? void 0 : item.data) === null || _b === void 0 ? void 0 : _b.newtab) ? '_blank' : undefined, size: "lg", variant: "filled", className: "leadgen-btn leadgen-btn_action", onClick: () => {
4216
- onClose === null || onClose === void 0 ? void 0 : onClose();
4217
- onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
4218
- } }, (_c = item === null || item === void 0 ? void 0 : item.data) === null || _c === void 0 ? void 0 : _c.value));
4219
- })));
4220
- const PopupHeader = showHeader && (React__default.createElement("header", { className: clsx('leadgen-header', { 'leadgen-header_only': onlyHeader }) }, LEADGEN_SHOW_HEADER.includes(currentLayout) ? (React__default.createElement(HeaderImage, { src: imageMobile, className: "lead-modal__image" })) : (React__default.createElement(React__default.Fragment, null,
4221
- React__default.createElement(HeaderImage, { src: imageDesktop, className: "le-only-desktop lead-modal__image" }),
4222
- React__default.createElement(HeaderImage, { src: imageMobile, className: "le-only-mobile lead-modal__image" })))));
4223
- const PopupEmpty = showEmpty && (React__default.createElement(EmptyComponent, { onClose: onClose, onContinue: () => setShowEmpty(false) }));
4224
- const PopupForm = (React__default.createElement(LeadFormProvider, { form: form },
4225
- React__default.createElement("form", { ref: formRef, className: "leadgen-form", onFocus: onFocus, onSubmit: middlewareOnSubmit },
4226
- React__default.createElement(FormContainer, { title: title, titleAlign: titleAlign, description: description, descriptionAlign: descriptionAlign, header: headerInsideFormContainer && PopupHeader, footer: hasForm ? ButtonSubmit : ButtonLink, "data-hidden-form": !hasForm },
4227
- React__default.createElement("div", { className: "leadgen-form_inner" },
4228
- React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit }))))));
4229
- const PopupOtp = showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
4230
- setShowOtpPhone(null);
4231
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
4232
- } }));
4233
- const PopupThankYou = showThankyou && (React__default.createElement(ThankyouPopup, { title: showThankyou.title, titleAlign: showThankyou.titleAlign, subtitle: showThankyou.subtitle, subtitleAlign: showThankyou.subtitleAlign, link: showThankyou.link, linkNewTab: showThankyou.linkNewTab, linkText: showThankyou.linkText, image: showThankyou.image }));
4234
- const PopupContent = (React__default.createElement("div", { className: clsx('leadgen-content', {
4235
- 'leadgen-content_small': limitFieldsLightBoxB,
4236
- }) },
4237
- !headerInsideFormContainer && PopupHeader,
4238
- !onlyHeader && (React__default.createElement("div", { className: "leadgen-inner" },
4239
- PopupThankYou,
4240
- !showThankyou && (React__default.createElement(React__default.Fragment, null,
4241
- PopupOtp,
4242
- PopupEmpty,
4243
- !(showOtpPhone || showEmpty) && PopupForm))))));
4244
- const styleOverlay = useMemo(() => {
4245
- let styleContent = `.leadgen-inner {background-repeat: no-repeat;background-size: cover;background-position:center;}`;
4246
- if (isMobile && imageOverlayMobile) {
4247
- styleContent += `.leadgen-inner {background-image: url(${imageOverlayMobile});}`;
4248
- }
4249
- if (!isMobile && imageOverlayDesktop) {
4250
- styleContent += `@media screen and (min-width:768px) {.leadgen-inner {background-image: url(${imageOverlayDesktop});}}`;
3147
+ }
3148
+ else {
3149
+ LeadLog('🚧 No lead campaigns on current URL, tags');
3150
+ }
4251
3151
  }
4252
- return styleContent;
4253
- }, [isMobile, imageOverlayDesktop, imageOverlayMobile]);
4254
- const PopupWrapper = (React__default.createElement(React__default.Fragment, null,
4255
- React__default.createElement("style", { dangerouslySetInnerHTML: { __html: styleOverlay } }),
4256
- React__default.createElement("div", { className: clsx('leadgen-wrapper', {
4257
- 'leadgen-wrapper_small': limitFieldsLightBoxB,
4258
- }) },
4259
- showButtonClose && (React__default.createElement(CloseButton, { onClose: () => onOpenChange(false), containerClassName: "leadgen-close_btn" })),
4260
- PopupContent)));
4261
- const popupContainerClassName = clsx('leadgen', `leadgen-${currentLayout}`, {
4262
- 'leadgen-lightbox': isLightBox,
4263
- 'leadgen-inline': isInPage,
4264
- 'leadgen-slider': isSlider,
3152
+ })
3153
+ .catch((err) => {
3154
+ LeadLog(`Lead error: `, err);
4265
3155
  });
4266
- const PopupContainer = isDrawer ? (React__default.createElement(DrawerComponent, { fadeFromIndex: ZINDEX_SSO - 9e6, open: open, snapPoints: [0.8, 1], activeSnapPoint: snap, setActiveSnapPoint: setSnap, onOpenChange: onOpenChange, overlayClassName: popupContainerClassName, className: "leadgen-drawer" },
4267
- PopupWrapper,
4268
- React__default.createElement("div", { style: { position: 'absolute', inset: 0, zIndex: snap === 1 ? -1 : 1 }, onClick: () => setSnap(1) }))) : (React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: popupContainerClassName },
4269
- isFullscreen ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
4270
- aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
4271
- } })) : null,
4272
- PopupWrapper));
4273
- if (!renderAfterImageSizes)
4274
- return null;
4275
- if (isLightBox || isFullscreen || isSlider) {
4276
- return PopupContainer;
4277
- }
4278
- else if (isSidebar) {
4279
- return React__default.createElement(SideBarLayout, { content: PopupContainer });
4280
- }
4281
- else if (isInline) {
4282
- return (React__default.createElement(InlineLayout, { content: PopupContainer, inlinePosition: extraFields.popupInlinePosition }));
3156
+ }
3157
+ const LeadLog = (...params) => {
3158
+ if (process.env.NODE_ENV !== 'production' ||
3159
+ (process.env.NEXT_PUBLIC_DEPLOY_ENV &&
3160
+ process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
3161
+ (typeof localStorage !== 'undefined' &&
3162
+ localStorage.getItem('hhg_debug') === 'true')) {
3163
+ console.log(...params);
4283
3164
  }
4284
- return null;
4285
- };
4286
-
4287
- const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
4288
- const currentPath = location.pathname;
4289
- const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
4290
- const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
4291
- if (!imageMobileLoaded || !imageDesktopLoaded)
4292
- return null;
4293
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
4294
- currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4295
- React__default.createElement("div", { className: "le-skin-a-desktop" },
4296
- React__default.createElement("div", { style: { position: 'relative' } },
4297
- React__default.createElement("img", { src: imageDesktop, style: {
4298
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4299
- } }),
4300
- React__default.createElement("a", { style: {
4301
- position: 'absolute',
4302
- top: '75%',
4303
- left: '50%',
4304
- transform: 'translate(-50%, -50%)',
4305
- textAlign: 'center',
4306
- width: 'calc(100% - 15px)',
4307
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4308
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
4309
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
4310
- React__default.createElement("div", { className: "" },
4311
- React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
4312
- React__default.createElement("img", { src: imageDesktop, style: {
4313
- width: '100%',
4314
- aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
4315
- } }),
4316
- React__default.createElement("a", { style: {
4317
- position: 'absolute',
4318
- top: '75%',
4319
- left: '50%',
4320
- transform: 'translate(-50%, -50%)',
4321
- textAlign: 'center',
4322
- width: '100%',
4323
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4324
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4325
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
4326
- React__default.createElement("aside", { className: "le-only-mobile" },
4327
- React__default.createElement("div", { className: "le-skin-mobile" },
4328
- React__default.createElement("div", { style: { position: 'relative' } },
4329
- isVideo(imageMobile) ? (React__default.createElement("video", { muted: true, autoPlay: true, loop: true },
4330
- React__default.createElement("source", { src: imageMobile, type: "video/mp4" }))) : (React__default.createElement("img", { src: imageMobile, style: {
4331
- width: '100%',
4332
- aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
4333
- } })),
4334
- React__default.createElement("a", { style: {
4335
- position: 'absolute',
4336
- top: '82%',
4337
- left: '50%',
4338
- transform: 'translate(-50%, -50%)',
4339
- textAlign: 'center',
4340
- maxWidth: 'calc(100% - 15px)',
4341
- }, href: link, target: linkNewTab ? 'blank' : '_parent' },
4342
- React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
4343
- React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
4344
- };
4345
-
4346
- // url: imageBlocks.imageMobile.data.url
4347
- // newTab: imageBlocks.imageMobile.data.newtab
4348
- // image: campaignShow.image
4349
- // imageDestkop: campaignShow.image_desktop
4350
- const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
4351
- const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
4352
- if (!imageLoaded)
4353
- return null;
4354
- return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
4355
- React__default.createElement("div", { className: "le-tab-popup" },
4356
- React__default.createElement("div", { style: { position: 'relative' } },
4357
- React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
4358
- React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
4359
- aspectRatio: `${imageWidth}/${imageHeight}`,
4360
- } })),
4361
- React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
4362
3165
  };
4363
3166
 
4364
3167
  function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
@@ -4374,7 +3177,7 @@ function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
4374
3177
  }
4375
3178
  const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, showEmpty, setShowEmpty, userInfo, }) => {
4376
3179
  var _a, _b;
4377
- const { apiUrl, siteDomain } = useContext(LeadGenContext$1);
3180
+ const { apiUrl, siteDomain } = useContext(LeadGenContext);
4378
3181
  useEffect(() => {
4379
3182
  const gaCookie = getCookie('_ga') || null;
4380
3183
  fetch(`${apiUrl}api/campaign/${code}/impression`, {
@@ -4500,7 +3303,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
4500
3303
  };
4501
3304
 
4502
3305
  // mount css
4503
- const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
3306
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, primaryColor, apiSubotUrl, DEBUG_URL, forceCampaign, children, extraPayloadValues = [], excludeExitRulesHandler, userInfo, onClose: onCloseProps, }) => {
4504
3307
  var _a;
4505
3308
  const scrollEventHandlerRef = useRef();
4506
3309
  const leadStartTimeRef = useRef(Date.now());
@@ -4769,7 +3572,7 @@ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
4769
3572
  leadStartTimeRef.current = Date.now();
4770
3573
  }
4771
3574
  }, [showCampaign]);
4772
- return (React__default.createElement(LeadGenContext$1.Provider, { value: { apiUrl, siteDomain, siteId, locale } },
3575
+ return (React__default.createElement(LeadGenContext.Provider, { value: { primaryColor, apiUrl, siteDomain, siteId, locale } },
4773
3576
  React__default.createElement(TranslationsContext.Provider, { value: { locale, values: getTranslations(locale) } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, setShowThankyou: setShowThankyou, locale: locale, showEmpty: showEmpty, setShowEmpty: setShowEmpty, userInfo: userInfo }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
4774
3577
  React__default.createElement(Box, { sx: { position: 'fixed', zIndex: ZINDEX_SSO - 9e6 } },
4775
3578
  React__default.createElement(Transition, { mounted: Boolean(((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1'), transition: "fade", duration: 600, timingFunction: "ease" }, (styles) => {
@@ -4789,4 +3592,4 @@ LeadGen.Thankyou = Thankyou;
4789
3592
  LeadGen.OtpForm = OtpBlock$1;
4790
3593
  LeadGen.Close = Close;
4791
3594
 
4792
- export { LeadGen, LeadGenSubscriptionBox };
3595
+ export { LeadGen };