@hhgtech/hhg-components 1.28.79 → 1.28.80

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 (309) hide show
  1. package/build/Close-b7a203d1.js +29 -0
  2. package/build/adapters.js +14 -14
  3. package/build/babyGrowth.js +77 -77
  4. package/build/cache.js +3 -3
  5. package/build/care.js +17 -17
  6. package/build/components.js +55 -55
  7. package/build/{constants-8023e54c.js → constants-3479888e.js} +2 -2
  8. package/build/{constants-4e3b8eea.js → constants-bd8afa18.js} +2 -2
  9. package/build/constants.js +3 -3
  10. package/build/{core-5ccd5f28.js → core-22367a27.js} +2 -2
  11. package/build/{dataTransform-e07e040d.js → dataTransform-29cc3dd2.js} +1 -1
  12. package/build/ecom.js +6 -6
  13. package/build/esm/Close-4ca83dfd.js +7 -0
  14. package/build/esm/adapters.js +14 -14
  15. package/build/esm/babyGrowth.js +78 -78
  16. package/build/esm/cache.js +3 -3
  17. package/build/esm/care.js +17 -17
  18. package/build/esm/components.js +55 -55
  19. package/build/esm/{constants-4ea5ae41.js → constants-004f080a.js} +2 -2
  20. package/build/esm/{constants-328aaf66.js → constants-d53f9101.js} +2 -2
  21. package/build/esm/constants.js +3 -3
  22. package/build/esm/{core-c8dca256.js → core-7e4b4d85.js} +2 -2
  23. package/build/esm/{dataTransform-66574912.js → dataTransform-bf6753e4.js} +1 -1
  24. package/build/esm/ecom.js +6 -6
  25. package/build/esm/footer.js +19 -19
  26. package/build/esm/gAssets.js +4 -4
  27. package/build/esm/{getDynamicHealthTool-d1509b7d.js → getDynamicHealthTool-296bc3be.js} +4 -4
  28. package/build/esm/{getSocialList-a1af3491.js → getSocialList-2ebfcd4a.js} +2 -2
  29. package/build/esm/hooks.js +17 -17
  30. package/build/esm/i18n.js +2 -2
  31. package/build/esm/i18nV2.js +2 -2
  32. package/build/esm/{index-b8ea5a23.js → index-14587dbf.js} +8 -8
  33. package/build/esm/{index-80a1ccbd.js → index-22221342.js} +2 -2
  34. package/build/esm/{index-d4998039.js → index-2516c87e.js} +4 -4
  35. package/build/esm/{index-8bd363fa.js → index-27cc65d4.js} +29 -29
  36. package/build/esm/{index-219dd023.js → index-39528b9b.js} +1 -1
  37. package/build/esm/{index-a0e6fe5a.js → index-5849268c.js} +9 -9
  38. package/build/esm/{index-95da4552.js → index-76a63956.js} +5 -5
  39. package/build/esm/{index-5a4f0130.js → index-77f900fd.js} +10 -10
  40. package/build/esm/{index-6c13160b.js → index-78b15ede.js} +2 -2
  41. package/build/esm/{index-191caa64.js → index-8573ee56.js} +2 -2
  42. package/build/esm/{index-3abc2ca4.js → index-97d0e5e4.js} +2 -2
  43. package/build/esm/{index-84d11205.js → index-98cf27df.js} +6 -6
  44. package/build/esm/{index-4c09a22b.js → index-991703e4.js} +2 -2
  45. package/build/esm/{index-2aa3b49f.js → index-992d5b21.js} +9 -9
  46. package/build/esm/{index-91eacfa6.js → index-9964165a.js} +1 -1
  47. package/build/esm/{index-41561634.js → index-b42b746d.js} +3 -3
  48. package/build/esm/{index-f2e62740.js → index-bb6a15db.js} +2 -2
  49. package/build/esm/{index-dc498320.js → index-c6b43ed7.js} +9 -9
  50. package/build/esm/{index-5e669834.js → index-ce7d88c1.js} +3 -3
  51. package/build/esm/{index-68780c19.js → index-cf62426e.js} +4 -4
  52. package/build/esm/{index-34c718a9.js → index-d108d803.js} +13 -13
  53. package/build/esm/{index-6b9e9cd1.js → index-d5783ce8.js} +5 -5
  54. package/build/esm/{index-6d0db6db.js → index-dc60f279.js} +47 -43
  55. package/build/esm/{index-9de0216f.js → index-e329bfff.js} +2 -2
  56. package/build/esm/{index-611c21bf.js → index-f98bf91e.js} +2 -2
  57. package/build/esm/index.js +69 -68
  58. package/build/esm/{index.styled-007a7d61.js → index.styled-938c9e2d.js} +2 -2
  59. package/build/esm/{index.styles-ea8ece6c.js → index.styles-cf0b32a3.js} +6 -6
  60. package/build/esm/lead/components/close.d.ts +9 -0
  61. package/build/esm/lead/components/context.d.ts +35 -0
  62. package/build/esm/lead/components/description.d.ts +3 -0
  63. package/build/esm/lead/components/form/fields/index.d.ts +10 -0
  64. package/build/esm/lead/components/form/fields/index.styles.d.ts +8 -0
  65. package/build/esm/lead/components/form/fields/locationBlock.d.ts +6 -0
  66. package/build/esm/lead/components/form/fields/subtitleBlock.d.ts +5 -0
  67. package/build/esm/lead/components/form/fields/titleBlock.d.ts +5 -0
  68. package/build/esm/lead/components/form/formContext.d.ts +12 -0
  69. package/build/esm/lead/components/form/index.d.ts +5 -0
  70. package/build/esm/lead/components/form/index.styles.d.ts +15 -0
  71. package/build/esm/lead/components/heading.d.ts +3 -0
  72. package/build/esm/lead/components/index.d.ts +12 -0
  73. package/build/esm/lead/components/otpBlock/index.d.ts +9 -0
  74. package/build/esm/lead/components/otpBlock/index.styles.d.ts +13 -0
  75. package/build/esm/lead/components/thankyou.d.ts +4 -0
  76. package/build/esm/lead/index.d.ts +18 -2
  77. package/build/esm/lead.js +833 -221
  78. package/build/esm/mantine.js +19 -19
  79. package/build/esm/misc.js +17 -17
  80. package/build/esm/navigation.js +34 -34
  81. package/build/esm/onboardingV2.js +29 -29
  82. package/build/esm/pwg.js +18 -18
  83. package/build/esm/{routing-519f014d.js → routing-8faaacea.js} +2 -2
  84. package/build/esm/subot.js +20 -20
  85. package/build/esm/together.js +33 -32
  86. package/build/esm/{types-28a9c748.js → types-9f020bf6.js} +30 -34
  87. package/build/esm/{types-a6c6c403.js → types-a4e6af19.js} +13 -13
  88. package/build/esm/types.js +1 -1
  89. package/build/esm/{useCategory-a6a5af27.js → useCategory-b525a974.js} +5 -5
  90. package/build/esm/{useHealthToolCache-683560a0.js → useHealthToolCache-f6dcb4d8.js} +2 -2
  91. package/build/esm/{usePlacesAutocomplete-17fceeb6.js → usePlacesAutocomplete-e14d1036.js} +1 -1
  92. package/build/esm/{useTranslations-23fdfbc6.js → useTranslations-a559a7a5.js} +1 -1
  93. package/build/esm/{utils-dad13492.js → utils-8cfab824.js} +6 -6
  94. package/build/esm/{utils-b5c85238.js → utils-93eb13e7.js} +1 -1
  95. package/build/esm/{utils-ed2b6b73.js → utils-a88682f9.js} +4 -4
  96. package/build/esm/vaccination.js +24 -24
  97. package/build/footer.js +19 -19
  98. package/build/gAssets.js +4 -4
  99. package/build/{getDynamicHealthTool-def1121e.js → getDynamicHealthTool-fe550923.js} +4 -4
  100. package/build/{getSocialList-e60c0877.js → getSocialList-28b8aa45.js} +2 -2
  101. package/build/hooks.js +17 -17
  102. package/build/i18n.js +1 -1
  103. package/build/i18nV2.js +1 -1
  104. package/build/{index-be1aaf60.js → index-05304b9b.js} +4 -4
  105. package/build/{index-73797cf1.js → index-14226ab2.js} +46 -42
  106. package/build/{index-991334f4.js → index-17f9a72f.js} +2 -2
  107. package/build/{index-cc24bf8a.js → index-1cc3b628.js} +3 -3
  108. package/build/{index-815f4bdb.js → index-50a331ae.js} +2 -2
  109. package/build/{index-4d4699ec.js → index-72a41d2b.js} +5 -5
  110. package/build/{index-3f272096.js → index-76bb520c.js} +2 -2
  111. package/build/{index-fbf70389.js → index-830cfc43.js} +13 -13
  112. package/build/{index-2a7a1ff0.js → index-88286df3.js} +29 -29
  113. package/build/{index-35f2808a.js → index-8c630d76.js} +4 -4
  114. package/build/{index-59e6ab87.js → index-8d87268c.js} +3 -3
  115. package/build/{index-e023f4f1.js → index-90b4cf6b.js} +10 -10
  116. package/build/{index-f06ce46a.js → index-958f67bb.js} +2 -2
  117. package/build/{index-42566468.js → index-96b9585a.js} +9 -9
  118. package/build/{index-c52d0489.js → index-a2785ada.js} +2 -2
  119. package/build/{index-043ebe63.js → index-a3d460fa.js} +2 -2
  120. package/build/{index-dba46a36.js → index-a511db2b.js} +9 -9
  121. package/build/{index-ce679f9a.js → index-a79982f7.js} +2 -2
  122. package/build/{index-cbeab4a6.js → index-a84eedaa.js} +1 -1
  123. package/build/{index-fdc31354.js → index-a909db6f.js} +2 -2
  124. package/build/{index-641337b8.js → index-c194972d.js} +8 -8
  125. package/build/{index-fa31a970.js → index-d02a1631.js} +6 -6
  126. package/build/{index-c4aae21d.js → index-d7aea2d0.js} +1 -1
  127. package/build/{index-01ed5223.js → index-e3b0bdb0.js} +4 -4
  128. package/build/{index-cdad6882.js → index-f77accef.js} +9 -9
  129. package/build/index.js +113 -112
  130. package/build/{index.styled-c00771d3.js → index.styled-2ad9b370.js} +2 -2
  131. package/build/{index.styles-e837a685.js → index.styles-2705c1b1.js} +5 -5
  132. package/build/lead/components/close.d.ts +9 -0
  133. package/build/lead/components/context.d.ts +35 -0
  134. package/build/lead/components/description.d.ts +3 -0
  135. package/build/lead/components/form/fields/index.d.ts +10 -0
  136. package/build/lead/components/form/fields/index.styles.d.ts +8 -0
  137. package/build/lead/components/form/fields/locationBlock.d.ts +6 -0
  138. package/build/lead/components/form/fields/subtitleBlock.d.ts +5 -0
  139. package/build/lead/components/form/fields/titleBlock.d.ts +5 -0
  140. package/build/lead/components/form/formContext.d.ts +12 -0
  141. package/build/lead/components/form/index.d.ts +5 -0
  142. package/build/lead/components/form/index.styles.d.ts +15 -0
  143. package/build/lead/components/heading.d.ts +3 -0
  144. package/build/lead/components/index.d.ts +12 -0
  145. package/build/lead/components/otpBlock/index.d.ts +9 -0
  146. package/build/lead/components/otpBlock/index.styles.d.ts +13 -0
  147. package/build/lead/components/thankyou.d.ts +4 -0
  148. package/build/lead/index.d.ts +18 -2
  149. package/build/lead.js +856 -244
  150. package/build/mantine.js +17 -17
  151. package/build/misc.js +17 -17
  152. package/build/navigation.js +34 -34
  153. package/build/onboardingV2.js +28 -28
  154. package/build/pwg.js +18 -18
  155. package/build/{routing-6c762e84.js → routing-46b3def0.js} +2 -2
  156. package/build/subot.js +20 -20
  157. package/build/together.js +33 -32
  158. package/build/{types-ef54c184.js → types-03e001c9.js} +13 -13
  159. package/build/{types-4f6c5fb8.js → types-55014b2c.js} +656 -660
  160. package/build/types.js +1 -1
  161. package/build/{useCategory-746e7249.js → useCategory-54dfd7ee.js} +5 -5
  162. package/build/{useHealthToolCache-2c0db73c.js → useHealthToolCache-a5a6585a.js} +2 -2
  163. package/build/{usePlacesAutocomplete-6601cd7e.js → usePlacesAutocomplete-c73d655f.js} +1 -1
  164. package/build/{useTranslations-4804b349.js → useTranslations-ee85619b.js} +1 -1
  165. package/build/{utils-09717f21.js → utils-8aee541d.js} +1 -1
  166. package/build/{utils-0ff62762.js → utils-d583cd84.js} +4 -4
  167. package/build/{utils-e7e35048.js → utils-da97b7ae.js} +5 -5
  168. package/build/vaccination.js +24 -24
  169. package/package.json +1 -1
  170. /package/build/{BMI_BOYS.percentile.monthly-67b45bc7.js → BMI_BOYS.percentile.monthly-34095f55.js} +0 -0
  171. /package/build/{BMI_BOYS.percentile.weekly-8efa4b63.js → BMI_BOYS.percentile.weekly-b843a333.js} +0 -0
  172. /package/build/{BMI_BOYS.percentile.yearly-465e6d4b.js → BMI_BOYS.percentile.yearly-db0f25db.js} +0 -0
  173. /package/build/{BMI_BOYS.zscore.monthly-1d53737c.js → BMI_BOYS.zscore.monthly-36793c3e.js} +0 -0
  174. /package/build/{BMI_BOYS.zscore.weekly-087f544d.js → BMI_BOYS.zscore.weekly-92df605a.js} +0 -0
  175. /package/build/{BMI_BOYS.zscore.yearly-98a8df14.js → BMI_BOYS.zscore.yearly-33a1c871.js} +0 -0
  176. /package/build/{BMI_GIRLS.percentile.monthly-b6536309.js → BMI_GIRLS.percentile.monthly-4bf16f7d.js} +0 -0
  177. /package/build/{BMI_GIRLS.percentile.weekly-af6cb628.js → BMI_GIRLS.percentile.weekly-3bb97e2c.js} +0 -0
  178. /package/build/{BMI_GIRLS.percentile.yearly-0aac9851.js → BMI_GIRLS.percentile.yearly-5ff7d694.js} +0 -0
  179. /package/build/{BMI_GIRLS.zscore.monthly-7d88f50c.js → BMI_GIRLS.zscore.monthly-3be0d0e3.js} +0 -0
  180. /package/build/{BMI_GIRLS.zscore.weekly-54e4c51b.js → BMI_GIRLS.zscore.weekly-6d5c73b8.js} +0 -0
  181. /package/build/{BMI_GIRLS.zscore.yearly-06f436be.js → BMI_GIRLS.zscore.yearly-c16c2b7a.js} +0 -0
  182. /package/build/{ChevronDown-dfb37b0e.js → ChevronDown-00b6c45c.js} +0 -0
  183. /package/build/{HEAD CIRCUM_BOYS.percentile.monthly-97c28a58.js → HEAD CIRCUM_BOYS.percentile.monthly-5783abde.js} +0 -0
  184. /package/build/{HEAD CIRCUM_BOYS.percentile.weekly-0c97fd9c.js → HEAD CIRCUM_BOYS.percentile.weekly-69accc9b.js} +0 -0
  185. /package/build/{HEAD CIRCUM_BOYS.percentile.yearly-54275f5b.js → HEAD CIRCUM_BOYS.percentile.yearly-6f716357.js} +0 -0
  186. /package/build/{HEAD CIRCUM_BOYS.zscore.monthly-49735c17.js → HEAD CIRCUM_BOYS.zscore.monthly-740d8a88.js} +0 -0
  187. /package/build/{HEAD CIRCUM_BOYS.zscore.weekly-8aaa695d.js → HEAD CIRCUM_BOYS.zscore.weekly-75a83e4e.js} +0 -0
  188. /package/build/{HEAD CIRCUM_BOYS.zscore.yearly-da262754.js → HEAD CIRCUM_BOYS.zscore.yearly-beacfadd.js} +0 -0
  189. /package/build/{HEAD CIRCUM_GIRLS.percentile.monthly-2243ecfe.js → HEAD CIRCUM_GIRLS.percentile.monthly-4e9309e8.js} +0 -0
  190. /package/build/{HEAD CIRCUM_GIRLS.percentile.weekly-04cd2e1d.js → HEAD CIRCUM_GIRLS.percentile.weekly-8456b0af.js} +0 -0
  191. /package/build/{HEAD CIRCUM_GIRLS.percentile.yearly-d63e7c9f.js → HEAD CIRCUM_GIRLS.percentile.yearly-6bf9c34f.js} +0 -0
  192. /package/build/{HEAD CIRCUM_GIRLS.zscore.monthly-81c68d98.js → HEAD CIRCUM_GIRLS.zscore.monthly-561c12d7.js} +0 -0
  193. /package/build/{HEAD CIRCUM_GIRLS.zscore.weekly-a0e98c08.js → HEAD CIRCUM_GIRLS.zscore.weekly-27b56db8.js} +0 -0
  194. /package/build/{HEAD CIRCUM_GIRLS.zscore.yearly-d0d6cbcc.js → HEAD CIRCUM_GIRLS.zscore.yearly-e571dc07.js} +0 -0
  195. /package/build/{HEIGHT_BOYS.percentile.monthly-d69e7e60.js → HEIGHT_BOYS.percentile.monthly-52109c85.js} +0 -0
  196. /package/build/{HEIGHT_BOYS.percentile.weekly-08b91789.js → HEIGHT_BOYS.percentile.weekly-be6e5b1c.js} +0 -0
  197. /package/build/{HEIGHT_BOYS.percentile.yearly-0c17152c.js → HEIGHT_BOYS.percentile.yearly-3712519c.js} +0 -0
  198. /package/build/{HEIGHT_BOYS.zscore.monthly-c2793872.js → HEIGHT_BOYS.zscore.monthly-3ae90dec.js} +0 -0
  199. /package/build/{HEIGHT_BOYS.zscore.weekly-708f14ff.js → HEIGHT_BOYS.zscore.weekly-96915a5d.js} +0 -0
  200. /package/build/{HEIGHT_BOYS.zscore.yearly-a7076fa2.js → HEIGHT_BOYS.zscore.yearly-a3361503.js} +0 -0
  201. /package/build/{HEIGHT_GIRLS.percentile.monthly-8cb300b6.js → HEIGHT_GIRLS.percentile.monthly-d5d14ae4.js} +0 -0
  202. /package/build/{HEIGHT_GIRLS.percentile.weekly-efd17aae.js → HEIGHT_GIRLS.percentile.weekly-88d86966.js} +0 -0
  203. /package/build/{HEIGHT_GIRLS.percentile.yearly-4e02aa34.js → HEIGHT_GIRLS.percentile.yearly-00fab771.js} +0 -0
  204. /package/build/{HEIGHT_GIRLS.zscore.monthly-eeec3e4e.js → HEIGHT_GIRLS.zscore.monthly-6c2eeff3.js} +0 -0
  205. /package/build/{HEIGHT_GIRLS.zscore.weekly-9f2d5de0.js → HEIGHT_GIRLS.zscore.weekly-7619a61a.js} +0 -0
  206. /package/build/{HEIGHT_GIRLS.zscore.yearly-e5bad371.js → HEIGHT_GIRLS.zscore.yearly-122a294d.js} +0 -0
  207. /package/build/{Subot-48b9baf6.js → Subot-a11a4e5b.js} +0 -0
  208. /package/build/{Visible-c1268da8.js → Visible-c9b6d1c1.js} +0 -0
  209. /package/build/{WEIGHT_BOYS.percentile.monthly-92cac8bb.js → WEIGHT_BOYS.percentile.monthly-01c99b0d.js} +0 -0
  210. /package/build/{WEIGHT_BOYS.percentile.weekly-cef0861e.js → WEIGHT_BOYS.percentile.weekly-76f8bd4a.js} +0 -0
  211. /package/build/{WEIGHT_BOYS.percentile.yearly-f7a67820.js → WEIGHT_BOYS.percentile.yearly-c41a4d02.js} +0 -0
  212. /package/build/{WEIGHT_BOYS.zscore.monthly-c44320f9.js → WEIGHT_BOYS.zscore.monthly-04465ae9.js} +0 -0
  213. /package/build/{WEIGHT_BOYS.zscore.weekly-fd0ee996.js → WEIGHT_BOYS.zscore.weekly-fac29a95.js} +0 -0
  214. /package/build/{WEIGHT_BOYS.zscore.yearly-1ffe914a.js → WEIGHT_BOYS.zscore.yearly-66eb62c0.js} +0 -0
  215. /package/build/{WEIGHT_GIRLS.percentile.monthly-8c509873.js → WEIGHT_GIRLS.percentile.monthly-97e796d5.js} +0 -0
  216. /package/build/{WEIGHT_GIRLS.percentile.weekly-8acc8c12.js → WEIGHT_GIRLS.percentile.weekly-908cfdb5.js} +0 -0
  217. /package/build/{WEIGHT_GIRLS.percentile.yearly-52d175e3.js → WEIGHT_GIRLS.percentile.yearly-0e313840.js} +0 -0
  218. /package/build/{WEIGHT_GIRLS.zscore.monthly-20dc4379.js → WEIGHT_GIRLS.zscore.monthly-2497ec51.js} +0 -0
  219. /package/build/{WEIGHT_GIRLS.zscore.weekly-8e70083a.js → WEIGHT_GIRLS.zscore.weekly-45deda67.js} +0 -0
  220. /package/build/{WEIGHT_GIRLS.zscore.yearly-3241a1bf.js → WEIGHT_GIRLS.zscore.yearly-28b55590.js} +0 -0
  221. /package/build/{animation-693dcf31.js → animation-1621b827.js} +0 -0
  222. /package/build/{cookieHelper-51fe8b9c.js → cookieHelper-115e3b7b.js} +0 -0
  223. /package/build/esm/{BMI_BOYS.percentile.monthly-30b47425.js → BMI_BOYS.percentile.monthly-f22300a8.js} +0 -0
  224. /package/build/esm/{BMI_BOYS.percentile.weekly-dc18a954.js → BMI_BOYS.percentile.weekly-0916c196.js} +0 -0
  225. /package/build/esm/{BMI_BOYS.percentile.yearly-46570f22.js → BMI_BOYS.percentile.yearly-1958e38b.js} +0 -0
  226. /package/build/esm/{BMI_BOYS.zscore.monthly-0c249adc.js → BMI_BOYS.zscore.monthly-70d4e86e.js} +0 -0
  227. /package/build/esm/{BMI_BOYS.zscore.weekly-aec3c7f6.js → BMI_BOYS.zscore.weekly-d75f7e4a.js} +0 -0
  228. /package/build/esm/{BMI_BOYS.zscore.yearly-a690e4e7.js → BMI_BOYS.zscore.yearly-1930de04.js} +0 -0
  229. /package/build/esm/{BMI_GIRLS.percentile.monthly-a93aa923.js → BMI_GIRLS.percentile.monthly-e1df5f5d.js} +0 -0
  230. /package/build/esm/{BMI_GIRLS.percentile.weekly-8464b56f.js → BMI_GIRLS.percentile.weekly-0dab6bc5.js} +0 -0
  231. /package/build/esm/{BMI_GIRLS.percentile.yearly-dd28a8e3.js → BMI_GIRLS.percentile.yearly-e90dd797.js} +0 -0
  232. /package/build/esm/{BMI_GIRLS.zscore.monthly-f70006ce.js → BMI_GIRLS.zscore.monthly-e5c49595.js} +0 -0
  233. /package/build/esm/{BMI_GIRLS.zscore.weekly-7337b4b1.js → BMI_GIRLS.zscore.weekly-de23cfec.js} +0 -0
  234. /package/build/esm/{BMI_GIRLS.zscore.yearly-c3fa5e19.js → BMI_GIRLS.zscore.yearly-157d5f16.js} +0 -0
  235. /package/build/esm/{ChevronDown-ec19197d.js → ChevronDown-dba8fc93.js} +0 -0
  236. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.monthly-0c7fc386.js → HEAD CIRCUM_BOYS.percentile.monthly-ba646a48.js} +0 -0
  237. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.weekly-41d4ec43.js → HEAD CIRCUM_BOYS.percentile.weekly-88bcf790.js} +0 -0
  238. /package/build/esm/{HEAD CIRCUM_BOYS.percentile.yearly-fd423c7c.js → HEAD CIRCUM_BOYS.percentile.yearly-197b10a1.js} +0 -0
  239. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.monthly-9b146551.js → HEAD CIRCUM_BOYS.zscore.monthly-e8492701.js} +0 -0
  240. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.weekly-57cb8c81.js → HEAD CIRCUM_BOYS.zscore.weekly-fdd39166.js} +0 -0
  241. /package/build/esm/{HEAD CIRCUM_BOYS.zscore.yearly-4d1f2139.js → HEAD CIRCUM_BOYS.zscore.yearly-b9f25c32.js} +0 -0
  242. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.monthly-630afc45.js → HEAD CIRCUM_GIRLS.percentile.monthly-c5c9838b.js} +0 -0
  243. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.weekly-cb82686c.js → HEAD CIRCUM_GIRLS.percentile.weekly-c511c542.js} +0 -0
  244. /package/build/esm/{HEAD CIRCUM_GIRLS.percentile.yearly-3fa87019.js → HEAD CIRCUM_GIRLS.percentile.yearly-71243cc4.js} +0 -0
  245. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.monthly-c16b14e5.js → HEAD CIRCUM_GIRLS.zscore.monthly-584142c2.js} +0 -0
  246. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.weekly-2e8dc488.js → HEAD CIRCUM_GIRLS.zscore.weekly-58c12477.js} +0 -0
  247. /package/build/esm/{HEAD CIRCUM_GIRLS.zscore.yearly-3376dc6e.js → HEAD CIRCUM_GIRLS.zscore.yearly-f5df2c91.js} +0 -0
  248. /package/build/esm/{HEIGHT_BOYS.percentile.monthly-75afa773.js → HEIGHT_BOYS.percentile.monthly-70bda395.js} +0 -0
  249. /package/build/esm/{HEIGHT_BOYS.percentile.weekly-635561f4.js → HEIGHT_BOYS.percentile.weekly-30c20803.js} +0 -0
  250. /package/build/esm/{HEIGHT_BOYS.percentile.yearly-cf442ef0.js → HEIGHT_BOYS.percentile.yearly-5bbf1dac.js} +0 -0
  251. /package/build/esm/{HEIGHT_BOYS.zscore.monthly-b62bbbdc.js → HEIGHT_BOYS.zscore.monthly-e0538785.js} +0 -0
  252. /package/build/esm/{HEIGHT_BOYS.zscore.weekly-b32358ff.js → HEIGHT_BOYS.zscore.weekly-eb71c990.js} +0 -0
  253. /package/build/esm/{HEIGHT_BOYS.zscore.yearly-5269cf8f.js → HEIGHT_BOYS.zscore.yearly-4dc9859f.js} +0 -0
  254. /package/build/esm/{HEIGHT_GIRLS.percentile.monthly-571c1f33.js → HEIGHT_GIRLS.percentile.monthly-e414e4c7.js} +0 -0
  255. /package/build/esm/{HEIGHT_GIRLS.percentile.weekly-74645237.js → HEIGHT_GIRLS.percentile.weekly-1b851c3e.js} +0 -0
  256. /package/build/esm/{HEIGHT_GIRLS.percentile.yearly-fcb535d5.js → HEIGHT_GIRLS.percentile.yearly-b5d7f6d3.js} +0 -0
  257. /package/build/esm/{HEIGHT_GIRLS.zscore.monthly-11f4b03a.js → HEIGHT_GIRLS.zscore.monthly-11d155a8.js} +0 -0
  258. /package/build/esm/{HEIGHT_GIRLS.zscore.weekly-d32f79ca.js → HEIGHT_GIRLS.zscore.weekly-5d495735.js} +0 -0
  259. /package/build/esm/{HEIGHT_GIRLS.zscore.yearly-24d2056e.js → HEIGHT_GIRLS.zscore.yearly-be736caf.js} +0 -0
  260. /package/build/esm/{Subot-8b616873.js → Subot-7661c139.js} +0 -0
  261. /package/build/esm/{Visible-f33957d7.js → Visible-d824de49.js} +0 -0
  262. /package/build/esm/{WEIGHT_BOYS.percentile.monthly-06e8279e.js → WEIGHT_BOYS.percentile.monthly-9c5b188e.js} +0 -0
  263. /package/build/esm/{WEIGHT_BOYS.percentile.weekly-6da891d7.js → WEIGHT_BOYS.percentile.weekly-0fa721f6.js} +0 -0
  264. /package/build/esm/{WEIGHT_BOYS.percentile.yearly-60af91dd.js → WEIGHT_BOYS.percentile.yearly-c8a70cab.js} +0 -0
  265. /package/build/esm/{WEIGHT_BOYS.zscore.monthly-5c74895f.js → WEIGHT_BOYS.zscore.monthly-21d3428e.js} +0 -0
  266. /package/build/esm/{WEIGHT_BOYS.zscore.weekly-123acce9.js → WEIGHT_BOYS.zscore.weekly-4c58352b.js} +0 -0
  267. /package/build/esm/{WEIGHT_BOYS.zscore.yearly-eff30911.js → WEIGHT_BOYS.zscore.yearly-d4dd6ebb.js} +0 -0
  268. /package/build/esm/{WEIGHT_GIRLS.percentile.monthly-293eee77.js → WEIGHT_GIRLS.percentile.monthly-cd2ca8d6.js} +0 -0
  269. /package/build/esm/{WEIGHT_GIRLS.percentile.weekly-3a629d81.js → WEIGHT_GIRLS.percentile.weekly-bd2e8484.js} +0 -0
  270. /package/build/esm/{WEIGHT_GIRLS.percentile.yearly-34dbff44.js → WEIGHT_GIRLS.percentile.yearly-4079fc0b.js} +0 -0
  271. /package/build/esm/{WEIGHT_GIRLS.zscore.monthly-acc6961d.js → WEIGHT_GIRLS.zscore.monthly-314c62fd.js} +0 -0
  272. /package/build/esm/{WEIGHT_GIRLS.zscore.weekly-d9eeff9f.js → WEIGHT_GIRLS.zscore.weekly-b5e5c0f4.js} +0 -0
  273. /package/build/esm/{WEIGHT_GIRLS.zscore.yearly-1c204293.js → WEIGHT_GIRLS.zscore.yearly-3ebbf40b.js} +0 -0
  274. /package/build/esm/{animation-fa81f721.js → animation-9a852d86.js} +0 -0
  275. /package/build/esm/{cookieHelper-144d1108.js → cookieHelper-fb2f4bf7.js} +0 -0
  276. /package/build/esm/{index-bd70c317.js → index-11c2da20.js} +0 -0
  277. /package/build/esm/{index-01ad05b9.js → index-cf296b7d.js} +0 -0
  278. /package/build/esm/{index-dc65ac91.js → index-f408e111.js} +0 -0
  279. /package/build/esm/{isProduction-1651fbe3.js → isProduction-a14c0289.js} +0 -0
  280. /package/build/esm/{localizeNumberFormat-ad09362f.js → localizeNumberFormat-7ad2018e.js} +0 -0
  281. /package/build/esm/{normalizeLink-b0251b2e.js → normalizeLink-b27ea7f7.js} +0 -0
  282. /package/build/esm/{number-1cc61dbd.js → number-c4673157.js} +0 -0
  283. /package/build/esm/{paths-b77bbdfe.js → paths-24a48d7a.js} +0 -0
  284. /package/build/esm/{theme-a3e5a214.js → theme-b8e10c2e.js} +0 -0
  285. /package/build/esm/{translationsContext-b0ae072f.js → translationsContext-a710bd79.js} +0 -0
  286. /package/build/esm/{tslib.es6-0f26fe74.js → tslib.es6-2581561d.js} +0 -0
  287. /package/build/esm/{types-ff572579.js → types-d56b59d0.js} +0 -0
  288. /package/build/esm/{useIsInit-33e3bd4a.js → useIsInit-5759a12c.js} +0 -0
  289. /package/build/esm/{useOutsideClick-38645332.js → useOutsideClick-0cd449b6.js} +0 -0
  290. /package/build/esm/{useScrollbarSize-2da03206.js → useScrollbarSize-9a2c88e8.js} +0 -0
  291. /package/build/esm/{useUniqueId-b04da7b3.js → useUniqueId-4d87b935.js} +0 -0
  292. /package/build/esm/{utils-59d61ca1.js → utils-ad80dd9a.js} +0 -0
  293. /package/build/{index-dc8be5b5.js → index-306faebb.js} +0 -0
  294. /package/build/{index-f707c820.js → index-5f30931a.js} +0 -0
  295. /package/build/{index-87fa99ae.js → index-7aff6c39.js} +0 -0
  296. /package/build/{isProduction-f6ac6db3.js → isProduction-253f0a63.js} +0 -0
  297. /package/build/{localizeNumberFormat-cc6ff0f2.js → localizeNumberFormat-691759ff.js} +0 -0
  298. /package/build/{normalizeLink-a75dcce6.js → normalizeLink-289e65d5.js} +0 -0
  299. /package/build/{number-38620770.js → number-97ef064d.js} +0 -0
  300. /package/build/{paths-cdef268e.js → paths-a793ca70.js} +0 -0
  301. /package/build/{theme-fde2b656.js → theme-3069f85a.js} +0 -0
  302. /package/build/{translationsContext-5d32e21d.js → translationsContext-09f33cc8.js} +0 -0
  303. /package/build/{tslib.es6-3b38ec78.js → tslib.es6-05775979.js} +0 -0
  304. /package/build/{types-eb12b071.js → types-ab2e9e82.js} +0 -0
  305. /package/build/{useIsInit-6aed4c96.js → useIsInit-91ab8916.js} +0 -0
  306. /package/build/{useOutsideClick-b7334761.js → useOutsideClick-e32b8474.js} +0 -0
  307. /package/build/{useScrollbarSize-29a463ce.js → useScrollbarSize-3e2d19c9.js} +0 -0
  308. /package/build/{useUniqueId-7c6ca6f9.js → useUniqueId-3b22c3ca.js} +0 -0
  309. /package/build/{utils-25a8cc7b.js → utils-f7881466.js} +0 -0
