@hhgtech/hhg-components 1.28.67 → 1.28.69
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.
- package/build/BMI_BOYS.percentile.monthly-48c9471d.js +688 -0
- package/build/BMI_BOYS.percentile.weekly-4965852e.js +182 -0
- package/build/BMI_BOYS.percentile.yearly-0f7cc8f4.js +83 -0
- package/build/BMI_BOYS.zscore.monthly-5bb8a433.js +440 -0
- package/build/BMI_BOYS.zscore.weekly-3d56f80f.js +118 -0
- package/build/BMI_BOYS.zscore.yearly-57081f24.js +55 -0
- package/build/BMI_GIRLS.percentile.monthly-95859cd9.js +688 -0
- package/build/BMI_GIRLS.percentile.weekly-009cf4df.js +182 -0
- package/build/BMI_GIRLS.percentile.yearly-4436947b.js +83 -0
- package/build/BMI_GIRLS.zscore.monthly-689b4eee.js +440 -0
- package/build/BMI_GIRLS.zscore.weekly-dff693df.js +118 -0
- package/build/BMI_GIRLS.zscore.yearly-05ef5f4f.js +55 -0
- package/build/ChevronDown-275f1ab5.js +29 -0
- package/build/HEAD CIRCUM_BOYS.percentile.monthly-55c580a7.js +688 -0
- package/build/HEAD CIRCUM_BOYS.percentile.weekly-e30f4a42.js +182 -0
- package/build/HEAD CIRCUM_BOYS.percentile.yearly-2378a5f0.js +83 -0
- package/build/HEAD CIRCUM_BOYS.zscore.monthly-102d5559.js +440 -0
- package/build/HEAD CIRCUM_BOYS.zscore.weekly-7b0f1ba8.js +118 -0
- package/build/HEAD CIRCUM_BOYS.zscore.yearly-e9237d31.js +55 -0
- package/build/HEAD CIRCUM_GIRLS.percentile.monthly-1ddda8b3.js +688 -0
- package/build/HEAD CIRCUM_GIRLS.percentile.weekly-843147ea.js +182 -0
- package/build/HEAD CIRCUM_GIRLS.percentile.yearly-9b51c237.js +83 -0
- package/build/HEAD CIRCUM_GIRLS.zscore.monthly-3f1b233c.js +440 -0
- package/build/HEAD CIRCUM_GIRLS.zscore.weekly-9e14d3fe.js +118 -0
- package/build/HEAD CIRCUM_GIRLS.zscore.yearly-d924f5ae.js +55 -0
- package/build/HEIGHT_BOYS.percentile.monthly-15538920.js +688 -0
- package/build/HEIGHT_BOYS.percentile.weekly-10bd0277.js +182 -0
- package/build/HEIGHT_BOYS.percentile.yearly-8e678d38.js +237 -0
- package/build/HEIGHT_BOYS.zscore.monthly-2c110da9.js +440 -0
- package/build/HEIGHT_BOYS.zscore.weekly-288b7733.js +118 -0
- package/build/HEIGHT_BOYS.zscore.yearly-42f6f9f7.js +153 -0
- package/build/HEIGHT_GIRLS.percentile.monthly-04abe7d2.js +688 -0
- package/build/HEIGHT_GIRLS.percentile.weekly-9653b16c.js +182 -0
- package/build/HEIGHT_GIRLS.percentile.yearly-9efacd67.js +237 -0
- package/build/HEIGHT_GIRLS.zscore.monthly-c64a97b2.js +440 -0
- package/build/HEIGHT_GIRLS.zscore.weekly-3302dd83.js +118 -0
- package/build/HEIGHT_GIRLS.zscore.yearly-ebe5114f.js +153 -0
- package/build/Subot-5fc40fb5.js +217 -0
- package/build/Visible-5c5d57cf.js +29 -0
- package/build/WEIGHT_BOYS.percentile.monthly-5e11e7a0.js +688 -0
- package/build/WEIGHT_BOYS.percentile.weekly-68ae2578.js +182 -0
- package/build/WEIGHT_BOYS.percentile.yearly-030c06a4.js +138 -0
- package/build/WEIGHT_BOYS.zscore.monthly-d22c7b57.js +440 -0
- package/build/WEIGHT_BOYS.zscore.weekly-d8d901e6.js +118 -0
- package/build/WEIGHT_BOYS.zscore.yearly-c311a084.js +90 -0
- package/build/WEIGHT_GIRLS.percentile.monthly-5c44f8eb.js +688 -0
- package/build/WEIGHT_GIRLS.percentile.weekly-faa98671.js +182 -0
- package/build/WEIGHT_GIRLS.percentile.yearly-560b862e.js +138 -0
- package/build/WEIGHT_GIRLS.zscore.monthly-5365ba1a.js +440 -0
- package/build/WEIGHT_GIRLS.zscore.weekly-0d9dc521.js +118 -0
- package/build/WEIGHT_GIRLS.zscore.yearly-5a3c4e43.js +90 -0
- package/build/adapters.js +36 -1
- package/build/{esm/animation-0340efb3.js → animation-eb4e500b.js} +32 -10
- package/build/babyGrowth.js +913 -47
- package/build/cache.js +13 -1
- package/build/care.js +38 -1
- package/build/components/navigationV2/hooks/useNavConfig.d.ts +1 -3
- package/build/components.js +186 -1
- package/build/constants-8b8bc19f.js +255 -0
- package/build/constants-ae18ce18.js +935 -0
- package/build/constants.js +43 -1
- package/build/cookieHelper-5c9f4bb8.js +43 -0
- package/build/core-2aa8d86c.js +51 -0
- package/build/dataTransform-089f414c.js +66 -0
- package/build/ecom.js +745 -1
- package/build/esm/BMI_BOYS.percentile.monthly-de5dce68.js +686 -0
- package/build/esm/BMI_BOYS.percentile.weekly-9d3990b6.js +180 -0
- package/build/esm/BMI_BOYS.percentile.yearly-98b9114a.js +81 -0
- package/build/esm/BMI_BOYS.zscore.monthly-394646f0.js +438 -0
- package/build/esm/BMI_BOYS.zscore.weekly-c669ea51.js +116 -0
- package/build/esm/BMI_BOYS.zscore.yearly-771ef6b6.js +53 -0
- package/build/esm/BMI_GIRLS.percentile.monthly-1ff3d499.js +686 -0
- package/build/esm/BMI_GIRLS.percentile.weekly-211d2f27.js +180 -0
- package/build/esm/BMI_GIRLS.percentile.yearly-206fdcff.js +81 -0
- package/build/esm/BMI_GIRLS.zscore.monthly-b1137e36.js +438 -0
- package/build/esm/BMI_GIRLS.zscore.weekly-63ed3cd6.js +116 -0
- package/build/esm/BMI_GIRLS.zscore.yearly-221d187c.js +53 -0
- package/build/esm/ChevronDown-9a8ece61.js +7 -0
- package/build/esm/HEAD CIRCUM_BOYS.percentile.monthly-4c37847c.js +686 -0
- package/build/esm/HEAD CIRCUM_BOYS.percentile.weekly-8f6ea38a.js +180 -0
- package/build/esm/HEAD CIRCUM_BOYS.percentile.yearly-6c12a99a.js +81 -0
- package/build/esm/HEAD CIRCUM_BOYS.zscore.monthly-c531b497.js +438 -0
- package/build/esm/HEAD CIRCUM_BOYS.zscore.weekly-6cafba00.js +116 -0
- package/build/esm/HEAD CIRCUM_BOYS.zscore.yearly-fe8114a0.js +53 -0
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.monthly-25ce0d36.js +686 -0
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.weekly-5d3f2862.js +180 -0
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.yearly-2b709ca5.js +81 -0
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.monthly-e8617bae.js +438 -0
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.weekly-f3252d67.js +116 -0
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.yearly-5b62d41f.js +53 -0
- package/build/esm/HEIGHT_BOYS.percentile.monthly-63d2cf96.js +686 -0
- package/build/esm/HEIGHT_BOYS.percentile.weekly-8ea5102d.js +180 -0
- package/build/esm/HEIGHT_BOYS.percentile.yearly-8107b77b.js +235 -0
- package/build/esm/HEIGHT_BOYS.zscore.monthly-641cdfa3.js +438 -0
- package/build/esm/HEIGHT_BOYS.zscore.weekly-86da0362.js +116 -0
- package/build/esm/HEIGHT_BOYS.zscore.yearly-060f6e79.js +151 -0
- package/build/esm/HEIGHT_GIRLS.percentile.monthly-fb987d37.js +686 -0
- package/build/esm/HEIGHT_GIRLS.percentile.weekly-82655dc0.js +180 -0
- package/build/esm/HEIGHT_GIRLS.percentile.yearly-a63b8456.js +235 -0
- package/build/esm/HEIGHT_GIRLS.zscore.monthly-77d676a3.js +438 -0
- package/build/esm/HEIGHT_GIRLS.zscore.weekly-c0387a4e.js +116 -0
- package/build/esm/HEIGHT_GIRLS.zscore.yearly-41203c20.js +151 -0
- package/build/esm/Subot-3289bd8e.js +212 -0
- package/build/esm/Visible-a3d436dd.js +7 -0
- package/build/esm/WEIGHT_BOYS.percentile.monthly-50802d8b.js +686 -0
- package/build/esm/WEIGHT_BOYS.percentile.weekly-4d72ddd6.js +180 -0
- package/build/esm/WEIGHT_BOYS.percentile.yearly-20a29844.js +136 -0
- package/build/esm/WEIGHT_BOYS.zscore.monthly-729e6614.js +438 -0
- package/build/esm/WEIGHT_BOYS.zscore.weekly-90352f48.js +116 -0
- package/build/esm/WEIGHT_BOYS.zscore.yearly-fe1871cc.js +88 -0
- package/build/esm/WEIGHT_GIRLS.percentile.monthly-e6afb2e0.js +686 -0
- package/build/esm/WEIGHT_GIRLS.percentile.weekly-b66d3016.js +180 -0
- package/build/esm/WEIGHT_GIRLS.percentile.yearly-a55622c5.js +136 -0
- package/build/esm/WEIGHT_GIRLS.zscore.monthly-2cdcbe75.js +438 -0
- package/build/esm/WEIGHT_GIRLS.zscore.weekly-d5be31d5.js +116 -0
- package/build/esm/WEIGHT_GIRLS.zscore.yearly-99e8d3a7.js +88 -0
- package/build/esm/adapters.js +26 -1
- package/build/{animation-d5d9ef32.js → esm/animation-3d5edc39.js} +22 -10
- package/build/esm/babyGrowth.js +883 -47
- package/build/esm/cache.js +3 -1
- package/build/esm/care.js +26 -1
- package/build/esm/components/navigationV2/hooks/useNavConfig.d.ts +1 -3
- package/build/esm/components.js +88 -1
- package/build/esm/constants-2a6d2434.js +932 -0
- package/build/esm/constants-b77ffe3d.js +238 -0
- package/build/esm/constants.js +4 -1
- package/build/esm/cookieHelper-d314282c.js +39 -0
- package/build/esm/core-8c73d133.js +47 -0
- package/build/esm/dataTransform-8ecfc046.js +56 -0
- package/build/esm/ecom.js +737 -1
- package/build/esm/footer.js +31 -1
- package/build/esm/gAssets.js +5 -1
- package/build/esm/getDynamicHealthTool-f4497aa5.js +44 -0
- package/build/esm/getSocialList-a5b8462e.js +66 -0
- package/build/esm/hooks.js +21 -1
- package/build/esm/i18n-values/en-PH.js +600 -1
- package/build/esm/i18n-values/hi-IN.js +600 -1
- package/build/esm/i18n-values/id-ID.js +600 -1
- package/build/esm/i18n-values/km-KH.js +600 -1
- package/build/esm/i18n-values/ms-MY.js +602 -1
- package/build/esm/i18n-values/my-MM.js +600 -1
- package/build/esm/i18n-values/th-TH.js +600 -1
- package/build/esm/i18n-values/tl-PH.js +600 -1
- package/build/esm/i18n-values/vi-VN.js +607 -1
- package/build/esm/i18n-values/vi-VN_MB.js +607 -1
- package/build/esm/i18n-values/zh-TW.js +600 -1
- package/build/esm/i18n.js +55 -1
- package/build/esm/i18nV2.js +18 -1
- package/build/esm/index-12fa4985.js +8 -0
- package/build/esm/index-1e59f99a.js +152 -0
- package/build/esm/index-32e53dac.js +1936 -0
- package/build/esm/index-3474401a.js +149 -0
- package/build/esm/index-34899aa3.js +17 -0
- package/build/esm/index-350e8f5b.js +124 -0
- package/build/esm/index-41bf860a.js +151 -0
- package/build/esm/index-4aa8e518.js +116 -0
- package/build/esm/index-4fe2b03f.js +32 -0
- package/build/esm/index-6ea6484e.js +29 -0
- package/build/esm/index-717401ee.js +184 -0
- package/build/esm/index-7af5242a.js +24 -0
- package/build/esm/index-7b8c85cd.js +8302 -0
- package/build/esm/index-81f295b7.js +23 -0
- package/build/esm/index-8858383e.js +52 -0
- package/build/esm/index-8f52dcf3.js +33 -0
- package/build/esm/index-9ea7e838.js +33 -0
- package/build/esm/index-aabac2aa.js +3241 -0
- package/build/esm/index-b9b2c417.js +837 -0
- package/build/esm/index-c2da5293.js +12 -0
- package/build/esm/index-c56d60db.js +370 -0
- package/build/esm/index-c5d7f692.js +24 -0
- package/build/esm/index-cc93e010.js +53 -0
- package/build/esm/index-d7f046db.js +5 -0
- package/build/esm/index-d8177667.js +14 -0
- package/build/esm/index-da139dda.js +615 -0
- package/build/esm/index-e612be9c.js +905 -0
- package/build/esm/index-f3d0592b.js +71 -0
- package/build/esm/index.js +190 -1
- package/build/{index.styled-0a1fb891.js → esm/index.styled-9c9db9cc.js} +17 -5
- package/build/esm/index.styles-5add27c5.js +1303 -0
- package/build/esm/isProduction-0ea904dd.js +27 -0
- package/build/esm/lead.js +2140 -1
- package/build/esm/localizeNumberFormat-2ac3773e.js +23 -0
- package/build/esm/mantine.js +113 -1
- package/build/esm/misc.js +22 -1
- package/build/esm/navigation.js +51 -1
- package/build/esm/normalizeLink-d1c9617e.js +12 -0
- package/build/esm/number-0c126a39.js +38 -0
- package/build/esm/onboardingV2.js +860 -34
- package/build/esm/paths-a8204db4.js +14 -0
- package/build/esm/pwg.js +208 -7
- package/build/esm/routing-2474f896.js +40 -0
- package/build/esm/subot.js +4553 -134
- package/build/esm/theme-e74db08c.js +186 -0
- package/build/esm/together.js +52 -1
- package/build/esm/translationsContext-ad3e25de.js +5 -0
- package/build/esm/tslib.es6-1b1533a9.js +38 -0
- package/build/esm/types-06f00b3d.js +8015 -0
- package/build/esm/types-15e34418.js +3432 -0
- package/build/esm/types-ba190c26.js +21 -0
- package/build/esm/types.js +1 -1
- package/build/esm/unifyEnv.js +42 -1
- package/build/esm/useCategory-2c87152d.js +292 -0
- package/build/esm/useHealthToolCache-29d22ddb.js +17 -0
- package/build/esm/useIsInit-8a2fc8e5.js +11 -0
- package/build/esm/useOutsideClick-c8a7ff20.js +45 -0
- package/build/esm/usePlacesAutocomplete-63e04e8e.js +80 -0
- package/build/esm/useScrollbarSize-51ce1374.js +57 -0
- package/build/esm/useTranslations-4f1db486.js +26 -0
- package/build/esm/useUniqueId-3638402f.js +41 -0
- package/build/esm/utils-2c484c05.js +132 -0
- package/build/esm/utils-3a2a47d9.js +22 -0
- package/build/esm/utils-6d7b88da.js +367 -0
- package/build/esm/utils-70718e9c.js +1124 -0
- package/build/esm/vaccination.js +868 -40
- package/build/footer.js +39 -1
- package/build/gAssets.js +14 -1
- package/build/getDynamicHealthTool-114a1e27.js +48 -0
- package/build/getSocialList-4713441d.js +72 -0
- package/build/hooks.js +44 -1
- package/build/i18n-values/en-PH.js +611 -1
- package/build/i18n-values/hi-IN.js +611 -1
- package/build/i18n-values/id-ID.js +611 -1
- package/build/i18n-values/km-KH.js +611 -1
- package/build/i18n-values/ms-MY.js +613 -1
- package/build/i18n-values/my-MM.js +611 -1
- package/build/i18n-values/th-TH.js +611 -1
- package/build/i18n-values/tl-PH.js +611 -1
- package/build/i18n-values/vi-VN.js +618 -1
- package/build/i18n-values/vi-VN_MB.js +618 -1
- package/build/i18n-values/zh-TW.js +611 -1
- package/build/i18n.js +64 -1
- package/build/i18nV2.js +26 -1
- package/build/index-020e6908.js +39 -0
- package/build/index-0da9b2e8.js +59 -0
- package/build/index-11468c00.js +157 -0
- package/build/index-117448a5.js +133 -0
- package/build/index-12c07f71.js +18 -0
- package/build/index-1a105e87.js +123 -0
- package/build/index-1baaedb0.js +55 -0
- package/build/index-32d38318.js +7 -0
- package/build/index-38582ee0.js +8373 -0
- package/build/index-3e5fc2d6.js +1994 -0
- package/build/index-3eef6bed.js +853 -0
- package/build/index-4035e658.js +159 -0
- package/build/index-488d71ae.js +30 -0
- package/build/index-5553f9e1.js +930 -0
- package/build/index-5fa68e45.js +380 -0
- package/build/index-7b467209.js +39 -0
- package/build/index-81cb1142.js +77 -0
- package/build/index-84ab5b89.js +38 -0
- package/build/index-8a95d709.js +30 -0
- package/build/index-9da9f0c3.js +35 -0
- package/build/index-af91c83e.js +20 -0
- package/build/index-b6aea85e.js +191 -0
- package/build/index-bc4f4c33.js +156 -0
- package/build/index-c604d6bb.js +624 -0
- package/build/index-d330735e.js +30 -0
- package/build/index-d8a7efaf.js +14 -0
- package/build/index-e2e81fa2.js +23 -0
- package/build/index-e3d896b3.js +3261 -0
- package/build/index.js +436 -1
- package/build/{esm/index.styled-14b65c9e.js → index.styled-5628b3e7.js} +25 -5
- package/build/index.styles-b822bf42.js +1342 -0
- package/build/isProduction-5ce3a388.js +29 -0
- package/build/lead.js +2168 -1
- package/build/localizeNumberFormat-f5f50987.js +31 -0
- package/build/mantine.js +154 -1
- package/build/misc.js +70 -1
- package/build/navigation.js +61 -1
- package/build/normalizeLink-6f7b85d8.js +15 -0
- package/build/number-79fe92e1.js +40 -0
- package/build/onboardingV2.js +892 -34
- package/build/paths-a5643d9e.js +16 -0
- package/build/pwg.js +217 -7
- package/build/routing-191a9a00.js +46 -0
- package/build/subot.js +4592 -134
- package/build/theme-fa910869.js +189 -0
- package/build/together.js +112 -1
- package/build/translationsContext-950334bf.js +7 -0
- package/build/tslib.es6-65e312a5.js +41 -0
- package/build/types-0f117a9f.js +8084 -0
- package/build/types-1fedb3d1.js +3446 -0
- package/build/types-52a4e888.js +24 -0
- package/build/types.js +56 -1
- package/build/unifyEnv.js +46 -1
- package/build/useCategory-cfc702f5.js +299 -0
- package/build/useHealthToolCache-43a7014d.js +19 -0
- package/build/useIsInit-89535012.js +13 -0
- package/build/useOutsideClick-c6813964.js +49 -0
- package/build/usePlacesAutocomplete-297de092.js +84 -0
- package/build/useScrollbarSize-0fa31aa7.js +64 -0
- package/build/useTranslations-e1853417.js +32 -0
- package/build/useUniqueId-11369116.js +44 -0
- package/build/utils-52113753.js +384 -0
- package/build/utils-64bd0c42.js +143 -0
- package/build/utils-661411f6.js +1171 -0
- package/build/utils-e1513cbc.js +25 -0
- package/build/vaccination.js +891 -40
- package/package.json +4 -5
- package/build/BMI_BOYS.percentile.monthly-c56b0165.js +0 -1
- package/build/BMI_BOYS.percentile.weekly-64287e04.js +0 -1
- package/build/BMI_BOYS.percentile.yearly-8db65d54.js +0 -1
- package/build/BMI_BOYS.zscore.monthly-f12389cd.js +0 -1
- package/build/BMI_BOYS.zscore.weekly-fff37a57.js +0 -1
- package/build/BMI_BOYS.zscore.yearly-a19b57eb.js +0 -1
- package/build/BMI_GIRLS.percentile.monthly-a4b36d7d.js +0 -1
- package/build/BMI_GIRLS.percentile.weekly-b6089202.js +0 -1
- package/build/BMI_GIRLS.percentile.yearly-0d340818.js +0 -1
- package/build/BMI_GIRLS.zscore.monthly-fd5b57c0.js +0 -1
- package/build/BMI_GIRLS.zscore.weekly-d4577f50.js +0 -1
- package/build/BMI_GIRLS.zscore.yearly-e40b8a7d.js +0 -1
- package/build/ChevronDown-602ce39e.js +0 -1
- package/build/HEAD CIRCUM_BOYS.percentile.monthly-2e4c5776.js +0 -1
- package/build/HEAD CIRCUM_BOYS.percentile.weekly-fc5728a5.js +0 -1
- package/build/HEAD CIRCUM_BOYS.percentile.yearly-6bfab277.js +0 -1
- package/build/HEAD CIRCUM_BOYS.zscore.monthly-6af7ce44.js +0 -1
- package/build/HEAD CIRCUM_BOYS.zscore.weekly-9adb819b.js +0 -1
- package/build/HEAD CIRCUM_BOYS.zscore.yearly-9a6cdbcf.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.percentile.monthly-e7bfe9c6.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.percentile.weekly-9f17e019.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.percentile.yearly-8a59f541.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.zscore.monthly-b7ddb16c.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.zscore.weekly-72701c55.js +0 -1
- package/build/HEAD CIRCUM_GIRLS.zscore.yearly-dd94bded.js +0 -1
- package/build/HEIGHT_BOYS.percentile.monthly-b890068c.js +0 -1
- package/build/HEIGHT_BOYS.percentile.weekly-a1aa5130.js +0 -1
- package/build/HEIGHT_BOYS.percentile.yearly-5727d920.js +0 -1
- package/build/HEIGHT_BOYS.zscore.monthly-13b70aa6.js +0 -1
- package/build/HEIGHT_BOYS.zscore.weekly-3e1d7f23.js +0 -1
- package/build/HEIGHT_BOYS.zscore.yearly-a956102d.js +0 -1
- package/build/HEIGHT_GIRLS.percentile.monthly-da5ec01b.js +0 -1
- package/build/HEIGHT_GIRLS.percentile.weekly-e6205d32.js +0 -1
- package/build/HEIGHT_GIRLS.percentile.yearly-caefa502.js +0 -1
- package/build/HEIGHT_GIRLS.zscore.monthly-102ba473.js +0 -1
- package/build/HEIGHT_GIRLS.zscore.weekly-db4f710b.js +0 -1
- package/build/HEIGHT_GIRLS.zscore.yearly-36465920.js +0 -1
- package/build/Subot-4751194d.js +0 -1
- package/build/Visible-9497c463.js +0 -1
- package/build/WEIGHT_BOYS.percentile.monthly-554d0361.js +0 -1
- package/build/WEIGHT_BOYS.percentile.weekly-8e5334b8.js +0 -1
- package/build/WEIGHT_BOYS.percentile.yearly-536e1ccb.js +0 -1
- package/build/WEIGHT_BOYS.zscore.monthly-01eccee1.js +0 -1
- package/build/WEIGHT_BOYS.zscore.weekly-ee8f2c6b.js +0 -1
- package/build/WEIGHT_BOYS.zscore.yearly-0aea2749.js +0 -1
- package/build/WEIGHT_GIRLS.percentile.monthly-7abf9d06.js +0 -1
- package/build/WEIGHT_GIRLS.percentile.weekly-f9b6e963.js +0 -1
- package/build/WEIGHT_GIRLS.percentile.yearly-254865a5.js +0 -1
- package/build/WEIGHT_GIRLS.zscore.monthly-909f7417.js +0 -1
- package/build/WEIGHT_GIRLS.zscore.weekly-e62cd084.js +0 -1
- package/build/WEIGHT_GIRLS.zscore.yearly-8d6e5405.js +0 -1
- package/build/constants-00e06f68.js +0 -108
- package/build/constants-51251306.js +0 -1
- package/build/cookieHelper-7d519a72.js +0 -1
- package/build/core-ba3af3e2.js +0 -1
- package/build/dataTransform-1805eae3.js +0 -1
- package/build/esm/BMI_BOYS.percentile.monthly-6272f835.js +0 -1
- package/build/esm/BMI_BOYS.percentile.weekly-80d18f47.js +0 -1
- package/build/esm/BMI_BOYS.percentile.yearly-a7e5b5f6.js +0 -1
- package/build/esm/BMI_BOYS.zscore.monthly-d3658f97.js +0 -1
- package/build/esm/BMI_BOYS.zscore.weekly-6e6708dc.js +0 -1
- package/build/esm/BMI_BOYS.zscore.yearly-b8400c9d.js +0 -1
- package/build/esm/BMI_GIRLS.percentile.monthly-98586b46.js +0 -1
- package/build/esm/BMI_GIRLS.percentile.weekly-7c1511b0.js +0 -1
- package/build/esm/BMI_GIRLS.percentile.yearly-ea667f90.js +0 -1
- package/build/esm/BMI_GIRLS.zscore.monthly-3a4fd1a6.js +0 -1
- package/build/esm/BMI_GIRLS.zscore.weekly-cc1de097.js +0 -1
- package/build/esm/BMI_GIRLS.zscore.yearly-6dd1a364.js +0 -1
- package/build/esm/ChevronDown-4e59cac6.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.percentile.monthly-bd0965ae.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.percentile.weekly-db1053f7.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.percentile.yearly-cd38b622.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.zscore.monthly-d7f88a95.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.zscore.weekly-76f7db79.js +0 -1
- package/build/esm/HEAD CIRCUM_BOYS.zscore.yearly-3ce70f8e.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.monthly-b2e678ae.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.weekly-8e2664bb.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.percentile.yearly-f5c075a9.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.monthly-6f87849e.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.weekly-48da0aaa.js +0 -1
- package/build/esm/HEAD CIRCUM_GIRLS.zscore.yearly-4eea437b.js +0 -1
- package/build/esm/HEIGHT_BOYS.percentile.monthly-d1a8cc8e.js +0 -1
- package/build/esm/HEIGHT_BOYS.percentile.weekly-2b6cfe6c.js +0 -1
- package/build/esm/HEIGHT_BOYS.percentile.yearly-9e78afc3.js +0 -1
- package/build/esm/HEIGHT_BOYS.zscore.monthly-5292d78a.js +0 -1
- package/build/esm/HEIGHT_BOYS.zscore.weekly-fbdee645.js +0 -1
- package/build/esm/HEIGHT_BOYS.zscore.yearly-c11a8f1b.js +0 -1
- package/build/esm/HEIGHT_GIRLS.percentile.monthly-8e11e2dc.js +0 -1
- package/build/esm/HEIGHT_GIRLS.percentile.weekly-dc3965cb.js +0 -1
- package/build/esm/HEIGHT_GIRLS.percentile.yearly-490f7b4e.js +0 -1
- package/build/esm/HEIGHT_GIRLS.zscore.monthly-e3531c32.js +0 -1
- package/build/esm/HEIGHT_GIRLS.zscore.weekly-36a16a66.js +0 -1
- package/build/esm/HEIGHT_GIRLS.zscore.yearly-61736bba.js +0 -1
- package/build/esm/Subot-4642c5bf.js +0 -1
- package/build/esm/Visible-ff7d225c.js +0 -1
- package/build/esm/WEIGHT_BOYS.percentile.monthly-0cfe7ecd.js +0 -1
- package/build/esm/WEIGHT_BOYS.percentile.weekly-89802113.js +0 -1
- package/build/esm/WEIGHT_BOYS.percentile.yearly-0eb40972.js +0 -1
- package/build/esm/WEIGHT_BOYS.zscore.monthly-7f8c5a15.js +0 -1
- package/build/esm/WEIGHT_BOYS.zscore.weekly-3dcfa8ce.js +0 -1
- package/build/esm/WEIGHT_BOYS.zscore.yearly-98ce1ea0.js +0 -1
- package/build/esm/WEIGHT_GIRLS.percentile.monthly-df98e335.js +0 -1
- package/build/esm/WEIGHT_GIRLS.percentile.weekly-63fff42a.js +0 -1
- package/build/esm/WEIGHT_GIRLS.percentile.yearly-8db8cdd0.js +0 -1
- package/build/esm/WEIGHT_GIRLS.zscore.monthly-15c83c6d.js +0 -1
- package/build/esm/WEIGHT_GIRLS.zscore.weekly-747a55ec.js +0 -1
- package/build/esm/WEIGHT_GIRLS.zscore.yearly-197dc52d.js +0 -1
- package/build/esm/constants-6ecfa77c.js +0 -1
- package/build/esm/constants-f7c80032.js +0 -108
- package/build/esm/cookieHelper-4f089e3c.js +0 -1
- package/build/esm/core-80112758.js +0 -1
- package/build/esm/dataTransform-0fa341bb.js +0 -1
- package/build/esm/getDynamicHealthTool-a4c9d6dd.js +0 -1
- package/build/esm/getSocialList-4e48deba.js +0 -1
- package/build/esm/index-13dc1f44.js +0 -1
- package/build/esm/index-13e62563.js +0 -137
- package/build/esm/index-1e7ad007.js +0 -1
- package/build/esm/index-24557f2b.js +0 -1
- package/build/esm/index-252cb964.js +0 -1
- package/build/esm/index-2e99f941.js +0 -1
- package/build/esm/index-3452fed2.js +0 -1
- package/build/esm/index-3aff939b.js +0 -1
- package/build/esm/index-459e0362.js +0 -1
- package/build/esm/index-45dcd965.js +0 -1
- package/build/esm/index-486b71cd.js +0 -1
- package/build/esm/index-5408f5a4.js +0 -113
- package/build/esm/index-5e1af23a.js +0 -1
- package/build/esm/index-79ef3a30.js +0 -1
- package/build/esm/index-7c77273a.js +0 -1
- package/build/esm/index-823fd7c0.js +0 -117
- package/build/esm/index-8c77d7e0.js +0 -1
- package/build/esm/index-93e5b4f3.js +0 -1
- package/build/esm/index-9c7b9011.js +0 -2748
- package/build/esm/index-9e5956c2.js +0 -1
- package/build/esm/index-a83aad1c.js +0 -375
- package/build/esm/index-b7cc3ca2.js +0 -1
- package/build/esm/index-bf11f9e9.js +0 -50
- package/build/esm/index-ce3d38fd.js +0 -1
- package/build/esm/index-d27a0e25.js +0 -1
- package/build/esm/index-e21276e3.js +0 -1
- package/build/esm/index-f9514788.js +0 -177
- package/build/esm/index-fd04ccb7.js +0 -1430
- package/build/esm/index.styles-94af560f.js +0 -817
- package/build/esm/isProduction-00695d80.js +0 -1
- package/build/esm/localizeNumberFormat-8355a44f.js +0 -1
- package/build/esm/normalizeLink-1c194268.js +0 -1
- package/build/esm/number-1347eb7b.js +0 -1
- package/build/esm/paths-749b4b53.js +0 -1
- package/build/esm/routing-2b284b30.js +0 -1
- package/build/esm/theme-3db3c9a8.js +0 -1
- package/build/esm/translationsContext-6d2efd65.js +0 -1
- package/build/esm/tslib.es6-266309d1.js +0 -1
- package/build/esm/types-6d397125.js +0 -3004
- package/build/esm/types-850814a7.js +0 -785
- package/build/esm/types-d3da37d2.js +0 -1
- package/build/esm/useCategory-f5f74749.js +0 -1
- package/build/esm/useHealthToolCache-f1488032.js +0 -1
- package/build/esm/useIsInit-9661c5f5.js +0 -1
- package/build/esm/useOutsideClick-0704b383.js +0 -1
- package/build/esm/usePlacesAutocomplete-0733ec49.js +0 -1
- package/build/esm/useScrollbarSize-90b179a5.js +0 -1
- package/build/esm/useTranslations-df1b3bb8.js +0 -1
- package/build/esm/useUniqueId-03fbaecd.js +0 -1
- package/build/esm/utils-3d2e3f0f.js +0 -141
- package/build/esm/utils-5b4e60da.js +0 -1
- package/build/esm/utils-970ce0c0.js +0 -8
- package/build/esm/utils-b87ec473.js +0 -1
- package/build/getDynamicHealthTool-31f44ca1.js +0 -1
- package/build/getSocialList-29c0a6e8.js +0 -1
- package/build/index-1714c81c.js +0 -2748
- package/build/index-238813a4.js +0 -375
- package/build/index-2438163d.js +0 -1430
- package/build/index-29d302f4.js +0 -137
- package/build/index-3184ae4e.js +0 -1
- package/build/index-34b6bd24.js +0 -1
- package/build/index-35192783.js +0 -1
- package/build/index-41d684a8.js +0 -50
- package/build/index-4a8c8ce6.js +0 -1
- package/build/index-58e0d49f.js +0 -1
- package/build/index-64d2f812.js +0 -1
- package/build/index-85c621a2.js +0 -113
- package/build/index-90f4bc02.js +0 -1
- package/build/index-9a845847.js +0 -117
- package/build/index-9ed509d1.js +0 -1
- package/build/index-aa495d24.js +0 -1
- package/build/index-ad5cf64d.js +0 -1
- package/build/index-b21a1d96.js +0 -1
- package/build/index-b320255d.js +0 -1
- package/build/index-b9af15da.js +0 -1
- package/build/index-bd4b31bf.js +0 -1
- package/build/index-bf81cb71.js +0 -1
- package/build/index-c3cbb8f3.js +0 -1
- package/build/index-d25afe2f.js +0 -1
- package/build/index-e7c1ff53.js +0 -177
- package/build/index-ed8656f9.js +0 -1
- package/build/index-f6217f73.js +0 -1
- package/build/index-f7088d57.js +0 -1
- package/build/index.styles-2ecb9c85.js +0 -817
- package/build/isProduction-28d96804.js +0 -1
- package/build/localizeNumberFormat-22b2d7aa.js +0 -1
- package/build/normalizeLink-594ccff1.js +0 -1
- package/build/number-cf06dcc0.js +0 -1
- package/build/paths-ed72ecb8.js +0 -1
- package/build/routing-f2edd0d0.js +0 -1
- package/build/theme-f2b8aad7.js +0 -1
- package/build/translationsContext-4c4c33c4.js +0 -1
- package/build/tslib.es6-ceb091fd.js +0 -1
- package/build/types-49f0543a.js +0 -785
- package/build/types-5b303b71.js +0 -1
- package/build/types-bfd12e24.js +0 -3004
- package/build/useCategory-94d60dab.js +0 -1
- package/build/useHealthToolCache-7307d240.js +0 -1
- package/build/useIsInit-c3cf1925.js +0 -1
- package/build/useOutsideClick-15fef824.js +0 -1
- package/build/usePlacesAutocomplete-6ab0181b.js +0 -1
- package/build/useScrollbarSize-ab332673.js +0 -1
- package/build/useTranslations-233c68bc.js +0 -1
- package/build/useUniqueId-46834e18.js +0 -1
- package/build/utils-13ea4f2f.js +0 -8
- package/build/utils-45e691a3.js +0 -1
- package/build/utils-bee8be92.js +0 -141
- package/build/utils-d5766c73.js +0 -1
package/build/esm/lead.js
CHANGED
|
@@ -1 +1,2140 @@
|
|
|
1
|
-
import{_ as e,a as t}from"./tslib.es6-266309d1.js";import a,{createContext as l,useState as n,useEffect as o,useMemo as i,useRef as r,useContext as s}from"react";import d from"lodash/debounce";import{v1 as c}from"uuid";import{B as m}from"./index-3452fed2.js";import{C as u}from"./index-2e99f941.js";import{Portal as p,Box as h,Transition as g,Overlay as v}from"@mantine/core";import{T as b}from"./index-d27a0e25.js";import"./index.styles-94af560f.js";import{S as f,d as y,c as k,R as _,P as E,N as w}from"./index-5408f5a4.js";import"./constants-f7c80032.js";import"./Subot-4642c5bf.js";import"./utils-3d2e3f0f.js";import{b as C,a as N}from"./utils-5b4e60da.js";import{D as T}from"./index-93e5b4f3.js";import{t as S}from"./theme-3db3c9a8.js";import{T as x}from"./translationsContext-6d2efd65.js";import"string-format";import"@mantine/hooks";import"./index-9e5956c2.js";import"./utils-970ce0c0.js";import"./index.styled-14b65c9e.js";import"./index-8c77d7e0.js";import{M as O}from"./utils-b87ec473.js";import"@mantine/dates";import{u as P,G as B}from"./usePlacesAutocomplete-0733ec49.js";import{createFormContext as j}from"@mantine/form";import{u as L}from"./useTranslations-df1b3bb8.js";import{H as $}from"./index-24557f2b.js";import{createPortal as I}from"react-dom";import{g as A,s as D}from"./cookieHelper-4f089e3c.js";import U from"dayjs";import"./isProduction-00695d80.js";import"styled-components";import"./animation-0340efb3.js";import"react-keyed-flatten-children";import"@hhgtech/icons/other";import"@mantine/carousel";import"classnames";import"./useUniqueId-03fbaecd.js";import"@hhgtech/icons/core";import"date-fns/locale";import"slugify";const H=1,R=2;let M="https://dev.leadgen.hellobacsi.com/";const F=1,W=2;let V="";M.includes("localhost")&&(M="https://dev.leadgen.hellobacsi.com/"),location.hostname.includes("marrybaby.vn")&&(V="pink");let q="https://"+location.hostname+location.pathname+location.search;q=q.toLowerCase(),sessionStorage.getItem("insider_object")&&(window.insider_object=JSON.parse(sessionStorage.getItem("insider_object")));const J={"vi-VN":{popupLang:"vi",countryCode:"vn",countryCodeNumber:84},"id-ID":{popupLang:"id",countryCode:"id",countryCodeNumber:62},"th-TH":{popupLang:"th",countryCode:"th",countryCodeNumber:66},"ms-MY":{popupLang:"ms",countryCode:"my",countryCodeNumber:60},"zh-TW":{popupLang:"zh",countryCode:"tw",countryCodeNumber:886},"km-KH":{popupLang:"km",countryCode:"kh",countryCodeNumber:855},"my-MM":{popupLang:"my",countryCode:"mm",countryCodeNumber:95},"hi-IN":{popupLang:"hi",countryCode:"in",countryCodeNumber:91}},Y=J[document.documentElement.lang]||J["vi-VN"];const z={1:"Asia/Ho_Chi_Minh",10:"Asia/Ho_Chi_Minh",11:"Asia/Ho_Chi_Minh",12:"Asia/Ho_Chi_Minh",2:"Asia/Jakarta",3:"Asia/Bangkok",4:"Asia/Phnom_Penh",5:"Asia/Kuala_Lumpur",6:"Asia/Taipei",7:"Asia/Yangon",8:"Asia/Kolkata",9:"Asia/Manila"};var G={"validator.required":"This field is required.","validator.remote":"Please fix this field.","validator.email":"Please enter a valid email address.","validator.phone":"Please input correct phone number.","validator.url":"Please enter a valid URL.","validator.date":"Please enter a valid date.","validator.dateISO":"Please enter a valid date (ISO).","validator.number":"Please enter a valid number.","validator.digits":"Please enter only digits.","validator.creditcard":"Please enter a valid credit card number.","validator.equalTo":"Please enter the same value again.","validator.accept":"Please enter a value with a valid extension.","validator.maxlength":"jQuery.validator.format('Please enter no more than {0} characters.","validator.minlength":"jQuery.validator.format('Please enter at least {0} characters.","validator.rangelength":"jQuery.validator.format('Please enter a value between {0} and {1} characters long.","validator.range":"jQuery.validator.format('Please enter a value between {0} and {1}.","validator.max":"jQuery.validator.format('Please enter a value less than or equal to {0}.","validator.min":"jQuery.validator.format('Please enter a value greater than or equal to {0}.","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"};const K={"en-PH":G,"vi-VN":{"validator.required":"Vui lòng điền mục này","validator.email":"Vui lòng điền email có thật.","validator.number":"Vui lòng điền số có thật","validator.digits":"Vui lòng chỉ điền số","validator.maxlength":"Vui lòng điền dưới {0} số","validator.minlength":"Vui lòng điền hơn {0} số","validator.remote":"Hãy sửa cho đúng.","validator.url":"Hãy nhập URL.","validator.date":"Hãy nhập ngày.","validator.dateISO":"Hãy nhập ngày (ISO).","validator.creditcard":"Hãy nhập số thẻ tín dụng.","validator.equalTo":"Hãy nhập thêm lần nữa.","validator.extension":"Phần mở rộng không đúng.","validator.rangelength":"Hãy nhập từ {0} đến {1} kí tự.","validator.range":"Hãy nhập từ {0} đến {1}.","validator.max":"Hãy nhập từ {0} trở xuống.","validator.min":"Hãy nhập từ {0} trở lên.","validator.phone":"Nhập đúng định dạng số điện thoại","validator.emailUsed":"Email này đã được sử dụng cho chiến dịch.","validator.phoneUsed":"Số điện thoại này đã được sử dụng cho chiến dịch.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"hi-IN":{"validator.required":"इस क्षेत्र की आवश्यकता है।","validator.email":"कृपया एक मान्य ईमेल पता दर्ज करें","validator.number":"कृपया एक वैध संख्या दर्ज करें","validator.digits":"कृपया केवल अंक दर्ज करें","validator.maxlength":"कृपया {0} अक्षर से अधिक दर्ज न करें","validator.minlength":"कृपया कम से कम {0} अक्षर दर्ज करें","validator.phone":"कृपया एक वैध संख्या दर्ज करें","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"id-ID":{"validator.required":"Kolom ini wajib diisi","validator.email":"Tolong daftarkan email yang valid","validator.number":"Tolong daftarkan nomor telepon yang valid","validator.digits":"Tolong masukkan angka saja","validator.maxlength":"Jangan memasukkan lebih dari {0} karakter","validator.minlength":"Tolong ketik sedikitnya {0} karakter","validator.phone":"Tolong daftarkan nomor telepon yang valid","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"ms-MY":{"validator.required":"Bahagian ini wajib diisi.","validator.email":"Sila masukkan alamat emel yang sah.","validator.number":"Sila masukkan no telefon yang sah.","validator.digits":"Sila masukkan nombor digit sahaja.","validator.maxlength":"Sila masukkan tidak lebih dari {0} aksara","validator.minlength":"Sila masukkan sekurang-kurangnya {0} aksara","validator.phone":"Sila masukkan no telefon yang sah.","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"my-MM":{"validator.required":"ဒီနေရာမှာ ဖြည့်ဖို့ လိုအပ်ပါတယ်","validator.email":"မှန်ကန်သော အီးမေးလ်လိပ်စာထည့်သွင်းပါ","validator.number":"မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ","validator.digits":"နံပါတ်များသာဖြည့်ပါ","validator.maxlength":"ကျေးဇူးပြု၍ {0} ထပ်မပိုသော ဂဏန်းများသာဖြည့်ပါ","validator.minlength":"ကျေးဇူးပြု၍ အနည်းဆုံး {0} ဂဏန်းဖြည့်ပါ","validator.phone":"မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"km-KH":{"validator.required":"ព័ត៌មានចាំបាច់ដែលត្រូវបំពេញ","validator.email":"សូមវាយអាសយដ្ឋានអ៊ីម៉ែលឲ្យបានត្រឹមត្រូវ","validator.number":"សូមវាយបញ្ចូលលេខឲ្យបានត្រឹមត្រូវ","validator.digits":"វាយបញ្ចូលបានតែលេខប៉ុណ្ណោះ","validator.maxlength":"សូមវាយបញ្ចូលកុំឲ្យលើស {0} តួអក្សរ","validator.minlength":"សូមវាយបញ្ចូលតិចបំផុត {0} តួអក្ស","validator.phone":"សូមវាយបញ្ចូលលេខឲ្យបានត្រឹមត្រូវ","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"zh-TW":{"validator.required":"此為必填欄位","validator.email":"請填入有效的 email 地址","validator.number":"請填入有效的電話號碼","validator.digits":"此欄位僅能輸入數字","validator.maxlength":"請輸入少於 {0} 位數","validator.minlength":"請輸入至少 {0} 位數","validator.phone":"請填入有效的電話號碼","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"th-TH":{"validator.required":"ต้องระบุข้อมูลในช่องนี้","validator.email":"กรุณาใส่อีเมล์ที่ถูกต้อง","validator.number":"กรุณาใส่ตัวเลขที่ถูกต้อง","validator.digits":"กรุณาส่เฉพาะตัวเลข","validator.maxlength":"กรุณาใส่ตัวเลขมากกว่า {0} หลัก","validator.minlength":"กรุณาใส่ตัวเลขอย่างน้อย {0} หลัก","validator.phone":"กรุณาใส่ตัวเลขที่ถูกต้อง","validator.emailUsed":"Email already in use for this campaign.","validator.phoneUsed":"Your phone number already in use for this campaign.","lead.otp.title":"Enter OTP","lead.otp.desc":"We have sent an OTP to your mobile number {phone}","lead.otp.verify":"Verify","lead.otp.resend":"Resend OTP{timer}"},"tl-PH":G},Q=e=>{const t=K[e];return t||K["en-PH"]},X=l({}),Z=e=>{const[t,a]=n(16),[l,i]=n(9),[r,s]=n(!1);return o((()=>{if(s(!1),e){const t=new Image;t.addEventListener("load",(()=>{a(t.naturalWidth),i(t.naturalHeight),s(!0)})),t.addEventListener("error",(()=>{a(16),i(9),s(!0)})),t.src=e}else a(16),i(9),s(!0)}),[e]),{loaded:r,width:t,height:l}},ee=({onClose:e,containerClassName:t,svgClassName:l})=>a.createElement("button",{onClick:e,className:`le-newbuilder-close-button js-modal__close ${t||""}`},a.createElement("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none",className:l},a.createElement("circle",{cx:"16",cy:"16",r:"16",fill:"white"}),a.createElement("path",{d:"M16 17.05L10.925 22.125C10.7917 22.2584 10.621 22.329 10.413 22.337C10.2044 22.3457 10.025 22.275 9.87502 22.125C9.72502 21.975 9.65002 21.8 9.65002 21.6C9.65002 21.4 9.72502 21.225 9.87502 21.075L14.95 16L9.87502 10.925C9.74169 10.7917 9.67102 10.6207 9.66302 10.412C9.65436 10.204 9.72502 10.025 9.87502 9.87502C10.025 9.72502 10.2 9.65002 10.4 9.65002C10.6 9.65002 10.775 9.72502 10.925 9.87502L16 14.95L21.075 9.87502C21.2084 9.74169 21.3794 9.67069 21.588 9.66202C21.796 9.65402 21.975 9.72502 22.125 9.87502C22.275 10.025 22.35 10.2 22.35 10.4C22.35 10.6 22.275 10.775 22.125 10.925L17.05 16L22.125 21.075C22.2584 21.2084 22.329 21.379 22.337 21.587C22.3457 21.7957 22.275 21.975 22.125 22.125C21.975 22.275 21.8 22.35 21.6 22.35C21.4 22.35 21.225 22.275 21.075 22.125L16 17.05Z",fill:"#595959"}))),te=({popupId:e,url:t,newTab:l,imageDestkop:n,imageMobile:o,onClose:i,onOtherSubmit:r})=>{const{width:s,height:d,loaded:c}=Z(o),{width:m,height:u,loaded:p}=Z(n);return c&&p?a.createElement("div",{id:e,className:"lead-modal-wrapper","data-popup-url":location.pathname,"data-popup-type":"center_tab"},a.createElement("div",{className:"le-center-tab-popup"},a.createElement("div",{style:{position:"relative"}},a.createElement("a",{className:"js-popup-other-submit",href:t,target:l?"blank":"_parent",onClick:r},a.createElement("img",{className:"le-only-mobile",src:o,style:{aspectRatio:`${s}/${d}`}}),a.createElement("img",{className:"le-only-desktop",src:n,style:{aspectRatio:`${m}/${u}`}})),a.createElement(ee,{onClose:i,containerClassName:"close-button-top-right"})))):null},ae=({popupId:e,url:t,title:l,urlText:n,titleAlign:o,subtitle:i,subtitleAlign:r,newTab:s,imageDesktop:d,imageMobile:c,onClose:m,onOtherSubmit:u})=>{const{width:p,height:h,loaded:g}=Z(c),{width:v,height:b,loaded:f}=Z(d);return g&&f?a.createElement("div",{id:e,className:"lead-modal-wrapper lead-floating-wrapper","data-popup-url":location.pathname,"data-popup-type":"floating"},a.createElement("aside",{className:"le-only-desktop"},a.createElement("div",{className:"le-floating-desktop"},a.createElement("div",{className:"le-floating-desktop-wrap",style:{position:"relative",background:"#fff"}},d?a.createElement("div",null,a.createElement("img",{style:{maxWidth:120,borderTopLeftRadius:5,borderBottomLeftRadius:5,aspectRatio:`${v}/${b}`},src:d})):null,a.createElement("div",{style:{padding:20}},a.createElement("div",{className:`le-floating-desktop-title le-text-align-${o}`},l),a.createElement("div",{className:`le-floating-desktop-desc le-text-align-${r}`},i)),a.createElement("a",{target:s?"blank":"_parent",style:{marginLeft:35,textDecoration:"none"},href:t},a.createElement("button",{className:"le-joinbow-floating-btn js-popup-other-submit",onClick:u},n)),a.createElement(ee,{onClose:m,containerClassName:"close-button-top-right"})))),a.createElement("aside",{className:"le-only-mobile"},a.createElement("div",{className:"le-floating-mobile"},a.createElement("div",{className:"le-floating-mobile-wrap",style:{position:"relative",background:"#fff"}},a.createElement("aside",{style:{display:"flex",justifyContent:"space-between"}},a.createElement("div",null,a.createElement("div",{className:`le-floating-mobile-title le-text-align-${o}`},l),a.createElement("div",{className:`le-floating-mobile-desc le-text-align-${r}`},i)),c?a.createElement("div",null,a.createElement("img",{style:{marginLeft:15,marginTop:4,maxWidth:100,aspectRatio:`${p}/${h}`},src:c})):null),a.createElement("div",{style:{textAlign:"center",marginTop:10}},a.createElement("a",{target:s?"blank":"_parent",href:t,style:{textDecoration:"none"}},a.createElement("button",{className:"le-joinbow-floating-btn js-popup-other-submit",onClick:u},n))),a.createElement(ee,{onClose:m,containerClassName:"close-button-top-right"}))))):null};const le=new class{constructor(){this.apiLeadUrl="https://dev.leadgen.hellobacsi.com/",this.apiSubotUrl="https://staging-service-subot.hellohealthgroup.com/"}},ne={call(t){var{url:a,data:l}=t,n=e(t,["url","data"]);return n.body=JSON.stringify(l),n.headers={"Content-Type":"application/json"},fetch(`${le.apiLeadUrl}${a}`,n).then((e=>e.json())).catch((()=>({})))}},oe={call(t){var{url:a,data:l}=t,n=e(t,["url","data"]);return n.body=JSON.stringify(l),n.headers={"Content-Type":"application/json"},fetch(`${le.apiSubotUrl}${a}`,n).then((e=>e.json())).catch((()=>({})))}},ie=({bot_id:e,email:t,phone:a})=>{let l=a;return l&&l.startsWith("0")&&(l=l.substring(1)),oe.call({url:"frontend/api/subot-campaign/check",method:"post",data:{bot_id:e,email:t,phone:l}})},re=({campaign_id:e,email:t,phone:a})=>{let l=a;return l&&l.startsWith("0")&&(l=l.substring(1)),ne.call({url:"api/subot-campaign/check",method:"post",data:{campaign_id:e,email:t,phone:l}})},se=({phone:e,type:t})=>ne.call({url:"phone"===t?"api/sms/otp":"api/sms/whatsapp_otp",method:"post",data:{phone_number:"phone"===t?e.replace("+",""):e}}),de=({phone:e,otp:t,type:a})=>ne.call({url:"phone"===a?"api/sms/verify":"api/sms/whatsapp_verify",method:"post",data:{otp_code:t,phone_number:"phone"===a?e.replace("+",""):e}}),ce={email:{},phone:{}},me=(e,a,l)=>t(void 0,void 0,void 0,(function*(){const n="email"in l?"email":"phone",o="email"in l?l.email:l.phone,i="email"in l?"validator.emailUsed":"validator.phoneUsed";if(ce[n][o]){if(ce[n][o].value)return i;if(!ce[n][o].value&&ce[n][o].expire>Date.now())return""}const r=yield((e,a,l)=>t(void 0,void 0,void 0,(function*(){const t="email"in l?"email":"phone",n="email"in l?l.email:l.phone,o="email"in l?"validator.emailUsed":"validator.phoneUsed",i=yield re({campaign_id:[e],[t]:n});return"SubmitLeadWithBotId_ERR_001"===i._errorCode||"SubmitLeadWithBotId_ERR_002"===i._errorCode||a.length&&"CheckSuBotLeadTool_ERR_001"===(yield ie({bot_id:a,[t]:n}))._errorCode?o:void 0})))(e,a,l);return ce[n][o]=r?{value:!0}:{value:!1,expire:Date.now()+6e4},r})),[ue,pe,he]=j(),ge=["places"],ve=({name:e,placeholder:t,locale:l})=>{var s;const d=pe(),[c,m]=n(""),[u,p]=n(""),{predictions:h}=P(c,"","tl-PH"===l?"en":null===(s=null==l?void 0:l.split("-"))||void 0===s?void 0:s[0]),[g,v]=n(null),[b,y]=n(!1),k=r(Math.random().toString(36).substring(7)),_=i((()=>{const e=h.map((e=>({value:e.description,label:e.description}))),t=e.find((e=>e.value===u));return!u||t?e:[{value:u,label:u}].concat(e)}),[h,u]);return o((()=>{var e,t,a;(null===(a=null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.places)||void 0===a?void 0:a.AutocompleteService)?y(!0):import("@react-google-maps/api").then((e=>{v((()=>e.LoadScript)),setTimeout((()=>{y(!0)}),200)}))}),[]),b?a.createElement(a.Fragment,null,g&&a.createElement(g,{googleMapsApiKey:B,libraries:ge,loadingElement:a.createElement(a.Fragment,null)}),a.createElement("div",{style:{display:"none"},"data-extra":!0,"data-name":e,"data-control":"text"}),a.createElement(f,Object.assign({className:"lead-modal__form-control",label:t,placeholder:t,withAsterisk:!0,name:e,data:_,searchValue:c,onSearchChange:e=>{m(e)},filter:()=>!0,clearable:!0,searchable:!0,onChange:e=>p(e||""),icon:a.createElement("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none"},a.createElement("path",{d:"M9.99999 9.79167C10.4028 9.79167 10.7467 9.64944 11.0317 9.365C11.3161 9.08 11.4583 8.73611 11.4583 8.33333C11.4583 7.93056 11.3161 7.58667 11.0317 7.30167C10.7467 7.01722 10.4028 6.875 9.99999 6.875C9.59721 6.875 9.25332 7.01722 8.96832 7.30167C8.68388 7.58667 8.54166 7.93056 8.54166 8.33333C8.54166 8.73611 8.68388 9.08 8.96832 9.365C9.25332 9.64944 9.59721 9.79167 9.99999 9.79167ZM9.99999 17.875C9.90277 17.875 9.80555 17.8611 9.70832 17.8333C9.6111 17.8056 9.52082 17.7569 9.43749 17.6875C7.46527 15.8958 5.98971 14.2361 5.01082 12.7083C4.03138 11.1806 3.54166 9.77778 3.54166 8.5C3.54166 6.48611 4.1911 4.87833 5.48999 3.67667C6.78832 2.47556 8.29166 1.875 9.99999 1.875C11.7083 1.875 13.2119 2.47556 14.5108 3.67667C15.8092 4.87833 16.4583 6.48611 16.4583 8.5C16.4583 9.77778 15.9689 11.1806 14.99 12.7083C14.0105 14.2361 12.5347 15.8958 10.5625 17.6875C10.4792 17.7569 10.3889 17.8056 10.2917 17.8333C10.1944 17.8611 10.0972 17.875 9.99999 17.875Z",fill:"#8C8C8C"})),autoComplete:"no-auto-complete-"+k.current,rightSection:a.createElement(a.Fragment,null)},d.getInputProps(e)))):a.createElement("div",{style:{height:73}})},be=({children:e,align:t})=>a.createElement("p",{className:`lead-modal__description ${"le-text-align-"+(t||"")} ${V}`},e),fe=({children:e,align:t})=>a.createElement("h2",{className:`lead-modal__title ${"le-text-align-"+(t||"")} ${V}`},e),ye=({listBlockAdded:e,popupId:t,locale:l,onClose:n,onOtherSubmit:o})=>{const i=pe();return a.createElement(a.Fragment,null,e.map(((e,r)=>{const{name:s="",data:d={}}=e||{},{placeholder:c,value:u,align:p,listQuestion:h,isSendMailChimp:g=!1,newtab:v,url:b}=d;switch(s){case"TitleBlock":return a.createElement(fe,{key:r,align:p},u);case"SubtitleBlock":return a.createElement(be,{key:r,align:p},u);case"TextBlock":return a.createElement(k,Object.assign({key:r,withAsterisk:!0,spellCheck:!1,type:"text",placeholder:c,className:"lead-modal__form-control",label:c,"data-control":"text",name:u},i.getInputProps(u)));case"NumberBlock":return a.createElement(w,Object.assign({key:r,withAsterisk:!0,spellCheck:!1,type:"number",placeholder:c,className:"lead-modal__form-control",label:c,"data-control":"number",name:u},i.getInputProps(u)));case"EmailBlock":return a.createElement(k,Object.assign({key:r,withAsterisk:!0,spellCheck:!1,placeholder:c,className:"lead-modal__form-control",label:c,"data-control":"email",name:u},i.getInputProps(u)));case"PhoneOtpBlock":case"WhatsappOtpBlock":case"PhoneBlock":{const e=t+"-"+u+"-"+r;return a.createElement(k.Wrapper,Object.assign({size:"md",withAsterisk:!0,key:r,label:c,className:"lead-modal__form-control",labelProps:{htmlFor:e}},i.getInputProps(u)),a.createElement(E,{name:u,spellCheck:!1,type:"tel",placeholder:c,onChange:e=>{i.setFieldValue(u,e)},id:e,defaultCountry:l&&O[l]||"VN","data-control":"tel"}))}case"LocationBlock":return a.createElement(ve,{key:r,name:u,placeholder:c,locale:l});case"DateBlock":return a.createElement(a.Fragment,null,a.createElement(T,Object.assign({withAsterisk:!0,key:r,type:"default",name:u,placeholder:c,className:"lead-modal__form-control",label:c,"data-control":"date"},i.getInputProps(u))),a.createElement("input",{type:"hidden",name:u,"data-control":"date"}));case"LinkButtonBlock":return a.createElement("div",{key:r},a.createElement("a",{target:v?"blank":"parrent",href:b,style:{textDecoration:"none"}},a.createElement(m,{type:"button",size:"md",className:`lead-modal__btn ${V}`,onClick:()=>{null==n||n(),null==o||o()}},u)));case"CheckboxBlock":return a.createElement(a.Fragment,null,g&&a.createElement("div",{style:{display:"none"},"data-name":u+"-mailchimp"}),a.createElement(y.Group,Object.assign({withAsterisk:!0,className:"lead-modal__form-control",key:r,label:c,size:"md",sx:{display:"flex",flexDirection:"column",gap:8}},i.getInputProps(u)),h.map(((e,t)=>a.createElement(y,{name:u,key:t,value:e.value,label:e.placeholder,"data-control":"checkbox"})))));case"RadioBlock":return a.createElement(a.Fragment,null,g&&a.createElement(k,{type:"hidden",name:u+"-mailchimp",value:g}),a.createElement(_.Group,Object.assign({withAsterisk:!0,className:"lead-modal__form-control",key:r,label:c,size:"md"},i.getInputProps(u)),h.map(((e,t)=>a.createElement(_,{name:u,key:t,value:e.value,label:e.placeholder,"data-control":"radio"})))));case"DropdownBlock":return a.createElement(a.Fragment,null,a.createElement("div",{style:{display:"none"},"data-extra":!0,"data-name":u,"data-control":"dropdown"}),a.createElement(f,Object.assign({key:r,className:"lead-modal__form-control",label:c,withAsterisk:!0,name:u,data:h.map((e=>({value:e.value,label:e.placeholder})))},i.getInputProps(u))));case"TncBlock":const s=i.getInputProps("TNC-"+e.id);return a.createElement(a.Fragment,null,a.createElement(y,Object.assign({name:"TNC-"+e.id,key:e.id,label:a.createElement("p",{className:"lead-modal__tnc-link",dangerouslySetInnerHTML:{__html:d.valueHTML}}),className:"tnc-block","data-control":"checkbox"},s,{error:s.error?a.createElement(a.Fragment,null):void 0})))}return null})))},ke=({otpData:e,onSuccess:l,autoSendWhenOpen:i})=>{const{t:s}=L(),d=e.phone,c=e.type,[u,p]=n(""),[h,g]=n(!1),[v,f]=n(i?0:60),y=r(null),[_,E]=n(),[w,C]=n(""),N=r(),[T,x]=n(!1);o((()=>{t(void 0,void 0,void 0,(function*(){var e;if(!N.current){const e=yield import("react-phone-number-input");N.current=e.formatPhoneNumberIntl}C((null===(e=N.current)||void 0===e?void 0:e.call(N,d))||d)}))}),[d]);const O=()=>t(void 0,void 0,void 0,(function*(){var e;if(!d)return;const t=yield se({phone:d,type:c}),a=null===(e=null==t?void 0:t._messages)||void 0===e?void 0:e[0];"Send sms successfully"===a||"Send WhatsApp successfully"===a?(f(60),setTimeout((()=>{y.current&&(y.current.focus(),y.current.scrollIntoView({block:"center"}))}),100)):"This phone number was verified"===a?l():E(a||"Something went wrong!")}));return o((()=>{setTimeout((()=>{v>0&&f((e=>e-1))}),1e3)}),[v]),o((()=>{i&&!v&&O()}),[]),a.createElement(a.Fragment,null,a.createElement("form",{onSubmit:e=>{e.preventDefault(),t(void 0,void 0,void 0,(function*(){if(!d||!u)return;x(!0);const e=yield de({phone:d,otp:u,type:c}),t=null==e?void 0:e._messages[0];"Verify successfully"===t||"Verify WhatsApp OTP sucess"===t||"This phone number was verified"===t?l():E(t||"something Wrong"),x(!1)}))},className:"lead-phone-otp-form"},a.createElement($,{tag:"h3",fontWeight:"bold",style:{marginBottom:4}},s("lead.otp.title")),a.createElement(b,{size:"p1",color:S.colors.gray600},s("lead.otp.desc",{phone:w})),a.createElement(k,{ref:y,name:"_"+name+"-otp",spellCheck:!1,type:"number",placeholder:"Enter OTP",className:"lead-modal__form-control",label:"Phone OTP","data-control":"otp",withAsterisk:!0,pattern:"[0-9]*",value:u,maxLength:6,onChange:e=>{g(!0),p(e),E(h&&!e?"OTP is required":void 0)},error:h?_:void 0}),a.createElement(m,{size:"md",color:"primary",className:`lead-modal__btn ${V}`,disabled:!u,isLoading:T},s("lead.otp.verify")),a.createElement(m,{type:"button",size:"md",color:"transparent",className:`lead-modal__btn lead-phone-otp-button ${V}`,onClick:()=>{O()},disabled:!!v},s("lead.otp.resend",{timer:v?` (${v}s)`:""}))))},_e=({title:e,titleAlign:t,subtitle:l,subtitleAlign:n,link:o,linkNewTab:i,linkText:r,image:s})=>{const{width:d,height:c,loaded:m}=Z(s);return m?a.createElement("div",{className:"lead-modal__thank-you"},a.createElement("div",{style:{width:"100%"}},a.createElement("img",{src:s,style:{maxHeight:162,objectFit:"cover",aspectRatio:`${d}/${c}`},loading:"lazy"}),e&&a.createElement("h1",{className:`le-thankyou-title le-text-align-${t}`},e),l&&a.createElement("p",{className:`le-thankyou-subtitle le-text-align-${n}`},l),r&&a.createElement("div",null,a.createElement("a",{href:o,target:i?"_blank":"parrent",rel:"noreferrer"},a.createElement("button",{className:`lead-modal__btn ${V}`},r))))):null},Ee=({content:e,inlinePosition:t})=>{const a=i((()=>{if(!t)return null;const e=document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`),a=Array.from(e).reduce(((e,t)=>[...e,...Array.from(t.children)]),[]);if(null==a?void 0:a.length){const e=a.filter((e=>"P"===e.nodeName)),l=a.filter((e=>"H2"===e.nodeName));let n=null;switch(t){case"1th":n=e[0];break;case"2th":n=e[1];break;case"3th":n=e[2];break;case"4th":n=e[3];break;case"5th":n=e[4];break;case"6th":n=e[5];break;case"7th":n=e[6];break;case"8th":n=e[7];break;case"9th":n=e[8];break;case"10th":n=e[9];break;case"11th":n=e[10];break;case"12th":n=e[11];break;case"lastP":n=e[e.length-1];break;case"1thH2":n=l[0];break;case"2thH2":n=l[1];break;case"3thH2":n=l[2];break;case"4thH2":n=l[3];break;case"5thH2":n=l[4];break;case"6thH2":n=l[5];break;case"7thH2":n=l[6];break;case"8thH2":n=l[7];break;case"9thH2":n=l[8];break;case"10thH2":n=l[9];break;case"lastH2":n=l[l.length-1]}if(n){if(n.parentElement.querySelector(".inline-lead-wrapper"))return n.parentElement.querySelector(".inline-lead-wrapper");{const e=document.createElement("div");return e.classList.add("inline-lead-wrapper"),n.nextElementSibling?n.parentElement.insertBefore(e,n.nextElementSibling):n.parentElement.appendChild(e),e}}}}),[t]);return t&&a?I(e,a):null},we=({content:e})=>{const t=i((()=>{const e=Array.from(document.querySelectorAll(".hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar"));return e.forEach((e=>{if(e.querySelector(".sidebar-lead-modal-wrapper"))return;const t=document.createElement("div");t.classList.add("sidebar-lead-modal-wrapper"),e.prepend(t)})),e.map((e=>e.querySelector(".sidebar-lead-modal-wrapper")))}),[]);return a.createElement(a.Fragment,null,t.map((t=>I(e,C(t,"sidebar-lead-modal-wrapper")))))},Ce=({popupId:e,extraFields:t,onClose:l,onOtherSubmit:s,imageMobile:d,imageDesktop:c,imageOverlayMobile:p,imageOverlayDesktop:h,imageBackground:g,currentLayout:v,title:b,onSubmit:f,showThankyou:y,campaignId:k,campaign_subot_id:_,locale:E})=>{var w,C,N;const T=JSON.parse(t.listBlockAdded),S=JSON.parse(t.actionBlocks),x=JSON.parse(t.textBlocks),O=S.submitBlock.data.url,P=S.submitBlock.data.text,B=S.submitBlock.data.text2,j=S.submitBlock.data.value,$=location.pathname,I=v.includes("Inline")||"Sidebar"===v,A="Slider"===v,[D,U]=n(!0),[H,R]=n(null),[M,F]=n(!1),W=r(),q=()=>{H?R(null):null==l||l()};if(window.innerWidth<769&&["Fullscreen","Slider"].includes(v))return console.log("😎 Not show fullscreen, slider on mobile "),null;o((()=>{(v.includes("LightBox")||"Fullscreen"==v)&&document.body.classList.add("noscroll"),window.intlTelInputUtils||require("intl-tel-input/build/js/utils"),ce.email={},ce.phone={}}),[]);const J=r(!1),z=r(!1),{form:G,validateObj:K}=(({listBlockAdded:e=[],validatingPhoneRef:t,validatingEmailRef:a,campaignId:l,campaign_subot_id:n=[]})=>{const{t:o}=L(),s=i((()=>{const i=["TextBlock","NumberBlock","EmailBlock","PhoneBlock","DateBlock","CheckboxBlock","RadioBlock","DropdownBlock","PhoneOtpBlock","WhatsappOtpBlock","LocationBlock","TncBlock"],r=(e,t)=>a=>{if(c.current.isTouched(e))return void 0===a||""===a||Array.isArray(a)&&0===a.length?o("validator.required"):null==t?void 0:t(a)};return e.filter((e=>i.includes(e.name))).reduce(((e,i)=>"NumberBlock"===i.name?Object.assign(Object.assign({},e),{[i.data.value]:r(i.data.value,(e=>{if(isNaN(Number(e)))return o("validator.number")}))}):"EmailBlock"===i.name?Object.assign(Object.assign({},e),{[i.data.value]:r(i.data.value,(e=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e))return o("validator.email");a.current=!0,setTimeout((()=>{c.current.setFieldError(i.data.value,"Validating..."),me(l,n,{email:e}).then((e=>{e?c.current.setFieldError(i.data.value,o(e)):c.current.clearFieldError(i.data.value),a.current=!1})).catch((e=>{console.error(e),c.current.setFieldError(i.data.value,e.message||"Something went wrong"),a.current=!1}))}),200)}))}):"PhoneBlock"===i.name||"PhoneOtpBlock"===i.name||"WhatsappOtpBlock"===i.name?Object.assign(Object.assign({},e),{[i.data.value]:r(i.data.value,(e=>{if(window.intlTelInputUtils&&!window.intlTelInputUtils.isValidNumber(String(e),Y.countryCode))return o("validator.phone");t.current=!0,setTimeout((()=>{c.current.setFieldError(i.data.value,"Validating..."),me(l,n,{phone:e}).then((e=>{e?c.current.setFieldError(i.data.value,o(e)):c.current.clearFieldError(i.data.value),t.current=!1})).catch((e=>{console.error(e),c.current.setFieldError(i.data.value,e.message||"Something went wrong"),t.current=!1}))}),200)}))}):"DateBlock"===i.name?Object.assign(Object.assign({},e),{[i.data.value]:r(i.data.value,(e=>{if(isNaN(Date.parse(e)))return o("validator.date")}))}):"TncBlock"===i.name?Object.assign(Object.assign({},e),{["TNC-"+i.id]:r("TNC-"+i.id)}):Object.assign(Object.assign({},e),{[i.data.value]:r(i.data.value)})),{})}),[e.map((e=>e.name)).join(",")]),d=he({validateInputOnChange:!0,clearInputErrorOnChange:!0,validate:s}),c=r(d);return c.current=d,{form:d,validateObj:s}})({listBlockAdded:T,validatingPhoneRef:J,validatingEmailRef:z,campaignId:k,campaign_subot_id:_}),{width:Q,height:X,loaded:te}=Z(g),{width:ae,height:le,loaded:ne}=Z(d),{width:oe,height:ie,loaded:re}=Z(c),de=ne&&re&&("Fullscreen"!=v||te),pe=a.createElement(a.Fragment,null,a.createElement("style",{dangerouslySetInnerHTML:{__html:`\n .le-newbuilder-overlay {\n background-repeat: no-repeat;\n background-size: cover;\n }\n ${p?`\n .le-newbuilder-overlay {\n background: url(${p}) ;\n }`:""}\n ${h?`\n @media screen and (min-width:768px) {\n .le-newbuilder-overlay {\n background: url(${h}) ;\n }\n }`:""}`}}),a.createElement("div",{id:e,"data-popup-url":$,"data-popup-type":"lightbox-inline",className:`lead-modal lead-modal-wrapper modal--animate-scale ${I?"le-buider-inline":""} ${A?"le-buider-slider":""}`},"Fullscreen"==v?a.createElement("img",{className:"le-only-desktop le-fullscreen-img",draggable:!1,src:g||"",style:{aspectRatio:`${Q}/${X}`}}):null,a.createElement("div",{className:`lead-modal__wrapper le-newbuilder-wrap-${v}`},a.createElement("div",{className:`lead-modal__content le-newbuilder-${v}`},y?a.createElement(_e,{title:y.title,titleAlign:y.titleAlign,subtitle:y.subtitle,subtitleAlign:y.subtitleAlign,link:y.link,linkNewTab:y.linkNewTab,linkText:y.linkText,image:y.image}):a.createElement(a.Fragment,null,a.createElement("header",{className:"lead-modal__header"},H?a.createElement("img",{src:u.getAssetPath("lead-otp-thumb.png"),draggable:"false",alt:"",style:{width:"100%",minHeight:"150px",backgroundColor:"#f2f2f2"},loading:"lazy"}):a.createElement(a.Fragment,null,["LightBoxA","InlineA","Sidebar","Slider"].includes(v)?d?a.createElement("img",{draggable:"false",className:"lead-modal__image lead-modal-image-cover",src:d,style:{aspectRatio:`${ae}/${le}`},alt:""}):null:a.createElement(a.Fragment,null,c?a.createElement("img",{draggable:"false",className:"le-only-desktop lead-modal__image lead-modal-image-cover",style:{objectFit:"cover",aspectRatio:`${oe}/${ie}`},src:c,alt:""}):null,d?a.createElement("img",{draggable:"false",className:"le-only-mobile lead-modal__image lead-modal-image-cover",src:d,alt:"",style:{aspectRatio:`${ae}/${le}`}}):null))),H&&a.createElement(ke,{otpData:H,autoSendWhenOpen:!1,onSuccess:()=>{R(null),null==f||f(W.current,G.values)}}),a.createElement("div",{"data-hidden":!!H,className:"lead-modal__body le-newbuilder-overlay"},a.createElement(ue,{form:G},a.createElement("form",{ref:W,className:`lead-modal__form ${e}`,onSubmit:e=>{e.preventDefault(),G.setTouched(Object.keys(K).reduce(((e,t)=>(e[t]=!0,e)),{})),z.current||J.current||setTimeout((()=>{G.onSubmit((e=>{var t,a,l,n,o,i;if(Object.keys(G.errors).length)return;let r=null;if(T.findIndex((e=>"PhoneOtpBlock"===e.name))>-1){const n=null===(a=null===(t=T.find((e=>"PhoneOtpBlock"===e.name)))||void 0===t?void 0:t.data)||void 0===a?void 0:a.value;(null===(l=e[n])||void 0===l?void 0:l.startsWith("+"))&&(r={phone:e[n],type:"phone"})}if(T.findIndex((e=>"WhatsappOtpBlock"===e.name))>-1){const t=null===(o=null===(n=T.find((e=>"WhatsappOtpBlock"===e.name)))||void 0===n?void 0:n.data)||void 0===o?void 0:o.value;(null===(i=e[t])||void 0===i?void 0:i.startsWith("+"))&&(r={phone:e[t],type:"whatsapp"})}if(r)return F(!0),void se(r).then((t=>{var a;"This phone number was verified"!==(null===(a=null==t?void 0:t._messages)||void 0===a?void 0:a[0])?R(r):null==f||f(W.current,e)})).finally((()=>{F(!1)}));null==f||f(W.current,e)}))(e)}),100)}},a.createElement("div",{style:{marginBottom:20}},a.createElement("h2",{className:`lead-modal__title ${"le-text-align-"+(null===(w=x.titleBlock.data)||void 0===w?void 0:w.align)} ${V}`},b),a.createElement("p",{className:`lead-modal__description ${"le-text-align-"+(null===(C=x.titleBlock.data)||void 0===C?void 0:C.align)} ${V}`},x.subtitleBlock.data.value)),a.createElement("div",{className:"lead-modal__form-control-wrapper"},a.createElement(ye,{listBlockAdded:T,popupId:e,locale:E,onClose:q,onOtherSubmit:s})),(null===(N=null==S?void 0:S.submitBlock)||void 0===N?void 0:N.isHide)?null:a.createElement(a.Fragment,null,a.createElement("div",{className:`lead-modal__checkbox-wrapper ${V}`},a.createElement("div",{className:"lead-modal__checkbox"},a.createElement("input",{id:"lead-term-checkbox",className:`lead-modal__checkbox__input ${V}`,type:"checkbox","aria-label":"Checkbox label",checked:D,onChange:e=>U(e.currentTarget.checked)}),a.createElement("div",{className:"lead-modal__checkbox__control","aria-hidden":"true"})),a.createElement("label",{htmlFor:"checkbox",className:"lead-modal__checkbox__label"},P," ",a.createElement("span",{style:{fontWeight:"bold"}},a.createElement("a",{target:"blank",href:O||"https://hellobacsi.com/chinh-sach",rel:"noopener noreferrer",style:{textDecoration:"none"}},B)))),a.createElement(m,{size:"md",id:"lead-submit",type:"submit",className:`lead-modal__btn ${V}`,disabled:!D,isLoading:M},j))))))),!v.includes("Inline")&&a.createElement(ee,{onClose:q,containerClassName:"close-button-top-right"}))));return de?v.includes("LightBox")||"Fullscreen"==v||"Slider"==v?pe:"Sidebar"==v?a.createElement(we,{content:pe}):v.includes("Inline")?a.createElement(Ee,{content:pe,inlinePosition:t.popupInlinePosition}):null:null},Ne=({popupId:e,link:t,linkText:l,linkNewTab:n,onClose:o,imageMobile:i,imageDesktop:r,currentLayout:s,onOtherSubmit:d})=>{const c=location.pathname,{width:m,height:u,loaded:p}=Z(i),{width:h,height:g,loaded:v}=Z(r);return p&&v?a.createElement("div",{id:e,className:"lead-modal-wrapper","data-popup-url":c,"data-popup-type":"skin_ab"},"SkinA"==s?a.createElement("aside",{className:"le-only-desktop"},a.createElement("div",{className:"le-skin-a-desktop"},a.createElement("div",{style:{position:"relative"}},a.createElement("img",{src:r,style:{aspectRatio:`${h}/${g}`}}),a.createElement("a",{style:{position:"absolute",top:"75%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",width:"calc(100% - 15px)"},href:t,target:n?"blank":"_parent"},a.createElement("button",{onClick:d,className:"le-joinbow-btn js-popup-other-submit"},l)),a.createElement(ee,{onClose:o,containerClassName:"close-button-top-right"})))):"SkinB"==s?a.createElement("aside",{className:"le-only-desktop"},a.createElement("div",{className:""},a.createElement("div",{style:{position:"relative",zIndex:1e4}},a.createElement("img",{src:r,style:{width:"100%",aspectRatio:`${h}/${g}`}}),a.createElement("a",{style:{position:"absolute",top:"75%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",width:"100%"},href:t,target:n?"blank":"_parent"},a.createElement("button",{onClick:d,className:"le-joinbow-btn-mobile js-popup-other-submit"},l)),a.createElement(ee,{containerClassName:"close-button-top-right",onClose:o})))):null,a.createElement("aside",{className:"le-only-mobile"},a.createElement("div",{className:"le-skin-mobile"},a.createElement("div",{style:{position:"relative"}},a.createElement("img",{src:i,style:{width:"100%",aspectRatio:`${m}/${u}`}}),a.createElement("a",{style:{position:"absolute",top:"82%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center",maxWidth:"calc(100% - 15px)"},href:t,target:n?"blank":"_parent"},a.createElement("button",{onClick:d,className:"le-joinbow-btn-mobile js-popup-other-submit"},l)),a.createElement(ee,{containerClassName:"close-button-top-right",svgClassName:"le-mobile-btn",onClose:o}))))):null},Te=({popupId:e,url:t,newTab:l,image:n,onClose:o,onOtherSubmit:i})=>{const{width:r,height:s,loaded:d}=Z(n);return d?a.createElement("div",{id:e,className:"lead-modal-wrapper","data-popup-url":location.pathname,"data-popup-type":"tab"},a.createElement("div",{className:"le-tab-popup"},a.createElement("div",{style:{position:"relative"}},a.createElement("a",{href:t,target:l?"blank":"_parent",onClick:i},a.createElement("img",{className:"js-popup-other-submit",src:n,style:{aspectRatio:`${r}/${s}`}})),a.createElement(ee,{onClose:o,containerClassName:"close-button-top-right"})))):null},Se=[],xe=[],Oe=[],Pe=[],Be=[],je=[];const Le=(e="UTC")=>{const t=new Date;return new Date(t.toLocaleString("en-US",{timeZone:e}))},$e=e=>{try{const[t,a]=e.split(" "),[l,n,o]=t.split("-").map(Number),[i,r,s]=a.split(":").map(Number);return new Date(l,n-1,o,i,r,s)}catch(e){return null}};const Ie=e=>!function(e){var t;const a=Number(null===(t=e.rules.find((e=>"exclude_sponsored"==e.rule)))||void 0===t?void 0:t.value);return!(!Boolean(document.querySelector(".hhg-disclaimer-text"))||!a||(Pe.push(e),0))}(e)&&(!!function(e){var t,a;try{const l=null===(t=e.rules.find((e=>"exclude_sponsored_list"==e.rule)))||void 0===t?void 0:t.value,n=l instanceof Array?l:JSON.parse(l),o=Number(null===(a=document.querySelector("[data-sponsored-id]"))||void 0===a?void 0:a.getAttribute("data-sponsored-id"));return!o||o<=0||0===n.length||(!!n.find((e=>e.id==o))||(Be.push({id:e.id,rules:e.rules}),!1))}catch(e){return!0}}(e)&&(1===e.formatted_status?function(e){var t;if(1===e.forever)return!0;const a=e.started_at,l=e.ended_at,n=$e(a),o=$e(l);if(!n||!o)return!0;const i=(null===(t=e.site)||void 0===t?void 0:t.id)||1;return!(Le(z[i]).getTime()>o.getTime()&&(Oe.push(e),1))}(e):0===e.formatted_status&&(Se.push(e),(e=>{var t;const a=(null===(t=e.site)||void 0===t?void 0:t.id)||1,l=e.started_at,n=e.ended_at,o=$e(l),i=$e(n);if(!o||!i)return!1;const r=Le(z[a]).getTime();return r<=i.getTime()&&r>=o.getTime()&&(xe.push(e),!0)})(e)))),Ae=e=>{var t;try{const a=(e,t,a)=>{const l=t.split(":"),n=a.split(":"),o=new Date;o.setHours(Number(l[0]),Number(l[1]),0,0);const i=new Date;return i.setHours(Number(n[0]),Number(n[1]),0,0),e>=o&&e<=i},l=null===(t=e.rules.find((e=>"appearance_time"==e.rule)))||void 0===t?void 0:t.value,n=l.startTime,o=l.endTime||"23:59";return!n||(!!a(new Date,n,o)||(je.push(e),!1))}catch(e){return!0}};let De=null;function Ue({leadApi:e,leadSiteId:t,leadDomain:a,onShowPopup:l,DEBUG_URL:n}){const o=n||("https://"+location.hostname+location.pathname+location.search).toLowerCase();fetch(e+"api/campaign/"+t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:o,ga_client_id:A("_ga")||null})}).then((e=>e.json())).then((e=>{var t,n,i,r;if(He("List campagin: ",e),q="https://"+location.hostname+location.pathname+location.search,1==e._status){const s=((null===(n=null===(t=e._data)||void 0===t?void 0:t.campaigns)||void 0===n?void 0:n.filter(Ie))||[]).filter(Ae);A("hhg-id")||(D("hhg-id",c(),{domain:"."+a,path:"/"}),He("😍 Set HHG ID cookie"));let d=[];d=/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent)?s.filter((e=>e.device_types.some((e=>e.id==F)))):s.filter((e=>e.device_types.some((e=>e.id==W)))),He("👓 campaignsDevice",d),He("--listCampaignScheduled",Se),He("--listCampaignScheduledToActivated",xe),He("--listCampaignActiveButExpired",Oe),He("--listCampaignExcludeSonsored",Pe),He("--listCampaignDifferentSponsor",Be),He("--listCampaignNotDisplayInRangeOfTime",je);let m=d.map(((e,t)=>e.targets.filter((e=>e.type==H)).map((e=>Object.assign(Object.assign({},e),{campaignIndex:t}))))).flat(1);m=m.filter((e=>{var t;const a=new URL(String(e.target).toLowerCase());if("exact_match"==e.option)return Boolean(o===(null===(t=a.href)||void 0===t?void 0:t.toLowerCase()));if("start_with"==e.option){if(o.includes(String(e.target).toLowerCase())){const t=e.sub_target.filter((e=>"excluding"==e.option)).map((e=>{var t;return null===(t=e.value)||void 0===t?void 0:t.toLowerCase()}));return!t.includes(o.split("?")[0])}return!1}}));const u=Array.from(document.getElementsByTagName("META")).filter((e=>"article:tag"==e.getAttribute("property"))).map((e=>e.content));let p=[],h=[];u&&u.length&&(p=d.map(((e,t)=>e.targets.filter((e=>e.type==R)).map((e=>Object.assign(Object.assign({},e),{campaignIndex:t}))))).flat(1),h=p.filter((e=>u.includes(e.target))));const g=[...m,...h],v=document.cookie.split("; ").map((e=>e.split("=")[0])),b=v.filter((e=>e.includes("lead_submited")));He("--listCampaignCodeSubmited",b);const f=v.filter((e=>e.includes("lead_closed")));He("--listCampaignCodeClosed",f);const y=[...b,...f],k=(e=>{const t=[...e];for(let e=t.length-1;e>0;e--){const a=Math.floor(Math.random()*(e+1)),l=t[e];t[e]=t[a],t[a]=l}return t})(g.filter((e=>!y.some((t=>t.includes(d[e.campaignIndex].code))))));if(He("--listCampaignValid : ",k),k&&k.length){const e=d[k[0].campaignIndex];He("CAMPAIGN_SHOW",e);const{rules:t}=e,a=Number(null===(i=t.find((e=>"time"==e.rule)))||void 0===i?void 0:i.value);He("timeoutRule",a);const n=Number(null===(r=t.find((e=>"scroll"==e.rule)))||void 0===r?void 0:r.value);He("scrollRule",n);let o="TIME";if(Number.isInteger(a)&&(o="TIME",He("✨ SHOW AWESOME POPUP AFTER: ",a," seconds"),De&&clearTimeout(De),De=setTimeout((()=>{null==l||l(e,o)}),1e3*a)),Number.isInteger(n)){o="SCROLL",He("✨ SHOW AWESOME AFTER: SCROLL",n," %");const t=document.querySelector(`[data-url="${location.pathname}"]`)||document.querySelector("body"),a=t.getBoundingClientRect().top,i=t.offsetHeight;He("👓 Element check scroll: ",t);const r=function(){const t=window.pageYOffset||document.documentElement.scrollTop;let s=0;t>=a&&(s=Math.round((t-a)/(i-innerHeight)*100)),He("---Scroll",s,n),s>=n&&(window.removeEventListener("scroll",r),null==l||l(e,o))};window.addEventListener("scroll",r,{passive:!0})}}else He("🚧 No lead campaigns on current URL, tags")}})).catch((e=>{He("Lead error: ",e)}))}const He=(...e)=>{("production"!==process.env.NODE_ENV||process.env.NEXT_PUBLIC_DEPLOY_ENV&&"production"!==process.env.NEXT_PUBLIC_DEPLOY_ENV||"undefined"!=typeof localStorage&&"true"===localStorage.getItem("hhg_debug"))&&console.log(...e)};const Re=({campaign:e,action:t,onSubmit:l,onClose:n,showThankyou:i,locale:d})=>{var m,u;const{apiUrl:p,siteDomain:h}=s(X);o((()=>{const e=A("_ga")||null;fetch(`${p}api/campaign/${f}/impression`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:t,url:location.href.toLowerCase(),title_article:document.title,cookie_id:A("hhg-id"),ga_client_id:e})})}),[]);const{extra_fields:g,image:v,image_desktop:b,code:f,image_background:y,image_overlay_mobile:k,image_overlay_desktop:_}=e||{},{currentLayout:E}=g,w=g.imageBlocks?JSON.parse(g.imageBlocks):{},C=JSON.parse(g.actionBlocks),N=JSON.parse(g.textBlocks);let T=(null===(u=null===(m=null==N?void 0:N.titleBlock)||void 0===m?void 0:m.data)||void 0===u?void 0:u.value)||"";const S={1:{},2:{},3:{}},x=r("lead-modal-"+c()),O=function(e="Xin chao {{category_2}} extra"){if(e.includes("{{category_")){const t=11,a=e.search("{{category_");return+e.charAt(t+a)}return null}(T);if(O){He("⚡️ Has categoryLevel",O);const e=Array.from(document.getElementsByTagName("META")),t=e.find((e=>e.name===`content_category_${O}`)),a=e.find((e=>e.name===`content_category_en_${O}`));if(!t||!a)return He("⚡️ No META TAG for categoryLevel, not show popup",O),null;S[O]={value:t.content,value_en:a.content},T=T.replace(`{{category_${O}}}`,t.content),He("⚡️ Set categoryData ",O)}else He("⚡️ No categoryLevel",O);const P=()=>{var t,a,l,o;if(He("👌 Other submit click"),document.body.classList.remove("noscroll"),E.includes("Skin")){const e=document.querySelector("#masthead");e&&(e.style.top="0px !important;")}const i=Number(null!==(a=null===(t=e.rules.find((e=>"days_to_show_again"==e.rule)))||void 0===t?void 0:t.value)&&void 0!==a?a:7),r=Number(null!==(o=null===(l=e.rules.find((e=>"show_again_after_submit"==e.rule)))||void 0===l?void 0:l.value)&&void 0!==o?o:0);0===r&&(He("⛔ Popup never show again!"),D(`lead_submited_${f}`,`target_${g.popupVersion}`,{domain:"."+h,path:"/"})),1==r&&(He(`⌛ Popup will show again after ${i} days!`),D(`lead_submited_${f}`,`target_${g.popupVersion}`,{domain:"."+h,days:i,path:"/"}));const s=A("_ga")||null,d={url:location.href.toLowerCase(),title_article:document.title,meta:[],cookie_id:A("hhg-id"),ga_client_id:s};O&&(d.category=S[O].value_en),fetch(`${p}api/campaign/${f}/lead`,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}}).then((e=>e.json())).then((e=>{"error"===e.status&&He(e)})).catch((e=>{He("Error:",e)})),null==n||n()};return"CenterTab"===E?a.createElement(te,{popupId:x.current,url:w.imageMobile.data.url,newTab:w.imageMobile.data.newtab,imageMobile:v,imageDestkop:b,onClose:n,onOtherSubmit:P}):"Tab"===E?a.createElement(Te,{popupId:x.current,url:w.imageMobile.data.url,newTab:w.imageMobile.data.newtab,image:v,onClose:n,onOtherSubmit:P}):"Floating"===E?a.createElement(ae,{popupId:x.current,title:T,titleAlign:N.titleBlock.data.align,subtitle:N.subtitleBlock.data.value,subtitleAlign:N.subtitleBlock.data.align,url:C.linkButtonBlock.data.url,urlText:C.linkButtonBlock.data.value,newTab:C.linkButtonBlock.data.newtab,imageMobile:v,imageDesktop:b,onClose:n,onOtherSubmit:P}):E.includes("LightBox")||E.includes("Inline")||"Fullscreen"==E||"Sidebar"==E||"Slider"==E?a.createElement(Ce,{popupId:x.current,extraFields:g,onClose:n,onOtherSubmit:P,imageMobile:v,imageDesktop:b,imageBackground:y,currentLayout:E,title:T,onSubmit:(e,t)=>l(e,t,O,S),key:E,imageOverlayDesktop:_,imageOverlayMobile:k,showThankyou:i,campaignId:e.id,campaign_subot_id:e.bot_id||[],locale:d}):E.includes("Skin")?a.createElement(Ne,{popupId:x.current,link:C.linkButtonBlock.data.url,linkNewTab:!!C.linkButtonBlock.data.newtab,linkText:C.linkButtonBlock.data.value,onClose:n,onOtherSubmit:P,imageMobile:v,imageDesktop:b,currentLayout:E}):null},Me=({apiUrl:e,siteDomain:l,siteId:s,locale:c,apiSubotUrl:m,DEBUG_URL:u,forceCampaign:b})=>{var f;const y=r(),k=r(Date.now()),{apiUrl:_}=i((()=>{let t=e;return t.includes("localhost")&&(t="https://dev.leadgen.hellobacsi.com/"),{apiUrl:t}}),[e,l,s]),[E,w]=n(b),[C,T]=n(""),[S,O]=n(null);o((()=>{b&&(w(b),T("SHOW"))}),[null==b?void 0:b.code]),o((()=>{le.apiLeadUrl=_,le.apiSubotUrl=m}),[_,m]);const P=(e,t)=>{w(e),T(t)},B=()=>{var e,t;if(!E)return;He(`👋👋👋 CLOSE POPUP ${E.code} 👋👋👋`);const a=Number(null===(e=E.rules.find((e=>"show_again_after_exit"==e.rule)))||void 0===e?void 0:e.value),n=Number(null===(t=E.rules.find((e=>"days_to_show_again"==e.rule)))||void 0===t?void 0:t.value);0==a&&D(`lead_closed_${E.code}`,`target_${null==E?void 0:E.extra_fields.popupVersion}`,n?{domain:"."+l,days:n,path:"/"}:{domain:"."+l,path:"/"}),document.body.classList.remove("noscroll"),fetch(`${_}api/campaign/${E.code}/popup_exit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"CLICK",url:location.href.toLowerCase(),title_article:document.title,cookie_id:A("hhg-id"),duration:Math.ceil((Date.now()-k.current)/1e3)})}),w(null),O(null)};o((()=>{if(!(null==b?void 0:b.code)){if(window.next){const e=d((e=>{He("--🌻 routeChangeComplete",e,Date.now());const t=location.pathname;B(),document.querySelectorAll(`[data-popup-url="${t}"]`).length?He("🔥 This URL page has show popup!"):(He("--Process checkShowPopup"),Ue({leadApi:_,leadDomain:l,leadSiteId:s,onShowPopup:P,DEBUG_URL:u})),y.current&&window.removeEventListener("scroll",y.current)}),500);window.next.router.events.on("routeChangeComplete",e)}Ue({leadApi:_,leadDomain:l,leadSiteId:s,onShowPopup:P,DEBUG_URL:u})}}),[]);const j=(e,a,n,o)=>t(void 0,void 0,void 0,(function*(){var t,i,r,s,d,c,m,u,p,h,g;if(!a)return;He("submitHandler",n,o);const v=Object.keys(a).map((e=>({name:e,value:String(a[e])}))),b=A("_ga")||null;window.intlTelInputUtils||(yield require("intl-tel-input/build/js/utils"));const f={url:location.href.toLowerCase(),title_article:document.title,meta:v.map((t=>{var a,l;const n=(null===(a=e.querySelector(`*[name="${t.name}"][data-control]`))||void 0===a?void 0:a.getAttribute("data-control"))||(null===(l=e.querySelector(`*[data-extra][data-name="${t.name}"]`))||void 0===l?void 0:l.getAttribute("data-control"))||"text",o="tel"===n?window.intlTelInputUtils.formatNumber(String(t.value),null==Y?void 0:Y.countryCodeNumber,2).replace(/\s+/g,""):"date"===n?U(t.value).format("YYYY-MM-DD"):t.value;return{key:t.name,value:o,control:n}})),cookie_id:A("hhg-id"),ga_client_id:b};n&&o[n].value_en&&(f.category=o[n].value_en);const y=Number((null===(i=null===(t=E.rules)||void 0===t?void 0:t.find((e=>"days_to_show_again"===e.rule)))||void 0===i?void 0:i.value)||7),k=Number((null===(s=null===(r=E.rules)||void 0===r?void 0:r.find((e=>"show_again_after_submit"===e.rule)))||void 0===s?void 0:s.value)||0);if(0==k&&(He("⛔ Popup never show again!"),D(`lead_submited_${E.code}`,`target_${null==E?void 0:E.extra_fields.targetType}`,{domain:"."+l,path:"/"})),1==k&&(He(`⌛ Popup will show again after ${y} days!`),D(`lead_submited_${E.code}`,`target_${null==E?void 0:E.extra_fields.targetType}`,{domain:"."+l,days:y,path:"/"})),fetch(`${_}api/campaign/${E.code}/lead`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),"notshow"==(null==E?void 0:E.extra_fields.popupShowThankYou))return B(),void document.body.classList.remove("noscroll");let w=!0;const C=E.thank_you_image||`${_}admin/img/thanksyou.png`;let N,T,S=(null==E?void 0:E.extra_fields.popupThankyouTitle)||"Thank you.",x=(null==E?void 0:E.extra_fields.popupThankyouDesc)||"We appreciate your time!",P="",j="",L="";if("2.1"==(null==E?void 0:E.extra_fields.popupVersion)){const e=E.extra_fields,t=JSON.parse(e.listBlockThankyou),a=t.find((e=>"TitleBlock"==e.name)),l=t.find((e=>"SubtitleBlock"==e.name)),n=t.find((e=>"LinkButtonBlock"==e.name));S=(null===(d=null==a?void 0:a.data)||void 0===d?void 0:d.value)||"",P=(null===(c=null==a?void 0:a.data)||void 0===c?void 0:c.align)||"",x=(null===(m=null==l?void 0:l.data)||void 0===m?void 0:m.value)||"",j=(null===(u=null==l?void 0:l.data)||void 0===u?void 0:u.align)||"",N=(null===(p=null==n?void 0:n.data)||void 0===p?void 0:p.value)||"",T=(null===(h=null==n?void 0:n.data)||void 0===h?void 0:h.newtab)||!1,L=(null===(g=null==n?void 0:n.data)||void 0===g?void 0:g.url)||"";const o=E.extra_fields.currentLayout;["SkinA","SkinB","Floating","Tab","CenterTab"].includes(o)&&(w=!1)}O(w?{title:S,titleAlign:P,subtitle:x,subtitleAlign:j,link:L,linkNewTab:T,linkText:N,image:C}:null),sessionStorage.getItem("insider_object")?window.insider_object=JSON.parse(sessionStorage.getItem("insider_object")):window.insider_object={user:{email:"",phone_number:"",gdpr_optin:!0,sms_optin:!0,email_optin:!0}},v.map((e=>{const t=e.name,a=e.value;"tel"==t?window.insider_object.user.phone_number=a:"email"==t&&(window.insider_object.user.email=a)})),sessionStorage.setItem("insider_object",JSON.stringify(window.insider_object))}));return o((()=>{E&&(k.current=Date.now())}),[E]),a.createElement(X.Provider,{value:{apiUrl:_,siteDomain:l,siteId:s,locale:c}},a.createElement(x.Provider,{value:{locale:c,values:Q(c)}},a.createElement(p,{target:N()},a.createElement(h,{sx:{position:"fixed",zIndex:9999999999}},a.createElement(g,{mounted:Boolean("2.1"===(null===(f=null==E?void 0:E.extra_fields)||void 0===f?void 0:f.popupVersion)),transition:"fade",duration:600,timingFunction:"ease"},(e=>{var t;return a.createElement(h,{style:e},"2.1"===(null===(t=null==E?void 0:E.extra_fields)||void 0===t?void 0:t.popupVersion)&&a.createElement(a.Fragment,null,!!E.extra_fields.currentLayout&&!E.extra_fields.currentLayout.includes("Inline")&&!E.extra_fields.currentLayout.includes("Sidebar")&&a.createElement(v,{color:"#000",opacity:.5,center:!0,zIndex:400,pos:"fixed",onClick:()=>B()}),a.createElement(Re,{campaign:E,action:C,onSubmit:j,onClose:B,showThankyou:S,locale:c})))}))))))};export{Me as LeadGen};
|
|
1
|
+
import { _ as __rest, a as __awaiter } from './tslib.es6-1b1533a9.js';
|
|
2
|
+
import React__default, { createContext, useState, useEffect, useMemo, useRef, useContext } from 'react';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import { v1 } from 'uuid';
|
|
5
|
+
import { B as Button } from './index-6ea6484e.js';
|
|
6
|
+
import { C as CommonGAssets } from './index-8858383e.js';
|
|
7
|
+
import { Portal, Box, Transition, Overlay } from '@mantine/core';
|
|
8
|
+
import { T as Text } from './index-3474401a.js';
|
|
9
|
+
import './index.styles-5add27c5.js';
|
|
10
|
+
import { S as Select, d as Checkbox, c as Input, R as Radio, P as Phone, N as NumberInput } from './index-32e53dac.js';
|
|
11
|
+
import './constants-b77ffe3d.js';
|
|
12
|
+
import './Subot-3289bd8e.js';
|
|
13
|
+
import './utils-6d7b88da.js';
|
|
14
|
+
import { b as getWrapperDomWithSelector, a as getPopupWrapperDom } from './utils-2c484c05.js';
|
|
15
|
+
import { D as DatePicker } from './index-9ea7e838.js';
|
|
16
|
+
import { t as theme } from './theme-e74db08c.js';
|
|
17
|
+
import { T as TranslationsContext } from './translationsContext-ad3e25de.js';
|
|
18
|
+
import 'string-format';
|
|
19
|
+
import '@mantine/hooks';
|
|
20
|
+
import './index-e612be9c.js';
|
|
21
|
+
import './utils-70718e9c.js';
|
|
22
|
+
import './index.styled-9c9db9cc.js';
|
|
23
|
+
import './index-12fa4985.js';
|
|
24
|
+
import { M as MAPPED_LOCALE } from './utils-3a2a47d9.js';
|
|
25
|
+
import '@mantine/dates';
|
|
26
|
+
import { u as usePlacesAutocomplete, G as GOOGLE_API_KEY } from './usePlacesAutocomplete-63e04e8e.js';
|
|
27
|
+
import { createFormContext } from '@mantine/form';
|
|
28
|
+
import { u as useTranslations } from './useTranslations-4f1db486.js';
|
|
29
|
+
import { H as Heading } from './index-34899aa3.js';
|
|
30
|
+
import { createPortal } from 'react-dom';
|
|
31
|
+
import { g as getCookie, s as setCookie } from './cookieHelper-d314282c.js';
|
|
32
|
+
import dayjs from 'dayjs';
|
|
33
|
+
import './isProduction-0ea904dd.js';
|
|
34
|
+
import 'styled-components';
|
|
35
|
+
import './animation-3d5edc39.js';
|
|
36
|
+
import 'react-keyed-flatten-children';
|
|
37
|
+
import '@hhgtech/icons/other';
|
|
38
|
+
import '@mantine/carousel';
|
|
39
|
+
import 'classnames';
|
|
40
|
+
import './useUniqueId-3638402f.js';
|
|
41
|
+
import '@hhgtech/icons/core';
|
|
42
|
+
import 'date-fns/locale';
|
|
43
|
+
import 'slugify';
|
|
44
|
+
|
|
45
|
+
const CAMPAIGN_TARGET_TYPE = { LINKS: 1, TAGS: 2 };
|
|
46
|
+
let LEAD_API = 'https://dev.leadgen.hellobacsi.com/';
|
|
47
|
+
const LEAD_DEVICE_TYPE = {
|
|
48
|
+
MOBILE: 1,
|
|
49
|
+
DESKTOP: 2,
|
|
50
|
+
};
|
|
51
|
+
let LEAD_CLASS = '';
|
|
52
|
+
if (LEAD_API.includes('localhost')) {
|
|
53
|
+
LEAD_API = 'https://dev.leadgen.hellobacsi.com/';
|
|
54
|
+
}
|
|
55
|
+
if (location.hostname.includes('marrybaby.vn')) {
|
|
56
|
+
LEAD_CLASS = 'pink';
|
|
57
|
+
}
|
|
58
|
+
// var LEAD_CURRENT_URL = location.href.toLowerCase();
|
|
59
|
+
let LEAD_CURRENT_URL = 'https://' + location.hostname + location.pathname + location.search;
|
|
60
|
+
LEAD_CURRENT_URL = LEAD_CURRENT_URL.toLowerCase();
|
|
61
|
+
// TODO: set inital object if exists
|
|
62
|
+
if (sessionStorage.getItem('insider_object')) {
|
|
63
|
+
window.insider_object = JSON.parse(sessionStorage.getItem('insider_object'));
|
|
64
|
+
}
|
|
65
|
+
const docLang = document.documentElement.lang;
|
|
66
|
+
// TODO: country code
|
|
67
|
+
const LEAD_LOCALE_DATA = {
|
|
68
|
+
'vi-VN': {
|
|
69
|
+
popupLang: 'vi',
|
|
70
|
+
countryCode: 'vn',
|
|
71
|
+
countryCodeNumber: 84,
|
|
72
|
+
},
|
|
73
|
+
'id-ID': {
|
|
74
|
+
popupLang: 'id',
|
|
75
|
+
countryCode: 'id',
|
|
76
|
+
countryCodeNumber: 62,
|
|
77
|
+
},
|
|
78
|
+
'th-TH': {
|
|
79
|
+
popupLang: 'th',
|
|
80
|
+
countryCode: 'th',
|
|
81
|
+
countryCodeNumber: 66,
|
|
82
|
+
},
|
|
83
|
+
'ms-MY': {
|
|
84
|
+
popupLang: 'ms',
|
|
85
|
+
countryCode: 'my',
|
|
86
|
+
countryCodeNumber: 60,
|
|
87
|
+
},
|
|
88
|
+
'zh-TW': {
|
|
89
|
+
popupLang: 'zh',
|
|
90
|
+
countryCode: 'tw',
|
|
91
|
+
countryCodeNumber: 886,
|
|
92
|
+
},
|
|
93
|
+
'km-KH': {
|
|
94
|
+
popupLang: 'km',
|
|
95
|
+
countryCode: 'kh',
|
|
96
|
+
countryCodeNumber: 855,
|
|
97
|
+
},
|
|
98
|
+
'my-MM': {
|
|
99
|
+
popupLang: 'my',
|
|
100
|
+
countryCode: 'mm',
|
|
101
|
+
countryCodeNumber: 95,
|
|
102
|
+
},
|
|
103
|
+
'hi-IN': {
|
|
104
|
+
popupLang: 'hi',
|
|
105
|
+
countryCode: 'in',
|
|
106
|
+
countryCodeNumber: 91,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
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
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var enPH = {
|
|
131
|
+
"validator.required": "This field is required.",
|
|
132
|
+
"validator.remote": "Please fix this field.",
|
|
133
|
+
"validator.email": "Please enter a valid email address.",
|
|
134
|
+
"validator.phone": "Please input correct phone number.",
|
|
135
|
+
"validator.url": "Please enter a valid URL.",
|
|
136
|
+
"validator.date": "Please enter a valid date.",
|
|
137
|
+
"validator.dateISO": "Please enter a valid date (ISO).",
|
|
138
|
+
"validator.number": "Please enter a valid number.",
|
|
139
|
+
"validator.digits": "Please enter only digits.",
|
|
140
|
+
"validator.creditcard": "Please enter a valid credit card number.",
|
|
141
|
+
"validator.equalTo": "Please enter the same value again.",
|
|
142
|
+
"validator.accept": "Please enter a value with a valid extension.",
|
|
143
|
+
"validator.maxlength": "jQuery.validator.format('Please enter no more than {0} characters.",
|
|
144
|
+
"validator.minlength": "jQuery.validator.format('Please enter at least {0} characters.",
|
|
145
|
+
"validator.rangelength": "jQuery.validator.format('Please enter a value between {0} and {1} characters long.",
|
|
146
|
+
"validator.range": "jQuery.validator.format('Please enter a value between {0} and {1}.",
|
|
147
|
+
"validator.max": "jQuery.validator.format('Please enter a value less than or equal to {0}.",
|
|
148
|
+
"validator.min": "jQuery.validator.format('Please enter a value greater than or equal to {0}.",
|
|
149
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
150
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
151
|
+
"lead.otp.title": "Enter OTP",
|
|
152
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
153
|
+
"lead.otp.verify": "Verify",
|
|
154
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var hiIN = {
|
|
158
|
+
"validator.required": "इस क्षेत्र की आवश्यकता है।",
|
|
159
|
+
"validator.email": "कृपया एक मान्य ईमेल पता दर्ज करें",
|
|
160
|
+
"validator.number": "कृपया एक वैध संख्या दर्ज करें",
|
|
161
|
+
"validator.digits": "कृपया केवल अंक दर्ज करें",
|
|
162
|
+
"validator.maxlength": "कृपया {0} अक्षर से अधिक दर्ज न करें",
|
|
163
|
+
"validator.minlength": "कृपया कम से कम {0} अक्षर दर्ज करें",
|
|
164
|
+
"validator.phone": "कृपया एक वैध संख्या दर्ज करें",
|
|
165
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
166
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
167
|
+
"lead.otp.title": "Enter OTP",
|
|
168
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
169
|
+
"lead.otp.verify": "Verify",
|
|
170
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var idID = {
|
|
174
|
+
"validator.required": "Kolom ini wajib diisi",
|
|
175
|
+
"validator.email": "Tolong daftarkan email yang valid",
|
|
176
|
+
"validator.number": "Tolong daftarkan nomor telepon yang valid",
|
|
177
|
+
"validator.digits": "Tolong masukkan angka saja",
|
|
178
|
+
"validator.maxlength": "Jangan memasukkan lebih dari {0} karakter",
|
|
179
|
+
"validator.minlength": "Tolong ketik sedikitnya {0} karakter",
|
|
180
|
+
"validator.phone": "Tolong daftarkan nomor telepon yang valid",
|
|
181
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
182
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
183
|
+
"lead.otp.title": "Enter OTP",
|
|
184
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
185
|
+
"lead.otp.verify": "Verify",
|
|
186
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var kmKH = {
|
|
190
|
+
"validator.required": "ព័ត៌មានចាំបាច់ដែលត្រូវបំពេញ",
|
|
191
|
+
"validator.email": "សូមវាយអាសយដ្ឋានអ៊ីម៉ែលឲ្យបានត្រឹមត្រូវ",
|
|
192
|
+
"validator.number": "សូមវាយបញ្ចូលលេខឲ្យបានត្រឹមត្រូវ",
|
|
193
|
+
"validator.digits": "វាយបញ្ចូលបានតែលេខប៉ុណ្ណោះ",
|
|
194
|
+
"validator.maxlength": "សូមវាយបញ្ចូលកុំឲ្យលើស {0} តួអក្សរ",
|
|
195
|
+
"validator.minlength": "សូមវាយបញ្ចូលតិចបំផុត {0} តួអក្ស",
|
|
196
|
+
"validator.phone": "សូមវាយបញ្ចូលលេខឲ្យបានត្រឹមត្រូវ",
|
|
197
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
198
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
199
|
+
"lead.otp.title": "Enter OTP",
|
|
200
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
201
|
+
"lead.otp.verify": "Verify",
|
|
202
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
var msMY = {
|
|
206
|
+
"validator.required": "Bahagian ini wajib diisi.",
|
|
207
|
+
"validator.email": "Sila masukkan alamat emel yang sah.",
|
|
208
|
+
"validator.number": "Sila masukkan no telefon yang sah.",
|
|
209
|
+
"validator.digits": "Sila masukkan nombor digit sahaja.",
|
|
210
|
+
"validator.maxlength": "Sila masukkan tidak lebih dari {0} aksara",
|
|
211
|
+
"validator.minlength": "Sila masukkan sekurang-kurangnya {0} aksara",
|
|
212
|
+
"validator.phone": "Sila masukkan no telefon yang sah.",
|
|
213
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
214
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
215
|
+
"lead.otp.title": "Enter OTP",
|
|
216
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
217
|
+
"lead.otp.verify": "Verify",
|
|
218
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
var myMM = {
|
|
222
|
+
"validator.required": "ဒီနေရာမှာ ဖြည့်ဖို့ လိုအပ်ပါတယ်",
|
|
223
|
+
"validator.email": "မှန်ကန်သော အီးမေးလ်လိပ်စာထည့်သွင်းပါ",
|
|
224
|
+
"validator.number": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
|
|
225
|
+
"validator.digits": "နံပါတ်များသာဖြည့်ပါ",
|
|
226
|
+
"validator.maxlength": "ကျေးဇူးပြု၍ {0} ထပ်မပိုသော ဂဏန်းများသာဖြည့်ပါ",
|
|
227
|
+
"validator.minlength": "ကျေးဇူးပြု၍ အနည်းဆုံး {0} ဂဏန်းဖြည့်ပါ",
|
|
228
|
+
"validator.phone": "မှန်ကန်သော ဖုန်းနံပါတ်ထည့်သွင်းပါ",
|
|
229
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
230
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
231
|
+
"lead.otp.title": "Enter OTP",
|
|
232
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
233
|
+
"lead.otp.verify": "Verify",
|
|
234
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
var thTH = {
|
|
238
|
+
"validator.required": "ต้องระบุข้อมูลในช่องนี้",
|
|
239
|
+
"validator.email": "กรุณาใส่อีเมล์ที่ถูกต้อง",
|
|
240
|
+
"validator.number": "กรุณาใส่ตัวเลขที่ถูกต้อง",
|
|
241
|
+
"validator.digits": "กรุณาส่เฉพาะตัวเลข",
|
|
242
|
+
"validator.maxlength": "กรุณาใส่ตัวเลขมากกว่า {0} หลัก",
|
|
243
|
+
"validator.minlength": "กรุณาใส่ตัวเลขอย่างน้อย {0} หลัก",
|
|
244
|
+
"validator.phone": "กรุณาใส่ตัวเลขที่ถูกต้อง",
|
|
245
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
246
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
247
|
+
"lead.otp.title": "Enter OTP",
|
|
248
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
249
|
+
"lead.otp.verify": "Verify",
|
|
250
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
var viVN = {
|
|
254
|
+
"validator.required": "Vui lòng điền mục này",
|
|
255
|
+
"validator.email": "Vui lòng điền email có thật.",
|
|
256
|
+
"validator.number": "Vui lòng điền số có thật",
|
|
257
|
+
"validator.digits": "Vui lòng chỉ điền số",
|
|
258
|
+
"validator.maxlength": "Vui lòng điền dưới {0} số",
|
|
259
|
+
"validator.minlength": "Vui lòng điền hơn {0} số",
|
|
260
|
+
"validator.remote": "Hãy sửa cho đúng.",
|
|
261
|
+
"validator.url": "Hãy nhập URL.",
|
|
262
|
+
"validator.date": "Hãy nhập ngày.",
|
|
263
|
+
"validator.dateISO": "Hãy nhập ngày (ISO).",
|
|
264
|
+
"validator.creditcard": "Hãy nhập số thẻ tín dụng.",
|
|
265
|
+
"validator.equalTo": "Hãy nhập thêm lần nữa.",
|
|
266
|
+
"validator.extension": "Phần mở rộng không đúng.",
|
|
267
|
+
"validator.rangelength": "Hãy nhập từ {0} đến {1} kí tự.",
|
|
268
|
+
"validator.range": "Hãy nhập từ {0} đến {1}.",
|
|
269
|
+
"validator.max": "Hãy nhập từ {0} trở xuống.",
|
|
270
|
+
"validator.min": "Hãy nhập từ {0} trở lên.",
|
|
271
|
+
"validator.phone": "Nhập đúng định dạng số điện thoại",
|
|
272
|
+
"validator.emailUsed": "Email này đã được sử dụng cho chiến dịch.",
|
|
273
|
+
"validator.phoneUsed": "Số điện thoại này đã được sử dụng cho chiến dịch.",
|
|
274
|
+
"lead.otp.title": "Enter OTP",
|
|
275
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
276
|
+
"lead.otp.verify": "Verify",
|
|
277
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
var zhTW = {
|
|
281
|
+
"validator.required": "此為必填欄位",
|
|
282
|
+
"validator.email": "請填入有效的 email 地址",
|
|
283
|
+
"validator.number": "請填入有效的電話號碼",
|
|
284
|
+
"validator.digits": "此欄位僅能輸入數字",
|
|
285
|
+
"validator.maxlength": "請輸入少於 {0} 位數",
|
|
286
|
+
"validator.minlength": "請輸入至少 {0} 位數",
|
|
287
|
+
"validator.phone": "請填入有效的電話號碼",
|
|
288
|
+
"validator.emailUsed": "Email already in use for this campaign.",
|
|
289
|
+
"validator.phoneUsed": "Your phone number already in use for this campaign.",
|
|
290
|
+
"lead.otp.title": "Enter OTP",
|
|
291
|
+
"lead.otp.desc": "We have sent an OTP to your mobile number {phone}",
|
|
292
|
+
"lead.otp.verify": "Verify",
|
|
293
|
+
"lead.otp.resend": "Resend OTP{timer}"
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const translationsMap = {
|
|
297
|
+
'en-PH': enPH,
|
|
298
|
+
'vi-VN': viVN,
|
|
299
|
+
'hi-IN': hiIN,
|
|
300
|
+
'id-ID': idID,
|
|
301
|
+
'ms-MY': msMY,
|
|
302
|
+
'my-MM': myMM,
|
|
303
|
+
'km-KH': kmKH,
|
|
304
|
+
'zh-TW': zhTW,
|
|
305
|
+
'th-TH': thTH,
|
|
306
|
+
'tl-PH': enPH,
|
|
307
|
+
};
|
|
308
|
+
const getTranslations = (locale) => {
|
|
309
|
+
const translations = translationsMap[locale];
|
|
310
|
+
if (translations) {
|
|
311
|
+
return translations;
|
|
312
|
+
}
|
|
313
|
+
return translationsMap['en-PH'];
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const LeadGenContext = createContext({});
|
|
317
|
+
|
|
318
|
+
const useImageSize = (src) => {
|
|
319
|
+
const [width, setWidth] = useState(16);
|
|
320
|
+
const [height, setHeight] = useState(9);
|
|
321
|
+
const [loaded, setLoaded] = useState(false);
|
|
322
|
+
// load src image to get its width and height
|
|
323
|
+
useEffect(() => {
|
|
324
|
+
setLoaded(false);
|
|
325
|
+
if (src) {
|
|
326
|
+
const img = new Image();
|
|
327
|
+
img.addEventListener('load', () => {
|
|
328
|
+
setWidth(img.naturalWidth);
|
|
329
|
+
setHeight(img.naturalHeight);
|
|
330
|
+
setLoaded(true);
|
|
331
|
+
});
|
|
332
|
+
img.addEventListener('error', () => {
|
|
333
|
+
setWidth(16);
|
|
334
|
+
setHeight(9);
|
|
335
|
+
setLoaded(true);
|
|
336
|
+
});
|
|
337
|
+
img.src = src;
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
setWidth(16);
|
|
341
|
+
setHeight(9);
|
|
342
|
+
setLoaded(true);
|
|
343
|
+
}
|
|
344
|
+
}, [src]);
|
|
345
|
+
return {
|
|
346
|
+
loaded,
|
|
347
|
+
width,
|
|
348
|
+
height,
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const CloseButton = ({ onClose, containerClassName, svgClassName, }) => (React__default.createElement("button", { onClick: onClose, className: `le-newbuilder-close-button js-modal__close ${containerClassName || ''}` },
|
|
353
|
+
React__default.createElement("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", className: svgClassName },
|
|
354
|
+
React__default.createElement("circle", { cx: "16", cy: "16", r: "16", fill: "white" }),
|
|
355
|
+
React__default.createElement("path", { d: "M16 17.05L10.925 22.125C10.7917 22.2584 10.621 22.329 10.413 22.337C10.2044 22.3457 10.025 22.275 9.87502 22.125C9.72502 21.975 9.65002 21.8 9.65002 21.6C9.65002 21.4 9.72502 21.225 9.87502 21.075L14.95 16L9.87502 10.925C9.74169 10.7917 9.67102 10.6207 9.66302 10.412C9.65436 10.204 9.72502 10.025 9.87502 9.87502C10.025 9.72502 10.2 9.65002 10.4 9.65002C10.6 9.65002 10.775 9.72502 10.925 9.87502L16 14.95L21.075 9.87502C21.2084 9.74169 21.3794 9.67069 21.588 9.66202C21.796 9.65402 21.975 9.72502 22.125 9.87502C22.275 10.025 22.35 10.2 22.35 10.4C22.35 10.6 22.275 10.775 22.125 10.925L17.05 16L22.125 21.075C22.2584 21.2084 22.329 21.379 22.337 21.587C22.3457 21.7957 22.275 21.975 22.125 22.125C21.975 22.275 21.8 22.35 21.6 22.35C21.4 22.35 21.225 22.275 21.075 22.125L16 17.05Z", fill: "#595959" }))));
|
|
356
|
+
|
|
357
|
+
// url: imageBlocks.imageMobile.data.url
|
|
358
|
+
// newTab: imageBlocks.imageMobile.data.newtab
|
|
359
|
+
// imageMobile: campaignShow.image
|
|
360
|
+
// imageDestkop: campaignShow.image_desktop
|
|
361
|
+
const CenterTabLayout = ({ popupId, url, newTab, imageDestkop, imageMobile, onClose, onOtherSubmit, }) => {
|
|
362
|
+
const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
|
|
363
|
+
const { width: imageDestkopWidth, height: imageDestkopHeight, loaded: imageDestkopLoaded, } = useImageSize(imageDestkop);
|
|
364
|
+
if (!imageMobileLoaded || !imageDestkopLoaded)
|
|
365
|
+
return null;
|
|
366
|
+
return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "center_tab" },
|
|
367
|
+
React__default.createElement("div", { className: "le-center-tab-popup" },
|
|
368
|
+
React__default.createElement("div", { style: { position: 'relative' } },
|
|
369
|
+
React__default.createElement("a", { className: "js-popup-other-submit", href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
|
|
370
|
+
React__default.createElement("img", { className: "le-only-mobile", src: imageMobile, style: {
|
|
371
|
+
aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
|
|
372
|
+
} }),
|
|
373
|
+
React__default.createElement("img", { className: "le-only-desktop", src: imageDestkop, style: {
|
|
374
|
+
aspectRatio: `${imageDestkopWidth}/${imageDestkopHeight}`,
|
|
375
|
+
} })),
|
|
376
|
+
React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
// title: titleText
|
|
380
|
+
// titleAlign: textBlocks.titleBlock.data.align
|
|
381
|
+
// subtitle: textBlocks.subtitleBlock.data.value
|
|
382
|
+
// subtitleAlign: textBlocks.subtitleBlock.data.align
|
|
383
|
+
// url: actionBlocks.linkButtonBlock.data.url
|
|
384
|
+
// urlText: actionBlocks.linkButtonBlock.data.value
|
|
385
|
+
// newTab: actionBlocks.linkButtonBlock.data.newtab
|
|
386
|
+
// imageMobile: campaignShow.image
|
|
387
|
+
// imageDesktop: campaignShow.image_desktop
|
|
388
|
+
const FloatingLayout = ({ popupId, url, title, urlText, titleAlign, subtitle, subtitleAlign, newTab, imageDesktop, imageMobile, onClose, onOtherSubmit, }) => {
|
|
389
|
+
const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
|
|
390
|
+
const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
|
|
391
|
+
if (!imageMobileLoaded || !imageDesktopLoaded)
|
|
392
|
+
return null;
|
|
393
|
+
return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper lead-floating-wrapper", "data-popup-url": location.pathname, "data-popup-type": "floating" },
|
|
394
|
+
React__default.createElement("aside", { className: "le-only-desktop" },
|
|
395
|
+
React__default.createElement("div", { className: "le-floating-desktop" },
|
|
396
|
+
React__default.createElement("div", { className: "le-floating-desktop-wrap", style: { position: 'relative', background: '#fff' } },
|
|
397
|
+
imageDesktop ? (React__default.createElement("div", null,
|
|
398
|
+
React__default.createElement("img", { style: {
|
|
399
|
+
maxWidth: 120,
|
|
400
|
+
borderTopLeftRadius: 5,
|
|
401
|
+
borderBottomLeftRadius: 5,
|
|
402
|
+
aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
|
|
403
|
+
}, src: imageDesktop }))) : null,
|
|
404
|
+
React__default.createElement("div", { style: { padding: 20 } },
|
|
405
|
+
React__default.createElement("div", { className: `le-floating-desktop-title le-text-align-${titleAlign}` }, title),
|
|
406
|
+
React__default.createElement("div", { className: `le-floating-desktop-desc le-text-align-${subtitleAlign}` }, subtitle)),
|
|
407
|
+
React__default.createElement("a", { target: newTab ? 'blank' : '_parent', style: { marginLeft: 35, textDecoration: 'none' }, href: url },
|
|
408
|
+
React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText)),
|
|
409
|
+
React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))),
|
|
410
|
+
React__default.createElement("aside", { className: "le-only-mobile" },
|
|
411
|
+
React__default.createElement("div", { className: "le-floating-mobile" },
|
|
412
|
+
React__default.createElement("div", { className: "le-floating-mobile-wrap", style: { position: 'relative', background: '#fff' } },
|
|
413
|
+
React__default.createElement("aside", { style: { display: 'flex', justifyContent: 'space-between' } },
|
|
414
|
+
React__default.createElement("div", null,
|
|
415
|
+
React__default.createElement("div", { className: `le-floating-mobile-title le-text-align-${titleAlign}` }, title),
|
|
416
|
+
React__default.createElement("div", { className: `le-floating-mobile-desc le-text-align-${subtitleAlign}` }, subtitle)),
|
|
417
|
+
imageMobile ? (React__default.createElement("div", null,
|
|
418
|
+
React__default.createElement("img", { style: {
|
|
419
|
+
marginLeft: 15,
|
|
420
|
+
marginTop: 4,
|
|
421
|
+
maxWidth: 100,
|
|
422
|
+
aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
|
|
423
|
+
}, src: imageMobile }))) : null),
|
|
424
|
+
React__default.createElement("div", { style: { textAlign: 'center', marginTop: 10 } },
|
|
425
|
+
React__default.createElement("a", { target: newTab ? 'blank' : '_parent', href: url, style: { textDecoration: 'none' } },
|
|
426
|
+
React__default.createElement("button", { className: "le-joinbow-floating-btn js-popup-other-submit", onClick: onOtherSubmit }, urlText))),
|
|
427
|
+
React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
|
|
428
|
+
};
|
|
429
|
+
|
|
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
|
+
// You can give context variables any name
|
|
590
|
+
const [LeadFormProvider, useLeadFormContext, useLeadForm] = createFormContext();
|
|
591
|
+
const useLeadFormConfig = ({ listBlockAdded = [], validatingPhoneRef, validatingEmailRef, campaignId, campaign_subot_id = [], }) => {
|
|
592
|
+
const { t } = useTranslations();
|
|
593
|
+
const validateObj = useMemo(() => {
|
|
594
|
+
const InputBlocks = [
|
|
595
|
+
'TextBlock',
|
|
596
|
+
'NumberBlock',
|
|
597
|
+
'EmailBlock',
|
|
598
|
+
'PhoneBlock',
|
|
599
|
+
'DateBlock',
|
|
600
|
+
'CheckboxBlock',
|
|
601
|
+
'RadioBlock',
|
|
602
|
+
'DropdownBlock',
|
|
603
|
+
'PhoneOtpBlock',
|
|
604
|
+
'WhatsappOtpBlock',
|
|
605
|
+
'LocationBlock',
|
|
606
|
+
'TncBlock',
|
|
607
|
+
];
|
|
608
|
+
// ALL are required and can skip if not touched yet
|
|
609
|
+
const withSharedCheck = (name, cb) => {
|
|
610
|
+
return (value) => {
|
|
611
|
+
if (!formRef.current.isTouched(name))
|
|
612
|
+
return;
|
|
613
|
+
if (typeof value === 'undefined' ||
|
|
614
|
+
value === '' ||
|
|
615
|
+
(Array.isArray(value) && value.length === 0)) {
|
|
616
|
+
return t('validator.required');
|
|
617
|
+
}
|
|
618
|
+
return cb === null || cb === void 0 ? void 0 : cb(value);
|
|
619
|
+
};
|
|
620
|
+
};
|
|
621
|
+
return listBlockAdded
|
|
622
|
+
.filter((b) => InputBlocks.includes(b.name))
|
|
623
|
+
.reduce((r, b) => {
|
|
624
|
+
if (b.name === 'NumberBlock') {
|
|
625
|
+
return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
|
|
626
|
+
if (isNaN(Number(value))) {
|
|
627
|
+
return t('validator.number');
|
|
628
|
+
}
|
|
629
|
+
}) });
|
|
630
|
+
}
|
|
631
|
+
else if (b.name === 'EmailBlock') {
|
|
632
|
+
return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
|
|
633
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
|
|
634
|
+
return t('validator.email');
|
|
635
|
+
}
|
|
636
|
+
validatingEmailRef.current = true;
|
|
637
|
+
setTimeout(() => {
|
|
638
|
+
formRef.current.setFieldError(b.data.value, 'Validating...');
|
|
639
|
+
checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
|
|
640
|
+
email: value,
|
|
641
|
+
})
|
|
642
|
+
.then((tKey) => {
|
|
643
|
+
if (tKey) {
|
|
644
|
+
formRef.current.setFieldError(b.data.value, t(tKey));
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
formRef.current.clearFieldError(b.data.value);
|
|
648
|
+
}
|
|
649
|
+
validatingEmailRef.current = false;
|
|
650
|
+
})
|
|
651
|
+
.catch((e) => {
|
|
652
|
+
console.error(e);
|
|
653
|
+
formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
|
|
654
|
+
validatingEmailRef.current = false;
|
|
655
|
+
});
|
|
656
|
+
}, 200);
|
|
657
|
+
}) });
|
|
658
|
+
}
|
|
659
|
+
else if (b.name === 'PhoneBlock' ||
|
|
660
|
+
b.name === 'PhoneOtpBlock' ||
|
|
661
|
+
b.name === 'WhatsappOtpBlock') {
|
|
662
|
+
return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
|
|
663
|
+
if (window.intlTelInputUtils &&
|
|
664
|
+
!window.intlTelInputUtils.isValidNumber(String(value), LEAD_LOCALE.countryCode)) {
|
|
665
|
+
return t('validator.phone');
|
|
666
|
+
}
|
|
667
|
+
validatingPhoneRef.current = true;
|
|
668
|
+
setTimeout(() => {
|
|
669
|
+
formRef.current.setFieldError(b.data.value, 'Validating...');
|
|
670
|
+
checkUsedEmailOrPhoneWithCache(campaignId, campaign_subot_id, {
|
|
671
|
+
phone: value,
|
|
672
|
+
})
|
|
673
|
+
.then((tKey) => {
|
|
674
|
+
if (tKey) {
|
|
675
|
+
formRef.current.setFieldError(b.data.value, t(tKey));
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
formRef.current.clearFieldError(b.data.value);
|
|
679
|
+
}
|
|
680
|
+
validatingPhoneRef.current = false;
|
|
681
|
+
})
|
|
682
|
+
.catch((e) => {
|
|
683
|
+
console.error(e);
|
|
684
|
+
formRef.current.setFieldError(b.data.value, e.message || 'Something went wrong');
|
|
685
|
+
validatingPhoneRef.current = false;
|
|
686
|
+
});
|
|
687
|
+
}, 200);
|
|
688
|
+
}) });
|
|
689
|
+
}
|
|
690
|
+
else if (b.name === 'DateBlock') {
|
|
691
|
+
return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value, (value) => {
|
|
692
|
+
if (isNaN(Date.parse(value))) {
|
|
693
|
+
return t('validator.date');
|
|
694
|
+
}
|
|
695
|
+
}) });
|
|
696
|
+
}
|
|
697
|
+
else if (b.name === 'TncBlock') {
|
|
698
|
+
return Object.assign(Object.assign({}, r), { [`TNC-` + b.id]: withSharedCheck('TNC-' + b.id) });
|
|
699
|
+
}
|
|
700
|
+
else {
|
|
701
|
+
return Object.assign(Object.assign({}, r), { [b.data.value]: withSharedCheck(b.data.value) });
|
|
702
|
+
}
|
|
703
|
+
}, {});
|
|
704
|
+
}, [listBlockAdded.map((b) => b.name).join(',')]);
|
|
705
|
+
const form = useLeadForm({
|
|
706
|
+
validateInputOnChange: true,
|
|
707
|
+
clearInputErrorOnChange: true,
|
|
708
|
+
validate: validateObj,
|
|
709
|
+
});
|
|
710
|
+
const formRef = useRef(form);
|
|
711
|
+
formRef.current = form;
|
|
712
|
+
return { form, validateObj };
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
const libraries = ['places'];
|
|
716
|
+
const LocationBlock = ({ name, placeholder, locale, }) => {
|
|
717
|
+
var _a;
|
|
718
|
+
const form = useLeadFormContext();
|
|
719
|
+
const [searchValue, setSearchValue] = useState('');
|
|
720
|
+
const [address, setAddress] = useState('');
|
|
721
|
+
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]);
|
|
722
|
+
const [LoadScript, setLoadScript] = useState(null);
|
|
723
|
+
const [ready, setReady] = useState(false);
|
|
724
|
+
const randRef = useRef(Math.random().toString(36).substring(7));
|
|
725
|
+
const options = useMemo(() => {
|
|
726
|
+
const _opts = predictions.map((p) => {
|
|
727
|
+
return {
|
|
728
|
+
value: p.description,
|
|
729
|
+
label: p.description,
|
|
730
|
+
};
|
|
731
|
+
});
|
|
732
|
+
const isExist = _opts.find((o) => o.value === address);
|
|
733
|
+
if (!address || isExist) {
|
|
734
|
+
return _opts;
|
|
735
|
+
}
|
|
736
|
+
return [{ value: address, label: address }].concat(_opts);
|
|
737
|
+
}, [predictions, address]);
|
|
738
|
+
useEffect(() => {
|
|
739
|
+
var _a, _b, _c;
|
|
740
|
+
// only load extra google script when not yet loaded
|
|
741
|
+
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)) {
|
|
742
|
+
import('@react-google-maps/api').then((m) => {
|
|
743
|
+
setLoadScript(() => m.LoadScript);
|
|
744
|
+
setTimeout(() => {
|
|
745
|
+
setReady(true);
|
|
746
|
+
}, 200);
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
setReady(true);
|
|
751
|
+
}
|
|
752
|
+
}, []);
|
|
753
|
+
if (!ready)
|
|
754
|
+
return (React__default.createElement("div", { style: {
|
|
755
|
+
height: 73,
|
|
756
|
+
} }));
|
|
757
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
758
|
+
LoadScript && (React__default.createElement(LoadScript, { googleMapsApiKey: GOOGLE_API_KEY, libraries: libraries, loadingElement: React__default.createElement(React__default.Fragment, null) })),
|
|
759
|
+
React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": name, "data-control": 'text' }),
|
|
760
|
+
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) => {
|
|
761
|
+
setSearchValue(query);
|
|
762
|
+
}, 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" },
|
|
763
|
+
React__default.createElement("path", { d: "M9.99999 9.79167C10.4028 9.79167 10.7467 9.64944 11.0317 9.365C11.3161 9.08 11.4583 8.73611 11.4583 8.33333C11.4583 7.93056 11.3161 7.58667 11.0317 7.30167C10.7467 7.01722 10.4028 6.875 9.99999 6.875C9.59721 6.875 9.25332 7.01722 8.96832 7.30167C8.68388 7.58667 8.54166 7.93056 8.54166 8.33333C8.54166 8.73611 8.68388 9.08 8.96832 9.365C9.25332 9.64944 9.59721 9.79167 9.99999 9.79167ZM9.99999 17.875C9.90277 17.875 9.80555 17.8611 9.70832 17.8333C9.6111 17.8056 9.52082 17.7569 9.43749 17.6875C7.46527 15.8958 5.98971 14.2361 5.01082 12.7083C4.03138 11.1806 3.54166 9.77778 3.54166 8.5C3.54166 6.48611 4.1911 4.87833 5.48999 3.67667C6.78832 2.47556 8.29166 1.875 9.99999 1.875C11.7083 1.875 13.2119 2.47556 14.5108 3.67667C15.8092 4.87833 16.4583 6.48611 16.4583 8.5C16.4583 9.77778 15.9689 11.1806 14.99 12.7083C14.0105 14.2361 12.5347 15.8958 10.5625 17.6875C10.4792 17.7569 10.3889 17.8056 10.2917 17.8333C10.1944 17.8611 10.0972 17.875 9.99999 17.875Z", fill: "#8C8C8C" })), autoComplete: 'no-auto-complete-' + randRef.current, rightSection: React__default.createElement(React__default.Fragment, null) }, form.getInputProps(name)))));
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
const SubtitleBlock = ({ children, align, }) => (React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
|
|
767
|
+
|
|
768
|
+
const TitleBlock = ({ children, align, }) => (React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + (align || '')} ${LEAD_CLASS}` }, children));
|
|
769
|
+
|
|
770
|
+
const LightboxFields = ({ listBlockAdded, popupId, locale, onClose, onOtherSubmit, }) => {
|
|
771
|
+
const form = useLeadFormContext();
|
|
772
|
+
return (React__default.createElement(React__default.Fragment, null, listBlockAdded.map((b, index) => {
|
|
773
|
+
const { name = '', data = {} } = b || {};
|
|
774
|
+
const { placeholder, value, align, listQuestion, isSendMailChimp = false, newtab, url, } = data;
|
|
775
|
+
switch (name) {
|
|
776
|
+
case 'TitleBlock':
|
|
777
|
+
return (React__default.createElement(TitleBlock, { key: index, align: align }, value));
|
|
778
|
+
case 'SubtitleBlock':
|
|
779
|
+
return (React__default.createElement(SubtitleBlock, { key: index, align: align }, value));
|
|
780
|
+
case 'TextBlock':
|
|
781
|
+
return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "text", placeholder: placeholder, className: "lead-modal__form-control",
|
|
782
|
+
// onChangeRaw={(e) => inputOnChange('text', e)}
|
|
783
|
+
label: placeholder, "data-control": "text", name: value }, form.getInputProps(value))));
|
|
784
|
+
case 'NumberBlock':
|
|
785
|
+
return (React__default.createElement(NumberInput, Object.assign({ key: index, withAsterisk: true, spellCheck: false, type: "number", placeholder: placeholder, className: "lead-modal__form-control",
|
|
786
|
+
// onChange={(e) => inputOnChange('number', e)}
|
|
787
|
+
label: placeholder, "data-control": "number", name: value }, form.getInputProps(value))));
|
|
788
|
+
case 'EmailBlock':
|
|
789
|
+
return (React__default.createElement(Input, Object.assign({ key: index, withAsterisk: true, spellCheck: false,
|
|
790
|
+
// type="email"
|
|
791
|
+
placeholder: placeholder, className: "lead-modal__form-control", label: placeholder, "data-control": "email", name: value }, form.getInputProps(value))));
|
|
792
|
+
case 'PhoneOtpBlock':
|
|
793
|
+
case 'WhatsappOtpBlock':
|
|
794
|
+
case 'PhoneBlock': {
|
|
795
|
+
const id = popupId + '-' + value + '-' + index;
|
|
796
|
+
return (React__default.createElement(Input.Wrapper, Object.assign({ size: "md", withAsterisk: true, key: index, label: placeholder,
|
|
797
|
+
// error={errorField.phone}
|
|
798
|
+
className: "lead-modal__form-control", labelProps: {
|
|
799
|
+
htmlFor: id,
|
|
800
|
+
} }, form.getInputProps(value)),
|
|
801
|
+
React__default.createElement(Phone, { name: value, spellCheck: false, type: "tel", placeholder: placeholder, onChange: (v) => {
|
|
802
|
+
form.setFieldValue(value, v);
|
|
803
|
+
},
|
|
804
|
+
// onBlur={(e) => inputOnBlur('tel', e)}
|
|
805
|
+
id: id, defaultCountry: (locale ? MAPPED_LOCALE[locale] || 'VN' : 'VN'), "data-control": "tel" })));
|
|
806
|
+
}
|
|
807
|
+
case 'LocationBlock': {
|
|
808
|
+
return (React__default.createElement(LocationBlock, { key: index, name: value, placeholder: placeholder, locale: locale }));
|
|
809
|
+
}
|
|
810
|
+
case 'DateBlock':
|
|
811
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
812
|
+
React__default.createElement(DatePicker, Object.assign({ withAsterisk: true, key: index, type: "default", name: value, placeholder: placeholder, className: "lead-modal__form-control", label: placeholder, "data-control": "date" }, form.getInputProps(value))),
|
|
813
|
+
React__default.createElement("input", { type: "hidden", name: value, "data-control": "date" })));
|
|
814
|
+
case 'LinkButtonBlock':
|
|
815
|
+
return (React__default.createElement("div", { key: index },
|
|
816
|
+
React__default.createElement("a", { target: newtab ? 'blank' : 'parrent', href: url, style: { textDecoration: 'none' } },
|
|
817
|
+
React__default.createElement(Button, { type: "button", size: "md", className: `lead-modal__btn ${LEAD_CLASS}`, onClick: () => {
|
|
818
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
819
|
+
onOtherSubmit === null || onOtherSubmit === void 0 ? void 0 : onOtherSubmit();
|
|
820
|
+
} }, value))));
|
|
821
|
+
case 'CheckboxBlock':
|
|
822
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
823
|
+
isSendMailChimp && (React__default.createElement("div", { style: {
|
|
824
|
+
display: 'none',
|
|
825
|
+
}, "data-name": value + '-mailchimp' })),
|
|
826
|
+
React__default.createElement(Checkbox.Group, Object.assign({ withAsterisk: true, className: "lead-modal__form-control", key: index, label: placeholder, size: "md", sx: {
|
|
827
|
+
display: 'flex',
|
|
828
|
+
flexDirection: 'column',
|
|
829
|
+
gap: 8,
|
|
830
|
+
} }, form.getInputProps(value)), listQuestion.map((l, _index) => (React__default.createElement(Checkbox, { name: value, key: _index, value: l.value, label: l.placeholder, "data-control": "checkbox" }))))));
|
|
831
|
+
case 'RadioBlock':
|
|
832
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
833
|
+
isSendMailChimp && (React__default.createElement(Input, { type: "hidden", name: value + '-mailchimp', value: isSendMailChimp })),
|
|
834
|
+
React__default.createElement(Radio.Group, Object.assign({ withAsterisk: true, className: "lead-modal__form-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" }))))));
|
|
835
|
+
case 'DropdownBlock':
|
|
836
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
837
|
+
React__default.createElement("div", { style: { display: 'none' }, "data-extra": true, "data-name": value, "data-control": 'dropdown' }),
|
|
838
|
+
React__default.createElement(Select, Object.assign({ key: index, className: "lead-modal__form-control", label: placeholder, withAsterisk: true, name: value, data: listQuestion.map((l) => ({
|
|
839
|
+
value: l.value,
|
|
840
|
+
label: l.placeholder,
|
|
841
|
+
})) }, form.getInputProps(value)))));
|
|
842
|
+
case 'TncBlock':
|
|
843
|
+
const tncInputProps = form.getInputProps('TNC-' + b.id);
|
|
844
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
845
|
+
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 }))));
|
|
846
|
+
}
|
|
847
|
+
return null;
|
|
848
|
+
})));
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
const OtpBlock = ({ otpData, onSuccess, autoSendWhenOpen, }) => {
|
|
852
|
+
const { t } = useTranslations();
|
|
853
|
+
const phone = otpData.phone;
|
|
854
|
+
const otpType = otpData.type;
|
|
855
|
+
const [otp, setOtp] = useState('');
|
|
856
|
+
const [isDirty, setIsDirty] = useState(false);
|
|
857
|
+
const [resendTimer, setResendTimer] = useState(autoSendWhenOpen ? 0 : 60);
|
|
858
|
+
const inputRef = useRef(null);
|
|
859
|
+
const [errorMsg, setErrorMsg] = useState();
|
|
860
|
+
const [displayPhone, setDisplayPhone] = useState('');
|
|
861
|
+
const formatPhoneNumberIntlRef = useRef();
|
|
862
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
863
|
+
useEffect(() => {
|
|
864
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
865
|
+
var _a;
|
|
866
|
+
if (!formatPhoneNumberIntlRef.current) {
|
|
867
|
+
const res = yield import('react-phone-number-input');
|
|
868
|
+
formatPhoneNumberIntlRef.current = res.formatPhoneNumberIntl;
|
|
869
|
+
}
|
|
870
|
+
setDisplayPhone(((_a = formatPhoneNumberIntlRef.current) === null || _a === void 0 ? void 0 : _a.call(formatPhoneNumberIntlRef, phone)) || phone);
|
|
871
|
+
}))();
|
|
872
|
+
}, [phone]);
|
|
873
|
+
const sendOtp = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
874
|
+
var _a;
|
|
875
|
+
if (!phone) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const res = yield Service.sendSMSOtpLead({
|
|
879
|
+
phone,
|
|
880
|
+
type: otpType,
|
|
881
|
+
});
|
|
882
|
+
const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
|
|
883
|
+
if (respMessage === 'Send sms successfully' ||
|
|
884
|
+
respMessage === 'Send WhatsApp successfully') {
|
|
885
|
+
setResendTimer(60);
|
|
886
|
+
setTimeout(() => {
|
|
887
|
+
if (inputRef.current) {
|
|
888
|
+
inputRef.current.focus();
|
|
889
|
+
inputRef.current.scrollIntoView({ block: 'center' });
|
|
890
|
+
}
|
|
891
|
+
}, 100);
|
|
892
|
+
}
|
|
893
|
+
else if (respMessage === 'This phone number was verified') {
|
|
894
|
+
onSuccess();
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
setErrorMsg(respMessage || 'Something went wrong!');
|
|
898
|
+
// const defaultError = f({ id: 'notification.comment.somethingWrong' })
|
|
899
|
+
// setStatusVerifyOTP('idle')
|
|
900
|
+
// pushNotifications({
|
|
901
|
+
// title: respMessage || defaultError,
|
|
902
|
+
// message: '',
|
|
903
|
+
// type: 'danger',
|
|
904
|
+
// })
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
const submitOtp = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
908
|
+
if (!phone || !otp) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
setIsSubmitLoading(true);
|
|
912
|
+
const res = yield Service.verifyOtpLead({
|
|
913
|
+
phone,
|
|
914
|
+
otp,
|
|
915
|
+
type: otpType,
|
|
916
|
+
});
|
|
917
|
+
const respMessage = res === null || res === void 0 ? void 0 : res._messages[0];
|
|
918
|
+
if (respMessage === 'Verify successfully' ||
|
|
919
|
+
respMessage === 'Verify WhatsApp OTP sucess') {
|
|
920
|
+
onSuccess();
|
|
921
|
+
}
|
|
922
|
+
else if (respMessage === 'This phone number was verified') {
|
|
923
|
+
onSuccess();
|
|
924
|
+
}
|
|
925
|
+
else {
|
|
926
|
+
setErrorMsg(respMessage || 'something Wrong');
|
|
927
|
+
// setIsShowError(true)
|
|
928
|
+
// setStatusVerifyOTP('sent')
|
|
929
|
+
// pushNotifications({
|
|
930
|
+
// title: res?._messages[0] || defaultError,
|
|
931
|
+
// message: '',
|
|
932
|
+
// type: 'danger',
|
|
933
|
+
// })
|
|
934
|
+
}
|
|
935
|
+
setIsSubmitLoading(false);
|
|
936
|
+
});
|
|
937
|
+
useEffect(() => {
|
|
938
|
+
setTimeout(() => {
|
|
939
|
+
if (resendTimer > 0) {
|
|
940
|
+
setResendTimer((r) => r - 1);
|
|
941
|
+
}
|
|
942
|
+
}, 1000);
|
|
943
|
+
}, [resendTimer]);
|
|
944
|
+
useEffect(() => {
|
|
945
|
+
if (autoSendWhenOpen && !resendTimer) {
|
|
946
|
+
sendOtp();
|
|
947
|
+
}
|
|
948
|
+
}, []);
|
|
949
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
950
|
+
React__default.createElement("form", { onSubmit: (e) => {
|
|
951
|
+
e.preventDefault();
|
|
952
|
+
submitOtp();
|
|
953
|
+
}, className: "lead-phone-otp-form" },
|
|
954
|
+
React__default.createElement(Heading, { tag: "h3", fontWeight: "bold", style: { marginBottom: 4 } }, t('lead.otp.title')),
|
|
955
|
+
React__default.createElement(Text, { size: "p1", color: theme.colors.gray600 }, t('lead.otp.desc', { phone: displayPhone })),
|
|
956
|
+
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
|
+
setIsDirty(true);
|
|
958
|
+
setOtp(v);
|
|
959
|
+
if (isDirty && !v)
|
|
960
|
+
setErrorMsg('OTP is required');
|
|
961
|
+
else
|
|
962
|
+
setErrorMsg(undefined);
|
|
963
|
+
}, error: isDirty ? errorMsg : undefined }),
|
|
964
|
+
React__default.createElement(Button, { size: "md", color: "primary", className: `lead-modal__btn ${LEAD_CLASS}`,
|
|
965
|
+
// onClick={() => submitOtp()}
|
|
966
|
+
disabled: !otp, isLoading: isSubmitLoading }, t('lead.otp.verify')),
|
|
967
|
+
React__default.createElement(Button, { type: "button", size: "md", color: "transparent", className: `lead-modal__btn lead-phone-otp-button ${LEAD_CLASS}`, onClick: () => {
|
|
968
|
+
sendOtp();
|
|
969
|
+
}, disabled: !!resendTimer }, t('lead.otp.resend', {
|
|
970
|
+
timer: resendTimer ? ` (${resendTimer}s)` : '',
|
|
971
|
+
})))));
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
const ThankyouPopup = ({ title, titleAlign, subtitle, subtitleAlign, link, linkNewTab, linkText, image, }) => {
|
|
975
|
+
const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
|
|
976
|
+
if (!imageLoaded)
|
|
977
|
+
return null;
|
|
978
|
+
return (React__default.createElement("div", { className: "lead-modal__thank-you" },
|
|
979
|
+
React__default.createElement("div", { style: { width: '100%' } },
|
|
980
|
+
React__default.createElement("img", { src: image, style: {
|
|
981
|
+
maxHeight: 162,
|
|
982
|
+
objectFit: 'cover',
|
|
983
|
+
aspectRatio: `${imageWidth}/${imageHeight}`,
|
|
984
|
+
}, loading: "lazy" }),
|
|
985
|
+
title && (React__default.createElement("h1", { className: `le-thankyou-title le-text-align-${titleAlign}` }, title)),
|
|
986
|
+
subtitle && (React__default.createElement("p", { className: `le-thankyou-subtitle le-text-align-${subtitleAlign}` }, subtitle)),
|
|
987
|
+
linkText && (React__default.createElement("div", null,
|
|
988
|
+
React__default.createElement("a", { href: link, target: linkNewTab ? '_blank' : 'parrent', rel: "noreferrer" },
|
|
989
|
+
React__default.createElement("button", { className: `lead-modal__btn ${LEAD_CLASS}` }, linkText)))))));
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
const InlineLayout = ({ content, inlinePosition, }) => {
|
|
993
|
+
const target = useMemo(() => {
|
|
994
|
+
if (!inlinePosition)
|
|
995
|
+
return null;
|
|
996
|
+
const parents = document.querySelectorAll(`[data-url="${location.pathname}"] .body-content`);
|
|
997
|
+
const allChildren = Array.from(parents).reduce((r, p) => {
|
|
998
|
+
return [...r, ...Array.from(p.children)];
|
|
999
|
+
}, []);
|
|
1000
|
+
if (allChildren === null || allChildren === void 0 ? void 0 : allChildren.length) {
|
|
1001
|
+
// find the third p tag in the body content, some other tags might mix in between
|
|
1002
|
+
const allPTags = allChildren.filter((c) => c.nodeName === 'P');
|
|
1003
|
+
const allH2Tags = allChildren.filter((c) => c.nodeName === 'H2');
|
|
1004
|
+
let target = null;
|
|
1005
|
+
switch (inlinePosition) {
|
|
1006
|
+
case '1th':
|
|
1007
|
+
target = allPTags[0];
|
|
1008
|
+
break;
|
|
1009
|
+
case '2th':
|
|
1010
|
+
target = allPTags[1];
|
|
1011
|
+
break;
|
|
1012
|
+
case '3th':
|
|
1013
|
+
target = allPTags[2];
|
|
1014
|
+
break;
|
|
1015
|
+
case '4th':
|
|
1016
|
+
target = allPTags[3];
|
|
1017
|
+
break;
|
|
1018
|
+
case '5th':
|
|
1019
|
+
target = allPTags[4];
|
|
1020
|
+
break;
|
|
1021
|
+
case '6th':
|
|
1022
|
+
target = allPTags[5];
|
|
1023
|
+
break;
|
|
1024
|
+
case '7th':
|
|
1025
|
+
target = allPTags[6];
|
|
1026
|
+
break;
|
|
1027
|
+
case '8th':
|
|
1028
|
+
target = allPTags[7];
|
|
1029
|
+
break;
|
|
1030
|
+
case '9th':
|
|
1031
|
+
target = allPTags[8];
|
|
1032
|
+
break;
|
|
1033
|
+
case '10th':
|
|
1034
|
+
target = allPTags[9];
|
|
1035
|
+
break;
|
|
1036
|
+
case '11th':
|
|
1037
|
+
target = allPTags[10];
|
|
1038
|
+
break;
|
|
1039
|
+
case '12th':
|
|
1040
|
+
target = allPTags[11];
|
|
1041
|
+
break;
|
|
1042
|
+
case 'lastP':
|
|
1043
|
+
target = allPTags[allPTags.length - 1];
|
|
1044
|
+
break;
|
|
1045
|
+
case '1thH2':
|
|
1046
|
+
target = allH2Tags[0];
|
|
1047
|
+
break;
|
|
1048
|
+
case '2thH2':
|
|
1049
|
+
target = allH2Tags[1];
|
|
1050
|
+
break;
|
|
1051
|
+
case '3thH2':
|
|
1052
|
+
target = allH2Tags[2];
|
|
1053
|
+
break;
|
|
1054
|
+
case '4thH2':
|
|
1055
|
+
target = allH2Tags[3];
|
|
1056
|
+
break;
|
|
1057
|
+
case '5thH2':
|
|
1058
|
+
target = allH2Tags[4];
|
|
1059
|
+
break;
|
|
1060
|
+
case '6thH2':
|
|
1061
|
+
target = allH2Tags[5];
|
|
1062
|
+
break;
|
|
1063
|
+
case '7thH2':
|
|
1064
|
+
target = allH2Tags[6];
|
|
1065
|
+
break;
|
|
1066
|
+
case '8thH2':
|
|
1067
|
+
target = allH2Tags[7];
|
|
1068
|
+
break;
|
|
1069
|
+
case '9thH2':
|
|
1070
|
+
target = allH2Tags[8];
|
|
1071
|
+
break;
|
|
1072
|
+
case '10thH2':
|
|
1073
|
+
target = allH2Tags[9];
|
|
1074
|
+
break;
|
|
1075
|
+
case 'lastH2':
|
|
1076
|
+
target = allH2Tags[allH2Tags.length - 1];
|
|
1077
|
+
break;
|
|
1078
|
+
}
|
|
1079
|
+
if (target) {
|
|
1080
|
+
if (!target.parentElement.querySelector('.inline-lead-wrapper')) {
|
|
1081
|
+
const wrapper = document.createElement('div');
|
|
1082
|
+
wrapper.classList.add('inline-lead-wrapper');
|
|
1083
|
+
if (target.nextElementSibling) {
|
|
1084
|
+
target.parentElement.insertBefore(wrapper, target.nextElementSibling);
|
|
1085
|
+
}
|
|
1086
|
+
else {
|
|
1087
|
+
target.parentElement.appendChild(wrapper);
|
|
1088
|
+
}
|
|
1089
|
+
return wrapper;
|
|
1090
|
+
}
|
|
1091
|
+
else {
|
|
1092
|
+
return target.parentElement.querySelector('.inline-lead-wrapper');
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}, [inlinePosition]);
|
|
1097
|
+
if (!inlinePosition || !target)
|
|
1098
|
+
return null;
|
|
1099
|
+
return createPortal(content, target);
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
const SideBarLayout = ({ content }) => {
|
|
1103
|
+
const targets = useMemo(() => {
|
|
1104
|
+
const targetDoms = Array.from(document.querySelectorAll('.hc2-sidebar-with-ads,.page-main-col .right-col.f-right,.hhg-lead-sidebar'));
|
|
1105
|
+
targetDoms.forEach((dom) => {
|
|
1106
|
+
if (dom.querySelector('.sidebar-lead-modal-wrapper'))
|
|
1107
|
+
return;
|
|
1108
|
+
const wrapper = document.createElement('div');
|
|
1109
|
+
wrapper.classList.add('sidebar-lead-modal-wrapper');
|
|
1110
|
+
dom.prepend(wrapper);
|
|
1111
|
+
});
|
|
1112
|
+
return targetDoms.map((d) => d.querySelector('.sidebar-lead-modal-wrapper'));
|
|
1113
|
+
}, []);
|
|
1114
|
+
return (React__default.createElement(React__default.Fragment, null, targets.map((target) => createPortal(content, getWrapperDomWithSelector(target, 'sidebar-lead-modal-wrapper')))));
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
// url: imageBlocks.imageMobile.data.url
|
|
1118
|
+
// newTab: imageBlocks.imageMobile.data.newtab
|
|
1119
|
+
// image: campaignShow.image
|
|
1120
|
+
// imageDestkop: campaignShow.image_desktop
|
|
1121
|
+
const LightboxLayout = ({ popupId, extraFields, onClose: onCloseProp, onOtherSubmit, imageMobile, imageDesktop, imageOverlayMobile, imageOverlayDesktop, imageBackground, currentLayout, title, onSubmit, showThankyou, campaignId, campaign_subot_id, locale, }) => {
|
|
1122
|
+
var _a, _b, _c;
|
|
1123
|
+
const listBlockAdded = JSON.parse(extraFields.listBlockAdded);
|
|
1124
|
+
const actionBlocks = JSON.parse(extraFields.actionBlocks);
|
|
1125
|
+
const textBlocks = JSON.parse(extraFields.textBlocks);
|
|
1126
|
+
const popUpTermURL = actionBlocks.submitBlock.data.url;
|
|
1127
|
+
const popUpTermAgreeText = actionBlocks.submitBlock.data.text;
|
|
1128
|
+
const popUpTermText = actionBlocks.submitBlock.data.text2;
|
|
1129
|
+
const popUpSubmitText = actionBlocks.submitBlock.data.value;
|
|
1130
|
+
const currentPath = location.pathname;
|
|
1131
|
+
const isInPage = currentLayout.includes('Inline') || currentLayout === 'Sidebar';
|
|
1132
|
+
const isSlider = currentLayout === 'Slider';
|
|
1133
|
+
const [checkedTerm, setCheckedTerm] = useState(true);
|
|
1134
|
+
const [showOtpPhone, setShowOtpPhone] = useState(null);
|
|
1135
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
1136
|
+
const formRef = useRef();
|
|
1137
|
+
const onClose = () => {
|
|
1138
|
+
if (showOtpPhone) {
|
|
1139
|
+
setShowOtpPhone(null);
|
|
1140
|
+
}
|
|
1141
|
+
else {
|
|
1142
|
+
onCloseProp === null || onCloseProp === void 0 ? void 0 : onCloseProp();
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
if (window.innerWidth < 769 &&
|
|
1146
|
+
['Fullscreen', 'Slider'].includes(currentLayout)) {
|
|
1147
|
+
console.log('😎 Not show fullscreen, slider on mobile ');
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1150
|
+
useEffect(() => {
|
|
1151
|
+
if (currentLayout.includes('LightBox') || currentLayout == 'Fullscreen') {
|
|
1152
|
+
document.body.classList.add('noscroll');
|
|
1153
|
+
}
|
|
1154
|
+
if (!window.intlTelInputUtils) {
|
|
1155
|
+
require('intl-tel-input/build/js/utils');
|
|
1156
|
+
}
|
|
1157
|
+
clearCacheUsedEmailOrPhone();
|
|
1158
|
+
}, []);
|
|
1159
|
+
const validatingPhoneRef = useRef(false);
|
|
1160
|
+
const validatingEmailRef = useRef(false);
|
|
1161
|
+
const { form, validateObj } = useLeadFormConfig({
|
|
1162
|
+
listBlockAdded,
|
|
1163
|
+
validatingPhoneRef,
|
|
1164
|
+
validatingEmailRef,
|
|
1165
|
+
campaignId,
|
|
1166
|
+
campaign_subot_id,
|
|
1167
|
+
});
|
|
1168
|
+
const middlewareOnSubmit = (e) => {
|
|
1169
|
+
e.preventDefault();
|
|
1170
|
+
// mark all as touched to allow validation
|
|
1171
|
+
form.setTouched(Object.keys(validateObj).reduce((acc, cur) => {
|
|
1172
|
+
acc[cur] = true;
|
|
1173
|
+
return acc;
|
|
1174
|
+
}, {}));
|
|
1175
|
+
if (validatingEmailRef.current || validatingPhoneRef.current) {
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
setTimeout(() => {
|
|
1179
|
+
form.onSubmit((v) => {
|
|
1180
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1181
|
+
if (Object.keys(form.errors).length)
|
|
1182
|
+
return;
|
|
1183
|
+
let newShowOtpPhone = null;
|
|
1184
|
+
if (listBlockAdded.findIndex((x) => x.name === 'PhoneOtpBlock') > -1) {
|
|
1185
|
+
// not submit yet, open otp
|
|
1186
|
+
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;
|
|
1187
|
+
if ((_c = v[fieldName]) === null || _c === void 0 ? void 0 : _c.startsWith('+')) {
|
|
1188
|
+
newShowOtpPhone = {
|
|
1189
|
+
phone: v[fieldName],
|
|
1190
|
+
type: 'phone',
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
if (listBlockAdded.findIndex((x) => x.name === 'WhatsappOtpBlock') > -1) {
|
|
1195
|
+
// not submit yet, open otp
|
|
1196
|
+
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;
|
|
1197
|
+
if ((_f = v[fieldName]) === null || _f === void 0 ? void 0 : _f.startsWith('+')) {
|
|
1198
|
+
newShowOtpPhone = {
|
|
1199
|
+
phone: v[fieldName],
|
|
1200
|
+
type: 'whatsapp',
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
if (newShowOtpPhone) {
|
|
1205
|
+
setIsSubmitLoading(true);
|
|
1206
|
+
Service.sendSMSOtpLead(newShowOtpPhone)
|
|
1207
|
+
.then((res) => {
|
|
1208
|
+
var _a;
|
|
1209
|
+
const respMessage = (_a = res === null || res === void 0 ? void 0 : res._messages) === null || _a === void 0 ? void 0 : _a[0];
|
|
1210
|
+
if (respMessage === 'This phone number was verified') {
|
|
1211
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
setShowOtpPhone(newShowOtpPhone);
|
|
1215
|
+
})
|
|
1216
|
+
.finally(() => {
|
|
1217
|
+
setIsSubmitLoading(false);
|
|
1218
|
+
});
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, v);
|
|
1222
|
+
})(e);
|
|
1223
|
+
}, 100);
|
|
1224
|
+
};
|
|
1225
|
+
const { width: imageBackgroundWidth, height: imageBackgroundHeight, loaded: imageBackgroundLoaded, } = useImageSize(imageBackground);
|
|
1226
|
+
const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
|
|
1227
|
+
const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
|
|
1228
|
+
const renderAfterImageSizes = imageMobileLoaded &&
|
|
1229
|
+
imageDesktopLoaded &&
|
|
1230
|
+
(currentLayout == 'Fullscreen' ? imageBackgroundLoaded : true);
|
|
1231
|
+
const PopupContent = (React__default.createElement(React__default.Fragment, null,
|
|
1232
|
+
React__default.createElement("style", { dangerouslySetInnerHTML: {
|
|
1233
|
+
__html: `
|
|
1234
|
+
.le-newbuilder-overlay {
|
|
1235
|
+
background-repeat: no-repeat;
|
|
1236
|
+
background-size: cover;
|
|
1237
|
+
}
|
|
1238
|
+
${imageOverlayMobile
|
|
1239
|
+
? `
|
|
1240
|
+
.le-newbuilder-overlay {
|
|
1241
|
+
background: url(${imageOverlayMobile}) ;
|
|
1242
|
+
}`
|
|
1243
|
+
: ``}
|
|
1244
|
+
${imageOverlayDesktop
|
|
1245
|
+
? `
|
|
1246
|
+
@media screen and (min-width:768px) {
|
|
1247
|
+
.le-newbuilder-overlay {
|
|
1248
|
+
background: url(${imageOverlayDesktop}) ;
|
|
1249
|
+
}
|
|
1250
|
+
}`
|
|
1251
|
+
: ``}`,
|
|
1252
|
+
} }),
|
|
1253
|
+
React__default.createElement("div", { id: popupId, "data-popup-url": currentPath, "data-popup-type": "lightbox-inline", className: `lead-modal lead-modal-wrapper modal--animate-scale ${isInPage ? 'le-buider-inline' : ''} ${isSlider ? 'le-buider-slider' : ''}` },
|
|
1254
|
+
currentLayout == 'Fullscreen' ? (React__default.createElement("img", { className: "le-only-desktop le-fullscreen-img", draggable: false, src: imageBackground || '', style: {
|
|
1255
|
+
aspectRatio: `${imageBackgroundWidth}/${imageBackgroundHeight}`,
|
|
1256
|
+
} })) : null,
|
|
1257
|
+
React__default.createElement("div", { className: `lead-modal__wrapper le-newbuilder-wrap-${currentLayout}` },
|
|
1258
|
+
React__default.createElement("div", { className: `lead-modal__content le-newbuilder-${currentLayout}` }, 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 })) : (React__default.createElement(React__default.Fragment, null,
|
|
1259
|
+
React__default.createElement("header", { className: "lead-modal__header" }, showOtpPhone ? (React__default.createElement("img", { src: CommonGAssets.getAssetPath('lead-otp-thumb.png'), draggable: "false", alt: "", style: {
|
|
1260
|
+
width: '100%',
|
|
1261
|
+
minHeight: '150px',
|
|
1262
|
+
backgroundColor: '#f2f2f2',
|
|
1263
|
+
}, loading: "lazy" })) : (React__default.createElement(React__default.Fragment, null, ['LightBoxA', 'InlineA', 'Sidebar', 'Slider'].includes(currentLayout) ? (imageMobile ? (React__default.createElement("img", { draggable: "false", className: "lead-modal__image lead-modal-image-cover", src: imageMobile, style: {
|
|
1264
|
+
aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
|
|
1265
|
+
}, alt: "" })) : null) : (React__default.createElement(React__default.Fragment, null,
|
|
1266
|
+
imageDesktop ? (React__default.createElement("img", { draggable: "false", className: "le-only-desktop lead-modal__image lead-modal-image-cover", style: {
|
|
1267
|
+
objectFit: 'cover',
|
|
1268
|
+
aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
|
|
1269
|
+
}, src: imageDesktop, alt: "" })) : null,
|
|
1270
|
+
imageMobile ? (React__default.createElement("img", { draggable: "false", className: "le-only-mobile lead-modal__image lead-modal-image-cover", src: imageMobile, alt: "", style: {
|
|
1271
|
+
aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
|
|
1272
|
+
} })) : null))))),
|
|
1273
|
+
showOtpPhone && (React__default.createElement(OtpBlock, { otpData: showOtpPhone, autoSendWhenOpen: false, onSuccess: () => {
|
|
1274
|
+
setShowOtpPhone(null);
|
|
1275
|
+
onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(formRef.current, form.values);
|
|
1276
|
+
} })),
|
|
1277
|
+
React__default.createElement("div", { "data-hidden": !!showOtpPhone, className: "lead-modal__body le-newbuilder-overlay" },
|
|
1278
|
+
React__default.createElement(LeadFormProvider, { form: form },
|
|
1279
|
+
React__default.createElement("form", { ref: formRef, className: `lead-modal__form ${popupId}`, onSubmit: middlewareOnSubmit },
|
|
1280
|
+
React__default.createElement("div", { style: { marginBottom: 20 } },
|
|
1281
|
+
React__default.createElement("h2", { className: `lead-modal__title ${'le-text-align-' + ((_a = textBlocks.titleBlock.data) === null || _a === void 0 ? void 0 : _a.align)} ${LEAD_CLASS}` }, title),
|
|
1282
|
+
React__default.createElement("p", { className: `lead-modal__description ${'le-text-align-' + ((_b = textBlocks.titleBlock.data) === null || _b === void 0 ? void 0 : _b.align)} ${LEAD_CLASS}` }, textBlocks.subtitleBlock.data.value)),
|
|
1283
|
+
React__default.createElement("div", { className: "lead-modal__form-control-wrapper" },
|
|
1284
|
+
React__default.createElement(LightboxFields, { listBlockAdded: listBlockAdded, popupId: popupId, locale: locale, onClose: onClose, onOtherSubmit: onOtherSubmit })),
|
|
1285
|
+
((_c = actionBlocks === null || actionBlocks === void 0 ? void 0 : actionBlocks.submitBlock) === null || _c === void 0 ? void 0 : _c.isHide) ? null : (React__default.createElement(React__default.Fragment, null,
|
|
1286
|
+
React__default.createElement("div", { className: `lead-modal__checkbox-wrapper ${LEAD_CLASS}` },
|
|
1287
|
+
React__default.createElement("div", { className: "lead-modal__checkbox" },
|
|
1288
|
+
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) }),
|
|
1289
|
+
React__default.createElement("div", { className: "lead-modal__checkbox__control", "aria-hidden": "true" })),
|
|
1290
|
+
React__default.createElement("label", { htmlFor: "checkbox", className: "lead-modal__checkbox__label" },
|
|
1291
|
+
popUpTermAgreeText,
|
|
1292
|
+
' ',
|
|
1293
|
+
React__default.createElement("span", { style: { fontWeight: 'bold' } },
|
|
1294
|
+
React__default.createElement("a", { target: "blank", href: popUpTermURL ||
|
|
1295
|
+
'https://hellobacsi.com/chinh-sach', rel: "noopener noreferrer", style: { textDecoration: 'none' } }, popUpTermText)))),
|
|
1296
|
+
React__default.createElement(Button, { size: "md", id: "lead-submit", type: "submit", className: `lead-modal__btn ${LEAD_CLASS}`, disabled: !checkedTerm, isLoading: isSubmitLoading }, popUpSubmitText))))))))),
|
|
1297
|
+
!currentLayout.includes('Inline') && (React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))));
|
|
1298
|
+
if (!renderAfterImageSizes)
|
|
1299
|
+
return null;
|
|
1300
|
+
if (currentLayout.includes('LightBox') ||
|
|
1301
|
+
currentLayout == 'Fullscreen' ||
|
|
1302
|
+
currentLayout == 'Slider') {
|
|
1303
|
+
return PopupContent;
|
|
1304
|
+
}
|
|
1305
|
+
else if (currentLayout == 'Sidebar') {
|
|
1306
|
+
return React__default.createElement(SideBarLayout, { content: PopupContent });
|
|
1307
|
+
}
|
|
1308
|
+
else if (currentLayout.includes('Inline')) {
|
|
1309
|
+
return (React__default.createElement(InlineLayout, { content: PopupContent, inlinePosition: extraFields.popupInlinePosition }));
|
|
1310
|
+
}
|
|
1311
|
+
return null;
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
const SkinLayout = ({ popupId, link, linkText, linkNewTab, onClose, imageMobile, imageDesktop, currentLayout, onOtherSubmit, }) => {
|
|
1315
|
+
const currentPath = location.pathname;
|
|
1316
|
+
const { width: imageMobileWidth, height: imageMobileHeight, loaded: imageMobileLoaded, } = useImageSize(imageMobile);
|
|
1317
|
+
const { width: imageDesktopWidth, height: imageDesktopHeight, loaded: imageDesktopLoaded, } = useImageSize(imageDesktop);
|
|
1318
|
+
if (!imageMobileLoaded || !imageDesktopLoaded)
|
|
1319
|
+
return null;
|
|
1320
|
+
return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": currentPath, "data-popup-type": "skin_ab" },
|
|
1321
|
+
currentLayout == 'SkinA' ? (React__default.createElement("aside", { className: "le-only-desktop" },
|
|
1322
|
+
React__default.createElement("div", { className: "le-skin-a-desktop" },
|
|
1323
|
+
React__default.createElement("div", { style: { position: 'relative' } },
|
|
1324
|
+
React__default.createElement("img", { src: imageDesktop, style: {
|
|
1325
|
+
aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
|
|
1326
|
+
} }),
|
|
1327
|
+
React__default.createElement("a", { style: {
|
|
1328
|
+
position: 'absolute',
|
|
1329
|
+
top: '75%',
|
|
1330
|
+
left: '50%',
|
|
1331
|
+
transform: 'translate(-50%, -50%)',
|
|
1332
|
+
textAlign: 'center',
|
|
1333
|
+
width: 'calc(100% - 15px)',
|
|
1334
|
+
}, href: link, target: linkNewTab ? 'blank' : '_parent' },
|
|
1335
|
+
React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn js-popup-other-submit" }, linkText)),
|
|
1336
|
+
React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" }))))) : currentLayout == 'SkinB' ? (React__default.createElement("aside", { className: "le-only-desktop" },
|
|
1337
|
+
React__default.createElement("div", { className: "" },
|
|
1338
|
+
React__default.createElement("div", { style: { position: 'relative', zIndex: 10000 } },
|
|
1339
|
+
React__default.createElement("img", { src: imageDesktop, style: {
|
|
1340
|
+
width: '100%',
|
|
1341
|
+
aspectRatio: `${imageDesktopWidth}/${imageDesktopHeight}`,
|
|
1342
|
+
} }),
|
|
1343
|
+
React__default.createElement("a", { style: {
|
|
1344
|
+
position: 'absolute',
|
|
1345
|
+
top: '75%',
|
|
1346
|
+
left: '50%',
|
|
1347
|
+
transform: 'translate(-50%, -50%)',
|
|
1348
|
+
textAlign: 'center',
|
|
1349
|
+
width: '100%',
|
|
1350
|
+
}, href: link, target: linkNewTab ? 'blank' : '_parent' },
|
|
1351
|
+
React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
|
|
1352
|
+
React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", onClose: onClose }))))) : null,
|
|
1353
|
+
React__default.createElement("aside", { className: "le-only-mobile" },
|
|
1354
|
+
React__default.createElement("div", { className: "le-skin-mobile" },
|
|
1355
|
+
React__default.createElement("div", { style: { position: 'relative' } },
|
|
1356
|
+
React__default.createElement("img", { src: imageMobile, style: {
|
|
1357
|
+
width: '100%',
|
|
1358
|
+
aspectRatio: `${imageMobileWidth}/${imageMobileHeight}`,
|
|
1359
|
+
} }),
|
|
1360
|
+
React__default.createElement("a", { style: {
|
|
1361
|
+
position: 'absolute',
|
|
1362
|
+
top: '82%',
|
|
1363
|
+
left: '50%',
|
|
1364
|
+
transform: 'translate(-50%, -50%)',
|
|
1365
|
+
textAlign: 'center',
|
|
1366
|
+
maxWidth: 'calc(100% - 15px)',
|
|
1367
|
+
}, href: link, target: linkNewTab ? 'blank' : '_parent' },
|
|
1368
|
+
React__default.createElement("button", { onClick: onOtherSubmit, className: "le-joinbow-btn-mobile js-popup-other-submit" }, linkText)),
|
|
1369
|
+
React__default.createElement(CloseButton, { containerClassName: "close-button-top-right", svgClassName: "le-mobile-btn", onClose: onClose }))))));
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
// url: imageBlocks.imageMobile.data.url
|
|
1373
|
+
// newTab: imageBlocks.imageMobile.data.newtab
|
|
1374
|
+
// image: campaignShow.image
|
|
1375
|
+
// imageDestkop: campaignShow.image_desktop
|
|
1376
|
+
const TabLayout = ({ popupId, url, newTab, image, onClose, onOtherSubmit, }) => {
|
|
1377
|
+
const { width: imageWidth, height: imageHeight, loaded: imageLoaded, } = useImageSize(image);
|
|
1378
|
+
if (!imageLoaded)
|
|
1379
|
+
return null;
|
|
1380
|
+
return (React__default.createElement("div", { id: popupId, className: "lead-modal-wrapper", "data-popup-url": location.pathname, "data-popup-type": "tab" },
|
|
1381
|
+
React__default.createElement("div", { className: "le-tab-popup" },
|
|
1382
|
+
React__default.createElement("div", { style: { position: 'relative' } },
|
|
1383
|
+
React__default.createElement("a", { href: url, target: newTab ? 'blank' : '_parent', onClick: onOtherSubmit },
|
|
1384
|
+
React__default.createElement("img", { className: "js-popup-other-submit", src: image, style: {
|
|
1385
|
+
aspectRatio: `${imageWidth}/${imageHeight}`,
|
|
1386
|
+
} })),
|
|
1387
|
+
React__default.createElement(CloseButton, { onClose: onClose, containerClassName: "close-button-top-right" })))));
|
|
1388
|
+
};
|
|
1389
|
+
|
|
1390
|
+
// import mockLeadData from './mockLeadData'
|
|
1391
|
+
const listCampaignScheduled = [];
|
|
1392
|
+
const listCampaignScheduledToActivated = [];
|
|
1393
|
+
const listCampaignActiveButExpired = [];
|
|
1394
|
+
const listCampaignExcludeSonsored = [];
|
|
1395
|
+
const listCampaignDifferentSponsor = [];
|
|
1396
|
+
const listCampaignNotDisplayInRangeOfTime = [];
|
|
1397
|
+
function isMobile() {
|
|
1398
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i.test(navigator.userAgent);
|
|
1399
|
+
}
|
|
1400
|
+
const getShuffleArray = (array) => {
|
|
1401
|
+
const newArray = [...array];
|
|
1402
|
+
for (let i = newArray.length - 1; i > 0; i--) {
|
|
1403
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
1404
|
+
const temp = newArray[i];
|
|
1405
|
+
newArray[i] = newArray[j];
|
|
1406
|
+
newArray[j] = temp;
|
|
1407
|
+
}
|
|
1408
|
+
return newArray;
|
|
1409
|
+
};
|
|
1410
|
+
const getTimeByTimezone = (timeZone = 'UTC') => {
|
|
1411
|
+
const date = new Date();
|
|
1412
|
+
return new Date(date.toLocaleString('en-US', { timeZone }));
|
|
1413
|
+
};
|
|
1414
|
+
const parseDateByCampaignTime = (dateStr) => {
|
|
1415
|
+
// Format like this: 2023-04-04 00:00:00
|
|
1416
|
+
try {
|
|
1417
|
+
const [datePart, timePart] = dateStr.split(' ');
|
|
1418
|
+
const [year, month, day] = datePart.split('-').map(Number);
|
|
1419
|
+
const [hours, minutes, seconds] = timePart.split(':').map(Number);
|
|
1420
|
+
/** JavaScript counts months from 0 to 11 */
|
|
1421
|
+
return new Date(year, month - 1, day, hours, minutes, seconds);
|
|
1422
|
+
}
|
|
1423
|
+
catch (err) {
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
const checkCampaignNowInTimeframe = (c) => {
|
|
1428
|
+
var _a;
|
|
1429
|
+
const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
|
|
1430
|
+
const startedAtStr = c.started_at;
|
|
1431
|
+
const endedAtStr = c.ended_at;
|
|
1432
|
+
const startedDate = parseDateByCampaignTime(startedAtStr);
|
|
1433
|
+
const endedDate = parseDateByCampaignTime(endedAtStr);
|
|
1434
|
+
if (!startedDate || !endedDate) {
|
|
1435
|
+
return false;
|
|
1436
|
+
}
|
|
1437
|
+
const timeZone = LEAD_TIMEZONE_DATA[siteId];
|
|
1438
|
+
const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
|
|
1439
|
+
if (nowWithTimezoneMs <= endedDate.getTime() &&
|
|
1440
|
+
nowWithTimezoneMs >= startedDate.getTime()) {
|
|
1441
|
+
listCampaignScheduledToActivated.push(c);
|
|
1442
|
+
return true;
|
|
1443
|
+
}
|
|
1444
|
+
return false;
|
|
1445
|
+
};
|
|
1446
|
+
function checkCampaignActiveButExpireAlready(c) {
|
|
1447
|
+
var _a;
|
|
1448
|
+
/** Do not setup timeframe for this campaign. No need to check */
|
|
1449
|
+
if (c.forever === 1) {
|
|
1450
|
+
return true;
|
|
1451
|
+
}
|
|
1452
|
+
const startedAtStr = c.started_at;
|
|
1453
|
+
const endedAtStr = c.ended_at;
|
|
1454
|
+
const startedDate = parseDateByCampaignTime(startedAtStr);
|
|
1455
|
+
const endedDate = parseDateByCampaignTime(endedAtStr);
|
|
1456
|
+
/** Do not setup timeframe for this campaign. No need to check */
|
|
1457
|
+
if (!startedDate || !endedDate) {
|
|
1458
|
+
return true;
|
|
1459
|
+
}
|
|
1460
|
+
const siteId = ((_a = c.site) === null || _a === void 0 ? void 0 : _a.id) || 1;
|
|
1461
|
+
const timeZone = LEAD_TIMEZONE_DATA[siteId];
|
|
1462
|
+
const nowWithTimezoneMs = getTimeByTimezone(timeZone).getTime();
|
|
1463
|
+
/** Check if this expire already, do not show */
|
|
1464
|
+
if (nowWithTimezoneMs > endedDate.getTime()) {
|
|
1465
|
+
listCampaignActiveButExpired.push(c);
|
|
1466
|
+
return false;
|
|
1467
|
+
}
|
|
1468
|
+
return true;
|
|
1469
|
+
}
|
|
1470
|
+
function shouldNotDisplayIfExcludeAllSponsors(c) {
|
|
1471
|
+
var _a;
|
|
1472
|
+
const excludeSponsored = Number((_a = c.rules.find((i) => i.rule == 'exclude_sponsored')) === null || _a === void 0 ? void 0 : _a.value);
|
|
1473
|
+
const isSponsored = Boolean(document.querySelector('.hhg-disclaimer-text'));
|
|
1474
|
+
if (isSponsored && excludeSponsored) {
|
|
1475
|
+
listCampaignExcludeSonsored.push(c);
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
return false;
|
|
1479
|
+
}
|
|
1480
|
+
function shouldDisplayWithCurrentSponsor(c) {
|
|
1481
|
+
var _a, _b;
|
|
1482
|
+
try {
|
|
1483
|
+
// TODO: BE will rename `exclude_sponsored_list` later
|
|
1484
|
+
const stringOrArray = (_a = c.rules.find((i) => i.rule == 'exclude_sponsored_list')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1485
|
+
const whiteListSponsors = stringOrArray instanceof Array ? stringOrArray : JSON.parse(stringOrArray);
|
|
1486
|
+
const dataSponsoredId = Number((_b = document
|
|
1487
|
+
.querySelector('[data-sponsored-id]')) === null || _b === void 0 ? void 0 : _b.getAttribute('data-sponsored-id'));
|
|
1488
|
+
// There is no config for sponsor id and white list, should show as default
|
|
1489
|
+
if (!dataSponsoredId ||
|
|
1490
|
+
dataSponsoredId <= 0 ||
|
|
1491
|
+
whiteListSponsors.length === 0) {
|
|
1492
|
+
return true;
|
|
1493
|
+
}
|
|
1494
|
+
// Check the dataSponsoredId exists in the white list or not.
|
|
1495
|
+
const isExist = whiteListSponsors.find((s) => s.id == dataSponsoredId);
|
|
1496
|
+
if (isExist) {
|
|
1497
|
+
return true;
|
|
1498
|
+
}
|
|
1499
|
+
listCampaignDifferentSponsor.push({ id: c.id, rules: c.rules });
|
|
1500
|
+
return false;
|
|
1501
|
+
}
|
|
1502
|
+
catch (err) {
|
|
1503
|
+
// Default is show
|
|
1504
|
+
return true;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
const filterFnCampaign = (c) => {
|
|
1508
|
+
if (shouldNotDisplayIfExcludeAllSponsors(c)) {
|
|
1509
|
+
return false;
|
|
1510
|
+
}
|
|
1511
|
+
else if (!shouldDisplayWithCurrentSponsor(c)) {
|
|
1512
|
+
return false;
|
|
1513
|
+
}
|
|
1514
|
+
/** Active */
|
|
1515
|
+
if (c.formatted_status === 1) {
|
|
1516
|
+
return checkCampaignActiveButExpireAlready(c);
|
|
1517
|
+
}
|
|
1518
|
+
/** Schedule */
|
|
1519
|
+
if (c.formatted_status === 0) {
|
|
1520
|
+
listCampaignScheduled.push(c);
|
|
1521
|
+
return checkCampaignNowInTimeframe(c);
|
|
1522
|
+
}
|
|
1523
|
+
return false;
|
|
1524
|
+
};
|
|
1525
|
+
const fillterApprearanceTimeCampaign = (c) => {
|
|
1526
|
+
var _a;
|
|
1527
|
+
try {
|
|
1528
|
+
const isTimeInRange = (currentTime, startTime, endTime) => {
|
|
1529
|
+
const startParts = startTime.split(':');
|
|
1530
|
+
const endParts = endTime.split(':');
|
|
1531
|
+
const startDate = new Date();
|
|
1532
|
+
startDate.setHours(Number(startParts[0]), Number(startParts[1]), 0, 0);
|
|
1533
|
+
const endDate = new Date();
|
|
1534
|
+
endDate.setHours(Number(endParts[0]), Number(endParts[1]), 0, 0);
|
|
1535
|
+
return currentTime >= startDate && currentTime <= endDate;
|
|
1536
|
+
};
|
|
1537
|
+
const rulesApprValue = (_a = c.rules.find((i) => i.rule == 'appearance_time')) === null || _a === void 0 ? void 0 : _a.value;
|
|
1538
|
+
const startTime = rulesApprValue.startTime;
|
|
1539
|
+
const endTime = rulesApprValue.endTime || '23:59';
|
|
1540
|
+
if (!startTime) {
|
|
1541
|
+
return true;
|
|
1542
|
+
}
|
|
1543
|
+
if (isTimeInRange(new Date(), startTime, endTime)) {
|
|
1544
|
+
return true;
|
|
1545
|
+
}
|
|
1546
|
+
listCampaignNotDisplayInRangeOfTime.push(c);
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
catch (err) {
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
let timeoutRef = null;
|
|
1554
|
+
function checkShowPopup({ leadApi, leadSiteId, leadDomain, onShowPopup, DEBUG_URL, }) {
|
|
1555
|
+
const leadCurrentUrl = DEBUG_URL ||
|
|
1556
|
+
('https://' +
|
|
1557
|
+
location.hostname +
|
|
1558
|
+
location.pathname +
|
|
1559
|
+
location.search).toLowerCase();
|
|
1560
|
+
fetch(leadApi + 'api/campaign/' + leadSiteId, {
|
|
1561
|
+
method: 'POST',
|
|
1562
|
+
headers: {
|
|
1563
|
+
'Content-Type': 'application/json',
|
|
1564
|
+
},
|
|
1565
|
+
body: JSON.stringify({
|
|
1566
|
+
url: leadCurrentUrl,
|
|
1567
|
+
ga_client_id: getCookie('_ga') || null,
|
|
1568
|
+
}),
|
|
1569
|
+
})
|
|
1570
|
+
.then((response) => {
|
|
1571
|
+
return response.json();
|
|
1572
|
+
// return mockLeadData || response.json()
|
|
1573
|
+
})
|
|
1574
|
+
.then((data) => {
|
|
1575
|
+
var _a, _b, _c, _d;
|
|
1576
|
+
LeadLog('List campagin: ', data);
|
|
1577
|
+
LEAD_RESET_VAR();
|
|
1578
|
+
if (data._status == 1) {
|
|
1579
|
+
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);
|
|
1580
|
+
if (!getCookie('hhg-id')) {
|
|
1581
|
+
setCookie('hhg-id', v1(), {
|
|
1582
|
+
domain: '.' + leadDomain,
|
|
1583
|
+
path: '/',
|
|
1584
|
+
});
|
|
1585
|
+
LeadLog('😍 Set HHG ID cookie');
|
|
1586
|
+
}
|
|
1587
|
+
// getCookie('hhg-id')
|
|
1588
|
+
// TODO: HP-534 Filter desktop
|
|
1589
|
+
let campaignsDevice = [];
|
|
1590
|
+
if (isMobile()) {
|
|
1591
|
+
campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.MOBILE));
|
|
1592
|
+
}
|
|
1593
|
+
else {
|
|
1594
|
+
campaignsDevice = campaigns.filter((c) => c.device_types.some((d) => d.id == LEAD_DEVICE_TYPE.DESKTOP));
|
|
1595
|
+
}
|
|
1596
|
+
LeadLog(`👓 campaignsDevice`, campaignsDevice);
|
|
1597
|
+
LeadLog('--listCampaignScheduled', listCampaignScheduled);
|
|
1598
|
+
LeadLog('--listCampaignScheduledToActivated', listCampaignScheduledToActivated);
|
|
1599
|
+
LeadLog('--listCampaignActiveButExpired', listCampaignActiveButExpired);
|
|
1600
|
+
LeadLog('--listCampaignExcludeSonsored', listCampaignExcludeSonsored);
|
|
1601
|
+
LeadLog('--listCampaignDifferentSponsor', listCampaignDifferentSponsor);
|
|
1602
|
+
LeadLog('--listCampaignNotDisplayInRangeOfTime', listCampaignNotDisplayInRangeOfTime);
|
|
1603
|
+
// Check links
|
|
1604
|
+
let listLinksObj = campaignsDevice
|
|
1605
|
+
.map((i, index) => i.targets
|
|
1606
|
+
.filter((i) => i.type == CAMPAIGN_TARGET_TYPE.LINKS)
|
|
1607
|
+
.map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
|
|
1608
|
+
.flat(1);
|
|
1609
|
+
// Check list link match current href
|
|
1610
|
+
listLinksObj = listLinksObj.filter((i) => {
|
|
1611
|
+
var _a;
|
|
1612
|
+
const target = new URL(String(i.target).toLowerCase());
|
|
1613
|
+
if (i.option == 'exact_match')
|
|
1614
|
+
// FOR TEST LOCAL:
|
|
1615
|
+
// return Boolean(location.pathname === target.pathname)
|
|
1616
|
+
return Boolean(leadCurrentUrl === ((_a = target.href) === null || _a === void 0 ? void 0 : _a.toLowerCase()));
|
|
1617
|
+
if (i.option == 'start_with') {
|
|
1618
|
+
// FOR TEST LOCAL:
|
|
1619
|
+
// if (location.pathname.includes(target.pathname)) {
|
|
1620
|
+
if (leadCurrentUrl.includes(String(i.target).toLowerCase())) {
|
|
1621
|
+
const listExcluding = i.sub_target
|
|
1622
|
+
.filter((i) => i.option == 'excluding')
|
|
1623
|
+
.map((i) => { var _a; return (_a = i.value) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
|
|
1624
|
+
return !listExcluding.includes(leadCurrentUrl.split('?')[0]);
|
|
1625
|
+
}
|
|
1626
|
+
else {
|
|
1627
|
+
return false;
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
// Check tags
|
|
1632
|
+
const listMetaTag = Array.from(document.getElementsByTagName('META')).filter((i) => i.getAttribute('property') == 'article:tag');
|
|
1633
|
+
const listTags = listMetaTag.map((i) => i.content);
|
|
1634
|
+
let listCampaignHasTag = [];
|
|
1635
|
+
let listTagsObj = [];
|
|
1636
|
+
if (listTags && listTags.length) {
|
|
1637
|
+
listCampaignHasTag = campaignsDevice
|
|
1638
|
+
.map((i, index) => i.targets
|
|
1639
|
+
.filter((i) => i.type == CAMPAIGN_TARGET_TYPE.TAGS)
|
|
1640
|
+
.map((i) => (Object.assign(Object.assign({}, i), { campaignIndex: index }))))
|
|
1641
|
+
.flat(1);
|
|
1642
|
+
listTagsObj = listCampaignHasTag.filter((i) => listTags.includes(i.target));
|
|
1643
|
+
}
|
|
1644
|
+
const listCampaginsMatch = [...listLinksObj, ...listTagsObj];
|
|
1645
|
+
const cookieKeys = document.cookie
|
|
1646
|
+
.split('; ')
|
|
1647
|
+
.map((i) => i.split('=')[0]);
|
|
1648
|
+
const listCampaignCodeSubmited = cookieKeys.filter((i) => i.includes('lead_submited'));
|
|
1649
|
+
LeadLog(`--listCampaignCodeSubmited`, listCampaignCodeSubmited);
|
|
1650
|
+
const listCampaignCodeClosed = cookieKeys.filter((i) => i.includes('lead_closed'));
|
|
1651
|
+
LeadLog(`--listCampaignCodeClosed`, listCampaignCodeClosed);
|
|
1652
|
+
const listCampaignSubmitedClosed = [
|
|
1653
|
+
...listCampaignCodeSubmited,
|
|
1654
|
+
...listCampaignCodeClosed,
|
|
1655
|
+
];
|
|
1656
|
+
const listCampaignNoSubmitedClosed = listCampaginsMatch.filter((i) => {
|
|
1657
|
+
const hasSubmited = listCampaignSubmitedClosed.some((k) => k.includes(campaignsDevice[i.campaignIndex].code));
|
|
1658
|
+
return !hasSubmited;
|
|
1659
|
+
});
|
|
1660
|
+
const listCampaignValid = getShuffleArray(listCampaignNoSubmitedClosed);
|
|
1661
|
+
// .sort(
|
|
1662
|
+
// (a, b) =>
|
|
1663
|
+
// (listCampaignValid[a.campaignIndex]?.score || 0) -
|
|
1664
|
+
// (listCampaignValid[b.campaignIndex]?.score || 0),
|
|
1665
|
+
// )
|
|
1666
|
+
LeadLog('--listCampaignValid : ', listCampaignValid);
|
|
1667
|
+
if (listCampaignValid && listCampaignValid.length) {
|
|
1668
|
+
const CAMPAIGN_SHOW = campaignsDevice[listCampaignValid[0].campaignIndex];
|
|
1669
|
+
LeadLog(`CAMPAIGN_SHOW`, CAMPAIGN_SHOW);
|
|
1670
|
+
const { rules } = CAMPAIGN_SHOW;
|
|
1671
|
+
// CHECK RULE TRIGGER POPUP
|
|
1672
|
+
const timeoutRule = Number((_c = rules.find((i) => i.rule == 'time')) === null || _c === void 0 ? void 0 : _c.value);
|
|
1673
|
+
LeadLog(`timeoutRule`, timeoutRule);
|
|
1674
|
+
const scrollRule = Number((_d = rules.find((i) => i.rule == 'scroll')) === null || _d === void 0 ? void 0 : _d.value);
|
|
1675
|
+
LeadLog(`scrollRule`, scrollRule);
|
|
1676
|
+
let impressionAction = 'TIME';
|
|
1677
|
+
if (Number.isInteger(timeoutRule)) {
|
|
1678
|
+
impressionAction = 'TIME';
|
|
1679
|
+
LeadLog('✨ SHOW AWESOME POPUP AFTER: ', timeoutRule, ' seconds');
|
|
1680
|
+
if (timeoutRef)
|
|
1681
|
+
clearTimeout(timeoutRef);
|
|
1682
|
+
timeoutRef = setTimeout(() => {
|
|
1683
|
+
onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
|
|
1684
|
+
}, timeoutRule * 1000);
|
|
1685
|
+
}
|
|
1686
|
+
if (Number.isInteger(scrollRule)) {
|
|
1687
|
+
impressionAction = 'SCROLL';
|
|
1688
|
+
LeadLog('✨ SHOW AWESOME AFTER: SCROLL', scrollRule, ' %');
|
|
1689
|
+
const $p = document.querySelector(`[data-url="${location.pathname}"]`) ||
|
|
1690
|
+
document.querySelector('body');
|
|
1691
|
+
const pct = $p.getBoundingClientRect().top;
|
|
1692
|
+
const pb = $p.offsetHeight;
|
|
1693
|
+
LeadLog(`👓 Element check scroll: `, $p);
|
|
1694
|
+
const LEAD_SCROLL_EVENT = function leadScollCheckHandler() {
|
|
1695
|
+
const wt = window.pageYOffset || document.documentElement.scrollTop;
|
|
1696
|
+
let percent = 0;
|
|
1697
|
+
if (wt >= pct) {
|
|
1698
|
+
percent = Math.round(((wt - pct) / (pb - innerHeight)) * 100);
|
|
1699
|
+
}
|
|
1700
|
+
LeadLog('---Scroll', percent, scrollRule);
|
|
1701
|
+
// TODO: CHECK FOOTER HEIGHT
|
|
1702
|
+
if (percent >= scrollRule) {
|
|
1703
|
+
window.removeEventListener('scroll', LEAD_SCROLL_EVENT);
|
|
1704
|
+
onShowPopup === null || onShowPopup === void 0 ? void 0 : onShowPopup(CAMPAIGN_SHOW, impressionAction);
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
window.addEventListener('scroll', LEAD_SCROLL_EVENT, {
|
|
1708
|
+
passive: true,
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
else {
|
|
1713
|
+
LeadLog('🚧 No lead campaigns on current URL, tags');
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
})
|
|
1717
|
+
.catch((err) => {
|
|
1718
|
+
LeadLog(`Lead error: `, err);
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
const LeadLog = (...params) => {
|
|
1722
|
+
if (process.env.NODE_ENV !== 'production' ||
|
|
1723
|
+
(process.env.NEXT_PUBLIC_DEPLOY_ENV &&
|
|
1724
|
+
process.env.NEXT_PUBLIC_DEPLOY_ENV !== 'production') ||
|
|
1725
|
+
(typeof localStorage !== 'undefined' &&
|
|
1726
|
+
localStorage.getItem('hhg_debug') === 'true')) {
|
|
1727
|
+
console.log(...params);
|
|
1728
|
+
}
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
function getCategoryLevel(t = 'Xin chao {{category_2}} extra') {
|
|
1732
|
+
if (t.includes('{{category_')) {
|
|
1733
|
+
const cl = '{{category_'.length;
|
|
1734
|
+
const sc = t.search('{{category_');
|
|
1735
|
+
const sf = t.charAt(cl + sc);
|
|
1736
|
+
return +sf;
|
|
1737
|
+
}
|
|
1738
|
+
else {
|
|
1739
|
+
return null;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
const NewLeadPopup = ({ campaign, action, onSubmit, onClose, showThankyou, locale, }) => {
|
|
1743
|
+
var _a, _b;
|
|
1744
|
+
const { apiUrl, siteDomain } = useContext(LeadGenContext);
|
|
1745
|
+
useEffect(() => {
|
|
1746
|
+
const gaCookie = getCookie('_ga') || null;
|
|
1747
|
+
fetch(`${apiUrl}api/campaign/${code}/impression`, {
|
|
1748
|
+
method: 'POST',
|
|
1749
|
+
headers: {
|
|
1750
|
+
'Content-Type': 'application/json',
|
|
1751
|
+
},
|
|
1752
|
+
body: JSON.stringify({
|
|
1753
|
+
action,
|
|
1754
|
+
url: location.href.toLowerCase(),
|
|
1755
|
+
title_article: document.title,
|
|
1756
|
+
cookie_id: getCookie('hhg-id'),
|
|
1757
|
+
ga_client_id: gaCookie,
|
|
1758
|
+
}),
|
|
1759
|
+
});
|
|
1760
|
+
}, []);
|
|
1761
|
+
const { extra_fields, image, image_desktop, code, image_background, image_overlay_mobile, image_overlay_desktop, } = campaign || {};
|
|
1762
|
+
const { currentLayout } = extra_fields;
|
|
1763
|
+
const imageBlocks = extra_fields.imageBlocks
|
|
1764
|
+
? JSON.parse(extra_fields.imageBlocks)
|
|
1765
|
+
: {};
|
|
1766
|
+
const actionBlocks = JSON.parse(extra_fields.actionBlocks);
|
|
1767
|
+
const textBlocks = JSON.parse(extra_fields.textBlocks);
|
|
1768
|
+
let titleText = ((_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) || '';
|
|
1769
|
+
const categoryData = {
|
|
1770
|
+
1: {},
|
|
1771
|
+
2: {},
|
|
1772
|
+
3: {},
|
|
1773
|
+
};
|
|
1774
|
+
const popupIdRef = useRef('lead-modal-' + v1());
|
|
1775
|
+
const categoryLevel = getCategoryLevel(titleText);
|
|
1776
|
+
if (categoryLevel) {
|
|
1777
|
+
LeadLog('⚡️ Has categoryLevel', categoryLevel);
|
|
1778
|
+
const listMeta = Array.from(document.getElementsByTagName('META'));
|
|
1779
|
+
const valueMeta = listMeta.find((i) => i.name === `content_category_${categoryLevel}`);
|
|
1780
|
+
const valueMetaEn = listMeta.find((i) => i.name === `content_category_en_${categoryLevel}`);
|
|
1781
|
+
if (valueMeta && valueMetaEn) {
|
|
1782
|
+
categoryData[categoryLevel] = {
|
|
1783
|
+
value: valueMeta.content,
|
|
1784
|
+
value_en: valueMetaEn.content,
|
|
1785
|
+
};
|
|
1786
|
+
titleText = titleText.replace(`{{category_${categoryLevel}}}`, valueMeta.content);
|
|
1787
|
+
LeadLog('⚡️ Set categoryData ', categoryLevel);
|
|
1788
|
+
}
|
|
1789
|
+
else {
|
|
1790
|
+
LeadLog('⚡️ No META TAG for categoryLevel, not show popup', categoryLevel);
|
|
1791
|
+
return null;
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
else {
|
|
1795
|
+
LeadLog('⚡️ No categoryLevel', categoryLevel);
|
|
1796
|
+
}
|
|
1797
|
+
const onOtherSubmit = () => {
|
|
1798
|
+
var _a, _b, _c, _d;
|
|
1799
|
+
LeadLog('👌 Other submit click');
|
|
1800
|
+
document.body.classList.remove('noscroll');
|
|
1801
|
+
if (currentLayout.includes('Skin')) {
|
|
1802
|
+
const $head = document.querySelector('#masthead');
|
|
1803
|
+
if ($head) {
|
|
1804
|
+
$head.style.top = 0 + 'px !important;';
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
const expiresDay = Number((_b = (_a = campaign.rules.find((r) => r.rule == 'days_to_show_again')) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 7);
|
|
1808
|
+
const showAgain = Number((_d = (_c = campaign.rules.find((r) => r.rule == 'show_again_after_submit')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0);
|
|
1809
|
+
if (showAgain === 0) {
|
|
1810
|
+
LeadLog('⛔ Popup never show again!');
|
|
1811
|
+
setCookie(`lead_submited_${code}`, `target_${extra_fields.popupVersion}`, { domain: '.' + siteDomain, path: '/' });
|
|
1812
|
+
}
|
|
1813
|
+
if (showAgain == 1) {
|
|
1814
|
+
LeadLog(`⌛ Popup will show again after ${expiresDay} days!`);
|
|
1815
|
+
setCookie(`lead_submited_${code}`, `target_${extra_fields.popupVersion}`, { domain: '.' + siteDomain, days: expiresDay, path: '/' });
|
|
1816
|
+
}
|
|
1817
|
+
const gaCookie = getCookie('_ga') || null;
|
|
1818
|
+
const data = {
|
|
1819
|
+
url: location.href.toLowerCase(),
|
|
1820
|
+
title_article: document.title,
|
|
1821
|
+
meta: [],
|
|
1822
|
+
cookie_id: getCookie('hhg-id'),
|
|
1823
|
+
ga_client_id: gaCookie,
|
|
1824
|
+
};
|
|
1825
|
+
if (categoryLevel) {
|
|
1826
|
+
data['category'] = categoryData[categoryLevel].value_en;
|
|
1827
|
+
}
|
|
1828
|
+
fetch(`${apiUrl}api/campaign/${code}/lead`, {
|
|
1829
|
+
method: 'POST',
|
|
1830
|
+
body: JSON.stringify(data),
|
|
1831
|
+
headers: {
|
|
1832
|
+
'Content-Type': 'application/json',
|
|
1833
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
1834
|
+
},
|
|
1835
|
+
})
|
|
1836
|
+
.then((response) => response.json())
|
|
1837
|
+
.then((data) => {
|
|
1838
|
+
if (data.status === 'error') {
|
|
1839
|
+
LeadLog(data);
|
|
1840
|
+
}
|
|
1841
|
+
})
|
|
1842
|
+
.catch((error) => {
|
|
1843
|
+
LeadLog('Error:', error);
|
|
1844
|
+
});
|
|
1845
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
1846
|
+
};
|
|
1847
|
+
if (currentLayout === 'CenterTab') {
|
|
1848
|
+
return (React__default.createElement(CenterTabLayout, { popupId: popupIdRef.current, url: imageBlocks.imageMobile.data.url, newTab: imageBlocks.imageMobile.data.newtab, imageMobile: image, imageDestkop: image_desktop, onClose: onClose, onOtherSubmit: onOtherSubmit }));
|
|
1849
|
+
}
|
|
1850
|
+
else if (currentLayout === 'Tab') {
|
|
1851
|
+
return (React__default.createElement(TabLayout, { popupId: popupIdRef.current, url: imageBlocks.imageMobile.data.url, newTab: imageBlocks.imageMobile.data.newtab, image: image, onClose: onClose, onOtherSubmit: onOtherSubmit }));
|
|
1852
|
+
}
|
|
1853
|
+
else if (currentLayout === 'Floating') {
|
|
1854
|
+
return (React__default.createElement(FloatingLayout, { popupId: popupIdRef.current, title: titleText, titleAlign: textBlocks.titleBlock.data.align, subtitle: textBlocks.subtitleBlock.data.value, subtitleAlign: textBlocks.subtitleBlock.data.align, url: actionBlocks.linkButtonBlock.data.url, urlText: actionBlocks.linkButtonBlock.data.value, newTab: actionBlocks.linkButtonBlock.data.newtab, imageMobile: image, imageDesktop: image_desktop, onClose: onClose, onOtherSubmit: onOtherSubmit }));
|
|
1855
|
+
}
|
|
1856
|
+
else if (currentLayout.includes('LightBox') ||
|
|
1857
|
+
currentLayout.includes('Inline') ||
|
|
1858
|
+
currentLayout == 'Fullscreen' ||
|
|
1859
|
+
currentLayout == 'Sidebar' ||
|
|
1860
|
+
currentLayout == 'Slider') {
|
|
1861
|
+
return (React__default.createElement(LightboxLayout, { popupId: popupIdRef.current, extraFields: extra_fields, onClose: onClose, onOtherSubmit: onOtherSubmit, imageMobile: image, imageDesktop: image_desktop, imageBackground: image_background, currentLayout: currentLayout, title: titleText, onSubmit: (form, values) => onSubmit(form, values, categoryLevel, categoryData), key: currentLayout, imageOverlayDesktop: image_overlay_desktop, imageOverlayMobile: image_overlay_mobile, showThankyou: showThankyou, campaignId: campaign.id, campaign_subot_id: campaign.bot_id || [], locale: locale }));
|
|
1862
|
+
}
|
|
1863
|
+
else if (currentLayout.includes('Skin')) {
|
|
1864
|
+
return (React__default.createElement(SkinLayout, { popupId: popupIdRef.current, link: actionBlocks.linkButtonBlock.data.url, linkNewTab: !!actionBlocks.linkButtonBlock.data.newtab, linkText: actionBlocks.linkButtonBlock.data.value, onClose: onClose, onOtherSubmit: onOtherSubmit, imageMobile: image, imageDesktop: image_desktop, currentLayout: currentLayout }));
|
|
1865
|
+
}
|
|
1866
|
+
return null;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
// mount css
|
|
1870
|
+
const LeadGen = ({ apiUrl: apiUrlProp, siteDomain, siteId, locale, apiSubotUrl, DEBUG_URL, forceCampaign, }) => {
|
|
1871
|
+
var _a;
|
|
1872
|
+
const scrollEventHandlerRef = useRef();
|
|
1873
|
+
const leadStartTimeRef = useRef(Date.now());
|
|
1874
|
+
const { apiUrl } = useMemo(() => {
|
|
1875
|
+
let apiUrl = apiUrlProp;
|
|
1876
|
+
if (apiUrl.includes('localhost')) {
|
|
1877
|
+
apiUrl = 'https://dev.leadgen.hellobacsi.com/';
|
|
1878
|
+
}
|
|
1879
|
+
return {
|
|
1880
|
+
apiUrl,
|
|
1881
|
+
};
|
|
1882
|
+
}, [apiUrlProp, siteDomain, siteId]);
|
|
1883
|
+
const [showCampaign, setShowCampaign] = useState(forceCampaign);
|
|
1884
|
+
const [action, setAction] = useState('');
|
|
1885
|
+
const [showThankyou, setShowThankyou] = useState(null);
|
|
1886
|
+
useEffect(() => {
|
|
1887
|
+
if (forceCampaign) {
|
|
1888
|
+
setShowCampaign(forceCampaign);
|
|
1889
|
+
setAction('SHOW');
|
|
1890
|
+
}
|
|
1891
|
+
}, [forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code]);
|
|
1892
|
+
useEffect(() => {
|
|
1893
|
+
leadStore.apiLeadUrl = apiUrl;
|
|
1894
|
+
leadStore.apiSubotUrl = apiSubotUrl;
|
|
1895
|
+
}, [apiUrl, apiSubotUrl]);
|
|
1896
|
+
const onShowPopup = (campaign, action) => {
|
|
1897
|
+
// TODO: run campaign
|
|
1898
|
+
setShowCampaign(campaign);
|
|
1899
|
+
setAction(action);
|
|
1900
|
+
};
|
|
1901
|
+
const onClose = () => {
|
|
1902
|
+
var _a, _b;
|
|
1903
|
+
if (!showCampaign)
|
|
1904
|
+
return;
|
|
1905
|
+
LeadLog(`👋👋👋 CLOSE POPUP ${showCampaign.code} 👋👋👋`);
|
|
1906
|
+
const showAfterExit = Number((_a = showCampaign.rules.find((rule) => rule.rule == 'show_again_after_exit')) === null || _a === void 0 ? void 0 : _a.value);
|
|
1907
|
+
const expiresDay = Number((_b = showCampaign.rules.find((rule) => rule.rule == 'days_to_show_again')) === null || _b === void 0 ? void 0 : _b.value);
|
|
1908
|
+
if (showAfterExit == 0) {
|
|
1909
|
+
if (!expiresDay) {
|
|
1910
|
+
setCookie(`lead_closed_${showCampaign.code}`, `target_${showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupVersion}`, { domain: '.' + siteDomain, path: '/' });
|
|
1911
|
+
}
|
|
1912
|
+
else {
|
|
1913
|
+
setCookie(`lead_closed_${showCampaign.code}`, `target_${showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupVersion}`, { domain: '.' + siteDomain, days: expiresDay, path: '/' });
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
document.body.classList.remove('noscroll');
|
|
1917
|
+
fetch(`${apiUrl}api/campaign/${showCampaign.code}/popup_exit`, {
|
|
1918
|
+
method: 'POST',
|
|
1919
|
+
headers: {
|
|
1920
|
+
'Content-Type': 'application/json',
|
|
1921
|
+
},
|
|
1922
|
+
body: JSON.stringify({
|
|
1923
|
+
action: 'CLICK',
|
|
1924
|
+
url: location.href.toLowerCase(),
|
|
1925
|
+
title_article: document.title,
|
|
1926
|
+
cookie_id: getCookie('hhg-id'),
|
|
1927
|
+
duration: Math.ceil((Date.now() - leadStartTimeRef.current) / 1000),
|
|
1928
|
+
}),
|
|
1929
|
+
});
|
|
1930
|
+
setShowCampaign(null);
|
|
1931
|
+
setShowThankyou(null);
|
|
1932
|
+
}; //
|
|
1933
|
+
useEffect(() => {
|
|
1934
|
+
if (forceCampaign === null || forceCampaign === void 0 ? void 0 : forceCampaign.code)
|
|
1935
|
+
return;
|
|
1936
|
+
// window.next only on nextjs page
|
|
1937
|
+
if (window.next) {
|
|
1938
|
+
const debounced = debounce((e) => {
|
|
1939
|
+
LeadLog('--🌻 routeChangeComplete', e, Date.now());
|
|
1940
|
+
const currentPath = location.pathname;
|
|
1941
|
+
// Remove floating, inline when url change
|
|
1942
|
+
onClose();
|
|
1943
|
+
if (document.querySelectorAll(`[data-popup-url="${currentPath}"]`).length) {
|
|
1944
|
+
LeadLog('🔥 This URL page has show popup!');
|
|
1945
|
+
}
|
|
1946
|
+
else {
|
|
1947
|
+
LeadLog('--Process checkShowPopup');
|
|
1948
|
+
checkShowPopup({
|
|
1949
|
+
leadApi: apiUrl,
|
|
1950
|
+
leadDomain: siteDomain,
|
|
1951
|
+
leadSiteId: siteId,
|
|
1952
|
+
onShowPopup,
|
|
1953
|
+
DEBUG_URL,
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
if (scrollEventHandlerRef.current) {
|
|
1957
|
+
window.removeEventListener('scroll', scrollEventHandlerRef.current);
|
|
1958
|
+
}
|
|
1959
|
+
}, 500);
|
|
1960
|
+
window.next.router.events.on('routeChangeComplete', debounced);
|
|
1961
|
+
}
|
|
1962
|
+
checkShowPopup({
|
|
1963
|
+
leadApi: apiUrl,
|
|
1964
|
+
leadDomain: siteDomain,
|
|
1965
|
+
leadSiteId: siteId,
|
|
1966
|
+
onShowPopup,
|
|
1967
|
+
DEBUG_URL,
|
|
1968
|
+
});
|
|
1969
|
+
}, []);
|
|
1970
|
+
const onSubmit = (currentForm, formDataObj, categoryLevel, categoryData) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1971
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1972
|
+
if (!formDataObj)
|
|
1973
|
+
return;
|
|
1974
|
+
LeadLog('submitHandler', categoryLevel, categoryData);
|
|
1975
|
+
const formData = Object.keys(formDataObj).map((key) => ({
|
|
1976
|
+
name: key,
|
|
1977
|
+
value: String(formDataObj[key]),
|
|
1978
|
+
}));
|
|
1979
|
+
const numberFormatType = 2; // i18n.phonenumbers.PhoneNumberFormat.NATIONAL
|
|
1980
|
+
// Get ga_client_id from cookies
|
|
1981
|
+
const gaCookie = getCookie('_ga') || null;
|
|
1982
|
+
if (!window.intlTelInputUtils) {
|
|
1983
|
+
yield require('intl-tel-input/build/js/utils');
|
|
1984
|
+
}
|
|
1985
|
+
const data = {
|
|
1986
|
+
url: location.href.toLowerCase(),
|
|
1987
|
+
title_article: document.title,
|
|
1988
|
+
meta: formData.map((i) => {
|
|
1989
|
+
var _a, _b;
|
|
1990
|
+
const control = ((_a = currentForm
|
|
1991
|
+
.querySelector(`*[name="${i.name}"][data-control]`)) === null || _a === void 0 ? void 0 : _a.getAttribute('data-control')) ||
|
|
1992
|
+
((_b = currentForm
|
|
1993
|
+
.querySelector(`*[data-extra][data-name="${i.name}"]`)) === null || _b === void 0 ? void 0 : _b.getAttribute('data-control')) ||
|
|
1994
|
+
'text';
|
|
1995
|
+
const value = control === 'tel'
|
|
1996
|
+
? window.intlTelInputUtils
|
|
1997
|
+
.formatNumber(String(i.value), LEAD_LOCALE === null || LEAD_LOCALE === void 0 ? void 0 : LEAD_LOCALE.countryCodeNumber, numberFormatType)
|
|
1998
|
+
.replace(/\s+/g, '')
|
|
1999
|
+
: control === 'date'
|
|
2000
|
+
? dayjs(i.value).format('YYYY-MM-DD')
|
|
2001
|
+
: i.value;
|
|
2002
|
+
return {
|
|
2003
|
+
key: i.name,
|
|
2004
|
+
value,
|
|
2005
|
+
control,
|
|
2006
|
+
// is_sent_mailchimp: currentForm.querySelector(
|
|
2007
|
+
// `div[data-name="${i.name}-mailchimp"]`,
|
|
2008
|
+
// )
|
|
2009
|
+
// ? 'true'
|
|
2010
|
+
// : 'false',
|
|
2011
|
+
};
|
|
2012
|
+
}),
|
|
2013
|
+
cookie_id: getCookie('hhg-id'),
|
|
2014
|
+
ga_client_id: gaCookie,
|
|
2015
|
+
};
|
|
2016
|
+
// categoryLevel
|
|
2017
|
+
if (categoryLevel) {
|
|
2018
|
+
if (categoryData[categoryLevel].value_en) {
|
|
2019
|
+
data['category'] = categoryData[categoryLevel].value_en;
|
|
2020
|
+
}
|
|
2021
|
+
}
|
|
2022
|
+
const expiresDay = Number(((_c = (_b = showCampaign.rules) === null || _b === void 0 ? void 0 : _b.find((r) => r.rule === 'days_to_show_again')) === null || _c === void 0 ? void 0 : _c.value) ||
|
|
2023
|
+
7);
|
|
2024
|
+
const showAgain = Number(((_e = (_d = showCampaign.rules) === null || _d === void 0 ? void 0 : _d.find((r) => r.rule === 'show_again_after_submit')) === null || _e === void 0 ? void 0 : _e.value) || 0);
|
|
2025
|
+
if (showAgain == 0) {
|
|
2026
|
+
LeadLog('⛔ Popup never show again!');
|
|
2027
|
+
setCookie(`lead_submited_${showCampaign.code}`, `target_${showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.targetType}`, { domain: '.' + siteDomain, path: '/' });
|
|
2028
|
+
}
|
|
2029
|
+
if (showAgain == 1) {
|
|
2030
|
+
LeadLog(`⌛ Popup will show again after ${expiresDay} days!`);
|
|
2031
|
+
setCookie(`lead_submited_${showCampaign.code}`, `target_${showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.targetType}`, { domain: '.' + siteDomain, days: expiresDay, path: '/' });
|
|
2032
|
+
}
|
|
2033
|
+
fetch(`${apiUrl}api/campaign/${showCampaign.code}/lead`, {
|
|
2034
|
+
method: 'POST',
|
|
2035
|
+
headers: {
|
|
2036
|
+
'Content-Type': 'application/json',
|
|
2037
|
+
},
|
|
2038
|
+
body: JSON.stringify(data),
|
|
2039
|
+
});
|
|
2040
|
+
if ((showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupShowThankYou) == 'notshow') {
|
|
2041
|
+
onClose();
|
|
2042
|
+
document.body.classList.remove('noscroll');
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
let isShowThanksYou = true;
|
|
2046
|
+
const thanksImg = showCampaign.thank_you_image || `${apiUrl}admin/img/thanksyou.png`;
|
|
2047
|
+
let thankTitle = (showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupThankyouTitle) || 'Thank you.';
|
|
2048
|
+
let thankDesc = (showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupThankyouDesc) || 'We appreciate your time!';
|
|
2049
|
+
let titleAlign = '';
|
|
2050
|
+
let descAlign = '';
|
|
2051
|
+
let linkText, linkNewTab, linkUrl = '';
|
|
2052
|
+
if ((showCampaign === null || showCampaign === void 0 ? void 0 : showCampaign.extra_fields.popupVersion) == '2.1') {
|
|
2053
|
+
const extra = showCampaign.extra_fields;
|
|
2054
|
+
const listBlockThankyou = JSON.parse(extra.listBlockThankyou);
|
|
2055
|
+
const titleBlock = listBlockThankyou.find((i) => i.name == 'TitleBlock');
|
|
2056
|
+
const subtitleBlock = listBlockThankyou.find((i) => i.name == 'SubtitleBlock');
|
|
2057
|
+
const linkButtonBlock = listBlockThankyou.find((i) => i.name == 'LinkButtonBlock');
|
|
2058
|
+
thankTitle = ((_f = titleBlock === null || titleBlock === void 0 ? void 0 : titleBlock.data) === null || _f === void 0 ? void 0 : _f.value) || '';
|
|
2059
|
+
titleAlign = ((_g = titleBlock === null || titleBlock === void 0 ? void 0 : titleBlock.data) === null || _g === void 0 ? void 0 : _g.align) || '';
|
|
2060
|
+
thankDesc = ((_h = subtitleBlock === null || subtitleBlock === void 0 ? void 0 : subtitleBlock.data) === null || _h === void 0 ? void 0 : _h.value) || '';
|
|
2061
|
+
descAlign = ((_j = subtitleBlock === null || subtitleBlock === void 0 ? void 0 : subtitleBlock.data) === null || _j === void 0 ? void 0 : _j.align) || '';
|
|
2062
|
+
linkText = ((_k = linkButtonBlock === null || linkButtonBlock === void 0 ? void 0 : linkButtonBlock.data) === null || _k === void 0 ? void 0 : _k.value) || '';
|
|
2063
|
+
linkNewTab = ((_l = linkButtonBlock === null || linkButtonBlock === void 0 ? void 0 : linkButtonBlock.data) === null || _l === void 0 ? void 0 : _l.newtab) || false;
|
|
2064
|
+
linkUrl = ((_m = linkButtonBlock === null || linkButtonBlock === void 0 ? void 0 : linkButtonBlock.data) === null || _m === void 0 ? void 0 : _m.url) || '';
|
|
2065
|
+
const curLayout = showCampaign.extra_fields.currentLayout;
|
|
2066
|
+
// TODO: newbuilder thank you
|
|
2067
|
+
// List layout not show thanks you
|
|
2068
|
+
if (['SkinA', 'SkinB', 'Floating', 'Tab', 'CenterTab'].includes(curLayout)) {
|
|
2069
|
+
isShowThanksYou = false;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
if (isShowThanksYou) {
|
|
2073
|
+
setShowThankyou({
|
|
2074
|
+
title: thankTitle,
|
|
2075
|
+
titleAlign,
|
|
2076
|
+
subtitle: thankDesc,
|
|
2077
|
+
subtitleAlign: descAlign,
|
|
2078
|
+
link: linkUrl,
|
|
2079
|
+
linkNewTab,
|
|
2080
|
+
linkText,
|
|
2081
|
+
image: thanksImg,
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
else {
|
|
2085
|
+
setShowThankyou(null);
|
|
2086
|
+
}
|
|
2087
|
+
// Other
|
|
2088
|
+
// Init Insider Obj
|
|
2089
|
+
if (sessionStorage.getItem('insider_object')) {
|
|
2090
|
+
window.insider_object = JSON.parse(sessionStorage.getItem('insider_object'));
|
|
2091
|
+
}
|
|
2092
|
+
else {
|
|
2093
|
+
window.insider_object = {
|
|
2094
|
+
user: {
|
|
2095
|
+
email: '',
|
|
2096
|
+
phone_number: '',
|
|
2097
|
+
gdpr_optin: true,
|
|
2098
|
+
sms_optin: true,
|
|
2099
|
+
email_optin: true,
|
|
2100
|
+
},
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
// Submit Inisder Obj
|
|
2104
|
+
formData.map((data) => {
|
|
2105
|
+
const name = data.name;
|
|
2106
|
+
const value = data.value;
|
|
2107
|
+
if (name == 'tel') {
|
|
2108
|
+
window.insider_object.user.phone_number = value;
|
|
2109
|
+
}
|
|
2110
|
+
else if (name == 'email') {
|
|
2111
|
+
window.insider_object.user.email = value;
|
|
2112
|
+
}
|
|
2113
|
+
});
|
|
2114
|
+
sessionStorage.setItem('insider_object', JSON.stringify(window.insider_object));
|
|
2115
|
+
// End Init Insider Obj
|
|
2116
|
+
// End Submit handler
|
|
2117
|
+
});
|
|
2118
|
+
useEffect(() => {
|
|
2119
|
+
if (showCampaign) {
|
|
2120
|
+
leadStartTimeRef.current = Date.now();
|
|
2121
|
+
}
|
|
2122
|
+
}, [showCampaign]);
|
|
2123
|
+
return (React__default.createElement(LeadGenContext.Provider, { value: { apiUrl, siteDomain, siteId, locale } },
|
|
2124
|
+
React__default.createElement(TranslationsContext.Provider, { value: {
|
|
2125
|
+
locale,
|
|
2126
|
+
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
|
+
};
|
|
2139
|
+
|
|
2140
|
+
export { LeadGen };
|