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AOqD,aAErCE,YAAa,WACXtD,KAAKE,KAAK0E,OACV5E,KAAKI,QAAQyE,YAAY,YAKA,oBAAdC,WAGTA,UAAUC,KAAK,CAAE,MAAS","sources":["webpack:///./resources/js/components/generic/exact-target-formV2.ts"],"sourcesContent":["import * as $ from \"jquery\";\nimport { ConsentHelper } from '../../common/ConsentHubV2';\nimport Environment from \"../../common/environment\";\nimport imkt from '../../imkt';\nimport 'jquery-validation';\n\ntype RulesType = {\n [key: string]: {\n required: boolean;\n email: boolean;\n }\n};\n\ntype MessagesType = {\n [key: string]: {\n required: string;\n email: string;\n }\n};\n\nexport default function ExactTargetFormV2(domRoot: HTMLElement, params: { name: string, useSocs: boolean; }) {\n this.domRoot = $(domRoot);\n this.params = { ...params };\n\n //Component elements\n this.form = $('.exact-target-form', this.domRoot);\n this.emailInput = $('.exact-target-form__email-input input', this.domRoot);\n this.message = $('.exact-target-form__message', this.domRoot);\n this.honeypot = $('.exact-target-form__hp-field input', this.domRoot);\n this.useSocs = params.useSocs;\n this.consentHubPromise = null;\n this.consentYes = this.params.consentYes;\n this.useConsentHub = this.consentYes.match('generalMarketingOptIn|allowPartnerShare') || this.params.isEAP || (this.params.useGdpr && this.params.subscriptionKey.trim() !== '');\n this.useSubmissionBlock = this.params.useSubmissionBlock === 'true';\n this.postSubmissionBlock = this.useSubmissionBlock && document.querySelectorAll(`#${this.params.postSubmissionBlockId}, .${this.params.postSubmissionBlockId}`);\n\n if (this.useConsentHub) {\n this.init();\n } else {\n this.bindFormValidation();\n }\n};\n\nExactTargetFormV2.prototype = {\n init: function () {\n this.consentHubPromise = (new ConsentHelper(this.params, this.form)).configPromise;\n this.bindFormValidation();\n },\n bindFormValidation: function () {\n\n // Bind validation rules to our form using jQuery Validate functions\n const rules: RulesType = {};\n const messages: MessagesType = {};\n rules[this.params.name] = {\n required: true,\n email: true\n };\n messages[this.params.name] = {\n required: this.params.requiredError,\n email: this.params.invalidEmailError\n };\n this.form.validate({\n rules: rules,\n messages: messages,\n submitHandler: () => {\n if (this.honeypot.val() === \"\") {\n if (this.useConsentHub) {\n this.consentHubPromise.then((consentHub: ConsentHelper) => {\n consentHub.submitForm(this.submitSuccess.bind(this), this.submitError.bind(this));\n }).catch((error: unknown) => {\n console.error(error);\n this.submitError();\n });\n } else {\n this.submitDirectlyToExactTarget();\n }\n }\n }\n });\n },\n submitSuccess: function () {\n this.setSocsCookie();\n if (this.useSubmissionBlock) {\n // hide Form\n this.form.css('display', 'none');\n // show post submission content block\n if (this.postSubmissionBlock) {\n const postSubmissionBlocks = Array.from(document.querySelectorAll(`#${this.params.postSubmissionBlockId}, .${this.params.postSubmissionBlockId}`));\n postSubmissionBlocks.forEach(psb => {\n (psb as HTMLElement).style.display = 'block';\n })\n }\n } else {\n this.params.redirectUrl ? this.redirect() : this.showMessage();\n }\n },\n submitError: function () {\n if ($('.error--server', this.domRoot).length === 0) {\n this.form.after('
' + this.params.submitError + '
');\n }\n },\n setSocsCookie: function () {\n if (this.useSocs) {\n imkt.utils?.storage.setCookie(\"atl_soc2_nda_signed\", 1, false, \"Strict\", \"atlassian.com\");\n }\n },\n submitDirectlyToExactTarget: function () {\n const self = this;\n const emailAddress = this.emailInput.val();\n const endpointDomain = Environment.isProduction() ? 'www' : 'wac.stg.internal';\n const postUrl = `https://${endpointDomain}.atlassian.com/apis/exact-target/${emailAddress}/subscribe?mailingListId=${this.params.exactTargetId}`;\n $.ajax({\n url: postUrl,\n method: \"POST\",\n dataType: \"text\",\n complete: function (jqXHR, textStatus) {\n if (textStatus === 'success') {\n self.setSocsCookie();\n self.params.redirectUrl ? self.redirect() : self.showMessage();\n } else {\n // did not submit successfully, if there is not an error then show one\n if ($('.error--server', self.domRoot).length === 0) {\n self.form.append('
' + self.params.submitError + '
');\n }\n }\n }\n });\n },\n redirect: function () {\n window.location.href = this.params.redirectUrl;\n },\n showMessage: function () {\n this.form.hide();\n this.message.removeClass('hide-all');\n\n // TODO: Is this behavior in use, can this be removed or scoped to a type?\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (typeof dataLayer !== \"undefined\") {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n dataLayer.push({ 'event': 'emailSubmissionSuccess' });\n }\n }\n};\n"],"names":["ExactTargetFormV2","domRoot","params","this","$","form","emailInput","message","honeypot","useSocs","consentHubPromise","consentYes","useConsentHub","match","isEAP","useGdpr","subscriptionKey","trim","useSubmissionBlock","postSubmissionBlock","document","querySelectorAll","postSubmissionBlockId","init","bindFormValidation","prototype","ConsentHelper","configPromise","rules","messages","name","required","email","requiredError","invalidEmailError","validate","submitHandler","val","then","consentHub","submitForm","submitSuccess","bind","submitError","error","console","submitDirectlyToExactTarget","setSocsCookie","css","Array","from","forEach","psb","style","display","redirectUrl","redirect","showMessage","length","after","imkt","storage","setCookie","self","emailAddress","endpointDomain","Environment","postUrl","exactTargetId","url","method","dataType","complete","jqXHR","textStatus","append","window","location","href","hide","removeClass","dataLayer","push"],"sourceRoot":""}