package/build/esm/lead.js CHANGED
@@ -1,47 +1,50 @@
1
- import { _ as __rest, a as __awaiter } from './tslib.es6-0f26fe74.js';
2
- import React__default, { createContext, useState, useEffect, useMemo, useRef, useContext } from 'react';
1
+ import { _ as __rest, a as __awaiter } from './tslib.es6-2581561d.js';
2
+ import React__default, { createContext, useMemo, useRef, useState, useEffect, useContext } from 'react';
3
3
  import debounce from 'lodash/debounce';
4
- import { v1 } from 'uuid';
5
- import { B as Button } from './index-6c13160b.js';
6
- import { C as CommonGAssets } from './index-3abc2ca4.js';
7
- import { Portal, Box, Transition, Overlay } from '@mantine/core';
8
- import { T as Text } from './index-219dd023.js';
9
- import './index.styles-ea8ece6c.js';
10
- import { S as Select, d as Checkbox, c as Input, R as Radio, P as Phone, N as NumberInput } from './index-b8ea5a23.js';
11
- import './constants-328aaf66.js';
12
- import './Subot-8b616873.js';
13
- import './utils-ed2b6b73.js';
14
- import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-59d61ca1.js';
15
- import { D as DatePicker } from './index-95da4552.js';
16
- import { t as theme } from './theme-a3e5a214.js';
17
- import { T as TranslationsContext } from './translationsContext-b0ae072f.js';
4
+ import { createFormContext } from '@mantine/form';
5
+ import { u as useTranslations } from './useTranslations-a559a7a5.js';
6
+ import { T as Text } from './index-39528b9b.js';
7
+ import { createStyles, Box, Portal, Transition, Overlay } from '@mantine/core';
8
+ import './index.styles-cf0b32a3.js';
9
+ import { S as Select, d as Checkbox, c as Input, R as Radio, P as Phone, N as NumberInput, B as Button$1 } from './index-14587dbf.js';
10
+ import { B as Button } from './index-78b15ede.js';
11
+ import { C as CommonGAssets } from './index-97d0e5e4.js';
12
+ import './constants-d53f9101.js';
13
+ import './Subot-7661c139.js';
14
+ import './utils-a88682f9.js';
15
+ import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-ad80dd9a.js';
16
+ import { D as DatePicker } from './index-76a63956.js';
17
+ import { t as theme } from './theme-b8e10c2e.js';
18
+ import { T as TranslationsContext } from './translationsContext-a710bd79.js';
18
19
  import 'string-format';
