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BAAiBR,EAAAA,EAAAA,OAAOnF,MAE1B6D,EAAgBrC,QACZqD,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAOpD,EAAYM,KACtD4D,EAAAA,EAAAA,oBAAoB,IAAI,KAE9B3D,GACC,KACHnB,EAAAA,EAAAA,oBAAoB,MAAOoB,EAAa,CACrCuB,EAAWjC,QACPqD,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,IAAK3C,KACxCyD,EAAAA,EAAAA,oBAAoB,IAAI,GAC3BhC,EAAMpC,QACFqD,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAOzC,GAAawD,EAAAA,EAAAA,iBAAiBjC,EAAMpC,OAAQ,KACtFoE,EAAAA,EAAAA,oBAAoB,IAAI,GAC3BjC,EAAUnC,QACNqD,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAOvC,EAAa,wCACvDqD,EAAAA,EAAAA,oBAAoB,IAAI,WAKpCpD,GACC,IAEL,IC5NA,MAAMsD,EAAc,EAEpB,O","sources":["webpack://beliefnet-frontend/./src/composables/newsletter.composable.ts","webpack://beliefnet-frontend/./src/components/newsletters/NewsletterSignupBetterYou.vue?ed06","webpack://beliefnet-frontend/./src/components/newsletters/NewsletterSignupBetterYou.vue"],"sourcesContent":["import { NewsletterSubscription } from '../common/models/newsletters/newsletter-subscription.model';\nimport { NewslettersService } from '../services/newsletters.service';\nimport { GTMService } from '../services/gtm.service';\nimport { useIdentityStore } from '../stores/identity-store';\nimport useQueryParameter from './query-parameter.composable';\nimport { useSessionStore } from '../stores/SessionStorage';\n\n\nexport default function useNewsletterSubmit(newslettersService: NewslettersService | undefined, gtmService: GTMService | undefined): any {\n    const errorMessage = 'We apologize, we were unable to complete your subscription at this time, please try again later.';\n\n    const newsletterSubmit = async (listId: number, email: string, sourceDesc: string, partner: boolean, path: string) => {\n        const sessionStore = useSessionStore();\n        // get rsid from query parameter\n        const rsid = sessionStore.rsid;\n\n        // after we capture the email, update the identity store\n        if (email) {\n            const identity = useIdentityStore();\n            identity.registerEmail(email).then(() => 'Identity Email Registration Complete');\n        }\n        \n        if (newslettersService == undefined) {\n            return { message: 'Failed to integrate with newsletter service', success: false };\n        }\n        // if nl id is set to -1, signup to postup is disabled\n        if (isNaN(listId) || listId <= 0) {\n            // still return true to falsely show that we signed up\n            return { message: null, success: true };\n        }\n\n        const subscription: NewsletterSubscription = {\n            email: email ?? '',\n            name: '',\n            newsletter: [listId],\n            sourceDesc: sourceDesc,\n            partners: partner,\n            rsid: rsid\n        };\n\n        // first determine if we have a path url and if so let's go there\n        if (path) {\n            if (email && !rsid) {\n                window.open(`${path}/step/2?email=${email}`, '_blank');\n            } else if (email && rsid) {\n                window.open(`${path}/step/2?email=${email}&rsid=${rsid}`, '_blank');\n            } else {\n                window.open(`${path}/step/2`, '_blank');\n            }\n        }\n\n        try {\n            const result = await newslettersService?.subscribe(subscription);\n\n            if (result?.processed) {\n                // GTM Form Tracking\n                gtmService?.registerEvent('formNewsletterSuccess', {\n                    formId: 'newsletter-signup-form-head'\n                });\n\n                return { message: null, success: true };\n            }\n        } catch (err) {\n            return { message: errorMessage, success: false };\n        }\n\n        return { message: errorMessage, success: false };\n    };\n\n    return { newsletterSubmit };\n}\n","import { defineComponent as _defineComponent } from 'vue'\nimport { createElementVNode as _createElementVNode, unref as _unref, isRef as _isRef, vModelText as _vModelText, withDirectives as _withDirectives, vModelCheckbox as _vModelCheckbox, normalizeClass as _normalizeClass, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, Fragment as _Fragment } from \"vue\"\n\nconst _hoisted_1 = { class: \"wide-layout-column score-center\" }\nconst _hoisted_2 = { class: \"better-me-signup-custom\" }\nconst _hoisted_3 = { class: \"inner\" }\nconst _hoisted_4 = /*#__PURE__*/_createElementVNode(\"img\", {\n  src: \"https://www.beliefnet.com/~/media/images/components/newsletter-su/better-me-title.png\",\n  alt: \"Become a Better You\",\n  width: \"496\",\n  height: \"126\",\n  class: \"title\"\n}, null, -1)\nconst _hoisted_5 = /*#__PURE__*/_createElementVNode(\"img\", {\n  src: \"https://www.beliefnet.com/~/media/images/components/newsletter-su/better-me-title-m-w-header.png\",\n  alt: \"Become a Better You\",\n  width: \"100%\",\n  height: \"auto\",\n  class: \"title-mobile\"\n}, null, -1)\nconst _hoisted_6 = [\"innerHTML\"]\nconst _hoisted_7 = /*#__PURE__*/_createElementVNode(\"input\", {\n  type: \"submit\",\n  id: \"ABetterMeSignup\",\n  value: \"submit\"\n}, null, -1)\nconst _hoisted_8 = { class: \"col-sm-offset-1 col-sm-11\" }\nconst _hoisted_9 = {\n  key: 0,\n  class: \"checkbox text-left\"\n}\nconst _hoisted_10 = /*#__PURE__*/_createElementVNode(\"div\", { class: \"fine-print remove-padding\" }, [\n  /*#__PURE__*/_createTextVNode(\" Please also opt me in for Exclusive Offers from Beliefnet’s Partners \"),\n  /*#__PURE__*/_createElementVNode(\"a\", {\n    href: \"/about-us/privacy-policy.aspx\",\n    target: \"_blank\"\n  }, \"Privacy and Data Policy\")\n], -1)\nconst _hoisted_11 = [\n  _hoisted_10\n]\nconst _hoisted_12 = /*#__PURE__*/_createElementVNode(\"div\", { class: \"tnc\" }, \"From time to time you will also receive Special Offers from our partners\", -1)\nconst _hoisted_13 = { class: \"newsletter-signup-msgs add-padding\" }\nconst _hoisted_14 = {\n  key: 0,\n  class: \"fa fa-spinner fa-spin\",\n  style: {\"font-size\":\"36px\"}\n}\nconst _hoisted_15 = {\n  key: 1,\n  class: \"alert alert-danger\",\n  role: \"alert\"\n}\nconst _hoisted_16 = {\n  key: 2,\n  class: \"alert alert-success\",\n  role: \"alert\"\n}\nconst _hoisted_17 = /*#__PURE__*/_createElementVNode(\"br\", null, null, -1)\n\nimport { ref, inject, onMounted } from 'vue';\nimport { useField, useForm } from 'vee-validate';\nimport { useLogger } from 'vue-logger-plugin';\nimport { NewslettersService } from '../../services/newsletters.service';\nimport { GTMService } from '../../services/gtm.service';\nimport useNewsletterSubmit from '../../composables/newsletter.composable';\nimport { LocationService } from '../../services/location.service';\nimport useValidators from '../../composables/validators.composable';\n\n// Define Component Input Properties\n\nexport default /*#__PURE__*/_defineComponent({\n  __name: 'NewsletterSignupBetterYou',\n  props: {\n    header: {\n        type: String,\n        default: ''\n    },\n    blurb: {\n        type: String,\n        default: ''\n    },\n    listId: {\n        type: Number,\n        default: -1\n    },\n    sourceDesc: {\n        type: String,\n        default: ''\n    },\n    customClass: {\n        type: String,\n        default: ''\n    },\n    pathUrl: {\n        type: String,\n        default: ''\n    }\n},\n  setup(__props) {\n\nconst props = __props;\n\n\n\nconst logger = useLogger();\n// inject our newsletter service\nconst newslettersService: NewslettersService | undefined = inject('NewslettersService');\n// inject our locationservice\nconst locationService: LocationService | undefined = inject('LocationService');\n\nconst gtmService: GTMService | undefined = inject('GTMService');\nconst { newsletterSubmit } = useNewsletterSubmit(newslettersService, gtmService);\n\n// Component Locally Tracked Values\nconst submitting = ref(false);\nconst submitted = ref(false);\nconst error = ref('');\nconst isCookieLawZone = ref(false);\n\n// get validators\nconst { isRequired, isEmail } = useValidators();\n// generate validation schema\nconst validationSchema = {\n    email: (value: string) => isRequired(value, 'Email is required') && isEmail(value),\n    partners: () => true\n};\n\n// Form Configuration\nconst { handleSubmit, errors } = useForm({\n    validationSchema,\n    initialValues: {\n        email: '',\n        partners: !isCookieLawZone.value\n    }\n});\n\n// Field Configurations\nconst { value: email } = useField('email');\nconst { value: partners } = useField('partners');\n\n// Handle Form Submit\nconst submit = handleSubmit(async (values) => {\n    // start spinner\n    submitting.value = true;\n\n    // reset error message\n    error.value = '';\n\n    // submit to newsletter service\n    const { message, success } = await newsletterSubmit(props.listId, values.email, props.sourceDesc, partners.value, props.pathUrl);\n\n    if (success) {\n        submitted.value = true;\n    } else {\n        submitted.value = false;\n        error.value = message;\n    }\n\n    // stop spinner\n    submitting.value = false;\n});\n\nonMounted(async () => {\n    isCookieLawZone.value = (await locationService?.isCookieLawZone()) || false;\n    logger.debug('Setting cookie zone law', isCookieLawZone.value);\n});\n\nreturn (_ctx: any,_cache: any) => {\n  return (_openBlock(), _createElementBlock(_Fragment, null, [\n    _createElementVNode(\"div\", _hoisted_1, [\n      _createElementVNode(\"div\", _hoisted_2, [\n        _createElementVNode(\"div\", _hoisted_3, [\n          _hoisted_4,\n          _hoisted_5,\n          _createElementVNode(\"span\", { innerHTML: __props.blurb }, null, 8, _hoisted_6),\n          _createElementVNode(\"form\", {\n            class: \"newsletter-signup\",\n            onSubmit: _cache[2] || (_cache[2] = \n//@ts-ignore\n(...args) => (_unref(submit) && _unref(submit)(...args)))\n          }, [\n            _withDirectives(_createElementVNode(\"input\", {\n              type: \"email\",\n              name: \"email\",\n              placeholder: \"Enter your email address\",\n              \"onUpdate:modelValue\": _cache[0] || (_cache[0] = ($event: any) => (_isRef(email) ? (email).value = $event : null))\n            }, null, 512), [\n              [_vModelText, _unref(email)]\n            ]),\n            _hoisted_7,\n            _createElementVNode(\"div\", _hoisted_8, [\n              _withDirectives(_createElementVNode(\"input\", {\n                type: \"checkbox\",\n                name: \"partners\",\n                class: _normalizeClass({ hide: !isCookieLawZone.value }),\n                \"onUpdate:modelValue\": _cache[1] || (_cache[1] = ($event: any) => (_isRef(partners) ? (partners).value = $event : null))\n              }, null, 2), [\n                [_vModelCheckbox, _unref(partners)]\n              ]),\n              (isCookieLawZone.value)\n                ? (_openBlock(), _createElementBlock(\"div\", _hoisted_9, _hoisted_11))\n                : _createCommentVNode(\"\", true)\n            ]),\n            _hoisted_12\n          ], 32),\n          _createElementVNode(\"div\", _hoisted_13, [\n            (submitting.value)\n              ? (_openBlock(), _createElementBlock(\"i\", _hoisted_14))\n              : _createCommentVNode(\"\", true),\n            (error.value)\n              ? (_openBlock(), _createElementBlock(\"div\", _hoisted_15, _toDisplayString(error.value), 1))\n              : _createCommentVNode(\"\", true),\n            (submitted.value)\n              ? (_openBlock(), _createElementBlock(\"div\", _hoisted_16, \" Thank you for your subscription. \"))\n              : _createCommentVNode(\"\", true)\n          ])\n        ])\n      ])\n    ]),\n    _hoisted_17\n  ], 64))\n}\n}\n\n})","import script from \"./NewsletterSignupBetterYou.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./NewsletterSignupBetterYou.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["useNewsletterSubmit","newslettersService","gtmService","errorMessage","newsletterSubmit","listId","email","sourceDesc","partner","path","__awaiter","sessionStore","useSessionStore","rsid","identity","useIdentityStore","registerEmail","then","undefined","message","success","isNaN","subscription","name","newsletter","partners","window","open","result","subscribe","processed","registerEvent","formId","err","_hoisted_1","class","_hoisted_2","_hoisted_3","_hoisted_4","_createElementVNode","src","alt","width","height","_hoisted_5","_hoisted_6","_hoisted_7","type","id","value","_hoisted_8","_hoisted_9","key","_hoisted_10","_createTextVNode","href","target","_hoisted_11","_hoisted_12","_hoisted_13","_hoisted_14","style","_hoisted_15","role","_hoisted_16","_hoisted_17","_defineComponent","__name","props","header","String","default","blurb","Number","customClass","pathUrl","setup","__props","logger","useLogger","inject","locationService","submitting","ref","submitted","error","isCookieLawZone","isRequired","isEmail","useValidators","validationSchema","handleSubmit","errors","useForm","initialValues","useField","submit","values","onMounted","debug","_ctx","_cache","_openBlock","_createElementBlock","_Fragment","innerHTML","onSubmit","args","_unref","_withDirectives","placeholder","$event","_isRef","_vModelText","_normalizeClass","hide","_vModelCheckbox","_createCommentVNode","_toDisplayString","__exports__"],"sourceRoot":""}