19
20
  import '@mantine/hooks';
20
- import './index-9de0216f.js';
21
- import './utils-dad13492.js';
22
- import './index.styled-007a7d61.js';
23
- import './index-bd70c317.js';
24
- import { M as MAPPED_LOCALE } from './utils-b5c85238.js';
21
+ import './index-e329bfff.js';
22
+ import './utils-8cfab824.js';
23
+ import './index.styled-938c9e2d.js';
24
+ import './index-11c2da20.js';
25
+ import { M as MAPPED_LOCALE } from './utils-93eb13e7.js';
25
26
  import '@mantine/dates';
26
- import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-17fceeb6.js';
27
- import { createFormContext } from '@mantine/form';
28
- import { u as useTranslations } from './useTranslations-23fdfbc6.js';
29
- import { H as Heading } from './index-611c21bf.js';
27
+ import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-e14d1036.js';
28
+ import { H as Heading$1 } from './index-f98bf91e.js';
29
+ import { v1 } from 'uuid';
30
30
  import { createPortal } from 'react-dom';
31
- import { g as getCookie, s as setCookie } from './cookieHelper-144d1108.js';
31
+ import { g as getCookie, s as setCookie } from './cookieHelper-fb2f4bf7.js';
32
32
  import dayjs from 'dayjs';
33
- import './isProduction-1651fbe3.js';
33
+ import { C as Close } from './Close-4ca83dfd.js';
34
34
  import 'styled-components';
35
- import './animation-fa81f721.js';
35
+ import './animation-9a852d86.js';
36
36
  import 'react-keyed-flatten-children';
37
37
  import '@hhgtech/icons/other';
38
38
  import '@mantine/carousel';
39
39
  import 'classnames';
40
- import './useUniqueId-b04da7b3.js';
40
+ import './useUniqueId-4d87b935.js';
41
41
  import '@hhgtech/icons/core';
42
+ import './isProduction-a14c0289.js';
42
43
  import 'date-fns/locale';
43
44
  import 'slugify';
44
45
 
46
+ const LeadGenComponentContext = createContext({});
47
+
45
48
  const CAMPAIGN_TARGET_TYPE = { LINKS: 1, TAGS: 2 };
46
49
  let LEAD_API = 'https://dev.leadgen.hellobacsi.com/';
47
50
  const LEAD_DEVICE_TYPE = {
@@ -106,25 +109,787 @@ const LEAD_LOCALE_DATA = {
106
109
  countryCodeNumber: 91,
107
110
  },
108
111
  };
109
- const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
110
- function LEAD_RESET_VAR() {
111
- // LEAD_CURRENT_URL = location.href.toLowerCase();
112
- LEAD_CURRENT_URL =
113
- 'https://' + location.hostname + location.pathname + location.search;
114
- }
115
- const LEAD_TIMEZONE_DATA = {
116
- 1: 'Asia/Ho_Chi_Minh',
117
- 10: 'Asia/Ho_Chi_Minh',
118
- 11: 'Asia/Ho_Chi_Minh',
119
- 12: 'Asia/Ho_Chi_Minh',
120
- 2: 'Asia/Jakarta',
121
- 3: 'Asia/Bangkok',
122
- 4: 'Asia/Phnom_Penh',
123
- 5: 'Asia/Kuala_Lumpur',
124
- 6: 'Asia/Taipei',
125
- 7: 'Asia/Yangon',
126
- 8: 'Asia/Kolkata',
127
- 9: 'Asia/Manila', // Philippines / Filipinos Site
112
+ const LEAD_LOCALE = LEAD_LOCALE_DATA[docLang] || LEAD_LOCALE_DATA['vi-VN'];
113
+ function LEAD_RESET_VAR() {
114
+ // LEAD_CURRENT_URL = location.href.toLowerCase();
115
+ LEAD_CURRENT_URL =
116
+ 'https://' + location.hostname + location.pathname + location.search;
117
+ }
118
+ const LEAD_TIMEZONE_DATA = {
119
+ 1: 'Asia/Ho_Chi_Minh',
120
+ 10: 'Asia/Ho_Chi_Minh',
121
+ 11: 'Asia/Ho_Chi_Minh',
122
+ 12: 'Asia/Ho_Chi_Minh',
123
+ 2: 'Asia/Jakarta',
124
+ 3: 'Asia/Bangkok',
125
+ 4: 'Asia/Phnom_Penh',
126
+ 5: 'Asia/Kuala_Lumpur',
127
+ 6: 'Asia/Taipei',
128
+ 7: 'Asia/Yangon',
129
+ 8: 'Asia/Kolkata',
130
+ 9: 'Asia/Manila', // Philippines / Filipinos Site
131
+ };
132
+
133
+ class Store {
134
+ constructor() {
135
+ this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
136
+ this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
137
+ }
138
+ }
139
+ const leadStore = new Store();
140
+
141
+ const leadApi = {
142
+ call(_a) {
143
+ var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
144
+ config.body = JSON.stringify(data);
145
+ config.headers = {
146
+ 'Content-Type': 'application/json',
147
+ };
148
+ return fetch(`${leadStore.apiLeadUrl}${url}`, config)
149
+ .then((res) => res.json())
150
+ .catch(() => ({}));
151
+ },
152
+ };
153
+ const subotApi = {
154
+ call(_a) {
155
+ var { url, data } = _a, config = __rest(_a, ["url", "data"]);
156
+ config.body = JSON.stringify(data);
157
+ config.headers = {
158
+ 'Content-Type': 'application/json',
159
+ };
160
+ return fetch(`${leadStore.apiSubotUrl}${url}`, config)
161
+ .then((res) => res.json())
162
+ .catch(() => ({}));
163
+ },
164
+ };
165
+ const campaignGetById = (id) => {
166
+ return leadApi.call({
167
+ url: `api/internal/campaign/${id}`,
168
+ method: 'get',
169
+ });
170
+ };
171
+ const validateEmailOrPhoneOnLeadGen = ({ campaign_id, email, phone, }) => {
172
+ let phoneToSend = phone;
173
+ // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
174
+ if (phoneToSend && phoneToSend.startsWith('0')) {
175
+ phoneToSend = phoneToSend.substring(1);
176
+ }
177
+ return leadApi.call({
178
+ url: 'api/subot-campaign/check',
179
+ method: 'post',
180
+ data: {
181
+ campaign_id,
182
+ email,
183
+ phone: phoneToSend,
184
+ },
185
+ });
186
+ };
187
+ const validateEmailOrPhoneOnSubot = ({ bot_id, email, phone, }) => {
188
+ let phoneToSend = phone;
189
+ // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
190
+ if (phoneToSend && phoneToSend.startsWith('0')) {
191
+ phoneToSend = phoneToSend.substring(1);
192
+ }
193
+ return subotApi.call({
194
+ url: 'frontend/api/subot-campaign/check',
195
+ method: 'post',
196
+ data: {
197
+ bot_id,
198
+ email,
199
+ phone: phoneToSend,
200
+ },
201
+ });
202
+ };
203
+ const sendSMSOtpLead = ({ phone, type, }) => {
204
+ return leadApi.call({
205
+ url: type === 'phone' ? 'api/sms/otp' : 'api/sms/whatsapp_otp',
206
+ method: 'post',
207
+ data: {
208
+ // The type Whatsapp do not remove the '+'
209
+ phone_number: type === 'phone' ? phone.replace('+', '') : phone,
210
+ },
211
+ });
212
+ };
213
+ const verifyOtpLead = ({ phone, otp, type, }) => {
214
+ return leadApi.call({
215
+ url: type === 'phone' ? 'api/sms/verify' : 'api/sms/whatsapp_verify',
216
+ method: 'post',
217
+ data: {
218
+ // The type Whatsapp do not remove the '+'
219
+ otp_code: otp,
220
+ phone_number: type === 'phone' ? phone.replace('+', '') : phone,
221
+ },
222
+ });
223
+ };
224
+ const Service = {
225
+ campaignGetById,
226
+ validateEmailOrPhoneOnSubot,
227
+ validateEmailOrPhoneOnLeadGen,
228
+ sendSMSOtpLead,
229
+ verifyOtpLead,
230
+ };
231
+
232
+ const checkUsedEmailOrPhone = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
233
+ const key = 'email' in data ? 'email' : 'phone';
234
+ const value = 'email' in data ? data.email : data.phone;
235
+ const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
236
+ /** Check on Leadgen Tool */
237
+ const resLeadGen = yield Service.validateEmailOrPhoneOnLeadGen({
238
+ campaign_id: [campaignId],
239
+ [key]: value, // Can be email or phone
240
+ });
241
+ if (resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_001' ||
242
+ resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_002') {
243
+ return errorMsg;
244
+ }
245
+ /** Check on Subot */
246
+ if (campaign_subot_id.length) {
247
+ const resSubot = yield Service.validateEmailOrPhoneOnSubot({
248
+ bot_id: campaign_subot_id,
249
+ [key]: value, // Can be email or phone
250
+ });
251
+ if (resSubot._errorCode === 'CheckSuBotLeadTool_ERR_001') {
252
+ return errorMsg;
253
+ }
254
+ }
255
+ });
256
+ const validatedCache = {
257
+ email: {},
258
+ phone: {},
259
+ };
260
+ const checkUsedEmailOrPhoneWithCache = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
261
+ const key = 'email' in data ? 'email' : 'phone';
262
+ const value = 'email' in data ? data.email : data.phone;
263
+ const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
264
+ if (validatedCache[key][value]) {
265
+ if (validatedCache[key][value].value) {
266
+ return errorMsg;
267
+ }
268
+ else if (!validatedCache[key][value].value &&
269
+ validatedCache[key][value].expire > Date.now()) {
270
+ return '';
271
+ }
272
+ }
273
+ const res = yield checkUsedEmailOrPhone(campaignId, campaign_subot_id, data);
274
+ if (res) {
275
+ validatedCache[key][value] = {
276
+ value: true,
277
+ };
278
+ }
279
+ else {
280
+ validatedCache[key][value] = {
281
+ value: false,
282
+ expire: Date.now() + 1000 * 60,
283
+ };
284
+ }
285
+ return res;
286
+ });
287
+ const clearCacheUsedEmailOrPhone = () => {
288
+ validatedCache.email = {};
289
+ validatedCache.phone = {};
290
+ };
291
+
292
+ // You can give context variables any name
293
+ const [LeadFormProvider$1, useLeadFormContext$1, useLeadForm$1] = createFormContext();
294
+ const useLeadFormConfig$1 = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], }) => {
295
+ const { t } = useTranslations();
296
+ const validateObj = useMemo(() => {
297
+ const InputBlocks = [
298
+ 'TextBlock',
299
+ 'NumberBlock',
300
+ 'EmailBlock',
301
+ 'PhoneBlock',
302
+ 'DateBlock',
303
+ 'CheckboxBlock',
304
+ 'RadioBlock',
305
+ 'DropdownBlock',
306
+ 'PhoneOtpBlock',
307
+ 'WhatsappOtpBlock',
308
+ 'LocationBlock',
309
+ 'TncBlock',
310
+ ];
311
+ // ALL are required and can skip if not touched yet
312
+ const withSharedCheck = (name, cb) => {
313
+ return (value) => {
314
+ if (!formRef.current.isTouched(name))
315
+ return;
316
+ if (typeof value === 'undefined' ||
317
+ value === '' ||
318
+ (Array.isArray(value) && value.length === 0)) {
319
+ return t('validator.required');
320
+ }
321
+ return cb === null || cb === void 0 ? void 0 : cb(value);
322
+ };
323
+ };
324
+ return listBlockAdded
325
+ .filter((b) => InputBlocks.includes(b.name))
326
+ .reduce((r, b) => {
327
+ if (b.name === 'NumberBlock') {
328
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
329
+ if (isNaN(Number(value))) {
330
+ return t('validator.number');
331
+ }
332
+ }) });
333
+ }
334
+ else if (b.name === 'EmailBlock') {
335
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
336
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
337
+ return t('validator.email');
338
+ }
339
+ validatingEmailRef.current = true;
340
+ setTimeout(() => {
341
+ formRef.current.setFieldError(b.data.value, 'Validating...');
342
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
343
+ email: value,
344
+ })
345
+ .then((tKey) => {
346
+ if (tKey) {
347
+ formRef.current.setFieldError(b.data.value, t(tKey));
348
+ }
349
+ else {
350
+ formRef.current.clearFieldError(b.data.value);
351
+ }
352
+ validatingEmailRef.current = false;
353
+ })
354
+ .catch((e) => {
355
+ console.error(e);
356
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
357
+ validatingEmailRef.current = false;
358
+ });
359
+ }, 200);
360
+ }) });
361
+ }
362
+ else if (b.name === 'PhoneBlock' ||
363
+ b.name === 'PhoneOtpBlock' ||
364
+ b.name === 'WhatsappOtpBlock') {
365
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
366
+ if (window.intlTelInputUtils &&
367
+ !window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
368
+ return t('validator.phone');
369
+ }
370
+ validatingPhoneRef.current = true;
371
+ setTimeout(() => {
372
+ formRef.current.setFieldError(b.data.value, 'Validating...');
373
+ checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
374
+ phone: value,
375
+ })
376
+ .then((tKey) => {
377
+ if (tKey) {
378
+ formRef.current.setFieldError(b.data.value, t(tKey));
379
+ }
380
+ else {
381
+ formRef.current.clearFieldError(b.data.value);
382
+ }
383
+ validatingPhoneRef.current = false;
384
+ })
385
+ .catch((e) => {
386
+ console.error(e);
387
+ formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
388
+ validatingPhoneRef.current = false;
389
+ });
390
+ }, 200);
391
+ }) });
392
+ }
393
+ else if (b.name === 'DateBlock') {
394
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
395
+ if (isNaN(Date.parse(value))) {
396
+ return t('validator.date');
397
+ }
398
+ }) });
399
+ }
400
+ else if (b.name === 'TncBlock') {
401
+ return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id) });
402
+ }
403
+ else {
404
+ return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value) });
405
+ }
406
+ }, {});
407
+ }, [listBlockAdded.map((b) => b.name).join(',')]);
408
+ const form = useLeadForm$1({
409
+ validateInputOnChange: true,
410
+ clearInputErrorOnChange: true,
411
+ validate: validateObj,
412
+ });
413
+ const formRef = useRef(form);
414
+ formRef.current = form;
415
+ return { form, validateObj };
416
+ };
417
+
418
+ const Component = ({ campaign, onClose: onCloseProp, onOtherSubmit, onSubmit, showThankyou, locale, children, }) => {
419
+ var _a, _b;
420
+ const extraFields = campaign.extra_fields;
421
+ const campaignId = campaign.id;
422
+ const campaign_subot_id = campaign.bot_id || [];
423
+ const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
424
+ const actionBlocks = JSON.parse(extraFields.actionBlocks);
425
+ const textBlocks = JSON.parse(extraFields.textBlocks);
426
+ const heading = ((_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) || '';
427
+ const description = textBlocks.subtitleBlock.data.value;
428
+ const validatingPhoneRef = useRef(false);
429
+ const validatingEmailRef = useRef(false);
430
+ const leadFormConfig = useLeadFormConfig$1({
431
+ listBlockAdded,
432
+ validatingPhoneRef,
433
+ validatingEmailRef,
434
+ campaignId,
435
+ campaign_subot_id,
436
+ });
437
+ const [showOtpPhone, setShowOtpPhone] = useState(null);
438
+ const formRef = useRef();
439
+ const onClose = () => {
440
+ if (showOtpPhone) {
441
+ setShowOtpPhone(null);
442
+ }
443
+ else {
444
+ onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
445
+ }
446
+ };
447
+ useEffect(() => {
448
+ if (!window.intlTelInputUtils) {
449
+ require('intl-tel-input/build/js/utils');
450
+ }
451
+ clearCacheUsedEmailOrPhone();
452
+ }, []);
453
+ return campaign ? (React__default.createElement(LeadGenComponentContext.Provider, { value: {
454
+ campaignId,
455
+ campaign_subot_id,
456
+ heading,
457
+ description,
458
+ listBlockAdded,
459
+ textBlocks,
460
+ actionBlocks,
461
+ leadFormConfig,
462
+ validatingEmailRef,
463
+ validatingPhoneRef,
464
+ formRef,
465
+ locale,
466
+ onClose,
467
+ onOtherSubmit,
468
+ showOtpPhone,
469
+ setShowOtpPhone,
470
+ onSubmit,
471
+ showThankyou,
472
+ } }, children)) : null;
473
+ };
474
+
475
+ const Description = (_a) => {
476
+ var rest = __rest(_a, []);
477
+ const { description } = useContext(LeadGenComponentContext);
478
+ return description ? (React__default.createElement(Text, Object.assign({ size: "p3" }, rest), description)) : null;
479
+ };
480
+
481
+ var useStyles$2 = createStyles(() => {
482
+ return {
483
+ control: {},
484
+ };
485
+ });
486
+
487
+ const libraries$1 = ['places'];
488
+ const LocationBlock$1 = ({ name, placeholder, locale, }) => {
489
+ var _a;
490
+ const form = useLeadFormContext$1();
491
+ const [searchValue, setSearchValue] = useState('');
492
+ const [address, setAddress] = useState('');
493
+ const { predictions } = usePlacesAutocomplete(searchValue, '', locale === 'tl-PH' ? 'en' : (_a = locale === null || locale === void 0 ? void 0 : locale.split('-')) === null || _a === void 0 ? void 0 : _a[0]);
494
+ const [LoadScript, setLoadScript] = useState(null);
495
+ const [ready, setReady] = useState(false);
496
+ const randRef = useRef(Math.random().toString(36).substring(7));
497
+ const options = useMemo(() => {
498
+ const _opts = predictions.map((p) => {
499
+ return {
500
+ value: p.description,
501
+ label: p.description,
502
+ };
503
+ });
504
+ const isExist = _opts.find((o) => o.value === address);
505
+ if (!address || isExist) {
506
+ return _opts;
507
+ }
508
+ return [{ value: address, label: address }].concat(_opts);
509
+ }, [predictions, address]);
510
+ useEffect(() => {
511
+ var _a, _b, _c;
512
+ // only load extra google script when not yet loaded
513
+ 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)) {
514
+ import('@react-google-maps/api').then((m) => {
515
+ setLoadScript(() => m.LoadScript);
516
+ setTimeout(() => {
517
+ setReady(true);
518
+ }, 200);
519
+ });
520
+ }
521
+ else {
522
+ setReady(true);
523
+ }
524
+ }, []);
525
+ if (!ready)
526
+ return (React__default.createElement("div", { style: {
527
+ height: 73,
528
+ } }));
529
+ return (React__default.createElement(React__default.Fragment, null,
530
+ LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries$1, loadingElement: React__default.createElement(React__default.Fragment, null) })),
531
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
532
+ React__default.createElement(Select, Object.assign({ className: "lead-modal__form-control", label: placeholder, placeholder: placeholder, withAsterisk: true, name: name, data: options, searchValue: searchValue, onSearchChange: (query) => {
533
+ setSearchValue(query);
534
+ }, filter: () => true, clearable: true, searchable: true, onChange: (val) => setAddress(val || ''), icon: React__default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" },
535
+ React__default.createElement("path", { d: "M10 9.792q.605 0 1.032-.427.426-.428.426-1.032 0-.603-.426-1.031A1.4 1.4 0 0 0 10 6.875q-.604 0-1.032.427a1.4 1.4 0 0 0-.426 1.031q0 .604.426 1.032.428.426 1.032.427m0 8.083q-.145 0-.292-.042a.7.7 0 0 1-.27-.145Q6.478 15 5.01 12.708 3.54 10.418 3.54 8.5q0-3.021 1.949-4.823T10 1.875t4.51 1.802q1.95 1.802 1.949 4.823 0 1.917-1.468 4.208-1.47 2.292-4.427 4.98a.7.7 0 0 1-.271.145 1 1 0 0 1-.292.042", fill: "#8C8C8C" })), autoComplete: 'no-auto-complete-' + randRef.current, rightSection: React__default.createElement(React__default.Fragment, null) }, form.getInputProps(name)))));
536
+ };
537
+
538
+ const SubtitleBlock$1 = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
539
+
540
+ const TitleBlock$1 = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
541
+
542
+ const Fields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, styles, classNames, }) => {
543
+ const { classes, cx } = useStyles$2(undefined, {
544
+ name: 'LeadGen__Field',
545
+ styles,
546
+ classNames,
547
+ });
548
+ const form = useLeadFormContext$1();
549
+ return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
550
+ const { name = '', data = {} } = b || {};
551
+ const { placeholder, value, align, listQuestion, isSendMailChimp = false, newtab, url, } = data;
552
+ switch (name) {
553
+ case 'TitleBlock':
554
+ return (React__default.createElement(TitleBlock$1, { key: index, align: align }, value));
555
+ case 'SubtitleBlock':
556
+ return (React__default.createElement(SubtitleBlock$1, { key: index, align: align }, value));
557
+ case 'TextBlock':
558
+ return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "text", placeholder: placeholder, className: cx('leadgen-control', classes.control),
559
+ // onChangeRaw={(e) => inputOnChange('text', e)}
560
+ label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
561
+ case 'NumberBlock':
562
+ return (React__default.createElement(NumberInput, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "number", placeholder: placeholder, className: cx('leadgen-control', classes.control),
563
+ // onChange={(e) => inputOnChange('number', e)}
564
+ label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
565
+ case 'EmailBlock':
566
+ return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false,
567
+ // type="email"
568
+ placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
569
+ case 'PhoneOtpBlock':
570
+ case 'WhatsappOtpBlock':
571
+ case 'PhoneBlock': {
572
+ const id = popupId + '-' + value + '-' + index;
573
+ return (React__default.createElement(Input.Wrapper, Object.assign({ size: "md", withAsterisk: true, key: index, label: placeholder,
574
+ // error={errorField.phone}
575
+ className: cx('leadgen-control', classes.control), labelProps: {
576
+ htmlFor: id,
577
+ } }, form.getInputProps(value)),
578
+ React__default.createElement(Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, onChange: (v) => {
579
+ form.setFieldValue(value, v);
580
+ },
581
+ // onBlur={(e) => inputOnBlur('tel', e)}
582
+ id: id, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" })));
583
+ }
584
+ case 'LocationBlock': {
585
+ return (React__default.createElement(LocationBlock$1, { key: index, name: value, placeholder: placeholder, locale: locale }));
586
+ }
587
+ case 'DateBlock':
588
+ return (React__default.createElement(React__default.Fragment, null,
589
+ React__default.createElement(DatePicker, Object.assign({ withAsterisk: true, key: index, type: "default", name: value, placeholder: placeholder, className: cx('leadgen-control', classes.control), label: placeholder, "data-control": "date" }, form.getInputProps(value))),
590
+ React__default.createElement("input", { type: "hidden", name: value, "data-control": "date" })));
591
+ case 'LinkButtonBlock':
592
+ return (React__default.createElement("div", { key: index },
593
+ React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
594
+ React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
595
+ onClose === null || onClose === void 0 ? void 0 : onClose();
596
+ onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
597
+ } }, value))));
598
+ case 'CheckboxBlock':
599
+ return (React__default.createElement(React__default.Fragment, null,
600
+ isSendMailChimp && (React__default.createElement("div", { style: {
601
+ display: 'none',
602
+ }, "data-name": value + '-mailchimp' })),
603
+ React__default.createElement(Checkbox.Group, Object.assign({ withAsterisk: true, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md", sx: {
604
+ display: 'flex',
605
+ flexDirection: 'column',
606
+ gap: 8,
607
+ } }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default.createElement(Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
608
+ case 'RadioBlock':
609
+ return (React__default.createElement(React__default.Fragment, null,
610
+ isSendMailChimp && (React__default.createElement(Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
611
+ React__default.createElement(Radio.Group, Object.assign({ withAsterisk: true, className: cx('leadgen-control', classes.control), key: index, label: placeholder, size: "md" }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default.createElement(Radio, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "radio" }))))));
612
+ case 'DropdownBlock':
613
+ return (React__default.createElement(React__default.Fragment, null,
614
+ React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
615
+ React__default.createElement(Select, Object.assign({ key: index, className: cx('leadgen-control', classes.control), label: placeholder, withAsterisk: true, name: value, data: listQuestion.map((l) => ({
616
+ value: l.value,
617
+ label: l.placeholder,
618
+ })) }, form.getInputProps(value)))));
619
+ case 'TncBlock':
620
+ const tncInputProps = form.getInputProps('TNC-' + b.id);
621
+ return (React__default.createElement(React__default.Fragment, null,
622
+ React__default.createElement(Checkbox, Object.assign({ name: 'TNC-' + b.id, key: b.id, label: React__default.createElement("p", { className: "lead-modal__tnc-link", dangerouslySetInnerHTML: { __html: data.valueHTML } }), className: "tnc-block", "data-control": "checkbox" }, tncInputProps, { error: tncInputProps.error ? React__default.createElement(React__default.Fragment, null) : undefined }))));
623
+ }
624
+ return null;
625
+ })));
626
+ };
627
+
628
+ var useStyles$1 = createStyles(() => {
629
+ return {
630
+ root: {},
631
+ header: {},
632
+ heading: {},
633
+ description: {},
634
+ term: {},
635
+ controlList: {},
636
+ control: {},
637
+ submitBtn: {},
638
+ };
639
+ });
640
+
641
+ const Heading = (_a) => {
642
+ var rest = __rest(_a, []);
643
+ const { heading } = useContext(LeadGenComponentContext);
644
+ return heading ? (React__default.createElement(Text, Object.assign({ size: "h3" }, rest), heading)) : null;
645
+ };
646
+
647
+ const FormComponent = ({ styles, className, classNames }) => {
648
+ var _a;
649
+ const { listBlockAdded, leadFormConfig: { form, validateObj }, validatingEmailRef, validatingPhoneRef, formRef, onClose, onOtherSubmit, actionBlocks, locale, setShowOtpPhone, onSubmit, } = useContext(LeadGenComponentContext);
650
+ const { classes, cx } = useStyles$1(undefined, {
651
+ name: 'LeadGen__FormComponent',
652
+ styles,
653
+ classNames,
654
+ });
655
+ const [checkedTerm, setCheckedTerm] = useState(true);
656
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
657
+ const popUpTermURL = actionBlocks.submitBlock.data.url;
658
+ const popUpTermAgreeText = actionBlocks.submitBlock.data.text;
659
+ const popUpTermText = actionBlocks.submitBlock.data.text2;
660
+ const popUpSubmitText = actionBlocks.submitBlock.data.value;
661
+ const middlewareOnSubmit = (e) => {
662
+ e.preventDefault();
663
+ // mark all as touched to allow validation
664
+ form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
665
+ acc[cur] = true;
666
+ return acc;
667
+ }, {}));
668
+ if (validatingEmailRef.current || validatingPhoneRef.current) {
669
+ return;
670
+ }
671
+ setTimeout(() => {
672
+ form.onSubmit((v) => {
673
+ var _a, _b, _c, _d, _e, _f;
674
+ if (Object.keys(form.errors).length)
675
+ return;
676
+ let newShowOtpPhone = null;
677
+ if (listBlockAdded.findIndex((x) => x.name === 'PhoneOtpBlock') > -1) {
678
+ // not submit yet, open otp
679
+ const fieldName = (_b = (_a = listBlockAdded.find((x) => x.name === 'PhoneOtpBlock')) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.value;
680
+ if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
681
+ newShowOtpPhone = {
682
+ phone: v[fieldName],
683
+ type: 'phone',
684
+ };
685
+ }
686
+ }
687
+ if (listBlockAdded.findIndex((x) => x.name === 'WhatsappOtpBlock') > -1) {
688
+ // not submit yet, open otp
689
+ const fieldName = (_e = (_d = listBlockAdded.find((x) => x.name === 'WhatsappOtpBlock')) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.value;
690
+ if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
691
+ newShowOtpPhone = {
692
+ phone: v[fieldName],
693
+ type: 'whatsapp',
694
+ };
695
+ }
696
+ }
697
+ if (newShowOtpPhone) {
698
+ setIsSubmitLoading(true);
699
+ Service.sendSMSOtpLead(newShowOtpPhone)
700
+ .then((res) => {
701
+ var _a;
702
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
703
+ if (respMessage === 'This phone number was verified') {
704
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
705
+ return;
706
+ }
707
+ setShowOtpPhone(newShowOtpPhone);
708
+ })
709
+ .finally(() => {
710
+ setIsSubmitLoading(false);
711
+ });
712
+ return;
713
+ }
714
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
715
+ })(e);
716
+ }, 100);
717
+ };
718
+ return (React__default.createElement(LeadFormProvider$1, { form: form },
719
+ React__default.createElement(Box, { component: "form", ref: formRef, className: cx(className, classes.root), onSubmit: middlewareOnSubmit, styles: styles },
720
+ React__default.createElement("div", { className: classes.header },
721
+ React__default.createElement(Heading, { className: classes.heading }),
722
+ React__default.createElement(Description, { className: classes.description })),
723
+ React__default.createElement("div", { className: classes.controlList },
724
+ React__default.createElement(Fields, { classNames: {
725
+ control: classes.control,
726
+ }, listBlockAdded: listBlockAdded, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit })),
727
+ ((_a = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _a === void 0 ? void 0 : _a.isHide) ? null : (React__default.createElement(React__default.Fragment, null,
728
+ React__default.createElement("div", { className: classes.term },
729
+ React__default.createElement("div", { className: "lead-modal__checkbox" },
730
+ React__default.createElement("input", { id: "lead-term-checkbox", className: `lead-modal__checkbox__input ${LEAD_CLASS}`, type: "checkbox", "aria-label": "Checkbox label", checked: checkedTerm, onChange: (e) => setCheckedTerm(e.currentTarget.checked) }),
731
+ React__default.createElement("div", { className: "lead-modal__checkbox__control", "aria-hidden": "true" })),
732
+ React__default.createElement("label", { htmlFor: "checkbox", className: "lead-modal__checkbox__label" },
733
+ popUpTermAgreeText,
734
+ ' ',
735
+ React__default.createElement("span", { style: { fontWeight: 'bold' } },
736
+ React__default.createElement("a", { target: "blank", href: popUpTermURL || 'https://hellobacsi.com/chinh-sach', rel: "noopener noreferrer", style: { textDecoration: 'none' } }, popUpTermText)))),
737
+ React__default.createElement(Button$1, { size: "md", id: "lead-submit", type: "submit", className: classes.submitBtn, disabled: !checkedTerm, loading: isSubmitLoading }, popUpSubmitText))))));
738
+ };
739
+ const Form = (props) => {
740
+ const { showOtpPhone, showThankyou } = useContext(LeadGenComponentContext);
741
+ return showThankyou || showOtpPhone ? null : React__default.createElement(FormComponent, Object.assign({}, props));
742
+ };
743
+
744
+ var useStyles = createStyles(() => {
745
+ return {
746
+ root: {},
747
+ heading: {},
748
+ description: {},
749
+ control: {},
750
+ submitBtn: {},
751
+ resendOtp: {},
752
+ };
753
+ });
754
+
755
+ const OtpBlockComponent = ({ otpData, onSuccess, autoSendWhenOpen, className, styles, classNames, }) => {
756
+ const { t } = useTranslations();
757
+ const phone = otpData.phone;
758
+ const otpType = otpData.type;
759
+ const [otp, setOtp] = useState('');
760
+ const [isDirty, setIsDirty] = useState(false);
761
+ const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
762
+ const inputRef = useRef(null);
763
+ const [errorMsg, setErrorMsg] = useState();
764
+ const [displayPhone, setDisplayPhone] = useState('');
765
+ const formatPhoneNumberIntlRef = useRef();
766
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
767
+ const { classes, cx } = useStyles(undefined, {
768
+ name: 'LeadGen__OTP',
769
+ styles,
770
+ classNames,
771
+ });
772
+ useEffect(() => {
773
+ (() => __awaiter(void 0, void 0, void 0, function* () {
774
+ var _a;
775
+ if (!formatPhoneNumberIntlRef.current) {
776
+ const res = yield import('react-phone-number-input');
777
+ formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
778
+ }
779
+ setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
780
+ }))();
781
+ }, [phone]);
782
+ const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
783
+ var _a;
784
+ if (!phone) {
785
+ return;
786
+ }
787
+ const res = yield Service.sendSMSOtpLead({
788
+ phone,
789
+ type: otpType,
790
+ });
791
+ const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
792
+ if (respMessage === 'Send sms successfully' ||
793
+ respMessage === 'Send WhatsApp successfully') {
794
+ setResendTimer(60);
795
+ setTimeout(() => {
796
+ if (inputRef.current) {
797
+ inputRef.current.focus();
798
+ inputRef.current.scrollIntoView({ block: 'center' });
799
+ }
800
+ }, 100);
801
+ }
802
+ else if (respMessage === 'This phone number was verified') {
803
+ onSuccess();
804
+ }
805
+ else {
806
+ setErrorMsg(respMessage || 'Something went wrong!');
807
+ // const defaultError = f({ id: 'notification.comment.somethingWrong' })
808
+ // setStatusVerifyOTP('idle')
809
+ // pushNotifications({
810
+ // title: respMessage || defaultError,
811
+ // message: '',
812
+ // type: 'danger',
813
+ // })
814
+ }
815
+ });
816
+ const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
817
+ if (!phone || !otp) {
818
+ return;
819
+ }
820
+ setIsSubmitLoading(true);
821
+ const res = yield Service.verifyOtpLead({
822
+ phone,
823
+ otp,
824
+ type: otpType,
825
+ });
826
+ const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
827
+ if (respMessage === 'Verify successfully' ||
828
+ respMessage === 'Verify WhatsApp OTP sucess') {
829
+ onSuccess();
830
+ }
831
+ else if (respMessage === 'This phone number was verified') {
832
+ onSuccess();
833
+ }
834
+ else {
835
+ setErrorMsg(respMessage || 'something Wrong');
836
+ // setIsShowError(true)
837
+ // setStatusVerifyOTP('sent')
838
+ // pushNotifications({
839
+ // title: res?._messages[0] || defaultError,
840
+ // message: '',
841
+ // type: 'danger',
842
+ // })
843
+ }
844
+ setIsSubmitLoading(false);
845
+ });
846
+ useEffect(() => {
847
+ setTimeout(() => {
848
+ if (resendTimer > 0) {
849
+ setResendTimer((r) => r - 1);
850
+ }
851
+ }, 1000);
852
+ }, [resendTimer]);
853
+ useEffect(() => {
854
+ if (autoSendWhenOpen && !resendTimer) {
855
+ sendOtp();
856
+ }
857
+ }, []);
858
+ return (React__default.createElement(React__default.Fragment, null,
859
+ React__default.createElement(Box, { component: "form", onSubmit: (e) => {
860
+ e.preventDefault();
861
+ submitOtp();
862
+ }, className: cx(classes.root, className) },
863
+ React__default.createElement(Heading$1, { tag: "h3", className: classes.heading }, t('lead.otp.title')),
864
+ React__default.createElement(Text, { size: "p1", className: classes.description }, t('lead.otp.desc', { phone: displayPhone })),
865
+ React__default.createElement(Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: "Enter OTP", className: classes.control, label: "Phone OTP", "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
866
+ setIsDirty(true);
867
+ setOtp(v);
868
+ if (isDirty && !v)
869
+ setErrorMsg('OTP is required');
870
+ else
871
+ setErrorMsg(undefined);
872
+ }, error: isDirty ? errorMsg : undefined }),
873
+ React__default.createElement(Button$1, { type: "submit", size: "md", color: "primary", className: classes.submitBtn,
874
+ // onClick={() => submitOtp()}
875
+ disabled: !otp, loading: isSubmitLoading }, t('lead.otp.verify')),
876
+ React__default.createElement(Button$1, { type: "button", size: "md", color: "transparent", className: classes.resendOtp, onClick: () => {
877
+ sendOtp();
878
+ }, disabled: !!resendTimer }, t('lead.otp.resend', {
879
+ timer: resendTimer ? ` (${resendTimer}s)` : '',
880
+ })))));
881
+ };
882
+ const OtpBlock$1 = ({}) => {
883
+ const { showOtpPhone, setShowOtpPhone, onSubmit, formRef, leadFormConfig: { form }, } = useContext(LeadGenComponentContext);
884
+ return showOtpPhone ? (React__default.createElement(OtpBlockComponent, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
885
+ setShowOtpPhone(null);
886
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
887
+ } })) : null;
888
+ };
889
+
890
+ const Thankyou = ({ children, }) => {
891
+ const { showThankyou } = useContext(LeadGenComponentContext);
892
+ return showThankyou ? typeof children(showThankyou) : null;
128
893
  };
129
894
 
130
895
  var enPH = {
@@ -427,165 +1192,6 @@ const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, su
427
1192
  React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
428
1193
  };
429
1194
 
430
- class Store {
431
- constructor() {
432
- this.apiLeadUrl = 'https://dev.leadgen.hellobacsi.com/';
433
- this.apiSubotUrl = 'https://staging-service-subot.hellohealthgroup.com/';
434
- }
435
- }
436
- const leadStore = new Store();
437
-
438
- const leadApi = {
439
- call(_a) {
440
- var { url, data = undefined } = _a, config = __rest(_a, ["url", "data"]);
441
- config.body = JSON.stringify(data);
442
- config.headers = {
443
- 'Content-Type': 'application/json',
444
- };
445
- return fetch(`${leadStore.apiLeadUrl}${url}`, config)
446
- .then((res) => res.json())
447
- .catch(() => ({}));
448
- },
449
- };
450
- const subotApi = {
451
- call(_a) {
452
- var { url, data } = _a, config = __rest(_a, ["url", "data"]);
453
- config.body = JSON.stringify(data);
454
- config.headers = {
455
- 'Content-Type': 'application/json',
456
- };
457
- return fetch(`${leadStore.apiSubotUrl}${url}`, config)
458
- .then((res) => res.json())
459
- .catch(() => ({}));
460
- },
461
- };
462
- const campaignGetById = (id) => {
463
- return leadApi.call({
464
- url: `api/internal/campaign/${id}`,
465
- method: 'get',
466
- });
467
- };
468
- const validateEmailOrPhoneOnLeadGen = ({ campaign_id, email, phone, }) => {
469
- let phoneToSend = phone;
470
- // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
471
- if (phoneToSend && phoneToSend.startsWith('0')) {
472
- phoneToSend = phoneToSend.substring(1);
473
- }
474
- return leadApi.call({
475
- url: 'api/subot-campaign/check',
476
- method: 'post',
477
- data: {
478
- campaign_id,
479
- email,
480
- phone: phoneToSend,
481
- },
482
- });
483
- };
484
- const validateEmailOrPhoneOnSubot = ({ bot_id, email, phone, }) => {
485
- let phoneToSend = phone;
486
- // Remove the '0' part. Logic from Back to check between Subot and Lead with different format
487
- if (phoneToSend && phoneToSend.startsWith('0')) {
488
- phoneToSend = phoneToSend.substring(1);
489
- }
490
- return subotApi.call({
491
- url: 'frontend/api/subot-campaign/check',
492
- method: 'post',
493
- data: {
494
- bot_id,
495
- email,
496
- phone: phoneToSend,
497
- },
498
- });
499
- };
500
- const sendSMSOtpLead = ({ phone, type, }) => {
501
- return leadApi.call({
502
- url: type === 'phone' ? 'api/sms/otp' : 'api/sms/whatsapp_otp',
503
- method: 'post',
504
- data: {
505
- // The type Whatsapp do not remove the '+'
506
- phone_number: type === 'phone' ? phone.replace('+', '') : phone,
507
- },
508
- });
509
- };
510
- const verifyOtpLead = ({ phone, otp, type, }) => {
511
- return leadApi.call({
512
- url: type === 'phone' ? 'api/sms/verify' : 'api/sms/whatsapp_verify',
513
- method: 'post',
514
- data: {
515
- // The type Whatsapp do not remove the '+'
516
- otp_code: otp,
517
- phone_number: type === 'phone' ? phone.replace('+', '') : phone,
518
- },
519
- });
520
- };
521
- const Service = {
522
- campaignGetById,
523
- validateEmailOrPhoneOnSubot,
524
- validateEmailOrPhoneOnLeadGen,
525
- sendSMSOtpLead,
526
- verifyOtpLead,
527
- };
528
-
529
- const checkUsedEmailOrPhone = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
530
- const key = 'email' in data ? 'email' : 'phone';
531
- const value = 'email' in data ? data.email : data.phone;
532
- const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
533
- /** Check on Leadgen Tool */
534
- const resLeadGen = yield Service.validateEmailOrPhoneOnLeadGen({
535
- campaign_id: [campaignId],
536
- [key]: value, // Can be email or phone
537
- });
538
- if (resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_001' ||
539
- resLeadGen._errorCode === 'SubmitLeadWithBotId_ERR_002') {
540
- return errorMsg;
541
- }
542
- /** Check on Subot */
543
- if (campaign_subot_id.length) {
544
- const resSubot = yield Service.validateEmailOrPhoneOnSubot({
545
- bot_id: campaign_subot_id,
546
- [key]: value, // Can be email or phone
547
- });
548
- if (resSubot._errorCode === 'CheckSuBotLeadTool_ERR_001') {
549
- return errorMsg;
550
- }
551
- }
552
- });
553
- const validatedCache = {
554
- email: {},
555
- phone: {},
556
- };
557
- const checkUsedEmailOrPhoneWithCache = (campaignId, campaign_subot_id, data) => __awaiter(void 0, void 0, void 0, function* () {
558
- const key = 'email' in data ? 'email' : 'phone';
559
- const value = 'email' in data ? data.email : data.phone;
560
- const errorMsg = 'email' in data ? 'validator.emailUsed' : 'validator.phoneUsed';
561
- if (validatedCache[key][value]) {
562
- if (validatedCache[key][value].value) {
563
- return errorMsg;
564
- }
565
- else if (!validatedCache[key][value].value &&
566
- validatedCache[key][value].expire > Date.now()) {
567
- return '';
568
- }
569
- }
570
- const res = yield checkUsedEmailOrPhone(campaignId, campaign_subot_id, data);
571
- if (res) {
572
- validatedCache[key][value] = {
573
- value: true,
574
- };
575
- }
576
- else {
577
- validatedCache[key][value] = {
578
- value: false,
579
- expire: Date.now() + 1000 * 60,
580
- };
581
- }
582
- return res;
583
- });
584
- const clearCacheUsedEmailOrPhone = () => {
585
- validatedCache.email = {};
586
- validatedCache.phone = {};
587
- };
588
-
589
1195
  // You can give context variables any name
590
1196
  const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
591
1197
  const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], }) => {
@@ -951,7 +1557,7 @@ const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
951
1557
  e.preventDefault();
952
1558
  submitOtp();
953
1559
  }, className: "lead-phone-otp-form" },
954
- React__default.createElement(Heading, { tag: "h3", fontWeight: "bold", style: { marginBottom: 4 } }, t('lead.otp.title')),
1560
+ React__default.createElement(Heading$1, { tag: "h3", fontWeight: "bold", style: { marginBottom: 4 } }, t('lead.otp.title')),
955
1561
  React__default.createElement(Text, { size: "p1", color: theme.colors.gray600 }, t('lead.otp.desc', { phone: displayPhone })),
956
1562
  React__default.createElement(Input, { ref: inputRef, name: '_' + name + '-otp', spellCheck: false, type: "number", placeholder: "Enter OTP", className: "lead-modal__form-control", label: "Phone OTP", "data-control": "otp", withAsterisk: true, pattern: "[0-9]*", value: otp, maxLength: 6, onChange: (v) => {
957
1563
  setIsDirty(true);
@@ -1867,7 +2473,7 @@ const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, local
1867
2473
  };
1868
2474
 
1869
2475
  // mount css
1870
- const LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, }) => {
2476
+ const _LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, children, }) => {
1871
2477
  var _a;
1872
2478
  const scrollEventHandlerRef = useRef();
1873
2479
  const leadStartTimeRef = useRef(Date.now());
@@ -2124,17 +2730,23 @@ const LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl,
2124
2730
  React__default.createElement(TranslationsContext.Provider, { value: {
2125
2731
  locale,
2126
2732
  values: getTranslations(locale),
2127
- } },
2128
- React__default.createElement(Portal, { target: getPopupWrapperDom() },
2129
- React__default.createElement(Box, { sx: { position: 'fixed', zIndex: 9999999999 } },
2130
- 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) => {
2131
- var _a;
2132
- return (React__default.createElement(Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default.createElement(React__default.Fragment, null,
2133
- !!showCampaign.extra_fields.currentLayout &&
2134
- !showCampaign.extra_fields.currentLayout.includes('Inline') &&
2135
- !showCampaign.extra_fields.currentLayout.includes('Sidebar') && (React__default.createElement(Overlay, { color: "#000", opacity: 0.5, center: true, zIndex: 400, pos: 'fixed', onClick: () => onClose() })),
2136
- React__default.createElement(NewLeadPopup, { campaign: showCampaign, action: action, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale })))));
2137
- }))))));
2138
- };
2733
+ } }, children ? (React__default.createElement(Component, { campaign: showCampaign, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale }, children)) : (React__default.createElement(Portal, { target: getPopupWrapperDom() },
2734
+ React__default.createElement(Box, { sx: { position: 'fixed', zIndex: 9999999999 } },
2735
+ 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) => {
2736
+ var _a;
2737
+ return (React__default.createElement(Box, { style: styles }, ((_a = showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields) === null || _a === void 0 ? void 0 : _a.popupVersion) === '2.1' && (React__default.createElement(React__default.Fragment, null,
2738
+ !!showCampaign.extra_fields.currentLayout &&
2739
+ !showCampaign.extra_fields.currentLayout.includes('Inline') &&
2740
+ !showCampaign.extra_fields.currentLayout.includes('Sidebar') && (React__default.createElement(Overlay, { color: "#000", opacity: 0.5, center: true, zIndex: 400, pos: 'fixed', onClick: () => onClose() })),
2741
+ React__default.createElement(NewLeadPopup, { campaign: showCampaign, action: action, onSubmit: onSubmit, onClose: onClose, showThankyou: showThankyou, locale: locale })))));
2742
+ })))))));
2743
+ };
2744
+ const LeadGen = _LeadGen;
2745
+ LeadGen.Heading = Heading;
2746
+ LeadGen.Description = Description;
2747
+ LeadGen.Form = Form;
2748
+ LeadGen.Thankyou = Thankyou;
2749
+ LeadGen.OtpForm = OtpBlock$1;
2750
+ LeadGen.Close = Close;
2139
2751
 
2140
2752
  export { LeadGen };